mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
interfaced utilsservice for popup and dependencies
This commit is contained in:
@@ -11,7 +11,7 @@ import { Identity } from './identity';
|
||||
import { Login } from './login';
|
||||
import { SecureNote } from './secureNote';
|
||||
|
||||
import UtilsService from '../../services/utils.service';
|
||||
import { UtilsService } from '../../services/abstractions/utils.service';
|
||||
|
||||
class Cipher extends Domain {
|
||||
id: string;
|
||||
@@ -31,6 +31,8 @@ class Cipher extends Domain {
|
||||
attachments: Attachment[];
|
||||
fields: Field[];
|
||||
|
||||
private utilsService: UtilsService;
|
||||
|
||||
constructor(obj?: CipherData, alreadyEncrypted: boolean = false, localData: any = null) {
|
||||
super();
|
||||
if (obj == null) {
|
||||
@@ -113,7 +115,11 @@ class Cipher extends Domain {
|
||||
model.login = await this.login.decrypt(this.organizationId);
|
||||
model.subTitle = model.login.username;
|
||||
if (model.login.uri) {
|
||||
model.login.domain = UtilsService.getDomain(model.login.uri);
|
||||
if (this.utilsService == null) {
|
||||
this.utilsService = chrome.extension.getBackgroundPage().bg_utilsService as UtilsService;
|
||||
}
|
||||
|
||||
model.login.domain = this.utilsService.getDomain(model.login.uri);
|
||||
}
|
||||
break;
|
||||
case CipherType.SecureNote:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { BrowserType } from '../../enums/browserType.enum';
|
||||
import { UtilsService } from '../../services/abstractions/utils.service';
|
||||
|
||||
class DeviceRequest {
|
||||
type: number; // TODO: enum
|
||||
type: BrowserType;
|
||||
name: string;
|
||||
identifier: string;
|
||||
pushToken?: string;
|
||||
|
||||
constructor(appId: string, utilsService: any) { // TODO: utils service type
|
||||
this.type = utilsService.getDeviceType();
|
||||
this.name = utilsService.getBrowser();
|
||||
constructor(appId: string, utilsService: UtilsService) {
|
||||
this.type = utilsService.getBrowser();
|
||||
this.name = utilsService.getBrowserString();
|
||||
this.identifier = appId;
|
||||
this.pushToken = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user