@kya-os/checkpoint-nextjs 1.2.0 → 1.7.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 (44) hide show
  1. package/CHANGELOG.md +159 -0
  2. package/dist/composed-policy.d.mts +108 -0
  3. package/dist/composed-policy.d.ts +108 -0
  4. package/dist/composed-policy.js +91 -0
  5. package/dist/composed-policy.mjs +85 -0
  6. package/dist/config-_nfPN3E3.d.mts +205 -0
  7. package/dist/config-kxFihzR_.d.ts +205 -0
  8. package/dist/create-middleware.js +0 -2
  9. package/dist/create-middleware.mjs +0 -2
  10. package/dist/edge-runtime-loader.js +3 -1
  11. package/dist/edge-runtime-loader.mjs +3 -1
  12. package/dist/edge-wasm-middleware.d.mts +6 -6
  13. package/dist/edge-wasm-middleware.d.ts +6 -6
  14. package/dist/index.d.mts +6 -14
  15. package/dist/index.d.ts +6 -14
  16. package/dist/index.js +160 -8
  17. package/dist/index.mjs +161 -9
  18. package/dist/middleware-edge.d.mts +7 -3
  19. package/dist/middleware-edge.d.ts +7 -3
  20. package/dist/middleware-edge.js +157 -3
  21. package/dist/middleware-edge.mjs +154 -3
  22. package/dist/middleware-node.d.mts +39 -116
  23. package/dist/middleware-node.d.ts +39 -116
  24. package/dist/middleware-node.js +164 -3
  25. package/dist/middleware-node.mjs +161 -4
  26. package/dist/middleware.d.mts +10 -1
  27. package/dist/middleware.d.ts +10 -1
  28. package/dist/middleware.js +6 -0
  29. package/dist/middleware.mjs +6 -1
  30. package/dist/nodejs-wasm-loader.d.mts +3 -4
  31. package/dist/nodejs-wasm-loader.d.ts +3 -4
  32. package/dist/nodejs-wasm-loader.js +1 -1
  33. package/dist/nodejs-wasm-loader.mjs +1 -1
  34. package/dist/signature-verifier.js +2 -2
  35. package/dist/signature-verifier.mjs +2 -2
  36. package/dist/wasm-setup.js +1 -1
  37. package/dist/wasm-setup.mjs +1 -1
  38. package/package.json +4 -9
  39. package/dist/.tsbuildinfo +0 -1
  40. package/dist/wasm-middleware.d.mts +0 -98
  41. package/dist/wasm-middleware.d.ts +0 -98
  42. package/dist/wasm-middleware.js +0 -125
  43. package/dist/wasm-middleware.mjs +0 -121
  44. package/templates/middleware-wasm-100.ts +0 -161
@@ -2,8 +2,10 @@
2
2
 
3
3
  var orchestrator = require('@kya-os/checkpoint-wasm-runtime/orchestrator');
4
4
  var adapters = require('@kya-os/checkpoint-wasm-runtime/adapters');
5
- var server = require('next/server');
5
+ var reporter = require('@kya-os/checkpoint-wasm-runtime/reporter');
6
6
  var checkpointShared = require('@kya-os/checkpoint-shared');
7
+ var server = require('next/server');
8
+ var composedPolicy = require('@kya-os/checkpoint-wasm-runtime/composed-policy');
7
9
 
8
10
  // src/middleware-node.ts
9
11
  function adaptToNextResponse(rendered, req) {
@@ -54,6 +56,85 @@ function applyHeaders(res, headers) {
54
56
  res.headers.set(key, value);
55
57
  }
56
58
  }
59
+ var DEFAULT_DASHBOARD_URL = "https://kya.vouched.id";
60
+ var NOOP_LOGGER = {
61
+ shadowDivergence: () => {
62
+ },
63
+ evaluationError: () => {
64
+ }
65
+ };
66
+ function makeComposedPolicyContext(opts) {
67
+ const { projectId, fetcher } = opts;
68
+ const cache = composedPolicy.makeComposedPolicyCache({ compile: opts.compile, cacheMax: opts.cacheMax });
69
+ const logger = opts.logger ?? NOOP_LOGGER;
70
+ return {
71
+ async apply(result, path) {
72
+ const structured = { decision: result.decision, acted: false };
73
+ const policy = await fetcher.getPolicy(projectId);
74
+ const outcome = await composedPolicy.evaluateComposedPolicy({
75
+ cache,
76
+ projectId,
77
+ flags: {
78
+ policyLanguage: policy.policyLanguage,
79
+ policySourceText: policy.policySourceText,
80
+ engineEnforcementEnabled: policy.engineEnforcementEnabled,
81
+ enabled: policy.enabled
82
+ },
83
+ authorizeInput: composedPolicy.verifyResultToAuthorizeInput(result, { tenantId: projectId, path }),
84
+ baselineDecisionKind: result.decision.kind
85
+ });
86
+ if ((outcome.status === "acting" || outcome.status === "shadow") && outcome.diverged) {
87
+ logger.shadowDivergence({
88
+ projectId,
89
+ path,
90
+ engineDecision: outcome.engineDecision.kind,
91
+ structuredDecision: result.decision.kind,
92
+ detectionClass: result.detectionDetail.detectionClass.type,
93
+ verificationMethod: result.detectionDetail.verificationMethod,
94
+ confidence: result.detectionDetail.confidence,
95
+ agentName: result.detectionDetail.detectedAgent?.name
96
+ });
97
+ }
98
+ if (outcome.status === "error") {
99
+ logger.evaluationError(projectId, outcome.error);
100
+ return structured;
101
+ }
102
+ if (outcome.status === "acting") {
103
+ return { decision: outcome.engineDecision, acted: true };
104
+ }
105
+ return structured;
106
+ },
107
+ async trustedDelegationRoots() {
108
+ const policy = await fetcher.getPolicy(projectId);
109
+ return policy.trustedDelegationRoots ?? [];
110
+ }
111
+ };
112
+ }
113
+ async function resolveTrustedDelegationRootsForRequest(resolver, headers) {
114
+ if (!resolver) return void 0;
115
+ if (!checkpointShared.requestCarriesDelegationProof(headers)) return void 0;
116
+ const roots = await resolver();
117
+ return roots.length > 0 ? roots : void 0;
118
+ }
119
+ async function applyComposedPolicy(context, result, path) {
120
+ if (!context) return;
121
+ try {
122
+ const outcome = await context.apply(result, path);
123
+ if (outcome.acted) result.decision = outcome.decision;
124
+ } catch {
125
+ }
126
+ }
127
+ var consoleComposedPolicyLogger = {
128
+ shadowDivergence(info) {
129
+ console.warn("[checkpoint/composed-policy] shadow-divergence", info);
130
+ },
131
+ evaluationError(projectId, error) {
132
+ console.error(
133
+ `[checkpoint/composed-policy] evaluation failed for ${projectId}; using structured decision:`,
134
+ error
135
+ );
136
+ }
137
+ };
57
138
 
58
139
  // src/translate.ts
59
140
  async function nextRequestToHttpLike(req, opts = {}) {
@@ -98,15 +179,91 @@ function extractRemoteAddress(req) {
98
179
  // src/middleware-node.ts
99
180
  function withCheckpoint(config) {
100
181
  const opts = buildVerifyOpts(config);
182
+ const reporter = buildReporter(config);
183
+ const composed = buildComposedContext(config);
184
+ const trustedRootsResolver = buildTrustedRootsResolver(config, composed);
101
185
  const translateOpts = { drainJsonBody: config.drainJsonBody };
102
- return async function checkpointMiddleware(req) {
186
+ return async function checkpointMiddleware(req, event) {
103
187
  const httpLike = await nextRequestToHttpLike(req, translateOpts);
104
- const result = await orchestrator.verifyRequest(httpLike, opts);
188
+ const trustedDelegationRoots = await resolveTrustedDelegationRootsForRequest(
189
+ trustedRootsResolver,
190
+ req.headers
191
+ );
192
+ const result = await orchestrator.verifyRequest(
193
+ httpLike,
194
+ trustedDelegationRoots ? { ...opts, trustedDelegationRoots } : opts
195
+ );
196
+ await applyComposedPolicy(composed, result, req.nextUrl.pathname);
197
+ if (reporter) {
198
+ const reportPromise = reporter(result, extractReporterContext(req));
199
+ if (event) {
200
+ event.waitUntil(reportPromise);
201
+ }
202
+ }
105
203
  await dispatchOnResult(config, result, req);
106
204
  const rendered = orchestrator.renderDecisionAsResponse(result);
107
205
  return adaptToNextResponse(rendered, req);
108
206
  };
109
207
  }
208
+ var SDK_NAME = "@kya-os/checkpoint-nextjs";
209
+ var VERSION = "1.7.0";
210
+ function buildReporter(config, runtime = "node") {
211
+ if (!config.apiKey) return null;
212
+ return reporter.makeDetectionReporter({
213
+ apiKey: config.apiKey,
214
+ baseUrl: config.baseUrl,
215
+ debug: config.debug,
216
+ // Self-identify (incl. node-vs-edge) so the dashboard can version-gate
217
+ // enforcement. Next.js EDGE composed enforcement is opt-in (needs
218
+ // `cedarWasmModule`), so the dashboard shows it as opt-in, never "Enforcing".
219
+ sdk: { name: SDK_NAME, version: VERSION, runtime }
220
+ });
221
+ }
222
+ function buildTrustedRootsResolver(config, composed) {
223
+ if (composed?.trustedDelegationRoots) {
224
+ return () => composed.trustedDelegationRoots();
225
+ }
226
+ if (!config.projectId) return null;
227
+ const fetcher = new checkpointShared.PolicyFetcher({
228
+ apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
229
+ apiKey: config.apiKey,
230
+ cacheTtlSeconds: config.policyCacheTtlSeconds
231
+ });
232
+ const projectId = config.projectId;
233
+ return async () => (await fetcher.getPolicy(projectId)).trustedDelegationRoots ?? [];
234
+ }
235
+ function buildComposedContext(config) {
236
+ if (config.composedPolicyEnforcer) return config.composedPolicyEnforcer;
237
+ if (!config.projectId) return null;
238
+ return makeComposedPolicyContext({
239
+ projectId: config.projectId,
240
+ fetcher: new checkpointShared.PolicyFetcher({
241
+ apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
242
+ apiKey: config.apiKey,
243
+ cacheTtlSeconds: config.policyCacheTtlSeconds
244
+ }),
245
+ // LAZY dynamic import — NOT a top-level `import` — so the node-only
246
+ // `./policy` glue (`createRequire`/`fs` at module load) is never pulled into
247
+ // the Edge bundle. `middleware-edge.ts` imports helpers from this file, so a
248
+ // top-level `./policy` import would surface as a side-effect import in the
249
+ // edge bundle and boot-fail on Vercel edge. The import is cached after first
250
+ // call; the core's single-flight cache wraps the (now async) compile.
251
+ compile: async (_language, source) => {
252
+ const { createPolicyEvaluator } = await import('@kya-os/checkpoint-wasm-runtime/policy');
253
+ return createPolicyEvaluator(source);
254
+ },
255
+ logger: config.debug ? consoleComposedPolicyLogger : void 0
256
+ });
257
+ }
258
+ function extractReporterContext(req) {
259
+ return {
260
+ userAgent: req.headers.get("user-agent") ?? void 0,
261
+ ipAddress: req.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ?? req.headers.get("x-real-ip") ?? void 0,
262
+ path: req.nextUrl.pathname,
263
+ url: req.nextUrl.href,
264
+ method: req.method
265
+ };
266
+ }
110
267
  function buildVerifyOpts(config) {
111
268
  const overrides = config.adapters ?? {};
112
269
  return {
@@ -131,5 +288,9 @@ async function dispatchOnResult(config, result, req) {
131
288
  }
132
289
  }
133
290
 
291
+ exports.VERSION = VERSION;
292
+ exports._buildReporter = buildReporter;
293
+ exports._buildTrustedRootsResolver = buildTrustedRootsResolver;
134
294
  exports._buildVerifyOpts = buildVerifyOpts;
295
+ exports._extractReporterContext = extractReporterContext;
135
296
  exports.withCheckpoint = withCheckpoint;
@@ -1,7 +1,9 @@
1
1
  import { verifyRequest, renderDecisionAsResponse } from '@kya-os/checkpoint-wasm-runtime/orchestrator';
2
2
  import { makeSystemClock, makePolicyEvaluator, makeReputationOracle, makeStatusListCache, makeDidResolver } from '@kya-os/checkpoint-wasm-runtime/adapters';
3
+ import { makeDetectionReporter } from '@kya-os/checkpoint-wasm-runtime/reporter';
4
+ import { PolicyFetcher, requestCarriesDelegationProof, acceptsHtml, encodeVerdictCookie, classifyResponseShape, BLOCKED_PATH, VERDICT_COOKIE_NAME } from '@kya-os/checkpoint-shared';
3
5
  import { NextResponse } from 'next/server';
4
- import { acceptsHtml, encodeVerdictCookie, classifyResponseShape, BLOCKED_PATH, VERDICT_COOKIE_NAME } from '@kya-os/checkpoint-shared';
6
+ import { makeComposedPolicyCache, evaluateComposedPolicy, verifyResultToAuthorizeInput } from '@kya-os/checkpoint-wasm-runtime/composed-policy';
5
7
 
6
8
  // src/middleware-node.ts
7
9
  function adaptToNextResponse(rendered, req) {
@@ -52,6 +54,85 @@ function applyHeaders(res, headers) {
52
54
  res.headers.set(key, value);
53
55
  }
54
56
  }
57
+ var DEFAULT_DASHBOARD_URL = "https://kya.vouched.id";
58
+ var NOOP_LOGGER = {
59
+ shadowDivergence: () => {
60
+ },
61
+ evaluationError: () => {
62
+ }
63
+ };
64
+ function makeComposedPolicyContext(opts) {
65
+ const { projectId, fetcher } = opts;
66
+ const cache = makeComposedPolicyCache({ compile: opts.compile, cacheMax: opts.cacheMax });
67
+ const logger = opts.logger ?? NOOP_LOGGER;
68
+ return {
69
+ async apply(result, path) {
70
+ const structured = { decision: result.decision, acted: false };
71
+ const policy = await fetcher.getPolicy(projectId);
72
+ const outcome = await evaluateComposedPolicy({
73
+ cache,
74
+ projectId,
75
+ flags: {
76
+ policyLanguage: policy.policyLanguage,
77
+ policySourceText: policy.policySourceText,
78
+ engineEnforcementEnabled: policy.engineEnforcementEnabled,
79
+ enabled: policy.enabled
80
+ },
81
+ authorizeInput: verifyResultToAuthorizeInput(result, { tenantId: projectId, path }),
82
+ baselineDecisionKind: result.decision.kind
83
+ });
84
+ if ((outcome.status === "acting" || outcome.status === "shadow") && outcome.diverged) {
85
+ logger.shadowDivergence({
86
+ projectId,
87
+ path,
88
+ engineDecision: outcome.engineDecision.kind,
89
+ structuredDecision: result.decision.kind,
90
+ detectionClass: result.detectionDetail.detectionClass.type,
91
+ verificationMethod: result.detectionDetail.verificationMethod,
92
+ confidence: result.detectionDetail.confidence,
93
+ agentName: result.detectionDetail.detectedAgent?.name
94
+ });
95
+ }
96
+ if (outcome.status === "error") {
97
+ logger.evaluationError(projectId, outcome.error);
98
+ return structured;
99
+ }
100
+ if (outcome.status === "acting") {
101
+ return { decision: outcome.engineDecision, acted: true };
102
+ }
103
+ return structured;
104
+ },
105
+ async trustedDelegationRoots() {
106
+ const policy = await fetcher.getPolicy(projectId);
107
+ return policy.trustedDelegationRoots ?? [];
108
+ }
109
+ };
110
+ }
111
+ async function resolveTrustedDelegationRootsForRequest(resolver, headers) {
112
+ if (!resolver) return void 0;
113
+ if (!requestCarriesDelegationProof(headers)) return void 0;
114
+ const roots = await resolver();
115
+ return roots.length > 0 ? roots : void 0;
116
+ }
117
+ async function applyComposedPolicy(context, result, path) {
118
+ if (!context) return;
119
+ try {
120
+ const outcome = await context.apply(result, path);
121
+ if (outcome.acted) result.decision = outcome.decision;
122
+ } catch {
123
+ }
124
+ }
125
+ var consoleComposedPolicyLogger = {
126
+ shadowDivergence(info) {
127
+ console.warn("[checkpoint/composed-policy] shadow-divergence", info);
128
+ },
129
+ evaluationError(projectId, error) {
130
+ console.error(
131
+ `[checkpoint/composed-policy] evaluation failed for ${projectId}; using structured decision:`,
132
+ error
133
+ );
134
+ }
135
+ };
55
136
 
56
137
  // src/translate.ts
57
138
  async function nextRequestToHttpLike(req, opts = {}) {
@@ -96,15 +177,91 @@ function extractRemoteAddress(req) {
96
177
  // src/middleware-node.ts
97
178
  function withCheckpoint(config) {
98
179
  const opts = buildVerifyOpts(config);
180
+ const reporter = buildReporter(config);
181
+ const composed = buildComposedContext(config);
182
+ const trustedRootsResolver = buildTrustedRootsResolver(config, composed);
99
183
  const translateOpts = { drainJsonBody: config.drainJsonBody };
100
- return async function checkpointMiddleware(req) {
184
+ return async function checkpointMiddleware(req, event) {
101
185
  const httpLike = await nextRequestToHttpLike(req, translateOpts);
102
- const result = await verifyRequest(httpLike, opts);
186
+ const trustedDelegationRoots = await resolveTrustedDelegationRootsForRequest(
187
+ trustedRootsResolver,
188
+ req.headers
189
+ );
190
+ const result = await verifyRequest(
191
+ httpLike,
192
+ trustedDelegationRoots ? { ...opts, trustedDelegationRoots } : opts
193
+ );
194
+ await applyComposedPolicy(composed, result, req.nextUrl.pathname);
195
+ if (reporter) {
196
+ const reportPromise = reporter(result, extractReporterContext(req));
197
+ if (event) {
198
+ event.waitUntil(reportPromise);
199
+ }
200
+ }
103
201
  await dispatchOnResult(config, result, req);
104
202
  const rendered = renderDecisionAsResponse(result);
105
203
  return adaptToNextResponse(rendered, req);
106
204
  };
107
205
  }
206
+ var SDK_NAME = "@kya-os/checkpoint-nextjs";
207
+ var VERSION = "1.7.0";
208
+ function buildReporter(config, runtime = "node") {
209
+ if (!config.apiKey) return null;
210
+ return makeDetectionReporter({
211
+ apiKey: config.apiKey,
212
+ baseUrl: config.baseUrl,
213
+ debug: config.debug,
214
+ // Self-identify (incl. node-vs-edge) so the dashboard can version-gate
215
+ // enforcement. Next.js EDGE composed enforcement is opt-in (needs
216
+ // `cedarWasmModule`), so the dashboard shows it as opt-in, never "Enforcing".
217
+ sdk: { name: SDK_NAME, version: VERSION, runtime }
218
+ });
219
+ }
220
+ function buildTrustedRootsResolver(config, composed) {
221
+ if (composed?.trustedDelegationRoots) {
222
+ return () => composed.trustedDelegationRoots();
223
+ }
224
+ if (!config.projectId) return null;
225
+ const fetcher = new PolicyFetcher({
226
+ apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
227
+ apiKey: config.apiKey,
228
+ cacheTtlSeconds: config.policyCacheTtlSeconds
229
+ });
230
+ const projectId = config.projectId;
231
+ return async () => (await fetcher.getPolicy(projectId)).trustedDelegationRoots ?? [];
232
+ }
233
+ function buildComposedContext(config) {
234
+ if (config.composedPolicyEnforcer) return config.composedPolicyEnforcer;
235
+ if (!config.projectId) return null;
236
+ return makeComposedPolicyContext({
237
+ projectId: config.projectId,
238
+ fetcher: new PolicyFetcher({
239
+ apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,
240
+ apiKey: config.apiKey,
241
+ cacheTtlSeconds: config.policyCacheTtlSeconds
242
+ }),
243
+ // LAZY dynamic import — NOT a top-level `import` — so the node-only
244
+ // `./policy` glue (`createRequire`/`fs` at module load) is never pulled into
245
+ // the Edge bundle. `middleware-edge.ts` imports helpers from this file, so a
246
+ // top-level `./policy` import would surface as a side-effect import in the
247
+ // edge bundle and boot-fail on Vercel edge. The import is cached after first
248
+ // call; the core's single-flight cache wraps the (now async) compile.
249
+ compile: async (_language, source) => {
250
+ const { createPolicyEvaluator } = await import('@kya-os/checkpoint-wasm-runtime/policy');
251
+ return createPolicyEvaluator(source);
252
+ },
253
+ logger: config.debug ? consoleComposedPolicyLogger : void 0
254
+ });
255
+ }
256
+ function extractReporterContext(req) {
257
+ return {
258
+ userAgent: req.headers.get("user-agent") ?? void 0,
259
+ ipAddress: req.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ?? req.headers.get("x-real-ip") ?? void 0,
260
+ path: req.nextUrl.pathname,
261
+ url: req.nextUrl.href,
262
+ method: req.method
263
+ };
264
+ }
108
265
  function buildVerifyOpts(config) {
109
266
  const overrides = config.adapters ?? {};
110
267
  return {
@@ -129,4 +286,4 @@ async function dispatchOnResult(config, result, req) {
129
286
  }
130
287
  }
131
288
 
132
- export { buildVerifyOpts as _buildVerifyOpts, withCheckpoint };
289
+ export { VERSION, buildReporter as _buildReporter, buildTrustedRootsResolver as _buildTrustedRootsResolver, buildVerifyOpts as _buildVerifyOpts, extractReporterContext as _extractReporterContext, withCheckpoint };
@@ -32,5 +32,14 @@ declare function createAgentShieldMiddleware(_config?: Partial<NextJSMiddlewareC
32
32
  * Migrate to `withCheckpoint`.
33
33
  */
34
34
  declare function agentShield(config?: Partial<NextJSMiddlewareConfig>): (request: NextRequest) => Promise<NextResponse>;
35
+ /**
36
+ * Pass-through export required by Next.js 16+ middleware file validation.
37
+ * Next.js requires any file named `middleware.ts` to export a function named
38
+ * `middleware` or a default function. This stub satisfies that constraint so
39
+ * consumers that still reference the `./middleware` subpath can build.
40
+ *
41
+ * @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
42
+ */
43
+ declare function middleware(_request: NextRequest): NextResponse<unknown>;
35
44
 
36
- export { agentShield, createAgentShieldMiddleware };
45
+ export { agentShield, createAgentShieldMiddleware, middleware };
@@ -32,5 +32,14 @@ declare function createAgentShieldMiddleware(_config?: Partial<NextJSMiddlewareC
32
32
  * Migrate to `withCheckpoint`.
33
33
  */
34
34
  declare function agentShield(config?: Partial<NextJSMiddlewareConfig>): (request: NextRequest) => Promise<NextResponse>;
35
+ /**
36
+ * Pass-through export required by Next.js 16+ middleware file validation.
37
+ * Next.js requires any file named `middleware.ts` to export a function named
38
+ * `middleware` or a default function. This stub satisfies that constraint so
39
+ * consumers that still reference the `./middleware` subpath can build.
40
+ *
41
+ * @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
42
+ */
43
+ declare function middleware(_request: NextRequest): NextResponse<unknown>;
35
44
 
36
- export { agentShield, createAgentShieldMiddleware };
45
+ export { agentShield, createAgentShieldMiddleware, middleware };
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var server = require('next/server');
4
+
3
5
  // src/middleware.ts
4
6
  var MIGRATION_ERROR = "@kya-os/checkpoint-nextjs's `createAgentShieldMiddleware` / `agentShield` were deleted in Phase D (engine consolidation). The 600-line TS pattern matcher that backed them is gone. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` (Node runtime) or `@kya-os/checkpoint-nextjs/edge` (Edge runtime). See packages/checkpoint-nextjs/CHANGELOG.md (1.0.0) for the recipe.";
5
7
  function createAgentShieldMiddleware(_config = {}) {
@@ -8,6 +10,10 @@ function createAgentShieldMiddleware(_config = {}) {
8
10
  function agentShield(config = {}) {
9
11
  return createAgentShieldMiddleware(config);
10
12
  }
13
+ function middleware(_request) {
14
+ return server.NextResponse.next();
15
+ }
11
16
 
12
17
  exports.agentShield = agentShield;
13
18
  exports.createAgentShieldMiddleware = createAgentShieldMiddleware;
19
+ exports.middleware = middleware;
@@ -1,3 +1,5 @@
1
+ import { NextResponse } from 'next/server';
2
+
1
3
  // src/middleware.ts
2
4
  var MIGRATION_ERROR = "@kya-os/checkpoint-nextjs's `createAgentShieldMiddleware` / `agentShield` were deleted in Phase D (engine consolidation). The 600-line TS pattern matcher that backed them is gone. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` (Node runtime) or `@kya-os/checkpoint-nextjs/edge` (Edge runtime). See packages/checkpoint-nextjs/CHANGELOG.md (1.0.0) for the recipe.";
3
5
  function createAgentShieldMiddleware(_config = {}) {
@@ -6,5 +8,8 @@ function createAgentShieldMiddleware(_config = {}) {
6
8
  function agentShield(config = {}) {
7
9
  return createAgentShieldMiddleware(config);
8
10
  }
11
+ function middleware(_request) {
12
+ return NextResponse.next();
13
+ }
9
14
 
10
- export { agentShield, createAgentShieldMiddleware };
15
+ export { agentShield, createAgentShieldMiddleware, middleware };
@@ -1,10 +1,9 @@
1
1
  /**
2
2
  * @deprecated Phase-D.9a — legacy Node.js WASM loader for the retired
3
3
  * `agentshield-wasm` Rust crate. This file used `fs.readFileSync` to
4
- * locate + load the legacy detector's WASM binary into the
5
- * `@kya-os/checkpoint` `AgentDetector` class via `setWasmModule`. Both
6
- * the WASM crate (Phase-D.9a/D.9b) and the AgentDetector class
7
- * (AgentDetector-Deletion-2, next minor) are slated for deletion.
4
+ * locate + load the legacy detector's WASM binary into the legacy
5
+ * detection class. Both the WASM crate (Phase-D.9a/D.9b) and the
6
+ * detection class (removed in AgentDetector-Deletion-2) are retired.
8
7
  *
9
8
  * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — it
10
9
  * loads the canonical `kya-os-engine` WASM automatically via
@@ -1,10 +1,9 @@
1
1
  /**
2
2
  * @deprecated Phase-D.9a — legacy Node.js WASM loader for the retired
3
3
  * `agentshield-wasm` Rust crate. This file used `fs.readFileSync` to
4
- * locate + load the legacy detector's WASM binary into the
5
- * `@kya-os/checkpoint` `AgentDetector` class via `setWasmModule`. Both
6
- * the WASM crate (Phase-D.9a/D.9b) and the AgentDetector class
7
- * (AgentDetector-Deletion-2, next minor) are slated for deletion.
4
+ * locate + load the legacy detector's WASM binary into the legacy
5
+ * detection class. Both the WASM crate (Phase-D.9a/D.9b) and the
6
+ * detection class (removed in AgentDetector-Deletion-2) are retired.
8
7
  *
9
8
  * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — it
10
9
  * loads the canonical `kya-os-engine` WASM automatically via
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/nodejs-wasm-loader.ts
4
- var MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy `AgentDetector` class they fed is slated for deletion in AgentDetector-Deletion-2 (next minor). Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` \u2014 engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
4
+ var MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy detection class they fed was removed in AgentDetector-Deletion-2. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` \u2014 engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
5
5
  var _nodejsWasmWarned = false;
6
6
  function warnNodejsWasmDeprecated() {
7
7
  if (_nodejsWasmWarned) return;
@@ -1,5 +1,5 @@
1
1
  // src/nodejs-wasm-loader.ts
2
- var MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy `AgentDetector` class they fed is slated for deletion in AgentDetector-Deletion-2 (next minor). Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` \u2014 engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
2
+ var MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy detection class they fed was removed in AgentDetector-Deletion-2. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` \u2014 engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
3
3
  var _nodejsWasmWarned = false;
4
4
  function warnNodejsWasmDeprecated() {
5
5
  if (_nodejsWasmWarned) return;
@@ -34,8 +34,8 @@ var KNOWN_KEYS = {
34
34
  publicKey: "7F_3jDlxaquwh291MiACkcS3Opq88NksyHiakzS-Y1g",
35
35
  validFrom: 1735689600,
36
36
  // Jan 1, 2025 (nbf from OpenAI)
37
- validUntil: 1769029093
38
- // Jan 21, 2026 (exp from OpenAI)
37
+ validUntil: 1780362143
38
+ // Jun 1, 2026 (exp from OpenAI live directory 2026-05-25)
39
39
  }
40
40
  ]
41
41
  };
@@ -12,8 +12,8 @@ var KNOWN_KEYS = {
12
12
  publicKey: "7F_3jDlxaquwh291MiACkcS3Opq88NksyHiakzS-Y1g",
13
13
  validFrom: 1735689600,
14
14
  // Jan 1, 2025 (nbf from OpenAI)
15
- validUntil: 1769029093
16
- // Jan 21, 2026 (exp from OpenAI)
15
+ validUntil: 1780362143
16
+ // Jun 1, 2026 (exp from OpenAI live directory 2026-05-25)
17
17
  }
18
18
  ]
19
19
  };
@@ -53,7 +53,7 @@ function isWasmInitialized() {
53
53
  var MIGRATION_ERROR, _nodejsWasmWarned;
54
54
  var init_nodejs_wasm_loader = __esm({
55
55
  "src/nodejs-wasm-loader.ts"() {
56
- MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy `AgentDetector` class they fed is slated for deletion in AgentDetector-Deletion-2 (next minor). Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` \u2014 engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
56
+ MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy detection class they fed was removed in AgentDetector-Deletion-2. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` \u2014 engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
57
57
  _nodejsWasmWarned = false;
58
58
  }
59
59
  });
@@ -51,7 +51,7 @@ function isWasmInitialized() {
51
51
  var MIGRATION_ERROR, _nodejsWasmWarned;
52
52
  var init_nodejs_wasm_loader = __esm({
53
53
  "src/nodejs-wasm-loader.ts"() {
54
- MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy `AgentDetector` class they fed is slated for deletion in AgentDetector-Deletion-2 (next minor). Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` \u2014 engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
54
+ MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy detection class they fed was removed in AgentDetector-Deletion-2. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` \u2014 engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
55
55
  _nodejsWasmWarned = false;
56
56
  }
57
57
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kya-os/checkpoint-nextjs",
3
- "version": "1.2.0",
3
+ "version": "1.7.0",
4
4
  "description": "Checkpoint Next.js middleware for AI agent detection (formerly @kya-os/agentshield-nextjs)",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -62,11 +62,6 @@
62
62
  "import": "./dist/wasm-setup.mjs",
63
63
  "require": "./dist/wasm-setup.js"
64
64
  },
65
- "./wasm-middleware": {
66
- "types": "./dist/wasm-middleware.d.ts",
67
- "import": "./dist/wasm-middleware.mjs",
68
- "require": "./dist/wasm-middleware.js"
69
- },
70
65
  "./edge-wasm-middleware": {
71
66
  "types": "./dist/edge-wasm-middleware.d.ts",
72
67
  "import": "./dist/edge-wasm-middleware.mjs",
@@ -136,9 +131,9 @@
136
131
  "dependencies": {
137
132
  "@noble/ed25519": "^2.2.3",
138
133
  "@noble/hashes": "^2.0.1",
139
- "@kya-os/checkpoint": "1.0.1",
140
- "@kya-os/checkpoint-shared": "1.1.0",
141
- "@kya-os/checkpoint-wasm-runtime": "^1.4.0"
134
+ "@kya-os/checkpoint": "1.2.0",
135
+ "@kya-os/checkpoint-shared": "1.2.0",
136
+ "@kya-os/checkpoint-wasm-runtime": "^1.8.0"
142
137
  },
143
138
  "scripts": {
144
139
  "build": "tsup",