@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
@@ -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-DNK2BgIf.mjs';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-CgDCUfo8.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-L15pYd2c.mjs';
4
+ import '../types-B3USs-Kx.mjs';
5
5
 
6
6
  /**
7
7
  * @astrasyncai/adapter-openclaw-browser
@@ -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-DoWIuzfj.js';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-R5N4ET6x.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-L15pYd2c.js';
4
+ import '../types-B3USs-Kx.js';
5
5
 
6
6
  /**
7
7
  * @astrasyncai/adapter-openclaw-browser
@@ -1,6 +1,6 @@
1
- import { b as LocalPurposeRule, d as LocalScope, c as LocalRiskThresholds, L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-DNK2BgIf.mjs';
1
+ import { b as LocalPurposeRule, d as LocalScope, c as LocalRiskThresholds, L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-CgDCUfo8.mjs';
2
2
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.mjs';
3
- import '../types-L15pYd2c.mjs';
3
+ import '../types-B3USs-Kx.mjs';
4
4
  import '../gateway/gateway.mjs';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { b as LocalPurposeRule, d as LocalScope, c as LocalRiskThresholds, L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-DoWIuzfj.js';
1
+ import { b as LocalPurposeRule, d as LocalScope, c as LocalRiskThresholds, L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-R5N4ET6x.js';
2
2
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.js';
3
- import '../types-L15pYd2c.js';
3
+ import '../types-B3USs-Kx.js';
4
4
  import '../gateway/gateway.js';
5
5
 
6
6
  /**
@@ -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-DNK2BgIf.mjs';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-CgDCUfo8.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-L15pYd2c.mjs';
4
+ import '../types-B3USs-Kx.mjs';
5
5
 
6
6
  /**
7
7
  * @astrasyncai/adapter-cursor
@@ -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-DoWIuzfj.js';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-R5N4ET6x.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-L15pYd2c.js';
4
+ import '../types-B3USs-Kx.js';
5
5
 
6
6
  /**
7
7
  * @astrasyncai/adapter-cursor
@@ -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-DNK2BgIf.mjs';
5
- import '../types-L15pYd2c.mjs';
4
+ import '../types-CgDCUfo8.mjs';
5
+ import '../types-B3USs-Kx.mjs';
6
6
 
7
7
  /**
8
8
  * VS Code Extension entry point for AstraSync Local Guard (Cursor/VS Code).
@@ -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-DoWIuzfj.js';
5
- import '../types-L15pYd2c.js';
4
+ import '../types-R5N4ET6x.js';
5
+ import '../types-B3USs-Kx.js';
6
6
 
7
7
  /**
8
8
  * VS Code Extension entry point for AstraSync Local Guard (Cursor/VS Code).
@@ -350,7 +350,10 @@ var LocalEvaluator = class {
350
350
  }
351
351
  const depth = context.metadata?.subAgentDepth || 0;
352
352
  if (this.policy.selfInstantiation.maxDepth !== void 0 && depth >= this.policy.selfInstantiation.maxDepth) {
353
- return { recommendation: "DENY", reason: `Sub-agent depth ${depth} exceeds max depth ${this.policy.selfInstantiation.maxDepth}` };
353
+ return {
354
+ recommendation: "DENY",
355
+ reason: `Sub-agent depth ${depth} exceeds max depth ${this.policy.selfInstantiation.maxDepth}`
356
+ };
354
357
  }
355
358
  }
356
359
  if (purposeRule.requiresApproval) {
@@ -431,7 +434,10 @@ var LocalEvaluator = class {
431
434
  return { recommendation: "DENY", reason: `Risk score ${riskScore} exceeds block threshold` };
432
435
  }
433
436
  if (riskScore >= thresholds.requireApproval.min) {
434
- return { recommendation: "MANUAL_REVIEW", reason: `Risk score ${riskScore} requires approval` };
437
+ return {
438
+ recommendation: "MANUAL_REVIEW",
439
+ reason: `Risk score ${riskScore} requires approval`
440
+ };
435
441
  }
436
442
  return null;
437
443
  }
@@ -496,6 +502,10 @@ var LocalEvaluator = class {
496
502
  */
497
503
  matchGlob(value, pattern) {
498
504
  if (pattern === value) return true;
505
+ const starCount = (pattern.match(/\*/g) ?? []).length;
506
+ if (starCount > 8) {
507
+ return false;
508
+ }
499
509
  const regexStr = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
500
510
  try {
501
511
  return new RegExp(`^${regexStr}$`, "i").test(value);
@@ -3299,7 +3309,7 @@ function getTrustLevel(score) {
3299
3309
  }
3300
3310
 
3301
3311
  // src/version.ts
3302
- var SDK_VERSION = "2.4.11";
3312
+ var SDK_VERSION = "2.4.13";
3303
3313
 
3304
3314
  // src/verify.ts
3305
3315
  var DEFAULT_CONFIG = {
@@ -3318,22 +3328,27 @@ var DEFAULT_CONFIG = {
3318
3328
  };
3319
3329
  var initCheckPerformed = false;
3320
3330
  var deprecationWarningShown = false;
3321
- async function performInitCheck(apiBaseUrl, debug) {
3331
+ async function performInitCheck(apiBaseUrl, debug, strictInit) {
3322
3332
  initCheckPerformed = true;
3323
3333
  try {
3324
3334
  const probeUrl = `${apiBaseUrl}/agents/verify-access`;
3325
3335
  const response = await fetch(probeUrl, { method: "HEAD" });
3326
3336
  const contentType = response.headers.get("content-type") ?? "";
3327
3337
  if (contentType.startsWith("text/html")) {
3328
- console.warn(
3329
- `[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.`
3330
- );
3338
+ 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).`;
3339
+ if (strictInit) {
3340
+ throw new Error(`${message} (strictInit=true)`);
3341
+ }
3342
+ console.warn(`${message} Set disableInitChecks: true on GatewayConfig to silence.`);
3331
3343
  } else if (debug) {
3332
3344
  console.log(
3333
3345
  `[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
3334
3346
  );
3335
3347
  }
3336
3348
  } catch (err) {
3349
+ if (strictInit) {
3350
+ throw err;
3351
+ }
3337
3352
  if (debug) {
3338
3353
  console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
3339
3354
  }
@@ -3357,7 +3372,23 @@ function getCacheKey(request) {
3357
3372
  request.counterpartyType || "",
3358
3373
  request.isSubAgentRequest ? "1" : "0",
3359
3374
  request.parentAgentId || "",
3360
- request.subAgentDepth ?? ""
3375
+ request.subAgentDepth ?? "",
3376
+ // Audit F-A1-07: previously-missing dimensions that DO affect the
3377
+ // backend verdict. Without these, two requests with different
3378
+ // durations (e.g. 60s vs 86400s) collided on the same cache key and
3379
+ // the shorter-duration allow served the longer-duration request.
3380
+ request.durationRequired ?? "",
3381
+ request.invocationProtocol || "",
3382
+ request.enableRuntimeChallenge ? "1" : "0",
3383
+ // callerMetadata fields contribute to risk model; include the ones
3384
+ // backend reads. sourceIp/userAgent/forwardedFor change per-request
3385
+ // so their inclusion effectively forces a re-check for any varying
3386
+ // client (the right behavior — IP-driven anomaly scoring shouldn't
3387
+ // be cached across IPs).
3388
+ request.callerMetadata?.sourceIp || "",
3389
+ request.callerMetadata?.userAgent || "",
3390
+ request.callerMetadata?.forwardedFor || "",
3391
+ request.callerMetadata?.agentCardUrl || ""
3361
3392
  ].join("|");
3362
3393
  }
3363
3394
  function getCachedResult(request) {
@@ -3386,7 +3417,7 @@ function createGuidanceResponse(config, reason, options = {}) {
3386
3417
  const isApiError = source === "api_error";
3387
3418
  const guidance = isApiError ? {
3388
3419
  message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
3389
- registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
3420
+ registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
3390
3421
  documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
3391
3422
  steps: [
3392
3423
  "Retry the request with exponential backoff",
@@ -3394,7 +3425,7 @@ function createGuidanceResponse(config, reason, options = {}) {
3394
3425
  ]
3395
3426
  } : {
3396
3427
  message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
3397
- registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
3428
+ registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
3398
3429
  documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
3399
3430
  steps: [
3400
3431
  "Register for an AstraSync account",
@@ -3471,12 +3502,8 @@ async function callVerifyAccessAPI(config, request) {
3471
3502
  "Content-Type": "application/json",
3472
3503
  ...config.customHeaders
3473
3504
  };
3474
- if (credentials.authorizationHeader) {
3475
- headers["Authorization"] = credentials.authorizationHeader;
3476
- } else if (config.apiKey) {
3477
- headers["Authorization"] = `Bearer ${config.apiKey}`;
3478
- }
3479
3505
  if (config.apiKey) {
3506
+ headers["Authorization"] = `Bearer ${config.apiKey}`;
3480
3507
  headers["X-API-Key"] = config.apiKey;
3481
3508
  }
3482
3509
  try {
@@ -3522,7 +3549,11 @@ async function callVerifyAccessAPI(config, request) {
3522
3549
  async function verify(config, request) {
3523
3550
  const mergedConfig = { ...DEFAULT_CONFIG, ...config };
3524
3551
  if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
3525
- void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug);
3552
+ if (mergedConfig.strictInit) {
3553
+ await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
3554
+ } else {
3555
+ void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
3556
+ }
3526
3557
  }
3527
3558
  if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
3528
3559
  deprecationWarningShown = true;
@@ -3576,7 +3607,7 @@ async function verify(config, request) {
3576
3607
  requiresApproval: apiResponse.access?.requiresApproval,
3577
3608
  guidance: {
3578
3609
  message: apiResponse.access?.reason || "Access denied by PDLSS policy",
3579
- registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/register`,
3610
+ registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
3580
3611
  documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
3581
3612
  },
3582
3613
  verifiedAt: /* @__PURE__ */ new Date(),
@@ -3646,13 +3677,15 @@ async function verify(config, request) {
3646
3677
  result.denialReasons = result.recommendationReasons || [
3647
3678
  "Access denied by AstraSync recommendation"
3648
3679
  ];
3649
- if (result.runtimeChallenge) {
3650
- result.guidance = {
3651
- message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
3652
- registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/register`,
3653
- documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/runtime-challenge`
3654
- };
3655
- }
3680
+ result.guidance = result.runtimeChallenge ? {
3681
+ message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
3682
+ registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
3683
+ documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/runtime-challenge`
3684
+ } : {
3685
+ message: result.recommendationReasons?.[0] || "Access denied by AstraSync recommendation",
3686
+ registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
3687
+ documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
3688
+ };
3656
3689
  } else if (result.recommendation === "step_up_required") {
3657
3690
  result.requiresStepUp = true;
3658
3691
  if (ACCESS_LEVEL_HIERARCHY[result.accessLevel] > ACCESS_LEVEL_HIERARCHY["read-only"]) {
@@ -3678,6 +3711,35 @@ var import_structured_headers = require("structured-headers");
3678
3711
  // src/transport/rfc9421-verify.ts
3679
3712
  var import_http_message_signatures = require("http-message-signatures");
3680
3713
 
3714
+ // src/transport/nonce-store.ts
3715
+ var InMemoryNonceStore = class {
3716
+ constructor(capacity = 1e4) {
3717
+ this.entries = /* @__PURE__ */ new Map();
3718
+ this.lastSweepMs = 0;
3719
+ this.capacity = capacity;
3720
+ }
3721
+ seen(key, expiresAtMs) {
3722
+ const nowMs = Date.now();
3723
+ if (nowMs - this.lastSweepMs > 1e3) {
3724
+ for (const [k, exp] of this.entries) {
3725
+ if (exp <= nowMs) this.entries.delete(k);
3726
+ }
3727
+ this.lastSweepMs = nowMs;
3728
+ }
3729
+ const existing = this.entries.get(key);
3730
+ if (existing !== void 0 && existing > nowMs) {
3731
+ return true;
3732
+ }
3733
+ if (this.entries.size >= this.capacity) {
3734
+ const oldest = this.entries.keys().next().value;
3735
+ if (oldest !== void 0) this.entries.delete(oldest);
3736
+ }
3737
+ this.entries.set(key, expiresAtMs);
3738
+ return false;
3739
+ }
3740
+ };
3741
+ var defaultNonceStore = new InMemoryNonceStore();
3742
+
3681
3743
  // src/transport/vi.ts
3682
3744
  var import_decode = require("@sd-jwt/decode");
3683
3745
  var import_node_crypto = require("crypto");