@astrasyncai/verification-gateway 5.12.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 (73) hide show
  1. package/dist/adapters/express.js +36 -10
  2. package/dist/adapters/express.js.map +1 -1
  3. package/dist/adapters/express.mjs +36 -10
  4. package/dist/adapters/express.mjs.map +1 -1
  5. package/dist/adapters/mcp.js +26 -9
  6. package/dist/adapters/mcp.js.map +1 -1
  7. package/dist/adapters/mcp.mjs +26 -9
  8. package/dist/adapters/mcp.mjs.map +1 -1
  9. package/dist/adapters/nextjs.js +36 -10
  10. package/dist/adapters/nextjs.js.map +1 -1
  11. package/dist/adapters/nextjs.mjs +36 -10
  12. package/dist/adapters/nextjs.mjs.map +1 -1
  13. package/dist/adapters/sdk.js +26 -9
  14. package/dist/adapters/sdk.js.map +1 -1
  15. package/dist/adapters/sdk.mjs +26 -9
  16. package/dist/adapters/sdk.mjs.map +1 -1
  17. package/dist/agent/index.js +1 -1
  18. package/dist/agent/index.js.map +1 -1
  19. package/dist/agent/index.mjs +1 -1
  20. package/dist/agent/index.mjs.map +1 -1
  21. package/dist/bin/astrasync-claude-hook.js +26 -9
  22. package/dist/bin/astrasync-codex-hook.js +26 -9
  23. package/dist/bin/astrasync-guard.js +26 -9
  24. package/dist/bin/astrasync.js +26 -9
  25. package/dist/browser/background.js +26 -9
  26. package/dist/browser/background.js.map +1 -1
  27. package/dist/browser/background.mjs +26 -9
  28. package/dist/browser/background.mjs.map +1 -1
  29. package/dist/cli/index.js +1 -1
  30. package/dist/cli/index.js.map +1 -1
  31. package/dist/cli/index.mjs +1 -1
  32. package/dist/cli/index.mjs.map +1 -1
  33. package/dist/codex/index.js +26 -9
  34. package/dist/codex/index.js.map +1 -1
  35. package/dist/codex/index.mjs +26 -9
  36. package/dist/codex/index.mjs.map +1 -1
  37. package/dist/cursor/extension.js +26 -9
  38. package/dist/cursor/extension.js.map +1 -1
  39. package/dist/cursor/extension.mjs +26 -9
  40. package/dist/cursor/extension.mjs.map +1 -1
  41. package/dist/edge-config.js +1 -1
  42. package/dist/edge-config.js.map +1 -1
  43. package/dist/edge-config.mjs +1 -1
  44. package/dist/edge-config.mjs.map +1 -1
  45. package/dist/edge-core/index.js +26 -9
  46. package/dist/edge-core/index.js.map +1 -1
  47. package/dist/edge-core/index.mjs +26 -9
  48. package/dist/edge-core/index.mjs.map +1 -1
  49. package/dist/gateway/gateway.js +26 -9
  50. package/dist/gateway/gateway.js.map +1 -1
  51. package/dist/gateway/gateway.mjs +26 -9
  52. package/dist/gateway/gateway.mjs.map +1 -1
  53. package/dist/index.d.mts +2 -12
  54. package/dist/index.d.ts +2 -12
  55. package/dist/index.js +36 -10
  56. package/dist/index.js.map +1 -1
  57. package/dist/index.mjs +36 -10
  58. package/dist/index.mjs.map +1 -1
  59. package/dist/registration/index.js +1 -1
  60. package/dist/registration/index.js.map +1 -1
  61. package/dist/registration/index.mjs +1 -1
  62. package/dist/registration/index.mjs.map +1 -1
  63. package/dist/transport/index.js +1 -1
  64. package/dist/transport/index.js.map +1 -1
  65. package/dist/transport/index.mjs +1 -1
  66. package/dist/transport/index.mjs.map +1 -1
  67. package/dist/verify.d.mts +0 -10
  68. package/dist/verify.d.ts +0 -10
  69. package/dist/verify.js +36 -10
  70. package/dist/verify.js.map +1 -1
  71. package/dist/verify.mjs +36 -10
  72. package/dist/verify.mjs.map +1 -1
  73. package/package.json +3 -2
@@ -3994,7 +3994,7 @@ function getTrustLevel(score) {
3994
3994
  }
3995
3995
 
3996
3996
  // src/version.ts
3997
- var SDK_VERSION = "5.12.0";
3997
+ var SDK_VERSION = "5.13.0";
3998
3998
 
3999
3999
  // src/http.ts
4000
4000
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -4041,7 +4041,7 @@ var DEFAULT_CONFIG = {
4041
4041
  };
4042
4042
  var initCheckPerformed = false;
4043
4043
  var deprecationWarningShown = false;
4044
- async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4044
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
4045
4045
  initCheckPerformed = true;
4046
4046
  try {
4047
4047
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -4059,7 +4059,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4059
4059
  );
4060
4060
  }
4061
4061
  if (apiKey) {
4062
- const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
4062
+ const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
4063
+ const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
4063
4064
  headers: { Authorization: `Bearer ${apiKey}` }
4064
4065
  });
4065
4066
  if (selfCheck.status === 401) {
@@ -4071,6 +4072,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4071
4072
  console.error(message);
4072
4073
  } else if (selfCheck.ok) {
4073
4074
  const body = await selfCheck.json().catch(() => ({}));
4075
+ if (body.counterparty && body.counterparty.canVerify === false) {
4076
+ const message = `[VerificationGateway] the configured AstraSync API key cannot verify for this endpoint (${body.counterparty.message ?? "endpoint not found or owned by another account"}). Every inbound agent will be turned away until the key or counterparty is corrected.`;
4077
+ if (strictInit) {
4078
+ throw new Error(`${message} (strictInit=true)`);
4079
+ }
4080
+ console.error(message);
4081
+ }
4074
4082
  if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
4075
4083
  console.warn(
4076
4084
  `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
@@ -4175,11 +4183,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
4175
4183
  const isMisconfig = source === "merchant_misconfig";
4176
4184
  const urls = options.urls;
4177
4185
  const guidance = isMisconfig ? {
4178
- 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.",
4186
+ message: "This site's AstraSync integration is misconfigured (its API key was revoked, expired, rotated, or belongs to another account). Your identity and the AstraSync platform are fine \u2014 contact the site operator. Retrying will not help.",
4179
4187
  registrationUrl: urls?.registrationUrl ?? "",
4180
4188
  documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
4181
4189
  steps: [
4182
- "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
4190
+ "Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
4183
4191
  "Do not retry: the failure is deterministic until the operator updates their key"
4184
4192
  ]
4185
4193
  } : isApiError ? {
@@ -4391,12 +4399,13 @@ async function callVerifyAccessAPI(config, request) {
4391
4399
  };
4392
4400
  }
4393
4401
  if (!response.ok) {
4394
- if (response.status === 401) {
4402
+ const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
4403
+ if (response.status === 401 || keyMismatch) {
4395
4404
  return {
4396
4405
  success: false,
4397
4406
  error: data.message || data.error || "Integration API key rejected",
4398
4407
  misconfig: true,
4399
- misconfigCode: typeof data?.code === "string" ? data.code : void 0,
4408
+ misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
4400
4409
  remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
4401
4410
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4402
4411
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
@@ -4429,14 +4438,22 @@ async function verify(config, request, options) {
4429
4438
  mergedConfig.apiBaseUrl,
4430
4439
  mergedConfig.debug,
4431
4440
  true,
4432
- mergedConfig.apiKey
4441
+ mergedConfig.apiKey,
4442
+ {
4443
+ id: mergedConfig.counterpartyId,
4444
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4445
+ }
4433
4446
  );
4434
4447
  } else {
4435
4448
  void performInitCheck(
4436
4449
  mergedConfig.apiBaseUrl,
4437
4450
  mergedConfig.debug,
4438
4451
  false,
4439
- mergedConfig.apiKey
4452
+ mergedConfig.apiKey,
4453
+ {
4454
+ id: mergedConfig.counterpartyId,
4455
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4456
+ }
4440
4457
  );
4441
4458
  }
4442
4459
  }