@lightninglabs/lnc-web
Version:
Lightning Node Connect npm module for web
82 lines • 3.36 kB
TypeScript
import { AuthenticationInfo, UnlockOptions } from '../types/lightningNodeConnect';
import { AuthStrategy } from './authStrategy';
import { CredentialCache } from './credentialCache';
import { SessionCoordinator } from './sessionCoordinator';
import { StrategyManager } from './strategyManager';
/**
* Coordinates authentication operations across strategies, cache, and sessions.
*/
export declare class AuthenticationCoordinator {
private strategyManager;
private credentialCache;
private sessionCoordinator;
private activeStrategy?;
private sessionRestored;
private initializeCachePromise?;
constructor(strategyManager: StrategyManager, credentialCache: CredentialCache, sessionCoordinator: SessionCoordinator);
/**
* Check if the credential store is currently unlocked
*/
get isUnlocked(): boolean;
/**
* Get the active strategy used for authentication
*/
getActiveStrategy(): AuthStrategy | undefined;
/**
* Clear the auth state
*/
clearSession(): void;
/**
* Unlock the credential store using the specified method.
*
* When the session strategy already restored credentials via tryAutoRestore(),
* the cache is already populated and the crypto pipeline does not need to run
* again. This avoids redundant device-fingerprint, origin-key, unwrap, and
* decrypt operations that would otherwise fire on every unlock({session}) call.
*/
unlock(options: UnlockOptions): Promise<boolean>;
/**
* Get authentication information based on the current state of the credential store
*/
getAuthenticationInfo(): Promise<AuthenticationInfo>;
/**
* Try to automatically restore the credential store from the session.
* Delegates the actual restore to SessionCoordinator which performs a
* single restoreSession call and starts the refresh manager on success.
*/
tryAutoRestore(): Promise<boolean>;
/**
* Create a new session from the current CredentialCache contents.
* Only creates the session — does not persist credentials to a strategy.
*/
createSessionAfterConnection(): Promise<void>;
/**
* Get the cached credential
*/
private getCachedCredential;
/**
* Initialize the credential cache
*/
private initializeCache;
/**
* Wait for the background session restoration to complete. Called
* internally by unlock() and getAuthenticationInfo(), and externally
* by pair() to prevent a race with the constructor's async
* initializeCache().
*/
waitForSessionRestoration(): Promise<void>;
/**
* Persist the cached credentials to the strategy. Attempts all keys even if
* some fail, then throws an aggregate error if any persistence failed so the
* caller can handle partial persistence appropriately. Also sets the active
* strategy so subsequent session creation uses the same non-session strategy.
*/
persistCachedCredentials(strategy: AuthStrategy): Promise<void>;
/**
* Load credentials from the strategy into the cache. Attempts all keys
* even if some fail, then throws an aggregate error so the caller knows
* the cache may be incomplete.
*/
private loadCredentialsFromStrategy;
}
//# sourceMappingURL=authenticationCoordinator.d.ts.map