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 { export class Stronghold {
path: string; 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. * Initializes a stronghold.
* If the snapshot path located at `path` exists, the password must match. * If the snapshot path located at `path` exists, the password must match.
* @param path * @param path
* @param password * @param password
*/ */
constructor(path: string, password: string) { static async init(path: string, password: string): Promise<Stronghold> {
this.path = path; let stronghold = new Stronghold(path);
void this.reload(password); await stronghold.reload(password);
return stronghold;
} }
/** /**

Loading…
Cancel
Save