mirror of
https://github.com/logos-messaging/js-rln.git
synced 2026-01-08 00:23:12 +00:00
add keys operation to Keystore
This commit is contained in:
parent
eb119aa763
commit
17e48d12da
@ -164,6 +164,14 @@ export class Keystore {
|
|||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read array of hashes of current credentials
|
||||||
|
* @returns array of keys of credentials in current Keystore
|
||||||
|
*/
|
||||||
|
public keys(): string[] {
|
||||||
|
return Object.keys(this.toObject().credentials || {});
|
||||||
|
}
|
||||||
|
|
||||||
private static isValidNwakuStore(obj: unknown): boolean {
|
private static isValidNwakuStore(obj: unknown): boolean {
|
||||||
if (!isKeystoreValid(obj)) {
|
if (!isKeystoreValid(obj)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -203,7 +203,7 @@ export class RLNInstance {
|
|||||||
private _contract: undefined | RLNContract;
|
private _contract: undefined | RLNContract;
|
||||||
private _signer: undefined | ethers.Signer;
|
private _signer: undefined | ethers.Signer;
|
||||||
|
|
||||||
private _keystore = Keystore.create();
|
private keystore = Keystore.create();
|
||||||
private _credentials: undefined | DecryptedCredentials;
|
private _credentials: undefined | DecryptedCredentials;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -219,10 +219,6 @@ export class RLNInstance {
|
|||||||
return this._signer;
|
return this._signer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get keystore(): Keystore {
|
|
||||||
return this._keystore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async start(options: StartRLNOptions = {}): Promise<void> {
|
public async start(options: StartRLNOptions = {}): Promise<void> {
|
||||||
if (this.started || this.starting) {
|
if (this.started || this.starting) {
|
||||||
return;
|
return;
|
||||||
@ -297,7 +293,7 @@ export class RLNInstance {
|
|||||||
throw Error("Failed to start RLN: cannot read Keystore provided.");
|
throw Error("Failed to start RLN: cannot read Keystore provided.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this._keystore = keystore;
|
this.keystore = keystore;
|
||||||
this._credentials = await keystore.readCredential(
|
this._credentials = await keystore.readCredential(
|
||||||
credentials.id,
|
credentials.id,
|
||||||
credentials.password
|
credentials.password
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user