@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstraSyncGateway } from '../gateway/gateway.mjs';
|
|
2
|
-
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-DNK2BgIf.mjs';
|
|
3
|
+
import '../types-L15pYd2c.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* PlatformAdapter Interface
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstraSyncGateway } from '../gateway/gateway.js';
|
|
2
|
-
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-DoWIuzfj.js';
|
|
3
|
+
import '../types-L15pYd2c.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* PlatformAdapter Interface
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
import '../types-
|
|
3
|
-
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-
|
|
2
|
+
import '../types-L15pYd2c.mjs';
|
|
3
|
+
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-4WStX3PV.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
import '../types-
|
|
3
|
-
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-
|
|
2
|
+
import '../types-L15pYd2c.js';
|
|
3
|
+
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-C1ePFB7n.js';
|
package/dist/adapters/express.js
CHANGED
|
@@ -45,7 +45,7 @@ function hasMinimumAccess(actual, required) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// src/version.ts
|
|
48
|
-
var SDK_VERSION = "2.4.
|
|
48
|
+
var SDK_VERSION = "2.4.10";
|
|
49
49
|
|
|
50
50
|
// src/verify.ts
|
|
51
51
|
var DEFAULT_CONFIG = {
|
|
@@ -56,8 +56,10 @@ var DEFAULT_CONFIG = {
|
|
|
56
56
|
// through (`hasMinimumAccess('guidance', 'guidance') === true`).
|
|
57
57
|
defaultAccessLevel: "none",
|
|
58
58
|
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
59
|
-
|
|
60
|
-
//
|
|
59
|
+
// Round-18.5 F4: cacheTtl deliberately unset. When undefined, cacheResult
|
|
60
|
+
// applies the split default (60s autonomous / 300s step-up). When the
|
|
61
|
+
// caller sets cacheTtl explicitly, that value is honoured uniformly.
|
|
62
|
+
// Set cacheTtl: 0 to disable caching entirely.
|
|
61
63
|
debug: false
|
|
62
64
|
};
|
|
63
65
|
var initCheckPerformed = false;
|
|
@@ -84,11 +86,28 @@ async function performInitCheck(apiBaseUrl, debug) {
|
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
var verificationCache = /* @__PURE__ */ new Map();
|
|
87
|
-
function getCacheKey(
|
|
88
|
-
|
|
89
|
+
function getCacheKey(request) {
|
|
90
|
+
const c = request.credentials;
|
|
91
|
+
return [
|
|
92
|
+
c.astraId || "",
|
|
93
|
+
c.apiKey || "",
|
|
94
|
+
c.jwt || "",
|
|
95
|
+
request.purpose || "",
|
|
96
|
+
request.action || "",
|
|
97
|
+
request.resourceType || "",
|
|
98
|
+
request.resource || "",
|
|
99
|
+
request.jurisdiction || "",
|
|
100
|
+
request.transactionValue ?? "",
|
|
101
|
+
request.currency || "",
|
|
102
|
+
request.counterpartyUrl || "",
|
|
103
|
+
request.counterpartyType || "",
|
|
104
|
+
request.isSubAgentRequest ? "1" : "0",
|
|
105
|
+
request.parentAgentId || "",
|
|
106
|
+
request.subAgentDepth ?? ""
|
|
107
|
+
].join("|");
|
|
89
108
|
}
|
|
90
|
-
function getCachedResult(
|
|
91
|
-
const key = getCacheKey(
|
|
109
|
+
function getCachedResult(request) {
|
|
110
|
+
const key = getCacheKey(request);
|
|
92
111
|
const cached = verificationCache.get(key);
|
|
93
112
|
if (cached && cached.expiresAt > Date.now()) {
|
|
94
113
|
return cached.result;
|
|
@@ -98,8 +117,11 @@ function getCachedResult(credentials) {
|
|
|
98
117
|
}
|
|
99
118
|
return null;
|
|
100
119
|
}
|
|
101
|
-
|
|
102
|
-
|
|
120
|
+
var DEFAULT_AUTONOMOUS_TTL_SECONDS = 60;
|
|
121
|
+
var DEFAULT_STEP_UP_TTL_SECONDS = 300;
|
|
122
|
+
function cacheResult(request, result, configuredTtl) {
|
|
123
|
+
const ttlSeconds = configuredTtl && configuredTtl > 0 ? configuredTtl : result.requiresStepUp ? DEFAULT_STEP_UP_TTL_SECONDS : DEFAULT_AUTONOMOUS_TTL_SECONDS;
|
|
124
|
+
const key = getCacheKey(request);
|
|
103
125
|
verificationCache.set(key, {
|
|
104
126
|
result,
|
|
105
127
|
expiresAt: Date.now() + ttlSeconds * 1e3
|
|
@@ -156,12 +178,17 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
156
178
|
]
|
|
157
179
|
};
|
|
158
180
|
return {
|
|
159
|
-
|
|
181
|
+
// Round-18 G4: createGuidanceResponse fires for unverified-agent path or
|
|
182
|
+
// API-error fallback. Identity is not verified (no agent resolved);
|
|
183
|
+
// policy is not evaluated (we never reached the gate).
|
|
184
|
+
identityVerified: false,
|
|
185
|
+
policyAllowed: false,
|
|
160
186
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
161
|
-
// Adapters additionally short-circuit on
|
|
162
|
-
// the gate check, but the access level still has
|
|
163
|
-
// data layer so downstream consumers (SDK adapters
|
|
164
|
-
// custom integrations) inherit the correct
|
|
187
|
+
// Adapters additionally short-circuit on `!identityVerified ||
|
|
188
|
+
// !policyAllowed` before the gate check, but the access level still has
|
|
189
|
+
// to be honest at the data layer so downstream consumers (SDK adapters
|
|
190
|
+
// in other languages, custom integrations) inherit the correct
|
|
191
|
+
// semantics.
|
|
165
192
|
accessLevel: "none",
|
|
166
193
|
guidance,
|
|
167
194
|
denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
|
|
@@ -277,8 +304,8 @@ async function verify(config, request) {
|
|
|
277
304
|
"[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."
|
|
278
305
|
);
|
|
279
306
|
}
|
|
280
|
-
if (mergedConfig.cacheTtl
|
|
281
|
-
const cached = getCachedResult(request
|
|
307
|
+
if (mergedConfig.cacheTtl !== 0) {
|
|
308
|
+
const cached = getCachedResult(request);
|
|
282
309
|
if (cached) {
|
|
283
310
|
if (mergedConfig.debug) {
|
|
284
311
|
console.log("[VerificationGateway] Returning cached result");
|
|
@@ -305,15 +332,17 @@ async function verify(config, request) {
|
|
|
305
332
|
}
|
|
306
333
|
if (!apiResponse.access?.allowed) {
|
|
307
334
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
335
|
+
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true;
|
|
308
336
|
const result2 = {
|
|
309
|
-
|
|
337
|
+
identityVerified: idVerifiedFromBackend,
|
|
338
|
+
policyAllowed: false,
|
|
310
339
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
311
340
|
// Pre-rename this hardcoded `'guidance'`, which conflated with the
|
|
312
341
|
// colocated `guidance: {...}` help-payload object below and let
|
|
313
342
|
// denied requests pass any route gated at `'guidance'` because
|
|
314
343
|
// `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
|
|
315
|
-
// ALSO short-circuit on
|
|
316
|
-
// belt-and-braces.
|
|
344
|
+
// ALSO short-circuit on `!identityVerified || !policyAllowed` before
|
|
345
|
+
// the gate check — belt-and-braces.
|
|
317
346
|
accessLevel: "none",
|
|
318
347
|
denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
|
|
319
348
|
failures: aggregatedFailures,
|
|
@@ -357,7 +386,13 @@ async function verify(config, request) {
|
|
|
357
386
|
const verificationContext = apiResponse.verificationContext;
|
|
358
387
|
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
359
388
|
const result = {
|
|
360
|
-
|
|
389
|
+
// Round-18 G4: backend allowed access. Identity is verified (we resolved
|
|
390
|
+
// the caller to an agent) and policy passed all gates. Read idVerified
|
|
391
|
+
// from verificationContext for symmetry with the deny branch; default true
|
|
392
|
+
// on success path since `access.allowed === true` implies identity was
|
|
393
|
+
// resolvable (anonymous-allow paths flow through createGuidanceResponse).
|
|
394
|
+
identityVerified: apiResponse.verificationContext?.idVerified !== false,
|
|
395
|
+
policyAllowed: true,
|
|
361
396
|
accessLevel,
|
|
362
397
|
agent,
|
|
363
398
|
developer,
|
|
@@ -380,7 +415,7 @@ async function verify(config, request) {
|
|
|
380
415
|
warningHeader: apiResponse.warningHeader
|
|
381
416
|
};
|
|
382
417
|
if (result.recommendation === "deny") {
|
|
383
|
-
result.
|
|
418
|
+
result.policyAllowed = false;
|
|
384
419
|
result.accessLevel = "none";
|
|
385
420
|
result.denialReasons = result.recommendationReasons || [
|
|
386
421
|
"Access denied by AstraSync recommendation"
|
|
@@ -399,8 +434,8 @@ async function verify(config, request) {
|
|
|
399
434
|
}
|
|
400
435
|
result.denialReasons = result.recommendationReasons || ["Step-up verification required"];
|
|
401
436
|
}
|
|
402
|
-
if (mergedConfig.cacheTtl
|
|
403
|
-
cacheResult(request
|
|
437
|
+
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny") {
|
|
438
|
+
cacheResult(request, result, mergedConfig.cacheTtl);
|
|
404
439
|
}
|
|
405
440
|
return result;
|
|
406
441
|
}
|
|
@@ -497,8 +532,15 @@ function extractHttpCredentials(headers) {
|
|
|
497
532
|
// src/pdlss-pre-check.ts
|
|
498
533
|
function performCounterpartyPreCheck(routeConfig, astraCreds, purpose) {
|
|
499
534
|
const failures = [];
|
|
500
|
-
if (
|
|
501
|
-
if (!routeConfig.allowedPurposes.
|
|
535
|
+
if (purpose) {
|
|
536
|
+
if (!routeConfig.allowedPurposes || routeConfig.allowedPurposes.length === 0) {
|
|
537
|
+
failures.push({
|
|
538
|
+
field: "purpose",
|
|
539
|
+
requested: purpose,
|
|
540
|
+
limit: [],
|
|
541
|
+
message: `Purpose "${purpose}" not allowed: route declares no allowedPurposes. The endpoint owner must enumerate allowedPurposes on the route config to authorise specific purposes.`
|
|
542
|
+
});
|
|
543
|
+
} else if (!routeConfig.allowedPurposes.includes(purpose)) {
|
|
502
544
|
failures.push({
|
|
503
545
|
field: "purpose",
|
|
504
546
|
requested: purpose,
|
|
@@ -528,9 +570,16 @@ function performCounterpartyPreCheck(routeConfig, astraCreds, purpose) {
|
|
|
528
570
|
});
|
|
529
571
|
}
|
|
530
572
|
}
|
|
531
|
-
if (
|
|
573
|
+
if (astraCreds?.pdlss?.scope?.jurisdiction) {
|
|
532
574
|
const requested = astraCreds.pdlss.scope.jurisdiction;
|
|
533
|
-
if (!routeConfig.allowedJurisdictions.
|
|
575
|
+
if (!routeConfig.allowedJurisdictions || routeConfig.allowedJurisdictions.length === 0) {
|
|
576
|
+
failures.push({
|
|
577
|
+
field: "jurisdiction",
|
|
578
|
+
requested,
|
|
579
|
+
limit: [],
|
|
580
|
+
message: `Jurisdiction "${requested}" not allowed: route declares no allowedJurisdictions. The endpoint owner must enumerate allowedJurisdictions on the route config to authorise specific jurisdictions.`
|
|
581
|
+
});
|
|
582
|
+
} else if (!routeConfig.allowedJurisdictions.includes(requested)) {
|
|
534
583
|
failures.push({
|
|
535
584
|
field: "jurisdiction",
|
|
536
585
|
requested,
|
|
@@ -593,12 +642,12 @@ function findRouteConfig(routes, path, method) {
|
|
|
593
642
|
});
|
|
594
643
|
}
|
|
595
644
|
function defaultOnDenied(result, _req, res) {
|
|
596
|
-
const statusCode = result.
|
|
645
|
+
const statusCode = !result.identityVerified ? 401 : 403;
|
|
597
646
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
598
647
|
res.status(statusCode).json({
|
|
599
648
|
success: false,
|
|
600
649
|
error: {
|
|
601
|
-
code: result.
|
|
650
|
+
code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
|
|
602
651
|
message: result.denialReasons?.[0] || "Access denied",
|
|
603
652
|
accessLevel: result.accessLevel,
|
|
604
653
|
guidance: result.guidance,
|
|
@@ -692,7 +741,8 @@ function createMiddleware(options) {
|
|
|
692
741
|
const preCheckFailures = performCounterpartyPreCheck(routeConfig, astraCreds, purpose);
|
|
693
742
|
if (preCheckFailures.length > 0) {
|
|
694
743
|
const result2 = {
|
|
695
|
-
|
|
744
|
+
identityVerified: false,
|
|
745
|
+
policyAllowed: false,
|
|
696
746
|
accessLevel: "none",
|
|
697
747
|
denialReasons: preCheckFailures.map((f) => f.message),
|
|
698
748
|
guidance: {
|
|
@@ -741,7 +791,7 @@ function createMiddleware(options) {
|
|
|
741
791
|
});
|
|
742
792
|
req.agentVerification = result;
|
|
743
793
|
const sessionId = result.sessionId;
|
|
744
|
-
if (!result.
|
|
794
|
+
if (!result.identityVerified || !result.policyAllowed) {
|
|
745
795
|
if (shouldRecordDecisions && sessionId) {
|
|
746
796
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
747
797
|
});
|