@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.
- package/README.md +64 -30
- package/dist/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +2 -2
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.js +74 -95
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +74 -95
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +2 -2
- package/dist/adapters/nextjs.d.ts +2 -2
- package/dist/adapters/nextjs.js +74 -115
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +74 -115
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +2 -2
- package/dist/adapters/sdk.d.ts +2 -2
- package/dist/adapters/sdk.js +56 -55
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +56 -55
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +68 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +66 -2
- package/dist/agent/index.mjs.map +1 -1
- package/dist/browser/background.js +56 -55
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +56 -55
- package/dist/browser/background.mjs.map +1 -1
- package/dist/browser/browser-adapter.d.mts +2 -2
- package/dist/browser/browser-adapter.d.ts +2 -2
- package/dist/cli/index.d.mts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cursor/cursor-adapter.d.mts +2 -2
- package/dist/cursor/cursor-adapter.d.ts +2 -2
- package/dist/cursor/extension.d.mts +2 -2
- package/dist/cursor/extension.d.ts +2 -2
- package/dist/cursor/extension.js +56 -55
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +56 -55
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-Bcl-uBUE.d.ts → express-BtKlLI8U.d.ts} +2 -2
- package/dist/{express-CtwDIZyF.d.mts → express-DgwpS8Ha.d.mts} +2 -2
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +56 -55
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +56 -55
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/git-trigger/git-hooks.d.mts +2 -2
- package/dist/git-trigger/git-hooks.d.ts +2 -2
- package/dist/{index-BY8yQ8N8.d.mts → index-AzhK20t0.d.mts} +46 -3
- package/dist/{index-CME6r4uH.d.ts → index-Ba0Lvsjo.d.ts} +1 -1
- package/dist/{index-3NRaBNvp.d.mts → index-BaxpmTGA.d.mts} +1 -1
- package/dist/{index-CtYSYwn3.d.ts → index-DpJS1JEI.d.ts} +46 -3
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +158 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +158 -117
- package/dist/index.mjs.map +1 -1
- package/dist/local-evaluator/evaluator.d.mts +2 -2
- package/dist/local-evaluator/evaluator.d.ts +2 -2
- package/dist/{nextjs-CEldnIJ9.d.ts → nextjs-B2kg19c1.d.ts} +1 -1
- package/dist/{nextjs-BQyMCSx_.d.mts → nextjs-ZymQ8jDh.d.mts} +1 -1
- package/dist/{sdk-BhvuJSrH.d.mts → sdk-B7id0VFS.d.mts} +2 -2
- package/dist/{sdk-BlyVSC_S.d.ts → sdk-Bso0FSI0.d.ts} +2 -2
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-79qS7aON.d.ts → types-BYKAY6Cc.d.ts} +1 -1
- package/dist/{types-jJnPXStc.d.mts → types-CgXPKUwi.d.mts} +1 -1
- package/dist/{types-CxQwJKbd.d.mts → types-DOrqNMgy.d.mts} +79 -13
- package/dist/{types-CxQwJKbd.d.ts → types-DOrqNMgy.d.ts} +79 -13
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/webhooks.d.mts +59 -0
- package/dist/webhooks.d.ts +59 -0
- package/dist/webhooks.js +81 -0
- package/dist/webhooks.js.map +1 -0
- package/dist/webhooks.mjs +55 -0
- package/dist/webhooks.mjs.map +1 -0
- package/package.json +8 -3
|
@@ -3264,51 +3264,45 @@ var ACCESS_LEVEL_HIERARCHY = {
|
|
|
3264
3264
|
full: 4,
|
|
3265
3265
|
internal: 5
|
|
3266
3266
|
};
|
|
3267
|
-
var DEFAULT_TRUST_THRESHOLDS = {
|
|
3268
|
-
none: 0,
|
|
3269
|
-
guidance: 0,
|
|
3270
|
-
"read-only": 20,
|
|
3271
|
-
standard: 40,
|
|
3272
|
-
full: 70,
|
|
3273
|
-
internal: 0
|
|
3274
|
-
// Internal is based on org membership, not score
|
|
3275
|
-
};
|
|
3276
3267
|
function getTrustLevel(score) {
|
|
3277
3268
|
if (score >= 80) return "PLATINUM";
|
|
3278
3269
|
if (score >= 60) return "GOLD";
|
|
3279
3270
|
if (score >= 40) return "SILVER";
|
|
3280
3271
|
return "BRONZE";
|
|
3281
3272
|
}
|
|
3282
|
-
function getAccessLevelForScore(trustScore, thresholds = DEFAULT_TRUST_THRESHOLDS) {
|
|
3283
|
-
if (trustScore >= thresholds.full) return "full";
|
|
3284
|
-
if (trustScore >= thresholds.standard) return "standard";
|
|
3285
|
-
if (trustScore >= thresholds["read-only"]) return "read-only";
|
|
3286
|
-
return "guidance";
|
|
3287
|
-
}
|
|
3288
|
-
function determineAccessLevel(verified, trustScore, isOrgMember, customThresholds) {
|
|
3289
|
-
if (!verified) {
|
|
3290
|
-
return "guidance";
|
|
3291
|
-
}
|
|
3292
|
-
if (isOrgMember) {
|
|
3293
|
-
return "internal";
|
|
3294
|
-
}
|
|
3295
|
-
const thresholds = {
|
|
3296
|
-
...DEFAULT_TRUST_THRESHOLDS,
|
|
3297
|
-
...customThresholds
|
|
3298
|
-
};
|
|
3299
|
-
return getAccessLevelForScore(trustScore, thresholds);
|
|
3300
|
-
}
|
|
3301
3273
|
|
|
3302
3274
|
// src/verify.ts
|
|
3303
3275
|
var DEFAULT_CONFIG = {
|
|
3304
|
-
apiBaseUrl: "https://
|
|
3276
|
+
apiBaseUrl: "https://astrasync.ai/api",
|
|
3305
3277
|
defaultAccessLevel: "guidance",
|
|
3306
|
-
minTrustScore
|
|
3307
|
-
minTrustScoreForFull: 70,
|
|
3278
|
+
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
3308
3279
|
cacheTtl: 300,
|
|
3309
3280
|
// 5 minutes
|
|
3310
3281
|
debug: false
|
|
3311
3282
|
};
|
|
3283
|
+
var initCheckPerformed = false;
|
|
3284
|
+
var deprecationWarningShown = false;
|
|
3285
|
+
async function performInitCheck(apiBaseUrl, debug) {
|
|
3286
|
+
initCheckPerformed = true;
|
|
3287
|
+
try {
|
|
3288
|
+
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
3289
|
+
const response = await fetch(probeUrl, { method: "HEAD" });
|
|
3290
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
3291
|
+
if (contentType.startsWith("text/html")) {
|
|
3292
|
+
console.warn(
|
|
3293
|
+
`[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.`
|
|
3294
|
+
);
|
|
3295
|
+
} else if (debug) {
|
|
3296
|
+
console.log(
|
|
3297
|
+
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
3298
|
+
);
|
|
3299
|
+
}
|
|
3300
|
+
} catch (err) {
|
|
3301
|
+
if (debug) {
|
|
3302
|
+
console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3312
3306
|
var verificationCache = /* @__PURE__ */ new Map();
|
|
3313
3307
|
function getCacheKey(credentials) {
|
|
3314
3308
|
return `${credentials.astraId || ""}-${credentials.apiKey || ""}-${credentials.jwt || ""}`;
|
|
@@ -3331,9 +3325,6 @@ function cacheResult(credentials, result, ttlSeconds) {
|
|
|
3331
3325
|
expiresAt: Date.now() + ttlSeconds * 1e3
|
|
3332
3326
|
});
|
|
3333
3327
|
}
|
|
3334
|
-
function hasCredentials(credentials) {
|
|
3335
|
-
return !!(credentials.astraId || credentials.apiKey || credentials.jwt);
|
|
3336
|
-
}
|
|
3337
3328
|
function createGuidanceResponse(config, reason) {
|
|
3338
3329
|
const guidance = {
|
|
3339
3330
|
message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
|
|
@@ -3357,7 +3348,7 @@ function createGuidanceResponse(config, reason) {
|
|
|
3357
3348
|
async function callVerifyAccessAPI(config, request) {
|
|
3358
3349
|
const { credentials, ...requestData } = request;
|
|
3359
3350
|
const body = {
|
|
3360
|
-
agentId: credentials.astraId,
|
|
3351
|
+
...credentials.astraId && { agentId: credentials.astraId },
|
|
3361
3352
|
purpose: requestData.purpose || "general"
|
|
3362
3353
|
};
|
|
3363
3354
|
if (requestData.action) body.action = requestData.action;
|
|
@@ -3369,21 +3360,34 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3369
3360
|
if (requestData.isSubAgentRequest) body.isSubAgentRequest = requestData.isSubAgentRequest;
|
|
3370
3361
|
if (requestData.parentAgentId) body.parentAgentId = requestData.parentAgentId;
|
|
3371
3362
|
if (requestData.subAgentDepth !== void 0) body.subAgentDepth = requestData.subAgentDepth;
|
|
3372
|
-
if (requestData.enableRuntimeChallenge)
|
|
3363
|
+
if (requestData.enableRuntimeChallenge)
|
|
3364
|
+
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
3373
3365
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
3374
3366
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
3375
3367
|
if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
|
|
3376
3368
|
if (requestData.counterpartyUrl) body.counterpartyUrl = requestData.counterpartyUrl;
|
|
3377
|
-
if (
|
|
3369
|
+
if (config.counterpartyId) body.counterpartyId = config.counterpartyId;
|
|
3370
|
+
if (requestData.runtimeChallengeOptions)
|
|
3371
|
+
body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
|
|
3372
|
+
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
3373
|
+
const meta = {
|
|
3374
|
+
...requestData.clientIp && { sourceIp: requestData.clientIp },
|
|
3375
|
+
...requestData.userAgent && { userAgent: requestData.userAgent },
|
|
3376
|
+
...requestData.callerMetadata
|
|
3377
|
+
};
|
|
3378
|
+
if (Object.keys(meta).length > 0) body.callerMetadata = meta;
|
|
3379
|
+
}
|
|
3378
3380
|
const headers = {
|
|
3379
3381
|
"Content-Type": "application/json",
|
|
3380
3382
|
...config.customHeaders
|
|
3381
3383
|
};
|
|
3382
|
-
if (config.apiKey) {
|
|
3383
|
-
headers["X-API-Key"] = config.apiKey;
|
|
3384
|
-
}
|
|
3385
3384
|
if (credentials.authorizationHeader) {
|
|
3386
3385
|
headers["Authorization"] = credentials.authorizationHeader;
|
|
3386
|
+
} else if (config.apiKey) {
|
|
3387
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
3388
|
+
}
|
|
3389
|
+
if (config.apiKey) {
|
|
3390
|
+
headers["X-API-Key"] = config.apiKey;
|
|
3387
3391
|
}
|
|
3388
3392
|
try {
|
|
3389
3393
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
@@ -3409,8 +3413,14 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3409
3413
|
}
|
|
3410
3414
|
async function verify(config, request) {
|
|
3411
3415
|
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
3412
|
-
if (!
|
|
3413
|
-
|
|
3416
|
+
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
3417
|
+
void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug);
|
|
3418
|
+
}
|
|
3419
|
+
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
3420
|
+
deprecationWarningShown = true;
|
|
3421
|
+
console.warn(
|
|
3422
|
+
"[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."
|
|
3423
|
+
);
|
|
3414
3424
|
}
|
|
3415
3425
|
if (mergedConfig.cacheTtl && mergedConfig.cacheTtl > 0) {
|
|
3416
3426
|
const cached = getCachedResult(request.credentials);
|
|
@@ -3482,18 +3492,7 @@ async function verify(config, request) {
|
|
|
3482
3492
|
selfInstantiationAllowed: apiResponse.access.pdlss.selfInstantiationAllowed,
|
|
3483
3493
|
appliedPolicy: apiResponse.access.appliedPolicy
|
|
3484
3494
|
} : void 0;
|
|
3485
|
-
const
|
|
3486
|
-
const isOrgMember = false;
|
|
3487
|
-
const accessLevel = determineAccessLevel(
|
|
3488
|
-
true,
|
|
3489
|
-
trustScore,
|
|
3490
|
-
isOrgMember,
|
|
3491
|
-
{
|
|
3492
|
-
"read-only": 20,
|
|
3493
|
-
standard: mergedConfig.minTrustScore || 40,
|
|
3494
|
-
full: mergedConfig.minTrustScoreForFull || 70
|
|
3495
|
-
}
|
|
3496
|
-
);
|
|
3495
|
+
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
3497
3496
|
const result = {
|
|
3498
3497
|
verified: true,
|
|
3499
3498
|
accessLevel,
|
|
@@ -3515,7 +3514,9 @@ async function verify(config, request) {
|
|
|
3515
3514
|
if (result.recommendation === "deny") {
|
|
3516
3515
|
result.verified = false;
|
|
3517
3516
|
result.accessLevel = "none";
|
|
3518
|
-
result.denialReasons = result.recommendationReasons || [
|
|
3517
|
+
result.denialReasons = result.recommendationReasons || [
|
|
3518
|
+
"Access denied by AstraSync recommendation"
|
|
3519
|
+
];
|
|
3519
3520
|
if (result.runtimeChallenge) {
|
|
3520
3521
|
result.guidance = {
|
|
3521
3522
|
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|