@agent-score/commerce 2.0.1 → 2.1.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 (116) hide show
  1. package/README.md +26 -11
  2. package/dist/_core-kI7FRAiZ.d.mts +10 -0
  3. package/dist/_core-kI7FRAiZ.d.ts +10 -0
  4. package/dist/challenge/index.d.mts +3 -3
  5. package/dist/challenge/index.d.ts +3 -3
  6. package/dist/challenge/index.js +21 -14
  7. package/dist/challenge/index.js.map +1 -1
  8. package/dist/challenge/index.mjs +21 -14
  9. package/dist/challenge/index.mjs.map +1 -1
  10. package/dist/{checkout-B1JuEcbx.d.ts → checkout-BH-I_Ns8.d.ts} +19 -12
  11. package/dist/{checkout-BN5i1Fi7.d.mts → checkout-Bd_4aQ6c.d.mts} +19 -12
  12. package/dist/core.js +1 -1
  13. package/dist/core.js.map +1 -1
  14. package/dist/core.mjs +1 -1
  15. package/dist/core.mjs.map +1 -1
  16. package/dist/default_rails-BWAquZeu.d.mts +188 -0
  17. package/dist/default_rails-BxBzcCA1.d.ts +188 -0
  18. package/dist/discovery/index.d.mts +5 -5
  19. package/dist/discovery/index.d.ts +5 -5
  20. package/dist/discovery/index.js +14 -1
  21. package/dist/discovery/index.js.map +1 -1
  22. package/dist/discovery/index.mjs +14 -1
  23. package/dist/discovery/index.mjs.map +1 -1
  24. package/dist/identity/express.d.mts +7 -3
  25. package/dist/identity/express.d.ts +7 -3
  26. package/dist/identity/express.js +39 -96
  27. package/dist/identity/express.js.map +1 -1
  28. package/dist/identity/express.mjs +37 -87
  29. package/dist/identity/express.mjs.map +1 -1
  30. package/dist/identity/fastify.d.mts +4 -4
  31. package/dist/identity/fastify.d.ts +4 -4
  32. package/dist/identity/fastify.js +60 -96
  33. package/dist/identity/fastify.js.map +1 -1
  34. package/dist/identity/fastify.mjs +58 -87
  35. package/dist/identity/fastify.mjs.map +1 -1
  36. package/dist/identity/hono.d.mts +11 -3
  37. package/dist/identity/hono.d.ts +11 -3
  38. package/dist/identity/hono.js +39 -93
  39. package/dist/identity/hono.js.map +1 -1
  40. package/dist/identity/hono.mjs +37 -84
  41. package/dist/identity/hono.mjs.map +1 -1
  42. package/dist/identity/nextjs.d.mts +10 -3
  43. package/dist/identity/nextjs.d.ts +10 -3
  44. package/dist/identity/nextjs.js +49 -93
  45. package/dist/identity/nextjs.js.map +1 -1
  46. package/dist/identity/nextjs.mjs +46 -84
  47. package/dist/identity/nextjs.mjs.map +1 -1
  48. package/dist/identity/policy.js +220 -129
  49. package/dist/identity/policy.js.map +1 -1
  50. package/dist/identity/policy.mjs +222 -131
  51. package/dist/identity/policy.mjs.map +1 -1
  52. package/dist/identity/web.d.mts +9 -3
  53. package/dist/identity/web.d.ts +9 -3
  54. package/dist/identity/web.js +45 -93
  55. package/dist/identity/web.js.map +1 -1
  56. package/dist/identity/web.mjs +42 -84
  57. package/dist/identity/web.mjs.map +1 -1
  58. package/dist/index.d.mts +554 -90
  59. package/dist/index.d.ts +554 -90
  60. package/dist/index.js +951 -152
  61. package/dist/index.js.map +1 -1
  62. package/dist/index.mjs +939 -152
  63. package/dist/index.mjs.map +1 -1
  64. package/dist/middleware/express.d.mts +10 -0
  65. package/dist/middleware/express.d.ts +10 -0
  66. package/dist/middleware/express.js +128 -0
  67. package/dist/middleware/express.js.map +1 -0
  68. package/dist/middleware/express.mjs +91 -0
  69. package/dist/middleware/express.mjs.map +1 -0
  70. package/dist/middleware/fastify.d.mts +10 -0
  71. package/dist/middleware/fastify.d.ts +10 -0
  72. package/dist/middleware/fastify.js +127 -0
  73. package/dist/middleware/fastify.js.map +1 -0
  74. package/dist/middleware/fastify.mjs +90 -0
  75. package/dist/middleware/fastify.mjs.map +1 -0
  76. package/dist/middleware/hono.d.mts +10 -0
  77. package/dist/middleware/hono.d.ts +10 -0
  78. package/dist/middleware/hono.js +122 -0
  79. package/dist/middleware/hono.js.map +1 -0
  80. package/dist/middleware/hono.mjs +85 -0
  81. package/dist/middleware/hono.mjs.map +1 -0
  82. package/dist/middleware/nextjs.d.mts +22 -0
  83. package/dist/middleware/nextjs.d.ts +22 -0
  84. package/dist/middleware/nextjs.js +143 -0
  85. package/dist/middleware/nextjs.js.map +1 -0
  86. package/dist/middleware/nextjs.mjs +105 -0
  87. package/dist/middleware/nextjs.mjs.map +1 -0
  88. package/dist/middleware/web.d.mts +25 -0
  89. package/dist/middleware/web.d.ts +25 -0
  90. package/dist/middleware/web.js +128 -0
  91. package/dist/middleware/web.js.map +1 -0
  92. package/dist/middleware/web.mjs +91 -0
  93. package/dist/middleware/web.mjs.map +1 -0
  94. package/dist/payment/index.d.mts +21 -6
  95. package/dist/payment/index.d.ts +21 -6
  96. package/dist/payment/index.js +136 -9
  97. package/dist/payment/index.js.map +1 -1
  98. package/dist/payment/index.mjs +127 -9
  99. package/dist/payment/index.mjs.map +1 -1
  100. package/dist/{pricing-CxzwyiO6.d.mts → pricing-4n5Ota0D.d.mts} +14 -4
  101. package/dist/{pricing-CQ9DIFaw.d.ts → pricing-DHfH3ogG.d.ts} +14 -4
  102. package/dist/{rail_spec-XP0wKgJV.d.mts → rail_spec-D6qzh3J0.d.mts} +1 -1
  103. package/dist/{rail_spec-XP0wKgJV.d.ts → rail_spec-D6qzh3J0.d.ts} +1 -1
  104. package/dist/stripe-multichain/index.d.mts +150 -47
  105. package/dist/stripe-multichain/index.d.ts +150 -47
  106. package/dist/stripe-multichain/index.js +19749 -42
  107. package/dist/stripe-multichain/index.js.map +1 -1
  108. package/dist/stripe-multichain/index.mjs +19758 -27
  109. package/dist/stripe-multichain/index.mjs.map +1 -1
  110. package/dist/{x402_server-hgQzWQwB.d.mts → x402_server-Ciz2mls2.d.mts} +1 -1
  111. package/dist/{x402_server-hgQzWQwB.d.ts → x402_server-Ciz2mls2.d.ts} +1 -1
  112. package/package.json +43 -5
  113. package/dist/_response-BFYN3b6i.d.mts +0 -142
  114. package/dist/_response-_iPD5AIj.d.ts +0 -142
  115. package/dist/solana-Cds87OTu.d.mts +0 -67
  116. package/dist/solana-Cds87OTu.d.ts +0 -67
@@ -78,4 +78,4 @@ interface BuildX402AcceptsForOptions {
78
78
  */
79
79
  declare function buildX402AcceptsFor402(server: X402Server, opts: BuildX402AcceptsForOptions): Promise<unknown[]>;
80
80
 
81
- export { type BuildX402AcceptsForOptions as B, type CreateX402ServerOptions as C, type X402Server as X, type X402FacilitatorChoice as a, type X402SymbolicRail as b, buildX402AcceptsFor402 as c, createX402Server as d };
81
+ export { type BuildX402AcceptsForOptions as B, type CreateX402ServerOptions as C, type X402FacilitatorChoice as X, type X402Server as a, type X402SymbolicRail as b, buildX402AcceptsFor402 as c, createX402Server as d };
@@ -78,4 +78,4 @@ interface BuildX402AcceptsForOptions {
78
78
  */
79
79
  declare function buildX402AcceptsFor402(server: X402Server, opts: BuildX402AcceptsForOptions): Promise<unknown[]>;
80
80
 
81
- export { type BuildX402AcceptsForOptions as B, type CreateX402ServerOptions as C, type X402Server as X, type X402FacilitatorChoice as a, type X402SymbolicRail as b, buildX402AcceptsFor402 as c, createX402Server as d };
81
+ export { type BuildX402AcceptsForOptions as B, type CreateX402ServerOptions as C, type X402FacilitatorChoice as X, type X402Server as a, type X402SymbolicRail as b, buildX402AcceptsFor402 as c, createX402Server as d };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-score/commerce",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "Agent commerce SDK — identity middleware (Hono, Express, Fastify, Next.js, Web Fetch) + payment helpers + 402 builders + discovery + Stripe multichain. The full merchant-side toolkit for AgentScore-powered agent commerce.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -70,6 +70,31 @@
70
70
  "types": "./dist/api/index.d.ts",
71
71
  "import": "./dist/api/index.mjs",
72
72
  "require": "./dist/api/index.js"
73
+ },
74
+ "./middleware/hono": {
75
+ "types": "./dist/middleware/hono.d.ts",
76
+ "import": "./dist/middleware/hono.mjs",
77
+ "require": "./dist/middleware/hono.js"
78
+ },
79
+ "./middleware/express": {
80
+ "types": "./dist/middleware/express.d.ts",
81
+ "import": "./dist/middleware/express.mjs",
82
+ "require": "./dist/middleware/express.js"
83
+ },
84
+ "./middleware/fastify": {
85
+ "types": "./dist/middleware/fastify.d.ts",
86
+ "import": "./dist/middleware/fastify.mjs",
87
+ "require": "./dist/middleware/fastify.js"
88
+ },
89
+ "./middleware/nextjs": {
90
+ "types": "./dist/middleware/nextjs.d.ts",
91
+ "import": "./dist/middleware/nextjs.mjs",
92
+ "require": "./dist/middleware/nextjs.js"
93
+ },
94
+ "./middleware/web": {
95
+ "types": "./dist/middleware/web.d.ts",
96
+ "import": "./dist/middleware/web.mjs",
97
+ "require": "./dist/middleware/web.js"
73
98
  }
74
99
  },
75
100
  "files": [
@@ -126,7 +151,14 @@
126
151
  },
127
152
  "overrides": {
128
153
  "axios": "^1.15.0",
129
- "fast-uri": "^3.1.1"
154
+ "fast-uri": "^3.1.1",
155
+ "minimatch@^3.0.0": {
156
+ "brace-expansion": "1.1.12"
157
+ },
158
+ "minimatch@^10.0.0": {
159
+ "brace-expansion": "5.0.6"
160
+ },
161
+ "ws": "^8.20.1"
130
162
  },
131
163
  "peerDependencies": {
132
164
  "@solana/kit": ">=6.5.0",
@@ -134,6 +166,7 @@
134
166
  "express": ">=4.0.0",
135
167
  "fastify": ">=4.0.0",
136
168
  "hono": ">=4.0.0",
169
+ "ioredis": ">=5.0.0",
137
170
  "jose": ">=6.0.0",
138
171
  "stripe": ">=17.0.0"
139
172
  },
@@ -153,6 +186,9 @@
153
186
  "hono": {
154
187
  "optional": true
155
188
  },
189
+ "ioredis": {
190
+ "optional": true
191
+ },
156
192
  "jose": {
157
193
  "optional": true
158
194
  },
@@ -161,6 +197,7 @@
161
197
  }
162
198
  },
163
199
  "devDependencies": {
200
+ "@a2a-js/sdk": "^0.3.13",
164
201
  "@coinbase/x402": "^2.1.0",
165
202
  "@eslint/js": "^9.39.4",
166
203
  "@solana/kit": "^6.9.0",
@@ -177,11 +214,12 @@
177
214
  "eslint-plugin-unused-imports": "^4.4.1",
178
215
  "express": "^5.2.1",
179
216
  "fastify": "^5.8.5",
180
- "hono": "^4.12.18",
217
+ "hono": "^4.12.19",
218
+ "ioredis": "^5.10.1",
181
219
  "jose": "^6.2.3",
182
- "knip": "^6.13.1",
220
+ "knip": "^6.14.1",
183
221
  "lefthook": "^2.1.6",
184
- "mppx": "^0.6.20",
222
+ "mppx": "^0.6.25",
185
223
  "tsup": "^8.5.1",
186
224
  "typescript": "^6.0.3",
187
225
  "typescript-eslint": "^8.59.3",
@@ -1,142 +0,0 @@
1
- import { VerifyWalletSignerResult, DenialReason } from './core.mjs';
2
-
3
- /**
4
- * Universal denial helpers shared across every adapter.
5
- *
6
- * What lives here:
7
- * - `FIXABLE_DENIAL_REASONS` / `isFixableDenial` — classifier for compliance reasons that can
8
- * be resolved by re-completing KYC (vs sanctions / age failures which are permanent).
9
- * - `denialReasonStatus` — picks the right HTTP status code per denial code (401 for credential
10
- * problems, 503 for transient API errors, 403 for everything else).
11
- * - `buildSignerMismatchBody` — produces the standard 403 body for a non-pass signer_match
12
- * verdict (read via `getSignerVerdict`).
13
- * - `buildContactSupportNextSteps` — standard `next_steps.action: "contact_support"` shape for
14
- * unfixable compliance denials.
15
- * - `verificationAgentInstructions` — the canned `agent_instructions` block for
16
- * identity-verification 403s. Vendors can override individual fields.
17
- *
18
- * Adapters use `denialReasonStatus` inside their default `onDenied` so vendors get the right
19
- * status code for free. The body builders are exported from each adapter so vendors who write
20
- * a custom `onDenied` can compose them without copy-paste.
21
- */
22
-
23
- /**
24
- * Compliance denial reasons that can be resolved by re-completing KYC. The API emits these
25
- * when KYC is missing/pending/failed; the user can re-verify and retry.
26
- *
27
- * `jurisdiction_restricted` is NOT in this set — the API only emits it AFTER KYC is verified,
28
- * meaning the user's KYC'd country is in the merchant's blocked list (or absent from the
29
- * allowed list). Re-doing KYC won't change the country, so it's permanent. Same shape as
30
- * `sanctions_flagged` and `age_insufficient` — surface contact_support, don't waste a
31
- * /v1/sessions mint.
32
- */
33
- declare const FIXABLE_DENIAL_REASONS: ReadonlySet<string>;
34
- /**
35
- * Returns true when a `wallet_not_trusted` denial's reasons are all fixable via KYC
36
- * re-verification. False when any reason is permanent (sanctions, age, jurisdiction_restricted).
37
- *
38
- * Empty reasons returns false — without a known reason we can't promise a fix, so default to
39
- * the bare denial path (vendors can override via custom onDenied if they want different
40
- * behavior on empty reasons).
41
- */
42
- declare function isFixableDenial(reasons: readonly string[] | undefined): boolean;
43
- /**
44
- * The right HTTP status code for a denial. `defaultOnDenied` in every adapter uses this so
45
- * vendors get correct status codes without writing per-code branches.
46
- *
47
- * - 401 for credential problems the agent can recover from (`token_expired`, `invalid_credential`)
48
- * - 503 for transient `api_error`
49
- * - 403 for everything else (identity required, compliance fail, signer mismatch, etc.)
50
- */
51
- declare function denialReasonStatus(reason: DenialReason): 401 | 403 | 503;
52
- /**
53
- * Standard 403 body for a non-pass signer-match verdict. Returns null for `pass` so vendors
54
- * can call it unconditionally:
55
- *
56
- * const verdict = getSignerVerdict(c);
57
- * if (verdict?.signer_match) {
58
- * const mismatchBody = buildSignerMismatchBody({ result: verdict.signer_match });
59
- * if (mismatchBody) return c.json(mismatchBody, 403);
60
- * }
61
- *
62
- * Body shape mirrors the gate's denial bodies: top-level error.code, all signer-match fields
63
- * (`claimed_operator`, `actual_signer_operator`, `expected_signer`, `actual_signer`,
64
- * `linked_wallets`), plus a `next_steps` action describing the recovery path.
65
- */
66
- declare function buildSignerMismatchBody({ result, userMessage, learnMoreUrl, }: {
67
- /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). Only non-pass
68
- * kinds produce a body. */
69
- result: VerifyWalletSignerResult;
70
- /** Optional override for the human-facing `next_steps.user_message`. */
71
- userMessage?: string;
72
- /** Optional override for `next_steps.learn_more_url`. Default: AgentScore agent-identity guide. */
73
- learnMoreUrl?: string;
74
- }): Record<string, unknown> | null;
75
- /**
76
- * Standard `next_steps` block for unfixable compliance denials (sanctions, age, etc.). Vendors
77
- * spread this into a 403 body alongside the usual `error`/`reasons` fields.
78
- *
79
- * return c.json({
80
- * error: { code: 'compliance_denied', message: '...' },
81
- * reasons,
82
- * next_steps: buildContactSupportNextSteps('support@example.com'),
83
- * }, 403);
84
- */
85
- declare function buildContactSupportNextSteps(supportEmail: string, message?: string): {
86
- action: 'contact_support';
87
- support_email: string;
88
- user_message: string;
89
- };
90
- /**
91
- * The canonical `agent_instructions` block for identity-verification 403s. Tells the agent how to
92
- * present the verify_url, poll for the operator_token, and retry the original request. Universal
93
- * across every AgentScore-gated merchant — overrides let vendors add merchant-specific steps
94
- * (e.g. "include order_id when retrying").
95
- */
96
- declare function verificationAgentInstructions({ userAction, retryStep, extraSteps, pollIntervalSeconds, timeoutSeconds, orderTtl, extra, }?: {
97
- /** Override the user-facing message. */
98
- userAction?: string;
99
- /** Replace the generic "Retry the original merchant request..." step with a merchant-specific
100
- * one (e.g. "Retry POST /purchase with X-Operator-Token AND include order_id..."). When set,
101
- * this REPLACES baseSteps[4] rather than appending — use it instead of `extraSteps[0]` when
102
- * your retry instruction is a refinement of the canonical retry, not an additional step. */
103
- retryStep?: string;
104
- /** Append additional steps after the retry step. Use this for genuinely additional steps
105
- * (e.g. "After payment the same call returns 200 with the order"), not for re-stating the
106
- * retry — use `retryStep` for that. */
107
- extraSteps?: string[];
108
- /** Override the poll cadence. Default 5 seconds. */
109
- pollIntervalSeconds?: number;
110
- /** Override how long the agent should keep polling. Default 3600 seconds (1 hour). */
111
- timeoutSeconds?: number;
112
- /** Optional `order_ttl` note describing how long pending orders survive. */
113
- orderTtl?: string;
114
- /** Arbitrary additional fields merged into the instructions object. */
115
- extra?: Record<string, unknown>;
116
- }): {
117
- action: 'poll_for_credential';
118
- user_action: string;
119
- steps: string[];
120
- poll_interval_seconds: number;
121
- poll_secret_header: 'X-Poll-Secret';
122
- retry_token_header: 'X-Operator-Token';
123
- timeout_seconds: number;
124
- order_ttl?: string;
125
- [key: string]: unknown;
126
- };
127
-
128
- /**
129
- * Shared DenialReason → response body serialization for all adapters.
130
- *
131
- * Keeps Hono / Express / Fastify / Web / Next.js defaults aligned — a field added
132
- * here shows up in every adapter's 403 body automatically, and there's one place
133
- * to test the marshaling.
134
- *
135
- * Body shape: `{ error: { code, message }, ... }` — matches the canonical AgentScore
136
- * error envelope so downstream agents see one consistent `error.code` +
137
- * `error.message` pair regardless of which layer produced the denial.
138
- */
139
-
140
- declare function denialReasonToBody(reason: DenialReason): Record<string, unknown>;
141
-
142
- export { FIXABLE_DENIAL_REASONS as F, buildSignerMismatchBody as a, buildContactSupportNextSteps as b, denialReasonToBody as c, denialReasonStatus as d, isFixableDenial as i, verificationAgentInstructions as v };
@@ -1,142 +0,0 @@
1
- import { VerifyWalletSignerResult, DenialReason } from './core.js';
2
-
3
- /**
4
- * Universal denial helpers shared across every adapter.
5
- *
6
- * What lives here:
7
- * - `FIXABLE_DENIAL_REASONS` / `isFixableDenial` — classifier for compliance reasons that can
8
- * be resolved by re-completing KYC (vs sanctions / age failures which are permanent).
9
- * - `denialReasonStatus` — picks the right HTTP status code per denial code (401 for credential
10
- * problems, 503 for transient API errors, 403 for everything else).
11
- * - `buildSignerMismatchBody` — produces the standard 403 body for a non-pass signer_match
12
- * verdict (read via `getSignerVerdict`).
13
- * - `buildContactSupportNextSteps` — standard `next_steps.action: "contact_support"` shape for
14
- * unfixable compliance denials.
15
- * - `verificationAgentInstructions` — the canned `agent_instructions` block for
16
- * identity-verification 403s. Vendors can override individual fields.
17
- *
18
- * Adapters use `denialReasonStatus` inside their default `onDenied` so vendors get the right
19
- * status code for free. The body builders are exported from each adapter so vendors who write
20
- * a custom `onDenied` can compose them without copy-paste.
21
- */
22
-
23
- /**
24
- * Compliance denial reasons that can be resolved by re-completing KYC. The API emits these
25
- * when KYC is missing/pending/failed; the user can re-verify and retry.
26
- *
27
- * `jurisdiction_restricted` is NOT in this set — the API only emits it AFTER KYC is verified,
28
- * meaning the user's KYC'd country is in the merchant's blocked list (or absent from the
29
- * allowed list). Re-doing KYC won't change the country, so it's permanent. Same shape as
30
- * `sanctions_flagged` and `age_insufficient` — surface contact_support, don't waste a
31
- * /v1/sessions mint.
32
- */
33
- declare const FIXABLE_DENIAL_REASONS: ReadonlySet<string>;
34
- /**
35
- * Returns true when a `wallet_not_trusted` denial's reasons are all fixable via KYC
36
- * re-verification. False when any reason is permanent (sanctions, age, jurisdiction_restricted).
37
- *
38
- * Empty reasons returns false — without a known reason we can't promise a fix, so default to
39
- * the bare denial path (vendors can override via custom onDenied if they want different
40
- * behavior on empty reasons).
41
- */
42
- declare function isFixableDenial(reasons: readonly string[] | undefined): boolean;
43
- /**
44
- * The right HTTP status code for a denial. `defaultOnDenied` in every adapter uses this so
45
- * vendors get correct status codes without writing per-code branches.
46
- *
47
- * - 401 for credential problems the agent can recover from (`token_expired`, `invalid_credential`)
48
- * - 503 for transient `api_error`
49
- * - 403 for everything else (identity required, compliance fail, signer mismatch, etc.)
50
- */
51
- declare function denialReasonStatus(reason: DenialReason): 401 | 403 | 503;
52
- /**
53
- * Standard 403 body for a non-pass signer-match verdict. Returns null for `pass` so vendors
54
- * can call it unconditionally:
55
- *
56
- * const verdict = getSignerVerdict(c);
57
- * if (verdict?.signer_match) {
58
- * const mismatchBody = buildSignerMismatchBody({ result: verdict.signer_match });
59
- * if (mismatchBody) return c.json(mismatchBody, 403);
60
- * }
61
- *
62
- * Body shape mirrors the gate's denial bodies: top-level error.code, all signer-match fields
63
- * (`claimed_operator`, `actual_signer_operator`, `expected_signer`, `actual_signer`,
64
- * `linked_wallets`), plus a `next_steps` action describing the recovery path.
65
- */
66
- declare function buildSignerMismatchBody({ result, userMessage, learnMoreUrl, }: {
67
- /** Projected signer_match verdict (from `getSignerVerdict(ctx).signer_match`). Only non-pass
68
- * kinds produce a body. */
69
- result: VerifyWalletSignerResult;
70
- /** Optional override for the human-facing `next_steps.user_message`. */
71
- userMessage?: string;
72
- /** Optional override for `next_steps.learn_more_url`. Default: AgentScore agent-identity guide. */
73
- learnMoreUrl?: string;
74
- }): Record<string, unknown> | null;
75
- /**
76
- * Standard `next_steps` block for unfixable compliance denials (sanctions, age, etc.). Vendors
77
- * spread this into a 403 body alongside the usual `error`/`reasons` fields.
78
- *
79
- * return c.json({
80
- * error: { code: 'compliance_denied', message: '...' },
81
- * reasons,
82
- * next_steps: buildContactSupportNextSteps('support@example.com'),
83
- * }, 403);
84
- */
85
- declare function buildContactSupportNextSteps(supportEmail: string, message?: string): {
86
- action: 'contact_support';
87
- support_email: string;
88
- user_message: string;
89
- };
90
- /**
91
- * The canonical `agent_instructions` block for identity-verification 403s. Tells the agent how to
92
- * present the verify_url, poll for the operator_token, and retry the original request. Universal
93
- * across every AgentScore-gated merchant — overrides let vendors add merchant-specific steps
94
- * (e.g. "include order_id when retrying").
95
- */
96
- declare function verificationAgentInstructions({ userAction, retryStep, extraSteps, pollIntervalSeconds, timeoutSeconds, orderTtl, extra, }?: {
97
- /** Override the user-facing message. */
98
- userAction?: string;
99
- /** Replace the generic "Retry the original merchant request..." step with a merchant-specific
100
- * one (e.g. "Retry POST /purchase with X-Operator-Token AND include order_id..."). When set,
101
- * this REPLACES baseSteps[4] rather than appending — use it instead of `extraSteps[0]` when
102
- * your retry instruction is a refinement of the canonical retry, not an additional step. */
103
- retryStep?: string;
104
- /** Append additional steps after the retry step. Use this for genuinely additional steps
105
- * (e.g. "After payment the same call returns 200 with the order"), not for re-stating the
106
- * retry — use `retryStep` for that. */
107
- extraSteps?: string[];
108
- /** Override the poll cadence. Default 5 seconds. */
109
- pollIntervalSeconds?: number;
110
- /** Override how long the agent should keep polling. Default 3600 seconds (1 hour). */
111
- timeoutSeconds?: number;
112
- /** Optional `order_ttl` note describing how long pending orders survive. */
113
- orderTtl?: string;
114
- /** Arbitrary additional fields merged into the instructions object. */
115
- extra?: Record<string, unknown>;
116
- }): {
117
- action: 'poll_for_credential';
118
- user_action: string;
119
- steps: string[];
120
- poll_interval_seconds: number;
121
- poll_secret_header: 'X-Poll-Secret';
122
- retry_token_header: 'X-Operator-Token';
123
- timeout_seconds: number;
124
- order_ttl?: string;
125
- [key: string]: unknown;
126
- };
127
-
128
- /**
129
- * Shared DenialReason → response body serialization for all adapters.
130
- *
131
- * Keeps Hono / Express / Fastify / Web / Next.js defaults aligned — a field added
132
- * here shows up in every adapter's 403 body automatically, and there's one place
133
- * to test the marshaling.
134
- *
135
- * Body shape: `{ error: { code, message }, ... }` — matches the canonical AgentScore
136
- * error envelope so downstream agents see one consistent `error.code` +
137
- * `error.message` pair regardless of which layer produced the denial.
138
- */
139
-
140
- declare function denialReasonToBody(reason: DenialReason): Record<string, unknown>;
141
-
142
- export { FIXABLE_DENIAL_REASONS as F, buildSignerMismatchBody as a, buildContactSupportNextSteps as b, denialReasonToBody as c, denialReasonStatus as d, isFixableDenial as i, verificationAgentInstructions as v };
@@ -1,67 +0,0 @@
1
- /**
2
- * USD ↔ atomic-unit conversion for token amounts.
3
- *
4
- * `usdToAtomic(usd, { decimals: 6 })` returns the bigint atomic value of a USD
5
- * amount for a token with `decimals` places of precision (USDC is 6). String
6
- * parsing + bigint arithmetic so the result is exact; ROUND_HALF_UP at the
7
- * rounding boundary matches the cross-language Python sibling.
8
- *
9
- * Rejects negative, NaN, infinite, and unparseable inputs. Fixed-notation only;
10
- * scientific notation (e.g. `"1e6"`) is not parsed (mirrors the locked cross-
11
- * language fixture corpus, which uses fixed notation exclusively).
12
- */
13
- /**
14
- * Convert a USD amount to atomic units for a token with `decimals` places.
15
- *
16
- * @param usd USD amount. Strings (`"1.23"`) and `number`s (`1.23`) are accepted.
17
- * `number` is converted via `String(usd)` before parsing, so JS float precision
18
- * limits apply when the float can't represent the value exactly.
19
- * @param opts.decimals Number of decimal places in the atomic unit (6 for USDC,
20
- * 18 for ETH, etc.). Must be a non-negative integer.
21
- *
22
- * @returns Integer atomic units as a `bigint`. `"1.23"` with `decimals: 6`
23
- * returns `1_230_000n`.
24
- *
25
- * @throws RangeError when `usd` is negative, NaN, infinite, or `decimals` is
26
- * not a non-negative integer.
27
- * @throws SyntaxError when `usd` cannot be parsed as a fixed-notation decimal.
28
- */
29
- declare function usdToAtomic(usd: string | number, opts: {
30
- decimals: number;
31
- }): bigint;
32
- /**
33
- * Format an integer cent amount as a fixed-2-decimal USD string.
34
- *
35
- * `formatUsdCents(500)` returns `"5.00"`. Negative values are formatted with a
36
- * leading minus. Use everywhere a merchant emits `(cents / 100).toFixed(2)`;
37
- * consistent formatting across catalog rows, order responses, and 402 bodies
38
- * prevents agent-side string-comparison flakiness.
39
- */
40
- declare function formatUsdCents(cents: number): string;
41
-
42
- /**
43
- * Solana MPP fee-payer signer loader.
44
- *
45
- * Buyers paying via Solana MPP USDC don't typically carry SOL for transaction
46
- * fees, so merchants commonly co-sign the buyer's `solana/charge` tx as the
47
- * fee payer (~5000 lamports per tx; negligible vs the USDC value moved).
48
- *
49
- * `loadSolanaFeePayer({ privateKey })` accepts a Solana keypair in any of the
50
- * three forms agents commonly export it as:
51
- *
52
- * - **base58** (Phantom export format) — 64-byte secret+public, or 32-byte
53
- * secret-only
54
- * - **hex** — 128-char string (64 bytes hex: 32-byte secret + 32-byte public)
55
- *
56
- * Returns a `KeyPairSigner` from `@solana/kit` ready to pass as the `signer`
57
- * field on a `SolanaMppRailSpec`. Returns `undefined` when `privateKey` is
58
- * empty / absent (so consumers can use `process.env.X` directly without
59
- * null-checks).
60
- *
61
- * Requires the `@solana/kit` peer dependency.
62
- */
63
- declare function loadSolanaFeePayer(opts: {
64
- privateKey: string | undefined;
65
- }): Promise<unknown | undefined>;
66
-
67
- export { formatUsdCents as f, loadSolanaFeePayer as l, usdToAtomic as u };
@@ -1,67 +0,0 @@
1
- /**
2
- * USD ↔ atomic-unit conversion for token amounts.
3
- *
4
- * `usdToAtomic(usd, { decimals: 6 })` returns the bigint atomic value of a USD
5
- * amount for a token with `decimals` places of precision (USDC is 6). String
6
- * parsing + bigint arithmetic so the result is exact; ROUND_HALF_UP at the
7
- * rounding boundary matches the cross-language Python sibling.
8
- *
9
- * Rejects negative, NaN, infinite, and unparseable inputs. Fixed-notation only;
10
- * scientific notation (e.g. `"1e6"`) is not parsed (mirrors the locked cross-
11
- * language fixture corpus, which uses fixed notation exclusively).
12
- */
13
- /**
14
- * Convert a USD amount to atomic units for a token with `decimals` places.
15
- *
16
- * @param usd USD amount. Strings (`"1.23"`) and `number`s (`1.23`) are accepted.
17
- * `number` is converted via `String(usd)` before parsing, so JS float precision
18
- * limits apply when the float can't represent the value exactly.
19
- * @param opts.decimals Number of decimal places in the atomic unit (6 for USDC,
20
- * 18 for ETH, etc.). Must be a non-negative integer.
21
- *
22
- * @returns Integer atomic units as a `bigint`. `"1.23"` with `decimals: 6`
23
- * returns `1_230_000n`.
24
- *
25
- * @throws RangeError when `usd` is negative, NaN, infinite, or `decimals` is
26
- * not a non-negative integer.
27
- * @throws SyntaxError when `usd` cannot be parsed as a fixed-notation decimal.
28
- */
29
- declare function usdToAtomic(usd: string | number, opts: {
30
- decimals: number;
31
- }): bigint;
32
- /**
33
- * Format an integer cent amount as a fixed-2-decimal USD string.
34
- *
35
- * `formatUsdCents(500)` returns `"5.00"`. Negative values are formatted with a
36
- * leading minus. Use everywhere a merchant emits `(cents / 100).toFixed(2)`;
37
- * consistent formatting across catalog rows, order responses, and 402 bodies
38
- * prevents agent-side string-comparison flakiness.
39
- */
40
- declare function formatUsdCents(cents: number): string;
41
-
42
- /**
43
- * Solana MPP fee-payer signer loader.
44
- *
45
- * Buyers paying via Solana MPP USDC don't typically carry SOL for transaction
46
- * fees, so merchants commonly co-sign the buyer's `solana/charge` tx as the
47
- * fee payer (~5000 lamports per tx; negligible vs the USDC value moved).
48
- *
49
- * `loadSolanaFeePayer({ privateKey })` accepts a Solana keypair in any of the
50
- * three forms agents commonly export it as:
51
- *
52
- * - **base58** (Phantom export format) — 64-byte secret+public, or 32-byte
53
- * secret-only
54
- * - **hex** — 128-char string (64 bytes hex: 32-byte secret + 32-byte public)
55
- *
56
- * Returns a `KeyPairSigner` from `@solana/kit` ready to pass as the `signer`
57
- * field on a `SolanaMppRailSpec`. Returns `undefined` when `privateKey` is
58
- * empty / absent (so consumers can use `process.env.X` directly without
59
- * null-checks).
60
- *
61
- * Requires the `@solana/kit` peer dependency.
62
- */
63
- declare function loadSolanaFeePayer(opts: {
64
- privateKey: string | undefined;
65
- }): Promise<unknown | undefined>;
66
-
67
- export { formatUsdCents as f, loadSolanaFeePayer as l, usdToAtomic as u };