mirror of
https://github.com/bitwarden/browser
synced 2026-02-08 12:40:26 +00:00
Add comments and add backward compatibilty for sync
This commit is contained in:
@@ -19,8 +19,10 @@ export class ProfileResponse extends BaseResponse {
|
||||
key: string;
|
||||
avatarColor: string;
|
||||
creationDate: string;
|
||||
// Cleanup: Can be removed after moving to accountKeys
|
||||
privateKey: string;
|
||||
accountKeys: PrivateAccountKeysResponseModel;
|
||||
// Cleanup: This should be non-optional after the server has been released for a while https://bitwarden.atlassian.net/browse/PM-21768
|
||||
accountKeys: PrivateAccountKeysResponseModel | null;
|
||||
securityStamp: string;
|
||||
forcePasswordReset: boolean;
|
||||
usesKeyConnector: boolean;
|
||||
@@ -40,7 +42,12 @@ export class ProfileResponse extends BaseResponse {
|
||||
this.culture = this.getResponseProperty("Culture");
|
||||
this.twoFactorEnabled = this.getResponseProperty("TwoFactorEnabled");
|
||||
this.key = this.getResponseProperty("Key");
|
||||
this.accountKeys = new PrivateAccountKeysResponseModel(this.getResponseProperty("AccountKeys"));
|
||||
// Cleanup: This should be non-optional after the server has been released for a while https://bitwarden.atlassian.net/browse/PM-21768
|
||||
if (this.getResponseProperty("AccountKeys") != null) {
|
||||
this.accountKeys = new PrivateAccountKeysResponseModel(
|
||||
this.getResponseProperty("AccountKeys"),
|
||||
);
|
||||
}
|
||||
this.avatarColor = this.getResponseProperty("AvatarColor");
|
||||
this.creationDate = this.getResponseProperty("CreationDate");
|
||||
this.privateKey = this.getResponseProperty("PrivateKey");
|
||||
|
||||
@@ -195,15 +195,20 @@ export class DefaultSyncService extends CoreSyncService {
|
||||
|
||||
/// Key management initialization
|
||||
await this.keyService.setMasterKeyEncryptedUserKey(response.key, response.id);
|
||||
await this.keyService.setPrivateKey(
|
||||
response.accountKeys.AsymmetricEncryptionKeys.wrappedPrivateKey.encryptedString!,
|
||||
response.id,
|
||||
);
|
||||
if (response.accountKeys.SigningKeys !== null) {
|
||||
await this.keyService.setUserSigningKey(
|
||||
response.accountKeys.SigningKeys.wrappedSigningKey,
|
||||
// Cleanup: Only the first branch should be kept after the server always returns accountKeys https://bitwarden.atlassian.net/browse/PM-21768
|
||||
if (response.accountKeys != null) {
|
||||
await this.keyService.setPrivateKey(
|
||||
response.accountKeys.AsymmetricEncryptionKeys.wrappedPrivateKey.encryptedString!,
|
||||
response.id,
|
||||
);
|
||||
if (response.accountKeys.SigningKeys !== null) {
|
||||
await this.keyService.setUserSigningKey(
|
||||
response.accountKeys.SigningKeys.wrappedSigningKey,
|
||||
response.id,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
await this.keyService.setPrivateKey(response.privateKey, response.id);
|
||||
}
|
||||
await this.keyService.setProviderKeys(response.providers, response.id);
|
||||
await this.keyService.setOrgKeys(
|
||||
|
||||
Reference in New Issue
Block a user