MCPcopy Create free account
hub / github.com/DeepNotesApp/DeepNotes / deriveUserValues

Function deriveUserValues

apps/client/src/code/crypto.ts:46–68  ·  view source on GitHub ↗
(input: {
  email: string;
  password: string;
})

Source from the content-addressed store, hash-verified

44}
45
46export 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}
69export function generateRandomUserKeys(
70 userId: string,
71 masterKey: SymmetricKey,

Callers 5

rotateUserKeysFunction · 0.90
deleteAccountFunction · 0.90
changePasswordFunction · 0.90
step2Function · 0.90
step2Function · 0.90

Calls 1

derivePasswordValuesFunction · 0.70

Tested by

no test coverage detected