@agent-score/commerce 1.6.0 → 1.8.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.
Files changed (58) hide show
  1. package/README.md +8 -10
  2. package/dist/{_response-DpB-cm2c.d.mts → _response-BMt2y4Or.d.mts} +11 -8
  3. package/dist/{_response-C2yFQoIA.d.ts → _response-DyJ3mWI3.d.ts} +11 -8
  4. package/dist/challenge/index.d.mts +2 -1
  5. package/dist/challenge/index.d.ts +2 -1
  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 +73 -11
  47. package/dist/index.d.ts +73 -11
  48. package/dist/index.js +45 -9
  49. package/dist/index.js.map +1 -1
  50. package/dist/index.mjs +41 -7
  51. package/dist/index.mjs.map +1 -1
  52. package/dist/payment/index.d.mts +1 -1
  53. package/dist/payment/index.d.ts +1 -1
  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/package.json +6 -6
package/README.md CHANGED
@@ -23,11 +23,12 @@ 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`. |
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`. |
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
+ | `/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` + `getSignerVerdict` fields land directly on the handler arg / guard result (no separate getter). Plus shared `captureWallet`. |
28
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). |
29
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). |
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. |
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. |
31
32
  | `/stripe-multichain` | `createMultichainPaymentIntent`, `getDepositAddress`, `simulateCryptoDeposit`, `createMppxStripe`; `createPiCache` (TTL'd PI / deposit-address cache, Redis-backed when `redisUrl` set, in-memory otherwise), `simulateDepositIfTestMode` (gates on `sk_test_` and looks up the PI for you), `STRIPE_TEST_TX_HASH_SUCCESS` / `STRIPE_TEST_TX_HASH_FAILED` constants. Peer dep on `stripe`. |
32
33
  | `/api` | Everything from `@agent-score/sdk` re-exported in one place: `AgentScore` + `AgentScoreError`, `AGENTSCORE_TEST_ADDRESSES` + `isAgentScoreTestAddress`. **Don't add `@agent-score/sdk` as a separate dep**; the two can drift versions and cause subtle type mismatches. |
33
34
 
@@ -41,7 +42,7 @@ import {
41
42
  agentscoreGate,
42
43
  captureWallet,
43
44
  getAgentScoreData,
44
- verifyWalletSignerMatch,
45
+ getSignerVerdict,
45
46
  } from "@agent-score/commerce/identity/hono";
46
47
 
47
48
  const app = new Hono();
@@ -223,12 +224,9 @@ const profile = buildUCPProfile({
223
224
  ],
224
225
  },
225
226
  payment_handlers: {
226
- 'sh.agentscore.payment.tempo': [{
227
- id: 'tempo', version: '2026-04-08',
228
- spec: 'https://agentscore.sh/specification/payment-handlers/tempo',
229
- schema: 'https://agentscore.sh/schemas/payment-handlers/tempo.json',
230
- config: { recipient: TEMPO_ADDR },
231
- }],
227
+ ...mppPaymentHandler({ networks: [{ network: 'tempo-mainnet', chain_id: 4217, recipient: TEMPO_ADDR }] }),
228
+ ...x402PaymentHandler({ networks: [{ network: 'base-8453', recipient: BASE_ADDR }] }),
229
+ ...stripeSptPaymentHandler({ profile_id: 'profile_5xKvNqM9BaH' }),
232
230
  },
233
231
  signing_keys,
234
232
  // Optional: declare the merchant's gate policy as an `sh.agentscore.identity` capability
@@ -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`,
@@ -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`,
@@ -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';
@@ -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[];
@@ -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';
@@ -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[];