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

Function step2

apps/client/src/code/api-interface/pages/move.ts:187–337  ·  view source on GitHub ↗
(
    input_: (typeof moveProcedureStep1)['_def']['_output_out'],
  )

Source from the content-addressed store, hash-verified

185 }
186
187 async function step2(
188 input_: (typeof moveProcedureStep1)['_def']['_output_out'],
189 ): Promise<(typeof moveProcedureStep2)['_def']['_input_in']> {
190 const sourceGroupId = await internals.realtime.hget(
191 'page',
192 input.pageId,
193 'group-id',
194 );
195
196 const oldPageKeyring = await pageKeyrings()(
197 `${sourceGroupId}:${input.pageId}`,
198 ).getAsync();
199
200 if (oldPageKeyring?.topLayer !== DataLayer.Raw) {
201 throw new Error('Invalid page keyring');
202 }
203
204 const newPageKeyring = createSymmetricKeyring();
205
206 const pageEncryptedSymmetricKeyring = newPageKeyring.wrapSymmetric(
207 destGroupContentKeyring!,
208 {
209 associatedData: {
210 context: 'PageKeyring',
211 pageId: input.pageId,
212 },
213 },
214 ).wrappedValue;
215
216 const pageEncryptedRelativeTitle = newPageKeyring.encrypt(
217 oldPageKeyring.decrypt(input_.pageEncryptedRelativeTitle, {
218 padding: true,
219 associatedData: {
220 context: 'PageRelativeTitle',
221 pageId: input.pageId,
222 },
223 }),
224 {
225 padding: true,
226 associatedData: {
227 context: 'PageRelativeTitle',
228 pageId: input.pageId,
229 },
230 },
231 );
232
233 const pageEncryptedAbsoluteTitle = newPageKeyring.encrypt(
234 oldPageKeyring.decrypt(input_.pageEncryptedAbsoluteTitle, {
235 padding: true,
236 associatedData: {
237 context: 'PageAbsoluteTitle',
238 pageId: input.pageId,
239 },
240 }),
241 {
242 padding: true,
243 associatedData: {
244 context: 'PageAbsoluteTitle',

Callers

nothing calls this directly

Calls 9

createSymmetricKeyringFunction · 0.90
createPageDocFunction · 0.90
objFromEntriesFunction · 0.90
objEntriesFunction · 0.90
wrapSymmetricKeyFunction · 0.90
wrapSymmetricMethod · 0.65
hgetMethod · 0.45
encryptMethod · 0.45
decryptMethod · 0.45

Tested by

no test coverage detected