@kya-os/checkpoint-nextjs 1.9.0 → 1.11.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/CHANGELOG.md +322 -0
- package/README.md +205 -31
- package/dist/adapt-BdQ9R7Iw.mjs +97 -0
- package/dist/adapt-BdQ9R7Iw.mjs.map +1 -0
- package/dist/adapt-CCSKGjVH.js +107 -0
- package/dist/api-client-JHOrRUA_.d.mts +222 -0
- package/dist/api-client-JHOrRUA_.d.mts.map +1 -0
- package/dist/api-client-JHOrRUA_.d.ts +222 -0
- package/dist/api-client-JHOrRUA_.d.ts.map +1 -0
- package/dist/api-client.d.mts +2 -213
- package/dist/api-client.d.ts +2 -213
- package/dist/api-client.js +221 -206
- package/dist/api-client.mjs +222 -202
- package/dist/api-client.mjs.map +1 -0
- package/dist/api-middleware-BWjokNis.d.mts +131 -0
- package/dist/api-middleware-BWjokNis.d.mts.map +1 -0
- package/dist/api-middleware-Bf3xmM9W.js +391 -0
- package/dist/api-middleware-C-ngFX_8.mjs +387 -0
- package/dist/api-middleware-C-ngFX_8.mjs.map +1 -0
- package/dist/api-middleware-DyLDqOYF.d.ts +131 -0
- package/dist/api-middleware-DyLDqOYF.d.ts.map +1 -0
- package/dist/api-middleware.d.mts +2 -166
- package/dist/api-middleware.d.ts +2 -166
- package/dist/api-middleware.js +3 -526
- package/dist/api-middleware.mjs +2 -521
- package/dist/cedar-wasm.d.mts +20 -0
- package/dist/cedar-wasm.d.mts.map +1 -0
- package/dist/cedar-wasm.d.ts +19 -0
- package/dist/cedar-wasm.d.ts.map +1 -0
- package/dist/cedar-wasm.js +24 -0
- package/dist/cedar-wasm.mjs +23 -0
- package/dist/cedar-wasm.mjs.map +1 -0
- package/dist/config-CPP1RV0f.d.mts +291 -0
- package/dist/config-CPP1RV0f.d.mts.map +1 -0
- package/dist/config-DVgOFxJs.d.ts +291 -0
- package/dist/config-DVgOFxJs.d.ts.map +1 -0
- package/dist/engine-wasm.d.mts +20 -0
- package/dist/engine-wasm.d.mts.map +1 -0
- package/dist/engine-wasm.d.ts +19 -0
- package/dist/engine-wasm.d.ts.map +1 -0
- package/dist/engine-wasm.js +24 -0
- package/dist/engine-wasm.mjs +23 -0
- package/dist/engine-wasm.mjs.map +1 -0
- package/dist/index-edge.d.mts +8 -0
- package/dist/index-edge.d.ts +8 -0
- package/dist/index-edge.js +14 -0
- package/dist/index-edge.mjs +7 -0
- package/dist/index.d.mts +8 -17
- package/dist/index.d.ts +8 -17
- package/dist/index.js +36 -1275
- package/dist/index.mjs +29 -1234
- package/dist/index.mjs.map +1 -0
- package/dist/middleware-bundler.d.mts +6 -12
- package/dist/middleware-bundler.d.mts.map +1 -0
- package/dist/middleware-bundler.d.ts +6 -12
- package/dist/middleware-bundler.d.ts.map +1 -0
- package/dist/middleware-bundler.js +12 -350
- package/dist/middleware-bundler.mjs +11 -347
- package/dist/middleware-bundler.mjs.map +1 -0
- package/dist/middleware-core-B0jf5_Hm.mjs +264 -0
- package/dist/middleware-core-B0jf5_Hm.mjs.map +1 -0
- package/dist/middleware-core-Bol44X9C.d.ts +17 -0
- package/dist/middleware-core-Bol44X9C.d.ts.map +1 -0
- package/dist/middleware-core-CMc-2QkU.js +274 -0
- package/dist/middleware-core-DycsbHUd.d.mts +17 -0
- package/dist/middleware-core-DycsbHUd.d.mts.map +1 -0
- package/dist/middleware-edge.d.mts +16 -14
- package/dist/middleware-edge.d.mts.map +1 -0
- package/dist/middleware-edge.d.ts +16 -14
- package/dist/middleware-edge.d.ts.map +1 -0
- package/dist/middleware-edge.js +94 -355
- package/dist/middleware-edge.mjs +90 -347
- package/dist/middleware-edge.mjs.map +1 -0
- package/dist/middleware-node-context-591KsiYg.js +39 -0
- package/dist/middleware-node-context-D_ZyUEcA.mjs +35 -0
- package/dist/middleware-node-context-D_ZyUEcA.mjs.map +1 -0
- package/dist/middleware-node.d.mts +10 -25
- package/dist/middleware-node.d.mts.map +1 -0
- package/dist/middleware-node.d.ts +10 -25
- package/dist/middleware-node.d.ts.map +1 -0
- package/dist/middleware-node.js +21 -351
- package/dist/middleware-node.mjs +19 -347
- package/dist/middleware-node.mjs.map +1 -0
- package/dist/posture-outcome-Ccujx_9V.d.mts +14 -0
- package/dist/posture-outcome-Ccujx_9V.d.mts.map +1 -0
- package/dist/posture-outcome-Ccujx_9V.d.ts +14 -0
- package/dist/posture-outcome-Ccujx_9V.d.ts.map +1 -0
- package/dist/posture-outcome-DQ4fdMfq.mjs +21 -0
- package/dist/posture-outcome-DQ4fdMfq.mjs.map +1 -0
- package/dist/posture-outcome-DddsJtL8.js +25 -0
- package/dist/public-api-CYsHrTQI.d.ts +5 -0
- package/dist/public-api-DkG7pRE0.d.mts +5 -0
- package/dist/rolldown-runtime-C24Yb2bl.js +33 -0
- package/dist/utils-Cnwg0VrY.mjs +88 -0
- package/dist/utils-Cnwg0VrY.mjs.map +1 -0
- package/dist/utils-dyFxqlFI.js +104 -0
- package/package.json +31 -66
- package/EDGE_RUNTIME_WASM_SETUP.md +0 -342
- package/bin/setup-edge-wasm.js +0 -513
- package/dist/adapt.d.mts +0 -39
- package/dist/adapt.d.ts +0 -39
- package/dist/adapt.js +0 -59
- package/dist/adapt.mjs +0 -57
- package/dist/composed-policy.d.mts +0 -115
- package/dist/composed-policy.d.ts +0 -115
- package/dist/composed-policy.js +0 -103
- package/dist/composed-policy.mjs +0 -97
- package/dist/config-CleTeeoW.d.mts +0 -233
- package/dist/config-XMOIkxFN.d.ts +0 -233
- package/dist/create-middleware.d.mts +0 -22
- package/dist/create-middleware.d.ts +0 -22
- package/dist/create-middleware.js +0 -34
- package/dist/create-middleware.mjs +0 -31
- package/dist/edge/index.d.mts +0 -112
- package/dist/edge/index.d.ts +0 -112
- package/dist/edge/index.js +0 -277
- package/dist/edge/index.mjs +0 -275
- package/dist/edge-runtime-loader.d.mts +0 -77
- package/dist/edge-runtime-loader.d.ts +0 -77
- package/dist/edge-runtime-loader.js +0 -242
- package/dist/edge-runtime-loader.mjs +0 -235
- package/dist/edge-wasm-middleware.d.mts +0 -62
- package/dist/edge-wasm-middleware.d.ts +0 -62
- package/dist/edge-wasm-middleware.js +0 -26
- package/dist/edge-wasm-middleware.mjs +0 -22
- package/dist/middleware.d.mts +0 -45
- package/dist/middleware.d.ts +0 -45
- package/dist/middleware.js +0 -19
- package/dist/middleware.mjs +0 -15
- package/dist/nodejs-wasm-loader.d.mts +0 -41
- package/dist/nodejs-wasm-loader.d.ts +0 -41
- package/dist/nodejs-wasm-loader.js +0 -36
- package/dist/nodejs-wasm-loader.mjs +0 -30
- package/dist/policy.d.mts +0 -162
- package/dist/policy.d.ts +0 -162
- package/dist/policy.js +0 -198
- package/dist/policy.mjs +0 -174
- package/dist/session-tracker.d.mts +0 -55
- package/dist/session-tracker.d.ts +0 -55
- package/dist/session-tracker.js +0 -172
- package/dist/session-tracker.mjs +0 -169
- package/dist/translate.d.mts +0 -63
- package/dist/translate.d.ts +0 -63
- package/dist/translate.js +0 -44
- package/dist/translate.mjs +0 -42
- package/dist/types-Chgi5TFC.d.mts +0 -105
- package/dist/types-Chgi5TFC.d.ts +0 -105
- package/dist/wasm-setup.d.mts +0 -46
- package/dist/wasm-setup.d.ts +0 -46
- package/dist/wasm-setup.js +0 -122
- package/dist/wasm-setup.mjs +0 -118
- package/wasm/agentshield_wasm.d.ts +0 -479
- package/wasm/agentshield_wasm.js +0 -1536
- package/wasm/agentshield_wasm_bg.wasm +0 -0
- package/wasm/package.json +0 -30
- package/wasm.d.ts +0 -21
|
@@ -1,352 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { applyBrowserPosture, applyBrowserIntegrityStepUp, validateBrowserIntegrityChallenge, makeComposedPolicyCache, isCredentialVerificationBlock, evaluateComposedPolicy, verifyResultToAuthorizeInput } from '@kya-os/checkpoint-wasm-runtime/composed-policy';
|
|
4
|
-
import { makeSystemClock, makePolicyEvaluator, makeReputationOracle, makeStatusListCache, makeDidResolver } from '@kya-os/checkpoint-wasm-runtime/adapters';
|
|
5
|
-
import { makeDetectionReporter } from '@kya-os/checkpoint-wasm-runtime/reporter';
|
|
6
|
-
import { selectBodyReadable200, resolveChallengeContext, PolicyFetcher, requestCarriesDelegationProof, resolveClientIp, acceptsHtml, encodeVerdictCookie, classifyResponseShape, BLOCKED_PATH, VERDICT_COOKIE_NAME } from '@kya-os/checkpoint-shared';
|
|
7
|
-
import { NextResponse } from 'next/server';
|
|
1
|
+
import { n as makeNextMiddleware } from "./middleware-core-B0jf5_Hm.mjs";
|
|
2
|
+
import { t as buildComposedContext } from "./middleware-node-context-D_ZyUEcA.mjs";
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const clientAcceptsHtml = acceptsHtml(req.headers);
|
|
12
|
-
const verdictCookie = encodeVerdictCookie(rendered);
|
|
13
|
-
const shape = classifyResponseShape(rendered, clientAcceptsHtml);
|
|
14
|
-
switch (shape) {
|
|
15
|
-
case "pass-through": {
|
|
16
|
-
const res = NextResponse.next();
|
|
17
|
-
applyHeaders(res, rendered);
|
|
18
|
-
setVerdictCookie(res, verdictCookie);
|
|
19
|
-
return res;
|
|
20
|
-
}
|
|
21
|
-
case "redirect": {
|
|
22
|
-
const target = new URL(rendered.headers.Location);
|
|
23
|
-
const res = NextResponse.redirect(target);
|
|
24
|
-
applyHeaders(res, rendered);
|
|
25
|
-
setVerdictCookie(res, verdictCookie);
|
|
26
|
-
return res;
|
|
27
|
-
}
|
|
28
|
-
case "html-block": {
|
|
29
|
-
const blockedUrl = new URL(BLOCKED_PATH, req.url);
|
|
30
|
-
const res = NextResponse.rewrite(blockedUrl, { status: 200 });
|
|
31
|
-
applyHeaders(res, rendered);
|
|
32
|
-
setVerdictCookie(res, verdictCookie);
|
|
33
|
-
return res;
|
|
34
|
-
}
|
|
35
|
-
case "json-block": {
|
|
36
|
-
const body = rendered.body ?? {};
|
|
37
|
-
const res = NextResponse.json(body, { status: rendered.status });
|
|
38
|
-
applyHeaders(res, rendered);
|
|
39
|
-
setVerdictCookie(res, verdictCookie);
|
|
40
|
-
return res;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function setVerdictCookie(res, value) {
|
|
45
|
-
res.cookies.set({
|
|
46
|
-
name: VERDICT_COOKIE_NAME,
|
|
47
|
-
value,
|
|
48
|
-
path: "/",
|
|
49
|
-
sameSite: "lax",
|
|
50
|
-
httpOnly: false
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function applyHeaders(res, rendered) {
|
|
54
|
-
for (const [key, value] of Object.entries(rendered.headers)) {
|
|
55
|
-
res.headers.set(key, value);
|
|
56
|
-
}
|
|
57
|
-
for (const [key, value] of rendered.headerEntries ?? []) {
|
|
58
|
-
res.headers.append(key, value);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
var DEFAULT_DASHBOARD_URL = "https://kya.vouched.id";
|
|
62
|
-
var NOOP_LOGGER = {
|
|
63
|
-
shadowDivergence: () => {
|
|
64
|
-
},
|
|
65
|
-
evaluationError: () => {
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
function makeComposedPolicyContext(opts) {
|
|
69
|
-
const { projectId, fetcher } = opts;
|
|
70
|
-
const cache = makeComposedPolicyCache({ compile: opts.compile, cacheMax: opts.cacheMax });
|
|
71
|
-
const logger = opts.logger ?? NOOP_LOGGER;
|
|
72
|
-
return {
|
|
73
|
-
async apply(result, path) {
|
|
74
|
-
const structured = { decision: result.decision, acted: false };
|
|
75
|
-
if (isCredentialVerificationBlock(result.decision)) return structured;
|
|
76
|
-
const policy = await fetcher.getPolicy(projectId);
|
|
77
|
-
const outcome = await evaluateComposedPolicy({
|
|
78
|
-
cache,
|
|
79
|
-
projectId,
|
|
80
|
-
flags: {
|
|
81
|
-
policyLanguage: policy.policyLanguage,
|
|
82
|
-
policySourceText: policy.policySourceText,
|
|
83
|
-
engineEnforcementEnabled: policy.engineEnforcementEnabled,
|
|
84
|
-
enabled: policy.enabled
|
|
85
|
-
},
|
|
86
|
-
authorizeInput: verifyResultToAuthorizeInput(result, { tenantId: projectId, path }),
|
|
87
|
-
baselineDecisionKind: result.decision.kind
|
|
88
|
-
});
|
|
89
|
-
if ((outcome.status === "acting" || outcome.status === "shadow") && outcome.diverged) {
|
|
90
|
-
logger.shadowDivergence({
|
|
91
|
-
projectId,
|
|
92
|
-
path,
|
|
93
|
-
engineDecision: outcome.engineDecision.kind,
|
|
94
|
-
structuredDecision: result.decision.kind,
|
|
95
|
-
detectionClass: result.detectionDetail.detectionClass.type,
|
|
96
|
-
verificationMethod: result.detectionDetail.verificationMethod,
|
|
97
|
-
confidence: result.detectionDetail.confidence,
|
|
98
|
-
agentName: result.detectionDetail.detectedAgent?.name
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
if (outcome.status === "error") {
|
|
102
|
-
logger.evaluationError(projectId, outcome.error);
|
|
103
|
-
return structured;
|
|
104
|
-
}
|
|
105
|
-
if (outcome.status === "acting") {
|
|
106
|
-
return {
|
|
107
|
-
decision: outcome.engineDecision,
|
|
108
|
-
acted: true,
|
|
109
|
-
// Echo the SSOT revision pin with the decision it produced (#3246
|
|
110
|
-
// PR5). Conditional spread: absent upstream stays absent here.
|
|
111
|
-
...policy.policySourceHash ? { composedBlobHash: policy.policySourceHash } : {}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
return structured;
|
|
115
|
-
},
|
|
116
|
-
async trustedDelegationRoots() {
|
|
117
|
-
const policy = await fetcher.getPolicy(projectId);
|
|
118
|
-
return policy.trustedDelegationRoots ?? [];
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
async function resolveTrustedDelegationRootsForRequest(resolver, headers) {
|
|
123
|
-
if (!resolver) return void 0;
|
|
124
|
-
if (!requestCarriesDelegationProof(headers)) return void 0;
|
|
125
|
-
const roots = await resolver();
|
|
126
|
-
return roots.length > 0 ? roots : void 0;
|
|
127
|
-
}
|
|
128
|
-
async function applyComposedPolicy(context, result, path) {
|
|
129
|
-
if (!context) return;
|
|
130
|
-
try {
|
|
131
|
-
const outcome = await context.apply(result, path);
|
|
132
|
-
if (outcome.acted) {
|
|
133
|
-
result.decision = outcome.decision;
|
|
134
|
-
if (outcome.composedBlobHash) {
|
|
135
|
-
result.composedBlobHash = outcome.composedBlobHash;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
} catch {
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
var consoleComposedPolicyLogger = {
|
|
142
|
-
shadowDivergence(info) {
|
|
143
|
-
console.warn("[checkpoint/composed-policy] shadow-divergence", info);
|
|
144
|
-
},
|
|
145
|
-
evaluationError(projectId, error) {
|
|
146
|
-
console.error(
|
|
147
|
-
`[checkpoint/composed-policy] evaluation failed for ${projectId}; using structured decision:`,
|
|
148
|
-
error
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
async function nextRequestToHttpLike(req, opts = {}) {
|
|
153
|
-
const url = new URL(req.url);
|
|
154
|
-
const body = await tryDrainJsonBody(req, opts);
|
|
155
|
-
return {
|
|
156
|
-
method: req.method,
|
|
157
|
-
// Path + query only — orchestrator's URL parsing expects no scheme/host.
|
|
158
|
-
url: url.pathname + url.search,
|
|
159
|
-
headers: headersToRecord(req.headers),
|
|
160
|
-
body,
|
|
161
|
-
remoteAddress: extractRemoteAddress(req, opts.clientIpPolicy ?? { platform: "direct" })
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
async function tryDrainJsonBody(req, opts) {
|
|
165
|
-
if (opts.drainJsonBody === false) return null;
|
|
166
|
-
const contentType = req.headers.get("content-type") ?? "";
|
|
167
|
-
if (!contentType.toLowerCase().includes("application/json")) return null;
|
|
168
|
-
try {
|
|
169
|
-
return await req.clone().text();
|
|
170
|
-
} catch {
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function headersToRecord(headers) {
|
|
175
|
-
const out = {};
|
|
176
|
-
headers.forEach((value, key) => {
|
|
177
|
-
out[key.toLowerCase()] = value;
|
|
178
|
-
});
|
|
179
|
-
return out;
|
|
180
|
-
}
|
|
181
|
-
function extractRemoteAddress(req, policy) {
|
|
182
|
-
const maybeIp = req.ip;
|
|
183
|
-
return resolveClientIp({
|
|
184
|
-
headers: req.headers,
|
|
185
|
-
frameworkAddress: maybeIp,
|
|
186
|
-
policy
|
|
187
|
-
}).ip ?? void 0;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// src/middleware-core.ts
|
|
191
|
-
function makeNextMiddleware(verifyRequest2, renderDecisionAsResponse2, config, host) {
|
|
192
|
-
if (config.browserPosture) validateBrowserPostureConfig(config.browserPosture, config.projectId);
|
|
193
|
-
if (config.browserPosture?.protectedRoutes?.length && !config.resolveDelegationChallenge) {
|
|
194
|
-
throw new Error(
|
|
195
|
-
"browserPosture.protectedRoutes requires resolveDelegationChallenge (see createBrowserIntegrityChallengeResolver)"
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
const opts = buildVerifyOpts(config);
|
|
199
|
-
const reporter = buildReporter(config, host.runtime);
|
|
200
|
-
const composed = host.buildComposedContext(config);
|
|
201
|
-
const trustedRootsResolver = buildTrustedRootsResolver(config, composed);
|
|
202
|
-
const translateOpts = {
|
|
203
|
-
drainJsonBody: config.drainJsonBody,
|
|
204
|
-
clientIpPolicy: config.clientIpPolicy
|
|
205
|
-
};
|
|
206
|
-
return async function checkpointMiddleware(req, event) {
|
|
207
|
-
const httpLike = await nextRequestToHttpLike(req, translateOpts);
|
|
208
|
-
const trustedDelegationRoots = await resolveTrustedDelegationRootsForRequest(
|
|
209
|
-
trustedRootsResolver,
|
|
210
|
-
req.headers
|
|
211
|
-
);
|
|
212
|
-
const result = await verifyRequest2(
|
|
213
|
-
httpLike,
|
|
214
|
-
trustedDelegationRoots ? { ...opts, trustedDelegationRoots } : opts
|
|
215
|
-
);
|
|
216
|
-
await applyBrowserPosture(
|
|
217
|
-
result,
|
|
218
|
-
req.headers.get("cookie"),
|
|
219
|
-
config.browserPosture,
|
|
220
|
-
config.projectId
|
|
221
|
-
);
|
|
222
|
-
await applyComposedPolicy(composed, result, req.nextUrl.pathname);
|
|
223
|
-
applyBrowserIntegrityStepUp(result, config.browserPosture, req.nextUrl.pathname);
|
|
224
|
-
if (reporter) {
|
|
225
|
-
const reportPromise = reporter(
|
|
226
|
-
result,
|
|
227
|
-
extractReporterContext(req, config.clientIpPolicy ?? { platform: "direct" })
|
|
228
|
-
);
|
|
229
|
-
if (event) {
|
|
230
|
-
event.waitUntil(reportPromise);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
await dispatchOnResult(config, result, req);
|
|
234
|
-
const bodyReadable200 = selectBodyReadable200(
|
|
235
|
-
config.delegationChallengeMode ?? "negotiated",
|
|
236
|
-
req.headers,
|
|
237
|
-
result.detectionDetail.detectionClass,
|
|
238
|
-
result.detectionDetail.isAgent
|
|
239
|
-
);
|
|
240
|
-
const challengeContextRequested = result.enforcementMode === "enforce" && result.decision.kind === "Challenge" && config.resolveDelegationChallenge !== void 0;
|
|
241
|
-
const delegationChallenge = challengeContextRequested ? await resolveChallengeContext(
|
|
242
|
-
config.resolveDelegationChallenge,
|
|
243
|
-
{ result, request: req },
|
|
244
|
-
{
|
|
245
|
-
timeoutMs: config.delegationChallengeTimeoutMs,
|
|
246
|
-
onFailure: config.onDelegationChallengeFailure
|
|
247
|
-
}
|
|
248
|
-
) : void 0;
|
|
249
|
-
const rendered = renderDecisionAsResponse2(result, {
|
|
250
|
-
bodyReadable200,
|
|
251
|
-
delegationChallenge: validateBrowserIntegrityChallenge(result, delegationChallenge),
|
|
252
|
-
challengeContextRequested
|
|
253
|
-
});
|
|
254
|
-
return adaptToNextResponse(rendered, req);
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
var SDK_NAME = "@kya-os/checkpoint-nextjs";
|
|
258
|
-
var VERSION = "1.9.0";
|
|
259
|
-
function buildReporter(config, runtime = "node") {
|
|
260
|
-
if (!config.apiKey) return null;
|
|
261
|
-
return makeDetectionReporter({
|
|
262
|
-
apiKey: config.apiKey,
|
|
263
|
-
baseUrl: config.baseUrl,
|
|
264
|
-
debug: config.debug,
|
|
265
|
-
// Self-identify (incl. node-vs-edge) so the dashboard can version-gate
|
|
266
|
-
// enforcement. Next.js EDGE composed enforcement is opt-in (needs
|
|
267
|
-
// `cedarWasmModule`), so the dashboard shows it as opt-in, never "Enforcing".
|
|
268
|
-
sdk: { name: SDK_NAME, version: VERSION, runtime }
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
function buildTrustedRootsResolver(config, composed) {
|
|
272
|
-
if (config.trustedDelegationRoots) return () => Promise.resolve(config.trustedDelegationRoots);
|
|
273
|
-
if (composed?.trustedDelegationRoots) {
|
|
274
|
-
return () => composed.trustedDelegationRoots();
|
|
275
|
-
}
|
|
276
|
-
if (!config.projectId) return null;
|
|
277
|
-
const fetcher = new PolicyFetcher({
|
|
278
|
-
apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
|
|
279
|
-
apiKey: config.apiKey,
|
|
280
|
-
cacheTtlSeconds: config.policyCacheTtlSeconds
|
|
281
|
-
});
|
|
282
|
-
const projectId = config.projectId;
|
|
283
|
-
return async () => (await fetcher.getPolicy(projectId)).trustedDelegationRoots ?? [];
|
|
284
|
-
}
|
|
285
|
-
function extractReporterContext(req, policy) {
|
|
286
|
-
const resolution = resolveClientIp({
|
|
287
|
-
headers: req.headers,
|
|
288
|
-
frameworkAddress: req.ip,
|
|
289
|
-
policy
|
|
290
|
-
});
|
|
291
|
-
return {
|
|
292
|
-
userAgent: req.headers.get("user-agent") ?? void 0,
|
|
293
|
-
ipAddress: resolution.ip ?? void 0,
|
|
294
|
-
path: req.nextUrl.pathname,
|
|
295
|
-
url: req.nextUrl.href,
|
|
296
|
-
method: req.method
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
function buildVerifyOpts(config) {
|
|
300
|
-
const overrides = config.adapters ?? {};
|
|
301
|
-
return {
|
|
302
|
-
didResolver: overrides.didResolver ?? makeDidResolver(),
|
|
303
|
-
statusListCache: overrides.statusListCache ?? makeStatusListCache(),
|
|
304
|
-
reputationOracle: overrides.reputationOracle ?? makeReputationOracle({ argusUrl: config.argusUrl }),
|
|
305
|
-
policyEvaluator: overrides.policyEvaluator ?? makePolicyEvaluator({ dashboardUrl: config.dashboardUrl }),
|
|
306
|
-
clock: makeSystemClock(),
|
|
307
|
-
tenantHost: config.tenantHost,
|
|
308
|
-
resourceOrgDid: config.resourceOrgDid,
|
|
309
|
-
trustedDelegationRoots: config.trustedDelegationRoots,
|
|
310
|
-
enforcementMode: config.enforcementMode ?? "enforce",
|
|
311
|
-
reputationBaseline: config.reputationBaseline,
|
|
312
|
-
argusUrl: config.argusUrl,
|
|
313
|
-
legacyEnvelopeFallback: config.legacyEnvelopeFallback ?? false,
|
|
314
|
-
engineConfig: config.engineConfig
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
async function dispatchOnResult(config, result, req) {
|
|
318
|
-
if (!config.onResult) return;
|
|
319
|
-
try {
|
|
320
|
-
await config.onResult(result, req);
|
|
321
|
-
} catch {
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
function buildComposedContext(config) {
|
|
325
|
-
if (config.composedPolicyEnforcer) return config.composedPolicyEnforcer;
|
|
326
|
-
if (!config.projectId) return null;
|
|
327
|
-
return makeComposedPolicyContext({
|
|
328
|
-
projectId: config.projectId,
|
|
329
|
-
fetcher: new PolicyFetcher({
|
|
330
|
-
apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
|
|
331
|
-
apiKey: config.apiKey,
|
|
332
|
-
cacheTtlSeconds: config.policyCacheTtlSeconds
|
|
333
|
-
}),
|
|
334
|
-
// Load the Node policy compiler only on first use. This module is imported
|
|
335
|
-
// exclusively by the Node and bundler hosts, never by the Edge pipeline.
|
|
336
|
-
compile: async (_language, source) => {
|
|
337
|
-
const { createPolicyEvaluator } = await import('@kya-os/checkpoint-wasm-runtime/policy');
|
|
338
|
-
return createPolicyEvaluator(source);
|
|
339
|
-
},
|
|
340
|
-
logger: config.debug ? consoleComposedPolicyLogger : void 0
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// src/middleware-bundler.ts
|
|
4
|
+
//#region src/middleware-bundler.ts
|
|
5
|
+
/** Next.js server bundlers import the WASM asset rather than relocating a Node fs read. */
|
|
345
6
|
function withCheckpoint(config) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
7
|
+
return makeNextMiddleware(config, {
|
|
8
|
+
runtime: "node",
|
|
9
|
+
loadEngine: () => import("@kya-os/checkpoint-wasm-runtime/orchestrator/bundler"),
|
|
10
|
+
buildComposedContext
|
|
11
|
+
});
|
|
350
12
|
}
|
|
351
13
|
|
|
14
|
+
//#endregion
|
|
352
15
|
export { withCheckpoint };
|
|
16
|
+
//# sourceMappingURL=middleware-bundler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-bundler.mjs","names":[],"sources":["../src/middleware-bundler.ts"],"sourcesContent":["import { makeNextMiddleware } from './middleware-core';\nimport { buildComposedContext } from './middleware-node-context';\nimport type { CheckpointConfig } from './config';\nexport type { CheckpointConfig } from './config';\n\n/** Next.js server bundlers import the WASM asset rather than relocating a Node fs read. */\nexport function withCheckpoint(config: CheckpointConfig) {\n return makeNextMiddleware(config, {\n runtime: 'node',\n // Imported on first use: a failure to load the engine is then answered 503\n // per request instead of failing this module.\n loadEngine: () => import('@kya-os/checkpoint-wasm-runtime/orchestrator/bundler'),\n buildComposedContext,\n });\n}\n"],"mappings":";;;;;AAMA,SAAgB,eAAe,QAA0B;CACvD,OAAO,mBAAmB,QAAQ;EAChC,SAAS;EAGT,kBAAkB,OAAO;EACzB;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { n as failClosedResponse, t as adaptToNextResponse } from "./adapt-BdQ9R7Iw.mjs";
|
|
2
|
+
import { t as getClientIp } from "./utils-Cnwg0VrY.mjs";
|
|
3
|
+
import { postureRequestFromHeaders, validateBrowserPostureConfig } from "@kya-os/checkpoint-shared/browser-posture";
|
|
4
|
+
import { DEFAULT_DASHBOARD_URL, applyBrowserIntegrityStepUp, applyBrowserPosture, applyComposedPolicy, applyRequestClaim, createLocalRequestClaimStore, createPlatformRequestClaimStore, isConsentRemediableBlock, resolveTrustedDelegationRootsForRequest, validateBrowserIntegrityChallenge } from "@kya-os/checkpoint-wasm-runtime/composed-policy";
|
|
5
|
+
import { makeEngineDefaults } from "@kya-os/checkpoint-wasm-runtime/adapters";
|
|
6
|
+
import { makeDetectionReporter } from "@kya-os/checkpoint-wasm-runtime/reporter";
|
|
7
|
+
import { PolicyFetcher } from "@kya-os/checkpoint-shared/policy/fetcher";
|
|
8
|
+
import { resolveChallengeContext, selectBodyReadable200 } from "@kya-os/checkpoint-shared/host-adapter";
|
|
9
|
+
import { waitUntil } from "@vercel/functions";
|
|
10
|
+
|
|
11
|
+
//#region src/translate.ts
|
|
12
|
+
/**
|
|
13
|
+
* Translate a Next.js `NextRequest` into the orchestrator's
|
|
14
|
+
* `IncomingHttpLike` shape.
|
|
15
|
+
*
|
|
16
|
+
* When `opts.drainJsonBody !== false` and the request is JSON, the
|
|
17
|
+
* translator clones the request and reads the body into a string so
|
|
18
|
+
* the orchestrator's `buildAgentRequest` can extract a
|
|
19
|
+
* `_meta.proof.jws` envelope. The original `req.body` stream is
|
|
20
|
+
* preserved for downstream handlers via `req.clone()`.
|
|
21
|
+
*
|
|
22
|
+
* When the body can't be read (drain disabled, non-JSON, or a stream
|
|
23
|
+
* error) we pass `body: null` and the orchestrator routes to
|
|
24
|
+
* PlainHttp — same behavior as the pre-1.1.0 default.
|
|
25
|
+
*/
|
|
26
|
+
async function nextRequestToHttpLike(req, opts = {}) {
|
|
27
|
+
const url = new URL(req.url);
|
|
28
|
+
const body = await tryDrainJsonBody(req, opts);
|
|
29
|
+
return {
|
|
30
|
+
method: req.method,
|
|
31
|
+
url: url.pathname + url.search,
|
|
32
|
+
headers: headersToRecord(req.headers),
|
|
33
|
+
body,
|
|
34
|
+
remoteAddress: getClientIp(req, opts.clientIpPolicy)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Read the request body as a UTF-8 string when JSON and the caller
|
|
39
|
+
* has opted in (default). Returns `null` on any failure — the
|
|
40
|
+
* orchestrator handles `null` as "no body present" (→ PlainHttp).
|
|
41
|
+
*
|
|
42
|
+
* Clone-first means the original `req.body` ReadableStream stays
|
|
43
|
+
* unconsumed and downstream handlers can re-read it. Without the
|
|
44
|
+
* clone, calling `req.text()` in middleware would block any route
|
|
45
|
+
* handler that needs the body.
|
|
46
|
+
*/
|
|
47
|
+
async function tryDrainJsonBody(req, opts) {
|
|
48
|
+
if (opts.drainJsonBody === false) return null;
|
|
49
|
+
if (!(req.headers.get("content-type") ?? "").toLowerCase().includes("application/json")) return null;
|
|
50
|
+
try {
|
|
51
|
+
return await req.clone().text();
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Convert a `Headers` instance into a lowercase-keyed plain object.
|
|
58
|
+
* HTTP header names are case-insensitive (RFC 9110 § 5.1); the
|
|
59
|
+
* orchestrator does case-sensitive lookups, so we normalise to
|
|
60
|
+
* lowercase here. Multi-value headers (Set-Cookie, Accept) are
|
|
61
|
+
* surfaced as their `Headers.get()` view — a single string with
|
|
62
|
+
* comma-joined values, matching what other host adapters produce.
|
|
63
|
+
*/
|
|
64
|
+
function headersToRecord(headers) {
|
|
65
|
+
const out = {};
|
|
66
|
+
headers.forEach((value, key) => {
|
|
67
|
+
out[key.toLowerCase()] = value;
|
|
68
|
+
});
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/middleware-core.ts
|
|
74
|
+
/**
|
|
75
|
+
* Shared Next.js request pipeline. Node, bundler and Edge hosts inject their
|
|
76
|
+
* engine and policy-context factories; runtime-specific WASM initialization
|
|
77
|
+
* stays in each host entry. Public withCheckpoint exports live there too.
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Build the Checkpoint middleware. Returns a function `(req) => NextResponse`
|
|
81
|
+
* suitable for `export default withCheckpoint({...})` in `middleware.ts`.
|
|
82
|
+
*
|
|
83
|
+
* Every verification decision flows through the Rust `kya-os-engine`
|
|
84
|
+
* via WASM. The TS layer translates request shape, calls
|
|
85
|
+
* `verifyRequest`, and translates the verdict to `NextResponse`. No
|
|
86
|
+
* verification logic lives in this file.
|
|
87
|
+
*
|
|
88
|
+
* It never throws. An error in the configuration or in loading the engine
|
|
89
|
+
* would otherwise fail the middleware module, and a Next.js middleware that
|
|
90
|
+
* fails to load can let requests through unchecked. Every such error is
|
|
91
|
+
* answered 503 instead (fail closed) and logged.
|
|
92
|
+
*/
|
|
93
|
+
let warnedLocalClaimStore = false;
|
|
94
|
+
/**
|
|
95
|
+
* Where accepted signed requests are claimed: the caller's store, else the
|
|
96
|
+
* dashboard's shared ledger when the project is configured, else this
|
|
97
|
+
* process (or isolate), with a one-time warning that several instances need
|
|
98
|
+
* a shared store.
|
|
99
|
+
*/
|
|
100
|
+
function buildRequestClaimStore(config) {
|
|
101
|
+
if (config.requestClaimStore) return config.requestClaimStore;
|
|
102
|
+
if (config.apiKey && config.projectId) return createPlatformRequestClaimStore({
|
|
103
|
+
baseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
|
|
104
|
+
apiKey: config.apiKey
|
|
105
|
+
});
|
|
106
|
+
if (!warnedLocalClaimStore) {
|
|
107
|
+
warnedLocalClaimStore = true;
|
|
108
|
+
console.warn("[checkpoint] signed requests are claimed in this process only; a deployment with several instances needs apiKey and projectId, or a shared requestClaimStore");
|
|
109
|
+
}
|
|
110
|
+
return createLocalRequestClaimStore();
|
|
111
|
+
}
|
|
112
|
+
function makeNextMiddleware(config, host) {
|
|
113
|
+
try {
|
|
114
|
+
return makePipeline(config, host);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
return async function misconfiguredCheckpointMiddleware() {
|
|
117
|
+
console.error("[checkpoint] withCheckpoint is misconfigured; responding 503:", error);
|
|
118
|
+
return failClosedResponse();
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function makePipeline(config, host) {
|
|
123
|
+
if (config.browserPosture) validateBrowserPostureConfig(config.browserPosture, config.projectId);
|
|
124
|
+
if (config.browserPosture?.protectedRoutes?.length && !config.resolveDelegationChallenge) throw new Error("browserPosture.protectedRoutes requires resolveDelegationChallenge (see createBrowserIntegrityChallengeResolver)");
|
|
125
|
+
host.start?.(config);
|
|
126
|
+
const engine = memoizeEngine(host.loadEngine);
|
|
127
|
+
engine().catch(() => void 0);
|
|
128
|
+
const opts = buildVerifyOpts(config);
|
|
129
|
+
const reporter = buildReporter(config, host.runtime);
|
|
130
|
+
const composed = host.buildComposedContext(config);
|
|
131
|
+
const requestClaimStore = buildRequestClaimStore(config);
|
|
132
|
+
const trustedRootsResolver = buildTrustedRootsResolver(config, composed);
|
|
133
|
+
const translateOpts = {
|
|
134
|
+
drainJsonBody: config.drainJsonBody,
|
|
135
|
+
clientIpPolicy: config.clientIpPolicy
|
|
136
|
+
};
|
|
137
|
+
return async function checkpointMiddleware(req, event) {
|
|
138
|
+
const waitUntil$1 = event ? (promise) => event.waitUntil(promise) : waitUntil;
|
|
139
|
+
try {
|
|
140
|
+
const { verifyRequest, renderDecisionAsResponse } = await engine().catch((error) => {
|
|
141
|
+
console.error("[checkpoint] kya-os-engine failed to load; responding 503:", error);
|
|
142
|
+
throw error;
|
|
143
|
+
});
|
|
144
|
+
const httpLike = await nextRequestToHttpLike(req, translateOpts);
|
|
145
|
+
const trustedDelegationRoots = await resolveTrustedDelegationRootsForRequest(trustedRootsResolver, req.headers);
|
|
146
|
+
const result = await verifyRequest(httpLike, {
|
|
147
|
+
...opts,
|
|
148
|
+
...trustedDelegationRoots ? { trustedDelegationRoots } : {},
|
|
149
|
+
waitUntil: waitUntil$1
|
|
150
|
+
});
|
|
151
|
+
await applyBrowserPosture(result, postureRequestFromHeaders((name) => req.headers.get(name)), config.browserPosture, config.projectId);
|
|
152
|
+
await applyComposedPolicy(composed, result, req.nextUrl.pathname);
|
|
153
|
+
applyBrowserIntegrityStepUp(result, config.browserPosture, req.nextUrl.pathname);
|
|
154
|
+
await applyRequestClaim(result, requestClaimStore, { sourceIp: getClientIp(req, config.clientIpPolicy) ?? void 0 });
|
|
155
|
+
if (reporter) waitUntil$1(reporter(result, extractReporterContext(req, config.clientIpPolicy)));
|
|
156
|
+
await dispatchOnResult(config, result, req);
|
|
157
|
+
const bodyReadable200 = selectBodyReadable200(config.delegationChallengeMode ?? "negotiated", req.headers, result.detectionDetail.detectionClass, result.detectionDetail.isAgent);
|
|
158
|
+
const challengeContextRequested = result.enforcementMode === "enforce" && (result.decision.kind === "Challenge" || isConsentRemediableBlock(result)) && config.resolveDelegationChallenge !== void 0;
|
|
159
|
+
const delegationChallenge = challengeContextRequested ? await resolveChallengeContext(config.resolveDelegationChallenge, {
|
|
160
|
+
result,
|
|
161
|
+
request: req
|
|
162
|
+
}, {
|
|
163
|
+
timeoutMs: config.delegationChallengeTimeoutMs,
|
|
164
|
+
onFailure: config.onDelegationChallengeFailure
|
|
165
|
+
}) : void 0;
|
|
166
|
+
const rendered = renderDecisionAsResponse(result, {
|
|
167
|
+
bodyReadable200,
|
|
168
|
+
delegationChallenge: validateBrowserIntegrityChallenge(result, delegationChallenge),
|
|
169
|
+
challengeContextRequested
|
|
170
|
+
});
|
|
171
|
+
return adaptToNextResponse(rendered, req);
|
|
172
|
+
} catch (err) {
|
|
173
|
+
if (config.debug) console.error("[checkpoint] verification pipeline failed; responding 503:", err);
|
|
174
|
+
return failClosedResponse();
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/** Load the engine once; a failed load is retried by the next request. */
|
|
179
|
+
function memoizeEngine(load) {
|
|
180
|
+
let loading;
|
|
181
|
+
return () => loading ??= load().catch((error) => {
|
|
182
|
+
loading = void 0;
|
|
183
|
+
throw error;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Build a fire-and-forget detection reporter from the host config. Returns
|
|
188
|
+
* `null` when `apiKey` is not set — that case is the documented opt-out
|
|
189
|
+
* (engine still runs locally, dashboard just sees no detections).
|
|
190
|
+
*/
|
|
191
|
+
/** npm package name this SDK self-reports to the detection reporter. */
|
|
192
|
+
const SDK_NAME = "@kya-os/checkpoint-nextjs";
|
|
193
|
+
/**
|
|
194
|
+
* Installed SDK version, self-reported to the detection reporter so the
|
|
195
|
+
* dashboard can version-gate "composed policy enforces here". MUST equal
|
|
196
|
+
* `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
|
|
197
|
+
* drifted). Re-exported as `VERSION` from the package index.
|
|
198
|
+
*/
|
|
199
|
+
const VERSION = "1.11.0";
|
|
200
|
+
function buildReporter(config, runtime = "node") {
|
|
201
|
+
if (!config.apiKey) return null;
|
|
202
|
+
return makeDetectionReporter({
|
|
203
|
+
apiKey: config.apiKey,
|
|
204
|
+
baseUrl: config.baseUrl,
|
|
205
|
+
debug: config.debug,
|
|
206
|
+
sdk: {
|
|
207
|
+
name: SDK_NAME,
|
|
208
|
+
version: VERSION,
|
|
209
|
+
runtime
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Build the per-factory trusted-delegation-roots resolver (P2 / DR-1). Root
|
|
215
|
+
* pinning is a security concern INDEPENDENT of composed Cedar enforcement, so it
|
|
216
|
+
* must resolve wherever a `projectId` exists — including Edge setups that never
|
|
217
|
+
* wire `cedarWasmModule` (where `buildComposedContext` returns null). Prefers the
|
|
218
|
+
* composed context's accessor (reuses its cached fetcher / honors an injected
|
|
219
|
+
* enforcer); otherwise falls back to a `projectId`-only policy fetch. Returns
|
|
220
|
+
* `null` when no source is configured (no roots → the engine rejects delegation).
|
|
221
|
+
* An origin outage rejects with `PolicyUnavailableError`, which the middleware
|
|
222
|
+
* answers as a retryable 503.
|
|
223
|
+
*/
|
|
224
|
+
function buildTrustedRootsResolver(config, composed) {
|
|
225
|
+
if (config.trustedDelegationRoots) return () => Promise.resolve(config.trustedDelegationRoots);
|
|
226
|
+
if (composed?.trustedDelegationRoots) return () => composed.trustedDelegationRoots();
|
|
227
|
+
if (!config.projectId) return null;
|
|
228
|
+
const fetcher = new PolicyFetcher({
|
|
229
|
+
apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
|
|
230
|
+
apiKey: config.apiKey,
|
|
231
|
+
cacheTtlSeconds: config.policyCacheTtlSeconds,
|
|
232
|
+
throwOnUnavailable: true
|
|
233
|
+
});
|
|
234
|
+
const projectId = config.projectId;
|
|
235
|
+
return async () => (await fetcher.getPolicy(projectId)).trustedDelegationRoots ?? [];
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Pull the request context the dashboard's `/api/v1/log-detection`
|
|
239
|
+
* endpoint expects out of a `NextRequest`. Works under both Node and
|
|
240
|
+
* Edge runtimes — no runtime-specific APIs.
|
|
241
|
+
*/
|
|
242
|
+
function extractReporterContext(req, policy) {
|
|
243
|
+
return {
|
|
244
|
+
userAgent: req.headers.get("user-agent") ?? void 0,
|
|
245
|
+
ipAddress: getClientIp(req, policy),
|
|
246
|
+
path: req.nextUrl.pathname,
|
|
247
|
+
url: req.nextUrl.href,
|
|
248
|
+
method: req.method
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/** The engine's default options for this config; per-request fields go on top. */
|
|
252
|
+
function buildVerifyOpts(config) {
|
|
253
|
+
return makeEngineDefaults(config);
|
|
254
|
+
}
|
|
255
|
+
async function dispatchOnResult(config, result, req) {
|
|
256
|
+
if (!config.onResult) return;
|
|
257
|
+
try {
|
|
258
|
+
await config.onResult(result, req);
|
|
259
|
+
} catch {}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
//#endregion
|
|
263
|
+
export { makeNextMiddleware as n, VERSION as t };
|
|
264
|
+
//# sourceMappingURL=middleware-core-B0jf5_Hm.mjs.map
|