@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
|
@@ -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-
|
|
2
|
+
import { V as VerificationResult, E as ExpressMiddlewareOptions, A as AstraSyncCredentials, a as AccessLevel } from './types-DOrqNMgy.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://
|
|
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-
|
|
2
|
+
import { V as VerificationResult, E as ExpressMiddlewareOptions, A as AstraSyncCredentials, a as AccessLevel } from './types-DOrqNMgy.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://
|
|
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-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { b as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-CgXPKUwi.mjs';
|
|
2
|
+
import '../types-DOrqNMgy.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-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { b as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-BYKAY6Cc.js';
|
|
2
|
+
import '../types-DOrqNMgy.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* AstraSyncGateway — Primary API surface for agent verification.
|
package/dist/gateway/gateway.js
CHANGED
|
@@ -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://
|
|
3059
|
+
apiBaseUrl: "https://astrasync.ai/api",
|
|
3088
3060
|
defaultAccessLevel: "guidance",
|
|
3089
|
-
minTrustScore
|
|
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;
|
|
@@ -3152,21 +3143,34 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3152
3143
|
if (requestData.isSubAgentRequest) body.isSubAgentRequest = requestData.isSubAgentRequest;
|
|
3153
3144
|
if (requestData.parentAgentId) body.parentAgentId = requestData.parentAgentId;
|
|
3154
3145
|
if (requestData.subAgentDepth !== void 0) body.subAgentDepth = requestData.subAgentDepth;
|
|
3155
|
-
if (requestData.enableRuntimeChallenge)
|
|
3146
|
+
if (requestData.enableRuntimeChallenge)
|
|
3147
|
+
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
3156
3148
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
3157
3149
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
3158
3150
|
if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
|
|
3159
3151
|
if (requestData.counterpartyUrl) body.counterpartyUrl = requestData.counterpartyUrl;
|
|
3160
|
-
if (
|
|
3152
|
+
if (config.counterpartyId) body.counterpartyId = config.counterpartyId;
|
|
3153
|
+
if (requestData.runtimeChallengeOptions)
|
|
3154
|
+
body.runtimeChallengeOptions = requestData.runtimeChallengeOptions;
|
|
3155
|
+
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
3156
|
+
const meta = {
|
|
3157
|
+
...requestData.clientIp && { sourceIp: requestData.clientIp },
|
|
3158
|
+
...requestData.userAgent && { userAgent: requestData.userAgent },
|
|
3159
|
+
...requestData.callerMetadata
|
|
3160
|
+
};
|
|
3161
|
+
if (Object.keys(meta).length > 0) body.callerMetadata = meta;
|
|
3162
|
+
}
|
|
3161
3163
|
const headers = {
|
|
3162
3164
|
"Content-Type": "application/json",
|
|
3163
3165
|
...config.customHeaders
|
|
3164
3166
|
};
|
|
3165
|
-
if (config.apiKey) {
|
|
3166
|
-
headers["X-API-Key"] = config.apiKey;
|
|
3167
|
-
}
|
|
3168
3167
|
if (credentials.authorizationHeader) {
|
|
3169
3168
|
headers["Authorization"] = credentials.authorizationHeader;
|
|
3169
|
+
} else if (config.apiKey) {
|
|
3170
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
3171
|
+
}
|
|
3172
|
+
if (config.apiKey) {
|
|
3173
|
+
headers["X-API-Key"] = config.apiKey;
|
|
3170
3174
|
}
|
|
3171
3175
|
try {
|
|
3172
3176
|
const response = await fetch(`${config.apiBaseUrl}/agents/verify-access`, {
|
|
@@ -3192,8 +3196,14 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3192
3196
|
}
|
|
3193
3197
|
async function verify(config, request) {
|
|
3194
3198
|
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
3195
|
-
if (!
|
|
3196
|
-
|
|
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
|
+
);
|
|
3197
3207
|
}
|
|
3198
3208
|
if (mergedConfig.cacheTtl && mergedConfig.cacheTtl > 0) {
|
|
3199
3209
|
const cached = getCachedResult(request.credentials);
|
|
@@ -3265,18 +3275,7 @@ async function verify(config, request) {
|
|
|
3265
3275
|
selfInstantiationAllowed: apiResponse.access.pdlss.selfInstantiationAllowed,
|
|
3266
3276
|
appliedPolicy: apiResponse.access.appliedPolicy
|
|
3267
3277
|
} : void 0;
|
|
3268
|
-
const
|
|
3269
|
-
const isOrgMember = false;
|
|
3270
|
-
const accessLevel = determineAccessLevel(
|
|
3271
|
-
true,
|
|
3272
|
-
trustScore,
|
|
3273
|
-
isOrgMember,
|
|
3274
|
-
{
|
|
3275
|
-
"read-only": 20,
|
|
3276
|
-
standard: mergedConfig.minTrustScore || 40,
|
|
3277
|
-
full: mergedConfig.minTrustScoreForFull || 70
|
|
3278
|
-
}
|
|
3279
|
-
);
|
|
3278
|
+
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
3280
3279
|
const result = {
|
|
3281
3280
|
verified: true,
|
|
3282
3281
|
accessLevel,
|
|
@@ -3298,7 +3297,9 @@ async function verify(config, request) {
|
|
|
3298
3297
|
if (result.recommendation === "deny") {
|
|
3299
3298
|
result.verified = false;
|
|
3300
3299
|
result.accessLevel = "none";
|
|
3301
|
-
result.denialReasons = result.recommendationReasons || [
|
|
3300
|
+
result.denialReasons = result.recommendationReasons || [
|
|
3301
|
+
"Access denied by AstraSync recommendation"
|
|
3302
|
+
];
|
|
3302
3303
|
if (result.runtimeChallenge) {
|
|
3303
3304
|
result.guidance = {
|
|
3304
3305
|
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|