@astrasyncai/verification-gateway 4.2.1 → 4.3.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 +45 -21
- 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 +56 -4
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +56 -4
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +38 -30
- package/dist/adapters/mcp.d.ts +38 -30
- package/dist/adapters/mcp.js +22 -5
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +22 -5
- 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 +54 -4
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +54 -4
- 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/agent/index.d.mts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/bin/astrasync.js +10 -0
- package/dist/browser/background.js.map +1 -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/claude-code/claude-code-adapter.d.mts +2 -2
- package/dist/claude-code/claude-code-adapter.d.ts +2 -2
- package/dist/cli/index.d.mts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/codex/index.d.mts +2 -2
- package/dist/codex/index.d.ts +2 -2
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs.map +1 -1
- 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.map +1 -1
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.d.mts +1 -1
- package/dist/edge-config.d.ts +1 -1
- package/dist/edge-core/index.d.mts +1 -1
- package/dist/edge-core/index.d.ts +1 -1
- package/dist/edge-core/index.js +25 -5
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +25 -5
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/{express-D_4hTn5Z.d.mts → express-CR6F3njD.d.mts} +1 -1
- package/dist/{express-BVd1_3FE.d.ts → express-DaqL11tx.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.map +1 -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-BqHKlLOU.d.ts → index-B5Ts1WtM.d.ts} +1 -1
- package/dist/{index-T1aBoUcc.d.ts → index-BfIxCYIZ.d.ts} +1 -1
- package/dist/{index-BTeQ9fgV.d.mts → index-Cub7lK-T.d.mts} +1 -1
- package/dist/{index-DQb5-_1X.d.mts → index-CwAh7Tln.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +69 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -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/metadata-capture.d.mts +18 -5
- package/dist/metadata-capture.d.ts +18 -5
- package/dist/metadata-capture.js +21 -4
- package/dist/metadata-capture.js.map +1 -1
- package/dist/metadata-capture.mjs +20 -4
- package/dist/metadata-capture.mjs.map +1 -1
- package/dist/{nextjs-w7RTbP1P.d.ts → nextjs-DL6uE1ye.d.ts} +1 -1
- package/dist/{nextjs-WyeVr2Kp.d.mts → nextjs-DlX6xwbU.d.mts} +1 -1
- package/dist/{sdk-CbTNIkAa.d.mts → sdk-Bbh9B_dw.d.mts} +1 -1
- package/dist/{sdk-QeX0Z8Ho.d.ts → sdk-C6SASmsh.d.ts} +1 -1
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-r850cOt0.d.mts → types-C0zfSXMB.d.mts} +22 -0
- package/dist/{types-DqfPU5Bl.d.mts → types-C7Rb-w0d.d.mts} +1 -1
- package/dist/{types-sMxBT-nM.d.ts → types-DwSfO7Sb.d.ts} +22 -0
- package/dist/{types-BLUx92FJ.d.ts → types-nIh3HtuA.d.ts} +1 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +1 -1
- package/dist/verify.d.ts +1 -1
- package/package.json +1 -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-C7Rb-w0d.mjs';
|
|
3
|
+
import '../types-C0zfSXMB.mjs';
|
|
4
4
|
import '../metadata-capture.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -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-nIh3HtuA.js';
|
|
3
|
+
import '../types-DwSfO7Sb.js';
|
|
4
4
|
import '../metadata-capture.js';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-
|
|
2
|
-
export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationInterstitialProps, w as VerificationRequest, x as VerificationResult, y as VerifiedAgent, z as VerifiedDeveloper, B 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, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-
|
|
1
|
+
import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-C0zfSXMB.mjs';
|
|
2
|
+
export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationInterstitialProps, w as VerificationRequest, x as VerificationResult, y as VerifiedAgent, z as VerifiedDeveloper, B as VerifiedOrganization } from './types-C0zfSXMB.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, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-Bbh9B_dw.mjs';
|
|
4
4
|
export { VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, reportAttempt, reportUnregisteredAttempt, verify } from './verify.mjs';
|
|
5
|
-
export { e as express } from './express-
|
|
6
|
-
export { n as nextjs } from './nextjs-
|
|
7
|
-
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-
|
|
5
|
+
export { e as express } from './express-CR6F3njD.mjs';
|
|
6
|
+
export { n as nextjs } from './nextjs-DlX6xwbU.mjs';
|
|
7
|
+
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-Cub7lK-T.mjs';
|
|
8
8
|
export { McpMiddlewareOptions, ToolGateConfig, createMcpMiddleware } from './adapters/mcp.mjs';
|
|
9
9
|
export { AgentProtocol, AgentRecord, AstraSync, AstraSyncConfig, AstraSyncError, AuthenticationError, BuildGuidanceParams, FrameworkConfig, GuidanceEnvelope, HealthResponse, KYDRequiredError, ModelConfig, PDLSSConfig, PDLSSDuration, PDLSSLimits, PDLSSPurpose, PDLSSScope, PDLSSSelfInstantiation, PendingRegistrationResponse, PollRegistrationResult, RegisterOptions, RegisterResult, RegistrationDeniedError, RegistrationExpiredError, RegistrationResponse, RegistrationTimeoutError, VerifyResponse, WaitForApprovalOptions, buildGuidance } from './registration/index.mjs';
|
|
10
|
-
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-
|
|
10
|
+
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-CwAh7Tln.mjs';
|
|
11
11
|
export { DEFAULT_EDGE_CONFIG, EdgeConfig, EdgeMode, EdgePathRule, EdgeVerificationDepth, FetchEdgeConfigResult, FetchEdgeConfigSuccess, _resetEdgeConfigCache, degradeToObserve, fetchEdgeConfig, getEdgeConfig, isEdgeConfig, matchEdgePathRule } from './edge-config.mjs';
|
|
12
12
|
export { DynamicPlatformFingerprint, PLATFORM_AGENT_SIGNATURES, PlatformAgentVendor, PlatformDetectionInput, PlatformFingerprint, PlatformSignatureDef, detectPlatformFingerprint, matchPlatformSignature } from './platform-signatures.mjs';
|
|
13
13
|
export { CAPTURE_SCHEMA_VERSION, MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, ObservedMetadata, SanitizeHeadersResult, buildSdkObservedMetadata, deriveConnectionFromHeaders, extractApiKeyFormat, extractPlatformHeaders, sanitizeHeaders } from './metadata-capture.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-
|
|
2
|
-
export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationInterstitialProps, w as VerificationRequest, x as VerificationResult, y as VerifiedAgent, z as VerifiedDeveloper, B 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, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-
|
|
1
|
+
import { G as GatewayConfig, s as StepUpApprovalInfo, u as StepUpOutcome, t as StepUpApprovalStatus, E as EnhancedVerificationResult, A as AccessFailure } from './types-DwSfO7Sb.js';
|
|
2
|
+
export { a as AccessLevel, b as AgentCredentials, c as AstraSyncCredentials, d as AttemptOutcome, e as AttemptReport, C as CallerMetadata, f as CommerceArtifactsPayload, g as CommerceShieldProps, h as ConsiderationItem, i as ConsiderationSet, j as CounterpartyType, k as ExpressMiddlewareOptions, F as FiatSettlementBinding, l as GuidanceInfo, N as NextJsMiddlewareOptions, P as PDLSSInfo, m as ProtocolTransport, R as RouteAccessConfig, n as RuntimeChallengeResult, S as SDKOptions, o as SettlementArtifact, p as SettlementArtifactBinding, q as SettlementArtifactBindingBase, r as StablecoinSettlementBinding, T as TokenGuidance, v as TrustLevel, V as VerificationInterstitialProps, w as VerificationRequest, x as VerificationResult, y as VerifiedAgent, z as VerifiedDeveloper, B as VerifiedOrganization } from './types-DwSfO7Sb.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, e as getCapabilities, f as getTrustLevel, h as hasMinimumAccess, s as sdk } from './sdk-C6SASmsh.js';
|
|
4
4
|
export { VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, reportAttempt, reportUnregisteredAttempt, verify } from './verify.js';
|
|
5
|
-
export { e as express } from './express-
|
|
6
|
-
export { n as nextjs } from './nextjs-
|
|
7
|
-
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-
|
|
5
|
+
export { e as express } from './express-DaqL11tx.js';
|
|
6
|
+
export { n as nextjs } from './nextjs-DL6uE1ye.js';
|
|
7
|
+
export { aR as extractMcpCredentials, bg as setMcpMeta, b1 as transport } from './index-B5Ts1WtM.js';
|
|
8
8
|
export { McpMiddlewareOptions, ToolGateConfig, createMcpMiddleware } from './adapters/mcp.js';
|
|
9
9
|
export { AgentProtocol, AgentRecord, AstraSync, AstraSyncConfig, AstraSyncError, AuthenticationError, BuildGuidanceParams, FrameworkConfig, GuidanceEnvelope, HealthResponse, KYDRequiredError, ModelConfig, PDLSSConfig, PDLSSDuration, PDLSSLimits, PDLSSPurpose, PDLSSScope, PDLSSSelfInstantiation, PendingRegistrationResponse, PollRegistrationResult, RegisterOptions, RegisterResult, RegistrationDeniedError, RegistrationExpiredError, RegistrationResponse, RegistrationTimeoutError, VerifyResponse, WaitForApprovalOptions, buildGuidance } from './registration/index.js';
|
|
10
|
-
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-
|
|
10
|
+
export { A as AgentClient, C as ChallengeHandler, i as agent, r as recordDecision } from './index-BfIxCYIZ.js';
|
|
11
11
|
export { DEFAULT_EDGE_CONFIG, EdgeConfig, EdgeMode, EdgePathRule, EdgeVerificationDepth, FetchEdgeConfigResult, FetchEdgeConfigSuccess, _resetEdgeConfigCache, degradeToObserve, fetchEdgeConfig, getEdgeConfig, isEdgeConfig, matchEdgePathRule } from './edge-config.js';
|
|
12
12
|
export { DynamicPlatformFingerprint, PLATFORM_AGENT_SIGNATURES, PlatformAgentVendor, PlatformDetectionInput, PlatformFingerprint, PlatformSignatureDef, detectPlatformFingerprint, matchPlatformSignature } from './platform-signatures.js';
|
|
13
13
|
export { CAPTURE_SCHEMA_VERSION, MAX_HEADERS, MAX_HEADER_VALUE_BYTES, MAX_TOTAL_BYTES, ObservedMetadata, SanitizeHeadersResult, buildSdkObservedMetadata, deriveConnectionFromHeaders, extractApiKeyFormat, extractPlatformHeaders, sanitizeHeaders } from './metadata-capture.js';
|
package/dist/index.js
CHANGED
|
@@ -1087,6 +1087,34 @@ function extractHttpCredentials(headers) {
|
|
|
1087
1087
|
return credentials;
|
|
1088
1088
|
}
|
|
1089
1089
|
|
|
1090
|
+
// src/verified-hop.ts
|
|
1091
|
+
var MCP_VERIFIED_HOP_HEADER = "X-Astra-Verified-Hop";
|
|
1092
|
+
var MCP_VERIFIED_HOP_MAX_AGE_MS = 6e4;
|
|
1093
|
+
function serializeVerifiedHop(marker) {
|
|
1094
|
+
return `${marker.astraId};${marker.sessionId ?? ""};${marker.checkedAt}`;
|
|
1095
|
+
}
|
|
1096
|
+
function parseVerifiedHop(value) {
|
|
1097
|
+
if (!value) return null;
|
|
1098
|
+
const parts = value.split(";");
|
|
1099
|
+
if (parts.length !== 3) return null;
|
|
1100
|
+
const [astraId, sessionId, checkedAtRaw] = parts;
|
|
1101
|
+
if (!astraId) return null;
|
|
1102
|
+
const checkedAt = Number(checkedAtRaw);
|
|
1103
|
+
if (!Number.isFinite(checkedAt) || checkedAt <= 0) return null;
|
|
1104
|
+
return {
|
|
1105
|
+
astraId,
|
|
1106
|
+
...sessionId ? { sessionId } : {},
|
|
1107
|
+
checkedAt
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
function isVerifiedHopValidFor(marker, expectedAstraId, opts = {}) {
|
|
1111
|
+
if (!marker) return false;
|
|
1112
|
+
if (marker.astraId !== expectedAstraId) return false;
|
|
1113
|
+
const maxAge = opts.maxAgeMs ?? MCP_VERIFIED_HOP_MAX_AGE_MS;
|
|
1114
|
+
const now = opts.now ?? Date.now();
|
|
1115
|
+
return now - marker.checkedAt <= maxAge && now >= marker.checkedAt;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1090
1118
|
// src/adapters/http-pdlss.ts
|
|
1091
1119
|
var HTTP_METHOD_ACTION_TABLE = {
|
|
1092
1120
|
GET: "data.read",
|
|
@@ -1224,7 +1252,9 @@ var SECRET_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
|
1224
1252
|
"x-astrasync-signature",
|
|
1225
1253
|
"x-astrasync-secret",
|
|
1226
1254
|
"x-hub-signature",
|
|
1227
|
-
"x-hub-signature-256"
|
|
1255
|
+
"x-hub-signature-256",
|
|
1256
|
+
// Short-lived verify dedupe token — must never persist in stored metadata.
|
|
1257
|
+
"x-astra-verified-hop"
|
|
1228
1258
|
]);
|
|
1229
1259
|
var SECRET_HEADER_PREFIXES = ["x-astrasync-", "kya-", "kya_"];
|
|
1230
1260
|
var CREDENTIAL_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -1367,16 +1397,25 @@ var CONNECTION_HEADER_SOURCES = [
|
|
|
1367
1397
|
["cf-ipcountry", "x-vercel-ip-country", "cloudfront-viewer-country", "fastly-geo-country"]
|
|
1368
1398
|
],
|
|
1369
1399
|
["region", ["x-vercel-ip-country-region", "cloudfront-viewer-country-region"]],
|
|
1400
|
+
["countryRegionName", ["cloudfront-viewer-country-region-name"]],
|
|
1370
1401
|
["city", ["x-vercel-ip-city", "cloudfront-viewer-city"]],
|
|
1371
1402
|
["asn", ["cloudfront-viewer-asn"]],
|
|
1372
1403
|
["tlsVersion", ["cloudfront-viewer-tls"]],
|
|
1373
1404
|
["httpVersion", ["cloudfront-viewer-http-version"]],
|
|
1405
|
+
["timeZone", ["x-vercel-ip-timezone", "cloudfront-viewer-time-zone"]],
|
|
1406
|
+
["metroCode", ["cloudfront-viewer-metro-code"]],
|
|
1374
1407
|
// TLS fingerprints can only be computed where TLS terminates. When a CDN
|
|
1375
1408
|
// terminates TLS in front of the merchant, its fingerprint headers ARE the
|
|
1376
1409
|
// connection-layer truth — normalising them here is the permanent design.
|
|
1377
|
-
|
|
1378
|
-
|
|
1410
|
+
// CloudFront delivers JA3/JA4 only via an origin request policy and only
|
|
1411
|
+
// for HTTPS viewer connections.
|
|
1412
|
+
["tlsFingerprint", ["cf-ja3-hash", "cloudfront-viewer-ja3-fingerprint"]],
|
|
1413
|
+
["ja4", ["cf-ja4", "cloudfront-viewer-ja4-fingerprint"]],
|
|
1414
|
+
// Header-structure fingerprint: browser/SDK-distinctive header ordering.
|
|
1415
|
+
["headerOrder", ["cloudfront-viewer-header-order"]],
|
|
1416
|
+
["headerCount", ["cloudfront-viewer-header-count"]]
|
|
1379
1417
|
];
|
|
1418
|
+
var MAX_CONNECTION_VALUE_CHARS = 256;
|
|
1380
1419
|
function deriveConnectionFromHeaders(headers) {
|
|
1381
1420
|
if (!headers) return void 0;
|
|
1382
1421
|
const lower = {};
|
|
@@ -1389,11 +1428,15 @@ function deriveConnectionFromHeaders(headers) {
|
|
|
1389
1428
|
for (const source of sources) {
|
|
1390
1429
|
const value = lower[source]?.trim();
|
|
1391
1430
|
if (value) {
|
|
1392
|
-
connection[key] = value;
|
|
1431
|
+
connection[key] = value.slice(0, MAX_CONNECTION_VALUE_CHARS);
|
|
1393
1432
|
break;
|
|
1394
1433
|
}
|
|
1395
1434
|
}
|
|
1396
1435
|
}
|
|
1436
|
+
if (!connection.ip) {
|
|
1437
|
+
const addr = lower["cloudfront-viewer-address"]?.trim();
|
|
1438
|
+
if (addr) connection.ip = addr.replace(/:\d+$/, "");
|
|
1439
|
+
}
|
|
1397
1440
|
if (!connection.ip) {
|
|
1398
1441
|
const xff = lower["x-forwarded-for"];
|
|
1399
1442
|
const client = xff?.split(",")[0]?.trim();
|
|
@@ -1848,6 +1891,8 @@ function createMiddleware(options) {
|
|
|
1848
1891
|
failOnError = "open",
|
|
1849
1892
|
caseInsensitiveRouteMatch = false,
|
|
1850
1893
|
anonymousBeacon = true,
|
|
1894
|
+
trustVerifiedHop = false,
|
|
1895
|
+
verifiedHopMaxAgeMs,
|
|
1851
1896
|
...config
|
|
1852
1897
|
} = options;
|
|
1853
1898
|
if (config.apiBaseUrl) {
|
|
@@ -1940,6 +1985,16 @@ function createMiddleware(options) {
|
|
|
1940
1985
|
beaconPassThrough?.(req);
|
|
1941
1986
|
return next();
|
|
1942
1987
|
}
|
|
1988
|
+
if (trustVerifiedHop && credentials.astraId) {
|
|
1989
|
+
const hopRaw = req.headers[MCP_VERIFIED_HOP_HEADER.toLowerCase()];
|
|
1990
|
+
const hopValue = typeof hopRaw === "string" ? hopRaw : Array.isArray(hopRaw) ? hopRaw[0] : void 0;
|
|
1991
|
+
const marker = parseVerifiedHop(hopValue);
|
|
1992
|
+
if (isVerifiedHopValidFor(marker, credentials.astraId, {
|
|
1993
|
+
...verifiedHopMaxAgeMs !== void 0 ? { maxAgeMs: verifiedHopMaxAgeMs } : {}
|
|
1994
|
+
})) {
|
|
1995
|
+
return next();
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1943
1998
|
const pdlssPair = resolveRequestPdlss(
|
|
1944
1999
|
req,
|
|
1945
2000
|
routeConfig,
|
|
@@ -2395,6 +2450,8 @@ function createMiddleware2(options) {
|
|
|
2395
2450
|
enableRuntimeChallenge = true,
|
|
2396
2451
|
routesRefreshMs = DEFAULT_ROUTES_REFRESH_MS2,
|
|
2397
2452
|
anonymousBeacon = true,
|
|
2453
|
+
trustVerifiedHop = false,
|
|
2454
|
+
verifiedHopMaxAgeMs,
|
|
2398
2455
|
...config
|
|
2399
2456
|
} = options;
|
|
2400
2457
|
const interstitialEnabled = showInterstitial ?? showCommerceShield ?? true;
|
|
@@ -2457,6 +2514,14 @@ function createMiddleware2(options) {
|
|
|
2457
2514
|
return NextResponse.next();
|
|
2458
2515
|
}
|
|
2459
2516
|
const credentials = extractCredentialsFromNextRequest(request);
|
|
2517
|
+
if (trustVerifiedHop && credentials.astraId) {
|
|
2518
|
+
const marker = parseVerifiedHop(request.headers.get(MCP_VERIFIED_HOP_HEADER) ?? void 0);
|
|
2519
|
+
if (isVerifiedHopValidFor(marker, credentials.astraId, {
|
|
2520
|
+
...verifiedHopMaxAgeMs !== void 0 ? { maxAgeMs: verifiedHopMaxAgeMs } : {}
|
|
2521
|
+
})) {
|
|
2522
|
+
return NextResponse.next();
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2460
2525
|
const counterpartyUrl = config.counterpartyUrl || request.nextUrl.origin;
|
|
2461
2526
|
const pdlssPair = resolveNextPdlss(request, routeConfig);
|
|
2462
2527
|
const purpose = pdlssPair.purpose;
|
|
@@ -5345,32 +5410,6 @@ function extractCredentialsFromProtocol(protocol, context) {
|
|
|
5345
5410
|
}
|
|
5346
5411
|
|
|
5347
5412
|
// src/transport/mcp-server.ts
|
|
5348
|
-
var MCP_VERIFIED_HOP_HEADER = "X-Astra-Verified-Hop";
|
|
5349
|
-
var MCP_VERIFIED_HOP_MAX_AGE_MS = 6e4;
|
|
5350
|
-
function serializeVerifiedHop(marker) {
|
|
5351
|
-
return `${marker.astraId};${marker.sessionId ?? ""};${marker.checkedAt}`;
|
|
5352
|
-
}
|
|
5353
|
-
function parseVerifiedHop(value) {
|
|
5354
|
-
if (!value) return null;
|
|
5355
|
-
const parts = value.split(";");
|
|
5356
|
-
if (parts.length !== 3) return null;
|
|
5357
|
-
const [astraId, sessionId, checkedAtRaw] = parts;
|
|
5358
|
-
if (!astraId) return null;
|
|
5359
|
-
const checkedAt = Number(checkedAtRaw);
|
|
5360
|
-
if (!Number.isFinite(checkedAt) || checkedAt <= 0) return null;
|
|
5361
|
-
return {
|
|
5362
|
-
astraId,
|
|
5363
|
-
...sessionId ? { sessionId } : {},
|
|
5364
|
-
checkedAt
|
|
5365
|
-
};
|
|
5366
|
-
}
|
|
5367
|
-
function isVerifiedHopValidFor(marker, expectedAstraId, opts = {}) {
|
|
5368
|
-
if (!marker) return false;
|
|
5369
|
-
if (marker.astraId !== expectedAstraId) return false;
|
|
5370
|
-
const maxAge = opts.maxAgeMs ?? MCP_VERIFIED_HOP_MAX_AGE_MS;
|
|
5371
|
-
const now = opts.now ?? Date.now();
|
|
5372
|
-
return now - marker.checkedAt <= maxAge && now >= marker.checkedAt;
|
|
5373
|
-
}
|
|
5374
5413
|
function parseMcpJsonRpc(body) {
|
|
5375
5414
|
if (!body || typeof body !== "object" || Array.isArray(body)) return null;
|
|
5376
5415
|
const obj = body;
|