x402check 0.3.0 → 0.3.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.
package/README.md CHANGED
@@ -10,6 +10,29 @@ Validate [x402](https://www.x402.org/) payment configurations. Works in Node, br
10
10
  npm i x402check
11
11
  ```
12
12
 
13
+ ## CLI
14
+
15
+ Validate configs from the command line — no code required.
16
+
17
+ ```
18
+ npx x402check '{"x402Version":2,"accepts":[...]}'
19
+ npx x402check config.json
20
+ npx x402check https://api.example.com/resource
21
+ echo '...' | npx x402check
22
+ ```
23
+
24
+ Flags:
25
+
26
+ | Flag | Description |
27
+ |------|-------------|
28
+ | `--strict` | Promote all warnings to errors |
29
+ | `--json` | Output raw JSON (for piping) |
30
+ | `--quiet` | Suppress output, exit code only |
31
+
32
+ Exit codes: `0` valid, `1` invalid, `2` input error.
33
+
34
+ Install globally with `npm i -g x402check` to use `x402check` directly.
35
+
13
36
  ## Quick start
14
37
 
15
38
  ```js
@@ -35,6 +58,30 @@ result.normalized // canonical v2 config
35
58
 
36
59
  ## API
37
60
 
61
+ ### `check(response, options?)`
62
+
63
+ All-in-one: extracts config from an HTTP 402 response, validates it, and enriches with registry data (network names, asset symbols, decimals).
64
+
65
+ ```js
66
+ import { check } from 'x402check'
67
+
68
+ const res = await fetch(url)
69
+ const result = check({
70
+ body: await res.json(),
71
+ headers: res.headers
72
+ })
73
+
74
+ result.extracted // true | false
75
+ result.source // 'body' | 'header' | null
76
+ result.valid // true | false
77
+ result.errors // ValidationIssue[]
78
+ result.warnings // ValidationIssue[]
79
+ result.summary // AcceptSummary[] — display-ready payment options
80
+ result.normalized // canonical v2 config
81
+ ```
82
+
83
+ Each `summary` entry includes `networkName`, `assetSymbol`, `assetDecimals`, and other registry-resolved fields.
84
+
38
85
  ### `validate(input, options?)`
39
86
 
40
87
  Validates a config object or JSON string. Returns errors, warnings, and a normalized v2 config.
package/dist/cli.mjs CHANGED
@@ -2135,7 +2135,7 @@ function check(response, options) {
2135
2135
 
2136
2136
  //#endregion
2137
2137
  //#region src/index.ts
2138
- const VERSION = "0.3.0";
2138
+ const VERSION = "0.3.1";
2139
2139
 
2140
2140
  //#endregion
2141
2141
  //#region src/cli.ts
package/dist/index.cjs CHANGED
@@ -2132,7 +2132,7 @@ function check(response, options) {
2132
2132
 
2133
2133
  //#endregion
2134
2134
  //#region src/index.ts
2135
- const VERSION = "0.3.0";
2135
+ const VERSION = "0.3.1";
2136
2136
 
2137
2137
  //#endregion
2138
2138
  exports.CAIP2_REGEX = CAIP2_REGEX;