@astrasyncai/verification-gateway 2.4.12 → 2.4.14
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/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 +125 -35
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +125 -35
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +26 -4
- package/dist/adapters/mcp.d.ts +26 -4
- package/dist/adapters/mcp.js +94 -28
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +94 -28
- package/dist/adapters/mcp.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 +71 -28
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +71 -28
- 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 +45 -22
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +45 -22
- 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 +29 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +29 -0
- package/dist/agent/index.mjs.map +1 -1
- package/dist/browser/background.js +86 -24
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +86 -24
- 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 +86 -24
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +86 -24
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-C1ePFB7n.d.ts → express-CrfwoNAR.d.ts} +1 -1
- package/dist/{express-4WStX3PV.d.mts → express-ienhAXps.d.mts} +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +86 -24
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +86 -24
- 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-ChPX4WHl.d.mts → index-B5e2IDWU.d.mts} +1 -1
- package/dist/{index-CzJMCgEy.d.ts → index-CCdZxvAr.d.ts} +71 -6
- package/dist/{index-D8IEntil.d.mts → index-CEg_WG6y.d.mts} +71 -6
- package/dist/{index-Cjm-zBeZ.d.ts → index-DC5f8eoQ.d.ts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +336 -71
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +336 -71
- 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/local-evaluator/evaluator.js +12 -2
- package/dist/local-evaluator/evaluator.js.map +1 -1
- package/dist/local-evaluator/evaluator.mjs +12 -2
- package/dist/local-evaluator/evaluator.mjs.map +1 -1
- package/dist/{nextjs-BIORS__0.d.ts → nextjs-66R1KW8e.d.ts} +1 -1
- package/dist/{nextjs-CjzHdaXA.d.mts → nextjs-DSpisQst.d.mts} +1 -1
- package/dist/{sdk-Chhz-FcT.d.mts → sdk-5U_CBRpr.d.mts} +1 -1
- package/dist/{sdk-CqTEQAc6.d.ts → sdk-Bm8np66n.d.ts} +1 -1
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/transport/index.js +146 -28
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +146 -28
- package/dist/transport/index.mjs.map +1 -1
- package/dist/{types-L15pYd2c.d.mts → types-B3USs-Kx.d.mts} +42 -1
- package/dist/{types-L15pYd2c.d.ts → types-B3USs-Kx.d.ts} +42 -1
- package/dist/{types-DNK2BgIf.d.mts → types-CgDCUfo8.d.mts} +1 -1
- package/dist/{types-DoWIuzfj.d.ts → types-R5N4ET6x.d.ts} +1 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/gateway/gateway.mjs
CHANGED
|
@@ -80,7 +80,10 @@ var LocalEvaluator = class {
|
|
|
80
80
|
}
|
|
81
81
|
const depth = context.metadata?.subAgentDepth || 0;
|
|
82
82
|
if (this.policy.selfInstantiation.maxDepth !== void 0 && depth >= this.policy.selfInstantiation.maxDepth) {
|
|
83
|
-
return {
|
|
83
|
+
return {
|
|
84
|
+
recommendation: "DENY",
|
|
85
|
+
reason: `Sub-agent depth ${depth} exceeds max depth ${this.policy.selfInstantiation.maxDepth}`
|
|
86
|
+
};
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
if (purposeRule.requiresApproval) {
|
|
@@ -161,7 +164,10 @@ var LocalEvaluator = class {
|
|
|
161
164
|
return { recommendation: "DENY", reason: `Risk score ${riskScore} exceeds block threshold` };
|
|
162
165
|
}
|
|
163
166
|
if (riskScore >= thresholds.requireApproval.min) {
|
|
164
|
-
return {
|
|
167
|
+
return {
|
|
168
|
+
recommendation: "MANUAL_REVIEW",
|
|
169
|
+
reason: `Risk score ${riskScore} requires approval`
|
|
170
|
+
};
|
|
165
171
|
}
|
|
166
172
|
return null;
|
|
167
173
|
}
|
|
@@ -226,6 +232,10 @@ var LocalEvaluator = class {
|
|
|
226
232
|
*/
|
|
227
233
|
matchGlob(value, pattern) {
|
|
228
234
|
if (pattern === value) return true;
|
|
235
|
+
const starCount = (pattern.match(/\*/g) ?? []).length;
|
|
236
|
+
if (starCount > 8) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
229
239
|
const regexStr = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
230
240
|
try {
|
|
231
241
|
return new RegExp(`^${regexStr}$`, "i").test(value);
|
|
@@ -3029,7 +3039,7 @@ function getTrustLevel(score) {
|
|
|
3029
3039
|
}
|
|
3030
3040
|
|
|
3031
3041
|
// src/version.ts
|
|
3032
|
-
var SDK_VERSION = "2.4.
|
|
3042
|
+
var SDK_VERSION = "2.4.13";
|
|
3033
3043
|
|
|
3034
3044
|
// src/verify.ts
|
|
3035
3045
|
var DEFAULT_CONFIG = {
|
|
@@ -3048,22 +3058,27 @@ var DEFAULT_CONFIG = {
|
|
|
3048
3058
|
};
|
|
3049
3059
|
var initCheckPerformed = false;
|
|
3050
3060
|
var deprecationWarningShown = false;
|
|
3051
|
-
async function performInitCheck(apiBaseUrl, debug) {
|
|
3061
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
3052
3062
|
initCheckPerformed = true;
|
|
3053
3063
|
try {
|
|
3054
3064
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
3055
3065
|
const response = await fetch(probeUrl, { method: "HEAD" });
|
|
3056
3066
|
const contentType = response.headers.get("content-type") ?? "";
|
|
3057
3067
|
if (contentType.startsWith("text/html")) {
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3068
|
+
const message = `[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).`;
|
|
3069
|
+
if (strictInit) {
|
|
3070
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
3071
|
+
}
|
|
3072
|
+
console.warn(`${message} Set disableInitChecks: true on GatewayConfig to silence.`);
|
|
3061
3073
|
} else if (debug) {
|
|
3062
3074
|
console.log(
|
|
3063
3075
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
3064
3076
|
);
|
|
3065
3077
|
}
|
|
3066
3078
|
} catch (err) {
|
|
3079
|
+
if (strictInit) {
|
|
3080
|
+
throw err;
|
|
3081
|
+
}
|
|
3067
3082
|
if (debug) {
|
|
3068
3083
|
console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
|
|
3069
3084
|
}
|
|
@@ -3087,7 +3102,23 @@ function getCacheKey(request) {
|
|
|
3087
3102
|
request.counterpartyType || "",
|
|
3088
3103
|
request.isSubAgentRequest ? "1" : "0",
|
|
3089
3104
|
request.parentAgentId || "",
|
|
3090
|
-
request.subAgentDepth ?? ""
|
|
3105
|
+
request.subAgentDepth ?? "",
|
|
3106
|
+
// Audit F-A1-07: previously-missing dimensions that DO affect the
|
|
3107
|
+
// backend verdict. Without these, two requests with different
|
|
3108
|
+
// durations (e.g. 60s vs 86400s) collided on the same cache key and
|
|
3109
|
+
// the shorter-duration allow served the longer-duration request.
|
|
3110
|
+
request.durationRequired ?? "",
|
|
3111
|
+
request.invocationProtocol || "",
|
|
3112
|
+
request.enableRuntimeChallenge ? "1" : "0",
|
|
3113
|
+
// callerMetadata fields contribute to risk model; include the ones
|
|
3114
|
+
// backend reads. sourceIp/userAgent/forwardedFor change per-request
|
|
3115
|
+
// so their inclusion effectively forces a re-check for any varying
|
|
3116
|
+
// client (the right behavior — IP-driven anomaly scoring shouldn't
|
|
3117
|
+
// be cached across IPs).
|
|
3118
|
+
request.callerMetadata?.sourceIp || "",
|
|
3119
|
+
request.callerMetadata?.userAgent || "",
|
|
3120
|
+
request.callerMetadata?.forwardedFor || "",
|
|
3121
|
+
request.callerMetadata?.agentCardUrl || ""
|
|
3091
3122
|
].join("|");
|
|
3092
3123
|
}
|
|
3093
3124
|
function getCachedResult(request) {
|
|
@@ -3116,7 +3147,7 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
3116
3147
|
const isApiError = source === "api_error";
|
|
3117
3148
|
const guidance = isApiError ? {
|
|
3118
3149
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
3119
|
-
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
|
|
3150
|
+
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
|
|
3120
3151
|
documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
|
|
3121
3152
|
steps: [
|
|
3122
3153
|
"Retry the request with exponential backoff",
|
|
@@ -3124,7 +3155,7 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
3124
3155
|
]
|
|
3125
3156
|
} : {
|
|
3126
3157
|
message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
|
|
3127
|
-
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
|
|
3158
|
+
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
|
|
3128
3159
|
documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
|
|
3129
3160
|
steps: [
|
|
3130
3161
|
"Register for an AstraSync account",
|
|
@@ -3201,12 +3232,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3201
3232
|
"Content-Type": "application/json",
|
|
3202
3233
|
...config.customHeaders
|
|
3203
3234
|
};
|
|
3204
|
-
if (credentials.authorizationHeader) {
|
|
3205
|
-
headers["Authorization"] = credentials.authorizationHeader;
|
|
3206
|
-
} else if (config.apiKey) {
|
|
3207
|
-
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
3208
|
-
}
|
|
3209
3235
|
if (config.apiKey) {
|
|
3236
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
3210
3237
|
headers["X-API-Key"] = config.apiKey;
|
|
3211
3238
|
}
|
|
3212
3239
|
try {
|
|
@@ -3252,7 +3279,11 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3252
3279
|
async function verify(config, request) {
|
|
3253
3280
|
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
3254
3281
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
3255
|
-
|
|
3282
|
+
if (mergedConfig.strictInit) {
|
|
3283
|
+
await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
|
|
3284
|
+
} else {
|
|
3285
|
+
void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
|
|
3286
|
+
}
|
|
3256
3287
|
}
|
|
3257
3288
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
3258
3289
|
deprecationWarningShown = true;
|
|
@@ -3306,7 +3337,7 @@ async function verify(config, request) {
|
|
|
3306
3337
|
requiresApproval: apiResponse.access?.requiresApproval,
|
|
3307
3338
|
guidance: {
|
|
3308
3339
|
message: apiResponse.access?.reason || "Access denied by PDLSS policy",
|
|
3309
|
-
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/register`,
|
|
3340
|
+
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
3310
3341
|
documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
|
|
3311
3342
|
},
|
|
3312
3343
|
verifiedAt: /* @__PURE__ */ new Date(),
|
|
@@ -3376,13 +3407,15 @@ async function verify(config, request) {
|
|
|
3376
3407
|
result.denialReasons = result.recommendationReasons || [
|
|
3377
3408
|
"Access denied by AstraSync recommendation"
|
|
3378
3409
|
];
|
|
3379
|
-
|
|
3380
|
-
result.
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3410
|
+
result.guidance = result.runtimeChallenge ? {
|
|
3411
|
+
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|
|
3412
|
+
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
3413
|
+
documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/runtime-challenge`
|
|
3414
|
+
} : {
|
|
3415
|
+
message: result.recommendationReasons?.[0] || "Access denied by AstraSync recommendation",
|
|
3416
|
+
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
3417
|
+
documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
|
|
3418
|
+
};
|
|
3386
3419
|
} else if (result.recommendation === "step_up_required") {
|
|
3387
3420
|
result.requiresStepUp = true;
|
|
3388
3421
|
if (ACCESS_LEVEL_HIERARCHY[result.accessLevel] > ACCESS_LEVEL_HIERARCHY["read-only"]) {
|
|
@@ -3408,6 +3441,35 @@ import { parseDictionary } from "structured-headers";
|
|
|
3408
3441
|
// src/transport/rfc9421-verify.ts
|
|
3409
3442
|
import { httpbis } from "http-message-signatures";
|
|
3410
3443
|
|
|
3444
|
+
// src/transport/nonce-store.ts
|
|
3445
|
+
var InMemoryNonceStore = class {
|
|
3446
|
+
constructor(capacity = 1e4) {
|
|
3447
|
+
this.entries = /* @__PURE__ */ new Map();
|
|
3448
|
+
this.lastSweepMs = 0;
|
|
3449
|
+
this.capacity = capacity;
|
|
3450
|
+
}
|
|
3451
|
+
seen(key, expiresAtMs) {
|
|
3452
|
+
const nowMs = Date.now();
|
|
3453
|
+
if (nowMs - this.lastSweepMs > 1e3) {
|
|
3454
|
+
for (const [k, exp] of this.entries) {
|
|
3455
|
+
if (exp <= nowMs) this.entries.delete(k);
|
|
3456
|
+
}
|
|
3457
|
+
this.lastSweepMs = nowMs;
|
|
3458
|
+
}
|
|
3459
|
+
const existing = this.entries.get(key);
|
|
3460
|
+
if (existing !== void 0 && existing > nowMs) {
|
|
3461
|
+
return true;
|
|
3462
|
+
}
|
|
3463
|
+
if (this.entries.size >= this.capacity) {
|
|
3464
|
+
const oldest = this.entries.keys().next().value;
|
|
3465
|
+
if (oldest !== void 0) this.entries.delete(oldest);
|
|
3466
|
+
}
|
|
3467
|
+
this.entries.set(key, expiresAtMs);
|
|
3468
|
+
return false;
|
|
3469
|
+
}
|
|
3470
|
+
};
|
|
3471
|
+
var defaultNonceStore = new InMemoryNonceStore();
|
|
3472
|
+
|
|
3411
3473
|
// src/transport/vi.ts
|
|
3412
3474
|
import { splitSdJwt, decodeSdJwtSync } from "@sd-jwt/decode";
|
|
3413
3475
|
import { createHash } from "crypto";
|