cyphertap
Version:
Nostr, Lightning and Ecash on a single Button component
70 lines (69 loc) • 2.53 kB
TypeScript
import NDKSvelte from '@nostr-dev-kit/ndk-svelte';
import NDK, { type NDKUser, type NDKSigner } from '@nostr-dev-kit/ndk';
export declare const ndkInstance: import("svelte/store").Writable<NDKSvelte | null>;
export declare const currentUser: import("svelte/store").Writable<NDKUser | null>;
export declare const isConnecting: import("svelte/store").Writable<boolean>;
export declare const loginError: import("svelte/store").Writable<string | null>;
export declare const ENCRYPTED_KEY = "ncrypt";
export declare const EXTENSION_LOGIN = "nip07";
/**
* Initialize NDK with a specific user context
* @param signer - The signer to use
* @returns An object containing the NDK instance and user
*/
export declare function initNDK(signer: NDKSigner): Promise<{
ndk: NDKSvelte;
user: NDKUser;
}>;
/**
* Generate a new keypair for the user
* @returns Private key string
*/
export declare function generateNewKeypair(): string;
/**
* Login with a private key (nsec)
*/
export declare function privateKeyLogin(nsec: string): Promise<boolean>;
/**
* Login with a NIP-07 extension
*/
export declare function nip07Login(): Promise<boolean>;
/**
* Unified login function that handles both login methods
* Keeps all login logic in the Nostr service
*/
export declare function login(options: {
method: 'private-key' | 'nip-07';
privateKey?: string;
}): Promise<void>;
/**
* Try to auto-login with stored credentials
* This function only handles the NDK initialization, not other components
*/
export declare function autoLogin(): Promise<void | null>;
/**
* Logout function
*/
export declare function logout(clearCache?: boolean): void;
export declare function getNDK(): NDK;
/**
* Add a relay to the NDK instance and publish the updated relay list
* @param url The relay URL to add
*/
export declare function addRelay(url: string): Promise<string>;
/**
* Remove a relay from the NDK instance and publish the updated relay list
* @param url The relay URL to remove
*/
export declare function removeRelay(url: string): Promise<void>;
/**
* Publish the current relay list as a Nostr event
*/
export declare function publishRelayList(): Promise<void>;
export declare const isLoggedIn: import("svelte/store").Readable<boolean>;
export declare const relays: import("svelte/store").Readable<import("@nostr-dev-kit/ndk").NDKRelay[]>;
export declare const relayConnectionStatus: import("svelte/store").Readable<{
url: string;
connected: boolean;
status: import("@nostr-dev-kit/ndk").NDKRelayStatus;
}[]>;