mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
refactor for login uris and response model changes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { CardApi } from '../api/cardApi';
|
||||
|
||||
export class CardData {
|
||||
cardholderName: string;
|
||||
brand: string;
|
||||
@@ -6,12 +8,12 @@ export class CardData {
|
||||
expYear: string;
|
||||
code: string;
|
||||
|
||||
constructor(data: any) {
|
||||
this.cardholderName = data.CardholderName;
|
||||
this.brand = data.Brand;
|
||||
this.number = data.Number;
|
||||
this.expMonth = data.ExpMonth;
|
||||
this.expYear = data.ExpYear;
|
||||
this.code = data.Code;
|
||||
constructor(data: CardApi) {
|
||||
this.cardholderName = data.cardholderName;
|
||||
this.brand = data.brand;
|
||||
this.number = data.number;
|
||||
this.expMonth = data.expMonth;
|
||||
this.expYear = data.expYear;
|
||||
this.code = data.code;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ export class CipherData {
|
||||
this.favorite = response.favorite;
|
||||
this.revisionDate = response.revisionDate;
|
||||
this.type = response.type;
|
||||
this.name = response.name;
|
||||
this.notes = response.notes;
|
||||
|
||||
if (collectionIds != null) {
|
||||
this.collectionIds = collectionIds;
|
||||
@@ -47,29 +49,26 @@ export class CipherData {
|
||||
this.collectionIds = response.collectionIds;
|
||||
}
|
||||
|
||||
this.name = response.data.Name;
|
||||
this.notes = response.data.Notes;
|
||||
|
||||
switch (this.type) {
|
||||
case CipherType.Login:
|
||||
this.login = new LoginData(response.data);
|
||||
this.login = new LoginData(response.login);
|
||||
break;
|
||||
case CipherType.SecureNote:
|
||||
this.secureNote = new SecureNoteData(response.data);
|
||||
this.secureNote = new SecureNoteData(response.secureNote);
|
||||
break;
|
||||
case CipherType.Card:
|
||||
this.card = new CardData(response.data);
|
||||
this.card = new CardData(response.card);
|
||||
break;
|
||||
case CipherType.Identity:
|
||||
this.identity = new IdentityData(response.data);
|
||||
this.identity = new IdentityData(response.identity);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (response.data.Fields != null) {
|
||||
if (response.fields != null) {
|
||||
this.fields = [];
|
||||
response.data.Fields.forEach((field: any) => {
|
||||
response.fields.forEach((field) => {
|
||||
this.fields.push(new FieldData(field));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { FieldType } from '../../enums/fieldType';
|
||||
|
||||
import { FieldApi } from '../api/fieldApi';
|
||||
|
||||
export class FieldData {
|
||||
type: FieldType;
|
||||
name: string;
|
||||
value: string;
|
||||
|
||||
constructor(response: any) {
|
||||
this.type = response.Type;
|
||||
this.name = response.Name;
|
||||
this.value = response.Value;
|
||||
constructor(response: FieldApi) {
|
||||
this.type = response.type;
|
||||
this.name = response.name;
|
||||
this.value = response.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { IdentityApi } from '../api/identityApi';
|
||||
|
||||
export class IdentityData {
|
||||
title: string;
|
||||
firstName: string;
|
||||
@@ -18,24 +20,24 @@ export class IdentityData {
|
||||
passportNumber: string;
|
||||
licenseNumber: string;
|
||||
|
||||
constructor(data: any) {
|
||||
this.title = data.Title;
|
||||
this.firstName = data.FirstName;
|
||||
this.middleName = data.MiddleName;
|
||||
this.lastName = data.LastName;
|
||||
this.address1 = data.Address1;
|
||||
this.address2 = data.Address2;
|
||||
this.address3 = data.Address3;
|
||||
this.city = data.City;
|
||||
this.state = data.State;
|
||||
this.postalCode = data.PostalCode;
|
||||
this.country = data.Country;
|
||||
this.company = data.Company;
|
||||
this.email = data.Email;
|
||||
this.phone = data.Phone;
|
||||
this.ssn = data.SSN;
|
||||
this.username = data.Username;
|
||||
this.passportNumber = data.PassportNumber;
|
||||
this.licenseNumber = data.LicenseNumber;
|
||||
constructor(data: IdentityApi) {
|
||||
this.title = data.title;
|
||||
this.firstName = data.firstName;
|
||||
this.middleName = data.middleName;
|
||||
this.lastName = data.lastName;
|
||||
this.address1 = data.address1;
|
||||
this.address2 = data.address2;
|
||||
this.address3 = data.address3;
|
||||
this.city = data.city;
|
||||
this.state = data.state;
|
||||
this.postalCode = data.postalCode;
|
||||
this.country = data.country;
|
||||
this.company = data.company;
|
||||
this.email = data.email;
|
||||
this.phone = data.phone;
|
||||
this.ssn = data.ssn;
|
||||
this.username = data.username;
|
||||
this.passportNumber = data.passportNumber;
|
||||
this.licenseNumber = data.licenseNumber;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ export { FieldData } from './fieldData';
|
||||
export { FolderData } from './folderData';
|
||||
export { IdentityData } from './identityData';
|
||||
export { LoginData } from './loginData';
|
||||
export { LoginUriData } from './loginUriData';
|
||||
export { SecureNoteData } from './secureNoteData';
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
import { LoginApi } from '../api/loginApi';
|
||||
import { LoginUriApi } from '../api/loginUriApi';
|
||||
|
||||
import { LoginUriData } from './loginUriData';
|
||||
|
||||
export class LoginData {
|
||||
uri: string;
|
||||
uris: LoginUriData[];
|
||||
username: string;
|
||||
password: string;
|
||||
totp: string;
|
||||
|
||||
constructor(data: any) {
|
||||
this.uri = data.Uri;
|
||||
this.username = data.Username;
|
||||
this.password = data.Password;
|
||||
this.totp = data.Totp;
|
||||
constructor(data: LoginApi) {
|
||||
this.username = data.username;
|
||||
this.password = data.password;
|
||||
this.totp = data.totp;
|
||||
|
||||
if (data.uris) {
|
||||
this.uris = [];
|
||||
data.uris.forEach((u) => {
|
||||
this.uris.push(new LoginUriData(u));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
src/models/data/loginUriData.ts
Normal file
13
src/models/data/loginUriData.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { UriMatchType } from '../../enums/uriMatchType';
|
||||
|
||||
import { LoginUriApi } from '../api/loginUriApi';
|
||||
|
||||
export class LoginUriData {
|
||||
uri: string;
|
||||
match: UriMatchType = null;
|
||||
|
||||
constructor(data: LoginUriApi) {
|
||||
this.uri = data.uri;
|
||||
this.match = data.match;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import { SecureNoteType } from '../../enums/secureNoteType';
|
||||
|
||||
import { SecureNoteApi } from '../api/secureNoteApi';
|
||||
|
||||
export class SecureNoteData {
|
||||
type: SecureNoteType;
|
||||
|
||||
constructor(data: any) {
|
||||
this.type = data.Type;
|
||||
constructor(data: SecureNoteApi) {
|
||||
this.type = data.type;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user