@astrasyncai/verification-gateway 2.2.0 → 2.3.4

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 +40 -89
  7. package/dist/adapters/express.js.map +1 -1
  8. package/dist/adapters/express.mjs +40 -89
  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 +39 -109
  13. package/dist/adapters/nextjs.js.map +1 -1
  14. package/dist/adapters/nextjs.mjs +39 -109
  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 +39 -53
  19. package/dist/adapters/sdk.js.map +1 -1
  20. package/dist/adapters/sdk.mjs +39 -53
  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 +2 -2
  25. package/dist/agent/index.js.map +1 -1
  26. package/dist/agent/index.mjs +2 -2
  27. package/dist/agent/index.mjs.map +1 -1
  28. package/dist/browser/background.js +39 -53
  29. package/dist/browser/background.js.map +1 -1
  30. package/dist/browser/background.mjs +39 -53
  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 +39 -53
  41. package/dist/cursor/extension.js.map +1 -1
  42. package/dist/cursor/extension.mjs +39 -53
  43. package/dist/cursor/extension.mjs.map +1 -1
  44. package/dist/{express-DpwYW08E.d.ts → express-CraCA8_t.d.ts} +2 -2
  45. package/dist/{express-C9KqJNWV.d.mts → express-DtvJ6BGt.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 +39 -53
  49. package/dist/gateway/gateway.js.map +1 -1
  50. package/dist/gateway/gateway.mjs +39 -53
  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-gM-lgX_X.d.ts → index--KzVRa32.d.ts} +1 -1
  55. package/dist/{index-BMZdjGT4.d.mts → index-BZ85CeEr.d.mts} +2 -2
  56. package/dist/{index-Dm2xA6j1.d.ts → index-BzAFmemy.d.ts} +2 -2
  57. package/dist/{index-DlsYN3Et.d.mts → index-SEgnWzkf.d.mts} +1 -1
  58. package/dist/index.d.mts +7 -7
  59. package/dist/index.d.ts +7 -7
  60. package/dist/index.js +42 -107
  61. package/dist/index.js.map +1 -1
  62. package/dist/index.mjs +42 -107
  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-yNzimC3a.d.ts → nextjs-B8o9C0t6.d.ts} +1 -1
  67. package/dist/{nextjs-BEqidT0U.d.mts → nextjs-DZHAn9j-.d.mts} +1 -1
  68. package/dist/{sdk-CP9C9Qu0.d.ts → sdk-BQ3olp3v.d.ts} +2 -2
  69. package/dist/{sdk-7fa9H0qa.d.mts → sdk-CRSUFQH2.d.mts} +2 -2
  70. package/dist/transport/index.d.mts +2 -2
  71. package/dist/transport/index.d.ts +2 -2
  72. package/dist/{types-CrVMq_Td.d.mts → types-JMgPake9.d.mts} +135 -28
  73. package/dist/{types-CrVMq_Td.d.ts → types-JMgPake9.d.ts} +135 -28
  74. package/dist/{types-DE0ooQJ6.d.mts → types-aN1UHhyy.d.mts} +1 -1
  75. package/dist/{types-rigu2bH3.d.ts → types-osMd_dpT.d.ts} +1 -1
  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 +6 -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-DE0ooQJ6.mjs';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-aN1UHhyy.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-CrVMq_Td.mjs';
4
+ import '../types-JMgPake9.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-rigu2bH3.js';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-osMd_dpT.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-CrVMq_Td.js';
4
+ import '../types-JMgPake9.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-DE0ooQJ6.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-aN1UHhyy.mjs';
2
2
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.mjs';
3
- import '../types-CrVMq_Td.mjs';
3
+ import '../types-JMgPake9.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-rigu2bH3.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-osMd_dpT.js';
2
2
  import { PlatformAdapter, AdapterConfig } from '../adapter-interface/interface.js';
3
- import '../types-CrVMq_Td.js';
3
+ import '../types-JMgPake9.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-DE0ooQJ6.mjs';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-aN1UHhyy.mjs';
3
3
  import '../gateway/gateway.mjs';
4
- import '../types-CrVMq_Td.mjs';
4
+ import '../types-JMgPake9.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-rigu2bH3.js';
2
+ import { P as PDLSSContext, V as VerificationDecision, A as AgentAction, I as InterceptResult } from '../types-osMd_dpT.js';
3
3
  import '../gateway/gateway.js';
4
- import '../types-CrVMq_Td.js';
4
+ import '../types-JMgPake9.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-DE0ooQJ6.mjs';
5
- import '../types-CrVMq_Td.mjs';
4
+ import '../types-aN1UHhyy.mjs';
5
+ import '../types-JMgPake9.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-rigu2bH3.js';
5
- import '../types-CrVMq_Td.js';
4
+ import '../types-osMd_dpT.js';
5
+ import '../types-JMgPake9.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;
@@ -3402,6 +3393,7 @@ async function callVerifyAccessAPI(config, request) {
3402
3393
  if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
3403
3394
  if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
3404
3395
  if (requestData.counterpartyUrl) body.counterpartyUrl = requestData.counterpartyUrl;
3396
+ if (config.counterpartyId) body.counterpartyId = config.counterpartyId;
3405
3397
  if (requestData.runtimeChallengeOptions)
3406
3398
  body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
3407
3399
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
@@ -3448,8 +3440,14 @@ async function callVerifyAccessAPI(config, request) {
3448
3440
  }
3449
3441
  async function verify(config, request) {
3450
3442
  const mergedConfig = { ...DEFAULT_CONFIG, ...config };
3451
- if (!hasCredentials(request.credentials)) {
3452
- 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
+ );
3453
3451
  }
3454
3452
  if (mergedConfig.cacheTtl && mergedConfig.cacheTtl > 0) {
3455
3453
  const cached = getCachedResult(request.credentials);
@@ -3513,28 +3511,16 @@ async function verify(config, request) {
3513
3511
  verified: apiResponse.organization.verified,
3514
3512
  trustScore: apiResponse.organization.trustScore
3515
3513
  } : void 0;
3516
- const pdlss = apiResponse.access?.pdlss ? {
3517
- purposeAllowed: apiResponse.access.pdlss.purposeAllowed,
3518
- withinDuration: apiResponse.access.pdlss.withinDuration,
3519
- withinLimits: apiResponse.access.pdlss.withinLimits,
3520
- scopeAllowed: apiResponse.access.pdlss.scopeAllowed,
3521
- selfInstantiationAllowed: apiResponse.access.pdlss.selfInstantiationAllowed,
3522
- appliedPolicy: apiResponse.access.appliedPolicy
3523
- } : void 0;
3524
- const trustScore = agent?.trustScore || 0;
3525
- const isOrgMember = false;
3526
- const accessLevel = determineAccessLevel(true, trustScore, isOrgMember, {
3527
- "read-only": 20,
3528
- standard: mergedConfig.minTrustScore || 40,
3529
- full: mergedConfig.minTrustScoreForFull || 70
3530
- });
3514
+ const verificationContext = apiResponse.verificationContext;
3515
+ const accessLevel = apiResponse.access?.accessLevel ?? "standard";
3531
3516
  const result = {
3532
3517
  verified: true,
3533
3518
  accessLevel,
3534
3519
  agent,
3535
3520
  developer,
3536
3521
  organization,
3537
- pdlss,
3522
+ appliedPolicy: apiResponse.access?.appliedPolicy,
3523
+ verificationContext,
3538
3524
  requiresStepUp: apiResponse.access?.requiresStepUp,
3539
3525
  requiresApproval: apiResponse.access?.requiresApproval,
3540
3526
  verifiedAt: /* @__PURE__ */ new Date(),