@wasit-dev/cli 0.8.0-beta.2 → 0.8.0-beta.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.
package/README.md CHANGED
@@ -8,7 +8,7 @@ For both MPP charge payments and x402 payments it verifies the settlement indepe
8
8
 
9
9
  **Testnet by default.** Several checks settle real transactions. The payment checks pay on test networks only: any other network, `stellar:pubnet` included, is refused before a key is read, but for `wasit run --mainnet` (beta, below). Do not use production keys: the mainnet opt-in takes a dedicated account only.
10
10
 
11
- **This README describes 0.8.0-beta.2**, a pre-release on npm under the `beta` tag (`npm install -g @wasit-dev/cli@beta`). `latest` is still 0.7.0. New in 0.8.0-beta.2: `wasit init`, which writes the config from one unpaid request to your route and can set up a testnet payer; MPP charge and channel checks in `wasit run`; the capped mainnet opt-in, `wasit run --mainnet` (beta, x402 only); and "resource consumed", the result for a single-use route. New in 0.8.0-beta.1: `wasit run` for a whole service from a `wasit.config.json`, `wasit ci-report`, the GitHub Action, a seventeenth check (`X402-11`), and a cap on every payment Wasit signs.
11
+ **This README describes 0.8.0-beta.3**, a pre-release on npm under the `beta` tag (`npm install -g @wasit-dev/cli@beta`). `latest` is still 0.7.0. New in 0.8.0-beta.3: fixes for what a fresh install pulled in (the address-bound Stellar credentials of `@stellar/stellar-sdk` 17, `@solana/kit` 8 and version 1 Solana transactions), the x402 libraries pinned to the versions the suites ran on, a clean exit on Windows, and `X402-10` on Stellar waiting on the chain (see the CHANGELOG). New in 0.8.0-beta.2: `wasit init`, which writes the config from one unpaid request to your route and can set up a testnet payer; MPP charge and channel checks in `wasit run`; the capped mainnet opt-in, `wasit run --mainnet` (beta, x402 only); and "resource consumed", the result for a single-use route. New in 0.8.0-beta.1: `wasit run` for a whole service from a `wasit.config.json`, `wasit ci-report`, the GitHub Action, a seventeenth check (`X402-11`), and a cap on every payment Wasit signs.
12
12
 
13
13
  ## Install
14
14
 
@@ -29,6 +29,14 @@ reads `.env` from the directory you run it in — so on a machine already set up
29
29
  for a later suite, the first command in this README would settle a real testnet
30
30
  payment.
31
31
 
32
+ ### Windows
33
+
34
+ Tested on Windows 11 with Node 24 in PowerShell (2026-11-29, `0.8.0-beta.2`), for the read-only run (`wasit run --read-only --start`); no other Windows version has been run.
35
+
36
+ - PowerShell blocks `npm.ps1` and `npx.ps1` by default ("running scripts is disabled on this system"). Call the `.cmd` files instead: `npm.cmd install -g @wasit-dev/cli@beta`, `npx.cmd wasit --version`. Changing the policy (`Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`) also works, and is your choice.
37
+ - Pressing Ctrl+C while `npx.cmd` runs `wasit` makes `cmd.exe` ask "Terminate batch job (Y/N)?" itself. To stop without that question, run Node on the CLI's file directly: `node .\node_modules\@wasit-dev\cli\dist\index.js run --start`.
38
+ - The GitHub Action runs on Linux runners only.
39
+
32
40
  ## Quick start
33
41
 
34
42
  The default posture costs nothing — no keys required:
package/dist/exit.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * How a command ends once its work is done and its output is written.
3
+ *
4
+ * On Linux and macOS: `process.exit(code)`, as always.
5
+ *
6
+ * On Windows, `process.exit()` called right after a network request can abort
7
+ * Node with a libuv assertion (`!(handle->flags & UV_HANDLE_CLOSING)`,
8
+ * `src\win\async.c`, line 76): the results are printed, then the process dies
9
+ * with exit code 0xC0000409 (-1073740791) instead of the one the command chose,
10
+ * which a script or CI step reads as a crash. Shown on Windows 11 26H2 with
11
+ * Node 24.14.1 (2026-11-29) with plain Node, no Wasit: `fetch` to an RPC, then
12
+ * `process.exit(2)` at once, aborted; the same with `process.exitCode = 2` and
13
+ * no exit call, or with the exit 2 s later, ended with 2. Every Wasit command
14
+ * that reads a chain, a faucet or an RPC ended that way.
15
+ *
16
+ * So on Windows the code is set and the event loop is let drain: pending work
17
+ * (a DNS lookup, a socket closing) finishes first, and Node then exits with the
18
+ * code. A timer that does not keep the process alive ends, after the grace
19
+ * period, a process that something else holds open (and there the abort can
20
+ * still happen).
21
+ *
22
+ * Not covered: the exits before any network work (bad arguments, a missing
23
+ * key), which keep `process.exit`; and the exits on a signal (Ctrl+C during a
24
+ * run, in service.ts, and in `wasit serve`), which stop at once on purpose, so
25
+ * on Windows a Ctrl+C while a request is in flight may still abort.
26
+ */
27
+ /** How long a Windows process may stay open after its command finished. */
28
+ export declare const WINDOWS_EXIT_GRACE_MS = 10000;
29
+ export interface FinishDeps {
30
+ readonly platform: NodeJS.Platform;
31
+ readonly exit: (code: number) => void;
32
+ readonly setExitCode: (code: number) => void;
33
+ readonly setTimer: (callback: () => void, ms: number) => {
34
+ unref(): unknown;
35
+ };
36
+ }
37
+ /**
38
+ * Ends the command with `code`. On Windows it returns at once and the process
39
+ * ends when the event loop is empty, so the caller must return right after it
40
+ * and run nothing else.
41
+ */
42
+ export declare function finish(code: number, deps?: FinishDeps): void;
package/dist/exit.js ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * How a command ends once its work is done and its output is written.
3
+ *
4
+ * On Linux and macOS: `process.exit(code)`, as always.
5
+ *
6
+ * On Windows, `process.exit()` called right after a network request can abort
7
+ * Node with a libuv assertion (`!(handle->flags & UV_HANDLE_CLOSING)`,
8
+ * `src\win\async.c`, line 76): the results are printed, then the process dies
9
+ * with exit code 0xC0000409 (-1073740791) instead of the one the command chose,
10
+ * which a script or CI step reads as a crash. Shown on Windows 11 26H2 with
11
+ * Node 24.14.1 (2026-11-29) with plain Node, no Wasit: `fetch` to an RPC, then
12
+ * `process.exit(2)` at once, aborted; the same with `process.exitCode = 2` and
13
+ * no exit call, or with the exit 2 s later, ended with 2. Every Wasit command
14
+ * that reads a chain, a faucet or an RPC ended that way.
15
+ *
16
+ * So on Windows the code is set and the event loop is let drain: pending work
17
+ * (a DNS lookup, a socket closing) finishes first, and Node then exits with the
18
+ * code. A timer that does not keep the process alive ends, after the grace
19
+ * period, a process that something else holds open (and there the abort can
20
+ * still happen).
21
+ *
22
+ * Not covered: the exits before any network work (bad arguments, a missing
23
+ * key), which keep `process.exit`; and the exits on a signal (Ctrl+C during a
24
+ * run, in service.ts, and in `wasit serve`), which stop at once on purpose, so
25
+ * on Windows a Ctrl+C while a request is in flight may still abort.
26
+ */
27
+ /** How long a Windows process may stay open after its command finished. */
28
+ export const WINDOWS_EXIT_GRACE_MS = 10_000;
29
+ const PROCESS = {
30
+ get platform() {
31
+ return process.platform;
32
+ },
33
+ exit: (code) => process.exit(code),
34
+ setExitCode: (code) => {
35
+ process.exitCode = code;
36
+ },
37
+ setTimer: (callback, ms) => setTimeout(callback, ms),
38
+ };
39
+ /**
40
+ * Ends the command with `code`. On Windows it returns at once and the process
41
+ * ends when the event loop is empty, so the caller must return right after it
42
+ * and run nothing else.
43
+ */
44
+ export function finish(code, deps = PROCESS) {
45
+ if (deps.platform !== "win32") {
46
+ deps.exit(code);
47
+ return;
48
+ }
49
+ deps.setExitCode(code);
50
+ deps.setTimer(() => deps.exit(code), WINDOWS_EXIT_GRACE_MS).unref();
51
+ }
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import { executeCiReport } from "./ci-report-command.js";
11
11
  import { note, report } from "./output.js";
12
12
  import { liveX402Test } from "./test-live.js";
13
13
  import { colorDepth, colorEnabled, lineWidth, styler } from "./style.js";
14
+ import { finish } from "./exit.js";
14
15
  import { executeRun } from "./run.js";
15
16
  import { DEFAULT_CONFIG_FILE, executeInit } from "./init-command.js";
16
17
  import { LIVE_KEY_SETUP } from "./init-keys.js";
@@ -86,7 +87,7 @@ program.hook("preAction", (_program, action) => {
86
87
  return;
87
88
  loadDotenv();
88
89
  });
89
- /** Waits until what was written to stdout and stderr has been handed to the system, so `process.exit` cannot cut a long report. */
90
+ /** Waits until what was written to stdout and stderr has been handed to the system, so the exit (see `finish`) cannot cut a long report. */
90
91
  async function flushOutput() {
91
92
  await Promise.all([process.stdout, process.stderr].map((stream) => new Promise((resolve) => stream.write("", () => resolve()))));
92
93
  }
@@ -181,7 +182,8 @@ or NO_COLOR gives the plain text; FORCE_COLOR=1 colours a pipe.`)
181
182
  // A person at a terminal gets the coloured, live output; a pipe, CI, NO_COLOR
182
183
  // and --json get the plain text below, unchanged.
183
184
  if (!jsonMode && colorEnabled(process.stdout, process.env)) {
184
- process.exit(await liveX402Test(opts, shape, { stream: process.stdout, env: process.env }));
185
+ finish(await liveX402Test(opts, shape, { stream: process.stdout, env: process.env }));
186
+ return;
185
187
  }
186
188
  const results = await runX402ReadChecks({ target: opts.target, ...shape });
187
189
  // Each chain reads its own payer key: a Stellar secret is no use on EVM.
@@ -205,7 +207,7 @@ or NO_COLOR gives the plain text; FORCE_COLOR=1 colours a pipe.`)
205
207
  })));
206
208
  }
207
209
  // One endpoint: a service Wasit could not grade exits 2, not 0 (spec A8 #3).
208
- process.exit(report(results, jsonMode, { protocol: "x402" }));
210
+ finish(report(results, jsonMode, { protocol: "x402" }));
209
211
  });
210
212
  program
211
213
  .command("run")
@@ -224,7 +226,8 @@ program
224
226
  "The service does not receive Wasit's key variables, header variables or WASIT_RPC_URL.", false)
225
227
  .option("--start-if-local", "Like --start, but only when service.start is set and the environment is on this machine (localhost, 127.x.x.x or [::1]); " +
226
228
  "otherwise the configured baseUrl is read as it is, which is how a deployed endpoint is checked. Not with --start.", false)
227
- .option("--baseline <file>", "The report of the default branch: an endpoint graded there that is unsupported or without a verdict now is a regression (exit 1)")
229
+ .option("--baseline <file>", "The report of the default branch: an endpoint graded there that is unsupported or without a verdict now is a regression (exit 1), " +
230
+ "unless this run's tier skipped every check of it (an MPP endpoint on a pull request, or a run without its key)")
228
231
  .option("--mainnet", "Pay real USDC on stellar:pubnet (x402 only). Runs only when every rule holds: the environment is on stellar:pubnet with " +
229
232
  "operatedByMe true and pinned payTo and asset (mainnet USDC); the key is in WASIT_MAINNET_PAYER_SECRET and in no other " +
230
233
  "variable; an https RPC for stellar:pubnet is set (rpcUrl or WASIT_RPC_URL); the payer holds at most $10.00 of USDC; " +
@@ -305,7 +308,7 @@ In CI (CI or GITHUB_ACTIONS set) a .env file in the working directory is not rea
305
308
  code = 2;
306
309
  }
307
310
  await flushOutput();
308
- process.exit(code);
311
+ finish(code);
309
312
  });
310
313
  program
311
314
  .command("init")
@@ -408,7 +411,7 @@ given); 2 init refused, and nothing was written.`)
408
411
  rl?.close();
409
412
  }
410
413
  await flushOutput();
411
- process.exit(code);
414
+ finish(code);
412
415
  });
413
416
  program
414
417
  .command("ci-report")
@@ -442,7 +445,7 @@ program
442
445
  code = 2;
443
446
  }
444
447
  await flushOutput();
445
- process.exit(code);
448
+ finish(code);
446
449
  });
447
450
  program
448
451
  .command("serve")
@@ -557,7 +560,7 @@ that channel.`)
557
560
  ...(Number.isInteger(refundWaitingPeriod) ? { refundWaitingPeriod } : {}),
558
561
  },
559
562
  });
560
- process.exit(report(results, jsonMode, terminalStyle(jsonMode)));
563
+ finish(report(results, jsonMode, terminalStyle(jsonMode)));
561
564
  });
562
565
  /** Colours for the MPP commands' text output, when a person is at the terminal. */
563
566
  function terminalStyle(jsonMode) {
@@ -596,7 +599,7 @@ a real payment and moves testnet funds, because charge mode has no dry run.`)
596
599
  payerSecretKey,
597
600
  ...(opts.rpcUrl ? { rpcUrl: opts.rpcUrl } : {}),
598
601
  });
599
- process.exit(report(results, jsonMode, terminalStyle(jsonMode)));
602
+ finish(report(results, jsonMode, terminalStyle(jsonMode)));
600
603
  });
601
604
  registerWalletCommand(program);
602
605
  const isBareInteractiveInvocation = process.argv.length <= 2 && process.stdout.isTTY === true;
package/dist/service.d.ts CHANGED
@@ -17,8 +17,13 @@
17
17
  * SIGINT, SIGTERM and SIGHUP, and, as a last synchronous resort, when the Node
18
18
  * process exits. A SIGKILL of Wasit itself cannot be caught.
19
19
  *
20
- * Windows: the group kill is `taskkill /pid <pid> /T /F`. That path has NOT been
21
- * run on Windows; no Windows machine was available.
20
+ * Windows: the group kill is `taskkill /pid <pid> /T /F`. It was run once on
21
+ * Windows 11 (26H2, Node 24, PowerShell, 2026-11-29): `wasit run --read-only
22
+ * --start` against a service started with `npm start` left no listener and no
23
+ * node process, after a run that ended normally and after Ctrl+C (with `node` run
24
+ * directly: `npx.cmd` is a batch file, and `cmd.exe` asks "Terminate batch job"
25
+ * itself). Not run: the payment tier, other Windows versions and other ways
26
+ * a run can end (a failing run, SIGTERM, SIGHUP).
22
27
  */
23
28
  /**
24
29
  * The OS user a service runs as when it must not share a user with the payer
package/dist/service.js CHANGED
@@ -17,8 +17,13 @@
17
17
  * SIGINT, SIGTERM and SIGHUP, and, as a last synchronous resort, when the Node
18
18
  * process exits. A SIGKILL of Wasit itself cannot be caught.
19
19
  *
20
- * Windows: the group kill is `taskkill /pid <pid> /T /F`. That path has NOT been
21
- * run on Windows; no Windows machine was available.
20
+ * Windows: the group kill is `taskkill /pid <pid> /T /F`. It was run once on
21
+ * Windows 11 (26H2, Node 24, PowerShell, 2026-11-29): `wasit run --read-only
22
+ * --start` against a service started with `npm start` left no listener and no
23
+ * node process, after a run that ended normally and after Ctrl+C (with `node` run
24
+ * directly: `npx.cmd` is a batch file, and `cmd.exe` asks "Terminate batch job"
25
+ * itself). Not run: the payment tier, other Windows versions and other ways
26
+ * a run can end (a failing run, SIGTERM, SIGHUP).
22
27
  */
23
28
  import { spawn, spawnSync } from "node:child_process";
24
29
  import { existsSync, realpathSync } from "node:fs";
@@ -16,6 +16,7 @@
16
16
  import { oraPromise } from "ora";
17
17
  import { createUsdcTrustline, fundWithFriendbot, generateCommitmentKey, generateTestnetWallet, getTestnetWalletStatus, paymentChainFor, publicKeyFromSecret, sendUsdcFromDistributor, TESTNET_USDC_ISSUER, } from "@wasit-dev/core";
18
18
  import { DEFAULT_SERVE_NETWORK, SERVE_NETWORKS } from "./serve.js";
19
+ import { finish } from "./exit.js";
19
20
  /** Every role a key can be generated for. */
20
21
  const ROLES = ["x402", "mpp-charge", "mpp-channel"];
21
22
  /**
@@ -258,7 +259,8 @@ docs/guides/configuration.md) and has no on-chain balance of its own.`)
258
259
  if (opts.network !== DEFAULT_SERVE_NETWORK) {
259
260
  const role = opts.role === undefined ? "x402" : requireRole(opts.role, ACCOUNT_ROLES);
260
261
  const network = requireNetwork(opts.network, role);
261
- process.exit(await printPayerStatus(network, jsonMode));
262
+ finish(await printPayerStatus(network, jsonMode));
263
+ return;
262
264
  }
263
265
  const roles = opts.role !== undefined ? [requireRole(opts.role, ACCOUNT_ROLES)] : ACCOUNT_ROLES;
264
266
  const rows = [];
@@ -295,7 +297,8 @@ docs/guides/configuration.md) and has no on-chain balance of its own.`)
295
297
  const exitCode = walletStatusExitCode(opts.role !== undefined, rows);
296
298
  if (jsonMode) {
297
299
  console.log(JSON.stringify(rows, null, 2));
298
- process.exit(exitCode);
300
+ finish(exitCode);
301
+ return;
299
302
  }
300
303
  for (const row of rows) {
301
304
  if (!row.configured) {
@@ -309,7 +312,7 @@ docs/guides/configuration.md) and has no on-chain balance of its own.`)
309
312
  }
310
313
  printWalletStatus(row.role, row.publicKey, row.status);
311
314
  }
312
- process.exit(exitCode);
315
+ finish(exitCode);
313
316
  });
314
317
  wallet
315
318
  .command("create")
@@ -375,7 +378,8 @@ are recording, and never paste a pubnet key into these variables.`)
375
378
  });
376
379
  }
377
380
  catch {
378
- process.exit(1);
381
+ finish(1);
382
+ return;
379
383
  }
380
384
  }
381
385
  });
@@ -425,7 +429,8 @@ prints where to get USDC for the configured x402 payer.`)
425
429
  });
426
430
  }
427
431
  catch {
428
- process.exit(1);
432
+ finish(1);
433
+ return;
429
434
  }
430
435
  return;
431
436
  }
@@ -435,7 +440,8 @@ prints where to get USDC for the configured x402 payer.`)
435
440
  }
436
441
  catch (error) {
437
442
  console.error(`Could not read the account: ${messageOf(error)}`);
438
- process.exit(1);
443
+ finish(1);
444
+ return;
439
445
  }
440
446
  const xlmBalance = before.balances.find((balance) => balance.code === "XLM");
441
447
  if (!before.exists || Number(xlmBalance?.balance ?? "0") < 2) {
@@ -447,7 +453,8 @@ prints where to get USDC for the configured x402 payer.`)
447
453
  });
448
454
  }
449
455
  catch {
450
- process.exit(1);
456
+ finish(1);
457
+ return;
451
458
  }
452
459
  }
453
460
  try {
@@ -458,7 +465,8 @@ prints where to get USDC for the configured x402 payer.`)
458
465
  });
459
466
  }
460
467
  catch {
461
- process.exit(1);
468
+ finish(1);
469
+ return;
462
470
  }
463
471
  const distributorSecret = process.env.WASIT_USDC_DISTRIBUTOR_SECRET;
464
472
  if (!distributorSecret) {
@@ -477,7 +485,8 @@ prints where to get USDC for the configured x402 payer.`)
477
485
  });
478
486
  }
479
487
  catch {
480
- process.exit(1);
488
+ finish(1);
489
+ return;
481
490
  }
482
491
  });
483
492
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasit-dev/cli",
3
- "version": "0.8.0-beta.2",
3
+ "version": "0.8.0-beta.3",
4
4
  "description": "CLI for x402/MPP protocol-conformance testing on Stellar — verifies a service's payment flow settles on-chain per spec.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,7 +41,7 @@
41
41
  "typecheck": "tsc -p test/tsconfig.json"
42
42
  },
43
43
  "dependencies": {
44
- "@wasit-dev/core": "^0.8.0-beta.2",
44
+ "@wasit-dev/core": "^0.8.0-beta.3",
45
45
  "cfonts": "^3.3.1",
46
46
  "commander": "^15.0.0",
47
47
  "dotenv": "^17.4.2",