1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 03:33:54 +00:00

refactor for login uris and response model changes

This commit is contained in:
Kyle Spearrin
2018-03-01 23:44:29 -05:00
parent 52f3ea58d1
commit 063bb010db
27 changed files with 405 additions and 102 deletions

View File

@@ -1,12 +1,15 @@
import { LoginUri } from './loginUri';
import { LoginData } from '../data/loginData';
import { LoginUriView } from '../view/loginUriView';
import { LoginView } from '../view/loginView';
import { CipherString } from './cipherString';
import Domain from './domain';
export class Login extends Domain {
uri: CipherString;
uris: LoginUri[];
username: CipherString;
password: CipherString;
totp: CipherString;
@@ -18,19 +21,34 @@ export class Login extends Domain {
}
this.buildDomainModel(this, obj, {
uri: null,
username: null,
password: null,
totp: null,
}, alreadyEncrypted, []);
if (obj.uris) {
this.uris = [];
obj.uris.forEach((u) => {
this.uris.push(new LoginUri(u, alreadyEncrypted));
});
}
}
decrypt(orgId: string): Promise<LoginView> {
return this.decryptObj(new LoginView(this), {
uri: null,
async decrypt(orgId: string): Promise<LoginView> {
const view = await this.decryptObj(new LoginView(this), {
username: null,
password: null,
totp: null,
}, orgId);
if (this.uris != null) {
view.uris = [];
for (let i = 0; i < this.uris.length; i++) {
const uri = await this.uris[i].decrypt(orgId);
view.uris.push(uri);
}
}
return view;
}
}