import { Emitter, MaybeAsync } from "@welshman/lib"; import { HashedEvent, StampedEvent, TrustedEvent } from "@welshman/util"; import { AdapterContext } from "@welshman/net"; import { ISigner, EncryptionImplementation, SignerOptions } from "../util.js"; import { Nip01Signer } from "./nip01.js"; export type Nip46Context = { debug: boolean; }; export declare const nip46Context: { debug: boolean; }; export type Nip46Algorithm = "nip04" | "nip44"; export declare enum Nip46Event { Send = "send", Receive = "receive" } export type Nip46BrokerParams = { relays: string[]; clientSecret: string; connectSecret?: string; signerPubkey?: string; algorithm?: Nip46Algorithm; context?: AdapterContext; }; export type Nip46Response = { id: string; url: string; event: TrustedEvent; error?: string; result?: string; }; export type Nip46ResponseWithResult = { id: string; url: string; event: TrustedEvent; result: string; }; export type Nip46ResponseWithError = { id: string; url: string; event: TrustedEvent; error: string; }; export type PromenadeOptions = { secret: string; policy: [number, number]; coordinatorUrl: string; signerPubkeys: string[]; onProgress?: (progress: number) => void; generatePow: (event: HashedEvent, difficulty: number) => MaybeAsync; getPubkeyRelays: (pubkey: string, mode: string) => MaybeAsync; }; export declare class PromenadeShardError extends Error { readonly errorsBySignerPubkey: Map; constructor(message: string, errorsBySignerPubkey: Map); } export declare class Nip46Receiver extends Emitter { signer: ISigner; params: Nip46BrokerParams; abortController?: AbortController; private stopped; private retryDelay; constructor(signer: ISigner, params: Nip46BrokerParams); start: () => Promise; stop: () => void; } export declare class Nip46Sender extends Emitter { signer: ISigner; params: Nip46BrokerParams; processing: boolean; queue: Nip46Request[]; constructor(signer: ISigner, params: Nip46BrokerParams); send: (request: Nip46Request) => Promise; process: () => Promise; enqueue: (request: Nip46Request) => void; stop: () => void; } export declare class Nip46Request { readonly method: string; readonly params: string[]; id: string; promise: import("@welshman/lib").Deferred; constructor(method: string, params: string[]); listen: (receiver: Nip46Receiver) => Promise; send: (sender: Nip46Sender) => Promise; } export declare class Nip46Broker extends Emitter { params: Nip46BrokerParams; signer: ISigner; sender: Nip46Sender; receiver: Nip46Receiver; constructor(params: Nip46BrokerParams); static parseBunkerUrl: (url: string) => { relays: string[]; signerPubkey: string; connectSecret: string; }; static fromBunkerUrl: (url: string) => Nip46Broker; makeSigner: () => Nip01Signer; makeSender: () => Nip46Sender; makeReceiver: () => Nip46Receiver; cleanup: () => void; enqueue: (method: string, params: string[]) => Promise; send: (method: string, params: string[]) => Promise; makeNostrconnectUrl: (meta?: Record) => Promise; waitForNostrconnect: (url: string, signal: AbortSignal) => Promise; getBunkerUrl: () => string; ping: () => Promise; getPublicKey: () => Promise; createAccount: (username: string, domain: string, perms?: string) => Promise; connect: (connectSecret?: string, perms?: string) => Promise; signEvent: (event: StampedEvent) => Promise; nip04Encrypt: (pk: string, message: string) => Promise; nip04Decrypt: (pk: string, message: string) => Promise; nip44Encrypt: (pk: string, message: string) => Promise; nip44Decrypt: (pk: string, message: string) => Promise; switchRelays: () => Promise; } /** * A bunker answers over relays rather than one at a time, so requests here are not queued * and a priority would order nothing. Each one still carries its own deadline. */ export declare class Nip46Signer implements ISigner { broker: Nip46Broker; pubkey?: string; nip04: EncryptionImplementation; nip44: EncryptionImplementation; constructor(broker: Nip46Broker); getPubkey: (options?: SignerOptions) => Promise; sign: (template: StampedEvent, options?: SignerOptions) => Promise; cleanup: () => Promise; } //# sourceMappingURL=nip46.d.ts.map