@fileverse/api 0.0.17 → 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 +4 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/cloudflare.js +46 -66
- package/dist/cloudflare.js.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/index.js +46 -66
- package/dist/index.js.map +1 -1
- package/dist/worker.js +43 -50
- package/dist/worker.js.map +1 -1
- package/package.json +1 -2
package/dist/worker.js
CHANGED
|
@@ -1672,19 +1672,29 @@ var init_pimlico_utils = __esm({
|
|
|
1672
1672
|
version: "0.7"
|
|
1673
1673
|
}
|
|
1674
1674
|
});
|
|
1675
|
-
signerToSmartAccount = async (signer) =>
|
|
1676
|
-
client
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1675
|
+
signerToSmartAccount = async (signer) => {
|
|
1676
|
+
console.log("[pimlico] creating public client");
|
|
1677
|
+
const client = getPublicClient();
|
|
1678
|
+
console.log("[pimlico] calling toSafeSmartAccount");
|
|
1679
|
+
const account = await toSafeSmartAccount({
|
|
1680
|
+
client,
|
|
1681
|
+
owners: [signer],
|
|
1682
|
+
entryPoint: {
|
|
1683
|
+
address: entryPoint07Address,
|
|
1684
|
+
version: "0.7"
|
|
1685
|
+
},
|
|
1686
|
+
version: "1.4.1"
|
|
1687
|
+
});
|
|
1688
|
+
console.log("[pimlico] safe smart account created");
|
|
1689
|
+
return account;
|
|
1690
|
+
};
|
|
1684
1691
|
getSmartAccountClient = async (signer, authToken, portalAddress) => {
|
|
1692
|
+
console.log("[pimlico] signerToSmartAccount start");
|
|
1685
1693
|
const smartAccount = await signerToSmartAccount(signer);
|
|
1694
|
+
console.log("[pimlico] creating pimlico client");
|
|
1686
1695
|
const pimlicoClient = getPimlicoClient(authToken, portalAddress, smartAccount.address);
|
|
1687
|
-
|
|
1696
|
+
console.log("[pimlico] creating smart account client");
|
|
1697
|
+
const result = createSmartAccountClient({
|
|
1688
1698
|
account: smartAccount,
|
|
1689
1699
|
chain: CHAIN,
|
|
1690
1700
|
paymaster: pimlicoClient,
|
|
@@ -1702,6 +1712,8 @@ var init_pimlico_utils = __esm({
|
|
|
1702
1712
|
estimateFeesPerGas: async () => (await pimlicoClient.getUserOperationGasPrice()).fast
|
|
1703
1713
|
}
|
|
1704
1714
|
});
|
|
1715
|
+
console.log("[pimlico] smart account client created");
|
|
1716
|
+
return result;
|
|
1705
1717
|
};
|
|
1706
1718
|
getNonce = () => hexToBigInt(
|
|
1707
1719
|
toHex(toBytes(generatePrivateKey()).slice(0, 24), {
|
|
@@ -1737,13 +1749,17 @@ var init_smart_agent = __esm({
|
|
|
1737
1749
|
MAX_CALL_GAS_LIMIT = 5e5;
|
|
1738
1750
|
authOptions = { namespace: "proxy", segment: "ACCESS", scheme: "pimlico" };
|
|
1739
1751
|
async initializeAgentClient(keyMaterial) {
|
|
1752
|
+
console.log("[agent] creating account from key");
|
|
1740
1753
|
const agentAccount = privateKeyToAccount(toHex2(keyMaterial));
|
|
1754
|
+
console.log("[agent] getting auth token");
|
|
1741
1755
|
const authToken = await this.authTokenProvider.getAuthToken(STATIC_CONFIG.PROXY_SERVER_DID, this.authOptions);
|
|
1756
|
+
console.log("[agent] getting smart account client");
|
|
1742
1757
|
const smartAccountClient = await getSmartAccountClient(
|
|
1743
1758
|
agentAccount,
|
|
1744
1759
|
authToken,
|
|
1745
1760
|
this.authTokenProvider.portalAddress
|
|
1746
1761
|
);
|
|
1762
|
+
console.log("[agent] smart account client ready");
|
|
1747
1763
|
this.smartAccountAgent = smartAccountClient;
|
|
1748
1764
|
}
|
|
1749
1765
|
getSmartAccountAgent() {
|
|
@@ -1783,17 +1799,19 @@ var init_smart_agent = __esm({
|
|
|
1783
1799
|
]);
|
|
1784
1800
|
}
|
|
1785
1801
|
async sendUserOperation(request, customGasLimit) {
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
}
|
|
1802
|
+
const smartAccountAgent = this.getSmartAccountAgent();
|
|
1803
|
+
console.log("[agent] encoding call data");
|
|
1804
|
+
const callData = await this.getCallData(request);
|
|
1805
|
+
console.log("[agent] generating nonce");
|
|
1806
|
+
const nonce = getNonce();
|
|
1807
|
+
console.log("[agent] sending user operation");
|
|
1808
|
+
const hash = await smartAccountAgent.sendUserOperation({
|
|
1809
|
+
callData,
|
|
1810
|
+
callGasLimit: BigInt(customGasLimit || this.MAX_CALL_GAS_LIMIT),
|
|
1811
|
+
nonce
|
|
1812
|
+
});
|
|
1813
|
+
console.log("[agent] user operation sent");
|
|
1814
|
+
return hash;
|
|
1797
1815
|
}
|
|
1798
1816
|
async executeUserOperationRequest(request, timeout, customGasLimit) {
|
|
1799
1817
|
const userOpHash = await this.sendUserOperation(request, customGasLimit);
|
|
@@ -2723,6 +2741,7 @@ var init_file_utils = __esm({
|
|
|
2723
2741
|
// src/sdk/file-manager.ts
|
|
2724
2742
|
import { fromUint8Array as fromUint8Array2, toUint8Array as toUint8Array3 } from "js-base64";
|
|
2725
2743
|
import { generateAESKey, exportAESKey } from "@fileverse/crypto/webcrypto";
|
|
2744
|
+
import { markdownToYjs } from "@fileverse/content-processor";
|
|
2726
2745
|
var FileManager;
|
|
2727
2746
|
var init_file_manager = __esm({
|
|
2728
2747
|
"src/sdk/file-manager.ts"() {
|
|
@@ -2739,32 +2758,6 @@ var init_file_manager = __esm({
|
|
|
2739
2758
|
this.keyStore = keyStore;
|
|
2740
2759
|
this.agentClient = agentClient;
|
|
2741
2760
|
}
|
|
2742
|
-
async convertMarkdown(content) {
|
|
2743
|
-
const g = globalThis;
|
|
2744
|
-
const saved = {
|
|
2745
|
-
window: g.window,
|
|
2746
|
-
navigator: g.navigator,
|
|
2747
|
-
document: g.document,
|
|
2748
|
-
Node: g.Node,
|
|
2749
|
-
HTMLElement: g.HTMLElement,
|
|
2750
|
-
Text: g.Text,
|
|
2751
|
-
DOMParser: g.DOMParser,
|
|
2752
|
-
Element: g.Element,
|
|
2753
|
-
DocumentFragment: g.DocumentFragment,
|
|
2754
|
-
getComputedStyle: g.getComputedStyle,
|
|
2755
|
-
MutationObserver: g.MutationObserver,
|
|
2756
|
-
Range: g.Range
|
|
2757
|
-
};
|
|
2758
|
-
try {
|
|
2759
|
-
const { markdownToYjs } = await import("@fileverse/content-processor");
|
|
2760
|
-
return markdownToYjs(content);
|
|
2761
|
-
} finally {
|
|
2762
|
-
for (const [key, value] of Object.entries(saved)) {
|
|
2763
|
-
if (value === void 0) delete g[key];
|
|
2764
|
-
else g[key] = value;
|
|
2765
|
-
}
|
|
2766
|
-
}
|
|
2767
|
-
}
|
|
2768
2761
|
createLocks(key, encryptedSecretKey, commentKey) {
|
|
2769
2762
|
const appLock = {
|
|
2770
2763
|
lockedFileKey: this.keyStore.encryptData(toUint8Array3(key)),
|
|
@@ -2808,7 +2801,7 @@ var init_file_manager = __esm({
|
|
|
2808
2801
|
const nonce = toUint8Array3(file.linkKeyNonce);
|
|
2809
2802
|
const secretKey = toUint8Array3(file.secretKey);
|
|
2810
2803
|
console.log("Got encrypted secret key, nonce, and secret key");
|
|
2811
|
-
const yJSContent =
|
|
2804
|
+
const yJSContent = markdownToYjs(file.content);
|
|
2812
2805
|
console.log("Generated yjs content");
|
|
2813
2806
|
const { encryptedFile, key } = await createEncryptedContentFile(yJSContent);
|
|
2814
2807
|
console.log("Generated encrypted content file");
|
|
@@ -2868,7 +2861,7 @@ var init_file_manager = __esm({
|
|
|
2868
2861
|
const encryptedSecretKey = file.linkKey;
|
|
2869
2862
|
const nonce = toUint8Array3(file.linkKeyNonce);
|
|
2870
2863
|
const secretKey = toUint8Array3(file.secretKey);
|
|
2871
|
-
const yjsContent =
|
|
2864
|
+
const yjsContent = markdownToYjs(file.content);
|
|
2872
2865
|
const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
|
|
2873
2866
|
const commentKey = toUint8Array3(file.commentKey);
|
|
2874
2867
|
const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
|
|
@@ -2917,7 +2910,7 @@ var init_file_manager = __esm({
|
|
|
2917
2910
|
const nonce = toUint8Array3(file.linkKeyNonce);
|
|
2918
2911
|
const secretKey = toUint8Array3(file.secretKey);
|
|
2919
2912
|
logger.debug(`Generating encrypted content file for file ${file.ddocId} with onChainFileId ${file.onChainFileId}`);
|
|
2920
|
-
const yjsContent =
|
|
2913
|
+
const yjsContent = markdownToYjs(file.content);
|
|
2921
2914
|
const { encryptedFile, key } = await createEncryptedContentFile(yjsContent);
|
|
2922
2915
|
const commentKey = toUint8Array3(file.commentKey);
|
|
2923
2916
|
const { appLock, ownerLock } = this.createLocks(key, encryptedSecretKey, commentKey);
|