@agent-score/commerce 1.7.0 → 1.8.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 (62) hide show
  1. package/README.md +3 -3
  2. package/dist/{_response-DpB-cm2c.d.mts → _response-9yp6Fit2.d.mts} +13 -11
  3. package/dist/{_response-C2yFQoIA.d.ts → _response-CC6jNb8q.d.ts} +13 -11
  4. package/dist/challenge/index.d.mts +6 -5
  5. package/dist/challenge/index.d.ts +6 -5
  6. package/dist/challenge/index.js.map +1 -1
  7. package/dist/challenge/index.mjs.map +1 -1
  8. package/dist/core.d.mts +36 -27
  9. package/dist/core.d.ts +36 -27
  10. package/dist/core.js +21 -101
  11. package/dist/core.js.map +1 -1
  12. package/dist/core.mjs +21 -101
  13. package/dist/core.mjs.map +1 -1
  14. package/dist/identity/express.d.mts +12 -13
  15. package/dist/identity/express.d.ts +12 -13
  16. package/dist/identity/express.js +38 -121
  17. package/dist/identity/express.js.map +1 -1
  18. package/dist/identity/express.mjs +36 -118
  19. package/dist/identity/express.mjs.map +1 -1
  20. package/dist/identity/fastify.d.mts +12 -11
  21. package/dist/identity/fastify.d.ts +12 -11
  22. package/dist/identity/fastify.js +38 -121
  23. package/dist/identity/fastify.js.map +1 -1
  24. package/dist/identity/fastify.mjs +36 -118
  25. package/dist/identity/fastify.mjs.map +1 -1
  26. package/dist/identity/hono.d.mts +13 -28
  27. package/dist/identity/hono.d.ts +13 -28
  28. package/dist/identity/hono.js +31 -123
  29. package/dist/identity/hono.js.map +1 -1
  30. package/dist/identity/hono.mjs +29 -120
  31. package/dist/identity/hono.mjs.map +1 -1
  32. package/dist/identity/nextjs.d.mts +8 -7
  33. package/dist/identity/nextjs.d.ts +8 -7
  34. package/dist/identity/nextjs.js +27 -119
  35. package/dist/identity/nextjs.js.map +1 -1
  36. package/dist/identity/nextjs.mjs +27 -118
  37. package/dist/identity/nextjs.mjs.map +1 -1
  38. package/dist/identity/policy.d.mts +1 -0
  39. package/dist/identity/policy.d.ts +1 -0
  40. package/dist/identity/web.d.mts +12 -14
  41. package/dist/identity/web.d.ts +12 -14
  42. package/dist/identity/web.js +27 -119
  43. package/dist/identity/web.js.map +1 -1
  44. package/dist/identity/web.mjs +27 -118
  45. package/dist/identity/web.mjs.map +1 -1
  46. package/dist/index.d.mts +3 -3
  47. package/dist/index.d.ts +3 -3
  48. package/dist/index.js +1 -7
  49. package/dist/index.js.map +1 -1
  50. package/dist/index.mjs +1 -6
  51. package/dist/index.mjs.map +1 -1
  52. package/dist/payment/index.d.mts +2 -2
  53. package/dist/payment/index.d.ts +2 -2
  54. package/dist/payment/index.js.map +1 -1
  55. package/dist/payment/index.mjs.map +1 -1
  56. package/dist/{signer-kCAJUZwp.d.mts → signer-CFVQsWjL.d.mts} +1 -6
  57. package/dist/{signer-kCAJUZwp.d.ts → signer-CFVQsWjL.d.ts} +1 -6
  58. package/dist/stripe-multichain/index.d.mts +1 -1
  59. package/dist/stripe-multichain/index.d.ts +1 -1
  60. package/dist/stripe-multichain/index.js.map +1 -1
  61. package/dist/stripe-multichain/index.mjs.map +1 -1
  62. package/package.json +11 -9
package/README.md CHANGED
@@ -23,9 +23,9 @@ 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}` | 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`. |
26
+ | `/identity/{hono,express,fastify}` | Trust gate middleware: KYC, sanctions (account name + signer wallet), age, jurisdiction. Context-getter pattern: `agentscoreGate(opts)` middleware + `getAgentScoreData(ctx)` / `getGateDegradedState(ctx)` / `getGateQuotaInfo(ctx)` / `getSignerVerdict(ctx)` accessors, `captureWallet(...)`. Plus shared denial helpers: `denialReasonStatus`, `denialReasonToBody`, `buildSignerMismatchBody`, `buildContactSupportNextSteps`, `verificationAgentInstructions`, `isFixableDenial`, `FIXABLE_DENIAL_REASONS`. |
27
27
  | `/identity/policy` | Per-product compliance helpers for multi-product merchants (each product carries its own policy: hard gate vs soft vs none, per-product shipping allowlists): `PolicyBlock`, `GateResult`, `EnforcementMode`, `IdentityStatus`, `buildGateOptionsFromPolicy`, `runGateWithEnforcement`, `shippingCountryAllowed`, `shippingStateAllowed`. |
28
- | `/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`. |
28
+ | `/identity/{nextjs,web}` | Same gate, wrapper pattern: `withAgentScoreGate(opts, handler)` / `createAgentScoreGate(opts) => guard(req)`. The `data` + `degraded` + `infraReason` + `getSignerVerdict` fields land directly on the handler arg / guard result (no separate getter). Plus shared `captureWallet`. |
29
29
  | `/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). |
30
30
  | `/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). |
31
31
  | `/challenge` | `build402Body`, `buildAcceptedMethods`, `buildIdentityMetadata`, `buildHowToPay`, `buildAgentInstructions` (auto-emits per-rail `compatible_clients`: smoke-verified CLIs the agent should use; vendor override supported; pure helper `compatibleClientsByRails(rails)` returns the same map for vendors building custom 402s), `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. |
@@ -42,7 +42,7 @@ import {
42
42
  agentscoreGate,
43
43
  captureWallet,
44
44
  getAgentScoreData,
45
- verifyWalletSignerMatch,
45
+ getSignerVerdict,
46
46
  } from "@agent-score/commerce/identity/hono";
47
47
 
48
48
  const app = new Hono();
@@ -8,8 +8,8 @@ import { VerifyWalletSignerResult, DenialReason } from './core.mjs';
8
8
  * be resolved by re-completing KYC (vs sanctions / age failures which are permanent).
9
9
  * - `denialReasonStatus` — picks the right HTTP status code per denial code (401 for credential
10
10
  * problems, 503 for transient API errors, 403 for everything else).
11
- * - `buildSignerMismatchBody` — produces the standard 403 body for a `verifyWalletSignerMatch`
12
- * non-pass result.
11
+ * - `buildSignerMismatchBody` — produces the standard 403 body for a non-pass signer_match
12
+ * verdict (read via `getSignerVerdict`).
13
13
  * - `buildContactSupportNextSteps` — standard `next_steps.action: "contact_support"` shape for
14
14
  * unfixable compliance denials.
15
15
  * - `verificationAgentInstructions` — the canned `agent_instructions` block for
@@ -50,7 +50,8 @@ declare function isFixableDenial(reasons: readonly string[] | undefined): boolea
50
50
  */
51
51
  declare function denialReasonStatus(reason: DenialReason): 401 | 403 | 503;
52
52
  interface SignerMismatchBodyInput {
53
- /** Result from `verifyWalletSignerMatch`. The function only emits a body for non-pass results. */
53
+ /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). Only non-pass
54
+ * kinds produce a body. */
54
55
  result: VerifyWalletSignerResult;
55
56
  /** Optional override for the human-facing `next_steps.user_message`. */
56
57
  userMessage?: string;
@@ -58,12 +59,14 @@ interface SignerMismatchBodyInput {
58
59
  learnMoreUrl?: string;
59
60
  }
60
61
  /**
61
- * Standard 403 body for a non-pass `verifyWalletSignerMatch` result. Returns null for `pass` /
62
- * `api_error` so vendors can call it unconditionally:
62
+ * Standard 403 body for a non-pass signer-match verdict. Returns null for `pass` so vendors
63
+ * can call it unconditionally:
63
64
  *
64
- * const result = await verifyWalletSignerMatch(c);
65
- * const mismatchBody = buildSignerMismatchBody({ result });
66
- * if (mismatchBody) return c.json(mismatchBody, 403);
65
+ * const verdict = getSignerVerdict(c);
66
+ * if (verdict?.signer_match) {
67
+ * const mismatchBody = buildSignerMismatchBody({ result: verdict.signer_match });
68
+ * if (mismatchBody) return c.json(mismatchBody, 403);
69
+ * }
67
70
  *
68
71
  * Body shape mirrors the gate's denial bodies: top-level error.code, all signer-match fields
69
72
  * (`claimed_operator`, `actual_signer_operator`, `expected_signer`, `actual_signer`,
@@ -132,9 +135,8 @@ declare function verificationAgentInstructions(input?: VerificationAgentInstruct
132
135
  * to test the marshaling.
133
136
  *
134
137
  * Body shape: `{ error: { code, message }, ... }` — matches the canonical AgentScore
135
- * core API response shape (`core/api/src/lib/auth.ts`, `lib/rate-limit.ts`, etc.) and
136
- * martin-estate's pre-commerce shape, so downstream agents see one consistent
137
- * `error.code` + `error.message` pair regardless of which layer produced the denial.
138
+ * error envelope so downstream agents see one consistent `error.code` +
139
+ * `error.message` pair regardless of which layer produced the denial.
138
140
  */
139
141
 
140
142
  declare function denialReasonToBody(reason: DenialReason): Record<string, unknown>;
@@ -8,8 +8,8 @@ import { VerifyWalletSignerResult, DenialReason } from './core.js';
8
8
  * be resolved by re-completing KYC (vs sanctions / age failures which are permanent).
9
9
  * - `denialReasonStatus` — picks the right HTTP status code per denial code (401 for credential
10
10
  * problems, 503 for transient API errors, 403 for everything else).
11
- * - `buildSignerMismatchBody` — produces the standard 403 body for a `verifyWalletSignerMatch`
12
- * non-pass result.
11
+ * - `buildSignerMismatchBody` — produces the standard 403 body for a non-pass signer_match
12
+ * verdict (read via `getSignerVerdict`).
13
13
  * - `buildContactSupportNextSteps` — standard `next_steps.action: "contact_support"` shape for
14
14
  * unfixable compliance denials.
15
15
  * - `verificationAgentInstructions` — the canned `agent_instructions` block for
@@ -50,7 +50,8 @@ declare function isFixableDenial(reasons: readonly string[] | undefined): boolea
50
50
  */
51
51
  declare function denialReasonStatus(reason: DenialReason): 401 | 403 | 503;
52
52
  interface SignerMismatchBodyInput {
53
- /** Result from `verifyWalletSignerMatch`. The function only emits a body for non-pass results. */
53
+ /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). Only non-pass
54
+ * kinds produce a body. */
54
55
  result: VerifyWalletSignerResult;
55
56
  /** Optional override for the human-facing `next_steps.user_message`. */
56
57
  userMessage?: string;
@@ -58,12 +59,14 @@ interface SignerMismatchBodyInput {
58
59
  learnMoreUrl?: string;
59
60
  }
60
61
  /**
61
- * Standard 403 body for a non-pass `verifyWalletSignerMatch` result. Returns null for `pass` /
62
- * `api_error` so vendors can call it unconditionally:
62
+ * Standard 403 body for a non-pass signer-match verdict. Returns null for `pass` so vendors
63
+ * can call it unconditionally:
63
64
  *
64
- * const result = await verifyWalletSignerMatch(c);
65
- * const mismatchBody = buildSignerMismatchBody({ result });
66
- * if (mismatchBody) return c.json(mismatchBody, 403);
65
+ * const verdict = getSignerVerdict(c);
66
+ * if (verdict?.signer_match) {
67
+ * const mismatchBody = buildSignerMismatchBody({ result: verdict.signer_match });
68
+ * if (mismatchBody) return c.json(mismatchBody, 403);
69
+ * }
67
70
  *
68
71
  * Body shape mirrors the gate's denial bodies: top-level error.code, all signer-match fields
69
72
  * (`claimed_operator`, `actual_signer_operator`, `expected_signer`, `actual_signer`,
@@ -132,9 +135,8 @@ declare function verificationAgentInstructions(input?: VerificationAgentInstruct
132
135
  * to test the marshaling.
133
136
  *
134
137
  * Body shape: `{ error: { code, message }, ... }` — matches the canonical AgentScore
135
- * core API response shape (`core/api/src/lib/auth.ts`, `lib/rate-limit.ts`, etc.) and
136
- * martin-estate's pre-commerce shape, so downstream agents see one consistent
137
- * `error.code` + `error.message` pair regardless of which layer produced the denial.
138
+ * error envelope so downstream agents see one consistent `error.code` +
139
+ * `error.message` pair regardless of which layer produced the denial.
138
140
  */
139
141
 
140
142
  declare function denialReasonToBody(reason: DenialReason): Record<string, unknown>;
@@ -3,6 +3,7 @@ export { B as BuildAgentInstructionsInput, a as BuildHowToPayInput, C as Compati
3
3
  import { AgentMemoryHint } from '../core.mjs';
4
4
  export { buildAgentMemoryHint } from '../core.mjs';
5
5
  import { P as PaymentRequiredHeaderInput } from '../wwwauthenticate-CU1eNvMQ.mjs';
6
+ import '../signer-CFVQsWjL.mjs';
6
7
 
7
8
  interface TempoMethodEntry {
8
9
  method: 'tempo/charge';
@@ -70,7 +71,7 @@ interface BuildAcceptedMethodsInput {
70
71
  /**
71
72
  * Build the `accepted_methods[]` array for an enriched 402 body. Each rail entry is
72
73
  * conditionally included based on whether the vendor passed it. Per-rail shapes follow
73
- * the conventions established in martin-estate's reference 402.
74
+ * a canonical 402 shape across rails.
74
75
  */
75
76
  declare function buildAcceptedMethods(input: BuildAcceptedMethodsInput): AcceptedMethodEntry[];
76
77
 
@@ -86,7 +87,7 @@ interface IdentityMetadataInput {
86
87
  mode: IdentityMode;
87
88
  /** Claimed wallet address (when mode === 'wallet'). */
88
89
  wallet?: string;
89
- /** Result of a prior verifyWalletSignerMatch call. */
90
+ /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). */
90
91
  signerMatchResult?: SignerMatchResultLike;
91
92
  /** Same-operator linked wallets (from assess response). */
92
93
  linkedWallets?: string[];
@@ -158,9 +159,9 @@ declare function firstEncounterAgentMemory(input: FirstEncounterAgentMemoryInput
158
159
  * Pricing block builder + canonical type.
159
160
  *
160
161
  * Composes the cents-denominated price components into the dollar-string shape that
161
- * 402 challenge bodies advertise. Lifts the inline pattern from martin-estate's
162
- * `purchase.ts` so every merchant — current and future commerce-platform plugins
163
- * (Commerce7, WooCommerce, Shopify) — surfaces the same shape to agents.
162
+ * 402 challenge bodies advertise. Standardizes the pricing block so every merchant
163
+ * — current and future commerce-platform plugins (Commerce7, WooCommerce, Shopify) —
164
+ * surfaces the same shape to agents.
164
165
  *
165
166
  * Shipping is included by default because most physical-goods merchants carry it; pass
166
167
  * `shippingCents: 0` (or omit) for digital goods / services. Tax is optional for
@@ -3,6 +3,7 @@ export { B as BuildAgentInstructionsInput, a as BuildHowToPayInput, C as Compati
3
3
  import { AgentMemoryHint } from '../core.js';
4
4
  export { buildAgentMemoryHint } from '../core.js';
5
5
  import { P as PaymentRequiredHeaderInput } from '../wwwauthenticate-CU1eNvMQ.js';
6
+ import '../signer-CFVQsWjL.js';
6
7
 
7
8
  interface TempoMethodEntry {
8
9
  method: 'tempo/charge';
@@ -70,7 +71,7 @@ interface BuildAcceptedMethodsInput {
70
71
  /**
71
72
  * Build the `accepted_methods[]` array for an enriched 402 body. Each rail entry is
72
73
  * conditionally included based on whether the vendor passed it. Per-rail shapes follow
73
- * the conventions established in martin-estate's reference 402.
74
+ * a canonical 402 shape across rails.
74
75
  */
75
76
  declare function buildAcceptedMethods(input: BuildAcceptedMethodsInput): AcceptedMethodEntry[];
76
77
 
@@ -86,7 +87,7 @@ interface IdentityMetadataInput {
86
87
  mode: IdentityMode;
87
88
  /** Claimed wallet address (when mode === 'wallet'). */
88
89
  wallet?: string;
89
- /** Result of a prior verifyWalletSignerMatch call. */
90
+ /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). */
90
91
  signerMatchResult?: SignerMatchResultLike;
91
92
  /** Same-operator linked wallets (from assess response). */
92
93
  linkedWallets?: string[];
@@ -158,9 +159,9 @@ declare function firstEncounterAgentMemory(input: FirstEncounterAgentMemoryInput
158
159
  * Pricing block builder + canonical type.
159
160
  *
160
161
  * Composes the cents-denominated price components into the dollar-string shape that
161
- * 402 challenge bodies advertise. Lifts the inline pattern from martin-estate's
162
- * `purchase.ts` so every merchant — current and future commerce-platform plugins
163
- * (Commerce7, WooCommerce, Shopify) — surfaces the same shape to agents.
162
+ * 402 challenge bodies advertise. Standardizes the pricing block so every merchant
163
+ * — current and future commerce-platform plugins (Commerce7, WooCommerce, Shopify) —
164
+ * surfaces the same shape to agents.
164
165
  *
165
166
  * Shipping is included by default because most physical-goods merchants carry it; pass
166
167
  * `shippingCents: 0` (or omit) for digital goods / services. Tax is optional for