@stackernews/lnc-web
Version:
Lightning Node Connect npm module for web
70 lines • 2.97 kB
TypeScript
import { CredentialStore } from '../types/lnc';
/**
* A wrapper around `window.localStorage` used to store sensitive data required
* by LNC to reconnect after the initial pairing process has been completed. The
* data is encrypted at rest using the provided `password`.
*/
export default class LncCredentialStore implements CredentialStore {
private persisted;
private _localKey;
private _remoteKey;
private _pairingPhrase;
/** The password used to encrypt and decrypt the stored data */
private _password?;
/** The namespace to use in the localStorage key */
private namespace;
/**
* Constructs a new `LncCredentialStore` instance
*/
constructor(namespace?: string, password?: string);
/**
* Stores the optional password to use for encryption of the data. LNC does not
* read or write the password. This is just exposed publicly to simplify access
* to the field via `lnc.credentials.password`
*/
get password(): string;
/**
* Stores the optional password to use for encryption of the data. LNC does not
* read or write the password. This is just exposed publicly to simplify access
* to the field via `lnc.credentials.password`
*/
set password(password: string);
/** Stores the host:port of the Lightning Node Connect proxy server to connect to */
get serverHost(): string;
/** Stores the host:port of the Lightning Node Connect proxy server to connect to */
set serverHost(host: string);
/** Stores the LNC pairing phrase used to initialize the connection to the LNC proxy */
get pairingPhrase(): string;
/** Stores the LNC pairing phrase used to initialize the connection to the LNC proxy */
set pairingPhrase(phrase: string);
/** Stores the local private key which LNC uses to reestablish a connection */
get localKey(): string;
/** Stores the local private key which LNC uses to reestablish a connection */
set localKey(key: string);
/** Stores the remote static key which LNC uses to reestablish a connection */
get remoteKey(): string;
/** Stores the remote static key which LNC uses to reestablish a connection */
set remoteKey(key: string);
/**
* Read-only field which should return `true` if the client app has prior
* credentials persisted in teh store
*/
get isPaired(): boolean;
/** Clears any persisted data in the store */
clear(memoryOnly?: boolean): void;
/** Loads persisted data from localStorage */
private _load;
/** Saves persisted data to localStorage */
private _save;
/**
* A wrapper around `encrypt` which just returns an empty string if the
* value or password have no value
*/
private _encrypt;
/**
* A wrapper around `decrypt` which just returns an empty string if the
* value or password have no value
*/
private _decrypt;
}
//# sourceMappingURL=credentialStore.d.ts.map