@astrasyncai/verification-gateway 3.11.1 → 4.0.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 (99) hide show
  1. package/dist/adapter-interface/interface.d.mts +2 -2
  2. package/dist/adapter-interface/interface.d.ts +2 -2
  3. package/dist/adapters/express.d.mts +2 -2
  4. package/dist/adapters/express.d.ts +2 -2
  5. package/dist/adapters/express.js +106 -10
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +106 -10
  8. package/dist/adapters/express.mjs.map +1 -1
  9. package/dist/adapters/mcp.d.mts +1 -1
  10. package/dist/adapters/mcp.d.ts +1 -1
  11. package/dist/adapters/mcp.js +111 -10
  12. package/dist/adapters/mcp.js.map +1 -1
  13. package/dist/adapters/mcp.mjs +111 -10
  14. package/dist/adapters/mcp.mjs.map +1 -1
  15. package/dist/adapters/nextjs.d.mts +2 -2
  16. package/dist/adapters/nextjs.d.ts +2 -2
  17. package/dist/adapters/nextjs.js +107 -10
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +107 -10
  20. package/dist/adapters/nextjs.mjs.map +1 -1
  21. package/dist/adapters/sdk.d.mts +2 -2
  22. package/dist/adapters/sdk.d.ts +2 -2
  23. package/dist/adapters/sdk.js +92 -10
  24. package/dist/adapters/sdk.js.map +1 -1
  25. package/dist/adapters/sdk.mjs +92 -10
  26. package/dist/adapters/sdk.mjs.map +1 -1
  27. package/dist/agent/index.d.mts +2 -2
  28. package/dist/agent/index.d.ts +2 -2
  29. package/dist/bin/astrasync-claude-hook.js +92 -10
  30. package/dist/bin/astrasync-codex-hook.js +92 -10
  31. package/dist/bin/astrasync-guard.js +92 -10
  32. package/dist/bin/astrasync.js +93 -10
  33. package/dist/browser/background.js +92 -10
  34. package/dist/browser/background.js.map +1 -1
  35. package/dist/browser/background.mjs +92 -10
  36. package/dist/browser/background.mjs.map +1 -1
  37. package/dist/browser/browser-adapter.d.mts +2 -2
  38. package/dist/browser/browser-adapter.d.ts +2 -2
  39. package/dist/claude-code/claude-code-adapter.d.mts +2 -2
  40. package/dist/claude-code/claude-code-adapter.d.ts +2 -2
  41. package/dist/cli/index.d.mts +2 -2
  42. package/dist/cli/index.d.ts +2 -2
  43. package/dist/codex/index.d.mts +2 -2
  44. package/dist/codex/index.d.ts +2 -2
  45. package/dist/codex/index.js +92 -10
  46. package/dist/codex/index.js.map +1 -1
  47. package/dist/codex/index.mjs +92 -10
  48. package/dist/codex/index.mjs.map +1 -1
  49. package/dist/cursor/cursor-adapter.d.mts +2 -2
  50. package/dist/cursor/cursor-adapter.d.ts +2 -2
  51. package/dist/cursor/extension.d.mts +2 -2
  52. package/dist/cursor/extension.d.ts +2 -2
  53. package/dist/cursor/extension.js +92 -10
  54. package/dist/cursor/extension.js.map +1 -1
  55. package/dist/cursor/extension.mjs +92 -10
  56. package/dist/cursor/extension.mjs.map +1 -1
  57. package/dist/edge-config.d.mts +1 -1
  58. package/dist/edge-config.d.ts +1 -1
  59. package/dist/{express-DCXa1oqj.d.mts → express-BZajRs4i.d.mts} +1 -1
  60. package/dist/{express-ClNtDhhc.d.ts → express-CjCUB1k7.d.ts} +1 -1
  61. package/dist/gateway/gateway.d.mts +2 -2
  62. package/dist/gateway/gateway.d.ts +2 -2
  63. package/dist/gateway/gateway.js +92 -10
  64. package/dist/gateway/gateway.js.map +1 -1
  65. package/dist/gateway/gateway.mjs +92 -10
  66. package/dist/gateway/gateway.mjs.map +1 -1
  67. package/dist/git-trigger/git-hooks.d.mts +2 -2
  68. package/dist/git-trigger/git-hooks.d.ts +2 -2
  69. package/dist/{index-BrNKDmiR.d.mts → index-B0cyMZDL.d.mts} +1 -1
  70. package/dist/{index-Dr_XiN65.d.mts → index-BRYteOqO.d.mts} +1 -1
  71. package/dist/{index-CfHurO1P.d.ts → index-BZQdVqNw.d.ts} +1 -1
  72. package/dist/{index-D2ztkumS.d.ts → index-adgKhujR.d.ts} +1 -1
  73. package/dist/index.d.mts +9 -9
  74. package/dist/index.d.ts +9 -9
  75. package/dist/index.js +160 -10
  76. package/dist/index.js.map +1 -1
  77. package/dist/index.mjs +159 -10
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/local-evaluator/evaluator.d.mts +2 -2
  80. package/dist/local-evaluator/evaluator.d.ts +2 -2
  81. package/dist/{nextjs-CEBVBsdi.d.ts → nextjs-D_iFf5k-.d.ts} +1 -1
  82. package/dist/{nextjs-DcQIk6Zj.d.mts → nextjs-DeUTnOBd.d.mts} +1 -1
  83. package/dist/{sdk-H0JCLW2y.d.ts → sdk-BM3mwEAq.d.ts} +1 -1
  84. package/dist/{sdk-CZkbSOeO.d.mts → sdk-_il1Q41f.d.mts} +1 -1
  85. package/dist/transport/index.d.mts +2 -2
  86. package/dist/transport/index.d.ts +2 -2
  87. package/dist/{types-sy3tq8lp.d.mts → types-BcDf9Kk0.d.mts} +118 -1
  88. package/dist/{types-DhFPiZ3t.d.ts → types-CHKCgDFC.d.ts} +1 -1
  89. package/dist/{types-cQVCMeNV.d.mts → types-DfnP7JiM.d.mts} +1 -1
  90. package/dist/{types-9tns4wyl.d.ts → types-fTQD448H.d.ts} +118 -1
  91. package/dist/ui/index.d.mts +1 -1
  92. package/dist/ui/index.d.ts +1 -1
  93. package/dist/verify.d.mts +15 -2
  94. package/dist/verify.d.ts +15 -2
  95. package/dist/verify.js +117 -10
  96. package/dist/verify.js.map +1 -1
  97. package/dist/verify.mjs +115 -10
  98. package/dist/verify.mjs.map +1 -1
  99. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.mjs';
2
- import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-cQVCMeNV.mjs';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-DfnP7JiM.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-sy3tq8lp.mjs';
4
+ import '../types-BcDf9Kk0.mjs';
5
5
  import '../metadata-capture.mjs';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.js';
2
- import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-DhFPiZ3t.js';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-CHKCgDFC.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-9tns4wyl.js';
4
+ import '../types-fTQD448H.js';
5
5
  import '../metadata-capture.js';
6
6
 
7
7
  /**
@@ -1,8 +1,8 @@
1
1
  import { VSCodeAPI } from './cursor-adapter.mjs';
2
2
  import '../adapter-interface/interface.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-cQVCMeNV.mjs';
5
- import '../types-sy3tq8lp.mjs';
4
+ import '../types-DfnP7JiM.mjs';
5
+ import '../types-BcDf9Kk0.mjs';
6
6
  import '../metadata-capture.mjs';
7
7
 
8
8
  /**
@@ -1,8 +1,8 @@
1
1
  import { VSCodeAPI } from './cursor-adapter.js';
2
2
  import '../adapter-interface/interface.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-DhFPiZ3t.js';
5
- import '../types-9tns4wyl.js';
4
+ import '../types-CHKCgDFC.js';
5
+ import '../types-fTQD448H.js';
6
6
  import '../metadata-capture.js';
7
7
 
8
8
  /**
@@ -3942,7 +3942,7 @@ function getTrustLevel(score) {
3942
3942
  }
3943
3943
 
3944
3944
  // src/version.ts
3945
- var SDK_VERSION = "3.11.1";
3945
+ var SDK_VERSION = "4.0.0";
3946
3946
 
3947
3947
  // src/well-known.ts
3948
3948
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -3968,7 +3968,7 @@ var DEFAULT_CONFIG = {
3968
3968
  };
3969
3969
  var initCheckPerformed = false;
3970
3970
  var deprecationWarningShown = false;
3971
- async function performInitCheck(apiBaseUrl, debug, strictInit) {
3971
+ async function performInitCheck(apiBaseUrl, debug, strictInit, apiKey) {
3972
3972
  initCheckPerformed = true;
3973
3973
  try {
3974
3974
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
@@ -3985,6 +3985,28 @@ async function performInitCheck(apiBaseUrl, debug, strictInit) {
3985
3985
  `[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
3986
3986
  );
3987
3987
  }
3988
+ if (apiKey) {
3989
+ const selfCheck = await fetch(`${apiBaseUrl}/agents/verify-access/self-check`, {
3990
+ headers: { Authorization: `Bearer ${apiKey}` }
3991
+ });
3992
+ if (selfCheck.status === 401) {
3993
+ const body = await selfCheck.json().catch(() => ({}));
3994
+ const message = `[VerificationGateway] the configured AstraSync API key was REJECTED at startup (${body.code ?? "api_key_invalid"}: ${body.message ?? "invalid key"}). Every inbound agent will be turned away until the key is rotated` + (body.remediation?.manageUrl ? ` at ${body.remediation.manageUrl}` : "") + `.`;
3995
+ if (strictInit) {
3996
+ throw new Error(`${message} (strictInit=true)`);
3997
+ }
3998
+ console.error(message);
3999
+ } else if (selfCheck.ok) {
4000
+ const body = await selfCheck.json().catch(() => ({}));
4001
+ if (typeof body.daysToExpiry === "number" && body.daysToExpiry <= 7) {
4002
+ console.warn(
4003
+ `[VerificationGateway] the configured AstraSync API key expires in ${body.daysToExpiry} day(s) \u2014 rotate it at Settings \u2192 Developer Tools before integrations start failing.`
4004
+ );
4005
+ } else if (debug) {
4006
+ console.log("[VerificationGateway] API key self-check passed");
4007
+ }
4008
+ }
4009
+ }
3988
4010
  } catch (err) {
3989
4011
  if (strictInit) {
3990
4012
  throw err;
@@ -4062,8 +4084,17 @@ function cacheResult(request, result, configuredTtl, counterpartyId) {
4062
4084
  function createGuidanceResponse(_config, reason, options = {}) {
4063
4085
  const source = options.source ?? "no_credentials";
4064
4086
  const isApiError = source === "api_error";
4087
+ const isMisconfig = source === "merchant_misconfig";
4065
4088
  const urls = options.urls;
4066
- const guidance = isApiError ? {
4089
+ const guidance = isMisconfig ? {
4090
+ 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.",
4091
+ registrationUrl: urls?.registrationUrl ?? "",
4092
+ documentationUrl: options.remediation?.docsUrl ?? urls?.documentationUrl ?? "",
4093
+ steps: [
4094
+ "Report the failure to the site operator \u2014 their AstraSync API key needs rotating",
4095
+ "Do not retry: the failure is deterministic until the operator updates their key"
4096
+ ]
4097
+ } : isApiError ? {
4067
4098
  message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
4068
4099
  registrationUrl: urls?.registrationUrl ?? "",
4069
4100
  documentationUrl: urls?.documentationUrl ?? "",
@@ -4101,14 +4132,24 @@ function createGuidanceResponse(_config, reason, options = {}) {
4101
4132
  // partners (and their custom onDenied handlers) can branch on
4102
4133
  // dimension. Without this, the synthesised stub was indistinguishable
4103
4134
  // from a real policy deny.
4104
- failures: isApiError ? [
4135
+ failures: isMisconfig ? [
4136
+ {
4137
+ dimension: "verify_access.merchant_misconfigured",
4138
+ message: reason ?? "The integration API key was rejected by AstraSync",
4139
+ guidance: guidance.message
4140
+ }
4141
+ ] : isApiError ? [
4105
4142
  {
4106
4143
  dimension: "verify_access.api_error",
4107
4144
  message: reason ?? "Verification temporarily unavailable",
4108
4145
  guidance: guidance.message
4109
4146
  }
4110
4147
  ] : void 0,
4148
+ // 4.0.0: typed marker so adapters render the misconfig envelope (503 +
4149
+ // MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
4150
+ ...isMisconfig && { misconfigured: true },
4111
4151
  correlationId: options.correlationId,
4152
+ attemptId: options.attemptId,
4112
4153
  verifiedAt: /* @__PURE__ */ new Date()
4113
4154
  };
4114
4155
  }
@@ -4138,6 +4179,8 @@ async function callVerifyAccessAPI(config, request) {
4138
4179
  body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
4139
4180
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
4140
4181
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
4182
+ if (requestData.attemptId) body.attemptId = requestData.attemptId;
4183
+ if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
4141
4184
  body.sdkVersion = SDK_VERSION;
4142
4185
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
4143
4186
  const meta = {
@@ -4159,12 +4202,16 @@ async function callVerifyAccessAPI(config, request) {
4159
4202
  const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
4160
4203
  method: "POST",
4161
4204
  headers,
4162
- body: JSON.stringify(body)
4205
+ body: JSON.stringify(body),
4206
+ signal: AbortSignal.timeout(config.verifyTimeoutMs ?? 1e4)
4163
4207
  });
4164
4208
  const data = await response.json();
4165
4209
  if (response.status === 410) {
4166
4210
  return {
4167
4211
  success: true,
4212
+ // 3.12.0 (Trust Record): keep the server-echoed attempt handle even on
4213
+ // the synthesised 410 deny shape (echoed on every branch).
4214
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
4168
4215
  access: {
4169
4216
  allowed: false,
4170
4217
  accessLevel: "none",
@@ -4180,10 +4227,22 @@ async function callVerifyAccessAPI(config, request) {
4180
4227
  };
4181
4228
  }
4182
4229
  if (!response.ok) {
4230
+ if (response.status === 401) {
4231
+ return {
4232
+ success: false,
4233
+ error: data.message || data.error || "Integration API key rejected",
4234
+ misconfig: true,
4235
+ misconfigCode: typeof data?.code === "string" ? data.code : void 0,
4236
+ remediation: data?.remediation && typeof data.remediation === "object" ? data.remediation : void 0,
4237
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4238
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
4239
+ };
4240
+ }
4183
4241
  return {
4184
4242
  success: false,
4185
4243
  error: data.message || data.error || `API returned ${response.status}`,
4186
- correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0
4244
+ correlationId: typeof data?.correlationId === "string" ? data.correlationId : void 0,
4245
+ attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0
4187
4246
  };
4188
4247
  }
4189
4248
  return data;
@@ -4200,9 +4259,19 @@ async function verify(config, request, options) {
4200
4259
  const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
4201
4260
  if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
4202
4261
  if (mergedConfig.strictInit) {
4203
- await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
4262
+ await performInitCheck(
4263
+ mergedConfig.apiBaseUrl,
4264
+ mergedConfig.debug,
4265
+ true,
4266
+ mergedConfig.apiKey
4267
+ );
4204
4268
  } else {
4205
- void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
4269
+ void performInitCheck(
4270
+ mergedConfig.apiBaseUrl,
4271
+ mergedConfig.debug,
4272
+ false,
4273
+ mergedConfig.apiKey
4274
+ );
4206
4275
  }
4207
4276
  }
4208
4277
  if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
@@ -4217,7 +4286,13 @@ async function verify(config, request, options) {
4217
4286
  if (mergedConfig.debug) {
4218
4287
  console.log("[VerificationGateway] Returning cached result");
4219
4288
  }
4220
- return cached;
4289
+ const hit = { ...cached };
4290
+ if (request.attemptId) {
4291
+ hit.attemptId = request.attemptId;
4292
+ } else {
4293
+ delete hit.attemptId;
4294
+ }
4295
+ return hit;
4221
4296
  }
4222
4297
  }
4223
4298
  const enrichedRequest = { ...request };
@@ -4235,8 +4310,10 @@ async function verify(config, request, options) {
4235
4310
  const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
4236
4311
  if (!apiResponse.success) {
4237
4312
  return createGuidanceResponse(mergedConfig, apiResponse.error, {
4238
- source: "api_error",
4313
+ source: apiResponse.misconfig ? "merchant_misconfig" : "api_error",
4239
4314
  correlationId: apiResponse.correlationId,
4315
+ attemptId: apiResponse.attemptId,
4316
+ remediation: apiResponse.remediation,
4240
4317
  urls
4241
4318
  });
4242
4319
  }
@@ -4272,6 +4349,9 @@ async function verify(config, request, options) {
4272
4349
  // Anonymous traffic has no session → correlationId is the per-attempt
4273
4350
  // linking key (the sessionId-equivalent for anonymous callers).
4274
4351
  correlationId: apiResponse.correlationId,
4352
+ // 3.12.0 (Trust Record): server echoes the attempt-chain handle on
4353
+ // every branch — denials included (the funnel outlives one deny).
4354
+ attemptId: apiResponse.attemptId,
4275
4355
  recommendation: apiResponse.recommendation,
4276
4356
  recommendationReasons: apiResponse.recommendationReasons,
4277
4357
  stepUpApproval: apiResponse.stepUpApproval,
@@ -4323,6 +4403,8 @@ async function verify(config, request, options) {
4323
4403
  // v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
4324
4404
  // (no session row exists for unverified callers).
4325
4405
  correlationId: apiResponse.correlationId,
4406
+ // 3.12.0 (Trust Record): server-echoed attempt-chain handle.
4407
+ attemptId: apiResponse.attemptId,
4326
4408
  runtimeChallenge: apiResponse.runtimeChallenge,
4327
4409
  tokenGuidance: apiResponse.tokenGuidance,
4328
4410
  recommendation: apiResponse.recommendation,