@fileverse/api 0.0.18 → 0.0.20
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 +21 -94
- 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/index.js
CHANGED
|
@@ -2547,9 +2547,9 @@ var init_aes = __esm({
|
|
|
2547
2547
|
const nonceLen = EMPTY_BLOCK.slice();
|
|
2548
2548
|
const view = createView(nonceLen);
|
|
2549
2549
|
view.setBigUint64(8, BigInt(nonce.length * 8), false);
|
|
2550
|
-
const
|
|
2551
|
-
|
|
2552
|
-
|
|
2550
|
+
const g = ghash.create(authKey).update(nonce).update(nonceLen);
|
|
2551
|
+
g.digestInto(counter);
|
|
2552
|
+
g.destroy();
|
|
2553
2553
|
}
|
|
2554
2554
|
const tagMask = ctr32(xk, false, counter, EMPTY_BLOCK);
|
|
2555
2555
|
return { xk, authKey, counter, tagMask };
|
|
@@ -2905,25 +2905,6 @@ var init_file_utils = __esm({
|
|
|
2905
2905
|
}
|
|
2906
2906
|
});
|
|
2907
2907
|
|
|
2908
|
-
// src/sdk/dom-globals.ts
|
|
2909
|
-
function removeDOMGlobals() {
|
|
2910
|
-
delete g.window;
|
|
2911
|
-
delete g.document;
|
|
2912
|
-
}
|
|
2913
|
-
function restoreDOMGlobals() {
|
|
2914
|
-
if (!savedGlobals) return;
|
|
2915
|
-
Object.assign(g, savedGlobals);
|
|
2916
|
-
}
|
|
2917
|
-
var g, savedGlobals;
|
|
2918
|
-
var init_dom_globals = __esm({
|
|
2919
|
-
"src/sdk/dom-globals.ts"() {
|
|
2920
|
-
"use strict";
|
|
2921
|
-
init_esm_shims();
|
|
2922
|
-
g = globalThis;
|
|
2923
|
-
savedGlobals = null;
|
|
2924
|
-
}
|
|
2925
|
-
});
|
|
2926
|
-
|
|
2927
2908
|
// src/sdk/file-manager.ts
|
|
2928
2909
|
import { fromUint8Array as fromUint8Array2, toUint8Array as toUint8Array3 } from "js-base64";
|
|
2929
2910
|
import { generateAESKey, exportAESKey } from "@fileverse/crypto/webcrypto";
|
|
@@ -2936,7 +2917,6 @@ var init_file_manager = __esm({
|
|
|
2936
2917
|
init_file_utils();
|
|
2937
2918
|
init_constants();
|
|
2938
2919
|
init_constants3();
|
|
2939
|
-
init_dom_globals();
|
|
2940
2920
|
init_infra();
|
|
2941
2921
|
FileManager = class {
|
|
2942
2922
|
keyStore;
|
|
@@ -2945,14 +2925,6 @@ var init_file_manager = __esm({
|
|
|
2945
2925
|
this.keyStore = keyStore;
|
|
2946
2926
|
this.agentClient = agentClient;
|
|
2947
2927
|
}
|
|
2948
|
-
convertMarkdown(content) {
|
|
2949
|
-
restoreDOMGlobals();
|
|
2950
|
-
try {
|
|
2951
|
-
return markdownToYjs(content);
|
|
2952
|
-
} finally {
|
|
2953
|
-
removeDOMGlobals();
|
|
2954
|
-
}
|
|
2955
|
-
}
|
|
2956
2928
|
createLocks(key, encryptedSecretKey, commentKey) {
|
|
2957
2929
|
const appLock = {
|
|
2958
2930
|
lockedFileKey: this.keyStore.encryptData(toUint8Array3(key)),
|
|
@@ -2996,7 +2968,7 @@ var init_file_manager = __esm({
|
|
|
2996
2968
|
const nonce = toUint8Array3(file2.linkKeyNonce);
|
|
2997
2969
|
const secretKey = toUint8Array3(file2.secretKey);
|
|
2998
2970
|
console.log("Got encrypted secret key, nonce, and secret key");
|
|
2999
|
-
const yJSContent =
|
|
2971
|
+
const yJSContent = markdownToYjs(file2.content);
|
|
3000
2972
|
console.log("Generated yjs content");
|
|
3001
2973
|
const { encryptedFile, key } = await createEncryptedContentFile(yJSContent);
|
|
3002
2974
|
console.log("Generated encrypted content file");
|
|
@@ -3056,7 +3028,7 @@ var init_file_manager = __esm({
|
|
|
3056
3028
|
const encryptedSecretKey = file2.linkKey;
|
|
3057
3029
|
const nonce = toUint8Array3(file2.linkKeyNonce);
|
|
3058
3030
|
const secretKey = toUint8Array3(file2.secretKey);
|
|
3059
|
-
const yjsContent =
|
|
3031
|
+
const yjsContent = markdownToYjs(file2.content);
|
|
3060
3032
|
const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
|
|
3061
3033
|
const commentKey = toUint8Array3(file2.commentKey);
|
|
3062
3034
|
const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
|
|
@@ -3105,7 +3077,7 @@ var init_file_manager = __esm({
|
|
|
3105
3077
|
const nonce = toUint8Array3(file2.linkKeyNonce);
|
|
3106
3078
|
const secretKey = toUint8Array3(file2.secretKey);
|
|
3107
3079
|
logger.debug(`Generating encrypted content file for file ${file2.ddocId} with onChainFileId ${file2.onChainFileId}`);
|
|
3108
|
-
const yjsContent =
|
|
3080
|
+
const yjsContent = markdownToYjs(file2.content);
|
|
3109
3081
|
const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
|
|
3110
3082
|
const commentKey = toUint8Array3(file2.commentKey);
|
|
3111
3083
|
const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
|
|
@@ -3865,30 +3837,17 @@ init_esm_shims();
|
|
|
3865
3837
|
// src/cli/fetch-api-key.ts
|
|
3866
3838
|
init_esm_shims();
|
|
3867
3839
|
init_constants();
|
|
3868
|
-
import axios from "axios";
|
|
3869
3840
|
import { toUint8Array as toUint8Array5 } from "js-base64";
|
|
3870
3841
|
import { sha256 } from "viem";
|
|
3871
3842
|
var fetchApiKeyData = async (apiKey) => {
|
|
3872
3843
|
try {
|
|
3873
3844
|
const keyHash = sha256(toUint8Array5(apiKey));
|
|
3874
3845
|
const fullUrl = BASE_CONFIG.API_URL + `api-access/${keyHash}`;
|
|
3875
|
-
const response = await
|
|
3876
|
-
const { encryptedKeyMaterial, encryptedAppMaterial, id } = response.
|
|
3846
|
+
const response = await fetch(fullUrl);
|
|
3847
|
+
const { encryptedKeyMaterial, encryptedAppMaterial, id } = await response.json();
|
|
3877
3848
|
return { encryptedKeyMaterial, encryptedAppMaterial, id };
|
|
3878
3849
|
} catch (error48) {
|
|
3879
|
-
|
|
3880
|
-
if (error48.response?.status === 401) {
|
|
3881
|
-
throw new Error("Invalid API key");
|
|
3882
|
-
}
|
|
3883
|
-
if (error48.response?.status === 404) {
|
|
3884
|
-
throw new Error("API key not found");
|
|
3885
|
-
}
|
|
3886
|
-
if (error48.code === "ECONNREFUSED") {
|
|
3887
|
-
throw new Error(`Cannot connect to server at ${BASE_CONFIG.API_URL}`);
|
|
3888
|
-
}
|
|
3889
|
-
throw new Error(`Server error: ${error48.response?.data?.message || error48.message}`);
|
|
3890
|
-
}
|
|
3891
|
-
throw error48;
|
|
3850
|
+
throw new Error(`Server error: ${error48.message}`);
|
|
3892
3851
|
}
|
|
3893
3852
|
};
|
|
3894
3853
|
|