import { Deferred } from "applesauce-core/promise";
import { ISigner, NostrConnectionMethodsOptions, NostrPool, NostrPublishMethod, NostrSubscriptionMethod, SimpleSigner } from "applesauce-signers";
import { EventTemplate, NostrEvent, verifyEvent } from "nostr-tools";
import { Subscription } from "rxjs";
import { BunkerURI, NostrConnectAppMetadata } from "../helpers/nostr-connect.js";
export type NostrConnectSignerOptions = NostrConnectionMethodsOptions & {
    /** The relays to communicate over */
    relays: string[];
    /** A {@link SimpleSigner} for this client */
    signer?: SimpleSigner;
    /** pubkey of the remote signer application */
    remote?: string;
    /** Users pubkey */
    pubkey?: string;
    /** A secret used when initalizing the connection from the client side */
    secret?: string;
    /** A method for handling "auth" requests */
    onAuth?: (url: string) => Promise<void>;
};
export declare class NostrConnectSigner implements ISigner {
    /** A fallback method to use for subscriptionMethod if none is pass in when creating the signer */
    static subscriptionMethod: NostrSubscriptionMethod | undefined;
    /** A fallback method to use for publishMethod if none is pass in when creating the signer */
    static publishMethod: NostrPublishMethod | undefined;
    /** A fallback pool to use if none is pass in when creating the signer */
    static pool: NostrPool | undefined;
    /** A method that is called when an event needs to be published */
    protected publishMethod: NostrPublishMethod;
    /** The active nostr subscription */
    protected subscriptionMethod: NostrSubscriptionMethod;
    protected log: import("debug").Debugger;
    /** The local client signer */
    signer: SimpleSigner;
    /** Whether the signer is listening for events */
    listening: boolean;
    /** Whether the signer is connected to the remote signer */
    isConnected: boolean;
    /** The users pubkey */
    protected pubkey?: string;
    /** Relays to communicate over */
    relays: string[];
    /** The remote signer pubkey */
    remote?: string;
    /** Client pubkey */
    get clientPubkey(): string;
    /** A method for handling "auth" requests */
    onAuth: (url: string) => Promise<void>;
    verifyEvent: typeof verifyEvent;
    /** A secret used when initiating a connection from the client side */
    secret: string;
    nip04?: {
        encrypt: (pubkey: string, plaintext: string) => Promise<string>;
        decrypt: (pubkey: string, ciphertext: string) => Promise<string>;
    } | undefined;
    nip44?: {
        encrypt: (pubkey: string, plaintext: string) => Promise<string>;
        decrypt: (pubkey: string, ciphertext: string) => Promise<string>;
    } | undefined;
    constructor(options: NostrConnectSignerOptions);
    /** The currently active REQ subscription */
    protected req?: Subscription;
    /** Open the connection */
    open(): Promise<void>;
    /** Close the connection */
    close(): Promise<void>;
    protected requests: Map<string, Deferred<any>>;
    protected auths: Set<string>;
    /** Call this method with incoming events */
    handleEvent(event: NostrEvent): Promise<void>;
    protected createRequestEvent(content: string, target?: string | undefined, kind?: number): Promise<import("nostr-tools").VerifiedEvent>;
    private makeRequest;
    /** Connect to remote signer */
    connect(secret?: string | undefined, permissions?: string[]): Promise<string>;
    private waitingPromise;
    /** Wait for a remote signer to connect */
    waitForSigner(abort?: AbortSignal): Promise<void>;
    /** Request to create an account on the remote signer */
    createAccount(username: string, domain: string, email?: string, permissions?: string[]): Promise<string>;
    /** Ensure the signer is connected to the remote signer */
    requireConnection(): Promise<void>;
    /** Get the users pubkey */
    getPublicKey(): Promise<string>;
    /** Request to sign an event */
    signEvent(template: EventTemplate & {
        pubkey?: string;
    }): Promise<import("nostr-tools").VerifiedEvent>;
    nip04Encrypt(pubkey: string, plaintext: string): Promise<string>;
    nip04Decrypt(pubkey: string, ciphertext: string): Promise<string>;
    nip44Encrypt(pubkey: string, plaintext: string): Promise<string>;
    nip44Decrypt(pubkey: string, ciphertext: string): Promise<string>;
    /** Returns the nostrconnect:// URI for this signer */
    getNostrConnectURI(metadata?: NostrConnectAppMetadata): string;
    /** Parses a bunker:// URI */
    static parseBunkerURI(uri: string): BunkerURI;
    /** Builds an array of signing permissions for event kinds */
    static buildSigningPermissions(kinds: number[]): string[];
    /** Create a {@link NostrConnectSigner} from a bunker:// URI */
    static fromBunkerURI(uri: string, options?: Omit<NostrConnectSignerOptions, "relays"> & {
        permissions?: string[];
        signer?: SimpleSigner;
    }): Promise<NostrConnectSigner>;
}
