@astrasyncai/verification-gateway 5.11.0 → 5.13.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 (98) hide show
  1. package/README.md +4 -0
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +394 -39
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +394 -39
  7. package/dist/adapters/express.mjs.map +1 -1
  8. package/dist/adapters/mcp.d.mts +5 -1
  9. package/dist/adapters/mcp.d.ts +5 -1
  10. package/dist/adapters/mcp.js +193 -49
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +193 -49
  13. package/dist/adapters/mcp.mjs.map +1 -1
  14. package/dist/adapters/nextjs.d.mts +1 -1
  15. package/dist/adapters/nextjs.d.ts +1 -1
  16. package/dist/adapters/nextjs.js +387 -22
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +387 -22
  19. package/dist/adapters/nextjs.mjs.map +1 -1
  20. package/dist/adapters/sdk.d.mts +9 -1
  21. package/dist/adapters/sdk.d.ts +9 -1
  22. package/dist/adapters/sdk.js +125 -16
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +125 -16
  25. package/dist/adapters/sdk.mjs.map +1 -1
  26. package/dist/agent/index.js +1 -1
  27. package/dist/agent/index.js.map +1 -1
  28. package/dist/agent/index.mjs +1 -1
  29. package/dist/agent/index.mjs.map +1 -1
  30. package/dist/bin/astrasync-claude-hook.js +309 -15
  31. package/dist/bin/astrasync-codex-hook.js +309 -15
  32. package/dist/bin/astrasync-guard.js +309 -15
  33. package/dist/bin/astrasync.js +322 -17
  34. package/dist/browser/background.js +309 -15
  35. package/dist/browser/background.js.map +1 -1
  36. package/dist/browser/background.mjs +309 -15
  37. package/dist/browser/background.mjs.map +1 -1
  38. package/dist/cli/index.js +1 -1
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/cli/index.mjs +1 -1
  41. package/dist/cli/index.mjs.map +1 -1
  42. package/dist/codex/index.js +309 -15
  43. package/dist/codex/index.js.map +1 -1
  44. package/dist/codex/index.mjs +309 -15
  45. package/dist/codex/index.mjs.map +1 -1
  46. package/dist/cursor/extension.js +309 -15
  47. package/dist/cursor/extension.js.map +1 -1
  48. package/dist/cursor/extension.mjs +309 -15
  49. package/dist/cursor/extension.mjs.map +1 -1
  50. package/dist/edge-config.d.mts +1 -1
  51. package/dist/edge-config.d.ts +1 -1
  52. package/dist/edge-config.js +1 -1
  53. package/dist/edge-config.js.map +1 -1
  54. package/dist/edge-config.mjs +1 -1
  55. package/dist/edge-config.mjs.map +1 -1
  56. package/dist/edge-core/index.d.mts +128 -13
  57. package/dist/edge-core/index.d.ts +128 -13
  58. package/dist/edge-core/index.js +362 -63
  59. package/dist/edge-core/index.js.map +1 -1
  60. package/dist/edge-core/index.mjs +359 -63
  61. package/dist/edge-core/index.mjs.map +1 -1
  62. package/dist/gateway/gateway.js +309 -15
  63. package/dist/gateway/gateway.js.map +1 -1
  64. package/dist/gateway/gateway.mjs +309 -15
  65. package/dist/gateway/gateway.mjs.map +1 -1
  66. package/dist/git-trigger/git-hooks.d.mts +1 -1
  67. package/dist/git-trigger/git-hooks.d.ts +1 -1
  68. package/dist/index.d.mts +118 -15
  69. package/dist/index.d.ts +118 -15
  70. package/dist/index.js +521 -72
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +515 -72
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/platform-signatures.js +4 -1
  75. package/dist/platform-signatures.js.map +1 -1
  76. package/dist/platform-signatures.mjs +4 -1
  77. package/dist/platform-signatures.mjs.map +1 -1
  78. package/dist/registration/index.js +1 -1
  79. package/dist/registration/index.js.map +1 -1
  80. package/dist/registration/index.mjs +1 -1
  81. package/dist/registration/index.mjs.map +1 -1
  82. package/dist/transport/index.js +1 -1
  83. package/dist/transport/index.js.map +1 -1
  84. package/dist/transport/index.mjs +1 -1
  85. package/dist/transport/index.mjs.map +1 -1
  86. package/dist/{types-CTmUpNpS.d.mts → types-BCkwBA84.d.mts} +12 -0
  87. package/dist/{types-CTmUpNpS.d.ts → types-BCkwBA84.d.ts} +12 -0
  88. package/dist/{types-CtFXmDzm.d.ts → types-C_b4QTyO.d.ts} +18 -0
  89. package/dist/{types-DQrn_kei.d.mts → types-DlshIIR-.d.mts} +18 -0
  90. package/dist/ui/index.d.mts +1 -1
  91. package/dist/ui/index.d.ts +1 -1
  92. package/dist/verify.d.mts +35 -14
  93. package/dist/verify.d.ts +35 -14
  94. package/dist/verify.js +165 -25
  95. package/dist/verify.js.map +1 -1
  96. package/dist/verify.mjs +164 -25
  97. package/dist/verify.mjs.map +1 -1
  98. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- import { T as TokenGuidance, b as CounterpartyType } from '../types-DQrn_kei.mjs';
1
+ import { T as TokenGuidance, b as CounterpartyType } from '../types-DlshIIR-.mjs';
2
2
  import '../metadata-capture.mjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { T as TokenGuidance, b as CounterpartyType } from '../types-CtFXmDzm.js';
1
+ import { T as TokenGuidance, b as CounterpartyType } from '../types-C_b4QTyO.js';
2
2
  import '../metadata-capture.js';
3
3
 
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -645,6 +645,18 @@ interface VerificationResult {
645
645
  * on misconfig (deterministic — retrying will not help) and on real denials.
646
646
  */
647
647
  retryable?: boolean;
648
+ /**
649
+ * 5.12.0: HTTP status the verify-access backend answered with on a
650
+ * non-2xx (e.g. 429, 503). Lets adapters and integrators tell a platform
651
+ * rate limit apart from an outage. Absent on network errors / timeouts.
652
+ */
653
+ httpStatus?: number;
654
+ /**
655
+ * 5.12.0: the backend's `Retry-After`, in milliseconds, when it sent one
656
+ * (429 / 503). Adapters relay it on their own 503 so callers back off for
657
+ * as long as the platform asked.
658
+ */
659
+ retryAfterMs?: number;
648
660
  /** Whether step-up authentication is required */
649
661
  requiresStepUp?: boolean;
650
662
  /** Whether approval is required */
@@ -1009,6 +1021,12 @@ interface AttemptReport {
1009
1021
  agentId?: string;
1010
1022
  considerationSet?: ConsiderationSet;
1011
1023
  outcome?: AttemptOutcome;
1024
+ /**
1025
+ * Where a catalog view was answered from: `bridge_cache` (the AstraSync
1026
+ * bridge's anonymous cache — no load on the merchant's site) or `merchant`
1027
+ * (fetched fresh). Attribution only.
1028
+ */
1029
+ servedFrom?: 'bridge_cache' | 'merchant';
1012
1030
  }
1013
1031
  /**
1014
1032
  * Raw commerce-protocol artifacts as verify-access accepts them (backend
@@ -1479,19 +1497,24 @@ declare function verify(config: GatewayConfig, request: VerificationRequest, opt
1479
1497
  * Authenticated with the same credentials as verify(); the backend responds
1480
1498
  * 202 and folds the data into the attempt chain keyed by `attemptId`.
1481
1499
  *
1482
- * Fire-and-forget — errors are silently swallowed, never throws.
1483
- */
1484
- declare function reportAttempt(config: GatewayConfig, report: AttemptReport): Promise<void>;
1485
- /**
1486
- * Fetch the per-route policy for an endpoint from the AstraSync backend.
1487
- * v2.9.7 moved policy authority into the dashboard — the SDK no longer
1488
- * accepts `routes` from merchant-side source code, it fetches them from
1489
- * here on init (and refreshes periodically).
1490
- *
1491
- * Returns `null` when the request fails for any reason — the caller decides
1492
- * how to fall back (the middleware allows-all when no policy is loaded so
1493
- * a misconfigured init doesn't take down the merchant's API).
1500
+ * Fire-and-forget — never throws. 5.12.0: a 429/5xx is retried once
1501
+ * (Retry-After honoured, capped at 2s) off the caller's path; a lost report
1502
+ * is surfaced via `options.onFailure`.
1494
1503
  */
1504
+ declare function reportAttempt(config: GatewayConfig, report: AttemptReport, options?: ReportAttemptOptions): Promise<void>;
1505
+ /** 5.12.0: options for {@link reportAttempt}. */
1506
+ interface ReportAttemptOptions {
1507
+ /**
1508
+ * Called once when the report is finally lost (non-retryable status,
1509
+ * network error, or the single retry failed). For counters/telemetry;
1510
+ * exceptions it throws are swallowed.
1511
+ */
1512
+ onFailure?: (failure: {
1513
+ status?: number;
1514
+ error?: string;
1515
+ retried: boolean;
1516
+ }) => void;
1517
+ }
1495
1518
  declare function fetchRoutes(config: GatewayConfig, counterpartyId: string): Promise<RouteAccessConfigShape[] | null>;
1496
1519
  /**
1497
1520
  * Minimal shape of an EndpointRoute as the SDK consumes it. Mirrors the
@@ -1571,8 +1594,76 @@ declare function quickVerify(config: GatewayConfig, credentials: AgentCredential
1571
1594
  identityVerified: boolean;
1572
1595
  policyAllowed: boolean;
1573
1596
  reason?: string;
1597
+ /**
1598
+ * 5.12.0: verification infrastructure was unavailable (timeout / 5xx /
1599
+ * the platform's 429) — NOT a denial. Callers should fail open on reads
1600
+ * or answer 503 + Retry-After (`retryAfterMs`, else 30s), never 401.
1601
+ */
1602
+ unavailable?: true;
1603
+ retryAfterMs?: number;
1574
1604
  }>;
1575
1605
 
1606
+ /**
1607
+ * 5.12.0 — HTTP adapter failure posture, lifted from edge-core
1608
+ * (`pipeline.ts` isApiErrorResult/unavailableOutcome, `enforce.ts` 503 +
1609
+ * Retry-After + buildUnavailableBody) so the Express and Next.js adapters
1610
+ * and `quickVerify` answer an AstraSync outage the way the edge does.
1611
+ *
1612
+ * The 1 Oct load test: the platform rate-limited a merchant's verify-access
1613
+ * calls (429), the SDK mapped that to `UNAUTHORIZED` 401 and failed closed
1614
+ * — even for anonymous catalogue reads — so the merchant was down for 11
1615
+ * minutes. Fail posture follows success posture:
1616
+ *
1617
+ * - observe routes and anonymous reads (GET/HEAD, no credentials) pass
1618
+ * through, stamped `X-Astra-Verification: unavailable`;
1619
+ * - enforced routes answer 503 + `Retry-After` (the backend's value, else
1620
+ * 30s) + `VERIFICATION_UNAVAILABLE`. Never 401 — the caller's identity
1621
+ * was never evaluated.
1622
+ *
1623
+ * Identity status mapping (contract correction, not a break): credentials
1624
+ * missing → 401; a presented id that is malformed or unknown → 403 with
1625
+ * registration guidance (re-authenticating with the same id cannot help).
1626
+ */
1627
+
1628
+ /** Response header stamped on a fail-open pass-through during an outage. */
1629
+ declare const VERIFICATION_STATUS_HEADER = "X-Astra-Verification";
1630
+ /**
1631
+ * A verify() result that is the SDK's typed, retryable api_error fallback —
1632
+ * infrastructure unavailability (timeout, 5xx, 429), not a policy deny and
1633
+ * not the deterministic merchant misconfig — or an adapter's internal-error
1634
+ * fail-closed result.
1635
+ */
1636
+ declare function isVerificationUnavailable(result: VerificationResult): boolean;
1637
+ /** Retry-After seconds to relay: the backend's value (≥1s), else 30. */
1638
+ declare function unavailableRetryAfterSeconds(result: VerificationResult): number;
1639
+ /** Machine-readable 503 body — same shape as edge-core's buildUnavailableBody. */
1640
+ declare function buildVerificationUnavailableBody(result: VerificationResult): {
1641
+ success: false;
1642
+ error: {
1643
+ code: 'VERIFICATION_UNAVAILABLE';
1644
+ message: string;
1645
+ retryable: true;
1646
+ retryAfterSeconds: number;
1647
+ failures?: VerificationResult['failures'];
1648
+ correlationId?: string;
1649
+ guidance: {
1650
+ message: string;
1651
+ };
1652
+ };
1653
+ };
1654
+ /** True when the deny is about a presented-but-malformed/unknown agent id. */
1655
+ declare function isRejectedIdentityClaim(result: VerificationResult): boolean;
1656
+ /**
1657
+ * HTTP status + code for an ordinary (non-outage, non-misconfig) deny:
1658
+ * missing identity → 401 UNAUTHORIZED; presented-but-rejected id → 403
1659
+ * AGENT_IDENTITY_REJECTED; identity fine but policy denied → 403 with the
1660
+ * adapter's policy code.
1661
+ */
1662
+ declare function denyStatusFor(result: VerificationResult, policyDeniedCode: string): {
1663
+ status: 401 | 403;
1664
+ code: string;
1665
+ };
1666
+
1576
1667
  /**
1577
1668
  * Step-up hold-and-poll (3.6.0) — the synchronous half of the MFA-style gate,
1578
1669
  * mirroring the Java SDK's `awaitStepUpApproval` / `pollStepUpStatus`.
@@ -1828,6 +1919,12 @@ declare class VerificationGatewayClient {
1828
1919
  * fulfil against it only once the order is settled / pending_merchant. An
1829
1920
  * explicit `buyerEmail` (here or on the bridge handoff body) wins over the
1830
1921
  * account default.
1922
+ *
1923
+ * 5.12.0 approval binding: pass the bridge handoff body's `attemptId` (and
1924
+ * the same `checkoutSessionId`) so a step-up approval minted for this cart
1925
+ * is matched to — and only to — this confirm. A held cart's approval is
1926
+ * bound to its checkout session and exact value; a confirm for any other
1927
+ * cart is held for its own approval.
1831
1928
  */
1832
1929
  confirmCheckout(options: {
1833
1930
  astraId?: string;
@@ -1839,6 +1936,8 @@ declare class VerificationGatewayClient {
1839
1936
  currency?: string;
1840
1937
  checkoutSessionId?: string;
1841
1938
  checkoutItems?: VerificationRequest['checkoutItems'];
1939
+ /** 5.12.0: the `att_…` attempt-chain id from the bridge handoff body. */
1940
+ attemptId?: string;
1842
1941
  /** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
1843
1942
  * the platform default `fulfilment.email` to the buyer's account email. */
1844
1943
  buyerEmail?: string;
@@ -3700,6 +3799,10 @@ interface McpMiddlewareOptions extends GatewayConfig {
3700
3799
  * record what WOULD be denied with `failOnError: 'closed'` so merchants
3701
3800
  * can grep correlationId for impact analysis during the observation
3702
3801
  * window. Default flips to `'closed'` in a follow-up release.
3802
+ *
3803
+ * 5.12.0: `'closed'` answers the retryable verification-unavailable
3804
+ * JSON-RPC error (HTTP 503 + Retry-After, code -32003) — never an
3805
+ * identity-shaped 401.
3703
3806
  */
3704
3807
  failOnError?: 'open' | 'closed';
3705
3808
  }
@@ -4832,7 +4935,7 @@ declare function detectRuntime(userAgent: string | undefined | null): string | u
4832
4935
  * silently (never throwing), so this is a no-op there — which is correct:
4833
4936
  * in a browser the page's real UA is the honest identity.
4834
4937
  */
4835
- declare const SDK_USER_AGENT = "astrasync-sdk/5.11.0";
4938
+ declare const SDK_USER_AGENT = "astrasync-sdk/5.13.0";
4836
4939
  declare const sdkFetch: typeof fetch;
4837
4940
 
4838
4941
  interface LocalPolicy {
@@ -4950,6 +5053,6 @@ declare function parseYaml(yamlContent: string): ParseResult;
4950
5053
  * is fine — bumping both in the release-ceremony commit keeps them
4951
5054
  * lockstep.
4952
5055
  */
4953
- declare const SDK_VERSION = "5.11.0";
5056
+ declare const SDK_VERSION = "5.13.0";
4954
5057
 
4955
- export { AgentClient, type AgentCredentials, type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, 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, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FiatSettlementBinding, type FrameworkConfig, type FulfilmentInfo, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HealthResponse, KYDRequiredError, 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, type MerchantSettlementToken, type ModelConfig, 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 PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, RUNTIME_SIGNATURES, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type RouteAccessConfig, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, type SettlementRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, _resetEdgeConfigCache, index as agent, authorizeSettlement, awaitStepUpApproval, buildGuidance, buildSdkObservedMetadata, clearCache, createMcpMiddleware, degradeToObserve, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, express, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, hasCredentials, isEdgeConfig, isVerifiedHopValidFor, matchEdgePathRule, matchPlatformSignature, nextjs, normalizeDeclaredSource, parseYaml as parseLocalPolicyYaml, parseVerifiedHop, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, sanitizeHeaders, sdk, sdkFetch, serializeVerifiedHop, setMcpMeta, index$1 as transport, validatePolicy as validateLocalPolicy, verify };
5058
+ export { AgentClient, type AgentCredentials, type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, 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, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FiatSettlementBinding, type FrameworkConfig, type FulfilmentInfo, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HealthResponse, KYDRequiredError, 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, type MerchantSettlementToken, type ModelConfig, 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 PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, RUNTIME_SIGNATURES, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type ReportAttemptOptions, type RouteAccessConfig, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, type SettlementRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, VERIFICATION_STATUS_HEADER, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, _resetEdgeConfigCache, index as agent, authorizeSettlement, awaitStepUpApproval, buildGuidance, buildSdkObservedMetadata, buildVerificationUnavailableBody, clearCache, createMcpMiddleware, degradeToObserve, denyStatusFor, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, express, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, hasCredentials, isEdgeConfig, isRejectedIdentityClaim, isVerificationUnavailable, isVerifiedHopValidFor, matchEdgePathRule, matchPlatformSignature, nextjs, normalizeDeclaredSource, parseYaml as parseLocalPolicyYaml, parseVerifiedHop, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, sanitizeHeaders, sdk, sdkFetch, serializeVerifiedHop, setMcpMeta, index$1 as transport, unavailableRetryAfterSeconds, validatePolicy as validateLocalPolicy, verify };
package/dist/index.d.ts CHANGED
@@ -645,6 +645,18 @@ interface VerificationResult {
645
645
  * on misconfig (deterministic — retrying will not help) and on real denials.
646
646
  */
647
647
  retryable?: boolean;
648
+ /**
649
+ * 5.12.0: HTTP status the verify-access backend answered with on a
650
+ * non-2xx (e.g. 429, 503). Lets adapters and integrators tell a platform
651
+ * rate limit apart from an outage. Absent on network errors / timeouts.
652
+ */
653
+ httpStatus?: number;
654
+ /**
655
+ * 5.12.0: the backend's `Retry-After`, in milliseconds, when it sent one
656
+ * (429 / 503). Adapters relay it on their own 503 so callers back off for
657
+ * as long as the platform asked.
658
+ */
659
+ retryAfterMs?: number;
648
660
  /** Whether step-up authentication is required */
649
661
  requiresStepUp?: boolean;
650
662
  /** Whether approval is required */
@@ -1009,6 +1021,12 @@ interface AttemptReport {
1009
1021
  agentId?: string;
1010
1022
  considerationSet?: ConsiderationSet;
1011
1023
  outcome?: AttemptOutcome;
1024
+ /**
1025
+ * Where a catalog view was answered from: `bridge_cache` (the AstraSync
1026
+ * bridge's anonymous cache — no load on the merchant's site) or `merchant`
1027
+ * (fetched fresh). Attribution only.
1028
+ */
1029
+ servedFrom?: 'bridge_cache' | 'merchant';
1012
1030
  }
1013
1031
  /**
1014
1032
  * Raw commerce-protocol artifacts as verify-access accepts them (backend
@@ -1479,19 +1497,24 @@ declare function verify(config: GatewayConfig, request: VerificationRequest, opt
1479
1497
  * Authenticated with the same credentials as verify(); the backend responds
1480
1498
  * 202 and folds the data into the attempt chain keyed by `attemptId`.
1481
1499
  *
1482
- * Fire-and-forget — errors are silently swallowed, never throws.
1483
- */
1484
- declare function reportAttempt(config: GatewayConfig, report: AttemptReport): Promise<void>;
1485
- /**
1486
- * Fetch the per-route policy for an endpoint from the AstraSync backend.
1487
- * v2.9.7 moved policy authority into the dashboard — the SDK no longer
1488
- * accepts `routes` from merchant-side source code, it fetches them from
1489
- * here on init (and refreshes periodically).
1490
- *
1491
- * Returns `null` when the request fails for any reason — the caller decides
1492
- * how to fall back (the middleware allows-all when no policy is loaded so
1493
- * a misconfigured init doesn't take down the merchant's API).
1500
+ * Fire-and-forget — never throws. 5.12.0: a 429/5xx is retried once
1501
+ * (Retry-After honoured, capped at 2s) off the caller's path; a lost report
1502
+ * is surfaced via `options.onFailure`.
1494
1503
  */
1504
+ declare function reportAttempt(config: GatewayConfig, report: AttemptReport, options?: ReportAttemptOptions): Promise<void>;
1505
+ /** 5.12.0: options for {@link reportAttempt}. */
1506
+ interface ReportAttemptOptions {
1507
+ /**
1508
+ * Called once when the report is finally lost (non-retryable status,
1509
+ * network error, or the single retry failed). For counters/telemetry;
1510
+ * exceptions it throws are swallowed.
1511
+ */
1512
+ onFailure?: (failure: {
1513
+ status?: number;
1514
+ error?: string;
1515
+ retried: boolean;
1516
+ }) => void;
1517
+ }
1495
1518
  declare function fetchRoutes(config: GatewayConfig, counterpartyId: string): Promise<RouteAccessConfigShape[] | null>;
1496
1519
  /**
1497
1520
  * Minimal shape of an EndpointRoute as the SDK consumes it. Mirrors the
@@ -1571,8 +1594,76 @@ declare function quickVerify(config: GatewayConfig, credentials: AgentCredential
1571
1594
  identityVerified: boolean;
1572
1595
  policyAllowed: boolean;
1573
1596
  reason?: string;
1597
+ /**
1598
+ * 5.12.0: verification infrastructure was unavailable (timeout / 5xx /
1599
+ * the platform's 429) — NOT a denial. Callers should fail open on reads
1600
+ * or answer 503 + Retry-After (`retryAfterMs`, else 30s), never 401.
1601
+ */
1602
+ unavailable?: true;
1603
+ retryAfterMs?: number;
1574
1604
  }>;
1575
1605
 
1606
+ /**
1607
+ * 5.12.0 — HTTP adapter failure posture, lifted from edge-core
1608
+ * (`pipeline.ts` isApiErrorResult/unavailableOutcome, `enforce.ts` 503 +
1609
+ * Retry-After + buildUnavailableBody) so the Express and Next.js adapters
1610
+ * and `quickVerify` answer an AstraSync outage the way the edge does.
1611
+ *
1612
+ * The 1 Oct load test: the platform rate-limited a merchant's verify-access
1613
+ * calls (429), the SDK mapped that to `UNAUTHORIZED` 401 and failed closed
1614
+ * — even for anonymous catalogue reads — so the merchant was down for 11
1615
+ * minutes. Fail posture follows success posture:
1616
+ *
1617
+ * - observe routes and anonymous reads (GET/HEAD, no credentials) pass
1618
+ * through, stamped `X-Astra-Verification: unavailable`;
1619
+ * - enforced routes answer 503 + `Retry-After` (the backend's value, else
1620
+ * 30s) + `VERIFICATION_UNAVAILABLE`. Never 401 — the caller's identity
1621
+ * was never evaluated.
1622
+ *
1623
+ * Identity status mapping (contract correction, not a break): credentials
1624
+ * missing → 401; a presented id that is malformed or unknown → 403 with
1625
+ * registration guidance (re-authenticating with the same id cannot help).
1626
+ */
1627
+
1628
+ /** Response header stamped on a fail-open pass-through during an outage. */
1629
+ declare const VERIFICATION_STATUS_HEADER = "X-Astra-Verification";
1630
+ /**
1631
+ * A verify() result that is the SDK's typed, retryable api_error fallback —
1632
+ * infrastructure unavailability (timeout, 5xx, 429), not a policy deny and
1633
+ * not the deterministic merchant misconfig — or an adapter's internal-error
1634
+ * fail-closed result.
1635
+ */
1636
+ declare function isVerificationUnavailable(result: VerificationResult): boolean;
1637
+ /** Retry-After seconds to relay: the backend's value (≥1s), else 30. */
1638
+ declare function unavailableRetryAfterSeconds(result: VerificationResult): number;
1639
+ /** Machine-readable 503 body — same shape as edge-core's buildUnavailableBody. */
1640
+ declare function buildVerificationUnavailableBody(result: VerificationResult): {
1641
+ success: false;
1642
+ error: {
1643
+ code: 'VERIFICATION_UNAVAILABLE';
1644
+ message: string;
1645
+ retryable: true;
1646
+ retryAfterSeconds: number;
1647
+ failures?: VerificationResult['failures'];
1648
+ correlationId?: string;
1649
+ guidance: {
1650
+ message: string;
1651
+ };
1652
+ };
1653
+ };
1654
+ /** True when the deny is about a presented-but-malformed/unknown agent id. */
1655
+ declare function isRejectedIdentityClaim(result: VerificationResult): boolean;
1656
+ /**
1657
+ * HTTP status + code for an ordinary (non-outage, non-misconfig) deny:
1658
+ * missing identity → 401 UNAUTHORIZED; presented-but-rejected id → 403
1659
+ * AGENT_IDENTITY_REJECTED; identity fine but policy denied → 403 with the
1660
+ * adapter's policy code.
1661
+ */
1662
+ declare function denyStatusFor(result: VerificationResult, policyDeniedCode: string): {
1663
+ status: 401 | 403;
1664
+ code: string;
1665
+ };
1666
+
1576
1667
  /**
1577
1668
  * Step-up hold-and-poll (3.6.0) — the synchronous half of the MFA-style gate,
1578
1669
  * mirroring the Java SDK's `awaitStepUpApproval` / `pollStepUpStatus`.
@@ -1828,6 +1919,12 @@ declare class VerificationGatewayClient {
1828
1919
  * fulfil against it only once the order is settled / pending_merchant. An
1829
1920
  * explicit `buyerEmail` (here or on the bridge handoff body) wins over the
1830
1921
  * account default.
1922
+ *
1923
+ * 5.12.0 approval binding: pass the bridge handoff body's `attemptId` (and
1924
+ * the same `checkoutSessionId`) so a step-up approval minted for this cart
1925
+ * is matched to — and only to — this confirm. A held cart's approval is
1926
+ * bound to its checkout session and exact value; a confirm for any other
1927
+ * cart is held for its own approval.
1831
1928
  */
1832
1929
  confirmCheckout(options: {
1833
1930
  astraId?: string;
@@ -1839,6 +1936,8 @@ declare class VerificationGatewayClient {
1839
1936
  currency?: string;
1840
1937
  checkoutSessionId?: string;
1841
1938
  checkoutItems?: VerificationRequest['checkoutItems'];
1939
+ /** 5.12.0: the `att_…` attempt-chain id from the bridge handoff body. */
1940
+ attemptId?: string;
1842
1941
  /** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
1843
1942
  * the platform default `fulfilment.email` to the buyer's account email. */
1844
1943
  buyerEmail?: string;
@@ -3700,6 +3799,10 @@ interface McpMiddlewareOptions extends GatewayConfig {
3700
3799
  * record what WOULD be denied with `failOnError: 'closed'` so merchants
3701
3800
  * can grep correlationId for impact analysis during the observation
3702
3801
  * window. Default flips to `'closed'` in a follow-up release.
3802
+ *
3803
+ * 5.12.0: `'closed'` answers the retryable verification-unavailable
3804
+ * JSON-RPC error (HTTP 503 + Retry-After, code -32003) — never an
3805
+ * identity-shaped 401.
3703
3806
  */
3704
3807
  failOnError?: 'open' | 'closed';
3705
3808
  }
@@ -4832,7 +4935,7 @@ declare function detectRuntime(userAgent: string | undefined | null): string | u
4832
4935
  * silently (never throwing), so this is a no-op there — which is correct:
4833
4936
  * in a browser the page's real UA is the honest identity.
4834
4937
  */
4835
- declare const SDK_USER_AGENT = "astrasync-sdk/5.11.0";
4938
+ declare const SDK_USER_AGENT = "astrasync-sdk/5.13.0";
4836
4939
  declare const sdkFetch: typeof fetch;
4837
4940
 
4838
4941
  interface LocalPolicy {
@@ -4950,6 +5053,6 @@ declare function parseYaml(yamlContent: string): ParseResult;
4950
5053
  * is fine — bumping both in the release-ceremony commit keeps them
4951
5054
  * lockstep.
4952
5055
  */
4953
- declare const SDK_VERSION = "5.11.0";
5056
+ declare const SDK_VERSION = "5.13.0";
4954
5057
 
4955
- export { AgentClient, type AgentCredentials, type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, 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, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FiatSettlementBinding, type FrameworkConfig, type FulfilmentInfo, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HealthResponse, KYDRequiredError, 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, type MerchantSettlementToken, type ModelConfig, 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 PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, RUNTIME_SIGNATURES, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type RouteAccessConfig, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, type SettlementRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, _resetEdgeConfigCache, index as agent, authorizeSettlement, awaitStepUpApproval, buildGuidance, buildSdkObservedMetadata, clearCache, createMcpMiddleware, degradeToObserve, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, express, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, hasCredentials, isEdgeConfig, isVerifiedHopValidFor, matchEdgePathRule, matchPlatformSignature, nextjs, normalizeDeclaredSource, parseYaml as parseLocalPolicyYaml, parseVerifiedHop, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, sanitizeHeaders, sdk, sdkFetch, serializeVerifiedHop, setMcpMeta, index$1 as transport, validatePolicy as validateLocalPolicy, verify };
5058
+ export { AgentClient, type AgentCredentials, type AgentProtocol, type AgentRecord, AstraSync, type AstraSyncConfig, type AstraSyncCredentials, AstraSyncError, 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, type DynamicPlatformFingerprint, type EdgeConfig, type EdgeMode, type EdgePathRule, type EdgeVerificationDepth, type EnhancedVerificationResult, type ExpressMiddlewareOptions, type FetchEdgeConfigResult, type FetchEdgeConfigSuccess, type FiatSettlementBinding, type FrameworkConfig, type FulfilmentInfo, type GatewayConfig, type GuidanceEnvelope, type GuidanceInfo, type HealthResponse, KYDRequiredError, 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, type MerchantSettlementToken, type ModelConfig, 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 PlatformAgentVendor, type PlatformDetectionInput, type PlatformFingerprint, type PlatformSignatureDef, type PollRegistrationResult, type ProtocolTransport, RUNTIME_SIGNATURES, type RegisterOptions, type RegisterResult, RegistrationDeniedError, RegistrationExpiredError, type RegistrationResponse, RegistrationTimeoutError, type ReportAttemptOptions, type RouteAccessConfig, type RuntimeChallengeResult, type RuntimeSignature, type SDKOptions, SDK_USER_AGENT, type SanitizeHeadersResult, type SettlementArtifact, type SettlementArtifactBinding, type SettlementArtifactBindingBase, type SettlementDecision, type SettlementOutcomeInfo, type SettlementRequest, type StablecoinSettlementBinding, type StepUpApprovalInfo, type StepUpApprovalStatus, type StepUpOutcome, TRUST_LEVEL_RANGES, type TokenGuidance, type ToolGate, type ToolGateConfig, type TrustLevel, VERIFICATION_STATUS_HEADER, SDK_VERSION as VERSION, type VerificationInterstitialProps, type VerificationRequest, type VerificationResult, type VerifiedAgent, type VerifiedDeveloper, type VerifiedHopMarker, type VerifiedOrganization, type VerifyOptions, type VerifyResponse, type WaitForApprovalOptions, type WellKnownAgenticCommerce, _resetEdgeConfigCache, index as agent, authorizeSettlement, awaitStepUpApproval, buildGuidance, buildSdkObservedMetadata, buildVerificationUnavailableBody, clearCache, createMcpMiddleware, degradeToObserve, denyStatusFor, deriveConnectionFromHeaders, detectPlatformFingerprint, detectRuntime, express, extractApiKeyFormat, extractCredentials, extractMcpCredentials, extractPlatformHeaders, fetchEdgeConfig, fetchRoutes, getCachedWellKnownUrls, getEdgeConfig, getTrustLevel, getWellKnownUrls, hasCredentials, isEdgeConfig, isRejectedIdentityClaim, isVerificationUnavailable, isVerifiedHopValidFor, matchEdgePathRule, matchPlatformSignature, nextjs, normalizeDeclaredSource, parseYaml as parseLocalPolicyYaml, parseVerifiedHop, pollStepUpStatus, prefetchWellKnown, quickVerify, recordDecision, reportAttempt, reportUnregisteredAttempt, sanitizeHeaders, sdk, sdkFetch, serializeVerifiedHop, setMcpMeta, index$1 as transport, unavailableRetryAfterSeconds, validatePolicy as validateLocalPolicy, verify };