@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.
Files changed (156) hide show
  1. package/CHANGELOG.md +322 -0
  2. package/README.md +205 -31
  3. package/dist/adapt-BdQ9R7Iw.mjs +97 -0
  4. package/dist/adapt-BdQ9R7Iw.mjs.map +1 -0
  5. package/dist/adapt-CCSKGjVH.js +107 -0
  6. package/dist/api-client-JHOrRUA_.d.mts +222 -0
  7. package/dist/api-client-JHOrRUA_.d.mts.map +1 -0
  8. package/dist/api-client-JHOrRUA_.d.ts +222 -0
  9. package/dist/api-client-JHOrRUA_.d.ts.map +1 -0
  10. package/dist/api-client.d.mts +2 -213
  11. package/dist/api-client.d.ts +2 -213
  12. package/dist/api-client.js +221 -206
  13. package/dist/api-client.mjs +222 -202
  14. package/dist/api-client.mjs.map +1 -0
  15. package/dist/api-middleware-BWjokNis.d.mts +131 -0
  16. package/dist/api-middleware-BWjokNis.d.mts.map +1 -0
  17. package/dist/api-middleware-Bf3xmM9W.js +391 -0
  18. package/dist/api-middleware-C-ngFX_8.mjs +387 -0
  19. package/dist/api-middleware-C-ngFX_8.mjs.map +1 -0
  20. package/dist/api-middleware-DyLDqOYF.d.ts +131 -0
  21. package/dist/api-middleware-DyLDqOYF.d.ts.map +1 -0
  22. package/dist/api-middleware.d.mts +2 -166
  23. package/dist/api-middleware.d.ts +2 -166
  24. package/dist/api-middleware.js +3 -526
  25. package/dist/api-middleware.mjs +2 -521
  26. package/dist/cedar-wasm.d.mts +20 -0
  27. package/dist/cedar-wasm.d.mts.map +1 -0
  28. package/dist/cedar-wasm.d.ts +19 -0
  29. package/dist/cedar-wasm.d.ts.map +1 -0
  30. package/dist/cedar-wasm.js +24 -0
  31. package/dist/cedar-wasm.mjs +23 -0
  32. package/dist/cedar-wasm.mjs.map +1 -0
  33. package/dist/config-CPP1RV0f.d.mts +291 -0
  34. package/dist/config-CPP1RV0f.d.mts.map +1 -0
  35. package/dist/config-DVgOFxJs.d.ts +291 -0
  36. package/dist/config-DVgOFxJs.d.ts.map +1 -0
  37. package/dist/engine-wasm.d.mts +20 -0
  38. package/dist/engine-wasm.d.mts.map +1 -0
  39. package/dist/engine-wasm.d.ts +19 -0
  40. package/dist/engine-wasm.d.ts.map +1 -0
  41. package/dist/engine-wasm.js +24 -0
  42. package/dist/engine-wasm.mjs +23 -0
  43. package/dist/engine-wasm.mjs.map +1 -0
  44. package/dist/index-edge.d.mts +8 -0
  45. package/dist/index-edge.d.ts +8 -0
  46. package/dist/index-edge.js +14 -0
  47. package/dist/index-edge.mjs +7 -0
  48. package/dist/index.d.mts +8 -17
  49. package/dist/index.d.ts +8 -17
  50. package/dist/index.js +36 -1275
  51. package/dist/index.mjs +29 -1234
  52. package/dist/index.mjs.map +1 -0
  53. package/dist/middleware-bundler.d.mts +6 -12
  54. package/dist/middleware-bundler.d.mts.map +1 -0
  55. package/dist/middleware-bundler.d.ts +6 -12
  56. package/dist/middleware-bundler.d.ts.map +1 -0
  57. package/dist/middleware-bundler.js +12 -350
  58. package/dist/middleware-bundler.mjs +11 -347
  59. package/dist/middleware-bundler.mjs.map +1 -0
  60. package/dist/middleware-core-B0jf5_Hm.mjs +264 -0
  61. package/dist/middleware-core-B0jf5_Hm.mjs.map +1 -0
  62. package/dist/middleware-core-Bol44X9C.d.ts +17 -0
  63. package/dist/middleware-core-Bol44X9C.d.ts.map +1 -0
  64. package/dist/middleware-core-CMc-2QkU.js +274 -0
  65. package/dist/middleware-core-DycsbHUd.d.mts +17 -0
  66. package/dist/middleware-core-DycsbHUd.d.mts.map +1 -0
  67. package/dist/middleware-edge.d.mts +16 -14
  68. package/dist/middleware-edge.d.mts.map +1 -0
  69. package/dist/middleware-edge.d.ts +16 -14
  70. package/dist/middleware-edge.d.ts.map +1 -0
  71. package/dist/middleware-edge.js +94 -355
  72. package/dist/middleware-edge.mjs +90 -347
  73. package/dist/middleware-edge.mjs.map +1 -0
  74. package/dist/middleware-node-context-591KsiYg.js +39 -0
  75. package/dist/middleware-node-context-D_ZyUEcA.mjs +35 -0
  76. package/dist/middleware-node-context-D_ZyUEcA.mjs.map +1 -0
  77. package/dist/middleware-node.d.mts +10 -25
  78. package/dist/middleware-node.d.mts.map +1 -0
  79. package/dist/middleware-node.d.ts +10 -25
  80. package/dist/middleware-node.d.ts.map +1 -0
  81. package/dist/middleware-node.js +21 -351
  82. package/dist/middleware-node.mjs +19 -347
  83. package/dist/middleware-node.mjs.map +1 -0
  84. package/dist/posture-outcome-Ccujx_9V.d.mts +14 -0
  85. package/dist/posture-outcome-Ccujx_9V.d.mts.map +1 -0
  86. package/dist/posture-outcome-Ccujx_9V.d.ts +14 -0
  87. package/dist/posture-outcome-Ccujx_9V.d.ts.map +1 -0
  88. package/dist/posture-outcome-DQ4fdMfq.mjs +21 -0
  89. package/dist/posture-outcome-DQ4fdMfq.mjs.map +1 -0
  90. package/dist/posture-outcome-DddsJtL8.js +25 -0
  91. package/dist/public-api-CYsHrTQI.d.ts +5 -0
  92. package/dist/public-api-DkG7pRE0.d.mts +5 -0
  93. package/dist/rolldown-runtime-C24Yb2bl.js +33 -0
  94. package/dist/utils-Cnwg0VrY.mjs +88 -0
  95. package/dist/utils-Cnwg0VrY.mjs.map +1 -0
  96. package/dist/utils-dyFxqlFI.js +104 -0
  97. package/package.json +31 -66
  98. package/EDGE_RUNTIME_WASM_SETUP.md +0 -342
  99. package/bin/setup-edge-wasm.js +0 -513
  100. package/dist/adapt.d.mts +0 -39
  101. package/dist/adapt.d.ts +0 -39
  102. package/dist/adapt.js +0 -59
  103. package/dist/adapt.mjs +0 -57
  104. package/dist/composed-policy.d.mts +0 -115
  105. package/dist/composed-policy.d.ts +0 -115
  106. package/dist/composed-policy.js +0 -103
  107. package/dist/composed-policy.mjs +0 -97
  108. package/dist/config-CleTeeoW.d.mts +0 -233
  109. package/dist/config-XMOIkxFN.d.ts +0 -233
  110. package/dist/create-middleware.d.mts +0 -22
  111. package/dist/create-middleware.d.ts +0 -22
  112. package/dist/create-middleware.js +0 -34
  113. package/dist/create-middleware.mjs +0 -31
  114. package/dist/edge/index.d.mts +0 -112
  115. package/dist/edge/index.d.ts +0 -112
  116. package/dist/edge/index.js +0 -277
  117. package/dist/edge/index.mjs +0 -275
  118. package/dist/edge-runtime-loader.d.mts +0 -77
  119. package/dist/edge-runtime-loader.d.ts +0 -77
  120. package/dist/edge-runtime-loader.js +0 -242
  121. package/dist/edge-runtime-loader.mjs +0 -235
  122. package/dist/edge-wasm-middleware.d.mts +0 -62
  123. package/dist/edge-wasm-middleware.d.ts +0 -62
  124. package/dist/edge-wasm-middleware.js +0 -26
  125. package/dist/edge-wasm-middleware.mjs +0 -22
  126. package/dist/middleware.d.mts +0 -45
  127. package/dist/middleware.d.ts +0 -45
  128. package/dist/middleware.js +0 -19
  129. package/dist/middleware.mjs +0 -15
  130. package/dist/nodejs-wasm-loader.d.mts +0 -41
  131. package/dist/nodejs-wasm-loader.d.ts +0 -41
  132. package/dist/nodejs-wasm-loader.js +0 -36
  133. package/dist/nodejs-wasm-loader.mjs +0 -30
  134. package/dist/policy.d.mts +0 -162
  135. package/dist/policy.d.ts +0 -162
  136. package/dist/policy.js +0 -198
  137. package/dist/policy.mjs +0 -174
  138. package/dist/session-tracker.d.mts +0 -55
  139. package/dist/session-tracker.d.ts +0 -55
  140. package/dist/session-tracker.js +0 -172
  141. package/dist/session-tracker.mjs +0 -169
  142. package/dist/translate.d.mts +0 -63
  143. package/dist/translate.d.ts +0 -63
  144. package/dist/translate.js +0 -44
  145. package/dist/translate.mjs +0 -42
  146. package/dist/types-Chgi5TFC.d.mts +0 -105
  147. package/dist/types-Chgi5TFC.d.ts +0 -105
  148. package/dist/wasm-setup.d.mts +0 -46
  149. package/dist/wasm-setup.d.ts +0 -46
  150. package/dist/wasm-setup.js +0 -122
  151. package/dist/wasm-setup.mjs +0 -118
  152. package/wasm/agentshield_wasm.d.ts +0 -479
  153. package/wasm/agentshield_wasm.js +0 -1536
  154. package/wasm/agentshield_wasm_bg.wasm +0 -0
  155. package/wasm/package.json +0 -30
  156. package/wasm.d.ts +0 -21
@@ -1,352 +1,95 @@
1
- import { initEngineEdge, renderDecisionAsResponse, verifyRequestEdge } from '@kya-os/checkpoint-wasm-runtime/orchestrator/edge';
2
- export { initEngineEdge } from '@kya-os/checkpoint-wasm-runtime/orchestrator/edge';
3
- import { initPolicyEvaluatorEdge, evaluatePolicy } from '@kya-os/checkpoint-wasm-runtime/policy-edge';
4
- export { initPolicyEvaluatorEdge } from '@kya-os/checkpoint-wasm-runtime/policy-edge';
5
- import { selectBodyReadable200, resolveChallengeContext, PolicyFetcher, requestCarriesDelegationProof, resolveClientIp, acceptsHtml, encodeVerdictCookie, classifyResponseShape, BLOCKED_PATH, VERDICT_COOKIE_NAME } from '@kya-os/checkpoint-shared';
6
- import { applyBrowserPosture, applyBrowserIntegrityStepUp, validateBrowserIntegrityChallenge, makeComposedPolicyCache, isCredentialVerificationBlock, evaluateComposedPolicy, verifyResultToAuthorizeInput } from '@kya-os/checkpoint-wasm-runtime/composed-policy';
7
- import { validateBrowserPostureConfig } from '@kya-os/checkpoint-shared/browser-posture';
8
- import { makeSystemClock, makePolicyEvaluator, makeReputationOracle, makeStatusListCache, makeDidResolver } from '@kya-os/checkpoint-wasm-runtime/adapters';
9
- import { makeDetectionReporter } from '@kya-os/checkpoint-wasm-runtime/reporter';
10
- import { NextResponse } from 'next/server';
1
+ import { n as makeNextMiddleware } from "./middleware-core-B0jf5_Hm.mjs";
2
+ import { t as getCheckpointPostureOutcome } from "./posture-outcome-DQ4fdMfq.mjs";
3
+ import { DEFAULT_DASHBOARD_URL, consoleComposedPolicyLogger, makeComposedPolicyContext } from "@kya-os/checkpoint-wasm-runtime/composed-policy";
4
+ import { PolicyFetcher } from "@kya-os/checkpoint-shared/policy/fetcher";
5
+ import { initEngineEdge, renderDecisionAsResponse, verifyRequestEdge } from "@kya-os/checkpoint-wasm-runtime/orchestrator/edge";
6
+ import { evaluatePolicy, initPolicyEvaluatorEdge, isCedarModule } from "@kya-os/checkpoint-wasm-runtime/policy-edge";
11
7
 
12
- // src/middleware-edge.ts
13
- var DEFAULT_DASHBOARD_URL = "https://kya.vouched.id";
14
- var NOOP_LOGGER = {
15
- shadowDivergence: () => {
16
- },
17
- evaluationError: () => {
18
- }
19
- };
20
- function makeComposedPolicyContext(opts) {
21
- const { projectId, fetcher } = opts;
22
- const cache = makeComposedPolicyCache({ compile: opts.compile, cacheMax: opts.cacheMax });
23
- const logger = opts.logger ?? NOOP_LOGGER;
24
- return {
25
- async apply(result, path) {
26
- const structured = { decision: result.decision, acted: false };
27
- if (isCredentialVerificationBlock(result.decision)) return structured;
28
- const policy = await fetcher.getPolicy(projectId);
29
- const outcome = await evaluateComposedPolicy({
30
- cache,
31
- projectId,
32
- flags: {
33
- policyLanguage: policy.policyLanguage,
34
- policySourceText: policy.policySourceText,
35
- engineEnforcementEnabled: policy.engineEnforcementEnabled,
36
- enabled: policy.enabled
37
- },
38
- authorizeInput: verifyResultToAuthorizeInput(result, { tenantId: projectId, path }),
39
- baselineDecisionKind: result.decision.kind
40
- });
41
- if ((outcome.status === "acting" || outcome.status === "shadow") && outcome.diverged) {
42
- logger.shadowDivergence({
43
- projectId,
44
- path,
45
- engineDecision: outcome.engineDecision.kind,
46
- structuredDecision: result.decision.kind,
47
- detectionClass: result.detectionDetail.detectionClass.type,
48
- verificationMethod: result.detectionDetail.verificationMethod,
49
- confidence: result.detectionDetail.confidence,
50
- agentName: result.detectionDetail.detectedAgent?.name
51
- });
52
- }
53
- if (outcome.status === "error") {
54
- logger.evaluationError(projectId, outcome.error);
55
- return structured;
56
- }
57
- if (outcome.status === "acting") {
58
- return {
59
- decision: outcome.engineDecision,
60
- acted: true,
61
- // Echo the SSOT revision pin with the decision it produced (#3246
62
- // PR5). Conditional spread: absent upstream stays absent here.
63
- ...policy.policySourceHash ? { composedBlobHash: policy.policySourceHash } : {}
64
- };
65
- }
66
- return structured;
67
- },
68
- async trustedDelegationRoots() {
69
- const policy = await fetcher.getPolicy(projectId);
70
- return policy.trustedDelegationRoots ?? [];
71
- }
72
- };
73
- }
74
- async function resolveTrustedDelegationRootsForRequest(resolver, headers) {
75
- if (!resolver) return void 0;
76
- if (!requestCarriesDelegationProof(headers)) return void 0;
77
- const roots = await resolver();
78
- return roots.length > 0 ? roots : void 0;
79
- }
80
- async function applyComposedPolicy(context, result, path) {
81
- if (!context) return;
82
- try {
83
- const outcome = await context.apply(result, path);
84
- if (outcome.acted) {
85
- result.decision = outcome.decision;
86
- if (outcome.composedBlobHash) {
87
- result.composedBlobHash = outcome.composedBlobHash;
88
- }
89
- }
90
- } catch {
91
- }
92
- }
93
- var consoleComposedPolicyLogger = {
94
- shadowDivergence(info) {
95
- console.warn("[checkpoint/composed-policy] shadow-divergence", info);
96
- },
97
- evaluationError(projectId, error) {
98
- console.error(
99
- `[checkpoint/composed-policy] evaluation failed for ${projectId}; using structured decision:`,
100
- error
101
- );
102
- }
103
- };
104
- function adaptToNextResponse(rendered, req) {
105
- const clientAcceptsHtml = acceptsHtml(req.headers);
106
- const verdictCookie = encodeVerdictCookie(rendered);
107
- const shape = classifyResponseShape(rendered, clientAcceptsHtml);
108
- switch (shape) {
109
- case "pass-through": {
110
- const res = NextResponse.next();
111
- applyHeaders(res, rendered);
112
- setVerdictCookie(res, verdictCookie);
113
- return res;
114
- }
115
- case "redirect": {
116
- const target = new URL(rendered.headers.Location);
117
- const res = NextResponse.redirect(target);
118
- applyHeaders(res, rendered);
119
- setVerdictCookie(res, verdictCookie);
120
- return res;
121
- }
122
- case "html-block": {
123
- const blockedUrl = new URL(BLOCKED_PATH, req.url);
124
- const res = NextResponse.rewrite(blockedUrl, { status: 200 });
125
- applyHeaders(res, rendered);
126
- setVerdictCookie(res, verdictCookie);
127
- return res;
128
- }
129
- case "json-block": {
130
- const body = rendered.body ?? {};
131
- const res = NextResponse.json(body, { status: rendered.status });
132
- applyHeaders(res, rendered);
133
- setVerdictCookie(res, verdictCookie);
134
- return res;
135
- }
136
- }
137
- }
138
- function setVerdictCookie(res, value) {
139
- res.cookies.set({
140
- name: VERDICT_COOKIE_NAME,
141
- value,
142
- path: "/",
143
- sameSite: "lax",
144
- httpOnly: false
145
- });
146
- }
147
- function applyHeaders(res, rendered) {
148
- for (const [key, value] of Object.entries(rendered.headers)) {
149
- res.headers.set(key, value);
150
- }
151
- for (const [key, value] of rendered.headerEntries ?? []) {
152
- res.headers.append(key, value);
153
- }
154
- }
155
- async function nextRequestToHttpLike(req, opts = {}) {
156
- const url = new URL(req.url);
157
- const body = await tryDrainJsonBody(req, opts);
158
- return {
159
- method: req.method,
160
- // Path + query only — orchestrator's URL parsing expects no scheme/host.
161
- url: url.pathname + url.search,
162
- headers: headersToRecord(req.headers),
163
- body,
164
- remoteAddress: extractRemoteAddress(req, opts.clientIpPolicy ?? { platform: "direct" })
165
- };
166
- }
167
- async function tryDrainJsonBody(req, opts) {
168
- if (opts.drainJsonBody === false) return null;
169
- const contentType = req.headers.get("content-type") ?? "";
170
- if (!contentType.toLowerCase().includes("application/json")) return null;
171
- try {
172
- return await req.clone().text();
173
- } catch {
174
- return null;
175
- }
176
- }
177
- function headersToRecord(headers) {
178
- const out = {};
179
- headers.forEach((value, key) => {
180
- out[key.toLowerCase()] = value;
181
- });
182
- return out;
183
- }
184
- function extractRemoteAddress(req, policy) {
185
- const maybeIp = req.ip;
186
- return resolveClientIp({
187
- headers: req.headers,
188
- frameworkAddress: maybeIp,
189
- policy
190
- }).ip ?? void 0;
191
- }
192
-
193
- // src/middleware-core.ts
194
- function makeNextMiddleware(verifyRequest, renderDecisionAsResponse2, config, host) {
195
- if (config.browserPosture) validateBrowserPostureConfig(config.browserPosture, config.projectId);
196
- if (config.browserPosture?.protectedRoutes?.length && !config.resolveDelegationChallenge) {
197
- throw new Error(
198
- "browserPosture.protectedRoutes requires resolveDelegationChallenge (see createBrowserIntegrityChallengeResolver)"
199
- );
200
- }
201
- const opts = buildVerifyOpts(config);
202
- const reporter = buildReporter(config, host.runtime);
203
- const composed = host.buildComposedContext(config);
204
- const trustedRootsResolver = buildTrustedRootsResolver(config, composed);
205
- const translateOpts = {
206
- drainJsonBody: config.drainJsonBody,
207
- clientIpPolicy: config.clientIpPolicy
208
- };
209
- return async function checkpointMiddleware(req, event) {
210
- const httpLike = await nextRequestToHttpLike(req, translateOpts);
211
- const trustedDelegationRoots = await resolveTrustedDelegationRootsForRequest(
212
- trustedRootsResolver,
213
- req.headers
214
- );
215
- const result = await verifyRequest(
216
- httpLike,
217
- trustedDelegationRoots ? { ...opts, trustedDelegationRoots } : opts
218
- );
219
- await applyBrowserPosture(
220
- result,
221
- req.headers.get("cookie"),
222
- config.browserPosture,
223
- config.projectId
224
- );
225
- await applyComposedPolicy(composed, result, req.nextUrl.pathname);
226
- applyBrowserIntegrityStepUp(result, config.browserPosture, req.nextUrl.pathname);
227
- if (reporter) {
228
- const reportPromise = reporter(
229
- result,
230
- extractReporterContext(req, config.clientIpPolicy ?? { platform: "direct" })
231
- );
232
- if (event) {
233
- event.waitUntil(reportPromise);
234
- }
235
- }
236
- await dispatchOnResult(config, result, req);
237
- const bodyReadable200 = selectBodyReadable200(
238
- config.delegationChallengeMode ?? "negotiated",
239
- req.headers,
240
- result.detectionDetail.detectionClass,
241
- result.detectionDetail.isAgent
242
- );
243
- const challengeContextRequested = result.enforcementMode === "enforce" && result.decision.kind === "Challenge" && config.resolveDelegationChallenge !== void 0;
244
- const delegationChallenge = challengeContextRequested ? await resolveChallengeContext(
245
- config.resolveDelegationChallenge,
246
- { result, request: req },
247
- {
248
- timeoutMs: config.delegationChallengeTimeoutMs,
249
- onFailure: config.onDelegationChallengeFailure
250
- }
251
- ) : void 0;
252
- const rendered = renderDecisionAsResponse2(result, {
253
- bodyReadable200,
254
- delegationChallenge: validateBrowserIntegrityChallenge(result, delegationChallenge),
255
- challengeContextRequested
256
- });
257
- return adaptToNextResponse(rendered, req);
258
- };
259
- }
260
- var SDK_NAME = "@kya-os/checkpoint-nextjs";
261
- var VERSION = "1.9.0";
262
- function buildReporter(config, runtime = "node") {
263
- if (!config.apiKey) return null;
264
- return makeDetectionReporter({
265
- apiKey: config.apiKey,
266
- baseUrl: config.baseUrl,
267
- debug: config.debug,
268
- // Self-identify (incl. node-vs-edge) so the dashboard can version-gate
269
- // enforcement. Next.js EDGE composed enforcement is opt-in (needs
270
- // `cedarWasmModule`), so the dashboard shows it as opt-in, never "Enforcing".
271
- sdk: { name: SDK_NAME, version: VERSION, runtime }
272
- });
273
- }
274
- function buildTrustedRootsResolver(config, composed) {
275
- if (config.trustedDelegationRoots) return () => Promise.resolve(config.trustedDelegationRoots);
276
- if (composed?.trustedDelegationRoots) {
277
- return () => composed.trustedDelegationRoots();
278
- }
279
- if (!config.projectId) return null;
280
- const fetcher = new PolicyFetcher({
281
- apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
282
- apiKey: config.apiKey,
283
- cacheTtlSeconds: config.policyCacheTtlSeconds
284
- });
285
- const projectId = config.projectId;
286
- return async () => (await fetcher.getPolicy(projectId)).trustedDelegationRoots ?? [];
287
- }
288
- function extractReporterContext(req, policy) {
289
- const resolution = resolveClientIp({
290
- headers: req.headers,
291
- frameworkAddress: req.ip,
292
- policy
293
- });
294
- return {
295
- userAgent: req.headers.get("user-agent") ?? void 0,
296
- ipAddress: resolution.ip ?? void 0,
297
- path: req.nextUrl.pathname,
298
- url: req.nextUrl.href,
299
- method: req.method
300
- };
301
- }
302
- function buildVerifyOpts(config) {
303
- const overrides = config.adapters ?? {};
304
- return {
305
- didResolver: overrides.didResolver ?? makeDidResolver(),
306
- statusListCache: overrides.statusListCache ?? makeStatusListCache(),
307
- reputationOracle: overrides.reputationOracle ?? makeReputationOracle({ argusUrl: config.argusUrl }),
308
- policyEvaluator: overrides.policyEvaluator ?? makePolicyEvaluator({ dashboardUrl: config.dashboardUrl }),
309
- clock: makeSystemClock(),
310
- tenantHost: config.tenantHost,
311
- resourceOrgDid: config.resourceOrgDid,
312
- trustedDelegationRoots: config.trustedDelegationRoots,
313
- enforcementMode: config.enforcementMode ?? "enforce",
314
- reputationBaseline: config.reputationBaseline,
315
- argusUrl: config.argusUrl,
316
- legacyEnvelopeFallback: config.legacyEnvelopeFallback ?? false,
317
- engineConfig: config.engineConfig
318
- };
319
- }
320
- async function dispatchOnResult(config, result, req) {
321
- if (!config.onResult) return;
322
- try {
323
- await config.onResult(result, req);
324
- } catch {
325
- }
326
- }
327
-
328
- // src/middleware-edge.ts
8
+ //#region src/middleware-edge.ts
9
+ /**
10
+ * Edge host: the engine runs on the module the host passes. The Cedar build
11
+ * (`./cedar-wasm`) is the engine plus Cedar, so passed as `engineWasmModule`
12
+ * (or alone as `cedarWasmModule`) one instance serves detection and policy.
13
+ */
329
14
  function withCheckpoint(config) {
330
- void initEngineEdge();
331
- return makeNextMiddleware(verifyRequestEdge, renderDecisionAsResponse, config, {
332
- runtime: "edge",
333
- buildComposedContext
334
- });
335
- }
15
+ return makeNextMiddleware(config, {
16
+ runtime: "edge",
17
+ loadEngine: async () => {
18
+ await initEngineEdge(engineModule(config));
19
+ return {
20
+ verifyRequest: verifyRequestEdge,
21
+ renderDecisionAsResponse
22
+ };
23
+ },
24
+ buildComposedContext,
25
+ start: checkModules
26
+ });
27
+ }
28
+ /** The module the engine runs on: `engineWasmModule`, else the Cedar build. */
29
+ function engineModule(config) {
30
+ return config.engineWasmModule ?? config.cedarWasmModule;
31
+ }
32
+ /** The Cedar build, whichever field it was passed in. */
33
+ function cedarModule(config) {
34
+ if (config.cedarWasmModule) return config.cedarWasmModule;
35
+ return isCedarModule(config.engineWasmModule) ? config.engineWasmModule : void 0;
36
+ }
37
+ function checkModules(config) {
38
+ if (!engineModule(config)) throw new Error("withCheckpoint on the Edge runtime needs engineWasmModule: import it from '@kya-os/checkpoint-nextjs/engine-wasm' (detection), or from '@kya-os/checkpoint-nextjs/cedar-wasm' (detection and Cedar policy), and pass it in the config");
39
+ if (config.debug && config.engineWasmModule && config.cedarWasmModule && !isCedarModule(config.engineWasmModule)) console.warn("[checkpoint] engineWasmModule and cedarWasmModule are two different builds, so the Edge bundle carries the engine twice. The Cedar build is the engine too: pass '@kya-os/checkpoint-nextjs/cedar-wasm' as engineWasmModule alone to run detection and Cedar on one module.");
40
+ }
41
+ /**
42
+ * A project has a Cedar policy, but this Edge middleware has no Cedar module to
43
+ * evaluate it with.
44
+ */
45
+ var CedarWasmModuleMissingError = class extends Error {
46
+ constructor(projectId) {
47
+ super(`Project ${projectId} has a Cedar policy, but withCheckpoint on the Edge runtime has no Cedar module to evaluate it: import it from '@kya-os/checkpoint-nextjs/cedar-wasm' and pass it as engineWasmModule, in place of the engine-only build, so one module runs detection and Cedar. Requests are answered 503 while the policy is enforcing.`);
48
+ this.name = "CedarWasmModuleMissingError";
49
+ }
50
+ };
51
+ /**
52
+ * Build the EDGE-runtime composed-policy context. The Cedar build is opt-in on
53
+ * the Edge runtime (it is larger than the engine-only build), so Edge bundles
54
+ * that never evaluate Cedar don't carry it. When the host passes it, as
55
+ * `engineWasmModule` or `cedarWasmModule`, it is registered via
56
+ * `initPolicyEvaluatorEdge`, wasm-runtime evaluates policy on the engine's own
57
+ * instance when the engine runs on it, and the async `evaluatePolicy` compiler
58
+ * is injected into the shared core.
59
+ *
60
+ * Without it a project's policy is still fetched and is never skipped: its
61
+ * compiler throws `CedarWasmModuleMissingError`, so a project with no Cedar
62
+ * policy is unaffected, a policy in shadow mode keeps the structured decision,
63
+ * and an enforcing policy answers 503, as any composed-policy fault does.
64
+ */
336
65
  function buildComposedContext(config) {
337
- if (config.composedPolicyEnforcer) return config.composedPolicyEnforcer;
338
- if (!config.projectId || !config.cedarWasmModule) return null;
339
- initPolicyEvaluatorEdge(config.cedarWasmModule);
340
- return makeComposedPolicyContext({
341
- projectId: config.projectId,
342
- fetcher: new PolicyFetcher({
343
- apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
344
- apiKey: config.apiKey,
345
- cacheTtlSeconds: config.policyCacheTtlSeconds
346
- }),
347
- compile: (language, source) => evaluatePolicy(language, source),
348
- logger: config.debug ? consoleComposedPolicyLogger : void 0
349
- });
66
+ if (config.composedPolicyEnforcer) return config.composedPolicyEnforcer;
67
+ if (!config.projectId) return null;
68
+ const projectId = config.projectId;
69
+ const cedarWasmModule = cedarModule(config);
70
+ if (cedarWasmModule) initPolicyEvaluatorEdge(cedarWasmModule);
71
+ let reportedMissingModule = false;
72
+ return makeComposedPolicyContext({
73
+ projectId,
74
+ fetcher: new PolicyFetcher({
75
+ apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
76
+ apiKey: config.apiKey,
77
+ cacheTtlSeconds: config.policyCacheTtlSeconds,
78
+ throwOnUnavailable: true
79
+ }),
80
+ compile: async (language, source) => {
81
+ if (cedarWasmModule) return evaluatePolicy(language, source);
82
+ const error = new CedarWasmModuleMissingError(projectId);
83
+ if (!reportedMissingModule) {
84
+ reportedMissingModule = true;
85
+ console.error(`[checkpoint] ${error.message}`);
86
+ }
87
+ throw error;
88
+ },
89
+ logger: config.debug ? consoleComposedPolicyLogger : void 0
90
+ });
350
91
  }
351
92
 
352
- export { withCheckpoint };
93
+ //#endregion
94
+ export { CedarWasmModuleMissingError, getCheckpointPostureOutcome, initEngineEdge, initPolicyEvaluatorEdge, withCheckpoint };
95
+ //# sourceMappingURL=middleware-edge.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware-edge.mjs","names":[],"sources":["../src/middleware-edge.ts"],"sourcesContent":["/**\n * Edge host: the engine runs on the module the host passes. The Cedar build\n * (`./cedar-wasm`) is the engine plus Cedar, so passed as `engineWasmModule`\n * (or alone as `cedarWasmModule`) one instance serves detection and policy.\n */\nimport {\n initEngineEdge,\n renderDecisionAsResponse,\n verifyRequestEdge,\n} from '@kya-os/checkpoint-wasm-runtime/orchestrator/edge';\nimport {\n evaluatePolicy,\n initPolicyEvaluatorEdge,\n isCedarModule,\n} from '@kya-os/checkpoint-wasm-runtime/policy-edge';\nimport { PolicyFetcher } from '@kya-os/checkpoint-shared/policy/fetcher';\nimport {\n makeComposedPolicyContext,\n consoleComposedPolicyLogger,\n DEFAULT_DASHBOARD_URL,\n type ComposedPolicyContext,\n} from '@kya-os/checkpoint-wasm-runtime/composed-policy';\nimport { makeNextMiddleware } from './middleware-core';\nimport type { CheckpointConfig, CheckpointEdgeConfig } from './config';\nexport type { CheckpointConfig, CheckpointEdgeConfig } from './config';\nexport {\n getCheckpointPostureOutcome,\n type CheckpointPostureOptions,\n type CheckpointPostureOutcome,\n} from './posture-outcome';\n\nexport function withCheckpoint(config: CheckpointEdgeConfig) {\n return makeNextMiddleware(config, {\n runtime: 'edge',\n // Every attempt passes the module: after a failed init wasm-runtime\n // forgets the module it was given, and an init without one tries to\n // compile bytes, which the Edge runtime cannot do. A failed load is\n // retried by the next request; once loaded, this resolves at once.\n loadEngine: async () => {\n await initEngineEdge(engineModule(config));\n return { verifyRequest: verifyRequestEdge, renderDecisionAsResponse };\n },\n buildComposedContext,\n start: checkModules,\n });\n}\n\n/** The module the engine runs on: `engineWasmModule`, else the Cedar build. */\nfunction engineModule(config: CheckpointConfig): WebAssembly.Module | undefined {\n return config.engineWasmModule ?? config.cedarWasmModule;\n}\n\n/** The Cedar build, whichever field it was passed in. */\nfunction cedarModule(config: CheckpointConfig): WebAssembly.Module | undefined {\n if (config.cedarWasmModule) return config.cedarWasmModule;\n return isCedarModule(config.engineWasmModule) ? config.engineWasmModule : undefined;\n}\n\nfunction checkModules(config: CheckpointConfig): void {\n // `config` is typed, but the `.` entry's types are the Node build's, where\n // both modules are optional, so check here.\n if (!engineModule(config)) {\n throw new Error(\n 'withCheckpoint on the Edge runtime needs engineWasmModule: import it from ' +\n \"'@kya-os/checkpoint-nextjs/engine-wasm' (detection), or from \" +\n \"'@kya-os/checkpoint-nextjs/cedar-wasm' (detection and Cedar policy), and pass it in the config\"\n );\n }\n if (\n config.debug &&\n config.engineWasmModule &&\n config.cedarWasmModule &&\n !isCedarModule(config.engineWasmModule)\n ) {\n console.warn(\n '[checkpoint] engineWasmModule and cedarWasmModule are two different builds, so the Edge ' +\n 'bundle carries the engine twice. The Cedar build is the engine too: pass ' +\n \"'@kya-os/checkpoint-nextjs/cedar-wasm' as engineWasmModule alone to run detection and \" +\n 'Cedar on one module.'\n );\n }\n}\n\n/**\n * A project has a Cedar policy, but this Edge middleware has no Cedar module to\n * evaluate it with.\n */\nexport class CedarWasmModuleMissingError extends Error {\n constructor(projectId: string) {\n super(\n `Project ${projectId} has a Cedar policy, but withCheckpoint on the Edge runtime has no ` +\n \"Cedar module to evaluate it: import it from '@kya-os/checkpoint-nextjs/cedar-wasm' and \" +\n 'pass it as engineWasmModule, in place of the engine-only build, so one module runs ' +\n 'detection and Cedar. Requests are answered 503 while the policy is enforcing.'\n );\n this.name = 'CedarWasmModuleMissingError';\n }\n}\n\n/**\n * Build the EDGE-runtime composed-policy context. The Cedar build is opt-in on\n * the Edge runtime (it is larger than the engine-only build), so Edge bundles\n * that never evaluate Cedar don't carry it. When the host passes it, as\n * `engineWasmModule` or `cedarWasmModule`, it is registered via\n * `initPolicyEvaluatorEdge`, wasm-runtime evaluates policy on the engine's own\n * instance when the engine runs on it, and the async `evaluatePolicy` compiler\n * is injected into the shared core.\n *\n * Without it a project's policy is still fetched and is never skipped: its\n * compiler throws `CedarWasmModuleMissingError`, so a project with no Cedar\n * policy is unaffected, a policy in shadow mode keeps the structured decision,\n * and an enforcing policy answers 503, as any composed-policy fault does.\n */\nfunction buildComposedContext(config: CheckpointConfig): ComposedPolicyContext | null {\n if (config.composedPolicyEnforcer) return config.composedPolicyEnforcer;\n if (!config.projectId) return null;\n const projectId = config.projectId;\n const cedarWasmModule = cedarModule(config);\n if (cedarWasmModule) initPolicyEvaluatorEdge(cedarWasmModule);\n let reportedMissingModule = false;\n return makeComposedPolicyContext({\n projectId,\n fetcher: new PolicyFetcher({\n apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,\n apiKey: config.apiKey,\n cacheTtlSeconds: config.policyCacheTtlSeconds,\n throwOnUnavailable: true,\n }),\n compile: async (language, source) => {\n if (cedarWasmModule) return evaluatePolicy(language, source);\n const error = new CedarWasmModuleMissingError(projectId);\n if (!reportedMissingModule) {\n reportedMissingModule = true;\n console.error(`[checkpoint] ${error.message}`);\n }\n throw error;\n },\n logger: config.debug ? consoleComposedPolicyLogger : undefined,\n });\n}\n\n// Allow hosts to initialize their WASM modules explicitly at startup.\nexport { initEngineEdge, initPolicyEvaluatorEdge };\n"],"mappings":";;;;;;;;;;;;;AA+BA,SAAgB,eAAe,QAA8B;CAC3D,OAAO,mBAAmB,QAAQ;EAChC,SAAS;EAKT,YAAY,YAAY;GACtB,MAAM,eAAe,aAAa,MAAM,CAAC;GACzC,OAAO;IAAE,eAAe;IAAmB;GAAyB;EACtE;EACA;EACA,OAAO;CACT,CAAC;AACH;;AAGA,SAAS,aAAa,QAA0D;CAC9E,OAAO,OAAO,oBAAoB,OAAO;AAC3C;;AAGA,SAAS,YAAY,QAA0D;CAC7E,IAAI,OAAO,iBAAiB,OAAO,OAAO;CAC1C,OAAO,cAAc,OAAO,gBAAgB,IAAI,OAAO,mBAAmB;AAC5E;AAEA,SAAS,aAAa,QAAgC;CAGpD,IAAI,CAAC,aAAa,MAAM,GACtB,MAAM,IAAI,MACR,uOAGF;CAEF,IACE,OAAO,SACP,OAAO,oBACP,OAAO,mBACP,CAAC,cAAc,OAAO,gBAAgB,GAEtC,QAAQ,KACN,6QAIF;AAEJ;;;;;AAMA,IAAa,8BAAb,cAAiD,MAAM;CACrD,YAAY,WAAmB;EAC7B,MACE,WAAW,UAAU,2TAIvB;EACA,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;;;;AAgBA,SAAS,qBAAqB,QAAwD;CACpF,IAAI,OAAO,wBAAwB,OAAO,OAAO;CACjD,IAAI,CAAC,OAAO,WAAW,OAAO;CAC9B,MAAM,YAAY,OAAO;CACzB,MAAM,kBAAkB,YAAY,MAAM;CAC1C,IAAI,iBAAiB,wBAAwB,eAAe;CAC5D,IAAI,wBAAwB;CAC5B,OAAO,0BAA0B;EAC/B;EACA,SAAS,IAAI,cAAc;GACzB,YAAY,OAAO,gBAAgB,OAAO,WAAW;GACrD,QAAQ,OAAO;GACf,iBAAiB,OAAO;GACxB,oBAAoB;EACtB,CAAC;EACD,SAAS,OAAO,UAAU,WAAW;GACnC,IAAI,iBAAiB,OAAO,eAAe,UAAU,MAAM;GAC3D,MAAM,QAAQ,IAAI,4BAA4B,SAAS;GACvD,IAAI,CAAC,uBAAuB;IAC1B,wBAAwB;IACxB,QAAQ,MAAM,gBAAgB,MAAM,SAAS;GAC/C;GACA,MAAM;EACR;EACA,QAAQ,OAAO,QAAQ,8BAA8B;CACvD,CAAC;AACH"}
@@ -0,0 +1,39 @@
1
+ let _kya_os_checkpoint_wasm_runtime_composed_policy = require("@kya-os/checkpoint-wasm-runtime/composed-policy");
2
+ let _kya_os_checkpoint_shared_policy_fetcher = require("@kya-os/checkpoint-shared/policy/fetcher");
3
+
4
+ //#region src/middleware-node-context.ts
5
+ /**
6
+ * Build the Node-runtime composed-policy context. Prefers an injected enforcer
7
+ * (advanced/testing); otherwise constructs one from `projectId` with the SYNC
8
+ * `createPolicyEvaluator` compiler (loads the cedar-nodejs glue lazily on first
9
+ * use — no init handshake, never bundled into the edge build). Returns `null`
10
+ * when composed enforcement isn't configured (back-compat). The composed-policy
11
+ * fetch honors `dashboardUrl ?? baseUrl ?? default` (the documented policy-fetch
12
+ * base).
13
+ */
14
+ function buildComposedContext(config) {
15
+ if (config.composedPolicyEnforcer) return config.composedPolicyEnforcer;
16
+ if (!config.projectId) return null;
17
+ return (0, _kya_os_checkpoint_wasm_runtime_composed_policy.makeComposedPolicyContext)({
18
+ projectId: config.projectId,
19
+ fetcher: new _kya_os_checkpoint_shared_policy_fetcher.PolicyFetcher({
20
+ apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? _kya_os_checkpoint_wasm_runtime_composed_policy.DEFAULT_DASHBOARD_URL,
21
+ apiKey: config.apiKey,
22
+ cacheTtlSeconds: config.policyCacheTtlSeconds,
23
+ throwOnUnavailable: true
24
+ }),
25
+ compile: async (_language, source) => {
26
+ const { createPolicyEvaluator } = await import("@kya-os/checkpoint-wasm-runtime/policy");
27
+ return createPolicyEvaluator(source);
28
+ },
29
+ logger: config.debug ? _kya_os_checkpoint_wasm_runtime_composed_policy.consoleComposedPolicyLogger : void 0
30
+ });
31
+ }
32
+
33
+ //#endregion
34
+ Object.defineProperty(exports, 'buildComposedContext', {
35
+ enumerable: true,
36
+ get: function () {
37
+ return buildComposedContext;
38
+ }
39
+ });
@@ -0,0 +1,35 @@
1
+ import { DEFAULT_DASHBOARD_URL, consoleComposedPolicyLogger, makeComposedPolicyContext } from "@kya-os/checkpoint-wasm-runtime/composed-policy";
2
+ import { PolicyFetcher } from "@kya-os/checkpoint-shared/policy/fetcher";
3
+
4
+ //#region src/middleware-node-context.ts
5
+ /**
6
+ * Build the Node-runtime composed-policy context. Prefers an injected enforcer
7
+ * (advanced/testing); otherwise constructs one from `projectId` with the SYNC
8
+ * `createPolicyEvaluator` compiler (loads the cedar-nodejs glue lazily on first
9
+ * use — no init handshake, never bundled into the edge build). Returns `null`
10
+ * when composed enforcement isn't configured (back-compat). The composed-policy
11
+ * fetch honors `dashboardUrl ?? baseUrl ?? default` (the documented policy-fetch
12
+ * base).
13
+ */
14
+ function buildComposedContext(config) {
15
+ if (config.composedPolicyEnforcer) return config.composedPolicyEnforcer;
16
+ if (!config.projectId) return null;
17
+ return makeComposedPolicyContext({
18
+ projectId: config.projectId,
19
+ fetcher: new PolicyFetcher({
20
+ apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
21
+ apiKey: config.apiKey,
22
+ cacheTtlSeconds: config.policyCacheTtlSeconds,
23
+ throwOnUnavailable: true
24
+ }),
25
+ compile: async (_language, source) => {
26
+ const { createPolicyEvaluator } = await import("@kya-os/checkpoint-wasm-runtime/policy");
27
+ return createPolicyEvaluator(source);
28
+ },
29
+ logger: config.debug ? consoleComposedPolicyLogger : void 0
30
+ });
31
+ }
32
+
33
+ //#endregion
34
+ export { buildComposedContext as t };
35
+ //# sourceMappingURL=middleware-node-context-D_ZyUEcA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware-node-context-D_ZyUEcA.mjs","names":[],"sources":["../src/middleware-node-context.ts"],"sourcesContent":["import { PolicyFetcher } from '@kya-os/checkpoint-shared/policy/fetcher';\nimport type { CheckpointConfig } from './config';\nimport {\n makeComposedPolicyContext,\n consoleComposedPolicyLogger,\n DEFAULT_DASHBOARD_URL,\n type ComposedPolicyContext,\n} from '@kya-os/checkpoint-wasm-runtime/composed-policy';\n\n/**\n * Build the Node-runtime composed-policy context. Prefers an injected enforcer\n * (advanced/testing); otherwise constructs one from `projectId` with the SYNC\n * `createPolicyEvaluator` compiler (loads the cedar-nodejs glue lazily on first\n * use — no init handshake, never bundled into the edge build). Returns `null`\n * when composed enforcement isn't configured (back-compat). The composed-policy\n * fetch honors `dashboardUrl ?? baseUrl ?? default` (the documented policy-fetch\n * base).\n */\nexport function buildComposedContext(config: CheckpointConfig): ComposedPolicyContext | null {\n if (config.composedPolicyEnforcer) return config.composedPolicyEnforcer;\n if (!config.projectId) return null;\n return makeComposedPolicyContext({\n projectId: config.projectId,\n fetcher: new PolicyFetcher({\n apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,\n apiKey: config.apiKey,\n cacheTtlSeconds: config.policyCacheTtlSeconds,\n throwOnUnavailable: true,\n }),\n // Load the Node policy compiler only on first use. This module is imported\n // exclusively by the Node and bundler hosts, never by the Edge pipeline.\n compile: async (_language, source) => {\n const { createPolicyEvaluator } = await import('@kya-os/checkpoint-wasm-runtime/policy');\n return createPolicyEvaluator(source);\n },\n logger: config.debug ? consoleComposedPolicyLogger : undefined,\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAgB,qBAAqB,QAAwD;CAC3F,IAAI,OAAO,wBAAwB,OAAO,OAAO;CACjD,IAAI,CAAC,OAAO,WAAW,OAAO;CAC9B,OAAO,0BAA0B;EAC/B,WAAW,OAAO;EAClB,SAAS,IAAI,cAAc;GACzB,YAAY,OAAO,gBAAgB,OAAO,WAAW;GACrD,QAAQ,OAAO;GACf,iBAAiB,OAAO;GACxB,oBAAoB;EACtB,CAAC;EAGD,SAAS,OAAO,WAAW,WAAW;GACpC,MAAM,EAAE,0BAA0B,MAAM,OAAO;GAC/C,OAAO,sBAAsB,MAAM;EACrC;EACA,QAAQ,OAAO,QAAQ,8BAA8B;CACvD,CAAC;AACH"}
@@ -1,27 +1,12 @@
1
- import * as next_server from 'next/server';
2
- import { C as CheckpointConfig } from './config-CleTeeoW.mjs';
3
- import '@kya-os/checkpoint-shared/browser-posture';
4
- import '@kya-os/checkpoint-wasm-runtime/adapters';
5
- import '@kya-os/checkpoint-wasm-runtime/engine';
6
- import '@kya-os/checkpoint-shared';
7
- import './composed-policy.mjs';
8
- import '@kya-os/checkpoint-wasm-runtime/composed-policy';
9
-
1
+ import { t as CheckpointConfig } from "./config-CPP1RV0f.mjs";
2
+ import { t as VERSION } from "./middleware-core-DycsbHUd.mjs";
3
+ //#region src/middleware-node.d.ts
10
4
  /**
11
- * Shared Next.js request pipeline. Node, bundler and Edge hosts inject their
12
- * engine and policy-context factories; runtime-specific WASM initialization
13
- * stays in each host entry. Public withCheckpoint exports live there too.
5
+ * `withCheckpoint` on the Node.js runtime, bundled (`proxy.ts`, `middleware.ts`)
6
+ * or not. The engine's Node build loads its `.wasm` through `new URL(...,
7
+ * import.meta.url)`, which bundlers follow and copy.
14
8
  */
15
-
16
- /**
17
- * Installed SDK version, self-reported to the detection reporter so the
18
- * dashboard can version-gate "composed policy enforces here". MUST equal
19
- * `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
20
- * drifted). Re-exported as `VERSION` from the package index.
21
- */
22
- declare const VERSION = "1.9.0";
23
-
24
- /** Node host with native filesystem WASM loading. */
25
- declare function withCheckpoint(config: CheckpointConfig): (req: next_server.NextRequest, event?: Pick<next_server.NextFetchEvent, "waitUntil">) => Promise<next_server.NextResponse>;
26
-
27
- export { CheckpointConfig, VERSION, withCheckpoint };
9
+ export declare function withCheckpoint(config: CheckpointConfig): (req: import("next/server").NextRequest, event?: Pick<import("next/server").NextFetchEvent, "waitUntil">) => Promise<import("next/server").NextResponse>;
10
+ //#endregion
11
+ export { type CheckpointConfig, VERSION };
12
+ //# sourceMappingURL=middleware-node.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware-node.d.mts","names":[],"sources":["../src/middleware-node.ts"],"mappings":";;;;;;;;wBAUgB,eAAe,QAAQ,oBAAgB,2BAAA,aAAA,QAAA,2BAAA,iCAAA,8BAAA"}
@@ -1,27 +1,12 @@
1
- import * as next_server from 'next/server';
2
- import { C as CheckpointConfig } from './config-XMOIkxFN.js';
3
- import '@kya-os/checkpoint-shared/browser-posture';
4
- import '@kya-os/checkpoint-wasm-runtime/adapters';
5
- import '@kya-os/checkpoint-wasm-runtime/engine';
6
- import '@kya-os/checkpoint-shared';
7
- import './composed-policy.js';
8
- import '@kya-os/checkpoint-wasm-runtime/composed-policy';
9
-
1
+ import { t as CheckpointConfig } from "./config-DVgOFxJs.js";
2
+ import { t as VERSION } from "./middleware-core-Bol44X9C.js";
3
+ //#region src/middleware-node.d.ts
10
4
  /**
11
- * Shared Next.js request pipeline. Node, bundler and Edge hosts inject their
12
- * engine and policy-context factories; runtime-specific WASM initialization
13
- * stays in each host entry. Public withCheckpoint exports live there too.
5
+ * `withCheckpoint` on the Node.js runtime, bundled (`proxy.ts`, `middleware.ts`)
6
+ * or not. The engine's Node build loads its `.wasm` through `new URL(...,
7
+ * import.meta.url)`, which bundlers follow and copy.
14
8
  */
15
-
16
- /**
17
- * Installed SDK version, self-reported to the detection reporter so the
18
- * dashboard can version-gate "composed policy enforces here". MUST equal
19
- * `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
20
- * drifted). Re-exported as `VERSION` from the package index.
21
- */
22
- declare const VERSION = "1.9.0";
23
-
24
- /** Node host with native filesystem WASM loading. */
25
- declare function withCheckpoint(config: CheckpointConfig): (req: next_server.NextRequest, event?: Pick<next_server.NextFetchEvent, "waitUntil">) => Promise<next_server.NextResponse>;
26
-
27
- export { CheckpointConfig, VERSION, withCheckpoint };
9
+ export declare function withCheckpoint(config: CheckpointConfig): (req: import("next/server").NextRequest, event?: Pick<import("next/server").NextFetchEvent, "waitUntil">) => Promise<import("next/server").NextResponse>;
10
+ //#endregion
11
+ export { type CheckpointConfig, VERSION };
12
+ //# sourceMappingURL=middleware-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware-node.d.ts","names":[],"sources":["../src/middleware-node.ts"],"mappings":";;;;;;;;wBAUgB,eAAe,QAAQ,oBAAgB,2BAAA,aAAA,QAAA,2BAAA,iCAAA,8BAAA"}