@wasit-dev/core 0.1.1 → 0.2.0

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
@@ -78,7 +78,7 @@ Every check function returns `Promise<CheckResult[]>` and never rejects for a ta
78
78
  | `skipped(id, name, reason)` | Builds a non-destructive `SKIP` result |
79
79
  | `skippedDestructive(id, name, reason)` | Builds a `SKIP` result for a destructive check not opted into |
80
80
 
81
- The full check catalogue — every check's exact pass criteria and spec reference — is in [`docs/CHECKS.md`](https://github.com/dzakwannajmi/wasit/blob/main/docs/CHECKS.md).
81
+ The full check catalogue — every check's exact pass criteria and spec reference — is in [`docs/CHECKS.md`](https://github.com/wasit-dev/wasit/blob/main/docs/CHECKS.md).
82
82
 
83
83
  ## Design
84
84
 
@@ -88,10 +88,11 @@ The full check catalogue — every check's exact pass criteria and spec referenc
88
88
 
89
89
  ## Related
90
90
 
91
+ - [Website](https://usewasit.dev)
91
92
  - [`@wasit-dev/cli`](https://www.npmjs.com/package/@wasit-dev/cli) — terminal front end
92
93
  - [`@wasit-dev/server`](https://www.npmjs.com/package/@wasit-dev/server) — MCP front end, for Claude Code and other agents
93
- - [Full documentation](https://github.com/dzakwannajmi/wasit)
94
+ - [Full documentation](https://github.com/wasit-dev/wasit)
94
95
 
95
96
  ## License
96
97
 
97
- Apache-2.0 — see [LICENSE](https://github.com/dzakwannajmi/wasit/blob/main/LICENSE).
98
+ Apache-2.0 — see [LICENSE](https://github.com/wasit-dev/wasit/blob/main/LICENSE).
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Structured summary of every check in the catalogue.
3
+ *
4
+ * This is a short-form companion to docs/CHECKS.md, not a replacement for
5
+ * it: full pass-criteria prose, spec citations, and the revision/status
6
+ * notes only live in the markdown doc. This file exists so the CLI's
7
+ * `wasit checks` command (and any future consumer that needs the catalogue
8
+ * as data rather than prose) has one small, typed source instead of
9
+ * parsing markdown or duplicating IDs by hand.
10
+ *
11
+ * MAINTENANCE: kept in sync with docs/CHECKS.md manually. If you add,
12
+ * rename, or re-scope a check there, update the matching entry here in the
13
+ * same change — there is currently no generator tying the two together.
14
+ */
15
+ export type ProtocolId = "x402" | "mpp-charge" | "mpp-channel";
16
+ export declare const PROTOCOL_IDS: readonly ProtocolId[];
17
+ export interface CheckCatalogueEntry {
18
+ /** Stable catalogue identifier, e.g. "MPP-11". Must match docs/CHECKS.md. */
19
+ readonly id: string;
20
+ readonly name: string;
21
+ readonly protocol: ProtocolId;
22
+ /** Where in the spec (or SDK behavior) this check is grounded. */
23
+ readonly specRef: string;
24
+ /** One-line summary of what the check verifies. Full pass criteria: docs/CHECKS.md. */
25
+ readonly summary: string;
26
+ /** True for a check that only passes because the target correctly REJECTED something. */
27
+ readonly negative?: true;
28
+ /** True for a check that permanently alters the target's state (see SECURITY.md). */
29
+ readonly destructive?: true;
30
+ /** True for a check that settles or risks settling a real on-chain payment. */
31
+ readonly costsFunds?: true;
32
+ }
33
+ export declare const CHECK_CATALOGUE: readonly CheckCatalogueEntry[];
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Structured summary of every check in the catalogue.
3
+ *
4
+ * This is a short-form companion to docs/CHECKS.md, not a replacement for
5
+ * it: full pass-criteria prose, spec citations, and the revision/status
6
+ * notes only live in the markdown doc. This file exists so the CLI's
7
+ * `wasit checks` command (and any future consumer that needs the catalogue
8
+ * as data rather than prose) has one small, typed source instead of
9
+ * parsing markdown or duplicating IDs by hand.
10
+ *
11
+ * MAINTENANCE: kept in sync with docs/CHECKS.md manually. If you add,
12
+ * rename, or re-scope a check there, update the matching entry here in the
13
+ * same change — there is currently no generator tying the two together.
14
+ */
15
+ export const PROTOCOL_IDS = ["x402", "mpp-charge", "mpp-channel"];
16
+ export const CHECK_CATALOGUE = [
17
+ {
18
+ id: "X402-01",
19
+ name: "402 Response Status",
20
+ protocol: "x402",
21
+ specRef: "x402 spec, HTTP semantics",
22
+ summary: "An unpaid request must be answered with status code 402.",
23
+ },
24
+ {
25
+ id: "X402-02",
26
+ name: "Payment Header Present",
27
+ protocol: "x402",
28
+ specRef: "x402 built-on-stellar guide",
29
+ summary: "The 402 response must include a payment header.",
30
+ },
31
+ {
32
+ id: "X402-03",
33
+ name: "Header Payload Decodable",
34
+ protocol: "x402",
35
+ specRef: "x402 spec §payment-required-object",
36
+ summary: "The header value must be valid base64 that decodes to JSON.",
37
+ },
38
+ {
39
+ id: "X402-04",
40
+ name: "Required Fields Present",
41
+ protocol: "x402",
42
+ specRef: "x402 spec §payment-required-object",
43
+ summary: "The payload must include the core payment terms, under the field names its advertised version requires.",
44
+ },
45
+ {
46
+ id: "X402-05",
47
+ name: "Network Identifier Valid",
48
+ protocol: "x402",
49
+ specRef: "x402 built-on-stellar guide",
50
+ summary: "The network identifier must follow CAIP-2 (stellar:testnet or stellar:pubnet).",
51
+ },
52
+ {
53
+ id: "X402-06",
54
+ name: "Signature Resubmit Accepted",
55
+ protocol: "x402",
56
+ specRef: "x402 spec §payment-flow",
57
+ summary: "A resubmitted request carrying a valid signature must be accepted.",
58
+ costsFunds: true,
59
+ },
60
+ {
61
+ id: "X402-07",
62
+ name: "Invalid Signature Rejected",
63
+ protocol: "x402",
64
+ specRef: "x402 spec §payment-flow",
65
+ summary: "A deliberately corrupted signature must be rejected, not accepted.",
66
+ negative: true,
67
+ costsFunds: true,
68
+ },
69
+ {
70
+ id: "MPP-01",
71
+ name: "Charge Settlement On-Chain",
72
+ protocol: "mpp-charge",
73
+ specRef: "MPP Charge Guide; CAP-46 transfer events",
74
+ summary: "The charge settles on-chain for exactly what the target advertised.",
75
+ costsFunds: true,
76
+ },
77
+ {
78
+ id: "MPP-10",
79
+ name: "Channel Deploy",
80
+ protocol: "mpp-channel",
81
+ specRef: "MPP Channel Guide",
82
+ summary: "The channel contract deploys correctly and is the same channel the target bills through.",
83
+ },
84
+ {
85
+ id: "MPP-11",
86
+ name: "Cumulative Commitment Ordering",
87
+ protocol: "mpp-channel",
88
+ specRef: "MPP Channel Guide §closing-the-channel; @stellar/mpp channel server",
89
+ summary: "A commitment must exceed the stored cumulative and cover the price of the current request.",
90
+ },
91
+ {
92
+ id: "MPP-12",
93
+ name: "Challenge Replay Rejection",
94
+ protocol: "mpp-channel",
95
+ specRef: "MPP Channel Guide §closing-the-channel; @stellar/mpp channel server",
96
+ summary: "A byte-identical credential resubmitted against the same challenge must be rejected.",
97
+ negative: true,
98
+ },
99
+ {
100
+ id: "MPP-13",
101
+ name: "Close Settlement",
102
+ protocol: "mpp-channel",
103
+ specRef: "MPP Channel Guide §closing-the-channel",
104
+ summary: "Closing with the highest commitment settles on-chain. Permanently ends the channel.",
105
+ destructive: true,
106
+ costsFunds: true,
107
+ },
108
+ {
109
+ id: "MPP-14",
110
+ name: "Commitment Replay Rejection",
111
+ protocol: "mpp-channel",
112
+ specRef: "MPP Channel Guide §closing-the-channel; @stellar/mpp channel server",
113
+ summary: "A captured (amount, signature) pair must not be redeemable against a new challenge.",
114
+ negative: true,
115
+ },
116
+ ];
package/dist/check.d.ts CHANGED
@@ -68,3 +68,34 @@ export declare function skippedDestructive(id: string, name: string, reason: str
68
68
  export declare function errored(id: string, name: string, error: unknown): CheckResult;
69
69
  /** Builds the result for a check that was not run, for a non-destructive reason. */
70
70
  export declare function skipped(id: string, name: string, reason: string): CheckResult;
71
+ /** One check's result, reshaped for a machine-readable front end (CLI --json, MCP). */
72
+ export interface StructuredCheckResult {
73
+ readonly id: string;
74
+ readonly name: string;
75
+ readonly status: CheckStatus;
76
+ readonly detail: string;
77
+ readonly destructive: boolean;
78
+ /** Present only when `status` is "ERROR": unreachable | configuration | harness. */
79
+ readonly errorKind?: string;
80
+ }
81
+ /** A full run, reshaped for a machine-readable front end (CLI --json, MCP). */
82
+ export interface StructuredRun {
83
+ /**
84
+ * Named rather than left as a numeric exit code: an exit code means
85
+ * nothing outside a shell, and "no-verdict" must never be read as
86
+ * "compliant" by whatever consumes this — a script or an agent alike.
87
+ */
88
+ readonly outcome: "conformant" | "non-conformant" | "no-verdict";
89
+ readonly passed: number;
90
+ readonly failed: number;
91
+ readonly errored: number;
92
+ readonly skipped: number;
93
+ readonly results: readonly StructuredCheckResult[];
94
+ }
95
+ /**
96
+ * Reshapes a run into the one JSON shape every machine-readable front end
97
+ * uses — the CLI's `--json` output and the MCP server's `structuredContent`
98
+ * both call this rather than each rolling their own mapping, so the two
99
+ * can never drift into reporting the same run two different ways.
100
+ */
101
+ export declare function toStructuredRun(results: CheckResult[]): StructuredRun;
package/dist/check.js CHANGED
@@ -94,3 +94,32 @@ export function skipped(id, name, reason) {
94
94
  detail: `Skipped: ${reason}`,
95
95
  };
96
96
  }
97
+ /**
98
+ * Reshapes a run into the one JSON shape every machine-readable front end
99
+ * uses — the CLI's `--json` output and the MCP server's `structuredContent`
100
+ * both call this rather than each rolling their own mapping, so the two
101
+ * can never drift into reporting the same run two different ways.
102
+ */
103
+ export function toStructuredRun(results) {
104
+ const counts = summarize(results);
105
+ const outcome = counts.exitCode === 0
106
+ ? "conformant"
107
+ : counts.exitCode === 1
108
+ ? "non-conformant"
109
+ : "no-verdict";
110
+ return {
111
+ outcome,
112
+ passed: counts.passed,
113
+ failed: counts.failed,
114
+ errored: counts.errored,
115
+ skipped: counts.skipped,
116
+ results: results.map((result) => ({
117
+ id: result.id,
118
+ name: result.name,
119
+ status: checkStatus(result),
120
+ detail: result.detail,
121
+ destructive: result.destructive === true,
122
+ ...(result.error ? { errorKind: result.error.kind } : {}),
123
+ })),
124
+ };
125
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export { checkStatus, errored, skipped, skippedDestructive, summarize } from "./check.js";
2
- export type { CheckResult, CheckStatus, RunSummary } from "./check.js";
1
+ export { checkStatus, errored, skipped, skippedDestructive, summarize, toStructuredRun, } from "./check.js";
2
+ export type { CheckResult, CheckStatus, RunSummary, StructuredCheckResult, StructuredRun, } from "./check.js";
3
+ export { CHECK_CATALOGUE, PROTOCOL_IDS } from "./catalogue.js";
4
+ export type { CheckCatalogueEntry, ProtocolId } from "./catalogue.js";
3
5
  export * from "./errors.js";
4
6
  export * from "./x402/simulator.js";
5
7
  export * from "./mpp/channel.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- export { checkStatus, errored, skipped, skippedDestructive, summarize } from "./check.js";
1
+ export { checkStatus, errored, skipped, skippedDestructive, summarize, toStructuredRun, } from "./check.js";
2
+ export { CHECK_CATALOGUE, PROTOCOL_IDS } from "./catalogue.js";
2
3
  export * from "./errors.js";
3
4
  export * from "./x402/simulator.js";
4
5
  export * from "./mpp/channel.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasit-dev/core",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
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",
@@ -10,12 +10,12 @@
10
10
  ],
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git+https://github.com/dzakwannajmi/wasit.git",
13
+ "url": "git+https://github.com/wasit-dev/wasit.git",
14
14
  "directory": "packages/core"
15
15
  },
16
- "homepage": "https://github.com/dzakwannajmi/wasit#readme",
16
+ "homepage": "https://github.com/wasit-dev/wasit#readme",
17
17
  "bugs": {
18
- "url": "https://github.com/dzakwannajmi/wasit/issues"
18
+ "url": "https://github.com/wasit-dev/wasit/issues"
19
19
  },
20
20
  "keywords": [
21
21
  "stellar",
@@ -39,16 +39,16 @@
39
39
  "dependencies": {
40
40
  "@stellar/mpp": "^0.7.1",
41
41
  "@stellar/stellar-sdk": "^16.1.0",
42
- "@x402/core": "^2.19.0",
43
- "@x402/express": "^2.19.0",
44
42
  "@x402/fetch": "^2.19.0",
45
43
  "@x402/stellar": "^2.19.0",
46
- "commander": "^15.0.0",
47
- "dotenv": "^17.4.2",
48
44
  "mppx": "^0.8.14"
49
45
  },
50
46
  "devDependencies": {
51
47
  "@types/node": "^26.1.1",
48
+ "@x402/core": "^2.19.0",
49
+ "@x402/express": "^2.19.0",
50
+ "dotenv": "^17.4.2",
51
+ "express": "^5.2.1",
52
52
  "tsx": "^4.23.1"
53
53
  }
54
54
  }