import { Emitter } from "@welshman/lib"; import { SignedEvent, StampedEvent } from "@welshman/util"; export declare const nip04: { detect: (m: string) => boolean; encrypt: (pubkey: string, secret: string, m: string) => string; decrypt: (pubkey: string, secret: string, m: string) => string; }; export declare const nip44: { getSharedSecret: { (...args: string[]): Uint8Array; cache: import("@welshman/lib").LRUCache>; getKey: (args: string[]) => string; getValue: (args: string[]) => Uint8Array; pop: (...args: string[]) => Uint8Array; }; encrypt: (pubkey: string, secret: string, m: string) => string; decrypt: (pubkey: string, secret: string, m: string) => string; }; export type SignerOptions = { signal?: AbortSignal; /** Requests to one signer are answered highest first, 0 by default, so bulk work behind the * user can ask for a negative one and leave the user's own requests ahead of it. */ priority?: number; }; export type Sign = (event: StampedEvent, options?: SignerOptions) => Promise; export type Encrypt = (pubkey: string, message: string, options?: SignerOptions) => Promise; export type Decrypt = (pubkey: string, message: string, options?: SignerOptions) => Promise; export type EncryptionImplementation = { encrypt: Encrypt; decrypt: Decrypt; }; export interface ISigner { sign: Sign; nip04: EncryptionImplementation; nip44: EncryptionImplementation; getPubkey: (options?: SignerOptions) => Promise; cleanup?: () => Promise; } export declare const decrypt: (signer: ISigner, pubkey: string, message: string, options?: SignerOptions) => Promise; export type SignerMethodWrapper = (method: string, thunk: () => Promise, args: unknown[]) => Promise; export declare class WrappedSigner extends Emitter implements ISigner { readonly signer: ISigner; readonly wrapMethod: SignerMethodWrapper; constructor(signer: ISigner, wrapMethod: SignerMethodWrapper); sign: (event: StampedEvent, options?: SignerOptions) => Promise; getPubkey: (options?: SignerOptions) => Promise; nip04: { encrypt: (pubkey: string, message: string, options?: SignerOptions) => Promise; decrypt: (pubkey: string, message: string, options?: SignerOptions) => Promise; }; nip44: { encrypt: (pubkey: string, message: string, options?: SignerOptions) => Promise; decrypt: (pubkey: string, message: string, options?: SignerOptions) => Promise; }; cleanup(): Promise; } export declare const SIGNER_TIMEOUT = 30000; /** * How long welshman waits for one request to a signer, rather than how long that request * runs — an extension, a native app and a bunker all answer when they answer, and offer * no way to recall a request. The caller's `AbortSignal` and `SIGNER_TIMEOUT` each give up * on it, so the signer may still answer afterwards with nobody listening. * * It starts `request` itself, so a request whose signal is already aborted is never sent, and * one that throws rather than rejecting still settles. */ export declare const signerCall: (request: () => Promise, { signal }?: SignerOptions) => Promise; //# sourceMappingURL=util.d.ts.map