Skip to content

Commit

Permalink
[PM-3120] fix: device key not being saved properly
Browse files Browse the repository at this point in the history
  • Loading branch information
coroiu committed Jul 24, 2023
1 parent f2298c1 commit 64fa810
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions libs/common/src/platform/models/domain/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Utils } from "../../misc/utils";
import { ServerConfigData } from "../../models/data/server-config.data";

import { EncryptedString, EncString } from "./enc-string";
import { DeviceKey, MasterKey, SymmetricCryptoKey, UserKey } from "./symmetric-crypto-key";
import { MasterKey, SymmetricCryptoKey, UserKey } from "./symmetric-crypto-key";

export class EncryptionPair<TEncrypted, TDecrypted> {
encrypted?: TEncrypted;
Expand Down Expand Up @@ -107,7 +107,7 @@ export class AccountKeys {
userKeyMasterKey?: string;
userKeyAuto?: string;
userKeyBiometric?: string;
deviceKey?: DeviceKey;
deviceKey?: ReturnType<SymmetricCryptoKey["toJSON"]>;
organizationKeys?: EncryptionPair<
{ [orgId: string]: EncryptedOrganizationKeyData },
Record<string, SymmetricCryptoKey>
Expand Down Expand Up @@ -149,7 +149,7 @@ export class AccountKeys {
return Object.assign(new AccountKeys(), {
userKey: SymmetricCryptoKey.fromJSON(obj?.userKey),
masterKey: SymmetricCryptoKey.fromJSON(obj?.masterKey),
deviceKey: SymmetricCryptoKey.fromJSON(obj?.deviceKey),
deviceKey: obj?.deviceKey,
cryptoMasterKey: SymmetricCryptoKey.fromJSON(obj?.cryptoMasterKey),
cryptoSymmetricKey: EncryptionPair.fromJSON(
obj?.cryptoSymmetricKey,
Expand Down
2 changes: 1 addition & 1 deletion libs/common/src/platform/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ export class StateService<

const account = await this.getAccount(options);

account.keys.deviceKey = value;
account.keys.deviceKey = value.toJSON();

await this.saveAccount(account, options);
}
Expand Down

0 comments on commit 64fa810

Please sign in to comment.