(input: {
email: string;
password: string;
})
| 44 | } |
| 45 | |
| 46 | export async function deriveUserValues(input: { |
| 47 | email: string; |
| 48 | password: string; |
| 49 | }) { |
| 50 | const emailHash = sodium.crypto_generichash( |
| 51 | sodium.crypto_pwhash_SALTBYTES, |
| 52 | (process.env.EMAIL_CASE_SENSITIVITY_EXCEPTIONS ?? '') |
| 53 | .split(';') |
| 54 | .includes(input.email) |
| 55 | ? input.email |
| 56 | : input.email.toLowerCase(), |
| 57 | ); |
| 58 | |
| 59 | const passwordValues = await derivePasswordValues({ |
| 60 | password: input.password, |
| 61 | salt: emailHash, |
| 62 | }); |
| 63 | |
| 64 | return { |
| 65 | masterKey: passwordValues.key, |
| 66 | loginHash: passwordValues.hash, |
| 67 | }; |
| 68 | } |
| 69 | export function generateRandomUserKeys( |
| 70 | userId: string, |
| 71 | masterKey: SymmetricKey, |
no test coverage detected