@agent-score/commerce 2.6.0 → 2.6.2
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 +3 -3
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/identity/express.js +1 -1
- package/dist/identity/express.mjs +1 -1
- package/dist/identity/fastify.js +1 -1
- package/dist/identity/fastify.mjs +1 -1
- package/dist/identity/hono.js +1 -1
- package/dist/identity/hono.mjs +1 -1
- package/dist/identity/nextjs.js +1 -1
- package/dist/identity/nextjs.mjs +1 -1
- package/dist/identity/web.js +1 -1
- package/dist/identity/web.mjs +1 -1
- package/dist/index.js +82 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -65
- package/dist/index.mjs.map +1 -1
- package/dist/stripe-multichain/index.js +60 -51
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs +60 -51
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@agent-score/commerce)
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
|
|
6
|
-
The full merchant-side SDK for [AgentScore](https://www.agentscore.com): agent commerce in one install. Ships identity gating, payment rail helpers, 402 challenge builders, MPP discovery, and Stripe multichain support. Built and maintained by AgentScore; works with any
|
|
6
|
+
The full merchant-side SDK for [AgentScore](https://www.agentscore.com): agent commerce in one install. Ships identity gating, payment rail helpers, 402 challenge builders, MPP discovery, and Stripe multichain support. Built and maintained by AgentScore; works with any x402/MPP merchant in the ecosystem, AgentScore-gated or not.
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -29,7 +29,7 @@ npm install hono mppx @x402/core @x402/evm @solana/mpp @solana/kit stripe # wh
|
|
|
29
29
|
| `/payment` | `networks`, `USDC`, `rails` registries; `paymentDirective`, `buildPaymentDirective`, `wwwAuthenticateHeader`, `paymentRequiredHeader`, `aliasAmountFields` (opt-in v1↔v2 amount-field shim: adds both `amount` and `maxAmountRequired` to an entry. The 402 builders do NOT apply it by default, strict x402 v2 settlement matches the agent's echoed requirement by exact comparison, so an extra field the server's rebuilt requirement lacks breaks settle; use only when you know a client is hardcoded to read `maxAmountRequired`), `settlementOverrideHeader`, `dispatchSettlementByNetwork`, `extractPaymentSigner` (Request-based; recovers signer from x402 EIP-3009 `payload.authorization.from` OR MPP `Authorization: Payment <base64>` `did:pkh:eip155:<chain>:<addr>` / `did:pkh:solana:<genesis>:<addr>` source DID, including Solana `TransferChecked` authority fallback when `@solana/kit` is installed), `extractPaymentSignerFromAuth` (header-string variant for callers that already have the `Authorization` value in hand), `detectRailFromHeaders` (returns `"x402"` / `"mpp"` / `null` from inbound headers); `createX402Server`, `createMppxServer` (the solana rail's `ataCreationRequired` defaults to `true` so Solana settles work on `@solana/mpp >= 0.6.0` out of the box, opt out only if every recipient's ATA is guaranteed to pre-exist; see `SolanaMppRailSpec.ataCreationRequired` for economics), `buildDefaultCheckoutRails({tempo?, x402Base?, solanaMpp?, stripe?})` (canonical 4-rail `rails` dict factory: flipping `network` alone derives the right `token` + `chainId`, Base Sepolia → Sepolia USDC + chainId 84532, Solana devnet → devnet USDC mint. Solana's `network` accepts both CAIP-2 and the raw `@solana/mpp` form `mainnet-beta` / `devnet` / `localnet`. Explicit overrides always win), `buildMppxComposeRails({amountUsd, tempoRecipient?, solanaRecipient?, ...})` (per-call intent factory replacing the hand-rolled `[['tempo/charge',{...}],['solana/charge',{...}],['stripe/charge',{...}]]` array; auto-handles USD→atomic conversion for Solana; auto-drops `stripe/charge` when `amountUsd < 0.50` since Stripe's fixed ~$0.30 fee makes sub-50-cent charges unprofitable, sub-50-cent APIs pass `includeStripe: false` explicitly to silence the warning); 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), `classifyOrchestrationError` (same `ClassifiedX402Error` shape but for uncaught exceptions thrown elsewhere in the orchestration; returns `null` for unknown errors so merchants rethrow instead of swallowing); `zeroAmountCarveOut` (skip CDP / mppx upstream verify+settle for $0 settles where the upstream rejects value=0 payloads; parses the credential, lifts signer + network, returns a `ZeroSettleResult` shaped identically to the success path so callers branch on rail, not on result shape); `usdToAtomic` (BigInt-based USD → atomic value, ROUND_HALF_UP, for Tempo / Solana / Base USDC amount construction). |
|
|
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), `buildRedemptionSkillMd` (delivery-neutral redemption-code template, printed mailers, emailed codes, API trial credits all covered; `endpointPath`/`deliveryIntro`/`bodyShape`/`bodyRules`/`extraRecoveryRows` overrides for non-goods shapes), `agentscoreOpenApiSnippets`, `createBazaarDiscovery`, `noindexNonDiscoveryPaths` (Hono middleware emitting `X-Robots-Tag: noindex` on every path except the agent-discovery surfaces; pure helpers `isDiscoveryPath` + `defaultDiscoveryPaths` for non-Hono frameworks), `buildMerchantIndexJson` (canonical `/` discovery body), `standardEndpointDescriptions({kind})` (canonical method+path → description map for goods vs api merchants; optional `includeOrderStatusRoute` for goods), `buildSuccessNextSteps` (universal Passport-active success block), `buildAgentscoreOnboardingSteps` (canonical skill.md onboarding for goods or API merchants). Plus the UCP/JWKS publish surface: `buildSignedUcpResponse`, `buildSignedJwksResponse`, `wellKnownPreflightResponse`, `defaultA2aServices`, `bootstrapUcpSigningKey`, and the framework-neutral `SignedDiscoveryResponse` + per-framework wrappers `signedResponse{Hono,Express,Fastify,Nextjs,Web}`. |
|
|
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`, `Receipt` (canonical 200-receipt shape returned post-settle, universal: goods merchants fill the shipping/fulfillment/product slots, API merchants populate only the universal fields); `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. |
|
|
32
|
-
| `/stripe-multichain` | `createMultichainPaymentIntent` (returns `{ paymentIntentId, depositAddresses }`, read `depositAddresses[network]` directly), `createPayToAddressFromStripePI({request, amountCents, stripe, piCache, networks?, staticRecipients?, metadata?, orderId?, preferredNetwork?})`, per-order payTo resolver: on the settle leg, reuses the buyer's signed-against payTo from the MPP credential (after `piCache.hasAddress` check OR a `staticRecipients` match, the static address is always-accepted because the merchant owns it); on the discovery leg, mints a fresh PI for the rails NOT covered by `staticRecipients`, caches the merged map, registers static addresses with `piCache.cacheAddress` so verify-leg lookups pass. `mintMultichainRecipients({...same opts})`, structured variant that returns `{ recipients: Record<string,string>, paymentIntentId?, reusedFromCredential }`; prefer this when your `mintRecipients` hook needs the full per-rail map (typical multi-rail merchant).
|
|
32
|
+
| `/stripe-multichain` | `createMultichainPaymentIntent` (returns `{ paymentIntentId, depositAddresses }`, read `depositAddresses[network]` directly), `createPayToAddressFromStripePI({request, amountCents, stripe, piCache, networks?, staticRecipients?, metadata?, orderId?, preferredNetwork?})`, per-order payTo resolver: on the settle leg, reuses the buyer's signed-against payTo from the MPP credential (after `piCache.hasAddress` check OR a `staticRecipients` match, the static address is always-accepted because the merchant owns it); on the discovery leg, mints a fresh PI for the rails NOT covered by `staticRecipients`, caches the merged map, registers static addresses with `piCache.cacheAddress` so verify-leg lookups pass. `mintMultichainRecipients({...same opts})`, structured variant that returns `{ recipients: Record<string,string>, paymentIntentId?, reusedFromCredential }`; prefer this when your `mintRecipients` hook needs the full per-rail map (typical multi-rail merchant). Solana MPP requires a static recipient: pass `staticRecipients: { solana: '<wallet>' }` and pre-fund its USDC ATA once from any external wallet. Rotating (per-order, Stripe-minted) Solana recipients do not settle, since the settlement transaction does not create the recipient's token account; the SDK logs a warning when one is minted. The static recipient is reused forever, each settle pays only the ~$0.001 per-tx fee, and this also sidesteps the per-call ATA rent (~$0.50 against MPP spec §13.6). `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`. |
|
|
33
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. |
|
|
34
34
|
| `/middleware/{hono,express,fastify,nextjs,web}` | Framework-specific rate-limit middleware. Hono / Express / Fastify expose middleware factories (`rateLimitHono`, `rateLimitExpress`, `rateLimitFastify`); Next.js exposes `withRateLimit(opts, handler)`; Web Fetch exposes `createRateLimit(opts) => guard(req)`. Shared options: `windowSeconds` (default 60), `maxRequests` (default 60), `keyResolver` (default first hop of `x-forwarded-for`), `redisUrl` (lazy-imports `ioredis` when set, in-memory `Map` fallback otherwise), `keyPrefix`. `ioredis` is an optional peer dep, install it only if you want distributed limiting. |
|
|
35
35
|
| `@agent-score/commerce` (top-level) | `Checkout` orchestrator + `CheckoutContext` + `CheckoutGateConfig` + `CheckoutValidationError` + `DiscoveryProbeConfig` + `MountUcpRoutesOptions` + `SettleOutcome` + `MppxComposeOutcome` + `PricingResult` (the 2.0 high-level surface: one config object, hooks for preValidate/computePricing/onSettled/mintRecipients/composeMppx, auto-derived x402+mppx servers, per-framework adapters `handleHono`/`handleExpress`/`handleFastify`/`handleNextjs`/`handleWeb`, signed UCP routes via `mountUcpRoutes{Hono,Express,Fastify}`); `pricingResult` (factory: cents-denominated → typed `PricingResult` with embedded `PricingBlock`); `validationResponse{Hono,Express,Fastify,Nextjs,Web}` (per-framework 4xx envelope wrappers); `loadUCPSigningKeyFromEnv` (cached env-driven loader for the UCP signing key, reads `UCP_SIGNING_KEY_JWK_PRIVATE` JSON JWK, detects alg from shape, falls back to ephemeral when unset, sanitizes errors so key bytes never reach logs, concurrent-safe via Promise-pinned cache); `hashOperatorToken` (sha256 hex of plaintext `opc_...`, for merchants persisting `operator_token_id` to their own DB without ever storing the plaintext); `extractOwnerScope(headers) → { walletAddress?, operatorTokenHash? }` (canonical owner-identity extractor for caller-scoped resource queries, reads `X-Wallet-Address` / `X-Operator-Token`, hashes the token so plaintext never leaves the request); `hasPaymentHeader` / `hasX402Header` / `hasMppxHeader` (request discriminators, any-credential vs x402 vs MPP); `defaultReadOnlyOnDenied(reason)` (canonical `onDenied` for read-only resource gates: 401 + `Cache-Control: no-store` while still spreading `denialReasonToBody`); plus the cross-vendor publishers `buildA2AAgentCard` + `buildUCPProfile` (return unsigned payloads: vendor signs + publishes). |
|
|
@@ -476,7 +476,7 @@ The `getGateDegradedState` helper is exported by the context-getter adapters (Ho
|
|
|
476
476
|
|
|
477
477
|
## Examples
|
|
478
478
|
|
|
479
|
-
The [examples/](./examples) directory has
|
|
479
|
+
The [examples/](./examples) directory has 8 runnable single-file Hono apps covering common merchant scenarios; copy-paste templates, not frameworks. See [examples/README.md](./examples/README.md) for the full table.
|
|
480
480
|
|
|
481
481
|
## Vendor profile examples
|
|
482
482
|
|
package/dist/core.js
CHANGED
|
@@ -227,7 +227,7 @@ function createAgentScoreCore(options) {
|
|
|
227
227
|
} = options;
|
|
228
228
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
229
229
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
230
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
230
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
231
231
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
232
232
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
233
233
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/core.mjs
CHANGED
|
@@ -209,7 +209,7 @@ function createAgentScoreCore(options) {
|
|
|
209
209
|
} = options;
|
|
210
210
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
211
211
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
212
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
212
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
213
213
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
214
214
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
215
215
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/express.js
CHANGED
|
@@ -920,7 +920,7 @@ function createAgentScoreCore(options) {
|
|
|
920
920
|
} = options;
|
|
921
921
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
922
922
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
923
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
923
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
924
924
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
925
925
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
926
926
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -892,7 +892,7 @@ function createAgentScoreCore(options) {
|
|
|
892
892
|
} = options;
|
|
893
893
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
894
894
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
895
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
895
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
896
896
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
897
897
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
898
898
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/fastify.js
CHANGED
|
@@ -921,7 +921,7 @@ function createAgentScoreCore(options) {
|
|
|
921
921
|
} = options;
|
|
922
922
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
923
923
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
924
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
924
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
925
925
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
926
926
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
927
927
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -892,7 +892,7 @@ function createAgentScoreCore(options) {
|
|
|
892
892
|
} = options;
|
|
893
893
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
894
894
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
895
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
895
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
896
896
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
897
897
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
898
898
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/hono.js
CHANGED
|
@@ -901,7 +901,7 @@ function createAgentScoreCore(options) {
|
|
|
901
901
|
} = options;
|
|
902
902
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
903
903
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
904
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
904
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
905
905
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
906
906
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
907
907
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/hono.mjs
CHANGED
|
@@ -873,7 +873,7 @@ function createAgentScoreCore(options) {
|
|
|
873
873
|
} = options;
|
|
874
874
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
875
875
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
876
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
876
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
877
877
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
878
878
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
879
879
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/nextjs.js
CHANGED
|
@@ -922,7 +922,7 @@ function createAgentScoreCore(options) {
|
|
|
922
922
|
} = options;
|
|
923
923
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
924
924
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
925
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
925
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
926
926
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
927
927
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
928
928
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/nextjs.mjs
CHANGED
|
@@ -897,7 +897,7 @@ function createAgentScoreCore(options) {
|
|
|
897
897
|
} = options;
|
|
898
898
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
899
899
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
900
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
900
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
901
901
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
902
902
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
903
903
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/web.js
CHANGED
|
@@ -898,7 +898,7 @@ function createAgentScoreCore(options) {
|
|
|
898
898
|
} = options;
|
|
899
899
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
900
900
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
901
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
901
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
902
902
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
903
903
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
904
904
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/web.mjs
CHANGED
|
@@ -873,7 +873,7 @@ function createAgentScoreCore(options) {
|
|
|
873
873
|
} = options;
|
|
874
874
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
875
875
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
876
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
876
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
877
877
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
878
878
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
879
879
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/index.js
CHANGED
|
@@ -5535,9 +5535,9 @@ function stringifyPrimitive(value) {
|
|
|
5535
5535
|
return `"${value}"`;
|
|
5536
5536
|
return `${value}`;
|
|
5537
5537
|
}
|
|
5538
|
-
function optionalKeys(
|
|
5539
|
-
return Object.keys(
|
|
5540
|
-
return
|
|
5538
|
+
function optionalKeys(shape2) {
|
|
5539
|
+
return Object.keys(shape2).filter((k) => {
|
|
5540
|
+
return shape2[k]._zod.optin === "optional" && shape2[k]._zod.optout === "optional";
|
|
5541
5541
|
});
|
|
5542
5542
|
}
|
|
5543
5543
|
function pick(schema, mask) {
|
|
@@ -5590,15 +5590,15 @@ function omit(schema, mask) {
|
|
|
5590
5590
|
});
|
|
5591
5591
|
return clone(schema, def);
|
|
5592
5592
|
}
|
|
5593
|
-
function extend(schema,
|
|
5594
|
-
if (!isPlainObject(
|
|
5593
|
+
function extend(schema, shape2) {
|
|
5594
|
+
if (!isPlainObject(shape2)) {
|
|
5595
5595
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
5596
5596
|
}
|
|
5597
5597
|
const checks = schema._zod.def.checks;
|
|
5598
5598
|
const hasChecks = checks && checks.length > 0;
|
|
5599
5599
|
if (hasChecks) {
|
|
5600
5600
|
const existingShape = schema._zod.def.shape;
|
|
5601
|
-
for (const key in
|
|
5601
|
+
for (const key in shape2) {
|
|
5602
5602
|
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
5603
5603
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
5604
5604
|
}
|
|
@@ -5606,20 +5606,20 @@ function extend(schema, shape) {
|
|
|
5606
5606
|
}
|
|
5607
5607
|
const def = mergeDefs(schema._zod.def, {
|
|
5608
5608
|
get shape() {
|
|
5609
|
-
const _shape = { ...schema._zod.def.shape, ...
|
|
5609
|
+
const _shape = { ...schema._zod.def.shape, ...shape2 };
|
|
5610
5610
|
assignProp(this, "shape", _shape);
|
|
5611
5611
|
return _shape;
|
|
5612
5612
|
}
|
|
5613
5613
|
});
|
|
5614
5614
|
return clone(schema, def);
|
|
5615
5615
|
}
|
|
5616
|
-
function safeExtend(schema,
|
|
5617
|
-
if (!isPlainObject(
|
|
5616
|
+
function safeExtend(schema, shape2) {
|
|
5617
|
+
if (!isPlainObject(shape2)) {
|
|
5618
5618
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
5619
5619
|
}
|
|
5620
5620
|
const def = mergeDefs(schema._zod.def, {
|
|
5621
5621
|
get shape() {
|
|
5622
|
-
const _shape = { ...schema._zod.def.shape, ...
|
|
5622
|
+
const _shape = { ...schema._zod.def.shape, ...shape2 };
|
|
5623
5623
|
assignProp(this, "shape", _shape);
|
|
5624
5624
|
return _shape;
|
|
5625
5625
|
}
|
|
@@ -5653,7 +5653,7 @@ function partial(Class2, schema, mask) {
|
|
|
5653
5653
|
const def = mergeDefs(schema._zod.def, {
|
|
5654
5654
|
get shape() {
|
|
5655
5655
|
const oldShape = schema._zod.def.shape;
|
|
5656
|
-
const
|
|
5656
|
+
const shape2 = { ...oldShape };
|
|
5657
5657
|
if (mask) {
|
|
5658
5658
|
for (const key in mask) {
|
|
5659
5659
|
if (!(key in oldShape)) {
|
|
@@ -5661,21 +5661,21 @@ function partial(Class2, schema, mask) {
|
|
|
5661
5661
|
}
|
|
5662
5662
|
if (!mask[key])
|
|
5663
5663
|
continue;
|
|
5664
|
-
|
|
5664
|
+
shape2[key] = Class2 ? new Class2({
|
|
5665
5665
|
type: "optional",
|
|
5666
5666
|
innerType: oldShape[key]
|
|
5667
5667
|
}) : oldShape[key];
|
|
5668
5668
|
}
|
|
5669
5669
|
} else {
|
|
5670
5670
|
for (const key in oldShape) {
|
|
5671
|
-
|
|
5671
|
+
shape2[key] = Class2 ? new Class2({
|
|
5672
5672
|
type: "optional",
|
|
5673
5673
|
innerType: oldShape[key]
|
|
5674
5674
|
}) : oldShape[key];
|
|
5675
5675
|
}
|
|
5676
5676
|
}
|
|
5677
|
-
assignProp(this, "shape",
|
|
5678
|
-
return
|
|
5677
|
+
assignProp(this, "shape", shape2);
|
|
5678
|
+
return shape2;
|
|
5679
5679
|
},
|
|
5680
5680
|
checks: []
|
|
5681
5681
|
});
|
|
@@ -5685,29 +5685,29 @@ function required(Class2, schema, mask) {
|
|
|
5685
5685
|
const def = mergeDefs(schema._zod.def, {
|
|
5686
5686
|
get shape() {
|
|
5687
5687
|
const oldShape = schema._zod.def.shape;
|
|
5688
|
-
const
|
|
5688
|
+
const shape2 = { ...oldShape };
|
|
5689
5689
|
if (mask) {
|
|
5690
5690
|
for (const key in mask) {
|
|
5691
|
-
if (!(key in
|
|
5691
|
+
if (!(key in shape2)) {
|
|
5692
5692
|
throw new Error(`Unrecognized key: "${key}"`);
|
|
5693
5693
|
}
|
|
5694
5694
|
if (!mask[key])
|
|
5695
5695
|
continue;
|
|
5696
|
-
|
|
5696
|
+
shape2[key] = new Class2({
|
|
5697
5697
|
type: "nonoptional",
|
|
5698
5698
|
innerType: oldShape[key]
|
|
5699
5699
|
});
|
|
5700
5700
|
}
|
|
5701
5701
|
} else {
|
|
5702
5702
|
for (const key in oldShape) {
|
|
5703
|
-
|
|
5703
|
+
shape2[key] = new Class2({
|
|
5704
5704
|
type: "nonoptional",
|
|
5705
5705
|
innerType: oldShape[key]
|
|
5706
5706
|
});
|
|
5707
5707
|
}
|
|
5708
5708
|
}
|
|
5709
|
-
assignProp(this, "shape",
|
|
5710
|
-
return
|
|
5709
|
+
assignProp(this, "shape", shape2);
|
|
5710
|
+
return shape2;
|
|
5711
5711
|
}
|
|
5712
5712
|
});
|
|
5713
5713
|
return clone(schema, def);
|
|
@@ -8002,10 +8002,10 @@ var init_schemas = __esm({
|
|
|
8002
8002
|
}
|
|
8003
8003
|
const _normalized = cached(() => normalizeDef(def));
|
|
8004
8004
|
defineLazy(inst._zod, "propValues", () => {
|
|
8005
|
-
const
|
|
8005
|
+
const shape2 = def.shape;
|
|
8006
8006
|
const propValues = {};
|
|
8007
|
-
for (const key in
|
|
8008
|
-
const field =
|
|
8007
|
+
for (const key in shape2) {
|
|
8008
|
+
const field = shape2[key]._zod;
|
|
8009
8009
|
if (field.values) {
|
|
8010
8010
|
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
8011
8011
|
for (const v of field.values)
|
|
@@ -8031,9 +8031,9 @@ var init_schemas = __esm({
|
|
|
8031
8031
|
}
|
|
8032
8032
|
payload.value = {};
|
|
8033
8033
|
const proms = [];
|
|
8034
|
-
const
|
|
8034
|
+
const shape2 = value.shape;
|
|
8035
8035
|
for (const key of value.keys) {
|
|
8036
|
-
const el =
|
|
8036
|
+
const el = shape2[key];
|
|
8037
8037
|
const isOptionalIn = el._zod.optin === "optional";
|
|
8038
8038
|
const isOptionalOut = el._zod.optout === "optional";
|
|
8039
8039
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
@@ -8053,7 +8053,7 @@ var init_schemas = __esm({
|
|
|
8053
8053
|
$ZodObject.init(inst, def);
|
|
8054
8054
|
const superParse = inst._zod.parse;
|
|
8055
8055
|
const _normalized = cached(() => normalizeDef(def));
|
|
8056
|
-
const generateFastpass = (
|
|
8056
|
+
const generateFastpass = (shape2) => {
|
|
8057
8057
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
8058
8058
|
const normalized = _normalized.value;
|
|
8059
8059
|
const parseStr = (key) => {
|
|
@@ -8070,7 +8070,7 @@ var init_schemas = __esm({
|
|
|
8070
8070
|
for (const key of normalized.keys) {
|
|
8071
8071
|
const id = ids[key];
|
|
8072
8072
|
const k = esc(key);
|
|
8073
|
-
const schema =
|
|
8073
|
+
const schema = shape2[key];
|
|
8074
8074
|
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
8075
8075
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
8076
8076
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
@@ -8144,7 +8144,7 @@ var init_schemas = __esm({
|
|
|
8144
8144
|
doc.write(`payload.value = newResult;`);
|
|
8145
8145
|
doc.write(`return payload;`);
|
|
8146
8146
|
const fn = doc.compile();
|
|
8147
|
-
return (payload, ctx) => fn(
|
|
8147
|
+
return (payload, ctx) => fn(shape2, payload, ctx);
|
|
8148
8148
|
};
|
|
8149
8149
|
let fastpass;
|
|
8150
8150
|
const isObject3 = isObject;
|
|
@@ -17202,14 +17202,14 @@ var init_json_schema_processors = __esm({
|
|
|
17202
17202
|
const def = schema._zod.def;
|
|
17203
17203
|
json2.type = "object";
|
|
17204
17204
|
json2.properties = {};
|
|
17205
|
-
const
|
|
17206
|
-
for (const key in
|
|
17207
|
-
json2.properties[key] = process2(
|
|
17205
|
+
const shape2 = def.shape;
|
|
17206
|
+
for (const key in shape2) {
|
|
17207
|
+
json2.properties[key] = process2(shape2[key], ctx, {
|
|
17208
17208
|
...params,
|
|
17209
17209
|
path: [...params.path, "properties", key]
|
|
17210
17210
|
});
|
|
17211
17211
|
}
|
|
17212
|
-
const allKeys = new Set(Object.keys(
|
|
17212
|
+
const allKeys = new Set(Object.keys(shape2));
|
|
17213
17213
|
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
17214
17214
|
const v = def.shape[key]._zod;
|
|
17215
17215
|
if (ctx.io === "input") {
|
|
@@ -18070,47 +18070,47 @@ function array(element, params) {
|
|
|
18070
18070
|
}
|
|
18071
18071
|
// @__NO_SIDE_EFFECTS__
|
|
18072
18072
|
function keyof(schema) {
|
|
18073
|
-
const
|
|
18074
|
-
return /* @__PURE__ */ _enum2(Object.keys(
|
|
18073
|
+
const shape2 = schema._zod.def.shape;
|
|
18074
|
+
return /* @__PURE__ */ _enum2(Object.keys(shape2));
|
|
18075
18075
|
}
|
|
18076
18076
|
// @__NO_SIDE_EFFECTS__
|
|
18077
|
-
function object(
|
|
18077
|
+
function object(shape2, params) {
|
|
18078
18078
|
const def = {
|
|
18079
18079
|
type: "object",
|
|
18080
|
-
shape:
|
|
18080
|
+
shape: shape2 ?? {},
|
|
18081
18081
|
...normalizeParams(params)
|
|
18082
18082
|
};
|
|
18083
18083
|
return new ZodMiniObject(def);
|
|
18084
18084
|
}
|
|
18085
18085
|
// @__NO_SIDE_EFFECTS__
|
|
18086
|
-
function strictObject(
|
|
18086
|
+
function strictObject(shape2, params) {
|
|
18087
18087
|
return new ZodMiniObject({
|
|
18088
18088
|
type: "object",
|
|
18089
|
-
shape,
|
|
18089
|
+
shape: shape2,
|
|
18090
18090
|
catchall: /* @__PURE__ */ never(),
|
|
18091
18091
|
...normalizeParams(params)
|
|
18092
18092
|
});
|
|
18093
18093
|
}
|
|
18094
18094
|
// @__NO_SIDE_EFFECTS__
|
|
18095
|
-
function looseObject(
|
|
18095
|
+
function looseObject(shape2, params) {
|
|
18096
18096
|
return new ZodMiniObject({
|
|
18097
18097
|
type: "object",
|
|
18098
|
-
shape,
|
|
18098
|
+
shape: shape2,
|
|
18099
18099
|
catchall: /* @__PURE__ */ unknown(),
|
|
18100
18100
|
...normalizeParams(params)
|
|
18101
18101
|
});
|
|
18102
18102
|
}
|
|
18103
18103
|
// @__NO_SIDE_EFFECTS__
|
|
18104
|
-
function extend2(schema,
|
|
18105
|
-
return extend(schema,
|
|
18104
|
+
function extend2(schema, shape2) {
|
|
18105
|
+
return extend(schema, shape2);
|
|
18106
18106
|
}
|
|
18107
18107
|
// @__NO_SIDE_EFFECTS__
|
|
18108
|
-
function safeExtend2(schema,
|
|
18109
|
-
return safeExtend(schema,
|
|
18108
|
+
function safeExtend2(schema, shape2) {
|
|
18109
|
+
return safeExtend(schema, shape2);
|
|
18110
18110
|
}
|
|
18111
18111
|
// @__NO_SIDE_EFFECTS__
|
|
18112
|
-
function merge2(schema,
|
|
18113
|
-
return extend(schema,
|
|
18112
|
+
function merge2(schema, shape2) {
|
|
18113
|
+
return extend(schema, shape2);
|
|
18114
18114
|
}
|
|
18115
18115
|
// @__NO_SIDE_EFFECTS__
|
|
18116
18116
|
function pick2(schema, mask) {
|
|
@@ -20148,7 +20148,7 @@ var version3;
|
|
|
20148
20148
|
var init_version2 = __esm({
|
|
20149
20149
|
"node_modules/viem/_esm/errors/version.js"() {
|
|
20150
20150
|
"use strict";
|
|
20151
|
-
version3 = "2.54.
|
|
20151
|
+
version3 = "2.54.6";
|
|
20152
20152
|
}
|
|
20153
20153
|
});
|
|
20154
20154
|
|
|
@@ -21143,14 +21143,14 @@ function fromResponse2(response) {
|
|
|
21143
21143
|
throw new Error(`Missing ${Headers2.paymentReceipt} header.`);
|
|
21144
21144
|
return deserialize4(header);
|
|
21145
21145
|
}
|
|
21146
|
-
var Schema2;
|
|
21146
|
+
var shape, BaseSchema, Schema2;
|
|
21147
21147
|
var init_Receipt = __esm({
|
|
21148
21148
|
"node_modules/mppx/dist/Receipt.js"() {
|
|
21149
21149
|
"use strict";
|
|
21150
21150
|
init_esm2();
|
|
21151
21151
|
init_Constants();
|
|
21152
21152
|
init_zod();
|
|
21153
|
-
|
|
21153
|
+
shape = {
|
|
21154
21154
|
/** Payment method used (e.g., "tempo", "stripe"). */
|
|
21155
21155
|
method: string2(),
|
|
21156
21156
|
/** Method-specific reference (e.g., transaction hash). */
|
|
@@ -21163,7 +21163,9 @@ var init_Receipt = __esm({
|
|
|
21163
21163
|
status: literal("success"),
|
|
21164
21164
|
/** RFC 3339 settlement timestamp. */
|
|
21165
21165
|
timestamp: datetime3()
|
|
21166
|
-
}
|
|
21166
|
+
};
|
|
21167
|
+
BaseSchema = object(shape);
|
|
21168
|
+
Schema2 = looseObject(shape);
|
|
21167
21169
|
}
|
|
21168
21170
|
});
|
|
21169
21171
|
|
|
@@ -22662,7 +22664,7 @@ function createAgentScoreCore(options) {
|
|
|
22662
22664
|
} = options;
|
|
22663
22665
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
22664
22666
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
22665
|
-
const defaultUa = `@agent-score/commerce@${"2.6.
|
|
22667
|
+
const defaultUa = `@agent-score/commerce@${"2.6.2"}`;
|
|
22666
22668
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
22667
22669
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
22668
22670
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -24636,6 +24638,27 @@ async function dynamicImport(moduleName) {
|
|
|
24636
24638
|
}
|
|
24637
24639
|
}
|
|
24638
24640
|
|
|
24641
|
+
// src/forwarded_proto.ts
|
|
24642
|
+
function applyForwardedProto(url2, forwardedProto) {
|
|
24643
|
+
const proto = typeof forwardedProto === "string" ? forwardedProto.split(",")[0]?.trim() : void 0;
|
|
24644
|
+
if (!proto) return url2;
|
|
24645
|
+
try {
|
|
24646
|
+
const u = new URL(url2);
|
|
24647
|
+
u.protocol = `${proto}:`;
|
|
24648
|
+
return u.toString();
|
|
24649
|
+
} catch {
|
|
24650
|
+
return url2;
|
|
24651
|
+
}
|
|
24652
|
+
}
|
|
24653
|
+
function readForwardedProto(headers) {
|
|
24654
|
+
if (typeof headers.get === "function") {
|
|
24655
|
+
return headers.get("x-forwarded-proto") ?? void 0;
|
|
24656
|
+
}
|
|
24657
|
+
const rec = headers;
|
|
24658
|
+
const raw = rec["x-forwarded-proto"] ?? rec["X-Forwarded-Proto"];
|
|
24659
|
+
return Array.isArray(raw) ? raw[0] : raw;
|
|
24660
|
+
}
|
|
24661
|
+
|
|
24639
24662
|
// src/payment/constants.ts
|
|
24640
24663
|
var STRIPE_MIN_CHARGE_USD = 0.5;
|
|
24641
24664
|
|
|
@@ -26423,17 +26446,7 @@ function validationResponseWeb(input) {
|
|
|
26423
26446
|
return validationResponseHono(input);
|
|
26424
26447
|
}
|
|
26425
26448
|
function resolveResourceUrl(request) {
|
|
26426
|
-
|
|
26427
|
-
const proto = typeof fwd === "string" ? fwd.split(",")[0]?.trim() : void 0;
|
|
26428
|
-
if (proto) {
|
|
26429
|
-
try {
|
|
26430
|
-
const u = new URL(request.url);
|
|
26431
|
-
u.protocol = `${proto}:`;
|
|
26432
|
-
return u.toString();
|
|
26433
|
-
} catch {
|
|
26434
|
-
}
|
|
26435
|
-
}
|
|
26436
|
-
return request.url;
|
|
26449
|
+
return applyForwardedProto(request.url, readForwardedProto(request.headers));
|
|
26437
26450
|
}
|
|
26438
26451
|
function stripContentType(headers) {
|
|
26439
26452
|
const out = {};
|
|
@@ -27029,7 +27042,11 @@ function computeFirstCheckout(opts) {
|
|
|
27029
27042
|
for (const [k, v] of Object.entries(mppChallengeHeaders)) headers.set(k, v);
|
|
27030
27043
|
headers.set(
|
|
27031
27044
|
"PAYMENT-REQUIRED",
|
|
27032
|
-
paymentRequiredHeader2({
|
|
27045
|
+
paymentRequiredHeader2({
|
|
27046
|
+
x402Version: 2,
|
|
27047
|
+
accepts: accepted,
|
|
27048
|
+
resource: { url: applyForwardedProto(req.url, readForwardedProto(req.headers)) }
|
|
27049
|
+
})
|
|
27033
27050
|
);
|
|
27034
27051
|
return new Response(JSON.stringify(body402), { status: 402, headers });
|
|
27035
27052
|
}
|
|
@@ -27088,7 +27105,7 @@ function computeFirstCheckout(opts) {
|
|
|
27088
27105
|
maxTimeoutSeconds: 300
|
|
27089
27106
|
},
|
|
27090
27107
|
resourceMeta: {
|
|
27091
|
-
url: req.url,
|
|
27108
|
+
url: applyForwardedProto(req.url, readForwardedProto(req.headers)),
|
|
27092
27109
|
description: `Agent purchase via x402-exact (${opts.name})`,
|
|
27093
27110
|
mimeType: "application/json"
|
|
27094
27111
|
}
|