@astrasyncai/verification-gateway 2.3.4 → 2.3.7
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 +59 -21
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +58 -18
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +245 -0
- package/dist/adapters/mcp.d.ts +245 -0
- package/dist/adapters/mcp.js +589 -0
- package/dist/adapters/mcp.js.map +1 -0
- package/dist/adapters/mcp.mjs +555 -0
- package/dist/adapters/mcp.mjs.map +1 -0
- package/dist/adapters/nextjs.d.mts +2 -2
- package/dist/adapters/nextjs.d.ts +2 -2
- package/dist/adapters/nextjs.js +57 -3
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +57 -3
- 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 +3 -1
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +3 -1
- 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 +9 -1
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +9 -1
- 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 +9 -1
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +9 -1
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-DtvJ6BGt.d.mts → express-D9oRsseg.d.mts} +17 -14
- package/dist/{express-CraCA8_t.d.ts → express-DMSIl20m.d.ts} +17 -14
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +9 -1
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +9 -1
- 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-BZ85CeEr.d.mts → index-Bn_7eGjb.d.mts} +1 -1
- package/dist/{index--KzVRa32.d.ts → index-BtU9yFda.d.ts} +1 -1
- package/dist/{index-BzAFmemy.d.ts → index-EwUWXC5T.d.ts} +1 -1
- package/dist/{index-SEgnWzkf.d.mts → index-YNPs800Z.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +93 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -20
- 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-B8o9C0t6.d.ts → nextjs-B5ZBpHra.d.ts} +8 -2
- package/dist/{nextjs-DZHAn9j-.d.mts → nextjs-BLtjRbc-.d.mts} +8 -2
- package/dist/{sdk-CRSUFQH2.d.mts → sdk-BhkxvqnK.d.mts} +1 -1
- package/dist/{sdk-BQ3olp3v.d.ts → sdk-YmE3RG8n.d.ts} +1 -1
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-osMd_dpT.d.ts → types-BecRpozv.d.ts} +1 -1
- package/dist/{types-JMgPake9.d.mts → types-Bxqj1sKY.d.mts} +48 -6
- package/dist/{types-JMgPake9.d.ts → types-Bxqj1sKY.d.ts} +48 -6
- package/dist/{types-aN1UHhyy.d.mts → types-DxY5zt4z.d.mts} +1 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/package.json +6 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstraSyncGateway } from '../gateway/gateway.mjs';
|
|
2
|
-
import { V as VerificationDecision, P as PDLSSContext } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { V as VerificationDecision, P as PDLSSContext } from '../types-DxY5zt4z.mjs';
|
|
3
|
+
import '../types-Bxqj1sKY.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Git Trigger — Enterprise git push / PR verification
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstraSyncGateway } from '../gateway/gateway.js';
|
|
2
|
-
import { V as VerificationDecision, P as PDLSSContext } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { V as VerificationDecision, P as PDLSSContext } from '../types-BecRpozv.js';
|
|
3
|
+
import '../types-Bxqj1sKY.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Git Trigger — Enterprise git push / PR verification
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, c as VerificationRequest, V as VerificationResult } from './types-
|
|
2
|
-
export { A as AstraSyncCredentials, d as CommerceShieldProps, C as CounterpartyType, e as EnhancedVerificationResult, E as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, i as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-
|
|
3
|
-
export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, c as getCapabilities, e as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-
|
|
4
|
-
export { e as express } from './express-
|
|
5
|
-
export { n as nextjs } from './nextjs-
|
|
6
|
-
export { i as transport } from './index-
|
|
7
|
-
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-
|
|
1
|
+
import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, c as VerificationRequest, V as VerificationResult } from './types-Bxqj1sKY.mjs';
|
|
2
|
+
export { A as AstraSyncCredentials, d as CommerceShieldProps, C as CounterpartyType, e as EnhancedVerificationResult, E as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, i as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-Bxqj1sKY.mjs';
|
|
3
|
+
export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, c as getCapabilities, e as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-BhkxvqnK.mjs';
|
|
4
|
+
export { e as express } from './express-D9oRsseg.mjs';
|
|
5
|
+
export { n as nextjs } from './nextjs-BLtjRbc-.mjs';
|
|
6
|
+
export { i as transport } from './index-YNPs800Z.mjs';
|
|
7
|
+
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-Bn_7eGjb.mjs';
|
|
8
8
|
import 'express';
|
|
9
9
|
import 'next/server';
|
|
10
10
|
import 'jose';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, c as VerificationRequest, V as VerificationResult } from './types-
|
|
2
|
-
export { A as AstraSyncCredentials, d as CommerceShieldProps, C as CounterpartyType, e as EnhancedVerificationResult, E as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, i as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-
|
|
3
|
-
export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, c as getCapabilities, e as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-
|
|
4
|
-
export { e as express } from './express-
|
|
5
|
-
export { n as nextjs } from './nextjs-
|
|
6
|
-
export { i as transport } from './index
|
|
7
|
-
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-
|
|
1
|
+
import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, c as VerificationRequest, V as VerificationResult } from './types-Bxqj1sKY.js';
|
|
2
|
+
export { A as AstraSyncCredentials, d as CommerceShieldProps, C as CounterpartyType, e as EnhancedVerificationResult, E as ExpressMiddlewareOptions, f as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, g as ProtocolTransport, R as RouteAccessConfig, h as RuntimeChallengeResult, S as SDKOptions, T as TokenGuidance, i as TrustLevel, j as VerifiedAgent, k as VerifiedDeveloper, l as VerifiedOrganization } from './types-Bxqj1sKY.js';
|
|
3
|
+
export { A as ACCESS_LEVEL_DESCRIPTIONS, a as ACCESS_LEVEL_HIERARCHY, b as AccessCapabilities, D as DEFAULT_TRUST_THRESHOLDS, T as TRUST_LEVEL_RANGES, d as determineAccessLevel, g as getAccessLevelForScore, c as getCapabilities, e as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-YmE3RG8n.js';
|
|
4
|
+
export { e as express } from './express-DMSIl20m.js';
|
|
5
|
+
export { n as nextjs } from './nextjs-B5ZBpHra.js';
|
|
6
|
+
export { i as transport } from './index-BtU9yFda.js';
|
|
7
|
+
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-EwUWXC5T.js';
|
|
8
8
|
import 'express';
|
|
9
9
|
import 'next/server';
|
|
10
10
|
import 'jose';
|
package/dist/index.js
CHANGED
|
@@ -386,10 +386,12 @@ async function verify(config, request) {
|
|
|
386
386
|
return createGuidanceResponse(mergedConfig, apiResponse.error);
|
|
387
387
|
}
|
|
388
388
|
if (!apiResponse.access?.allowed) {
|
|
389
|
+
const aggregatedFailures = apiResponse.access?.failures;
|
|
389
390
|
const result2 = {
|
|
390
391
|
verified: false,
|
|
391
392
|
accessLevel: "guidance",
|
|
392
|
-
denialReasons: apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
|
|
393
|
+
denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
|
|
394
|
+
failures: aggregatedFailures,
|
|
393
395
|
requiresStepUp: apiResponse.access?.requiresStepUp,
|
|
394
396
|
requiresApproval: apiResponse.access?.requiresApproval,
|
|
395
397
|
guidance: {
|
|
@@ -483,6 +485,25 @@ async function recordDecision(config, sessionId, decision, reason) {
|
|
|
483
485
|
}).catch(() => {
|
|
484
486
|
});
|
|
485
487
|
}
|
|
488
|
+
async function fetchRoutes(config, counterpartyId) {
|
|
489
|
+
if (!counterpartyId) return null;
|
|
490
|
+
const headers = { "Content-Type": "application/json" };
|
|
491
|
+
if (config.apiKey) {
|
|
492
|
+
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
493
|
+
headers["X-API-Key"] = config.apiKey;
|
|
494
|
+
}
|
|
495
|
+
try {
|
|
496
|
+
const response = await fetch(
|
|
497
|
+
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes`,
|
|
498
|
+
{ method: "GET", headers }
|
|
499
|
+
);
|
|
500
|
+
if (!response.ok) return null;
|
|
501
|
+
const body = await response.json();
|
|
502
|
+
return body.data?.routes ?? [];
|
|
503
|
+
} catch {
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
486
507
|
async function reportCounterpartyPreCheckFailure(config, data) {
|
|
487
508
|
const apiBaseUrl = config.apiBaseUrl || DEFAULT_CONFIG.apiBaseUrl;
|
|
488
509
|
await fetch(`${apiBaseUrl}/verification-activity/counterparty-pre-check-failure`, {
|
|
@@ -508,9 +529,7 @@ async function quickVerify(config, credentials) {
|
|
|
508
529
|
var express_exports = {};
|
|
509
530
|
__export(express_exports, {
|
|
510
531
|
createMiddleware: () => createMiddleware,
|
|
511
|
-
extractAstraSyncCredentials: () => extractAstraSyncCredentials
|
|
512
|
-
requireAccess: () => requireAccess,
|
|
513
|
-
verifyOnly: () => verifyOnly
|
|
532
|
+
extractAstraSyncCredentials: () => extractAstraSyncCredentials
|
|
514
533
|
});
|
|
515
534
|
|
|
516
535
|
// src/transport/http.ts
|
|
@@ -683,24 +702,57 @@ function defaultOnDenied(result, _req, res) {
|
|
|
683
702
|
}
|
|
684
703
|
});
|
|
685
704
|
}
|
|
705
|
+
var DEFAULT_ROUTES_REFRESH_MS = 5 * 60 * 1e3;
|
|
686
706
|
function createMiddleware(options) {
|
|
687
707
|
const {
|
|
688
|
-
routes = [],
|
|
689
708
|
extractCredentials: customExtractCredentials,
|
|
690
709
|
extractPurpose: customExtractPurpose,
|
|
691
710
|
skipPaths = [],
|
|
692
711
|
onDenied = defaultOnDenied,
|
|
693
712
|
recordDecisions,
|
|
694
713
|
enableRuntimeChallenge = true,
|
|
714
|
+
routesRefreshMs = DEFAULT_ROUTES_REFRESH_MS,
|
|
695
715
|
...config
|
|
696
716
|
} = options;
|
|
717
|
+
let cachedRoutes = [];
|
|
718
|
+
let lastFetchAt = 0;
|
|
719
|
+
let refreshing = null;
|
|
720
|
+
let warnedNoCounterparty = false;
|
|
721
|
+
async function refreshRoutes() {
|
|
722
|
+
if (!config.counterpartyId) {
|
|
723
|
+
if (!warnedNoCounterparty) {
|
|
724
|
+
console.warn(
|
|
725
|
+
"[VerificationGateway] No counterpartyId configured \u2014 falling through (allow all). Per-route policy lives in the AstraSync dashboard now; register the endpoint and set counterpartyId in your middleware config to enforce policy."
|
|
726
|
+
);
|
|
727
|
+
warnedNoCounterparty = true;
|
|
728
|
+
}
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
const fetched = await fetchRoutes(config, config.counterpartyId);
|
|
732
|
+
if (fetched) {
|
|
733
|
+
cachedRoutes = fetched;
|
|
734
|
+
lastFetchAt = Date.now();
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
refreshing = refreshRoutes().finally(() => {
|
|
738
|
+
refreshing = null;
|
|
739
|
+
});
|
|
697
740
|
return async (req, res, next) => {
|
|
698
741
|
try {
|
|
699
742
|
const shouldSkip = skipPaths.some((pattern) => matchRoute(pattern, req.path));
|
|
700
743
|
if (shouldSkip) {
|
|
701
744
|
return next();
|
|
702
745
|
}
|
|
703
|
-
|
|
746
|
+
if (refreshing) {
|
|
747
|
+
await refreshing.catch(() => {
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
if (config.counterpartyId && Date.now() - lastFetchAt > routesRefreshMs) {
|
|
751
|
+
refreshing = refreshRoutes().finally(() => {
|
|
752
|
+
refreshing = null;
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
const routeConfig = findRouteConfig(cachedRoutes, req.path, req.method);
|
|
704
756
|
if (!routeConfig) {
|
|
705
757
|
return next();
|
|
706
758
|
}
|
|
@@ -795,18 +847,6 @@ function createMiddleware(options) {
|
|
|
795
847
|
}
|
|
796
848
|
};
|
|
797
849
|
}
|
|
798
|
-
function requireAccess(minAccessLevel, options) {
|
|
799
|
-
return createMiddleware({
|
|
800
|
-
...options,
|
|
801
|
-
routes: [{ pattern: "*", method: "*", minAccessLevel }]
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
function verifyOnly(options) {
|
|
805
|
-
return createMiddleware({
|
|
806
|
-
...options,
|
|
807
|
-
routes: [{ pattern: "*", method: "*", minAccessLevel: "none" }]
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
850
|
|
|
811
851
|
// src/adapters/nextjs.ts
|
|
812
852
|
var nextjs_exports = {};
|
|
@@ -1030,14 +1070,38 @@ function generateCommerceShieldHtml(result, options) {
|
|
|
1030
1070
|
</html>
|
|
1031
1071
|
`.trim();
|
|
1032
1072
|
}
|
|
1073
|
+
var DEFAULT_ROUTES_REFRESH_MS2 = 5 * 60 * 1e3;
|
|
1033
1074
|
function createMiddleware2(options) {
|
|
1034
1075
|
const {
|
|
1035
|
-
routes = [],
|
|
1036
1076
|
skipPaths = [],
|
|
1037
1077
|
showCommerceShield = true,
|
|
1038
1078
|
enableRuntimeChallenge = true,
|
|
1079
|
+
routesRefreshMs = DEFAULT_ROUTES_REFRESH_MS2,
|
|
1039
1080
|
...config
|
|
1040
1081
|
} = options;
|
|
1082
|
+
let cachedRoutes = [];
|
|
1083
|
+
let lastFetchAt = 0;
|
|
1084
|
+
let refreshing = null;
|
|
1085
|
+
let warnedNoCounterparty = false;
|
|
1086
|
+
async function refreshRoutes() {
|
|
1087
|
+
if (!config.counterpartyId) {
|
|
1088
|
+
if (!warnedNoCounterparty) {
|
|
1089
|
+
console.warn(
|
|
1090
|
+
"[VerificationGateway/Next.js] No counterpartyId configured \u2014 falling through (allow all). Per-route policy lives in the AstraSync dashboard now; register the endpoint and set counterpartyId in your middleware config to enforce policy."
|
|
1091
|
+
);
|
|
1092
|
+
warnedNoCounterparty = true;
|
|
1093
|
+
}
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
const fetched = await fetchRoutes(config, config.counterpartyId);
|
|
1097
|
+
if (fetched) {
|
|
1098
|
+
cachedRoutes = fetched;
|
|
1099
|
+
lastFetchAt = Date.now();
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
refreshing = refreshRoutes().finally(() => {
|
|
1103
|
+
refreshing = null;
|
|
1104
|
+
});
|
|
1041
1105
|
return async function middleware(request) {
|
|
1042
1106
|
const { NextResponse } = await import("next/server");
|
|
1043
1107
|
const pathname = request.nextUrl.pathname;
|
|
@@ -1045,7 +1109,16 @@ function createMiddleware2(options) {
|
|
|
1045
1109
|
if (shouldSkip) {
|
|
1046
1110
|
return NextResponse.next();
|
|
1047
1111
|
}
|
|
1048
|
-
|
|
1112
|
+
if (refreshing) {
|
|
1113
|
+
await refreshing.catch(() => {
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
if (config.counterpartyId && Date.now() - lastFetchAt > routesRefreshMs) {
|
|
1117
|
+
refreshing = refreshRoutes().finally(() => {
|
|
1118
|
+
refreshing = null;
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
const routeConfig = findRouteConfig2(cachedRoutes, pathname, request.method);
|
|
1049
1122
|
if (!routeConfig) {
|
|
1050
1123
|
return NextResponse.next();
|
|
1051
1124
|
}
|