@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
|
@@ -3272,7 +3272,7 @@ function getTrustLevel(score) {
|
|
|
3272
3272
|
}
|
|
3273
3273
|
|
|
3274
3274
|
// src/version.ts
|
|
3275
|
-
var SDK_VERSION = "2.4.
|
|
3275
|
+
var SDK_VERSION = "2.4.10";
|
|
3276
3276
|
|
|
3277
3277
|
// src/verify.ts
|
|
3278
3278
|
var DEFAULT_CONFIG = {
|
|
@@ -3283,8 +3283,10 @@ var DEFAULT_CONFIG = {
|
|
|
3283
3283
|
// through (`hasMinimumAccess('guidance', 'guidance') === true`).
|
|
3284
3284
|
defaultAccessLevel: "none",
|
|
3285
3285
|
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
3286
|
-
|
|
3287
|
-
//
|
|
3286
|
+
// Round-18.5 F4: cacheTtl deliberately unset. When undefined, cacheResult
|
|
3287
|
+
// applies the split default (60s autonomous / 300s step-up). When the
|
|
3288
|
+
// caller sets cacheTtl explicitly, that value is honoured uniformly.
|
|
3289
|
+
// Set cacheTtl: 0 to disable caching entirely.
|
|
3288
3290
|
debug: false
|
|
3289
3291
|
};
|
|
3290
3292
|
var initCheckPerformed = false;
|
|
@@ -3311,11 +3313,28 @@ async function performInitCheck(apiBaseUrl, debug) {
|
|
|
3311
3313
|
}
|
|
3312
3314
|
}
|
|
3313
3315
|
var verificationCache = /* @__PURE__ */ new Map();
|
|
3314
|
-
function getCacheKey(
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3316
|
+
function getCacheKey(request) {
|
|
3317
|
+
const c = request.credentials;
|
|
3318
|
+
return [
|
|
3319
|
+
c.astraId || "",
|
|
3320
|
+
c.apiKey || "",
|
|
3321
|
+
c.jwt || "",
|
|
3322
|
+
request.purpose || "",
|
|
3323
|
+
request.action || "",
|
|
3324
|
+
request.resourceType || "",
|
|
3325
|
+
request.resource || "",
|
|
3326
|
+
request.jurisdiction || "",
|
|
3327
|
+
request.transactionValue ?? "",
|
|
3328
|
+
request.currency || "",
|
|
3329
|
+
request.counterpartyUrl || "",
|
|
3330
|
+
request.counterpartyType || "",
|
|
3331
|
+
request.isSubAgentRequest ? "1" : "0",
|
|
3332
|
+
request.parentAgentId || "",
|
|
3333
|
+
request.subAgentDepth ?? ""
|
|
3334
|
+
].join("|");
|
|
3335
|
+
}
|
|
3336
|
+
function getCachedResult(request) {
|
|
3337
|
+
const key = getCacheKey(request);
|
|
3319
3338
|
const cached = verificationCache.get(key);
|
|
3320
3339
|
if (cached && cached.expiresAt > Date.now()) {
|
|
3321
3340
|
return cached.result;
|
|
@@ -3325,8 +3344,11 @@ function getCachedResult(credentials) {
|
|
|
3325
3344
|
}
|
|
3326
3345
|
return null;
|
|
3327
3346
|
}
|
|
3328
|
-
|
|
3329
|
-
|
|
3347
|
+
var DEFAULT_AUTONOMOUS_TTL_SECONDS = 60;
|
|
3348
|
+
var DEFAULT_STEP_UP_TTL_SECONDS = 300;
|
|
3349
|
+
function cacheResult(request, result, configuredTtl) {
|
|
3350
|
+
const ttlSeconds = configuredTtl && configuredTtl > 0 ? configuredTtl : result.requiresStepUp ? DEFAULT_STEP_UP_TTL_SECONDS : DEFAULT_AUTONOMOUS_TTL_SECONDS;
|
|
3351
|
+
const key = getCacheKey(request);
|
|
3330
3352
|
verificationCache.set(key, {
|
|
3331
3353
|
result,
|
|
3332
3354
|
expiresAt: Date.now() + ttlSeconds * 1e3
|
|
@@ -3355,12 +3377,17 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
3355
3377
|
]
|
|
3356
3378
|
};
|
|
3357
3379
|
return {
|
|
3358
|
-
|
|
3380
|
+
// Round-18 G4: createGuidanceResponse fires for unverified-agent path or
|
|
3381
|
+
// API-error fallback. Identity is not verified (no agent resolved);
|
|
3382
|
+
// policy is not evaluated (we never reached the gate).
|
|
3383
|
+
identityVerified: false,
|
|
3384
|
+
policyAllowed: false,
|
|
3359
3385
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
3360
|
-
// Adapters additionally short-circuit on
|
|
3361
|
-
// the gate check, but the access level still has
|
|
3362
|
-
// data layer so downstream consumers (SDK adapters
|
|
3363
|
-
// custom integrations) inherit the correct
|
|
3386
|
+
// Adapters additionally short-circuit on `!identityVerified ||
|
|
3387
|
+
// !policyAllowed` before the gate check, but the access level still has
|
|
3388
|
+
// to be honest at the data layer so downstream consumers (SDK adapters
|
|
3389
|
+
// in other languages, custom integrations) inherit the correct
|
|
3390
|
+
// semantics.
|
|
3364
3391
|
accessLevel: "none",
|
|
3365
3392
|
guidance,
|
|
3366
3393
|
denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
|
|
@@ -3476,8 +3503,8 @@ async function verify(config, request) {
|
|
|
3476
3503
|
"[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."
|
|
3477
3504
|
);
|
|
3478
3505
|
}
|
|
3479
|
-
if (mergedConfig.cacheTtl
|
|
3480
|
-
const cached = getCachedResult(request
|
|
3506
|
+
if (mergedConfig.cacheTtl !== 0) {
|
|
3507
|
+
const cached = getCachedResult(request);
|
|
3481
3508
|
if (cached) {
|
|
3482
3509
|
if (mergedConfig.debug) {
|
|
3483
3510
|
console.log("[VerificationGateway] Returning cached result");
|
|
@@ -3504,15 +3531,17 @@ async function verify(config, request) {
|
|
|
3504
3531
|
}
|
|
3505
3532
|
if (!apiResponse.access?.allowed) {
|
|
3506
3533
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
3534
|
+
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true;
|
|
3507
3535
|
const result2 = {
|
|
3508
|
-
|
|
3536
|
+
identityVerified: idVerifiedFromBackend,
|
|
3537
|
+
policyAllowed: false,
|
|
3509
3538
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
3510
3539
|
// Pre-rename this hardcoded `'guidance'`, which conflated with the
|
|
3511
3540
|
// colocated `guidance: {...}` help-payload object below and let
|
|
3512
3541
|
// denied requests pass any route gated at `'guidance'` because
|
|
3513
3542
|
// `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
|
|
3514
|
-
// ALSO short-circuit on
|
|
3515
|
-
// belt-and-braces.
|
|
3543
|
+
// ALSO short-circuit on `!identityVerified || !policyAllowed` before
|
|
3544
|
+
// the gate check — belt-and-braces.
|
|
3516
3545
|
accessLevel: "none",
|
|
3517
3546
|
denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
|
|
3518
3547
|
failures: aggregatedFailures,
|
|
@@ -3556,7 +3585,13 @@ async function verify(config, request) {
|
|
|
3556
3585
|
const verificationContext = apiResponse.verificationContext;
|
|
3557
3586
|
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
3558
3587
|
const result = {
|
|
3559
|
-
|
|
3588
|
+
// Round-18 G4: backend allowed access. Identity is verified (we resolved
|
|
3589
|
+
// the caller to an agent) and policy passed all gates. Read idVerified
|
|
3590
|
+
// from verificationContext for symmetry with the deny branch; default true
|
|
3591
|
+
// on success path since `access.allowed === true` implies identity was
|
|
3592
|
+
// resolvable (anonymous-allow paths flow through createGuidanceResponse).
|
|
3593
|
+
identityVerified: apiResponse.verificationContext?.idVerified !== false,
|
|
3594
|
+
policyAllowed: true,
|
|
3560
3595
|
accessLevel,
|
|
3561
3596
|
agent,
|
|
3562
3597
|
developer,
|
|
@@ -3579,7 +3614,7 @@ async function verify(config, request) {
|
|
|
3579
3614
|
warningHeader: apiResponse.warningHeader
|
|
3580
3615
|
};
|
|
3581
3616
|
if (result.recommendation === "deny") {
|
|
3582
|
-
result.
|
|
3617
|
+
result.policyAllowed = false;
|
|
3583
3618
|
result.accessLevel = "none";
|
|
3584
3619
|
result.denialReasons = result.recommendationReasons || [
|
|
3585
3620
|
"Access denied by AstraSync recommendation"
|
|
@@ -3598,8 +3633,8 @@ async function verify(config, request) {
|
|
|
3598
3633
|
}
|
|
3599
3634
|
result.denialReasons = result.recommendationReasons || ["Step-up verification required"];
|
|
3600
3635
|
}
|
|
3601
|
-
if (mergedConfig.cacheTtl
|
|
3602
|
-
cacheResult(request
|
|
3636
|
+
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny") {
|
|
3637
|
+
cacheResult(request, result, mergedConfig.cacheTtl);
|
|
3603
3638
|
}
|
|
3604
3639
|
return result;
|
|
3605
3640
|
}
|
|
@@ -3674,7 +3709,7 @@ function toVerificationRequest(context, astraId) {
|
|
|
3674
3709
|
};
|
|
3675
3710
|
}
|
|
3676
3711
|
function toDecision(result) {
|
|
3677
|
-
if (result.
|
|
3712
|
+
if (result.identityVerified && result.policyAllowed) {
|
|
3678
3713
|
return {
|
|
3679
3714
|
recommendation: "ALLOW",
|
|
3680
3715
|
reason: `Verified with access level: ${result.accessLevel}`,
|