1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 06:13:38 +00:00

interfaced utilsservice for popup and dependencies

This commit is contained in:
Kyle Spearrin
2017-11-13 15:37:38 -05:00
parent 907247b3a7
commit 11f392b036
13 changed files with 98 additions and 59 deletions

View File

@@ -8,11 +8,10 @@ class CipherString {
cipherText?: string;
initializationVector?: string;
mac?: string;
cryptoService: CryptoService;
private cryptoService: CryptoService;
constructor(encryptedStringOrType: string | EncryptionType, ct?: string, iv?: string, mac?: string) {
this.cryptoService = chrome.extension.getBackgroundPage().bg_cryptoService as CryptoService;
if (ct != null) {
// ct and header
const encType = encryptedStringOrType as EncryptionType;
@@ -90,13 +89,16 @@ class CipherString {
}
decrypt(orgId: string) {
const self = this;
if (this.decryptedValue) {
return Promise.resolve(self.decryptedValue);
return Promise.resolve(this.decryptedValue);
}
return self.cryptoService.getOrgKey(orgId).then((orgKey: any) => {
const self = this;
if (this.cryptoService == null) {
this.cryptoService = chrome.extension.getBackgroundPage().bg_cryptoService as CryptoService;
}
return this.cryptoService.getOrgKey(orgId).then((orgKey: any) => {
return self.cryptoService.decrypt(self, orgKey);
}).then((decValue: any) => {
self.decryptedValue = decValue;