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

Function getRegistrationValues

apps/client/src/code/auth/register.ts:14–127  ·  view source on GitHub ↗
(input: {
  derivedUserValues: Awaited<ReturnType<typeof deriveUserValues>>;
  userName: string;
})

Source from the content-addressed store, hash-verified

12} from 'src/code/pages/serialization';
13
14export async function getRegistrationValues(input: {
15 derivedUserValues: Awaited<ReturnType<typeof deriveUserValues>>;
16 userName: string;
17}): Promise<UserRegistrationSchema> {
18 const userId = nanoid();
19 const pageId = nanoid();
20
21 const randomUserKeys = generateRandomUserKeys(
22 userId,
23 input.derivedUserValues.masterKey,
24 );
25 const groupValues = await generateGroupValues({
26 userKeyPair: randomUserKeys.keyPair,
27 isPublic: false,
28 });
29 const pageKeyring = createSymmetricKeyring();
30
31 return {
32 userId,
33 groupId: groupValues.groupId,
34 pageId,
35
36 userPublicKeyring: (randomUserKeys.keyPair.publicKey as Keyring)
37 .wrappedValue,
38 userEncryptedPrivateKeyring:
39 randomUserKeys.encryptedPrivateKeyring.wrappedValue,
40
41 userEncryptedSymmetricKeyring:
42 randomUserKeys.encryptedSymmetricKeyring.wrappedValue,
43
44 userEncryptedName: randomUserKeys.symmetricKeyring.encrypt(
45 textToBytes(input.userName),
46 {
47 padding: true,
48 associatedData: {
49 context: 'UserName',
50 userId,
51 },
52 },
53 ),
54
55 userEncryptedDefaultNote: randomUserKeys.symmetricKeyring.encrypt(
56 pack({
57 root: { noteIdxs: [0] },
58 notes: [
59 {
60 anchor: {
61 y: 0,
62 },
63 },
64 ],
65 } as ISerialObjectInput),
66 {
67 padding: true,
68 associatedData: {
69 context: 'UserDefaultNote',
70 userId,
71 },

Callers 1

enterDemoFunction · 0.90

Calls 5

generateRandomUserKeysFunction · 0.90
generateGroupValuesFunction · 0.90
createSymmetricKeyringFunction · 0.90
textToBytesFunction · 0.90
encryptMethod · 0.45

Tested by

no test coverage detected