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

Function createNotifications

apps/client/src/code/pages/utils.ts:83–206  ·  view source on GitHub ↗
(input: {
  recipients: Record<string, { publicKeyring: Uint8Array }>;

  patientId?: string;

  notifications: {
    agent?: object;
    target?: object;
    observers?: object;
  };
})

Source from the content-addressed store, hash-verified

81}
82
83export async function createNotifications(input: {
84 recipients: Record<string, { publicKeyring: Uint8Array }>;
85
86 patientId?: string;
87
88 notifications: {
89 agent?: object;
90 target?: object;
91 observers?: object;
92 };
93}): Promise<
94 {
95 recipients: Record<string, { encryptedSymmetricKey: Uint8Array }>;
96 encryptedContent: Uint8Array;
97 }[]
98> {
99 const agentId = authStore().userId;
100
101 const agentSymmetricKey = wrapSymmetricKey();
102 const targetSymmetricKey = wrapSymmetricKey();
103 const observersSymmetricKey = wrapSymmetricKey();
104
105 return [
106 // Agent
107
108 ...(input.notifications.agent != null
109 ? [
110 {
111 recipients: {
112 [agentId]: {
113 encryptedSymmetricKey: internals.keyPair.encrypt(
114 agentSymmetricKey.value,
115 internals.keyPair.publicKey,
116 ),
117 },
118 },
119
120 encryptedContent: agentSymmetricKey.encrypt(
121 pack({
122 ...input.notifications.agent,
123
124 recipientType: 'agent',
125 }),
126 {
127 padding: true,
128 associatedData: { context: 'UserNotificationContent' },
129 },
130 ),
131 },
132 ]
133 : []),
134
135 // Target
136
137 ...(input.notifications.target != null &&
138 input.patientId != null &&
139 input.recipients[input.patientId] != null
140 ? [

Callers 10

step2Function · 0.90
step2Function · 0.90
step2Function · 0.90
step2Function · 0.90
step2Function · 0.90
step2Function · 0.90
step2Function · 0.90
step2Function · 0.90
step2Function · 0.90
step2Function · 0.90

Calls 5

wrapSymmetricKeyFunction · 0.90
createKeyringFunction · 0.90
objFromEntriesFunction · 0.90
objEntriesFunction · 0.90
encryptMethod · 0.45

Tested by

no test coverage detected