MCPcopy Index your code
hub / github.com/DeepNotesApp/DeepNotes / registerUser

Function registerUser

apps/app-server/src/utils/users.ts:51–174  ·  view source on GitHub ↗
(
  input: {
    ip: string;
    userAgent: string;

    demo?: boolean;

    email: string;

    passwordValues: PasswordValues;

    dtrx?: DataTransaction;
  } & UserRegistrationSchema,
)

Source from the content-addressed store, hash-verified

49>;
50
51export async function registerUser(
52 input: {
53 ip: string;
54 userAgent: string;
55
56 demo?: boolean;
57
58 email: string;
59
60 passwordValues: PasswordValues;
61
62 dtrx?: DataTransaction;
63 } & UserRegistrationSchema,
64) {
65 const emailVerificationCode = nanoid();
66
67 await UserModel.query(input.dtrx?.trx)
68 .where('email_hash', Buffer.from(hashUserEmail(input.email)))
69 .delete();
70
71 const userModel = {
72 id: input.userId,
73
74 encrypted_email: encryptUserEmail(input.email),
75 email_hash: hashUserEmail(input.email),
76
77 encrypted_rehashed_login_hash: input.demo
78 ? new Uint8Array()
79 : encryptUserRehashedLoginHash(
80 encodePasswordHash(
81 input.passwordValues.hash,
82 input.passwordValues.salt,
83 2,
84 32,
85 ),
86 ),
87
88 demo: !!input.demo,
89
90 email_verified: false,
91 ...(!input.demo
92 ? {
93 encrypted_new_email: encryptUserEmail(input.email),
94 email_verification_code: emailVerificationCode,
95 email_verification_expiration_date: addHours(new Date(), 1),
96 }
97 : {}),
98
99 personal_group_id: input.groupId,
100
101 starting_page_id: input.pageId,
102 recent_page_ids: [input.pageId],
103 recent_group_ids: [input.groupId],
104
105 public_keyring: input.userPublicKeyring,
106 encrypted_private_keyring: createPrivateKeyring(
107 input.userEncryptedPrivateKeyring,
108 ).wrapSymmetric(input.passwordValues.key, {

Callers 2

registerFunction · 0.90
startDemoFunction · 0.90

Calls 11

hashUserEmailFunction · 0.90
encryptUserEmailFunction · 0.90
encodePasswordHashFunction · 0.90
addHoursFunction · 0.90
createPrivateKeyringFunction · 0.90
createSymmetricKeyringFunction · 0.90
createGroupFunction · 0.90
insertMethod · 0.80
wrapSymmetricMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected