@fileverse/api 0.0.20 → 0.0.21
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 +40 -57
- package/dist/cloudflare.js.map +1 -1
- package/dist/commands/index.js +1 -6
- package/dist/commands/index.js.map +1 -1
- package/dist/index.js +22 -45
- package/dist/index.js.map +1 -1
- package/dist/worker.js +21 -39
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/public/llm.txt +478 -204
package/dist/cloudflare.js
CHANGED
|
@@ -1438,29 +1438,19 @@ var init_pimlico_utils = __esm({
|
|
|
1438
1438
|
version: "0.7"
|
|
1439
1439
|
}
|
|
1440
1440
|
});
|
|
1441
|
-
signerToSmartAccount = async (signer) => {
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
version: "0.7"
|
|
1451
|
-
},
|
|
1452
|
-
version: "1.4.1"
|
|
1453
|
-
});
|
|
1454
|
-
console.log("[pimlico] safe smart account created");
|
|
1455
|
-
return account;
|
|
1456
|
-
};
|
|
1441
|
+
signerToSmartAccount = async (signer) => await toSafeSmartAccount({
|
|
1442
|
+
client: getPublicClient(),
|
|
1443
|
+
owners: [signer],
|
|
1444
|
+
entryPoint: {
|
|
1445
|
+
address: entryPoint07Address,
|
|
1446
|
+
version: "0.7"
|
|
1447
|
+
},
|
|
1448
|
+
version: "1.4.1"
|
|
1449
|
+
});
|
|
1457
1450
|
getSmartAccountClient = async (signer, authToken, portalAddress) => {
|
|
1458
|
-
console.log("[pimlico] signerToSmartAccount start");
|
|
1459
1451
|
const smartAccount = await signerToSmartAccount(signer);
|
|
1460
|
-
console.log("[pimlico] creating pimlico client");
|
|
1461
1452
|
const pimlicoClient = getPimlicoClient(authToken, portalAddress, smartAccount.address);
|
|
1462
|
-
|
|
1463
|
-
const result = createSmartAccountClient({
|
|
1453
|
+
return createSmartAccountClient({
|
|
1464
1454
|
account: smartAccount,
|
|
1465
1455
|
chain: CHAIN,
|
|
1466
1456
|
paymaster: pimlicoClient,
|
|
@@ -1478,8 +1468,6 @@ var init_pimlico_utils = __esm({
|
|
|
1478
1468
|
estimateFeesPerGas: async () => (await pimlicoClient.getUserOperationGasPrice()).fast
|
|
1479
1469
|
}
|
|
1480
1470
|
});
|
|
1481
|
-
console.log("[pimlico] smart account client created");
|
|
1482
|
-
return result;
|
|
1483
1471
|
};
|
|
1484
1472
|
getNonce = () => hexToBigInt(
|
|
1485
1473
|
toHex(toBytes(generatePrivateKey()).slice(0, 24), {
|
|
@@ -1523,17 +1511,13 @@ var init_smart_agent = __esm({
|
|
|
1523
1511
|
MAX_CALL_GAS_LIMIT = 5e5;
|
|
1524
1512
|
authOptions = { namespace: "proxy", segment: "ACCESS", scheme: "pimlico" };
|
|
1525
1513
|
async initializeAgentClient(keyMaterial) {
|
|
1526
|
-
console.log("[agent] creating account from key");
|
|
1527
1514
|
const agentAccount = privateKeyToAccount(toHex2(keyMaterial));
|
|
1528
|
-
console.log("[agent] getting auth token");
|
|
1529
1515
|
const authToken = await this.authTokenProvider.getAuthToken(STATIC_CONFIG.PROXY_SERVER_DID, this.authOptions);
|
|
1530
|
-
console.log("[agent] getting smart account client");
|
|
1531
1516
|
const smartAccountClient = await getSmartAccountClient(
|
|
1532
1517
|
agentAccount,
|
|
1533
1518
|
authToken,
|
|
1534
1519
|
this.authTokenProvider.portalAddress
|
|
1535
1520
|
);
|
|
1536
|
-
console.log("[agent] smart account client ready");
|
|
1537
1521
|
this.smartAccountAgent = smartAccountClient;
|
|
1538
1522
|
}
|
|
1539
1523
|
getSmartAccountAgent() {
|
|
@@ -1573,19 +1557,17 @@ var init_smart_agent = __esm({
|
|
|
1573
1557
|
]);
|
|
1574
1558
|
}
|
|
1575
1559
|
async sendUserOperation(request, customGasLimit) {
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
}
|
|
1587
|
-
console.log("[agent] user operation sent");
|
|
1588
|
-
return hash2;
|
|
1560
|
+
try {
|
|
1561
|
+
const smartAccountAgent = this.getSmartAccountAgent();
|
|
1562
|
+
const callData = await this.getCallData(request);
|
|
1563
|
+
return await smartAccountAgent.sendUserOperation({
|
|
1564
|
+
callData,
|
|
1565
|
+
callGasLimit: BigInt(customGasLimit || this.MAX_CALL_GAS_LIMIT),
|
|
1566
|
+
nonce: getNonce()
|
|
1567
|
+
});
|
|
1568
|
+
} catch (error48) {
|
|
1569
|
+
throw error48;
|
|
1570
|
+
}
|
|
1589
1571
|
}
|
|
1590
1572
|
async executeUserOperationRequest(request, timeout, customGasLimit) {
|
|
1591
1573
|
const userOpHash = await this.sendUserOperation(request, customGasLimit);
|
|
@@ -3038,38 +3020,44 @@ var init_eventProcessor = __esm({
|
|
|
3038
3020
|
if (!file2) throw new Error(`File ${fileId} not found`);
|
|
3039
3021
|
if (file2.isDeleted === 1) {
|
|
3040
3022
|
logger.info(`File ${fileId} is deleted, skipping create submit`);
|
|
3041
|
-
return
|
|
3023
|
+
return;
|
|
3042
3024
|
}
|
|
3043
3025
|
console.log("Submitting new file op");
|
|
3044
3026
|
const result = await handleNewFileOp(fileId);
|
|
3045
3027
|
console.log("New file op submitted");
|
|
3028
|
+
await EventsModel.setEventPendingOp(event._id, result.userOpHash, {
|
|
3029
|
+
metadata: result.metadata
|
|
3030
|
+
});
|
|
3046
3031
|
logger.info(`File ${file2.ddocId} create op submitted (hash: ${result.userOpHash})`);
|
|
3047
|
-
|
|
3032
|
+
break;
|
|
3048
3033
|
}
|
|
3049
3034
|
case "update": {
|
|
3050
3035
|
const file2 = await FilesModel.findByIdExcludingDeleted(fileId);
|
|
3051
|
-
if (!file2) return
|
|
3052
|
-
if (file2.localVersion <= file2.onchainVersion) return
|
|
3036
|
+
if (!file2) return;
|
|
3037
|
+
if (file2.localVersion <= file2.onchainVersion) return;
|
|
3053
3038
|
const result = await submitUpdateFileOp(fileId);
|
|
3039
|
+
await EventsModel.setEventPendingOp(event._id, result.userOpHash, {
|
|
3040
|
+
metadata: result.metadata,
|
|
3041
|
+
localVersion: file2.localVersion
|
|
3042
|
+
});
|
|
3054
3043
|
logger.info(`File ${file2.ddocId} update op submitted (hash: ${result.userOpHash})`);
|
|
3055
|
-
|
|
3056
|
-
userOpHash: result.userOpHash,
|
|
3057
|
-
pendingPayload: { metadata: result.metadata, localVersion: file2.localVersion }
|
|
3058
|
-
};
|
|
3044
|
+
break;
|
|
3059
3045
|
}
|
|
3060
3046
|
case "delete": {
|
|
3061
3047
|
const file2 = await FilesModel.findByIdIncludingDeleted(fileId);
|
|
3062
|
-
if (!file2) return
|
|
3048
|
+
if (!file2) return;
|
|
3063
3049
|
if (file2.isDeleted === 1 && file2.syncStatus === "synced") {
|
|
3064
3050
|
logger.info(`File ${fileId} deletion already synced, skipping`);
|
|
3065
|
-
return
|
|
3051
|
+
return;
|
|
3066
3052
|
}
|
|
3067
3053
|
if (file2.onChainFileId === null || file2.onChainFileId === void 0) {
|
|
3068
|
-
|
|
3054
|
+
await FilesModel.update(fileId, { syncStatus: "synced", isDeleted: 1 }, file2.portalAddress);
|
|
3055
|
+
return;
|
|
3069
3056
|
}
|
|
3070
3057
|
const result = await submitDeleteFileOp(fileId);
|
|
3058
|
+
await EventsModel.setEventPendingOp(event._id, result.userOpHash, {});
|
|
3071
3059
|
logger.info(`File ${file2.ddocId} delete op submitted (hash: ${result.userOpHash})`);
|
|
3072
|
-
|
|
3060
|
+
break;
|
|
3073
3061
|
}
|
|
3074
3062
|
default:
|
|
3075
3063
|
throw new Error(`Unknown event type: ${type}`);
|
|
@@ -3825,12 +3813,7 @@ import hkdf from "futoin-hkdf";
|
|
|
3825
3813
|
import tweetnacl2 from "tweetnacl";
|
|
3826
3814
|
import { fromUint8Array as fromUint8Array4, toUint8Array as toUint8Array5 } from "js-base64";
|
|
3827
3815
|
var deriveKeyFromAg2Hash = async (pass, salt) => {
|
|
3828
|
-
const key = await getArgon2idHash(pass, salt
|
|
3829
|
-
t: 2,
|
|
3830
|
-
m: 4096,
|
|
3831
|
-
p: 8,
|
|
3832
|
-
dkLen: 32
|
|
3833
|
-
});
|
|
3816
|
+
const key = await getArgon2idHash(pass, salt);
|
|
3834
3817
|
return hkdf(Buffer.from(key), tweetnacl2.secretbox.keyLength, {
|
|
3835
3818
|
info: Buffer.from("encryptionKey")
|
|
3836
3819
|
});
|