Add new function to initialize Stronghold javascript type to avoid data race

pull/415/head
vdang 2 years ago
parent 29bf8a2ab4
commit bd517977c0
No known key found for this signature in database
GPG Key ID: 48DFAD25A8F31057

@ -389,15 +389,26 @@ export class Vault extends ProcedureExecutor {
export class Stronghold {
path: string;
/**
* Private constructor.
* Use `Stronghold.init` to create a Stronghold instance.
* @param path
* @param password
*/
private constructor(path: string) {
this.path = path;
}
/**
* Initializes a stronghold.
* If the snapshot path located at `path` exists, the password must match.
* @param path
* @param password
*/
constructor(path: string, password: string) {
this.path = path;
void this.reload(password);
static async init(path: string, password: string): Promise<Stronghold> {
let stronghold = new Stronghold(path);
await stronghold.reload(password);
return stronghold;
}
/**

Loading…
Cancel
Save