1 import { ARGON2_PARAMS, CryptoProxy } from '@proton/crypto';
2 import { uint8ArrayToBase64String } from '@proton/shared/lib/helpers/encoding';
4 import { captureMessage } from '../helpers/sentry';
6 export interface OfflineKey {
11 export const getOfflineKey = (password: string, salt: Uint8Array) => {
12 return CryptoProxy.computeArgon2({
13 params: ARGON2_PARAMS.RECOMMENDED,
19 export const generateOfflineKey = async (clearKeyPassword: string): Promise<OfflineKey | undefined> => {
21 const salt = crypto.getRandomValues(new Uint8Array(32));
22 const key = await getOfflineKey(clearKeyPassword, salt);
24 password: uint8ArrayToBase64String(key),
25 salt: uint8ArrayToBase64String(salt),
28 captureMessage('Argon2 error', { level: 'info', extra: { message: e.message } });