(input: {
password: string | Uint8Array;
salt: Uint8Array;
})
| 15 | const moduleLogger = mainLogger.sub('crypto.client.ts'); |
| 16 | |
| 17 | export async function derivePasswordValues(input: { |
| 18 | password: string | Uint8Array; |
| 19 | salt: Uint8Array; |
| 20 | }) { |
| 21 | moduleLogger.info('Started key derivation'); |
| 22 | |
| 23 | const derivedKey = ( |
| 24 | await (globalThis as any).argon2.hash({ |
| 25 | pass: input.password, |
| 26 | salt: input.salt, |
| 27 | |
| 28 | hashLen: 32 + 64, |
| 29 | |
| 30 | time: 8, |
| 31 | mem: 32 * 1024, |
| 32 | parallelism: 1, |
| 33 | |
| 34 | type: (globalThis as any).argon2.ArgonType.Argon2id, |
| 35 | }) |
| 36 | ).hash as Uint8Array; |
| 37 | |
| 38 | moduleLogger.info('Finished key derivation'); |
| 39 | |
| 40 | return { |
| 41 | key: wrapSymmetricKey(derivedKey.slice(0, 32)), |
| 42 | hash: derivedKey.slice(32), |
| 43 | }; |
| 44 | } |
| 45 | |
| 46 | export async function deriveUserValues(input: { |
| 47 | email: string; |
no test coverage detected