@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
@@ -3969,7 +3969,7 @@ function getTrustLevel(score) {
3969
3969
  }
3970
3970
 
3971
3971
  // src/version.ts
3972
- var SDK_VERSION = "5.12.0";
3972
+ var SDK_VERSION = "5.13.0";
3973
3973
 
3974
3974
  // src/http.ts
3975
3975
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -4016,7 +4016,7 @@ var DEFAULT_CONFIG = {
4016
4016
  };
4017
4017
  var initCheckPerformed = false;
4018
4018
  var deprecationWarningShown = false;
4019
- async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4019
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
4020
4020
  initCheckPerformed = true;
4021
4021
  try {
4022
4022
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -4034,7 +4034,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4034
4034
  );
4035
4035
  }
4036
4036
  if (apiKey) {
4037
- const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
4037
+ const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
4038
+ const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
4038
4039
  headers: { Authorization: `Bearer ${apiKey}` }
4039
4040
  });
4040
4041
  if (selfCheck.status === 401) {
@@ -4046,6 +4047,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4046
4047
  console.error(message);
4047
4048
  } else if (selfCheck.ok) {
4048
4049
  const body = await selfCheck.json().catch(() => ({}));
4050
+ if (body.counterparty && body.counterparty.canVerify === false) {
4051
+ 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.`;
4052
+ if (strictInit) {
4053
+ throw new Error(`${message} (strictInit=true)`);
4054
+ }
4055
+ console.error(message);
4056
+ }
4049
4057
  if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
4050
4058
  console.warn(
4051
4059
  `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
@@ -4150,11 +4158,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
4150
4158
  const isMisconfig = source === "merchant_misconfig";
4151
4159
  const urls = options.urls;
4152
4160
  const guidance = isMisconfig ? {
4153
- 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.",
4161
+ 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.",
4154
4162
  registrationUrl: urls?.registrationUrl ?? "",
4155
4163
  documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
4156
4164
  steps: [
4157
- "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
4165
+ "Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
4158
4166
  "Do not retry: the failure is deterministic until the operator updates their key"
4159
4167
  ]
4160
4168
  } : isApiError ? {
@@ -4366,12 +4374,13 @@ async function callVerifyAccessAPI(config, request) {
4366
4374
  };
4367
4375
  }
4368
4376
  if (!response.ok) {
4369
- if (response.status === 401) {
4377
+ const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
4378
+ if (response.status === 401 || keyMismatch) {
4370
4379
  return {
4371
4380
  success: false,
4372
4381
  error: data.message || data.error || "Integration API key rejected",
4373
4382
  misconfig: true,
4374
- misconfigCode: typeof data?.code === "string" ? data.code : void 0,
4383
+ misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
4375
4384
  remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
4376
4385
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4377
4386
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
@@ -4404,14 +4413,22 @@ async function verify(config, request, options) {
4404
4413
  mergedConfig.apiBaseUrl,
4405
4414
  mergedConfig.debug,
4406
4415
  true,
4407
- mergedConfig.apiKey
4416
+ mergedConfig.apiKey,
4417
+ {
4418
+ id: mergedConfig.counterpartyId,
4419
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4420
+ }
4408
4421
  );
4409
4422
  } else {
4410
4423
  void performInitCheck(
4411
4424
  mergedConfig.apiBaseUrl,
4412
4425
  mergedConfig.debug,
4413
4426
  false,
4414
- mergedConfig.apiKey
4427
+ mergedConfig.apiKey,
4428
+ {
4429
+ id: mergedConfig.counterpartyId,
4430
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4431
+ }
4415
4432
  );
4416
4433
  }
4417
4434
  }