@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
@@ -3955,7 +3955,7 @@ function getTrustLevel(score) {
3955
3955
  }
3956
3956
 
3957
3957
  // src/version.ts
3958
- var SDK_VERSION = "3.12.0";
3958
+ var SDK_VERSION = "4.0.0";
3959
3959
 
3960
3960
  // src/well-known.ts
3961
3961
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -3981,7 +3981,7 @@ var DEFAULT_CONFIG = {
3981
3981
  };
3982
3982
  var initCheckPerformed = false;
3983
3983
  var deprecationWarningShown = false;
3984
- async function performInitCheck(apiBaseUrl, debug, strictInit) {
3984
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
3985
3985
  initCheckPerformed = true;
3986
3986
  try {
3987
3987
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -3998,6 +3998,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
3998
3998
  `[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
3999
3999
  );
4000
4000
  }
4001
+ if (apiKey) {
4002
+ const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
4003
+ headers: { Authorization: `Bearer ${apiKey}` }
4004
+ });
4005
+ if (selfCheck.status === 401) {
4006
+ const body = await selfCheck.json().catch(() => ({}));
4007
+ 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}` : "") + `.`;
4008
+ if (strictInit) {
4009
+ throw new Error(`${message} (strictInit=true)`);
4010
+ }
4011
+ console.error(message);
4012
+ } else if (selfCheck.ok) {
4013
+ const body = await selfCheck.json().catch(() => ({}));
4014
+ if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
4015
+ console.warn(
4016
+ `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
4017
+ );
4018
+ } else if (debug) {
4019
+ console.log("[VerificationGateway] API key self-check passed");
4020
+ }
4021
+ }
4022
+ }
4001
4023
  } catch (err) {
4002
4024
  if (strictInit) {
4003
4025
  throw err;
@@ -4075,8 +4097,17 @@ function cacheResult(request, result, configuredTtl, counterpartyId) {
4075
4097
  function createGuidanceResponse(_config, reason, options = {}) {
4076
4098
  const source = options.source ?? "no_credentials";
4077
4099
  const isApiError = source === "api_error";
4100
+ const isMisconfig = source === "merchant_misconfig";
4078
4101
  const urls = options.urls;
4079
- const guidance = isApiError ? {
4102
+ const guidance = isMisconfig ? {
4103
+ 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.",
4104
+ registrationUrl: urls?.registrationUrl ?? "",
4105
+ documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
4106
+ steps: [
4107
+ "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
4108
+ "Do not retry: the failure is deterministic until the operator updates their key"
4109
+ ]
4110
+ } : isApiError ? {
4080
4111
  message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
4081
4112
  registrationUrl: urls?.registrationUrl ?? "",
4082
4113
  documentationUrl: urls?.documentationUrl ?? "",
@@ -4114,13 +4145,22 @@ function createGuidanceResponse(_config, reason, options = {}) {
4114
4145
  // partners (and their custom onDenied handlers) can branch on
4115
4146
  // dimension. Without this, the synthesised stub was indistinguishable
4116
4147
  // from a real policy deny.
4117
- failures: isApiError ? [
4148
+ failures: isMisconfig ? [
4149
+ {
4150
+ dimension: "verify_access.merchant_misconfigured",
4151
+ message: reason ?? "The integration API key was rejected by AstraSync",
4152
+ guidance: guidance.message
4153
+ }
4154
+ ] : isApiError ? [
4118
4155
  {
4119
4156
  dimension: "verify_access.api_error",
4120
4157
  message: reason ?? "Verification temporarily unavailable",
4121
4158
  guidance: guidance.message
4122
4159
  }
4123
4160
  ] : void 0,
4161
+ // 4.0.0: typed marker so adapters render the misconfig envelope (503 +
4162
+ // MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
4163
+ ...isMisconfig && { misconfigured: true },
4124
4164
  correlationId: options.correlationId,
4125
4165
  attemptId: options.attemptId,
4126
4166
  verifiedAt: /* @__PURE__ */ new Date()
@@ -4175,7 +4215,8 @@ async function callVerifyAccessAPI(config, request) {
4175
4215
  const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
4176
4216
  method: "POST",
4177
4217
  headers,
4178
- body: JSON.stringify(body)
4218
+ body: JSON.stringify(body),
4219
+ signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
4179
4220
  });
4180
4221
  const data = await response.json();
4181
4222
  if (response.status === 410) {
@@ -4199,6 +4240,17 @@ async function callVerifyAccessAPI(config, request) {
4199
4240
  };
4200
4241
  }
4201
4242
  if (!response.ok) {
4243
+ if (response.status === 401) {
4244
+ return {
4245
+ success: false,
4246
+ error: data.message || data.error || "Integration API key rejected",
4247
+ misconfig: true,
4248
+ misconfigCode: typeof data?.code === "string" ? data.code : void 0,
4249
+ remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
4250
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4251
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
4252
+ };
4253
+ }
4202
4254
  return {
4203
4255
  success: false,
4204
4256
  error: data.message || data.error || `API returned ${response.status}`,
@@ -4220,9 +4272,19 @@ async function verify(config, request, options) {
4220
4272
  const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
4221
4273
  if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
4222
4274
  if (mergedConfig.strictInit) {
4223
- await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
4275
+ await performInitCheck(
4276
+ mergedConfig.apiBaseUrl,
4277
+ mergedConfig.debug,
4278
+ true,
4279
+ mergedConfig.apiKey
4280
+ );
4224
4281
  } else {
4225
- void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
4282
+ void performInitCheck(
4283
+ mergedConfig.apiBaseUrl,
4284
+ mergedConfig.debug,
4285
+ false,
4286
+ mergedConfig.apiKey
4287
+ );
4226
4288
  }
4227
4289
  }
4228
4290
  if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
@@ -4261,9 +4323,10 @@ async function verify(config, request, options) {
4261
4323
  const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
4262
4324
  if (!apiResponse.success) {
4263
4325
  return createGuidanceResponse(mergedConfig, apiResponse.error, {
4264
- source: "api_error",
4326
+ source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
4265
4327
  correlationId: apiResponse.correlationId,
4266
4328
  attemptId: apiResponse.attemptId,
4329
+ remediation: apiResponse.remediation,
4267
4330
  urls
4268
4331
  });
4269
4332
  }