mirror of
https://github.com/bitwarden/browser
synced 2025-01-28 03:59:50 +01:00
improved some syntax and a few fixes
This commit is contained in:
parent
42771c1a2d
commit
b7a736294b
@ -5,7 +5,7 @@ export class AttachmentData {
|
||||
url: string;
|
||||
fileName: string;
|
||||
key: string;
|
||||
size: number;
|
||||
size: string;
|
||||
sizeName: string;
|
||||
|
||||
constructor(response?: AttachmentResponse) {
|
||||
|
@ -48,12 +48,7 @@ export class CipherData {
|
||||
this.type = response.type;
|
||||
this.name = response.name;
|
||||
this.notes = response.notes;
|
||||
|
||||
if (collectionIds != null) {
|
||||
this.collectionIds = collectionIds;
|
||||
} else {
|
||||
this.collectionIds = response.collectionIds;
|
||||
}
|
||||
this.collectionIds = collectionIds != null ? collectionIds : response.collectionIds;
|
||||
|
||||
switch (this.type) {
|
||||
case CipherType.Login:
|
||||
@ -73,24 +68,13 @@ export class CipherData {
|
||||
}
|
||||
|
||||
if (response.fields != null) {
|
||||
this.fields = [];
|
||||
response.fields.forEach((field) => {
|
||||
this.fields.push(new FieldData(field));
|
||||
});
|
||||
this.fields = response.fields.map((f) => new FieldData(f));
|
||||
}
|
||||
|
||||
if (response.attachments != null) {
|
||||
this.attachments = [];
|
||||
response.attachments.forEach((attachment) => {
|
||||
this.attachments.push(new AttachmentData(attachment));
|
||||
});
|
||||
this.attachments = response.attachments.map((a) => new AttachmentData(a));
|
||||
}
|
||||
|
||||
if (response.passwordHistory != null) {
|
||||
this.passwordHistory = [];
|
||||
response.passwordHistory.forEach((ph) => {
|
||||
this.passwordHistory.push(new PasswordHistoryData(ph));
|
||||
});
|
||||
this.passwordHistory = response.passwordHistory.map((ph) => new PasswordHistoryData(ph));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import { Utils } from '../../misc/utils';
|
||||
export class Attachment extends Domain {
|
||||
id: string;
|
||||
url: string;
|
||||
size: number;
|
||||
size: string;
|
||||
sizeName: string;
|
||||
key: CipherString;
|
||||
fileName: CipherString;
|
||||
@ -62,6 +62,7 @@ export class Attachment extends Domain {
|
||||
|
||||
toAttachmentData(): AttachmentData {
|
||||
const a = new AttachmentData();
|
||||
a.size = this.size;
|
||||
this.buildDataModel(this, a, {
|
||||
id: null,
|
||||
url: null,
|
||||
|
@ -76,28 +76,19 @@ export class Cipher extends Domain {
|
||||
}
|
||||
|
||||
if (obj.attachments != null) {
|
||||
this.attachments = [];
|
||||
obj.attachments.forEach((attachment) => {
|
||||
this.attachments.push(new Attachment(attachment, alreadyEncrypted));
|
||||
});
|
||||
this.attachments = obj.attachments.map((a) => new Attachment(a, alreadyEncrypted));
|
||||
} else {
|
||||
this.attachments = null;
|
||||
}
|
||||
|
||||
if (obj.fields != null) {
|
||||
this.fields = [];
|
||||
obj.fields.forEach((field) => {
|
||||
this.fields.push(new Field(field, alreadyEncrypted));
|
||||
});
|
||||
this.fields = obj.fields.map((f) => new Field(f, alreadyEncrypted));
|
||||
} else {
|
||||
this.fields = null;
|
||||
}
|
||||
|
||||
if (obj.passwordHistory != null) {
|
||||
this.passwordHistory = [];
|
||||
obj.passwordHistory.forEach((ph) => {
|
||||
this.passwordHistory.push(new Password(ph, alreadyEncrypted));
|
||||
});
|
||||
this.passwordHistory = obj.passwordHistory.map((ph) => new Password(ph, alreadyEncrypted));
|
||||
} else {
|
||||
this.passwordHistory = null;
|
||||
}
|
||||
@ -205,24 +196,13 @@ export class Cipher extends Domain {
|
||||
}
|
||||
|
||||
if (this.fields != null) {
|
||||
c.fields = [];
|
||||
this.fields.forEach((field) => {
|
||||
c.fields.push(field.toFieldData());
|
||||
});
|
||||
c.fields = this.fields.map((f) => f.toFieldData());
|
||||
}
|
||||
|
||||
if (this.attachments != null) {
|
||||
c.attachments = [];
|
||||
this.attachments.forEach((attachment) => {
|
||||
c.attachments.push(attachment.toAttachmentData());
|
||||
});
|
||||
c.attachments = this.attachments.map((a) => a.toAttachmentData());
|
||||
}
|
||||
|
||||
if (this.passwordHistory != null) {
|
||||
c.passwordHistory = [];
|
||||
this.passwordHistory.forEach((ph) => {
|
||||
c.passwordHistory.push(ph.toPasswordHistoryData());
|
||||
});
|
||||
c.passwordHistory = this.passwordHistory.map((ph) => ph.toPasswordHistoryData());
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ export class Password extends Domain {
|
||||
this.lastUsedDate = new Date(obj.lastUsedDate);
|
||||
}
|
||||
|
||||
async decrypt(orgId: string): Promise<PasswordHistoryView> {
|
||||
const view = await this.decryptObj(new PasswordHistoryView(this), {
|
||||
decrypt(orgId: string): Promise<PasswordHistoryView> {
|
||||
return this.decryptObj(new PasswordHistoryView(this), {
|
||||
password: null,
|
||||
}, orgId);
|
||||
return view;
|
||||
}
|
||||
|
||||
toPasswordHistoryData(): PasswordHistoryData {
|
||||
|
@ -5,7 +5,7 @@ export class AttachmentResponse extends BaseResponse {
|
||||
url: string;
|
||||
fileName: string;
|
||||
key: string;
|
||||
size: number;
|
||||
size: string;
|
||||
sizeName: string;
|
||||
|
||||
constructor(response: any) {
|
||||
|
@ -6,7 +6,7 @@ import { SymmetricCryptoKey } from '../domain/symmetricCryptoKey';
|
||||
export class AttachmentView implements View {
|
||||
id: string = null;
|
||||
url: string = null;
|
||||
size: number = null;
|
||||
size: string = null;
|
||||
sizeName: string = null;
|
||||
fileName: string = null;
|
||||
key: SymmetricCryptoKey = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user