@agent-score/commerce 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +19 -17
  2. package/dist/challenge/index.d.mts +31 -3
  3. package/dist/challenge/index.d.ts +31 -3
  4. package/dist/challenge/index.js +25 -9
  5. package/dist/challenge/index.js.map +1 -1
  6. package/dist/challenge/index.mjs +25 -9
  7. package/dist/challenge/index.mjs.map +1 -1
  8. package/dist/{checkout-B-MIzYzW.d.ts → checkout-C4RD7M0Z.d.ts} +117 -13
  9. package/dist/{checkout-Bn7ZKIBD.d.mts → checkout-CzB9f_jf.d.mts} +117 -13
  10. package/dist/core.d.mts +40 -7
  11. package/dist/core.d.ts +40 -7
  12. package/dist/core.js +52 -27
  13. package/dist/core.js.map +1 -1
  14. package/dist/core.mjs +52 -27
  15. package/dist/core.mjs.map +1 -1
  16. package/dist/discovery/index.d.mts +33 -3
  17. package/dist/discovery/index.d.ts +33 -3
  18. package/dist/discovery/index.js +50 -16
  19. package/dist/discovery/index.js.map +1 -1
  20. package/dist/discovery/index.mjs +49 -16
  21. package/dist/discovery/index.mjs.map +1 -1
  22. package/dist/gate-D2RP6bZg.d.ts +307 -0
  23. package/dist/gate-GCXy4FHI.d.mts +307 -0
  24. package/dist/identity/express.d.mts +28 -1
  25. package/dist/identity/express.d.ts +28 -1
  26. package/dist/identity/express.js +714 -31
  27. package/dist/identity/express.js.map +1 -1
  28. package/dist/identity/express.mjs +710 -30
  29. package/dist/identity/express.mjs.map +1 -1
  30. package/dist/identity/fastify.d.mts +14 -2
  31. package/dist/identity/fastify.d.ts +14 -2
  32. package/dist/identity/fastify.js +727 -31
  33. package/dist/identity/fastify.js.map +1 -1
  34. package/dist/identity/fastify.mjs +723 -30
  35. package/dist/identity/fastify.mjs.map +1 -1
  36. package/dist/identity/hono.d.mts +28 -1
  37. package/dist/identity/hono.d.ts +28 -1
  38. package/dist/identity/hono.js +696 -33
  39. package/dist/identity/hono.js.map +1 -1
  40. package/dist/identity/hono.mjs +692 -32
  41. package/dist/identity/hono.mjs.map +1 -1
  42. package/dist/identity/nextjs.d.mts +5 -0
  43. package/dist/identity/nextjs.d.ts +5 -0
  44. package/dist/identity/nextjs.js +695 -30
  45. package/dist/identity/nextjs.js.map +1 -1
  46. package/dist/identity/nextjs.mjs +691 -29
  47. package/dist/identity/nextjs.mjs.map +1 -1
  48. package/dist/identity/policy.d.mts +21 -2
  49. package/dist/identity/policy.d.ts +21 -2
  50. package/dist/identity/policy.js +22 -1
  51. package/dist/identity/policy.js.map +1 -1
  52. package/dist/identity/policy.mjs +21 -1
  53. package/dist/identity/policy.mjs.map +1 -1
  54. package/dist/identity/web.d.mts +26 -1
  55. package/dist/identity/web.d.ts +26 -1
  56. package/dist/identity/web.js +695 -30
  57. package/dist/identity/web.js.map +1 -1
  58. package/dist/identity/web.mjs +691 -29
  59. package/dist/identity/web.mjs.map +1 -1
  60. package/dist/index.d.mts +165 -4
  61. package/dist/index.d.ts +165 -4
  62. package/dist/index.js +3103 -534
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +3086 -545
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/payment/index.d.mts +1 -1
  67. package/dist/payment/index.d.ts +1 -1
  68. package/dist/payment/index.js +10 -2
  69. package/dist/payment/index.js.map +1 -1
  70. package/dist/payment/index.mjs +10 -2
  71. package/dist/payment/index.mjs.map +1 -1
  72. package/dist/stripe-multichain/index.js +1614 -266
  73. package/dist/stripe-multichain/index.js.map +1 -1
  74. package/dist/stripe-multichain/index.mjs +1614 -266
  75. package/dist/stripe-multichain/index.mjs.map +1 -1
  76. package/dist/types-D1slMt0H.d.mts +137 -0
  77. package/dist/types-D1slMt0H.d.ts +137 -0
  78. package/dist/{wwwauthenticate-CVaGUMjU.d.mts → wwwauthenticate-Dgm-_af9.d.mts} +11 -1
  79. package/dist/{wwwauthenticate-CVaGUMjU.d.ts → wwwauthenticate-Dgm-_af9.d.ts} +11 -1
  80. package/package.json +26 -21
package/dist/index.d.mts CHANGED
@@ -1,14 +1,19 @@
1
1
  import { VerifyWalletSignerResult, DenialReason } from './core.mjs';
2
2
  export { AccountVerification, AgentIdentity, AgentMemoryHint, AgentScoreCore, AssessResult, CreateSessionOnMissing, DenialCode, EvaluateOutcome, OperatorVerification, PolicyCheck, PolicyResult, SignerVerdict, buildAgentMemoryHint } from './core.mjs';
3
3
  export { P as PaymentSigner, S as SignerNetwork, e as extractPaymentSigner, a as extractPaymentSignerFromAuth, b as extractSignerForPrecheck, r as readX402PaymentHeader } from './signer-3FAit11j.mjs';
4
- import { q as UCPSigningKey, n as UCPProfile } from './checkout-Bn7ZKIBD.mjs';
5
- export { A as AGENTSCORE_UCP_CAPABILITY, a as AgentScoreGatePolicy, C as Checkout, b as CheckoutContext, c as CheckoutGateConfig, d as CheckoutRailSpec, e as CheckoutRequest, f as CheckoutResult, g as ComposeMppxFn, D as DiscoveryProbeConfig, G as GateDenial, I as IsCachedAddressFn, M as MountUcpRoutesOptions, h as MppxComposeOutcome, O as OnSettledFn, P as PreValidateFn, i as PricingFn, j as PricingResult, R as RecipientsFn, k as ReferenceIdFn, l as RunGateFn, S as SettleOutcome, U as UCPCapabilityBinding, m as UCPPaymentHandlerBinding, o as UCPProfileBody, p as UCPServiceBinding, r as buildUCPProfile, s as getIdentityStatus, t as makeMppxComposeHook, u as mppPaymentHandler, v as pricingResult, w as stripeSptPaymentHandler, x as validationEnvelope, y as validationResponseExpress, z as validationResponseFastify, B as validationResponseHono, E as validationResponseNextjs, F as validationResponseWeb, H as x402PaymentHandler } from './checkout-Bn7ZKIBD.mjs';
4
+ import { q as UCPSigningKey, n as UCPProfile } from './checkout-CzB9f_jf.mjs';
5
+ export { A as AGENTSCORE_UCP_CAPABILITY, a as AgentScoreGatePolicy, C as Checkout, b as CheckoutContext, c as CheckoutGateConfig, d as CheckoutRailSpec, e as CheckoutRequest, f as CheckoutResult, g as ComposeMppxFn, D as DiscoveryProbeConfig, G as GateDenial, I as IsCachedAddressFn, M as MountUcpRoutesOptions, h as MppxComposeOutcome, O as OnSettledFn, P as PreValidateFn, i as PricingFn, j as PricingResult, R as RecipientsFn, k as ReferenceIdFn, l as RunGateFn, S as SettleOutcome, U as UCPCapabilityBinding, m as UCPPaymentHandlerBinding, o as UCPProfileBody, p as UCPServiceBinding, r as buildAipTrustedIssuers, s as buildUCPProfile, t as getIdentityStatus, u as makeMppxComposeHook, v as mppPaymentHandler, w as pricingResult, x as stripeSptPaymentHandler, y as validationEnvelope, z as validationResponseExpress, B as validationResponseFastify, E as validationResponseHono, F as validationResponseNextjs, H as validationResponseWeb, J as x402PaymentHandler } from './checkout-CzB9f_jf.mjs';
6
6
  export { EnforcementMode, GateResult, IdentityStatus, PolicyBlock, buildGateFromPolicy, runGateWithEnforcement, shippingCountryAllowed, shippingStateAllowed, validateShippingAgainstPolicy } from './identity/policy.mjs';
7
7
  import { H as HeadersLike } from './network_kind-C0EMkdzz.mjs';
8
8
  export { c as buildDefaultCheckoutRails, d as buildMppxComposeRails, f as formatUsdCents, h as hasMppxHeader, e as hasPaymentHeader, g as hasX402Header, i as isEvmNetwork, j as isSolanaNetwork, l as loadSolanaFeePayer } from './network_kind-C0EMkdzz.mjs';
9
9
  import { T as TempoRailSpec, X as X402BaseRailSpec, S as SolanaMppRailSpec, b as StripeRailSpec } from './rail_spec-BFZmW9RN.mjs';
10
10
  export { c as TempoSessionRailSpec } from './rail_spec-BFZmW9RN.mjs';
11
11
  import { Context } from 'hono';
12
+ import { l as VerifyRequestContext } from './gate-GCXy4FHI.mjs';
13
+ export { A as AGENTSCORE_CANONICAL_ISSUER, a as AGENT_IDENTITY_HEADER, b as AipErrorRequirements, c as AipGateEvaluation, d as AipGateOptions, e as AipGateResult, H as HARD_MAX_CACHE_SECONDS, J as JWKS_WELL_KNOWN_PATH, f as JwksCache, g as JwksCacheOptions, h as JwksLookupResult, V as VerifiedAit, i as VerifyAitFailure, j as VerifyAitOptions, k as VerifyAitResult, m as aipErrorCode, n as aipErrorStatus, o as buildAipErrorBody, p as buildAipWeakAuthBody, q as canonicalizeIssuer, r as checkTrustRequirements, s as evaluateAipParts, t as evaluateAipRequest, v as verifyAit, u as verifyAitRequest } from './gate-GCXy4FHI.mjs';
14
+ import { JWK } from 'jose';
15
+ export { A as AitHeader, a as AitPayload, b as AitValidationResult, c as AmrValue, I as IdentityClaim, d as IntentClaim, T as TrustLevel, i as isAitShape, v as validateAitPayload } from './types-D1slMt0H.mjs';
16
+ import '@agent-score/sdk';
12
17
  import './pricing-KHDqMLd7.mjs';
13
18
  import './x402_server-Ciz2mls2.mjs';
14
19
 
@@ -207,6 +212,9 @@ declare function denialReasonToBody(reason: DenialReason): Record<string, unknow
207
212
  * `capabilities.extensions[]` to detect UCP support on the agent card. Pinned
208
213
  * to the 2026-04-08 spec snapshot. */
209
214
  declare const UCP_A2A_EXTENSION_URI = "https://ucp.dev/2026-04-08/specification/reference";
215
+ /** Canonical URI for the AIP (Agentic Identity Protocol) A2A agent-card extension — points at the
216
+ * issuer-discovery well-known so a reader can resolve the protocol. */
217
+ declare const AIP_A2A_EXTENSION_URI = "https://www.agentscore.com/.well-known/agent-identity";
210
218
  /** One transport+URL combination the agent exposes. Lives in `AgentCard.additionalInterfaces[]`
211
219
  * for multi-binding agents; the PRIMARY transport+URL pair lives on `AgentCard.url` +
212
220
  * `AgentCard.preferredTransport`. */
@@ -262,6 +270,17 @@ declare function ucpA2AExtension(capabilities?: Record<string, Array<{
262
270
  }>>, options?: {
263
271
  required?: boolean;
264
272
  }): A2AAgentCardExtension;
273
+ /** Build the AIP entry for an A2A agent card's `capabilities.extensions[]`. Advertises that the
274
+ * agent accepts an Agent Identity Token (JWT) in an `Agent-Identity` header plus an RFC 9421
275
+ * proof-of-possession signature — so an agent discovering via the agent-card learns it can present
276
+ * an AIT (matching what the merchant's mpp.json / llms.txt / skill.md already advertise). Optional
277
+ * `requiredTrustLevel` / `requiredAmr` surface a gate's human-presence requirement. */
278
+ declare function aipA2AExtension(opts?: {
279
+ trustedIssuers?: string[];
280
+ requiredTrustLevel?: 'autonomous' | 'human_present' | 'human_confirmed';
281
+ requiredAmr?: string[];
282
+ required?: boolean;
283
+ }): A2AAgentCardExtension;
265
284
  /** Optional capabilities the agent supports. */
266
285
  interface A2AAgentCardCapabilities {
267
286
  extensions?: A2AAgentCardExtension[];
@@ -562,6 +581,8 @@ declare function loadUCPSigningKeyFromEnv({ envJwkVar, envKidVar, envAlgVar, def
562
581
  defaultAlg?: 'EdDSA' | 'ES256';
563
582
  }): Promise<GeneratedUCPKey>;
564
583
 
584
+ declare const normalizeAddress: (address: string) => string;
585
+
565
586
  /**
566
587
  * Operator-token hashing.
567
588
  *
@@ -586,9 +607,14 @@ type OwnerScope = {
586
607
  /**
587
608
  * Pull the canonical owner identity from request headers so caller-scoped
588
609
  * lookups never see the plaintext operator token. Reads `X-Wallet-Address` and
589
- * `X-Operator-Token`; returns the wallet address verbatim and the
610
+ * `X-Operator-Token`; returns the network-normalized wallet address and the
590
611
  * sha256 hash of the token. Either or both may be undefined.
591
612
  *
613
+ * The wallet address is normalized via `normalizeAddress` (EVM lowercased,
614
+ * Solana base58 preserved) so it matches the stored `orders.wallet_address`
615
+ * column, which persists the lowercased signer. Without normalization, a
616
+ * checksummed (EIP-55) `X-Wallet-Address` would miss its own order rows (404).
617
+ *
592
618
  * Use at owner-scoped resource queries (`GET /orders/:id`, `GET /receipts/:id`,
593
619
  * ...) so persistence + lookup agree on the hashed column shape and plaintext
594
620
  * tokens never leave the request.
@@ -927,4 +953,139 @@ declare function createDefaultOnDenied(opts: CreateDefaultOnDeniedOptions): (rea
927
953
  */
928
954
  declare function defaultReadOnlyOnDenied(reason: DenialReason): DefaultOnDeniedResult;
929
955
 
930
- export { type A2AAgentCard, type A2AAgentCardCapabilities, type A2AAgentCardExtension, type A2AAgentCardSignature, type A2AAgentInterface, type A2AAgentProvider, type A2AAgentSkill, A2A_DEFAULT_TRANSPORT, A2A_PROTOCOL_VERSION, type CachedQuote, CheckoutValidationError, type ComputeFirstHandler, type ComputeFirstMintContext, type ComputeFirstMppContext, type ComputeFirstOptions, type ComputeFirstRails, type ComputeFirstSettledContext, type ComputeFirstWorkContext, type CreateDefaultOnDeniedOptions, type DefaultOnDeniedResult, DenialReason, FIXABLE_DENIAL_REASONS, type GeneratedUCPKey, type JWKSResponse, type MintedRecipients, type OwnerScope, type QuoteCache, type QuoteCacheOptions, type SignedUCPProfile, SolanaMppRailSpec, StripeRailSpec, type SuccessBodyArgs, TempoRailSpec, UCPProfile, UCPSigningKey, UCPVerificationError, UCP_A2A_EXTENSION_URI, VerifyWalletSignerResult, type WorkOutcome, X402BaseRailSpec, buildA2AAgentCard, buildContactSupportNextSteps, buildJWKSResponse, buildSignerMismatchBody, buildVerificationRequiredBody, computeFirstCheckout, createDefaultOnDenied, createQuoteCache, defaultReadOnlyOnDenied, denialReasonStatus, denialReasonToBody, extractOwnerScope, generateUCPSigningKey, hashOperatorToken, isFixableDenial, loadUCPSigningKeyFromEnv, signUCPProfile, ucpA2AExtension, verificationAgentInstructions, verifyUCPProfile };
956
+ /**
957
+ * RFC 9421 HTTP Message Signatures — the AIP-constrained subset.
958
+ *
959
+ * AIP (Agentic Identity Protocol) binds an Agent Identity Token (AIT) to the
960
+ * agent that presents it: the agent signs each HTTP request with the private key whose
961
+ * public half is carried in the AIT's `cnf.jwk` (RFC 7800). A verifier reconstructs the
962
+ * RFC 9421 signature base, verifies it against `cnf.jwk`, and confirms the signature's
963
+ * `keyid` equals the JWK thumbprint (RFC 7638) of that key. A stolen AIT is then useless
964
+ * without the bound private key.
965
+ *
966
+ * This module implements ONLY the shape AIP uses, not the full RFC 9421 grammar:
967
+ *
968
+ * - Covered components: the derived components `@method`, `@authority`, `@path`, plus the
969
+ * `agent-identity` header field. (The AIP "minimum required" set.) Extra components in a
970
+ * presented signature are accepted and covered if the caller supplies their values.
971
+ * - One labeled signature per request, tagged `tag="agent-identity"`. Web Bot Auth
972
+ * signatures (`tag="web-bot-auth"`) may coexist on the same request under a different
973
+ * label; we select ours by tag, ignoring the rest.
974
+ * - Algorithm: Ed25519 (EdDSA over OKP/Ed25519). AIP's default and only signing curve.
975
+ *
976
+ * The structured-field parsing here is deliberately narrow: it parses the AIP member of the
977
+ * `Signature-Input` / `Signature` dictionaries (a parenthesized inner list + integer/string
978
+ * params, and a single byte-sequence value). It is not a general RFC 8941 parser.
979
+ */
980
+
981
+ /** The AIP "minimum required" covered components, in canonical order. */
982
+ declare const AIP_COVERED_COMPONENTS: readonly ["@method", "@authority", "@path", "agent-identity"];
983
+ /** Tag that identifies the AIP signature among coexisting RFC 9421 signatures. */
984
+ declare const AIP_SIGNATURE_TAG = "agent-identity";
985
+ /** Hard ceiling on the PoP signature's own declared lifetime (`expires - created`), in seconds.
986
+ * Requiring `created`+`expires` bounds replay to the declared window — but with no ceiling a
987
+ * malicious trusted-issuer agent could set `expires = created + (AIT lifetime)` and replay for the
988
+ * full window. Cap it tightly so every accepted PoP is short-lived. First-party `pay` signs a 60s
989
+ * window, so it passes; this only bites a signer that declares an over-long PoP. Matches the
990
+ * authoritative API verifier's `MAX_POP_WINDOW_SECONDS` (the AgentScore API verifier) so the
991
+ * edge (standalone `aipGate`) and the API can't drift. (Distinct from the AIT JWT's `exp - iat`
992
+ * ceiling in verify.ts — this is the HTTP-signature layer.) */
993
+ declare const MAX_POP_WINDOW_SECONDS = 120;
994
+ /** Parameters parsed from (or used to build) a `Signature-Input` member. */
995
+ interface SignatureParams {
996
+ components: string[];
997
+ created?: number;
998
+ expires?: number;
999
+ keyid?: string;
1000
+ tag?: string;
1001
+ alg?: string;
1002
+ }
1003
+ interface VerifyMessageSignatureInput {
1004
+ /** HTTP method, e.g. `POST`. Case-insensitive; normalized to upper. */
1005
+ method: string;
1006
+ /** Authority (host[:port]), e.g. `wine-merchant.com`. Lowercased; default ports dropped. */
1007
+ authority: string;
1008
+ /** Request path (no query), e.g. `/checkout`. */
1009
+ path: string;
1010
+ /** Raw value of the `Agent-Identity` header the signature covers. */
1011
+ agentIdentity: string;
1012
+ /** Raw `Signature-Input` header value. */
1013
+ signatureInput: string;
1014
+ /** Raw `Signature` header value. */
1015
+ signature: string;
1016
+ /** The agent's public key from the AIT's `cnf.jwk`. */
1017
+ cnfJwk: JWK;
1018
+ /** Wall-clock seconds; defaults to now. Injectable for tests. */
1019
+ now?: number;
1020
+ /** Skew tolerance for created/expires. Defaults to {@link DEFAULT_MAX_SKEW_SECONDS}. */
1021
+ maxSkewSeconds?: number;
1022
+ /** Extra covered-component values, keyed by component name (for components beyond the AIP minimum). */
1023
+ extraComponents?: Record<string, string>;
1024
+ }
1025
+ type VerifyFailureReason = 'no_aip_signature' | 'malformed_signature_input' | 'malformed_signature' | 'unsupported_alg' | 'missing_keyid' | 'keyid_mismatch' | 'missing_covered_component' | 'created_missing' | 'expires_missing' | 'pop_window_too_long' | 'created_in_future' | 'expired' | 'unsupported_cnf_key' | 'signature_invalid';
1026
+ type VerifyMessageSignatureResult = {
1027
+ ok: true;
1028
+ params: SignatureParams;
1029
+ } | {
1030
+ ok: false;
1031
+ reason: VerifyFailureReason;
1032
+ };
1033
+ /**
1034
+ * Verify an AIP HTTP Message Signature. Performs the full check:
1035
+ * 1. select the AIP-tagged member of `Signature-Input`
1036
+ * 2. confirm the AIP minimum covered components are present
1037
+ * 3. REQUIRE both `created` and `expires`, reject an over-long declared window
1038
+ * (`expires - created` > MAX_POP_WINDOW_SECONDS → `pop_window_too_long`), then enforce them
1039
+ * against `now` with skew tolerance. Both are mandatory: an optional time bound is no time
1040
+ * bound — without `expires` a captured `(token, Signature-Input, Signature)` triple is
1041
+ * replayable for the whole AIT lifetime. A signature omitting either is rejected
1042
+ * (`created_missing` / `expires_missing`). This matches the authoritative API verifier
1043
+ * (the AgentScore API verifier) so a merchant running `aipGate` STANDALONE (the
1044
+ * crypto-identity-only deployment with no `/v1/assess`) gets the same replay defense.
1045
+ * 4. confirm `keyid` equals the RFC 7638 thumbprint of `cnf.jwk`
1046
+ * 5. reconstruct the signature base and verify Ed25519 over it
1047
+ *
1048
+ * NOTE: this is a STATELESS verifier — it bounds the replay WINDOW but does not dedupe within it.
1049
+ * A captured triple can still be replayed until `expires` (≤ MAX_POP_WINDOW_SECONDS + skew from
1050
+ * `created`). A stateful seen-signature cache (as in the authoritative API) is out of scope for the
1051
+ * SDK edge; the tight window bound is the meaningful mitigation here.
1052
+ */
1053
+ declare const verifyMessageSignature: (input: VerifyMessageSignatureInput) => Promise<VerifyMessageSignatureResult>;
1054
+ interface SignMessageInput {
1055
+ method: string;
1056
+ authority: string;
1057
+ path: string;
1058
+ agentIdentity: string;
1059
+ /** Agent private key (Ed25519 JWK with `d`). */
1060
+ privateJwk: JWK;
1061
+ /** Agent public key; used to derive `keyid` (thumbprint). */
1062
+ publicJwk: JWK;
1063
+ created?: number;
1064
+ expires?: number;
1065
+ /** Signature dictionary label. Defaults to `ait`. */
1066
+ label?: string;
1067
+ components?: string[];
1068
+ extraComponents?: Record<string, string>;
1069
+ }
1070
+ /** Build the `Signature-Input` and `Signature` header values for an AIP request. */
1071
+ declare const signMessage: (input: SignMessageInput) => Promise<{
1072
+ signatureInput: string;
1073
+ signature: string;
1074
+ }>;
1075
+
1076
+ /**
1077
+ * Build an AIP {@link VerifyRequestContext} from a standard WHATWG `Request`.
1078
+ *
1079
+ * Every framework adapter ultimately has (or can produce) a `Request`: Hono exposes
1080
+ * `c.req.raw`, Next.js / Web Fetch hand you one directly, and Express/Fastify can be shimmed.
1081
+ * This helper centralizes the header + URL extraction so adapters stay thin and the parsing
1082
+ * rules (authority derivation, multiple `Agent-Identity` headers) live in one place.
1083
+ */
1084
+
1085
+ /** Build the framework-agnostic verify context from a standard `Request`. A configured
1086
+ * `authority` pin (e.g. `AipGateOptions.authority`) wins over the inbound `Host` header. */
1087
+ declare const buildVerifyContextFromRequest: (req: Request, authority?: string) => VerifyRequestContext;
1088
+ /** True when the request carries an AIP credential (at least one `Agent-Identity` header). */
1089
+ declare const hasAgentIdentityHeader: (req: Request) => boolean;
1090
+
1091
+ export { type A2AAgentCard, type A2AAgentCardCapabilities, type A2AAgentCardExtension, type A2AAgentCardSignature, type A2AAgentInterface, type A2AAgentProvider, type A2AAgentSkill, A2A_DEFAULT_TRANSPORT, A2A_PROTOCOL_VERSION, AIP_A2A_EXTENSION_URI, AIP_COVERED_COMPONENTS, AIP_SIGNATURE_TAG, type CachedQuote, CheckoutValidationError, type ComputeFirstHandler, type ComputeFirstMintContext, type ComputeFirstMppContext, type ComputeFirstOptions, type ComputeFirstRails, type ComputeFirstSettledContext, type ComputeFirstWorkContext, type CreateDefaultOnDeniedOptions, type DefaultOnDeniedResult, DenialReason, FIXABLE_DENIAL_REASONS, type GeneratedUCPKey, type JWKSResponse, MAX_POP_WINDOW_SECONDS, type MintedRecipients, type OwnerScope, type QuoteCache, type QuoteCacheOptions, type SignMessageInput, type SignedUCPProfile, SolanaMppRailSpec, StripeRailSpec, type SuccessBodyArgs, TempoRailSpec, UCPProfile, UCPSigningKey, UCPVerificationError, UCP_A2A_EXTENSION_URI, type VerifyFailureReason, type VerifyMessageSignatureInput, type VerifyMessageSignatureResult, VerifyRequestContext, VerifyWalletSignerResult, type WorkOutcome, X402BaseRailSpec, aipA2AExtension, buildA2AAgentCard, buildContactSupportNextSteps, buildJWKSResponse, buildSignerMismatchBody, buildVerificationRequiredBody, buildVerifyContextFromRequest, computeFirstCheckout, createDefaultOnDenied, createQuoteCache, defaultReadOnlyOnDenied, denialReasonStatus, denialReasonToBody, extractOwnerScope, generateUCPSigningKey, hasAgentIdentityHeader, hashOperatorToken, isFixableDenial, loadUCPSigningKeyFromEnv, normalizeAddress, signMessage, signUCPProfile, ucpA2AExtension, verificationAgentInstructions, verifyMessageSignature, verifyUCPProfile };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,19 @@
1
1
  import { VerifyWalletSignerResult, DenialReason } from './core.js';
2
2
  export { AccountVerification, AgentIdentity, AgentMemoryHint, AgentScoreCore, AssessResult, CreateSessionOnMissing, DenialCode, EvaluateOutcome, OperatorVerification, PolicyCheck, PolicyResult, SignerVerdict, buildAgentMemoryHint } from './core.js';
3
3
  export { P as PaymentSigner, S as SignerNetwork, e as extractPaymentSigner, a as extractPaymentSignerFromAuth, b as extractSignerForPrecheck, r as readX402PaymentHeader } from './signer-3FAit11j.js';
4
- import { q as UCPSigningKey, n as UCPProfile } from './checkout-B-MIzYzW.js';
5
- export { A as AGENTSCORE_UCP_CAPABILITY, a as AgentScoreGatePolicy, C as Checkout, b as CheckoutContext, c as CheckoutGateConfig, d as CheckoutRailSpec, e as CheckoutRequest, f as CheckoutResult, g as ComposeMppxFn, D as DiscoveryProbeConfig, G as GateDenial, I as IsCachedAddressFn, M as MountUcpRoutesOptions, h as MppxComposeOutcome, O as OnSettledFn, P as PreValidateFn, i as PricingFn, j as PricingResult, R as RecipientsFn, k as ReferenceIdFn, l as RunGateFn, S as SettleOutcome, U as UCPCapabilityBinding, m as UCPPaymentHandlerBinding, o as UCPProfileBody, p as UCPServiceBinding, r as buildUCPProfile, s as getIdentityStatus, t as makeMppxComposeHook, u as mppPaymentHandler, v as pricingResult, w as stripeSptPaymentHandler, x as validationEnvelope, y as validationResponseExpress, z as validationResponseFastify, B as validationResponseHono, E as validationResponseNextjs, F as validationResponseWeb, H as x402PaymentHandler } from './checkout-B-MIzYzW.js';
4
+ import { q as UCPSigningKey, n as UCPProfile } from './checkout-C4RD7M0Z.js';
5
+ export { A as AGENTSCORE_UCP_CAPABILITY, a as AgentScoreGatePolicy, C as Checkout, b as CheckoutContext, c as CheckoutGateConfig, d as CheckoutRailSpec, e as CheckoutRequest, f as CheckoutResult, g as ComposeMppxFn, D as DiscoveryProbeConfig, G as GateDenial, I as IsCachedAddressFn, M as MountUcpRoutesOptions, h as MppxComposeOutcome, O as OnSettledFn, P as PreValidateFn, i as PricingFn, j as PricingResult, R as RecipientsFn, k as ReferenceIdFn, l as RunGateFn, S as SettleOutcome, U as UCPCapabilityBinding, m as UCPPaymentHandlerBinding, o as UCPProfileBody, p as UCPServiceBinding, r as buildAipTrustedIssuers, s as buildUCPProfile, t as getIdentityStatus, u as makeMppxComposeHook, v as mppPaymentHandler, w as pricingResult, x as stripeSptPaymentHandler, y as validationEnvelope, z as validationResponseExpress, B as validationResponseFastify, E as validationResponseHono, F as validationResponseNextjs, H as validationResponseWeb, J as x402PaymentHandler } from './checkout-C4RD7M0Z.js';
6
6
  export { EnforcementMode, GateResult, IdentityStatus, PolicyBlock, buildGateFromPolicy, runGateWithEnforcement, shippingCountryAllowed, shippingStateAllowed, validateShippingAgainstPolicy } from './identity/policy.js';
7
7
  import { H as HeadersLike } from './network_kind-BIJM2peR.js';
8
8
  export { c as buildDefaultCheckoutRails, d as buildMppxComposeRails, f as formatUsdCents, h as hasMppxHeader, e as hasPaymentHeader, g as hasX402Header, i as isEvmNetwork, j as isSolanaNetwork, l as loadSolanaFeePayer } from './network_kind-BIJM2peR.js';
9
9
  import { T as TempoRailSpec, X as X402BaseRailSpec, S as SolanaMppRailSpec, b as StripeRailSpec } from './rail_spec-BFZmW9RN.js';
10
10
  export { c as TempoSessionRailSpec } from './rail_spec-BFZmW9RN.js';
11
11
  import { Context } from 'hono';
12
+ import { l as VerifyRequestContext } from './gate-D2RP6bZg.js';
13
+ export { A as AGENTSCORE_CANONICAL_ISSUER, a as AGENT_IDENTITY_HEADER, b as AipErrorRequirements, c as AipGateEvaluation, d as AipGateOptions, e as AipGateResult, H as HARD_MAX_CACHE_SECONDS, J as JWKS_WELL_KNOWN_PATH, f as JwksCache, g as JwksCacheOptions, h as JwksLookupResult, V as VerifiedAit, i as VerifyAitFailure, j as VerifyAitOptions, k as VerifyAitResult, m as aipErrorCode, n as aipErrorStatus, o as buildAipErrorBody, p as buildAipWeakAuthBody, q as canonicalizeIssuer, r as checkTrustRequirements, s as evaluateAipParts, t as evaluateAipRequest, v as verifyAit, u as verifyAitRequest } from './gate-D2RP6bZg.js';
14
+ import { JWK } from 'jose';
15
+ export { A as AitHeader, a as AitPayload, b as AitValidationResult, c as AmrValue, I as IdentityClaim, d as IntentClaim, T as TrustLevel, i as isAitShape, v as validateAitPayload } from './types-D1slMt0H.js';
16
+ import '@agent-score/sdk';
12
17
  import './pricing-CytRwhC2.js';
13
18
  import './x402_server-Ciz2mls2.js';
14
19
 
@@ -207,6 +212,9 @@ declare function denialReasonToBody(reason: DenialReason): Record<string, unknow
207
212
  * `capabilities.extensions[]` to detect UCP support on the agent card. Pinned
208
213
  * to the 2026-04-08 spec snapshot. */
209
214
  declare const UCP_A2A_EXTENSION_URI = "https://ucp.dev/2026-04-08/specification/reference";
215
+ /** Canonical URI for the AIP (Agentic Identity Protocol) A2A agent-card extension — points at the
216
+ * issuer-discovery well-known so a reader can resolve the protocol. */
217
+ declare const AIP_A2A_EXTENSION_URI = "https://www.agentscore.com/.well-known/agent-identity";
210
218
  /** One transport+URL combination the agent exposes. Lives in `AgentCard.additionalInterfaces[]`
211
219
  * for multi-binding agents; the PRIMARY transport+URL pair lives on `AgentCard.url` +
212
220
  * `AgentCard.preferredTransport`. */
@@ -262,6 +270,17 @@ declare function ucpA2AExtension(capabilities?: Record<string, Array<{
262
270
  }>>, options?: {
263
271
  required?: boolean;
264
272
  }): A2AAgentCardExtension;
273
+ /** Build the AIP entry for an A2A agent card's `capabilities.extensions[]`. Advertises that the
274
+ * agent accepts an Agent Identity Token (JWT) in an `Agent-Identity` header plus an RFC 9421
275
+ * proof-of-possession signature — so an agent discovering via the agent-card learns it can present
276
+ * an AIT (matching what the merchant's mpp.json / llms.txt / skill.md already advertise). Optional
277
+ * `requiredTrustLevel` / `requiredAmr` surface a gate's human-presence requirement. */
278
+ declare function aipA2AExtension(opts?: {
279
+ trustedIssuers?: string[];
280
+ requiredTrustLevel?: 'autonomous' | 'human_present' | 'human_confirmed';
281
+ requiredAmr?: string[];
282
+ required?: boolean;
283
+ }): A2AAgentCardExtension;
265
284
  /** Optional capabilities the agent supports. */
266
285
  interface A2AAgentCardCapabilities {
267
286
  extensions?: A2AAgentCardExtension[];
@@ -562,6 +581,8 @@ declare function loadUCPSigningKeyFromEnv({ envJwkVar, envKidVar, envAlgVar, def
562
581
  defaultAlg?: 'EdDSA' | 'ES256';
563
582
  }): Promise<GeneratedUCPKey>;
564
583
 
584
+ declare const normalizeAddress: (address: string) => string;
585
+
565
586
  /**
566
587
  * Operator-token hashing.
567
588
  *
@@ -586,9 +607,14 @@ type OwnerScope = {
586
607
  /**
587
608
  * Pull the canonical owner identity from request headers so caller-scoped
588
609
  * lookups never see the plaintext operator token. Reads `X-Wallet-Address` and
589
- * `X-Operator-Token`; returns the wallet address verbatim and the
610
+ * `X-Operator-Token`; returns the network-normalized wallet address and the
590
611
  * sha256 hash of the token. Either or both may be undefined.
591
612
  *
613
+ * The wallet address is normalized via `normalizeAddress` (EVM lowercased,
614
+ * Solana base58 preserved) so it matches the stored `orders.wallet_address`
615
+ * column, which persists the lowercased signer. Without normalization, a
616
+ * checksummed (EIP-55) `X-Wallet-Address` would miss its own order rows (404).
617
+ *
592
618
  * Use at owner-scoped resource queries (`GET /orders/:id`, `GET /receipts/:id`,
593
619
  * ...) so persistence + lookup agree on the hashed column shape and plaintext
594
620
  * tokens never leave the request.
@@ -927,4 +953,139 @@ declare function createDefaultOnDenied(opts: CreateDefaultOnDeniedOptions): (rea
927
953
  */
928
954
  declare function defaultReadOnlyOnDenied(reason: DenialReason): DefaultOnDeniedResult;
929
955
 
930
- export { type A2AAgentCard, type A2AAgentCardCapabilities, type A2AAgentCardExtension, type A2AAgentCardSignature, type A2AAgentInterface, type A2AAgentProvider, type A2AAgentSkill, A2A_DEFAULT_TRANSPORT, A2A_PROTOCOL_VERSION, type CachedQuote, CheckoutValidationError, type ComputeFirstHandler, type ComputeFirstMintContext, type ComputeFirstMppContext, type ComputeFirstOptions, type ComputeFirstRails, type ComputeFirstSettledContext, type ComputeFirstWorkContext, type CreateDefaultOnDeniedOptions, type DefaultOnDeniedResult, DenialReason, FIXABLE_DENIAL_REASONS, type GeneratedUCPKey, type JWKSResponse, type MintedRecipients, type OwnerScope, type QuoteCache, type QuoteCacheOptions, type SignedUCPProfile, SolanaMppRailSpec, StripeRailSpec, type SuccessBodyArgs, TempoRailSpec, UCPProfile, UCPSigningKey, UCPVerificationError, UCP_A2A_EXTENSION_URI, VerifyWalletSignerResult, type WorkOutcome, X402BaseRailSpec, buildA2AAgentCard, buildContactSupportNextSteps, buildJWKSResponse, buildSignerMismatchBody, buildVerificationRequiredBody, computeFirstCheckout, createDefaultOnDenied, createQuoteCache, defaultReadOnlyOnDenied, denialReasonStatus, denialReasonToBody, extractOwnerScope, generateUCPSigningKey, hashOperatorToken, isFixableDenial, loadUCPSigningKeyFromEnv, signUCPProfile, ucpA2AExtension, verificationAgentInstructions, verifyUCPProfile };
956
+ /**
957
+ * RFC 9421 HTTP Message Signatures — the AIP-constrained subset.
958
+ *
959
+ * AIP (Agentic Identity Protocol) binds an Agent Identity Token (AIT) to the
960
+ * agent that presents it: the agent signs each HTTP request with the private key whose
961
+ * public half is carried in the AIT's `cnf.jwk` (RFC 7800). A verifier reconstructs the
962
+ * RFC 9421 signature base, verifies it against `cnf.jwk`, and confirms the signature's
963
+ * `keyid` equals the JWK thumbprint (RFC 7638) of that key. A stolen AIT is then useless
964
+ * without the bound private key.
965
+ *
966
+ * This module implements ONLY the shape AIP uses, not the full RFC 9421 grammar:
967
+ *
968
+ * - Covered components: the derived components `@method`, `@authority`, `@path`, plus the
969
+ * `agent-identity` header field. (The AIP "minimum required" set.) Extra components in a
970
+ * presented signature are accepted and covered if the caller supplies their values.
971
+ * - One labeled signature per request, tagged `tag="agent-identity"`. Web Bot Auth
972
+ * signatures (`tag="web-bot-auth"`) may coexist on the same request under a different
973
+ * label; we select ours by tag, ignoring the rest.
974
+ * - Algorithm: Ed25519 (EdDSA over OKP/Ed25519). AIP's default and only signing curve.
975
+ *
976
+ * The structured-field parsing here is deliberately narrow: it parses the AIP member of the
977
+ * `Signature-Input` / `Signature` dictionaries (a parenthesized inner list + integer/string
978
+ * params, and a single byte-sequence value). It is not a general RFC 8941 parser.
979
+ */
980
+
981
+ /** The AIP "minimum required" covered components, in canonical order. */
982
+ declare const AIP_COVERED_COMPONENTS: readonly ["@method", "@authority", "@path", "agent-identity"];
983
+ /** Tag that identifies the AIP signature among coexisting RFC 9421 signatures. */
984
+ declare const AIP_SIGNATURE_TAG = "agent-identity";
985
+ /** Hard ceiling on the PoP signature's own declared lifetime (`expires - created`), in seconds.
986
+ * Requiring `created`+`expires` bounds replay to the declared window — but with no ceiling a
987
+ * malicious trusted-issuer agent could set `expires = created + (AIT lifetime)` and replay for the
988
+ * full window. Cap it tightly so every accepted PoP is short-lived. First-party `pay` signs a 60s
989
+ * window, so it passes; this only bites a signer that declares an over-long PoP. Matches the
990
+ * authoritative API verifier's `MAX_POP_WINDOW_SECONDS` (the AgentScore API verifier) so the
991
+ * edge (standalone `aipGate`) and the API can't drift. (Distinct from the AIT JWT's `exp - iat`
992
+ * ceiling in verify.ts — this is the HTTP-signature layer.) */
993
+ declare const MAX_POP_WINDOW_SECONDS = 120;
994
+ /** Parameters parsed from (or used to build) a `Signature-Input` member. */
995
+ interface SignatureParams {
996
+ components: string[];
997
+ created?: number;
998
+ expires?: number;
999
+ keyid?: string;
1000
+ tag?: string;
1001
+ alg?: string;
1002
+ }
1003
+ interface VerifyMessageSignatureInput {
1004
+ /** HTTP method, e.g. `POST`. Case-insensitive; normalized to upper. */
1005
+ method: string;
1006
+ /** Authority (host[:port]), e.g. `wine-merchant.com`. Lowercased; default ports dropped. */
1007
+ authority: string;
1008
+ /** Request path (no query), e.g. `/checkout`. */
1009
+ path: string;
1010
+ /** Raw value of the `Agent-Identity` header the signature covers. */
1011
+ agentIdentity: string;
1012
+ /** Raw `Signature-Input` header value. */
1013
+ signatureInput: string;
1014
+ /** Raw `Signature` header value. */
1015
+ signature: string;
1016
+ /** The agent's public key from the AIT's `cnf.jwk`. */
1017
+ cnfJwk: JWK;
1018
+ /** Wall-clock seconds; defaults to now. Injectable for tests. */
1019
+ now?: number;
1020
+ /** Skew tolerance for created/expires. Defaults to {@link DEFAULT_MAX_SKEW_SECONDS}. */
1021
+ maxSkewSeconds?: number;
1022
+ /** Extra covered-component values, keyed by component name (for components beyond the AIP minimum). */
1023
+ extraComponents?: Record<string, string>;
1024
+ }
1025
+ type VerifyFailureReason = 'no_aip_signature' | 'malformed_signature_input' | 'malformed_signature' | 'unsupported_alg' | 'missing_keyid' | 'keyid_mismatch' | 'missing_covered_component' | 'created_missing' | 'expires_missing' | 'pop_window_too_long' | 'created_in_future' | 'expired' | 'unsupported_cnf_key' | 'signature_invalid';
1026
+ type VerifyMessageSignatureResult = {
1027
+ ok: true;
1028
+ params: SignatureParams;
1029
+ } | {
1030
+ ok: false;
1031
+ reason: VerifyFailureReason;
1032
+ };
1033
+ /**
1034
+ * Verify an AIP HTTP Message Signature. Performs the full check:
1035
+ * 1. select the AIP-tagged member of `Signature-Input`
1036
+ * 2. confirm the AIP minimum covered components are present
1037
+ * 3. REQUIRE both `created` and `expires`, reject an over-long declared window
1038
+ * (`expires - created` > MAX_POP_WINDOW_SECONDS → `pop_window_too_long`), then enforce them
1039
+ * against `now` with skew tolerance. Both are mandatory: an optional time bound is no time
1040
+ * bound — without `expires` a captured `(token, Signature-Input, Signature)` triple is
1041
+ * replayable for the whole AIT lifetime. A signature omitting either is rejected
1042
+ * (`created_missing` / `expires_missing`). This matches the authoritative API verifier
1043
+ * (the AgentScore API verifier) so a merchant running `aipGate` STANDALONE (the
1044
+ * crypto-identity-only deployment with no `/v1/assess`) gets the same replay defense.
1045
+ * 4. confirm `keyid` equals the RFC 7638 thumbprint of `cnf.jwk`
1046
+ * 5. reconstruct the signature base and verify Ed25519 over it
1047
+ *
1048
+ * NOTE: this is a STATELESS verifier — it bounds the replay WINDOW but does not dedupe within it.
1049
+ * A captured triple can still be replayed until `expires` (≤ MAX_POP_WINDOW_SECONDS + skew from
1050
+ * `created`). A stateful seen-signature cache (as in the authoritative API) is out of scope for the
1051
+ * SDK edge; the tight window bound is the meaningful mitigation here.
1052
+ */
1053
+ declare const verifyMessageSignature: (input: VerifyMessageSignatureInput) => Promise<VerifyMessageSignatureResult>;
1054
+ interface SignMessageInput {
1055
+ method: string;
1056
+ authority: string;
1057
+ path: string;
1058
+ agentIdentity: string;
1059
+ /** Agent private key (Ed25519 JWK with `d`). */
1060
+ privateJwk: JWK;
1061
+ /** Agent public key; used to derive `keyid` (thumbprint). */
1062
+ publicJwk: JWK;
1063
+ created?: number;
1064
+ expires?: number;
1065
+ /** Signature dictionary label. Defaults to `ait`. */
1066
+ label?: string;
1067
+ components?: string[];
1068
+ extraComponents?: Record<string, string>;
1069
+ }
1070
+ /** Build the `Signature-Input` and `Signature` header values for an AIP request. */
1071
+ declare const signMessage: (input: SignMessageInput) => Promise<{
1072
+ signatureInput: string;
1073
+ signature: string;
1074
+ }>;
1075
+
1076
+ /**
1077
+ * Build an AIP {@link VerifyRequestContext} from a standard WHATWG `Request`.
1078
+ *
1079
+ * Every framework adapter ultimately has (or can produce) a `Request`: Hono exposes
1080
+ * `c.req.raw`, Next.js / Web Fetch hand you one directly, and Express/Fastify can be shimmed.
1081
+ * This helper centralizes the header + URL extraction so adapters stay thin and the parsing
1082
+ * rules (authority derivation, multiple `Agent-Identity` headers) live in one place.
1083
+ */
1084
+
1085
+ /** Build the framework-agnostic verify context from a standard `Request`. A configured
1086
+ * `authority` pin (e.g. `AipGateOptions.authority`) wins over the inbound `Host` header. */
1087
+ declare const buildVerifyContextFromRequest: (req: Request, authority?: string) => VerifyRequestContext;
1088
+ /** True when the request carries an AIP credential (at least one `Agent-Identity` header). */
1089
+ declare const hasAgentIdentityHeader: (req: Request) => boolean;
1090
+
1091
+ export { type A2AAgentCard, type A2AAgentCardCapabilities, type A2AAgentCardExtension, type A2AAgentCardSignature, type A2AAgentInterface, type A2AAgentProvider, type A2AAgentSkill, A2A_DEFAULT_TRANSPORT, A2A_PROTOCOL_VERSION, AIP_A2A_EXTENSION_URI, AIP_COVERED_COMPONENTS, AIP_SIGNATURE_TAG, type CachedQuote, CheckoutValidationError, type ComputeFirstHandler, type ComputeFirstMintContext, type ComputeFirstMppContext, type ComputeFirstOptions, type ComputeFirstRails, type ComputeFirstSettledContext, type ComputeFirstWorkContext, type CreateDefaultOnDeniedOptions, type DefaultOnDeniedResult, DenialReason, FIXABLE_DENIAL_REASONS, type GeneratedUCPKey, type JWKSResponse, MAX_POP_WINDOW_SECONDS, type MintedRecipients, type OwnerScope, type QuoteCache, type QuoteCacheOptions, type SignMessageInput, type SignedUCPProfile, SolanaMppRailSpec, StripeRailSpec, type SuccessBodyArgs, TempoRailSpec, UCPProfile, UCPSigningKey, UCPVerificationError, UCP_A2A_EXTENSION_URI, type VerifyFailureReason, type VerifyMessageSignatureInput, type VerifyMessageSignatureResult, VerifyRequestContext, VerifyWalletSignerResult, type WorkOutcome, X402BaseRailSpec, aipA2AExtension, buildA2AAgentCard, buildContactSupportNextSteps, buildJWKSResponse, buildSignerMismatchBody, buildVerificationRequiredBody, buildVerifyContextFromRequest, computeFirstCheckout, createDefaultOnDenied, createQuoteCache, defaultReadOnlyOnDenied, denialReasonStatus, denialReasonToBody, extractOwnerScope, generateUCPSigningKey, hasAgentIdentityHeader, hashOperatorToken, isFixableDenial, loadUCPSigningKeyFromEnv, normalizeAddress, signMessage, signUCPProfile, ucpA2AExtension, verificationAgentInstructions, verifyMessageSignature, verifyUCPProfile };