@agent-score/commerce 1.8.0 → 2.0.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 +73 -9
- package/dist/{_response-BMt2y4Or.d.mts → _response-BFYN3b6i.d.mts} +19 -22
- package/dist/{_response-DyJ3mWI3.d.ts → _response-_iPD5AIj.d.ts} +19 -22
- package/dist/challenge/index.d.mts +106 -198
- package/dist/challenge/index.d.ts +106 -198
- package/dist/challenge/index.js +238 -111
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs +238 -111
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/checkout-BoFwnVsj.d.ts +931 -0
- package/dist/checkout-DRbQ0Fsh.d.mts +931 -0
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- 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/discovery/index.d.mts +453 -51
- package/dist/discovery/index.d.ts +453 -51
- package/dist/discovery/index.js +1092 -58
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +1060 -57
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/identity/express.d.mts +3 -3
- package/dist/identity/express.d.ts +3 -3
- package/dist/identity/express.js +30 -19
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +30 -19
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +4 -4
- package/dist/identity/fastify.d.ts +4 -4
- package/dist/identity/fastify.js +30 -19
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +30 -19
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +3 -3
- package/dist/identity/hono.d.ts +3 -3
- package/dist/identity/hono.js +30 -19
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +30 -19
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +6 -7
- package/dist/identity/nextjs.d.ts +6 -7
- package/dist/identity/nextjs.js +30 -19
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +30 -19
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/policy.d.mts +41 -4
- package/dist/identity/policy.d.ts +41 -4
- package/dist/identity/policy.js +3662 -18
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs +3648 -3
- 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 +30 -19
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +30 -19
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +72 -329
- package/dist/index.d.ts +72 -329
- package/dist/index.js +3651 -373
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3628 -361
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.d.mts +257 -266
- package/dist/payment/index.d.ts +257 -266
- package/dist/payment/index.js +586 -149
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +573 -148
- package/dist/payment/index.mjs.map +1 -1
- package/dist/{agent_instructions-DiMSGkdm.d.mts → pricing-CQ9DIFaw.d.ts} +109 -56
- package/dist/{agent_instructions-DiMSGkdm.d.ts → pricing-CxzwyiO6.d.mts} +109 -56
- package/dist/rail_spec-XP0wKgJV.d.mts +132 -0
- package/dist/rail_spec-XP0wKgJV.d.ts +132 -0
- package/dist/{signer-CFVQsWjL.d.mts → signer-3FAit11j.d.mts} +27 -1
- package/dist/{signer-CFVQsWjL.d.ts → signer-3FAit11j.d.ts} +27 -1
- package/dist/solana-Cds87OTu.d.mts +67 -0
- package/dist/solana-Cds87OTu.d.ts +67 -0
- package/dist/stripe-multichain/index.d.mts +56 -67
- package/dist/stripe-multichain/index.d.ts +56 -67
- package/dist/stripe-multichain/index.js +68 -42
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs +68 -41
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/dist/{wwwauthenticate-CU1eNvMQ.d.mts → wwwauthenticate-D_FMnPgU.d.mts} +9 -10
- package/dist/{wwwauthenticate-CU1eNvMQ.d.ts → wwwauthenticate-D_FMnPgU.d.ts} +9 -10
- package/dist/x402_server-hgQzWQwB.d.mts +81 -0
- package/dist/x402_server-hgQzWQwB.d.ts +81 -0
- package/package.json +13 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DenialReason, AgentScoreCoreOptions } from '../core.js';
|
|
2
|
-
import '../signer-
|
|
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
|
|
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
|
|
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,
|
|
152
|
+
export { type EnforcementMode, type GateResult, type IdentityStatus, type PolicyBlock, buildGateFromPolicy, runGateWithEnforcement, shippingCountryAllowed, shippingStateAllowed, validateShippingAgainstPolicy };
|