@nostr-dev-kit/ndk-mobile
Version:
NDK Mobile
66 lines • 3.06 kB
TypeScript
import type NDK from "@nostr-dev-kit/ndk";
import { type NDKEncryptionScheme, type NDKSigner, NDKUser, type NostrEvent } from "@nostr-dev-kit/ndk";
import * as Nip55 from "expo-nip55";
export type NDKNip55Permission = Nip55.Permission;
export declare class NDKNip55Signer implements NDKSigner {
private _pubkey;
private _user?;
packageName: string;
private ndk?;
permissions: NDKNip55Permission[];
constructor(packageName: string, ndk?: NDK, permissions?: NDKNip55Permission[]);
/**
* Blocks until the signer is ready and returns the associated NDKUser.
* @returns A promise that resolves to the NDKUser instance.
*/
blockUntilReady(): Promise<NDKUser>;
/**
* Getter for the user property.
* @returns A promise that resolves to the NDKUser instance.
*/
user(): Promise<NDKUser>;
get userSync(): NDKUser;
get pubkey(): string;
/**
* Signs the given Nostr event.
* @param event - The Nostr event to be signed.
* @returns A promise that resolves to the signature of the signed event.
*/
sign(event: NostrEvent): Promise<string>;
/**
* Determine the types of encryption (by nip) that this signer can perform.
* Implementing classes SHOULD return a value even for legacy (only nip04) third party signers.
* @nip Optionally returns an array with single supported nip or empty, to check for truthy or falsy.
* @return A promised list of any (or none) of these strings ['nip04', 'nip44']
*/
encryptionEnabled?(scheme?: NDKEncryptionScheme): Promise<NDKEncryptionScheme[]>;
/**
* Encrypts the given Nostr event for the given recipient.
* Implementing classes SHOULD equate legacy (only nip04) to nip == `nip04` || undefined
* @param recipient - The recipient (pubkey or conversationKey) of the encrypted value.
* @param value - The value to be encrypted.
* @param nip - which NIP is being implemented ('nip04', 'nip44')
*/
encrypt(recipient: NDKUser, value: string, scheme?: NDKEncryptionScheme): Promise<string>;
/**
* Decrypts the given value.
* Implementing classes SHOULD equate legacy (only nip04) to nip == `nip04` || undefined
* @param sender - The sender (pubkey or conversationKey) of the encrypted value
* @param value - The value to be decrypted
* @param scheme - which NIP is being implemented ('nip04', 'nip44', 'nip49')
*/
decrypt(sender: NDKUser, value: string, scheme?: NDKEncryptionScheme): Promise<string>;
/**
* Serializes the signer's package name and pubkey.
* @returns A JSON string containing the type, package name, and pubkey.
*/
toPayload(): string;
/**
* Deserializes the signer from a payload string.
* @param payloadString The JSON string obtained from toPayload().
* @param ndk Optional NDK instance.
* @returns An instance of NDKNip55Signer.
*/
static fromPayload(payloadString: string, ndk?: NDK): Promise<NDKNip55Signer>;
}
//# sourceMappingURL=nip55.d.ts.map