@agent-score/commerce 1.5.1 → 1.6.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 +22 -8
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/core.d.mts +36 -27
- package/dist/core.d.ts +36 -27
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/identity/express.d.mts +2 -2
- package/dist/identity/express.d.ts +2 -2
- package/dist/identity/express.js +1 -1
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +1 -1
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +2 -2
- package/dist/identity/fastify.d.ts +2 -2
- package/dist/identity/fastify.js +1 -1
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +1 -1
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +2 -2
- package/dist/identity/hono.d.ts +2 -2
- package/dist/identity/hono.js +1 -1
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +1 -1
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +2 -2
- package/dist/identity/nextjs.d.ts +2 -2
- package/dist/identity/nextjs.js +1 -1
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +1 -1
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/policy.d.mts +3 -3
- package/dist/identity/policy.d.ts +3 -3
- package/dist/identity/policy.js +3 -3
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs +2 -2
- package/dist/identity/policy.mjs.map +1 -1
- package/dist/identity/web.d.mts +3 -3
- package/dist/identity/web.d.ts +3 -3
- package/dist/identity/web.js +1 -1
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +1 -1
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +217 -123
- package/dist/index.d.ts +217 -123
- package/dist/index.js +86 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -68
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,8 @@ npm install hono mppx @x402/core @x402/evm @solana/mpp @solana/kit stripe # wh
|
|
|
23
23
|
|
|
24
24
|
| Subpath | What it provides |
|
|
25
25
|
|---|---|
|
|
26
|
-
| `/identity/{hono,express,fastify
|
|
26
|
+
| `/identity/{hono,express,fastify}` | Trust gate middleware: KYC, sanctions, age, jurisdiction. Context-getter pattern: `agentscoreGate(opts)` middleware + `getAgentScoreData(ctx)` / `getGateDegradedState(ctx)` / `getGateQuotaInfo(ctx)` accessors, `captureWallet(...)`, `verifyWalletSignerMatch(...)`. Plus shared denial helpers: `denialReasonStatus`, `denialReasonToBody`, `buildSignerMismatchBody`, `buildContactSupportNextSteps`, `verificationAgentInstructions`, `isFixableDenial`, `FIXABLE_DENIAL_REASONS`. |
|
|
27
|
+
| `/identity/{nextjs,web}` | Same gate, wrapper pattern: `withAgentScoreGate(opts, handler)` / `createAgentScoreGate(opts) => guard(req)`. The `data` + `degraded` + `infraReason` fields land directly on the handler arg / guard result (no separate getter). Plus shared `captureWallet`, `verifyWalletSignerMatch`. |
|
|
27
28
|
| `/payment` | `networks`, `USDC`, `rails` registries; `paymentDirective`, `buildPaymentDirective`, `wwwAuthenticateHeader`, `paymentRequiredHeader`, `aliasAmountFields` (v1↔v2 amount field shim: emits both `amount` and `maxAmountRequired` so v1-only x402 parsers like Coinbase awal can read v2 bodies), `settlementOverrideHeader`, `dispatchSettlementByNetwork`, `extractPaymentSigner` (returns `{address, network}`); `createX402Server`, `createMppxServer`; drop-in x402 helpers: `validateX402NetworkConfig` (boot-time guard), `verifyX402Request` (parse + validate inbound X-Payment), `processX402Settle` (verify-then-settle with one call), `classifyX402SettleResult` (maps the tagged settle result to a recommended HTTP status / code / nextSteps so merchants get a controlled envelope without coupling to facilitator-specific error text). |
|
|
28
29
|
| `/discovery` | `isDiscoveryProbeRequest`, `buildDiscoveryProbeResponse` (with optional `x402Sample` for x402-aware crawlers, e.g. `awal x402 details`), `sampleX402AcceptForNetwork` (USDC sample-accept builder for known CAIP-2 networks), `buildWellKnownMpp`, `buildLlmsTxt` + `llmsTxtIdentitySection` + `llmsTxtPaymentSection` (compact + verbose modes), `buildSkillMd` (Claude-Skill-compatible `/skill.md` agent-discovery manifest; strictly agent-facing data only, no internal posture), `agentscoreOpenApiSnippets`, `createBazaarDiscovery`, `noindexNonDiscoveryPaths` (Hono middleware that emits `X-Robots-Tag: noindex` on every path except the agent-discovery surfaces; defaults cover `/openapi.json`, `/llms.txt`, `/skill.md`, `/.well-known/{mpp.json,agent-card.json,ucp,jwks.json}`, `/favicon.{png,ico}`; pure helpers `isDiscoveryPath` + `defaultDiscoveryPaths` for non-Hono frameworks). |
|
|
29
30
|
| `/challenge` | `build402Body`, `buildAcceptedMethods`, `buildIdentityMetadata`, `buildHowToPay`, `buildAgentInstructions` (auto-emits per-rail `compatible_clients`: smoke-verified CLIs the agent should use; vendor override supported), `buildPricingBlock`, `firstEncounterAgentMemory`, `OrderReceipt`; `respond402`, a drop-in 402 emit that preserves mppx's `WWW-Authenticate` and layers x402's `PAYMENT-REQUIRED`. `buildValidationError`: structured 4xx body builder (`{error: {code, message}, required_fields?, example_body?, next_steps?, ...extra}`) so vendors compose body shapes by name instead of inlining at every validation site. |
|
|
@@ -193,10 +194,19 @@ return new Response(JSON.stringify(responseBody), { status: 402, headers });
|
|
|
193
194
|
import { buildA2AAgentCard, buildUCPProfile, ucpA2AExtension } from "@agent-score/commerce";
|
|
194
195
|
|
|
195
196
|
// Google A2A v1.0 Signed Agent Card; publish at /.well-known/agent-card.json.
|
|
196
|
-
// Per UCP §A2A binding, the card MUST declare the canonical UCP extension URI
|
|
197
|
-
// pass `ucpA2AExtension()` with empty capabilities
|
|
198
|
-
// capabilities (dev.ucp.shopping.checkout, etc.).
|
|
199
|
-
|
|
197
|
+
// Per UCP §A2A binding, the card MUST declare the canonical UCP extension URI in
|
|
198
|
+
// `capabilities.extensions[]`; pass `ucpA2AExtension()` with empty capabilities
|
|
199
|
+
// until you bind formal UCP capabilities (dev.ucp.shopping.checkout, etc.).
|
|
200
|
+
// Skills are top-level AgentSkill objects; identity claims live in a separate
|
|
201
|
+
// AgentCardSignature (RFC 7515 JWS) wrapping the serialized card.
|
|
202
|
+
const card = buildA2AAgentCard({
|
|
203
|
+
name,
|
|
204
|
+
description,
|
|
205
|
+
url,
|
|
206
|
+
version: "1.0.0",
|
|
207
|
+
skills: [{ id: "purchase", name: "Purchase", description: "Buy products via agent payments.", tags: ["commerce", "payment"] }],
|
|
208
|
+
extensions: [ucpA2AExtension()],
|
|
209
|
+
});
|
|
200
210
|
|
|
201
211
|
// Google Universal Commerce Protocol; publish at /.well-known/ucp
|
|
202
212
|
// Output shape: { ucp: { version, services, capabilities, payment_handlers,
|
|
@@ -209,7 +219,7 @@ const profile = buildUCPProfile({
|
|
|
209
219
|
'dev.ucp.shopping': [
|
|
210
220
|
{ version: '2026-04-08', spec: 'https://ucp.dev/2026-04-08/specification/overview',
|
|
211
221
|
transport: 'mcp', endpoint: 'https://merchant.example/api/ucp/mcp',
|
|
212
|
-
schema: 'https://ucp.dev/services/shopping/openrpc.json' },
|
|
222
|
+
schema: 'https://ucp.dev/services/shopping/mcp.openrpc.json' },
|
|
213
223
|
],
|
|
214
224
|
},
|
|
215
225
|
payment_handlers: {
|
|
@@ -220,7 +230,11 @@ const profile = buildUCPProfile({
|
|
|
220
230
|
config: { recipient: TEMPO_ADDR },
|
|
221
231
|
}],
|
|
222
232
|
},
|
|
223
|
-
signing_keys,
|
|
233
|
+
signing_keys,
|
|
234
|
+
// Optional: declare the merchant's gate policy as an `sh.agentscore.identity` capability
|
|
235
|
+
// binding inside the public profile. Static policy declaration only — no per-operator data.
|
|
236
|
+
// Per-operator identity attestation lives on the AP2 risk-signal endpoint, not here.
|
|
237
|
+
agentscore_gate: { require_kyc: true, min_age: 21, allowed_jurisdictions: ['US'] },
|
|
224
238
|
});
|
|
225
239
|
```
|
|
226
240
|
|
|
@@ -379,7 +393,7 @@ When `failOpen: true` AND the failure is infra-shape, the gate carries `degraded
|
|
|
379
393
|
|
|
380
394
|
For regulated commerce (alcohol, age-gated, sanctioned-jurisdiction-relevant) keep the default `failOpen: false`: outage is the correct posture, and bypassing compliance on infra failure is a compliance gap. For low-stakes commerce or high-uptime SLAs, opt in and use the `degraded` flag as the audit trail.
|
|
381
395
|
|
|
382
|
-
The `getGateDegradedState` helper is exported by
|
|
396
|
+
The `getGateDegradedState` helper is exported by the context-getter adapters (Hono, Express, Fastify). For the wrapper-pattern adapters (Next.js, Web Fetch via `withAgentScoreGate` / `createAgentScoreGate`), the `degraded` + `infraReason` fields land directly on the `gate` object passed to your handler — no separate getter.
|
|
383
397
|
|
|
384
398
|
## Examples
|
|
385
399
|
|