@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,5 +1,5 @@
1
1
  import { RequestHandler, Request } from 'express';
2
- import { V as VerificationResult, E as ExpressMiddlewareOptions, A as AstraSyncCredentials, a as AccessLevel } from './types-CrVMq_Td.js';
2
+ import { V as VerificationResult, E as ExpressMiddlewareOptions, A as AstraSyncCredentials, a as AccessLevel } from './types-JMgPake9.js';
3
3
 
4
4
  /**
5
5
  * AstraSync Universal Verification Gateway - Express Middleware
@@ -14,7 +14,7 @@ import { V as VerificationResult, E as ExpressMiddlewareOptions, A as AstraSyncC
14
14
  * const app = express();
15
15
  *
16
16
  * app.use(createMiddleware({
17
- * apiBaseUrl: 'https://api.astrasync.ai',
17
+ * apiBaseUrl: 'https://astrasync.ai/api',
18
18
  * routes: [
19
19
  * { pattern: '/api/public/*', method: '*', minAccessLevel: 'none' },
20
20
  * { pattern: '/api/data/*', method: 'GET', minAccessLevel: 'read-only' },
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler, Request } from 'express';
2
- import { V as VerificationResult, E as ExpressMiddlewareOptions, A as AstraSyncCredentials, a as AccessLevel } from './types-CrVMq_Td.mjs';
2
+ import { V as VerificationResult, E as ExpressMiddlewareOptions, A as AstraSyncCredentials, a as AccessLevel } from './types-JMgPake9.mjs';
3
3
 
4
4
  /**
5
5
  * AstraSync Universal Verification Gateway - Express Middleware
@@ -14,7 +14,7 @@ import { V as VerificationResult, E as ExpressMiddlewareOptions, A as AstraSyncC
14
14
  * const app = express();
15
15
  *
16
16
  * app.use(createMiddleware({
17
- * apiBaseUrl: 'https://api.astrasync.ai',
17
+ * apiBaseUrl: 'https://astrasync.ai/api',
18
18
  * routes: [
19
19
  * { pattern: '/api/public/*', method: '*', minAccessLevel: 'none' },
20
20
  * { pattern: '/api/data/*', method: 'GET', minAccessLevel: 'read-only' },
@@ -1,5 +1,5 @@
1
- import { b as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-DE0ooQJ6.mjs';
2
- import '../types-CrVMq_Td.mjs';
1
+ import { b as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-aN1UHhyy.mjs';
2
+ import '../types-JMgPake9.mjs';
3
3
 
4
4
  /**
5
5
  * AstraSyncGateway — Primary API surface for agent verification.
@@ -1,5 +1,5 @@
1
- import { b as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-rigu2bH3.js';
2
- import '../types-CrVMq_Td.js';
1
+ import { b as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-osMd_dpT.js';
2
+ import '../types-JMgPake9.js';
3
3
 
4
4
  /**
5
5
  * AstraSyncGateway — Primary API surface for agent verification.
@@ -3047,51 +3047,45 @@ var ACCESS_LEVEL_HIERARCHY = {
3047
3047
  full: 4,
3048
3048
  internal: 5
3049
3049
  };
3050
- var DEFAULT_TRUST_THRESHOLDS = {
3051
- none: 0,
3052
- guidance: 0,
3053
- "read-only": 20,
3054
- standard: 40,
3055
- full: 70,
3056
- internal: 0
3057
- // Internal is based on org membership, not score
3058
- };
3059
3050
  function getTrustLevel(score) {
3060
3051
  if (score >= 80) return "PLATINUM";
3061
3052
  if (score >= 60) return "GOLD";
3062
3053
  if (score >= 40) return "SILVER";
3063
3054
  return "BRONZE";
3064
3055
  }
3065
- function getAccessLevelForScore(trustScore, thresholds = DEFAULT_TRUST_THRESHOLDS) {
3066
- if (trustScore >= thresholds.full) return "full";
3067
- if (trustScore >= thresholds.standard) return "standard";
3068
- if (trustScore >= thresholds["read-only"]) return "read-only";
3069
- return "guidance";
3070
- }
3071
- function determineAccessLevel(verified, trustScore, isOrgMember, customThresholds) {
3072
- if (!verified) {
3073
- return "guidance";
3074
- }
3075
- if (isOrgMember) {
3076
- return "internal";
3077
- }
3078
- const thresholds = {
3079
- ...DEFAULT_TRUST_THRESHOLDS,
3080
- ...customThresholds
3081
- };
3082
- return getAccessLevelForScore(trustScore, thresholds);
3083
- }
3084
3056
 
3085
3057
  // src/verify.ts
3086
3058
  var DEFAULT_CONFIG = {
3087
- apiBaseUrl: "https://api.astrasync.ai",
3059
+ apiBaseUrl: "https://astrasync.ai/api",
3088
3060
  defaultAccessLevel: "guidance",
3089
- minTrustScore: 40,
3090
- minTrustScoreForFull: 70,
3061
+ // minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
3091
3062
  cacheTtl: 300,
3092
3063
  // 5 minutes
3093
3064
  debug: false
3094
3065
  };
3066
+ var initCheckPerformed = false;
3067
+ var deprecationWarningShown = false;
3068
+ async function performInitCheck(apiBaseUrl, debug) {
3069
+ initCheckPerformed = true;
3070
+ try {
3071
+ const probeUrl = `${apiBaseUrl}/agents/verify-access`;
3072
+ const response = await fetch(probeUrl, { method: "HEAD" });
3073
+ const contentType = response.headers.get("content-type") ?? "";
3074
+ if (contentType.startsWith("text/html")) {
3075
+ console.warn(
3076
+ `[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.`
3077
+ );
3078
+ } else if (debug) {
3079
+ console.log(
3080
+ `[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
3081
+ );
3082
+ }
3083
+ } catch (err) {
3084
+ if (debug) {
3085
+ console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
3086
+ }
3087
+ }
3088
+ }
3095
3089
  var verificationCache = /* @__PURE__ */ new Map();
3096
3090
  function getCacheKey(credentials) {
3097
3091
  return `${credentials.astraId || ""}-${credentials.apiKey || ""}-${credentials.jwt || ""}`;
@@ -3114,9 +3108,6 @@ function cacheResult(credentials, result, ttlSeconds) {
3114
3108
  expiresAt: Date.now() + ttlSeconds * 1e3
3115
3109
  });
3116
3110
  }
3117
- function hasCredentials(credentials) {
3118
- return !!(credentials.astraId || credentials.apiKey || credentials.jwt);
3119
- }
3120
3111
  function createGuidanceResponse(config, reason) {
3121
3112
  const guidance = {
3122
3113
  message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
@@ -3140,7 +3131,7 @@ function createGuidanceResponse(config, reason) {
3140
3131
  async function callVerifyAccessAPI(config, request) {
3141
3132
  const { credentials, ...requestData } = request;
3142
3133
  const body = {
3143
- agentId: credentials.astraId,
3134
+ ...credentials.astraId && { agentId: credentials.astraId },
3144
3135
  purpose: requestData.purpose || "general"
3145
3136
  };
3146
3137
  if (requestData.action) body.action = requestData.action;
@@ -3158,6 +3149,7 @@ async function callVerifyAccessAPI(config, request) {
3158
3149
  if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
3159
3150
  if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
3160
3151
  if (requestData.counterpartyUrl) body.counterpartyUrl = requestData.counterpartyUrl;
3152
+ if (config.counterpartyId) body.counterpartyId = config.counterpartyId;
3161
3153
  if (requestData.runtimeChallengeOptions)
3162
3154
  body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
3163
3155
  if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
@@ -3204,8 +3196,14 @@ async function callVerifyAccessAPI(config, request) {
3204
3196
  }
3205
3197
  async function verify(config, request) {
3206
3198
  const mergedConfig = { ...DEFAULT_CONFIG, ...config };
3207
- if (!hasCredentials(request.credentials)) {
3208
- return createGuidanceResponse(mergedConfig, "No agent credentials provided");
3199
+ if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
3200
+ void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug);
3201
+ }
3202
+ if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
3203
+ deprecationWarningShown = true;
3204
+ console.warn(
3205
+ "[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."
3206
+ );
3209
3207
  }
3210
3208
  if (mergedConfig.cacheTtl && mergedConfig.cacheTtl > 0) {
3211
3209
  const cached = getCachedResult(request.credentials);
@@ -3269,28 +3267,16 @@ async function verify(config, request) {
3269
3267
  verified: apiResponse.organization.verified,
3270
3268
  trustScore: apiResponse.organization.trustScore
3271
3269
  } : void 0;
3272
- const pdlss = apiResponse.access?.pdlss ? {
3273
- purposeAllowed: apiResponse.access.pdlss.purposeAllowed,
3274
- withinDuration: apiResponse.access.pdlss.withinDuration,
3275
- withinLimits: apiResponse.access.pdlss.withinLimits,
3276
- scopeAllowed: apiResponse.access.pdlss.scopeAllowed,
3277
- selfInstantiationAllowed: apiResponse.access.pdlss.selfInstantiationAllowed,
3278
- appliedPolicy: apiResponse.access.appliedPolicy
3279
- } : void 0;
3280
- const trustScore = agent?.trustScore || 0;
3281
- const isOrgMember = false;
3282
- const accessLevel = determineAccessLevel(true, trustScore, isOrgMember, {
3283
- "read-only": 20,
3284
- standard: mergedConfig.minTrustScore || 40,
3285
- full: mergedConfig.minTrustScoreForFull || 70
3286
- });
3270
+ const verificationContext = apiResponse.verificationContext;
3271
+ const accessLevel = apiResponse.access?.accessLevel ?? "standard";
3287
3272
  const result = {
3288
3273
  verified: true,
3289
3274
  accessLevel,
3290
3275
  agent,
3291
3276
  developer,
3292
3277
  organization,
3293
- pdlss,
3278
+ appliedPolicy: apiResponse.access?.appliedPolicy,
3279
+ verificationContext,
3294
3280
  requiresStepUp: apiResponse.access?.requiresStepUp,
3295
3281
  requiresApproval: apiResponse.access?.requiresApproval,
3296
3282
  verifiedAt: /* @__PURE__ */ new Date(),