@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
package/dist/index.mjs CHANGED
@@ -19,7 +19,7 @@ function getTrustLevel(score) {
19
19
  }
20
20
 
21
21
  // src/version.ts
22
- var SDK_VERSION = "5.12.0";
22
+ var SDK_VERSION = "5.13.0";
23
23
 
24
24
  // src/http.ts
25
25
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -163,7 +163,7 @@ var DEFAULT_CONFIG = {
163
163
  };
164
164
  var initCheckPerformed = false;
165
165
  var deprecationWarningShown = false;
166
- async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
166
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
167
167
  initCheckPerformed = true;
168
168
  try {
169
169
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -181,7 +181,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
181
181
  );
182
182
  }
183
183
  if (apiKey) {
184
- const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
184
+ const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
185
+ const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
185
186
  headers: { Authorization: `Bearer ${apiKey}` }
186
187
  });
187
188
  if (selfCheck.status === 401) {
@@ -193,6 +194,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
193
194
  console.error(message);
194
195
  } else if (selfCheck.ok) {
195
196
  const body = await selfCheck.json().catch(() => ({}));
197
+ if (body.counterparty && body.counterparty.canVerify === false) {
198
+ 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.`;
199
+ if (strictInit) {
200
+ throw new Error(`${message} (strictInit=true)`);
201
+ }
202
+ console.error(message);
203
+ }
196
204
  if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
197
205
  console.warn(
198
206
  `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
@@ -337,11 +345,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
337
345
  const isMisconfig = source === "merchant_misconfig";
338
346
  const urls = options.urls;
339
347
  const guidance = isMisconfig ? {
340
- 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.",
348
+ 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.",
341
349
  registrationUrl: urls?.registrationUrl ?? "",
342
350
  documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
343
351
  steps: [
344
- "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
352
+ "Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
345
353
  "Do not retry: the failure is deterministic until the operator updates their key"
346
354
  ]
347
355
  } : isApiError ? {
@@ -553,12 +561,13 @@ async function callVerifyAccessAPI(config, request) {
553
561
  };
554
562
  }
555
563
  if (!response.ok) {
556
- if (response.status === 401) {
564
+ const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
565
+ if (response.status === 401 || keyMismatch) {
557
566
  return {
558
567
  success: false,
559
568
  error: data.message || data.error || "Integration API key rejected",
560
569
  misconfig: true,
561
- misconfigCode: typeof data?.code === "string" ? data.code : void 0,
570
+ misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
562
571
  remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
563
572
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
564
573
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
@@ -591,14 +600,22 @@ async function verify(config, request, options) {
591
600
  mergedConfig.apiBaseUrl,
592
601
  mergedConfig.debug,
593
602
  true,
594
- mergedConfig.apiKey
603
+ mergedConfig.apiKey,
604
+ {
605
+ id: mergedConfig.counterpartyId,
606
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
607
+ }
595
608
  );
596
609
  } else {
597
610
  void performInitCheck(
598
611
  mergedConfig.apiBaseUrl,
599
612
  mergedConfig.debug,
600
613
  false,
601
- mergedConfig.apiKey
614
+ mergedConfig.apiKey,
615
+ {
616
+ id: mergedConfig.counterpartyId,
617
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
618
+ }
602
619
  );
603
620
  }
604
621
  }
@@ -829,6 +846,7 @@ async function reportAttempt(config, report, options = {}) {
829
846
  timer.unref?.();
830
847
  }
831
848
  var ATTEMPT_REPORT_MAX_RETRY_DELAY_MS = 2e3;
849
+ var refusedPolicyReads = /* @__PURE__ */ new Set();
832
850
  async function fetchRoutes(config, counterpartyId) {
833
851
  if (!counterpartyId) return null;
834
852
  const headers = { "Content-Type": "application/json" };
@@ -841,7 +859,15 @@ async function fetchRoutes(config, counterpartyId) {
841
859
  `${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
842
860
  { method: "GET", headers }
843
861
  );
844
- if (!response.ok) return null;
862
+ if (!response.ok) {
863
+ if ((response.status === 401 || response.status === 403 || response.status === 404) && !refusedPolicyReads.has(counterpartyId)) {
864
+ refusedPolicyReads.add(counterpartyId);
865
+ console.error(
866
+ `[VerificationGateway] the configured API key cannot read the route policy for ${counterpartyId} (HTTP ${response.status}). The key belongs to an account that does not own this endpoint, or the counterpartyId is wrong. The gateway is in PASS-THROUGH mode: no agent is being verified.`
867
+ );
868
+ }
869
+ return null;
870
+ }
845
871
  const body = await response.json();
846
872
  return body.data?.routes ?? [];
847
873
  } catch {