run402-mcp 1.57.3 → 1.57.5
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/package.json +1 -1
- package/sdk/dist/namespaces/admin.d.ts +6 -5
- package/sdk/dist/namespaces/admin.d.ts.map +1 -1
- package/sdk/dist/namespaces/admin.js +5 -4
- package/sdk/dist/namespaces/admin.js.map +1 -1
- package/core/dist/wallet-auth.d.ts +0 -15
- package/core/dist/wallet-auth.d.ts.map +0 -1
- package/core/dist/wallet-auth.js +0 -62
- package/core/dist/wallet-auth.js.map +0 -1
- package/core/dist/wallet.d.ts +0 -10
- package/core/dist/wallet.d.ts.map +0 -1
- package/core/dist/wallet.js +0 -25
- package/core/dist/wallet.js.map +0 -1
- package/dist/paid-fetch.d.ts +0 -25
- package/dist/paid-fetch.d.ts.map +0 -1
- package/dist/paid-fetch.js +0 -114
- package/dist/paid-fetch.js.map +0 -1
- package/dist/tools/archive-project.d.ts +0 -14
- package/dist/tools/archive-project.d.ts.map +0 -1
- package/dist/tools/archive-project.js +0 -35
- package/dist/tools/archive-project.js.map +0 -1
- package/dist/tools/delete-file.d.ts +0 -18
- package/dist/tools/delete-file.d.ts.map +0 -1
- package/dist/tools/delete-file.js +0 -33
- package/dist/tools/delete-file.js.map +0 -1
- package/dist/tools/download-file.d.ts +0 -18
- package/dist/tools/download-file.d.ts.map +0 -1
- package/dist/tools/download-file.js +0 -34
- package/dist/tools/download-file.js.map +0 -1
- package/dist/tools/list-files.d.ts +0 -16
- package/dist/tools/list-files.d.ts.map +0 -1
- package/dist/tools/list-files.js +0 -47
- package/dist/tools/list-files.js.map +0 -1
- package/dist/tools/renew.d.ts +0 -16
- package/dist/tools/renew.d.ts.map +0 -1
- package/dist/tools/renew.js +0 -64
- package/dist/tools/renew.js.map +0 -1
- package/dist/tools/upload-file.d.ts +0 -22
- package/dist/tools/upload-file.d.ts.map +0 -1
- package/dist/tools/upload-file.js +0 -40
- package/dist/tools/upload-file.js.map +0 -1
- package/dist/tools/wallet-create.d.ts +0 -9
- package/dist/tools/wallet-create.d.ts.map +0 -1
- package/dist/tools/wallet-create.js +0 -52
- package/dist/tools/wallet-create.js.map +0 -1
- package/dist/tools/wallet-export.d.ts +0 -9
- package/dist/tools/wallet-export.d.ts.map +0 -1
- package/dist/tools/wallet-export.js +0 -20
- package/dist/tools/wallet-export.js.map +0 -1
- package/dist/tools/wallet-status.d.ts +0 -9
- package/dist/tools/wallet-status.d.ts.map +0 -1
- package/dist/tools/wallet-status.js +0 -28
- package/dist/tools/wallet-status.js.map +0 -1
- package/dist/wallet-auth.d.ts +0 -21
- package/dist/wallet-auth.d.ts.map +0 -1
- package/dist/wallet-auth.js +0 -26
- package/dist/wallet-auth.js.map +0 -1
- package/dist/wallet.d.ts +0 -3
- package/dist/wallet.d.ts.map +0 -1
- package/dist/wallet.js +0 -2
- package/dist/wallet.js.map +0 -1
- package/sdk/core-dist/wallet-auth.d.ts +0 -15
- package/sdk/core-dist/wallet-auth.js +0 -62
- package/sdk/core-dist/wallet.d.ts +0 -10
- package/sdk/core-dist/wallet.js +0 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "run402-mcp",
|
|
3
|
-
"version": "1.57.
|
|
3
|
+
"version": "1.57.5",
|
|
4
4
|
"description": "MCP server for Run402 — AI-native Postgres databases with REST API, auth, storage, and row-level security. Pay with x402 USDC micropayments.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,8 +27,8 @@ export interface AdminProjectFinanceOptions {
|
|
|
27
27
|
window?: AdminFinanceWindow;
|
|
28
28
|
/**
|
|
29
29
|
* Optional admin session cookie header. Node operators can pass the value of
|
|
30
|
-
* RUN402_ADMIN_COOKIE
|
|
31
|
-
* headers
|
|
30
|
+
* RUN402_ADMIN_COOKIE when they want browser-session auth; otherwise the
|
|
31
|
+
* credential provider's normal auth headers are used.
|
|
32
32
|
*/
|
|
33
33
|
cookie?: string;
|
|
34
34
|
}
|
|
@@ -63,9 +63,10 @@ export declare class Admin {
|
|
|
63
63
|
* Fetch per-project finance for platform operators.
|
|
64
64
|
*
|
|
65
65
|
* This is the same admin-only surface used by the Run402 Finance tab. It is
|
|
66
|
-
* gated by
|
|
67
|
-
*
|
|
68
|
-
* credential provider whose `getAuth()` returns
|
|
66
|
+
* gated by platform-admin auth; project service keys are not sufficient.
|
|
67
|
+
* Use the Node SDK with an admin allowance wallet, pass `cookie` for browser
|
|
68
|
+
* session auth, or provide a credential provider whose `getAuth()` returns
|
|
69
|
+
* suitable admin headers.
|
|
69
70
|
*/
|
|
70
71
|
getProjectFinance(projectId: string, opts?: AdminProjectFinanceOptions): Promise<AdminProjectFinanceResult>;
|
|
71
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/namespaces/admin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC;AAE9D,MAAM,WAAW,0BAA0B;IACzC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B;;;;OAIG;IACH,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CACrB,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,0BAA+B,GACpC,OAAO,CAAC,yBAAyB,CAAC;CAoBtC"}
|
|
@@ -37,16 +37,17 @@ export class Admin {
|
|
|
37
37
|
* Fetch per-project finance for platform operators.
|
|
38
38
|
*
|
|
39
39
|
* This is the same admin-only surface used by the Run402 Finance tab. It is
|
|
40
|
-
* gated by
|
|
41
|
-
*
|
|
42
|
-
* credential provider whose `getAuth()` returns
|
|
40
|
+
* gated by platform-admin auth; project service keys are not sufficient.
|
|
41
|
+
* Use the Node SDK with an admin allowance wallet, pass `cookie` for browser
|
|
42
|
+
* session auth, or provide a credential provider whose `getAuth()` returns
|
|
43
|
+
* suitable admin headers.
|
|
43
44
|
*/
|
|
44
45
|
async getProjectFinance(projectId, opts = {}) {
|
|
45
46
|
const window = opts.window ?? "30d";
|
|
46
47
|
if (!FINANCE_WINDOWS.has(window)) {
|
|
47
48
|
throw new LocalError(`Invalid finance window: ${String(window)}. Expected one of: 24h, 7d, 30d, 90d.`, "fetching project finance");
|
|
48
49
|
}
|
|
49
|
-
const headers = {};
|
|
50
|
+
const headers = { "X-Admin-Mode": "1" };
|
|
50
51
|
if (opts.cookie)
|
|
51
52
|
headers.Cookie = opts.cookie;
|
|
52
53
|
return this.client.request(`/admin/api/finance/project/${encodeURIComponent(projectId)}?window=${encodeURIComponent(window)}`, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/namespaces/admin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAmD1C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAqB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF,MAAM,OAAO,KAAK;IACa;IAA7B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,wE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3
|
-
* Uses @noble/curves (lighter than viem) for signing.
|
|
4
|
-
*/
|
|
5
|
-
export interface WalletAuthHeaders {
|
|
6
|
-
"X-Run402-Wallet": string;
|
|
7
|
-
"X-Run402-Signature": string;
|
|
8
|
-
"X-Run402-Timestamp": string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Get wallet auth headers for the Run402 API.
|
|
12
|
-
* Returns null if no wallet is configured.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getWalletAuthHeaders(walletPath?: string): WalletAuthHeaders | null;
|
|
15
|
-
//# sourceMappingURL=wallet-auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-auth.d.ts","sourceRoot":"","sources":["../src/wallet-auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AA4CD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAYlF"}
|
package/core/dist/wallet-auth.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wallet auth helper — generates EIP-191 signature headers for Run402 API.
|
|
3
|
-
* Uses @noble/curves (lighter than viem) for signing.
|
|
4
|
-
*/
|
|
5
|
-
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
6
|
-
import { keccak_256 } from "@noble/hashes/sha3.js";
|
|
7
|
-
import { bytesToHex } from "@noble/hashes/utils.js";
|
|
8
|
-
import { readWallet } from "./wallet.js";
|
|
9
|
-
/**
|
|
10
|
-
* EIP-191 personal_sign: sign a message with the wallet's private key.
|
|
11
|
-
*/
|
|
12
|
-
function personalSign(privateKeyHex, address, message) {
|
|
13
|
-
const msgBytes = new TextEncoder().encode(message);
|
|
14
|
-
const prefix = new TextEncoder().encode(`\x19Ethereum Signed Message:\n${msgBytes.length}`);
|
|
15
|
-
const prefixed = new Uint8Array(prefix.length + msgBytes.length);
|
|
16
|
-
prefixed.set(prefix);
|
|
17
|
-
prefixed.set(msgBytes, prefix.length);
|
|
18
|
-
const hash = keccak_256(prefixed);
|
|
19
|
-
const pkHex = privateKeyHex.startsWith("0x")
|
|
20
|
-
? privateKeyHex.slice(2)
|
|
21
|
-
: privateKeyHex;
|
|
22
|
-
const pkBytes = Uint8Array.from(Buffer.from(pkHex, "hex"));
|
|
23
|
-
const rawSig = secp256k1.sign(hash, pkBytes);
|
|
24
|
-
const sig = secp256k1.Signature.fromBytes(rawSig);
|
|
25
|
-
// Determine recovery bit by trying both and matching the address
|
|
26
|
-
let recovery = 0;
|
|
27
|
-
for (const v of [0, 1]) {
|
|
28
|
-
try {
|
|
29
|
-
const recovered = sig.addRecoveryBit(v).recoverPublicKey(hash);
|
|
30
|
-
const pubBytes = recovered.toBytes(false).slice(1); // uncompressed, drop 04 prefix
|
|
31
|
-
const addrBytes = keccak_256(pubBytes).slice(-20);
|
|
32
|
-
if ("0x" + bytesToHex(addrBytes) === address.toLowerCase()) {
|
|
33
|
-
recovery = v;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const r = sig.r.toString(16).padStart(64, "0");
|
|
42
|
-
const s = sig.s.toString(16).padStart(64, "0");
|
|
43
|
-
const vHex = (recovery + 27).toString(16).padStart(2, "0");
|
|
44
|
-
return "0x" + r + s + vHex;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Get wallet auth headers for the Run402 API.
|
|
48
|
-
* Returns null if no wallet is configured.
|
|
49
|
-
*/
|
|
50
|
-
export function getWalletAuthHeaders(walletPath) {
|
|
51
|
-
const wallet = readWallet(walletPath);
|
|
52
|
-
if (!wallet || !wallet.address || !wallet.privateKey)
|
|
53
|
-
return null;
|
|
54
|
-
const timestamp = Math.floor(Date.now() / 1000).toString();
|
|
55
|
-
const signature = personalSign(wallet.privateKey, wallet.address, `run402:${timestamp}`);
|
|
56
|
-
return {
|
|
57
|
-
"X-Run402-Wallet": wallet.address,
|
|
58
|
-
"X-Run402-Signature": signature,
|
|
59
|
-
"X-Run402-Timestamp": timestamp,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=wallet-auth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-auth.js","sourceRoot":"","sources":["../src/wallet-auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQzC;;GAEG;AACH,SAAS,YAAY,CAAC,aAAqB,EAAE,OAAe,EAAE,OAAe;IAC3E,MAAM,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CACrC,iCAAiC,QAAQ,CAAC,MAAM,EAAE,CACnD,CAAC;IACF,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAEtC,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC;QAC1C,CAA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,CAAC;IAC/C,MAAM,IAAI,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3D,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAmB;IACtD,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAElE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC3D,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,SAAS,EAAE,CAAC,CAAC;IAEzF,OAAO;QACL,iBAAiB,EAAE,MAAM,CAAC,OAAO;QACjC,oBAAoB,EAAE,SAAS;QAC/B,oBAAoB,EAAE,SAAS;KAChC,CAAC;AACJ,CAAC"}
|
package/core/dist/wallet.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface WalletData {
|
|
2
|
-
address: string;
|
|
3
|
-
privateKey: string;
|
|
4
|
-
created?: string;
|
|
5
|
-
funded?: boolean;
|
|
6
|
-
lastFaucet?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function readWallet(path?: string): WalletData | null;
|
|
9
|
-
export declare function saveWallet(data: WalletData, path?: string): void;
|
|
10
|
-
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAQ3D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAQhE"}
|
package/core/dist/wallet.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync, chmodSync, renameSync } from "node:fs";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { randomBytes } from "node:crypto";
|
|
4
|
-
import { getWalletPath } from "./config.js";
|
|
5
|
-
export function readWallet(path) {
|
|
6
|
-
const p = path ?? getWalletPath();
|
|
7
|
-
if (!existsSync(p))
|
|
8
|
-
return null;
|
|
9
|
-
try {
|
|
10
|
-
return JSON.parse(readFileSync(p, "utf-8"));
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export function saveWallet(data, path) {
|
|
17
|
-
const p = path ?? getWalletPath();
|
|
18
|
-
const dir = dirname(p);
|
|
19
|
-
mkdirSync(dir, { recursive: true });
|
|
20
|
-
const tmp = join(dir, `.wallet.${randomBytes(4).toString("hex")}.tmp`);
|
|
21
|
-
writeFileSync(tmp, JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
22
|
-
renameSync(tmp, p);
|
|
23
|
-
chmodSync(p, 0o600);
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=wallet.js.map
|
package/core/dist/wallet.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src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
package/dist/paid-fetch.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Paid fetch for MCP server — reads the local allowance, branches on rail
|
|
3
|
-
* (x402 vs mpp), returns a wrapped fetch that intercepts 402 responses,
|
|
4
|
-
* signs payment, and retries automatically.
|
|
5
|
-
*
|
|
6
|
-
* Checks on-chain balances at setup time and selects funded networks.
|
|
7
|
-
* Returns null when no allowance is configured or payment libraries are
|
|
8
|
-
* unavailable (graceful degradation).
|
|
9
|
-
*/
|
|
10
|
-
import type { ApiResponse, ApiRequestOptions } from "./client.js";
|
|
11
|
-
type FetchFn = typeof globalThis.fetch;
|
|
12
|
-
/**
|
|
13
|
-
* Create a payment-wrapping fetch function from the local allowance.
|
|
14
|
-
* Returns null if no allowance exists or payment libraries fail to load.
|
|
15
|
-
*/
|
|
16
|
-
export declare function setupPaidFetch(): Promise<FetchFn | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Like apiRequest, but uses the paid fetch wrapper when available.
|
|
19
|
-
* Falls back to bare apiRequest when no allowance is configured.
|
|
20
|
-
*/
|
|
21
|
-
export declare function paidApiRequest(path: string, opts?: ApiRequestOptions): Promise<ApiResponse>;
|
|
22
|
-
/** Reset cached state — exposed for testing only */
|
|
23
|
-
export declare function _resetPaidFetchCache(): void;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=paid-fetch.d.ts.map
|
package/dist/paid-fetch.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paid-fetch.d.ts","sourceRoot":"","sources":["../src/paid-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAElE,KAAK,OAAO,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC;AAoBvC;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAyD9D;AAKD;;;GAGG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAgBtB;AAED,oDAAoD;AACpD,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
package/dist/paid-fetch.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Paid fetch for MCP server — reads the local allowance, branches on rail
|
|
3
|
-
* (x402 vs mpp), returns a wrapped fetch that intercepts 402 responses,
|
|
4
|
-
* signs payment, and retries automatically.
|
|
5
|
-
*
|
|
6
|
-
* Checks on-chain balances at setup time and selects funded networks.
|
|
7
|
-
* Returns null when no allowance is configured or payment libraries are
|
|
8
|
-
* unavailable (graceful degradation).
|
|
9
|
-
*/
|
|
10
|
-
import { readAllowance } from "./allowance.js";
|
|
11
|
-
import { apiRequest } from "./client.js";
|
|
12
|
-
const USDC_ABI = [{ name: "balanceOf", type: "function", stateMutability: "view", inputs: [{ name: "account", type: "address" }], outputs: [{ name: "", type: "uint256" }] }];
|
|
13
|
-
const USDC_MAINNET = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
14
|
-
const USDC_SEPOLIA = "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
|
|
15
|
-
async function checkBalance(publicClient, tokenAddress, walletAddress) {
|
|
16
|
-
try {
|
|
17
|
-
const raw = await publicClient.readContract({
|
|
18
|
-
address: tokenAddress,
|
|
19
|
-
abi: USDC_ABI,
|
|
20
|
-
functionName: "balanceOf",
|
|
21
|
-
args: [walletAddress],
|
|
22
|
-
});
|
|
23
|
-
return Number(raw);
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Create a payment-wrapping fetch function from the local allowance.
|
|
31
|
-
* Returns null if no allowance exists or payment libraries fail to load.
|
|
32
|
-
*/
|
|
33
|
-
export async function setupPaidFetch() {
|
|
34
|
-
const allowance = readAllowance();
|
|
35
|
-
if (!allowance)
|
|
36
|
-
return null;
|
|
37
|
-
try {
|
|
38
|
-
if (allowance.rail === "mpp") {
|
|
39
|
-
// mppx is an optional peer — use variable to skip TS module resolution
|
|
40
|
-
const mppxMod = "mppx/client";
|
|
41
|
-
const { Mppx, tempo } = await import(/* webpackIgnore: true */ mppxMod);
|
|
42
|
-
const { privateKeyToAccount } = await import("viem/accounts");
|
|
43
|
-
const account = privateKeyToAccount(allowance.privateKey);
|
|
44
|
-
const mppx = Mppx.create({
|
|
45
|
-
polyfill: false,
|
|
46
|
-
methods: [tempo({ account })],
|
|
47
|
-
});
|
|
48
|
-
return mppx.fetch;
|
|
49
|
-
}
|
|
50
|
-
// Default: x402
|
|
51
|
-
const { privateKeyToAccount } = await import("viem/accounts");
|
|
52
|
-
const { createPublicClient, http } = await import("viem");
|
|
53
|
-
const { base, baseSepolia } = await import("viem/chains");
|
|
54
|
-
const { x402Client, wrapFetchWithPayment } = await import("@x402/fetch");
|
|
55
|
-
const { ExactEvmScheme } = await import("@x402/evm/exact/client");
|
|
56
|
-
const { toClientEvmSigner } = await import("@x402/evm");
|
|
57
|
-
const account = privateKeyToAccount(allowance.privateKey);
|
|
58
|
-
const mainnetClient = createPublicClient({ chain: base, transport: http() });
|
|
59
|
-
const sepoliaClient = createPublicClient({ chain: baseSepolia, transport: http() });
|
|
60
|
-
// Check balances in parallel
|
|
61
|
-
const [mainnetBalance, sepoliaBalance] = await Promise.all([
|
|
62
|
-
checkBalance(mainnetClient, USDC_MAINNET, allowance.address),
|
|
63
|
-
checkBalance(sepoliaClient, USDC_SEPOLIA, allowance.address),
|
|
64
|
-
]);
|
|
65
|
-
const client = new x402Client();
|
|
66
|
-
client.register("eip155:8453", new ExactEvmScheme(toClientEvmSigner(account, mainnetClient)));
|
|
67
|
-
client.register("eip155:84532", new ExactEvmScheme(toClientEvmSigner(account, sepoliaClient)));
|
|
68
|
-
// Policy: only allow networks where the wallet has funds
|
|
69
|
-
if (mainnetBalance > 0 || sepoliaBalance > 0) {
|
|
70
|
-
client.registerPolicy((_version, reqs) => {
|
|
71
|
-
const funded = reqs.filter((r) => {
|
|
72
|
-
if (r.network === "eip155:8453")
|
|
73
|
-
return mainnetBalance > 0;
|
|
74
|
-
if (r.network === "eip155:84532")
|
|
75
|
-
return sepoliaBalance > 0;
|
|
76
|
-
return false;
|
|
77
|
-
});
|
|
78
|
-
return funded.length > 0 ? funded : reqs;
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return wrapFetchWithPayment(fetch, client);
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
// Payment libraries not available — degrade gracefully
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/** Cached paid fetch — initialized lazily on first call */
|
|
89
|
-
let cachedPaidFetch;
|
|
90
|
-
/**
|
|
91
|
-
* Like apiRequest, but uses the paid fetch wrapper when available.
|
|
92
|
-
* Falls back to bare apiRequest when no allowance is configured.
|
|
93
|
-
*/
|
|
94
|
-
export async function paidApiRequest(path, opts = {}) {
|
|
95
|
-
if (cachedPaidFetch === undefined) {
|
|
96
|
-
cachedPaidFetch = await setupPaidFetch();
|
|
97
|
-
}
|
|
98
|
-
if (!cachedPaidFetch) {
|
|
99
|
-
return apiRequest(path, opts);
|
|
100
|
-
}
|
|
101
|
-
const originalFetch = globalThis.fetch;
|
|
102
|
-
globalThis.fetch = cachedPaidFetch;
|
|
103
|
-
try {
|
|
104
|
-
return await apiRequest(path, opts);
|
|
105
|
-
}
|
|
106
|
-
finally {
|
|
107
|
-
globalThis.fetch = originalFetch;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/** Reset cached state — exposed for testing only */
|
|
111
|
-
export function _resetPaidFetchCache() {
|
|
112
|
-
cachedPaidFetch = undefined;
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=paid-fetch.js.map
|
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P,uDAAuD;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,2DAA2D;AAC3D,IAAI,eAA2C,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAAY,EACZ,OAA0B,EAAE;IAE5B,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAClC,eAAe,GAAG,MAAM,cAAc,EAAE,CAAC;IAC3C,CAAC;IAED,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC;IACvC,UAAU,CAAC,KAAK,GAAG,eAAe,CAAC;IACnC,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,KAAK,GAAG,aAAa,CAAC;IACnC,CAAC;AACH,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,oBAAoB;IAClC,eAAe,GAAG,SAAS,CAAC;AAC9B,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const archiveProjectSchema: {
|
|
3
|
-
project_id: z.ZodString;
|
|
4
|
-
};
|
|
5
|
-
export declare function handleArchiveProject(args: {
|
|
6
|
-
project_id: string;
|
|
7
|
-
}): Promise<{
|
|
8
|
-
content: Array<{
|
|
9
|
-
type: "text";
|
|
10
|
-
text: string;
|
|
11
|
-
}>;
|
|
12
|
-
isError?: boolean;
|
|
13
|
-
}>;
|
|
14
|
-
//# sourceMappingURL=archive-project.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"archive-project.d.ts","sourceRoot":"","sources":["../../src/tools/archive-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,oBAAoB;;CAIhC,CAAC;AAEF,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA0BjF"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { apiRequest } from "../client.js";
|
|
3
|
-
import { getProject, loadKeyStore, saveKeyStore } from "../keystore.js";
|
|
4
|
-
import { formatApiError, projectNotFound } from "../errors.js";
|
|
5
|
-
export const archiveProjectSchema = {
|
|
6
|
-
project_id: z
|
|
7
|
-
.string()
|
|
8
|
-
.describe("The project ID to soft-delete (enter the grace window)"),
|
|
9
|
-
};
|
|
10
|
-
export async function handleArchiveProject(args) {
|
|
11
|
-
const project = getProject(args.project_id);
|
|
12
|
-
if (!project)
|
|
13
|
-
return projectNotFound(args.project_id);
|
|
14
|
-
const res = await apiRequest(`/projects/v1/${args.project_id}`, {
|
|
15
|
-
method: "DELETE",
|
|
16
|
-
headers: {
|
|
17
|
-
Authorization: `Bearer ${project.service_key}`,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
if (!res.ok)
|
|
21
|
-
return formatApiError(res, "deleting project");
|
|
22
|
-
// Remove from local key store
|
|
23
|
-
const store = loadKeyStore();
|
|
24
|
-
delete store.projects[args.project_id];
|
|
25
|
-
saveKeyStore(store);
|
|
26
|
-
return {
|
|
27
|
-
content: [
|
|
28
|
-
{
|
|
29
|
-
type: "text",
|
|
30
|
-
text: `Project \`${args.project_id}\` entered the soft-delete state (status: purged) and was removed from the local key store. Renewing the tier during the grace window would have reactivated it.`,
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=archive-project.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"archive-project.js","sourceRoot":"","sources":["../../src/tools/archive-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,QAAQ,CAAC,wDAAwD,CAAC;CACtE,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAE1C;IACC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEtD,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,gBAAgB,IAAI,CAAC,UAAU,EAAE,EAAE;QAC9D,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,WAAW,EAAE;SAC/C;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,cAAc,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAE5D,8BAA8B;IAC9B,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAC7B,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvC,YAAY,CAAC,KAAK,CAAC,CAAC;IAEpB,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,aAAa,IAAI,CAAC,UAAU,kKAAkK;aACrM;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const deleteFileSchema: {
|
|
3
|
-
project_id: z.ZodString;
|
|
4
|
-
bucket: z.ZodString;
|
|
5
|
-
path: z.ZodString;
|
|
6
|
-
};
|
|
7
|
-
export declare function handleDeleteFile(args: {
|
|
8
|
-
project_id: string;
|
|
9
|
-
bucket: string;
|
|
10
|
-
path: string;
|
|
11
|
-
}): Promise<{
|
|
12
|
-
content: Array<{
|
|
13
|
-
type: "text";
|
|
14
|
-
text: string;
|
|
15
|
-
}>;
|
|
16
|
-
isError?: boolean;
|
|
17
|
-
}>;
|
|
18
|
-
//# sourceMappingURL=delete-file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-file.d.ts","sourceRoot":"","sources":["../../src/tools/delete-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAwBjF"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { apiRequest } from "../client.js";
|
|
3
|
-
import { getProject } from "../keystore.js";
|
|
4
|
-
import { formatApiError, projectNotFound } from "../errors.js";
|
|
5
|
-
export const deleteFileSchema = {
|
|
6
|
-
project_id: z.string().describe("The project ID"),
|
|
7
|
-
bucket: z.string().describe("Storage bucket name"),
|
|
8
|
-
path: z.string().describe("File path within the bucket"),
|
|
9
|
-
};
|
|
10
|
-
export async function handleDeleteFile(args) {
|
|
11
|
-
const project = getProject(args.project_id);
|
|
12
|
-
if (!project)
|
|
13
|
-
return projectNotFound(args.project_id);
|
|
14
|
-
const apiPath = `/storage/v1/object/${args.bucket}/${args.path}`;
|
|
15
|
-
const res = await apiRequest(apiPath, {
|
|
16
|
-
method: "DELETE",
|
|
17
|
-
headers: {
|
|
18
|
-
apikey: project.anon_key,
|
|
19
|
-
Authorization: `Bearer ${project.anon_key}`,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
if (!res.ok)
|
|
23
|
-
return formatApiError(res, "deleting file");
|
|
24
|
-
return {
|
|
25
|
-
content: [
|
|
26
|
-
{
|
|
27
|
-
type: "text",
|
|
28
|
-
text: `File \`${args.bucket}/${args.path}\` deleted.`,
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=delete-file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-file.js","sourceRoot":"","sources":["../../src/tools/delete-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IACjD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IAClD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;CACzD,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAItC;IACC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEtD,MAAM,OAAO,GAAG,sBAAsB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IAEjE,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE;QACpC,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE;YACP,MAAM,EAAE,OAAO,CAAC,QAAQ;YACxB,aAAa,EAAE,UAAU,OAAO,CAAC,QAAQ,EAAE;SAC5C;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,cAAc,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAEzD,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,UAAU,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,aAAa;aACtD;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const downloadFileSchema: {
|
|
3
|
-
project_id: z.ZodString;
|
|
4
|
-
bucket: z.ZodString;
|
|
5
|
-
path: z.ZodString;
|
|
6
|
-
};
|
|
7
|
-
export declare function handleDownloadFile(args: {
|
|
8
|
-
project_id: string;
|
|
9
|
-
bucket: string;
|
|
10
|
-
path: string;
|
|
11
|
-
}): Promise<{
|
|
12
|
-
content: Array<{
|
|
13
|
-
type: "text";
|
|
14
|
-
text: string;
|
|
15
|
-
}>;
|
|
16
|
-
isError?: boolean;
|
|
17
|
-
}>;
|
|
18
|
-
//# sourceMappingURL=download-file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download-file.d.ts","sourceRoot":"","sources":["../../src/tools/download-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,kBAAkB;;;;CAI9B,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA0BjF"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { apiRequest } from "../client.js";
|
|
3
|
-
import { getProject } from "../keystore.js";
|
|
4
|
-
import { formatApiError, projectNotFound } from "../errors.js";
|
|
5
|
-
export const downloadFileSchema = {
|
|
6
|
-
project_id: z.string().describe("The project ID"),
|
|
7
|
-
bucket: z.string().describe("Storage bucket name"),
|
|
8
|
-
path: z.string().describe("File path within the bucket"),
|
|
9
|
-
};
|
|
10
|
-
export async function handleDownloadFile(args) {
|
|
11
|
-
const project = getProject(args.project_id);
|
|
12
|
-
if (!project)
|
|
13
|
-
return projectNotFound(args.project_id);
|
|
14
|
-
const apiPath = `/storage/v1/object/${args.bucket}/${args.path}`;
|
|
15
|
-
const res = await apiRequest(apiPath, {
|
|
16
|
-
method: "GET",
|
|
17
|
-
headers: {
|
|
18
|
-
apikey: project.anon_key,
|
|
19
|
-
Authorization: `Bearer ${project.anon_key}`,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
if (!res.ok)
|
|
23
|
-
return formatApiError(res, "downloading file");
|
|
24
|
-
const content = typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2);
|
|
25
|
-
return {
|
|
26
|
-
content: [
|
|
27
|
-
{
|
|
28
|
-
type: "text",
|
|
29
|
-
text: `**${args.bucket}/${args.path}:**\n\n\`\`\`\n${content}\n\`\`\``,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=download-file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download-file.js","sourceRoot":"","sources":["../../src/tools/download-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IACjD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IAClD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;CACzD,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAIxC;IACC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEtD,MAAM,OAAO,GAAG,sBAAsB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IAEjE,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE;QACpC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,OAAO,CAAC,QAAQ;YACxB,aAAa,EAAE,UAAU,OAAO,CAAC,QAAQ,EAAE;SAC5C;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,cAAc,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAE5D,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAE5F,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,KAAK,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,kBAAkB,OAAO,UAAU;aACvE;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const listFilesSchema: {
|
|
3
|
-
project_id: z.ZodString;
|
|
4
|
-
bucket: z.ZodString;
|
|
5
|
-
};
|
|
6
|
-
export declare function handleListFiles(args: {
|
|
7
|
-
project_id: string;
|
|
8
|
-
bucket: string;
|
|
9
|
-
}): Promise<{
|
|
10
|
-
content: Array<{
|
|
11
|
-
type: "text";
|
|
12
|
-
text: string;
|
|
13
|
-
}>;
|
|
14
|
-
isError?: boolean;
|
|
15
|
-
}>;
|
|
16
|
-
//# sourceMappingURL=list-files.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-files.d.ts","sourceRoot":"","sources":["../../src/tools/list-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,eAAe;;;CAG3B,CAAC;AAEF,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA6CjF"}
|
package/dist/tools/list-files.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { apiRequest } from "../client.js";
|
|
3
|
-
import { getProject } from "../keystore.js";
|
|
4
|
-
import { formatApiError, projectNotFound } from "../errors.js";
|
|
5
|
-
export const listFilesSchema = {
|
|
6
|
-
project_id: z.string().describe("The project ID"),
|
|
7
|
-
bucket: z.string().describe("Storage bucket name"),
|
|
8
|
-
};
|
|
9
|
-
export async function handleListFiles(args) {
|
|
10
|
-
const project = getProject(args.project_id);
|
|
11
|
-
if (!project)
|
|
12
|
-
return projectNotFound(args.project_id);
|
|
13
|
-
const res = await apiRequest(`/storage/v1/object/list/${args.bucket}`, {
|
|
14
|
-
method: "GET",
|
|
15
|
-
headers: {
|
|
16
|
-
apikey: project.anon_key,
|
|
17
|
-
Authorization: `Bearer ${project.anon_key}`,
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
if (!res.ok)
|
|
21
|
-
return formatApiError(res, "listing files");
|
|
22
|
-
const body = res.body;
|
|
23
|
-
if (body.objects.length === 0) {
|
|
24
|
-
return {
|
|
25
|
-
content: [
|
|
26
|
-
{
|
|
27
|
-
type: "text",
|
|
28
|
-
text: `## Files in \`${args.bucket}\`\n\n_No files found._`,
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const lines = [
|
|
34
|
-
`## Files in \`${args.bucket}\` (${body.objects.length})`,
|
|
35
|
-
``,
|
|
36
|
-
`| File | Size | Modified |`,
|
|
37
|
-
`|------|------|----------|`,
|
|
38
|
-
];
|
|
39
|
-
for (const obj of body.objects) {
|
|
40
|
-
const size = obj.size < 1024
|
|
41
|
-
? `${obj.size}B`
|
|
42
|
-
: `${(obj.size / 1024).toFixed(1)}KB`;
|
|
43
|
-
lines.push(`| ${obj.key} | ${size} | ${obj.last_modified} |`);
|
|
44
|
-
}
|
|
45
|
-
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=list-files.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-files.js","sourceRoot":"","sources":["../../src/tools/list-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IACjD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;CACnD,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAGrC;IACC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEtD,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,2BAA2B,IAAI,CAAC,MAAM,EAAE,EAAE;QACrE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,OAAO,CAAC,QAAQ;YACxB,aAAa,EAAE,UAAU,OAAO,CAAC,QAAQ,EAAE;SAC5C;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,cAAc,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAEzD,MAAM,IAAI,GAAG,GAAG,CAAC,IAEhB,CAAC;IAEF,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,iBAAiB,IAAI,CAAC,MAAM,yBAAyB;iBAC5D;aACF;SACF,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG;QACZ,iBAAiB,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG;QACzD,EAAE;QACF,4BAA4B;QAC5B,4BAA4B;KAC7B,CAAC;IAEF,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,IAAI,GACR,GAAG,CAAC,IAAI,GAAG,IAAI;YACb,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG;YAChB,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1C,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,MAAM,IAAI,MAAM,GAAG,CAAC,aAAa,IAAI,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACjE,CAAC"}
|
package/dist/tools/renew.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const renewSchema: {
|
|
3
|
-
project_id: z.ZodString;
|
|
4
|
-
tier: z.ZodOptional<z.ZodEnum<["prototype", "hobby", "team"]>>;
|
|
5
|
-
};
|
|
6
|
-
export declare function handleRenew(args: {
|
|
7
|
-
project_id: string;
|
|
8
|
-
tier?: string;
|
|
9
|
-
}): Promise<{
|
|
10
|
-
content: Array<{
|
|
11
|
-
type: "text";
|
|
12
|
-
text: string;
|
|
13
|
-
}>;
|
|
14
|
-
isError?: boolean;
|
|
15
|
-
}>;
|
|
16
|
-
//# sourceMappingURL=renew.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renew.d.ts","sourceRoot":"","sources":["../../src/tools/renew.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,WAAW;;;CAMvB,CAAC;AAEF,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA6DjF"}
|
package/dist/tools/renew.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { apiRequest } from "../client.js";
|
|
3
|
-
import { getProject, saveProject } from "../keystore.js";
|
|
4
|
-
import { formatApiError, projectNotFound } from "../errors.js";
|
|
5
|
-
export const renewSchema = {
|
|
6
|
-
project_id: z.string().describe("The project ID to renew"),
|
|
7
|
-
tier: z
|
|
8
|
-
.enum(["prototype", "hobby", "team"])
|
|
9
|
-
.optional()
|
|
10
|
-
.describe("Tier for renewal (defaults to current tier)"),
|
|
11
|
-
};
|
|
12
|
-
export async function handleRenew(args) {
|
|
13
|
-
const project = getProject(args.project_id);
|
|
14
|
-
if (!project)
|
|
15
|
-
return projectNotFound(args.project_id);
|
|
16
|
-
const tier = args.tier || project.tier;
|
|
17
|
-
const res = await apiRequest(`/tiers/v1/renew/${tier}`, {
|
|
18
|
-
method: "POST",
|
|
19
|
-
body: {},
|
|
20
|
-
});
|
|
21
|
-
if (res.is402) {
|
|
22
|
-
const body = res.body;
|
|
23
|
-
const lines = [
|
|
24
|
-
`## Payment Required`,
|
|
25
|
-
``,
|
|
26
|
-
`To renew project \`${args.project_id}\` (tier: **${tier}**), an x402 payment is needed.`,
|
|
27
|
-
``,
|
|
28
|
-
];
|
|
29
|
-
if (body.x402) {
|
|
30
|
-
lines.push(`**Payment details:**`);
|
|
31
|
-
lines.push("```json");
|
|
32
|
-
lines.push(JSON.stringify(body.x402, null, 2));
|
|
33
|
-
lines.push("```");
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
lines.push(`**Server response:**`);
|
|
37
|
-
lines.push("```json");
|
|
38
|
-
lines.push(JSON.stringify(body, null, 2));
|
|
39
|
-
lines.push("```");
|
|
40
|
-
}
|
|
41
|
-
lines.push(``);
|
|
42
|
-
lines.push(`The user's wallet or payment agent must send the required amount. ` +
|
|
43
|
-
`Once payment is confirmed, retry this tool call.`);
|
|
44
|
-
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
45
|
-
}
|
|
46
|
-
if (!res.ok)
|
|
47
|
-
return formatApiError(res, "renewing project");
|
|
48
|
-
const body = res.body;
|
|
49
|
-
// Update key store with new expiry
|
|
50
|
-
saveProject(args.project_id, {
|
|
51
|
-
...project,
|
|
52
|
-
tier: body.tier,
|
|
53
|
-
expires_at: body.lease_expires_at,
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
content: [
|
|
57
|
-
{
|
|
58
|
-
type: "text",
|
|
59
|
-
text: `Project \`${body.project_id}\` renewed. New expiry: **${body.lease_expires_at}**`,
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=renew.js.map
|
package/dist/tools/renew.js.map
DELETED
|
@@ -1 +0,0 @@
|
|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IAAI;aACzF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const uploadFileSchema: {
|
|
3
|
-
project_id: z.ZodString;
|
|
4
|
-
bucket: z.ZodString;
|
|
5
|
-
path: z.ZodString;
|
|
6
|
-
content: z.ZodString;
|
|
7
|
-
content_type: z.ZodDefault<z.ZodString>;
|
|
8
|
-
};
|
|
9
|
-
export declare function handleUploadFile(args: {
|
|
10
|
-
project_id: string;
|
|
11
|
-
bucket: string;
|
|
12
|
-
path: string;
|
|
13
|
-
content: string;
|
|
14
|
-
content_type?: string;
|
|
15
|
-
}): Promise<{
|
|
16
|
-
content: Array<{
|
|
17
|
-
type: "text";
|
|
18
|
-
text: string;
|
|
19
|
-
}>;
|
|
20
|
-
isError?: boolean;
|
|
21
|
-
}>;
|
|
22
|
-
//# sourceMappingURL=upload-file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload-file.d.ts","sourceRoot":"","sources":["../../src/tools/upload-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,gBAAgB;;;;;;CAS5B,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA0BjF"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { apiRequest } from "../client.js";
|
|
3
|
-
import { getProject } from "../keystore.js";
|
|
4
|
-
import { formatApiError, projectNotFound } from "../errors.js";
|
|
5
|
-
export const uploadFileSchema = {
|
|
6
|
-
project_id: z.string().describe("The project ID"),
|
|
7
|
-
bucket: z.string().describe("Storage bucket name"),
|
|
8
|
-
path: z.string().describe("File path within the bucket (e.g. 'logs/2024-01-01.txt')"),
|
|
9
|
-
content: z.string().describe("Text content to upload"),
|
|
10
|
-
content_type: z
|
|
11
|
-
.string()
|
|
12
|
-
.default("text/plain")
|
|
13
|
-
.describe("MIME type (default: text/plain)"),
|
|
14
|
-
};
|
|
15
|
-
export async function handleUploadFile(args) {
|
|
16
|
-
const project = getProject(args.project_id);
|
|
17
|
-
if (!project)
|
|
18
|
-
return projectNotFound(args.project_id);
|
|
19
|
-
const contentType = args.content_type || "text/plain";
|
|
20
|
-
const apiPath = `/storage/v1/object/${args.bucket}/${args.path}`;
|
|
21
|
-
const res = await apiRequest(apiPath, {
|
|
22
|
-
method: "POST",
|
|
23
|
-
rawBody: args.content,
|
|
24
|
-
headers: {
|
|
25
|
-
"Content-Type": contentType,
|
|
26
|
-
apikey: project.anon_key,
|
|
27
|
-
Authorization: `Bearer ${project.anon_key}`,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
if (!res.ok)
|
|
31
|
-
return formatApiError(res, "uploading file");
|
|
32
|
-
const body = res.body;
|
|
33
|
-
const text = body.url
|
|
34
|
-
? `File uploaded: **${body.key}** (${body.size} bytes)\nPublic URL: ${body.url}`
|
|
35
|
-
: `File uploaded: **${body.key}** (${body.size} bytes)`;
|
|
36
|
-
return {
|
|
37
|
-
content: [{ type: "text", text }],
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=upload-file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload-file.js","sourceRoot":"","sources":["../../src/tools/upload-file.ts"],"names":[],"mappings":"AAAA,OAAO,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,QAAQ,EAAE;SAC5C;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,cAAc,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAE1D,MAAM,IAAI,GAAG,GAAG,CAAC,IAAmD,CAAC;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG;QACnB,CAAC,CAAC,oBAAoB,IAAI,CAAC,GAAG,OAAO,IAAI,CAAC,IAAI,wBAAwB,IAAI,CAAC,GAAG,EAAE;QAChF,CAAC,CAAC,oBAAoB,IAAI,CAAC,GAAG,OAAO,IAAI,CAAC,IAAI,SAAS,CAAC;IAC1D,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-create.d.ts","sourceRoot":"","sources":["../../src/tools/wallet-create.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,kBAAkB,IAAK,CAAC;AAErC,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAC3B,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAoDhF"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { getWalletPath } from "../config.js";
|
|
2
|
-
import { readWallet, saveWallet } from "../wallet.js";
|
|
3
|
-
import { randomBytes, createECDH } from "node:crypto";
|
|
4
|
-
import { keccak_256 } from "@noble/hashes/sha3.js";
|
|
5
|
-
export const walletCreateSchema = {};
|
|
6
|
-
export async function handleWalletCreate(_args) {
|
|
7
|
-
const walletPath = getWalletPath();
|
|
8
|
-
const existing = readWallet();
|
|
9
|
-
if (existing) {
|
|
10
|
-
return {
|
|
11
|
-
content: [
|
|
12
|
-
{
|
|
13
|
-
type: "text",
|
|
14
|
-
text: `Wallet already exists at \`${walletPath}\`.\n\nAddress: \`${existing.address}\`\n\nUse \`wallet_status\` to check details.`,
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
isError: true,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
// Generate private key
|
|
21
|
-
const privateKeyBytes = randomBytes(32);
|
|
22
|
-
const privateKey = `0x${privateKeyBytes.toString("hex")}`;
|
|
23
|
-
// Derive public key using secp256k1
|
|
24
|
-
const ecdh = createECDH("secp256k1");
|
|
25
|
-
ecdh.setPrivateKey(privateKeyBytes);
|
|
26
|
-
const uncompressedPubKey = ecdh.getPublicKey();
|
|
27
|
-
// Remove the 04 prefix (uncompressed point marker)
|
|
28
|
-
const pubKeyBody = uncompressedPubKey.subarray(1);
|
|
29
|
-
// Ethereum address = last 20 bytes of keccak256(publicKey)
|
|
30
|
-
const hash = keccak_256(pubKeyBody);
|
|
31
|
-
const addressBytes = hash.slice(-20);
|
|
32
|
-
const address = `0x${Buffer.from(addressBytes).toString("hex")}`;
|
|
33
|
-
// Save wallet using core's atomic write
|
|
34
|
-
saveWallet({
|
|
35
|
-
address,
|
|
36
|
-
privateKey,
|
|
37
|
-
created: new Date().toISOString(),
|
|
38
|
-
funded: false,
|
|
39
|
-
});
|
|
40
|
-
const lines = [
|
|
41
|
-
`## Wallet Created`,
|
|
42
|
-
``,
|
|
43
|
-
`| Field | Value |`,
|
|
44
|
-
`|-------|-------|`,
|
|
45
|
-
`| address | \`${address}\` |`,
|
|
46
|
-
`| saved to | \`${walletPath}\` |`,
|
|
47
|
-
``,
|
|
48
|
-
`Use \`request_faucet\` to fund it with testnet USDC, or send USDC on any supported chain.`,
|
|
49
|
-
];
|
|
50
|
-
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=wallet-create.js.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GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IAEjE,wCAAwC;IACxC,UAAU,CAAC;QACT,OAAO;QACP,UAAU;QACV,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACjC,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG;QACZ,mBAAmB;QACnB,EAAE;QACF,mBAAmB;QACnB,mBAAmB;QACnB,iBAAiB,OAAO,MAAM;QAC9B,kBAAkB,UAAU,MAAM;QAClC,EAAE;QACF,2FAA2F;KAC5F,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACjE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-export.d.ts","sourceRoot":"","sources":["../../src/tools/wallet-export.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,IAAK,CAAC;AAErC,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAC3B,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAkBhF"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { readWallet } from "../wallet.js";
|
|
2
|
-
export const walletExportSchema = {};
|
|
3
|
-
export async function handleWalletExport(_args) {
|
|
4
|
-
const wallet = readWallet();
|
|
5
|
-
if (!wallet) {
|
|
6
|
-
return {
|
|
7
|
-
content: [
|
|
8
|
-
{
|
|
9
|
-
type: "text",
|
|
10
|
-
text: "No wallet found. Use `wallet_create` to create one.",
|
|
11
|
-
},
|
|
12
|
-
],
|
|
13
|
-
isError: true,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
content: [{ type: "text", text: wallet.address }],
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=wallet-export.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-export.js","sourceRoot":"","sources":["../../src/tools/wallet-export.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAA4B;IAE5B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,qDAAqD;iBAC5D;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-status.d.ts","sourceRoot":"","sources":["../../src/tools/wallet-status.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,IAAK,CAAC;AAErC,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAC3B,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA0BhF"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { getWalletPath } from "../config.js";
|
|
2
|
-
import { readWallet } from "../wallet.js";
|
|
3
|
-
export const walletStatusSchema = {};
|
|
4
|
-
export async function handleWalletStatus(_args) {
|
|
5
|
-
const walletPath = getWalletPath();
|
|
6
|
-
const wallet = readWallet();
|
|
7
|
-
if (!wallet) {
|
|
8
|
-
return {
|
|
9
|
-
content: [
|
|
10
|
-
{
|
|
11
|
-
type: "text",
|
|
12
|
-
text: "No wallet found. Use `wallet_create` to create one.",
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const lines = [
|
|
18
|
-
`## Wallet Status`,
|
|
19
|
-
``,
|
|
20
|
-
`| Field | Value |`,
|
|
21
|
-
`|-------|-------|`,
|
|
22
|
-
`| address | \`${wallet.address}\` |`,
|
|
23
|
-
`| created | ${wallet.created || "unknown"} |`,
|
|
24
|
-
`| funded | ${wallet.funded ? "yes" : "no"} |`,
|
|
25
|
-
];
|
|
26
|
-
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=wallet-status.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-status.js","sourceRoot":"","sources":["../../src/tools/wallet-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAA4B;IAE5B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,qDAAqD;iBAC5D;aACF;SACF,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG;QACZ,kBAAkB;QAClB,EAAE;QACF,mBAAmB;QACnB,mBAAmB;QACnB,iBAAiB,MAAM,CAAC,OAAO,MAAM;QACrC,eAAe,MAAM,CAAC,OAAO,IAAI,SAAS,IAAI;QAC9C,cAAc,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI;KAC/C,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACjE,CAAC"}
|
package/dist/wallet-auth.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wallet auth helper — re-exports core signing + adds MCP-specific error wrapper.
|
|
3
|
-
*/
|
|
4
|
-
import { getWalletAuthHeaders as _getWalletAuthHeaders, type WalletAuthHeaders } from "../core/dist/wallet-auth.js";
|
|
5
|
-
export type { WalletAuthHeaders };
|
|
6
|
-
export declare const getWalletAuthHeaders: typeof _getWalletAuthHeaders;
|
|
7
|
-
/**
|
|
8
|
-
* Get wallet auth headers or return an MCP error result.
|
|
9
|
-
*/
|
|
10
|
-
export declare function requireWalletAuth(): {
|
|
11
|
-
headers: WalletAuthHeaders;
|
|
12
|
-
} | {
|
|
13
|
-
error: {
|
|
14
|
-
content: Array<{
|
|
15
|
-
type: "text";
|
|
16
|
-
text: string;
|
|
17
|
-
}>;
|
|
18
|
-
isError: true;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=wallet-auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-auth.d.ts","sourceRoot":"","sources":["../src/wallet-auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEpH,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,eAAO,MAAM,oBAAoB,8BAAwB,CAAC;AAE1D;;GAEG;AACH,wBAAgB,iBAAiB,IAAI;IACnC,OAAO,EAAE,iBAAiB,CAAC;CAC5B,GAAG;IACF,KAAK,EAAE;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAAC,OAAO,EAAE,IAAI,CAAA;KAAE,CAAC;CAC1E,CAgBA"}
|
package/dist/wallet-auth.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wallet auth helper — re-exports core signing + adds MCP-specific error wrapper.
|
|
3
|
-
*/
|
|
4
|
-
import { getWalletAuthHeaders as _getWalletAuthHeaders } from "../core/dist/wallet-auth.js";
|
|
5
|
-
export const getWalletAuthHeaders = _getWalletAuthHeaders;
|
|
6
|
-
/**
|
|
7
|
-
* Get wallet auth headers or return an MCP error result.
|
|
8
|
-
*/
|
|
9
|
-
export function requireWalletAuth() {
|
|
10
|
-
const headers = getWalletAuthHeaders();
|
|
11
|
-
if (!headers) {
|
|
12
|
-
return {
|
|
13
|
-
error: {
|
|
14
|
-
content: [
|
|
15
|
-
{
|
|
16
|
-
type: "text",
|
|
17
|
-
text: "Error: No wallet configured. Use `wallet_create` to create a wallet first, then `request_faucet` to fund it.",
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
isError: true,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return { headers };
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=wallet-auth.js.map
|
package/dist/wallet-auth.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-auth.js","sourceRoot":"","sources":["../src/wallet-auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,IAAI,qBAAqB,EAA0B,MAAM,6BAA6B,CAAC;AAIpH,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAK/B,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,KAAK,EAAE;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,8GAA8G;qBACrH;iBACF;gBACD,OAAO,EAAE,IAAI;aACd;SACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC"}
|
package/dist/wallet.d.ts
DELETED
package/dist/wallet.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/wallet.js
DELETED
package/dist/wallet.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wallet auth helper — generates EIP-191 signature headers for Run402 API.
|
|
3
|
-
* Uses @noble/curves (lighter than viem) for signing.
|
|
4
|
-
*/
|
|
5
|
-
export interface WalletAuthHeaders {
|
|
6
|
-
"X-Run402-Wallet": string;
|
|
7
|
-
"X-Run402-Signature": string;
|
|
8
|
-
"X-Run402-Timestamp": string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Get wallet auth headers for the Run402 API.
|
|
12
|
-
* Returns null if no wallet is configured.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getWalletAuthHeaders(walletPath?: string): WalletAuthHeaders | null;
|
|
15
|
-
//# sourceMappingURL=wallet-auth.d.ts.map
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wallet auth helper — generates EIP-191 signature headers for Run402 API.
|
|
3
|
-
* Uses @noble/curves (lighter than viem) for signing.
|
|
4
|
-
*/
|
|
5
|
-
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
6
|
-
import { keccak_256 } from "@noble/hashes/sha3.js";
|
|
7
|
-
import { bytesToHex } from "@noble/hashes/utils.js";
|
|
8
|
-
import { readWallet } from "./wallet.js";
|
|
9
|
-
/**
|
|
10
|
-
* EIP-191 personal_sign: sign a message with the wallet's private key.
|
|
11
|
-
*/
|
|
12
|
-
function personalSign(privateKeyHex, address, message) {
|
|
13
|
-
const msgBytes = new TextEncoder().encode(message);
|
|
14
|
-
const prefix = new TextEncoder().encode(`\x19Ethereum Signed Message:\n${msgBytes.length}`);
|
|
15
|
-
const prefixed = new Uint8Array(prefix.length + msgBytes.length);
|
|
16
|
-
prefixed.set(prefix);
|
|
17
|
-
prefixed.set(msgBytes, prefix.length);
|
|
18
|
-
const hash = keccak_256(prefixed);
|
|
19
|
-
const pkHex = privateKeyHex.startsWith("0x")
|
|
20
|
-
? privateKeyHex.slice(2)
|
|
21
|
-
: privateKeyHex;
|
|
22
|
-
const pkBytes = Uint8Array.from(Buffer.from(pkHex, "hex"));
|
|
23
|
-
const rawSig = secp256k1.sign(hash, pkBytes);
|
|
24
|
-
const sig = secp256k1.Signature.fromBytes(rawSig);
|
|
25
|
-
// Determine recovery bit by trying both and matching the address
|
|
26
|
-
let recovery = 0;
|
|
27
|
-
for (const v of [0, 1]) {
|
|
28
|
-
try {
|
|
29
|
-
const recovered = sig.addRecoveryBit(v).recoverPublicKey(hash);
|
|
30
|
-
const pubBytes = recovered.toBytes(false).slice(1); // uncompressed, drop 04 prefix
|
|
31
|
-
const addrBytes = keccak_256(pubBytes).slice(-20);
|
|
32
|
-
if ("0x" + bytesToHex(addrBytes) === address.toLowerCase()) {
|
|
33
|
-
recovery = v;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const r = sig.r.toString(16).padStart(64, "0");
|
|
42
|
-
const s = sig.s.toString(16).padStart(64, "0");
|
|
43
|
-
const vHex = (recovery + 27).toString(16).padStart(2, "0");
|
|
44
|
-
return "0x" + r + s + vHex;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Get wallet auth headers for the Run402 API.
|
|
48
|
-
* Returns null if no wallet is configured.
|
|
49
|
-
*/
|
|
50
|
-
export function getWalletAuthHeaders(walletPath) {
|
|
51
|
-
const wallet = readWallet(walletPath);
|
|
52
|
-
if (!wallet || !wallet.address || !wallet.privateKey)
|
|
53
|
-
return null;
|
|
54
|
-
const timestamp = Math.floor(Date.now() / 1000).toString();
|
|
55
|
-
const signature = personalSign(wallet.privateKey, wallet.address, `run402:${timestamp}`);
|
|
56
|
-
return {
|
|
57
|
-
"X-Run402-Wallet": wallet.address,
|
|
58
|
-
"X-Run402-Signature": signature,
|
|
59
|
-
"X-Run402-Timestamp": timestamp,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=wallet-auth.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface WalletData {
|
|
2
|
-
address: string;
|
|
3
|
-
privateKey: string;
|
|
4
|
-
created?: string;
|
|
5
|
-
funded?: boolean;
|
|
6
|
-
lastFaucet?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function readWallet(path?: string): WalletData | null;
|
|
9
|
-
export declare function saveWallet(data: WalletData, path?: string): void;
|
|
10
|
-
//# sourceMappingURL=wallet.d.ts.map
|
package/sdk/core-dist/wallet.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync, chmodSync, renameSync } from "node:fs";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { randomBytes } from "node:crypto";
|
|
4
|
-
import { getWalletPath } from "./config.js";
|
|
5
|
-
export function readWallet(path) {
|
|
6
|
-
const p = path ?? getWalletPath();
|
|
7
|
-
if (!existsSync(p))
|
|
8
|
-
return null;
|
|
9
|
-
try {
|
|
10
|
-
return JSON.parse(readFileSync(p, "utf-8"));
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export function saveWallet(data, path) {
|
|
17
|
-
const p = path ?? getWalletPath();
|
|
18
|
-
const dir = dirname(p);
|
|
19
|
-
mkdirSync(dir, { recursive: true });
|
|
20
|
-
const tmp = join(dir, `.wallet.${randomBytes(4).toString("hex")}.tmp`);
|
|
21
|
-
writeFileSync(tmp, JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
22
|
-
renameSync(tmp, p);
|
|
23
|
-
chmodSync(p, 0o600);
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=wallet.js.map
|