@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequestHandler, Request } from 'express';
|
|
2
|
-
import { i as VerificationResult, d as ExpressMiddlewareOptions, b as AstraSyncCredentials } from './types-
|
|
2
|
+
import { i as VerificationResult, d as ExpressMiddlewareOptions, b as AstraSyncCredentials } from './types-B3USs-Kx.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* AstraSync Universal Verification Gateway - Express Middleware
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequestHandler, Request } from 'express';
|
|
2
|
-
import { i as VerificationResult, d as ExpressMiddlewareOptions, b as AstraSyncCredentials } from './types-
|
|
2
|
+
import { i as VerificationResult, d as ExpressMiddlewareOptions, b as AstraSyncCredentials } from './types-B3USs-Kx.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* AstraSync Universal Verification Gateway - Express Middleware
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-CgDCUfo8.mjs';
|
|
2
|
+
import '../types-B3USs-Kx.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* AstraSyncGateway — Primary API surface for agent verification.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-R5N4ET6x.js';
|
|
2
|
+
import '../types-B3USs-Kx.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* AstraSyncGateway — Primary API surface for agent verification.
|
package/dist/gateway/gateway.js
CHANGED
|
@@ -106,7 +106,10 @@ var LocalEvaluator = class {
|
|
|
106
106
|
}
|
|
107
107
|
const depth = context.metadata?.subAgentDepth || 0;
|
|
108
108
|
if (this.policy.selfInstantiation.maxDepth !== void 0 && depth >= this.policy.selfInstantiation.maxDepth) {
|
|
109
|
-
return {
|
|
109
|
+
return {
|
|
110
|
+
recommendation: "DENY",
|
|
111
|
+
reason: `Sub-agent depth ${depth} exceeds max depth ${this.policy.selfInstantiation.maxDepth}`
|
|
112
|
+
};
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
if (purposeRule.requiresApproval) {
|
|
@@ -187,7 +190,10 @@ var LocalEvaluator = class {
|
|
|
187
190
|
return { recommendation: "DENY", reason: `Risk score ${riskScore} exceeds block threshold` };
|
|
188
191
|
}
|
|
189
192
|
if (riskScore >= thresholds.requireApproval.min) {
|
|
190
|
-
return {
|
|
193
|
+
return {
|
|
194
|
+
recommendation: "MANUAL_REVIEW",
|
|
195
|
+
reason: `Risk score ${riskScore} requires approval`
|
|
196
|
+
};
|
|
191
197
|
}
|
|
192
198
|
return null;
|
|
193
199
|
}
|
|
@@ -252,6 +258,10 @@ var LocalEvaluator = class {
|
|
|
252
258
|
*/
|
|
253
259
|
matchGlob(value, pattern) {
|
|
254
260
|
if (pattern === value) return true;
|
|
261
|
+
const starCount = (pattern.match(/\*/g) ?? []).length;
|
|
262
|
+
if (starCount > 8) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
255
265
|
const regexStr = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
256
266
|
try {
|
|
257
267
|
return new RegExp(`^${regexStr}$`, "i").test(value);
|
|
@@ -3055,7 +3065,7 @@ function getTrustLevel(score) {
|
|
|
3055
3065
|
}
|
|
3056
3066
|
|
|
3057
3067
|
// src/version.ts
|
|
3058
|
-
var SDK_VERSION = "2.4.
|
|
3068
|
+
var SDK_VERSION = "2.4.13";
|
|
3059
3069
|
|
|
3060
3070
|
// src/verify.ts
|
|
3061
3071
|
var DEFAULT_CONFIG = {
|
|
@@ -3074,22 +3084,27 @@ var DEFAULT_CONFIG = {
|
|
|
3074
3084
|
};
|
|
3075
3085
|
var initCheckPerformed = false;
|
|
3076
3086
|
var deprecationWarningShown = false;
|
|
3077
|
-
async function performInitCheck(apiBaseUrl, debug) {
|
|
3087
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
3078
3088
|
initCheckPerformed = true;
|
|
3079
3089
|
try {
|
|
3080
3090
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
3081
3091
|
const response = await fetch(probeUrl, { method: "HEAD" });
|
|
3082
3092
|
const contentType = response.headers.get("content-type") ?? "";
|
|
3083
3093
|
if (contentType.startsWith("text/html")) {
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3094
|
+
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).`;
|
|
3095
|
+
if (strictInit) {
|
|
3096
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
3097
|
+
}
|
|
3098
|
+
console.warn(`${message} Set disableInitChecks: true on GatewayConfig to silence.`);
|
|
3087
3099
|
} else if (debug) {
|
|
3088
3100
|
console.log(
|
|
3089
3101
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
3090
3102
|
);
|
|
3091
3103
|
}
|
|
3092
3104
|
} catch (err) {
|
|
3105
|
+
if (strictInit) {
|
|
3106
|
+
throw err;
|
|
3107
|
+
}
|
|
3093
3108
|
if (debug) {
|
|
3094
3109
|
console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
|
|
3095
3110
|
}
|
|
@@ -3113,7 +3128,23 @@ function getCacheKey(request) {
|
|
|
3113
3128
|
request.counterpartyType || "",
|
|
3114
3129
|
request.isSubAgentRequest ? "1" : "0",
|
|
3115
3130
|
request.parentAgentId || "",
|
|
3116
|
-
request.subAgentDepth ?? ""
|
|
3131
|
+
request.subAgentDepth ?? "",
|
|
3132
|
+
// Audit F-A1-07: previously-missing dimensions that DO affect the
|
|
3133
|
+
// backend verdict. Without these, two requests with different
|
|
3134
|
+
// durations (e.g. 60s vs 86400s) collided on the same cache key and
|
|
3135
|
+
// the shorter-duration allow served the longer-duration request.
|
|
3136
|
+
request.durationRequired ?? "",
|
|
3137
|
+
request.invocationProtocol || "",
|
|
3138
|
+
request.enableRuntimeChallenge ? "1" : "0",
|
|
3139
|
+
// callerMetadata fields contribute to risk model; include the ones
|
|
3140
|
+
// backend reads. sourceIp/userAgent/forwardedFor change per-request
|
|
3141
|
+
// so their inclusion effectively forces a re-check for any varying
|
|
3142
|
+
// client (the right behavior — IP-driven anomaly scoring shouldn't
|
|
3143
|
+
// be cached across IPs).
|
|
3144
|
+
request.callerMetadata?.sourceIp || "",
|
|
3145
|
+
request.callerMetadata?.userAgent || "",
|
|
3146
|
+
request.callerMetadata?.forwardedFor || "",
|
|
3147
|
+
request.callerMetadata?.agentCardUrl || ""
|
|
3117
3148
|
].join("|");
|
|
3118
3149
|
}
|
|
3119
3150
|
function getCachedResult(request) {
|
|
@@ -3142,7 +3173,7 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
3142
3173
|
const isApiError = source === "api_error";
|
|
3143
3174
|
const guidance = isApiError ? {
|
|
3144
3175
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
3145
|
-
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
|
|
3176
|
+
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
|
|
3146
3177
|
documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
|
|
3147
3178
|
steps: [
|
|
3148
3179
|
"Retry the request with exponential backoff",
|
|
@@ -3150,7 +3181,7 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
3150
3181
|
]
|
|
3151
3182
|
} : {
|
|
3152
3183
|
message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
|
|
3153
|
-
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
|
|
3184
|
+
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
|
|
3154
3185
|
documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
|
|
3155
3186
|
steps: [
|
|
3156
3187
|
"Register for an AstraSync account",
|
|
@@ -3227,12 +3258,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3227
3258
|
"Content-Type": "application/json",
|
|
3228
3259
|
...config.customHeaders
|
|
3229
3260
|
};
|
|
3230
|
-
if (credentials.authorizationHeader) {
|
|
3231
|
-
headers["Authorization"] = credentials.authorizationHeader;
|
|
3232
|
-
} else if (config.apiKey) {
|
|
3233
|
-
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
3234
|
-
}
|
|
3235
3261
|
if (config.apiKey) {
|
|
3262
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
3236
3263
|
headers["X-API-Key"] = config.apiKey;
|
|
3237
3264
|
}
|
|
3238
3265
|
try {
|
|
@@ -3278,7 +3305,11 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
3278
3305
|
async function verify(config, request) {
|
|
3279
3306
|
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
3280
3307
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
3281
|
-
|
|
3308
|
+
if (mergedConfig.strictInit) {
|
|
3309
|
+
await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
|
|
3310
|
+
} else {
|
|
3311
|
+
void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
|
|
3312
|
+
}
|
|
3282
3313
|
}
|
|
3283
3314
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
3284
3315
|
deprecationWarningShown = true;
|
|
@@ -3332,7 +3363,7 @@ async function verify(config, request) {
|
|
|
3332
3363
|
requiresApproval: apiResponse.access?.requiresApproval,
|
|
3333
3364
|
guidance: {
|
|
3334
3365
|
message: apiResponse.access?.reason || "Access denied by PDLSS policy",
|
|
3335
|
-
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/register`,
|
|
3366
|
+
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
3336
3367
|
documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
|
|
3337
3368
|
},
|
|
3338
3369
|
verifiedAt: /* @__PURE__ */ new Date(),
|
|
@@ -3402,13 +3433,15 @@ async function verify(config, request) {
|
|
|
3402
3433
|
result.denialReasons = result.recommendationReasons || [
|
|
3403
3434
|
"Access denied by AstraSync recommendation"
|
|
3404
3435
|
];
|
|
3405
|
-
|
|
3406
|
-
result.
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3436
|
+
result.guidance = result.runtimeChallenge ? {
|
|
3437
|
+
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|
|
3438
|
+
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
3439
|
+
documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/runtime-challenge`
|
|
3440
|
+
} : {
|
|
3441
|
+
message: result.recommendationReasons?.[0] || "Access denied by AstraSync recommendation",
|
|
3442
|
+
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
3443
|
+
documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
|
|
3444
|
+
};
|
|
3412
3445
|
} else if (result.recommendation === "step_up_required") {
|
|
3413
3446
|
result.requiresStepUp = true;
|
|
3414
3447
|
if (ACCESS_LEVEL_HIERARCHY[result.accessLevel] > ACCESS_LEVEL_HIERARCHY["read-only"]) {
|
|
@@ -3434,6 +3467,35 @@ var import_structured_headers = require("structured-headers");
|
|
|
3434
3467
|
// src/transport/rfc9421-verify.ts
|
|
3435
3468
|
var import_http_message_signatures = require("http-message-signatures");
|
|
3436
3469
|
|
|
3470
|
+
// src/transport/nonce-store.ts
|
|
3471
|
+
var InMemoryNonceStore = class {
|
|
3472
|
+
constructor(capacity = 1e4) {
|
|
3473
|
+
this.entries = /* @__PURE__ */ new Map();
|
|
3474
|
+
this.lastSweepMs = 0;
|
|
3475
|
+
this.capacity = capacity;
|
|
3476
|
+
}
|
|
3477
|
+
seen(key, expiresAtMs) {
|
|
3478
|
+
const nowMs = Date.now();
|
|
3479
|
+
if (nowMs - this.lastSweepMs > 1e3) {
|
|
3480
|
+
for (const [k, exp] of this.entries) {
|
|
3481
|
+
if (exp <= nowMs) this.entries.delete(k);
|
|
3482
|
+
}
|
|
3483
|
+
this.lastSweepMs = nowMs;
|
|
3484
|
+
}
|
|
3485
|
+
const existing = this.entries.get(key);
|
|
3486
|
+
if (existing !== void 0 && existing > nowMs) {
|
|
3487
|
+
return true;
|
|
3488
|
+
}
|
|
3489
|
+
if (this.entries.size >= this.capacity) {
|
|
3490
|
+
const oldest = this.entries.keys().next().value;
|
|
3491
|
+
if (oldest !== void 0) this.entries.delete(oldest);
|
|
3492
|
+
}
|
|
3493
|
+
this.entries.set(key, expiresAtMs);
|
|
3494
|
+
return false;
|
|
3495
|
+
}
|
|
3496
|
+
};
|
|
3497
|
+
var defaultNonceStore = new InMemoryNonceStore();
|
|
3498
|
+
|
|
3437
3499
|
// src/transport/vi.ts
|
|
3438
3500
|
var import_decode = require("@sd-jwt/decode");
|
|
3439
3501
|
var import_node_crypto = require("crypto");
|