@astrasyncai/verification-gateway 2.4.12 → 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 +125 -35
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +125 -35
  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 +71 -28
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +71 -28
  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 +336 -71
  66. package/dist/index.js.map +1 -1
  67. package/dist/index.mjs +336 -71
  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
@@ -344,7 +344,10 @@ var LocalEvaluator = class {
344
344
  }
345
345
  const depth = context.metadata?.subAgentDepth || 0;
346
346
  if (this.policy.selfInstantiation.maxDepth !== void 0 && depth >= this.policy.selfInstantiation.maxDepth) {
347
- return { recommendation: "DENY", reason: `Sub-agent depth ${depth} exceeds max depth ${this.policy.selfInstantiation.maxDepth}` };
347
+ return {
348
+ recommendation: "DENY",
349
+ reason: `Sub-agent depth ${depth} exceeds max depth ${this.policy.selfInstantiation.maxDepth}`
350
+ };
348
351
  }
349
352
  }
350
353
  if (purposeRule.requiresApproval) {
@@ -425,7 +428,10 @@ var LocalEvaluator = class {
425
428
  return { recommendation: "DENY", reason: `Risk score ${riskScore} exceeds block threshold` };
426
429
  }
427
430
  if (riskScore >= thresholds.requireApproval.min) {
428
- return { recommendation: "MANUAL_REVIEW", reason: `Risk score ${riskScore} requires approval` };
431
+ return {
432
+ recommendation: "MANUAL_REVIEW",
433
+ reason: `Risk score ${riskScore} requires approval`
434
+ };
429
435
  }
430
436
  return null;
431
437
  }
@@ -490,6 +496,10 @@ var LocalEvaluator = class {
490
496
  */
491
497
  matchGlob(value, pattern) {
492
498
  if (pattern === value) return true;
499
+ const starCount = (pattern.match(/\*/g) ?? []).length;
500
+ if (starCount > 8) {
501
+ return false;
502
+ }
493
503
  const regexStr = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
494
504
  try {
495
505
  return new RegExp(`^${regexStr}$`, "i").test(value);
@@ -3293,7 +3303,7 @@ function getTrustLevel(score) {
3293
3303
  }
3294
3304
 
3295
3305
  // src/version.ts
3296
- var SDK_VERSION = "2.4.12";
3306
+ var SDK_VERSION = "2.4.13";
3297
3307
 
3298
3308
  // src/verify.ts
3299
3309
  var DEFAULT_CONFIG = {
@@ -3312,22 +3322,27 @@ var DEFAULT_CONFIG = {
3312
3322
  };
3313
3323
  var initCheckPerformed = false;
3314
3324
  var deprecationWarningShown = false;
3315
- async function performInitCheck(apiBaseUrl, debug) {
3325
+ async function performInitCheck(apiBaseUrl, debug, strictInit) {
3316
3326
  initCheckPerformed = true;
3317
3327
  try {
3318
3328
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
3319
3329
  const response = await fetch(probeUrl, { method: "HEAD" });
3320
3330
  const contentType = response.headers.get("content-type") ?? "";
3321
3331
  if (contentType.startsWith("text/html")) {
3322
- console.warn(
3323
- `[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.`
3324
- );
3332
+ 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).`;
3333
+ if (strictInit) {
3334
+ throw new Error(`${message} (strictInit=true)`);
3335
+ }
3336
+ console.warn(`${message} Set disableInitChecks: true on GatewayConfig to silence.`);
3325
3337
  } else if (debug) {
3326
3338
  console.log(
3327
3339
  `[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
3328
3340
  );
3329
3341
  }
3330
3342
  } catch (err) {
3343
+ if (strictInit) {
3344
+ throw err;
3345
+ }
3331
3346
  if (debug) {
3332
3347
  console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
3333
3348
  }
@@ -3351,7 +3366,23 @@ function getCacheKey(request) {
3351
3366
  request.counterpartyType || "",
3352
3367
  request.isSubAgentRequest ? "1" : "0",
3353
3368
  request.parentAgentId || "",
3354
- request.subAgentDepth ?? ""
3369
+ request.subAgentDepth ?? "",
3370
+ // Audit F-A1-07: previously-missing dimensions that DO affect the
3371
+ // backend verdict. Without these, two requests with different
3372
+ // durations (e.g. 60s vs 86400s) collided on the same cache key and
3373
+ // the shorter-duration allow served the longer-duration request.
3374
+ request.durationRequired ?? "",
3375
+ request.invocationProtocol || "",
3376
+ request.enableRuntimeChallenge ? "1" : "0",
3377
+ // callerMetadata fields contribute to risk model; include the ones
3378
+ // backend reads. sourceIp/userAgent/forwardedFor change per-request
3379
+ // so their inclusion effectively forces a re-check for any varying
3380
+ // client (the right behavior — IP-driven anomaly scoring shouldn't
3381
+ // be cached across IPs).
3382
+ request.callerMetadata?.sourceIp || "",
3383
+ request.callerMetadata?.userAgent || "",
3384
+ request.callerMetadata?.forwardedFor || "",
3385
+ request.callerMetadata?.agentCardUrl || ""
3355
3386
  ].join("|");
3356
3387
  }
3357
3388
  function getCachedResult(request) {
@@ -3380,7 +3411,7 @@ function createGuidanceResponse(config, reason, options = {}) {
3380
3411
  const isApiError = source === "api_error";
3381
3412
  const guidance = isApiError ? {
3382
3413
  message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
3383
- registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
3414
+ registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
3384
3415
  documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
3385
3416
  steps: [
3386
3417
  "Retry the request with exponential backoff",
@@ -3388,7 +3419,7 @@ function createGuidanceResponse(config, reason, options = {}) {
3388
3419
  ]
3389
3420
  } : {
3390
3421
  message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
3391
- registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
3422
+ registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
3392
3423
  documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
3393
3424
  steps: [
3394
3425
  "Register for an AstraSync account",
@@ -3465,12 +3496,8 @@ async function callVerifyAccessAPI(config, request) {
3465
3496
  "Content-Type": "application/json",
3466
3497
  ...config.customHeaders
3467
3498
  };
3468
- if (credentials.authorizationHeader) {
3469
- headers["Authorization"] = credentials.authorizationHeader;
3470
- } else if (config.apiKey) {
3471
- headers["Authorization"] = `Bearer ${config.apiKey}`;
3472
- }
3473
3499
  if (config.apiKey) {
3500
+ headers["Authorization"] = `Bearer ${config.apiKey}`;
3474
3501
  headers["X-API-Key"] = config.apiKey;
3475
3502
  }
3476
3503
  try {
@@ -3516,7 +3543,11 @@ async function callVerifyAccessAPI(config, request) {
3516
3543
  async function verify(config, request) {
3517
3544
  const mergedConfig = { ...DEFAULT_CONFIG, ...config };
3518
3545
  if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
3519
- void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug);
3546
+ if (mergedConfig.strictInit) {
3547
+ await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
3548
+ } else {
3549
+ void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
3550
+ }
3520
3551
  }
3521
3552
  if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
3522
3553
  deprecationWarningShown = true;
@@ -3570,7 +3601,7 @@ async function verify(config, request) {
3570
3601
  requiresApproval: apiResponse.access?.requiresApproval,
3571
3602
  guidance: {
3572
3603
  message: apiResponse.access?.reason || "Access denied by PDLSS policy",
3573
- registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/register`,
3604
+ registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
3574
3605
  documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
3575
3606
  },
3576
3607
  verifiedAt: /* @__PURE__ */ new Date(),
@@ -3640,13 +3671,15 @@ async function verify(config, request) {
3640
3671
  result.denialReasons = result.recommendationReasons || [
3641
3672
  "Access denied by AstraSync recommendation"
3642
3673
  ];
3643
- if (result.runtimeChallenge) {
3644
- result.guidance = {
3645
- message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
3646
- registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/register`,
3647
- documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/runtime-challenge`
3648
- };
3649
- }
3674
+ result.guidance = result.runtimeChallenge ? {
3675
+ message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
3676
+ registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
3677
+ documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/runtime-challenge`
3678
+ } : {
3679
+ message: result.recommendationReasons?.[0] || "Access denied by AstraSync recommendation",
3680
+ registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
3681
+ documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
3682
+ };
3650
3683
  } else if (result.recommendation === "step_up_required") {
3651
3684
  result.requiresStepUp = true;
3652
3685
  if (ACCESS_LEVEL_HIERARCHY[result.accessLevel] > ACCESS_LEVEL_HIERARCHY["read-only"]) {
@@ -3672,6 +3705,35 @@ import { parseDictionary } from "structured-headers";
3672
3705
  // src/transport/rfc9421-verify.ts
3673
3706
  import { httpbis } from "http-message-signatures";
3674
3707
 
3708
+ // src/transport/nonce-store.ts
3709
+ var InMemoryNonceStore = class {
3710
+ constructor(capacity = 1e4) {
3711
+ this.entries = /* @__PURE__ */ new Map();
3712
+ this.lastSweepMs = 0;
3713
+ this.capacity = capacity;
3714
+ }
3715
+ seen(key, expiresAtMs) {
3716
+ const nowMs = Date.now();
3717
+ if (nowMs - this.lastSweepMs > 1e3) {
3718
+ for (const [k, exp] of this.entries) {
3719
+ if (exp <= nowMs) this.entries.delete(k);
3720
+ }
3721
+ this.lastSweepMs = nowMs;
3722
+ }
3723
+ const existing = this.entries.get(key);
3724
+ if (existing !== void 0 && existing > nowMs) {
3725
+ return true;
3726
+ }
3727
+ if (this.entries.size >= this.capacity) {
3728
+ const oldest = this.entries.keys().next().value;
3729
+ if (oldest !== void 0) this.entries.delete(oldest);
3730
+ }
3731
+ this.entries.set(key, expiresAtMs);
3732
+ return false;
3733
+ }
3734
+ };
3735
+ var defaultNonceStore = new InMemoryNonceStore();
3736
+
3675
3737
  // src/transport/vi.ts
3676
3738
  import { splitSdJwt, decodeSdJwtSync } from "@sd-jwt/decode";
3677
3739
  import { createHash } from "crypto";