mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
Add get key from storage for ensuring biometric browser integration (#408)
This commit is contained in:
parent
8797924bd1
commit
d2ca46b6f5
@ -15,6 +15,7 @@ export abstract class CryptoService {
|
|||||||
setEncPrivateKey: (encPrivateKey: string) => Promise<{}>;
|
setEncPrivateKey: (encPrivateKey: string) => Promise<{}>;
|
||||||
setOrgKeys: (orgs: ProfileOrganizationResponse[]) => Promise<{}>;
|
setOrgKeys: (orgs: ProfileOrganizationResponse[]) => Promise<{}>;
|
||||||
getKey: (keySuffix?: KeySuffixOptions) => Promise<SymmetricCryptoKey>;
|
getKey: (keySuffix?: KeySuffixOptions) => Promise<SymmetricCryptoKey>;
|
||||||
|
getKeyFromStorage: (keySuffix: KeySuffixOptions) => Promise<SymmetricCryptoKey>;
|
||||||
getKeyHash: () => Promise<string>;
|
getKeyHash: () => Promise<string>;
|
||||||
getEncKey: (key?: SymmetricCryptoKey) => Promise<SymmetricCryptoKey>;
|
getEncKey: (key?: SymmetricCryptoKey) => Promise<SymmetricCryptoKey>;
|
||||||
getPublicKey: () => Promise<ArrayBuffer>;
|
getPublicKey: () => Promise<ArrayBuffer>;
|
||||||
|
@ -100,7 +100,18 @@ export class CryptoService implements CryptoServiceAbstraction {
|
|||||||
if (this.key != null) {
|
if (this.key != null) {
|
||||||
return this.key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
keySuffix ||= 'auto';
|
keySuffix ||= 'auto';
|
||||||
|
const symmetricKey = await this.getKeyFromStorage(keySuffix);
|
||||||
|
|
||||||
|
if (symmetricKey != null) {
|
||||||
|
this.setKey(symmetricKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return symmetricKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getKeyFromStorage(keySuffix: KeySuffixOptions): Promise<SymmetricCryptoKey> {
|
||||||
const key = await this.retrieveKeyFromStorage(keySuffix);
|
const key = await this.retrieveKeyFromStorage(keySuffix);
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
|
|
||||||
@ -112,10 +123,9 @@ export class CryptoService implements CryptoServiceAbstraction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setKey(symmetricKey);
|
return symmetricKey;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
return key == null ? null : this.key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getKeyHash(): Promise<string> {
|
async getKeyHash(): Promise<string> {
|
||||||
|
Loading…
Reference in New Issue
Block a user