@astrasyncai/verification-gateway 5.18.1 → 5.19.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 (113) hide show
  1. package/CHANGELOG.md +149 -0
  2. package/README.md +168 -4
  3. package/dist/adapters/express.d.mts +9 -1
  4. package/dist/adapters/express.d.ts +9 -1
  5. package/dist/adapters/express.js +96 -37
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +96 -37
  8. package/dist/adapters/express.mjs.map +1 -1
  9. package/dist/adapters/http-pdlss.d.mts +7 -1
  10. package/dist/adapters/http-pdlss.d.ts +7 -1
  11. package/dist/adapters/http-pdlss.js +18 -2
  12. package/dist/adapters/http-pdlss.js.map +1 -1
  13. package/dist/adapters/http-pdlss.mjs +16 -1
  14. package/dist/adapters/http-pdlss.mjs.map +1 -1
  15. package/dist/adapters/kit-express.d.mts +93 -1
  16. package/dist/adapters/kit-express.d.ts +93 -1
  17. package/dist/adapters/kit-express.js +181 -2
  18. package/dist/adapters/kit-express.js.map +1 -1
  19. package/dist/adapters/kit-express.mjs +180 -2
  20. package/dist/adapters/kit-express.mjs.map +1 -1
  21. package/dist/adapters/mcp.d.mts +80 -9
  22. package/dist/adapters/mcp.d.ts +80 -9
  23. package/dist/adapters/mcp.js +153 -5
  24. package/dist/adapters/mcp.js.map +1 -1
  25. package/dist/adapters/mcp.mjs +151 -5
  26. package/dist/adapters/mcp.mjs.map +1 -1
  27. package/dist/adapters/nextjs.d.mts +1 -1
  28. package/dist/adapters/nextjs.d.ts +1 -1
  29. package/dist/adapters/nextjs.js +41 -4
  30. package/dist/adapters/nextjs.js.map +1 -1
  31. package/dist/adapters/nextjs.mjs +41 -4
  32. package/dist/adapters/nextjs.mjs.map +1 -1
  33. package/dist/adapters/sdk.d.mts +44 -1
  34. package/dist/adapters/sdk.d.ts +44 -1
  35. package/dist/adapters/sdk.js +76 -2
  36. package/dist/adapters/sdk.js.map +1 -1
  37. package/dist/adapters/sdk.mjs +76 -2
  38. package/dist/adapters/sdk.mjs.map +1 -1
  39. package/dist/agent/index.js +1 -1
  40. package/dist/agent/index.js.map +1 -1
  41. package/dist/agent/index.mjs +1 -1
  42. package/dist/agent/index.mjs.map +1 -1
  43. package/dist/bin/astrasync-claude-hook.js +46 -6
  44. package/dist/bin/astrasync-codex-hook.js +46 -6
  45. package/dist/bin/astrasync-guard.js +46 -6
  46. package/dist/bin/astrasync.js +77 -5
  47. package/dist/browser/background.js +46 -6
  48. package/dist/browser/background.js.map +1 -1
  49. package/dist/browser/background.mjs +46 -6
  50. package/dist/browser/background.mjs.map +1 -1
  51. package/dist/cli/index.js +1 -1
  52. package/dist/cli/index.js.map +1 -1
  53. package/dist/cli/index.mjs +1 -1
  54. package/dist/cli/index.mjs.map +1 -1
  55. package/dist/codex/index.js +46 -6
  56. package/dist/codex/index.js.map +1 -1
  57. package/dist/codex/index.mjs +46 -6
  58. package/dist/codex/index.mjs.map +1 -1
  59. package/dist/cursor/extension.js +46 -6
  60. package/dist/cursor/extension.js.map +1 -1
  61. package/dist/cursor/extension.mjs +46 -6
  62. package/dist/cursor/extension.mjs.map +1 -1
  63. package/dist/edge-config.d.mts +1 -1
  64. package/dist/edge-config.d.ts +1 -1
  65. package/dist/edge-config.js +1 -1
  66. package/dist/edge-config.js.map +1 -1
  67. package/dist/edge-config.mjs +1 -1
  68. package/dist/edge-config.mjs.map +1 -1
  69. package/dist/edge-core/index.d.mts +1 -1
  70. package/dist/edge-core/index.d.ts +1 -1
  71. package/dist/edge-core/index.js +21 -2
  72. package/dist/edge-core/index.js.map +1 -1
  73. package/dist/edge-core/index.mjs +21 -2
  74. package/dist/edge-core/index.mjs.map +1 -1
  75. package/dist/gateway/gateway.js +46 -6
  76. package/dist/gateway/gateway.js.map +1 -1
  77. package/dist/gateway/gateway.mjs +46 -6
  78. package/dist/gateway/gateway.mjs.map +1 -1
  79. package/dist/git-trigger/git-hooks.d.mts +1 -1
  80. package/dist/git-trigger/git-hooks.d.ts +1 -1
  81. package/dist/index.d.mts +541 -29
  82. package/dist/index.d.ts +541 -29
  83. package/dist/index.js +1171 -183
  84. package/dist/index.js.map +1 -1
  85. package/dist/index.mjs +1157 -173
  86. package/dist/index.mjs.map +1 -1
  87. package/dist/registration/index.js +1 -1
  88. package/dist/registration/index.js.map +1 -1
  89. package/dist/registration/index.mjs +1 -1
  90. package/dist/registration/index.mjs.map +1 -1
  91. package/dist/transport/index.js +3 -2
  92. package/dist/transport/index.js.map +1 -1
  93. package/dist/transport/index.mjs +3 -2
  94. package/dist/transport/index.mjs.map +1 -1
  95. package/dist/{types-3ObBpsnf.d.mts → types-BoGjyon0.d.mts} +81 -2
  96. package/dist/{types-Cns4l8gX.d.mts → types-DqWPkiYl.d.mts} +90 -12
  97. package/dist/{types-Cns4l8gX.d.ts → types-DqWPkiYl.d.ts} +90 -12
  98. package/dist/{types-BoxZEYPS.d.ts → types-eWyZuz-3.d.ts} +81 -2
  99. package/dist/ui/index.d.mts +1 -1
  100. package/dist/ui/index.d.ts +1 -1
  101. package/dist/verify.d.mts +23 -2
  102. package/dist/verify.d.ts +23 -2
  103. package/dist/verify.js +23 -4
  104. package/dist/verify.js.map +1 -1
  105. package/dist/verify.mjs +23 -4
  106. package/dist/verify.mjs.map +1 -1
  107. package/dist/webhooks.d.mts +16 -3
  108. package/dist/webhooks.d.ts +16 -3
  109. package/dist/webhooks.js +24 -13
  110. package/dist/webhooks.js.map +1 -1
  111. package/dist/webhooks.mjs +24 -13
  112. package/dist/webhooks.mjs.map +1 -1
  113. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -351,9 +351,15 @@ interface VerifiedAgent {
351
351
  astraId: string;
352
352
  /** Agent display name */
353
353
  name: string;
354
- /** Composite trust score (0-100) */
354
+ /**
355
+ * Composite trust score (0-100). 5.19.0: verify-access returns it to an
356
+ * authenticated counterparty (your API key) — counterparties may see an
357
+ * agent's score; the agent itself never does, so never relay it to the
358
+ * agent. It is withheld (undefined at runtime) for a keyless caller and when
359
+ * the caller is the agent itself; a route `minTrustScore` then fails closed.
360
+ */
355
361
  trustScore: number;
356
- /** Trust level tier */
362
+ /** Trust level tier (derived from `trustScore`) */
357
363
  trustLevel: TrustLevel;
358
364
  /** Whether the agent's identity record is anchored on-chain (5.9.0: was `blockchainVerified`) */
359
365
  blockchainAnchored: boolean;
@@ -605,6 +611,20 @@ interface SettlementArtifact {
605
611
  * - `counterparty.<allowlist|trust>`
606
612
  * - `attestation.<type>` (e.g. `attestation.verified_human_party`)
607
613
  * - `endpoint.<deactivated|trust|policy>`
614
+ * - `behaviour.<limit_probing|unattributed_limit_check>` (5.19.0) — the
615
+ * call is part of a sweep of unfinished attempts at rising values (quotes,
616
+ * held/denied confirms, orders that never settled) that maps the agent's
617
+ * spending limit. Completed purchases never count.
618
+ * - `behaviour.limit_probing`: the sweep is provably the agent's own
619
+ * (signed agent request, first-party bridge hop, runtime challenge or
620
+ * the agent's key). Denied with no new step-up approval; the agent's
621
+ * trust drops and its owner is alerted.
622
+ * - `behaviour.unattributed_limit_check`: the sweep can't be attributed
623
+ * to the agent (unsigned or direct merchant calls). Denied — it "needs
624
+ * a signed agent request" — with no agent trust penalty; owners are
625
+ * alerted with the evidence. A repeat of the merchant's own direct
626
+ * calls, or the same pattern across agents of two or more owners,
627
+ * reduces the endpoint owner's trust score.
608
628
  */
609
629
  interface AccessFailure {
610
630
  dimension: string;
@@ -884,6 +904,46 @@ interface CallerMetadata {
884
904
  */
885
905
  observedMetadata?: ObservedMetadata;
886
906
  }
907
+ /**
908
+ * 5.19.0 — the inbound agent request behind a kit confirm, forwarded so
909
+ * verify-access can tell whether the confirm is provably the agent's own
910
+ * (limit-probing attribution). The kits build it from `handle(req)`.
911
+ *
912
+ * - Signed (UCP, RFC 9421): the covered headers (`signature`,
913
+ * `signature-input`, `signature-agent`, `ucp-agent`, `content-digest` and
914
+ * every other header the signature covers — never `authorization` or
915
+ * `cookie`), the method, the PUBLIC request URL (your `publicOrigin` + the
916
+ * path and query, so `@target-uri` / `@authority` match what the agent
917
+ * signed behind a TLS-terminating proxy) and `contentDigest`, the
918
+ * `sha-256=:<base64>:` digest of the exact raw body.
919
+ * - `{ unsigned: true }`: the inbound request carried no signature, or it
920
+ * came over ACP (the ACP `Authorization` bearer is the platform's
921
+ * credential to you and is never forwarded, so ACP confirms are
922
+ * unattributable). Sent explicitly so the platform can tell a kit relay
923
+ * from a direct merchant call.
924
+ */
925
+ type AgentArtifacts = {
926
+ unsigned: true;
927
+ protocol?: 'ucp' | 'acp';
928
+ } | {
929
+ unsigned?: false;
930
+ protocol: 'ucp' | 'acp';
931
+ method: string;
932
+ /** Absolute public URL of the inbound request. */
933
+ url: string;
934
+ /** Lower-cased covered headers. */
935
+ headers: Record<string, string>;
936
+ /** `sha-256=:<base64>:` over the raw request body (absent for an empty body). */
937
+ contentDigest?: string;
938
+ };
939
+ /** 5.19.0 — kit context on a confirm (carried onto the approval and its events). */
940
+ interface CheckoutMetadata {
941
+ /** The kit's own checkout session id (`chk_…` / `cs_…`). */
942
+ kitSessionId?: string;
943
+ protocol?: 'ucp' | 'acp';
944
+ }
945
+ /** 5.19.0 — see {@link VerificationRequest.purposeSource}. */
946
+ type PurposeSource = 'route_config' | 'header' | 'body' | 'default';
887
947
  interface VerificationRequest {
888
948
  /** Agent credentials */
889
949
  credentials: AgentCredentials;
@@ -1015,6 +1075,25 @@ interface VerificationRequest {
1015
1075
  * from the verify cache key.
1016
1076
  */
1017
1077
  attemptId?: string;
1078
+ /**
1079
+ * 5.19.0 — where `purpose` came from: `'route_config'` (a dashboard route
1080
+ * rule matched this request), `'header'` (the agent's X-Astra-Purpose /
1081
+ * legacy header / query), `'body'` (request-derived by your own
1082
+ * extractor), or `'default'` (derived from the action or the transport
1083
+ * default). Set by the express and Next.js adapters. verify-access keeps a
1084
+ * `'route_config'` purpose over a commerce-derived one (e.g. an MPP paid
1085
+ * leg) only when a stored rule on the endpoint matches `requestMethod` +
1086
+ * `requestPath` with the same purpose and action.
1087
+ */
1088
+ purposeSource?: PurposeSource;
1089
+ /** 5.19.0 — the inbound agent request behind a kit confirm (see {@link AgentArtifacts}). */
1090
+ agentArtifacts?: AgentArtifacts;
1091
+ /** 5.19.0 — kit session id + protocol, stored on any approval this confirm creates. */
1092
+ metadata?: CheckoutMetadata;
1093
+ /** 5.19.0 — the inbound request's HTTP method (for the route-rule check above). */
1094
+ requestMethod?: string;
1095
+ /** 5.19.0 — the inbound request's path, without the query (for the route-rule check above). */
1096
+ requestPath?: string;
1018
1097
  /**
1019
1098
  * 3.12.0 — first-party observational data: the
1020
1099
  * offers the agent evaluated at this checkpoint (catalog browse / intent
@@ -1321,17 +1400,16 @@ interface ExpressMiddlewareOptions extends GatewayConfig {
1321
1400
  /**
1322
1401
  * Posture when the middleware itself throws an internal error (header
1323
1402
  * parsing failure, `fetchRoutes` network error, malformed proxy state,
1324
- * etc.). Default `'open'` for backward compatibility in SDK 2.4.13 —
1325
- * legitimate traffic continues to pass through during platform outages.
1403
+ * etc.).
1326
1404
  *
1327
- * In shadow mode (default), the middleware ALWAYS logs a
1328
- * `[SHADOW] would-have-denied` line on throws including correlationId so
1329
- * merchants can grep their own logs for impact analysis. The default
1330
- * flips to `'closed'` in a follow-up release once the shadow logs confirm
1331
- * legitimate traffic is unaffected.
1405
+ * 5.19.0 (behaviour change): default `'closed'` — the request is refused
1406
+ * with 503 + Retry-After + `VERIFICATION_UNAVAILABLE` (the
1407
+ * `middleware.internal_error` dimension; never an identity-shaped 401) and
1408
+ * your handler is not called. Set `'open'` explicitly to pass the request
1409
+ * through unverified instead (e.g. small-value demo merchants).
1332
1410
  *
1333
- * Small-value demo merchants can keep `'open'` indefinitely after the
1334
- * default flip by setting this explicitly.
1411
+ * The middleware always logs a `[SHADOW] would-have-denied` line on throws
1412
+ * including correlationId, whichever posture is set.
1335
1413
  */
1336
1414
  failOnError?: 'open' | 'closed';
1337
1415
  /**
@@ -1665,15 +1743,36 @@ interface ReportAttemptOptions {
1665
1743
  retried: boolean;
1666
1744
  }) => void;
1667
1745
  }
1668
- declare function fetchRoutes(config: GatewayConfig, counterpartyId: string): Promise<RouteAccessConfigShape[] | null>;
1746
+ declare function fetchRoutes(config: GatewayConfig, counterpartyId: string, options?: {
1747
+ /**
1748
+ * 5.19.0: tool names the MCP middleware gates in code, sent as
1749
+ * `?codeGates=a,b` so the dashboard can mark them "gated in code — a rule
1750
+ * here can only add checks".
1751
+ */
1752
+ codeGates?: string[];
1753
+ }): Promise<RouteAccessConfigShape[] | null>;
1669
1754
  /**
1670
1755
  * Minimal shape of an EndpointRoute as the SDK consumes it. Mirrors the
1671
1756
  * server's `EndpointRoute` type and the SDK's `RouteAccessConfig` — same
1672
1757
  * JSON moves between server and SDK unchanged.
1673
1758
  */
1674
1759
  interface RouteAccessConfigShape {
1760
+ /** Path pattern (path rules). Absent on an MCP tool rule. */
1675
1761
  pattern: string;
1676
1762
  method: string;
1763
+ /**
1764
+ * 5.19.0: MCP tool rule — the `tools/call` tool name this rule governs
1765
+ * (`mcp_server` endpoints store only tool rules: `{tool, purpose, action,
1766
+ * resource?, observe?}`). Path-rule matchers skip rules carrying it.
1767
+ */
1768
+ tool?: string;
1769
+ /** 5.19.0: a tool rule's resource override. */
1770
+ resource?: string;
1771
+ /**
1772
+ * 5.19.0: a path rule stored on an `mcp_server` endpoint before tool rules
1773
+ * existed. The MCP middleware ignores it (replace it with tool rules).
1774
+ */
1775
+ legacy?: boolean;
1677
1776
  /** Pass through unenforced (observe). Replaces `minAccessLevel: 'none'`. */
1678
1777
  observe?: boolean;
1679
1778
  minTrustScore?: number;
@@ -1929,6 +2028,14 @@ declare global {
1929
2028
  namespace Express {
1930
2029
  interface Request {
1931
2030
  agentVerification?: VerificationResult;
2031
+ /**
2032
+ * 5.19.0 (documented): the exact request bytes, when your JSON parser
2033
+ * keeps them — `express.json({ verify: (req, _res, buf) => { req.rawBody = buf } })`.
2034
+ * The gateway forwards these (not a re-serialised `req.body`) as the
2035
+ * protocol artifacts' raw body, so body digests (MPP, RFC 9421
2036
+ * content-digest) match without mounting `express.raw`.
2037
+ */
2038
+ rawBody?: Buffer | string;
1932
2039
  }
1933
2040
  }
1934
2041
  }
@@ -2036,6 +2143,37 @@ declare class VerificationGatewayClient {
2036
2143
  subAgentDepth?: number;
2037
2144
  counterpartyUrl?: string;
2038
2145
  counterpartyType?: string;
2146
+ /**
2147
+ * 5.19.0: `'quote'` marks a price / limit check (peek only: no order, no
2148
+ * approval redeemed) — prefer `quoteCheckout()`. Omitted with a
2149
+ * `transactionValue`, the call is a PURCHASE leg (see the warning below).
2150
+ */
2151
+ commercePhase?: 'quote';
2152
+ }): Promise<VerificationResult>;
2153
+ /**
2154
+ * 5.19.0: the QUOTE leg of a checkout — a price / limit check before the
2155
+ * purchase. Sends `commercePhase: 'quote'`: verify-access evaluates the
2156
+ * agent's policy at this value and tells you whether a purchase would be
2157
+ * granted, held for the owner's approval, or denied, but records no order,
2158
+ * moves no money and never redeems an approval. Always reaches the backend
2159
+ * (no verdict cache).
2160
+ *
2161
+ * Quotes count toward limit-probing detection: a run of rising quotes is
2162
+ * how an agent (or a merchant) maps a spending limit. Quote what the buyer
2163
+ * asked for, not a ladder of values.
2164
+ */
2165
+ quoteCheckout(options: {
2166
+ astraId?: string;
2167
+ apiKey?: string;
2168
+ jwt?: string;
2169
+ purpose?: string;
2170
+ action?: string;
2171
+ transactionValue?: number;
2172
+ currency?: string;
2173
+ checkoutSessionId?: string;
2174
+ attemptId?: string;
2175
+ counterpartyUrl?: string;
2176
+ counterpartyType?: string;
2039
2177
  }): Promise<VerificationResult>;
2040
2178
  /**
2041
2179
  * 5.4.0 (astra-pay): confirm-leg of a checkout — the ONLY call that may fire
@@ -2075,6 +2213,14 @@ declare class VerificationGatewayClient {
2075
2213
  * is matched to — and only to — this confirm. A held cart's approval is
2076
2214
  * bound to its checkout session and exact value; a confirm for any other
2077
2215
  * cart is held for its own approval.
2216
+ *
2217
+ * 5.19.0 checkout kits: pass the kit's `agentArtifacts` (the inbound agent
2218
+ * request — signed RFC 9421 headers with the public URL and raw-body
2219
+ * digest, or `{ unsigned: true }`) and `metadata` (`{ kitSessionId,
2220
+ * protocol }`) from the `verifyPurchase` context. The platform attributes
2221
+ * the confirm to the agent from the artifacts, and stores the metadata on
2222
+ * any approval this confirm creates so the approval event
2223
+ * (`handleApprovalEvents`) can find the kit session.
2078
2224
  */
2079
2225
  confirmCheckout(options: {
2080
2226
  astraId?: string;
@@ -2093,6 +2239,10 @@ declare class VerificationGatewayClient {
2093
2239
  /** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
2094
2240
  * the platform default `fulfilment.email` to the buyer's account email. */
2095
2241
  buyerEmail?: string;
2242
+ /** 5.19.0: the inbound agent request behind this confirm (from the kit's verifyPurchase ctx). */
2243
+ agentArtifacts?: AgentArtifacts;
2244
+ /** 5.19.0: `{ kitSessionId, protocol }` (from the kit's verifyPurchase ctx). */
2245
+ metadata?: CheckoutMetadata;
2096
2246
  counterpartyUrl?: string;
2097
2247
  counterpartyType?: string;
2098
2248
  }): Promise<VerificationResult>;
@@ -3954,19 +4104,49 @@ interface McpMiddlewareOptions extends GatewayConfig {
3954
4104
  recordDecisions?: boolean;
3955
4105
  /** Forward runtime challenge (default `true`). */
3956
4106
  enableRuntimeChallenge?: boolean;
4107
+ /**
4108
+ * 5.19.0: how a dashboard tool rule combines with a code `toolGates`
4109
+ * entry for the same tool. With `apiKey` + `counterpartyId` set, the
4110
+ * middleware fetches the endpoint's tool rules (`{tool, purpose, action,
4111
+ * resource?, observe?}`, edited in the AstraSync dashboard; refreshed every
4112
+ * `routesRefreshMs`) and turns each into a gate for that tool.
4113
+ *
4114
+ * - `'code'` (default): a dashboard rule can TIGHTEN a code gate but never
4115
+ * loosen it. For a tool gated in code (object form), a dashboard
4116
+ * `observe` rule, or one with no purpose, is ignored; a dashboard rule
4117
+ * whose purpose or action differs is evaluated IN ADDITION — both must
4118
+ * pass. Tools with no code gate (or a code `'observe'`) follow the
4119
+ * dashboard rule.
4120
+ * - `'dashboard'`: the dashboard rule wins outright for every tool it
4121
+ * names (including `observe`).
4122
+ *
4123
+ * Rules flagged `legacy: true` (path rules stored on an MCP endpoint before
4124
+ * tool rules existed) are ignored. The middleware sends its code-gated tool
4125
+ * names on the policy fetch (`?codeGates=`) so the dashboard can mark them.
4126
+ */
4127
+ toolGatePrecedence?: 'code' | 'dashboard';
4128
+ /** 5.19.0: refresh interval (ms) for the dashboard tool rules. Default 5 minutes. */
4129
+ routesRefreshMs?: number;
3957
4130
  /**
3958
4131
  * Posture when the MCP middleware itself throws an internal error.
3959
- * Default `'open'` for backward compatibility in SDK 2.4.13. Shadow logs
3960
- * record what WOULD be denied with `failOnError: 'closed'` so merchants
3961
- * can grep correlationId for impact analysis during the observation
3962
- * window. Default flips to `'closed'` in a follow-up release.
3963
4132
  *
3964
- * 5.12.0: `'closed'` answers the retryable verification-unavailable
3965
- * JSON-RPC error (HTTP 503 + Retry-After, code -32003) — never an
3966
- * identity-shaped 401.
4133
+ * 5.19.0 (behaviour change): default `'closed'` — an internal throw answers
4134
+ * the retryable verification-unavailable JSON-RPC error (HTTP 503 +
4135
+ * Retry-After, code -32003; never an identity-shaped 401) and the tool
4136
+ * handler is not called. `'open'` (pass the call through unverified) is
4137
+ * an explicit opt-in. The `[SHADOW] would-have-denied` log line is still
4138
+ * written on every throw, with the correlationId.
3967
4139
  */
3968
4140
  failOnError?: 'open' | 'closed';
3969
4141
  }
4142
+ /** 5.19.0: a dashboard tool rule as the MCP middleware evaluates it. */
4143
+ interface DashboardToolRule {
4144
+ tool: string;
4145
+ purpose?: string;
4146
+ action?: string;
4147
+ resource?: string;
4148
+ observe?: boolean;
4149
+ }
3970
4150
  /**
3971
4151
  * Create the MCP middleware. Attach AFTER `express.json()` — the body must
3972
4152
  * already be a parsed object.
@@ -5166,7 +5346,7 @@ declare function detectRuntime(userAgent: string | undefined | null): string | u
5166
5346
  * silently (never throwing), so this is a no-op there — which is correct:
5167
5347
  * in a browser the page's real UA is the honest identity.
5168
5348
  */
5169
- declare const SDK_USER_AGENT = "astrasync-sdk/5.18.1";
5349
+ declare const SDK_USER_AGENT = "astrasync-sdk/5.19.0";
5170
5350
  declare const sdkFetch: typeof fetch;
5171
5351
 
5172
5352
  interface LocalPolicy {
@@ -5284,7 +5464,7 @@ declare function parseYaml(yamlContent: string): ParseResult;
5284
5464
  * is fine — bumping both in the release-ceremony commit keeps them
5285
5465
  * lockstep.
5286
5466
  */
5287
- declare const SDK_VERSION = "5.18.1";
5467
+ declare const SDK_VERSION = "5.19.0";
5288
5468
 
5289
5469
  /**
5290
5470
  * 5.15.0 — the `UCP-Agent` request header (UCP 2026-08-25): an RFC 8941
@@ -5634,6 +5814,15 @@ declare function finishIdempotent(opts: IdempotencyOptions, decision: Extract<Id
5634
5814
  headers: Record<string, string>;
5635
5815
  body: string;
5636
5816
  }): Promise<void>;
5817
+ /**
5818
+ * 5.19.0: release a key without storing the response — for a NON-TERMINAL
5819
+ * outcome (e.g. a checkout held for the owner's approval) that a retry with
5820
+ * the same key must re-run rather than replay. The checkout kits use it for
5821
+ * held responses, so a re-drive after the approval reaches the kit.
5822
+ */
5823
+ declare function abandonIdempotent(opts: IdempotencyOptions, decision: Extract<IdempotencyDecision, {
5824
+ kind: 'proceed';
5825
+ }>): Promise<void>;
5637
5826
  interface ExpressReq {
5638
5827
  method: string;
5639
5828
  originalUrl?: string;
@@ -5664,6 +5853,63 @@ interface KitRequestContext {
5664
5853
  */
5665
5854
  callerId?: string;
5666
5855
  }
5856
+ /**
5857
+ * 5.19.0: a cart-level message from your `validateCart` hook. `type`
5858
+ * defaults to `'error'`; any error keeps the session from being completed
5859
+ * (UCP `incomplete`, ACP `not_ready_for_payment`) and `complete` is refused
5860
+ * before AstraSync is called. `path` points at the offending part of the
5861
+ * cart (e.g. `$.line_items[0].quantity`) — UCP `path`, ACP `param`.
5862
+ */
5863
+ interface KitMessage {
5864
+ type?: 'error' | 'warning' | 'info';
5865
+ code: string;
5866
+ content: string;
5867
+ path?: string;
5868
+ }
5869
+ /** 5.19.0: retry policy for settlement reports (`reportRetry` kit option). */
5870
+ interface ReportRetryOptions {
5871
+ /** Total attempts. Default 3. */
5872
+ attempts?: number;
5873
+ /** First backoff in ms, doubled per retry. Default 250. */
5874
+ backoffMs?: number;
5875
+ }
5876
+ /**
5877
+ * 5.19.0: what an approval-event resume did. `terminal` outcomes are final
5878
+ * for the event (the dispatcher answers 2xx and marks the event seen);
5879
+ * non-terminal ones (`busy`, `still_held`) answer 5xx so the platform
5880
+ * retries.
5881
+ */
5882
+ type ResumeOutcome = 'completed' | 'pending' | 'payment_failed' | 'cart_invalid' | 'not_authorized' | 'declined' | 'already_completed' | 'canceled' | 'not_held' | 'stale' | 'not_found' | 'busy' | 'still_held';
5883
+ interface ResumeResult<S> {
5884
+ outcome: ResumeOutcome;
5885
+ terminal: boolean;
5886
+ session: S | null;
5887
+ }
5888
+ /** 5.19.0: the approval event AstraSync POSTs to your endpoint's Events URL. */
5889
+ interface ApprovalEvent {
5890
+ /** Stable across retries — dedupe on it. */
5891
+ eventId: string;
5892
+ type: 'step_up.approved' | 'step_up.denied' | 'step_up.expired' | 'step_up.lapsed';
5893
+ approvalId: string;
5894
+ /** The cart id the confirm carried (the platform's, else the kit's session id). */
5895
+ checkoutSessionId: string;
5896
+ /** The kit session id the confirm carried in `metadata`. */
5897
+ kitSessionId?: string;
5898
+ protocol?: 'ucp' | 'acp';
5899
+ counterpartyId: string;
5900
+ agentAstraId: string;
5901
+ transactionValue: number;
5902
+ currency: string;
5903
+ decidedAt: string;
5904
+ /** Approved only: the approval can be redeemed until this instant (ISO). */
5905
+ redeemBy?: string;
5906
+ }
5907
+ /** A kit the approval-event dispatcher can route to (both checkout kits). */
5908
+ interface ApprovalEventKit {
5909
+ readonly protocol: 'ucp' | 'acp';
5910
+ /** Apply one verified event to the kit session it names. */
5911
+ applyApprovalEvent(event: ApprovalEvent): Promise<ResumeResult<unknown>>;
5912
+ }
5667
5913
 
5668
5914
  interface CatalogItem {
5669
5915
  id: string;
@@ -5682,7 +5928,9 @@ interface CheckoutLine {
5682
5928
  }
5683
5929
  interface CheckoutSession {
5684
5930
  id: string;
5685
- status: 'incomplete' | 'requires_escalation' | 'ready_for_complete' | 'complete_in_progress' | 'completed' | 'canceled';
5931
+ status: 'incomplete' | 'requires_escalation' | 'ready_for_complete' | 'complete_in_progress' | 'completed' | 'canceled'
5932
+ /** 5.19.0: kit-internal — `resolvePending` is finishing it (rendered as `complete_in_progress`). */
5933
+ | 'finishing';
5686
5934
  currency: string;
5687
5935
  line_items: CheckoutLine[];
5688
5936
  totals: Array<{
@@ -5705,6 +5953,8 @@ interface CheckoutSession {
5705
5953
  /** 5.18.0: a settlement the processor hasn't confirmed yet (see `resolvePending`). */
5706
5954
  _pending?: {
5707
5955
  orderId?: string;
5956
+ /** 5.19.0: the confirm's verification session id (report fallback when there is no orderId). */
5957
+ sessionId?: string;
5708
5958
  report: {
5709
5959
  amountMinor: number;
5710
5960
  currency: string;
@@ -5712,6 +5962,25 @@ interface CheckoutSession {
5712
5962
  /** The verification result, minus merchant-lane secrets. */
5713
5963
  result: VerificationResult;
5714
5964
  };
5965
+ /** 5.19.0: the owner approval a held checkout waits for. */
5966
+ _approvalId?: string;
5967
+ /** 5.19.0: the agent behind the held confirm (re-sent when the hold resumes). */
5968
+ _astraId?: string;
5969
+ /**
5970
+ * 5.19.0: what was held — the priced cart and the non-secret payment input
5971
+ * — so an approved hold settles exactly what the owner approved, without
5972
+ * the agent and without re-pricing.
5973
+ */
5974
+ _held?: {
5975
+ line_items: CheckoutLine[];
5976
+ totals: Array<{
5977
+ type: string;
5978
+ amount: number;
5979
+ }>;
5980
+ instrument?: Record<string, unknown>;
5981
+ pollUrl?: string;
5982
+ expiresAt?: string;
5983
+ };
5715
5984
  /** 5.18.0: the platform's order webhook URL from its profile, when it declared one. */
5716
5985
  _webhookUrl?: string;
5717
5986
  _platformProfile?: string;
@@ -5737,6 +6006,15 @@ interface CheckoutStore {
5737
6006
  claim?(id: string, from: CheckoutSession['status'], to: CheckoutSession['status']): Promise<boolean>;
5738
6007
  /** 5.18.0: the session that produced an order (for `GET /orders/{id}`). */
5739
6008
  findByOrderId?(orderId: string): Promise<CheckoutSession | null>;
6009
+ /**
6010
+ * 5.19.0: the session for an AstraSync cart id — the platform's
6011
+ * `X-Astra-Checkout-Session` value, else the session's own id. Approval
6012
+ * events name the cart this way; without it the kit can only use the
6013
+ * event's `kitSessionId`.
6014
+ */
6015
+ findByCheckoutSessionId?(checkoutSessionId: string): Promise<CheckoutSession | null>;
6016
+ /** 5.19.0: sessions held for an owner approval (`pollHeldSessions` with no ids). */
6017
+ listHeld?(): Promise<CheckoutSession[]>;
5740
6018
  }
5741
6019
  declare class MemoryCheckoutStore implements CheckoutStore {
5742
6020
  private m;
@@ -5745,6 +6023,8 @@ declare class MemoryCheckoutStore implements CheckoutStore {
5745
6023
  put(s: CheckoutSession): Promise<void>;
5746
6024
  claim(id: string, from: CheckoutSession['status'], to: CheckoutSession['status']): Promise<boolean>;
5747
6025
  findByOrderId(orderId: string): Promise<CheckoutSession | null>;
6026
+ findByCheckoutSessionId(checkoutSessionId: string): Promise<CheckoutSession | null>;
6027
+ listHeld(): Promise<CheckoutSession[]>;
5748
6028
  }
5749
6029
  /** 5.18.0: a policy link shown with the checkout (part of the signed body). */
5750
6030
  interface UcpLink {
@@ -5816,8 +6096,20 @@ interface UcpCheckoutKitOptions {
5816
6096
  /** Profile inputs (endpoint, keys, paymentHandlers, ap2Mandates). */
5817
6097
  profile: BuildProfileOptions;
5818
6098
  currency: string;
5819
- /** Your catalog: the item, or null when unknown. */
5820
- catalog: (itemId: string) => Promise<CatalogItem | null>;
6099
+ /**
6100
+ * Your catalog: the item, or null when unknown. 5.19.0: also receives the
6101
+ * requested quantity (for simple per-line caps — or use `validateCart`).
6102
+ */
6103
+ catalog: (itemId: string, quantity: number) => Promise<CatalogItem | null>;
6104
+ /**
6105
+ * 5.19.0: cart-level validation (stock, per-line or per-cart caps, …). Runs
6106
+ * on create, update and complete — before the session is claimed and
6107
+ * before `verifyPurchase` — and when an approved hold resumes. Any error
6108
+ * message keeps the session `incomplete` (messages are `recoverable`, with
6109
+ * your `path`, e.g. `$.line_items[0].quantity`) and `complete` is refused
6110
+ * without calling AstraSync.
6111
+ */
6112
+ validateCart?: (session: CheckoutSession) => Promise<KitMessage[]>;
5821
6113
  /** AstraSync verification of the purchase (e.g. `client.confirmCheckout`). */
5822
6114
  verifyPurchase: (ctx: {
5823
6115
  session: CheckoutSession;
@@ -5831,6 +6123,18 @@ interface UcpCheckoutKitOptions {
5831
6123
  attemptId?: string;
5832
6124
  checkoutJwt?: string;
5833
6125
  valueMajor: number;
6126
+ /**
6127
+ * 5.19.0: the inbound agent request (pass to `confirmCheckout`). An
6128
+ * approved hold resuming has none (`undefined`) — no agent request is
6129
+ * involved.
6130
+ */
6131
+ agentArtifacts?: AgentArtifacts;
6132
+ /** 5.19.0: `{ kitSessionId, protocol: 'ucp' }` — pass to `confirmCheckout`. */
6133
+ metadata: CheckoutMetadata;
6134
+ /** 5.19.0: set when an approved hold resumes (`resumeApproved`). */
6135
+ resumed?: {
6136
+ approvalId?: string;
6137
+ };
5834
6138
  }) => Promise<VerificationResult>;
5835
6139
  /** Charge / redeem with YOUR processor using the artifact AstraSync handed you. */
5836
6140
  settle: (ctx: {
@@ -5840,14 +6144,36 @@ interface UcpCheckoutKitOptions {
5840
6144
  }) => Promise<SettleResult>;
5841
6145
  /** Report the outcome to AstraSync (e.g. `client.reportSettlement`). */
5842
6146
  reportSettlement?: (r: Parameters<VerificationGatewayClient['reportSettlement']>[0]) => Promise<unknown>;
5843
- /** Create your order once paid. */
6147
+ /** Create your order once paid. 5.19.0: `settled` is your processor's settled outcome. */
5844
6148
  fulfil: (ctx: {
5845
6149
  session: CheckoutSession;
5846
6150
  result: VerificationResult;
6151
+ settled: Extract<PendingResolution, {
6152
+ status: 'settled';
6153
+ }>;
5847
6154
  }) => Promise<{
5848
6155
  id: string;
5849
6156
  permalink_url?: string;
5850
6157
  }>;
6158
+ /** 5.19.0: settlement-report retries on network / 429 / 5xx (default 3 attempts, 250 ms backoff). */
6159
+ reportRetry?: ReportRetryOptions;
6160
+ /**
6161
+ * 5.19.0: a settlement report or order webhook that still failed after its
6162
+ * retries (default: `console.error`). The order is yours to reconcile.
6163
+ */
6164
+ onReportError?: (err: unknown, ctx: {
6165
+ sessionId: string;
6166
+ orderId?: string;
6167
+ kind?: 'settlement_report' | 'order_webhook';
6168
+ }) => void;
6169
+ /**
6170
+ * 5.19.0: the public origin agents reach this kit at (e.g.
6171
+ * `https://shop.example` behind a TLS-terminating proxy). Used by
6172
+ * `expressHandler` to rebuild the request URL (signature `@target-uri` /
6173
+ * `@authority`) and for the forwarded agent artifacts. Default: the origin
6174
+ * of `profile.endpoint`.
6175
+ */
6176
+ publicOrigin?: string;
5851
6177
  /** Merchant key for ap2.merchant_authorization (when ap2Mandates). */
5852
6178
  signingKey?: {
5853
6179
  privateKey: KeyLike | KeyObject;
@@ -5926,11 +6252,73 @@ declare function createUcpCheckoutKit(opts: UcpCheckoutKitOptions): {
5926
6252
  status: number;
5927
6253
  attempts: number;
5928
6254
  } | null>;
6255
+ /** 5.19.0 */
6256
+ protocol: "ucp";
6257
+ publicOrigin: string;
6258
+ resumeApproved: (sessionId: string, event?: Pick<ApprovalEvent, "approvalId">) => Promise<ResumeResult<CheckoutSession>>;
6259
+ resumeDeclined: (sessionId: string, reason?: "denied" | "expired" | "lapsed" | (string & {}), event?: Pick<ApprovalEvent, "approvalId">) => Promise<ResumeResult<CheckoutSession>>;
6260
+ applyApprovalEvent: (event: ApprovalEvent) => Promise<ResumeResult<CheckoutSession>>;
6261
+ pollHeldSessions: (o?: {
6262
+ sessionIds?: string[];
6263
+ /** Resolves relative poll URLs (your `apiBaseUrl`). */
6264
+ apiBaseUrl?: string;
6265
+ }) => Promise<Array<{
6266
+ sessionId: string;
6267
+ outcome: ResumeResult<CheckoutSession>["outcome"] | "pending";
6268
+ }>>;
5929
6269
  };
5930
6270
 
5931
6271
  /** RFC 8785-style canonical JSON (sorted keys, no whitespace). */
5932
6272
  declare function canonicalJson(value: unknown): string;
5933
6273
 
6274
+ /** Where the dispatcher remembers events it finished (dedupe). */
6275
+ interface SeenEvents {
6276
+ has(eventId: string): Promise<boolean>;
6277
+ add(eventId: string): Promise<void>;
6278
+ }
6279
+ /** Process-local {@link SeenEvents} (single instance / tests). Bounded. */
6280
+ declare class MemorySeenEvents implements SeenEvents {
6281
+ private max;
6282
+ private ids;
6283
+ constructor(max?: number);
6284
+ has(eventId: string): Promise<boolean>;
6285
+ add(eventId: string): Promise<void>;
6286
+ }
6287
+ interface HandleApprovalEventsOptions {
6288
+ /** The kits the events can name (e.g. `[ucpKit, acpKit]`). */
6289
+ kits: ApprovalEventKit[];
6290
+ /**
6291
+ * Dedupe store. An object gets `add(eventId)` at a terminal outcome; a
6292
+ * function is a check only (you record seen ids yourself). Default: a
6293
+ * process-local memory set — use a shared store across instances.
6294
+ */
6295
+ seen?: SeenEvents | ((eventId: string) => Promise<boolean>);
6296
+ /** Signature timestamp tolerance (s). Default 300. */
6297
+ toleranceSeconds?: number;
6298
+ /** Override "now" (tests). */
6299
+ nowMs?: number;
6300
+ /** Called for every applied event (logging / metrics). */
6301
+ onEvent?: (event: ApprovalEvent, outcome: ResumeOutcome | 'duplicate' | 'ignored') => void;
6302
+ }
6303
+ interface ApprovalEventsResponse {
6304
+ /** 2xx: done (don't retry). 401/400: refused. 503: retry later. */
6305
+ status: number;
6306
+ body: {
6307
+ ok: boolean;
6308
+ eventId?: string;
6309
+ outcome?: ResumeOutcome | 'duplicate' | 'ignored';
6310
+ error?: string;
6311
+ };
6312
+ }
6313
+ /**
6314
+ * 5.19.0: verify and apply one approval event. Approved → the kit's
6315
+ * `resumeApproved` (settle, report, fulfil — no agent call); denied /
6316
+ * expired / lapsed → `resumeDeclined`. Routes by `protocol` and
6317
+ * `kitSessionId`, falling back to each kit's cart-id lookup. Never throws:
6318
+ * answer the returned `status` and `body`.
6319
+ */
6320
+ declare function handleApprovalEvents(rawBody: string | Buffer | Uint8Array, headers: Record<string, string | string[] | undefined> | Headers, secret: string | readonly string[], opts: HandleApprovalEventsOptions): Promise<ApprovalEventsResponse>;
6321
+
5934
6322
  /**
5935
6323
  * 5.15.0 — x402 v2 (x402 Foundation, specs/transports-v2/http.md) helpers for
5936
6324
  * a MERCHANT. The merchant's own facilitator verifies and settles; AstraSync
@@ -6306,7 +6694,9 @@ declare function aepPublicKeyDocument(keys: Array<{
6306
6694
  declare const ACP_API_VERSION = "2026-04-17";
6307
6695
  /** 5.18.0: `API-Version` values this kit serves. */
6308
6696
  declare const ACP_SUPPORTED_API_VERSIONS: readonly string[];
6309
- type AcpStatus = 'not_ready_for_payment' | 'ready_for_payment' | 'pending_approval' | 'complete_in_progress' | 'completed' | 'canceled';
6697
+ type AcpStatus = 'not_ready_for_payment' | 'ready_for_payment' | 'pending_approval' | 'complete_in_progress' | 'completed' | 'canceled'
6698
+ /** 5.19.0: kit-internal — `resolvePending` is finishing it (rendered as `complete_in_progress`). */
6699
+ | 'finishing';
6310
6700
  interface AcpMessage {
6311
6701
  type: 'error' | 'info' | 'warning';
6312
6702
  code?: string;
@@ -6347,12 +6737,29 @@ interface AcpCheckoutSession {
6347
6737
  /** 5.18.0: a settlement the processor hasn't confirmed yet (see `resolvePending`). */
6348
6738
  _pending?: {
6349
6739
  orderId?: string;
6740
+ /** 5.19.0: the confirm's verification session id (report fallback). */
6741
+ sessionId?: string;
6350
6742
  report: {
6351
6743
  amountMinor: number;
6352
6744
  currency: string;
6353
6745
  };
6354
6746
  result: VerificationResult;
6355
6747
  };
6748
+ /** 5.19.0: the owner approval a held session waits for, and the held confirm's agent + chain. */
6749
+ _approvalId?: string;
6750
+ _astraId?: string;
6751
+ _attemptId?: string;
6752
+ /** 5.19.0: the held cart and the NON-SECRET `payment_data` fields (see the UCP `_held`). */
6753
+ _held?: {
6754
+ line_items: AcpCheckoutSession['line_items'];
6755
+ totals: Array<{
6756
+ type: string;
6757
+ amount: number;
6758
+ }>;
6759
+ paymentData?: Record<string, unknown>;
6760
+ pollUrl?: string;
6761
+ expiresAt?: string;
6762
+ };
6356
6763
  }
6357
6764
  /** 5.18.0: the ACP kit's session store (`claim` and the memory default as in the UCP kit). */
6358
6765
  interface AcpCheckoutStore {
@@ -6360,13 +6767,24 @@ interface AcpCheckoutStore {
6360
6767
  put(s: AcpCheckoutSession): Promise<void>;
6361
6768
  /** Atomic compare-and-set of `status` (see the UCP `CheckoutStore.claim`). */
6362
6769
  claim?(id: string, from: AcpStatus, to: AcpStatus): Promise<boolean>;
6770
+ /** 5.19.0: the session for an AstraSync cart id (see the UCP `CheckoutStore`). */
6771
+ findByCheckoutSessionId?(checkoutSessionId: string): Promise<AcpCheckoutSession | null>;
6772
+ /** 5.19.0: sessions held for an owner approval (`pollHeldSessions` with no ids). */
6773
+ listHeld?(): Promise<AcpCheckoutSession[]>;
6363
6774
  }
6364
6775
  type AcpCheckoutStatus = AcpStatus;
6365
6776
  interface AcpCheckoutKitOptions {
6366
6777
  currency: string;
6367
6778
  /** Payment handlers you accept (endpoint paymentHandlers), e.g. ['ai.astrasync.voucher']. */
6368
6779
  paymentHandlers: string[];
6369
- catalog: (itemId: string) => Promise<CatalogItem | null>;
6780
+ /** Your catalog. 5.19.0: also receives the requested quantity. */
6781
+ catalog: (itemId: string, quantity: number) => Promise<CatalogItem | null>;
6782
+ /**
6783
+ * 5.19.0: cart-level validation (see the UCP kit). Any error keeps the
6784
+ * session `not_ready_for_payment` (messages are `invalid`, with your path
6785
+ * as `param`) and `complete` is refused without calling AstraSync.
6786
+ */
6787
+ validateCart?: (session: AcpCheckoutSession) => Promise<KitMessage[]>;
6370
6788
  verifyPurchase: (ctx: {
6371
6789
  session: AcpCheckoutSession;
6372
6790
  /** Pass as `checkoutSessionId` to AstraSync (the platform's cart id when sent). */
@@ -6374,6 +6792,14 @@ interface AcpCheckoutKitOptions {
6374
6792
  astraId?: string;
6375
6793
  attemptId?: string;
6376
6794
  valueMajor: number;
6795
+ /** 5.19.0: always `{ unsigned: true, protocol: 'acp' }` (pass to `confirmCheckout`); absent on a resume. */
6796
+ agentArtifacts?: AgentArtifacts;
6797
+ /** 5.19.0: `{ kitSessionId, protocol: 'acp' }` — pass to `confirmCheckout`. */
6798
+ metadata: CheckoutMetadata;
6799
+ /** 5.19.0: set when an approved hold resumes. */
6800
+ resumed?: {
6801
+ approvalId?: string;
6802
+ };
6377
6803
  }) => Promise<VerificationResult>;
6378
6804
  settle: (ctx: {
6379
6805
  session: AcpCheckoutSession;
@@ -6381,13 +6807,37 @@ interface AcpCheckoutKitOptions {
6381
6807
  paymentData?: Record<string, unknown>;
6382
6808
  }) => Promise<SettleResult>;
6383
6809
  reportSettlement?: (r: Parameters<VerificationGatewayClient['reportSettlement']>[0]) => Promise<unknown>;
6810
+ /** 5.19.0: `settled` is your processor's settled outcome. */
6384
6811
  fulfil: (ctx: {
6385
6812
  session: AcpCheckoutSession;
6386
6813
  result: VerificationResult;
6814
+ settled: Extract<PendingResolution, {
6815
+ status: 'settled';
6816
+ }>;
6387
6817
  }) => Promise<{
6388
6818
  id: string;
6389
6819
  permalink_url?: string;
6390
6820
  }>;
6821
+ /** 5.19.0: settlement-report retries (default 3 attempts, 250 ms backoff). */
6822
+ reportRetry?: ReportRetryOptions;
6823
+ /** 5.19.0: a settlement report that still failed after retries (default `console.error`). */
6824
+ onReportError?: (err: unknown, ctx: {
6825
+ sessionId: string;
6826
+ orderId?: string;
6827
+ kind?: 'settlement_report' | 'order_webhook';
6828
+ }) => void;
6829
+ /**
6830
+ * 5.19.0: the public origin agents reach this kit at; `expressHandler`
6831
+ * rebuilds the request URL from it. Default: Express's own view, using
6832
+ * `X-Forwarded-Proto` / `X-Forwarded-Host` only when `trust proxy` is set.
6833
+ */
6834
+ publicOrigin?: string;
6835
+ /** 5.19.0: policy links (terms of use, privacy, …) returned on every session. */
6836
+ links?: Array<{
6837
+ type: string;
6838
+ url: string;
6839
+ title?: string;
6840
+ }>;
6391
6841
  /** Base path the kit is mounted at (default ''). */
6392
6842
  basePath?: string;
6393
6843
  store?: AcpCheckoutStore;
@@ -6465,6 +6915,19 @@ declare function buildAcpWellKnown(opts: AcpWellKnownOptions): {
6465
6915
  declare function createAcpCheckoutKit(opts: AcpCheckoutKitOptions): {
6466
6916
  handle: (req: Request, reqCtx?: KitRequestContext) => Promise<Response>;
6467
6917
  resolvePending: (sessionId: string, outcome: PendingResolution) => Promise<AcpCheckoutSession | null>;
6918
+ /** 5.19.0 */
6919
+ protocol: "acp";
6920
+ publicOrigin: string | undefined;
6921
+ resumeApproved: (sessionId: string, event?: Pick<ApprovalEvent, "approvalId">) => Promise<ResumeResult<AcpCheckoutSession>>;
6922
+ resumeDeclined: (sessionId: string, reason?: "denied" | "expired" | "lapsed" | (string & {}), event?: Pick<ApprovalEvent, "approvalId">) => Promise<ResumeResult<AcpCheckoutSession>>;
6923
+ applyApprovalEvent: (event: ApprovalEvent) => Promise<ResumeResult<AcpCheckoutSession>>;
6924
+ pollHeldSessions: (o?: {
6925
+ sessionIds?: string[];
6926
+ apiBaseUrl?: string;
6927
+ }) => Promise<Array<{
6928
+ sessionId: string;
6929
+ outcome: ResumeResult<AcpCheckoutSession>["outcome"] | "pending";
6930
+ }>>;
6468
6931
  };
6469
6932
 
6470
6933
  /**
@@ -6483,11 +6946,28 @@ declare function createAcpCheckoutKit(opts: AcpCheckoutKitOptions): {
6483
6946
  * When the AstraSync middleware ran first, the caller's verified ASTRA-id
6484
6947
  * (`req.agentVerification.agent.astraId`) scopes sessions and idempotency
6485
6948
  * keys; override with `callerId`.
6949
+ *
6950
+ * 5.19.0:
6951
+ * - the request URL the kit sees uses the kit's `publicOrigin` (UCP default:
6952
+ * the origin of `profile.endpoint`), so RFC 9421 `@target-uri` /
6953
+ * `@authority` and the forwarded agent artifacts match what the agent
6954
+ * signed behind a TLS-terminating proxy. Without one (ACP default), the
6955
+ * origin is `X-Forwarded-Proto` / `X-Forwarded-Host` when Express
6956
+ * `trust proxy` is set, else `req.protocol` + Host.
6957
+ * - `approvalEventsPath` + `webhookSecret` mount the owner-approval events
6958
+ * receiver on the same handler (`handleApprovalEvents`); or mount
6959
+ * `approvalEventsHandler({ secret, kits: [ucpKit, acpKit] })` on its own
6960
+ * path to serve both kits from one Events URL.
6486
6961
  */
6487
6962
 
6488
6963
  /** Anything with a fetch-style `handle` (both checkout kits). */
6489
6964
  interface FetchKit {
6490
6965
  handle(req: Request, ctx?: KitRequestContext): Promise<Response>;
6966
+ /** 5.19.0: the public origin to rebuild request URLs with (both kits expose it). */
6967
+ readonly publicOrigin?: string;
6968
+ /** 5.19.0: present on both kits — makes the kit an approval-event target. */
6969
+ readonly protocol?: 'ucp' | 'acp';
6970
+ applyApprovalEvent?: ApprovalEventKit['applyApprovalEvent'];
6491
6971
  }
6492
6972
  /** The parts of an Express request this adapter reads. */
6493
6973
  interface KitExpressRequest {
@@ -6499,6 +6979,10 @@ interface KitExpressRequest {
6499
6979
  body?: unknown;
6500
6980
  rawBody?: unknown;
6501
6981
  get?(name: string): string | undefined;
6982
+ /** Express app (to read the `trust proxy` setting). */
6983
+ app?: {
6984
+ get(name: string): unknown;
6985
+ };
6502
6986
  agentVerification?: {
6503
6987
  identityVerified?: boolean;
6504
6988
  agent?: {
@@ -6515,7 +6999,35 @@ interface KitExpressResponse {
6515
6999
  interface ExpressHandlerOptions {
6516
7000
  /** The caller's verified ASTRA-id (default: from `req.agentVerification` when identity-verified). */
6517
7001
  callerId?: (req: KitExpressRequest) => string | undefined;
6518
- }
7002
+ /**
7003
+ * 5.19.0: serve owner-approval events on this path (POST; matched against
7004
+ * the full request path or the path under the mount point), e.g.
7005
+ * `'/astrasync/events'`. Set the endpoint's Events URL to it. Needs
7006
+ * `webhookSecret`.
7007
+ */
7008
+ approvalEventsPath?: string;
7009
+ /** 5.19.0: the endpoint's webhook secret — or `[current, previous]` during a rotation. */
7010
+ webhookSecret?: string | readonly string[];
7011
+ /** 5.19.0: the kits events may name (default: this kit). */
7012
+ approvalEventKits?: ApprovalEventKit[];
7013
+ /** 5.19.0: dedupe store for event ids (default: process-local memory). */
7014
+ seenEvents?: SeenEvents | ((eventId: string) => Promise<boolean>);
7015
+ }
7016
+ interface ApprovalEventsHandlerOptions {
7017
+ /** The endpoint's webhook secret — or `[current, previous]` during a rotation. */
7018
+ secret: string | readonly string[];
7019
+ /** The kits events may name, e.g. `[ucpKit, acpKit]`. */
7020
+ kits: ApprovalEventKit[];
7021
+ /** Dedupe store (default: process-local memory). */
7022
+ seen?: SeenEvents | ((eventId: string) => Promise<boolean>);
7023
+ }
7024
+ /**
7025
+ * 5.19.0: an Express handler for the endpoint's Events URL, serving both
7026
+ * kits: `app.post('/astrasync/events', express.raw({ type: '*\/*' }),
7027
+ * approvalEventsHandler({ secret, kits: [ucpKit, acpKit] }))`. Answers 2xx
7028
+ * when done, 401 on a bad signature, 503 to have the platform retry.
7029
+ */
7030
+ declare function approvalEventsHandler(options: ApprovalEventsHandlerOptions): (req: KitExpressRequest, res: KitExpressResponse, next: (err?: unknown) => void) => Promise<void>;
6519
7031
  /** An Express handler that runs a checkout kit and writes its Response back. */
6520
7032
  declare function expressHandler(kit: FetchKit, options?: ExpressHandlerOptions): (req: KitExpressRequest, res: KitExpressResponse, next: (err?: unknown) => void) => Promise<void>;
6521
7033
 
@@ -6766,4 +7278,4 @@ declare function contentDigest(body: string): string;
6766
7278
  */
6767
7279
  declare function signHttpRequest(req: SignableRequest, opts: SignHttpRequestOptions): Promise<Record<string, string>>;
6768
7280
 
6769
- export { ACP_API_VERSION, ACP_SUPPORTED_API_VERSIONS, AEP_SPEC_VERSION, AP2_VCT, type AcpCheckoutKitOptions, type AcpCheckoutSession, type AcpCheckoutStatus, type AcpCheckoutStore, type AcpWellKnownOptions, type AepActorType, type AepArtifactRecord, type AepArtifactType, AepChain, type AepChainOptions, type AepChainVerification, type AepHashInput, AgentClient, type AgentCredentials, type AgentProtocol, type AgentProtocolIdentities, type AgentRecord, type Ap2Party, type Ap2VerifyResult, AstraSync, type AstraSyncAepEvidence, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, type AstraSyncMandates, type AttemptOutcome, type AttemptReport, AuthenticationError, type BuildGuidanceParams, CAPTURE_SCHEMA_VERSION, type CallerMetadata, ChallengeHandler, type CommerceArtifactsPayload, type CommerceContext, type CommercePipelineInput, type CommerceShieldProps, type ConsiderationItem, type ConsiderationSet, type CounterpartyType, DECLARED_SOURCE_MAX, DEFAULT_EDGE_CONFIG, DEFAULT_IDEMPOTENCY_TTL_MS, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressHandlerOptions, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FetchKit, type FiatSettlementBinding, type FrameworkConfig, type FulfilmentInfo, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HealthResponse, type HttpSignatureAlgorithm, type IdempotencyOptions, type IdempotencyRecord, type IdempotencyStore, KYDRequiredError, type KitExpressRequest, type KitExpressResponse, type KitRequestContext, type KyaPayIdentity, type KyaPayResult, type KyaPayTokenType, type KyaPayVerifyOptions, type ParseResult as LocalPolicyParseResult, type ValidationError as LocalPolicyValidationError, type ValidationResult as LocalPolicyValidationResult, MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, MCP_VERIFIED_HOP_HEADER, MCP_VERIFIED_HOP_MAX_AGE_MS, type McpMiddlewareOptions, MemoryCheckoutStore, MemoryIdempotencyStore, MemoryMppChallengeStore, type MerchantSettlementToken, type ModelConfig, type MppChallenge, type MppChallengeStore, type MppCredential, type MppReceipt, type MppVerifyOptions, type MppVerifyResult, type NegotiationResult, type NextJsMiddlewareOptions, type ObservedMetadata, type PDLSSConfig$1 as PDLSSConfig, type PDLSSDuration, type PDLSSInfo, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, PLATFORM_AGENT_SIGNATURES, type PendingRegistrationResponse, type PendingResolution, type PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, RUNTIME_SIGNATURES, RedisIdempotencyStore, type RedisLike, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type ReportAttemptOptions, type RootKeyResolver, type RouteAccessConfig, type RoutePolicy, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, SettlementReportError, type SettlementRequest, type SignHttpRequestOptions, type SignableRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, UCP_ORDER_CAPABILITY, UCP_VERSION, type UcpAgentBinding, type CatalogItem as UcpCatalogItem, type UcpCheckoutKitOptions, type CheckoutSession as UcpCheckoutSession, type CheckoutStore as UcpCheckoutStore, type UcpLink, type UcpMessage, type UcpOrder, type UcpProfile, type UcpProfileResult, type SettleResult as UcpSettleResult, type UcpSeverity, type UcpSignatureResult, VERIFICATION_STATUS_HEADER, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyAp2Options, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, type X402PaymentPayload, type X402PaymentRequired, type X402PaymentRequirements, type X402ResourceInfo, type X402SettlementResponse, _resetEdgeConfigCache, acpPaymentHandlers, aepCanonicalJson, aepHash, aepPrivateKeyFromSeed, aepPublicKeyDocument, aepPublicKeyFromBase64, aepRawPublicKey, aepSign, aepTimestamp, aepVerifySignature, index as agent, astrasyncPaymentHandlers, authorizeSettlement, awaitStepUpApproval, beginIdempotent, buildAcpWellKnown, buildGuidance, buildMpp402Response, buildMppChallenge, buildSdkObservedMetadata, buildUcpOrder, buildUcpProfile, buildVerificationUnavailableBody, buildX402Challenge, canonicalJson, checkUcpAgentBinding, checkoutHash, clearCache, closedCheckoutMandate, closedPaymentMandate, contentDigest, createAcpCheckoutKit, createKbHop, createMcpMiddleware, createUcpCheckoutKit, decodeMppRequest, degradeToObserve, denyStatusFor, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, encodeMppReceipt, encodeX402SettlementResponse, express, expressHandler, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, fetchUcpProfile, finishIdempotent, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, hasCredentials, idempotencyMiddleware, isEdgeConfig, isRejectedIdentityClaim, isRetryableSettlementError, isSpecialUseIp, isVerificationUnavailable, isVerifiedHopValidFor, issueDelegateSdJwt, matchEdgePathRule, matchPlatformSignature, matchRoutePattern, mppBodyDigest, negotiateUcp, nextjs, normalizeDeclaredSource, openCheckoutMandate, openPaymentMandate, parseYaml as parseLocalPolicyYaml, parseMppCredential, parseUcpAgentHeader, parseVerifiedHop, parseX402Challenge, parseX402Payment, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, requestFingerprint, rootMandateDigest, routePatternToRegExp, routePolicyOf, sanitizeHeaders, sdk, sdkFetch, sendUcpWebhook, serializeVerifiedHop, setMcpMeta, signHttpRequest, signRootMandate, signUcpRequest, signUcpResponse, index$1 as transport, ucpError, ucpEscalation, ucpFailure, ucpProfileHandler, ucpRequiredComponents, unavailableRetryAfterSeconds, validatePolicy as validateLocalPolicy, verify, verifyAepChain, verifyAp2Mandate, verifyDelegateChain, verifyKyaPayTokens, verifyMppChallenge, verifyUcpRequest, withIdempotency, x402PaymentMatchesOffer };
7281
+ export { ACP_API_VERSION, ACP_SUPPORTED_API_VERSIONS, AEP_SPEC_VERSION, AP2_VCT, type AcpCheckoutKitOptions, type AcpCheckoutSession, type AcpCheckoutStatus, type AcpCheckoutStore, type AcpWellKnownOptions, type AepActorType, type AepArtifactRecord, type AepArtifactType, AepChain, type AepChainOptions, type AepChainVerification, type AepHashInput, type AgentArtifacts, AgentClient, type AgentCredentials, type AgentProtocol, type AgentProtocolIdentities, type AgentRecord, type Ap2Party, type Ap2VerifyResult, type ApprovalEvent, type ApprovalEventKit, type ApprovalEventsHandlerOptions, type ApprovalEventsResponse, AstraSync, type AstraSyncAepEvidence, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, type AstraSyncMandates, type AttemptOutcome, type AttemptReport, AuthenticationError, type BuildGuidanceParams, CAPTURE_SCHEMA_VERSION, type CallerMetadata, ChallengeHandler, type CheckoutMetadata, type CommerceArtifactsPayload, type CommerceContext, type CommercePipelineInput, type CommerceShieldProps, type ConsiderationItem, type ConsiderationSet, type CounterpartyType, DECLARED_SOURCE_MAX, DEFAULT_EDGE_CONFIG, DEFAULT_IDEMPOTENCY_TTL_MS, type DashboardToolRule, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressHandlerOptions, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FetchKit, type FiatSettlementBinding, type FrameworkConfig, type FulfilmentInfo, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HandleApprovalEventsOptions, type HealthResponse, type HttpSignatureAlgorithm, type IdempotencyOptions, type IdempotencyRecord, type IdempotencyStore, KYDRequiredError, type KitExpressRequest, type KitExpressResponse, type KitMessage, type KitRequestContext, type KyaPayIdentity, type KyaPayResult, type KyaPayTokenType, type KyaPayVerifyOptions, type ParseResult as LocalPolicyParseResult, type ValidationError as LocalPolicyValidationError, type ValidationResult as LocalPolicyValidationResult, MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, MCP_VERIFIED_HOP_HEADER, MCP_VERIFIED_HOP_MAX_AGE_MS, type McpMiddlewareOptions, MemoryCheckoutStore, MemoryIdempotencyStore, MemoryMppChallengeStore, MemorySeenEvents, type MerchantSettlementToken, type ModelConfig, type MppChallenge, type MppChallengeStore, type MppCredential, type MppReceipt, type MppVerifyOptions, type MppVerifyResult, type NegotiationResult, type NextJsMiddlewareOptions, type ObservedMetadata, type PDLSSConfig$1 as PDLSSConfig, type PDLSSDuration, type PDLSSInfo, type PDLSSLimits, type PDLSSPurpose, type PDLSSScope, type PDLSSSelfInstantiation, PLATFORM_AGENT_SIGNATURES, type PendingRegistrationResponse, type PendingResolution, type PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, type PurposeSource, RUNTIME_SIGNATURES, RedisIdempotencyStore, type RedisLike, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type ReportAttemptOptions, type ReportRetryOptions, type ResumeOutcome, type ResumeResult, type RootKeyResolver, type RouteAccessConfig, type RoutePolicy, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SeenEvents, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, SettlementReportError, type SettlementRequest, type SignHttpRequestOptions, type SignableRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, UCP_ORDER_CAPABILITY, UCP_VERSION, type UcpAgentBinding, type CatalogItem as UcpCatalogItem, type UcpCheckoutKitOptions, type CheckoutSession as UcpCheckoutSession, type CheckoutStore as UcpCheckoutStore, type UcpLink, type UcpMessage, type UcpOrder, type UcpProfile, type UcpProfileResult, type SettleResult as UcpSettleResult, type UcpSeverity, type UcpSignatureResult, VERIFICATION_STATUS_HEADER, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyAp2Options, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, type X402PaymentPayload, type X402PaymentRequired, type X402PaymentRequirements, type X402ResourceInfo, type X402SettlementResponse, _resetEdgeConfigCache, abandonIdempotent, acpPaymentHandlers, aepCanonicalJson, aepHash, aepPrivateKeyFromSeed, aepPublicKeyDocument, aepPublicKeyFromBase64, aepRawPublicKey, aepSign, aepTimestamp, aepVerifySignature, index as agent, approvalEventsHandler, astrasyncPaymentHandlers, authorizeSettlement, awaitStepUpApproval, beginIdempotent, buildAcpWellKnown, buildGuidance, buildMpp402Response, buildMppChallenge, buildSdkObservedMetadata, buildUcpOrder, buildUcpProfile, buildVerificationUnavailableBody, buildX402Challenge, canonicalJson, checkUcpAgentBinding, checkoutHash, clearCache, closedCheckoutMandate, closedPaymentMandate, contentDigest, createAcpCheckoutKit, createKbHop, createMcpMiddleware, createUcpCheckoutKit, decodeMppRequest, degradeToObserve, denyStatusFor, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, encodeMppReceipt, encodeX402SettlementResponse, express, expressHandler, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, fetchUcpProfile, finishIdempotent, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, handleApprovalEvents, hasCredentials, idempotencyMiddleware, isEdgeConfig, isRejectedIdentityClaim, isRetryableSettlementError, isSpecialUseIp, isVerificationUnavailable, isVerifiedHopValidFor, issueDelegateSdJwt, matchEdgePathRule, matchPlatformSignature, matchRoutePattern, mppBodyDigest, negotiateUcp, nextjs, normalizeDeclaredSource, openCheckoutMandate, openPaymentMandate, parseYaml as parseLocalPolicyYaml, parseMppCredential, parseUcpAgentHeader, parseVerifiedHop, parseX402Challenge, parseX402Payment, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, requestFingerprint, rootMandateDigest, routePatternToRegExp, routePolicyOf, sanitizeHeaders, sdk, sdkFetch, sendUcpWebhook, serializeVerifiedHop, setMcpMeta, signHttpRequest, signRootMandate, signUcpRequest, signUcpResponse, index$1 as transport, ucpError, ucpEscalation, ucpFailure, ucpProfileHandler, ucpRequiredComponents, unavailableRetryAfterSeconds, validatePolicy as validateLocalPolicy, verify, verifyAepChain, verifyAp2Mandate, verifyDelegateChain, verifyKyaPayTokens, verifyMppChallenge, verifyUcpRequest, withIdempotency, x402PaymentMatchesOffer };