mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
attach/read container service to window
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Enums } from '@bitwarden/jslib';
|
||||
import { Abstractions, Enums } from '@bitwarden/jslib';
|
||||
|
||||
import { CipherData } from '../data/cipherData';
|
||||
|
||||
@@ -11,8 +11,6 @@ import { Identity } from './identity';
|
||||
import { Login } from './login';
|
||||
import { SecureNote } from './secureNote';
|
||||
|
||||
import BrowserPlatformUtilsService from '../../services/browserPlatformUtils.service';
|
||||
|
||||
class Cipher extends Domain {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
@@ -117,7 +115,14 @@ class Cipher extends Domain {
|
||||
model.login = await this.login.decrypt(this.organizationId);
|
||||
model.subTitle = model.login.username;
|
||||
if (model.login.uri) {
|
||||
model.login.domain = BrowserPlatformUtilsService.getDomain(model.login.uri);
|
||||
const containerService = (window as any).BitwardenContainerService;
|
||||
if (containerService) {
|
||||
const platformUtilsService: Abstractions.PlatformUtilsService =
|
||||
containerService.getPlatformUtilsService();
|
||||
model.login.domain = platformUtilsService.getDomain(model.login.uri);
|
||||
} else {
|
||||
throw new Error('window.BitwardenContainerService not initialized.');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Enums.CipherType.SecureNote:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Enums } from '@bitwarden/jslib';
|
||||
|
||||
import ContainerService from '../../services/container.service';
|
||||
import { CryptoService } from '../../services/abstractions/crypto.service';
|
||||
|
||||
class CipherString {
|
||||
encryptedString?: string;
|
||||
@@ -92,12 +92,16 @@ class CipherString {
|
||||
return Promise.resolve(this.decryptedValue);
|
||||
}
|
||||
|
||||
if (ContainerService.cryptoService == null) {
|
||||
throw new Error('ContainerService.cryptoService not initialized');
|
||||
let cryptoService: CryptoService;
|
||||
const containerService = (window as any).BitwardenContainerService;
|
||||
if (containerService) {
|
||||
cryptoService = containerService.getCryptoService();
|
||||
} else {
|
||||
throw new Error('window.BitwardenContainerService not initialized.');
|
||||
}
|
||||
|
||||
return ContainerService.cryptoService.getOrgKey(orgId).then((orgKey: any) => {
|
||||
return ContainerService.cryptoService.decrypt(this, orgKey);
|
||||
return cryptoService.getOrgKey(orgId).then((orgKey: any) => {
|
||||
return cryptoService.decrypt(this, orgKey);
|
||||
}).then((decValue: any) => {
|
||||
this.decryptedValue = decValue;
|
||||
return this.decryptedValue;
|
||||
|
||||
Reference in New Issue
Block a user