mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 13:10:17 +00:00
updated localdata sdk type change
This commit is contained in:
@@ -770,6 +770,9 @@ describe("Cipher DTO", () => {
|
||||
|
||||
describe("toSdkCipher", () => {
|
||||
it("should map to SDK Cipher", () => {
|
||||
const lastUsedDate = new Date("2025-04-15T12:00:00.000Z").getTime();
|
||||
const lastLaunched = new Date("2025-04-15T12:00:00.000Z").getTime();
|
||||
|
||||
const cipherData: CipherData = {
|
||||
id: "id",
|
||||
organizationId: "orgId",
|
||||
@@ -838,7 +841,7 @@ describe("Cipher DTO", () => {
|
||||
],
|
||||
};
|
||||
|
||||
const cipher = new Cipher(cipherData);
|
||||
const cipher = new Cipher(cipherData, { lastUsedDate, lastLaunched });
|
||||
const sdkCipher = cipher.toSdkCipher();
|
||||
|
||||
expect(sdkCipher).toEqual({
|
||||
@@ -875,7 +878,10 @@ describe("Cipher DTO", () => {
|
||||
edit: true,
|
||||
permissions: new CipherPermissionsApi(),
|
||||
viewPassword: true,
|
||||
localData: undefined,
|
||||
localData: {
|
||||
lastUsedDate: "2025-04-15T12:00:00.000Z",
|
||||
lastLaunched: "2025-04-15T12:00:00.000Z",
|
||||
},
|
||||
attachments: [
|
||||
{
|
||||
id: "a1",
|
||||
|
||||
@@ -358,7 +358,14 @@ export class Cipher extends Domain implements Decryptable<CipherView> {
|
||||
permissions: this.permissions,
|
||||
viewPassword: this.viewPassword,
|
||||
localData: this.localData
|
||||
? { lastUsedDate: this.localData.lastUsedDate, lastLaunched: this.localData.lastLaunched }
|
||||
? {
|
||||
lastUsedDate: this.localData.lastUsedDate
|
||||
? new Date(this.localData.lastUsedDate).toISOString()
|
||||
: undefined,
|
||||
lastLaunched: this.localData.lastLaunched
|
||||
? new Date(this.localData.lastLaunched).toISOString()
|
||||
: undefined,
|
||||
}
|
||||
: undefined,
|
||||
attachments: this.attachments?.map((a) => a.toSdkAttachment()),
|
||||
fields: this.fields?.map((f) => f.toSdkField()),
|
||||
|
||||
@@ -245,7 +245,16 @@ export class CipherView implements View, InitializerMetadata {
|
||||
cipherView.permissions = CipherPermissionsApi.fromSdkCipherPermissions(obj.permissions);
|
||||
cipherView.edit = obj.edit;
|
||||
cipherView.viewPassword = obj.viewPassword;
|
||||
cipherView.localData = obj.localData;
|
||||
cipherView.localData = obj.localData
|
||||
? {
|
||||
lastUsedDate: obj.localData.lastUsedDate
|
||||
? new Date(obj.localData.lastUsedDate).getTime()
|
||||
: undefined,
|
||||
lastLaunched: obj.localData.lastLaunched
|
||||
? new Date(obj.localData.lastLaunched).getTime()
|
||||
: undefined,
|
||||
}
|
||||
: undefined;
|
||||
cipherView.attachments = obj.attachments?.map((a) => AttachmentView.fromSdkAttachmentView(a));
|
||||
cipherView.fields = obj.fields?.map((f) => FieldView.fromSdkFieldView(f));
|
||||
cipherView.passwordHistory = obj.passwordHistory?.map((ph) =>
|
||||
|
||||
@@ -30,7 +30,7 @@ export class DefaultCipherEncryptionService implements CipherEncryptionService {
|
||||
|
||||
using ref = sdk.take();
|
||||
const sdkCipherView = ref.value.vault().ciphers().decrypt(cipher.toSdkCipher());
|
||||
// The SDK returns a cipherView or throws an error if decryption fails.
|
||||
|
||||
const clientCipherView = CipherView.fromSdkCipherView(sdkCipherView)!;
|
||||
|
||||
// Decrypt Fido2 credentials if available
|
||||
|
||||
Reference in New Issue
Block a user