1 import { updatePrivateKeyRoute } from '@proton/shared/lib/api/keys';
2 import type { Api, DecryptedKey, User } from '@proton/shared/lib/interfaces';
3 import { getUpdateKeysPayload } from '@proton/shared/lib/keys/changePassword';
4 import type { DeviceSecretData } from '@proton/shared/lib/keys/device';
5 import { encryptAuthDeviceSecret } from '@proton/shared/lib/keys/device';
6 import { generateKeySaltAndPassphrase } from '@proton/shared/lib/keys/keys';
7 import { srpVerify } from '@proton/shared/lib/srp';
9 export const changeSSOUserKeysPasswordHelper = async ({
17 userKeys: DecryptedKey[];
18 deviceSecretData: DeviceSecretData;
19 newBackupPassword: string;
21 const { passphrase: keyPassword, salt: keySalt } = await generateKeySaltAndPassphrase(newBackupPassword);
23 const updateKeysPayload = await getUpdateKeysPayload({
24 addressesKeys: [], // Assuming always migrated keys
26 organizationKey: undefined,
29 forceMigratedAddressKeys: true,
32 const encryptedSecret = await encryptAuthDeviceSecret({
40 password: newBackupPassword,
42 config: updatePrivateKeyRoute({ ...updateKeysPayload, EncryptedSecret: encryptedSecret }),
45 return { keyPassword, encryptedSecret };