@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
|
@@ -3287,51 +3287,45 @@ var ACCESS_LEVEL_HIERARCHY = {
|
|
|
3287
3287
|
full: 4,
|
|
3288
3288
|
internal: 5
|
|
3289
3289
|
};
|
|
3290
|
-
var DEFAULT_TRUST_THRESHOLDS = {
|
|
3291
|
-
none: 0,
|
|
3292
|
-
guidance: 0,
|
|
3293
|
-
"read-only": 20,
|
|
3294
|
-
standard: 40,
|
|
3295
|
-
full: 70,
|
|
3296
|
-
internal: 0
|
|
3297
|
-
// Internal is based on org membership, not score
|
|
3298
|
-
};
|
|
3299
3290
|
function getTrustLevel(score) {
|
|
3300
3291
|
if (score >= 80) return "PLATINUM";
|
|
3301
3292
|
if (score >= 60) return "GOLD";
|
|
3302
3293
|
if (score >= 40) return "SILVER";
|
|
3303
3294
|
return "BRONZE";
|
|
3304
3295
|
}
|
|
3305
|
-
function getAccessLevelForScore(trustScore, thresholds = DEFAULT_TRUST_THRESHOLDS) {
|
|
3306
|
-
if (trustScore >= thresholds.full) return "full";
|
|
3307
|
-
if (trustScore >= thresholds.standard) return "standard";
|
|
3308
|
-
if (trustScore >= thresholds["read-only"]) return "read-only";
|
|
3309
|
-
return "guidance";
|
|
3310
|
-
}
|
|
3311
|
-
function determineAccessLevel(verified, trustScore, isOrgMember, customThresholds) {
|
|
3312
|
-
if (!verified) {
|
|
3313
|
-
return "guidance";
|
|
3314
|
-
}
|
|
3315
|
-
if (isOrgMember) {
|
|
3316
|
-
return "internal";
|
|
3317
|
-
}
|
|
3318
|
-
const thresholds = {
|
|
3319
|
-
...DEFAULT_TRUST_THRESHOLDS,
|
|
3320
|
-
...customThresholds
|
|
3321
|
-
};
|
|
3322
|
-
return getAccessLevelForScore(trustScore, thresholds);
|
|
3323
|
-
}
|
|
3324
3296
|
|
|
3325
3297
|
// src/verify.ts
|
|
3326
3298
|
var DEFAULT_CONFIG = {
|
|
3327
|
-
apiBaseUrl: "https://
|
|
3299
|
+
apiBaseUrl: "https://astrasync.ai/api",
|
|
3328
3300
|
defaultAccessLevel: "guidance",
|
|
3329
|
-
minTrustScore
|
|
3330
|
-
minTrustScoreForFull: 70,
|
|
3301
|
+
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
3331
3302
|
cacheTtl: 300,
|
|
3332
3303
|
// 5 minutes
|
|
3333
3304
|
debug: false
|
|
3334
3305
|
};
|
|
3306
|
+
var initCheckPerformed = false;
|
|
3307
|
+
var deprecationWarningShown = false;
|
|
3308
|
+
async function performInitCheck(apiBaseUrl, debug) {
|
|
3309
|
+
initCheckPerformed = true;
|
|
3310
|
+
try {
|
|
3311
|
+
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
3312
|
+
const response = await fetch(probeUrl, { method: "HEAD" });
|
|
3313
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
3314
|
+
if (contentType.startsWith("text/html")) {
|
|
3315
|
+
console.warn(
|
|
3316
|
+
`[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.`
|
|
3317
|
+
);
|
|
3318
|
+
} else if (debug) {
|
|
3319
|
+
console.log(
|
|
3320
|
+
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
3321
|
+
);
|
|
3322
|
+
}
|
|
3323
|
+
} catch (err) {
|
|
3324
|
+
if (debug) {
|
|
3325
|
+
console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3335
3329
|
var verificationCache = /* @__PURE__ */ new Map();
|
|
3336
3330
|
function getCacheKey(credentials) {
|
|
3337
3331
|
return `${credentials.astraId || ""}-${credentials.apiKey || ""}-${credentials.jwt || ""}`;
|
|
@@ -3354,9 +3348,6 @@ function cacheResult(credentials, result, ttlSeconds) {
|
|
|
3354
3348
|
expiresAt: Date.now() + ttlSeconds * 1e3
|
|
3355
3349
|
});
|
|
3356
3350
|
}
|
|
3357
|
-
function hasCredentials(credentials) {
|
|
3358
|
-
return !!(credentials.astraId || credentials.apiKey || credentials.jwt);
|
|
3359
|
-
}
|
|
3360
3351
|
function createGuidanceResponse(config, reason) {
|
|
3361
3352
|
const guidance = {
|
|
3362
3353
|
message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
|
|
@@ -3380,7 +3371,7 @@ function createGuidanceResponse(config, reason) {
|
|
|
3380
3371
|
async function callVerifyAccessAPI(config, request) {
|
|
3381
3372
|
const { credentials, ...requestData } = request;
|
|
3382
3373
|
const body = {
|
|
3383
|
-
agentId: credentials.astraId,
|
|
3374
|
+
...credentials.astraId && { agentId: credentials.astraId },
|
|
3384
3375
|
purpose: requestData.purpose || "general"
|
|
3385
3376
|
};
|
|
3386
3377
|
if (requestData.action) body.action = requestData.action;
|
|
@@ -3392,21 +3383,34 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3392
3383
|
if (requestData.isSubAgentRequest) body.isSubAgentRequest = requestData.isSubAgentRequest;
|
|
3393
3384
|
if (requestData.parentAgentId) body.parentAgentId = requestData.parentAgentId;
|
|
3394
3385
|
if (requestData.subAgentDepth !== void 0) body.subAgentDepth = requestData.subAgentDepth;
|
|
3395
|
-
if (requestData.enableRuntimeChallenge)
|
|
3386
|
+
if (requestData.enableRuntimeChallenge)
|
|
3387
|
+
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
3396
3388
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
3397
3389
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
3398
3390
|
if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
|
|
3399
3391
|
if (requestData.counterpartyUrl) body.counterpartyUrl = requestData.counterpartyUrl;
|
|
3400
|
-
if (
|
|
3392
|
+
if (config.counterpartyId) body.counterpartyId = config.counterpartyId;
|
|
3393
|
+
if (requestData.runtimeChallengeOptions)
|
|
3394
|
+
body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
|
|
3395
|
+
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
3396
|
+
const meta = {
|
|
3397
|
+
...requestData.clientIp && { sourceIp: requestData.clientIp },
|
|
3398
|
+
...requestData.userAgent && { userAgent: requestData.userAgent },
|
|
3399
|
+
...requestData.callerMetadata
|
|
3400
|
+
};
|
|
3401
|
+
if (Object.keys(meta).length > 0) body.callerMetadata = meta;
|
|
3402
|
+
}
|
|
3401
3403
|
const headers = {
|
|
3402
3404
|
"Content-Type": "application/json",
|
|
3403
3405
|
...config.customHeaders
|
|
3404
3406
|
};
|
|
3405
|
-
if (config.apiKey) {
|
|
3406
|
-
headers["X-API-Key"] = config.apiKey;
|
|
3407
|
-
}
|
|
3408
3407
|
if (credentials.authorizationHeader) {
|
|
3409
3408
|
headers["Authorization"] = credentials.authorizationHeader;
|
|
3409
|
+
} else if (config.apiKey) {
|
|
3410
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
3411
|
+
}
|
|
3412
|
+
if (config.apiKey) {
|
|
3413
|
+
headers["X-API-Key"] = config.apiKey;
|
|
3410
3414
|
}
|
|
3411
3415
|
try {
|
|
3412
3416
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
@@ -3432,8 +3436,14 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3432
3436
|
}
|
|
3433
3437
|
async function verify(config, request) {
|
|
3434
3438
|
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
3435
|
-
if (!
|
|
3436
|
-
|
|
3439
|
+
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
3440
|
+
void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug);
|
|
3441
|
+
}
|
|
3442
|
+
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
3443
|
+
deprecationWarningShown = true;
|
|
3444
|
+
console.warn(
|
|
3445
|
+
"[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."
|
|
3446
|
+
);
|
|
3437
3447
|
}
|
|
3438
3448
|
if (mergedConfig.cacheTtl && mergedConfig.cacheTtl > 0) {
|
|
3439
3449
|
const cached = getCachedResult(request.credentials);
|
|
@@ -3505,18 +3515,7 @@ async function verify(config, request) {
|
|
|
3505
3515
|
selfInstantiationAllowed: apiResponse.access.pdlss.selfInstantiationAllowed,
|
|
3506
3516
|
appliedPolicy: apiResponse.access.appliedPolicy
|
|
3507
3517
|
} : void 0;
|
|
3508
|
-
const
|
|
3509
|
-
const isOrgMember = false;
|
|
3510
|
-
const accessLevel = determineAccessLevel(
|
|
3511
|
-
true,
|
|
3512
|
-
trustScore,
|
|
3513
|
-
isOrgMember,
|
|
3514
|
-
{
|
|
3515
|
-
"read-only": 20,
|
|
3516
|
-
standard: mergedConfig.minTrustScore || 40,
|
|
3517
|
-
full: mergedConfig.minTrustScoreForFull || 70
|
|
3518
|
-
}
|
|
3519
|
-
);
|
|
3518
|
+
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
3520
3519
|
const result = {
|
|
3521
3520
|
verified: true,
|
|
3522
3521
|
accessLevel,
|
|
@@ -3538,7 +3537,9 @@ async function verify(config, request) {
|
|
|
3538
3537
|
if (result.recommendation === "deny") {
|
|
3539
3538
|
result.verified = false;
|
|
3540
3539
|
result.accessLevel = "none";
|
|
3541
|
-
result.denialReasons = result.recommendationReasons || [
|
|
3540
|
+
result.denialReasons = result.recommendationReasons || [
|
|
3541
|
+
"Access denied by AstraSync recommendation"
|
|
3542
|
+
];
|
|
3542
3543
|
if (result.runtimeChallenge) {
|
|
3543
3544
|
result.guidance = {
|
|
3544
3545
|
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|