Skip to content
This repository was archived by the owner on Jun 17, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions common/src/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export class StateService<
if (options?.userId == null) {
return;
}
await this.secureStorageService.save(`${options.userId}${partialKeys.autoKey}`, value, options);
await this.saveSecureStorageKey(partialKeys.autoKey, value, options);
}

async getCryptoMasterKeyB64(options?: StorageOptions): Promise<string> {
Expand All @@ -465,11 +465,7 @@ export class StateService<
if (options?.userId == null) {
return;
}
await this.secureStorageService.save(
`${options.userId}${partialKeys.masterKey}`,
value,
options
);
await this.saveSecureStorageKey(partialKeys.masterKey, value, options);
}

async getCryptoMasterKeyBiometric(options?: StorageOptions): Promise<string> {
Expand Down Expand Up @@ -508,11 +504,7 @@ export class StateService<
if (options?.userId == null) {
return;
}
await this.secureStorageService.save(
`${options.userId}${partialKeys.biometricKey}`,
value,
options
);
await this.saveSecureStorageKey(partialKeys.biometricKey, value, options);
}

async getDecodedToken(options?: StorageOptions): Promise<any> {
Expand Down Expand Up @@ -2502,4 +2494,10 @@ export class StateService<
: await this.defaultOnDiskOptions();
return this.reconcileOptions(options, defaultOptions);
}

private async saveSecureStorageKey(key: string, value: string, options?: StorageOptions) {
return value == null
? await this.secureStorageService.remove(`${options.userId}${key}`, options)
: await this.secureStorageService.save(`${options.userId}${key}`, value, options);
}
}