@astrasyncai/verification-gateway 3.12.0 → 4.0.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 (99) hide show
  1. package/dist/adapter-interface/interface.d.mts +2 -2
  2. package/dist/adapter-interface/interface.d.ts +2 -2
  3. package/dist/adapters/express.d.mts +2 -2
  4. package/dist/adapters/express.d.ts +2 -2
  5. package/dist/adapters/express.js +85 -8
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +85 -8
  8. package/dist/adapters/express.mjs.map +1 -1
  9. package/dist/adapters/mcp.d.mts +1 -1
  10. package/dist/adapters/mcp.d.ts +1 -1
  11. package/dist/adapters/mcp.js +90 -8
  12. package/dist/adapters/mcp.js.map +1 -1
  13. package/dist/adapters/mcp.mjs +90 -8
  14. package/dist/adapters/mcp.mjs.map +1 -1
  15. package/dist/adapters/nextjs.d.mts +2 -2
  16. package/dist/adapters/nextjs.d.ts +2 -2
  17. package/dist/adapters/nextjs.js +86 -8
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +86 -8
  20. package/dist/adapters/nextjs.mjs.map +1 -1
  21. package/dist/adapters/sdk.d.mts +2 -2
  22. package/dist/adapters/sdk.d.ts +2 -2
  23. package/dist/adapters/sdk.js +71 -8
  24. package/dist/adapters/sdk.js.map +1 -1
  25. package/dist/adapters/sdk.mjs +71 -8
  26. package/dist/adapters/sdk.mjs.map +1 -1
  27. package/dist/agent/index.d.mts +2 -2
  28. package/dist/agent/index.d.ts +2 -2
  29. package/dist/bin/astrasync-claude-hook.js +71 -8
  30. package/dist/bin/astrasync-codex-hook.js +71 -8
  31. package/dist/bin/astrasync-guard.js +71 -8
  32. package/dist/bin/astrasync.js +71 -8
  33. package/dist/browser/background.js +71 -8
  34. package/dist/browser/background.js.map +1 -1
  35. package/dist/browser/background.mjs +71 -8
  36. package/dist/browser/background.mjs.map +1 -1
  37. package/dist/browser/browser-adapter.d.mts +2 -2
  38. package/dist/browser/browser-adapter.d.ts +2 -2
  39. package/dist/claude-code/claude-code-adapter.d.mts +2 -2
  40. package/dist/claude-code/claude-code-adapter.d.ts +2 -2
  41. package/dist/cli/index.d.mts +2 -2
  42. package/dist/cli/index.d.ts +2 -2
  43. package/dist/codex/index.d.mts +2 -2
  44. package/dist/codex/index.d.ts +2 -2
  45. package/dist/codex/index.js +71 -8
  46. package/dist/codex/index.js.map +1 -1
  47. package/dist/codex/index.mjs +71 -8
  48. package/dist/codex/index.mjs.map +1 -1
  49. package/dist/cursor/cursor-adapter.d.mts +2 -2
  50. package/dist/cursor/cursor-adapter.d.ts +2 -2
  51. package/dist/cursor/extension.d.mts +2 -2
  52. package/dist/cursor/extension.d.ts +2 -2
  53. package/dist/cursor/extension.js +71 -8
  54. package/dist/cursor/extension.js.map +1 -1
  55. package/dist/cursor/extension.mjs +71 -8
  56. package/dist/cursor/extension.mjs.map +1 -1
  57. package/dist/edge-config.d.mts +1 -1
  58. package/dist/edge-config.d.ts +1 -1
  59. package/dist/{express-B39o89gf.d.mts → express-BZajRs4i.d.mts} +1 -1
  60. package/dist/{express-BuxKNO_q.d.ts → express-CjCUB1k7.d.ts} +1 -1
  61. package/dist/gateway/gateway.d.mts +2 -2
  62. package/dist/gateway/gateway.d.ts +2 -2
  63. package/dist/gateway/gateway.js +71 -8
  64. package/dist/gateway/gateway.js.map +1 -1
  65. package/dist/gateway/gateway.mjs +71 -8
  66. package/dist/gateway/gateway.mjs.map +1 -1
  67. package/dist/git-trigger/git-hooks.d.mts +2 -2
  68. package/dist/git-trigger/git-hooks.d.ts +2 -2
  69. package/dist/{index-DME3w3lf.d.mts → index-B0cyMZDL.d.mts} +1 -1
  70. package/dist/{index-CqydB4ks.d.mts → index-BRYteOqO.d.mts} +1 -1
  71. package/dist/{index-BG62SXso.d.ts → index-BZQdVqNw.d.ts} +1 -1
  72. package/dist/{index-CLHdqs2M.d.ts → index-adgKhujR.d.ts} +1 -1
  73. package/dist/index.d.mts +8 -8
  74. package/dist/index.d.ts +8 -8
  75. package/dist/index.js +119 -8
  76. package/dist/index.js.map +1 -1
  77. package/dist/index.mjs +119 -8
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/local-evaluator/evaluator.d.mts +2 -2
  80. package/dist/local-evaluator/evaluator.d.ts +2 -2
  81. package/dist/{nextjs-Ddlw_J1J.d.ts → nextjs-D_iFf5k-.d.ts} +1 -1
  82. package/dist/{nextjs-D74W7wt-.d.mts → nextjs-DeUTnOBd.d.mts} +1 -1
  83. package/dist/{sdk-CT7gdkfR.d.ts → sdk-BM3mwEAq.d.ts} +1 -1
  84. package/dist/{sdk-Bn6bj7kt.d.mts → sdk-_il1Q41f.d.mts} +1 -1
  85. package/dist/transport/index.d.mts +2 -2
  86. package/dist/transport/index.d.ts +2 -2
  87. package/dist/{types-BntuzEEn.d.mts → types-BcDf9Kk0.d.mts} +15 -0
  88. package/dist/{types-DHu7m9HI.d.ts → types-CHKCgDFC.d.ts} +1 -1
  89. package/dist/{types-Djw4GLtz.d.mts → types-DfnP7JiM.d.mts} +1 -1
  90. package/dist/{types-SDu4Llbe.d.ts → types-fTQD448H.d.ts} +15 -0
  91. package/dist/ui/index.d.mts +1 -1
  92. package/dist/ui/index.d.ts +1 -1
  93. package/dist/verify.d.mts +4 -2
  94. package/dist/verify.d.ts +4 -2
  95. package/dist/verify.js +76 -8
  96. package/dist/verify.js.map +1 -1
  97. package/dist/verify.mjs +75 -8
  98. package/dist/verify.mjs.map +1 -1
  99. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { AstraSyncGateway } from '../gateway/gateway.mjs';
2
- import { V as VerificationDecision, P as PDLSSContext } from '../types-Djw4GLtz.mjs';
3
- import '../types-BntuzEEn.mjs';
2
+ import { V as VerificationDecision, P as PDLSSContext } from '../types-DfnP7JiM.mjs';
3
+ import '../types-BcDf9Kk0.mjs';
4
4
  import '../metadata-capture.mjs';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { AstraSyncGateway } from '../gateway/gateway.js';
2
- import { V as VerificationDecision, P as PDLSSContext } from '../types-DHu7m9HI.js';
3
- import '../types-SDu4Llbe.js';
2
+ import { V as VerificationDecision, P as PDLSSContext } from '../types-CHKCgDFC.js';
3
+ import '../types-fTQD448H.js';
4
4
  import '../metadata-capture.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { c as AstraSyncCredentials, m as ProtocolTransport } from './types-BntuzEEn.mjs';
1
+ import { c as AstraSyncCredentials, m as ProtocolTransport } from './types-BcDf9Kk0.mjs';
2
2
  import { JWK } from 'jose';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { c as AstraSyncCredentials, m as ProtocolTransport, G as GatewayConfig } from './types-BntuzEEn.mjs';
1
+ import { c as AstraSyncCredentials, m as ProtocolTransport, G as GatewayConfig } from './types-BcDf9Kk0.mjs';
2
2
 
3
3
  /**
4
4
  * AgentClient — Credential Presentation
@@ -1,4 +1,4 @@
1
- import { c as AstraSyncCredentials, m as ProtocolTransport, G as GatewayConfig } from './types-SDu4Llbe.js';
1
+ import { c as AstraSyncCredentials, m as ProtocolTransport, G as GatewayConfig } from './types-fTQD448H.js';
2
2
 
3
3
  /**
4
4
  * AgentClient — Credential Presentation
@@ -1,4 +1,4 @@
1
- import { c as AstraSyncCredentials, m as ProtocolTransport } from './types-SDu4Llbe.js';
1
+ import { c as AstraSyncCredentials, m as ProtocolTransport } from './types-fTQD448H.js';
2
2
  import { JWK } from 'jose';
3
3
 
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
- import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-BntuzEEn.mjs';
2
- export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationRequest, w as VerificationResult, x as VerifiedAgent, y as VerifiedDeveloper, z as VerifiedOrganization } from './types-BntuzEEn.mjs';
3
- export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-Bn6bj7kt.mjs';
1
+ import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-BcDf9Kk0.mjs';
2
+ export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationRequest, w as VerificationResult, x as VerifiedAgent, y as VerifiedDeveloper, z as VerifiedOrganization } from './types-BcDf9Kk0.mjs';
3
+ export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-_il1Q41f.mjs';
4
4
  export { VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, reportAttempt, reportUnregisteredAttempt, verify } from './verify.mjs';
5
- export { e as express } from './express-B39o89gf.mjs';
6
- export { n as nextjs } from './nextjs-D74W7wt-.mjs';
7
- export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-DME3w3lf.mjs';
5
+ export { e as express } from './express-BZajRs4i.mjs';
6
+ export { n as nextjs } from './nextjs-DeUTnOBd.mjs';
7
+ export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-B0cyMZDL.mjs';
8
8
  export { McpMiddlewareOptions, ToolGateConfig, createMcpMiddleware } from './adapters/mcp.mjs';
9
9
  export { AgentProtocol, AgentRecord, AstraSync, AstraSyncConfig, AstraSyncError, AuthenticationError, BuildGuidanceParams, FrameworkConfig, GuidanceEnvelope, HealthResponse, KYDRequiredError, ModelConfig, PDLSSConfig, PDLSSDuration, PDLSSLimits, PDLSSPurpose, PDLSSScope, PDLSSSelfInstantiation, PendingRegistrationResponse, PollRegistrationResult, RegisterOptions, RegisterResult, RegistrationDeniedError, RegistrationExpiredError, RegistrationResponse, RegistrationTimeoutError, VerifyResponse, WaitForApprovalOptions, buildGuidance } from './registration/index.mjs';
10
- export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-CqydB4ks.mjs';
10
+ export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-BRYteOqO.mjs';
11
11
  export { DEFAULT_EDGE_CONFIG, EdgeConfig, EdgeMode, EdgePathRule, EdgeVerificationDepth, FetchEdgeConfigResult, FetchEdgeConfigSuccess, _resetEdgeConfigCache, degradeToObserve, fetchEdgeConfig, getEdgeConfig, isEdgeConfig, matchEdgePathRule } from './edge-config.mjs';
12
12
  export { DynamicPlatformFingerprint, PLATFORM_AGENT_SIGNATURES, PlatformAgentVendor, PlatformDetectionInput, PlatformFingerprint, PlatformSignatureDef, detectPlatformFingerprint, matchPlatformSignature } from './platform-signatures.mjs';
13
13
  export { MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, ObservedMetadata, SanitizeHeadersResult, extractApiKeyFormat, extractPlatformHeaders, sanitizeHeaders } from './metadata-capture.mjs';
@@ -145,6 +145,6 @@ declare function getCachedWellKnownUrls(apiBaseUrl: string): WellKnownAgenticCom
145
145
  * is fine — bumping both in the release-ceremony commit keeps them
146
146
  * lockstep.
147
147
  */
148
- declare const SDK_VERSION = "3.12.0";
148
+ declare const SDK_VERSION = "4.0.0";
149
149
 
150
150
  export { EnhancedVerificationResult, GatewayConfig, type SettlementDecision, type SettlementRequest, StepUpApprovalInfo, StepUpApprovalStatus, StepUpOutcome, SDK_VERSION as VERSION, type WellKnownAgenticCommerce, authorizeSettlement, awaitStepUpApproval, getCachedWellKnownUrls, getWellKnownUrls, pollStepUpStatus, prefetchWellKnown };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-SDu4Llbe.js';
2
- export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationRequest, w as VerificationResult, x as VerifiedAgent, y as VerifiedDeveloper, z as VerifiedOrganization } from './types-SDu4Llbe.js';
3
- export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-CT7gdkfR.js';
1
+ import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-fTQD448H.js';
2
+ export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationRequest, w as VerificationResult, x as VerifiedAgent, y as VerifiedDeveloper, z as VerifiedOrganization } from './types-fTQD448H.js';
3
+ export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-BM3mwEAq.js';
4
4
  export { VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, reportAttempt, reportUnregisteredAttempt, verify } from './verify.js';
5
- export { e as express } from './express-BuxKNO_q.js';
6
- export { n as nextjs } from './nextjs-Ddlw_J1J.js';
7
- export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-CLHdqs2M.js';
5
+ export { e as express } from './express-CjCUB1k7.js';
6
+ export { n as nextjs } from './nextjs-D_iFf5k-.js';
7
+ export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-adgKhujR.js';
8
8
  export { McpMiddlewareOptions, ToolGateConfig, createMcpMiddleware } from './adapters/mcp.js';
9
9
  export { AgentProtocol, AgentRecord, AstraSync, AstraSyncConfig, AstraSyncError, AuthenticationError, BuildGuidanceParams, FrameworkConfig, GuidanceEnvelope, HealthResponse, KYDRequiredError, ModelConfig, PDLSSConfig, PDLSSDuration, PDLSSLimits, PDLSSPurpose, PDLSSScope, PDLSSSelfInstantiation, PendingRegistrationResponse, PollRegistrationResult, RegisterOptions, RegisterResult, RegistrationDeniedError, RegistrationExpiredError, RegistrationResponse, RegistrationTimeoutError, VerifyResponse, WaitForApprovalOptions, buildGuidance } from './registration/index.js';
10
- export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-BG62SXso.js';
10
+ export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-BZQdVqNw.js';
11
11
  export { DEFAULT_EDGE_CONFIG, EdgeConfig, EdgeMode, EdgePathRule, EdgeVerificationDepth, FetchEdgeConfigResult, FetchEdgeConfigSuccess, _resetEdgeConfigCache, degradeToObserve, fetchEdgeConfig, getEdgeConfig, isEdgeConfig, matchEdgePathRule } from './edge-config.js';
12
12
  export { DynamicPlatformFingerprint, PLATFORM_AGENT_SIGNATURES, PlatformAgentVendor, PlatformDetectionInput, PlatformFingerprint, PlatformSignatureDef, detectPlatformFingerprint, matchPlatformSignature } from './platform-signatures.js';
13
13
  export { MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, ObservedMetadata, SanitizeHeadersResult, extractApiKeyFormat, extractPlatformHeaders, sanitizeHeaders } from './metadata-capture.js';
@@ -145,6 +145,6 @@ declare function getCachedWellKnownUrls(apiBaseUrl: string): WellKnownAgenticCom
145
145
  * is fine — bumping both in the release-ceremony commit keeps them
146
146
  * lockstep.
147
147
  */
148
- declare const SDK_VERSION = "3.12.0";
148
+ declare const SDK_VERSION = "4.0.0";
149
149
 
150
150
  export { EnhancedVerificationResult, GatewayConfig, type SettlementDecision, type SettlementRequest, StepUpApprovalInfo, StepUpApprovalStatus, StepUpOutcome, SDK_VERSION as VERSION, type WellKnownAgenticCommerce, authorizeSettlement, awaitStepUpApproval, getCachedWellKnownUrls, getWellKnownUrls, pollStepUpStatus, prefetchWellKnown };
package/dist/index.js CHANGED
@@ -214,7 +214,7 @@ function getCapabilities(accessLevel) {
214
214
  }
215
215
 
216
216
  // src/version.ts
217
- var SDK_VERSION = "3.12.0";
217
+ var SDK_VERSION = "4.0.0";
218
218
 
219
219
  // src/well-known.ts
220
220
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -292,7 +292,7 @@ var DEFAULT_CONFIG = {
292
292
  };
293
293
  var initCheckPerformed = false;
294
294
  var deprecationWarningShown = false;
295
- async function performInitCheck(apiBaseUrl, debug, strictInit) {
295
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
296
296
  initCheckPerformed = true;
297
297
  try {
298
298
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -309,6 +309,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
309
309
  `[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
310
310
  );
311
311
  }
312
+ if (apiKey) {
313
+ const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
314
+ headers: { Authorization: `Bearer ${apiKey}` }
315
+ });
316
+ if (selfCheck.status === 401) {
317
+ const body = await selfCheck.json().catch(() => ({}));
318
+ const message = `[VerificationGateway] the configured AstraSync API key was REJECTED at startup (${body.code ?? "api_key_invalid"}: ${body.message ?? "invalid key"}). Every inbound agent will be turned away until the key is rotated` + (body.remediation?.manageUrl ? ` at ${body.remediation.manageUrl}` : "") + `.`;
319
+ if (strictInit) {
320
+ throw new Error(`${message} (strictInit=true)`);
321
+ }
322
+ console.error(message);
323
+ } else if (selfCheck.ok) {
324
+ const body = await selfCheck.json().catch(() => ({}));
325
+ if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
326
+ console.warn(
327
+ `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
328
+ );
329
+ } else if (debug) {
330
+ console.log("[VerificationGateway] API key self-check passed");
331
+ }
332
+ }
333
+ }
312
334
  } catch (err) {
313
335
  if (strictInit) {
314
336
  throw err;
@@ -426,8 +448,17 @@ function hasCredentials(credentials) {
426
448
  function createGuidanceResponse(_config, reason, options = {}) {
427
449
  const source = options.source ?? "no_credentials";
428
450
  const isApiError = source === "api_error";
451
+ const isMisconfig = source === "merchant_misconfig";
429
452
  const urls = options.urls;
430
- const guidance = isApiError ? {
453
+ const guidance = isMisconfig ? {
454
+ message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, or rotated). Your identity and the AstraSync platform are fine \u2014 contact the site operator. Retrying will not help.",
455
+ registrationUrl: urls?.registrationUrl ?? "",
456
+ documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
457
+ steps: [
458
+ "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
459
+ "Do not retry: the failure is deterministic until the operator updates their key"
460
+ ]
461
+ } : isApiError ? {
431
462
  message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
432
463
  registrationUrl: urls?.registrationUrl ?? "",
433
464
  documentationUrl: urls?.documentationUrl ?? "",
@@ -465,13 +496,22 @@ function createGuidanceResponse(_config, reason, options = {}) {
465
496
  // partners (and their custom onDenied handlers) can branch on
466
497
  // dimension. Without this, the synthesised stub was indistinguishable
467
498
  // from a real policy deny.
468
- failures: isApiError ? [
499
+ failures: isMisconfig ? [
500
+ {
501
+ dimension: "verify_access.merchant_misconfigured",
502
+ message: reason ?? "The integration API key was rejected by AstraSync",
503
+ guidance: guidance.message
504
+ }
505
+ ] : isApiError ? [
469
506
  {
470
507
  dimension: "verify_access.api_error",
471
508
  message: reason ?? "Verification temporarily unavailable",
472
509
  guidance: guidance.message
473
510
  }
474
511
  ] : void 0,
512
+ // 4.0.0: typed marker so adapters render the misconfig envelope (503 +
513
+ // MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
514
+ ...isMisconfig && { misconfigured: true },
475
515
  correlationId: options.correlationId,
476
516
  attemptId: options.attemptId,
477
517
  verifiedAt: /* @__PURE__ */ new Date()
@@ -526,7 +566,8 @@ async function callVerifyAccessAPI(config, request) {
526
566
  const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
527
567
  method: "POST",
528
568
  headers,
529
- body: JSON.stringify(body)
569
+ body: JSON.stringify(body),
570
+ signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
530
571
  });
531
572
  const data = await response.json();
532
573
  if (response.status === 410) {
@@ -550,6 +591,17 @@ async function callVerifyAccessAPI(config, request) {
550
591
  };
551
592
  }
552
593
  if (!response.ok) {
594
+ if (response.status === 401) {
595
+ return {
596
+ success: false,
597
+ error: data.message || data.error || "Integration API key rejected",
598
+ misconfig: true,
599
+ misconfigCode: typeof data?.code === "string" ? data.code : void 0,
600
+ remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
601
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
602
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
603
+ };
604
+ }
553
605
  return {
554
606
  success: false,
555
607
  error: data.message || data.error || `API returned ${response.status}`,
@@ -571,9 +623,19 @@ async function verify(config, request, options) {
571
623
  const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
572
624
  if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
573
625
  if (mergedConfig.strictInit) {
574
- await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
626
+ await performInitCheck(
627
+ mergedConfig.apiBaseUrl,
628
+ mergedConfig.debug,
629
+ true,
630
+ mergedConfig.apiKey
631
+ );
575
632
  } else {
576
- void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
633
+ void performInitCheck(
634
+ mergedConfig.apiBaseUrl,
635
+ mergedConfig.debug,
636
+ false,
637
+ mergedConfig.apiKey
638
+ );
577
639
  }
578
640
  }
579
641
  if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
@@ -612,9 +674,10 @@ async function verify(config, request, options) {
612
674
  const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
613
675
  if (!apiResponse.success) {
614
676
  return createGuidanceResponse(mergedConfig, apiResponse.error, {
615
- source: "api_error",
677
+ source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
616
678
  correlationId: apiResponse.correlationId,
617
679
  attemptId: apiResponse.attemptId,
680
+ remediation: apiResponse.remediation,
618
681
  urls
619
682
  });
620
683
  }
@@ -1362,6 +1425,20 @@ function dedupeFailures(result) {
1362
1425
  }
1363
1426
  }
1364
1427
  function defaultOnDenied(result, _req, res) {
1428
+ if (result.misconfigured) {
1429
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
1430
+ res.status(503).json({
1431
+ success: false,
1432
+ error: {
1433
+ code: "MERCHANT_VERIFICATION_MISCONFIGURED",
1434
+ message: result.denialReasons?.[0] || "This site's AstraSync integration is misconfigured",
1435
+ guidance: result.guidance,
1436
+ failures: result.failures,
1437
+ correlationId: result.correlationId
1438
+ }
1439
+ });
1440
+ return;
1441
+ }
1365
1442
  const statusCode = !result.identityVerified ? 401 : 403;
1366
1443
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
1367
1444
  res.status(statusCode).json({
@@ -2078,6 +2155,21 @@ function createMiddleware2(options) {
2078
2155
  const approvalRequired = result.identityVerified && result.policyAllowed && requiresHumanApproval(result);
2079
2156
  if (approvalRequired) annotateApprovalRequired(result);
2080
2157
  if (!result.identityVerified || !result.policyAllowed || approvalRequired) {
2158
+ if (result.misconfigured && pathname.startsWith("/api/")) {
2159
+ return NextResponse.json(
2160
+ {
2161
+ success: false,
2162
+ error: {
2163
+ code: "MERCHANT_VERIFICATION_MISCONFIGURED",
2164
+ message: result.denialReasons?.[0] || "This site's AstraSync integration is misconfigured",
2165
+ guidance: result.guidance,
2166
+ failures: result.failures,
2167
+ correlationId: result.correlationId
2168
+ }
2169
+ },
2170
+ { status: 503 }
2171
+ );
2172
+ }
2081
2173
  if (pathname.startsWith("/api/")) {
2082
2174
  return NextResponse.json(
2083
2175
  {
@@ -5001,6 +5093,24 @@ function dedupeFailures2(result) {
5001
5093
  }
5002
5094
  function defaultMcpDenied(result, req, res) {
5003
5095
  const id = req.body?.id ?? null;
5096
+ if (result.misconfigured) {
5097
+ res.setHeader("X-Astra-Gateway-Mode", "enforced");
5098
+ res.status(503).json({
5099
+ jsonrpc: "2.0",
5100
+ id,
5101
+ error: {
5102
+ // -32002 → merchant verification misconfigured (see -32000/-32001 below)
5103
+ code: -32002,
5104
+ message: result.denialReasons?.[0] ?? "This server's AstraSync integration is misconfigured",
5105
+ data: {
5106
+ guidance: result.guidance,
5107
+ failures: result.failures,
5108
+ correlationId: result.correlationId
5109
+ }
5110
+ }
5111
+ });
5112
+ return;
5113
+ }
5004
5114
  const status = !result.identityVerified ? 401 : 403;
5005
5115
  res.setHeader("X-Astra-Gateway-Mode", "enforced");
5006
5116
  res.status(status).json({
@@ -5010,6 +5120,7 @@ function defaultMcpDenied(result, req, res) {
5010
5120
  // JSON-RPC error codes:
5011
5121
  // -32000 → unauthorized (no identity resolved)
5012
5122
  // -32001 → insufficient access (identity OK, policy denied)
5123
+ // -32002 → merchant verification misconfigured (handled above)
5013
5124
  code: !result.identityVerified ? -32e3 : -32001,
5014
5125
  message: result.denialReasons?.[0] ?? "Access denied",
5015
5126
  data: {