1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-06 10:33:57 +00:00

convert cipher service to ts

This commit is contained in:
Kyle Spearrin
2017-11-06 10:58:32 -05:00
parent 38e235302c
commit b05426f953
13 changed files with 543 additions and 23 deletions

View File

@@ -33,7 +33,7 @@ class Attachment extends Domain {
url: this.url,
};
return this.decryptObj(model, this, {
return this.decryptObj(model, {
fileName: null,
}, orgId);
}

View File

@@ -28,7 +28,7 @@ class Card extends Domain {
}
decrypt(orgId: string): Promise<any> {
return this.decryptObj({}, this, {
return this.decryptObj({}, {
cardholderName: null,
brand: null,
number: null,

View File

@@ -103,7 +103,7 @@ class Cipher extends Domain {
fields: null as any[],
};
await this.decryptObj(model, this, {
await this.decryptObj(model, {
name: null,
notes: null,
}, this.organizationId);

View File

@@ -16,8 +16,10 @@ export default abstract class Domain {
}
}
protected async decryptObj(model: any, self: any, map: any, orgId: string) {
protected async decryptObj(model: any, map: any, orgId: string) {
const promises = [];
const self: any = this;
for (const prop in map) {
if (!map.hasOwnProperty(prop)) {
continue;
@@ -33,7 +35,6 @@ export default abstract class Domain {
return null;
}).then((val: any) => {
model[theProp] = val;
return;
});
promises.push(p);
})(prop);

View File

@@ -28,7 +28,7 @@ class Field extends Domain {
type: this.type,
};
return this.decryptObj(model, this, {
return this.decryptObj(model, {
name: null,
value: null,
}, orgId);

View File

@@ -24,7 +24,7 @@ class Folder extends Domain {
id: this.id,
};
return this.decryptObj(model, this, {
return this.decryptObj(model, {
name: null,
}, null);
}

View File

@@ -52,7 +52,7 @@ class Identity extends Domain {
}
decrypt(orgId: string): Promise<any> {
return this.decryptObj({}, this, {
return this.decryptObj({}, {
title: null,
firstName: null,
middleName: null,

View File

@@ -24,7 +24,7 @@ class Login extends Domain {
}
decrypt(orgId: string): Promise<any> {
return this.decryptObj({}, this, {
return this.decryptObj({}, {
uri: null,
username: null,
password: null,