@astrasyncai/verification-gateway 3.11.1 → 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 +106 -10
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +106 -10
  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 +111 -10
  12. package/dist/adapters/mcp.js.map +1 -1
  13. package/dist/adapters/mcp.mjs +111 -10
  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 +107 -10
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +107 -10
  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 +92 -10
  24. package/dist/adapters/sdk.js.map +1 -1
  25. package/dist/adapters/sdk.mjs +92 -10
  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 +92 -10
  30. package/dist/bin/astrasync-codex-hook.js +92 -10
  31. package/dist/bin/astrasync-guard.js +92 -10
  32. package/dist/bin/astrasync.js +93 -10
  33. package/dist/browser/background.js +92 -10
  34. package/dist/browser/background.js.map +1 -1
  35. package/dist/browser/background.mjs +92 -10
  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 +92 -10
  46. package/dist/codex/index.js.map +1 -1
  47. package/dist/codex/index.mjs +92 -10
  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 +92 -10
  54. package/dist/cursor/extension.js.map +1 -1
  55. package/dist/cursor/extension.mjs +92 -10
  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-DCXa1oqj.d.mts → express-BZajRs4i.d.mts} +1 -1
  60. package/dist/{express-ClNtDhhc.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 +92 -10
  64. package/dist/gateway/gateway.js.map +1 -1
  65. package/dist/gateway/gateway.mjs +92 -10
  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-BrNKDmiR.d.mts → index-B0cyMZDL.d.mts} +1 -1
  70. package/dist/{index-Dr_XiN65.d.mts → index-BRYteOqO.d.mts} +1 -1
  71. package/dist/{index-CfHurO1P.d.ts → index-BZQdVqNw.d.ts} +1 -1
  72. package/dist/{index-D2ztkumS.d.ts → index-adgKhujR.d.ts} +1 -1
  73. package/dist/index.d.mts +9 -9
  74. package/dist/index.d.ts +9 -9
  75. package/dist/index.js +160 -10
  76. package/dist/index.js.map +1 -1
  77. package/dist/index.mjs +159 -10
  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-CEBVBsdi.d.ts → nextjs-D_iFf5k-.d.ts} +1 -1
  82. package/dist/{nextjs-DcQIk6Zj.d.mts → nextjs-DeUTnOBd.d.mts} +1 -1
  83. package/dist/{sdk-H0JCLW2y.d.ts → sdk-BM3mwEAq.d.ts} +1 -1
  84. package/dist/{sdk-CZkbSOeO.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-sy3tq8lp.d.mts → types-BcDf9Kk0.d.mts} +118 -1
  88. package/dist/{types-DhFPiZ3t.d.ts → types-CHKCgDFC.d.ts} +1 -1
  89. package/dist/{types-cQVCMeNV.d.mts → types-DfnP7JiM.d.mts} +1 -1
  90. package/dist/{types-9tns4wyl.d.ts → types-fTQD448H.d.ts} +118 -1
  91. package/dist/ui/index.d.mts +1 -1
  92. package/dist/ui/index.d.ts +1 -1
  93. package/dist/verify.d.mts +15 -2
  94. package/dist/verify.d.ts +15 -2
  95. package/dist/verify.js +117 -10
  96. package/dist/verify.js.map +1 -1
  97. package/dist/verify.mjs +115 -10
  98. package/dist/verify.mjs.map +1 -1
  99. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { G as GatewayConfig } from './types-sy3tq8lp.mjs';
1
+ import { G as GatewayConfig } from './types-BcDf9Kk0.mjs';
2
2
  import './metadata-capture.mjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { G as GatewayConfig } from './types-9tns4wyl.js';
1
+ import { G as GatewayConfig } from './types-fTQD448H.js';
2
2
  import './metadata-capture.js';
3
3
 
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler, Request } from 'express';
2
- import { r as VerificationResult, f as ExpressMiddlewareOptions, c as AstraSyncCredentials } from './types-sy3tq8lp.mjs';
2
+ import { w as VerificationResult, k as ExpressMiddlewareOptions, c as AstraSyncCredentials } from './types-BcDf9Kk0.mjs';
3
3
 
4
4
  /**
5
5
  * AstraSync Universal Verification Gateway - Express Middleware
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler, Request } from 'express';
2
- import { r as VerificationResult, f as ExpressMiddlewareOptions, c as AstraSyncCredentials } from './types-9tns4wyl.js';
2
+ import { w as VerificationResult, k as ExpressMiddlewareOptions, c as AstraSyncCredentials } from './types-fTQD448H.js';
3
3
 
4
4
  /**
5
5
  * AstraSync Universal Verification Gateway - Express Middleware
@@ -1,5 +1,5 @@
1
- import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-cQVCMeNV.mjs';
2
- import '../types-sy3tq8lp.mjs';
1
+ import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-DfnP7JiM.mjs';
2
+ import '../types-BcDf9Kk0.mjs';
3
3
  import '../metadata-capture.mjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-DhFPiZ3t.js';
2
- import '../types-9tns4wyl.js';
1
+ import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-CHKCgDFC.js';
2
+ import '../types-fTQD448H.js';
3
3
  import '../metadata-capture.js';
4
4
 
5
5
  /**
@@ -3698,7 +3698,7 @@ function getTrustLevel(score) {
3698
3698
  }
3699
3699
 
3700
3700
  // src/version.ts
3701
- var SDK_VERSION = "3.11.1";
3701
+ var SDK_VERSION = "4.0.0";
3702
3702
 
3703
3703
  // src/well-known.ts
3704
3704
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -3724,7 +3724,7 @@ var DEFAULT_CONFIG = {
3724
3724
  };
3725
3725
  var initCheckPerformed = false;
3726
3726
  var deprecationWarningShown = false;
3727
- async function performInitCheck(apiBaseUrl, debug, strictInit) {
3727
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
3728
3728
  initCheckPerformed = true;
3729
3729
  try {
3730
3730
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -3741,6 +3741,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
3741
3741
  `[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
3742
3742
  );
3743
3743
  }
3744
+ if (apiKey) {
3745
+ const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
3746
+ headers: { Authorization: `Bearer ${apiKey}` }
3747
+ });
3748
+ if (selfCheck.status === 401) {
3749
+ const body = await selfCheck.json().catch(() => ({}));
3750
+ 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}` : "") + `.`;
3751
+ if (strictInit) {
3752
+ throw new Error(`${message} (strictInit=true)`);
3753
+ }
3754
+ console.error(message);
3755
+ } else if (selfCheck.ok) {
3756
+ const body = await selfCheck.json().catch(() => ({}));
3757
+ if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
3758
+ console.warn(
3759
+ `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
3760
+ );
3761
+ } else if (debug) {
3762
+ console.log("[VerificationGateway] API key self-check passed");
3763
+ }
3764
+ }
3765
+ }
3744
3766
  } catch (err) {
3745
3767
  if (strictInit) {
3746
3768
  throw err;
@@ -3818,8 +3840,17 @@ function cacheResult(request, result, configuredTtl, counterpartyId) {
3818
3840
  function createGuidanceResponse(_config, reason, options = {}) {
3819
3841
  const source = options.source ?? "no_credentials";
3820
3842
  const isApiError = source === "api_error";
3843
+ const isMisconfig = source === "merchant_misconfig";
3821
3844
  const urls = options.urls;
3822
- const guidance = isApiError ? {
3845
+ const guidance = isMisconfig ? {
3846
+ 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.",
3847
+ registrationUrl: urls?.registrationUrl ?? "",
3848
+ documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
3849
+ steps: [
3850
+ "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
3851
+ "Do not retry: the failure is deterministic until the operator updates their key"
3852
+ ]
3853
+ } : isApiError ? {
3823
3854
  message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
3824
3855
  registrationUrl: urls?.registrationUrl ?? "",
3825
3856
  documentationUrl: urls?.documentationUrl ?? "",
@@ -3857,14 +3888,24 @@ function createGuidanceResponse(_config, reason, options = {}) {
3857
3888
  // partners (and their custom onDenied handlers) can branch on
3858
3889
  // dimension. Without this, the synthesised stub was indistinguishable
3859
3890
  // from a real policy deny.
3860
- failures: isApiError ? [
3891
+ failures: isMisconfig ? [
3892
+ {
3893
+ dimension: "verify_access.merchant_misconfigured",
3894
+ message: reason ?? "The integration API key was rejected by AstraSync",
3895
+ guidance: guidance.message
3896
+ }
3897
+ ] : isApiError ? [
3861
3898
  {
3862
3899
  dimension: "verify_access.api_error",
3863
3900
  message: reason ?? "Verification temporarily unavailable",
3864
3901
  guidance: guidance.message
3865
3902
  }
3866
3903
  ] : void 0,
3904
+ // 4.0.0: typed marker so adapters render the misconfig envelope (503 +
3905
+ // MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
3906
+ ...isMisconfig && { misconfigured: true },
3867
3907
  correlationId: options.correlationId,
3908
+ attemptId: options.attemptId,
3868
3909
  verifiedAt: /* @__PURE__ */ new Date()
3869
3910
  };
3870
3911
  }
@@ -3894,6 +3935,8 @@ async function callVerifyAccessAPI(config, request) {
3894
3935
  body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
3895
3936
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
3896
3937
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
3938
+ if (requestData.attemptId) body.attemptId = requestData.attemptId;
3939
+ if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
3897
3940
  body.sdkVersion = SDK_VERSION;
3898
3941
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
3899
3942
  const meta = {
@@ -3915,12 +3958,16 @@ async function callVerifyAccessAPI(config, request) {
3915
3958
  const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
3916
3959
  method: "POST",
3917
3960
  headers,
3918
- body: JSON.stringify(body)
3961
+ body: JSON.stringify(body),
3962
+ signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
3919
3963
  });
3920
3964
  const data = await response.json();
3921
3965
  if (response.status === 410) {
3922
3966
  return {
3923
3967
  success: true,
3968
+ // 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
3969
+ // the synthesised 410 deny shape (echoed on every branch).
3970
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
3924
3971
  access: {
3925
3972
  allowed: false,
3926
3973
  accessLevel: "none",
@@ -3936,10 +3983,22 @@ async function callVerifyAccessAPI(config, request) {
3936
3983
  };
3937
3984
  }
3938
3985
  if (!response.ok) {
3986
+ if (response.status === 401) {
3987
+ return {
3988
+ success: false,
3989
+ error: data.message || data.error || "Integration API key rejected",
3990
+ misconfig: true,
3991
+ misconfigCode: typeof data?.code === "string" ? data.code : void 0,
3992
+ remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
3993
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
3994
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
3995
+ };
3996
+ }
3939
3997
  return {
3940
3998
  success: false,
3941
3999
  error: data.message || data.error || `API returned ${response.status}`,
3942
- correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
4000
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4001
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
3943
4002
  };
3944
4003
  }
3945
4004
  return data;
@@ -3956,9 +4015,19 @@ async function verify(config, request, options) {
3956
4015
  const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
3957
4016
  if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
3958
4017
  if (mergedConfig.strictInit) {
3959
- await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
4018
+ await performInitCheck(
4019
+ mergedConfig.apiBaseUrl,
4020
+ mergedConfig.debug,
4021
+ true,
4022
+ mergedConfig.apiKey
4023
+ );
3960
4024
  } else {
3961
- void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
4025
+ void performInitCheck(
4026
+ mergedConfig.apiBaseUrl,
4027
+ mergedConfig.debug,
4028
+ false,
4029
+ mergedConfig.apiKey
4030
+ );
3962
4031
  }
3963
4032
  }
3964
4033
  if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
@@ -3973,7 +4042,13 @@ async function verify(config, request, options) {
3973
4042
  if (mergedConfig.debug) {
3974
4043
  console.log("[VerificationGateway] Returning cached result");
3975
4044
  }
3976
- return cached;
4045
+ const hit = { ...cached };
4046
+ if (request.attemptId) {
4047
+ hit.attemptId = request.attemptId;
4048
+ } else {
4049
+ delete hit.attemptId;
4050
+ }
4051
+ return hit;
3977
4052
  }
3978
4053
  }
3979
4054
  const enrichedRequest = { ...request };
@@ -3991,8 +4066,10 @@ async function verify(config, request, options) {
3991
4066
  const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
3992
4067
  if (!apiResponse.success) {
3993
4068
  return createGuidanceResponse(mergedConfig, apiResponse.error, {
3994
- source: "api_error",
4069
+ source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
3995
4070
  correlationId: apiResponse.correlationId,
4071
+ attemptId: apiResponse.attemptId,
4072
+ remediation: apiResponse.remediation,
3996
4073
  urls
3997
4074
  });
3998
4075
  }
@@ -4028,6 +4105,9 @@ async function verify(config, request, options) {
4028
4105
  // Anonymous traffic has no session → correlationId is the per-attempt
4029
4106
  // linking key (the sessionId-equivalent for anonymous callers).
4030
4107
  correlationId: apiResponse.correlationId,
4108
+ // 3.12.0 (Trust Record): server echoes the attempt-chain handle on
4109
+ // every branch — denials included (the funnel outlives one deny).
4110
+ attemptId: apiResponse.attemptId,
4031
4111
  recommendation: apiResponse.recommendation,
4032
4112
  recommendationReasons: apiResponse.recommendationReasons,
4033
4113
  stepUpApproval: apiResponse.stepUpApproval,
@@ -4079,6 +4159,8 @@ async function verify(config, request, options) {
4079
4159
  // v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
4080
4160
  // (no session row exists for unverified callers).
4081
4161
  correlationId: apiResponse.correlationId,
4162
+ // 3.12.0 (Trust Record): server-echoed attempt-chain handle.
4163
+ attemptId: apiResponse.attemptId,
4082
4164
  runtimeChallenge: apiResponse.runtimeChallenge,
4083
4165
  tokenGuidance: apiResponse.tokenGuidance,
4084
4166
  recommendation: apiResponse.recommendation,