@wasit-dev/core 0.1.0 → 0.1.1

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 (2) hide show
  1. package/README.md +97 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # @wasit-dev/core
2
+
3
+ The check suite behind [`@wasit-dev/cli`](https://www.npmjs.com/package/@wasit-dev/cli) and [`@wasit-dev/server`](https://www.npmjs.com/package/@wasit-dev/server) — protocol-compliance checks for **x402** and **MPP** on Stellar.
4
+
5
+ This package holds the actual check logic. The CLI and the MCP server are thin adapters over these same functions, so a CLI run and an agent's run can never disagree about the same target — there is only one implementation of each check.
6
+
7
+ **Testnet only.** Several checks settle real transactions on-chain.
8
+
9
+ Most people should reach for [`@wasit-dev/cli`](https://www.npmjs.com/package/@wasit-dev/cli) (terminal) or [`@wasit-dev/server`](https://www.npmjs.com/package/@wasit-dev/server) (MCP / agents) instead of this package directly. Install `@wasit-dev/core` yourself only if you're building your own tooling on top of the check suite.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @wasit-dev/core
15
+ ```
16
+
17
+ Requires Node.js `>=24`. Ships ESM only (`"type": "module"`), with TypeScript types included (`dist/index.d.ts`).
18
+
19
+ ## Usage
20
+
21
+ ```ts
22
+ import {
23
+ runX402ReadChecks,
24
+ runX402PaymentChecks,
25
+ summarize,
26
+ checkStatus,
27
+ } from "@wasit-dev/core";
28
+
29
+ const readResults = await runX402ReadChecks({
30
+ target: "https://your-service.example.com/paid",
31
+ });
32
+
33
+ // With a testnet payer key, also exercise the payment flow.
34
+ // X402-06 settles a real payment; X402-07 attempts one with a corrupted signature.
35
+ const paidResults = await runX402PaymentChecks({
36
+ target: "https://your-service.example.com/paid",
37
+ network: "stellar:testnet",
38
+ payerSecretKey: process.env.STELLAR_PRIVATE_KEY!,
39
+ });
40
+
41
+ const summary = summarize([...readResults, ...paidResults]);
42
+ console.log(summary.exitCode); // 0 conformant, 1 non-conformant, 2 no verdict
43
+ ```
44
+
45
+ Every check function returns `Promise<CheckResult[]>` and never rejects for a target-side problem — a check that couldn't run (unreachable target, bad config) comes back as an `ERROR` or `SKIP` result, not a thrown error.
46
+
47
+ ## API
48
+
49
+ ### x402
50
+
51
+ | Function | Checks | Cost |
52
+ |---|---|---|
53
+ | `runX402ReadChecks({ target, method?, body?, headers? })` | `X402-01`–`05` | Free |
54
+ | `runX402PaymentChecks({ target, network, payerSecretKey, method?, body?, headers? })` | `X402-06`, `07` | **Settles a real payment every call** |
55
+
56
+ ### MPP — charge mode
57
+
58
+ | Function | Checks | Cost |
59
+ |---|---|---|
60
+ | `runMppChargeSuite({ target, network, payerSecretKey, rpcUrl? })` | `MPP-01` | **Settles a real payment every call** |
61
+
62
+ ### MPP — channel mode
63
+
64
+ | Function | Checks | Cost |
65
+ |---|---|---|
66
+ | `runMppChannelSuite({ target, commitmentSecretHex, network, rpcUrl?, channelOverride?, expected?, allowDestructive?, destructiveChannel? })` | `MPP-10`–`12`, `14` free; `MPP-13` when `allowDestructive` is set | `MPP-13` **permanently closes the channel** |
67
+
68
+ `expected` is `Partial<{ token, from, to, refundWaitingPeriod }>` — `MPP-10`'s on-chain parameter assertions. `channelOverride` asserts which channel to inspect; the target's own 402 challenge is authoritative, so a mismatch fails `MPP-10` rather than silently inspecting two contracts.
69
+
70
+ ### Reporting
71
+
72
+ | Export | Signature |
73
+ |---|---|
74
+ | `CheckResult` | `{ id, name, pass, detail, skipped?, skipReason?, destructive?, error? }` |
75
+ | `checkStatus(result)` | → `"PASS" \| "FAIL" \| "ERROR" \| "SKIP"` |
76
+ | `summarize(results)` | → `{ passed, failed, errored, skipped, exitCode }` — `exitCode` is `0 \| 1 \| 2`, shared by both front ends so they can never disagree about the same run |
77
+ | `errored(id, name, error)` | Builds an `ERROR` result — mostly useful writing your own check |
78
+ | `skipped(id, name, reason)` | Builds a non-destructive `SKIP` result |
79
+ | `skippedDestructive(id, name, reason)` | Builds a `SKIP` result for a destructive check not opted into |
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).
82
+
83
+ ## Design
84
+
85
+ - **`FAIL`, `ERROR`, and `SKIP` are different claims.** `FAIL` means the target answered and didn't conform. `ERROR` means no verdict was produced at all (unreachable, misconfigured, harness failure). `SKIP` is neither. Conflating "your service is broken" with "we never reached your service" would make a tool worse than no tool.
86
+ - **Destructive checks require an explicit opt-in** (`allowDestructive: true`), and even then only run against a channel the caller explicitly names as disposable — they never touch the channel under active test.
87
+ - Every dependency this package calls into (`@stellar/mpp`, `mppx`, `@stellar/stellar-sdk`, `@x402/*`) was verified against its **compiled** output, not just its published types, before any check was written against it.
88
+
89
+ ## Related
90
+
91
+ - [`@wasit-dev/cli`](https://www.npmjs.com/package/@wasit-dev/cli) — terminal front end
92
+ - [`@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
+
95
+ ## License
96
+
97
+ Apache-2.0 — see [LICENSE](https://github.com/dzakwannajmi/wasit/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasit-dev/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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",