@kya-os/checkpoint-nextjs 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +322 -0
- package/README.md +205 -31
- package/dist/adapt-BdQ9R7Iw.mjs +97 -0
- package/dist/adapt-BdQ9R7Iw.mjs.map +1 -0
- package/dist/adapt-CCSKGjVH.js +107 -0
- package/dist/api-client-JHOrRUA_.d.mts +222 -0
- package/dist/api-client-JHOrRUA_.d.mts.map +1 -0
- package/dist/api-client-JHOrRUA_.d.ts +222 -0
- package/dist/api-client-JHOrRUA_.d.ts.map +1 -0
- package/dist/api-client.d.mts +2 -213
- package/dist/api-client.d.ts +2 -213
- package/dist/api-client.js +221 -206
- package/dist/api-client.mjs +222 -202
- package/dist/api-client.mjs.map +1 -0
- package/dist/api-middleware-BWjokNis.d.mts +131 -0
- package/dist/api-middleware-BWjokNis.d.mts.map +1 -0
- package/dist/api-middleware-Bf3xmM9W.js +391 -0
- package/dist/api-middleware-C-ngFX_8.mjs +387 -0
- package/dist/api-middleware-C-ngFX_8.mjs.map +1 -0
- package/dist/api-middleware-DyLDqOYF.d.ts +131 -0
- package/dist/api-middleware-DyLDqOYF.d.ts.map +1 -0
- package/dist/api-middleware.d.mts +2 -166
- package/dist/api-middleware.d.ts +2 -166
- package/dist/api-middleware.js +3 -526
- package/dist/api-middleware.mjs +2 -521
- package/dist/cedar-wasm.d.mts +20 -0
- package/dist/cedar-wasm.d.mts.map +1 -0
- package/dist/cedar-wasm.d.ts +19 -0
- package/dist/cedar-wasm.d.ts.map +1 -0
- package/dist/cedar-wasm.js +24 -0
- package/dist/cedar-wasm.mjs +23 -0
- package/dist/cedar-wasm.mjs.map +1 -0
- package/dist/config-CPP1RV0f.d.mts +291 -0
- package/dist/config-CPP1RV0f.d.mts.map +1 -0
- package/dist/config-DVgOFxJs.d.ts +291 -0
- package/dist/config-DVgOFxJs.d.ts.map +1 -0
- package/dist/engine-wasm.d.mts +20 -0
- package/dist/engine-wasm.d.mts.map +1 -0
- package/dist/engine-wasm.d.ts +19 -0
- package/dist/engine-wasm.d.ts.map +1 -0
- package/dist/engine-wasm.js +24 -0
- package/dist/engine-wasm.mjs +23 -0
- package/dist/engine-wasm.mjs.map +1 -0
- package/dist/index-edge.d.mts +8 -0
- package/dist/index-edge.d.ts +8 -0
- package/dist/index-edge.js +14 -0
- package/dist/index-edge.mjs +7 -0
- package/dist/index.d.mts +8 -17
- package/dist/index.d.ts +8 -17
- package/dist/index.js +36 -1275
- package/dist/index.mjs +29 -1234
- package/dist/index.mjs.map +1 -0
- package/dist/middleware-bundler.d.mts +6 -12
- package/dist/middleware-bundler.d.mts.map +1 -0
- package/dist/middleware-bundler.d.ts +6 -12
- package/dist/middleware-bundler.d.ts.map +1 -0
- package/dist/middleware-bundler.js +12 -350
- package/dist/middleware-bundler.mjs +11 -347
- package/dist/middleware-bundler.mjs.map +1 -0
- package/dist/middleware-core-B0jf5_Hm.mjs +264 -0
- package/dist/middleware-core-B0jf5_Hm.mjs.map +1 -0
- package/dist/middleware-core-Bol44X9C.d.ts +17 -0
- package/dist/middleware-core-Bol44X9C.d.ts.map +1 -0
- package/dist/middleware-core-CMc-2QkU.js +274 -0
- package/dist/middleware-core-DycsbHUd.d.mts +17 -0
- package/dist/middleware-core-DycsbHUd.d.mts.map +1 -0
- package/dist/middleware-edge.d.mts +16 -14
- package/dist/middleware-edge.d.mts.map +1 -0
- package/dist/middleware-edge.d.ts +16 -14
- package/dist/middleware-edge.d.ts.map +1 -0
- package/dist/middleware-edge.js +94 -355
- package/dist/middleware-edge.mjs +90 -347
- package/dist/middleware-edge.mjs.map +1 -0
- package/dist/middleware-node-context-591KsiYg.js +39 -0
- package/dist/middleware-node-context-D_ZyUEcA.mjs +35 -0
- package/dist/middleware-node-context-D_ZyUEcA.mjs.map +1 -0
- package/dist/middleware-node.d.mts +10 -25
- package/dist/middleware-node.d.mts.map +1 -0
- package/dist/middleware-node.d.ts +10 -25
- package/dist/middleware-node.d.ts.map +1 -0
- package/dist/middleware-node.js +21 -351
- package/dist/middleware-node.mjs +19 -347
- package/dist/middleware-node.mjs.map +1 -0
- package/dist/posture-outcome-Ccujx_9V.d.mts +14 -0
- package/dist/posture-outcome-Ccujx_9V.d.mts.map +1 -0
- package/dist/posture-outcome-Ccujx_9V.d.ts +14 -0
- package/dist/posture-outcome-Ccujx_9V.d.ts.map +1 -0
- package/dist/posture-outcome-DQ4fdMfq.mjs +21 -0
- package/dist/posture-outcome-DQ4fdMfq.mjs.map +1 -0
- package/dist/posture-outcome-DddsJtL8.js +25 -0
- package/dist/public-api-CYsHrTQI.d.ts +5 -0
- package/dist/public-api-DkG7pRE0.d.mts +5 -0
- package/dist/rolldown-runtime-C24Yb2bl.js +33 -0
- package/dist/utils-Cnwg0VrY.mjs +88 -0
- package/dist/utils-Cnwg0VrY.mjs.map +1 -0
- package/dist/utils-dyFxqlFI.js +104 -0
- package/package.json +31 -66
- package/EDGE_RUNTIME_WASM_SETUP.md +0 -342
- package/bin/setup-edge-wasm.js +0 -513
- package/dist/adapt.d.mts +0 -39
- package/dist/adapt.d.ts +0 -39
- package/dist/adapt.js +0 -59
- package/dist/adapt.mjs +0 -57
- package/dist/composed-policy.d.mts +0 -115
- package/dist/composed-policy.d.ts +0 -115
- package/dist/composed-policy.js +0 -103
- package/dist/composed-policy.mjs +0 -97
- package/dist/config-CleTeeoW.d.mts +0 -233
- package/dist/config-XMOIkxFN.d.ts +0 -233
- package/dist/create-middleware.d.mts +0 -22
- package/dist/create-middleware.d.ts +0 -22
- package/dist/create-middleware.js +0 -34
- package/dist/create-middleware.mjs +0 -31
- package/dist/edge/index.d.mts +0 -112
- package/dist/edge/index.d.ts +0 -112
- package/dist/edge/index.js +0 -277
- package/dist/edge/index.mjs +0 -275
- package/dist/edge-runtime-loader.d.mts +0 -77
- package/dist/edge-runtime-loader.d.ts +0 -77
- package/dist/edge-runtime-loader.js +0 -242
- package/dist/edge-runtime-loader.mjs +0 -235
- package/dist/edge-wasm-middleware.d.mts +0 -62
- package/dist/edge-wasm-middleware.d.ts +0 -62
- package/dist/edge-wasm-middleware.js +0 -26
- package/dist/edge-wasm-middleware.mjs +0 -22
- package/dist/middleware.d.mts +0 -45
- package/dist/middleware.d.ts +0 -45
- package/dist/middleware.js +0 -19
- package/dist/middleware.mjs +0 -15
- package/dist/nodejs-wasm-loader.d.mts +0 -41
- package/dist/nodejs-wasm-loader.d.ts +0 -41
- package/dist/nodejs-wasm-loader.js +0 -36
- package/dist/nodejs-wasm-loader.mjs +0 -30
- package/dist/policy.d.mts +0 -162
- package/dist/policy.d.ts +0 -162
- package/dist/policy.js +0 -198
- package/dist/policy.mjs +0 -174
- package/dist/session-tracker.d.mts +0 -55
- package/dist/session-tracker.d.ts +0 -55
- package/dist/session-tracker.js +0 -172
- package/dist/session-tracker.mjs +0 -169
- package/dist/translate.d.mts +0 -63
- package/dist/translate.d.ts +0 -63
- package/dist/translate.js +0 -44
- package/dist/translate.mjs +0 -42
- package/dist/types-Chgi5TFC.d.mts +0 -105
- package/dist/types-Chgi5TFC.d.ts +0 -105
- package/dist/wasm-setup.d.mts +0 -46
- package/dist/wasm-setup.d.ts +0 -46
- package/dist/wasm-setup.js +0 -122
- package/dist/wasm-setup.mjs +0 -118
- package/wasm/agentshield_wasm.d.ts +0 -479
- package/wasm/agentshield_wasm.js +0 -1536
- package/wasm/agentshield_wasm_bg.wasm +0 -0
- package/wasm/package.json +0 -30
- package/wasm.d.ts +0 -21
|
@@ -1,166 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { EnforcementDecision } from './api-client.mjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* API-based AgentShield Middleware for Next.js
|
|
7
|
-
*
|
|
8
|
-
* This middleware uses the AgentShield API for detection and enforcement,
|
|
9
|
-
* instead of running detection locally. This approach:
|
|
10
|
-
*
|
|
11
|
-
* 1. Works reliably in Edge Runtime (no WASM loading issues)
|
|
12
|
-
* 2. Ensures consistent detection across all platforms
|
|
13
|
-
* 3. Applies centralized policies from the dashboard
|
|
14
|
-
* 4. Supports deny lists, thresholds, and path rules
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // middleware.ts
|
|
19
|
-
* import { withCheckpointApi } from '@kya-os/checkpoint-nextjs/api-middleware';
|
|
20
|
-
*
|
|
21
|
-
* export default withCheckpointApi({
|
|
22
|
-
* apiKey: process.env.CHECKPOINT_API_KEY!,
|
|
23
|
-
* // Optional overrides:
|
|
24
|
-
* onBlock: 'redirect', // 'block' | 'redirect' | 'challenge'
|
|
25
|
-
* redirectUrl: '/blocked',
|
|
26
|
-
* skipPaths: ['/api/health', '/_next/*'],
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* export const config = {
|
|
30
|
-
* matcher: ['/((?!_next/static|favicon.ico).*)'],
|
|
31
|
-
* };
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Middleware configuration
|
|
37
|
-
*/
|
|
38
|
-
interface CheckpointApiMiddlewareConfig {
|
|
39
|
-
/** Explicit deployment/proxy trust profile for client-IP resolution. */
|
|
40
|
-
clientIpPolicy?: ClientIpTrustPolicy;
|
|
41
|
-
/** API key (or use CHECKPOINT_API_KEY env var) */
|
|
42
|
-
apiKey?: string;
|
|
43
|
-
/** API base URL (defaults to production) */
|
|
44
|
-
apiUrl?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Use edge detection for lower latency (~30-50ms vs ~150ms) and better coverage.
|
|
47
|
-
* Edge detection can identify non-JS clients (curl, Python, Claude Code WebFetch)
|
|
48
|
-
* that the pixel cannot detect since they don't execute JavaScript.
|
|
49
|
-
* Set to false to use the Vercel API instead.
|
|
50
|
-
* @default true
|
|
51
|
-
*/
|
|
52
|
-
useEdge?: boolean;
|
|
53
|
-
/** Request timeout in ms (default: 5000) */
|
|
54
|
-
timeout?: number;
|
|
55
|
-
/**
|
|
56
|
-
* Action to take when an agent should be blocked
|
|
57
|
-
* - 'block': Return 403 response
|
|
58
|
-
* - 'redirect': Redirect to redirectUrl
|
|
59
|
-
* - 'challenge': Show a challenge page (future)
|
|
60
|
-
* Default: uses policy from dashboard
|
|
61
|
-
*/
|
|
62
|
-
onBlock?: 'block' | 'redirect' | 'challenge';
|
|
63
|
-
/**
|
|
64
|
-
* URL to redirect to when blocking (if onBlock is 'redirect')
|
|
65
|
-
* Default: uses redirectUrl from dashboard policy
|
|
66
|
-
*/
|
|
67
|
-
redirectUrl?: string;
|
|
68
|
-
/**
|
|
69
|
-
* How the middleware handles a `redirect` / `instruct` action.
|
|
70
|
-
*
|
|
71
|
-
* - `'instruct'` (default): return HTTP 401 with a KYA-OS Link header + JSON
|
|
72
|
-
* body pointing the agent at the redirect URL. LLMs surface the URL as a
|
|
73
|
-
* clickable link for the user. Matches the Cloudflare Gateway contract.
|
|
74
|
-
* - `'http'`: legacy behavior — return HTTP 302 with `Location`. Most LLM
|
|
75
|
-
* fetchers won't follow the redirect, so this is only useful when your
|
|
76
|
-
* traffic is real browsers.
|
|
77
|
-
*
|
|
78
|
-
* @default 'instruct'
|
|
79
|
-
*/
|
|
80
|
-
redirectMode?: 'instruct' | 'http';
|
|
81
|
-
/**
|
|
82
|
-
* Challenge-emission envelope mode (draft-kya-http-02 §8.1 fetcher-200).
|
|
83
|
-
* `negotiated` serves a body-readable HTTP 200 instruct response to
|
|
84
|
-
* cooperative agents (so fetchers that drop 4xx bodies can read it),
|
|
85
|
-
* keeping the spec 401 for everyone else. Defaults to `negotiated` (#3530).
|
|
86
|
-
* A cooperative-UX bridge, NOT an access control.
|
|
87
|
-
*/
|
|
88
|
-
delegationChallengeMode?: ChallengeEnvelopeMode;
|
|
89
|
-
/**
|
|
90
|
-
* Custom blocked response
|
|
91
|
-
*/
|
|
92
|
-
blockedResponse?: {
|
|
93
|
-
status?: number;
|
|
94
|
-
message?: string;
|
|
95
|
-
headers?: Record<string, string>;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Paths to skip (in addition to dashboard policy)
|
|
99
|
-
* Supports glob patterns: '/api/*', '/_next/*'
|
|
100
|
-
*/
|
|
101
|
-
skipPaths?: string[];
|
|
102
|
-
/**
|
|
103
|
-
* Only enforce on these paths (overrides dashboard policy)
|
|
104
|
-
*/
|
|
105
|
-
includePaths?: string[];
|
|
106
|
-
/**
|
|
107
|
-
* Callback when an agent is detected
|
|
108
|
-
*/
|
|
109
|
-
onAgentDetected?: (request: NextRequest, decision: EnforcementDecision) => void | Promise<void>;
|
|
110
|
-
/**
|
|
111
|
-
* Callback to customize the blocked response
|
|
112
|
-
*/
|
|
113
|
-
customBlockedResponse?: (request: NextRequest, decision: EnforcementDecision) => NextResponse | Promise<NextResponse>;
|
|
114
|
-
/**
|
|
115
|
-
* Whether to fail open (allow) on API errors
|
|
116
|
-
* Default: true (recommended for production)
|
|
117
|
-
*/
|
|
118
|
-
failOpen?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Enable debug logging
|
|
121
|
-
*/
|
|
122
|
-
debug?: boolean;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Create AgentShield middleware with API-based detection
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```typescript
|
|
129
|
-
* // middleware.ts
|
|
130
|
-
* import { withCheckpointApi } from '@kya-os/checkpoint-nextjs/api-middleware';
|
|
131
|
-
*
|
|
132
|
-
* export default withCheckpointApi({
|
|
133
|
-
* onBlock: 'block',
|
|
134
|
-
* skipPaths: ['/api/health'],
|
|
135
|
-
* });
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
declare function withCheckpointApi(config?: CheckpointApiMiddlewareConfig): (request: NextRequest) => Promise<NextResponse>;
|
|
139
|
-
/** @deprecated Renamed to {@link withCheckpointApi}. The behaviour is identical. */
|
|
140
|
-
declare const withAgentShield: typeof withCheckpointApi;
|
|
141
|
-
/** @deprecated Renamed to {@link CheckpointApiMiddlewareConfig}. */
|
|
142
|
-
type AgentShieldMiddlewareConfig = CheckpointApiMiddlewareConfig;
|
|
143
|
-
/**
|
|
144
|
-
* @deprecated Module-load-time invocation of the legacy `withAgentShield()`.
|
|
145
|
-
* Construct the middleware explicitly via `withCheckpointApi({ apiKey })`
|
|
146
|
-
* instead of relying on a default-constructed singleton at import time.
|
|
147
|
-
*/
|
|
148
|
-
declare function agentShieldMiddleware(_request: NextRequest): Promise<NextResponse>;
|
|
149
|
-
/**
|
|
150
|
-
* @deprecated The "enhanced middleware" combined detection + storage +
|
|
151
|
-
* enforcement into a single legacy path that no longer exists. Migrate
|
|
152
|
-
* to `withCheckpoint` (local-engine) or `withCheckpointApi` (SaaS-gateway).
|
|
153
|
-
*/
|
|
154
|
-
declare function createEnhancedAgentShieldMiddleware(_config?: EnhancedMiddlewareConfig): (request: NextRequest) => Promise<NextResponse>;
|
|
155
|
-
/** @deprecated The enhanced-middleware path is gone. Use `CheckpointConfig` (local-engine) or `CheckpointApiMiddlewareConfig` (SaaS). */
|
|
156
|
-
type EnhancedMiddlewareConfig = Record<string, unknown>;
|
|
157
|
-
/** @deprecated Storage was tied to the legacy enhanced-middleware path. */
|
|
158
|
-
type StorageAdapter = Record<string, unknown>;
|
|
159
|
-
/** @deprecated Storage was tied to the legacy enhanced-middleware path. */
|
|
160
|
-
type StorageConfig = Record<string, unknown>;
|
|
161
|
-
/** @deprecated Detection events now flow through the engine; the legacy event shape no longer applies. */
|
|
162
|
-
type AgentDetectionEvent = Record<string, unknown>;
|
|
163
|
-
/** @deprecated Use `EdgeSessionTracker` / `StatelessSessionChecker` from `./session-tracker`. */
|
|
164
|
-
type AgentSession = Record<string, unknown>;
|
|
165
|
-
|
|
166
|
-
export { type AgentDetectionEvent, type AgentSession, type AgentShieldMiddlewareConfig, type CheckpointApiMiddlewareConfig, type EnhancedMiddlewareConfig, type StorageAdapter, type StorageConfig, agentShieldMiddleware, createEnhancedAgentShieldMiddleware, withAgentShield, withCheckpointApi };
|
|
1
|
+
import { n as withCheckpointApi, t as CheckpointApiMiddlewareConfig } from "./api-middleware-BWjokNis.mjs";
|
|
2
|
+
export { CheckpointApiMiddlewareConfig, withCheckpointApi };
|
package/dist/api-middleware.d.ts
CHANGED
|
@@ -1,166 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { EnforcementDecision } from './api-client.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* API-based AgentShield Middleware for Next.js
|
|
7
|
-
*
|
|
8
|
-
* This middleware uses the AgentShield API for detection and enforcement,
|
|
9
|
-
* instead of running detection locally. This approach:
|
|
10
|
-
*
|
|
11
|
-
* 1. Works reliably in Edge Runtime (no WASM loading issues)
|
|
12
|
-
* 2. Ensures consistent detection across all platforms
|
|
13
|
-
* 3. Applies centralized policies from the dashboard
|
|
14
|
-
* 4. Supports deny lists, thresholds, and path rules
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // middleware.ts
|
|
19
|
-
* import { withCheckpointApi } from '@kya-os/checkpoint-nextjs/api-middleware';
|
|
20
|
-
*
|
|
21
|
-
* export default withCheckpointApi({
|
|
22
|
-
* apiKey: process.env.CHECKPOINT_API_KEY!,
|
|
23
|
-
* // Optional overrides:
|
|
24
|
-
* onBlock: 'redirect', // 'block' | 'redirect' | 'challenge'
|
|
25
|
-
* redirectUrl: '/blocked',
|
|
26
|
-
* skipPaths: ['/api/health', '/_next/*'],
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* export const config = {
|
|
30
|
-
* matcher: ['/((?!_next/static|favicon.ico).*)'],
|
|
31
|
-
* };
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Middleware configuration
|
|
37
|
-
*/
|
|
38
|
-
interface CheckpointApiMiddlewareConfig {
|
|
39
|
-
/** Explicit deployment/proxy trust profile for client-IP resolution. */
|
|
40
|
-
clientIpPolicy?: ClientIpTrustPolicy;
|
|
41
|
-
/** API key (or use CHECKPOINT_API_KEY env var) */
|
|
42
|
-
apiKey?: string;
|
|
43
|
-
/** API base URL (defaults to production) */
|
|
44
|
-
apiUrl?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Use edge detection for lower latency (~30-50ms vs ~150ms) and better coverage.
|
|
47
|
-
* Edge detection can identify non-JS clients (curl, Python, Claude Code WebFetch)
|
|
48
|
-
* that the pixel cannot detect since they don't execute JavaScript.
|
|
49
|
-
* Set to false to use the Vercel API instead.
|
|
50
|
-
* @default true
|
|
51
|
-
*/
|
|
52
|
-
useEdge?: boolean;
|
|
53
|
-
/** Request timeout in ms (default: 5000) */
|
|
54
|
-
timeout?: number;
|
|
55
|
-
/**
|
|
56
|
-
* Action to take when an agent should be blocked
|
|
57
|
-
* - 'block': Return 403 response
|
|
58
|
-
* - 'redirect': Redirect to redirectUrl
|
|
59
|
-
* - 'challenge': Show a challenge page (future)
|
|
60
|
-
* Default: uses policy from dashboard
|
|
61
|
-
*/
|
|
62
|
-
onBlock?: 'block' | 'redirect' | 'challenge';
|
|
63
|
-
/**
|
|
64
|
-
* URL to redirect to when blocking (if onBlock is 'redirect')
|
|
65
|
-
* Default: uses redirectUrl from dashboard policy
|
|
66
|
-
*/
|
|
67
|
-
redirectUrl?: string;
|
|
68
|
-
/**
|
|
69
|
-
* How the middleware handles a `redirect` / `instruct` action.
|
|
70
|
-
*
|
|
71
|
-
* - `'instruct'` (default): return HTTP 401 with a KYA-OS Link header + JSON
|
|
72
|
-
* body pointing the agent at the redirect URL. LLMs surface the URL as a
|
|
73
|
-
* clickable link for the user. Matches the Cloudflare Gateway contract.
|
|
74
|
-
* - `'http'`: legacy behavior — return HTTP 302 with `Location`. Most LLM
|
|
75
|
-
* fetchers won't follow the redirect, so this is only useful when your
|
|
76
|
-
* traffic is real browsers.
|
|
77
|
-
*
|
|
78
|
-
* @default 'instruct'
|
|
79
|
-
*/
|
|
80
|
-
redirectMode?: 'instruct' | 'http';
|
|
81
|
-
/**
|
|
82
|
-
* Challenge-emission envelope mode (draft-kya-http-02 §8.1 fetcher-200).
|
|
83
|
-
* `negotiated` serves a body-readable HTTP 200 instruct response to
|
|
84
|
-
* cooperative agents (so fetchers that drop 4xx bodies can read it),
|
|
85
|
-
* keeping the spec 401 for everyone else. Defaults to `negotiated` (#3530).
|
|
86
|
-
* A cooperative-UX bridge, NOT an access control.
|
|
87
|
-
*/
|
|
88
|
-
delegationChallengeMode?: ChallengeEnvelopeMode;
|
|
89
|
-
/**
|
|
90
|
-
* Custom blocked response
|
|
91
|
-
*/
|
|
92
|
-
blockedResponse?: {
|
|
93
|
-
status?: number;
|
|
94
|
-
message?: string;
|
|
95
|
-
headers?: Record<string, string>;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Paths to skip (in addition to dashboard policy)
|
|
99
|
-
* Supports glob patterns: '/api/*', '/_next/*'
|
|
100
|
-
*/
|
|
101
|
-
skipPaths?: string[];
|
|
102
|
-
/**
|
|
103
|
-
* Only enforce on these paths (overrides dashboard policy)
|
|
104
|
-
*/
|
|
105
|
-
includePaths?: string[];
|
|
106
|
-
/**
|
|
107
|
-
* Callback when an agent is detected
|
|
108
|
-
*/
|
|
109
|
-
onAgentDetected?: (request: NextRequest, decision: EnforcementDecision) => void | Promise<void>;
|
|
110
|
-
/**
|
|
111
|
-
* Callback to customize the blocked response
|
|
112
|
-
*/
|
|
113
|
-
customBlockedResponse?: (request: NextRequest, decision: EnforcementDecision) => NextResponse | Promise<NextResponse>;
|
|
114
|
-
/**
|
|
115
|
-
* Whether to fail open (allow) on API errors
|
|
116
|
-
* Default: true (recommended for production)
|
|
117
|
-
*/
|
|
118
|
-
failOpen?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Enable debug logging
|
|
121
|
-
*/
|
|
122
|
-
debug?: boolean;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Create AgentShield middleware with API-based detection
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```typescript
|
|
129
|
-
* // middleware.ts
|
|
130
|
-
* import { withCheckpointApi } from '@kya-os/checkpoint-nextjs/api-middleware';
|
|
131
|
-
*
|
|
132
|
-
* export default withCheckpointApi({
|
|
133
|
-
* onBlock: 'block',
|
|
134
|
-
* skipPaths: ['/api/health'],
|
|
135
|
-
* });
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
declare function withCheckpointApi(config?: CheckpointApiMiddlewareConfig): (request: NextRequest) => Promise<NextResponse>;
|
|
139
|
-
/** @deprecated Renamed to {@link withCheckpointApi}. The behaviour is identical. */
|
|
140
|
-
declare const withAgentShield: typeof withCheckpointApi;
|
|
141
|
-
/** @deprecated Renamed to {@link CheckpointApiMiddlewareConfig}. */
|
|
142
|
-
type AgentShieldMiddlewareConfig = CheckpointApiMiddlewareConfig;
|
|
143
|
-
/**
|
|
144
|
-
* @deprecated Module-load-time invocation of the legacy `withAgentShield()`.
|
|
145
|
-
* Construct the middleware explicitly via `withCheckpointApi({ apiKey })`
|
|
146
|
-
* instead of relying on a default-constructed singleton at import time.
|
|
147
|
-
*/
|
|
148
|
-
declare function agentShieldMiddleware(_request: NextRequest): Promise<NextResponse>;
|
|
149
|
-
/**
|
|
150
|
-
* @deprecated The "enhanced middleware" combined detection + storage +
|
|
151
|
-
* enforcement into a single legacy path that no longer exists. Migrate
|
|
152
|
-
* to `withCheckpoint` (local-engine) or `withCheckpointApi` (SaaS-gateway).
|
|
153
|
-
*/
|
|
154
|
-
declare function createEnhancedAgentShieldMiddleware(_config?: EnhancedMiddlewareConfig): (request: NextRequest) => Promise<NextResponse>;
|
|
155
|
-
/** @deprecated The enhanced-middleware path is gone. Use `CheckpointConfig` (local-engine) or `CheckpointApiMiddlewareConfig` (SaaS). */
|
|
156
|
-
type EnhancedMiddlewareConfig = Record<string, unknown>;
|
|
157
|
-
/** @deprecated Storage was tied to the legacy enhanced-middleware path. */
|
|
158
|
-
type StorageAdapter = Record<string, unknown>;
|
|
159
|
-
/** @deprecated Storage was tied to the legacy enhanced-middleware path. */
|
|
160
|
-
type StorageConfig = Record<string, unknown>;
|
|
161
|
-
/** @deprecated Detection events now flow through the engine; the legacy event shape no longer applies. */
|
|
162
|
-
type AgentDetectionEvent = Record<string, unknown>;
|
|
163
|
-
/** @deprecated Use `EdgeSessionTracker` / `StatelessSessionChecker` from `./session-tracker`. */
|
|
164
|
-
type AgentSession = Record<string, unknown>;
|
|
165
|
-
|
|
166
|
-
export { type AgentDetectionEvent, type AgentSession, type AgentShieldMiddlewareConfig, type CheckpointApiMiddlewareConfig, type EnhancedMiddlewareConfig, type StorageAdapter, type StorageConfig, agentShieldMiddleware, createEnhancedAgentShieldMiddleware, withAgentShield, withCheckpointApi };
|
|
1
|
+
import { n as withCheckpointApi, t as CheckpointApiMiddlewareConfig } from "./api-middleware-DyLDqOYF.js";
|
|
2
|
+
export { CheckpointApiMiddlewareConfig, withCheckpointApi };
|