@astrasyncai/verification-gateway 3.5.0 → 3.6.0
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/README.md +16 -0
- 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 +96 -20
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +96 -20
- 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 +96 -20
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +96 -20
- 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 +101 -20
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +101 -20
- 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 +19 -16
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +19 -16
- 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 +22 -16
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +22 -16
- 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 +22 -16
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +22 -16
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-BH5ADAyb.d.mts → express-BnMO-H3y.d.mts} +1 -1
- package/dist/{express-jUzLIoep.d.ts → express-DQhDzNAt.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 +22 -16
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +22 -16
- 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-aZHAWujT.d.mts → index-BT_aRn-I.d.mts} +1 -1
- package/dist/{index-DlCnmpJH.d.ts → index-D8-dvUFA.d.ts} +1 -1
- package/dist/{index-BR2nmxBU.d.mts → index-WHKq2v17.d.mts} +1 -1
- package/dist/{index-DEixUCu0.d.ts → index-rftma0ln.d.ts} +1 -1
- package/dist/index.d.mts +55 -9
- package/dist/index.d.ts +55 -9
- package/dist/index.js +145 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -30
- 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-LTeoPqMH.d.mts → nextjs-DFKYhxe6.d.mts} +1 -1
- package/dist/{nextjs-DfXOd0Au.d.ts → nextjs-DPj7ZNlq.d.ts} +1 -1
- package/dist/{sdk-LmvyDVpL.d.ts → sdk-CAcHgB5x.d.ts} +1 -1
- package/dist/{sdk-DKhwVL9X.d.mts → sdk-Cy3wAmDt.d.mts} +1 -1
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-C8HyQEaz.d.mts → types-B-ubjHER.d.mts} +1 -1
- package/dist/{types-xofemo0G.d.ts → types-Bgn5gxHQ.d.ts} +1 -1
- package/dist/{types-DrDIouvO.d.mts → types-CKe8O0lR.d.mts} +41 -1
- package/dist/{types-DrDIouvO.d.ts → types-CKe8O0lR.d.ts} +41 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +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 = "3.
|
|
129
|
+
var SDK_VERSION = "3.6.0";
|
|
130
130
|
|
|
131
131
|
// src/well-known.ts
|
|
132
132
|
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
@@ -196,10 +196,10 @@ var DEFAULT_CONFIG = {
|
|
|
196
196
|
// through (`hasMinimumAccess('guidance', 'guidance') === true`).
|
|
197
197
|
defaultAccessLevel: "none",
|
|
198
198
|
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
// Set cacheTtl: 0 to disable caching entirely.
|
|
199
|
+
// cacheTtl deliberately unset. When undefined, cacheResult applies the 60s
|
|
200
|
+
// default; the caller's explicit value is honoured for cacheable results.
|
|
201
|
+
// Denials and step-up escalations are NEVER cached (3.6.0) regardless of
|
|
202
|
+
// cacheTtl. Set cacheTtl: 0 to disable caching entirely.
|
|
203
203
|
debug: false
|
|
204
204
|
};
|
|
205
205
|
var initCheckPerformed = false;
|
|
@@ -286,10 +286,9 @@ function getCachedResult(request, counterpartyId) {
|
|
|
286
286
|
}
|
|
287
287
|
return null;
|
|
288
288
|
}
|
|
289
|
-
var
|
|
290
|
-
var DEFAULT_STEP_UP_TTL_SECONDS = 300;
|
|
289
|
+
var DEFAULT_CACHE_TTL_SECONDS = 60;
|
|
291
290
|
function cacheResult(request, result, configuredTtl, counterpartyId) {
|
|
292
|
-
const ttlSeconds = configuredTtl && configuredTtl > 0 ? configuredTtl :
|
|
291
|
+
const ttlSeconds = configuredTtl && configuredTtl > 0 ? configuredTtl : DEFAULT_CACHE_TTL_SECONDS;
|
|
293
292
|
const key = getCacheKey(request, counterpartyId);
|
|
294
293
|
verificationCache.set(key, {
|
|
295
294
|
result,
|
|
@@ -471,7 +470,7 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
471
470
|
};
|
|
472
471
|
}
|
|
473
472
|
}
|
|
474
|
-
async function verify(config, request) {
|
|
473
|
+
async function verify(config, request, options) {
|
|
475
474
|
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
476
475
|
const urls = mergedConfig.apiBaseUrl ? getCachedWellKnownUrls(mergedConfig.apiBaseUrl) : void 0;
|
|
477
476
|
if (!initCheckPerformed && !mergedConfig.disableInitChecks && mergedConfig.apiBaseUrl) {
|
|
@@ -487,7 +486,7 @@ async function verify(config, request) {
|
|
|
487
486
|
"[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."
|
|
488
487
|
);
|
|
489
488
|
}
|
|
490
|
-
if (mergedConfig.cacheTtl !== 0) {
|
|
489
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
|
|
491
490
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
492
491
|
if (cached) {
|
|
493
492
|
if (mergedConfig.debug) {
|
|
@@ -507,6 +506,8 @@ async function verify(config, request) {
|
|
|
507
506
|
console.log("[VerificationGateway] Calling verify-access API");
|
|
508
507
|
}
|
|
509
508
|
const apiResponse = await callVerifyAccessAPI(mergedConfig, enrichedRequest);
|
|
509
|
+
const rawServerDenialReasons = apiResponse.denialReasons;
|
|
510
|
+
const serverDenialReasons = Array.isArray(rawServerDenialReasons) && rawServerDenialReasons.length > 0 ? rawServerDenialReasons : void 0;
|
|
510
511
|
if (!apiResponse.success) {
|
|
511
512
|
return createGuidanceResponse(mergedConfig, apiResponse.error, {
|
|
512
513
|
source: "api_error",
|
|
@@ -528,7 +529,10 @@ async function verify(config, request) {
|
|
|
528
529
|
// ALSO short-circuit on `!identityVerified || !policyAllowed` before
|
|
529
530
|
// the gate check — belt-and-braces.
|
|
530
531
|
accessLevel: "none",
|
|
531
|
-
|
|
532
|
+
// 3.6.0: the server now emits top-level denialReasons on every deny
|
|
533
|
+
// path — prefer it verbatim; the failure-message reconstruction remains
|
|
534
|
+
// as the fallback for older backends.
|
|
535
|
+
denialReasons: serverDenialReasons ?? (aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"]),
|
|
532
536
|
failures: aggregatedFailures,
|
|
533
537
|
requiresStepUp: apiResponse.access?.requiresStepUp,
|
|
534
538
|
requiresApproval: apiResponse.access?.requiresApproval,
|
|
@@ -605,9 +609,7 @@ async function verify(config, request) {
|
|
|
605
609
|
if (result.recommendation === "deny") {
|
|
606
610
|
result.policyAllowed = false;
|
|
607
611
|
result.accessLevel = "none";
|
|
608
|
-
result.denialReasons = result.recommendationReasons
|
|
609
|
-
"Access denied by AstraSync recommendation"
|
|
610
|
-
];
|
|
612
|
+
result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Access denied by AstraSync recommendation"];
|
|
611
613
|
result.guidance = result.runtimeChallenge ? {
|
|
612
614
|
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|
|
613
615
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
@@ -619,9 +621,10 @@ async function verify(config, request) {
|
|
|
619
621
|
};
|
|
620
622
|
} else if (result.recommendation === "step_up_required") {
|
|
621
623
|
result.requiresStepUp = true;
|
|
622
|
-
result.denialReasons = result.recommendationReasons
|
|
624
|
+
result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Step-up verification required"];
|
|
623
625
|
}
|
|
624
|
-
|
|
626
|
+
const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
|
|
627
|
+
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
|
|
625
628
|
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
626
629
|
}
|
|
627
630
|
return result;
|
|
@@ -680,6 +683,64 @@ async function quickVerify(config, credentials) {
|
|
|
680
683
|
};
|
|
681
684
|
}
|
|
682
685
|
|
|
686
|
+
// src/adapters/stepup-poll.ts
|
|
687
|
+
var DEFAULT_POLL_INTERVAL_MS = 3e3;
|
|
688
|
+
var MIN_POLL_INTERVAL_MS = 250;
|
|
689
|
+
var FALLBACK_MAX_WAIT_MS = 5 * 60 * 1e3;
|
|
690
|
+
var EXPIRY_GRACE_MS = 5e3;
|
|
691
|
+
var POLL_REQUEST_TIMEOUT_MS = 1e4;
|
|
692
|
+
function resolvePollUrl(config, pollUrl) {
|
|
693
|
+
if (pollUrl.startsWith("http")) return pollUrl;
|
|
694
|
+
const origin = (config.apiBaseUrl ?? "").replace(/\/api\/?$/, "");
|
|
695
|
+
return origin + pollUrl;
|
|
696
|
+
}
|
|
697
|
+
async function pollStepUpStatus(config, approval) {
|
|
698
|
+
if (!approval.pollUrl) return null;
|
|
699
|
+
try {
|
|
700
|
+
const res = await fetch(resolvePollUrl(config, approval.pollUrl), {
|
|
701
|
+
method: "GET",
|
|
702
|
+
signal: AbortSignal.timeout(POLL_REQUEST_TIMEOUT_MS)
|
|
703
|
+
});
|
|
704
|
+
if (!res.ok) return null;
|
|
705
|
+
const body = await res.json();
|
|
706
|
+
const data = body?.data;
|
|
707
|
+
const status = data && typeof data === "object" ? data.status : body?.status;
|
|
708
|
+
return typeof status === "string" ? status : null;
|
|
709
|
+
} catch {
|
|
710
|
+
return null;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
function resolveDeadline(config, approval) {
|
|
714
|
+
const now = Date.now();
|
|
715
|
+
const maxWait = config.stepUpMaxWaitMs ?? 0;
|
|
716
|
+
if (maxWait > 0) return now + maxWait;
|
|
717
|
+
if (approval.expiresAt) {
|
|
718
|
+
const expiry = Date.parse(approval.expiresAt);
|
|
719
|
+
if (!Number.isNaN(expiry)) return Math.max(now, expiry) + EXPIRY_GRACE_MS;
|
|
720
|
+
}
|
|
721
|
+
return now + FALLBACK_MAX_WAIT_MS;
|
|
722
|
+
}
|
|
723
|
+
function sleep(ms) {
|
|
724
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
725
|
+
}
|
|
726
|
+
async function awaitStepUpApproval(config, approval) {
|
|
727
|
+
const deadline = resolveDeadline(config, approval);
|
|
728
|
+
const pollInterval = Math.max(
|
|
729
|
+
MIN_POLL_INTERVAL_MS,
|
|
730
|
+
config.stepUpPollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS
|
|
731
|
+
);
|
|
732
|
+
while (Date.now() < deadline) {
|
|
733
|
+
const status = await pollStepUpStatus(config, approval);
|
|
734
|
+
if (status && status !== "pending") {
|
|
735
|
+
return status;
|
|
736
|
+
}
|
|
737
|
+
const remaining = deadline - Date.now();
|
|
738
|
+
if (remaining <= 0) break;
|
|
739
|
+
await sleep(Math.min(pollInterval, remaining));
|
|
740
|
+
}
|
|
741
|
+
return "timeout";
|
|
742
|
+
}
|
|
743
|
+
|
|
683
744
|
// src/adapters/approval-gate.ts
|
|
684
745
|
var APPROVAL_REASON = "Transaction is above the autonomous limit and requires human approval. The agent owner can approve or deny this transaction in the AstraSync dashboard.";
|
|
685
746
|
function requiresHumanApproval(result) {
|
|
@@ -1026,7 +1087,10 @@ function defaultOnDenied(result, _req, res) {
|
|
|
1026
1087
|
// Round-10: aggregated per-dimension detail + correlation handle.
|
|
1027
1088
|
failures: result.failures,
|
|
1028
1089
|
correlationId: result.correlationId,
|
|
1029
|
-
stepUpApproval: result.stepUpApproval
|
|
1090
|
+
stepUpApproval: result.stepUpApproval,
|
|
1091
|
+
// 3.6.0: terminal outcome of an opt-in hold-and-poll wait (denied /
|
|
1092
|
+
// expired / consumed / timeout). Absent when the feature is off.
|
|
1093
|
+
...result.stepUpOutcome && { stepUpOutcome: result.stepUpOutcome }
|
|
1030
1094
|
}
|
|
1031
1095
|
});
|
|
1032
1096
|
}
|
|
@@ -1191,7 +1255,7 @@ function createMiddleware(options) {
|
|
|
1191
1255
|
}
|
|
1192
1256
|
}
|
|
1193
1257
|
}
|
|
1194
|
-
const
|
|
1258
|
+
const verificationRequest = {
|
|
1195
1259
|
credentials,
|
|
1196
1260
|
purpose,
|
|
1197
1261
|
action: pdlssPair.action,
|
|
@@ -1211,9 +1275,21 @@ function createMiddleware(options) {
|
|
|
1211
1275
|
forwardedFor: forwardedForStr,
|
|
1212
1276
|
agentCardUrl
|
|
1213
1277
|
}
|
|
1214
|
-
}
|
|
1278
|
+
};
|
|
1279
|
+
let result = await verify(config, verificationRequest);
|
|
1215
1280
|
req.agentVerification = result;
|
|
1216
|
-
|
|
1281
|
+
let sessionId = result.sessionId;
|
|
1282
|
+
if (config.stepUpMaxWaitMs !== void 0 && result.identityVerified && requiresHumanApproval(result) && result.stepUpApproval?.pollUrl) {
|
|
1283
|
+
const outcome = await awaitStepUpApproval(config, result.stepUpApproval);
|
|
1284
|
+
res.setHeader("X-Astra-Step-Up", outcome);
|
|
1285
|
+
if (outcome === "approved") {
|
|
1286
|
+
result = await verify(config, verificationRequest, { bypassCache: true });
|
|
1287
|
+
req.agentVerification = result;
|
|
1288
|
+
sessionId = result.sessionId;
|
|
1289
|
+
} else {
|
|
1290
|
+
result.stepUpOutcome = outcome;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1217
1293
|
if (!result.identityVerified || !result.policyAllowed) {
|
|
1218
1294
|
if (shouldRecordDecisions && sessionId) {
|
|
1219
1295
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
@@ -1662,7 +1738,7 @@ function createMiddleware2(options) {
|
|
|
1662
1738
|
}
|
|
1663
1739
|
const forwardedFor = request.headers.get("x-forwarded-for") || void 0;
|
|
1664
1740
|
const originalClientIp = forwardedFor?.split(",")[0]?.trim();
|
|
1665
|
-
const
|
|
1741
|
+
const verificationRequest = {
|
|
1666
1742
|
credentials,
|
|
1667
1743
|
purpose,
|
|
1668
1744
|
action: pdlssPair.action,
|
|
@@ -1679,7 +1755,17 @@ function createMiddleware2(options) {
|
|
|
1679
1755
|
forwardedFor,
|
|
1680
1756
|
agentCardUrl: request.headers.get("x-astrasync-agent-card") || void 0
|
|
1681
1757
|
}
|
|
1682
|
-
}
|
|
1758
|
+
};
|
|
1759
|
+
let result = await verify(config, verificationRequest);
|
|
1760
|
+
let stepUpHoldOutcome;
|
|
1761
|
+
if (config.stepUpMaxWaitMs !== void 0 && result.identityVerified && requiresHumanApproval(result) && result.stepUpApproval?.pollUrl) {
|
|
1762
|
+
stepUpHoldOutcome = await awaitStepUpApproval(config, result.stepUpApproval);
|
|
1763
|
+
if (stepUpHoldOutcome === "approved") {
|
|
1764
|
+
result = await verify(config, verificationRequest, { bypassCache: true });
|
|
1765
|
+
} else {
|
|
1766
|
+
result.stepUpOutcome = stepUpHoldOutcome;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1683
1769
|
const approvalRequired = result.identityVerified && result.policyAllowed && requiresHumanApproval(result);
|
|
1684
1770
|
if (approvalRequired) annotateApprovalRequired(result);
|
|
1685
1771
|
if (!result.identityVerified || !result.policyAllowed || approvalRequired) {
|
|
@@ -1694,10 +1780,17 @@ function createMiddleware2(options) {
|
|
|
1694
1780
|
message: result.denialReasons?.[0] || "Access denied",
|
|
1695
1781
|
guidance: result.guidance,
|
|
1696
1782
|
failures: result.failures,
|
|
1697
|
-
stepUpApproval: result.stepUpApproval
|
|
1783
|
+
stepUpApproval: result.stepUpApproval,
|
|
1784
|
+
// 3.6.0: terminal outcome of an opt-in hold-and-poll wait.
|
|
1785
|
+
...result.stepUpOutcome && { stepUpOutcome: result.stepUpOutcome }
|
|
1698
1786
|
}
|
|
1699
1787
|
},
|
|
1700
|
-
{
|
|
1788
|
+
{
|
|
1789
|
+
status: !result.identityVerified ? 401 : 403,
|
|
1790
|
+
...stepUpHoldOutcome && {
|
|
1791
|
+
headers: { "X-Astra-Step-Up": stepUpHoldOutcome }
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1701
1794
|
);
|
|
1702
1795
|
}
|
|
1703
1796
|
if (showCommerceShield) {
|
|
@@ -1716,6 +1809,9 @@ function createMiddleware2(options) {
|
|
|
1716
1809
|
"X-AstraSync-Verified",
|
|
1717
1810
|
(result.identityVerified && result.policyAllowed).toString()
|
|
1718
1811
|
);
|
|
1812
|
+
if (stepUpHoldOutcome) {
|
|
1813
|
+
response.headers.set("X-Astra-Step-Up", stepUpHoldOutcome);
|
|
1814
|
+
}
|
|
1719
1815
|
response.headers.set("X-AstraSync-Identity-Verified", result.identityVerified.toString());
|
|
1720
1816
|
response.headers.set("X-AstraSync-Policy-Allowed", result.policyAllowed.toString());
|
|
1721
1817
|
response.headers.set("X-AstraSync-Access-Level", result.accessLevel);
|
|
@@ -4616,7 +4712,10 @@ function defaultMcpDenied(result, req, res) {
|
|
|
4616
4712
|
// Round-10: aggregated per-dimension detail + correlation handle.
|
|
4617
4713
|
failures: result.failures,
|
|
4618
4714
|
correlationId: result.correlationId,
|
|
4619
|
-
stepUpApproval: result.stepUpApproval
|
|
4715
|
+
stepUpApproval: result.stepUpApproval,
|
|
4716
|
+
// 3.6.0: terminal outcome of an opt-in hold-and-poll wait (denied /
|
|
4717
|
+
// expired / consumed / timeout). Absent when the feature is off.
|
|
4718
|
+
...result.stepUpOutcome && { stepUpOutcome: result.stepUpOutcome }
|
|
4620
4719
|
}
|
|
4621
4720
|
}
|
|
4622
4721
|
});
|
|
@@ -4757,7 +4856,7 @@ function createMcpMiddleware(options) {
|
|
|
4757
4856
|
}
|
|
4758
4857
|
const counterpartyUrl = config.counterpartyUrl || `${req.protocol}://${req.get("host")}${req.path}`;
|
|
4759
4858
|
const shouldRecordDecisions = recordDecisions !== false;
|
|
4760
|
-
const
|
|
4859
|
+
const verificationRequest = {
|
|
4761
4860
|
credentials,
|
|
4762
4861
|
purpose: pdlss.purpose,
|
|
4763
4862
|
action: pdlss.action,
|
|
@@ -4775,9 +4874,21 @@ function createMcpMiddleware(options) {
|
|
|
4775
4874
|
userAgent: req.headers["user-agent"],
|
|
4776
4875
|
host: req.headers.host
|
|
4777
4876
|
}
|
|
4778
|
-
}
|
|
4877
|
+
};
|
|
4878
|
+
let result = await verify(config, verificationRequest);
|
|
4779
4879
|
req.agentVerification = result;
|
|
4780
|
-
|
|
4880
|
+
let sessionId = result.sessionId;
|
|
4881
|
+
if (config.stepUpMaxWaitMs !== void 0 && result.identityVerified && requiresHumanApproval(result) && result.stepUpApproval?.pollUrl) {
|
|
4882
|
+
const outcome = await awaitStepUpApproval(config, result.stepUpApproval);
|
|
4883
|
+
res.setHeader("X-Astra-Step-Up", outcome);
|
|
4884
|
+
if (outcome === "approved") {
|
|
4885
|
+
result = await verify(config, verificationRequest, { bypassCache: true });
|
|
4886
|
+
req.agentVerification = result;
|
|
4887
|
+
sessionId = result.sessionId;
|
|
4888
|
+
} else {
|
|
4889
|
+
result.stepUpOutcome = outcome;
|
|
4890
|
+
}
|
|
4891
|
+
}
|
|
4781
4892
|
if (!result.identityVerified || !result.policyAllowed) {
|
|
4782
4893
|
if (shouldRecordDecisions && sessionId) {
|
|
4783
4894
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
@@ -4931,7 +5042,7 @@ var RegistrationTimeoutError = class extends AstraSyncError {
|
|
|
4931
5042
|
|
|
4932
5043
|
// src/registration/api.ts
|
|
4933
5044
|
var DEFAULT_BASE_URL = "https://astrasync.ai";
|
|
4934
|
-
var
|
|
5045
|
+
var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
4935
5046
|
var AstraSync = class {
|
|
4936
5047
|
constructor(config = {}) {
|
|
4937
5048
|
let raw = (config.baseUrl || process.env.ASTRASYNC_API_URL || DEFAULT_BASE_URL).replace(
|
|
@@ -5093,7 +5204,7 @@ var AstraSync = class {
|
|
|
5093
5204
|
if (result.state === "expired") {
|
|
5094
5205
|
throw new RegistrationExpiredError(requestId);
|
|
5095
5206
|
}
|
|
5096
|
-
await
|
|
5207
|
+
await sleep2(pollIntervalMs);
|
|
5097
5208
|
}
|
|
5098
5209
|
throw new RegistrationTimeoutError(requestId);
|
|
5099
5210
|
}
|
|
@@ -5562,6 +5673,7 @@ export {
|
|
|
5562
5673
|
VERSION,
|
|
5563
5674
|
agent_exports as agent,
|
|
5564
5675
|
authorizeSettlement,
|
|
5676
|
+
awaitStepUpApproval,
|
|
5565
5677
|
buildGuidance,
|
|
5566
5678
|
clearCache,
|
|
5567
5679
|
createMcpMiddleware,
|
|
@@ -5577,6 +5689,7 @@ export {
|
|
|
5577
5689
|
hasCredentials,
|
|
5578
5690
|
hasMinimumAccess,
|
|
5579
5691
|
nextjs_exports as nextjs,
|
|
5692
|
+
pollStepUpStatus,
|
|
5580
5693
|
prefetchWellKnown,
|
|
5581
5694
|
quickVerify,
|
|
5582
5695
|
recordDecision2 as recordDecision,
|