@fileverse/api 0.0.18 → 0.0.19
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 +3 -25
- package/dist/cli/index.js.map +1 -1
- package/dist/cloudflare.js +9 -76
- package/dist/cloudflare.js.map +1 -1
- package/dist/commands/index.js +0 -9
- package/dist/commands/index.js.map +1 -1
- package/dist/index.js +9 -50
- package/dist/index.js.map +1 -1
- package/dist/worker.js +6 -34
- package/dist/worker.js.map +1 -1
- package/package.json +1 -2
package/dist/cloudflare.js
CHANGED
|
@@ -2154,9 +2154,9 @@ var init_aes = __esm({
|
|
|
2154
2154
|
const nonceLen = EMPTY_BLOCK.slice();
|
|
2155
2155
|
const view = createView(nonceLen);
|
|
2156
2156
|
view.setBigUint64(8, BigInt(nonce.length * 8), false);
|
|
2157
|
-
const
|
|
2158
|
-
|
|
2159
|
-
|
|
2157
|
+
const g = ghash.create(authKey).update(nonce).update(nonceLen);
|
|
2158
|
+
g.digestInto(counter);
|
|
2159
|
+
g.destroy();
|
|
2160
2160
|
}
|
|
2161
2161
|
const tagMask = ctr32(xk, false, counter, EMPTY_BLOCK);
|
|
2162
2162
|
return { xk, authKey, counter, tagMask };
|
|
@@ -2512,46 +2512,6 @@ var init_file_utils = __esm({
|
|
|
2512
2512
|
}
|
|
2513
2513
|
});
|
|
2514
2514
|
|
|
2515
|
-
// src/sdk/dom-globals.ts
|
|
2516
|
-
function captureDOMGlobals() {
|
|
2517
|
-
if (savedGlobals) return;
|
|
2518
|
-
savedGlobals = {};
|
|
2519
|
-
for (const key of DOM_KEYS) {
|
|
2520
|
-
savedGlobals[key] = g[key];
|
|
2521
|
-
}
|
|
2522
|
-
}
|
|
2523
|
-
function removeDOMGlobals() {
|
|
2524
|
-
delete g.window;
|
|
2525
|
-
delete g.document;
|
|
2526
|
-
}
|
|
2527
|
-
function restoreDOMGlobals() {
|
|
2528
|
-
if (!savedGlobals) return;
|
|
2529
|
-
Object.assign(g, savedGlobals);
|
|
2530
|
-
}
|
|
2531
|
-
var DOM_KEYS, g, savedGlobals;
|
|
2532
|
-
var init_dom_globals = __esm({
|
|
2533
|
-
"src/sdk/dom-globals.ts"() {
|
|
2534
|
-
"use strict";
|
|
2535
|
-
init_esm_shims();
|
|
2536
|
-
DOM_KEYS = [
|
|
2537
|
-
"window",
|
|
2538
|
-
"document",
|
|
2539
|
-
"navigator",
|
|
2540
|
-
"Node",
|
|
2541
|
-
"HTMLElement",
|
|
2542
|
-
"Text",
|
|
2543
|
-
"DOMParser",
|
|
2544
|
-
"Element",
|
|
2545
|
-
"DocumentFragment",
|
|
2546
|
-
"getComputedStyle",
|
|
2547
|
-
"MutationObserver",
|
|
2548
|
-
"Range"
|
|
2549
|
-
];
|
|
2550
|
-
g = globalThis;
|
|
2551
|
-
savedGlobals = null;
|
|
2552
|
-
}
|
|
2553
|
-
});
|
|
2554
|
-
|
|
2555
2515
|
// src/sdk/file-manager.ts
|
|
2556
2516
|
import { fromUint8Array as fromUint8Array2, toUint8Array as toUint8Array3 } from "js-base64";
|
|
2557
2517
|
import { generateAESKey, exportAESKey } from "@fileverse/crypto/webcrypto";
|
|
@@ -2564,7 +2524,6 @@ var init_file_manager = __esm({
|
|
|
2564
2524
|
init_file_utils();
|
|
2565
2525
|
init_constants();
|
|
2566
2526
|
init_constants2();
|
|
2567
|
-
init_dom_globals();
|
|
2568
2527
|
init_infra();
|
|
2569
2528
|
FileManager = class {
|
|
2570
2529
|
keyStore;
|
|
@@ -2573,14 +2532,6 @@ var init_file_manager = __esm({
|
|
|
2573
2532
|
this.keyStore = keyStore;
|
|
2574
2533
|
this.agentClient = agentClient;
|
|
2575
2534
|
}
|
|
2576
|
-
convertMarkdown(content) {
|
|
2577
|
-
restoreDOMGlobals();
|
|
2578
|
-
try {
|
|
2579
|
-
return markdownToYjs(content);
|
|
2580
|
-
} finally {
|
|
2581
|
-
removeDOMGlobals();
|
|
2582
|
-
}
|
|
2583
|
-
}
|
|
2584
2535
|
createLocks(key, encryptedSecretKey, commentKey) {
|
|
2585
2536
|
const appLock = {
|
|
2586
2537
|
lockedFileKey: this.keyStore.encryptData(toUint8Array3(key)),
|
|
@@ -2624,7 +2575,7 @@ var init_file_manager = __esm({
|
|
|
2624
2575
|
const nonce = toUint8Array3(file2.linkKeyNonce);
|
|
2625
2576
|
const secretKey = toUint8Array3(file2.secretKey);
|
|
2626
2577
|
console.log("Got encrypted secret key, nonce, and secret key");
|
|
2627
|
-
const yJSContent =
|
|
2578
|
+
const yJSContent = markdownToYjs(file2.content);
|
|
2628
2579
|
console.log("Generated yjs content");
|
|
2629
2580
|
const { encryptedFile, key } = await createEncryptedContentFile(yJSContent);
|
|
2630
2581
|
console.log("Generated encrypted content file");
|
|
@@ -2684,7 +2635,7 @@ var init_file_manager = __esm({
|
|
|
2684
2635
|
const encryptedSecretKey = file2.linkKey;
|
|
2685
2636
|
const nonce = toUint8Array3(file2.linkKeyNonce);
|
|
2686
2637
|
const secretKey = toUint8Array3(file2.secretKey);
|
|
2687
|
-
const yjsContent =
|
|
2638
|
+
const yjsContent = markdownToYjs(file2.content);
|
|
2688
2639
|
const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
|
|
2689
2640
|
const commentKey = toUint8Array3(file2.commentKey);
|
|
2690
2641
|
const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
|
|
@@ -2733,7 +2684,7 @@ var init_file_manager = __esm({
|
|
|
2733
2684
|
const nonce = toUint8Array3(file2.linkKeyNonce);
|
|
2734
2685
|
const secretKey = toUint8Array3(file2.secretKey);
|
|
2735
2686
|
logger.debug(`Generating encrypted content file for file ${file2.ddocId} with onChainFileId ${file2.onChainFileId}`);
|
|
2736
|
-
const yjsContent =
|
|
2687
|
+
const yjsContent = markdownToYjs(file2.content);
|
|
2737
2688
|
const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
|
|
2738
2689
|
const commentKey = toUint8Array3(file2.commentKey);
|
|
2739
2690
|
const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
|
|
@@ -4132,30 +4083,17 @@ init_esm_shims();
|
|
|
4132
4083
|
// src/cli/fetch-api-key.ts
|
|
4133
4084
|
init_esm_shims();
|
|
4134
4085
|
init_constants();
|
|
4135
|
-
import axios from "axios";
|
|
4136
4086
|
import { toUint8Array as toUint8Array6 } from "js-base64";
|
|
4137
4087
|
import { sha256 } from "viem";
|
|
4138
4088
|
var fetchApiKeyData = async (apiKey) => {
|
|
4139
4089
|
try {
|
|
4140
4090
|
const keyHash = sha256(toUint8Array6(apiKey));
|
|
4141
4091
|
const fullUrl = BASE_CONFIG.API_URL + `api-access/${keyHash}`;
|
|
4142
|
-
const response = await
|
|
4143
|
-
const { encryptedKeyMaterial, encryptedAppMaterial, id } = response.
|
|
4092
|
+
const response = await fetch(fullUrl);
|
|
4093
|
+
const { encryptedKeyMaterial, encryptedAppMaterial, id } = await response.json();
|
|
4144
4094
|
return { encryptedKeyMaterial, encryptedAppMaterial, id };
|
|
4145
4095
|
} catch (error48) {
|
|
4146
|
-
|
|
4147
|
-
if (error48.response?.status === 401) {
|
|
4148
|
-
throw new Error("Invalid API key");
|
|
4149
|
-
}
|
|
4150
|
-
if (error48.response?.status === 404) {
|
|
4151
|
-
throw new Error("API key not found");
|
|
4152
|
-
}
|
|
4153
|
-
if (error48.code === "ECONNREFUSED") {
|
|
4154
|
-
throw new Error(`Cannot connect to server at ${BASE_CONFIG.API_URL}`);
|
|
4155
|
-
}
|
|
4156
|
-
throw new Error(`Server error: ${error48.response?.data?.message || error48.message}`);
|
|
4157
|
-
}
|
|
4158
|
-
throw error48;
|
|
4096
|
+
throw new Error(`Server error: ${error48.message}`);
|
|
4159
4097
|
}
|
|
4160
4098
|
};
|
|
4161
4099
|
|
|
@@ -18299,11 +18237,6 @@ function createMcpServer(config3) {
|
|
|
18299
18237
|
registerTools(server, client);
|
|
18300
18238
|
return server;
|
|
18301
18239
|
}
|
|
18302
|
-
|
|
18303
|
-
// src/cloudflare.ts
|
|
18304
|
-
init_dom_globals();
|
|
18305
|
-
captureDOMGlobals();
|
|
18306
|
-
removeDOMGlobals();
|
|
18307
18240
|
export {
|
|
18308
18241
|
ApiKeysModel,
|
|
18309
18242
|
EventsModel,
|