@openfort/cli 0.1.7 → 0.1.8
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/README.md +0 -8
- package/dist/cli.js +88 -67
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,14 +98,6 @@ openfort skills add
|
|
|
98
98
|
| `embedded-wallet` | Configure embedded wallet (Shield) API keys |
|
|
99
99
|
| `message` | Message utilities (e.g. keccak256 hashing) |
|
|
100
100
|
|
|
101
|
-
## Alias
|
|
102
|
-
|
|
103
|
-
The CLI is also available as `of`:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
of accounts list
|
|
107
|
-
```
|
|
108
|
-
|
|
109
101
|
## Documentation
|
|
110
102
|
|
|
111
103
|
For full documentation, visit [openfort.io/docs/overview/building-with-cli](https://www.openfort.io/docs/overview/building-with-cli).
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
import { readFileSync as readFileSync2 } from "fs";
|
|
9
|
-
import { Cli as
|
|
9
|
+
import { Cli as Cli14, z as z15, Errors as Errors5 } from "incur";
|
|
10
10
|
import Openfort from "@openfort/openfort-node";
|
|
11
11
|
|
|
12
12
|
// src/vars.ts
|
|
@@ -21,14 +21,9 @@ var OPENFORT_SHIELD_URL = process.env.OPENFORT_SHIELD_URL || "https://shield.ope
|
|
|
21
21
|
var AUTH_PAGE_URL = process.env.OPENFORT_AUTH_PAGE_URL || "https://dashboard.openfort.io";
|
|
22
22
|
var CLI_CALLBACK_PORT = Number(process.env.OPENFORT_CLI_CALLBACK_PORT) || 8271;
|
|
23
23
|
|
|
24
|
-
// src/commands/login.ts
|
|
25
|
-
import { randomBytes } from "crypto";
|
|
26
|
-
import { createServer } from "http";
|
|
27
|
-
import open from "open";
|
|
28
|
-
import { z as z2 } from "incur";
|
|
29
|
-
|
|
30
24
|
// src/env.ts
|
|
31
25
|
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
26
|
+
import { Errors } from "incur";
|
|
32
27
|
function loadEnvFile(envPath) {
|
|
33
28
|
const entries = /* @__PURE__ */ new Map();
|
|
34
29
|
if (!existsSync(envPath)) return entries;
|
|
@@ -54,8 +49,23 @@ function writeEnvKey(envPath, key, value) {
|
|
|
54
49
|
writeFileSync(envPath, `${lines.join("\n")}
|
|
55
50
|
`);
|
|
56
51
|
}
|
|
52
|
+
function requireApiKey() {
|
|
53
|
+
const apiKey = process.env.OPENFORT_API_KEY;
|
|
54
|
+
if (!apiKey) {
|
|
55
|
+
throw new Errors.IncurError({
|
|
56
|
+
code: "MISSING_API_KEY",
|
|
57
|
+
message: "OPENFORT_API_KEY is required.",
|
|
58
|
+
hint: "Run: openfort login"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return apiKey;
|
|
62
|
+
}
|
|
57
63
|
|
|
58
64
|
// src/commands/login.ts
|
|
65
|
+
import { randomBytes } from "crypto";
|
|
66
|
+
import { createServer } from "http";
|
|
67
|
+
import open from "open";
|
|
68
|
+
import { Cli, z as z2 } from "incur";
|
|
59
69
|
function base64url(buffer) {
|
|
60
70
|
return buffer.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
61
71
|
}
|
|
@@ -151,7 +161,7 @@ function waitForCallback(port, state) {
|
|
|
151
161
|
reject(new Error("Login timed out after 5 minutes. Please try again."));
|
|
152
162
|
}, 5 * 60 * 1e3);
|
|
153
163
|
const server = createServer((req, res) => {
|
|
154
|
-
const url = new URL(req.url, `http://localhost:${port}`);
|
|
164
|
+
const url = new URL(req.url ?? "/", `http://localhost:${port}`);
|
|
155
165
|
if (url.pathname === "/callback") {
|
|
156
166
|
const apiKey = url.searchParams.get("api_key");
|
|
157
167
|
const publishableKey = url.searchParams.get("publishable_key");
|
|
@@ -186,7 +196,7 @@ function waitForCallback(port, state) {
|
|
|
186
196
|
server.listen(port);
|
|
187
197
|
});
|
|
188
198
|
}
|
|
189
|
-
var
|
|
199
|
+
var login = Cli.create("login", {
|
|
190
200
|
description: "Log in to Openfort via browser and save your API key.",
|
|
191
201
|
output: z2.object({
|
|
192
202
|
apiKey: z2.string().describe("The API key saved to credentials"),
|
|
@@ -236,10 +246,10 @@ var loginConfig = {
|
|
|
236
246
|
}
|
|
237
247
|
);
|
|
238
248
|
}
|
|
239
|
-
};
|
|
249
|
+
});
|
|
240
250
|
|
|
241
251
|
// src/commands/accounts.ts
|
|
242
|
-
import { Cli, z as z3, middleware } from "incur";
|
|
252
|
+
import { Cli as Cli2, z as z3, middleware } from "incur";
|
|
243
253
|
var requireWallet = middleware((c, next) => {
|
|
244
254
|
const missing = [];
|
|
245
255
|
if (!process.env.OPENFORT_WALLET_SECRET) missing.push("OPENFORT_WALLET_SECRET");
|
|
@@ -256,7 +266,7 @@ var requireWallet = middleware((c, next) => {
|
|
|
256
266
|
}
|
|
257
267
|
return next();
|
|
258
268
|
});
|
|
259
|
-
var evm =
|
|
269
|
+
var evm = Cli2.create("evm", {
|
|
260
270
|
description: "EVM wallet management.",
|
|
261
271
|
vars: varsSchema
|
|
262
272
|
});
|
|
@@ -588,7 +598,7 @@ evm.command("send-transaction", {
|
|
|
588
598
|
});
|
|
589
599
|
}
|
|
590
600
|
});
|
|
591
|
-
var solana =
|
|
601
|
+
var solana = Cli2.create("solana", {
|
|
592
602
|
description: "Solana wallet management.",
|
|
593
603
|
vars: varsSchema
|
|
594
604
|
});
|
|
@@ -802,7 +812,7 @@ solana.command("transfer", {
|
|
|
802
812
|
return c.ok({ signature: res.signature });
|
|
803
813
|
}
|
|
804
814
|
});
|
|
805
|
-
var accounts =
|
|
815
|
+
var accounts = Cli2.create("accounts", {
|
|
806
816
|
description: "Manage wallets and accounts.",
|
|
807
817
|
vars: varsSchema
|
|
808
818
|
});
|
|
@@ -863,7 +873,7 @@ accounts.command(evm);
|
|
|
863
873
|
accounts.command(solana);
|
|
864
874
|
|
|
865
875
|
// src/commands/contracts.ts
|
|
866
|
-
import { Cli as
|
|
876
|
+
import { Cli as Cli3, z as z4 } from "incur";
|
|
867
877
|
var contractItem = z4.object({
|
|
868
878
|
id: z4.string(),
|
|
869
879
|
createdAt: z4.number(),
|
|
@@ -871,10 +881,10 @@ var contractItem = z4.object({
|
|
|
871
881
|
chainId: z4.number(),
|
|
872
882
|
address: z4.string(),
|
|
873
883
|
deleted: z4.boolean(),
|
|
874
|
-
abi: z4.array(z4.
|
|
884
|
+
abi: z4.array(z4.record(z4.string(), z4.unknown())),
|
|
875
885
|
publicVerification: z4.boolean()
|
|
876
886
|
});
|
|
877
|
-
var contracts =
|
|
887
|
+
var contracts = Cli3.create("contracts", {
|
|
878
888
|
description: "Manage smart contracts.",
|
|
879
889
|
vars: varsSchema
|
|
880
890
|
});
|
|
@@ -1038,7 +1048,7 @@ contracts.command("delete", {
|
|
|
1038
1048
|
});
|
|
1039
1049
|
|
|
1040
1050
|
// src/commands/paymasters.ts
|
|
1041
|
-
import { Cli as
|
|
1051
|
+
import { Cli as Cli4, z as z5 } from "incur";
|
|
1042
1052
|
var paymasterItem = z5.object({
|
|
1043
1053
|
id: z5.string(),
|
|
1044
1054
|
createdAt: z5.number(),
|
|
@@ -1046,7 +1056,7 @@ var paymasterItem = z5.object({
|
|
|
1046
1056
|
url: z5.string().optional(),
|
|
1047
1057
|
context: z5.record(z5.string(), z5.unknown()).optional()
|
|
1048
1058
|
});
|
|
1049
|
-
var paymasters =
|
|
1059
|
+
var paymasters = Cli4.create("paymasters", {
|
|
1050
1060
|
description: "Manage ERC-4337 paymasters.",
|
|
1051
1061
|
vars: varsSchema
|
|
1052
1062
|
});
|
|
@@ -1113,7 +1123,7 @@ paymasters.command("update", {
|
|
|
1113
1123
|
id: z5.string().describe("Paymaster ID (pay_...)")
|
|
1114
1124
|
}),
|
|
1115
1125
|
options: z5.object({
|
|
1116
|
-
address: z5.string().
|
|
1126
|
+
address: z5.string().describe("Paymaster address"),
|
|
1117
1127
|
name: z5.string().optional().describe("New name"),
|
|
1118
1128
|
url: z5.string().optional().describe("New URL")
|
|
1119
1129
|
}),
|
|
@@ -1155,9 +1165,9 @@ paymasters.command("delete", {
|
|
|
1155
1165
|
});
|
|
1156
1166
|
|
|
1157
1167
|
// src/commands/policies.ts
|
|
1158
|
-
import { Cli as
|
|
1168
|
+
import { Cli as Cli5, z as z6 } from "incur";
|
|
1159
1169
|
var policyScopes = ["project", "account", "transaction"];
|
|
1160
|
-
var policies =
|
|
1170
|
+
var policies = Cli5.create("policies", {
|
|
1161
1171
|
description: "Manage rules and conditions for backend wallets and fee sponsorship.",
|
|
1162
1172
|
vars: varsSchema
|
|
1163
1173
|
});
|
|
@@ -1287,7 +1297,7 @@ policies.command("get", {
|
|
|
1287
1297
|
accountId: z6.string().nullable(),
|
|
1288
1298
|
enabled: z6.boolean(),
|
|
1289
1299
|
priority: z6.number(),
|
|
1290
|
-
rules: z6.array(z6.
|
|
1300
|
+
rules: z6.array(z6.record(z6.string(), z6.unknown()))
|
|
1291
1301
|
}),
|
|
1292
1302
|
async run(c) {
|
|
1293
1303
|
const p = await c.var.openfort.policies.get(c.args.id);
|
|
@@ -1395,7 +1405,7 @@ policies.command("evaluate", {
|
|
|
1395
1405
|
});
|
|
1396
1406
|
|
|
1397
1407
|
// src/commands/sponsorship.ts
|
|
1398
|
-
import { Cli as
|
|
1408
|
+
import { Cli as Cli6, z as z7 } from "incur";
|
|
1399
1409
|
var sponsorSchemas = ["pay_for_user", "charge_custom_tokens", "fixed_rate"];
|
|
1400
1410
|
var sponsorshipItem = z7.object({
|
|
1401
1411
|
id: z7.string(),
|
|
@@ -1412,7 +1422,7 @@ var sponsorshipItem = z7.object({
|
|
|
1412
1422
|
paymasterId: z7.string().nullable(),
|
|
1413
1423
|
policyId: z7.string().nullable()
|
|
1414
1424
|
});
|
|
1415
|
-
var sponsorship =
|
|
1425
|
+
var sponsorship = Cli6.create("sponsorship", {
|
|
1416
1426
|
description: "Manage fee sponsorship strategies linked to policies.",
|
|
1417
1427
|
vars: varsSchema
|
|
1418
1428
|
});
|
|
@@ -1624,7 +1634,7 @@ sponsorship.command("delete", {
|
|
|
1624
1634
|
});
|
|
1625
1635
|
|
|
1626
1636
|
// src/commands/subscriptions.ts
|
|
1627
|
-
import { Cli as
|
|
1637
|
+
import { Cli as Cli7, z as z8 } from "incur";
|
|
1628
1638
|
var apiTopics = [
|
|
1629
1639
|
"transaction_intent.broadcast",
|
|
1630
1640
|
"transaction_intent.successful",
|
|
@@ -1640,7 +1650,7 @@ var apiTopics = [
|
|
|
1640
1650
|
"account.created"
|
|
1641
1651
|
];
|
|
1642
1652
|
var apiTriggerTypes = ["webhook", "email"];
|
|
1643
|
-
var triggers =
|
|
1653
|
+
var triggers = Cli7.create("triggers", {
|
|
1644
1654
|
description: "Manage subscription triggers.",
|
|
1645
1655
|
vars: varsSchema
|
|
1646
1656
|
});
|
|
@@ -1750,7 +1760,7 @@ triggers.command("delete", {
|
|
|
1750
1760
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
1751
1761
|
}
|
|
1752
1762
|
});
|
|
1753
|
-
var subscriptions =
|
|
1763
|
+
var subscriptions = Cli7.create("subscriptions", {
|
|
1754
1764
|
description: "Manage webhook subscriptions.",
|
|
1755
1765
|
vars: varsSchema
|
|
1756
1766
|
});
|
|
@@ -1883,7 +1893,7 @@ subscriptions.command("delete", {
|
|
|
1883
1893
|
subscriptions.command(triggers);
|
|
1884
1894
|
|
|
1885
1895
|
// src/commands/sessions.ts
|
|
1886
|
-
import { Cli as
|
|
1896
|
+
import { Cli as Cli8, z as z9 } from "incur";
|
|
1887
1897
|
var sessionItem = z9.object({
|
|
1888
1898
|
id: z9.string(),
|
|
1889
1899
|
createdAt: z9.number(),
|
|
@@ -1895,10 +1905,10 @@ var sessionItem = z9.object({
|
|
|
1895
1905
|
isActive: z9.boolean(),
|
|
1896
1906
|
nextAction: z9.object({
|
|
1897
1907
|
type: z9.string(),
|
|
1898
|
-
payload: z9.
|
|
1908
|
+
payload: z9.record(z9.string(), z9.unknown()).optional()
|
|
1899
1909
|
}).optional()
|
|
1900
1910
|
});
|
|
1901
|
-
var sessions =
|
|
1911
|
+
var sessions = Cli8.create("sessions", {
|
|
1902
1912
|
description: "Manage session keys.",
|
|
1903
1913
|
vars: varsSchema
|
|
1904
1914
|
});
|
|
@@ -2089,7 +2099,7 @@ sessions.command("sign", {
|
|
|
2089
2099
|
});
|
|
2090
2100
|
|
|
2091
2101
|
// src/commands/transactions.ts
|
|
2092
|
-
import { Cli as
|
|
2102
|
+
import { Cli as Cli9, z as z10 } from "incur";
|
|
2093
2103
|
var transactionIntentItem = z10.object({
|
|
2094
2104
|
id: z10.string(),
|
|
2095
2105
|
createdAt: z10.number(),
|
|
@@ -2105,7 +2115,7 @@ var transactionIntentItem = z10.object({
|
|
|
2105
2115
|
gasFee: z10.string().optional(),
|
|
2106
2116
|
status: z10.number().optional(),
|
|
2107
2117
|
to: z10.string().optional(),
|
|
2108
|
-
error: z10.
|
|
2118
|
+
error: z10.record(z10.string(), z10.unknown()).optional()
|
|
2109
2119
|
}).optional(),
|
|
2110
2120
|
interactions: z10.array(z10.object({
|
|
2111
2121
|
to: z10.string().optional(),
|
|
@@ -2114,10 +2124,10 @@ var transactionIntentItem = z10.object({
|
|
|
2114
2124
|
})).optional(),
|
|
2115
2125
|
nextAction: z10.object({
|
|
2116
2126
|
type: z10.string(),
|
|
2117
|
-
payload: z10.
|
|
2127
|
+
payload: z10.record(z10.string(), z10.unknown()).optional()
|
|
2118
2128
|
}).optional()
|
|
2119
2129
|
});
|
|
2120
|
-
var transactions =
|
|
2130
|
+
var transactions = Cli9.create("transactions", {
|
|
2121
2131
|
description: "Manage transaction intents.",
|
|
2122
2132
|
vars: varsSchema
|
|
2123
2133
|
});
|
|
@@ -2326,9 +2336,9 @@ transactions.command("estimate", {
|
|
|
2326
2336
|
});
|
|
2327
2337
|
|
|
2328
2338
|
// src/commands/embedded-wallet.ts
|
|
2329
|
-
import { Cli as
|
|
2339
|
+
import { Cli as Cli10, z as z11, Errors as Errors3 } from "incur";
|
|
2330
2340
|
var SHIELD_API_URL = OPENFORT_SHIELD_URL;
|
|
2331
|
-
var embeddedWallet =
|
|
2341
|
+
var embeddedWallet = Cli10.create("embedded-wallet", {
|
|
2332
2342
|
description: "Configure embedded wallet (Shield) API keys.",
|
|
2333
2343
|
vars: varsSchema
|
|
2334
2344
|
});
|
|
@@ -2352,17 +2362,17 @@ embeddedWallet.command("setup", {
|
|
|
2352
2362
|
async run(c) {
|
|
2353
2363
|
const publishableKey = process.env.OPENFORT_PUBLISHABLE_KEY;
|
|
2354
2364
|
if (!publishableKey) {
|
|
2355
|
-
throw new
|
|
2365
|
+
throw new Errors3.IncurError({
|
|
2356
2366
|
code: "MISSING_PUBLISHABLE_KEY",
|
|
2357
2367
|
message: "OPENFORT_PUBLISHABLE_KEY environment variable is required to create Shield keys.",
|
|
2358
2368
|
hint: "Run: openfort login"
|
|
2359
2369
|
});
|
|
2360
2370
|
}
|
|
2361
|
-
const apiKey =
|
|
2371
|
+
const apiKey = requireApiKey();
|
|
2362
2372
|
const environment = apiKey.startsWith("sk_live_") ? "live" : "test";
|
|
2363
2373
|
const projectId = c.options.project || process.env.OPENFORT_PROJECT_ID;
|
|
2364
2374
|
if (!projectId) {
|
|
2365
|
-
throw new
|
|
2375
|
+
throw new Errors3.IncurError({
|
|
2366
2376
|
code: "MISSING_PROJECT_ID",
|
|
2367
2377
|
message: "Project ID is required. Pass --project or set OPENFORT_PROJECT_ID.",
|
|
2368
2378
|
hint: "Run: openfort login"
|
|
@@ -2382,7 +2392,7 @@ embeddedWallet.command("setup", {
|
|
|
2382
2392
|
});
|
|
2383
2393
|
if (!registerRes.ok) {
|
|
2384
2394
|
const text = await registerRes.text();
|
|
2385
|
-
throw new
|
|
2395
|
+
throw new Errors3.IncurError({
|
|
2386
2396
|
code: "SHIELD_REGISTER_FAILED",
|
|
2387
2397
|
message: `Shield registration failed: ${text}`,
|
|
2388
2398
|
retryable: true
|
|
@@ -2390,7 +2400,7 @@ embeddedWallet.command("setup", {
|
|
|
2390
2400
|
}
|
|
2391
2401
|
const shieldData = await registerRes.json();
|
|
2392
2402
|
if (shieldData.error) {
|
|
2393
|
-
throw new
|
|
2403
|
+
throw new Errors3.IncurError({
|
|
2394
2404
|
code: "SHIELD_REGISTER_ERROR",
|
|
2395
2405
|
message: `Shield registration error: ${shieldData.error}`
|
|
2396
2406
|
});
|
|
@@ -2406,7 +2416,7 @@ embeddedWallet.command("setup", {
|
|
|
2406
2416
|
});
|
|
2407
2417
|
if (!res.ok) {
|
|
2408
2418
|
const text = await res.text();
|
|
2409
|
-
throw new
|
|
2419
|
+
throw new Errors3.IncurError({
|
|
2410
2420
|
code: "PERSIST_KEY_FAILED",
|
|
2411
2421
|
message: `Failed to persist ${type} key: ${text}`,
|
|
2412
2422
|
retryable: true
|
|
@@ -2434,7 +2444,7 @@ embeddedWallet.command("setup", {
|
|
|
2434
2444
|
});
|
|
2435
2445
|
if (!linkRes.ok) {
|
|
2436
2446
|
const text = await linkRes.text();
|
|
2437
|
-
throw new
|
|
2447
|
+
throw new Errors3.IncurError({
|
|
2438
2448
|
code: "SHIELD_LINK_FAILED",
|
|
2439
2449
|
message: `Failed to link Openfort provider to Shield: ${text}`,
|
|
2440
2450
|
retryable: true
|
|
@@ -2461,7 +2471,7 @@ embeddedWallet.command("setup", {
|
|
|
2461
2471
|
});
|
|
2462
2472
|
|
|
2463
2473
|
// src/commands/users.ts
|
|
2464
|
-
import { Cli as
|
|
2474
|
+
import { Cli as Cli11, z as z12 } from "incur";
|
|
2465
2475
|
var userItem = z12.object({
|
|
2466
2476
|
id: z12.string(),
|
|
2467
2477
|
createdAt: z12.number(),
|
|
@@ -2481,7 +2491,7 @@ var userItem = z12.object({
|
|
|
2481
2491
|
walletClientType: z12.string().optional()
|
|
2482
2492
|
}))
|
|
2483
2493
|
});
|
|
2484
|
-
var users =
|
|
2494
|
+
var users = Cli11.create("users", {
|
|
2485
2495
|
description: "Manage authenticated users.",
|
|
2486
2496
|
vars: varsSchema
|
|
2487
2497
|
});
|
|
@@ -2569,7 +2579,7 @@ users.command("delete", {
|
|
|
2569
2579
|
|
|
2570
2580
|
// src/commands/backend-wallet.ts
|
|
2571
2581
|
import { randomBytes as randomBytes2, subtle } from "crypto";
|
|
2572
|
-
import { Cli as
|
|
2582
|
+
import { Cli as Cli12, z as z13, Errors as Errors4 } from "incur";
|
|
2573
2583
|
function arrayBufferToBase64(buffer) {
|
|
2574
2584
|
return Buffer.from(buffer).toString("base64");
|
|
2575
2585
|
}
|
|
@@ -2577,7 +2587,7 @@ function arrayBufferToBase64Url(buffer) {
|
|
|
2577
2587
|
return Buffer.from(buffer).toString("base64url");
|
|
2578
2588
|
}
|
|
2579
2589
|
function stringToArrayBuffer(str) {
|
|
2580
|
-
return new TextEncoder().encode(str)
|
|
2590
|
+
return new TextEncoder().encode(str);
|
|
2581
2591
|
}
|
|
2582
2592
|
function formatPEMBody(base64) {
|
|
2583
2593
|
return base64.match(/.{1,64}/g)?.join("\n") || base64;
|
|
@@ -2585,9 +2595,10 @@ function formatPEMBody(base64) {
|
|
|
2585
2595
|
function sortObjectKeys(obj) {
|
|
2586
2596
|
if (obj === null || typeof obj !== "object") return obj;
|
|
2587
2597
|
if (Array.isArray(obj)) return obj.map(sortObjectKeys);
|
|
2598
|
+
const record = obj;
|
|
2588
2599
|
const sorted = {};
|
|
2589
|
-
for (const key of Object.keys(
|
|
2590
|
-
sorted[key] = sortObjectKeys(
|
|
2600
|
+
for (const key of Object.keys(record).sort()) {
|
|
2601
|
+
sorted[key] = sortObjectKeys(record[key]);
|
|
2591
2602
|
}
|
|
2592
2603
|
return sorted;
|
|
2593
2604
|
}
|
|
@@ -2639,7 +2650,7 @@ async function signWalletAuthJwt(privateKey, method, path, body) {
|
|
|
2639
2650
|
);
|
|
2640
2651
|
return `${signingInput}.${arrayBufferToBase64Url(signature)}`;
|
|
2641
2652
|
}
|
|
2642
|
-
var backendWallet =
|
|
2653
|
+
var backendWallet = Cli12.create("backend-wallet", {
|
|
2643
2654
|
description: "Configure backend wallet signing keys.",
|
|
2644
2655
|
vars: varsSchema
|
|
2645
2656
|
});
|
|
@@ -2656,7 +2667,7 @@ backendWallet.command("setup", {
|
|
|
2656
2667
|
],
|
|
2657
2668
|
hint: 'Requires OPENFORT_API_KEY. Run "openfort login" first.',
|
|
2658
2669
|
async run(c) {
|
|
2659
|
-
const apiKey =
|
|
2670
|
+
const apiKey = requireApiKey();
|
|
2660
2671
|
const { publicKey, privateKey, privateKeyCrypto } = await generateKeyPair();
|
|
2661
2672
|
const publicKeyPEM = `-----BEGIN PUBLIC KEY-----
|
|
2662
2673
|
${publicKey}
|
|
@@ -2678,7 +2689,7 @@ ${publicKey}
|
|
|
2678
2689
|
});
|
|
2679
2690
|
if (!registerRes.ok) {
|
|
2680
2691
|
const text = await registerRes.text();
|
|
2681
|
-
throw new
|
|
2692
|
+
throw new Errors4.IncurError({
|
|
2682
2693
|
code: "REGISTER_SECRET_FAILED",
|
|
2683
2694
|
message: `Failed to register wallet secret: ${text}`,
|
|
2684
2695
|
retryable: true
|
|
@@ -2694,7 +2705,7 @@ ${publicKey}
|
|
|
2694
2705
|
});
|
|
2695
2706
|
if (!storeRes.ok) {
|
|
2696
2707
|
const text = await storeRes.text();
|
|
2697
|
-
throw new
|
|
2708
|
+
throw new Errors4.IncurError({
|
|
2698
2709
|
code: "STORE_KEY_FAILED",
|
|
2699
2710
|
message: `Failed to store wallet key reference: ${text}`,
|
|
2700
2711
|
retryable: true
|
|
@@ -2731,11 +2742,11 @@ backendWallet.command("revoke", {
|
|
|
2731
2742
|
],
|
|
2732
2743
|
hint: 'Requires OPENFORT_WALLET_KEY_ID and OPENFORT_WALLET_SECRET. Run "openfort backend-wallet setup" first.',
|
|
2733
2744
|
async run(c) {
|
|
2734
|
-
const apiKey =
|
|
2745
|
+
const apiKey = requireApiKey();
|
|
2735
2746
|
const keyId = process.env.OPENFORT_WALLET_KEY_ID;
|
|
2736
2747
|
const privateKeyBase64 = process.env.OPENFORT_WALLET_SECRET;
|
|
2737
2748
|
if (!keyId || !privateKeyBase64) {
|
|
2738
|
-
throw new
|
|
2749
|
+
throw new Errors4.IncurError({
|
|
2739
2750
|
code: "MISSING_WALLET_KEY",
|
|
2740
2751
|
message: "OPENFORT_WALLET_KEY_ID and OPENFORT_WALLET_SECRET must be set. Run `backend-wallet setup` first.",
|
|
2741
2752
|
hint: "Run: openfort backend-wallet setup"
|
|
@@ -2756,7 +2767,7 @@ backendWallet.command("revoke", {
|
|
|
2756
2767
|
});
|
|
2757
2768
|
if (!res.ok) {
|
|
2758
2769
|
const text = await res.text();
|
|
2759
|
-
throw new
|
|
2770
|
+
throw new Errors4.IncurError({
|
|
2760
2771
|
code: "REVOKE_SECRET_FAILED",
|
|
2761
2772
|
message: `Failed to revoke wallet secret: ${text}`,
|
|
2762
2773
|
retryable: true
|
|
@@ -2779,7 +2790,7 @@ backendWallet.command("rotate", {
|
|
|
2779
2790
|
],
|
|
2780
2791
|
hint: 'Requires OPENFORT_API_KEY. Run "openfort login" first.',
|
|
2781
2792
|
async run(c) {
|
|
2782
|
-
const apiKey =
|
|
2793
|
+
const apiKey = requireApiKey();
|
|
2783
2794
|
const { publicKey, privateKey, privateKeyCrypto } = await generateKeyPair();
|
|
2784
2795
|
const newPublicKeyPEM = `-----BEGIN PUBLIC KEY-----
|
|
2785
2796
|
${publicKey}
|
|
@@ -2801,7 +2812,7 @@ ${publicKey}
|
|
|
2801
2812
|
});
|
|
2802
2813
|
if (!rotateRes.ok) {
|
|
2803
2814
|
const text = await rotateRes.text();
|
|
2804
|
-
throw new
|
|
2815
|
+
throw new Errors4.IncurError({
|
|
2805
2816
|
code: "ROTATE_SECRET_FAILED",
|
|
2806
2817
|
message: `Failed to rotate wallet secret: ${text}`,
|
|
2807
2818
|
retryable: true
|
|
@@ -2817,7 +2828,7 @@ ${publicKey}
|
|
|
2817
2828
|
});
|
|
2818
2829
|
if (!storeRes.ok) {
|
|
2819
2830
|
const text = await storeRes.text();
|
|
2820
|
-
throw new
|
|
2831
|
+
throw new Errors4.IncurError({
|
|
2821
2832
|
code: "STORE_KEY_FAILED",
|
|
2822
2833
|
message: `Failed to store rotated wallet key reference: ${text}`,
|
|
2823
2834
|
retryable: true
|
|
@@ -2832,9 +2843,9 @@ ${publicKey}
|
|
|
2832
2843
|
});
|
|
2833
2844
|
|
|
2834
2845
|
// src/commands/message.ts
|
|
2835
|
-
import { Cli as
|
|
2846
|
+
import { Cli as Cli13, z as z14 } from "incur";
|
|
2836
2847
|
import { keccak256, toBytes } from "viem";
|
|
2837
|
-
var message =
|
|
2848
|
+
var message = Cli13.create("message", {
|
|
2838
2849
|
description: "Message utilities.",
|
|
2839
2850
|
vars: varsSchema
|
|
2840
2851
|
});
|
|
@@ -2857,9 +2868,8 @@ message.command("hash", {
|
|
|
2857
2868
|
|
|
2858
2869
|
// src/cli.ts
|
|
2859
2870
|
var pkg = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf-8"));
|
|
2860
|
-
var cli =
|
|
2871
|
+
var cli = Cli14.create("openfort", {
|
|
2861
2872
|
version: pkg.version,
|
|
2862
|
-
aliases: ["of"],
|
|
2863
2873
|
description: "Openfort CLI \u2014 manage wallets, policies, and transactions from the terminal.",
|
|
2864
2874
|
vars: varsSchema,
|
|
2865
2875
|
env: z15.object({
|
|
@@ -2883,16 +2893,27 @@ var cli = Cli13.create("openfort", {
|
|
|
2883
2893
|
agents: ["claude-code", "cursor", "amp"]
|
|
2884
2894
|
}
|
|
2885
2895
|
});
|
|
2886
|
-
cli.command(
|
|
2896
|
+
cli.command(login);
|
|
2887
2897
|
cli.use(async (c, next) => {
|
|
2888
2898
|
const isLoginCommand = process.argv.slice(2).some((arg) => arg === "login");
|
|
2889
2899
|
if (isLoginCommand) {
|
|
2890
2900
|
await next();
|
|
2891
2901
|
return;
|
|
2892
2902
|
}
|
|
2893
|
-
|
|
2903
|
+
let apiKey = process.env.OPENFORT_API_KEY;
|
|
2904
|
+
if (!apiKey) {
|
|
2905
|
+
const creds = loadEnvFile(CREDENTIALS_PATH);
|
|
2906
|
+
apiKey = creds.get("OPENFORT_API_KEY");
|
|
2907
|
+
if (apiKey) {
|
|
2908
|
+
process.env.OPENFORT_API_KEY = apiKey;
|
|
2909
|
+
const pk = creds.get("OPENFORT_PUBLISHABLE_KEY");
|
|
2910
|
+
if (pk && !process.env.OPENFORT_PUBLISHABLE_KEY) process.env.OPENFORT_PUBLISHABLE_KEY = pk;
|
|
2911
|
+
const ws = creds.get("OPENFORT_WALLET_SECRET");
|
|
2912
|
+
if (ws && !process.env.OPENFORT_WALLET_SECRET) process.env.OPENFORT_WALLET_SECRET = ws;
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2894
2915
|
if (!apiKey) {
|
|
2895
|
-
throw new
|
|
2916
|
+
throw new Errors5.IncurError({
|
|
2896
2917
|
code: "MISSING_API_KEY",
|
|
2897
2918
|
message: "OPENFORT_API_KEY environment variable is required.",
|
|
2898
2919
|
hint: "Run: openfort login"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfort/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Openfort CLI — manage wallets, policies, and transactions from the terminal.",
|
|
5
5
|
"author": "Openfort (https://www.openfort.io)",
|
|
6
6
|
"bugs": "https://github.com/openfort-xyz/cli/issues",
|