mirror of
https://github.com/bitwarden/browser
synced 2026-01-06 02:23:44 +00:00
refactor for login uris and response model changes
This commit is contained in:
@@ -9,7 +9,7 @@ import { FieldView } from '../view/fieldView';
|
||||
|
||||
export class Field extends Domain {
|
||||
name: CipherString;
|
||||
vault: CipherString;
|
||||
value: CipherString;
|
||||
type: FieldType;
|
||||
|
||||
constructor(obj?: FieldData, alreadyEncrypted: boolean = false) {
|
||||
|
||||
@@ -10,6 +10,7 @@ export { Field } from './field';
|
||||
export { Folder } from './folder';
|
||||
export { Identity } from './identity';
|
||||
export { Login } from './login';
|
||||
export { LoginUri } from './loginUri';
|
||||
export { PasswordHistory } from './passwordHistory';
|
||||
export { SecureNote } from './secureNote';
|
||||
export { SymmetricCryptoKey } from './symmetricCryptoKey';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
31
src/models/domain/loginUri.ts
Normal file
31
src/models/domain/loginUri.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { UriMatchType } from '../../enums/uriMatchType';
|
||||
|
||||
import { LoginUriData } from '../data/loginUriData';
|
||||
|
||||
import { LoginUriView } from '../view/loginUriView';
|
||||
|
||||
import { CipherString } from './cipherString';
|
||||
import Domain from './domain';
|
||||
|
||||
export class LoginUri extends Domain {
|
||||
uri: CipherString;
|
||||
match: UriMatchType;
|
||||
|
||||
constructor(obj?: LoginUriData, alreadyEncrypted: boolean = false) {
|
||||
super();
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.match = obj.match;
|
||||
this.buildDomainModel(this, obj, {
|
||||
uri: null,
|
||||
}, alreadyEncrypted, []);
|
||||
}
|
||||
|
||||
decrypt(orgId: string): Promise<LoginUriView> {
|
||||
return this.decryptObj(new LoginUriView(this), {
|
||||
uri: null,
|
||||
}, orgId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user