@fileverse/api 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2488,20 +2488,28 @@ var init_file_manager = __esm({
2488
2488
  return this.agentClient.getAuthParams();
2489
2489
  }
2490
2490
  async submitAddFileTrx(file2) {
2491
+ console.log("Submitting add file trx");
2491
2492
  logger.debug(`Preparing to add file ${file2.ddocId}`);
2492
2493
  const encryptedSecretKey = file2.linkKey;
2493
2494
  const nonce = toUint8Array2(file2.linkKeyNonce);
2494
2495
  const secretKey = toUint8Array2(file2.secretKey);
2496
+ console.log("Got encrypted secret key, nonce, and secret key");
2495
2497
  const yJSContent = markdownToYjs(file2.content);
2498
+ console.log("Generated yjs content");
2496
2499
  const { encryptedFile, key } = await createEncryptedContentFile(yJSContent);
2500
+ console.log("Generated encrypted content file");
2497
2501
  logger.debug(`Generated encrypted content file for file ${file2.ddocId}`);
2498
2502
  const commentKey = await exportAESKey(await generateAESKey(128));
2503
+ console.log("Generated comment key");
2499
2504
  const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
2505
+ console.log("Built app lock and owner lock");
2500
2506
  const linkLock = buildLinklock(secretKey, toUint8Array2(key), commentKey);
2507
+ console.log("Built link lock");
2501
2508
  const encryptedTitle = await encryptTitleWithFileKey({
2502
2509
  title: file2.title || "Untitled",
2503
2510
  key
2504
2511
  });
2512
+ console.log("Built encrypted title");
2505
2513
  const metadata = buildFileMetadata({
2506
2514
  encryptedTitle,
2507
2515
  encryptedFileSize: encryptedFile.size,
@@ -2511,11 +2519,15 @@ var init_file_manager = __esm({
2511
2519
  nonce: fromUint8Array2(nonce),
2512
2520
  owner: this.agentClient.getAgentAddress()
2513
2521
  });
2522
+ console.log("Built metadata");
2514
2523
  const authParams = await this.getAuthParams();
2524
+ console.log("Got auth params");
2525
+ console.log("Uploading files to IPFS");
2515
2526
  const { metadataHash, contentHash, gateHash } = await uploadAllFilesToIPFS(
2516
2527
  { metadata, encryptedFile, linkLock, ddocId: file2.ddocId },
2517
2528
  authParams
2518
2529
  );
2530
+ console.log("Uploaded files to IPFS");
2519
2531
  logger.debug(`Uploaded files to IPFS for file ${file2.ddocId}`);
2520
2532
  const callData = prepareCallData({
2521
2533
  metadataHash,
@@ -2524,8 +2536,10 @@ var init_file_manager = __esm({
2524
2536
  appFileId: file2.ddocId,
2525
2537
  fileId: file2.fileId
2526
2538
  });
2539
+ console.log("Prepared call data");
2527
2540
  logger.debug(`Prepared call data for file ${file2.ddocId}`);
2528
2541
  const userOpHash = await this.sendFileOperation(callData);
2542
+ console.log("Submitted user op");
2529
2543
  logger.debug(`Submitted user op for file ${file2.ddocId}`);
2530
2544
  return {
2531
2545
  userOpHash,
@@ -2725,14 +2739,17 @@ var init_publish = __esm({
2725
2739
  };
2726
2740
  handleNewFileOp = async (fileId) => {
2727
2741
  const { file: file2, portalDetails, apiKey } = await getPortalData(fileId);
2742
+ console.log("Got portal data");
2728
2743
  const apiKeySeed = toUint8Array3(apiKey);
2729
2744
  const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
2745
+ console.log("Derived collaborator keys");
2730
2746
  const fileManager = await createFileManager(
2731
2747
  portalDetails.portalSeed,
2732
2748
  portalDetails.portalAddress,
2733
2749
  ucanSecret,
2734
2750
  privateAccountKey
2735
2751
  );
2752
+ console.log("Created file manager");
2736
2753
  return fileManager.submitAddFileTrx(file2);
2737
2754
  };
2738
2755
  getProxyAuthParams = async (fileId) => {
@@ -2930,13 +2947,17 @@ var init_eventProcessor = __esm({
2930
2947
  const { fileId, type } = event;
2931
2948
  switch (type) {
2932
2949
  case "create": {
2950
+ console.log("Starting create event submission");
2933
2951
  const file2 = await FilesModel.findByIdIncludingDeleted(fileId);
2952
+ console.log("File found");
2934
2953
  if (!file2) throw new Error(`File ${fileId} not found`);
2935
2954
  if (file2.isDeleted === 1) {
2936
2955
  logger.info(`File ${fileId} is deleted, skipping create submit`);
2937
2956
  return;
2938
2957
  }
2958
+ console.log("Submitting new file op");
2939
2959
  const result = await handleNewFileOp(fileId);
2960
+ console.log("New file op submitted");
2940
2961
  await EventsModel.setEventPendingOp(event._id, result.userOpHash, {
2941
2962
  linkKey: result.linkKey,
2942
2963
  linkKeyNonce: result.linkKeyNonce,