concordium-x402-guard 0.2.1 → 0.2.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.
- package/README.md +8 -0
- package/dist/networks.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,6 +41,12 @@ if (!response) {
|
|
|
41
41
|
}
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
If your agent is registered in the Agent Registry, name it so sellers that check buyers (for example with [`concordium-x402-seller`](https://www.npmjs.com/package/concordium-x402-seller)) can confirm it from the chain: send its token id in the `X-Concordium-Agent` header, and pay from its `agentWallet`. A seller set to `buyerAgent: "required"` refuses requests without it.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
await guarded.fetch(url, { method: "POST", body, headers: { "X-Concordium-Agent": "1478" } });
|
|
48
|
+
```
|
|
49
|
+
|
|
44
50
|
How a refusal looks: `response` is undefined, `verdict.ok` is false with every check listed, and `error` is also set (x402's "Payment creation aborted: refused to pay: …"). If `verdict` is undefined, the guard never saw a payment (a non-402 answer, or the x402 client failed first). `protect` accepts any `x402Client` from `@x402/fetch`, ESM or CommonJS build.
|
|
45
51
|
|
|
46
52
|
`network` is the **Concordium** network the checks read: `"testnet"` or `"mainnet"` (default testnet); anything else throws. It also pins what can be paid: a Concordium payment only on that network, an EVM payment only on its Base chain (Base Sepolia for testnet, Base for mainnet). A testnet agent never approves a mainnet payment.
|
|
@@ -83,6 +89,8 @@ Output of those runs: <https://github.com/jiahaoc040-ai/veriflow/tree/main/docs/
|
|
|
83
89
|
|
|
84
90
|
## Changes
|
|
85
91
|
|
|
92
|
+
0.2.2: `NETWORKS.*.caip2` is typed as a CAIP-2 template string, so it can be passed to `x402ResourceServer.register` and routes directly; README shows the `X-Concordium-Agent` header.
|
|
93
|
+
|
|
86
94
|
0.2.1: the `npx` command is actually included (0.2.0 was published without it).
|
|
87
95
|
|
|
88
96
|
0.2.0: `npx concordium-x402-guard check <url>`; `@x402/fetch` and `@x402/core` are peer dependencies; Node 22+ declared; an Agent Card host name that resolves to a private address is refused.
|
package/dist/networks.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
export type NetworkName = "testnet" | "mainnet";
|
|
3
3
|
export type ConcordiumNetwork = {
|
|
4
4
|
name: NetworkName;
|
|
5
|
-
/** CAIP-2 id used by x402 for this network */
|
|
6
|
-
caip2: string
|
|
5
|
+
/** CAIP-2 id used by x402 for this network (typed the way @x402/core's register() and routes expect it) */
|
|
6
|
+
caip2: `${string}:${string}`;
|
|
7
7
|
/** CIS-8004 Agent Registry */
|
|
8
8
|
agentRegistry: {
|
|
9
9
|
index: bigint;
|
|
@@ -20,6 +20,6 @@ export type ConcordiumNetwork = {
|
|
|
20
20
|
port: number;
|
|
21
21
|
};
|
|
22
22
|
/** EVM network whose keys agents usually bind (Base) */
|
|
23
|
-
evmNetwork: string
|
|
23
|
+
evmNetwork: `${string}:${string}`;
|
|
24
24
|
};
|
|
25
25
|
export declare const NETWORKS: Record<NetworkName, ConcordiumNetwork>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "concordium-x402-guard",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Check an x402 seller on Concordium before your agent pays it: Agent Registry badge, Active, Agent Card hash, payTo bound to the agent on-chain (CIS-8004 / CIS-8).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|