mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00:00
Fix mapping issue between client and SDK (#15056)
This commit is contained in:
@@ -887,7 +887,10 @@ describe("Cipher DTO", () => {
|
|||||||
reprompt: SdkCipherRepromptType.None,
|
reprompt: SdkCipherRepromptType.None,
|
||||||
organizationUseTotp: true,
|
organizationUseTotp: true,
|
||||||
edit: true,
|
edit: true,
|
||||||
permissions: new CipherPermissionsApi(),
|
permissions: {
|
||||||
|
delete: false,
|
||||||
|
restore: false,
|
||||||
|
},
|
||||||
viewPassword: true,
|
viewPassword: true,
|
||||||
localData: {
|
localData: {
|
||||||
lastUsedDate: "2025-04-15T12:00:00.000Z",
|
lastUsedDate: "2025-04-15T12:00:00.000Z",
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ export class Cipher extends Domain implements Decryptable<CipherView> {
|
|||||||
const domain = new Cipher();
|
const domain = new Cipher();
|
||||||
const name = EncString.fromJSON(obj.name);
|
const name = EncString.fromJSON(obj.name);
|
||||||
const notes = EncString.fromJSON(obj.notes);
|
const notes = EncString.fromJSON(obj.notes);
|
||||||
|
const creationDate = obj.creationDate == null ? null : new Date(obj.creationDate);
|
||||||
const revisionDate = obj.revisionDate == null ? null : new Date(obj.revisionDate);
|
const revisionDate = obj.revisionDate == null ? null : new Date(obj.revisionDate);
|
||||||
const deletedDate = obj.deletedDate == null ? null : new Date(obj.deletedDate);
|
const deletedDate = obj.deletedDate == null ? null : new Date(obj.deletedDate);
|
||||||
const attachments = obj.attachments?.map((a: any) => Attachment.fromJSON(a));
|
const attachments = obj.attachments?.map((a: any) => Attachment.fromJSON(a));
|
||||||
@@ -302,6 +303,7 @@ export class Cipher extends Domain implements Decryptable<CipherView> {
|
|||||||
Object.assign(domain, obj, {
|
Object.assign(domain, obj, {
|
||||||
name,
|
name,
|
||||||
notes,
|
notes,
|
||||||
|
creationDate,
|
||||||
revisionDate,
|
revisionDate,
|
||||||
deletedDate,
|
deletedDate,
|
||||||
attachments,
|
attachments,
|
||||||
@@ -341,17 +343,22 @@ export class Cipher extends Domain implements Decryptable<CipherView> {
|
|||||||
toSdkCipher(): SdkCipher {
|
toSdkCipher(): SdkCipher {
|
||||||
const sdkCipher: SdkCipher = {
|
const sdkCipher: SdkCipher = {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
organizationId: this.organizationId,
|
organizationId: this.organizationId ?? undefined,
|
||||||
folderId: this.folderId,
|
folderId: this.folderId ?? undefined,
|
||||||
collectionIds: this.collectionIds || [],
|
collectionIds: this.collectionIds ?? [],
|
||||||
key: this.key?.toJSON(),
|
key: this.key?.toJSON(),
|
||||||
name: this.name.toJSON(),
|
name: this.name.toJSON(),
|
||||||
notes: this.notes?.toJSON(),
|
notes: this.notes?.toJSON(),
|
||||||
type: this.type,
|
type: this.type,
|
||||||
favorite: this.favorite,
|
favorite: this.favorite ?? false,
|
||||||
organizationUseTotp: this.organizationUseTotp,
|
organizationUseTotp: this.organizationUseTotp ?? false,
|
||||||
edit: this.edit,
|
edit: this.edit,
|
||||||
permissions: this.permissions,
|
permissions: this.permissions
|
||||||
|
? {
|
||||||
|
delete: this.permissions.delete,
|
||||||
|
restore: this.permissions.restore,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
viewPassword: this.viewPassword,
|
viewPassword: this.viewPassword,
|
||||||
localData: this.localData
|
localData: this.localData
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ export class Login extends Domain {
|
|||||||
password: this.password?.toJSON(),
|
password: this.password?.toJSON(),
|
||||||
passwordRevisionDate: this.passwordRevisionDate?.toISOString(),
|
passwordRevisionDate: this.passwordRevisionDate?.toISOString(),
|
||||||
totp: this.totp?.toJSON(),
|
totp: this.totp?.toJSON(),
|
||||||
autofillOnPageLoad: this.autofillOnPageLoad,
|
autofillOnPageLoad: this.autofillOnPageLoad ?? undefined,
|
||||||
fido2Credentials: this.fido2Credentials?.map((f) => f.toSdkFido2Credential()),
|
fido2Credentials: this.fido2Credentials?.map((f) => f.toSdkFido2Credential()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ export class CipherView implements View, InitializerMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const view = new CipherView();
|
const view = new CipherView();
|
||||||
|
const creationDate = obj.creationDate == null ? null : new Date(obj.creationDate);
|
||||||
const revisionDate = obj.revisionDate == null ? null : new Date(obj.revisionDate);
|
const revisionDate = obj.revisionDate == null ? null : new Date(obj.revisionDate);
|
||||||
const deletedDate = obj.deletedDate == null ? null : new Date(obj.deletedDate);
|
const deletedDate = obj.deletedDate == null ? null : new Date(obj.deletedDate);
|
||||||
const attachments = obj.attachments?.map((a: any) => AttachmentView.fromJSON(a));
|
const attachments = obj.attachments?.map((a: any) => AttachmentView.fromJSON(a));
|
||||||
@@ -195,6 +196,7 @@ export class CipherView implements View, InitializerMetadata {
|
|||||||
const passwordHistory = obj.passwordHistory?.map((ph: any) => PasswordHistoryView.fromJSON(ph));
|
const passwordHistory = obj.passwordHistory?.map((ph: any) => PasswordHistoryView.fromJSON(ph));
|
||||||
|
|
||||||
Object.assign(view, obj, {
|
Object.assign(view, obj, {
|
||||||
|
creationDate: creationDate,
|
||||||
revisionDate: revisionDate,
|
revisionDate: revisionDate,
|
||||||
deletedDate: deletedDate,
|
deletedDate: deletedDate,
|
||||||
attachments: attachments,
|
attachments: attachments,
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
cipher.organizationId = model.organizationId;
|
cipher.organizationId = model.organizationId;
|
||||||
cipher.type = model.type;
|
cipher.type = model.type;
|
||||||
cipher.collectionIds = model.collectionIds;
|
cipher.collectionIds = model.collectionIds;
|
||||||
|
cipher.creationDate = model.creationDate;
|
||||||
cipher.revisionDate = model.revisionDate;
|
cipher.revisionDate = model.revisionDate;
|
||||||
cipher.reprompt = model.reprompt;
|
cipher.reprompt = model.reprompt;
|
||||||
cipher.edit = model.edit;
|
cipher.edit = model.edit;
|
||||||
|
|||||||
Reference in New Issue
Block a user