@openfort/cli 0.1.6 → 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 +97 -69
- package/package.json +2 -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,13 +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 { z as z2 } from "incur";
|
|
28
|
-
|
|
29
24
|
// src/env.ts
|
|
30
25
|
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
26
|
+
import { Errors } from "incur";
|
|
31
27
|
function loadEnvFile(envPath) {
|
|
32
28
|
const entries = /* @__PURE__ */ new Map();
|
|
33
29
|
if (!existsSync(envPath)) return entries;
|
|
@@ -53,8 +49,23 @@ function writeEnvKey(envPath, key, value) {
|
|
|
53
49
|
writeFileSync(envPath, `${lines.join("\n")}
|
|
54
50
|
`);
|
|
55
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
|
+
}
|
|
56
63
|
|
|
57
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";
|
|
58
69
|
function base64url(buffer) {
|
|
59
70
|
return buffer.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
60
71
|
}
|
|
@@ -150,7 +161,7 @@ function waitForCallback(port, state) {
|
|
|
150
161
|
reject(new Error("Login timed out after 5 minutes. Please try again."));
|
|
151
162
|
}, 5 * 60 * 1e3);
|
|
152
163
|
const server = createServer((req, res) => {
|
|
153
|
-
const url = new URL(req.url, `http://localhost:${port}`);
|
|
164
|
+
const url = new URL(req.url ?? "/", `http://localhost:${port}`);
|
|
154
165
|
if (url.pathname === "/callback") {
|
|
155
166
|
const apiKey = url.searchParams.get("api_key");
|
|
156
167
|
const publishableKey = url.searchParams.get("publishable_key");
|
|
@@ -185,7 +196,7 @@ function waitForCallback(port, state) {
|
|
|
185
196
|
server.listen(port);
|
|
186
197
|
});
|
|
187
198
|
}
|
|
188
|
-
var
|
|
199
|
+
var login = Cli.create("login", {
|
|
189
200
|
description: "Log in to Openfort via browser and save your API key.",
|
|
190
201
|
output: z2.object({
|
|
191
202
|
apiKey: z2.string().describe("The API key saved to credentials"),
|
|
@@ -200,9 +211,15 @@ var loginConfig = {
|
|
|
200
211
|
authUrl.searchParams.set("redirect_uri", redirectUri);
|
|
201
212
|
authUrl.searchParams.set("state", state);
|
|
202
213
|
if (!c.agent) {
|
|
203
|
-
|
|
204
|
-
console.log(`
|
|
205
|
-
`);
|
|
214
|
+
const url = authUrl.toString();
|
|
215
|
+
console.log(`
|
|
216
|
+
> Visit ${url}`);
|
|
217
|
+
try {
|
|
218
|
+
const browserProcess = await open(url);
|
|
219
|
+
browserProcess.on("error", () => {
|
|
220
|
+
});
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
206
223
|
console.log("Waiting for authentication...\n");
|
|
207
224
|
}
|
|
208
225
|
const { apiKey, publishableKey, projectId, project } = await waitForCallback(port, state);
|
|
@@ -229,10 +246,10 @@ var loginConfig = {
|
|
|
229
246
|
}
|
|
230
247
|
);
|
|
231
248
|
}
|
|
232
|
-
};
|
|
249
|
+
});
|
|
233
250
|
|
|
234
251
|
// src/commands/accounts.ts
|
|
235
|
-
import { Cli, z as z3, middleware } from "incur";
|
|
252
|
+
import { Cli as Cli2, z as z3, middleware } from "incur";
|
|
236
253
|
var requireWallet = middleware((c, next) => {
|
|
237
254
|
const missing = [];
|
|
238
255
|
if (!process.env.OPENFORT_WALLET_SECRET) missing.push("OPENFORT_WALLET_SECRET");
|
|
@@ -249,7 +266,7 @@ var requireWallet = middleware((c, next) => {
|
|
|
249
266
|
}
|
|
250
267
|
return next();
|
|
251
268
|
});
|
|
252
|
-
var evm =
|
|
269
|
+
var evm = Cli2.create("evm", {
|
|
253
270
|
description: "EVM wallet management.",
|
|
254
271
|
vars: varsSchema
|
|
255
272
|
});
|
|
@@ -581,7 +598,7 @@ evm.command("send-transaction", {
|
|
|
581
598
|
});
|
|
582
599
|
}
|
|
583
600
|
});
|
|
584
|
-
var solana =
|
|
601
|
+
var solana = Cli2.create("solana", {
|
|
585
602
|
description: "Solana wallet management.",
|
|
586
603
|
vars: varsSchema
|
|
587
604
|
});
|
|
@@ -795,7 +812,7 @@ solana.command("transfer", {
|
|
|
795
812
|
return c.ok({ signature: res.signature });
|
|
796
813
|
}
|
|
797
814
|
});
|
|
798
|
-
var accounts =
|
|
815
|
+
var accounts = Cli2.create("accounts", {
|
|
799
816
|
description: "Manage wallets and accounts.",
|
|
800
817
|
vars: varsSchema
|
|
801
818
|
});
|
|
@@ -856,7 +873,7 @@ accounts.command(evm);
|
|
|
856
873
|
accounts.command(solana);
|
|
857
874
|
|
|
858
875
|
// src/commands/contracts.ts
|
|
859
|
-
import { Cli as
|
|
876
|
+
import { Cli as Cli3, z as z4 } from "incur";
|
|
860
877
|
var contractItem = z4.object({
|
|
861
878
|
id: z4.string(),
|
|
862
879
|
createdAt: z4.number(),
|
|
@@ -864,10 +881,10 @@ var contractItem = z4.object({
|
|
|
864
881
|
chainId: z4.number(),
|
|
865
882
|
address: z4.string(),
|
|
866
883
|
deleted: z4.boolean(),
|
|
867
|
-
abi: z4.array(z4.
|
|
884
|
+
abi: z4.array(z4.record(z4.string(), z4.unknown())),
|
|
868
885
|
publicVerification: z4.boolean()
|
|
869
886
|
});
|
|
870
|
-
var contracts =
|
|
887
|
+
var contracts = Cli3.create("contracts", {
|
|
871
888
|
description: "Manage smart contracts.",
|
|
872
889
|
vars: varsSchema
|
|
873
890
|
});
|
|
@@ -1031,7 +1048,7 @@ contracts.command("delete", {
|
|
|
1031
1048
|
});
|
|
1032
1049
|
|
|
1033
1050
|
// src/commands/paymasters.ts
|
|
1034
|
-
import { Cli as
|
|
1051
|
+
import { Cli as Cli4, z as z5 } from "incur";
|
|
1035
1052
|
var paymasterItem = z5.object({
|
|
1036
1053
|
id: z5.string(),
|
|
1037
1054
|
createdAt: z5.number(),
|
|
@@ -1039,7 +1056,7 @@ var paymasterItem = z5.object({
|
|
|
1039
1056
|
url: z5.string().optional(),
|
|
1040
1057
|
context: z5.record(z5.string(), z5.unknown()).optional()
|
|
1041
1058
|
});
|
|
1042
|
-
var paymasters =
|
|
1059
|
+
var paymasters = Cli4.create("paymasters", {
|
|
1043
1060
|
description: "Manage ERC-4337 paymasters.",
|
|
1044
1061
|
vars: varsSchema
|
|
1045
1062
|
});
|
|
@@ -1106,7 +1123,7 @@ paymasters.command("update", {
|
|
|
1106
1123
|
id: z5.string().describe("Paymaster ID (pay_...)")
|
|
1107
1124
|
}),
|
|
1108
1125
|
options: z5.object({
|
|
1109
|
-
address: z5.string().
|
|
1126
|
+
address: z5.string().describe("Paymaster address"),
|
|
1110
1127
|
name: z5.string().optional().describe("New name"),
|
|
1111
1128
|
url: z5.string().optional().describe("New URL")
|
|
1112
1129
|
}),
|
|
@@ -1148,9 +1165,9 @@ paymasters.command("delete", {
|
|
|
1148
1165
|
});
|
|
1149
1166
|
|
|
1150
1167
|
// src/commands/policies.ts
|
|
1151
|
-
import { Cli as
|
|
1168
|
+
import { Cli as Cli5, z as z6 } from "incur";
|
|
1152
1169
|
var policyScopes = ["project", "account", "transaction"];
|
|
1153
|
-
var policies =
|
|
1170
|
+
var policies = Cli5.create("policies", {
|
|
1154
1171
|
description: "Manage rules and conditions for backend wallets and fee sponsorship.",
|
|
1155
1172
|
vars: varsSchema
|
|
1156
1173
|
});
|
|
@@ -1280,7 +1297,7 @@ policies.command("get", {
|
|
|
1280
1297
|
accountId: z6.string().nullable(),
|
|
1281
1298
|
enabled: z6.boolean(),
|
|
1282
1299
|
priority: z6.number(),
|
|
1283
|
-
rules: z6.array(z6.
|
|
1300
|
+
rules: z6.array(z6.record(z6.string(), z6.unknown()))
|
|
1284
1301
|
}),
|
|
1285
1302
|
async run(c) {
|
|
1286
1303
|
const p = await c.var.openfort.policies.get(c.args.id);
|
|
@@ -1388,7 +1405,7 @@ policies.command("evaluate", {
|
|
|
1388
1405
|
});
|
|
1389
1406
|
|
|
1390
1407
|
// src/commands/sponsorship.ts
|
|
1391
|
-
import { Cli as
|
|
1408
|
+
import { Cli as Cli6, z as z7 } from "incur";
|
|
1392
1409
|
var sponsorSchemas = ["pay_for_user", "charge_custom_tokens", "fixed_rate"];
|
|
1393
1410
|
var sponsorshipItem = z7.object({
|
|
1394
1411
|
id: z7.string(),
|
|
@@ -1405,7 +1422,7 @@ var sponsorshipItem = z7.object({
|
|
|
1405
1422
|
paymasterId: z7.string().nullable(),
|
|
1406
1423
|
policyId: z7.string().nullable()
|
|
1407
1424
|
});
|
|
1408
|
-
var sponsorship =
|
|
1425
|
+
var sponsorship = Cli6.create("sponsorship", {
|
|
1409
1426
|
description: "Manage fee sponsorship strategies linked to policies.",
|
|
1410
1427
|
vars: varsSchema
|
|
1411
1428
|
});
|
|
@@ -1617,7 +1634,7 @@ sponsorship.command("delete", {
|
|
|
1617
1634
|
});
|
|
1618
1635
|
|
|
1619
1636
|
// src/commands/subscriptions.ts
|
|
1620
|
-
import { Cli as
|
|
1637
|
+
import { Cli as Cli7, z as z8 } from "incur";
|
|
1621
1638
|
var apiTopics = [
|
|
1622
1639
|
"transaction_intent.broadcast",
|
|
1623
1640
|
"transaction_intent.successful",
|
|
@@ -1633,7 +1650,7 @@ var apiTopics = [
|
|
|
1633
1650
|
"account.created"
|
|
1634
1651
|
];
|
|
1635
1652
|
var apiTriggerTypes = ["webhook", "email"];
|
|
1636
|
-
var triggers =
|
|
1653
|
+
var triggers = Cli7.create("triggers", {
|
|
1637
1654
|
description: "Manage subscription triggers.",
|
|
1638
1655
|
vars: varsSchema
|
|
1639
1656
|
});
|
|
@@ -1743,7 +1760,7 @@ triggers.command("delete", {
|
|
|
1743
1760
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
1744
1761
|
}
|
|
1745
1762
|
});
|
|
1746
|
-
var subscriptions =
|
|
1763
|
+
var subscriptions = Cli7.create("subscriptions", {
|
|
1747
1764
|
description: "Manage webhook subscriptions.",
|
|
1748
1765
|
vars: varsSchema
|
|
1749
1766
|
});
|
|
@@ -1876,7 +1893,7 @@ subscriptions.command("delete", {
|
|
|
1876
1893
|
subscriptions.command(triggers);
|
|
1877
1894
|
|
|
1878
1895
|
// src/commands/sessions.ts
|
|
1879
|
-
import { Cli as
|
|
1896
|
+
import { Cli as Cli8, z as z9 } from "incur";
|
|
1880
1897
|
var sessionItem = z9.object({
|
|
1881
1898
|
id: z9.string(),
|
|
1882
1899
|
createdAt: z9.number(),
|
|
@@ -1888,10 +1905,10 @@ var sessionItem = z9.object({
|
|
|
1888
1905
|
isActive: z9.boolean(),
|
|
1889
1906
|
nextAction: z9.object({
|
|
1890
1907
|
type: z9.string(),
|
|
1891
|
-
payload: z9.
|
|
1908
|
+
payload: z9.record(z9.string(), z9.unknown()).optional()
|
|
1892
1909
|
}).optional()
|
|
1893
1910
|
});
|
|
1894
|
-
var sessions =
|
|
1911
|
+
var sessions = Cli8.create("sessions", {
|
|
1895
1912
|
description: "Manage session keys.",
|
|
1896
1913
|
vars: varsSchema
|
|
1897
1914
|
});
|
|
@@ -2082,7 +2099,7 @@ sessions.command("sign", {
|
|
|
2082
2099
|
});
|
|
2083
2100
|
|
|
2084
2101
|
// src/commands/transactions.ts
|
|
2085
|
-
import { Cli as
|
|
2102
|
+
import { Cli as Cli9, z as z10 } from "incur";
|
|
2086
2103
|
var transactionIntentItem = z10.object({
|
|
2087
2104
|
id: z10.string(),
|
|
2088
2105
|
createdAt: z10.number(),
|
|
@@ -2098,7 +2115,7 @@ var transactionIntentItem = z10.object({
|
|
|
2098
2115
|
gasFee: z10.string().optional(),
|
|
2099
2116
|
status: z10.number().optional(),
|
|
2100
2117
|
to: z10.string().optional(),
|
|
2101
|
-
error: z10.
|
|
2118
|
+
error: z10.record(z10.string(), z10.unknown()).optional()
|
|
2102
2119
|
}).optional(),
|
|
2103
2120
|
interactions: z10.array(z10.object({
|
|
2104
2121
|
to: z10.string().optional(),
|
|
@@ -2107,10 +2124,10 @@ var transactionIntentItem = z10.object({
|
|
|
2107
2124
|
})).optional(),
|
|
2108
2125
|
nextAction: z10.object({
|
|
2109
2126
|
type: z10.string(),
|
|
2110
|
-
payload: z10.
|
|
2127
|
+
payload: z10.record(z10.string(), z10.unknown()).optional()
|
|
2111
2128
|
}).optional()
|
|
2112
2129
|
});
|
|
2113
|
-
var transactions =
|
|
2130
|
+
var transactions = Cli9.create("transactions", {
|
|
2114
2131
|
description: "Manage transaction intents.",
|
|
2115
2132
|
vars: varsSchema
|
|
2116
2133
|
});
|
|
@@ -2319,9 +2336,9 @@ transactions.command("estimate", {
|
|
|
2319
2336
|
});
|
|
2320
2337
|
|
|
2321
2338
|
// src/commands/embedded-wallet.ts
|
|
2322
|
-
import { Cli as
|
|
2339
|
+
import { Cli as Cli10, z as z11, Errors as Errors3 } from "incur";
|
|
2323
2340
|
var SHIELD_API_URL = OPENFORT_SHIELD_URL;
|
|
2324
|
-
var embeddedWallet =
|
|
2341
|
+
var embeddedWallet = Cli10.create("embedded-wallet", {
|
|
2325
2342
|
description: "Configure embedded wallet (Shield) API keys.",
|
|
2326
2343
|
vars: varsSchema
|
|
2327
2344
|
});
|
|
@@ -2345,17 +2362,17 @@ embeddedWallet.command("setup", {
|
|
|
2345
2362
|
async run(c) {
|
|
2346
2363
|
const publishableKey = process.env.OPENFORT_PUBLISHABLE_KEY;
|
|
2347
2364
|
if (!publishableKey) {
|
|
2348
|
-
throw new
|
|
2365
|
+
throw new Errors3.IncurError({
|
|
2349
2366
|
code: "MISSING_PUBLISHABLE_KEY",
|
|
2350
2367
|
message: "OPENFORT_PUBLISHABLE_KEY environment variable is required to create Shield keys.",
|
|
2351
2368
|
hint: "Run: openfort login"
|
|
2352
2369
|
});
|
|
2353
2370
|
}
|
|
2354
|
-
const apiKey =
|
|
2371
|
+
const apiKey = requireApiKey();
|
|
2355
2372
|
const environment = apiKey.startsWith("sk_live_") ? "live" : "test";
|
|
2356
2373
|
const projectId = c.options.project || process.env.OPENFORT_PROJECT_ID;
|
|
2357
2374
|
if (!projectId) {
|
|
2358
|
-
throw new
|
|
2375
|
+
throw new Errors3.IncurError({
|
|
2359
2376
|
code: "MISSING_PROJECT_ID",
|
|
2360
2377
|
message: "Project ID is required. Pass --project or set OPENFORT_PROJECT_ID.",
|
|
2361
2378
|
hint: "Run: openfort login"
|
|
@@ -2375,7 +2392,7 @@ embeddedWallet.command("setup", {
|
|
|
2375
2392
|
});
|
|
2376
2393
|
if (!registerRes.ok) {
|
|
2377
2394
|
const text = await registerRes.text();
|
|
2378
|
-
throw new
|
|
2395
|
+
throw new Errors3.IncurError({
|
|
2379
2396
|
code: "SHIELD_REGISTER_FAILED",
|
|
2380
2397
|
message: `Shield registration failed: ${text}`,
|
|
2381
2398
|
retryable: true
|
|
@@ -2383,7 +2400,7 @@ embeddedWallet.command("setup", {
|
|
|
2383
2400
|
}
|
|
2384
2401
|
const shieldData = await registerRes.json();
|
|
2385
2402
|
if (shieldData.error) {
|
|
2386
|
-
throw new
|
|
2403
|
+
throw new Errors3.IncurError({
|
|
2387
2404
|
code: "SHIELD_REGISTER_ERROR",
|
|
2388
2405
|
message: `Shield registration error: ${shieldData.error}`
|
|
2389
2406
|
});
|
|
@@ -2399,7 +2416,7 @@ embeddedWallet.command("setup", {
|
|
|
2399
2416
|
});
|
|
2400
2417
|
if (!res.ok) {
|
|
2401
2418
|
const text = await res.text();
|
|
2402
|
-
throw new
|
|
2419
|
+
throw new Errors3.IncurError({
|
|
2403
2420
|
code: "PERSIST_KEY_FAILED",
|
|
2404
2421
|
message: `Failed to persist ${type} key: ${text}`,
|
|
2405
2422
|
retryable: true
|
|
@@ -2427,7 +2444,7 @@ embeddedWallet.command("setup", {
|
|
|
2427
2444
|
});
|
|
2428
2445
|
if (!linkRes.ok) {
|
|
2429
2446
|
const text = await linkRes.text();
|
|
2430
|
-
throw new
|
|
2447
|
+
throw new Errors3.IncurError({
|
|
2431
2448
|
code: "SHIELD_LINK_FAILED",
|
|
2432
2449
|
message: `Failed to link Openfort provider to Shield: ${text}`,
|
|
2433
2450
|
retryable: true
|
|
@@ -2454,7 +2471,7 @@ embeddedWallet.command("setup", {
|
|
|
2454
2471
|
});
|
|
2455
2472
|
|
|
2456
2473
|
// src/commands/users.ts
|
|
2457
|
-
import { Cli as
|
|
2474
|
+
import { Cli as Cli11, z as z12 } from "incur";
|
|
2458
2475
|
var userItem = z12.object({
|
|
2459
2476
|
id: z12.string(),
|
|
2460
2477
|
createdAt: z12.number(),
|
|
@@ -2474,7 +2491,7 @@ var userItem = z12.object({
|
|
|
2474
2491
|
walletClientType: z12.string().optional()
|
|
2475
2492
|
}))
|
|
2476
2493
|
});
|
|
2477
|
-
var users =
|
|
2494
|
+
var users = Cli11.create("users", {
|
|
2478
2495
|
description: "Manage authenticated users.",
|
|
2479
2496
|
vars: varsSchema
|
|
2480
2497
|
});
|
|
@@ -2562,7 +2579,7 @@ users.command("delete", {
|
|
|
2562
2579
|
|
|
2563
2580
|
// src/commands/backend-wallet.ts
|
|
2564
2581
|
import { randomBytes as randomBytes2, subtle } from "crypto";
|
|
2565
|
-
import { Cli as
|
|
2582
|
+
import { Cli as Cli12, z as z13, Errors as Errors4 } from "incur";
|
|
2566
2583
|
function arrayBufferToBase64(buffer) {
|
|
2567
2584
|
return Buffer.from(buffer).toString("base64");
|
|
2568
2585
|
}
|
|
@@ -2570,7 +2587,7 @@ function arrayBufferToBase64Url(buffer) {
|
|
|
2570
2587
|
return Buffer.from(buffer).toString("base64url");
|
|
2571
2588
|
}
|
|
2572
2589
|
function stringToArrayBuffer(str) {
|
|
2573
|
-
return new TextEncoder().encode(str)
|
|
2590
|
+
return new TextEncoder().encode(str);
|
|
2574
2591
|
}
|
|
2575
2592
|
function formatPEMBody(base64) {
|
|
2576
2593
|
return base64.match(/.{1,64}/g)?.join("\n") || base64;
|
|
@@ -2578,9 +2595,10 @@ function formatPEMBody(base64) {
|
|
|
2578
2595
|
function sortObjectKeys(obj) {
|
|
2579
2596
|
if (obj === null || typeof obj !== "object") return obj;
|
|
2580
2597
|
if (Array.isArray(obj)) return obj.map(sortObjectKeys);
|
|
2598
|
+
const record = obj;
|
|
2581
2599
|
const sorted = {};
|
|
2582
|
-
for (const key of Object.keys(
|
|
2583
|
-
sorted[key] = sortObjectKeys(
|
|
2600
|
+
for (const key of Object.keys(record).sort()) {
|
|
2601
|
+
sorted[key] = sortObjectKeys(record[key]);
|
|
2584
2602
|
}
|
|
2585
2603
|
return sorted;
|
|
2586
2604
|
}
|
|
@@ -2632,7 +2650,7 @@ async function signWalletAuthJwt(privateKey, method, path, body) {
|
|
|
2632
2650
|
);
|
|
2633
2651
|
return `${signingInput}.${arrayBufferToBase64Url(signature)}`;
|
|
2634
2652
|
}
|
|
2635
|
-
var backendWallet =
|
|
2653
|
+
var backendWallet = Cli12.create("backend-wallet", {
|
|
2636
2654
|
description: "Configure backend wallet signing keys.",
|
|
2637
2655
|
vars: varsSchema
|
|
2638
2656
|
});
|
|
@@ -2649,7 +2667,7 @@ backendWallet.command("setup", {
|
|
|
2649
2667
|
],
|
|
2650
2668
|
hint: 'Requires OPENFORT_API_KEY. Run "openfort login" first.',
|
|
2651
2669
|
async run(c) {
|
|
2652
|
-
const apiKey =
|
|
2670
|
+
const apiKey = requireApiKey();
|
|
2653
2671
|
const { publicKey, privateKey, privateKeyCrypto } = await generateKeyPair();
|
|
2654
2672
|
const publicKeyPEM = `-----BEGIN PUBLIC KEY-----
|
|
2655
2673
|
${publicKey}
|
|
@@ -2671,7 +2689,7 @@ ${publicKey}
|
|
|
2671
2689
|
});
|
|
2672
2690
|
if (!registerRes.ok) {
|
|
2673
2691
|
const text = await registerRes.text();
|
|
2674
|
-
throw new
|
|
2692
|
+
throw new Errors4.IncurError({
|
|
2675
2693
|
code: "REGISTER_SECRET_FAILED",
|
|
2676
2694
|
message: `Failed to register wallet secret: ${text}`,
|
|
2677
2695
|
retryable: true
|
|
@@ -2687,7 +2705,7 @@ ${publicKey}
|
|
|
2687
2705
|
});
|
|
2688
2706
|
if (!storeRes.ok) {
|
|
2689
2707
|
const text = await storeRes.text();
|
|
2690
|
-
throw new
|
|
2708
|
+
throw new Errors4.IncurError({
|
|
2691
2709
|
code: "STORE_KEY_FAILED",
|
|
2692
2710
|
message: `Failed to store wallet key reference: ${text}`,
|
|
2693
2711
|
retryable: true
|
|
@@ -2724,11 +2742,11 @@ backendWallet.command("revoke", {
|
|
|
2724
2742
|
],
|
|
2725
2743
|
hint: 'Requires OPENFORT_WALLET_KEY_ID and OPENFORT_WALLET_SECRET. Run "openfort backend-wallet setup" first.',
|
|
2726
2744
|
async run(c) {
|
|
2727
|
-
const apiKey =
|
|
2745
|
+
const apiKey = requireApiKey();
|
|
2728
2746
|
const keyId = process.env.OPENFORT_WALLET_KEY_ID;
|
|
2729
2747
|
const privateKeyBase64 = process.env.OPENFORT_WALLET_SECRET;
|
|
2730
2748
|
if (!keyId || !privateKeyBase64) {
|
|
2731
|
-
throw new
|
|
2749
|
+
throw new Errors4.IncurError({
|
|
2732
2750
|
code: "MISSING_WALLET_KEY",
|
|
2733
2751
|
message: "OPENFORT_WALLET_KEY_ID and OPENFORT_WALLET_SECRET must be set. Run `backend-wallet setup` first.",
|
|
2734
2752
|
hint: "Run: openfort backend-wallet setup"
|
|
@@ -2749,7 +2767,7 @@ backendWallet.command("revoke", {
|
|
|
2749
2767
|
});
|
|
2750
2768
|
if (!res.ok) {
|
|
2751
2769
|
const text = await res.text();
|
|
2752
|
-
throw new
|
|
2770
|
+
throw new Errors4.IncurError({
|
|
2753
2771
|
code: "REVOKE_SECRET_FAILED",
|
|
2754
2772
|
message: `Failed to revoke wallet secret: ${text}`,
|
|
2755
2773
|
retryable: true
|
|
@@ -2772,7 +2790,7 @@ backendWallet.command("rotate", {
|
|
|
2772
2790
|
],
|
|
2773
2791
|
hint: 'Requires OPENFORT_API_KEY. Run "openfort login" first.',
|
|
2774
2792
|
async run(c) {
|
|
2775
|
-
const apiKey =
|
|
2793
|
+
const apiKey = requireApiKey();
|
|
2776
2794
|
const { publicKey, privateKey, privateKeyCrypto } = await generateKeyPair();
|
|
2777
2795
|
const newPublicKeyPEM = `-----BEGIN PUBLIC KEY-----
|
|
2778
2796
|
${publicKey}
|
|
@@ -2794,7 +2812,7 @@ ${publicKey}
|
|
|
2794
2812
|
});
|
|
2795
2813
|
if (!rotateRes.ok) {
|
|
2796
2814
|
const text = await rotateRes.text();
|
|
2797
|
-
throw new
|
|
2815
|
+
throw new Errors4.IncurError({
|
|
2798
2816
|
code: "ROTATE_SECRET_FAILED",
|
|
2799
2817
|
message: `Failed to rotate wallet secret: ${text}`,
|
|
2800
2818
|
retryable: true
|
|
@@ -2810,7 +2828,7 @@ ${publicKey}
|
|
|
2810
2828
|
});
|
|
2811
2829
|
if (!storeRes.ok) {
|
|
2812
2830
|
const text = await storeRes.text();
|
|
2813
|
-
throw new
|
|
2831
|
+
throw new Errors4.IncurError({
|
|
2814
2832
|
code: "STORE_KEY_FAILED",
|
|
2815
2833
|
message: `Failed to store rotated wallet key reference: ${text}`,
|
|
2816
2834
|
retryable: true
|
|
@@ -2825,9 +2843,9 @@ ${publicKey}
|
|
|
2825
2843
|
});
|
|
2826
2844
|
|
|
2827
2845
|
// src/commands/message.ts
|
|
2828
|
-
import { Cli as
|
|
2846
|
+
import { Cli as Cli13, z as z14 } from "incur";
|
|
2829
2847
|
import { keccak256, toBytes } from "viem";
|
|
2830
|
-
var message =
|
|
2848
|
+
var message = Cli13.create("message", {
|
|
2831
2849
|
description: "Message utilities.",
|
|
2832
2850
|
vars: varsSchema
|
|
2833
2851
|
});
|
|
@@ -2850,9 +2868,8 @@ message.command("hash", {
|
|
|
2850
2868
|
|
|
2851
2869
|
// src/cli.ts
|
|
2852
2870
|
var pkg = JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf-8"));
|
|
2853
|
-
var cli =
|
|
2871
|
+
var cli = Cli14.create("openfort", {
|
|
2854
2872
|
version: pkg.version,
|
|
2855
|
-
aliases: ["of"],
|
|
2856
2873
|
description: "Openfort CLI \u2014 manage wallets, policies, and transactions from the terminal.",
|
|
2857
2874
|
vars: varsSchema,
|
|
2858
2875
|
env: z15.object({
|
|
@@ -2876,16 +2893,27 @@ var cli = Cli13.create("openfort", {
|
|
|
2876
2893
|
agents: ["claude-code", "cursor", "amp"]
|
|
2877
2894
|
}
|
|
2878
2895
|
});
|
|
2879
|
-
cli.command(
|
|
2896
|
+
cli.command(login);
|
|
2880
2897
|
cli.use(async (c, next) => {
|
|
2881
2898
|
const isLoginCommand = process.argv.slice(2).some((arg) => arg === "login");
|
|
2882
2899
|
if (isLoginCommand) {
|
|
2883
2900
|
await next();
|
|
2884
2901
|
return;
|
|
2885
2902
|
}
|
|
2886
|
-
|
|
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
|
+
}
|
|
2887
2915
|
if (!apiKey) {
|
|
2888
|
-
throw new
|
|
2916
|
+
throw new Errors5.IncurError({
|
|
2889
2917
|
code: "MISSING_API_KEY",
|
|
2890
2918
|
message: "OPENFORT_API_KEY environment variable is required.",
|
|
2891
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",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@openfort/openfort-node": "^0.10.2",
|
|
23
23
|
"incur": "^0.3.4",
|
|
24
|
+
"open": "^11.0.0",
|
|
24
25
|
"viem": "^2.47.2"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|