@agent-score/commerce 1.8.1 → 2.0.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 (90) hide show
  1. package/README.md +73 -9
  2. package/dist/{_response-9yp6Fit2.d.mts → _response-BFYN3b6i.d.mts} +17 -19
  3. package/dist/{_response-CC6jNb8q.d.ts → _response-_iPD5AIj.d.ts} +17 -19
  4. package/dist/challenge/index.d.mts +106 -198
  5. package/dist/challenge/index.d.ts +106 -198
  6. package/dist/challenge/index.js +238 -111
  7. package/dist/challenge/index.js.map +1 -1
  8. package/dist/challenge/index.mjs +238 -111
  9. package/dist/challenge/index.mjs.map +1 -1
  10. package/dist/checkout-B1JuEcbx.d.ts +939 -0
  11. package/dist/checkout-BN5i1Fi7.d.mts +939 -0
  12. package/dist/core.d.mts +2 -2
  13. package/dist/core.d.ts +2 -2
  14. package/dist/core.js +1 -1
  15. package/dist/core.js.map +1 -1
  16. package/dist/core.mjs +1 -1
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/discovery/index.d.mts +453 -51
  19. package/dist/discovery/index.d.ts +453 -51
  20. package/dist/discovery/index.js +1092 -58
  21. package/dist/discovery/index.js.map +1 -1
  22. package/dist/discovery/index.mjs +1060 -57
  23. package/dist/discovery/index.mjs.map +1 -1
  24. package/dist/identity/express.d.mts +3 -3
  25. package/dist/identity/express.d.ts +3 -3
  26. package/dist/identity/express.js +30 -19
  27. package/dist/identity/express.js.map +1 -1
  28. package/dist/identity/express.mjs +30 -19
  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 +30 -19
  33. package/dist/identity/fastify.js.map +1 -1
  34. package/dist/identity/fastify.mjs +30 -19
  35. package/dist/identity/fastify.mjs.map +1 -1
  36. package/dist/identity/hono.d.mts +3 -3
  37. package/dist/identity/hono.d.ts +3 -3
  38. package/dist/identity/hono.js +30 -19
  39. package/dist/identity/hono.js.map +1 -1
  40. package/dist/identity/hono.mjs +30 -19
  41. package/dist/identity/hono.mjs.map +1 -1
  42. package/dist/identity/nextjs.d.mts +6 -7
  43. package/dist/identity/nextjs.d.ts +6 -7
  44. package/dist/identity/nextjs.js +30 -19
  45. package/dist/identity/nextjs.js.map +1 -1
  46. package/dist/identity/nextjs.mjs +30 -19
  47. package/dist/identity/nextjs.mjs.map +1 -1
  48. package/dist/identity/policy.d.mts +41 -4
  49. package/dist/identity/policy.d.ts +41 -4
  50. package/dist/identity/policy.js +23307 -18
  51. package/dist/identity/policy.js.map +1 -1
  52. package/dist/identity/policy.mjs +23313 -3
  53. package/dist/identity/policy.mjs.map +1 -1
  54. package/dist/identity/web.d.mts +3 -3
  55. package/dist/identity/web.d.ts +3 -3
  56. package/dist/identity/web.js +30 -19
  57. package/dist/identity/web.js.map +1 -1
  58. package/dist/identity/web.mjs +30 -19
  59. package/dist/identity/web.mjs.map +1 -1
  60. package/dist/index.d.mts +72 -329
  61. package/dist/index.d.ts +72 -329
  62. package/dist/index.js +23301 -378
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +23294 -362
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/payment/index.d.mts +297 -265
  67. package/dist/payment/index.d.ts +297 -265
  68. package/dist/payment/index.js +605 -149
  69. package/dist/payment/index.js.map +1 -1
  70. package/dist/payment/index.mjs +590 -148
  71. package/dist/payment/index.mjs.map +1 -1
  72. package/dist/{agent_instructions-DiMSGkdm.d.mts → pricing-CQ9DIFaw.d.ts} +109 -56
  73. package/dist/{agent_instructions-DiMSGkdm.d.ts → pricing-CxzwyiO6.d.mts} +109 -56
  74. package/dist/rail_spec-XP0wKgJV.d.mts +132 -0
  75. package/dist/rail_spec-XP0wKgJV.d.ts +132 -0
  76. package/dist/{signer-CFVQsWjL.d.mts → signer-3FAit11j.d.mts} +27 -1
  77. package/dist/{signer-CFVQsWjL.d.ts → signer-3FAit11j.d.ts} +27 -1
  78. package/dist/solana-Cds87OTu.d.mts +67 -0
  79. package/dist/solana-Cds87OTu.d.ts +67 -0
  80. package/dist/stripe-multichain/index.d.mts +55 -66
  81. package/dist/stripe-multichain/index.d.ts +55 -66
  82. package/dist/stripe-multichain/index.js +68 -42
  83. package/dist/stripe-multichain/index.js.map +1 -1
  84. package/dist/stripe-multichain/index.mjs +68 -41
  85. package/dist/stripe-multichain/index.mjs.map +1 -1
  86. package/dist/{wwwauthenticate-CU1eNvMQ.d.mts → wwwauthenticate-D_FMnPgU.d.mts} +9 -10
  87. package/dist/{wwwauthenticate-CU1eNvMQ.d.ts → wwwauthenticate-D_FMnPgU.d.ts} +9 -10
  88. package/dist/x402_server-hgQzWQwB.d.mts +81 -0
  89. package/dist/x402_server-hgQzWQwB.d.ts +81 -0
  90. package/package.json +9 -7
@@ -1,5 +1,5 @@
1
1
  import { DenialReason, AgentScoreCoreOptions } from '../core.js';
2
- import '../signer-CFVQsWjL.js';
2
+ import '../signer-3FAit11j.js';
3
3
 
4
4
  /**
5
5
  * Per-product / per-tier compliance policy helpers.
@@ -19,7 +19,7 @@ import '../signer-CFVQsWjL.js';
19
19
  * This module ships three primitives:
20
20
  *
21
21
  * 1. {@link PolicyBlock} — the typed shape.
22
- * 2. {@link buildGateOptionsFromPolicy} — translate a block into the options object the
22
+ * 2. {@link buildGateFromPolicy} — translate a block into the options object the
23
23
  * per-framework `agentscoreGate(...)` accepts. Returns `null` when the policy
24
24
  * has no enforcement (treat as "no gate; anonymous OK").
25
25
  * 3. {@link runGateWithEnforcement} — wrap a per-framework middleware in the
@@ -72,7 +72,7 @@ interface GateResult {
72
72
  * when the policy varies per resource (e.g. per product). Each adapter's gate
73
73
  * is cheap to instantiate.
74
74
  */
75
- declare function buildGateOptionsFromPolicy(policy: PolicyBlock | null | undefined, base: {
75
+ declare function buildGateFromPolicy(policy: PolicyBlock | null | undefined, base: {
76
76
  apiKey: string;
77
77
  baseUrl?: string;
78
78
  }): AgentScoreCoreOptions | null;
@@ -111,5 +111,42 @@ declare function shippingCountryAllowed(country: string, policy: PolicyBlock | n
111
111
  * {@link shippingCountryAllowed} independently.
112
112
  */
113
113
  declare function shippingStateAllowed(state: string, country: string, policy: PolicyBlock | null | undefined): boolean;
114
+ /**
115
+ * Throw {@link CheckoutValidationError} when shipping isn't allowed by the policy.
116
+ *
117
+ * One-call replacement for the
118
+ *
119
+ * if (!shippingCountryAllowed(...)) throw new CheckoutValidationError(...);
120
+ * if (!shippingStateAllowed(...)) throw new CheckoutValidationError(...);
121
+ *
122
+ * boilerplate every goods merchant writes in their `preValidate` hook.
123
+ *
124
+ * `policy` is a {@link PolicyBlock} (or `null`/`undefined`); NULL policy means
125
+ * "ship anywhere" and the function is a no-op. The reason a location is
126
+ * excluded is **merchant-defined**: it might be regulatory (regulated goods
127
+ * + state allowlist), operational (no fulfillment partner), or commercial
128
+ * (fragility, fraud-rate-by-region, etc.) — the helper doesn't assume.
129
+ *
130
+ * `productName` is the user-facing item name surfaced in the error message
131
+ * ("Cannot ship 'Wine 2020' to NY ..."). Omit for a generic message.
132
+ *
133
+ * `errorCode` and `errorAction` let merchants override the canonical denial
134
+ * codes if their consumer agents expect different shapes.
135
+ *
136
+ * `countryMessage` / `stateMessage` override the default messages verbatim
137
+ * (use these when the default phrasing isn't right for your consumer agents
138
+ * — e.g. you want to surface the regulatory reason explicitly, or you want
139
+ * the message in a different language).
140
+ */
141
+ declare function validateShippingAgainstPolicy(opts: {
142
+ country: string;
143
+ state: string;
144
+ policy: PolicyBlock | null | undefined;
145
+ productName?: string;
146
+ errorCode?: string;
147
+ errorAction?: string;
148
+ countryMessage?: string;
149
+ stateMessage?: string;
150
+ }): void;
114
151
 
115
- export { type EnforcementMode, type GateResult, type IdentityStatus, type PolicyBlock, buildGateOptionsFromPolicy, runGateWithEnforcement, shippingCountryAllowed, shippingStateAllowed };
152
+ export { type EnforcementMode, type GateResult, type IdentityStatus, type PolicyBlock, buildGateFromPolicy, runGateWithEnforcement, shippingCountryAllowed, shippingStateAllowed, validateShippingAgainstPolicy };