@astrasyncai/verification-gateway 5.12.0 → 5.14.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 (75) hide show
  1. package/dist/adapters/express.js +63 -19
  2. package/dist/adapters/express.js.map +1 -1
  3. package/dist/adapters/express.mjs +63 -19
  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 +63 -19
  10. package/dist/adapters/nextjs.js.map +1 -1
  11. package/dist/adapters/nextjs.mjs +63 -19
  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 +53 -18
  22. package/dist/bin/astrasync-codex-hook.js +53 -18
  23. package/dist/bin/astrasync-guard.js +53 -18
  24. package/dist/bin/astrasync.js +54 -19
  25. package/dist/browser/background.js +53 -18
  26. package/dist/browser/background.js.map +1 -1
  27. package/dist/browser/background.mjs +53 -18
  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 +53 -18
  34. package/dist/codex/index.js.map +1 -1
  35. package/dist/codex/index.mjs +53 -18
  36. package/dist/codex/index.mjs.map +1 -1
  37. package/dist/cursor/extension.js +53 -18
  38. package/dist/cursor/extension.js.map +1 -1
  39. package/dist/cursor/extension.mjs +53 -18
  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.d.mts +32 -4
  46. package/dist/edge-core/index.d.ts +32 -4
  47. package/dist/edge-core/index.js +53 -18
  48. package/dist/edge-core/index.js.map +1 -1
  49. package/dist/edge-core/index.mjs +53 -18
  50. package/dist/edge-core/index.mjs.map +1 -1
  51. package/dist/gateway/gateway.js +53 -18
  52. package/dist/gateway/gateway.js.map +1 -1
  53. package/dist/gateway/gateway.mjs +53 -18
  54. package/dist/gateway/gateway.mjs.map +1 -1
  55. package/dist/index.d.mts +2 -12
  56. package/dist/index.d.ts +2 -12
  57. package/dist/index.js +63 -19
  58. package/dist/index.js.map +1 -1
  59. package/dist/index.mjs +63 -19
  60. package/dist/index.mjs.map +1 -1
  61. package/dist/registration/index.js +1 -1
  62. package/dist/registration/index.js.map +1 -1
  63. package/dist/registration/index.mjs +1 -1
  64. package/dist/registration/index.mjs.map +1 -1
  65. package/dist/transport/index.js +1 -1
  66. package/dist/transport/index.js.map +1 -1
  67. package/dist/transport/index.mjs +1 -1
  68. package/dist/transport/index.mjs.map +1 -1
  69. package/dist/verify.d.mts +0 -10
  70. package/dist/verify.d.ts +0 -10
  71. package/dist/verify.js +36 -10
  72. package/dist/verify.js.map +1 -1
  73. package/dist/verify.mjs +36 -10
  74. package/dist/verify.mjs.map +1 -1
  75. package/package.json +3 -2
@@ -28,7 +28,7 @@ __export(sdk_exports, {
28
28
  module.exports = __toCommonJS(sdk_exports);
29
29
 
30
30
  // src/version.ts
31
- var SDK_VERSION = "5.12.0";
31
+ var SDK_VERSION = "5.14.0";
32
32
 
33
33
  // src/http.ts
34
34
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -98,7 +98,7 @@ var DEFAULT_CONFIG = {
98
98
  };
99
99
  var initCheckPerformed = false;
100
100
  var deprecationWarningShown = false;
101
- async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
101
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
102
102
  initCheckPerformed = true;
103
103
  try {
104
104
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -116,7 +116,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
116
116
  );
117
117
  }
118
118
  if (apiKey) {
119
- const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
119
+ const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
120
+ const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
120
121
  headers: { Authorization: `Bearer ${apiKey}` }
121
122
  });
122
123
  if (selfCheck.status === 401) {
@@ -128,6 +129,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
128
129
  console.error(message);
129
130
  } else if (selfCheck.ok) {
130
131
  const body = await selfCheck.json().catch(() => ({}));
132
+ if (body.counterparty && body.counterparty.canVerify === false) {
133
+ 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.`;
134
+ if (strictInit) {
135
+ throw new Error(`${message} (strictInit=true)`);
136
+ }
137
+ console.error(message);
138
+ }
131
139
  if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
132
140
  console.warn(
133
141
  `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
@@ -235,11 +243,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
235
243
  const isMisconfig = source === "merchant_misconfig";
236
244
  const urls = options.urls;
237
245
  const guidance = isMisconfig ? {
238
- 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.",
246
+ 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.",
239
247
  registrationUrl: urls?.registrationUrl ?? "",
240
248
  documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
241
249
  steps: [
242
- "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
250
+ "Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
243
251
  "Do not retry: the failure is deterministic until the operator updates their key"
244
252
  ]
245
253
  } : isApiError ? {
@@ -451,12 +459,13 @@ async function callVerifyAccessAPI(config, request) {
451
459
  };
452
460
  }
453
461
  if (!response.ok) {
454
- if (response.status === 401) {
462
+ const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
463
+ if (response.status === 401 || keyMismatch) {
455
464
  return {
456
465
  success: false,
457
466
  error: data.message || data.error || "Integration API key rejected",
458
467
  misconfig: true,
459
- misconfigCode: typeof data?.code === "string" ? data.code : void 0,
468
+ misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
460
469
  remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
461
470
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
462
471
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
@@ -489,14 +498,22 @@ async function verify(config, request, options) {
489
498
  mergedConfig.apiBaseUrl,
490
499
  mergedConfig.debug,
491
500
  true,
492
- mergedConfig.apiKey
501
+ mergedConfig.apiKey,
502
+ {
503
+ id: mergedConfig.counterpartyId,
504
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
505
+ }
493
506
  );
494
507
  } else {
495
508
  void performInitCheck(
496
509
  mergedConfig.apiBaseUrl,
497
510
  mergedConfig.debug,
498
511
  false,
499
- mergedConfig.apiKey
512
+ mergedConfig.apiKey,
513
+ {
514
+ id: mergedConfig.counterpartyId,
515
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
516
+ }
500
517
  );
501
518
  }
502
519
  }