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

Function rotateGroupKeys

apps/app-server/src/utils/group-key-rotation.ts:166–249  ·  view source on GitHub ↗
(
  input: {
    groupId: string;

    dtrx?: DataTransaction;
  } & GroupKeyRotationValues,
)

Source from the content-addressed store, hash-verified

164}
165
166export async function rotateGroupKeys(
167 input: {
168 groupId: string;
169
170 dtrx?: DataTransaction;
171 } & GroupKeyRotationValues,
172) {
173 await dataAbstraction().patch(
174 'group',
175 input.groupId,
176 {
177 access_keyring:
178 input.groupAccessKeyring != null ? input.groupAccessKeyring : null,
179
180 encrypted_name: input.groupEncryptedName,
181 encrypted_content_keyring: input.groupEncryptedContentKeyring,
182
183 public_keyring: input.groupPublicKeyring,
184 encrypted_private_keyring: input.groupEncryptedPrivateKeyring,
185 },
186 { dtrx: input.dtrx },
187 );
188
189 for (const [userId, groupMember] of Object.entries(input.groupMembers)) {
190 await dataAbstraction().patch(
191 'group-member',
192 `${input.groupId}:${userId}`,
193 {
194 encrypted_access_keyring:
195 groupMember.encryptedAccessKeyring != null
196 ? groupMember.encryptedAccessKeyring
197 : null,
198 encrypted_internal_keyring: groupMember.encryptedInternalKeyring,
199
200 encrypted_name: groupMember.encryptedName,
201 },
202 { dtrx: input.dtrx },
203 );
204 }
205
206 for (const [userId, groupJoinInvitation] of Object.entries(
207 input.groupJoinInvitations,
208 )) {
209 await dataAbstraction().patch(
210 'group-join-invitation',
211 `${input.groupId}:${userId}`,
212 {
213 encrypted_access_keyring:
214 groupJoinInvitation.encryptedAccessKeyring != null
215 ? groupJoinInvitation.encryptedAccessKeyring
216 : null,
217 encrypted_internal_keyring:
218 groupJoinInvitation.encryptedInternalKeyring,
219
220 encrypted_name: groupJoinInvitation.encryptedName,
221 },
222 { dtrx: input.dtrx },
223 );

Callers 2

rotateKeysStep2Function · 0.90
makePrivateStep2Function · 0.90

Calls 1

patchMethod · 0.80

Tested by

no test coverage detected