UNPKG

applesauce-wallet-connect

Version:

NIP-47 Nostr Wallet Connect implementation for both clients and services.

28 lines (27 loc) 2.12 kB
import { EncryptionMethod } from "applesauce-core/helpers/encrypted-content"; import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event"; import { HiddenContentSigner, UnlockedHiddenContent } from "applesauce-core/helpers/hidden-content"; import { TWalletMethod } from "./methods.js"; export declare const WALLET_RESPONSE_KIND = 23195; /** A symbol used to cache the wallet response on the event */ export declare const WalletResponseSymbol: unique symbol; /** Type for events with unlocked hidden content */ export type UnlockedWalletResponse<Method extends TWalletMethod = TWalletMethod> = UnlockedHiddenContent & { [WalletResponseSymbol]: Method["response"]; }; /** Type for validated wallet response events */ export type WalletResponseEvent = KnownEvent<typeof WALLET_RESPONSE_KIND>; /** Checks if a kind 23195 event is locked */ export declare function isWalletResponseUnlocked<Method extends TWalletMethod = TWalletMethod>(response: any): response is UnlockedWalletResponse<Method>; /** Unlocks a kind 23195 event */ export declare function unlockWalletResponse<Method extends TWalletMethod = TWalletMethod>(response: NostrEvent, signer: HiddenContentSigner, override?: EncryptionMethod): Promise<Method["response"] | undefined>; /** Gets the wallet response from a kind 23195 event */ export declare function getWalletResponse<Method extends TWalletMethod = TWalletMethod>(response: NostrEvent): Method["response"] | undefined; /** Returns the client pubkey of client this response is for */ export declare function getWalletResponseClientPubkey(response: WalletResponseEvent): string; export declare function getWalletResponseClientPubkey(response: NostrEvent): string | undefined; /** Returns the request id of the request this response is for */ export declare function getWalletResponseRequestId(response: WalletResponseEvent): string; export declare function getWalletResponseRequestId(response: NostrEvent): string | undefined; /** Checks if event is a valid wallet response event */ export declare function isValidWalletResponse(response: NostrEvent): response is WalletResponseEvent;