nirium-cli 3.2.1 → 3.2.3

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.
Files changed (3) hide show
  1. package/README.md +127 -126
  2. package/bin/nirium.js +8 -8
  3. package/package.json +9 -5
package/README.md CHANGED
@@ -6,6 +6,127 @@ Scaffold Stellar agent projects, including one that charges for itself.
6
6
  npm install -g nirium-cli
7
7
  ```
8
8
 
9
+ Audit Trail receipts: anchor a sha-256 hash (optionally signed with ed25519) to IPFS, and anyone can independently verify it with `nirium verify` or at [nirium.xyz/verify](https://nirium.xyz/verify) - no account, no trust in this CLI's own output required.
10
+
11
+ ## Anchor a record
12
+
13
+ ```bash
14
+ nirium anchor --file evidence.json
15
+ nirium anchor --hash <64-hex-sha256>
16
+ nirium anchor --record '{"order":"A-12"}'
17
+ ```
18
+
19
+ Anchors a sha-256 hash (or a small JSON object, up to 8KB) to IPFS via an
20
+ Audit Trail node's `POST /api/audit/log`, and prints back the CID.
21
+
22
+ - `--file <path>` computes the sha-256 of the file locally and sends only
23
+ the hash - the file's contents are never uploaded. IPFS cannot delete
24
+ anything once pinned, so hashing locally means raw evidence never
25
+ leaves your machine.
26
+ - `--hash <hex>` sends a sha-256 you already have (64 hex chars, optional
27
+ `sha-256:` prefix).
28
+ - `--record <json>` anchors a small JSON object verbatim (max 8KB,
29
+ enforced here before the request, not just by the server). Don't put
30
+ personal data in it - an anchored record can never be deleted.
31
+
32
+ Exactly one of the three is required. `--tx <hash>` and `--tag <label>`
33
+ are optional and attached to the anchor as-is. There is no `--network`
34
+ flag: the agent box anchoring the record decides its own network, and a
35
+ client-supplied network field is rejected server-side anyway.
36
+
37
+ | Option | Purpose | Default |
38
+ |---|---|---|
39
+ | `--file <path>` | anchor this file's sha-256 | none |
40
+ | `--hash <hex>` | anchor this sha-256 directly | none |
41
+ | `--record <json>` | anchor this small JSON object verbatim | none |
42
+ | `--tx <hash>` | associate a transaction hash | none |
43
+ | `--tag <label>` | free-form label | none |
44
+ | `--sign` | attach an ed25519 attestation of which key produced this anchor | off |
45
+ | `--key-env <VAR>` | env var holding the secret key to sign with (`--sign` only) | config store's `secretKey` |
46
+ | `-u, --url <url>` | agent URL | `https://nirium-agent.fly.dev` |
47
+ | `--json` | machine-readable result | off |
48
+
49
+ On success, prints the CID, the content hash, the gateway URL, and a
50
+ `nirium verify <cid>` suggestion so the anchor can be independently
51
+ re-checked right away.
52
+
53
+ ### Attesting who produced an anchor
54
+
55
+ ```bash
56
+ nirium config set secretKey # hidden prompt, stored in ~/.niriumrc.json
57
+ nirium anchor --hash <64-hex> --sign
58
+ # or, without touching the config store:
59
+ NIRIUM_KEY=S... nirium anchor --hash <64-hex> --sign --key-env NIRIUM_KEY
60
+ ```
61
+
62
+ The CID alone proves the anchored fact wasn't altered; `--sign` proves
63
+ *who* declared it. The secret key signs `nirium-audit-v1:<content_sha256>`
64
+ locally with ed25519 - only the resulting signature and the derived
65
+ public key (`G...`) ever leave this process, never the secret itself. If
66
+ the node rejects the signature, nothing is anchored (`400`, exit non-zero).
67
+ `nirium verify <cid>` independently re-checks it afterward and reports
68
+ `SIGNATURE: VALID` against the same public key.
69
+
70
+ ## Verify an audit record
71
+
72
+ ```bash
73
+ nirium verify <cid>
74
+ ```
75
+
76
+ Independently re-checks a Nirium audit document anchored to IPFS: fetches
77
+ it from a gateway, recomputes its SHA-256 content hash, and, if the
78
+ document carries an agent attestation, verifies the ed25519 signature
79
+ over `nirium-audit-v1:<content_sha256>` against the declared signer's
80
+ Stellar public key. Nothing here trusts the document's own claims about
81
+ itself; both the hash and the signed statement are recomputed from the
82
+ raw content, not read off the document.
83
+
84
+ Hash-only anchors (no `record`, the recommended mode) have nothing to
85
+ recompute: the document's `content_sha256` is the hash you submitted. Pass
86
+ `--hash <hex>` or `--evidence <file>` to compare it with your own evidence;
87
+ without either, the hash is reported as NOT CHECKED (not as a mismatch)
88
+ and the signature is still verified over `nirium-audit-v1:<content_sha256>`.
89
+ Signatures are accepted as base64 or hex, raw ed25519 or SEP-53
90
+ (Freighter `signMessage`), like the anchoring node.
91
+
92
+ `-g, --gateway <url>` is repeatable and tried in order as fallbacks. A
93
+ `404` is retried on the *same* gateway up to `--retries` times with a
94
+ short backoff first - a fresh pin can take a moment to propagate, so a
95
+ 404 there doesn't mean the CID is wrong, just not there *yet*. Any other
96
+ failure (a real error, or a timed-out request) moves straight to the
97
+ next gateway instead, since retrying the same one won't help.
98
+
99
+ With no `--gateway`, it tries Filebase's dedicated gateway, then Pinata,
100
+ then `ipfs.io`, then `dweb.link`. Shared public gateways often answer
101
+ `429` under load, so the dedicated one goes first:
102
+
103
+ ```bash
104
+ nirium verify <cid> --gateway https://gateway.pinata.cloud --gateway https://ipfs.io --retries 3
105
+ ```
106
+
107
+ | Option | Purpose | Default |
108
+ |---|---|---|
109
+ | `-g, --gateway <url>` | IPFS gateway to fetch from - repeat for fallbacks | `nirium.myfilebase.com`, then `gateway.pinata.cloud`, `ipfs.io`, `dweb.link` |
110
+ | `--retries <n>` | retries per gateway on a 404, with backoff | `2` |
111
+ | `--timeout <ms>` | per-request timeout | `8000` |
112
+ | `--json` | machine-readable result | off |
113
+ | `--hash <hex>` | expected evidence hash for a hash-only anchor (`sha-256:` prefix optional) | none |
114
+ | `--evidence <file>` | file whose SHA-256 is compared with the anchored hash | none |
115
+
116
+ If every gateway comes back 404 after exhausting retries, that's
117
+ reported as **NOT YET AVAILABLE** (`availability: "not_yet_available"`
118
+ in `--json`) - distinct from a hash mismatch, because nothing was
119
+ actually fetched to compare. A mix of real errors across gateways is
120
+ reported as a gateway error instead. Both exit non-zero, same as before.
121
+
122
+ Exits non-zero (and prints which check failed) if the hash doesn't match
123
+ or the signature doesn't verify. A pass also requires that at least one
124
+ of the two checks actually ran and succeeded, a matching `--hash`/
125
+ `--evidence`, a valid agent signature, or both. If both were skipped
126
+ (an unsigned hash-only anchor with no `--hash` or `--evidence`), nothing
127
+ was verified, so `verify` prints `NOTHING VERIFIED`, exits non-zero, and
128
+ sets `verified: false` in `--json`, instead of reporting a pass.
129
+
9
130
  ## Charge for your API in five minutes
10
131
 
11
132
  ```bash
@@ -45,7 +166,7 @@ network, the number of routes or requests, the SDK version, and a short hash
45
166
  of your `X402_FACILITATOR_API_KEY` (the first 16 characters of its SHA-256,
46
167
  never the key itself). The ping never blocks, delays or fails a charge, and
47
168
  it does not authorize or gate anything. Leave the variable unset and nothing
48
- is sent. (Checked against the code of `nirium` 0.16.1; `dist/` is identical to 0.16.0.)
169
+ is sent. (Checked against the real `dist/` shipped in `nirium` 0.19.0 - same behavior as before, only the version citation was stale.)
49
170
 
50
171
  ## Listen to protocol signals
51
172
 
@@ -136,17 +257,16 @@ and for how long. It also prints a version and a network line, but they only
136
257
  carry a value when the agent reports one: the Nirium testnet agent's
137
258
  `/health` returns just `status`, `service` and `uptime` today, so those two
138
259
  lines are omitted rather than shown as `undefined`. `--url` points to the
139
- agent you want to check; `https://nirium-agent.fly.dev` is the Nirium
140
- testnet agent. Without `--url` it looks for an agent on your own machine at
141
- `http://localhost:3002` - the port `pnpm dev` runs the agent API on in this
142
- monorepo - so it reports "unreachable" if you are not running one there.
260
+ agent you want to check; it defaults to `https://nirium-agent.fly.dev`,
261
+ the Nirium testnet agent, so this works out of the box with no agent of
262
+ your own running anywhere.
143
263
 
144
264
  Exits 0 only when `/health` answers 2xx; exits 1 if the agent is
145
265
  unreachable, times out, or answers with anything else.
146
266
 
147
267
  | Option | Purpose | Default |
148
268
  |---|---|---|
149
- | `-u, --url <url>` | Agent to check | `http://localhost:3002` |
269
+ | `-u, --url <url>` | Agent to check | `https://nirium-agent.fly.dev` |
150
270
  | `--json` | The raw `/health` fields plus `ok` | off |
151
271
  | `--timeout <ms>` | Give up after this many milliseconds instead of hanging | `5000` |
152
272
 
@@ -202,125 +322,6 @@ Each line is pass or fail:
202
322
 
203
323
  `--json` prints the same report (`ok`, `seller`, `network`, `checks`) for CI.
204
324
 
205
- ## Anchor a record
206
-
207
- ```bash
208
- nirium anchor --file evidence.json
209
- nirium anchor --hash <64-hex-sha256>
210
- nirium anchor --record '{"order":"A-12"}'
211
- ```
212
-
213
- Anchors a sha-256 hash (or a small JSON object, up to 8KB) to IPFS via an
214
- Audit Trail node's `POST /api/audit/log`, and prints back the CID.
215
-
216
- - `--file <path>` computes the sha-256 of the file locally and sends only
217
- the hash - the file's contents are never uploaded. IPFS cannot delete
218
- anything once pinned, so hashing locally means raw evidence never
219
- leaves your machine.
220
- - `--hash <hex>` sends a sha-256 you already have (64 hex chars, optional
221
- `sha-256:` prefix).
222
- - `--record <json>` anchors a small JSON object verbatim (max 8KB,
223
- enforced here before the request, not just by the server). Don't put
224
- personal data in it - an anchored record can never be deleted.
225
-
226
- Exactly one of the three is required. `--tx <hash>` and `--tag <label>`
227
- are optional and attached to the anchor as-is. There is no `--network`
228
- flag: the agent box anchoring the record decides its own network, and a
229
- client-supplied network field is rejected server-side anyway.
230
-
231
- | Option | Purpose | Default |
232
- |---|---|---|
233
- | `--file <path>` | anchor this file's sha-256 | none |
234
- | `--hash <hex>` | anchor this sha-256 directly | none |
235
- | `--record <json>` | anchor this small JSON object verbatim | none |
236
- | `--tx <hash>` | associate a transaction hash | none |
237
- | `--tag <label>` | free-form label | none |
238
- | `--sign` | attach an ed25519 attestation of which key produced this anchor | off |
239
- | `--key-env <VAR>` | env var holding the secret key to sign with (`--sign` only) | config store's `secretKey` |
240
- | `-u, --url <url>` | agent URL | `http://localhost:3002` |
241
- | `--json` | machine-readable result | off |
242
-
243
- On success, prints the CID, the content hash, the gateway URL, and a
244
- `nirium verify <cid>` suggestion so the anchor can be independently
245
- re-checked right away.
246
-
247
- ### Attesting who produced an anchor
248
-
249
- ```bash
250
- nirium config set secretKey # hidden prompt, stored in ~/.niriumrc.json
251
- nirium anchor --hash <64-hex> --sign
252
- # or, without touching the config store:
253
- NIRIUM_KEY=S... nirium anchor --hash <64-hex> --sign --key-env NIRIUM_KEY
254
- ```
255
-
256
- The CID alone proves the anchored fact wasn't altered; `--sign` proves
257
- *who* declared it. The secret key signs `nirium-audit-v1:<content_sha256>`
258
- locally with ed25519 - only the resulting signature and the derived
259
- public key (`G...`) ever leave this process, never the secret itself. If
260
- the node rejects the signature, nothing is anchored (`400`, exit non-zero).
261
- `nirium verify <cid>` independently re-checks it afterward and reports
262
- `SIGNATURE: VALID` against the same public key.
263
-
264
- ## Verify an audit record
265
-
266
- ```bash
267
- nirium verify <cid>
268
- ```
269
-
270
- Independently re-checks a Nirium audit document anchored to IPFS: fetches
271
- it from a gateway, recomputes its SHA-256 content hash, and, if the
272
- document carries an agent attestation, verifies the ed25519 signature
273
- over `nirium-audit-v1:<content_sha256>` against the declared signer's
274
- Stellar public key. Nothing here trusts the document's own claims about
275
- itself; both the hash and the signed statement are recomputed from the
276
- raw content, not read off the document.
277
-
278
- Hash-only anchors (no `record`, the recommended mode) have nothing to
279
- recompute: the document's `content_sha256` is the hash you submitted. Pass
280
- `--hash <hex>` or `--evidence <file>` to compare it with your own evidence;
281
- without either, the hash is reported as NOT CHECKED (not as a mismatch)
282
- and the signature is still verified over `nirium-audit-v1:<content_sha256>`.
283
- Signatures are accepted as base64 or hex, raw ed25519 or SEP-53
284
- (Freighter `signMessage`), like the anchoring node.
285
-
286
- `-g, --gateway <url>` is repeatable and tried in order as fallbacks. A
287
- `404` is retried on the *same* gateway up to `--retries` times with a
288
- short backoff first - a fresh pin can take a moment to propagate, so a
289
- 404 there doesn't mean the CID is wrong, just not there *yet*. Any other
290
- failure (a real error, or a timed-out request) moves straight to the
291
- next gateway instead, since retrying the same one won't help.
292
-
293
- With no `--gateway`, it tries Filebase's dedicated gateway, then Pinata,
294
- then `ipfs.io`, then `dweb.link`. Shared public gateways often answer
295
- `429` under load, so the dedicated one goes first:
296
-
297
- ```bash
298
- nirium verify <cid> --gateway https://gateway.pinata.cloud --gateway https://ipfs.io --retries 3
299
- ```
300
-
301
- | Option | Purpose | Default |
302
- |---|---|---|
303
- | `-g, --gateway <url>` | IPFS gateway to fetch from - repeat for fallbacks | `nirium.myfilebase.com`, then `gateway.pinata.cloud`, `ipfs.io`, `dweb.link` |
304
- | `--retries <n>` | retries per gateway on a 404, with backoff | `2` |
305
- | `--timeout <ms>` | per-request timeout | `8000` |
306
- | `--json` | machine-readable result | off |
307
- | `--hash <hex>` | expected evidence hash for a hash-only anchor (`sha-256:` prefix optional) | none |
308
- | `--evidence <file>` | file whose SHA-256 is compared with the anchored hash | none |
309
-
310
- If every gateway comes back 404 after exhausting retries, that's
311
- reported as **NOT YET AVAILABLE** (`availability: "not_yet_available"`
312
- in `--json`) - distinct from a hash mismatch, because nothing was
313
- actually fetched to compare. A mix of real errors across gateways is
314
- reported as a gateway error instead. Both exit non-zero, same as before.
315
-
316
- Exits non-zero (and prints which check failed) if the hash doesn't match
317
- or the signature doesn't verify. A pass also requires that at least one
318
- of the two checks actually ran and succeeded, a matching `--hash`/
319
- `--evidence`, a valid agent signature, or both. If both were skipped
320
- (an unsigned hash-only anchor with no `--hash` or `--evidence`), nothing
321
- was verified, so `verify` prints `NOTHING VERIFIED`, exits non-zero, and
322
- sets `verified: false` in `--json`, instead of reporting a pass.
323
-
324
325
  ## Reporting: summaries and exports
325
326
 
326
327
  ```bash
@@ -357,7 +358,7 @@ receipts by gateway, and anchor counts for the period. `report export
357
358
  |---|---|---|
358
359
  | `--from <date>` / `--to <date>` | ISO date period | 30-day window |
359
360
  | `--network <testnet\|mainnet>` | restrict to one network | all |
360
- | `-u, --url <url>` | agent URL | `http://localhost:3002` |
361
+ | `-u, --url <url>` | agent URL | `https://nirium-agent.fly.dev` |
361
362
  | `--json` | machine-readable full response | off |
362
363
 
363
364
  | Option (`export` only) | Purpose | Default |
package/bin/nirium.js CHANGED
@@ -94,7 +94,7 @@ program
94
94
  program
95
95
  .command('status')
96
96
  .description('Check agent connection status')
97
- .option('-u, --url <url>', 'Agent URL', 'http://localhost:3002')
97
+ .option('-u, --url <url>', 'Agent URL', 'https://nirium-agent.fly.dev')
98
98
  .option('--json', 'Output the raw /health fields plus ok, as JSON')
99
99
  .option('--timeout <ms>', 'Give up after this many milliseconds', '5000')
100
100
  .action(async (options) => {
@@ -225,7 +225,7 @@ program
225
225
  .option('--tag <tag>', 'Free-form label for this anchor')
226
226
  .option('--sign', 'Attach an ed25519 attestation of which key produced this anchor')
227
227
  .option('--key-env <VAR>', 'Environment variable holding the Stellar secret key to sign with (--sign only; default: the config store\'s secretKey)')
228
- .option('-u, --url <url>', 'Agent URL', 'http://localhost:3002')
228
+ .option('-u, --url <url>', 'Agent URL', 'https://nirium-agent.fly.dev')
229
229
  .option('--json', 'Output result as JSON')
230
230
  .action(async (options) => {
231
231
  await executeAnchorCommand(options);
@@ -305,7 +305,7 @@ reportCommand
305
305
  .option('--from <date>', 'ISO date, start of period (default: a 30-day window)')
306
306
  .option('--to <date>', 'ISO date, end of period')
307
307
  .option('--network <network>', 'testnet or mainnet (default: all)')
308
- .option('-u, --url <url>', 'Agent URL', 'http://localhost:3002')
308
+ .option('-u, --url <url>', 'Agent URL', 'https://nirium-agent.fly.dev')
309
309
  .option('--json', 'Output as JSON')
310
310
  .action(async (options) => {
311
311
  await executeReportSummaryCommand(options);
@@ -314,13 +314,13 @@ reportCommand
314
314
  reportCommand
315
315
  .command('export')
316
316
  .argument('<type>', 'anchors, payments, or payroll')
317
- .description('Export rows for a period - "export anchors" prints one CID per line, pipeable to `nirium verify`')
317
+ .description('Export rows for a period - "export anchors" prints when and on which network each anchor was made (no CIDs: a CID belongs to whoever anchored it)')
318
318
  .option('--from <date>', 'ISO date, start of period (default: a 30-day window)')
319
319
  .option('--to <date>', 'ISO date, end of period')
320
320
  .option('--limit <n>', 'Max rows (server caps at 1000)')
321
321
  .option('--network <network>', 'testnet or mainnet (default: all)')
322
322
  .option('--csv <file>', 'Write the CSV export to this file instead of printing rows')
323
- .option('-u, --url <url>', 'Agent URL', 'http://localhost:3002')
323
+ .option('-u, --url <url>', 'Agent URL', 'https://nirium-agent.fly.dev')
324
324
  .option('--json', 'Output the full JSON response instead of one row per line')
325
325
  .action(async (type, options) => {
326
326
  await executeReportExportCommand(type, options);
@@ -337,7 +337,7 @@ function scaffoldX402(dir, name) {
337
337
  type: 'module',
338
338
  scripts: { dev: 'tsx watch src/server.ts', build: 'tsc' },
339
339
  dependencies: {
340
- nirium: '^0.16.0',
340
+ nirium: '^0.19.0',
341
341
  express: '^5.1.0',
342
342
  '@x402/express': '^2.17.0',
343
343
  '@x402/core': '^2.17.0',
@@ -403,7 +403,7 @@ function scaffoldTS(dir, name) {
403
403
  "build": "tsc"
404
404
  },
405
405
  dependencies: {
406
- "nirium": "^0.16.0",
406
+ "nirium": "^0.19.0",
407
407
  "tsx": "^4.19.0",
408
408
  "typescript": "^5.7.0",
409
409
  "dotenv": "^16.4.5"
@@ -931,7 +931,7 @@ async function executeServeCommand(options) {
931
931
  price,
932
932
  paidTo: payTo,
933
933
  timestamp: new Date().toISOString(),
934
- sampleData: { signal: 'CETES_REBALANCE_OPPORTUNITY', yieldApy: '5.57%', network },
934
+ sampleData: { signal: 'CETES_REBALANCE_OPPORTUNITY', yieldApy: '5.55%', network },
935
935
  });
936
936
  });
937
937
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nirium-cli",
3
- "version": "3.2.1",
4
- "description": "Nirium CLI — scaffold Stellar agent projects and check agent status",
3
+ "version": "3.2.3",
4
+ "description": "Nirium from the terminal: pay or serve an x402 API on Stellar, anchor and verify receipts, check an agent and export reports.",
5
5
  "main": "bin/nirium.js",
6
6
  "type": "module",
7
7
  "bin": {
@@ -13,10 +13,14 @@
13
13
  },
14
14
  "keywords": [
15
15
  "stellar",
16
- "soroban",
17
16
  "x402",
17
+ "usdc",
18
+ "payments",
19
+ "pay-per-request",
18
20
  "ai-agents",
19
- "nirium",
21
+ "agentic-payments",
22
+ "receipts",
23
+ "audit-trail",
20
24
  "cli"
21
25
  ],
22
26
  "author": "Nirium Team",
@@ -24,7 +28,7 @@
24
28
  "dependencies": {
25
29
  "axios": "^1.20.0",
26
30
  "commander": "^14.0.3",
27
- "nirium": "^0.16.1",
31
+ "nirium": "^0.19.0",
28
32
  "express": "^5.1.0",
29
33
  "@stellar/stellar-sdk": "^16.3.0",
30
34
  "@x402/express": "^2.28.0"