UNPKG

applesauce-wallet-connect

Version:

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

31 lines (30 loc) 2.27 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 { WalletConnectEncryptionMethod } from "./encryption.js"; import { TWalletMethod } from "./methods.js"; export declare const WALLET_REQUEST_KIND = 23194; export type WalletRequestEvent = KnownEvent<typeof WALLET_REQUEST_KIND>; /** A symbol used to cache the wallet request on the event */ export declare const WalletRequestSymbol: unique symbol; /** Type for events with unlocked hidden content */ export type UnlockedWalletRequest<Method extends TWalletMethod = TWalletMethod> = UnlockedHiddenContent & { [WalletRequestSymbol]: Method["request"]; }; /** Checks if a kind 23194 event is locked */ export declare function isWalletRequestUnlocked<Method extends TWalletMethod = TWalletMethod>(request: any): request is UnlockedWalletRequest<Method>; /** Unlocks a kind 23194 event */ export declare function unlockWalletRequest<Method extends TWalletMethod = TWalletMethod>(request: NostrEvent, signer: HiddenContentSigner, override?: EncryptionMethod): Promise<Method["request"] | undefined>; /** Gets the wallet request from a kind 23194 event */ export declare function getWalletRequest<Method extends TWalletMethod = TWalletMethod>(request: NostrEvent): Method["request"] | undefined; /** Returns the wallet service pubkey from a request */ export declare function getWalletRequestServicePubkey(request: WalletRequestEvent): string; export declare function getWalletRequestServicePubkey(request: NostrEvent): string | undefined; /** Returns the expiration timestamp from a request */ export declare function getWalletRequestExpiration(request: NostrEvent): number | undefined; /** Checks if a request has expired */ export declare function isWalletRequestExpired(request: NostrEvent): boolean; /** Gets the encryption method used for a request */ export declare function getWalletRequestEncryption(request: NostrEvent): WalletConnectEncryptionMethod; /** Checks if an event is a valid wallet request event */ export declare function isValidWalletRequest(request: NostrEvent): request is WalletRequestEvent;