@astrasyncai/verification-gateway 2.1.0 → 2.2.3

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 (84) hide show
  1. package/README.md +64 -30
  2. package/dist/adapter-interface/interface.d.mts +2 -2
  3. package/dist/adapter-interface/interface.d.ts +2 -2
  4. package/dist/adapters/express.d.mts +2 -2
  5. package/dist/adapters/express.d.ts +2 -2
  6. package/dist/adapters/express.js +74 -95
  7. package/dist/adapters/express.js.map +1 -1
  8. package/dist/adapters/express.mjs +74 -95
  9. package/dist/adapters/express.mjs.map +1 -1
  10. package/dist/adapters/nextjs.d.mts +2 -2
  11. package/dist/adapters/nextjs.d.ts +2 -2
  12. package/dist/adapters/nextjs.js +74 -115
  13. package/dist/adapters/nextjs.js.map +1 -1
  14. package/dist/adapters/nextjs.mjs +74 -115
  15. package/dist/adapters/nextjs.mjs.map +1 -1
  16. package/dist/adapters/sdk.d.mts +2 -2
  17. package/dist/adapters/sdk.d.ts +2 -2
  18. package/dist/adapters/sdk.js +56 -55
  19. package/dist/adapters/sdk.js.map +1 -1
  20. package/dist/adapters/sdk.mjs +56 -55
  21. package/dist/adapters/sdk.mjs.map +1 -1
  22. package/dist/agent/index.d.mts +2 -2
  23. package/dist/agent/index.d.ts +2 -2
  24. package/dist/agent/index.js +68 -2
  25. package/dist/agent/index.js.map +1 -1
  26. package/dist/agent/index.mjs +66 -2
  27. package/dist/agent/index.mjs.map +1 -1
  28. package/dist/browser/background.js +56 -55
  29. package/dist/browser/background.js.map +1 -1
  30. package/dist/browser/background.mjs +56 -55
  31. package/dist/browser/background.mjs.map +1 -1
  32. package/dist/browser/browser-adapter.d.mts +2 -2
  33. package/dist/browser/browser-adapter.d.ts +2 -2
  34. package/dist/cli/index.d.mts +2 -2
  35. package/dist/cli/index.d.ts +2 -2
  36. package/dist/cursor/cursor-adapter.d.mts +2 -2
  37. package/dist/cursor/cursor-adapter.d.ts +2 -2
  38. package/dist/cursor/extension.d.mts +2 -2
  39. package/dist/cursor/extension.d.ts +2 -2
  40. package/dist/cursor/extension.js +56 -55
  41. package/dist/cursor/extension.js.map +1 -1
  42. package/dist/cursor/extension.mjs +56 -55
  43. package/dist/cursor/extension.mjs.map +1 -1
  44. package/dist/{express-Bcl-uBUE.d.ts → express-BtKlLI8U.d.ts} +2 -2
  45. package/dist/{express-CtwDIZyF.d.mts → express-DgwpS8Ha.d.mts} +2 -2
  46. package/dist/gateway/gateway.d.mts +2 -2
  47. package/dist/gateway/gateway.d.ts +2 -2
  48. package/dist/gateway/gateway.js +56 -55
  49. package/dist/gateway/gateway.js.map +1 -1
  50. package/dist/gateway/gateway.mjs +56 -55
  51. package/dist/gateway/gateway.mjs.map +1 -1
  52. package/dist/git-trigger/git-hooks.d.mts +2 -2
  53. package/dist/git-trigger/git-hooks.d.ts +2 -2
  54. package/dist/{index-BY8yQ8N8.d.mts → index-AzhK20t0.d.mts} +46 -3
  55. package/dist/{index-CME6r4uH.d.ts → index-Ba0Lvsjo.d.ts} +1 -1
  56. package/dist/{index-3NRaBNvp.d.mts → index-BaxpmTGA.d.mts} +1 -1
  57. package/dist/{index-CtYSYwn3.d.ts → index-DpJS1JEI.d.ts} +46 -3
  58. package/dist/index.d.mts +7 -7
  59. package/dist/index.d.ts +7 -7
  60. package/dist/index.js +158 -117
  61. package/dist/index.js.map +1 -1
  62. package/dist/index.mjs +158 -117
  63. package/dist/index.mjs.map +1 -1
  64. package/dist/local-evaluator/evaluator.d.mts +2 -2
  65. package/dist/local-evaluator/evaluator.d.ts +2 -2
  66. package/dist/{nextjs-CEldnIJ9.d.ts → nextjs-B2kg19c1.d.ts} +1 -1
  67. package/dist/{nextjs-BQyMCSx_.d.mts → nextjs-ZymQ8jDh.d.mts} +1 -1
  68. package/dist/{sdk-BhvuJSrH.d.mts → sdk-B7id0VFS.d.mts} +2 -2
  69. package/dist/{sdk-BlyVSC_S.d.ts → sdk-Bso0FSI0.d.ts} +2 -2
  70. package/dist/transport/index.d.mts +2 -2
  71. package/dist/transport/index.d.ts +2 -2
  72. package/dist/{types-79qS7aON.d.ts → types-BYKAY6Cc.d.ts} +1 -1
  73. package/dist/{types-jJnPXStc.d.mts → types-CgXPKUwi.d.mts} +1 -1
  74. package/dist/{types-CxQwJKbd.d.mts → types-DOrqNMgy.d.mts} +79 -13
  75. package/dist/{types-CxQwJKbd.d.ts → types-DOrqNMgy.d.ts} +79 -13
  76. package/dist/ui/index.d.mts +1 -1
  77. package/dist/ui/index.d.ts +1 -1
  78. package/dist/webhooks.d.mts +59 -0
  79. package/dist/webhooks.d.ts +59 -0
  80. package/dist/webhooks.js +81 -0
  81. package/dist/webhooks.js.map +1 -0
  82. package/dist/webhooks.mjs +55 -0
  83. package/dist/webhooks.mjs.map +1 -0
  84. package/package.json +8 -3
@@ -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-jJnPXStc.mjs';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-CgXPKUwi.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-CxQwJKbd.mjs';
4
+ import '../types-DOrqNMgy.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-79qS7aON.js';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-BYKAY6Cc.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-CxQwJKbd.js';
4
+ import '../types-DOrqNMgy.js';
5
5
 
6
6
  /**
7
7
  * @astrasyncai/adapter-openclaw-browser
@@ -1,6 +1,6 @@
1
- import { a as LocalPurposeRule, c as LocalScope, d as LocalRiskThresholds, L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-jJnPXStc.mjs';
1
+ import { a as LocalPurposeRule, c as LocalScope, d as LocalRiskThresholds, L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-CgXPKUwi.mjs';
2
2
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.mjs';
3
- import '../types-CxQwJKbd.mjs';
3
+ import '../types-DOrqNMgy.mjs';
4
4
  import '../gateway/gateway.mjs';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { a as LocalPurposeRule, c as LocalScope, d as LocalRiskThresholds, L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-79qS7aON.js';
1
+ import { a as LocalPurposeRule, c as LocalScope, d as LocalRiskThresholds, L as LocalPolicy, P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-BYKAY6Cc.js';
2
2
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.js';
3
- import '../types-CxQwJKbd.js';
3
+ import '../types-DOrqNMgy.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-jJnPXStc.mjs';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-CgXPKUwi.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-CxQwJKbd.mjs';
4
+ import '../types-DOrqNMgy.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-79qS7aON.js';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-BYKAY6Cc.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-CxQwJKbd.js';
4
+ import '../types-DOrqNMgy.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-jJnPXStc.mjs';
5
- import '../types-CxQwJKbd.mjs';
4
+ import '../types-CgXPKUwi.mjs';
5
+ import '../types-DOrqNMgy.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-79qS7aON.js';
5
- import '../types-CxQwJKbd.js';
4
+ import '../types-BYKAY6Cc.js';
5
+ import '../types-DOrqNMgy.js';
6
6
 
7
7
  /**
8
8
  * VS Code Extension entry point for AstraSync Local Guard (Cursor/VS Code).
@@ -3291,51 +3291,45 @@ var ACCESS_LEVEL_HIERARCHY = {
3291
3291
  full: 4,
3292
3292
  internal: 5
3293
3293
  };
3294
- var DEFAULT_TRUST_THRESHOLDS = {
3295
- none: 0,
3296
- guidance: 0,
3297
- "read-only": 20,
3298
- standard: 40,
3299
- full: 70,
3300
- internal: 0
3301
- // Internal is based on org membership, not score
3302
- };
3303
3294
  function getTrustLevel(score) {
3304
3295
  if (score >= 80) return "PLATINUM";
3305
3296
  if (score >= 60) return "GOLD";
3306
3297
  if (score >= 40) return "SILVER";
3307
3298
  return "BRONZE";
3308
3299
  }
3309
- function getAccessLevelForScore(trustScore, thresholds = DEFAULT_TRUST_THRESHOLDS) {
3310
- if (trustScore >= thresholds.full) return "full";
3311
- if (trustScore >= thresholds.standard) return "standard";
3312
- if (trustScore >= thresholds["read-only"]) return "read-only";
3313
- return "guidance";
3314
- }
3315
- function determineAccessLevel(verified, trustScore, isOrgMember, customThresholds) {
3316
- if (!verified) {
3317
- return "guidance";
3318
- }
3319
- if (isOrgMember) {
3320
- return "internal";
3321
- }
3322
- const thresholds = {
3323
- ...DEFAULT_TRUST_THRESHOLDS,
3324
- ...customThresholds
3325
- };
3326
- return getAccessLevelForScore(trustScore, thresholds);
3327
- }
3328
3300
 
3329
3301
  // src/verify.ts
3330
3302
  var DEFAULT_CONFIG = {
3331
- apiBaseUrl: "https://api.astrasync.ai",
3303
+ apiBaseUrl: "https://astrasync.ai/api",
3332
3304
  defaultAccessLevel: "guidance",
3333
- minTrustScore: 40,
3334
- minTrustScoreForFull: 70,
3305
+ // minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
3335
3306
  cacheTtl: 300,
3336
3307
  // 5 minutes
3337
3308
  debug: false
3338
3309
  };
3310
+ var initCheckPerformed = false;
3311
+ var deprecationWarningShown = false;
3312
+ async function performInitCheck(apiBaseUrl, debug) {
3313
+ initCheckPerformed = true;
3314
+ try {
3315
+ const probeUrl = `${apiBaseUrl}/agents/verify-access`;
3316
+ const response = await fetch(probeUrl, { method: "HEAD" });
3317
+ const contentType = response.headers.get("content-type") ?? "";
3318
+ if (contentType.startsWith("text/html")) {
3319
+ console.warn(
3320
+ `[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.`
3321
+ );
3322
+ } else if (debug) {
3323
+ console.log(
3324
+ `[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
3325
+ );
3326
+ }
3327
+ } catch (err) {
3328
+ if (debug) {
3329
+ console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
3330
+ }
3331
+ }
3332
+ }
3339
3333
  var verificationCache = /* @__PURE__ */ new Map();
3340
3334
  function getCacheKey(credentials) {
3341
3335
  return `${credentials.astraId || ""}-${credentials.apiKey || ""}-${credentials.jwt || ""}`;
@@ -3358,9 +3352,6 @@ function cacheResult(credentials, result, ttlSeconds) {
3358
3352
  expiresAt: Date.now() + ttlSeconds * 1e3
3359
3353
  });
3360
3354
  }
3361
- function hasCredentials(credentials) {
3362
- return !!(credentials.astraId || credentials.apiKey || credentials.jwt);
3363
- }
3364
3355
  function createGuidanceResponse(config, reason) {
3365
3356
  const guidance = {
3366
3357
  message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
@@ -3384,7 +3375,7 @@ function createGuidanceResponse(config, reason) {
3384
3375
  async function callVerifyAccessAPI(config, request) {
3385
3376
  const { credentials, ...requestData } = request;
3386
3377
  const body = {
3387
- agentId: credentials.astraId,
3378
+ ...credentials.astraId && { agentId: credentials.astraId },
3388
3379
  purpose: requestData.purpose || "general"
3389
3380
  };
3390
3381
  if (requestData.action) body.action = requestData.action;
@@ -3396,21 +3387,34 @@ async function callVerifyAccessAPI(config, request) {
3396
3387
  if (requestData.isSubAgentRequest) body.isSubAgentRequest = requestData.isSubAgentRequest;
3397
3388
  if (requestData.parentAgentId) body.parentAgentId = requestData.parentAgentId;
3398
3389
  if (requestData.subAgentDepth !== void 0) body.subAgentDepth = requestData.subAgentDepth;
3399
- if (requestData.enableRuntimeChallenge) body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
3390
+ if (requestData.enableRuntimeChallenge)
3391
+ body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
3400
3392
  if (requestData.createSession) body.createSession = requestData.createSession;
3401
3393
  if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
3402
3394
  if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
3403
3395
  if (requestData.counterpartyUrl) body.counterpartyUrl = requestData.counterpartyUrl;
3404
- if (requestData.runtimeChallengeOptions) body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
3396
+ if (config.counterpartyId) body.counterpartyId = config.counterpartyId;
3397
+ if (requestData.runtimeChallengeOptions)
3398
+ body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
3399
+ if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
3400
+ const meta = {
3401
+ ...requestData.clientIp && { sourceIp: requestData.clientIp },
3402
+ ...requestData.userAgent && { userAgent: requestData.userAgent },
3403
+ ...requestData.callerMetadata
3404
+ };
3405
+ if (Object.keys(meta).length > 0) body.callerMetadata = meta;
3406
+ }
3405
3407
  const headers = {
3406
3408
  "Content-Type": "application/json",
3407
3409
  ...config.customHeaders
3408
3410
  };
3409
- if (config.apiKey) {
3410
- headers["X-API-Key"] = config.apiKey;
3411
- }
3412
3411
  if (credentials.authorizationHeader) {
3413
3412
  headers["Authorization"] = credentials.authorizationHeader;
3413
+ } else if (config.apiKey) {
3414
+ headers["Authorization"] = `Bearer ${config.apiKey}`;
3415
+ }
3416
+ if (config.apiKey) {
3417
+ headers["X-API-Key"] = config.apiKey;
3414
3418
  }
3415
3419
  try {
3416
3420
  const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
@@ -3436,8 +3440,14 @@ async function callVerifyAccessAPI(config, request) {
3436
3440
  }
3437
3441
  async function verify(config, request) {
3438
3442
  const mergedConfig = { ...DEFAULT_CONFIG, ...config };
3439
- if (!hasCredentials(request.credentials)) {
3440
- return createGuidanceResponse(mergedConfig, "No agent credentials provided");
3443
+ if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
3444
+ void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug);
3445
+ }
3446
+ if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
3447
+ deprecationWarningShown = true;
3448
+ console.warn(
3449
+ "[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access-level decisions (the SDK reads access.accessLevel from the verify-access response). To gate access to an endpoint, configure the endpoint's trust_score_requirement server-side."
3450
+ );
3441
3451
  }
3442
3452
  if (mergedConfig.cacheTtl && mergedConfig.cacheTtl > 0) {
3443
3453
  const cached = getCachedResult(request.credentials);
@@ -3509,18 +3519,7 @@ async function verify(config, request) {
3509
3519
  selfInstantiationAllowed: apiResponse.access.pdlss.selfInstantiationAllowed,
3510
3520
  appliedPolicy: apiResponse.access.appliedPolicy
3511
3521
  } : void 0;
3512
- const trustScore = agent?.trustScore || 0;
3513
- const isOrgMember = false;
3514
- const accessLevel = determineAccessLevel(
3515
- true,
3516
- trustScore,
3517
- isOrgMember,
3518
- {
3519
- "read-only": 20,
3520
- standard: mergedConfig.minTrustScore || 40,
3521
- full: mergedConfig.minTrustScoreForFull || 70
3522
- }
3523
- );
3522
+ const accessLevel = apiResponse.access?.accessLevel ?? "standard";
3524
3523
  const result = {
3525
3524
  verified: true,
3526
3525
  accessLevel,
@@ -3542,7 +3541,9 @@ async function verify(config, request) {
3542
3541
  if (result.recommendation === "deny") {
3543
3542
  result.verified = false;
3544
3543
  result.accessLevel = "none";
3545
- result.denialReasons = result.recommendationReasons || ["Access denied by AstraSync recommendation"];
3544
+ result.denialReasons = result.recommendationReasons || [
3545
+ "Access denied by AstraSync recommendation"
3546
+ ];
3546
3547
  if (result.runtimeChallenge) {
3547
3548
  result.guidance = {
3548
3549
  message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,