@wasit-dev/core 0.8.0-beta.1 → 0.8.0-beta.2

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 (57) hide show
  1. package/README.md +13 -2
  2. package/dist/baseline.js +3 -1
  3. package/dist/check.d.ts +1 -1
  4. package/dist/ci-report.js +15 -7
  5. package/dist/config-writer.d.ts +96 -0
  6. package/dist/config-writer.js +281 -0
  7. package/dist/guard/budget.d.ts +6 -3
  8. package/dist/guard/budget.js +10 -3
  9. package/dist/guard/ci-event.d.ts +6 -0
  10. package/dist/guard/ci-event.js +7 -3
  11. package/dist/guard/ci-mainnet.d.ts +59 -0
  12. package/dist/guard/ci-mainnet.js +149 -0
  13. package/dist/guard/horizon.d.ts +30 -0
  14. package/dist/guard/horizon.js +107 -0
  15. package/dist/guard/mainnet-payer.d.ts +66 -0
  16. package/dist/guard/mainnet-payer.js +92 -0
  17. package/dist/guard/mainnet-plan.d.ts +133 -0
  18. package/dist/guard/mainnet-plan.js +208 -0
  19. package/dist/guard/mainnet-run.d.ts +87 -0
  20. package/dist/guard/mainnet-run.js +225 -0
  21. package/dist/guard/networks.d.ts +9 -8
  22. package/dist/guard/networks.js +21 -10
  23. package/dist/guard/optin.d.ts +106 -0
  24. package/dist/guard/optin.js +202 -0
  25. package/dist/guard/run-ledger.d.ts +212 -0
  26. package/dist/guard/run-ledger.js +426 -0
  27. package/dist/guard/run-lock.d.ts +62 -0
  28. package/dist/guard/run-lock.js +172 -0
  29. package/dist/guard/signed-terms.d.ts +96 -0
  30. package/dist/guard/signed-terms.js +207 -0
  31. package/dist/index.d.ts +18 -7
  32. package/dist/index.js +19 -5
  33. package/dist/mpp/channel-credential.d.ts +13 -1
  34. package/dist/mpp/channel-credential.js +18 -2
  35. package/dist/mpp/channel.d.ts +6 -0
  36. package/dist/mpp/channel.js +7 -3
  37. package/dist/mpp/charge.d.ts +31 -1
  38. package/dist/mpp/charge.js +74 -20
  39. package/dist/mpp/plan.d.ts +77 -0
  40. package/dist/mpp/plan.js +188 -0
  41. package/dist/mpp/suite.d.ts +6 -0
  42. package/dist/mpp/suite.js +2 -1
  43. package/dist/route-reader.d.ts +124 -0
  44. package/dist/route-reader.js +349 -0
  45. package/dist/wallet.d.ts +58 -1
  46. package/dist/wallet.js +128 -0
  47. package/dist/x402/chains/stellar.js +134 -3
  48. package/dist/x402/chains/types.d.ts +36 -2
  49. package/dist/x402/plan.d.ts +102 -0
  50. package/dist/x402/plan.js +380 -6
  51. package/dist/x402/rejected-request.d.ts +10 -0
  52. package/dist/x402/rejected-request.js +18 -0
  53. package/dist/x402/simulator.d.ts +34 -0
  54. package/dist/x402/simulator.js +452 -46
  55. package/package.json +1 -1
  56. package/dist/guard/mainnet-optin.d.ts +0 -58
  57. package/dist/guard/mainnet-optin.js +0 -95
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasit-dev/core",
3
- "version": "0.8.0-beta.1",
3
+ "version": "0.8.0-beta.2",
4
4
  "description": "Check suite for x402/MPP protocol-conformance testing on Stellar. Powers the wasit CLI and wasit-mcp server.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,58 +0,0 @@
1
- /**
2
- * The mainnet opt-in switches (spec B5), as this version has them: switches
3
- * that always refuse (spec B12).
4
- *
5
- * A later version may let an x402 run pay on `stellar:pubnet` behind an
6
- * explicit opt-in. This one does not, and it has no code path that answers
7
- * "allowed" for it. The switches that opt-in would read exist here only so
8
- * that a run, a workflow or a server that asks for mainnet is stopped and told
9
- * why, instead of being run on whatever else it was given:
10
- *
11
- * - `--mainnet` on `wasit run` (never read from the config or the environment);
12
- * - `WASIT_MAINNET_OPT_IN` and `WASIT_MAINNET_CONFIG`, the MCP server's
13
- * start-up variables, and `--mainnet` among its arguments: the server does
14
- * not start.
15
- *
16
- * The Action's `mainnet` input is refused by the Action's own input check,
17
- * which runs before Wasit is installed and so cannot import this module.
18
- *
19
- * Every function here throws, or only says which switches are set.
20
- */
21
- import { ConfigurationError } from "../errors.js";
22
- /** The sentence of spec B12. */
23
- export declare const MAINNET_OPT_IN_ABSENT = "the mainnet opt-in is not part of this version";
24
- /** A switch that asks for mainnet: the CLI's flag, or one of the MCP server's start-up settings. */
25
- export type MainnetSwitch = "--mainnet" | "WASIT_MAINNET_OPT_IN" | "WASIT_MAINNET_CONFIG";
26
- /**
27
- * A switch asked for mainnet, and this version has no mainnet opt-in. A
28
- * `ConfigurationError`: it says nothing about any service. Nothing was read,
29
- * sent or signed when it is thrown.
30
- */
31
- export declare class MainnetOptInRefusedError extends ConfigurationError {
32
- readonly switchName: MainnetSwitch;
33
- constructor(switchName: MainnetSwitch, message: string);
34
- }
35
- /**
36
- * Refuses a switch that asks for mainnet. Always throws.
37
- *
38
- * For `--mainnet`, `context.event` is the GitHub event of the run when it runs
39
- * in GitHub Actions: on any event but `workflow_dispatch` the message says that
40
- * rule as well, so a push or a schedule with the switch set reads as refused for
41
- * that reason too.
42
- *
43
- * @throws {MainnetOptInRefusedError} Always.
44
- */
45
- export declare function refuseMainnetSwitch(switchName: MainnetSwitch, context?: {
46
- readonly event?: string;
47
- }): never;
48
- /**
49
- * The switches that ask the MCP server for mainnet at start-up: `--mainnet`
50
- * among its arguments (with or without a value), and each start-up variable
51
- * that holds a value that is not blank. Any value counts, "0" included: the
52
- * variable is there to be removed. Names are compared in upper case, as a
53
- * Windows environment does.
54
- *
55
- * @param env the server's environment
56
- * @param args the server's arguments, after the script (`process.argv.slice(2)`)
57
- */
58
- export declare function mainnetStartupSwitches(env: Readonly<Record<string, string | undefined>>, args: readonly string[]): MainnetSwitch[];
@@ -1,95 +0,0 @@
1
- /**
2
- * The mainnet opt-in switches (spec B5), as this version has them: switches
3
- * that always refuse (spec B12).
4
- *
5
- * A later version may let an x402 run pay on `stellar:pubnet` behind an
6
- * explicit opt-in. This one does not, and it has no code path that answers
7
- * "allowed" for it. The switches that opt-in would read exist here only so
8
- * that a run, a workflow or a server that asks for mainnet is stopped and told
9
- * why, instead of being run on whatever else it was given:
10
- *
11
- * - `--mainnet` on `wasit run` (never read from the config or the environment);
12
- * - `WASIT_MAINNET_OPT_IN` and `WASIT_MAINNET_CONFIG`, the MCP server's
13
- * start-up variables, and `--mainnet` among its arguments: the server does
14
- * not start.
15
- *
16
- * The Action's `mainnet` input is refused by the Action's own input check,
17
- * which runs before Wasit is installed and so cannot import this module.
18
- *
19
- * Every function here throws, or only says which switches are set.
20
- */
21
- import { ConfigurationError } from "../errors.js";
22
- import { NETWORK_CLASSES } from "./networks.js";
23
- /** The sentence of spec B12. */
24
- export const MAINNET_OPT_IN_ABSENT = "the mainnet opt-in is not part of this version";
25
- /** The MCP server's start-up variables that ask for mainnet. */
26
- const STARTUP_VARIABLES = ["WASIT_MAINNET_OPT_IN", "WASIT_MAINNET_CONFIG"];
27
- /** An event name as GitHub writes them; anything else is never echoed. */
28
- const EVENT_NAME = /^[a-z_]{1,64}$/;
29
- /**
30
- * A switch asked for mainnet, and this version has no mainnet opt-in. A
31
- * `ConfigurationError`: it says nothing about any service. Nothing was read,
32
- * sent or signed when it is thrown.
33
- */
34
- export class MainnetOptInRefusedError extends ConfigurationError {
35
- switchName;
36
- constructor(switchName, message) {
37
- super(message);
38
- this.name = "MainnetOptInRefusedError";
39
- this.switchName = switchName;
40
- }
41
- }
42
- function testNetworks() {
43
- return [...NETWORK_CLASSES]
44
- .filter(([, kind]) => kind === "test")
45
- .map(([network]) => network)
46
- .join(", ");
47
- }
48
- /**
49
- * Refuses a switch that asks for mainnet. Always throws.
50
- *
51
- * For `--mainnet`, `context.event` is the GitHub event of the run when it runs
52
- * in GitHub Actions: on any event but `workflow_dispatch` the message says that
53
- * rule as well, so a push or a schedule with the switch set reads as refused for
54
- * that reason too.
55
- *
56
- * @throws {MainnetOptInRefusedError} Always.
57
- */
58
- export function refuseMainnetSwitch(switchName, context = {}) {
59
- const networks = `Wasit pays on test networks only (${testNetworks()}).`;
60
- if (switchName === "--mainnet") {
61
- const event = context.event;
62
- const eventRule = event === undefined || event === "workflow_dispatch"
63
- ? ""
64
- : ` --mainnet is also refused on every GitHub event but workflow_dispatch, and this run's event is ` +
65
- `${EVENT_NAME.test(event) ? event : "another event"}.`;
66
- throw new MainnetOptInRefusedError(switchName, `--mainnet is refused: ${MAINNET_OPT_IN_ABSENT}. ${networks}${eventRule} ` +
67
- `The config was not read, and nothing was started, sent or signed.`);
68
- }
69
- throw new MainnetOptInRefusedError(switchName, `${switchName} is set: ${MAINNET_OPT_IN_ABSENT}, so this server does not start. ${networks} ` +
70
- `Nothing was read, sent or signed. Remove ${switchName} from the server's environment to start it.`);
71
- }
72
- /**
73
- * The switches that ask the MCP server for mainnet at start-up: `--mainnet`
74
- * among its arguments (with or without a value), and each start-up variable
75
- * that holds a value that is not blank. Any value counts, "0" included: the
76
- * variable is there to be removed. Names are compared in upper case, as a
77
- * Windows environment does.
78
- *
79
- * @param env the server's environment
80
- * @param args the server's arguments, after the script (`process.argv.slice(2)`)
81
- */
82
- export function mainnetStartupSwitches(env, args) {
83
- const found = [];
84
- if (args.some((arg) => arg === "--mainnet" || arg.startsWith("--mainnet=")))
85
- found.push("--mainnet");
86
- const set = new Set();
87
- for (const [name, value] of Object.entries(env)) {
88
- if (typeof value === "string" && value.trim() !== "")
89
- set.add(name.toUpperCase());
90
- }
91
- for (const name of STARTUP_VARIABLES)
92
- if (set.has(name))
93
- found.push(name);
94
- return found;
95
- }