@agent-score/commerce 2.3.0 → 2.5.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 +6 -6
- package/dist/challenge/index.d.mts +9 -5
- package/dist/challenge/index.d.ts +9 -5
- package/dist/challenge/index.js +11 -4
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs +11 -4
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/{checkout-ChyOi7aU.d.ts → checkout-McfNpZJf.d.ts} +80 -12
- package/dist/{checkout-Ceo1_rVJ.d.mts → checkout-o17dIxHi.d.mts} +80 -12
- package/dist/core.d.mts +27 -7
- package/dist/core.d.ts +27 -7
- package/dist/core.js +25 -11
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +25 -11
- package/dist/core.mjs.map +1 -1
- package/dist/discovery/index.d.mts +26 -10
- package/dist/discovery/index.d.ts +26 -10
- package/dist/discovery/index.js +58 -10
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +58 -10
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/gate-CWP10xPQ.d.mts +339 -0
- package/dist/gate-CWP10xPQ.d.ts +339 -0
- package/dist/identity/express.d.mts +26 -1
- package/dist/identity/express.d.ts +26 -1
- package/dist/identity/express.js +599 -25
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +595 -24
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +12 -2
- package/dist/identity/fastify.d.ts +12 -2
- package/dist/identity/fastify.js +607 -25
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +603 -24
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +26 -1
- package/dist/identity/hono.d.ts +26 -1
- package/dist/identity/hono.js +588 -25
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +584 -24
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +3 -0
- package/dist/identity/nextjs.d.ts +3 -0
- package/dist/identity/nextjs.js +593 -25
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +589 -24
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs.map +1 -1
- package/dist/identity/web.d.mts +24 -1
- package/dist/identity/web.d.ts +24 -1
- package/dist/identity/web.js +593 -25
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +589 -24
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +129 -14
- package/dist/index.d.ts +129 -14
- package/dist/index.js +978 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +956 -99
- package/dist/index.mjs.map +1 -1
- package/dist/{default_rails-DtR_E9N9.d.ts → network_kind-BIJM2peR.d.ts} +22 -8
- package/dist/{default_rails-K25PtWrL.d.mts → network_kind-C0EMkdzz.d.mts} +22 -8
- package/dist/payment/index.d.mts +16 -26
- package/dist/payment/index.d.ts +16 -26
- package/dist/payment/index.js +62 -57
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +62 -57
- package/dist/payment/index.mjs.map +1 -1
- package/dist/{pricing-B3-aKxSz.d.ts → pricing-CytRwhC2.d.ts} +1 -1
- package/dist/{pricing-BReyZiqN.d.mts → pricing-KHDqMLd7.d.mts} +1 -1
- package/dist/{rail_spec-B1239jPp.d.mts → rail_spec-BFZmW9RN.d.mts} +3 -4
- package/dist/{rail_spec-B1239jPp.d.ts → rail_spec-BFZmW9RN.d.ts} +3 -4
- package/dist/stripe-multichain/index.d.mts +2 -9
- package/dist/stripe-multichain/index.d.ts +2 -9
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/dist/{wwwauthenticate-D_FMnPgU.d.mts → wwwauthenticate-CVaGUMjU.d.mts} +8 -6
- package/dist/{wwwauthenticate-D_FMnPgU.d.ts → wwwauthenticate-CVaGUMjU.d.ts} +8 -6
- package/package.json +14 -13
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TempoRailSpec, S as SolanaMppRailSpec, c as TempoSessionRailSpec, b as StripeRailSpec, X as X402BaseRailSpec } from './rail_spec-
|
|
2
|
-
import { P as PricingBlock, R as RailKey } from './pricing-
|
|
1
|
+
import { T as TempoRailSpec, S as SolanaMppRailSpec, c as TempoSessionRailSpec, b as StripeRailSpec, X as X402BaseRailSpec } from './rail_spec-BFZmW9RN.js';
|
|
2
|
+
import { P as PricingBlock, R as RailKey } from './pricing-CytRwhC2.js';
|
|
3
3
|
import { CreateSessionOnMissing, AgentScoreCoreOptions, DenialReason } from './core.js';
|
|
4
4
|
import { a as X402Server } from './x402_server-Ciz2mls2.js';
|
|
5
5
|
|
|
@@ -26,9 +26,8 @@ import { a as X402Server } from './x402_server-Ciz2mls2.js';
|
|
|
26
26
|
/**
|
|
27
27
|
* Construct a UCPSigningKey from a public JWK dict (e.g. the `publicJWK` returned by
|
|
28
28
|
* `generateUCPSigningKey()`). Validates required fields and rejects symmetric keys that
|
|
29
|
-
* can't publicly verify a JWS in trust-mode UCP.
|
|
30
|
-
*
|
|
31
|
-
* static-method-style namespace export below.
|
|
29
|
+
* can't publicly verify a JWS in trust-mode UCP. Exposed as `UCPSigningKey.fromJWK`
|
|
30
|
+
* via the static-method-style namespace export below.
|
|
32
31
|
*/
|
|
33
32
|
declare function ucpSigningKeyFromJWKImpl(jwk: Record<string, unknown>): UCPSigningKey;
|
|
34
33
|
interface UCPSigningKey {
|
|
@@ -45,8 +44,8 @@ interface UCPSigningKey {
|
|
|
45
44
|
/** JWK x / y / n / e / etc. The full key material; passed through verbatim. */
|
|
46
45
|
[k: string]: unknown;
|
|
47
46
|
}
|
|
48
|
-
/** Static-method-style namespace on the `UCPSigningKey` interface
|
|
49
|
-
*
|
|
47
|
+
/** Static-method-style namespace on the `UCPSigningKey` interface.
|
|
48
|
+
* Use as `UCPSigningKey.fromJWK(jwk)`. */
|
|
50
49
|
declare const UCPSigningKey: {
|
|
51
50
|
fromJWK: typeof ucpSigningKeyFromJWKImpl;
|
|
52
51
|
};
|
|
@@ -175,7 +174,7 @@ interface BuildUCPProfileInput {
|
|
|
175
174
|
* attestation lives on the AP2 risk-signal endpoint, not here. */
|
|
176
175
|
agentscore_gate?: AgentScoreGatePolicy;
|
|
177
176
|
/** Optional override for the AgentScore capability schema URL. Field is snake_cased
|
|
178
|
-
*
|
|
177
|
+
* to match the on-the-wire UCP profile shape. */
|
|
179
178
|
agentscore_schema_url?: string;
|
|
180
179
|
/** Optional override for the AgentScore capability spec URL. */
|
|
181
180
|
agentscore_spec_url?: string;
|
|
@@ -435,9 +434,7 @@ declare function pricingResult(opts: {
|
|
|
435
434
|
* Per-route discovery-probe config. When passed to {@link Checkout}, any
|
|
436
435
|
* empty-body POST without a payment credential short-circuits with a sample
|
|
437
436
|
* 402 advertising the merchant's payment shape — the canonical pattern x402
|
|
438
|
-
* crawlers
|
|
439
|
-
*
|
|
440
|
-
* Mirrors python's `DiscoveryProbeConfig` dataclass.
|
|
437
|
+
* crawlers rely on.
|
|
441
438
|
*/
|
|
442
439
|
interface DiscoveryProbeConfig {
|
|
443
440
|
realm: string;
|
|
@@ -572,9 +569,64 @@ interface CheckoutGateConfig {
|
|
|
572
569
|
* DenialReason. Return a `GateDenial` to override the canonical body, or
|
|
573
570
|
* null to use `denialReasonToBody`. */
|
|
574
571
|
onDenied?: (ctx: CheckoutContext, reason: DenialReason) => GateDenial | null | Promise<GateDenial | null>;
|
|
572
|
+
/** Accept AIP Agent Identity Tokens (AITs) on this route. When set and a request carries
|
|
573
|
+
* an `Agent-Identity` header, the gate verifies the token offline (issuer signature via the
|
|
574
|
+
* trusted-issuer JWKS + RFC 9421 proof-of-possession) BEFORE the assess call, then sends the
|
|
575
|
+
* raw token to `/v1/assess` as `aip_token` so the same wine/age/sanctions policy evaluates
|
|
576
|
+
* against the token's attested identity. A present-but-invalid AIT is a hard deny (the gate
|
|
577
|
+
* does NOT fall through to wallet / operator-token). Requests with no `Agent-Identity` header
|
|
578
|
+
* use the existing wallet / operator-token path unchanged.
|
|
579
|
+
*
|
|
580
|
+
* Ignored when `runGate` is also set (a custom gate fully owns the flow). Without an `apiKey`,
|
|
581
|
+
* a verified AIT is honored offline for identity-only gates, but a gate that declares policy
|
|
582
|
+
* fields (KYC / age / sanctions / jurisdiction) without an `apiKey` fails closed
|
|
583
|
+
* (`aip_policy_requires_api_key`) since policy can only be evaluated via `/v1/assess`. */
|
|
584
|
+
aip?: AipGateConfig;
|
|
575
585
|
/** Full escape hatch — replaces the SDK gate flow. */
|
|
576
586
|
runGate?: RunGateFn;
|
|
577
587
|
}
|
|
588
|
+
/** AIP acceptance config for {@link CheckoutGateConfig.aip}. */
|
|
589
|
+
interface AipGateConfig {
|
|
590
|
+
/** ADDITIONAL external issuers to trust beyond AgentScore's own (e.g. `['https://issuer.example']`),
|
|
591
|
+
* matched after canonicalization. AgentScore's canonical issuer
|
|
592
|
+
* ({@link AGENTSCORE_CANONICAL_ISSUER}) is ALWAYS trusted and never needs listing — this SDK
|
|
593
|
+
* is the AgentScore verifier, so a merchant can't accidentally fail to trust AgentScore AITs.
|
|
594
|
+
* Omit/empty to accept only AgentScore-issued AITs. */
|
|
595
|
+
trustedIssuers?: string[];
|
|
596
|
+
/** Clock-skew tolerance in seconds for the RFC 9421 signature window (and, as an override,
|
|
597
|
+
* the AIT JWT `exp`/`iat`). Defaults to 30s for the signature / 60s for the JWT. */
|
|
598
|
+
maxSkewSeconds?: number;
|
|
599
|
+
/** Expected `@authority` (public hostname) the RFC 9421 signature must cover. When set, the
|
|
600
|
+
* verifier binds the signature to this value instead of trusting the inbound `Host` header —
|
|
601
|
+
* pin it to your real public host (e.g. `'wine.example.com'`) when behind a proxy that does
|
|
602
|
+
* not normalize `Host`, to prevent a captured AIT+signature from being replayed to a
|
|
603
|
+
* different virtual host on the same origin. */
|
|
604
|
+
authority?: string;
|
|
605
|
+
/** Per-issuer compliance policy override, keyed by issuer URL (canonicalized before lookup).
|
|
606
|
+
* When a request's AIT is verified and its `iss` matches a key here, that block REPLACES the
|
|
607
|
+
* gate's default policy fields (`requireKyc` / `requireSanctionsClear` / `minAge` /
|
|
608
|
+
* `allowed/blockedJurisdictions`) for that request — letting a merchant apply different rules
|
|
609
|
+
* by issuer (e.g. full compliance for its own AITs, a relaxed set for a partner issuer whose
|
|
610
|
+
* tokens carry fewer attested claims). The replacement is whole-policy, not a merge: an issuer
|
|
611
|
+
* block of `{ requireKyc: true, minAge: 21 }` evaluates ONLY those two rules for that issuer
|
|
612
|
+
* (sanctions / jurisdiction omitted → not enforced for that issuer). Issuers NOT listed here
|
|
613
|
+
* use the gate's default policy unchanged. Only the AIT path consults this — wallet /
|
|
614
|
+
* operator-token requests are unaffected.
|
|
615
|
+
*
|
|
616
|
+
* This is a deliberate compliance posture per issuer, not a default; an empty/absent map keeps
|
|
617
|
+
* every issuer on the gate's default policy. */
|
|
618
|
+
issuerPolicies?: Record<string, AipIssuerPolicy>;
|
|
619
|
+
}
|
|
620
|
+
/** A per-issuer compliance policy block for {@link AipGateConfig.issuerPolicies}. The same
|
|
621
|
+
* compliance fields as the gate, applied (as a whole-policy replacement) only to AITs from the
|
|
622
|
+
* matching issuer. */
|
|
623
|
+
interface AipIssuerPolicy {
|
|
624
|
+
requireKyc?: boolean;
|
|
625
|
+
requireSanctionsClear?: boolean;
|
|
626
|
+
minAge?: number;
|
|
627
|
+
blockedJurisdictions?: string[];
|
|
628
|
+
allowedJurisdictions?: string[];
|
|
629
|
+
}
|
|
578
630
|
/** Surface passed to `Checkout.onSettled` after a payment lands. */
|
|
579
631
|
interface SettleOutcome {
|
|
580
632
|
/** Protocol family that handled the settle. */
|
|
@@ -666,6 +718,18 @@ type IsCachedAddressFn = (address: string) => boolean | Promise<boolean>;
|
|
|
666
718
|
declare function makeMppxComposeHook(opts: {
|
|
667
719
|
serverGetter: () => Promise<unknown>;
|
|
668
720
|
}): ComposeMppxFn;
|
|
721
|
+
/** Resolve a per-issuer compliance-policy override for a verified AIT's issuer. Both the verified
|
|
722
|
+
* `iss` and the map keys are canonicalized (lowercase scheme+host, no default port / trailing
|
|
723
|
+
* slash) before comparison so `https://issuer.example` and `https://issuer.example/` resolve the same.
|
|
724
|
+
* Returns the matching policy block, or undefined when the issuer is not overridden (→ caller
|
|
725
|
+
* falls back to the gate's default policy). */
|
|
726
|
+
/** The effective AIP trusted-issuer list: AgentScore's canonical issuer (ALWAYS trusted) plus any
|
|
727
|
+
* external issuers. De-duped after canonicalization. Use this for the `agent_memory` hint and any
|
|
728
|
+
* presentation surface (llms.txt / mpp.json / skill.md) that advertises AIP acceptance, so a
|
|
729
|
+
* merchant relying solely on AgentScore AITs (no external issuers) still advertises the
|
|
730
|
+
* `agent_identity` path. Trust enforcement itself lives in {@link JwksCache}, which merges the
|
|
731
|
+
* canonical issuer independently. */
|
|
732
|
+
declare function buildAipTrustedIssuers(externalIssuers?: string[]): string[];
|
|
669
733
|
/**
|
|
670
734
|
* Framework-neutral 4xx envelope (`{ error, next_steps, agent_instructions }`).
|
|
671
735
|
*
|
|
@@ -741,6 +805,10 @@ declare class Checkout {
|
|
|
741
805
|
readonly discoveryExtensions: Record<string, unknown> | undefined;
|
|
742
806
|
readonly discoveryProbe: DiscoveryProbeConfig | undefined;
|
|
743
807
|
private _x402ServerGetter;
|
|
808
|
+
/** Lazily-built JWKS cache for AIP verification, shared across requests so issuer keys
|
|
809
|
+
* are fetched once and cached (per the verifier's hard 24h cap). Built on first AIT. */
|
|
810
|
+
private aipJwks;
|
|
811
|
+
private getAipJwks;
|
|
744
812
|
/**
|
|
745
813
|
* True when the merchant has configured an identity-bearing policy flag —
|
|
746
814
|
* `require_kyc`, `require_sanctions_clear` (name screening on the KYC
|
|
@@ -958,4 +1026,4 @@ interface MountUcpRoutesOptions {
|
|
|
958
1026
|
jwksPath?: string;
|
|
959
1027
|
}
|
|
960
1028
|
|
|
961
|
-
export { AGENTSCORE_UCP_CAPABILITY as A,
|
|
1029
|
+
export { AGENTSCORE_UCP_CAPABILITY as A, validationResponseFastify as B, Checkout as C, type DiscoveryProbeConfig as D, validationResponseHono as E, validationResponseNextjs as F, type GateDenial as G, validationResponseWeb as H, type IsCachedAddressFn as I, x402PaymentHandler as J, type MountUcpRoutesOptions as M, type OnSettledFn as O, type PreValidateFn as P, type RecipientsFn as R, type SettleOutcome as S, type UCPCapabilityBinding as U, type AgentScoreGatePolicy as a, type CheckoutContext as b, type CheckoutGateConfig as c, type CheckoutRailSpec as d, type CheckoutRequest as e, type CheckoutResult as f, type ComposeMppxFn as g, type MppxComposeOutcome as h, type PricingFn as i, type PricingResult as j, type ReferenceIdFn as k, type RunGateFn as l, type UCPPaymentHandlerBinding as m, type UCPProfile as n, type UCPProfileBody as o, type UCPServiceBinding as p, UCPSigningKey as q, buildAipTrustedIssuers as r, buildUCPProfile as s, getIdentityStatus as t, makeMppxComposeHook as u, mppPaymentHandler as v, pricingResult as w, stripeSptPaymentHandler as x, validationEnvelope as y, validationResponseExpress as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TempoRailSpec, S as SolanaMppRailSpec, c as TempoSessionRailSpec, b as StripeRailSpec, X as X402BaseRailSpec } from './rail_spec-
|
|
2
|
-
import { P as PricingBlock, R as RailKey } from './pricing-
|
|
1
|
+
import { T as TempoRailSpec, S as SolanaMppRailSpec, c as TempoSessionRailSpec, b as StripeRailSpec, X as X402BaseRailSpec } from './rail_spec-BFZmW9RN.mjs';
|
|
2
|
+
import { P as PricingBlock, R as RailKey } from './pricing-KHDqMLd7.mjs';
|
|
3
3
|
import { CreateSessionOnMissing, AgentScoreCoreOptions, DenialReason } from './core.mjs';
|
|
4
4
|
import { a as X402Server } from './x402_server-Ciz2mls2.mjs';
|
|
5
5
|
|
|
@@ -26,9 +26,8 @@ import { a as X402Server } from './x402_server-Ciz2mls2.mjs';
|
|
|
26
26
|
/**
|
|
27
27
|
* Construct a UCPSigningKey from a public JWK dict (e.g. the `publicJWK` returned by
|
|
28
28
|
* `generateUCPSigningKey()`). Validates required fields and rejects symmetric keys that
|
|
29
|
-
* can't publicly verify a JWS in trust-mode UCP.
|
|
30
|
-
*
|
|
31
|
-
* static-method-style namespace export below.
|
|
29
|
+
* can't publicly verify a JWS in trust-mode UCP. Exposed as `UCPSigningKey.fromJWK`
|
|
30
|
+
* via the static-method-style namespace export below.
|
|
32
31
|
*/
|
|
33
32
|
declare function ucpSigningKeyFromJWKImpl(jwk: Record<string, unknown>): UCPSigningKey;
|
|
34
33
|
interface UCPSigningKey {
|
|
@@ -45,8 +44,8 @@ interface UCPSigningKey {
|
|
|
45
44
|
/** JWK x / y / n / e / etc. The full key material; passed through verbatim. */
|
|
46
45
|
[k: string]: unknown;
|
|
47
46
|
}
|
|
48
|
-
/** Static-method-style namespace on the `UCPSigningKey` interface
|
|
49
|
-
*
|
|
47
|
+
/** Static-method-style namespace on the `UCPSigningKey` interface.
|
|
48
|
+
* Use as `UCPSigningKey.fromJWK(jwk)`. */
|
|
50
49
|
declare const UCPSigningKey: {
|
|
51
50
|
fromJWK: typeof ucpSigningKeyFromJWKImpl;
|
|
52
51
|
};
|
|
@@ -175,7 +174,7 @@ interface BuildUCPProfileInput {
|
|
|
175
174
|
* attestation lives on the AP2 risk-signal endpoint, not here. */
|
|
176
175
|
agentscore_gate?: AgentScoreGatePolicy;
|
|
177
176
|
/** Optional override for the AgentScore capability schema URL. Field is snake_cased
|
|
178
|
-
*
|
|
177
|
+
* to match the on-the-wire UCP profile shape. */
|
|
179
178
|
agentscore_schema_url?: string;
|
|
180
179
|
/** Optional override for the AgentScore capability spec URL. */
|
|
181
180
|
agentscore_spec_url?: string;
|
|
@@ -435,9 +434,7 @@ declare function pricingResult(opts: {
|
|
|
435
434
|
* Per-route discovery-probe config. When passed to {@link Checkout}, any
|
|
436
435
|
* empty-body POST without a payment credential short-circuits with a sample
|
|
437
436
|
* 402 advertising the merchant's payment shape — the canonical pattern x402
|
|
438
|
-
* crawlers
|
|
439
|
-
*
|
|
440
|
-
* Mirrors python's `DiscoveryProbeConfig` dataclass.
|
|
437
|
+
* crawlers rely on.
|
|
441
438
|
*/
|
|
442
439
|
interface DiscoveryProbeConfig {
|
|
443
440
|
realm: string;
|
|
@@ -572,9 +569,64 @@ interface CheckoutGateConfig {
|
|
|
572
569
|
* DenialReason. Return a `GateDenial` to override the canonical body, or
|
|
573
570
|
* null to use `denialReasonToBody`. */
|
|
574
571
|
onDenied?: (ctx: CheckoutContext, reason: DenialReason) => GateDenial | null | Promise<GateDenial | null>;
|
|
572
|
+
/** Accept AIP Agent Identity Tokens (AITs) on this route. When set and a request carries
|
|
573
|
+
* an `Agent-Identity` header, the gate verifies the token offline (issuer signature via the
|
|
574
|
+
* trusted-issuer JWKS + RFC 9421 proof-of-possession) BEFORE the assess call, then sends the
|
|
575
|
+
* raw token to `/v1/assess` as `aip_token` so the same wine/age/sanctions policy evaluates
|
|
576
|
+
* against the token's attested identity. A present-but-invalid AIT is a hard deny (the gate
|
|
577
|
+
* does NOT fall through to wallet / operator-token). Requests with no `Agent-Identity` header
|
|
578
|
+
* use the existing wallet / operator-token path unchanged.
|
|
579
|
+
*
|
|
580
|
+
* Ignored when `runGate` is also set (a custom gate fully owns the flow). Without an `apiKey`,
|
|
581
|
+
* a verified AIT is honored offline for identity-only gates, but a gate that declares policy
|
|
582
|
+
* fields (KYC / age / sanctions / jurisdiction) without an `apiKey` fails closed
|
|
583
|
+
* (`aip_policy_requires_api_key`) since policy can only be evaluated via `/v1/assess`. */
|
|
584
|
+
aip?: AipGateConfig;
|
|
575
585
|
/** Full escape hatch — replaces the SDK gate flow. */
|
|
576
586
|
runGate?: RunGateFn;
|
|
577
587
|
}
|
|
588
|
+
/** AIP acceptance config for {@link CheckoutGateConfig.aip}. */
|
|
589
|
+
interface AipGateConfig {
|
|
590
|
+
/** ADDITIONAL external issuers to trust beyond AgentScore's own (e.g. `['https://issuer.example']`),
|
|
591
|
+
* matched after canonicalization. AgentScore's canonical issuer
|
|
592
|
+
* ({@link AGENTSCORE_CANONICAL_ISSUER}) is ALWAYS trusted and never needs listing — this SDK
|
|
593
|
+
* is the AgentScore verifier, so a merchant can't accidentally fail to trust AgentScore AITs.
|
|
594
|
+
* Omit/empty to accept only AgentScore-issued AITs. */
|
|
595
|
+
trustedIssuers?: string[];
|
|
596
|
+
/** Clock-skew tolerance in seconds for the RFC 9421 signature window (and, as an override,
|
|
597
|
+
* the AIT JWT `exp`/`iat`). Defaults to 30s for the signature / 60s for the JWT. */
|
|
598
|
+
maxSkewSeconds?: number;
|
|
599
|
+
/** Expected `@authority` (public hostname) the RFC 9421 signature must cover. When set, the
|
|
600
|
+
* verifier binds the signature to this value instead of trusting the inbound `Host` header —
|
|
601
|
+
* pin it to your real public host (e.g. `'wine.example.com'`) when behind a proxy that does
|
|
602
|
+
* not normalize `Host`, to prevent a captured AIT+signature from being replayed to a
|
|
603
|
+
* different virtual host on the same origin. */
|
|
604
|
+
authority?: string;
|
|
605
|
+
/** Per-issuer compliance policy override, keyed by issuer URL (canonicalized before lookup).
|
|
606
|
+
* When a request's AIT is verified and its `iss` matches a key here, that block REPLACES the
|
|
607
|
+
* gate's default policy fields (`requireKyc` / `requireSanctionsClear` / `minAge` /
|
|
608
|
+
* `allowed/blockedJurisdictions`) for that request — letting a merchant apply different rules
|
|
609
|
+
* by issuer (e.g. full compliance for its own AITs, a relaxed set for a partner issuer whose
|
|
610
|
+
* tokens carry fewer attested claims). The replacement is whole-policy, not a merge: an issuer
|
|
611
|
+
* block of `{ requireKyc: true, minAge: 21 }` evaluates ONLY those two rules for that issuer
|
|
612
|
+
* (sanctions / jurisdiction omitted → not enforced for that issuer). Issuers NOT listed here
|
|
613
|
+
* use the gate's default policy unchanged. Only the AIT path consults this — wallet /
|
|
614
|
+
* operator-token requests are unaffected.
|
|
615
|
+
*
|
|
616
|
+
* This is a deliberate compliance posture per issuer, not a default; an empty/absent map keeps
|
|
617
|
+
* every issuer on the gate's default policy. */
|
|
618
|
+
issuerPolicies?: Record<string, AipIssuerPolicy>;
|
|
619
|
+
}
|
|
620
|
+
/** A per-issuer compliance policy block for {@link AipGateConfig.issuerPolicies}. The same
|
|
621
|
+
* compliance fields as the gate, applied (as a whole-policy replacement) only to AITs from the
|
|
622
|
+
* matching issuer. */
|
|
623
|
+
interface AipIssuerPolicy {
|
|
624
|
+
requireKyc?: boolean;
|
|
625
|
+
requireSanctionsClear?: boolean;
|
|
626
|
+
minAge?: number;
|
|
627
|
+
blockedJurisdictions?: string[];
|
|
628
|
+
allowedJurisdictions?: string[];
|
|
629
|
+
}
|
|
578
630
|
/** Surface passed to `Checkout.onSettled` after a payment lands. */
|
|
579
631
|
interface SettleOutcome {
|
|
580
632
|
/** Protocol family that handled the settle. */
|
|
@@ -666,6 +718,18 @@ type IsCachedAddressFn = (address: string) => boolean | Promise<boolean>;
|
|
|
666
718
|
declare function makeMppxComposeHook(opts: {
|
|
667
719
|
serverGetter: () => Promise<unknown>;
|
|
668
720
|
}): ComposeMppxFn;
|
|
721
|
+
/** Resolve a per-issuer compliance-policy override for a verified AIT's issuer. Both the verified
|
|
722
|
+
* `iss` and the map keys are canonicalized (lowercase scheme+host, no default port / trailing
|
|
723
|
+
* slash) before comparison so `https://issuer.example` and `https://issuer.example/` resolve the same.
|
|
724
|
+
* Returns the matching policy block, or undefined when the issuer is not overridden (→ caller
|
|
725
|
+
* falls back to the gate's default policy). */
|
|
726
|
+
/** The effective AIP trusted-issuer list: AgentScore's canonical issuer (ALWAYS trusted) plus any
|
|
727
|
+
* external issuers. De-duped after canonicalization. Use this for the `agent_memory` hint and any
|
|
728
|
+
* presentation surface (llms.txt / mpp.json / skill.md) that advertises AIP acceptance, so a
|
|
729
|
+
* merchant relying solely on AgentScore AITs (no external issuers) still advertises the
|
|
730
|
+
* `agent_identity` path. Trust enforcement itself lives in {@link JwksCache}, which merges the
|
|
731
|
+
* canonical issuer independently. */
|
|
732
|
+
declare function buildAipTrustedIssuers(externalIssuers?: string[]): string[];
|
|
669
733
|
/**
|
|
670
734
|
* Framework-neutral 4xx envelope (`{ error, next_steps, agent_instructions }`).
|
|
671
735
|
*
|
|
@@ -741,6 +805,10 @@ declare class Checkout {
|
|
|
741
805
|
readonly discoveryExtensions: Record<string, unknown> | undefined;
|
|
742
806
|
readonly discoveryProbe: DiscoveryProbeConfig | undefined;
|
|
743
807
|
private _x402ServerGetter;
|
|
808
|
+
/** Lazily-built JWKS cache for AIP verification, shared across requests so issuer keys
|
|
809
|
+
* are fetched once and cached (per the verifier's hard 24h cap). Built on first AIT. */
|
|
810
|
+
private aipJwks;
|
|
811
|
+
private getAipJwks;
|
|
744
812
|
/**
|
|
745
813
|
* True when the merchant has configured an identity-bearing policy flag —
|
|
746
814
|
* `require_kyc`, `require_sanctions_clear` (name screening on the KYC
|
|
@@ -958,4 +1026,4 @@ interface MountUcpRoutesOptions {
|
|
|
958
1026
|
jwksPath?: string;
|
|
959
1027
|
}
|
|
960
1028
|
|
|
961
|
-
export { AGENTSCORE_UCP_CAPABILITY as A,
|
|
1029
|
+
export { AGENTSCORE_UCP_CAPABILITY as A, validationResponseFastify as B, Checkout as C, type DiscoveryProbeConfig as D, validationResponseHono as E, validationResponseNextjs as F, type GateDenial as G, validationResponseWeb as H, type IsCachedAddressFn as I, x402PaymentHandler as J, type MountUcpRoutesOptions as M, type OnSettledFn as O, type PreValidateFn as P, type RecipientsFn as R, type SettleOutcome as S, type UCPCapabilityBinding as U, type AgentScoreGatePolicy as a, type CheckoutContext as b, type CheckoutGateConfig as c, type CheckoutRailSpec as d, type CheckoutRequest as e, type CheckoutResult as f, type ComposeMppxFn as g, type MppxComposeOutcome as h, type PricingFn as i, type PricingResult as j, type ReferenceIdFn as k, type RunGateFn as l, type UCPPaymentHandlerBinding as m, type UCPProfile as n, type UCPProfileBody as o, type UCPServiceBinding as p, UCPSigningKey as q, buildAipTrustedIssuers as r, buildUCPProfile as s, getIdentityStatus as t, makeMppxComposeHook as u, mppPaymentHandler as v, pricingResult as w, stripeSptPaymentHandler as x, validationEnvelope as y, validationResponseExpress as z };
|
package/dist/core.d.mts
CHANGED
|
@@ -3,6 +3,10 @@ import { P as PaymentSigner } from './signer-3FAit11j.mjs';
|
|
|
3
3
|
interface AgentIdentity {
|
|
4
4
|
address?: string;
|
|
5
5
|
operatorToken?: string;
|
|
6
|
+
/** Raw AIP Agent Identity Token (a JWT). When set, the gate has already verified the
|
|
7
|
+
* token's RFC 9421 proof-of-possession at the edge; `evaluate` sends it to `/v1/assess`
|
|
8
|
+
* as `aip_token` for server-side IdP-signature re-verification + policy enrichment. */
|
|
9
|
+
aipToken?: string;
|
|
6
10
|
}
|
|
7
11
|
/**
|
|
8
12
|
* Session metadata returned from `POST /v1/sessions`. Surfaced to the `onBeforeSession`
|
|
@@ -74,6 +78,11 @@ interface AgentScoreCoreOptions {
|
|
|
74
78
|
userAgent?: string;
|
|
75
79
|
/** When set and no identity is found, create a verification session instead of denying immediately. */
|
|
76
80
|
createSessionOnMissing?: CreateSessionOnMissing;
|
|
81
|
+
/** Issuers whose AIP Agent Identity Tokens this gate accepts. When set, the missing-identity
|
|
82
|
+
* recovery instructions and the `agent_memory` hint advertise the AIT path so agents holding
|
|
83
|
+
* one can present it. Set by Checkout from `gate.aip.trustedIssuers`; the actual AIT
|
|
84
|
+
* verification happens at the edge (Checkout) before `evaluate`. */
|
|
85
|
+
aipTrustedIssuers?: string[];
|
|
77
86
|
}
|
|
78
87
|
type DenialCode = 'wallet_not_trusted' | 'missing_identity' | 'api_error' | 'payment_required' | 'identity_verification_required' | 'wallet_signer_mismatch' | 'wallet_auth_requires_wallet_signing' | 'token_expired' | 'invalid_credential';
|
|
79
88
|
/**
|
|
@@ -90,7 +99,12 @@ interface AgentMemoryHint {
|
|
|
90
99
|
identity_paths: {
|
|
91
100
|
wallet: string;
|
|
92
101
|
operator_token: string;
|
|
102
|
+
agent_identity?: string;
|
|
93
103
|
};
|
|
104
|
+
/** Issuers whose AIP Agent Identity Tokens this merchant accepts. Present only when the
|
|
105
|
+
* merchant opted into AIP; an agent holding an AIT from one of these can present it via an
|
|
106
|
+
* `Agent-Identity` header + RFC 9421 signature instead of bootstrapping a fresh credential. */
|
|
107
|
+
aip_trusted_issuers?: string[];
|
|
94
108
|
bootstrap: string;
|
|
95
109
|
do_not_persist_in_memory: string[];
|
|
96
110
|
persist_in_credential_store: string[];
|
|
@@ -129,16 +143,14 @@ interface DenialReason {
|
|
|
129
143
|
/** Wallets the claimed operator could sign with (if enumerable). Present when non-empty. */
|
|
130
144
|
linked_wallets?: string[];
|
|
131
145
|
}
|
|
132
|
-
/** Operator verification details from the assess response.
|
|
133
|
-
* `OperatorVerification` dataclass. */
|
|
146
|
+
/** Operator verification details from the assess response. */
|
|
134
147
|
interface OperatorVerification {
|
|
135
148
|
level: string;
|
|
136
149
|
operator_type: string | null;
|
|
137
150
|
verified_at: string | null;
|
|
138
151
|
}
|
|
139
152
|
/** Account-level KYC facts that apply to every operator under the same account.
|
|
140
|
-
* Populated when the API returns account_verification (post-KYC operator).
|
|
141
|
-
* Mirrors python's account_verification dict shape. */
|
|
153
|
+
* Populated when the API returns account_verification (post-KYC operator). */
|
|
142
154
|
interface AccountVerification {
|
|
143
155
|
kyc_level?: string;
|
|
144
156
|
sanctions_clear?: boolean;
|
|
@@ -146,14 +158,14 @@ interface AccountVerification {
|
|
|
146
158
|
jurisdiction?: string;
|
|
147
159
|
verified_at?: string | null;
|
|
148
160
|
}
|
|
149
|
-
/** A single policy check from the assess response.
|
|
161
|
+
/** A single policy check from the assess response. */
|
|
150
162
|
interface PolicyCheck {
|
|
151
163
|
rule: string;
|
|
152
164
|
passed: boolean;
|
|
153
165
|
required?: unknown;
|
|
154
166
|
actual?: unknown;
|
|
155
167
|
}
|
|
156
|
-
/** Policy evaluation result from the assess response.
|
|
168
|
+
/** Policy evaluation result from the assess response. */
|
|
157
169
|
interface PolicyResult {
|
|
158
170
|
all_passed: boolean;
|
|
159
171
|
checks: PolicyCheck[];
|
|
@@ -171,6 +183,14 @@ interface AssessResult {
|
|
|
171
183
|
linked_wallets?: string[];
|
|
172
184
|
verify_url?: string;
|
|
173
185
|
policy_result?: PolicyResult | null;
|
|
186
|
+
/** IdP provenance, present only when `identity_method === 'aip_token'` — which issuer attested
|
|
187
|
+
* the identity and the trust level it asserted. Mirrors the SDK's `AssessResponse.aip`. */
|
|
188
|
+
aip?: {
|
|
189
|
+
issuer: string;
|
|
190
|
+
subject: string;
|
|
191
|
+
trust_level?: 'autonomous' | 'human_present' | 'human_confirmed';
|
|
192
|
+
agent_provider?: string;
|
|
193
|
+
};
|
|
174
194
|
}
|
|
175
195
|
/**
|
|
176
196
|
* Reason a failOpen allow short-circuited an evaluate call due to AgentScore-side
|
|
@@ -291,7 +311,7 @@ interface AgentScoreCore {
|
|
|
291
311
|
* swallows non-fatal errors because capture is informational, not on the critical path. */
|
|
292
312
|
captureWallet(options: CaptureWalletOptions): Promise<void>;
|
|
293
313
|
}
|
|
294
|
-
declare function buildAgentMemoryHint(): AgentMemoryHint;
|
|
314
|
+
declare function buildAgentMemoryHint(aipTrustedIssuers?: string[]): AgentMemoryHint;
|
|
295
315
|
declare function createAgentScoreCore(options: AgentScoreCoreOptions): AgentScoreCore;
|
|
296
316
|
|
|
297
317
|
export { type AccountVerification, type AgentIdentity, type AgentMemoryHint, type AgentScoreCore, type AgentScoreCoreOptions, type AssessResult, type CreateSessionOnMissing, type DenialCode, type DenialReason, type EvaluateOutcome, type FailOpenInfraReason, type GateQuotaInfo, type OperatorVerification, type PolicyCheck, type PolicyResult, type SessionMetadata, type SignerVerdict, type VerifyWalletSignerResult, buildAgentMemoryHint, createAgentScoreCore };
|
package/dist/core.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { P as PaymentSigner } from './signer-3FAit11j.js';
|
|
|
3
3
|
interface AgentIdentity {
|
|
4
4
|
address?: string;
|
|
5
5
|
operatorToken?: string;
|
|
6
|
+
/** Raw AIP Agent Identity Token (a JWT). When set, the gate has already verified the
|
|
7
|
+
* token's RFC 9421 proof-of-possession at the edge; `evaluate` sends it to `/v1/assess`
|
|
8
|
+
* as `aip_token` for server-side IdP-signature re-verification + policy enrichment. */
|
|
9
|
+
aipToken?: string;
|
|
6
10
|
}
|
|
7
11
|
/**
|
|
8
12
|
* Session metadata returned from `POST /v1/sessions`. Surfaced to the `onBeforeSession`
|
|
@@ -74,6 +78,11 @@ interface AgentScoreCoreOptions {
|
|
|
74
78
|
userAgent?: string;
|
|
75
79
|
/** When set and no identity is found, create a verification session instead of denying immediately. */
|
|
76
80
|
createSessionOnMissing?: CreateSessionOnMissing;
|
|
81
|
+
/** Issuers whose AIP Agent Identity Tokens this gate accepts. When set, the missing-identity
|
|
82
|
+
* recovery instructions and the `agent_memory` hint advertise the AIT path so agents holding
|
|
83
|
+
* one can present it. Set by Checkout from `gate.aip.trustedIssuers`; the actual AIT
|
|
84
|
+
* verification happens at the edge (Checkout) before `evaluate`. */
|
|
85
|
+
aipTrustedIssuers?: string[];
|
|
77
86
|
}
|
|
78
87
|
type DenialCode = 'wallet_not_trusted' | 'missing_identity' | 'api_error' | 'payment_required' | 'identity_verification_required' | 'wallet_signer_mismatch' | 'wallet_auth_requires_wallet_signing' | 'token_expired' | 'invalid_credential';
|
|
79
88
|
/**
|
|
@@ -90,7 +99,12 @@ interface AgentMemoryHint {
|
|
|
90
99
|
identity_paths: {
|
|
91
100
|
wallet: string;
|
|
92
101
|
operator_token: string;
|
|
102
|
+
agent_identity?: string;
|
|
93
103
|
};
|
|
104
|
+
/** Issuers whose AIP Agent Identity Tokens this merchant accepts. Present only when the
|
|
105
|
+
* merchant opted into AIP; an agent holding an AIT from one of these can present it via an
|
|
106
|
+
* `Agent-Identity` header + RFC 9421 signature instead of bootstrapping a fresh credential. */
|
|
107
|
+
aip_trusted_issuers?: string[];
|
|
94
108
|
bootstrap: string;
|
|
95
109
|
do_not_persist_in_memory: string[];
|
|
96
110
|
persist_in_credential_store: string[];
|
|
@@ -129,16 +143,14 @@ interface DenialReason {
|
|
|
129
143
|
/** Wallets the claimed operator could sign with (if enumerable). Present when non-empty. */
|
|
130
144
|
linked_wallets?: string[];
|
|
131
145
|
}
|
|
132
|
-
/** Operator verification details from the assess response.
|
|
133
|
-
* `OperatorVerification` dataclass. */
|
|
146
|
+
/** Operator verification details from the assess response. */
|
|
134
147
|
interface OperatorVerification {
|
|
135
148
|
level: string;
|
|
136
149
|
operator_type: string | null;
|
|
137
150
|
verified_at: string | null;
|
|
138
151
|
}
|
|
139
152
|
/** Account-level KYC facts that apply to every operator under the same account.
|
|
140
|
-
* Populated when the API returns account_verification (post-KYC operator).
|
|
141
|
-
* Mirrors python's account_verification dict shape. */
|
|
153
|
+
* Populated when the API returns account_verification (post-KYC operator). */
|
|
142
154
|
interface AccountVerification {
|
|
143
155
|
kyc_level?: string;
|
|
144
156
|
sanctions_clear?: boolean;
|
|
@@ -146,14 +158,14 @@ interface AccountVerification {
|
|
|
146
158
|
jurisdiction?: string;
|
|
147
159
|
verified_at?: string | null;
|
|
148
160
|
}
|
|
149
|
-
/** A single policy check from the assess response.
|
|
161
|
+
/** A single policy check from the assess response. */
|
|
150
162
|
interface PolicyCheck {
|
|
151
163
|
rule: string;
|
|
152
164
|
passed: boolean;
|
|
153
165
|
required?: unknown;
|
|
154
166
|
actual?: unknown;
|
|
155
167
|
}
|
|
156
|
-
/** Policy evaluation result from the assess response.
|
|
168
|
+
/** Policy evaluation result from the assess response. */
|
|
157
169
|
interface PolicyResult {
|
|
158
170
|
all_passed: boolean;
|
|
159
171
|
checks: PolicyCheck[];
|
|
@@ -171,6 +183,14 @@ interface AssessResult {
|
|
|
171
183
|
linked_wallets?: string[];
|
|
172
184
|
verify_url?: string;
|
|
173
185
|
policy_result?: PolicyResult | null;
|
|
186
|
+
/** IdP provenance, present only when `identity_method === 'aip_token'` — which issuer attested
|
|
187
|
+
* the identity and the trust level it asserted. Mirrors the SDK's `AssessResponse.aip`. */
|
|
188
|
+
aip?: {
|
|
189
|
+
issuer: string;
|
|
190
|
+
subject: string;
|
|
191
|
+
trust_level?: 'autonomous' | 'human_present' | 'human_confirmed';
|
|
192
|
+
agent_provider?: string;
|
|
193
|
+
};
|
|
174
194
|
}
|
|
175
195
|
/**
|
|
176
196
|
* Reason a failOpen allow short-circuited an evaluate call due to AgentScore-side
|
|
@@ -291,7 +311,7 @@ interface AgentScoreCore {
|
|
|
291
311
|
* swallows non-fatal errors because capture is informational, not on the critical path. */
|
|
292
312
|
captureWallet(options: CaptureWalletOptions): Promise<void>;
|
|
293
313
|
}
|
|
294
|
-
declare function buildAgentMemoryHint(): AgentMemoryHint;
|
|
314
|
+
declare function buildAgentMemoryHint(aipTrustedIssuers?: string[]): AgentMemoryHint;
|
|
295
315
|
declare function createAgentScoreCore(options: AgentScoreCoreOptions): AgentScoreCore;
|
|
296
316
|
|
|
297
317
|
export { type AccountVerification, type AgentIdentity, type AgentMemoryHint, type AgentScoreCore, type AgentScoreCoreOptions, type AssessResult, type CreateSessionOnMissing, type DenialCode, type DenialReason, type EvaluateOutcome, type FailOpenInfraReason, type GateQuotaInfo, type OperatorVerification, type PolicyCheck, type PolicyResult, type SessionMetadata, type SignerVerdict, type VerifyWalletSignerResult, buildAgentMemoryHint, createAgentScoreCore };
|
package/dist/core.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(core_exports, {
|
|
|
24
24
|
createAgentScoreCore: () => createAgentScoreCore
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(core_exports);
|
|
27
|
+
var import_node_crypto = require("crypto");
|
|
27
28
|
var import_sdk = require("@agent-score/sdk");
|
|
28
29
|
|
|
29
30
|
// src/_denial.ts
|
|
@@ -184,8 +185,9 @@ var INVALID_CREDENTIAL_INSTRUCTIONS = JSON.stringify({
|
|
|
184
185
|
],
|
|
185
186
|
user_message: "The operator_token is not recognized. Use a different stored token, or restart the verification session flow to mint a new one."
|
|
186
187
|
});
|
|
187
|
-
function buildAgentMemoryHint() {
|
|
188
|
+
function buildAgentMemoryHint(aipTrustedIssuers) {
|
|
188
189
|
const api = CANONICAL_AGENTSCORE_API;
|
|
190
|
+
const acceptsAip = aipTrustedIssuers !== void 0 && aipTrustedIssuers.length > 0;
|
|
189
191
|
return {
|
|
190
192
|
save_for_future_agentscore_gates: true,
|
|
191
193
|
pattern_summary: "AgentScore is a cross-merchant identity substrate for agent commerce. Any endpoint that returns 403 missing_identity / identity_verification_required or 402 challenges referencing AgentScore uses the same identity system. One KYC works across all AgentScore merchants \u2014 no re-verification per site. Save this pattern (and the endpoints below) to persistent memory so future AgentScore encounters skip the cold-start session flow.",
|
|
@@ -193,8 +195,12 @@ function buildAgentMemoryHint() {
|
|
|
193
195
|
identity_check_endpoint: `${api}/v1/credentials`,
|
|
194
196
|
identity_paths: {
|
|
195
197
|
wallet: "If paying from a crypto wallet you have used before on any AgentScore merchant, send `X-Wallet-Address: 0x...`. Shortest path; no token lifecycle to manage.",
|
|
196
|
-
operator_token: "For any rail (Stripe SPT, card, or a wallet you have not linked yet), send `X-Operator-Token: opc_...`. Reusable across merchants until the token expires."
|
|
198
|
+
operator_token: "For any rail (Stripe SPT, card, or a wallet you have not linked yet), send `X-Operator-Token: opc_...`. Reusable across merchants until the token expires.",
|
|
199
|
+
...acceptsAip && {
|
|
200
|
+
agent_identity: 'If you hold an AIP Agent Identity Token from a trusted issuer (see aip_trusted_issuers), present it: send the JWT in an `Agent-Identity` header plus an RFC 9421 HTTP Message Signature (Signature-Input + Signature over @method @authority @path agent-identity, tag="agent-identity") signed with the token-bound cnf key. The merchant verifies it and applies its policy \u2014 no separate AgentScore credential needed.'
|
|
201
|
+
}
|
|
197
202
|
},
|
|
203
|
+
...acceptsAip && { aip_trusted_issuers: aipTrustedIssuers },
|
|
198
204
|
bootstrap: "If you have neither a linked wallet nor a valid operator_token, follow the session/verify flow in the per-request `agent_instructions` block. This happens at most once per agent identity \u2014 after first verification, the operator_token and any subsequently used wallet are reusable everywhere.",
|
|
199
205
|
do_not_persist_in_memory: ["operator_token", "poll_secret"],
|
|
200
206
|
persist_in_credential_store: ["operator_token"]
|
|
@@ -216,11 +222,12 @@ function createAgentScoreCore(options) {
|
|
|
216
222
|
baseUrl: rawBaseUrl = "https://api.agentscore.sh",
|
|
217
223
|
chain: gateChain,
|
|
218
224
|
userAgent,
|
|
219
|
-
createSessionOnMissing
|
|
225
|
+
createSessionOnMissing,
|
|
226
|
+
aipTrustedIssuers
|
|
220
227
|
} = options;
|
|
221
228
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
222
|
-
const agentMemoryHint = buildAgentMemoryHint();
|
|
223
|
-
const defaultUa = `@agent-score/commerce@${"2.
|
|
229
|
+
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
230
|
+
const defaultUa = `@agent-score/commerce@${"2.5.0"}`;
|
|
224
231
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
225
232
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
226
233
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -238,6 +245,7 @@ function createAgentScoreCore(options) {
|
|
|
238
245
|
return s;
|
|
239
246
|
}
|
|
240
247
|
const cache = new TTLCache(cacheSeconds * 1e3);
|
|
248
|
+
const lastSignerRaw = /* @__PURE__ */ new Map();
|
|
241
249
|
async function tryMintSessionDenial(ctx) {
|
|
242
250
|
if (!createSessionOnMissing) return void 0;
|
|
243
251
|
try {
|
|
@@ -295,13 +303,18 @@ function createAgentScoreCore(options) {
|
|
|
295
303
|
}
|
|
296
304
|
}
|
|
297
305
|
async function evaluate(identity, ctx, signer) {
|
|
298
|
-
if (!identity || !identity.address && !identity.operatorToken) {
|
|
306
|
+
if (!identity || !identity.address?.trim() && !identity.operatorToken?.trim() && !identity.aipToken?.trim()) {
|
|
299
307
|
if (failOpen) return { kind: "allow" };
|
|
300
308
|
const sessionReason = await tryMintSessionDenial(ctx);
|
|
301
309
|
if (sessionReason) return { kind: "deny", reason: sessionReason };
|
|
310
|
+
const acceptsAip = aipTrustedIssuers !== void 0 && aipTrustedIssuers.length > 0;
|
|
311
|
+
const aipStep = acceptsAip ? [
|
|
312
|
+
`If you hold an AIP Agent Identity Token from a trusted issuer (${aipTrustedIssuers.join(", ")}): present it \u2014 send the JWT in an Agent-Identity header plus an RFC 9421 HTTP Message Signature (Signature-Input + Signature over @method @authority @path agent-identity, tag="agent-identity") signed with the token-bound cnf key. This satisfies identity in one round trip without an AgentScore credential.`
|
|
313
|
+
] : [];
|
|
302
314
|
const missingIdentityInstructions = JSON.stringify({
|
|
303
315
|
action: "probe_identity_then_session",
|
|
304
316
|
steps: [
|
|
317
|
+
...aipStep,
|
|
305
318
|
"If you have a wallet AND this merchant accepts a wallet-signing rail (Tempo MPP or x402 \u2014 see openapi.json x-payment-info): send X-Wallet-Address and retry. If the wallet is already linked to an AgentScore operator (via prior SIWE claim or prior captureWallet), this passes in one round trip. If the wallet is unlinked or the account has no KYC, the 403 will include a verify_url \u2014 share it with the user to claim the wallet + complete KYC, then retry.",
|
|
306
319
|
"If step 1 is denied or you already have a stored operator_token (valid + not expired): send X-Operator-Token: opc_... and retry.",
|
|
307
320
|
"If neither applies: retry with NO identity header. Merchants that auto-create verification sessions (most AgentScore merchants do) return verify_url + session_id + poll_secret in the 403 body \u2014 share verify_url with the user, then poll poll_url every 5s with the X-Poll-Secret header until status=verified (the poll returns a one-time operator_token). If the retry returns the same bare 403, this merchant does not support self-service session bootstrapping \u2014 direct the user to https://agentscore.sh/sign-up to create an AgentScore identity and mint an operator_token from their dashboard (https://agentscore.sh/dashboard/verify). The user hands the opc_... to you, and you retry with X-Operator-Token."
|
|
@@ -317,7 +330,7 @@ function createAgentScoreCore(options) {
|
|
|
317
330
|
}
|
|
318
331
|
};
|
|
319
332
|
}
|
|
320
|
-
const cacheKey = identity.operatorToken?.toLowerCase() ?? (identity.address ? normalizeAddress(identity.address) : "");
|
|
333
|
+
const cacheKey = identity.aipToken ? `aip:${(0, import_node_crypto.createHash)("sha256").update(identity.aipToken).digest("hex")}` : identity.operatorToken?.toLowerCase() ?? (identity.address ? normalizeAddress(identity.address) : "");
|
|
321
334
|
const cached = cache.get(cacheKey);
|
|
322
335
|
if (cached) {
|
|
323
336
|
if (cached.allow) {
|
|
@@ -362,7 +375,7 @@ function createAgentScoreCore(options) {
|
|
|
362
375
|
// regardless of policy.require_sanctions_clear (which gates the separate NAME screen).
|
|
363
376
|
...signer && { signer: { address: signer.address, network: signer.network } }
|
|
364
377
|
};
|
|
365
|
-
const result = identity.address ? await sdk.assess(identity.address, { ...opts, operatorToken: identity.operatorToken }) : await sdk.assess(null, { ...opts, operatorToken: identity.operatorToken });
|
|
378
|
+
const result = identity.aipToken ? await sdk.assess(null, { ...opts, aipToken: identity.aipToken }) : identity.address ? await sdk.assess(identity.address, { ...opts, operatorToken: identity.operatorToken }) : await sdk.assess(null, { ...opts, operatorToken: identity.operatorToken });
|
|
366
379
|
data = result;
|
|
367
380
|
} catch (err) {
|
|
368
381
|
if (err instanceof import_sdk.PaymentRequiredError) {
|
|
@@ -433,6 +446,9 @@ function createAgentScoreCore(options) {
|
|
|
433
446
|
const decisionReasons = data.decision_reasons ?? [];
|
|
434
447
|
const allow = decision === "allow" || decision == null;
|
|
435
448
|
cache.set(cacheKey, { allow, decision: decision ?? void 0, reasons: decisionReasons, raw: data });
|
|
449
|
+
if (identity.address !== void 0 && identity.operatorToken === void 0 && identity.aipToken === void 0 && (data.signer_match !== void 0 || data.signer_sanctions !== void 0)) {
|
|
450
|
+
lastSignerRaw.set(normalizeAddress(identity.address), data);
|
|
451
|
+
}
|
|
436
452
|
if (allow) {
|
|
437
453
|
const quota = data.quota;
|
|
438
454
|
return {
|
|
@@ -497,9 +513,7 @@ function createAgentScoreCore(options) {
|
|
|
497
513
|
}
|
|
498
514
|
function getSignerVerdict(claimedAddress) {
|
|
499
515
|
const claimedNorm = normalizeAddress(claimedAddress);
|
|
500
|
-
const
|
|
501
|
-
if (!cached) return void 0;
|
|
502
|
-
const raw = cached.raw;
|
|
516
|
+
const raw = lastSignerRaw.get(claimedNorm) ?? cache.get(claimedNorm)?.raw;
|
|
503
517
|
if (!raw) return void 0;
|
|
504
518
|
const rawMatch = raw.signer_match;
|
|
505
519
|
const rawSanctions = raw.signer_sanctions;
|