1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00
Files
browser/libs/common/src/vault/models/data/cipher.data.ts
SmithThe4th a3c902d25a [PM-1975] Move FIDO2 files into vault folder (#5496)
* Moved fido2 models to vault in libs

* Moved fido2 models to vault in libs

* Moved fido2 services and abstractions to vault folder in libs

* Moved fido2 popup to vault folder on the browser

* Updated import path after moving files to the vault folder

* Moved authenticator abstraction and service to the vault folder

* Updated content and page script path

* Added content script, page script and background messaging to vault

* fixed lint issue

* Updated reference paths

* Added missing fallbacksupported property in test files

* Added missing fallbacksupported to the newSession method
2023-06-07 12:46:52 -04:00

93 lines
3.0 KiB
TypeScript

import { CipherRepromptType } from "../../enums/cipher-reprompt-type";
import { CipherType } from "../../enums/cipher-type";
import { CipherResponse } from "../response/cipher.response";
import { AttachmentData } from "./attachment.data";
import { CardData } from "./card.data";
import { Fido2KeyData } from "./fido2-key.data";
import { FieldData } from "./field.data";
import { IdentityData } from "./identity.data";
import { LoginData } from "./login.data";
import { PasswordHistoryData } from "./password-history.data";
import { SecureNoteData } from "./secure-note.data";
export class CipherData {
id: string;
organizationId: string;
folderId: string;
edit: boolean;
viewPassword: boolean;
organizationUseTotp: boolean;
favorite: boolean;
revisionDate: string;
type: CipherType;
name: string;
notes: string;
login?: LoginData;
secureNote?: SecureNoteData;
card?: CardData;
identity?: IdentityData;
fido2Key?: Fido2KeyData;
fields?: FieldData[];
attachments?: AttachmentData[];
passwordHistory?: PasswordHistoryData[];
collectionIds?: string[];
creationDate: string;
deletedDate: string;
reprompt: CipherRepromptType;
constructor(response?: CipherResponse, collectionIds?: string[]) {
if (response == null) {
return;
}
this.id = response.id;
this.organizationId = response.organizationId;
this.folderId = response.folderId;
this.edit = response.edit;
this.viewPassword = response.viewPassword;
this.organizationUseTotp = response.organizationUseTotp;
this.favorite = response.favorite;
this.revisionDate = response.revisionDate;
this.type = response.type;
this.name = response.name;
this.notes = response.notes;
this.collectionIds = collectionIds != null ? collectionIds : response.collectionIds;
this.creationDate = response.creationDate;
this.deletedDate = response.deletedDate;
this.reprompt = response.reprompt;
switch (this.type) {
case CipherType.Login:
this.login = new LoginData(response.login);
this.fido2Key =
response.fido2Key != undefined ? new Fido2KeyData(response.fido2Key) : undefined;
break;
case CipherType.SecureNote:
this.secureNote = new SecureNoteData(response.secureNote);
break;
case CipherType.Card:
this.card = new CardData(response.card);
break;
case CipherType.Identity:
this.identity = new IdentityData(response.identity);
break;
case CipherType.Fido2Key:
this.fido2Key = new Fido2KeyData(response.fido2Key);
break;
default:
break;
}
if (response.fields != null) {
this.fields = response.fields.map((f) => new FieldData(f));
}
if (response.attachments != null) {
this.attachments = response.attachments.map((a) => new AttachmentData(a));
}
if (response.passwordHistory != null) {
this.passwordHistory = response.passwordHistory.map((ph) => new PasswordHistoryData(ph));
}
}
}