@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.
- package/dist/cli/index.js.map +1 -1
- package/dist/cloudflare.js +21 -0
- package/dist/cloudflare.js.map +1 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/worker.js +17 -0
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
package/dist/worker.js
CHANGED
|
@@ -2675,20 +2675,28 @@ var init_file_manager = __esm({
|
|
|
2675
2675
|
return this.agentClient.getAuthParams();
|
|
2676
2676
|
}
|
|
2677
2677
|
async submitAddFileTrx(file) {
|
|
2678
|
+
console.log("Submitting add file trx");
|
|
2678
2679
|
logger.debug(`Preparing to add file ${file.ddocId}`);
|
|
2679
2680
|
const encryptedSecretKey = file.linkKey;
|
|
2680
2681
|
const nonce = toUint8Array2(file.linkKeyNonce);
|
|
2681
2682
|
const secretKey = toUint8Array2(file.secretKey);
|
|
2683
|
+
console.log("Got encrypted secret key, nonce, and secret key");
|
|
2682
2684
|
const yJSContent = markdownToYjs(file.content);
|
|
2685
|
+
console.log("Generated yjs content");
|
|
2683
2686
|
const { encryptedFile, key } = await createEncryptedContentFile(yJSContent);
|
|
2687
|
+
console.log("Generated encrypted content file");
|
|
2684
2688
|
logger.debug(`Generated encrypted content file for file ${file.ddocId}`);
|
|
2685
2689
|
const commentKey = await exportAESKey(await generateAESKey(128));
|
|
2690
|
+
console.log("Generated comment key");
|
|
2686
2691
|
const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
|
|
2692
|
+
console.log("Built app lock and owner lock");
|
|
2687
2693
|
const linkLock = buildLinklock(secretKey, toUint8Array2(key), commentKey);
|
|
2694
|
+
console.log("Built link lock");
|
|
2688
2695
|
const encryptedTitle = await encryptTitleWithFileKey({
|
|
2689
2696
|
title: file.title || "Untitled",
|
|
2690
2697
|
key
|
|
2691
2698
|
});
|
|
2699
|
+
console.log("Built encrypted title");
|
|
2692
2700
|
const metadata = buildFileMetadata({
|
|
2693
2701
|
encryptedTitle,
|
|
2694
2702
|
encryptedFileSize: encryptedFile.size,
|
|
@@ -2698,11 +2706,15 @@ var init_file_manager = __esm({
|
|
|
2698
2706
|
nonce: fromUint8Array2(nonce),
|
|
2699
2707
|
owner: this.agentClient.getAgentAddress()
|
|
2700
2708
|
});
|
|
2709
|
+
console.log("Built metadata");
|
|
2701
2710
|
const authParams = await this.getAuthParams();
|
|
2711
|
+
console.log("Got auth params");
|
|
2712
|
+
console.log("Uploading files to IPFS");
|
|
2702
2713
|
const { metadataHash, contentHash, gateHash } = await uploadAllFilesToIPFS(
|
|
2703
2714
|
{ metadata, encryptedFile, linkLock, ddocId: file.ddocId },
|
|
2704
2715
|
authParams
|
|
2705
2716
|
);
|
|
2717
|
+
console.log("Uploaded files to IPFS");
|
|
2706
2718
|
logger.debug(`Uploaded files to IPFS for file ${file.ddocId}`);
|
|
2707
2719
|
const callData = prepareCallData({
|
|
2708
2720
|
metadataHash,
|
|
@@ -2711,8 +2723,10 @@ var init_file_manager = __esm({
|
|
|
2711
2723
|
appFileId: file.ddocId,
|
|
2712
2724
|
fileId: file.fileId
|
|
2713
2725
|
});
|
|
2726
|
+
console.log("Prepared call data");
|
|
2714
2727
|
logger.debug(`Prepared call data for file ${file.ddocId}`);
|
|
2715
2728
|
const userOpHash = await this.sendFileOperation(callData);
|
|
2729
|
+
console.log("Submitted user op");
|
|
2716
2730
|
logger.debug(`Submitted user op for file ${file.ddocId}`);
|
|
2717
2731
|
return {
|
|
2718
2732
|
userOpHash,
|
|
@@ -2912,14 +2926,17 @@ var init_publish = __esm({
|
|
|
2912
2926
|
};
|
|
2913
2927
|
handleNewFileOp = async (fileId) => {
|
|
2914
2928
|
const { file, portalDetails, apiKey } = await getPortalData(fileId);
|
|
2929
|
+
console.log("Got portal data");
|
|
2915
2930
|
const apiKeySeed = toUint8Array3(apiKey);
|
|
2916
2931
|
const { privateAccountKey, ucanSecret } = deriveCollaboratorKeys(apiKeySeed);
|
|
2932
|
+
console.log("Derived collaborator keys");
|
|
2917
2933
|
const fileManager = await createFileManager(
|
|
2918
2934
|
portalDetails.portalSeed,
|
|
2919
2935
|
portalDetails.portalAddress,
|
|
2920
2936
|
ucanSecret,
|
|
2921
2937
|
privateAccountKey
|
|
2922
2938
|
);
|
|
2939
|
+
console.log("Created file manager");
|
|
2923
2940
|
return fileManager.submitAddFileTrx(file);
|
|
2924
2941
|
};
|
|
2925
2942
|
getProxyAuthParams = async (fileId) => {
|