@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/adapters/nextjs.js
CHANGED
|
@@ -55,7 +55,7 @@ function hasMinimumAccess(actual, required) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// src/version.ts
|
|
58
|
-
var SDK_VERSION = "2.4.
|
|
58
|
+
var SDK_VERSION = "2.4.13";
|
|
59
59
|
|
|
60
60
|
// src/verify.ts
|
|
61
61
|
var DEFAULT_CONFIG = {
|
|
@@ -74,22 +74,27 @@ var DEFAULT_CONFIG = {
|
|
|
74
74
|
};
|
|
75
75
|
var initCheckPerformed = false;
|
|
76
76
|
var deprecationWarningShown = false;
|
|
77
|
-
async function performInitCheck(apiBaseUrl, debug) {
|
|
77
|
+
async function performInitCheck(apiBaseUrl, debug, strictInit) {
|
|
78
78
|
initCheckPerformed = true;
|
|
79
79
|
try {
|
|
80
80
|
const probeUrl = `${apiBaseUrl}/agents/verify-access`;
|
|
81
81
|
const response = await fetch(probeUrl, { method: "HEAD" });
|
|
82
82
|
const contentType = response.headers.get("content-type") ?? "";
|
|
83
83
|
if (contentType.startsWith("text/html")) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
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).`;
|
|
85
|
+
if (strictInit) {
|
|
86
|
+
throw new Error(`${message} (strictInit=true)`);
|
|
87
|
+
}
|
|
88
|
+
console.warn(`${message} Set disableInitChecks: true on GatewayConfig to silence.`);
|
|
87
89
|
} else if (debug) {
|
|
88
90
|
console.log(
|
|
89
91
|
`[VerificationGateway] init check passed for ${apiBaseUrl} (content-type: ${contentType})`
|
|
90
92
|
);
|
|
91
93
|
}
|
|
92
94
|
} catch (err) {
|
|
95
|
+
if (strictInit) {
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
93
98
|
if (debug) {
|
|
94
99
|
console.log(`[VerificationGateway] init check failed (non-blocking): ${String(err)}`);
|
|
95
100
|
}
|
|
@@ -113,7 +118,23 @@ function getCacheKey(request) {
|
|
|
113
118
|
request.counterpartyType || "",
|
|
114
119
|
request.isSubAgentRequest ? "1" : "0",
|
|
115
120
|
request.parentAgentId || "",
|
|
116
|
-
request.subAgentDepth ?? ""
|
|
121
|
+
request.subAgentDepth ?? "",
|
|
122
|
+
// Audit F-A1-07: previously-missing dimensions that DO affect the
|
|
123
|
+
// backend verdict. Without these, two requests with different
|
|
124
|
+
// durations (e.g. 60s vs 86400s) collided on the same cache key and
|
|
125
|
+
// the shorter-duration allow served the longer-duration request.
|
|
126
|
+
request.durationRequired ?? "",
|
|
127
|
+
request.invocationProtocol || "",
|
|
128
|
+
request.enableRuntimeChallenge ? "1" : "0",
|
|
129
|
+
// callerMetadata fields contribute to risk model; include the ones
|
|
130
|
+
// backend reads. sourceIp/userAgent/forwardedFor change per-request
|
|
131
|
+
// so their inclusion effectively forces a re-check for any varying
|
|
132
|
+
// client (the right behavior — IP-driven anomaly scoring shouldn't
|
|
133
|
+
// be cached across IPs).
|
|
134
|
+
request.callerMetadata?.sourceIp || "",
|
|
135
|
+
request.callerMetadata?.userAgent || "",
|
|
136
|
+
request.callerMetadata?.forwardedFor || "",
|
|
137
|
+
request.callerMetadata?.agentCardUrl || ""
|
|
117
138
|
].join("|");
|
|
118
139
|
}
|
|
119
140
|
function getCachedResult(request) {
|
|
@@ -142,7 +163,7 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
142
163
|
const isApiError = source === "api_error";
|
|
143
164
|
const guidance = isApiError ? {
|
|
144
165
|
message: "Verification is temporarily unavailable. Retry with exponential backoff; if the issue persists, contact support with the correlationId.",
|
|
145
|
-
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
|
|
166
|
+
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
|
|
146
167
|
documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
|
|
147
168
|
steps: [
|
|
148
169
|
"Retry the request with exponential backoff",
|
|
@@ -150,7 +171,7 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
150
171
|
]
|
|
151
172
|
} : {
|
|
152
173
|
message: "This service verifies AI agents before granting access. Please register your agent with AstraSync.",
|
|
153
|
-
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/register`,
|
|
174
|
+
registrationUrl: `${config.apiBaseUrl.replace("/api", "")}/agents/register`,
|
|
154
175
|
documentationUrl: `${config.apiBaseUrl.replace("/api", "")}/docs/agent-access`,
|
|
155
176
|
steps: [
|
|
156
177
|
"Register for an AstraSync account",
|
|
@@ -227,12 +248,8 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
227
248
|
"Content-Type": "application/json",
|
|
228
249
|
...config.customHeaders
|
|
229
250
|
};
|
|
230
|
-
if (credentials.authorizationHeader) {
|
|
231
|
-
headers["Authorization"] = credentials.authorizationHeader;
|
|
232
|
-
} else if (config.apiKey) {
|
|
233
|
-
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
234
|
-
}
|
|
235
251
|
if (config.apiKey) {
|
|
252
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
236
253
|
headers["X-API-Key"] = config.apiKey;
|
|
237
254
|
}
|
|
238
255
|
try {
|
|
@@ -278,7 +295,11 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
278
295
|
async function verify(config, request) {
|
|
279
296
|
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
280
297
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
281
|
-
|
|
298
|
+
if (mergedConfig.strictInit) {
|
|
299
|
+
await performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, true);
|
|
300
|
+
} else {
|
|
301
|
+
void performInitCheck(mergedConfig.apiBaseUrl, mergedConfig.debug, false);
|
|
302
|
+
}
|
|
282
303
|
}
|
|
283
304
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
284
305
|
deprecationWarningShown = true;
|
|
@@ -332,7 +353,7 @@ async function verify(config, request) {
|
|
|
332
353
|
requiresApproval: apiResponse.access?.requiresApproval,
|
|
333
354
|
guidance: {
|
|
334
355
|
message: apiResponse.access?.reason || "Access denied by PDLSS policy",
|
|
335
|
-
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/register`,
|
|
356
|
+
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
336
357
|
documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
|
|
337
358
|
},
|
|
338
359
|
verifiedAt: /* @__PURE__ */ new Date(),
|
|
@@ -402,13 +423,15 @@ async function verify(config, request) {
|
|
|
402
423
|
result.denialReasons = result.recommendationReasons || [
|
|
403
424
|
"Access denied by AstraSync recommendation"
|
|
404
425
|
];
|
|
405
|
-
|
|
406
|
-
result.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
426
|
+
result.guidance = result.runtimeChallenge ? {
|
|
427
|
+
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|
|
428
|
+
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
429
|
+
documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/runtime-challenge`
|
|
430
|
+
} : {
|
|
431
|
+
message: result.recommendationReasons?.[0] || "Access denied by AstraSync recommendation",
|
|
432
|
+
registrationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
433
|
+
documentationUrl: `${mergedConfig.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
|
|
434
|
+
};
|
|
412
435
|
} else if (result.recommendation === "step_up_required") {
|
|
413
436
|
result.requiresStepUp = true;
|
|
414
437
|
if (ACCESS_LEVEL_HIERARCHY[result.accessLevel] > ACCESS_LEVEL_HIERARCHY["read-only"]) {
|
|
@@ -538,6 +561,18 @@ function performCounterpartyPreCheck(routeConfig, astraCreds, purpose) {
|
|
|
538
561
|
}
|
|
539
562
|
|
|
540
563
|
// src/adapters/nextjs.ts
|
|
564
|
+
function escapeHtml(value) {
|
|
565
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
566
|
+
}
|
|
567
|
+
function sanitizeUrl(value, fallback) {
|
|
568
|
+
if (typeof value !== "string" || value.length === 0) return escapeHtml(fallback);
|
|
569
|
+
const trimmed = value.trim();
|
|
570
|
+
if (/^javascript:|^data:|^vbscript:/i.test(trimmed)) return escapeHtml(fallback);
|
|
571
|
+
if (/^https?:\/\//i.test(trimmed) || trimmed.startsWith("/")) {
|
|
572
|
+
return escapeHtml(trimmed);
|
|
573
|
+
}
|
|
574
|
+
return escapeHtml(fallback);
|
|
575
|
+
}
|
|
541
576
|
function extractCredentialsFromNextRequest(request) {
|
|
542
577
|
const credentials = {};
|
|
543
578
|
const astraId = request.headers.get("x-astra-id") || request.headers.get("X-Astra-Id");
|
|
@@ -609,10 +644,18 @@ function extractPurpose(request) {
|
|
|
609
644
|
}
|
|
610
645
|
}
|
|
611
646
|
function generateCommerceShieldHtml(result, options) {
|
|
612
|
-
const title = options.commerceShield?.title || "AstraSync Agent Verification";
|
|
613
|
-
const message =
|
|
614
|
-
|
|
615
|
-
|
|
647
|
+
const title = escapeHtml(options.commerceShield?.title || "AstraSync Agent Verification");
|
|
648
|
+
const message = escapeHtml(
|
|
649
|
+
options.commerceShield?.message || result.guidance?.message || "This site verifies AI agents before granting access. We noticed you're visiting without AstraSync credentials."
|
|
650
|
+
);
|
|
651
|
+
const registrationUrl = sanitizeUrl(
|
|
652
|
+
result.guidance?.registrationUrl,
|
|
653
|
+
"https://astrasync.ai/register"
|
|
654
|
+
);
|
|
655
|
+
const docsUrl = sanitizeUrl(
|
|
656
|
+
result.guidance?.documentationUrl,
|
|
657
|
+
"https://astrasync.ai/docs/agent-access"
|
|
658
|
+
);
|
|
616
659
|
const allowGuest = options.commerceShield?.allowGuestAccess ?? true;
|
|
617
660
|
return `
|
|
618
661
|
<!DOCTYPE html>
|
|
@@ -734,7 +777,7 @@ function generateCommerceShieldHtml(result, options) {
|
|
|
734
777
|
<div class="shield-steps">
|
|
735
778
|
<h3>To get verified access:</h3>
|
|
736
779
|
<ol>
|
|
737
|
-
<li>Register at <a href="${registrationUrl}">astrasync.ai/register</a></li>
|
|
780
|
+
<li>Register at <a href="${registrationUrl}">astrasync.ai/agents/register</a></li>
|
|
738
781
|
<li>Create and register your agent</li>
|
|
739
782
|
<li>Add your ASTRA-ID to request headers</li>
|
|
740
783
|
<li>Refresh this page</li>
|
|
@@ -822,7 +865,7 @@ function createMiddleware(options) {
|
|
|
822
865
|
denialReasons: preCheckFailures.map((f) => f.message),
|
|
823
866
|
guidance: {
|
|
824
867
|
message: "Request exceeds counterparty-defined PDLSS limits.",
|
|
825
|
-
registrationUrl: `${config.apiBaseUrl?.replace("/api", "")}/register`,
|
|
868
|
+
registrationUrl: `${config.apiBaseUrl?.replace("/api", "")}/agents/register`,
|
|
826
869
|
documentationUrl: `${config.apiBaseUrl?.replace("/api", "")}/docs/pdlss`
|
|
827
870
|
},
|
|
828
871
|
verifiedAt: /* @__PURE__ */ new Date()
|