@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
@@ -3752,7 +3752,7 @@ function getTrustLevel(score) {
3752
3752
  }
3753
3753
 
3754
3754
  // src/version.ts
3755
- var SDK_VERSION = "5.12.0";
3755
+ var SDK_VERSION = "5.13.0";
3756
3756
 
3757
3757
  // src/http.ts
3758
3758
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -3799,7 +3799,7 @@ var DEFAULT_CONFIG = {
3799
3799
  };
3800
3800
  var initCheckPerformed = false;
3801
3801
  var deprecationWarningShown = false;
3802
- async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
3802
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
3803
3803
  initCheckPerformed = true;
3804
3804
  try {
3805
3805
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -3817,7 +3817,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
3817
3817
  );
3818
3818
  }
3819
3819
  if (apiKey) {
3820
- const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
3820
+ const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
3821
+ const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
3821
3822
  headers: { Authorization: `Bearer ${apiKey}` }
3822
3823
  });
3823
3824
  if (selfCheck.status === 401) {
@@ -3829,6 +3830,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
3829
3830
  console.error(message);
3830
3831
  } else if (selfCheck.ok) {
3831
3832
  const body = await selfCheck.json().catch(() => ({}));
3833
+ if (body.counterparty && body.counterparty.canVerify === false) {
3834
+ 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.`;
3835
+ if (strictInit) {
3836
+ throw new Error(`${message} (strictInit=true)`);
3837
+ }
3838
+ console.error(message);
3839
+ }
3832
3840
  if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
3833
3841
  console.warn(
3834
3842
  `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
@@ -3933,11 +3941,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
3933
3941
  const isMisconfig = source === "merchant_misconfig";
3934
3942
  const urls = options.urls;
3935
3943
  const guidance = isMisconfig ? {
3936
- 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.",
3944
+ 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.",
3937
3945
  registrationUrl: urls?.registrationUrl ?? "",
3938
3946
  documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
3939
3947
  steps: [
3940
- "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
3948
+ "Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
3941
3949
  "Do not retry: the failure is deterministic until the operator updates their key"
3942
3950
  ]
3943
3951
  } : isApiError ? {
@@ -4149,12 +4157,13 @@ async function callVerifyAccessAPI(config, request) {
4149
4157
  };
4150
4158
  }
4151
4159
  if (!response.ok) {
4152
- if (response.status === 401) {
4160
+ const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
4161
+ if (response.status === 401 || keyMismatch) {
4153
4162
  return {
4154
4163
  success: false,
4155
4164
  error: data.message || data.error || "Integration API key rejected",
4156
4165
  misconfig: true,
4157
- misconfigCode: typeof data?.code === "string" ? data.code : void 0,
4166
+ misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
4158
4167
  remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
4159
4168
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4160
4169
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
@@ -4187,14 +4196,22 @@ async function verify(config, request, options) {
4187
4196
  mergedConfig.apiBaseUrl,
4188
4197
  mergedConfig.debug,
4189
4198
  true,
4190
- mergedConfig.apiKey
4199
+ mergedConfig.apiKey,
4200
+ {
4201
+ id: mergedConfig.counterpartyId,
4202
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4203
+ }
4191
4204
  );
4192
4205
  } else {
4193
4206
  void performInitCheck(
4194
4207
  mergedConfig.apiBaseUrl,
4195
4208
  mergedConfig.debug,
4196
4209
  false,
4197
- mergedConfig.apiKey
4210
+ mergedConfig.apiKey,
4211
+ {
4212
+ id: mergedConfig.counterpartyId,
4213
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4214
+ }
4198
4215
  );
4199
4216
  }
4200
4217
  }
@@ -3751,7 +3751,7 @@ function getTrustLevel(score) {
3751
3751
  }
3752
3752
 
3753
3753
  // src/version.ts
3754
- var SDK_VERSION = "5.12.0";
3754
+ var SDK_VERSION = "5.13.0";
3755
3755
 
3756
3756
  // src/http.ts
3757
3757
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -3798,7 +3798,7 @@ var DEFAULT_CONFIG = {
3798
3798
  };
3799
3799
  var initCheckPerformed = false;
3800
3800
  var deprecationWarningShown = false;
3801
- async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
3801
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
3802
3802
  initCheckPerformed = true;
3803
3803
  try {
3804
3804
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -3816,7 +3816,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
3816
3816
  );
3817
3817
  }
3818
3818
  if (apiKey) {
3819
- const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
3819
+ const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
3820
+ const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
3820
3821
  headers: { Authorization: `Bearer ${apiKey}` }
3821
3822
  });
3822
3823
  if (selfCheck.status === 401) {
@@ -3828,6 +3829,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
3828
3829
  console.error(message);
3829
3830
  } else if (selfCheck.ok) {
3830
3831
  const body = await selfCheck.json().catch(() => ({}));
3832
+ if (body.counterparty && body.counterparty.canVerify === false) {
3833
+ 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.`;
3834
+ if (strictInit) {
3835
+ throw new Error(`${message} (strictInit=true)`);
3836
+ }
3837
+ console.error(message);
3838
+ }
3831
3839
  if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
3832
3840
  console.warn(
3833
3841
  `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
@@ -3932,11 +3940,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
3932
3940
  const isMisconfig = source === "merchant_misconfig";
3933
3941
  const urls = options.urls;
3934
3942
  const guidance = isMisconfig ? {
3935
- 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.",
3943
+ 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.",
3936
3944
  registrationUrl: urls?.registrationUrl ?? "",
3937
3945
  documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
3938
3946
  steps: [
3939
- "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
3947
+ "Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
3940
3948
  "Do not retry: the failure is deterministic until the operator updates their key"
3941
3949
  ]
3942
3950
  } : isApiError ? {
@@ -4148,12 +4156,13 @@ async function callVerifyAccessAPI(config, request) {
4148
4156
  };
4149
4157
  }
4150
4158
  if (!response.ok) {
4151
- if (response.status === 401) {
4159
+ const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
4160
+ if (response.status === 401 || keyMismatch) {
4152
4161
  return {
4153
4162
  success: false,
4154
4163
  error: data.message || data.error || "Integration API key rejected",
4155
4164
  misconfig: true,
4156
- misconfigCode: typeof data?.code === "string" ? data.code : void 0,
4165
+ misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
4157
4166
  remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
4158
4167
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4159
4168
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
@@ -4186,14 +4195,22 @@ async function verify(config, request, options) {
4186
4195
  mergedConfig.apiBaseUrl,
4187
4196
  mergedConfig.debug,
4188
4197
  true,
4189
- mergedConfig.apiKey
4198
+ mergedConfig.apiKey,
4199
+ {
4200
+ id: mergedConfig.counterpartyId,
4201
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4202
+ }
4190
4203
  );
4191
4204
  } else {
4192
4205
  void performInitCheck(
4193
4206
  mergedConfig.apiBaseUrl,
4194
4207
  mergedConfig.debug,
4195
4208
  false,
4196
- mergedConfig.apiKey
4209
+ mergedConfig.apiKey,
4210
+ {
4211
+ id: mergedConfig.counterpartyId,
4212
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4213
+ }
4197
4214
  );
4198
4215
  }
4199
4216
  }
@@ -3713,7 +3713,7 @@ Policy saved to ${outputPath}`);
3713
3713
  };
3714
3714
 
3715
3715
  // src/version.ts
3716
- var SDK_VERSION = "5.12.0";
3716
+ var SDK_VERSION = "5.13.0";
3717
3717
 
3718
3718
  // src/http.ts
3719
3719
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -4664,7 +4664,7 @@ var DEFAULT_CONFIG = {
4664
4664
  };
4665
4665
  var initCheckPerformed = false;
4666
4666
  var deprecationWarningShown = false;
4667
- async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4667
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
4668
4668
  initCheckPerformed = true;
4669
4669
  try {
4670
4670
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -4682,7 +4682,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4682
4682
  );
4683
4683
  }
4684
4684
  if (apiKey) {
4685
- const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
4685
+ const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
4686
+ const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
4686
4687
  headers: { Authorization: `Bearer ${apiKey}` }
4687
4688
  });
4688
4689
  if (selfCheck.status === 401) {
@@ -4694,6 +4695,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4694
4695
  console.error(message);
4695
4696
  } else if (selfCheck.ok) {
4696
4697
  const body = await selfCheck.json().catch(() => ({}));
4698
+ if (body.counterparty && body.counterparty.canVerify === false) {
4699
+ 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.`;
4700
+ if (strictInit) {
4701
+ throw new Error(`${message} (strictInit=true)`);
4702
+ }
4703
+ console.error(message);
4704
+ }
4697
4705
  if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
4698
4706
  console.warn(
4699
4707
  `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
@@ -4798,11 +4806,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
4798
4806
  const isMisconfig = source === "merchant_misconfig";
4799
4807
  const urls = options.urls;
4800
4808
  const guidance = isMisconfig ? {
4801
- 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.",
4809
+ 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.",
4802
4810
  registrationUrl: urls?.registrationUrl ?? "",
4803
4811
  documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
4804
4812
  steps: [
4805
- "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
4813
+ "Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
4806
4814
  "Do not retry: the failure is deterministic until the operator updates their key"
4807
4815
  ]
4808
4816
  } : isApiError ? {
@@ -5014,12 +5022,13 @@ async function callVerifyAccessAPI(config, request2) {
5014
5022
  };
5015
5023
  }
5016
5024
  if (!response.ok) {
5017
- if (response.status === 401) {
5025
+ const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
5026
+ if (response.status === 401 || keyMismatch) {
5018
5027
  return {
5019
5028
  success: false,
5020
5029
  error: data.message || data.error || "Integration API key rejected",
5021
5030
  misconfig: true,
5022
- misconfigCode: typeof data?.code === "string" ? data.code : void 0,
5031
+ misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
5023
5032
  remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
5024
5033
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
5025
5034
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
@@ -5052,14 +5061,22 @@ async function verify(config, request2, options) {
5052
5061
  mergedConfig.apiBaseUrl,
5053
5062
  mergedConfig.debug,
5054
5063
  true,
5055
- mergedConfig.apiKey
5064
+ mergedConfig.apiKey,
5065
+ {
5066
+ id: mergedConfig.counterpartyId,
5067
+ url: mergedConfig.counterpartyUrl ?? request2.counterpartyUrl
5068
+ }
5056
5069
  );
5057
5070
  } else {
5058
5071
  void performInitCheck(
5059
5072
  mergedConfig.apiBaseUrl,
5060
5073
  mergedConfig.debug,
5061
5074
  false,
5062
- mergedConfig.apiKey
5075
+ mergedConfig.apiKey,
5076
+ {
5077
+ id: mergedConfig.counterpartyId,
5078
+ url: mergedConfig.counterpartyUrl ?? request2.counterpartyUrl
5079
+ }
5063
5080
  );
5064
5081
  }
5065
5082
  }
@@ -36,7 +36,7 @@ var SDK_VERSION;
36
36
  var init_version = __esm({
37
37
  "src/version.ts"() {
38
38
  "use strict";
39
- SDK_VERSION = "5.12.0";
39
+ SDK_VERSION = "5.13.0";
40
40
  }
41
41
  });
42
42
 
@@ -5072,7 +5072,7 @@ var init_failure_posture = __esm({
5072
5072
  });
5073
5073
 
5074
5074
  // src/verify.ts
5075
- async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
5075
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
5076
5076
  initCheckPerformed = true;
5077
5077
  try {
5078
5078
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -5090,7 +5090,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
5090
5090
  );
5091
5091
  }
5092
5092
  if (apiKey) {
5093
- const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
5093
+ const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
5094
+ const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
5094
5095
  headers: { Authorization: `Bearer ${apiKey}` }
5095
5096
  });
5096
5097
  if (selfCheck.status === 401) {
@@ -5102,6 +5103,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
5102
5103
  console.error(message);
5103
5104
  } else if (selfCheck.ok) {
5104
5105
  const body = await selfCheck.json().catch(() => ({}));
5106
+ if (body.counterparty && body.counterparty.canVerify === false) {
5107
+ 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.`;
5108
+ if (strictInit) {
5109
+ throw new Error(`${message} (strictInit=true)`);
5110
+ }
5111
+ console.error(message);
5112
+ }
5105
5113
  if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
5106
5114
  console.warn(
5107
5115
  `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
@@ -5204,11 +5212,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
5204
5212
  const isMisconfig = source === "merchant_misconfig";
5205
5213
  const urls = options.urls;
5206
5214
  const guidance = isMisconfig ? {
5207
- 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.",
5215
+ 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.",
5208
5216
  registrationUrl: urls?.registrationUrl ?? "",
5209
5217
  documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
5210
5218
  steps: [
5211
- "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
5219
+ "Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
5212
5220
  "Do not retry: the failure is deterministic until the operator updates their key"
5213
5221
  ]
5214
5222
  } : isApiError ? {
@@ -5419,12 +5427,13 @@ async function callVerifyAccessAPI(config, request2) {
5419
5427
  };
5420
5428
  }
5421
5429
  if (!response.ok) {
5422
- if (response.status === 401) {
5430
+ const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
5431
+ if (response.status === 401 || keyMismatch) {
5423
5432
  return {
5424
5433
  success: false,
5425
5434
  error: data.message || data.error || "Integration API key rejected",
5426
5435
  misconfig: true,
5427
- misconfigCode: typeof data?.code === "string" ? data.code : void 0,
5436
+ misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
5428
5437
  remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
5429
5438
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
5430
5439
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
@@ -5457,14 +5466,22 @@ async function verify(config, request2, options) {
5457
5466
  mergedConfig.apiBaseUrl,
5458
5467
  mergedConfig.debug,
5459
5468
  true,
5460
- mergedConfig.apiKey
5469
+ mergedConfig.apiKey,
5470
+ {
5471
+ id: mergedConfig.counterpartyId,
5472
+ url: mergedConfig.counterpartyUrl ?? request2.counterpartyUrl
5473
+ }
5461
5474
  );
5462
5475
  } else {
5463
5476
  void performInitCheck(
5464
5477
  mergedConfig.apiBaseUrl,
5465
5478
  mergedConfig.debug,
5466
5479
  false,
5467
- mergedConfig.apiKey
5480
+ mergedConfig.apiKey,
5481
+ {
5482
+ id: mergedConfig.counterpartyId,
5483
+ url: mergedConfig.counterpartyUrl ?? request2.counterpartyUrl
5484
+ }
5468
5485
  );
5469
5486
  }
5470
5487
  }
@@ -3988,7 +3988,7 @@ function getTrustLevel(score) {
3988
3988
  }
3989
3989
 
3990
3990
  // src/version.ts
3991
- var SDK_VERSION = "5.12.0";
3991
+ var SDK_VERSION = "5.13.0";
3992
3992
 
3993
3993
  // src/http.ts
3994
3994
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -4035,7 +4035,7 @@ var DEFAULT_CONFIG = {
4035
4035
  };
4036
4036
  var initCheckPerformed = false;
4037
4037
  var deprecationWarningShown = false;
4038
- async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4038
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey, counterparty) {
4039
4039
  initCheckPerformed = true;
4040
4040
  try {
4041
4041
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -4053,7 +4053,8 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4053
4053
  );
4054
4054
  }
4055
4055
  if (apiKey) {
4056
- const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
4056
+ const q = counterparty?.id ? `?counterpartyId=${encodeURIComponent(counterparty.id)}` : counterparty?.url ? `?counterpartyUrl=${encodeURIComponent(counterparty.url)}` : "";
4057
+ const selfCheck = await sdkFetch(`${apiBaseUrl}/agents/verify-access/self-check${q}`, {
4057
4058
  headers: { Authorization: `Bearer ${apiKey}` }
4058
4059
  });
4059
4060
  if (selfCheck.status === 401) {
@@ -4065,6 +4066,13 @@ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
4065
4066
  console.error(message);
4066
4067
  } else if (selfCheck.ok) {
4067
4068
  const body = await selfCheck.json().catch(() => ({}));
4069
+ if (body.counterparty && body.counterparty.canVerify === false) {
4070
+ 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.`;
4071
+ if (strictInit) {
4072
+ throw new Error(`${message} (strictInit=true)`);
4073
+ }
4074
+ console.error(message);
4075
+ }
4068
4076
  if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
4069
4077
  console.warn(
4070
4078
  `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
@@ -4169,11 +4177,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
4169
4177
  const isMisconfig = source === "merchant_misconfig";
4170
4178
  const urls = options.urls;
4171
4179
  const guidance = isMisconfig ? {
4172
- 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.",
4180
+ 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.",
4173
4181
  registrationUrl: urls?.registrationUrl ?? "",
4174
4182
  documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
4175
4183
  steps: [
4176
- "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
4184
+ "Report the failure to the site operator \u2014 their AstraSync API key needs replacing",
4177
4185
  "Do not retry: the failure is deterministic until the operator updates their key"
4178
4186
  ]
4179
4187
  } : isApiError ? {
@@ -4385,12 +4393,13 @@ async function callVerifyAccessAPI(config, request) {
4385
4393
  };
4386
4394
  }
4387
4395
  if (!response.ok) {
4388
- if (response.status === 401) {
4396
+ const keyMismatch = response.status === 403 && data?.error === "COUNTERPARTY_KEY_MISMATCH";
4397
+ if (response.status === 401 || keyMismatch) {
4389
4398
  return {
4390
4399
  success: false,
4391
4400
  error: data.message || data.error || "Integration API key rejected",
4392
4401
  misconfig: true,
4393
- misconfigCode: typeof data?.code === "string" ? data.code : void 0,
4402
+ misconfigCode: keyMismatch ? "counterparty_key_mismatch" : typeof data?.code === "string" ? data.code : void 0,
4394
4403
  remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
4395
4404
  correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4396
4405
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
@@ -4423,14 +4432,22 @@ async function verify(config, request, options) {
4423
4432
  mergedConfig.apiBaseUrl,
4424
4433
  mergedConfig.debug,
4425
4434
  true,
4426
- mergedConfig.apiKey
4435
+ mergedConfig.apiKey,
4436
+ {
4437
+ id: mergedConfig.counterpartyId,
4438
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4439
+ }
4427
4440
  );
4428
4441
  } else {
4429
4442
  void performInitCheck(
4430
4443
  mergedConfig.apiBaseUrl,
4431
4444
  mergedConfig.debug,
4432
4445
  false,
4433
- mergedConfig.apiKey
4446
+ mergedConfig.apiKey,
4447
+ {
4448
+ id: mergedConfig.counterpartyId,
4449
+ url: mergedConfig.counterpartyUrl ?? request.counterpartyUrl
4450
+ }
4434
4451
  );
4435
4452
  }
4436
4453
  }