@lightninglabs/lnc-web
Version:
Lightning Node Connect npm module for web
120 lines • 4.7 kB
TypeScript
import { FaradayApi, LitApi, LndApi, LoopApi, PoolApi, TaprootAssetsApi } from '@lightninglabs/lnc-core';
import { ClearOptions, LightningNodeConnectConfig, PasskeyUnlockOptions, PersistOptions, UnlockOptions } from './types/lightningNodeConnect';
/** The default values for the LightningNodeConnectConfig options. */
export declare const DEFAULT_CONFIG: LightningNodeConnectConfig;
/**
* Modern entrypoint supporting password, passkey, and session-based
* authentication. Does not expose a public CredentialStore — credential
* lifecycle is managed internally through the auth stack.
*/
export default class LightningNodeConnect {
lnd: LndApi;
loop: LoopApi;
pool: PoolApi;
faraday: FaradayApi;
tapd: TaprootAssetsApi;
lit: LitApi;
private _wasmManager;
private _credentialCache;
private _authCoordinator;
private _strategyManager;
private _sessionCoordinator;
private _config;
constructor(lncConfig?: LightningNodeConnectConfig);
get isReady(): boolean;
get isConnected(): boolean;
get status(): string;
get expiry(): Date;
get isReadOnly(): boolean;
get serverHost(): string;
/**
* Set the mailbox server host. This will be used to connect to the LNC proxy server.
*/
set serverHost(host: string);
hasPerms(permission: string): boolean;
/**
* Downloads the WASM client binary.
*/
preload(): Promise<void>;
/**
* Connects to the LNC proxy server. Builds ConnectionParams from the
* CredentialCache. The underlying WasmManager will bootstrap the WASM
* binary automatically if it has not been started yet.
*/
connect(): Promise<void>;
/**
* Disconnects from the proxy server.
*/
disconnect(): void;
/**
* Emulates a GRPC request but uses the WASM client instead.
*/
request<TRes>(method: string, request?: object): Promise<TRes>;
/**
* Subscribes to a GRPC server-streaming endpoint.
*/
subscribe<TRes>(method: string, request?: object, onMessage?: (res: TRes) => void, onError?: (res: Error) => void): void;
/**
* Set a pairing phrase, run the WASM client, and connect. Optionally
* persist credentials in a single call when the password or passkey is
* already known at pairing time.
*
* Without persist: `pair(phrase)` → caller must later call
* `persistWithPassword()` or `persistWithPasskey()` to survive a reload.
*
* With persist: `pair(phrase, { method: 'password', password })` connects
* and persists in one step.
*/
pair(pairingPhrase: string, persist?: PersistOptions): Promise<void>;
/**
* Convenience method for returning users. Unlocks the auth stack to
* hydrate credentials from storage, then connects to the proxy server.
*
* Equivalent to calling `unlock(options)` followed by `connect()`.
*/
login(options: UnlockOptions): Promise<void>;
/**
* Unlock the auth stack. Only authenticates and hydrates in-memory auth
* state — does not persist credentials or create sessions.
*/
unlock(options: UnlockOptions): Promise<boolean>;
/**
* Persist credentials using a password. Must be called after connect()
* so that the credential cache contains the connection keys.
*/
persistWithPassword(password: string): Promise<void>;
/**
* Persist credentials using a passkey. Must be called after connect()
* so that the credential cache contains the connection keys.
* @param options optional passkey options (createIfMissing, credentialId)
*/
persistWithPasskey(options?: Partial<PasskeyUnlockOptions>): Promise<void>;
/**
* Try to automatically restore auth state from a session without
* invoking WasmManager.connect().
*/
tryAutoRestore(): Promise<boolean>;
/**
* Get authentication information about the current state.
*/
getAuthenticationInfo(): Promise<import("./types/lightningNodeConnect").AuthenticationInfo>;
/**
* Returns true when passkeys are enabled in config AND the browser supports them.
*/
supportsPasskeys(): boolean;
/**
* Pure capability check — returns true if the browser supports passkeys,
* regardless of config.
*/
static isPasskeySupported(): Promise<boolean>;
/**
* Clear credentials. By default clears session data only.
* Pass `{ persisted: true }` to also clear long-term stored credentials.
*/
clear(options?: ClearOptions): void;
/**
* Runs the WASM client binary and waits until it is ready.
*/
private run;
}
//# sourceMappingURL=lightningNodeConnect.d.ts.map