@astrasyncai/verification-gateway 2.4.8 → 2.4.10
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 +81 -31
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +81 -31
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.d.ts +1 -1
- package/dist/adapters/mcp.js +64 -26
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +64 -26
- 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 +89 -32
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +89 -32
- 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 +65 -25
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +65 -25
- 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/browser/background.js +60 -25
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +60 -25
- 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 +60 -25
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +60 -25
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-DvVjR2H4.d.mts → express-4WStX3PV.d.mts} +1 -1
- package/dist/{express-714gJbaW.d.ts → express-C1ePFB7n.d.ts} +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +60 -25
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +60 -25
- 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-DYFS9QVb.d.mts → index-ChPX4WHl.d.mts} +1 -1
- package/dist/{index-DO0oG8ED.d.ts → index-Cjm-zBeZ.d.ts} +1 -1
- package/dist/{index-2WAlxs2G.d.ts → index-CzJMCgEy.d.ts} +1 -1
- package/dist/{index-P9t7M_dJ.d.mts → index-D8IEntil.d.mts} +1 -1
- package/dist/index.d.mts +22 -11
- package/dist/index.d.ts +22 -11
- package/dist/index.js +133 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -42
- 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-CZ-MwSOT.d.ts → nextjs-BIORS__0.d.ts} +1 -1
- package/dist/{nextjs-BCoH7EqF.d.mts → nextjs-CjzHdaXA.d.mts} +1 -1
- package/dist/registration/index.d.mts +76 -1
- package/dist/registration/index.d.ts +76 -1
- package/dist/registration/index.js +27 -2
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +25 -1
- package/dist/registration/index.mjs.map +1 -1
- package/dist/{sdk-wwhFDXWX.d.mts → sdk-Chhz-FcT.d.mts} +9 -4
- package/dist/{sdk-kiA49vqJ.d.ts → sdk-CqTEQAc6.d.ts} +9 -4
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-DOAb89cm.d.mts → types-DNK2BgIf.d.mts} +1 -1
- package/dist/{types-aucqzfUa.d.ts → types-DoWIuzfj.d.ts} +1 -1
- package/dist/{types-BwDmjIdr.d.mts → types-L15pYd2c.d.mts} +21 -4
- package/dist/{types-BwDmjIdr.d.ts → types-L15pYd2c.d.ts} +21 -4
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +1 -1
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -126,7 +126,7 @@ function getCapabilities(accessLevel) {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
// src/version.ts
|
|
129
|
-
var SDK_VERSION = "2.4.
|
|
129
|
+
var SDK_VERSION = "2.4.10";
|
|
130
130
|
|
|
131
131
|
// src/verify.ts
|
|
132
132
|
var DEFAULT_CONFIG = {
|
|
@@ -137,8 +137,10 @@ var DEFAULT_CONFIG = {
|
|
|
137
137
|
// through (`hasMinimumAccess('guidance', 'guidance') === true`).
|
|
138
138
|
defaultAccessLevel: "none",
|
|
139
139
|
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
140
|
-
|
|
141
|
-
//
|
|
140
|
+
// Round-18.5 F4: cacheTtl deliberately unset. When undefined, cacheResult
|
|
141
|
+
// applies the split default (60s autonomous / 300s step-up). When the
|
|
142
|
+
// caller sets cacheTtl explicitly, that value is honoured uniformly.
|
|
143
|
+
// Set cacheTtl: 0 to disable caching entirely.
|
|
142
144
|
debug: false
|
|
143
145
|
};
|
|
144
146
|
var initCheckPerformed = false;
|
|
@@ -165,11 +167,28 @@ async function performInitCheck(apiBaseUrl, debug) {
|
|
|
165
167
|
}
|
|
166
168
|
}
|
|
167
169
|
var verificationCache = /* @__PURE__ */ new Map();
|
|
168
|
-
function getCacheKey(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
function getCacheKey(request) {
|
|
171
|
+
const c = request.credentials;
|
|
172
|
+
return [
|
|
173
|
+
c.astraId || "",
|
|
174
|
+
c.apiKey || "",
|
|
175
|
+
c.jwt || "",
|
|
176
|
+
request.purpose || "",
|
|
177
|
+
request.action || "",
|
|
178
|
+
request.resourceType || "",
|
|
179
|
+
request.resource || "",
|
|
180
|
+
request.jurisdiction || "",
|
|
181
|
+
request.transactionValue ?? "",
|
|
182
|
+
request.currency || "",
|
|
183
|
+
request.counterpartyUrl || "",
|
|
184
|
+
request.counterpartyType || "",
|
|
185
|
+
request.isSubAgentRequest ? "1" : "0",
|
|
186
|
+
request.parentAgentId || "",
|
|
187
|
+
request.subAgentDepth ?? ""
|
|
188
|
+
].join("|");
|
|
189
|
+
}
|
|
190
|
+
function getCachedResult(request) {
|
|
191
|
+
const key = getCacheKey(request);
|
|
173
192
|
const cached = verificationCache.get(key);
|
|
174
193
|
if (cached && cached.expiresAt > Date.now()) {
|
|
175
194
|
return cached.result;
|
|
@@ -179,8 +198,11 @@ function getCachedResult(credentials) {
|
|
|
179
198
|
}
|
|
180
199
|
return null;
|
|
181
200
|
}
|
|
182
|
-
|
|
183
|
-
|
|
201
|
+
var DEFAULT_AUTONOMOUS_TTL_SECONDS = 60;
|
|
202
|
+
var DEFAULT_STEP_UP_TTL_SECONDS = 300;
|
|
203
|
+
function cacheResult(request, result, configuredTtl) {
|
|
204
|
+
const ttlSeconds = configuredTtl && configuredTtl > 0 ? configuredTtl : result.requiresStepUp ? DEFAULT_STEP_UP_TTL_SECONDS : DEFAULT_AUTONOMOUS_TTL_SECONDS;
|
|
205
|
+
const key = getCacheKey(request);
|
|
184
206
|
verificationCache.set(key, {
|
|
185
207
|
result,
|
|
186
208
|
expiresAt: Date.now() + ttlSeconds * 1e3
|
|
@@ -243,12 +265,17 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
243
265
|
]
|
|
244
266
|
};
|
|
245
267
|
return {
|
|
246
|
-
|
|
268
|
+
// Round-18 G4: createGuidanceResponse fires for unverified-agent path or
|
|
269
|
+
// API-error fallback. Identity is not verified (no agent resolved);
|
|
270
|
+
// policy is not evaluated (we never reached the gate).
|
|
271
|
+
identityVerified: false,
|
|
272
|
+
policyAllowed: false,
|
|
247
273
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
248
|
-
// Adapters additionally short-circuit on
|
|
249
|
-
// the gate check, but the access level still has
|
|
250
|
-
// data layer so downstream consumers (SDK adapters
|
|
251
|
-
// custom integrations) inherit the correct
|
|
274
|
+
// Adapters additionally short-circuit on `!identityVerified ||
|
|
275
|
+
// !policyAllowed` before the gate check, but the access level still has
|
|
276
|
+
// to be honest at the data layer so downstream consumers (SDK adapters
|
|
277
|
+
// in other languages, custom integrations) inherit the correct
|
|
278
|
+
// semantics.
|
|
252
279
|
accessLevel: "none",
|
|
253
280
|
guidance,
|
|
254
281
|
denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
|
|
@@ -364,8 +391,8 @@ async function verify(config, request) {
|
|
|
364
391
|
"[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."
|
|
365
392
|
);
|
|
366
393
|
}
|
|
367
|
-
if (mergedConfig.cacheTtl
|
|
368
|
-
const cached = getCachedResult(request
|
|
394
|
+
if (mergedConfig.cacheTtl !== 0) {
|
|
395
|
+
const cached = getCachedResult(request);
|
|
369
396
|
if (cached) {
|
|
370
397
|
if (mergedConfig.debug) {
|
|
371
398
|
console.log("[VerificationGateway] Returning cached result");
|
|
@@ -392,15 +419,17 @@ async function verify(config, request) {
|
|
|
392
419
|
}
|
|
393
420
|
if (!apiResponse.access?.allowed) {
|
|
394
421
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
422
|
+
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true;
|
|
395
423
|
const result2 = {
|
|
396
|
-
|
|
424
|
+
identityVerified: idVerifiedFromBackend,
|
|
425
|
+
policyAllowed: false,
|
|
397
426
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
398
427
|
// Pre-rename this hardcoded `'guidance'`, which conflated with the
|
|
399
428
|
// colocated `guidance: {...}` help-payload object below and let
|
|
400
429
|
// denied requests pass any route gated at `'guidance'` because
|
|
401
430
|
// `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
|
|
402
|
-
// ALSO short-circuit on
|
|
403
|
-
// belt-and-braces.
|
|
431
|
+
// ALSO short-circuit on `!identityVerified || !policyAllowed` before
|
|
432
|
+
// the gate check — belt-and-braces.
|
|
404
433
|
accessLevel: "none",
|
|
405
434
|
denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
|
|
406
435
|
failures: aggregatedFailures,
|
|
@@ -444,7 +473,13 @@ async function verify(config, request) {
|
|
|
444
473
|
const verificationContext = apiResponse.verificationContext;
|
|
445
474
|
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
446
475
|
const result = {
|
|
447
|
-
|
|
476
|
+
// Round-18 G4: backend allowed access. Identity is verified (we resolved
|
|
477
|
+
// the caller to an agent) and policy passed all gates. Read idVerified
|
|
478
|
+
// from verificationContext for symmetry with the deny branch; default true
|
|
479
|
+
// on success path since `access.allowed === true` implies identity was
|
|
480
|
+
// resolvable (anonymous-allow paths flow through createGuidanceResponse).
|
|
481
|
+
identityVerified: apiResponse.verificationContext?.idVerified !== false,
|
|
482
|
+
policyAllowed: true,
|
|
448
483
|
accessLevel,
|
|
449
484
|
agent,
|
|
450
485
|
developer,
|
|
@@ -467,7 +502,7 @@ async function verify(config, request) {
|
|
|
467
502
|
warningHeader: apiResponse.warningHeader
|
|
468
503
|
};
|
|
469
504
|
if (result.recommendation === "deny") {
|
|
470
|
-
result.
|
|
505
|
+
result.policyAllowed = false;
|
|
471
506
|
result.accessLevel = "none";
|
|
472
507
|
result.denialReasons = result.recommendationReasons || [
|
|
473
508
|
"Access denied by AstraSync recommendation"
|
|
@@ -486,8 +521,8 @@ async function verify(config, request) {
|
|
|
486
521
|
}
|
|
487
522
|
result.denialReasons = result.recommendationReasons || ["Step-up verification required"];
|
|
488
523
|
}
|
|
489
|
-
if (mergedConfig.cacheTtl
|
|
490
|
-
cacheResult(request
|
|
524
|
+
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny") {
|
|
525
|
+
cacheResult(request, result, mergedConfig.cacheTtl);
|
|
491
526
|
}
|
|
492
527
|
return result;
|
|
493
528
|
}
|
|
@@ -567,7 +602,8 @@ async function quickVerify(config, credentials) {
|
|
|
567
602
|
purpose: "verification"
|
|
568
603
|
});
|
|
569
604
|
return {
|
|
570
|
-
|
|
605
|
+
identityVerified: result.identityVerified,
|
|
606
|
+
policyAllowed: result.policyAllowed,
|
|
571
607
|
accessLevel: result.accessLevel,
|
|
572
608
|
reason: result.denialReasons?.[0]
|
|
573
609
|
};
|
|
@@ -643,8 +679,15 @@ function extractHttpCredentials(headers) {
|
|
|
643
679
|
// src/pdlss-pre-check.ts
|
|
644
680
|
function performCounterpartyPreCheck(routeConfig, astraCreds, purpose) {
|
|
645
681
|
const failures = [];
|
|
646
|
-
if (
|
|
647
|
-
if (!routeConfig.allowedPurposes.
|
|
682
|
+
if (purpose) {
|
|
683
|
+
if (!routeConfig.allowedPurposes || routeConfig.allowedPurposes.length === 0) {
|
|
684
|
+
failures.push({
|
|
685
|
+
field: "purpose",
|
|
686
|
+
requested: purpose,
|
|
687
|
+
limit: [],
|
|
688
|
+
message: `Purpose "${purpose}" not allowed: route declares no allowedPurposes. The endpoint owner must enumerate allowedPurposes on the route config to authorise specific purposes.`
|
|
689
|
+
});
|
|
690
|
+
} else if (!routeConfig.allowedPurposes.includes(purpose)) {
|
|
648
691
|
failures.push({
|
|
649
692
|
field: "purpose",
|
|
650
693
|
requested: purpose,
|
|
@@ -674,9 +717,16 @@ function performCounterpartyPreCheck(routeConfig, astraCreds, purpose) {
|
|
|
674
717
|
});
|
|
675
718
|
}
|
|
676
719
|
}
|
|
677
|
-
if (
|
|
720
|
+
if (astraCreds?.pdlss?.scope?.jurisdiction) {
|
|
678
721
|
const requested = astraCreds.pdlss.scope.jurisdiction;
|
|
679
|
-
if (!routeConfig.allowedJurisdictions.
|
|
722
|
+
if (!routeConfig.allowedJurisdictions || routeConfig.allowedJurisdictions.length === 0) {
|
|
723
|
+
failures.push({
|
|
724
|
+
field: "jurisdiction",
|
|
725
|
+
requested,
|
|
726
|
+
limit: [],
|
|
727
|
+
message: `Jurisdiction "${requested}" not allowed: route declares no allowedJurisdictions. The endpoint owner must enumerate allowedJurisdictions on the route config to authorise specific jurisdictions.`
|
|
728
|
+
});
|
|
729
|
+
} else if (!routeConfig.allowedJurisdictions.includes(requested)) {
|
|
680
730
|
failures.push({
|
|
681
731
|
field: "jurisdiction",
|
|
682
732
|
requested,
|
|
@@ -739,12 +789,12 @@ function findRouteConfig(routes, path, method) {
|
|
|
739
789
|
});
|
|
740
790
|
}
|
|
741
791
|
function defaultOnDenied(result, _req, res) {
|
|
742
|
-
const statusCode = result.
|
|
792
|
+
const statusCode = !result.identityVerified ? 401 : 403;
|
|
743
793
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
744
794
|
res.status(statusCode).json({
|
|
745
795
|
success: false,
|
|
746
796
|
error: {
|
|
747
|
-
code: result.
|
|
797
|
+
code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
|
|
748
798
|
message: result.denialReasons?.[0] || "Access denied",
|
|
749
799
|
accessLevel: result.accessLevel,
|
|
750
800
|
guidance: result.guidance,
|
|
@@ -838,7 +888,8 @@ function createMiddleware(options) {
|
|
|
838
888
|
const preCheckFailures = performCounterpartyPreCheck(routeConfig, astraCreds, purpose);
|
|
839
889
|
if (preCheckFailures.length > 0) {
|
|
840
890
|
const result2 = {
|
|
841
|
-
|
|
891
|
+
identityVerified: false,
|
|
892
|
+
policyAllowed: false,
|
|
842
893
|
accessLevel: "none",
|
|
843
894
|
denialReasons: preCheckFailures.map((f) => f.message),
|
|
844
895
|
guidance: {
|
|
@@ -887,7 +938,7 @@ function createMiddleware(options) {
|
|
|
887
938
|
});
|
|
888
939
|
req.agentVerification = result;
|
|
889
940
|
const sessionId = result.sessionId;
|
|
890
|
-
if (!result.
|
|
941
|
+
if (!result.identityVerified || !result.policyAllowed) {
|
|
891
942
|
if (shouldRecordDecisions && sessionId) {
|
|
892
943
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
893
944
|
});
|
|
@@ -1238,7 +1289,8 @@ function createMiddleware2(options) {
|
|
|
1238
1289
|
const preCheckFailures = performCounterpartyPreCheck(routeConfig, astraCreds, purpose);
|
|
1239
1290
|
if (preCheckFailures.length > 0) {
|
|
1240
1291
|
const preCheckResult = {
|
|
1241
|
-
|
|
1292
|
+
identityVerified: false,
|
|
1293
|
+
policyAllowed: false,
|
|
1242
1294
|
accessLevel: "none",
|
|
1243
1295
|
denialReasons: preCheckFailures.map((f) => f.message),
|
|
1244
1296
|
guidance: {
|
|
@@ -1301,20 +1353,22 @@ function createMiddleware2(options) {
|
|
|
1301
1353
|
agentCardUrl: request.headers.get("x-astrasync-agent-card") || void 0
|
|
1302
1354
|
}
|
|
1303
1355
|
});
|
|
1304
|
-
if (!result.
|
|
1356
|
+
if (!result.identityVerified || !result.policyAllowed || !hasMinimumAccess(result.accessLevel, routeConfig.minAccessLevel)) {
|
|
1305
1357
|
if (pathname.startsWith("/api/")) {
|
|
1306
1358
|
return NextResponse.json(
|
|
1307
1359
|
{
|
|
1308
1360
|
success: false,
|
|
1309
1361
|
error: {
|
|
1310
|
-
|
|
1362
|
+
// Round-18 G4: 401 → identity missing (re-auth); 403 → identity
|
|
1363
|
+
// OK, policy denied (update PDLSS / step up).
|
|
1364
|
+
code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
|
|
1311
1365
|
message: result.denialReasons?.[0] || "Access denied",
|
|
1312
1366
|
accessLevel: result.accessLevel,
|
|
1313
1367
|
required: routeConfig.minAccessLevel,
|
|
1314
1368
|
guidance: result.guidance
|
|
1315
1369
|
}
|
|
1316
1370
|
},
|
|
1317
|
-
{ status: result.
|
|
1371
|
+
{ status: !result.identityVerified ? 401 : 403 }
|
|
1318
1372
|
);
|
|
1319
1373
|
}
|
|
1320
1374
|
if (showCommerceShield) {
|
|
@@ -1329,7 +1383,12 @@ function createMiddleware2(options) {
|
|
|
1329
1383
|
return NextResponse.redirect(new URL("/unauthorized", request.url));
|
|
1330
1384
|
}
|
|
1331
1385
|
const response = NextResponse.next();
|
|
1332
|
-
response.headers.set(
|
|
1386
|
+
response.headers.set(
|
|
1387
|
+
"X-AstraSync-Verified",
|
|
1388
|
+
(result.identityVerified && result.policyAllowed).toString()
|
|
1389
|
+
);
|
|
1390
|
+
response.headers.set("X-AstraSync-Identity-Verified", result.identityVerified.toString());
|
|
1391
|
+
response.headers.set("X-AstraSync-Policy-Allowed", result.policyAllowed.toString());
|
|
1333
1392
|
response.headers.set("X-AstraSync-Access-Level", result.accessLevel);
|
|
1334
1393
|
if (result.agent) {
|
|
1335
1394
|
response.headers.set("X-AstraSync-Agent-Id", result.agent.astraId);
|
|
@@ -1397,7 +1456,11 @@ var VerificationGatewayClient = class {
|
|
|
1397
1456
|
);
|
|
1398
1457
|
}
|
|
1399
1458
|
/**
|
|
1400
|
-
* Quick verification
|
|
1459
|
+
* Quick verification — checks credentials and policy in one call.
|
|
1460
|
+
*
|
|
1461
|
+
* Round-18 G4: return shape mirrors `VerificationResult`'s identity/policy
|
|
1462
|
+
* split. Map to HTTP status the same way: `!identityVerified` → 401,
|
|
1463
|
+
* `identityVerified && !policyAllowed` → 403.
|
|
1401
1464
|
*/
|
|
1402
1465
|
async quickVerify(credentials) {
|
|
1403
1466
|
return this.executeWithRetry(() => quickVerify(this.config, credentials));
|
|
@@ -4043,13 +4106,16 @@ function readSingleHeader(value) {
|
|
|
4043
4106
|
}
|
|
4044
4107
|
function defaultMcpDenied(result, req, res) {
|
|
4045
4108
|
const id = req.body?.id ?? null;
|
|
4046
|
-
const status = result.
|
|
4109
|
+
const status = !result.identityVerified ? 401 : 403;
|
|
4047
4110
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
4048
4111
|
res.status(status).json({
|
|
4049
4112
|
jsonrpc: "2.0",
|
|
4050
4113
|
id,
|
|
4051
4114
|
error: {
|
|
4052
|
-
|
|
4115
|
+
// JSON-RPC error codes:
|
|
4116
|
+
// -32000 → unauthorized (no identity resolved)
|
|
4117
|
+
// -32001 → insufficient access (identity OK, policy denied)
|
|
4118
|
+
code: !result.identityVerified ? -32e3 : -32001,
|
|
4053
4119
|
message: result.denialReasons?.[0] ?? "Access denied",
|
|
4054
4120
|
data: {
|
|
4055
4121
|
accessLevel: result.accessLevel,
|
|
@@ -4183,7 +4249,7 @@ function createMcpMiddleware(options) {
|
|
|
4183
4249
|
req.agentVerification = result;
|
|
4184
4250
|
const sessionId = result.sessionId;
|
|
4185
4251
|
const correlationId = result.correlationId;
|
|
4186
|
-
if (!result.
|
|
4252
|
+
if (!result.identityVerified || !result.policyAllowed) {
|
|
4187
4253
|
if (shouldRecordDecisions && sessionId) {
|
|
4188
4254
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
4189
4255
|
});
|
|
@@ -4600,6 +4666,29 @@ var AstraSync = class {
|
|
|
4600
4666
|
}
|
|
4601
4667
|
};
|
|
4602
4668
|
|
|
4669
|
+
// src/registration/guidance.ts
|
|
4670
|
+
function buildGuidance(params) {
|
|
4671
|
+
const origin = params.origin.replace(/\/+$/, "");
|
|
4672
|
+
const docsPath = params.documentationPath ?? "/docs/agent-access";
|
|
4673
|
+
const message = params.message ?? "AstraSync registration requires credentials.";
|
|
4674
|
+
return {
|
|
4675
|
+
status: "credentials_required",
|
|
4676
|
+
message,
|
|
4677
|
+
guidance: {
|
|
4678
|
+
message: "AstraSync registration requires credentials. Get an account + API key, then call register_agent again.",
|
|
4679
|
+
registrationUrl: `${origin}/register`,
|
|
4680
|
+
documentationUrl: `${origin}${docsPath.startsWith("/") ? docsPath : `/${docsPath}`}`,
|
|
4681
|
+
steps: [
|
|
4682
|
+
"Visit registrationUrl and create an AstraSync account (or log in if you have one).",
|
|
4683
|
+
"Generate an API key from Settings \u2192 API Keys.",
|
|
4684
|
+
"Re-call register_agent with the apiKey populated.",
|
|
4685
|
+
"After registration returns status: pending_approval, the owner approves via email.",
|
|
4686
|
+
"Use poll_registration({ requestId }) to retrieve the astraId once approved."
|
|
4687
|
+
]
|
|
4688
|
+
}
|
|
4689
|
+
};
|
|
4690
|
+
}
|
|
4691
|
+
|
|
4603
4692
|
// src/agent/index.ts
|
|
4604
4693
|
var agent_exports = {};
|
|
4605
4694
|
__export(agent_exports, {
|
|
@@ -4932,6 +5021,7 @@ export {
|
|
|
4932
5021
|
TRUST_LEVEL_RANGES,
|
|
4933
5022
|
VERSION,
|
|
4934
5023
|
agent_exports as agent,
|
|
5024
|
+
buildGuidance,
|
|
4935
5025
|
clearCache,
|
|
4936
5026
|
createMcpMiddleware,
|
|
4937
5027
|
determineAccessLevel,
|