1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

Fix mapping issue between client and SDK (#15056)

This commit is contained in:
SmithThe4th
2025-06-13 10:58:38 -04:00
committed by GitHub
parent 7c2ab56768
commit c6e4a9ba75
5 changed files with 21 additions and 8 deletions

View File

@@ -887,7 +887,10 @@ describe("Cipher DTO", () => {
reprompt: SdkCipherRepromptType.None,
organizationUseTotp: true,
edit: true,
permissions: new CipherPermissionsApi(),
permissions: {
delete: false,
restore: false,
},
viewPassword: true,
localData: {
lastUsedDate: "2025-04-15T12:00:00.000Z",

View File

@@ -292,6 +292,7 @@ export class Cipher extends Domain implements Decryptable<CipherView> {
const domain = new Cipher();
const name = EncString.fromJSON(obj.name);
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 deletedDate = obj.deletedDate == null ? null : new Date(obj.deletedDate);
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, {
name,
notes,
creationDate,
revisionDate,
deletedDate,
attachments,
@@ -341,17 +343,22 @@ export class Cipher extends Domain implements Decryptable<CipherView> {
toSdkCipher(): SdkCipher {
const sdkCipher: SdkCipher = {
id: this.id,
organizationId: this.organizationId,
folderId: this.folderId,
collectionIds: this.collectionIds || [],
organizationId: this.organizationId ?? undefined,
folderId: this.folderId ?? undefined,
collectionIds: this.collectionIds ?? [],
key: this.key?.toJSON(),
name: this.name.toJSON(),
notes: this.notes?.toJSON(),
type: this.type,
favorite: this.favorite,
organizationUseTotp: this.organizationUseTotp,
favorite: this.favorite ?? false,
organizationUseTotp: this.organizationUseTotp ?? false,
edit: this.edit,
permissions: this.permissions,
permissions: this.permissions
? {
delete: this.permissions.delete,
restore: this.permissions.restore,
}
: undefined,
viewPassword: this.viewPassword,
localData: this.localData
? {

View File

@@ -159,7 +159,7 @@ export class Login extends Domain {
password: this.password?.toJSON(),
passwordRevisionDate: this.passwordRevisionDate?.toISOString(),
totp: this.totp?.toJSON(),
autofillOnPageLoad: this.autofillOnPageLoad,
autofillOnPageLoad: this.autofillOnPageLoad ?? undefined,
fido2Credentials: this.fido2Credentials?.map((f) => f.toSdkFido2Credential()),
};
}

View File

@@ -188,6 +188,7 @@ export class CipherView implements View, InitializerMetadata {
}
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 deletedDate = obj.deletedDate == null ? null : new Date(obj.deletedDate);
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));
Object.assign(view, obj, {
creationDate: creationDate,
revisionDate: revisionDate,
deletedDate: deletedDate,
attachments: attachments,

View File

@@ -217,6 +217,7 @@ export class CipherService implements CipherServiceAbstraction {
cipher.organizationId = model.organizationId;
cipher.type = model.type;
cipher.collectionIds = model.collectionIds;
cipher.creationDate = model.creationDate;
cipher.revisionDate = model.revisionDate;
cipher.reprompt = model.reprompt;
cipher.edit = model.edit;