@astrasyncai/verification-gateway 2.4.11 → 2.4.14

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 (91) 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 +129 -36
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +129 -36
  8. package/dist/adapters/express.mjs.map +1 -1
  9. package/dist/adapters/mcp.d.mts +26 -4
  10. package/dist/adapters/mcp.d.ts +26 -4
  11. package/dist/adapters/mcp.js +94 -28
  12. package/dist/adapters/mcp.js.map +1 -1
  13. package/dist/adapters/mcp.mjs +94 -28
  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 +75 -29
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +75 -29
  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 +45 -22
  24. package/dist/adapters/sdk.js.map +1 -1
  25. package/dist/adapters/sdk.mjs +45 -22
  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/agent/index.js +29 -0
  30. package/dist/agent/index.js.map +1 -1
  31. package/dist/agent/index.mjs +29 -0
  32. package/dist/agent/index.mjs.map +1 -1
  33. package/dist/browser/background.js +86 -24
  34. package/dist/browser/background.js.map +1 -1
  35. package/dist/browser/background.mjs +86 -24
  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/cli/index.d.mts +2 -2
  40. package/dist/cli/index.d.ts +2 -2
  41. package/dist/cursor/cursor-adapter.d.mts +2 -2
  42. package/dist/cursor/cursor-adapter.d.ts +2 -2
  43. package/dist/cursor/extension.d.mts +2 -2
  44. package/dist/cursor/extension.d.ts +2 -2
  45. package/dist/cursor/extension.js +86 -24
  46. package/dist/cursor/extension.js.map +1 -1
  47. package/dist/cursor/extension.mjs +86 -24
  48. package/dist/cursor/extension.mjs.map +1 -1
  49. package/dist/{express-C1ePFB7n.d.ts → express-CrfwoNAR.d.ts} +1 -1
  50. package/dist/{express-4WStX3PV.d.mts → express-ienhAXps.d.mts} +1 -1
  51. package/dist/gateway/gateway.d.mts +2 -2
  52. package/dist/gateway/gateway.d.ts +2 -2
  53. package/dist/gateway/gateway.js +86 -24
  54. package/dist/gateway/gateway.js.map +1 -1
  55. package/dist/gateway/gateway.mjs +86 -24
  56. package/dist/gateway/gateway.mjs.map +1 -1
  57. package/dist/git-trigger/git-hooks.d.mts +2 -2
  58. package/dist/git-trigger/git-hooks.d.ts +2 -2
  59. package/dist/{index-ChPX4WHl.d.mts → index-B5e2IDWU.d.mts} +1 -1
  60. package/dist/{index-CzJMCgEy.d.ts → index-CCdZxvAr.d.ts} +71 -6
  61. package/dist/{index-D8IEntil.d.mts → index-CEg_WG6y.d.mts} +71 -6
  62. package/dist/{index-Cjm-zBeZ.d.ts → index-DC5f8eoQ.d.ts} +1 -1
  63. package/dist/index.d.mts +7 -7
  64. package/dist/index.d.ts +7 -7
  65. package/dist/index.js +344 -73
  66. package/dist/index.js.map +1 -1
  67. package/dist/index.mjs +344 -73
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/local-evaluator/evaluator.d.mts +2 -2
  70. package/dist/local-evaluator/evaluator.d.ts +2 -2
  71. package/dist/local-evaluator/evaluator.js +12 -2
  72. package/dist/local-evaluator/evaluator.js.map +1 -1
  73. package/dist/local-evaluator/evaluator.mjs +12 -2
  74. package/dist/local-evaluator/evaluator.mjs.map +1 -1
  75. package/dist/{nextjs-BIORS__0.d.ts → nextjs-66R1KW8e.d.ts} +1 -1
  76. package/dist/{nextjs-CjzHdaXA.d.mts → nextjs-DSpisQst.d.mts} +1 -1
  77. package/dist/{sdk-Chhz-FcT.d.mts → sdk-5U_CBRpr.d.mts} +1 -1
  78. package/dist/{sdk-CqTEQAc6.d.ts → sdk-Bm8np66n.d.ts} +1 -1
  79. package/dist/transport/index.d.mts +2 -2
  80. package/dist/transport/index.d.ts +2 -2
  81. package/dist/transport/index.js +146 -28
  82. package/dist/transport/index.js.map +1 -1
  83. package/dist/transport/index.mjs +146 -28
  84. package/dist/transport/index.mjs.map +1 -1
  85. package/dist/{types-L15pYd2c.d.mts → types-B3USs-Kx.d.mts} +42 -1
  86. package/dist/{types-L15pYd2c.d.ts → types-B3USs-Kx.d.ts} +42 -1
  87. package/dist/{types-DNK2BgIf.d.mts → types-CgDCUfo8.d.mts} +1 -1
  88. package/dist/{types-DoWIuzfj.d.ts → types-R5N4ET6x.d.ts} +1 -1
  89. package/dist/ui/index.d.mts +1 -1
  90. package/dist/ui/index.d.ts +1 -1
  91. package/package.json +1 -1
@@ -323,7 +323,10 @@ var LocalEvaluator = class {
323
323
  }
324
324
  const depth = context.metadata?.subAgentDepth || 0;
325
325
  if (this.policy.selfInstantiation.maxDepth !== void 0 && depth >= this.policy.selfInstantiation.maxDepth) {
326
- return { recommendation: "DENY", reason: `Sub-agent depth ${depth} exceeds max depth ${this.policy.selfInstantiation.maxDepth}` };
326
+ return {
327
+ recommendation: "DENY",
328
+ reason: `Sub-agent depth ${depth} exceeds max depth ${this.policy.selfInstantiation.maxDepth}`
329
+ };
327
330
  }
328
331
  }
329
332
  if (purposeRule.requiresApproval) {
@@ -404,7 +407,10 @@ var LocalEvaluator = class {
404
407
  return { recommendation: "DENY", reason: `Risk score ${riskScore} exceeds block threshold` };
405
408
  }
406
409
  if (riskScore >= thresholds.requireApproval.min) {
407
- return { recommendation: "MANUAL_REVIEW", reason: `Risk score ${riskScore} requires approval` };
410
+ return {
411
+ recommendation: "MANUAL_REVIEW",
412
+ reason: `Risk score ${riskScore} requires approval`
413
+ };
408
414
  }
409
415
  return null;
410
416
  }
@@ -469,6 +475,10 @@ var LocalEvaluator = class {
469
475
  */
470
476
  matchGlob(value, pattern) {
471
477
  if (pattern === value) return true;
478
+ const starCount = (pattern.match(/\*/g) ?? []).length;
479
+ if (starCount > 8) {
480
+ return false;
481
+ }
472
482
  const regexStr = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
473
483
  try {
474
484
  return new RegExp(`^${regexStr}$`, "i").test(value);
@@ -3272,7 +3282,7 @@ function getTrustLevel(score) {
3272
3282
  }
3273
3283
 
3274
3284
  // src/version.ts
3275
- var SDK_VERSION = "2.4.11";
3285
+ var SDK_VERSION = "2.4.13";
3276
3286
 
3277
3287
  // src/verify.ts
3278
3288
  var DEFAULT_CONFIG = {
@@ -3291,22 +3301,27 @@ var DEFAULT_CONFIG = {
3291
3301
  };
3292
3302
  var initCheckPerformed = false;
3293
3303
  var deprecationWarningShown = false;
3294
- async function performInitCheck(apiBaseUrl, debug) {
3304
+ async function performInitCheck(apiBaseUrl, debug, strictInit) {
3295
3305
  initCheckPerformed = true;
3296
3306
  try {
3297
3307
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
3298
3308
  const response = await fetch(probeUrl, { method: "HEAD" });
3299
3309
  const contentType = response.headers.get("content-type") ?? "";
3300
3310
  if (contentType.startsWith("text/html")) {
3301
- console.warn(
3302
- `[VerificationGateway] apiBaseUrl '${apiBaseUrl}' returned HTML (content-type: ${contentType}). This usually means apiBaseUrl is pointing at a marketing site instead of the API. Expected: 'https://astrasync.ai/api' (prod) or 'https://staging.astrasync.ai/api' (staging). Set disableInitChecks: true on GatewayConfig to silence this warning.`
3303
- );
3311
+ const message = `[VerificationGateway] apiBaseUrl '${apiBaseUrl}' returned HTML (content-type: ${contentType}). This usually means apiBaseUrl is pointing at a marketing site instead of the API. Expected: 'https://astrasync.ai/api' (prod) or 'https://staging.astrasync.ai/api' (staging).`;
3312
+ if (strictInit) {
3313
+ throw new Error(`${message} (strictInit=true)`);
3314
+ }
3315
+ console.warn(`${message} Set disableInitChecks: true on GatewayConfig to silence.`);
3304
3316
  } else if (debug) {
3305
3317
  console.log(
3306
3318
  `[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
3307
3319
  );
3308
3320
  }
3309
3321
  } catch (err) {
3322
+ if (strictInit) {
3323
+ throw err;
3324
+ }
3310
3325
  if (debug) {
3311
3326
  console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
3312
3327
  }
@@ -3330,7 +3345,23 @@ function getCacheKey(request) {
3330
3345
  request.counterpartyType || "",
3331
3346
  request.isSubAgentRequest ? "1" : "0",
3332
3347
  request.parentAgentId || "",
3333
- request.subAgentDepth ?? ""
3348
+ request.subAgentDepth ?? "",
3349
+ // Audit F-A1-07: previously-missing dimensions that DO affect the
3350
+ // backend verdict. Without these, two requests with different
3351
+ // durations (e.g. 60s vs 86400s) collided on the same cache key and
3352
+ // the shorter-duration allow served the longer-duration request.
3353
+ request.durationRequired ?? "",
3354
+ request.invocationProtocol || "",
3355
+ request.enableRuntimeChallenge ? "1" : "0",
3356
+ // callerMetadata fields contribute to risk model; include the ones
3357
+ // backend reads. sourceIp/userAgent/forwardedFor change per-request
3358
+ // so their inclusion effectively forces a re-check for any varying
3359
+ // client (the right behavior — IP-driven anomaly scoring shouldn't
3360
+ // be cached across IPs).
3361
+ request.callerMetadata?.sourceIp || "",
3362
+ request.callerMetadata?.userAgent || "",
3363
+ request.callerMetadata?.forwardedFor || "",
3364
+ request.callerMetadata?.agentCardUrl || ""
3334
3365
  ].join("|");
3335
3366
  }
3336
3367
  function getCachedResult(request) {
@@ -3359,7 +3390,7 @@ function createGuidanceResponse(config, reason, options = {}) {
3359
3390
  const isApiError = source === "api_error";
3360
3391
  const guidance = isApiError ? {
3361
3392
  message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
3362
- registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
3393
+ registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
3363
3394
  documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
3364
3395
  steps: [
3365
3396
  "Retry the request with exponential backoff",
@@ -3367,7 +3398,7 @@ function createGuidanceResponse(config, reason, options = {}) {
3367
3398
  ]
3368
3399
  } : {
3369
3400
  message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
3370
- registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
3401
+ registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
3371
3402
  documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
3372
3403
  steps: [
3373
3404
  "Register for an AstraSync account",
@@ -3444,12 +3475,8 @@ async function callVerifyAccessAPI(config, request) {
3444
3475
  "Content-Type": "application/json",
3445
3476
  ...config.customHeaders
3446
3477
  };
3447
- if (credentials.authorizationHeader) {
3448
- headers["Authorization"] = credentials.authorizationHeader;
3449
- } else if (config.apiKey) {
3450
- headers["Authorization"] = `Bearer ${config.apiKey}`;
3451
- }
3452
3478
  if (config.apiKey) {
3479
+ headers["Authorization"] = `Bearer ${config.apiKey}`;
3453
3480
  headers["X-API-Key"] = config.apiKey;
3454
3481
  }
3455
3482
  try {
@@ -3495,7 +3522,11 @@ async function callVerifyAccessAPI(config, request) {
3495
3522
  async function verify(config, request) {
3496
3523
  const mergedConfig = { ...DEFAULT_CONFIG, ...config };
3497
3524
  if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
3498
- void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug);
3525
+ if (mergedConfig.strictInit) {
3526
+ await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
3527
+ } else {
3528
+ void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
3529
+ }
3499
3530
  }
3500
3531
  if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
3501
3532
  deprecationWarningShown = true;
@@ -3549,7 +3580,7 @@ async function verify(config, request) {
3549
3580
  requiresApproval: apiResponse.access?.requiresApproval,
3550
3581
  guidance: {
3551
3582
  message: apiResponse.access?.reason || "Access denied by PDLSS policy",
3552
- registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/register`,
3583
+ registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
3553
3584
  documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
3554
3585
  },
3555
3586
  verifiedAt: /* @__PURE__ */ new Date(),
@@ -3619,13 +3650,15 @@ async function verify(config, request) {
3619
3650
  result.denialReasons = result.recommendationReasons || [
3620
3651
  "Access denied by AstraSync recommendation"
3621
3652
  ];
3622
- if (result.runtimeChallenge) {
3623
- result.guidance = {
3624
- message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
3625
- registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/register`,
3626
- documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/runtime-challenge`
3627
- };
3628
- }
3653
+ result.guidance = result.runtimeChallenge ? {
3654
+ message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
3655
+ registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
3656
+ documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/runtime-challenge`
3657
+ } : {
3658
+ message: result.recommendationReasons?.[0] || "Access denied by AstraSync recommendation",
3659
+ registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
3660
+ documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
3661
+ };
3629
3662
  } else if (result.recommendation === "step_up_required") {
3630
3663
  result.requiresStepUp = true;
3631
3664
  if (ACCESS_LEVEL_HIERARCHY[result.accessLevel] > ACCESS_LEVEL_HIERARCHY["read-only"]) {
@@ -3651,6 +3684,35 @@ import { parseDictionary } from "structured-headers";
3651
3684
  // src/transport/rfc9421-verify.ts
3652
3685
  import { httpbis } from "http-message-signatures";
3653
3686
 
3687
+ // src/transport/nonce-store.ts
3688
+ var InMemoryNonceStore = class {
3689
+ constructor(capacity = 1e4) {
3690
+ this.entries = /* @__PURE__ */ new Map();
3691
+ this.lastSweepMs = 0;
3692
+ this.capacity = capacity;
3693
+ }
3694
+ seen(key, expiresAtMs) {
3695
+ const nowMs = Date.now();
3696
+ if (nowMs - this.lastSweepMs > 1e3) {
3697
+ for (const [k, exp] of this.entries) {
3698
+ if (exp <= nowMs) this.entries.delete(k);
3699
+ }
3700
+ this.lastSweepMs = nowMs;
3701
+ }
3702
+ const existing = this.entries.get(key);
3703
+ if (existing !== void 0 && existing > nowMs) {
3704
+ return true;
3705
+ }
3706
+ if (this.entries.size >= this.capacity) {
3707
+ const oldest = this.entries.keys().next().value;
3708
+ if (oldest !== void 0) this.entries.delete(oldest);
3709
+ }
3710
+ this.entries.set(key, expiresAtMs);
3711
+ return false;
3712
+ }
3713
+ };
3714
+ var defaultNonceStore = new InMemoryNonceStore();
3715
+
3654
3716
  // src/transport/vi.ts
3655
3717
  import { splitSdJwt, decodeSdJwtSync } from "@sd-jwt/decode";
3656
3718
  import { createHash } from "crypto";