@kya-os/checkpoint-nextjs 1.10.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 +245 -0
- package/README.md +205 -31
- package/dist/{adapt.mjs → adapt-BdQ9R7Iw.mjs} +15 -4
- package/dist/adapt-BdQ9R7Iw.mjs.map +1 -0
- package/dist/{adapt.js → adapt-CCSKGjVH.js} +34 -13
- 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 -204
- package/dist/api-client.d.ts +2 -204
- package/dist/api-client.js +19 -18
- package/dist/api-client.mjs +20 -16
- package/dist/api-client.mjs.map +1 -1
- package/dist/api-middleware-BWjokNis.d.mts +131 -0
- package/dist/api-middleware-BWjokNis.d.mts.map +1 -0
- package/dist/{api-middleware-CDSh3TSE.js → api-middleware-Bf3xmM9W.js} +75 -63
- package/dist/{api-middleware-CMDRoQik.mjs → api-middleware-C-ngFX_8.mjs} +68 -38
- 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 -152
- package/dist/api-middleware.d.ts +2 -152
- package/dist/api-middleware.js +1 -5
- package/dist/api-middleware.mjs +2 -3
- 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-Doe0Tn53.d.mts → config-CPP1RV0f.d.mts} +65 -29
- package/dist/config-CPP1RV0f.d.mts.map +1 -0
- package/dist/{config-CbAg2mze.d.ts → config-DVgOFxJs.d.ts} +66 -30
- 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 -10
- package/dist/index.d.ts +8 -10
- package/dist/index.js +20 -49
- package/dist/index.mjs +21 -8
- package/dist/index.mjs.map +1 -1
- package/dist/middleware-bundler.d.mts +1 -1
- package/dist/middleware-bundler.d.mts.map +1 -1
- package/dist/middleware-bundler.d.ts +1 -1
- package/dist/middleware-bundler.d.ts.map +1 -1
- package/dist/middleware-bundler.js +4 -4
- package/dist/middleware-bundler.mjs +4 -4
- package/dist/middleware-bundler.mjs.map +1 -1
- 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 +11 -3
- package/dist/middleware-edge.d.mts.map +1 -1
- package/dist/middleware-edge.d.ts +11 -3
- package/dist/middleware-edge.d.ts.map +1 -1
- package/dist/middleware-edge.js +77 -24
- package/dist/middleware-edge.mjs +74 -23
- package/dist/middleware-edge.mjs.map +1 -1
- package/dist/{middleware-node-context-rgnc7UNR.js → middleware-node-context-591KsiYg.js} +8 -7
- package/dist/{middleware-node-context-BqPbf-fI.mjs → middleware-node-context-D_ZyUEcA.mjs} +6 -5
- package/dist/middleware-node-context-D_ZyUEcA.mjs.map +1 -0
- package/dist/middleware-node.d.mts +12 -3
- package/dist/middleware-node.d.mts.map +1 -0
- package/dist/middleware-node.d.ts +12 -3
- package/dist/middleware-node.d.ts.map +1 -0
- package/dist/middleware-node.js +13 -5
- package/dist/middleware-node.mjs +13 -5
- package/dist/middleware-node.mjs.map +1 -1
- 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 +27 -62
- package/EDGE_RUNTIME_WASM_SETUP.md +0 -342
- package/bin/setup-edge-wasm.js +0 -513
- package/dist/adapt.d.mts +0 -11
- package/dist/adapt.d.mts.map +0 -1
- package/dist/adapt.d.ts +0 -11
- package/dist/adapt.d.ts.map +0 -1
- package/dist/adapt.mjs.map +0 -1
- package/dist/api-client.d.mts.map +0 -1
- package/dist/api-client.d.ts.map +0 -1
- package/dist/api-middleware-CMDRoQik.mjs.map +0 -1
- package/dist/api-middleware.d.mts.map +0 -1
- package/dist/api-middleware.d.ts.map +0 -1
- package/dist/composed-policy-BCaNiVHv.d.mts +0 -98
- package/dist/composed-policy-BCaNiVHv.d.mts.map +0 -1
- package/dist/composed-policy-zzJYNFTb.d.ts +0 -98
- package/dist/composed-policy-zzJYNFTb.d.ts.map +0 -1
- package/dist/composed-policy.d.mts +0 -2
- package/dist/composed-policy.d.ts +0 -2
- package/dist/composed-policy.js +0 -136
- package/dist/composed-policy.mjs +0 -132
- package/dist/composed-policy.mjs.map +0 -1
- package/dist/config-CbAg2mze.d.ts.map +0 -1
- package/dist/config-Doe0Tn53.d.mts.map +0 -1
- package/dist/create-middleware.d.mts +0 -11
- package/dist/create-middleware.d.mts.map +0 -1
- package/dist/create-middleware.d.ts +0 -11
- package/dist/create-middleware.d.ts.map +0 -1
- package/dist/create-middleware.js +0 -39
- package/dist/create-middleware.mjs +0 -38
- package/dist/create-middleware.mjs.map +0 -1
- package/dist/edge/index.d.mts +0 -88
- package/dist/edge/index.d.mts.map +0 -1
- package/dist/edge/index.d.ts +0 -88
- package/dist/edge/index.d.ts.map +0 -1
- package/dist/edge/index.js +0 -362
- package/dist/edge/index.mjs +0 -362
- package/dist/edge/index.mjs.map +0 -1
- package/dist/edge-runtime-loader.d.mts +0 -49
- package/dist/edge-runtime-loader.d.mts.map +0 -1
- package/dist/edge-runtime-loader.d.ts +0 -49
- package/dist/edge-runtime-loader.d.ts.map +0 -1
- package/dist/edge-runtime-loader.js +0 -297
- package/dist/edge-runtime-loader.mjs +0 -292
- package/dist/edge-runtime-loader.mjs.map +0 -1
- package/dist/edge-wasm-middleware.d.mts +0 -43
- package/dist/edge-wasm-middleware.d.mts.map +0 -1
- package/dist/edge-wasm-middleware.d.ts +0 -43
- package/dist/edge-wasm-middleware.d.ts.map +0 -1
- package/dist/edge-wasm-middleware.js +0 -37
- package/dist/edge-wasm-middleware.mjs +0 -35
- package/dist/edge-wasm-middleware.mjs.map +0 -1
- package/dist/middleware-core-BYQP9FND.mjs +0 -165
- package/dist/middleware-core-BYQP9FND.mjs.map +0 -1
- package/dist/middleware-core-D6TijE6P.js +0 -175
- package/dist/middleware-node-CE4GevYs.d.ts +0 -20
- package/dist/middleware-node-CE4GevYs.d.ts.map +0 -1
- package/dist/middleware-node-DtyOuPta.d.mts +0 -20
- package/dist/middleware-node-DtyOuPta.d.mts.map +0 -1
- package/dist/middleware-node-context-BqPbf-fI.mjs.map +0 -1
- package/dist/middleware.d.mts +0 -25
- package/dist/middleware.d.mts.map +0 -1
- package/dist/middleware.d.ts +0 -25
- package/dist/middleware.d.ts.map +0 -1
- package/dist/middleware.js +0 -53
- package/dist/middleware.mjs +0 -51
- package/dist/middleware.mjs.map +0 -1
- package/dist/nodejs-wasm-loader.d.mts +0 -42
- package/dist/nodejs-wasm-loader.d.mts.map +0 -1
- package/dist/nodejs-wasm-loader.d.ts +0 -42
- package/dist/nodejs-wasm-loader.d.ts.map +0 -1
- package/dist/nodejs-wasm-loader.js +0 -70
- package/dist/nodejs-wasm-loader.mjs +0 -66
- package/dist/nodejs-wasm-loader.mjs.map +0 -1
- package/dist/policy.d.mts +0 -138
- package/dist/policy.d.mts.map +0 -1
- package/dist/policy.d.ts +0 -138
- package/dist/policy.d.ts.map +0 -1
- package/dist/policy.js +0 -236
- package/dist/policy.mjs +0 -205
- package/dist/policy.mjs.map +0 -1
- package/dist/session-tracker.d.mts +0 -50
- package/dist/session-tracker.d.mts.map +0 -1
- package/dist/session-tracker.d.ts +0 -50
- package/dist/session-tracker.d.ts.map +0 -1
- package/dist/session-tracker.js +0 -148
- package/dist/session-tracker.mjs +0 -147
- package/dist/session-tracker.mjs.map +0 -1
- package/dist/translate.d.mts +0 -48
- package/dist/translate.d.mts.map +0 -1
- package/dist/translate.d.ts +0 -48
- package/dist/translate.d.ts.map +0 -1
- package/dist/translate.js +0 -79
- package/dist/translate.mjs +0 -79
- package/dist/translate.mjs.map +0 -1
- package/dist/types-C0SkqLMM.d.mts +0 -102
- package/dist/types-C0SkqLMM.d.mts.map +0 -1
- package/dist/types-C7DNSCTO.d.ts +0 -102
- package/dist/types-C7DNSCTO.d.ts.map +0 -1
- package/dist/utils-Cj4XNhIY.mjs +0 -35
- package/dist/utils-Cj4XNhIY.mjs.map +0 -1
- package/dist/utils-DAisnYnI.js +0 -45
- package/dist/wasm-setup.d.mts +0 -47
- package/dist/wasm-setup.d.mts.map +0 -1
- package/dist/wasm-setup.d.ts +0 -47
- package/dist/wasm-setup.d.ts.map +0 -1
- package/dist/wasm-setup.js +0 -91
- package/dist/wasm-setup.mjs +0 -95
- package/dist/wasm-setup.mjs.map +0 -1
- 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,43 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from "next/server";
|
|
2
|
-
//#region src/edge-wasm-middleware.d.ts
|
|
3
|
-
/** @deprecated See file header. Type-only surface preservation. */
|
|
4
|
-
export interface EdgeWasmDetectionResult {
|
|
5
|
-
isAgent: boolean;
|
|
6
|
-
isAiCrawler?: boolean;
|
|
7
|
-
confidence: number;
|
|
8
|
-
agent?: string;
|
|
9
|
-
verificationMethod: 'signature' | 'pattern' | 'wasm';
|
|
10
|
-
riskLevel: 'low' | 'medium' | 'high';
|
|
11
|
-
timestamp: string;
|
|
12
|
-
reasons?: string[];
|
|
13
|
-
}
|
|
14
|
-
/** @deprecated See file header. Type-only surface preservation. */
|
|
15
|
-
export interface EdgeAgentShieldConfig {
|
|
16
|
-
onAgentDetected?: (result: EdgeWasmDetectionResult) => void | Promise<void>;
|
|
17
|
-
blockOnHighConfidence?: boolean;
|
|
18
|
-
confidenceThreshold?: number;
|
|
19
|
-
skipPaths?: string[];
|
|
20
|
-
blockedResponse?: {
|
|
21
|
-
status?: number;
|
|
22
|
-
message?: string;
|
|
23
|
-
headers?: Record<string, string>;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/** @internal — test-only reset for the one-shot warn latch. */
|
|
27
|
-
export declare function __resetEdgeWasmWarningForTests(): void;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
|
|
30
|
-
* `@kya-os/checkpoint-nextjs/edge` instead. Throws on invocation;
|
|
31
|
-
* surface exists only so static analysis sees the historical export.
|
|
32
|
-
*/
|
|
33
|
-
export declare function initializeEdgeWasm(_wasmModule: WebAssembly.Module): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
|
|
36
|
-
* `@kya-os/checkpoint-nextjs/edge` instead. Throws on invocation;
|
|
37
|
-
* surface exists only so static analysis sees the historical export.
|
|
38
|
-
*/
|
|
39
|
-
export declare function createEdgeWasmMiddleware(_config: EdgeAgentShieldConfig & {
|
|
40
|
-
wasmModule: WebAssembly.Module;
|
|
41
|
-
}): (request: NextRequest) => Promise<NextResponse>;
|
|
42
|
-
//#endregion
|
|
43
|
-
//# sourceMappingURL=edge-wasm-middleware.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edge-wasm-middleware.d.ts","names":[],"sources":["../src/edge-wasm-middleware.ts"],"mappings":";;;iBAuBiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;iBAIe;EACf,mBAAmB,QAAQ,mCAAmC;EAC9D;EACA;EACA;EACA;IACE;IACA;IACA,UAAU;;;;wBAuBE;;;;;;wBASM,mBAAmB,aAAa,YAAY,SAAS;;;;;;wBAU3D,yBACd,SAAS;EACP,YAAY,YAAY;KAExB,SAAS,gBAAgB,QAAQ"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
//#region src/edge-wasm-middleware.ts
|
|
3
|
-
const MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs/edge-wasm-middleware` was deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs/edge` — engine-backed via the Rust `kya-os-engine` crate (PDM-1 #2560), runs the full orchestrator including KYA-OS envelope verification. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
|
|
4
|
-
let _edgeWasmWarned = false;
|
|
5
|
-
function warnEdgeWasmDeprecated() {
|
|
6
|
-
if (_edgeWasmWarned) return;
|
|
7
|
-
_edgeWasmWarned = true;
|
|
8
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
|
|
9
|
-
console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);
|
|
10
|
-
}
|
|
11
|
-
/** @internal — test-only reset for the one-shot warn latch. */
|
|
12
|
-
function __resetEdgeWasmWarningForTests() {
|
|
13
|
-
_edgeWasmWarned = false;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
|
|
17
|
-
* `@kya-os/checkpoint-nextjs/edge` instead. Throws on invocation;
|
|
18
|
-
* surface exists only so static analysis sees the historical export.
|
|
19
|
-
*/
|
|
20
|
-
async function initializeEdgeWasm(_wasmModule) {
|
|
21
|
-
warnEdgeWasmDeprecated();
|
|
22
|
-
throw new Error(MIGRATION_ERROR);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
|
|
26
|
-
* `@kya-os/checkpoint-nextjs/edge` instead. Throws on invocation;
|
|
27
|
-
* surface exists only so static analysis sees the historical export.
|
|
28
|
-
*/
|
|
29
|
-
function createEdgeWasmMiddleware(_config) {
|
|
30
|
-
warnEdgeWasmDeprecated();
|
|
31
|
-
throw new Error(MIGRATION_ERROR);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
exports.__resetEdgeWasmWarningForTests = __resetEdgeWasmWarningForTests;
|
|
36
|
-
exports.createEdgeWasmMiddleware = createEdgeWasmMiddleware;
|
|
37
|
-
exports.initializeEdgeWasm = initializeEdgeWasm;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region src/edge-wasm-middleware.ts
|
|
2
|
-
const MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs/edge-wasm-middleware` was deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs/edge` — engine-backed via the Rust `kya-os-engine` crate (PDM-1 #2560), runs the full orchestrator including KYA-OS envelope verification. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
|
|
3
|
-
let _edgeWasmWarned = false;
|
|
4
|
-
function warnEdgeWasmDeprecated() {
|
|
5
|
-
if (_edgeWasmWarned) return;
|
|
6
|
-
_edgeWasmWarned = true;
|
|
7
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
|
|
8
|
-
console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);
|
|
9
|
-
}
|
|
10
|
-
/** @internal — test-only reset for the one-shot warn latch. */
|
|
11
|
-
function __resetEdgeWasmWarningForTests() {
|
|
12
|
-
_edgeWasmWarned = false;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
|
|
16
|
-
* `@kya-os/checkpoint-nextjs/edge` instead. Throws on invocation;
|
|
17
|
-
* surface exists only so static analysis sees the historical export.
|
|
18
|
-
*/
|
|
19
|
-
async function initializeEdgeWasm(_wasmModule) {
|
|
20
|
-
warnEdgeWasmDeprecated();
|
|
21
|
-
throw new Error(MIGRATION_ERROR);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
|
|
25
|
-
* `@kya-os/checkpoint-nextjs/edge` instead. Throws on invocation;
|
|
26
|
-
* surface exists only so static analysis sees the historical export.
|
|
27
|
-
*/
|
|
28
|
-
function createEdgeWasmMiddleware(_config) {
|
|
29
|
-
warnEdgeWasmDeprecated();
|
|
30
|
-
throw new Error(MIGRATION_ERROR);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
export { __resetEdgeWasmWarningForTests, createEdgeWasmMiddleware, initializeEdgeWasm };
|
|
35
|
-
//# sourceMappingURL=edge-wasm-middleware.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edge-wasm-middleware.mjs","names":[],"sources":["../src/edge-wasm-middleware.ts"],"sourcesContent":["/**\n * @deprecated Phase-D.9a — legacy Edge Runtime WASM middleware wrapping\n * the retired `agentshield-wasm` Rust crate. This file shipped hand-\n * written wasm-bindgen glue code that loaded the legacy detector's\n * WASM binary; PR #2599's SSOT consolidation + PDM-1 #2560's engine\n * move + AgentDetector-Deletion-1 PR #2610's class-deprecation +\n * AgentDetector-Deletion-2's class removal made it structural dead weight.\n *\n * Phase-D.9a converts the exports to throw-stubs (same precedent the\n * `createWasmAgentShieldMiddleware` removal used). Phase-D.9b (follow-up)\n * deletes the underlying `agentshield-wasm` Rust crate after migrating\n * the production Cloudflare gateway worker.\n *\n * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs/edge` —\n * engine-backed, runs the full kya-os-engine orchestrator including\n * KYA-OS envelope verification. See `packages/checkpoint-nextjs/README.md`\n * for the canonical recipe.\n */\n\nimport type { NextRequest } from 'next/server';\nimport type { NextResponse } from 'next/server';\n\n/** @deprecated See file header. Type-only surface preservation. */\nexport interface EdgeWasmDetectionResult {\n isAgent: boolean;\n isAiCrawler?: boolean;\n confidence: number;\n agent?: string;\n verificationMethod: 'signature' | 'pattern' | 'wasm';\n riskLevel: 'low' | 'medium' | 'high';\n timestamp: string;\n reasons?: string[];\n}\n\n/** @deprecated See file header. Type-only surface preservation. */\nexport interface EdgeAgentShieldConfig {\n onAgentDetected?: (result: EdgeWasmDetectionResult) => void | Promise<void>;\n blockOnHighConfidence?: boolean;\n confidenceThreshold?: number;\n skipPaths?: string[];\n blockedResponse?: {\n status?: number;\n message?: string;\n headers?: Record<string, string>;\n };\n}\n\nconst MIGRATION_ERROR =\n '`@kya-os/checkpoint-nextjs/edge-wasm-middleware` was deprecated in Phase-D.9a ' +\n '(legacy `agentshield-wasm` Rust crate retirement). Migrate to `withCheckpoint` ' +\n 'from `@kya-os/checkpoint-nextjs/edge` — engine-backed via the Rust ' +\n '`kya-os-engine` crate (PDM-1 #2560), runs the full orchestrator including ' +\n 'KYA-OS envelope verification. See packages/checkpoint-nextjs/README.md for ' +\n 'the canonical recipe.';\n\n// One-shot dev-only deprecation warning. Suppressed in production\n// builds and after the first emission so HMR / test runs don't spam.\nlet _edgeWasmWarned = false;\nfunction warnEdgeWasmDeprecated(): void {\n if (_edgeWasmWarned) return;\n _edgeWasmWarned = true;\n if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'production') return;\n console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);\n}\n\n/** @internal — test-only reset for the one-shot warn latch. */\nexport function __resetEdgeWasmWarningForTests(): void {\n _edgeWasmWarned = false;\n}\n\n/**\n * @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from\n * `@kya-os/checkpoint-nextjs/edge` instead. Throws on invocation;\n * surface exists only so static analysis sees the historical export.\n */\nexport async function initializeEdgeWasm(_wasmModule: WebAssembly.Module): Promise<void> {\n warnEdgeWasmDeprecated();\n throw new Error(MIGRATION_ERROR);\n}\n\n/**\n * @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from\n * `@kya-os/checkpoint-nextjs/edge` instead. Throws on invocation;\n * surface exists only so static analysis sees the historical export.\n */\nexport function createEdgeWasmMiddleware(\n _config: EdgeAgentShieldConfig & {\n wasmModule: WebAssembly.Module;\n }\n): (request: NextRequest) => Promise<NextResponse> {\n warnEdgeWasmDeprecated();\n throw new Error(MIGRATION_ERROR);\n}\n"],"mappings":";AA+CA,MAAM,kBACJ;AASF,IAAI,kBAAkB;AACtB,SAAS,yBAA+B;CACtC,IAAI,iBAAiB;CACrB,kBAAkB;CAClB,IAAI,OAAO,YAAY,eAAe,QAAQ,KAAK,aAAa,cAAc;CAC9E,QAAQ,KAAK,gBAAgB,iBAAiB;AAChD;;AAGA,SAAgB,iCAAuC;CACrD,kBAAkB;AACpB;;;;;;AAOA,eAAsB,mBAAmB,aAAgD;CACvF,uBAAuB;CACvB,MAAM,IAAI,MAAM,eAAe;AACjC;;;;;;AAOA,SAAgB,yBACd,SAGiD;CACjD,uBAAuB;CACvB,MAAM,IAAI,MAAM,eAAe;AACjC"}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { adaptToNextResponse } from "./adapt.mjs";
|
|
2
|
-
import { DEFAULT_DASHBOARD_URL, applyComposedPolicy, resolveTrustedDelegationRootsForRequest } from "./composed-policy.mjs";
|
|
3
|
-
import { nextRequestToHttpLike } from "./translate.mjs";
|
|
4
|
-
import { validateBrowserPostureConfig } from "@kya-os/checkpoint-shared/browser-posture";
|
|
5
|
-
import { applyBrowserIntegrityStepUp, applyBrowserPosture, validateBrowserIntegrityChallenge } from "@kya-os/checkpoint-wasm-runtime/composed-policy";
|
|
6
|
-
import { makeDidResolver, makePolicyEvaluator, makeReputationOracle, makeStatusListCache, makeSystemClock } from "@kya-os/checkpoint-wasm-runtime/adapters";
|
|
7
|
-
import { makeDetectionReporter } from "@kya-os/checkpoint-wasm-runtime/reporter";
|
|
8
|
-
import { PolicyFetcher, resolveChallengeContext, resolveClientIp, selectBodyReadable200 } from "@kya-os/checkpoint-shared";
|
|
9
|
-
|
|
10
|
-
//#region src/middleware-core.ts
|
|
11
|
-
/**
|
|
12
|
-
* Shared Next.js request pipeline. Node, bundler and Edge hosts inject their
|
|
13
|
-
* engine and policy-context factories; runtime-specific WASM initialization
|
|
14
|
-
* stays in each host entry. Public withCheckpoint exports live there too.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Build the Checkpoint middleware. Returns a function `(req) => NextResponse`
|
|
18
|
-
* suitable for `export default withCheckpoint({...})` in `middleware.ts`.
|
|
19
|
-
*
|
|
20
|
-
* Every verification decision flows through the Rust `kya-os-engine`
|
|
21
|
-
* via WASM. The TS layer translates request shape, calls
|
|
22
|
-
* `verifyRequest`, and translates the verdict to `NextResponse`. No
|
|
23
|
-
* verification logic lives in this file.
|
|
24
|
-
*/
|
|
25
|
-
function makeNextMiddleware(verifyRequest, renderDecisionAsResponse, config, host) {
|
|
26
|
-
if (config.browserPosture) validateBrowserPostureConfig(config.browserPosture, config.projectId);
|
|
27
|
-
if (config.browserPosture?.protectedRoutes?.length && !config.resolveDelegationChallenge) throw new Error("browserPosture.protectedRoutes requires resolveDelegationChallenge (see createBrowserIntegrityChallengeResolver)");
|
|
28
|
-
const opts = buildVerifyOpts(config);
|
|
29
|
-
const reporter = buildReporter(config, host.runtime);
|
|
30
|
-
const composed = host.buildComposedContext(config);
|
|
31
|
-
const trustedRootsResolver = buildTrustedRootsResolver(config, composed);
|
|
32
|
-
const translateOpts = {
|
|
33
|
-
drainJsonBody: config.drainJsonBody,
|
|
34
|
-
clientIpPolicy: config.clientIpPolicy
|
|
35
|
-
};
|
|
36
|
-
return async function checkpointMiddleware(req, event) {
|
|
37
|
-
const httpLike = await nextRequestToHttpLike(req, translateOpts);
|
|
38
|
-
const trustedDelegationRoots = await resolveTrustedDelegationRootsForRequest(trustedRootsResolver, req.headers);
|
|
39
|
-
const result = await verifyRequest(httpLike, trustedDelegationRoots ? {
|
|
40
|
-
...opts,
|
|
41
|
-
trustedDelegationRoots
|
|
42
|
-
} : opts);
|
|
43
|
-
await applyBrowserPosture(result, req.headers.get("cookie"), config.browserPosture, config.projectId);
|
|
44
|
-
await applyComposedPolicy(composed, result, req.nextUrl.pathname);
|
|
45
|
-
applyBrowserIntegrityStepUp(result, config.browserPosture, req.nextUrl.pathname);
|
|
46
|
-
if (reporter) {
|
|
47
|
-
const reportPromise = reporter(result, extractReporterContext(req, config.clientIpPolicy ?? { platform: "direct" }));
|
|
48
|
-
if (event) event.waitUntil(reportPromise);
|
|
49
|
-
}
|
|
50
|
-
await dispatchOnResult(config, result, req);
|
|
51
|
-
const bodyReadable200 = selectBodyReadable200(config.delegationChallengeMode ?? "negotiated", req.headers, result.detectionDetail.detectionClass, result.detectionDetail.isAgent);
|
|
52
|
-
const challengeContextRequested = result.enforcementMode === "enforce" && result.decision.kind === "Challenge" && config.resolveDelegationChallenge !== void 0;
|
|
53
|
-
const delegationChallenge = challengeContextRequested ? await resolveChallengeContext(config.resolveDelegationChallenge, {
|
|
54
|
-
result,
|
|
55
|
-
request: req
|
|
56
|
-
}, {
|
|
57
|
-
timeoutMs: config.delegationChallengeTimeoutMs,
|
|
58
|
-
onFailure: config.onDelegationChallengeFailure
|
|
59
|
-
}) : void 0;
|
|
60
|
-
const rendered = renderDecisionAsResponse(result, {
|
|
61
|
-
bodyReadable200,
|
|
62
|
-
delegationChallenge: validateBrowserIntegrityChallenge(result, delegationChallenge),
|
|
63
|
-
challengeContextRequested
|
|
64
|
-
});
|
|
65
|
-
return adaptToNextResponse(rendered, req);
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Build a fire-and-forget detection reporter from the host config. Returns
|
|
70
|
-
* `null` when `apiKey` is not set — that case is the documented opt-out
|
|
71
|
-
* (engine still runs locally, dashboard just sees no detections).
|
|
72
|
-
*/
|
|
73
|
-
/** npm package name this SDK self-reports to the detection reporter. */
|
|
74
|
-
const SDK_NAME = "@kya-os/checkpoint-nextjs";
|
|
75
|
-
/**
|
|
76
|
-
* Installed SDK version, self-reported to the detection reporter so the
|
|
77
|
-
* dashboard can version-gate "composed policy enforces here". MUST equal
|
|
78
|
-
* `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
|
|
79
|
-
* drifted). Re-exported as `VERSION` from the package index.
|
|
80
|
-
*/
|
|
81
|
-
const VERSION = "1.10.0";
|
|
82
|
-
function buildReporter(config, runtime = "node") {
|
|
83
|
-
if (!config.apiKey) return null;
|
|
84
|
-
return makeDetectionReporter({
|
|
85
|
-
apiKey: config.apiKey,
|
|
86
|
-
baseUrl: config.baseUrl,
|
|
87
|
-
debug: config.debug,
|
|
88
|
-
sdk: {
|
|
89
|
-
name: SDK_NAME,
|
|
90
|
-
version: VERSION,
|
|
91
|
-
runtime
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Build the per-factory trusted-delegation-roots resolver (P2 / DR-1). Root
|
|
97
|
-
* pinning is a security concern INDEPENDENT of composed Cedar enforcement, so it
|
|
98
|
-
* must resolve wherever a `projectId` exists — including Edge setups that never
|
|
99
|
-
* wire `cedarWasmModule` (where `buildComposedContext` returns null). Prefers the
|
|
100
|
-
* composed context's accessor (reuses its cached fetcher / honors an injected
|
|
101
|
-
* enforcer); otherwise falls back to a `projectId`-only policy fetch. Returns
|
|
102
|
-
* `null` when no source is configured (no roots → engine open default).
|
|
103
|
-
*/
|
|
104
|
-
function buildTrustedRootsResolver(config, composed) {
|
|
105
|
-
if (config.trustedDelegationRoots) return () => Promise.resolve(config.trustedDelegationRoots);
|
|
106
|
-
if (composed?.trustedDelegationRoots) return () => composed.trustedDelegationRoots();
|
|
107
|
-
if (!config.projectId) return null;
|
|
108
|
-
const fetcher = new PolicyFetcher({
|
|
109
|
-
apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? "https://kya.vouched.id",
|
|
110
|
-
apiKey: config.apiKey,
|
|
111
|
-
cacheTtlSeconds: config.policyCacheTtlSeconds
|
|
112
|
-
});
|
|
113
|
-
const projectId = config.projectId;
|
|
114
|
-
return async () => (await fetcher.getPolicy(projectId)).trustedDelegationRoots ?? [];
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Pull the request context the dashboard's `/api/v1/log-detection`
|
|
118
|
-
* endpoint expects out of a `NextRequest`. Works under both Node and
|
|
119
|
-
* Edge runtimes — no runtime-specific APIs.
|
|
120
|
-
*/
|
|
121
|
-
function extractReporterContext(req, policy) {
|
|
122
|
-
const resolution = resolveClientIp({
|
|
123
|
-
headers: req.headers,
|
|
124
|
-
frameworkAddress: req.ip,
|
|
125
|
-
policy
|
|
126
|
-
});
|
|
127
|
-
return {
|
|
128
|
-
userAgent: req.headers.get("user-agent") ?? void 0,
|
|
129
|
-
ipAddress: resolution.ip ?? void 0,
|
|
130
|
-
path: req.nextUrl.pathname,
|
|
131
|
-
url: req.nextUrl.href,
|
|
132
|
-
method: req.method
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Compose adapter defaults with caller-supplied overrides for every host.
|
|
137
|
-
*/
|
|
138
|
-
function buildVerifyOpts(config) {
|
|
139
|
-
const overrides = config.adapters ?? {};
|
|
140
|
-
return {
|
|
141
|
-
didResolver: overrides.didResolver ?? makeDidResolver(),
|
|
142
|
-
statusListCache: overrides.statusListCache ?? makeStatusListCache(),
|
|
143
|
-
reputationOracle: overrides.reputationOracle ?? makeReputationOracle({ argusUrl: config.argusUrl }),
|
|
144
|
-
policyEvaluator: overrides.policyEvaluator ?? makePolicyEvaluator({ dashboardUrl: config.dashboardUrl }),
|
|
145
|
-
clock: makeSystemClock(),
|
|
146
|
-
tenantHost: config.tenantHost,
|
|
147
|
-
resourceOrgDid: config.resourceOrgDid,
|
|
148
|
-
trustedDelegationRoots: config.trustedDelegationRoots,
|
|
149
|
-
enforcementMode: config.enforcementMode ?? "enforce",
|
|
150
|
-
reputationBaseline: config.reputationBaseline,
|
|
151
|
-
argusUrl: config.argusUrl,
|
|
152
|
-
legacyEnvelopeFallback: config.legacyEnvelopeFallback ?? false,
|
|
153
|
-
engineConfig: config.engineConfig
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
async function dispatchOnResult(config, result, req) {
|
|
157
|
-
if (!config.onResult) return;
|
|
158
|
-
try {
|
|
159
|
-
await config.onResult(result, req);
|
|
160
|
-
} catch {}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
//#endregion
|
|
164
|
-
export { makeNextMiddleware as n, VERSION as t };
|
|
165
|
-
//# sourceMappingURL=middleware-core-BYQP9FND.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-core-BYQP9FND.mjs","names":[],"sources":["../src/middleware-core.ts"],"sourcesContent":["/**\n * Shared Next.js request pipeline. Node, bundler and Edge hosts inject their\n * engine and policy-context factories; runtime-specific WASM initialization\n * stays in each host entry. Public withCheckpoint exports live there too.\n */\n\nimport { validateBrowserPostureConfig } from '@kya-os/checkpoint-shared/browser-posture';\nimport {\n applyBrowserPosture,\n applyBrowserIntegrityStepUp,\n validateBrowserIntegrityChallenge,\n} from '@kya-os/checkpoint-wasm-runtime/composed-policy';\n\nimport { type NextFetchEvent, type NextRequest, type NextResponse } from 'next/server';\n\nimport type {\n renderDecisionAsResponse as RenderDecision,\n IncomingHttpLike,\n VerifyRequestOpts,\n} from '@kya-os/checkpoint-wasm-runtime/orchestrator';\nimport {\n makeDidResolver,\n makePolicyEvaluator,\n makeReputationOracle,\n makeStatusListCache,\n makeSystemClock,\n} from '@kya-os/checkpoint-wasm-runtime/adapters';\nimport {\n makeDetectionReporter,\n type DetectionReporter,\n type ReporterContext,\n} from '@kya-os/checkpoint-wasm-runtime/reporter';\nimport type { VerifyResult } from '@kya-os/checkpoint-wasm-runtime/engine';\nimport {\n PolicyFetcher,\n resolveChallengeContext,\n resolveClientIp,\n selectBodyReadable200,\n} from '@kya-os/checkpoint-shared';\n\nimport { adaptToNextResponse } from './adapt';\nimport type { CheckpointConfig } from './config';\nimport {\n applyComposedPolicy,\n resolveTrustedDelegationRootsForRequest,\n DEFAULT_DASHBOARD_URL,\n type ComposedPolicyContext,\n type TrustedDelegationRootsResolver,\n} from './composed-policy';\nimport { nextRequestToHttpLike } from './translate';\n\n// `CheckpointConfig` lives in `./config` (a 190-line documented contract); the\n// public import paths (`.`, `/node`, `/edge`) stay stable via this re-export.\nexport type { CheckpointConfig } from './config';\n\n/**\n * Build the Checkpoint middleware. Returns a function `(req) => NextResponse`\n * suitable for `export default withCheckpoint({...})` in `middleware.ts`.\n *\n * Every verification decision flows through the Rust `kya-os-engine`\n * via WASM. The TS layer translates request shape, calls\n * `verifyRequest`, and translates the verdict to `NextResponse`. No\n * verification logic lives in this file.\n */\nexport function makeNextMiddleware(\n verifyRequest: (req: IncomingHttpLike, opts: VerifyRequestOpts) => Promise<VerifyResult>,\n renderDecisionAsResponse: typeof RenderDecision,\n config: CheckpointConfig,\n host: {\n runtime: 'node' | 'edge';\n buildComposedContext: (config: CheckpointConfig) => ComposedPolicyContext | null;\n }\n): (req: NextRequest, event?: Pick<NextFetchEvent, 'waitUntil'>) => Promise<NextResponse> {\n if (config.browserPosture) validateBrowserPostureConfig(config.browserPosture, config.projectId);\n if (config.browserPosture?.protectedRoutes?.length && !config.resolveDelegationChallenge) {\n throw new Error(\n 'browserPosture.protectedRoutes requires resolveDelegationChallenge (see createBrowserIntegrityChallengeResolver)'\n );\n }\n const opts = buildVerifyOpts(config);\n const reporter = buildReporter(config, host.runtime);\n // Null deliberately disables composed policy on Edge without a Cedar module;\n // it must never fall back to a Node policy compiler.\n const composed = host.buildComposedContext(config);\n const trustedRootsResolver = buildTrustedRootsResolver(config, composed);\n const translateOpts = {\n drainJsonBody: config.drainJsonBody,\n clientIpPolicy: config.clientIpPolicy,\n };\n return async function checkpointMiddleware(\n req: NextRequest,\n event?: Pick<NextFetchEvent, 'waitUntil'>\n ): Promise<NextResponse> {\n const httpLike = await nextRequestToHttpLike(req, translateOpts);\n // P2 / DR-1: on a delegation request, pin the engine's L2 delegation chains\n // to the org's trusted roots (resolved from the same cached policy payload).\n // Omitted on the hot path → opts unchanged (byte-identical to pre-P2).\n const trustedDelegationRoots = await resolveTrustedDelegationRootsForRequest(\n trustedRootsResolver,\n req.headers\n );\n const result = await verifyRequest(\n httpLike,\n trustedDelegationRoots ? { ...opts, trustedDelegationRoots } : opts\n );\n // Composed (kya-os-engine) policy seam — swaps result.decision in place when\n // the project's deployed Cedar bundle acts. MUST run BEFORE the reporter so\n // the dashboard records the enforced decision (parity with Express + the\n // shadow→enforce telemetry). `req.nextUrl.pathname` is the query-free path\n // verification saw. Fail-open inside applyComposedPolicy.\n await applyBrowserPosture(\n result,\n req.headers.get('cookie'),\n config.browserPosture,\n config.projectId\n );\n await applyComposedPolicy(composed, result, req.nextUrl.pathname);\n applyBrowserIntegrityStepUp(result, config.browserPosture, req.nextUrl.pathname);\n if (reporter) {\n const reportPromise = reporter(\n result,\n extractReporterContext(req, config.clientIpPolicy ?? { platform: 'direct' })\n );\n if (event) {\n event.waitUntil(reportPromise);\n } else {\n void reportPromise;\n }\n }\n await dispatchOnResult(config, result, req);\n // Dual envelope: body-readable 200 step-up for cooperative agents under\n // negotiated mode; else the spec 401/422. Shared selector (drift-proof).\n const bodyReadable200 = selectBodyReadable200(\n config.delegationChallengeMode ?? 'negotiated',\n req.headers,\n result.detectionDetail.detectionClass,\n result.detectionDetail.isAgent\n );\n const challengeContextRequested =\n result.enforcementMode === 'enforce' &&\n result.decision.kind === 'Challenge' &&\n config.resolveDelegationChallenge !== undefined;\n const delegationChallenge = challengeContextRequested\n ? await resolveChallengeContext(\n config.resolveDelegationChallenge,\n { result, request: req },\n {\n timeoutMs: config.delegationChallengeTimeoutMs,\n onFailure: config.onDelegationChallengeFailure,\n }\n )\n : undefined;\n const rendered = renderDecisionAsResponse(result, {\n bodyReadable200,\n delegationChallenge: validateBrowserIntegrityChallenge(result, delegationChallenge),\n challengeContextRequested,\n });\n return adaptToNextResponse(rendered, req);\n };\n}\n\n/**\n * Build a fire-and-forget detection reporter from the host config. Returns\n * `null` when `apiKey` is not set — that case is the documented opt-out\n * (engine still runs locally, dashboard just sees no detections).\n */\n/** npm package name this SDK self-reports to the detection reporter. */\nconst SDK_NAME = '@kya-os/checkpoint-nextjs';\n\n/**\n * Installed SDK version, self-reported to the detection reporter so the\n * dashboard can version-gate \"composed policy enforces here\". MUST equal\n * `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had\n * drifted). Re-exported as `VERSION` from the package index.\n */\nexport const VERSION = '1.10.0';\n\nfunction buildReporter(\n config: CheckpointConfig,\n runtime: 'node' | 'edge' = 'node'\n): DetectionReporter | null {\n if (!config.apiKey) return null;\n return makeDetectionReporter({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n debug: config.debug,\n // Self-identify (incl. node-vs-edge) so the dashboard can version-gate\n // enforcement. Next.js EDGE composed enforcement is opt-in (needs\n // `cedarWasmModule`), so the dashboard shows it as opt-in, never \"Enforcing\".\n sdk: { name: SDK_NAME, version: VERSION, runtime },\n });\n}\n\n/**\n * Build the per-factory trusted-delegation-roots resolver (P2 / DR-1). Root\n * pinning is a security concern INDEPENDENT of composed Cedar enforcement, so it\n * must resolve wherever a `projectId` exists — including Edge setups that never\n * wire `cedarWasmModule` (where `buildComposedContext` returns null). Prefers the\n * composed context's accessor (reuses its cached fetcher / honors an injected\n * enforcer); otherwise falls back to a `projectId`-only policy fetch. Returns\n * `null` when no source is configured (no roots → engine open default).\n */\nfunction buildTrustedRootsResolver(\n config: CheckpointConfig,\n composed: ComposedPolicyContext | null\n): TrustedDelegationRootsResolver | null {\n if (config.trustedDelegationRoots) return () => Promise.resolve(config.trustedDelegationRoots!);\n if (composed?.trustedDelegationRoots) {\n return () => composed.trustedDelegationRoots!();\n }\n if (!config.projectId) return null;\n const fetcher = new PolicyFetcher({\n apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? DEFAULT_DASHBOARD_URL,\n apiKey: config.apiKey,\n cacheTtlSeconds: config.policyCacheTtlSeconds,\n });\n const projectId = config.projectId;\n return async () => (await fetcher.getPolicy(projectId)).trustedDelegationRoots ?? [];\n}\n\n/**\n * Pull the request context the dashboard's `/api/v1/log-detection`\n * endpoint expects out of a `NextRequest`. Works under both Node and\n * Edge runtimes — no runtime-specific APIs.\n */\nfunction extractReporterContext(\n req: NextRequest,\n policy: import('@kya-os/checkpoint-shared').ClientIpTrustPolicy\n): ReporterContext {\n const resolution = resolveClientIp({\n headers: req.headers,\n frameworkAddress: (req as unknown as { ip?: string }).ip,\n policy,\n });\n return {\n userAgent: req.headers.get('user-agent') ?? undefined,\n ipAddress: resolution.ip ?? undefined,\n path: req.nextUrl.pathname,\n url: req.nextUrl.href,\n method: req.method,\n };\n}\n\n/**\n * Compose adapter defaults with caller-supplied overrides for every host.\n */\nfunction buildVerifyOpts(config: CheckpointConfig) {\n const overrides = config.adapters ?? {};\n return {\n didResolver: overrides.didResolver ?? makeDidResolver(),\n statusListCache: overrides.statusListCache ?? makeStatusListCache(),\n reputationOracle:\n overrides.reputationOracle ?? makeReputationOracle({ argusUrl: config.argusUrl }),\n policyEvaluator:\n overrides.policyEvaluator ?? makePolicyEvaluator({ dashboardUrl: config.dashboardUrl }),\n clock: makeSystemClock(),\n tenantHost: config.tenantHost,\n resourceOrgDid: config.resourceOrgDid,\n trustedDelegationRoots: config.trustedDelegationRoots,\n enforcementMode: config.enforcementMode ?? 'enforce',\n reputationBaseline: config.reputationBaseline,\n argusUrl: config.argusUrl,\n legacyEnvelopeFallback: config.legacyEnvelopeFallback ?? false,\n engineConfig: config.engineConfig,\n };\n}\n\nasync function dispatchOnResult(\n config: CheckpointConfig,\n result: VerifyResult,\n req: NextRequest\n): Promise<void> {\n if (!config.onResult) return;\n try {\n await config.onResult(result, req);\n } catch {\n // Swallow — onResult is observability, not verdict-critical.\n // Verdict already computed; let the response proceed.\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
const require_adapt = require('./adapt.js');
|
|
2
|
-
const require_composed_policy = require('./composed-policy.js');
|
|
3
|
-
const require_translate = require('./translate.js');
|
|
4
|
-
let _kya_os_checkpoint_shared_browser_posture = require("@kya-os/checkpoint-shared/browser-posture");
|
|
5
|
-
let _kya_os_checkpoint_wasm_runtime_composed_policy = require("@kya-os/checkpoint-wasm-runtime/composed-policy");
|
|
6
|
-
let _kya_os_checkpoint_wasm_runtime_adapters = require("@kya-os/checkpoint-wasm-runtime/adapters");
|
|
7
|
-
let _kya_os_checkpoint_wasm_runtime_reporter = require("@kya-os/checkpoint-wasm-runtime/reporter");
|
|
8
|
-
let _kya_os_checkpoint_shared = require("@kya-os/checkpoint-shared");
|
|
9
|
-
|
|
10
|
-
//#region src/middleware-core.ts
|
|
11
|
-
/**
|
|
12
|
-
* Shared Next.js request pipeline. Node, bundler and Edge hosts inject their
|
|
13
|
-
* engine and policy-context factories; runtime-specific WASM initialization
|
|
14
|
-
* stays in each host entry. Public withCheckpoint exports live there too.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Build the Checkpoint middleware. Returns a function `(req) => NextResponse`
|
|
18
|
-
* suitable for `export default withCheckpoint({...})` in `middleware.ts`.
|
|
19
|
-
*
|
|
20
|
-
* Every verification decision flows through the Rust `kya-os-engine`
|
|
21
|
-
* via WASM. The TS layer translates request shape, calls
|
|
22
|
-
* `verifyRequest`, and translates the verdict to `NextResponse`. No
|
|
23
|
-
* verification logic lives in this file.
|
|
24
|
-
*/
|
|
25
|
-
function makeNextMiddleware(verifyRequest, renderDecisionAsResponse, config, host) {
|
|
26
|
-
if (config.browserPosture) (0, _kya_os_checkpoint_shared_browser_posture.validateBrowserPostureConfig)(config.browserPosture, config.projectId);
|
|
27
|
-
if (config.browserPosture?.protectedRoutes?.length && !config.resolveDelegationChallenge) throw new Error("browserPosture.protectedRoutes requires resolveDelegationChallenge (see createBrowserIntegrityChallengeResolver)");
|
|
28
|
-
const opts = buildVerifyOpts(config);
|
|
29
|
-
const reporter = buildReporter(config, host.runtime);
|
|
30
|
-
const composed = host.buildComposedContext(config);
|
|
31
|
-
const trustedRootsResolver = buildTrustedRootsResolver(config, composed);
|
|
32
|
-
const translateOpts = {
|
|
33
|
-
drainJsonBody: config.drainJsonBody,
|
|
34
|
-
clientIpPolicy: config.clientIpPolicy
|
|
35
|
-
};
|
|
36
|
-
return async function checkpointMiddleware(req, event) {
|
|
37
|
-
const httpLike = await require_translate.nextRequestToHttpLike(req, translateOpts);
|
|
38
|
-
const trustedDelegationRoots = await require_composed_policy.resolveTrustedDelegationRootsForRequest(trustedRootsResolver, req.headers);
|
|
39
|
-
const result = await verifyRequest(httpLike, trustedDelegationRoots ? {
|
|
40
|
-
...opts,
|
|
41
|
-
trustedDelegationRoots
|
|
42
|
-
} : opts);
|
|
43
|
-
await (0, _kya_os_checkpoint_wasm_runtime_composed_policy.applyBrowserPosture)(result, req.headers.get("cookie"), config.browserPosture, config.projectId);
|
|
44
|
-
await require_composed_policy.applyComposedPolicy(composed, result, req.nextUrl.pathname);
|
|
45
|
-
(0, _kya_os_checkpoint_wasm_runtime_composed_policy.applyBrowserIntegrityStepUp)(result, config.browserPosture, req.nextUrl.pathname);
|
|
46
|
-
if (reporter) {
|
|
47
|
-
const reportPromise = reporter(result, extractReporterContext(req, config.clientIpPolicy ?? { platform: "direct" }));
|
|
48
|
-
if (event) event.waitUntil(reportPromise);
|
|
49
|
-
}
|
|
50
|
-
await dispatchOnResult(config, result, req);
|
|
51
|
-
const bodyReadable200 = (0, _kya_os_checkpoint_shared.selectBodyReadable200)(config.delegationChallengeMode ?? "negotiated", req.headers, result.detectionDetail.detectionClass, result.detectionDetail.isAgent);
|
|
52
|
-
const challengeContextRequested = result.enforcementMode === "enforce" && result.decision.kind === "Challenge" && config.resolveDelegationChallenge !== void 0;
|
|
53
|
-
const delegationChallenge = challengeContextRequested ? await (0, _kya_os_checkpoint_shared.resolveChallengeContext)(config.resolveDelegationChallenge, {
|
|
54
|
-
result,
|
|
55
|
-
request: req
|
|
56
|
-
}, {
|
|
57
|
-
timeoutMs: config.delegationChallengeTimeoutMs,
|
|
58
|
-
onFailure: config.onDelegationChallengeFailure
|
|
59
|
-
}) : void 0;
|
|
60
|
-
const rendered = renderDecisionAsResponse(result, {
|
|
61
|
-
bodyReadable200,
|
|
62
|
-
delegationChallenge: (0, _kya_os_checkpoint_wasm_runtime_composed_policy.validateBrowserIntegrityChallenge)(result, delegationChallenge),
|
|
63
|
-
challengeContextRequested
|
|
64
|
-
});
|
|
65
|
-
return require_adapt.adaptToNextResponse(rendered, req);
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Build a fire-and-forget detection reporter from the host config. Returns
|
|
70
|
-
* `null` when `apiKey` is not set — that case is the documented opt-out
|
|
71
|
-
* (engine still runs locally, dashboard just sees no detections).
|
|
72
|
-
*/
|
|
73
|
-
/** npm package name this SDK self-reports to the detection reporter. */
|
|
74
|
-
const SDK_NAME = "@kya-os/checkpoint-nextjs";
|
|
75
|
-
/**
|
|
76
|
-
* Installed SDK version, self-reported to the detection reporter so the
|
|
77
|
-
* dashboard can version-gate "composed policy enforces here". MUST equal
|
|
78
|
-
* `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
|
|
79
|
-
* drifted). Re-exported as `VERSION` from the package index.
|
|
80
|
-
*/
|
|
81
|
-
const VERSION = "1.10.0";
|
|
82
|
-
function buildReporter(config, runtime = "node") {
|
|
83
|
-
if (!config.apiKey) return null;
|
|
84
|
-
return (0, _kya_os_checkpoint_wasm_runtime_reporter.makeDetectionReporter)({
|
|
85
|
-
apiKey: config.apiKey,
|
|
86
|
-
baseUrl: config.baseUrl,
|
|
87
|
-
debug: config.debug,
|
|
88
|
-
sdk: {
|
|
89
|
-
name: SDK_NAME,
|
|
90
|
-
version: VERSION,
|
|
91
|
-
runtime
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Build the per-factory trusted-delegation-roots resolver (P2 / DR-1). Root
|
|
97
|
-
* pinning is a security concern INDEPENDENT of composed Cedar enforcement, so it
|
|
98
|
-
* must resolve wherever a `projectId` exists — including Edge setups that never
|
|
99
|
-
* wire `cedarWasmModule` (where `buildComposedContext` returns null). Prefers the
|
|
100
|
-
* composed context's accessor (reuses its cached fetcher / honors an injected
|
|
101
|
-
* enforcer); otherwise falls back to a `projectId`-only policy fetch. Returns
|
|
102
|
-
* `null` when no source is configured (no roots → engine open default).
|
|
103
|
-
*/
|
|
104
|
-
function buildTrustedRootsResolver(config, composed) {
|
|
105
|
-
if (config.trustedDelegationRoots) return () => Promise.resolve(config.trustedDelegationRoots);
|
|
106
|
-
if (composed?.trustedDelegationRoots) return () => composed.trustedDelegationRoots();
|
|
107
|
-
if (!config.projectId) return null;
|
|
108
|
-
const fetcher = new _kya_os_checkpoint_shared.PolicyFetcher({
|
|
109
|
-
apiBaseUrl: config.dashboardUrl ?? config.baseUrl ?? "https://kya.vouched.id",
|
|
110
|
-
apiKey: config.apiKey,
|
|
111
|
-
cacheTtlSeconds: config.policyCacheTtlSeconds
|
|
112
|
-
});
|
|
113
|
-
const projectId = config.projectId;
|
|
114
|
-
return async () => (await fetcher.getPolicy(projectId)).trustedDelegationRoots ?? [];
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Pull the request context the dashboard's `/api/v1/log-detection`
|
|
118
|
-
* endpoint expects out of a `NextRequest`. Works under both Node and
|
|
119
|
-
* Edge runtimes — no runtime-specific APIs.
|
|
120
|
-
*/
|
|
121
|
-
function extractReporterContext(req, policy) {
|
|
122
|
-
const resolution = (0, _kya_os_checkpoint_shared.resolveClientIp)({
|
|
123
|
-
headers: req.headers,
|
|
124
|
-
frameworkAddress: req.ip,
|
|
125
|
-
policy
|
|
126
|
-
});
|
|
127
|
-
return {
|
|
128
|
-
userAgent: req.headers.get("user-agent") ?? void 0,
|
|
129
|
-
ipAddress: resolution.ip ?? void 0,
|
|
130
|
-
path: req.nextUrl.pathname,
|
|
131
|
-
url: req.nextUrl.href,
|
|
132
|
-
method: req.method
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Compose adapter defaults with caller-supplied overrides for every host.
|
|
137
|
-
*/
|
|
138
|
-
function buildVerifyOpts(config) {
|
|
139
|
-
const overrides = config.adapters ?? {};
|
|
140
|
-
return {
|
|
141
|
-
didResolver: overrides.didResolver ?? (0, _kya_os_checkpoint_wasm_runtime_adapters.makeDidResolver)(),
|
|
142
|
-
statusListCache: overrides.statusListCache ?? (0, _kya_os_checkpoint_wasm_runtime_adapters.makeStatusListCache)(),
|
|
143
|
-
reputationOracle: overrides.reputationOracle ?? (0, _kya_os_checkpoint_wasm_runtime_adapters.makeReputationOracle)({ argusUrl: config.argusUrl }),
|
|
144
|
-
policyEvaluator: overrides.policyEvaluator ?? (0, _kya_os_checkpoint_wasm_runtime_adapters.makePolicyEvaluator)({ dashboardUrl: config.dashboardUrl }),
|
|
145
|
-
clock: (0, _kya_os_checkpoint_wasm_runtime_adapters.makeSystemClock)(),
|
|
146
|
-
tenantHost: config.tenantHost,
|
|
147
|
-
resourceOrgDid: config.resourceOrgDid,
|
|
148
|
-
trustedDelegationRoots: config.trustedDelegationRoots,
|
|
149
|
-
enforcementMode: config.enforcementMode ?? "enforce",
|
|
150
|
-
reputationBaseline: config.reputationBaseline,
|
|
151
|
-
argusUrl: config.argusUrl,
|
|
152
|
-
legacyEnvelopeFallback: config.legacyEnvelopeFallback ?? false,
|
|
153
|
-
engineConfig: config.engineConfig
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
async function dispatchOnResult(config, result, req) {
|
|
157
|
-
if (!config.onResult) return;
|
|
158
|
-
try {
|
|
159
|
-
await config.onResult(result, req);
|
|
160
|
-
} catch {}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
//#endregion
|
|
164
|
-
Object.defineProperty(exports, 'VERSION', {
|
|
165
|
-
enumerable: true,
|
|
166
|
-
get: function () {
|
|
167
|
-
return VERSION;
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
Object.defineProperty(exports, 'makeNextMiddleware', {
|
|
171
|
-
enumerable: true,
|
|
172
|
-
get: function () {
|
|
173
|
-
return makeNextMiddleware;
|
|
174
|
-
}
|
|
175
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import "./composed-policy-zzJYNFTb.js";
|
|
2
|
-
import { t as CheckpointConfig } from "./config-CbAg2mze.js";
|
|
3
|
-
import { NextRequest, NextResponse } from "next/server";
|
|
4
|
-
import { IncomingHttpLike } from "@kya-os/checkpoint-wasm-runtime/orchestrator";
|
|
5
|
-
import { VerifyResult } from "@kya-os/checkpoint-wasm-runtime/engine";
|
|
6
|
-
//#region src/middleware-core.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Installed SDK version, self-reported to the detection reporter so the
|
|
9
|
-
* dashboard can version-gate "composed policy enforces here". MUST equal
|
|
10
|
-
* `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
|
|
11
|
-
* drifted). Re-exported as `VERSION` from the package index.
|
|
12
|
-
*/
|
|
13
|
-
declare const VERSION = "1.10.0";
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/middleware-node.d.ts
|
|
16
|
-
/** Node host with native filesystem WASM loading. */
|
|
17
|
-
declare function withCheckpoint(config: CheckpointConfig): (req: import("next/server").NextRequest, event?: Pick<import("next/server").NextFetchEvent, "waitUntil">) => Promise<import("next/server").NextResponse>;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { VERSION as n, withCheckpoint as t };
|
|
20
|
-
//# sourceMappingURL=middleware-node-CE4GevYs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-node-CE4GevYs.d.ts","names":[],"sources":["../src/middleware-core.ts","../src/middleware-node.ts"],"mappings":";;;;;;;;;;;;cA+Ka;;;;iBCrKG,eAAe,QAAQ,oBAAgB,2BAAA,aAAA,QAAA,2BAAA,iCAAA,8BAAA"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import "./composed-policy-BCaNiVHv.mjs";
|
|
2
|
-
import { t as CheckpointConfig } from "./config-Doe0Tn53.mjs";
|
|
3
|
-
import { IncomingHttpLike, renderDecisionAsResponse } from "@kya-os/checkpoint-wasm-runtime/orchestrator";
|
|
4
|
-
import { NextRequest, NextResponse } from "next/server";
|
|
5
|
-
import { VerifyResult } from "@kya-os/checkpoint-wasm-runtime/engine";
|
|
6
|
-
//#region src/middleware-core.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Installed SDK version, self-reported to the detection reporter so the
|
|
9
|
-
* dashboard can version-gate "composed policy enforces here". MUST equal
|
|
10
|
-
* `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
|
|
11
|
-
* drifted). Re-exported as `VERSION` from the package index.
|
|
12
|
-
*/
|
|
13
|
-
declare const VERSION = "1.10.0";
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/middleware-node.d.ts
|
|
16
|
-
/** Node host with native filesystem WASM loading. */
|
|
17
|
-
declare function withCheckpoint(config: CheckpointConfig): (req: import("next/server").NextRequest, event?: Pick<import("next/server").NextFetchEvent, "waitUntil">) => Promise<import("next/server").NextResponse>;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { VERSION as n, withCheckpoint as t };
|
|
20
|
-
//# sourceMappingURL=middleware-node-DtyOuPta.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-node-DtyOuPta.d.mts","names":[],"sources":["../src/middleware-core.ts","../src/middleware-node.ts"],"mappings":";;;;;;;;;;;;cA+Ka;;;;iBCrKG,eAAe,QAAQ,oBAAgB,2BAAA,aAAA,QAAA,2BAAA,iCAAA,8BAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-node-context-BqPbf-fI.mjs","names":[],"sources":["../src/middleware-node-context.ts"],"sourcesContent":["import { PolicyFetcher } from '@kya-os/checkpoint-shared';\nimport type { CheckpointConfig } from './config';\nimport {\n makeComposedPolicyContext,\n consoleComposedPolicyLogger,\n DEFAULT_DASHBOARD_URL,\n type ComposedPolicyContext,\n} from './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 }),\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;GAC1C,QAAQ,OAAO;GACf,iBAAiB,OAAO;EAC1B,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"}
|
package/dist/middleware.d.mts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { r as NextJSMiddlewareConfig } from "./types-C0SkqLMM.mjs";
|
|
2
|
-
import { NextRequest, NextResponse } from "next/server";
|
|
3
|
-
//#region src/middleware.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
|
|
6
|
-
* Throws on invocation; surface exists only so static analysis sees
|
|
7
|
-
* the historical export.
|
|
8
|
-
*/
|
|
9
|
-
export declare function createAgentShieldMiddleware(_config?: Partial<NextJSMiddlewareConfig>): (request: NextRequest) => Promise<NextResponse>;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Alias of the deprecated `createAgentShieldMiddleware`.
|
|
12
|
-
* Migrate to `withCheckpoint`.
|
|
13
|
-
*/
|
|
14
|
-
export declare function agentShield(config?: Partial<NextJSMiddlewareConfig>): (request: NextRequest) => Promise<NextResponse>;
|
|
15
|
-
/**
|
|
16
|
-
* Pass-through export required by Next.js 16+ middleware file validation.
|
|
17
|
-
* Next.js requires any file named `middleware.ts` to export a function named
|
|
18
|
-
* `middleware` or a default function. This stub satisfies that constraint so
|
|
19
|
-
* consumers that still reference the `./middleware` subpath can build.
|
|
20
|
-
*
|
|
21
|
-
* @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
|
|
22
|
-
*/
|
|
23
|
-
export declare function middleware(_request: NextRequest): NextResponse<unknown>;
|
|
24
|
-
//#endregion
|
|
25
|
-
//# sourceMappingURL=middleware.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.mts","names":[],"sources":["../src/middleware.ts"],"mappings":";;;;;;;;wBAoCgB,4BACd,UAAS,QAAQ,2BACf,SAAS,gBAAgB,QAAQ;;;;;wBAQrB,YACd,SAAQ,QAAQ,2BACd,SAAS,gBAAgB,QAAQ;;;;;;;;;wBAYrB,WAAW,UAAU,cAAW"}
|
package/dist/middleware.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { r as NextJSMiddlewareConfig } from "./types-C7DNSCTO.js";
|
|
2
|
-
import { NextRequest, NextResponse } from "next/server";
|
|
3
|
-
//#region src/middleware.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
|
|
6
|
-
* Throws on invocation; surface exists only so static analysis sees
|
|
7
|
-
* the historical export.
|
|
8
|
-
*/
|
|
9
|
-
export declare function createAgentShieldMiddleware(_config?: Partial<NextJSMiddlewareConfig>): (request: NextRequest) => Promise<NextResponse>;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Alias of the deprecated `createAgentShieldMiddleware`.
|
|
12
|
-
* Migrate to `withCheckpoint`.
|
|
13
|
-
*/
|
|
14
|
-
export declare function agentShield(config?: Partial<NextJSMiddlewareConfig>): (request: NextRequest) => Promise<NextResponse>;
|
|
15
|
-
/**
|
|
16
|
-
* Pass-through export required by Next.js 16+ middleware file validation.
|
|
17
|
-
* Next.js requires any file named `middleware.ts` to export a function named
|
|
18
|
-
* `middleware` or a default function. This stub satisfies that constraint so
|
|
19
|
-
* consumers that still reference the `./middleware` subpath can build.
|
|
20
|
-
*
|
|
21
|
-
* @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
|
|
22
|
-
*/
|
|
23
|
-
export declare function middleware(_request: NextRequest): NextResponse<unknown>;
|
|
24
|
-
//#endregion
|
|
25
|
-
//# sourceMappingURL=middleware.d.ts.map
|
package/dist/middleware.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","names":[],"sources":["../src/middleware.ts"],"mappings":";;;;;;;;wBAoCgB,4BACd,UAAS,QAAQ,2BACf,SAAS,gBAAgB,QAAQ;;;;;wBAQrB,YACd,SAAQ,QAAQ,2BACd,SAAS,gBAAgB,QAAQ;;;;;;;;;wBAYrB,WAAW,UAAU,cAAW"}
|