@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
package/bin/setup-edge-wasm.js
DELETED
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* AgentShield Edge Runtime WASM Setup Script
|
|
5
|
-
*
|
|
6
|
-
* This script helps Next.js users set up WASM support for Edge Runtime (middleware).
|
|
7
|
-
* It copies necessary files and creates the required configuration.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
const path = require('path');
|
|
12
|
-
const { execSync } = require('child_process');
|
|
13
|
-
|
|
14
|
-
// Colors for console output
|
|
15
|
-
const colors = {
|
|
16
|
-
reset: '\x1b[0m',
|
|
17
|
-
bright: '\x1b[1m',
|
|
18
|
-
green: '\x1b[32m',
|
|
19
|
-
yellow: '\x1b[33m',
|
|
20
|
-
blue: '\x1b[34m',
|
|
21
|
-
red: '\x1b[31m',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function log(message, color = colors.reset) {
|
|
25
|
-
console.log(`${color}${message}${colors.reset}`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function error(message) {
|
|
29
|
-
console.error(`${colors.red}❌ ${message}${colors.reset}`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function success(message) {
|
|
33
|
-
log(`✅ ${message}`, colors.green);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function info(message) {
|
|
37
|
-
log(`ℹ️ ${message}`, colors.blue);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function warning(message) {
|
|
41
|
-
log(`⚠️ ${message}`, colors.yellow);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function main() {
|
|
45
|
-
log('\n🚀 AgentShield Edge Runtime WASM Setup\n', colors.bright);
|
|
46
|
-
|
|
47
|
-
// Step 1: Check if we're in a Next.js project
|
|
48
|
-
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
49
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
50
|
-
error('No package.json found. Please run this command from your Next.js project root.');
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
55
|
-
const hasNext = packageJson.dependencies?.next || packageJson.devDependencies?.next;
|
|
56
|
-
|
|
57
|
-
if (!hasNext) {
|
|
58
|
-
warning('Next.js not detected in package.json. Continuing anyway...');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Step 2: Check if AgentShield is installed
|
|
62
|
-
const agentShieldPath = path.join(process.cwd(), 'node_modules', '@kya-os', 'agentshield-nextjs');
|
|
63
|
-
if (!fs.existsSync(agentShieldPath)) {
|
|
64
|
-
error('@kya-os/checkpoint-nextjs not found in node_modules.');
|
|
65
|
-
info('Please install it first:');
|
|
66
|
-
console.log(' npm install @kya-os/checkpoint-nextjs');
|
|
67
|
-
console.log(' # or');
|
|
68
|
-
console.log(' pnpm add @kya-os/checkpoint-nextjs');
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Step 3: Create wasm directory
|
|
73
|
-
const wasmDir = path.join(process.cwd(), 'wasm');
|
|
74
|
-
if (!fs.existsSync(wasmDir)) {
|
|
75
|
-
fs.mkdirSync(wasmDir, { recursive: true });
|
|
76
|
-
success('Created wasm/ directory');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Step 4: Copy WASM file
|
|
80
|
-
const sourceWasm = path.join(agentShieldPath, 'dist', 'wasm', 'agentshield_wasm_bg.wasm');
|
|
81
|
-
const destWasm = path.join(wasmDir, 'agentshield_wasm_bg.wasm');
|
|
82
|
-
|
|
83
|
-
if (fs.existsSync(sourceWasm)) {
|
|
84
|
-
fs.copyFileSync(sourceWasm, destWasm);
|
|
85
|
-
const sizeKB = (fs.statSync(destWasm).size / 1024).toFixed(1);
|
|
86
|
-
const sizeMB = (fs.statSync(destWasm).size / 1024 / 1024).toFixed(2);
|
|
87
|
-
const sizeStr = sizeKB < 1024 ? `${sizeKB}KB` : `${sizeMB}MB`;
|
|
88
|
-
success(`Copied WASM file to wasm/ (${sizeStr})`);
|
|
89
|
-
} else {
|
|
90
|
-
// Try alternative location
|
|
91
|
-
const altSourceWasm = path.join(agentShieldPath, 'wasm', 'agentshield_wasm_bg.wasm');
|
|
92
|
-
if (fs.existsSync(altSourceWasm)) {
|
|
93
|
-
fs.copyFileSync(altSourceWasm, destWasm);
|
|
94
|
-
const sizeKB = (fs.statSync(destWasm).size / 1024).toFixed(1);
|
|
95
|
-
const sizeMB = (fs.statSync(destWasm).size / 1024 / 1024).toFixed(2);
|
|
96
|
-
const sizeStr = sizeKB < 1024 ? `${sizeKB}KB` : `${sizeMB}MB`;
|
|
97
|
-
success(`Copied WASM file to wasm/ (${sizeStr})`);
|
|
98
|
-
} else {
|
|
99
|
-
error('WASM file not found in the package. The package may be corrupted.');
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Step 5: Create TypeScript definitions
|
|
105
|
-
const dtsContent = `// Auto-generated by agentshield-setup-edge
|
|
106
|
-
// TypeScript definitions for AgentShield WASM in Edge Runtime
|
|
107
|
-
|
|
108
|
-
declare module '*.wasm?module' {
|
|
109
|
-
const wasmModule: WebAssembly.Module;
|
|
110
|
-
export default wasmModule;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface AgentShieldWasm {
|
|
114
|
-
detect_agent(metadata: string): string;
|
|
115
|
-
get_version(): string;
|
|
116
|
-
memory: WebAssembly.Memory;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export type EdgeWasmDetectionDetail =
|
|
120
|
-
import('@kya-os/checkpoint-nextjs/edge-runtime-loader').EdgeRuntimeDetectionDetail;
|
|
121
|
-
`;
|
|
122
|
-
|
|
123
|
-
const dtsPath = path.join(wasmDir, 'agentshield.d.ts');
|
|
124
|
-
fs.writeFileSync(dtsPath, dtsContent);
|
|
125
|
-
success('Created TypeScript definitions');
|
|
126
|
-
|
|
127
|
-
// Step 6: Create lib directory and Edge loader
|
|
128
|
-
const libDir = path.join(process.cwd(), 'lib');
|
|
129
|
-
if (!fs.existsSync(libDir)) {
|
|
130
|
-
fs.mkdirSync(libDir, { recursive: true });
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const edgeLoaderContent = `/**
|
|
134
|
-
* AgentShield Edge Runtime Loader
|
|
135
|
-
* Auto-generated by agentshield-setup-edge
|
|
136
|
-
*
|
|
137
|
-
* This module provides WASM-based AI agent detection for Next.js Edge Runtime.
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
import type { NextRequest } from 'next/server';
|
|
141
|
-
import type { EdgeRuntimeDetectionDetail } from '@kya-os/checkpoint-nextjs/edge-runtime-loader';
|
|
142
|
-
import type { ClientIpTrustPolicy } from '@kya-os/checkpoint-shared';
|
|
143
|
-
import { resolveClientIp } from '@kya-os/checkpoint-shared/browser';
|
|
144
|
-
import wasmModule from '../wasm/agentshield_wasm_bg.wasm?module';
|
|
145
|
-
|
|
146
|
-
type EdgeWasmDetectionDetail = EdgeRuntimeDetectionDetail;
|
|
147
|
-
|
|
148
|
-
let wasmInstance: WebAssembly.Instance | null = null;
|
|
149
|
-
let wasmMemory: WebAssembly.Memory | null = null;
|
|
150
|
-
|
|
151
|
-
interface WasmExports {
|
|
152
|
-
detect_agent(metadataPtr: number, metadataLen: number): number;
|
|
153
|
-
get_version(): number;
|
|
154
|
-
__wbindgen_malloc(size: number): number;
|
|
155
|
-
__wbindgen_free(ptr: number, size: number): void;
|
|
156
|
-
__wbindgen_realloc(ptr: number, oldSize: number, newSize: number): number;
|
|
157
|
-
memory: WebAssembly.Memory;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
async function initWasm(): Promise<void> {
|
|
161
|
-
if (wasmInstance) return;
|
|
162
|
-
|
|
163
|
-
wasmMemory = new WebAssembly.Memory({ initial: 17, maximum: 256 });
|
|
164
|
-
|
|
165
|
-
const imports = {
|
|
166
|
-
wbg: {
|
|
167
|
-
__wbindgen_throw: (ptr: number, len: number) => {
|
|
168
|
-
throw new Error(readString(ptr, len));
|
|
169
|
-
},
|
|
170
|
-
__wbg_log_: (ptr: number, len: number) => {
|
|
171
|
-
console.log(readString(ptr, len));
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
env: {
|
|
175
|
-
memory: wasmMemory,
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
wasmInstance = await WebAssembly.instantiate(wasmModule, imports);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function readString(ptr: number, len: number): string {
|
|
183
|
-
if (!wasmInstance || !wasmMemory) throw new Error('WASM not initialized');
|
|
184
|
-
const memory = new Uint8Array(wasmMemory.buffer);
|
|
185
|
-
const bytes = memory.slice(ptr, ptr + len);
|
|
186
|
-
return new TextDecoder().decode(bytes);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function writeString(str: string): [number, number] {
|
|
190
|
-
if (!wasmInstance) throw new Error('WASM not initialized');
|
|
191
|
-
const exports = wasmInstance.exports as unknown as WasmExports;
|
|
192
|
-
|
|
193
|
-
const encoded = new TextEncoder().encode(str);
|
|
194
|
-
const ptr = exports.__wbindgen_malloc(encoded.length);
|
|
195
|
-
|
|
196
|
-
const memory = new Uint8Array(exports.memory.buffer);
|
|
197
|
-
memory.set(encoded, ptr);
|
|
198
|
-
|
|
199
|
-
return [ptr, encoded.length];
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface AgentShieldOptions {
|
|
203
|
-
enableWasm?: boolean;
|
|
204
|
-
clientIpPolicy?: ClientIpTrustPolicy;
|
|
205
|
-
onAgentDetected?: (result: EdgeWasmDetectionDetail) => void;
|
|
206
|
-
blockAgents?: boolean;
|
|
207
|
-
allowedAgents?: string[];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Create an AgentShield middleware instance
|
|
212
|
-
*/
|
|
213
|
-
export function createAgentShieldMiddleware(options: AgentShieldOptions = {}) {
|
|
214
|
-
let initialized = false;
|
|
215
|
-
|
|
216
|
-
return {
|
|
217
|
-
async init(): Promise<void> {
|
|
218
|
-
if (initialized) return;
|
|
219
|
-
|
|
220
|
-
if (options.enableWasm !== false) {
|
|
221
|
-
try {
|
|
222
|
-
await initWasm();
|
|
223
|
-
initialized = true;
|
|
224
|
-
console.log('✅ AgentShield WASM initialized in Edge Runtime');
|
|
225
|
-
} catch (error) {
|
|
226
|
-
console.warn('⚠️ WASM initialization failed, using pattern detection:', error);
|
|
227
|
-
initialized = true;
|
|
228
|
-
}
|
|
229
|
-
} else {
|
|
230
|
-
initialized = true;
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
async detect(request: NextRequest): Promise<EdgeWasmDetectionDetail> {
|
|
235
|
-
const metadata = {
|
|
236
|
-
userAgent: request.headers.get('user-agent') || '',
|
|
237
|
-
ipAddress:
|
|
238
|
-
resolveClientIp({
|
|
239
|
-
headers: request.headers,
|
|
240
|
-
frameworkAddress: request.ip,
|
|
241
|
-
policy: options.clientIpPolicy ?? { platform: 'direct' },
|
|
242
|
-
}).ip || '',
|
|
243
|
-
headers: Object.fromEntries(request.headers.entries()),
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
// Try WASM detection first
|
|
247
|
-
if (wasmInstance && options.enableWasm !== false) {
|
|
248
|
-
try {
|
|
249
|
-
const exports = wasmInstance.exports as unknown as WasmExports;
|
|
250
|
-
const [ptr, len] = writeString(JSON.stringify(metadata));
|
|
251
|
-
|
|
252
|
-
const resultPtr = exports.detect_agent(ptr, len);
|
|
253
|
-
const resultLen = 1024; // Assume max result size
|
|
254
|
-
const resultStr = readString(resultPtr, resultLen);
|
|
255
|
-
|
|
256
|
-
exports.__wbindgen_free(ptr, len);
|
|
257
|
-
exports.__wbindgen_free(resultPtr, resultLen);
|
|
258
|
-
|
|
259
|
-
const result = JSON.parse(resultStr);
|
|
260
|
-
|
|
261
|
-
// EdgeWasmDetectionDetail's contract is confidence on a 0-100
|
|
262
|
-
// scale. The canonical kya-os-engine emits 0-100 natively
|
|
263
|
-
// (see checkpoint-nextjs/src/edge-runtime-loader.ts's
|
|
264
|
-
// normalizeEngineConfidence). Clamp + round here as a defensive
|
|
265
|
-
// measure for malformed WASM output, but do NOT multiply —
|
|
266
|
-
// multiplying would produce 9500 instead of 95 for any user
|
|
267
|
-
// who's switched from the legacy agentshield_wasm binding to
|
|
268
|
-
// the current engine.
|
|
269
|
-
const detection: EdgeWasmDetectionDetail = {
|
|
270
|
-
...result,
|
|
271
|
-
confidence:
|
|
272
|
-
typeof result.confidence === 'number'
|
|
273
|
-
? Math.round(Math.max(0, Math.min(100, result.confidence)))
|
|
274
|
-
: 0,
|
|
275
|
-
verificationMethod: 'signature',
|
|
276
|
-
timestamp: Date.now(),
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
if (options.onAgentDetected && detection.isAgent) {
|
|
280
|
-
options.onAgentDetected(detection);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return detection;
|
|
284
|
-
} catch (error) {
|
|
285
|
-
console.error('WASM detection failed:', error);
|
|
286
|
-
// Fall through to pattern detection
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Fallback: Pattern-based detection
|
|
291
|
-
return patternDetection(metadata, options);
|
|
292
|
-
},
|
|
293
|
-
|
|
294
|
-
isInitialized(): boolean {
|
|
295
|
-
return initialized;
|
|
296
|
-
},
|
|
297
|
-
|
|
298
|
-
getVerificationMethod(): 'cryptographic' | 'pattern' {
|
|
299
|
-
return wasmInstance ? 'cryptographic' : 'pattern';
|
|
300
|
-
},
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Pattern-based detection fallback
|
|
306
|
-
*/
|
|
307
|
-
function patternDetection(
|
|
308
|
-
metadata: { userAgent: string; ipAddress: string; headers: Record<string, string> },
|
|
309
|
-
options: AgentShieldOptions
|
|
310
|
-
): EdgeWasmDetectionDetail {
|
|
311
|
-
const userAgent = metadata.userAgent.toLowerCase();
|
|
312
|
-
|
|
313
|
-
// Known AI agent patterns with confidence scores
|
|
314
|
-
const aiAgentPatterns = [
|
|
315
|
-
{ pattern: /chatgpt-user/i, name: 'ChatGPT', confidence: 0.95 },
|
|
316
|
-
{ pattern: /claude-web/i, name: 'Claude', confidence: 0.95 },
|
|
317
|
-
{ pattern: /anthropic/i, name: 'Anthropic', confidence: 0.90 },
|
|
318
|
-
{ pattern: /openai/i, name: 'OpenAI', confidence: 0.90 },
|
|
319
|
-
{ pattern: /gpt-crawler/i, name: 'GPT Crawler', confidence: 0.95 },
|
|
320
|
-
{ pattern: /copilot/i, name: 'GitHub Copilot', confidence: 0.85 },
|
|
321
|
-
{ pattern: /bard/i, name: 'Google Gemini', confidence: 0.85 }, // legacy Bard UA → Gemini (brand retired 2024)
|
|
322
|
-
{ pattern: /gemini/i, name: 'Google Gemini', confidence: 0.85 },
|
|
323
|
-
{ pattern: /perplexity/i, name: 'Perplexity', confidence: 0.85 },
|
|
324
|
-
];
|
|
325
|
-
|
|
326
|
-
// Check headers for AI-specific patterns
|
|
327
|
-
const suspiciousHeaders = [
|
|
328
|
-
'x-openai-',
|
|
329
|
-
'x-anthropic-',
|
|
330
|
-
'x-ai-',
|
|
331
|
-
'x-llm-',
|
|
332
|
-
];
|
|
333
|
-
|
|
334
|
-
let headerBoost = 0;
|
|
335
|
-
for (const [key, value] of Object.entries(metadata.headers)) {
|
|
336
|
-
if (suspiciousHeaders.some(prefix => key.toLowerCase().startsWith(prefix))) {
|
|
337
|
-
headerBoost = 0.1;
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// Check user agent patterns
|
|
343
|
-
for (const { pattern, name, confidence } of aiAgentPatterns) {
|
|
344
|
-
if (pattern.test(userAgent)) {
|
|
345
|
-
const finalConfidence = Math.min(confidence + headerBoost, 1.0);
|
|
346
|
-
|
|
347
|
-
const result: EdgeWasmDetectionDetail = {
|
|
348
|
-
isAgent: true,
|
|
349
|
-
confidence: Math.round(finalConfidence * 100),
|
|
350
|
-
agent: name,
|
|
351
|
-
detectionClass: { type: 'AiAgent', agentType: name },
|
|
352
|
-
detectedAgent: { type: 'ai_agent', name },
|
|
353
|
-
agentType: name,
|
|
354
|
-
reasons: [\`known_pattern:\${name.toLowerCase()}\`],
|
|
355
|
-
signals: [],
|
|
356
|
-
verificationMethod: 'pattern',
|
|
357
|
-
riskLevel: finalConfidence > 0.9 ? 'high' : 'medium',
|
|
358
|
-
timestamp: Date.now(),
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
if (options.onAgentDetected) {
|
|
362
|
-
options.onAgentDetected(result);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
return result;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// Not detected as AI agent
|
|
370
|
-
return {
|
|
371
|
-
isAgent: false,
|
|
372
|
-
confidence: 0,
|
|
373
|
-
detectionClass: { type: 'Human' },
|
|
374
|
-
reasons: ['No known agent indicators matched'],
|
|
375
|
-
signals: [],
|
|
376
|
-
verificationMethod: 'pattern',
|
|
377
|
-
timestamp: Date.now(),
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
export default createAgentShieldMiddleware;
|
|
382
|
-
`;
|
|
383
|
-
|
|
384
|
-
const edgeLoaderPath = path.join(libDir, 'agentshield-edge.ts');
|
|
385
|
-
fs.writeFileSync(edgeLoaderPath, edgeLoaderContent);
|
|
386
|
-
success('Created Edge Runtime loader at lib/agentshield-edge.ts');
|
|
387
|
-
|
|
388
|
-
// Step 7: Create example middleware if it doesn't exist
|
|
389
|
-
const middlewarePath = path.join(process.cwd(), 'middleware.ts');
|
|
390
|
-
if (!fs.existsSync(middlewarePath)) {
|
|
391
|
-
const middlewareContent = `import { NextResponse } from 'next/server';
|
|
392
|
-
import type { NextRequest } from 'next/server';
|
|
393
|
-
import { createAgentShieldMiddleware } from './lib/agentshield-edge';
|
|
394
|
-
|
|
395
|
-
// Initialize AgentShield
|
|
396
|
-
const agentShield = createAgentShieldMiddleware({
|
|
397
|
-
enableWasm: true,
|
|
398
|
-
onAgentDetected: (result) => {
|
|
399
|
-
console.log(\`🤖 AI Agent detected: \${result.agent} (confidence: \${result.confidence.toFixed(1)}%)\`);
|
|
400
|
-
},
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
export async function middleware(request: NextRequest) {
|
|
404
|
-
// Initialize WASM on first request
|
|
405
|
-
await agentShield.init();
|
|
406
|
-
|
|
407
|
-
// Detect AI agents
|
|
408
|
-
const detection = await agentShield.detect(request);
|
|
409
|
-
|
|
410
|
-
// Log detection results
|
|
411
|
-
if (detection.isAgent) {
|
|
412
|
-
console.log(\`AI Agent detected on \${request.url}:\`, detection);
|
|
413
|
-
|
|
414
|
-
// Optional: Add headers to track AI agent traffic
|
|
415
|
-
const response = NextResponse.next();
|
|
416
|
-
response.headers.set('X-Agent-Detected', detection.agent || 'unknown');
|
|
417
|
-
response.headers.set('X-Agent-Confidence', detection.confidence.toString());
|
|
418
|
-
return response;
|
|
419
|
-
|
|
420
|
-
// Optional: Block AI agents (confidence is on 0-100 scale)
|
|
421
|
-
// if (detection.confidence > 90) {
|
|
422
|
-
// return NextResponse.json(
|
|
423
|
-
// { error: 'AI agent access denied' },
|
|
424
|
-
// { status: 403 }
|
|
425
|
-
// );
|
|
426
|
-
// }
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
return NextResponse.next();
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
export const config = {
|
|
433
|
-
matcher: [
|
|
434
|
-
/*
|
|
435
|
-
* Match all request paths except for the ones starting with:
|
|
436
|
-
* - api/admin (protect admin APIs)
|
|
437
|
-
* - _next/static (static files)
|
|
438
|
-
* - _next/image (image optimization files)
|
|
439
|
-
* - favicon.ico (favicon file)
|
|
440
|
-
*/
|
|
441
|
-
'/((?!_next/static|_next/image|favicon.ico).*)',
|
|
442
|
-
],
|
|
443
|
-
};
|
|
444
|
-
`;
|
|
445
|
-
|
|
446
|
-
fs.writeFileSync(middlewarePath, middlewareContent);
|
|
447
|
-
success('Created example middleware.ts');
|
|
448
|
-
} else {
|
|
449
|
-
info('middleware.ts already exists - skipping creation');
|
|
450
|
-
info('See lib/agentshield-edge.ts for integration instructions');
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
// Step 8: Update next.config.js if needed
|
|
454
|
-
const nextConfigPath = path.join(process.cwd(), 'next.config.js');
|
|
455
|
-
const nextConfigMjsPath = path.join(process.cwd(), 'next.config.mjs');
|
|
456
|
-
const configPath = fs.existsSync(nextConfigPath)
|
|
457
|
-
? nextConfigPath
|
|
458
|
-
: fs.existsSync(nextConfigMjsPath)
|
|
459
|
-
? nextConfigMjsPath
|
|
460
|
-
: null;
|
|
461
|
-
|
|
462
|
-
if (configPath) {
|
|
463
|
-
const configContent = fs.readFileSync(configPath, 'utf8');
|
|
464
|
-
|
|
465
|
-
if (!configContent.includes('wasm')) {
|
|
466
|
-
warning('Your next.config.js may need to be updated to handle WASM files.');
|
|
467
|
-
console.log('\nAdd this to your webpack config:\n');
|
|
468
|
-
console.log(
|
|
469
|
-
colors.yellow +
|
|
470
|
-
` webpack: (config) => {
|
|
471
|
-
config.module.rules.push({
|
|
472
|
-
test: /\\.wasm$/,
|
|
473
|
-
type: 'asset/resource',
|
|
474
|
-
});
|
|
475
|
-
return config;
|
|
476
|
-
},` +
|
|
477
|
-
colors.reset
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// Step 9: Final instructions
|
|
483
|
-
console.log('\n' + colors.bright + '🎉 Setup Complete!' + colors.reset);
|
|
484
|
-
console.log(
|
|
485
|
-
'\n' + colors.green + 'AgentShield Edge Runtime WASM is now configured!' + colors.reset
|
|
486
|
-
);
|
|
487
|
-
console.log('\nNext steps:');
|
|
488
|
-
console.log('1. Review the generated files:');
|
|
489
|
-
console.log(' - wasm/agentshield_wasm_bg.wasm (WASM binary)');
|
|
490
|
-
console.log(' - lib/agentshield-edge.ts (Edge Runtime loader)');
|
|
491
|
-
console.log(' - middleware.ts (Example implementation)');
|
|
492
|
-
console.log('\n2. Test your setup:');
|
|
493
|
-
console.log(' npm run dev');
|
|
494
|
-
console.log(' # Visit your site and check the console for detection logs');
|
|
495
|
-
console.log('\n3. Deploy to Vercel:');
|
|
496
|
-
console.log(' git add .');
|
|
497
|
-
console.log(' git commit -m "Add AgentShield WASM for Edge Runtime"');
|
|
498
|
-
console.log(' git push');
|
|
499
|
-
console.log(
|
|
500
|
-
'\n' +
|
|
501
|
-
colors.blue +
|
|
502
|
-
'Documentation: https://github.com/kya-os/agentshield#edge-runtime' +
|
|
503
|
-
colors.reset
|
|
504
|
-
);
|
|
505
|
-
console.log(colors.blue + 'Issues: https://github.com/kya-os/agentshield/issues' + colors.reset);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// Run the setup
|
|
509
|
-
main().catch((err) => {
|
|
510
|
-
error('Setup failed: ' + err.message);
|
|
511
|
-
console.error(err);
|
|
512
|
-
process.exit(1);
|
|
513
|
-
});
|
package/dist/adapt.d.mts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { RenderedResponse } from "@kya-os/checkpoint-wasm-runtime/orchestrator";
|
|
2
|
-
import { NextRequest, NextResponse } from "next/server";
|
|
3
|
-
//#region src/adapt.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Convert the engine's transport-agnostic `RenderedResponse` into a
|
|
6
|
-
* `NextResponse`. Sites-1's Playwright suite is the regression gate;
|
|
7
|
-
* any drift here is caught downstream.
|
|
8
|
-
*/
|
|
9
|
-
export declare function adaptToNextResponse(rendered: RenderedResponse, req: NextRequest): NextResponse;
|
|
10
|
-
//#endregion
|
|
11
|
-
//# sourceMappingURL=adapt.d.mts.map
|
package/dist/adapt.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapt.d.mts","names":[],"sources":["../src/adapt.ts"],"mappings":";;;;;;;;wBA4CgB,oBAAoB,UAAU,kBAAkB,KAAK,cAAc"}
|
package/dist/adapt.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from "next/server";
|
|
2
|
-
import { RenderedResponse } from "@kya-os/checkpoint-wasm-runtime/orchestrator";
|
|
3
|
-
//#region src/adapt.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Convert the engine's transport-agnostic `RenderedResponse` into a
|
|
6
|
-
* `NextResponse`. Sites-1's Playwright suite is the regression gate;
|
|
7
|
-
* any drift here is caught downstream.
|
|
8
|
-
*/
|
|
9
|
-
export declare function adaptToNextResponse(rendered: RenderedResponse, req: NextRequest): NextResponse;
|
|
10
|
-
//#endregion
|
|
11
|
-
//# sourceMappingURL=adapt.d.ts.map
|
package/dist/adapt.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapt.d.ts","names":[],"sources":["../src/adapt.ts"],"mappings":";;;;;;;;wBA4CgB,oBAAoB,UAAU,kBAAkB,KAAK,cAAc"}
|
package/dist/adapt.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapt.mjs","names":[],"sources":["../src/adapt.ts"],"sourcesContent":["/**\n * D.3 — `RenderedResponse` → `NextResponse` adapter.\n *\n * The host wrapper's *only* job on the outbound path: take the\n * transport-agnostic `RenderedResponse` Phase C's\n * `renderDecisionAsResponse` produces and translate it to a\n * `NextResponse`. Zero verdict decisions, zero engine I/O.\n *\n * Shared between the Node-runtime and Edge-runtime entries. The\n * branching here is identical in both — Next.js `NextResponse` has the\n * same API surface across runtimes; only the underlying response\n * primitive differs (Node http.ServerResponse vs Edge `Response`).\n *\n * Architectural pins per architect § 4.3 / § 4.4:\n *\n * 1. **Verdict-cookie format is contract.** Sites-1's Sonner toast\n * depends on `__checkpoint_verdict=%7B%22verdict%22%3A%22<v>%22...\n * %7D` (single URL-encoded JSON). Byte-format pinned by adapt.test.\n *\n * 2. **HTML-accepting clients → `/blocked` rewrite at status 200**\n * (so the page renders with the verdict cookie set; Sonner picks\n * up the cookie and shows the toast). Non-HTML clients → JSON 4xx.\n *\n * 3. **`X-Checkpoint-Engine` carries `result.engineInfo.name`** —\n * `checkpoint-engine-wasm` after Phase D ships. Brian's Sites-2\n * deviation note confirmed the `X-Checkpoint-*` prefix is canon.\n */\n\nimport { type NextRequest, NextResponse } from 'next/server';\n\nimport type { RenderedResponse } from '@kya-os/checkpoint-wasm-runtime/orchestrator';\nimport {\n VERDICT_COOKIE_NAME,\n BLOCKED_PATH,\n encodeVerdictCookie,\n acceptsHtml,\n classifyResponseShape,\n} from '@kya-os/checkpoint-shared';\n\n/**\n * Convert the engine's transport-agnostic `RenderedResponse` into a\n * `NextResponse`. Sites-1's Playwright suite is the regression gate;\n * any drift here is caught downstream.\n */\nexport function adaptToNextResponse(rendered: RenderedResponse, req: NextRequest): NextResponse {\n const clientAcceptsHtml = acceptsHtml(req.headers);\n const verdictCookie = encodeVerdictCookie(rendered);\n const shape = classifyResponseShape(rendered, clientAcceptsHtml);\n\n switch (shape) {\n case 'pass-through': {\n // Permit OR Observe-mode any-verdict.\n const res = NextResponse.next();\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n\n case 'redirect': {\n // Decision::Redirect → 302 + Location.\n const target = new URL(rendered.headers.Location!);\n const res = NextResponse.redirect(target);\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n\n case 'html-block': {\n // Sites-1 contract: HTML clients (browsers) need a renderable page\n // to show the rejection UI. The verdict cookie carries the reason;\n // the /blocked route reads it and renders the toast.\n const blockedUrl = new URL(BLOCKED_PATH, req.url);\n const res = NextResponse.rewrite(blockedUrl, { status: 200 });\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n\n case 'json-block': {\n // The orchestrator's RenderedResponse already supplies the correct\n // status (401/403/422/...); we just need to materialise the body.\n // application/problem+json (Instruct) uses the Content-Type from\n // rendered.headers; defaults to application/json for everything else.\n const body = rendered.body ?? {};\n const res = NextResponse.json(body, { status: rendered.status as number });\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n }\n}\n\n// -----------------------------------------------------------------------------\n// Helpers — Next.js-specific glue. The framework-agnostic primitives\n// (encodeVerdictCookie, acceptsHtml, classifyResponseShape,\n// VERDICT_COOKIE_NAME, BLOCKED_PATH) live in `@kya-os/checkpoint-shared`\n// so checkpoint-express + future host wrappers produce byte-identical\n// cookies and route HTML/JSON branching the same way.\n// -----------------------------------------------------------------------------\n\nfunction setVerdictCookie(res: NextResponse, value: string): void {\n // Path / SameSite / HttpOnly chosen for the Sonner-bridge use case:\n // path=/ so any route can read it, SameSite=Lax so first-party\n // navigations carry it, HttpOnly=false so the client-side toast JS\n // can read it (it's verdict UX, not a session token).\n res.cookies.set({\n name: VERDICT_COOKIE_NAME,\n value,\n path: '/',\n sameSite: 'lax',\n httpOnly: false,\n });\n}\n\nfunction applyHeaders(res: NextResponse, rendered: RenderedResponse): void {\n // NextResponse.next() / rewrite() / json() return responses with\n // some default headers; orchestrator headers (X-Checkpoint-*, Location)\n // override. We don't strip pre-existing headers — only set new ones.\n for (const [key, value] of Object.entries(rendered.headers)) {\n res.headers.set(key, value);\n }\n for (const [key, value] of rendered.headerEntries ?? []) {\n res.headers.append(key, value);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgB,oBAAoB,UAA4B,KAAgC;CAC9F,MAAM,oBAAoB,YAAY,IAAI,OAAO;CACjD,MAAM,gBAAgB,oBAAoB,QAAQ;CAGlD,QAFc,sBAAsB,UAAU,iBAElC,GAAZ;EACE,KAAK,gBAAgB;GAEnB,MAAM,MAAM,aAAa,KAAK;GAC9B,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;EAEA,KAAK,YAAY;GAEf,MAAM,SAAS,IAAI,IAAI,SAAS,QAAQ,QAAS;GACjD,MAAM,MAAM,aAAa,SAAS,MAAM;GACxC,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;EAEA,KAAK,cAAc;GAIjB,MAAM,aAAa,IAAI,IAAI,cAAc,IAAI,GAAG;GAChD,MAAM,MAAM,aAAa,QAAQ,YAAY,EAAE,QAAQ,IAAI,CAAC;GAC5D,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;EAEA,KAAK,cAAc;GAKjB,MAAM,OAAO,SAAS,QAAQ,CAAC;GAC/B,MAAM,MAAM,aAAa,KAAK,MAAM,EAAE,QAAQ,SAAS,OAAiB,CAAC;GACzE,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;CACF;AACF;AAUA,SAAS,iBAAiB,KAAmB,OAAqB;CAKhE,IAAI,QAAQ,IAAI;EACd,MAAM;EACN;EACA,MAAM;EACN,UAAU;EACV,UAAU;CACZ,CAAC;AACH;AAEA,SAAS,aAAa,KAAmB,UAAkC;CAIzE,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,OAAO,GACxD,IAAI,QAAQ,IAAI,KAAK,KAAK;CAE5B,KAAK,MAAM,CAAC,KAAK,UAAU,SAAS,iBAAiB,CAAC,GACpD,IAAI,QAAQ,OAAO,KAAK,KAAK;AAEjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.mts","names":[],"sources":["../src/api-client.ts"],"mappings":";;;;;iBAgBiB;;EAEf;;EAEA;;;;;;;EAOA;;EAEA;;EAEA;;;;;iBAgBe;EACf,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;MACE;MACA;MACA;MACA;;;;;;;YAQM,qBAAqB,KAC/B;EAGA;;EAEA;EACA;EACA;EACA,UAAU;EACV,YAAY;;EAEZ;;;;;;;;;EASA;;;;;iBAWe;EACf;EACA;IACE,UAAU;IACV;IACA;IACA,YAAY;;EAEd;IACE;IACA;;;;;;iBAOa;;EAEf,UAAU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;IAEE;;IAEA;;;;;;iBAOa;;EAEf,WAAW;;EAEX;IACE;IACA;IACA;IACA;IACA;;;EAGF;;;;;;;;;;;;;;;;;;;;;;qBA+BW;UACH;UACA;UACA;UACA;UACA;EAEI,YAAA,QAAQ;;;;EAgBd,QAAQ,OAAO,eAAe,QAAQ;;;;;EAwFtC,WAAW,OAAO,eAAe;IACrC,QAAQ;IACR;;;;;EAoBF;;;;;;;;;;;;;;;;;EAoBM,aAAa,OAAO,oBAAoB;;wBAkGhC,uBACd,SAAS,QAAQ,6BAChB;;;;wBAgBa;;qBAeH,0BAAiB;;YAGlB,0BAA0B;;qBAGzB,6BAAoB;;qBAGpB,+BAAsB"}
|
package/dist/api-client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","names":[],"sources":["../src/api-client.ts"],"mappings":";;;;;iBAgBiB;;EAEf;;EAEA;;;;;;;EAOA;;EAEA;;EAEA;;;;;iBAgBe;EACf,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;MACE;MACA;MACA;MACA;;;;;;;YAQM,qBAAqB,KAC/B;EAGA;;EAEA;EACA;EACA;EACA,UAAU;EACV,YAAY;;EAEZ;;;;;;;;;EASA;;;;;iBAWe;EACf;EACA;IACE,UAAU;IACV;IACA;IACA,YAAY;;EAEd;IACE;IACA;;;;;;iBAOa;;EAEf,UAAU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;IAEE;;IAEA;;;;;;iBAOa;;EAEf,WAAW;;EAEX;IACE;IACA;IACA;IACA;IACA;;;EAGF;;;;;;;;;;;;;;;;;;;;;;qBA+BW;UACH;UACA;UACA;UACA;UACA;EAEI,YAAA,QAAQ;;;;EAgBd,QAAQ,OAAO,eAAe,QAAQ;;;;;EAwFtC,WAAW,OAAO,eAAe;IACrC,QAAQ;IACR;;;;;EAoBF;;;;;;;;;;;;;;;;;EAoBM,aAAa,OAAO,oBAAoB;;wBAkGhC,uBACd,SAAS,QAAQ,6BAChB;;;;wBAgBa;;qBAeH,0BAAiB;;YAGlB,0BAA0B;;qBAGzB,6BAAoB;;qBAGpB,+BAAsB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-middleware-CMDRoQik.mjs","names":[],"sources":["../src/responses/agent-instruction.ts","../src/api-middleware.ts"],"sourcesContent":["/**\n * Agent Instruction Response Builder (Next.js)\n *\n * Tells an AI agent where to send its user to complete consent / connect,\n * via a machine-parseable Link header + JSON body.\n *\n * **Dual envelope.** By default this is a 401 instruction response. AI-agent fetchers (Claude-User\n * WebFetch, ChatGPT) collapse 4xx responses and never surface the body to\n * the LLM, so the instruction is invisible. When the caller is a\n * cooperative, self-identifying agent (selected upstream via\n * `serveBodyReadable200`), pass `{ bodyReadable200: true }` to serve the\n * SAME body at HTTP 200 with NO `WWW-Authenticate` (a 200 + WWW-Authenticate\n * is reinterpreted as 401 by some fetchers); the consent URL stays in the\n * body + the `KYA-Auth-Url`/`Link` hint headers. This also realigns\n * TS-instruct (was 401-only) with .NET-instruct (200).\n *\n * Envelope selection is a cooperative-UX bridge, NOT an access control —\n * the authoritative consent target is the body `user_action_required.url`;\n * the `KYA-Auth-Url`/`Link` headers are unsigned hints.\n *\n * This is the in-app counterpart to the Cloudflare Gateway's builder at\n * `apps/web/workers/gateway/src/responses/agent-instruction.ts`. The body\n * is kept in sync so LLM and MCP clients see identical behavior whether a\n * site is protected by the gateway or by the Next.js middleware.\n *\n * Implements RFC 8288 Link discovery. It deliberately emits no\n * `WWW-Authenticate`; only a registered policy Challenge may emit the canonical\n * Delegation authentication fields.\n *\n * @see ../../apps/web/workers/gateway/src/responses/agent-instruction.ts\n */\n\nimport { NextResponse, type NextRequest } from 'next/server';\nimport type { EnforcementDecision } from '../api-client';\nimport { safeHostname } from '../utils';\n\nconst MCP_I_DOCS_URL = 'https://kya.vouched.id/docs/enforce/kya-os-enforcement';\nconst DEFAULT_CONNECT_PATH = '/connect';\n\n/** Options controlling which envelope `buildAgentInstructionResponse` emits. */\nexport interface AgentInstructionResponseOptions {\n /**\n * When true, serve the body-readable HTTP 200 fetcher envelope (same\n * body, no `WWW-Authenticate`) instead of the 401. The caller\n * decides this via the shared `serveBodyReadable200` predicate when its\n * challenge-emission mode is `negotiated`. Defaults to false.\n */\n bodyReadable200?: boolean;\n}\n\n/**\n * Build an \"agent must connect\" response for the Next.js middleware.\n *\n * The caller is responsible for deciding *when* to call this (typically when\n * `decision.action === 'redirect'` or `'instruct'`) and *which envelope* via\n * `options.bodyReadable200`. This helper only owns the response shape.\n */\nexport function buildAgentInstructionResponse(\n request: NextRequest,\n decision: EnforcementDecision,\n redirectUrl: string | undefined,\n options?: AgentInstructionResponseOptions\n): NextResponse {\n // Resolve the target to an absolute URL against the incoming request so the\n // Link header is dereferenceable by strict clients (some LLM fetchers refuse\n // relative URIs in Link).\n const resolved = resolveUrl(redirectUrl ?? DEFAULT_CONNECT_PATH, request.url);\n\n // Match gateway's \"connect page\" branch: attach ?agent= for client-specific\n // install cards on the landing page.\n const agentName = decision.agentName || decision.agentType || 'unknown';\n if (!resolved.searchParams.has('agent')) {\n resolved.searchParams.set('agent', agentName.toLowerCase());\n }\n\n const authUrl = resolved.toString();\n const hostname = safeHostname(request.url);\n\n const body = {\n // Markdown-formatted so clients that render markdown (Claude Desktop,\n // ChatGPT web) surface the URL as a clickable link. Tone mirrors the\n // gateway response so messaging stays consistent across platforms.\n message:\n `I can't access ${hostname} yet — this site checks AI assistants at the front door.\\n\\n` +\n `**To give me access, open this link:**\\n` +\n `[Connect securely to ${hostname}](${authUrl})\\n\\n` +\n `It only takes a moment and you won't need to do it again. ` +\n `Once you're done, ask me to try again and I'll connect through the verified channel automatically.`,\n\n user_action_required: {\n action: `Connect securely to ${hostname}`,\n url: authUrl,\n reason: `${hostname} checks AI assistants before they connect. Open the link to give your assistant a verified key.`,\n },\n\n mcp_i: {\n version: '1.0' as const,\n action: 'authenticate' as const,\n authorization_url: authUrl,\n flow: {\n type: 'oauth2_delegation' as const,\n steps: [\n '1. Direct your user to the authorization_url',\n '2. User reviews requested scopes and grants consent',\n '3. Receive delegation credential (JWT)',\n '4. Include credential in KYA-Delegation header',\n '5. Retry this request with the proof',\n ],\n },\n retry_instructions: {\n header: 'KYA-Delegation' as const,\n format: 'JWT delegation credential from authorization flow',\n },\n documentation: MCP_I_DOCS_URL,\n },\n\n error: 'mcp_authentication_required',\n code: 'AGENT_REQUIRES_DELEGATION',\n\n detection: {\n agent_type: decision.agentType || 'ai_agent',\n agent_name: decision.agentName || 'Unknown Agent',\n confidence: decision.confidence,\n },\n };\n\n // Dual envelope: 200 body-readable for cooperative fetchers, else 401.\n // The body is identical across both. INSTRUCT is not a registered policy\n // Delegation challenge, so it must not advertise a fabricated auth scheme.\n const bodyReadable200 = options?.bodyReadable200 ?? false;\n const response = NextResponse.json(body, { status: bodyReadable200 ? 200 : 401 });\n\n // RFC 8288 discovery pointer + KYA-* hints. Present on BOTH envelopes —\n // these are unsigned hints; the authoritative target is the body\n // `user_action_required.url`. `rel=\"kya-authorize\"` matches the CF gateway.\n response.headers.set(\n 'Link',\n `<${authUrl}>; rel=\"kya-authorize\", <${MCP_I_DOCS_URL}>; rel=\"help\"`\n );\n response.headers.set('KYA-Auth-Required', 'true');\n response.headers.set('KYA-Auth-Url', authUrl);\n response.headers.set('KYA-Action', 'instruct');\n response.headers.set('KYA-Detected-Agent', agentName);\n response.headers.set('KYA-Confidence', decision.confidence.toString());\n response.headers.set('Cache-Control', 'no-store');\n\n return response;\n}\n\n/**\n * Resolve a URL that may be absolute or a same-origin path.\n * Falls back to `/connect` on the request origin if parsing fails.\n */\nfunction resolveUrl(target: string, baseUrl: string): URL {\n try {\n return new URL(target, baseUrl);\n } catch {\n return new URL(DEFAULT_CONNECT_PATH, baseUrl);\n }\n}\n","/**\n * API-based AgentShield Middleware for Next.js\n *\n * This middleware uses the AgentShield API for detection and enforcement,\n * instead of running detection locally. This approach:\n *\n * 1. Works reliably in Edge Runtime (no WASM loading issues)\n * 2. Ensures consistent detection across all platforms\n * 3. Applies centralized policies from the dashboard\n * 4. Supports deny lists, thresholds, and path rules\n *\n * @example\n * ```typescript\n * // middleware.ts\n * import { withCheckpointApi } from '@kya-os/checkpoint-nextjs/api-middleware';\n *\n * export default withCheckpointApi({\n * apiKey: process.env.CHECKPOINT_API_KEY!,\n * // Optional overrides:\n * onBlock: 'redirect', // 'block' | 'redirect' | 'challenge'\n * redirectUrl: '/blocked',\n * skipPaths: ['/api/health', '/_next/*'],\n * });\n *\n * export const config = {\n * matcher: ['/((?!_next/static|favicon.ico).*)'],\n * };\n * ```\n */\n\nimport { NextRequest, NextResponse } from 'next/server';\nimport {\n matchPath,\n type ClientIpTrustPolicy,\n selectBodyReadable200,\n type ChallengeEnvelopeMode,\n} from '@kya-os/checkpoint-shared';\nimport {\n CheckpointApiClient,\n getCheckpointApiClient,\n type EnforcementDecision,\n} from './api-client';\nimport { buildAgentInstructionResponse } from './responses/agent-instruction';\nimport { getClientIp, safeHostname } from './utils';\n// A genuine hard dependency, not an optional one, despite forcing every\n// consumer (even non-Vercel ones) to install it (bestbrian review,\n// checkpoint#4460). Two reasons a dynamic/optional-peer import — the\n// pattern this file used briefly, mirroring `storage/index.ts`'s\n// `@upstash/redis` — does NOT work here (Bugbot review, checkpoint#4657):\n// 1. This middleware explicitly targets Edge Runtime (see the module doc\n// comment). A `webpackIgnore`d variable-name `import()` is invisible\n// to the bundler on purpose — but Edge Runtime has no filesystem/module\n// resolution at request time, only what the bundler actually included.\n// An intentionally-unbundled import can never resolve there; `waitUntil`\n// would silently never register, reintroducing the exact lost-detection\n// bug this wrapper exists to prevent.\n// 2. It's unnecessary: `waitUntil()`'s own implementation\n// (`getContext().waitUntil?.(promise)`, where `getContext()` returns\n// `{}` off Vercel) already no-ops safely everywhere it isn't backed by\n// a real Vercel request context — Node, Edge, tests, wherever. There is\n// no failure mode to guard against with a fallback; the only real cost\n// of the hard dependency is a few extra KB installed on non-Vercel\n// consumers, which is the correct trade against actually breaking\n// detection logging on Vercel.\nimport { waitUntil } from '@vercel/functions';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Middleware configuration\n */\nexport interface CheckpointApiMiddlewareConfig {\n /** Explicit deployment/proxy trust profile for client-IP resolution. */\n clientIpPolicy?: ClientIpTrustPolicy;\n /** API key (or use CHECKPOINT_API_KEY env var) */\n apiKey?: string;\n /**\n * Gateway base URL. Override for staging or self-hosted deployments.\n * With `useEdge: false` the default becomes `https://kya.vouched.id`.\n *\n * @default 'https://detect.checkpoint-gateway.ai'\n */\n apiUrl?: string;\n /**\n * Use edge detection for lower latency (~30-50ms vs ~150ms) and better coverage.\n * Edge detection can identify non-JS clients (curl, Python, Claude Code WebFetch)\n * that the pixel cannot detect since they don't execute JavaScript.\n * Set to false to use the Vercel API instead.\n * @default true\n */\n useEdge?: boolean;\n /**\n * Request timeout in milliseconds for the gateway call.\n *\n * @default 5000\n */\n timeout?: number;\n\n /**\n * Action to take when an agent should be blocked\n * - 'block': Return 403 response\n * - 'redirect': Redirect to redirectUrl\n * - 'challenge': Show a challenge page (future)\n * Default: uses policy from dashboard\n */\n onBlock?: 'block' | 'redirect' | 'challenge';\n\n /**\n * URL to redirect to when blocking (if onBlock is 'redirect')\n * Default: uses redirectUrl from dashboard policy\n */\n redirectUrl?: string;\n\n /**\n * How the middleware handles a `redirect` / `instruct` action.\n *\n * - `'instruct'` (default): return HTTP 401 with a KYA-OS Link header + JSON\n * body pointing the agent at the redirect URL. LLMs surface the URL as a\n * clickable link for the user. Matches the Cloudflare Gateway contract.\n * - `'http'`: legacy behavior — return HTTP 302 with `Location`. Most LLM\n * fetchers won't follow the redirect, so this is only useful when your\n * traffic is real browsers.\n *\n * @default 'instruct'\n */\n redirectMode?: 'instruct' | 'http';\n\n /**\n * Challenge-emission envelope mode (draft-kya-http-02 §8.1 fetcher-200).\n * `negotiated` serves a body-readable HTTP 200 instruct response to\n * cooperative agents (so fetchers that drop 4xx bodies can read it),\n * keeping the spec 401 for everyone else. Defaults to `negotiated` (#3530).\n * A cooperative-UX bridge, NOT an access control.\n *\n * @default 'negotiated'\n */\n delegationChallengeMode?: ChallengeEnvelopeMode;\n\n /**\n * Customize the blocked response's status, message, and extra headers.\n *\n * @default { status: 403, message: 'Access denied' }\n */\n blockedResponse?: {\n status?: number;\n message?: string;\n headers?: Record<string, string>;\n };\n\n /**\n * Paths to skip (in addition to dashboard policy)\n * Supports glob patterns: '/api/*', '/_next/*'\n */\n skipPaths?: string[];\n\n /**\n * Only enforce on these paths (overrides dashboard policy)\n */\n includePaths?: string[];\n\n /**\n * Callback when an agent is detected\n */\n onAgentDetected?: (request: NextRequest, decision: EnforcementDecision) => void | Promise<void>;\n\n /**\n * Callback to customize the blocked response\n */\n customBlockedResponse?: (\n request: NextRequest,\n decision: EnforcementDecision\n ) => NextResponse | Promise<NextResponse>;\n\n /**\n * Whether to fail open (allow) on API errors. Recommended for production.\n *\n * @default true\n */\n failOpen?: boolean;\n\n /**\n * Log detection decisions and errors to the console.\n *\n * @default false\n */\n debug?: boolean;\n}\n\n// ============================================================================\n// Path Matching\n// ============================================================================\n\n/**\n * Check if path should be skipped\n */\nfunction shouldSkipPath(path: string, skipPaths: string[]): boolean {\n return skipPaths.some((pattern) => matchPath(path, pattern));\n}\n\n/**\n * Check if path should be included (if includePaths is set)\n */\nfunction shouldIncludePath(path: string, includePaths?: string[]): boolean {\n if (!includePaths || includePaths.length === 0) return true;\n return includePaths.some((pattern) => matchPath(path, pattern));\n}\n\n// ============================================================================\n// Response Builders\n// ============================================================================\n\n/**\n * Build blocked response.\n *\n * When the policy attaches a `redirectUrl` (e.g. the dashboard's hosted\n * /connect page), we still respect the `block` action but surface the URL to\n * LLM clients so the user can recover: `Link` header + `user_action_required`\n * in the JSON body. Status stays 403 — this is not an auth challenge, it's a\n * blocked request with a recovery hint.\n */\nfunction buildBlockedResponse(\n request: NextRequest,\n decision: EnforcementDecision,\n config: CheckpointApiMiddlewareConfig\n): NextResponse {\n const status = config.blockedResponse?.status ?? 403;\n const message = config.blockedResponse?.message ?? decision.message ?? 'Access denied';\n\n const recoveryUrl = resolveRecoveryUrl(request, config.redirectUrl || decision.redirectUrl);\n\n const body: Record<string, unknown> = {\n error: message,\n code: 'AGENT_BLOCKED',\n reason: decision.reason,\n agentType: decision.agentType,\n };\n\n if (recoveryUrl) {\n const hostname = safeHostname(request.url);\n body.user_action_required = {\n action: `Connect securely to ${hostname}`,\n url: recoveryUrl,\n reason: `${hostname} blocks unverified AI assistants. Open the link to give your assistant a verified key and try again.`,\n };\n body.message =\n `I can't access ${hostname} — this site blocks unverified AI assistants.\\n\\n` +\n `**To give me access, open this link:**\\n` +\n `[Connect securely to ${hostname}](${recoveryUrl})\\n\\n` +\n `Once you're done, ask me to try again.`;\n }\n\n const response = NextResponse.json(body, { status });\n\n // Add custom headers\n if (config.blockedResponse?.headers) {\n for (const [key, value] of Object.entries(config.blockedResponse.headers)) {\n response.headers.set(key, value);\n }\n }\n\n if (recoveryUrl) {\n // RFC 8288 discovery pointer — same rel value the 401 instruct path uses\n // so LLM clients can parse it uniformly.\n response.headers.set('Link', `<${recoveryUrl}>; rel=\"kya-authorize\"`);\n response.headers.set('KYA-Auth-Url', recoveryUrl);\n }\n\n // Add AgentShield headers\n response.headers.set('KYA-Action', decision.action);\n response.headers.set('KYA-Reason', decision.reason);\n\n return response;\n}\n\nfunction resolveRecoveryUrl(request: NextRequest, target: string | undefined): string | undefined {\n if (!target) return undefined;\n try {\n return new URL(target, request.url).toString();\n } catch {\n return undefined;\n }\n}\n\n/**\n * Build redirect response\n */\nfunction buildRedirectResponse(\n request: NextRequest,\n decision: EnforcementDecision,\n config: CheckpointApiMiddlewareConfig\n): NextResponse {\n const redirectUrl = config.redirectUrl || decision.redirectUrl || '/blocked';\n const url = new URL(redirectUrl, request.url);\n\n // Add query params with detection info\n url.searchParams.set('reason', decision.reason);\n if (decision.agentType) {\n url.searchParams.set('agent', decision.agentType);\n }\n\n return NextResponse.redirect(url);\n}\n\n// ============================================================================\n// Middleware Factory\n// ============================================================================\n\n/**\n * Create AgentShield middleware with API-based detection\n *\n * @example\n * ```typescript\n * // middleware.ts\n * import { withCheckpointApi } from '@kya-os/checkpoint-nextjs/api-middleware';\n *\n * export default withCheckpointApi({\n * onBlock: 'block',\n * skipPaths: ['/api/health'],\n * });\n * ```\n */\nexport function withCheckpointApi(config: CheckpointApiMiddlewareConfig = {}) {\n // Initialize client (will use CHECKPOINT_API_KEY env var if not provided)\n let client: CheckpointApiClient | null = null;\n\n const getClient = () => {\n if (!client) {\n client = getCheckpointApiClient({\n apiKey: config.apiKey,\n baseUrl: config.apiUrl,\n useEdge: config.useEdge,\n timeout: config.timeout,\n debug: config.debug,\n });\n }\n return client;\n };\n\n // Default skip paths (static assets, etc.).\n //\n // `**` (globstar) is intentional for the `_next/*` patterns: Next.js\n // ships static assets at deeply nested paths like\n // `/_next/static/chunks/main.js` and `/_next/image/?url=…` query-\n // suffixed. The shared `matchPath` treats single `*` as `[^/]*`\n // (segment-local) — pre-rename this code relied on the local\n // matchPath's buggy `*` → `.*` (cross-boundary) coincidence; without\n // `**` here every static-asset request would now hit the enforcement\n // API. Picked up by cursor-bot on PR #2568 after the matchPath swap.\n const defaultSkipPaths = [\n '/_next/static/**',\n '/_next/image/**',\n '/favicon.ico',\n '/robots.txt',\n '/sitemap.xml',\n ];\n\n const skipPaths = [...defaultSkipPaths, ...(config.skipPaths || [])];\n const failOpen = config.failOpen ?? true;\n\n return async function middleware(request: NextRequest): Promise<NextResponse> {\n const path = request.nextUrl.pathname;\n const startTime = Date.now();\n\n // Check skip paths\n if (shouldSkipPath(path, skipPaths)) {\n return NextResponse.next();\n }\n\n // Check include paths\n if (!shouldIncludePath(path, config.includePaths)) {\n return NextResponse.next();\n }\n\n try {\n const client = getClient();\n\n // Extract request context for potential logging\n const userAgent = request.headers.get('user-agent') || undefined;\n const ipAddress = getClientIp(request, config.clientIpPolicy);\n\n // Call enforce API\n const result = await client.enforce({\n headers: Object.fromEntries(request.headers.entries()),\n userAgent,\n ipAddress,\n path,\n url: request.url,\n method: request.method,\n requestId: request.headers.get('x-request-id') || undefined,\n options: {\n // Always include detection results for logging (needed when using edge)\n includeDetectionResult: true,\n },\n });\n\n // Handle API error\n if (!result.success || !result.data) {\n if (config.debug) {\n console.warn('[Checkpoint] API error:', result.error);\n }\n\n if (failOpen) {\n return NextResponse.next();\n }\n\n // Fail closed - block on error\n return NextResponse.json(\n { error: 'Security check failed', code: 'API_ERROR' },\n { status: 503 }\n );\n }\n\n const decision = result.data.decision;\n\n // Log if debug enabled\n if (config.debug) {\n console.log('[Checkpoint] Decision:', {\n path,\n action: decision.action,\n isAgent: decision.isAgent,\n confidence: decision.confidence,\n agentName: decision.agentName,\n detectionMethod: result.data.detection?.detectionMethod || 'not-included',\n processingTimeMs: Date.now() - startTime,\n });\n }\n\n // Fire-and-forget logging - ONLY when using Gateway Worker (edge detection)\n // When useEdge: false, the /api/v1/enforce endpoint already logs to the database\n // This prevents double-logging while ensuring Gateway detections are persisted\n //\n // Wrapped in waitUntil(): on Vercel's Edge/Fluid Compute runtimes, the\n // platform is free to abort any work still pending once this function\n // returns its Response — an un-awaited fetch() with no lifecycle\n // extension gets killed mid-flight (observed live as `[Checkpoint] Log\n // detection failed: DOMException [AbortError]: This operation was\n // aborted`, 100% reproduction rate on a real deployment: every\n // detection classified correctly but never persisted). waitUntil()\n // tells the platform to keep the function alive until this promise\n // settles, without making the response wait for it. Off Vercel (or\n // wherever no request context backs it) waitUntil() itself no-ops\n // safely — see the import's doc comment — so this needs no fallback.\n if (client.isUsingEdge() && result.data.detection) {\n waitUntil(\n client\n .logDetection({\n detection: result.data.detection,\n context: { userAgent, ipAddress, path, url: request.url, method: request.method },\n // This is the Next.js middleware regardless of whether it used\n // edge detection or the Vercel API. `logDetection`'s own\n // default ('gateway') describes the transport, not the\n // installation, so this must say 'middleware' explicitly.\n source: 'middleware',\n })\n .catch((err) => {\n if (config.debug) {\n console.error('[Checkpoint] Log detection failed:', err);\n }\n })\n );\n }\n\n // Observability callbacks must not influence enforcement. A throwing\n // callback used to hit the outer fail-open catch before block/redirect\n // actions ran, allowing requests the API had already denied.\n if (decision.isAgent && config.onAgentDetected) {\n try {\n await config.onAgentDetected(request, decision);\n } catch (error) {\n if (config.debug) {\n console.error('[Checkpoint] onAgentDetected callback failed:', error);\n }\n }\n }\n\n // Handle enforcement action\n const redirectMode = config.redirectMode ?? 'instruct';\n switch (decision.action) {\n case 'block': {\n // Use custom response if provided. `return await` (not bare\n // `return`) keeps a rejected promise inside this try block so\n // the `failOpen` catch path below can absorb it — without the\n // await, the rejection escapes synchronously and the caller\n // sees an unhandled 500 instead of the intended `NextResponse.next()`\n // fail-open. Same shape as the `await config.onAgentDetected(...)`\n // call earlier in this handler.\n if (config.customBlockedResponse) {\n return await config.customBlockedResponse(request, decision);\n }\n\n // Check if config overrides to redirect\n if (config.onBlock === 'redirect') {\n return buildRedirectResponse(request, decision, config);\n }\n\n return buildBlockedResponse(request, decision, config);\n }\n\n case 'redirect':\n case 'instruct': {\n // Default behavior: 401 + Link header + JSON body so LLM clients can\n // surface the /connect URL as a link for the user to open. This\n // matches `buildAgentInstructionResponse` in the CF gateway, so\n // hostname-routed and self-hosted deployments behave the same.\n //\n // Legacy 302 behavior is available under `redirectMode: 'http'` for\n // customers who want a plain browser redirect.\n if (redirectMode === 'http' && decision.action === 'redirect') {\n return buildRedirectResponse(request, decision, config);\n }\n\n const targetUrl = config.redirectUrl || decision.redirectUrl;\n // Dual envelope: serve the body-readable 200 to cooperative agents\n // under negotiated mode; else the spec 401. Feed the shared selector\n // the API's detection class + isAgent from the SAME detection payload\n // the engine PEPs (express / nextjs middleware) use — so negotiated\n // mode can't disagree across PEPs, and the class/isAgent pair the\n // predicate gates on stays internally consistent (never the\n // `decision.isAgent` proxy, which could diverge from this payload).\n const bodyReadable200 = selectBodyReadable200(\n config.delegationChallengeMode ?? 'negotiated',\n request.headers,\n result.data.detection?.detectionClass,\n result.data.detection?.isAgent ?? false\n );\n return buildAgentInstructionResponse(request, decision, targetUrl, {\n bodyReadable200,\n });\n }\n\n case 'challenge': {\n return buildRedirectResponse(request, decision, config);\n }\n\n case 'log':\n case 'allow':\n default: {\n // Allow the request to proceed\n const response = NextResponse.next();\n\n // Add detection headers for downstream use\n if (decision.isAgent) {\n response.headers.set('KYA-Detected', 'true');\n response.headers.set('KYA-Confidence', decision.confidence.toString());\n if (decision.agentName) {\n response.headers.set('KYA-Agent', decision.agentName);\n }\n }\n\n return response;\n }\n }\n } catch (error) {\n // Unexpected error\n if (config.debug) {\n console.error('[Checkpoint] Middleware error:', error);\n }\n\n if (failOpen) {\n return NextResponse.next();\n }\n\n return NextResponse.json(\n { error: 'Security check failed', code: 'MIDDLEWARE_ERROR' },\n { status: 503 }\n );\n }\n };\n}\n\n// ---------------------------------------------------------------------------\n// Back-compat aliases (Phase D rename — `withAgentShield` → `withCheckpointApi`).\n//\n// The SaaS-API deployment shape is alive and maintained — it dispatches\n// to the Cloudflare DNS gateway (`https://detect.checkpoint-gateway.ai`)\n// rather than running the engine locally. Customers running on\n// platforms where the local-engine path (`withCheckpoint`) doesn't fit\n// (no WASM toolchain, edge runtime quirks, centralized policy needs)\n// stay on this path. The rename aligns the function name with the rest\n// of the `checkpoint-*` surface; the old `withAgentShield` name keeps\n// shipping as a deprecated alias.\n// ---------------------------------------------------------------------------\n\n/** @deprecated Renamed to {@link withCheckpointApi}. The behaviour is identical. */\nexport const withAgentShield = withCheckpointApi;\n\n/** @deprecated Renamed to {@link CheckpointApiMiddlewareConfig}. */\nexport type AgentShieldMiddlewareConfig = CheckpointApiMiddlewareConfig;\n\n// ---------------------------------------------------------------------------\n// Legacy throw-stubs — these forms predate Phase D and were ratified as\n// dead in the architect's review. The `withCheckpoint` (local engine)\n// and `withCheckpointApi` (SaaS gateway) paths replace them.\n// ---------------------------------------------------------------------------\n\nconst LEGACY_MIGRATION_ERROR =\n 'This export was removed in Phase D. Migrate to `withCheckpoint` ' +\n '(local-engine deployment) or `withCheckpointApi` (SaaS-gateway ' +\n 'deployment) from `@kya-os/checkpoint-nextjs`. See ' +\n 'packages/checkpoint-nextjs/README.md (Two deployment shapes) for ' +\n 'which one fits your runtime.';\n\n/**\n * @deprecated Module-load-time invocation of the legacy `withAgentShield()`.\n * Construct the middleware explicitly via `withCheckpointApi({ apiKey })`\n * instead of relying on a default-constructed singleton at import time.\n */\nexport function agentShieldMiddleware(_request: NextRequest): Promise<NextResponse> {\n throw new Error(LEGACY_MIGRATION_ERROR);\n}\n\n/**\n * @deprecated The \"enhanced middleware\" combined detection + storage +\n * enforcement into a single legacy path that no longer exists. Migrate\n * to `withCheckpoint` (local-engine) or `withCheckpointApi` (SaaS-gateway).\n */\nexport function createEnhancedAgentShieldMiddleware(\n _config: EnhancedMiddlewareConfig = {}\n): (request: NextRequest) => Promise<NextResponse> {\n throw new Error(LEGACY_MIGRATION_ERROR);\n}\n\n// Deprecated type aliases retained for compile-time surface stability —\n// every field was tied to the now-dead enhanced-middleware path.\n\n/** @deprecated The enhanced-middleware path is gone. Use `CheckpointConfig` (local-engine) or `CheckpointApiMiddlewareConfig` (SaaS). */\nexport type EnhancedMiddlewareConfig = Record<string, unknown>;\n\n/** @deprecated Storage was tied to the legacy enhanced-middleware path. */\nexport type StorageAdapter = Record<string, unknown>;\n\n/** @deprecated Storage was tied to the legacy enhanced-middleware path. */\nexport type StorageConfig = Record<string, unknown>;\n\n/** @deprecated Detection events now flow through the engine; the legacy event shape no longer applies. */\nexport type AgentDetectionEvent = Record<string, unknown>;\n\n/** @deprecated Use `EdgeSessionTracker` / `StatelessSessionChecker` from `./session-tracker`. */\nexport type AgentSession = Record<string, unknown>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,iBAAiB;AACvB,MAAM,uBAAuB;;;;;;;;AAoB7B,SAAgB,8BACd,SACA,UACA,aACA,SACc;CAId,MAAM,WAAW,WAAW,eAAe,sBAAsB,QAAQ,GAAG;CAI5E,MAAM,YAAY,SAAS,aAAa,SAAS,aAAa;CAC9D,IAAI,CAAC,SAAS,aAAa,IAAI,OAAO,GACpC,SAAS,aAAa,IAAI,SAAS,UAAU,YAAY,CAAC;CAG5D,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,WAAW,aAAa,QAAQ,GAAG;CAEzC,MAAM,OAAO;EAIX,SACE,kBAAkB,SAAS,2HAEH,SAAS,IAAI,QAAQ;EAI/C,sBAAsB;GACpB,QAAQ,uBAAuB;GAC/B,KAAK;GACL,QAAQ,GAAG,SAAS;EACtB;EAEA,OAAO;GACL,SAAS;GACT,QAAQ;GACR,mBAAmB;GACnB,MAAM;IACJ,MAAM;IACN,OAAO;KACL;KACA;KACA;KACA;KACA;IACF;GACF;GACA,oBAAoB;IAClB,QAAQ;IACR,QAAQ;GACV;GACA,eAAe;EACjB;EAEA,OAAO;EACP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