@kya-os/checkpoint-nextjs 1.11.0 → 1.12.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 +16 -0
- package/README.md +16 -8
- package/dist/{adapt-BdQ9R7Iw.mjs → adapt-BvqYgrAk.mjs} +2 -2
- package/dist/{adapt-BdQ9R7Iw.mjs.map → adapt-BvqYgrAk.mjs.map} +1 -1
- package/dist/{adapt-CCSKGjVH.js → adapt-DUEIfZnx.js} +1 -1
- package/dist/{api-middleware-BWjokNis.d.mts → api-middleware-BtsYJU5u.d.mts} +2 -2
- package/dist/{api-middleware-BWjokNis.d.mts.map → api-middleware-BtsYJU5u.d.mts.map} +1 -1
- package/dist/{api-middleware-C-ngFX_8.mjs → api-middleware-DvmkJ_Li.mjs} +4 -4
- package/dist/{api-middleware-C-ngFX_8.mjs.map → api-middleware-DvmkJ_Li.mjs.map} +1 -1
- package/dist/{api-middleware-Bf3xmM9W.js → api-middleware-beNlXd5P.js} +3 -3
- package/dist/api-middleware.d.mts +1 -1
- package/dist/api-middleware.js +1 -1
- package/dist/api-middleware.mjs +1 -1
- package/dist/cedar-wasm.d.mts +1 -1
- package/dist/cedar-wasm.d.ts +1 -1
- package/dist/cedar-wasm.js +1 -1
- package/dist/cedar-wasm.mjs +1 -1
- package/dist/cedar-wasm.mjs.map +1 -1
- package/dist/config-D7h2w_it.d.mts +89 -0
- package/dist/config-D7h2w_it.d.mts.map +1 -0
- package/dist/config-DkXvl4nH.d.ts +89 -0
- package/dist/config-DkXvl4nH.d.ts.map +1 -0
- package/dist/engine-wasm.d.mts +1 -1
- package/dist/engine-wasm.d.ts +1 -1
- package/dist/engine-wasm.js +1 -1
- package/dist/engine-wasm.mjs +1 -1
- package/dist/engine-wasm.mjs.map +1 -1
- package/dist/index-edge.d.mts +4 -4
- package/dist/index-edge.d.ts +3 -3
- package/dist/index-edge.js +2 -2
- package/dist/index-edge.mjs +2 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/middleware-bundler.d.mts +1 -1
- package/dist/middleware-bundler.d.ts +1 -1
- package/dist/middleware-bundler.js +3 -3
- package/dist/middleware-bundler.mjs +3 -3
- package/dist/middleware-bundler.mjs.map +1 -1
- package/dist/middleware-core-B1GuspOY.js +169 -0
- package/dist/{middleware-core-Bol44X9C.d.ts → middleware-core-BmW2kH8J.d.ts} +4 -7
- package/dist/middleware-core-BmW2kH8J.d.ts.map +1 -0
- package/dist/{middleware-core-DycsbHUd.d.mts → middleware-core-CnPUoD2v.d.mts} +4 -7
- package/dist/middleware-core-CnPUoD2v.d.mts.map +1 -0
- package/dist/middleware-core-WZeMSRqx.mjs +159 -0
- package/dist/middleware-core-WZeMSRqx.mjs.map +1 -0
- package/dist/middleware-edge.d.mts +1 -1
- package/dist/middleware-edge.d.mts.map +1 -1
- package/dist/middleware-edge.d.ts +1 -1
- package/dist/middleware-edge.d.ts.map +1 -1
- package/dist/middleware-edge.js +21 -35
- package/dist/middleware-edge.mjs +21 -35
- package/dist/middleware-edge.mjs.map +1 -1
- package/dist/middleware-node-context-BvqrL2Ra.mjs +16 -0
- package/dist/middleware-node-context-BvqrL2Ra.mjs.map +1 -0
- package/dist/middleware-node-context-TRMTgp3y.js +20 -0
- package/dist/middleware-node.d.mts +2 -2
- package/dist/middleware-node.d.ts +2 -2
- package/dist/middleware-node.js +3 -3
- package/dist/middleware-node.mjs +3 -3
- package/dist/middleware-node.mjs.map +1 -1
- package/dist/{public-api-CYsHrTQI.d.ts → public-api-Cw7Zj290.d.ts} +2 -2
- package/dist/public-api-DgCw1uo6.d.mts +5 -0
- package/package.json +3 -3
- package/dist/config-CPP1RV0f.d.mts +0 -291
- package/dist/config-CPP1RV0f.d.mts.map +0 -1
- package/dist/config-DVgOFxJs.d.ts +0 -291
- package/dist/config-DVgOFxJs.d.ts.map +0 -1
- package/dist/middleware-core-B0jf5_Hm.mjs +0 -264
- package/dist/middleware-core-B0jf5_Hm.mjs.map +0 -1
- package/dist/middleware-core-Bol44X9C.d.ts.map +0 -1
- package/dist/middleware-core-CMc-2QkU.js +0 -274
- package/dist/middleware-core-DycsbHUd.d.mts.map +0 -1
- package/dist/middleware-node-context-591KsiYg.js +0 -39
- package/dist/middleware-node-context-D_ZyUEcA.mjs +0 -35
- package/dist/middleware-node-context-D_ZyUEcA.mjs.map +0 -1
- package/dist/public-api-DkG7pRE0.d.mts +0 -5
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ClientIpTrustPolicy } from "@kya-os/checkpoint-shared";
|
|
2
|
+
import { NextRequest } from "next/server.js";
|
|
3
|
+
import { CheckpointHostConfig } from "@kya-os/checkpoint-wasm-runtime/pipeline";
|
|
4
|
+
//#region src/config.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for `withCheckpoint`. Every field is optional; on the Edge
|
|
7
|
+
* runtime `withCheckpoint` also needs a compiled engine module
|
|
8
|
+
* (`CheckpointEdgeConfig`).
|
|
9
|
+
*/
|
|
10
|
+
interface CheckpointConfig extends CheckpointHostConfig<NextRequest> {
|
|
11
|
+
/**
|
|
12
|
+
* Selects the infrastructure allowed to vouch for observed client addresses.
|
|
13
|
+
* Vercel headers are honored only inside its managed runtime (`VERCEL=1`).
|
|
14
|
+
* NextRequest exposes no socket peer, so generic proxy and Cloudflare origin
|
|
15
|
+
* profiles cannot authenticate that boundary and return no address. Use a
|
|
16
|
+
* transport-aware ingress, such as the Express adapter, for those profiles.
|
|
17
|
+
*/
|
|
18
|
+
clientIpPolicy?: ClientIpTrustPolicy;
|
|
19
|
+
/**
|
|
20
|
+
* Read the request body when `content-type` is `application/json` so
|
|
21
|
+
* the orchestrator can extract a KYA-OS envelope from
|
|
22
|
+
* `_meta.proof.jws`. Default `true`.
|
|
23
|
+
*
|
|
24
|
+
* **When to disable** — streaming middlewares that can't tolerate
|
|
25
|
+
* the `req.clone()` memory overhead (one full-body copy is buffered
|
|
26
|
+
* during the read). For those, set `false` and route KYA-OS
|
|
27
|
+
* envelopes through the `KYA-Delegation` header transport instead
|
|
28
|
+
* (requires `legacyEnvelopeFallback: true`).
|
|
29
|
+
*
|
|
30
|
+
* The clone preserves `req.body` for downstream handlers — disabling
|
|
31
|
+
* is a performance optimization, not a correctness fix.
|
|
32
|
+
*
|
|
33
|
+
* SDK-Envelope-Plumbing-1 (#2594). Added in `@kya-os/checkpoint-nextjs@1.1.0`.
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
drainJsonBody?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* EDGE runtime only. The Cedar build's `WebAssembly.Module`. Prefer passing
|
|
40
|
+
* it as `engineWasmModule` (see there); this field is kept so existing
|
|
41
|
+
* configs work. Passed alone it serves both roles, detection and policy, on
|
|
42
|
+
* one instance. Passed next to the engine-only build it runs as a second
|
|
43
|
+
* instance, and the Edge bundle carries the engine twice (`debug` logs a
|
|
44
|
+
* hint).
|
|
45
|
+
*
|
|
46
|
+
* Without a Cedar module the project's policy is still fetched and never
|
|
47
|
+
* skipped: with no Cedar policy nothing changes, a policy in shadow mode
|
|
48
|
+
* keeps the structured decision, and an enforcing policy answers every
|
|
49
|
+
* request 503 and logs which module is missing. The Node runtime ignores
|
|
50
|
+
* this field (it loads Cedar through `createPolicyEvaluator`).
|
|
51
|
+
*
|
|
52
|
+
* Added in `@kya-os/checkpoint-nextjs@1.5.0` (@Policy middleware-Cedar, #3076).
|
|
53
|
+
*/
|
|
54
|
+
cedarWasmModule?: WebAssembly.Module;
|
|
55
|
+
/**
|
|
56
|
+
* EDGE runtime only, and required there unless `cedarWasmModule` is set.
|
|
57
|
+
* The module the engine runs on, statically imported by the host:
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* // Detection only:
|
|
61
|
+
* import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';
|
|
62
|
+
* // Detection and the project's Cedar policy, on one module:
|
|
63
|
+
* import engineWasmModule from '@kya-os/checkpoint-nextjs/cedar-wasm';
|
|
64
|
+
*
|
|
65
|
+
* export default withCheckpoint({ projectId, engineWasmModule });
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* The Cedar build is the engine plus Cedar, so it replaces the engine-only
|
|
69
|
+
* build rather than adding to it; it is larger, which is why it is opt-in.
|
|
70
|
+
* A project whose Cedar policy is enforcing needs it on the Edge runtime.
|
|
71
|
+
*
|
|
72
|
+
* The Edge runtime does not let code compile WebAssembly from bytes, so the
|
|
73
|
+
* engine cannot fetch and compile its own binary there; the bundler has to
|
|
74
|
+
* hand it over as a compiled module. The Node runtime ignores this field.
|
|
75
|
+
*/
|
|
76
|
+
engineWasmModule?: WebAssembly.Module;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* `withCheckpoint` configuration for the Edge runtime (`./edge`): the engine
|
|
80
|
+
* needs a module, `engineWasmModule` or, on its own, `cedarWasmModule`.
|
|
81
|
+
*/
|
|
82
|
+
type CheckpointEdgeConfig = CheckpointConfig & ({
|
|
83
|
+
engineWasmModule: WebAssembly.Module;
|
|
84
|
+
} | {
|
|
85
|
+
cedarWasmModule: WebAssembly.Module;
|
|
86
|
+
});
|
|
87
|
+
//#endregion
|
|
88
|
+
export { CheckpointEdgeConfig as n, CheckpointConfig as t };
|
|
89
|
+
//# sourceMappingURL=config-DkXvl4nH.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-DkXvl4nH.d.ts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;;;;UAkBiB,yBAAyB,qBAAqB;;;;;;;;EAQ7D,iBAAiB;;;;;;;;;;;;;;;;;;;EAoBjB;;;;;;;;;;;;;;;;;EAkBA,kBAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;EAuB9B,mBAAmB,YAAY;;;;;;KAOrB,uBAAuB;EAC9B,kBAAkB,YAAY;;EAAa,iBAAiB,YAAY"}
|
package/dist/engine-wasm.d.mts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
7
|
* import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';
|
|
8
|
-
* export default withCheckpoint({
|
|
8
|
+
* export default withCheckpoint({ engineWasmModule });
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
11
|
* `?module` is how Next.js imports a `.wasm` file as a compiled module, which
|
package/dist/engine-wasm.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
7
7
|
* import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';
|
|
8
|
-
* export default withCheckpoint({
|
|
8
|
+
* export default withCheckpoint({ engineWasmModule });
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
11
|
* `?module` is how Next.js imports a `.wasm` file as a compiled module, which
|
package/dist/engine-wasm.js
CHANGED
|
@@ -9,7 +9,7 @@ _kya_os_checkpoint_wasm_runtime_wasm_kya_os_engine_web_kya_os_engine_bg_wasm_mod
|
|
|
9
9
|
*
|
|
10
10
|
* ```ts
|
|
11
11
|
* import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';
|
|
12
|
-
* export default withCheckpoint({
|
|
12
|
+
* export default withCheckpoint({ engineWasmModule });
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
15
|
* `?module` is how Next.js imports a `.wasm` file as a compiled module, which
|
package/dist/engine-wasm.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import compiled from "@kya-os/checkpoint-wasm-runtime/wasm/kya-os-engine-web/kya
|
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
9
|
* import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';
|
|
10
|
-
* export default withCheckpoint({
|
|
10
|
+
* export default withCheckpoint({ engineWasmModule });
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* `?module` is how Next.js imports a `.wasm` file as a compiled module, which
|
package/dist/engine-wasm.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-wasm.mjs","names":[],"sources":["../src/engine-wasm.ts"],"sourcesContent":["/**\n * The engine's compiled `WebAssembly.Module`, for `withCheckpoint`'s\n * `engineWasmModule` on the Edge runtime:\n *\n * ```ts\n * import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';\n * export default withCheckpoint({
|
|
1
|
+
{"version":3,"file":"engine-wasm.mjs","names":[],"sources":["../src/engine-wasm.ts"],"sourcesContent":["/**\n * The engine's compiled `WebAssembly.Module`, for `withCheckpoint`'s\n * `engineWasmModule` on the Edge runtime:\n *\n * ```ts\n * import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';\n * export default withCheckpoint({ engineWasmModule });\n * ```\n *\n * `?module` is how Next.js imports a `.wasm` file as a compiled module, which\n * the Edge runtime needs because it does not let code compile WebAssembly from\n * bytes. Importing it through this package keeps the binary the same version\n * as the engine glue this package loads, and works without a direct\n * dependency on `@kya-os/checkpoint-wasm-runtime`.\n */\n\nimport compiled from '@kya-os/checkpoint-wasm-runtime/wasm/kya-os-engine-web/kya_os_engine_bg.wasm?module';\n\n// Typed here so the published declaration names no `?module` specifier.\nconst engineWasmModule: WebAssembly.Module = compiled;\nexport default engineWasmModule;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,mBAAuC"}
|
package/dist/index-edge.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as EnforceResponse, c as LogDetectionInput, i as EnforceInput, l as getCheckpointApiClient, n as CheckpointApiClient, o as EnforcementAction, r as CheckpointApiClientConfig, s as EnforcementDecision, u as resetCheckpointApiClient } from "./api-client-JHOrRUA_.mjs";
|
|
2
|
-
import { n as withCheckpointApi, t as CheckpointApiMiddlewareConfig } from "./api-middleware-
|
|
3
|
-
import { t as CheckpointConfig } from "./config-
|
|
2
|
+
import { n as withCheckpointApi, t as CheckpointApiMiddlewareConfig } from "./api-middleware-BtsYJU5u.mjs";
|
|
3
|
+
import { t as CheckpointConfig } from "./config-D7h2w_it.mjs";
|
|
4
4
|
import { n as CheckpointPostureOutcome, r as getCheckpointPostureOutcome, t as CheckpointPostureOptions } from "./posture-outcome-Ccujx_9V.mjs";
|
|
5
5
|
import { withCheckpoint } from "./middleware-edge.mjs";
|
|
6
|
-
import { t as VERSION } from "./middleware-core-
|
|
7
|
-
import "./public-api-
|
|
6
|
+
import { t as VERSION } from "./middleware-core-CnPUoD2v.mjs";
|
|
7
|
+
import "./public-api-DgCw1uo6.mjs";
|
|
8
8
|
export { CheckpointApiClient, type CheckpointApiClientConfig, type CheckpointApiMiddlewareConfig, type CheckpointConfig, type CheckpointPostureOptions, type CheckpointPostureOutcome, type EnforceInput, type EnforceResponse, type EnforcementAction, type EnforcementDecision, type LogDetectionInput, VERSION, getCheckpointApiClient, getCheckpointPostureOutcome, resetCheckpointApiClient, withCheckpoint, withCheckpointApi };
|
package/dist/index-edge.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as EnforceResponse, c as LogDetectionInput, i as EnforceInput, l as getCheckpointApiClient, n as CheckpointApiClient, o as EnforcementAction, r as CheckpointApiClientConfig, s as EnforcementDecision, u as resetCheckpointApiClient } from "./api-client-JHOrRUA_.js";
|
|
2
2
|
import { n as withCheckpointApi, t as CheckpointApiMiddlewareConfig } from "./api-middleware-DyLDqOYF.js";
|
|
3
|
-
import { t as CheckpointConfig } from "./config-
|
|
3
|
+
import { t as CheckpointConfig } from "./config-DkXvl4nH.js";
|
|
4
4
|
import { n as CheckpointPostureOutcome, r as getCheckpointPostureOutcome, t as CheckpointPostureOptions } from "./posture-outcome-Ccujx_9V.js";
|
|
5
5
|
import { withCheckpoint } from "./middleware-edge.js";
|
|
6
|
-
import { t as VERSION } from "./middleware-core-
|
|
7
|
-
import "./public-api-
|
|
6
|
+
import { t as VERSION } from "./middleware-core-BmW2kH8J.js";
|
|
7
|
+
import "./public-api-Cw7Zj290.js";
|
|
8
8
|
export { CheckpointApiClient, type CheckpointApiClientConfig, type CheckpointApiMiddlewareConfig, type CheckpointConfig, type CheckpointPostureOptions, type CheckpointPostureOutcome, type EnforceInput, type EnforceResponse, type EnforcementAction, type EnforcementDecision, type LogDetectionInput, VERSION, getCheckpointApiClient, getCheckpointPostureOutcome, resetCheckpointApiClient, withCheckpoint, withCheckpointApi };
|
package/dist/index-edge.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_middleware_core = require('./middleware-core-
|
|
2
|
+
const require_middleware_core = require('./middleware-core-B1GuspOY.js');
|
|
3
3
|
const require_posture_outcome = require('./posture-outcome-DddsJtL8.js');
|
|
4
4
|
const require_api_client = require('./api-client.js');
|
|
5
|
-
const require_api_middleware = require('./api-middleware-
|
|
5
|
+
const require_api_middleware = require('./api-middleware-beNlXd5P.js');
|
|
6
6
|
const require_middleware_edge = require('./middleware-edge.js');
|
|
7
7
|
|
|
8
8
|
exports.CheckpointApiClient = require_api_client.CheckpointApiClient;
|
package/dist/index-edge.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as VERSION } from "./middleware-core-
|
|
1
|
+
import { t as VERSION } from "./middleware-core-WZeMSRqx.mjs";
|
|
2
2
|
import { t as getCheckpointPostureOutcome } from "./posture-outcome-DQ4fdMfq.mjs";
|
|
3
3
|
import { CheckpointApiClient, getCheckpointApiClient, resetCheckpointApiClient } from "./api-client.mjs";
|
|
4
|
-
import { t as withCheckpointApi } from "./api-middleware-
|
|
4
|
+
import { t as withCheckpointApi } from "./api-middleware-DvmkJ_Li.mjs";
|
|
5
5
|
import { withCheckpoint } from "./middleware-edge.mjs";
|
|
6
6
|
|
|
7
7
|
export { CheckpointApiClient, VERSION, getCheckpointApiClient, getCheckpointPostureOutcome, resetCheckpointApiClient, withCheckpoint, withCheckpointApi };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as EnforceResponse, c as LogDetectionInput, i as EnforceInput, l as getCheckpointApiClient, n as CheckpointApiClient, o as EnforcementAction, r as CheckpointApiClientConfig, s as EnforcementDecision, u as resetCheckpointApiClient } from "./api-client-JHOrRUA_.mjs";
|
|
2
|
-
import { n as withCheckpointApi, t as CheckpointApiMiddlewareConfig } from "./api-middleware-
|
|
3
|
-
import { t as CheckpointConfig } from "./config-
|
|
2
|
+
import { n as withCheckpointApi, t as CheckpointApiMiddlewareConfig } from "./api-middleware-BtsYJU5u.mjs";
|
|
3
|
+
import { t as CheckpointConfig } from "./config-D7h2w_it.mjs";
|
|
4
4
|
import { n as CheckpointPostureOutcome, r as getCheckpointPostureOutcome, t as CheckpointPostureOptions } from "./posture-outcome-Ccujx_9V.mjs";
|
|
5
|
-
import { t as VERSION } from "./middleware-core-
|
|
6
|
-
import "./public-api-
|
|
5
|
+
import { t as VERSION } from "./middleware-core-CnPUoD2v.mjs";
|
|
6
|
+
import "./public-api-DgCw1uo6.mjs";
|
|
7
7
|
import { withCheckpoint } from "./middleware-node.mjs";
|
|
8
8
|
export { CheckpointApiClient, type CheckpointApiClientConfig, type CheckpointApiMiddlewareConfig, type CheckpointConfig, type CheckpointPostureOptions, type CheckpointPostureOutcome, type EnforceInput, type EnforceResponse, type EnforcementAction, type EnforcementDecision, type LogDetectionInput, VERSION, getCheckpointApiClient, getCheckpointPostureOutcome, resetCheckpointApiClient, withCheckpoint, withCheckpointApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as EnforceResponse, c as LogDetectionInput, i as EnforceInput, l as getCheckpointApiClient, n as CheckpointApiClient, o as EnforcementAction, r as CheckpointApiClientConfig, s as EnforcementDecision, u as resetCheckpointApiClient } from "./api-client-JHOrRUA_.js";
|
|
2
2
|
import { n as withCheckpointApi, t as CheckpointApiMiddlewareConfig } from "./api-middleware-DyLDqOYF.js";
|
|
3
|
-
import { t as CheckpointConfig } from "./config-
|
|
3
|
+
import { t as CheckpointConfig } from "./config-DkXvl4nH.js";
|
|
4
4
|
import { n as CheckpointPostureOutcome, r as getCheckpointPostureOutcome, t as CheckpointPostureOptions } from "./posture-outcome-Ccujx_9V.js";
|
|
5
|
-
import { t as VERSION } from "./middleware-core-
|
|
6
|
-
import "./public-api-
|
|
5
|
+
import { t as VERSION } from "./middleware-core-BmW2kH8J.js";
|
|
6
|
+
import "./public-api-Cw7Zj290.js";
|
|
7
7
|
import { withCheckpoint } from "./middleware-node.js";
|
|
8
8
|
export { CheckpointApiClient, type CheckpointApiClientConfig, type CheckpointApiMiddlewareConfig, type CheckpointConfig, type CheckpointPostureOptions, type CheckpointPostureOutcome, type EnforceInput, type EnforceResponse, type EnforcementAction, type EnforcementDecision, type LogDetectionInput, VERSION, getCheckpointApiClient, getCheckpointPostureOutcome, resetCheckpointApiClient, withCheckpoint, withCheckpointApi };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_middleware_core = require('./middleware-core-
|
|
2
|
+
const require_middleware_core = require('./middleware-core-B1GuspOY.js');
|
|
3
3
|
const require_middleware_node = require('./middleware-node.js');
|
|
4
4
|
const require_posture_outcome = require('./posture-outcome-DddsJtL8.js');
|
|
5
5
|
const require_api_client = require('./api-client.js');
|
|
6
|
-
const require_api_middleware = require('./api-middleware-
|
|
6
|
+
const require_api_middleware = require('./api-middleware-beNlXd5P.js');
|
|
7
7
|
|
|
8
8
|
//#region src/index.ts
|
|
9
9
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as VERSION } from "./middleware-core-
|
|
1
|
+
import { t as VERSION } from "./middleware-core-WZeMSRqx.mjs";
|
|
2
2
|
import { withCheckpoint } from "./middleware-node.mjs";
|
|
3
3
|
import { t as getCheckpointPostureOutcome } from "./posture-outcome-DQ4fdMfq.mjs";
|
|
4
4
|
import { CheckpointApiClient, getCheckpointApiClient, resetCheckpointApiClient } from "./api-client.mjs";
|
|
5
|
-
import { t as withCheckpointApi } from "./api-middleware-
|
|
5
|
+
import { t as withCheckpointApi } from "./api-middleware-DvmkJ_Li.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/index.ts
|
|
8
8
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CheckpointConfig } from "./config-
|
|
1
|
+
import { t as CheckpointConfig } from "./config-D7h2w_it.mjs";
|
|
2
2
|
//#region src/middleware-bundler.d.ts
|
|
3
3
|
/** Next.js server bundlers import the WASM asset rather than relocating a Node fs read. */
|
|
4
4
|
export declare function withCheckpoint(config: CheckpointConfig): (req: import("next/server").NextRequest, event?: Pick<import("next/server").NextFetchEvent, "waitUntil">) => Promise<import("next/server").NextResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CheckpointConfig } from "./config-
|
|
1
|
+
import { t as CheckpointConfig } from "./config-DkXvl4nH.js";
|
|
2
2
|
//#region src/middleware-bundler.d.ts
|
|
3
3
|
/** Next.js server bundlers import the WASM asset rather than relocating a Node fs read. */
|
|
4
4
|
export declare function withCheckpoint(config: CheckpointConfig): (req: import("next/server").NextRequest, event?: Pick<import("next/server").NextFetchEvent, "waitUntil">) => Promise<import("next/server").NextResponse>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_middleware_core = require('./middleware-core-
|
|
3
|
-
const require_middleware_node_context = require('./middleware-node-context-
|
|
2
|
+
const require_middleware_core = require('./middleware-core-B1GuspOY.js');
|
|
3
|
+
const require_middleware_node_context = require('./middleware-node-context-TRMTgp3y.js');
|
|
4
4
|
|
|
5
5
|
//#region src/middleware-bundler.ts
|
|
6
6
|
/** Next.js server bundlers import the WASM asset rather than relocating a Node fs read. */
|
|
@@ -8,7 +8,7 @@ function withCheckpoint(config) {
|
|
|
8
8
|
return require_middleware_core.makeNextMiddleware(config, {
|
|
9
9
|
runtime: "node",
|
|
10
10
|
loadEngine: () => import("@kya-os/checkpoint-wasm-runtime/orchestrator/bundler"),
|
|
11
|
-
|
|
11
|
+
policyCompiler: require_middleware_node_context.nodePolicyCompiler
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as makeNextMiddleware } from "./middleware-core-
|
|
2
|
-
import { t as
|
|
1
|
+
import { n as makeNextMiddleware } from "./middleware-core-WZeMSRqx.mjs";
|
|
2
|
+
import { t as nodePolicyCompiler } from "./middleware-node-context-BvqrL2Ra.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware-bundler.ts
|
|
5
5
|
/** Next.js server bundlers import the WASM asset rather than relocating a Node fs read. */
|
|
@@ -7,7 +7,7 @@ function withCheckpoint(config) {
|
|
|
7
7
|
return makeNextMiddleware(config, {
|
|
8
8
|
runtime: "node",
|
|
9
9
|
loadEngine: () => import("@kya-os/checkpoint-wasm-runtime/orchestrator/bundler"),
|
|
10
|
-
|
|
10
|
+
policyCompiler: nodePolicyCompiler
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-bundler.mjs","names":[],"sources":["../src/middleware-bundler.ts"],"sourcesContent":["import { makeNextMiddleware } from './middleware-core';\nimport {
|
|
1
|
+
{"version":3,"file":"middleware-bundler.mjs","names":[],"sources":["../src/middleware-bundler.ts"],"sourcesContent":["import { makeNextMiddleware } from './middleware-core';\nimport { nodePolicyCompiler } from './middleware-node-context';\nimport type { CheckpointConfig } from './config';\nexport type { CheckpointConfig } from './config';\n\n/** Next.js server bundlers import the WASM asset rather than relocating a Node fs read. */\nexport function withCheckpoint(config: CheckpointConfig) {\n return makeNextMiddleware(config, {\n runtime: 'node',\n // Imported on first use: a failure to load the engine is then answered 503\n // per request instead of failing this module.\n loadEngine: () => import('@kya-os/checkpoint-wasm-runtime/orchestrator/bundler'),\n policyCompiler: nodePolicyCompiler,\n });\n}\n"],"mappings":";;;;;AAMA,SAAgB,eAAe,QAA0B;CACvD,OAAO,mBAAmB,QAAQ;EAChC,SAAS;EAGT,kBAAkB,OAAO;EACzB,gBAAgB;CAClB,CAAC;AACH"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
const require_adapt = require('./adapt-DUEIfZnx.js');
|
|
2
|
+
const require_utils = require('./utils-dyFxqlFI.js');
|
|
3
|
+
let _kya_os_checkpoint_wasm_runtime_pipeline = require("@kya-os/checkpoint-wasm-runtime/pipeline");
|
|
4
|
+
let _vercel_functions = require("@vercel/functions");
|
|
5
|
+
|
|
6
|
+
//#region src/translate.ts
|
|
7
|
+
/**
|
|
8
|
+
* Translate a Next.js `NextRequest` into the orchestrator's
|
|
9
|
+
* `IncomingHttpLike` shape.
|
|
10
|
+
*
|
|
11
|
+
* When `opts.drainJsonBody !== false` and the request is JSON, the
|
|
12
|
+
* translator clones the request and reads the body into a string so
|
|
13
|
+
* the orchestrator's `buildAgentRequest` can extract a
|
|
14
|
+
* `_meta.proof.jws` envelope. The original `req.body` stream is
|
|
15
|
+
* preserved for downstream handlers via `req.clone()`.
|
|
16
|
+
*
|
|
17
|
+
* When the body can't be read (drain disabled, non-JSON, or a stream
|
|
18
|
+
* error) we pass `body: null` and the orchestrator routes to
|
|
19
|
+
* PlainHttp — same behavior as the pre-1.1.0 default.
|
|
20
|
+
*/
|
|
21
|
+
async function nextRequestToHttpLike(req, opts = {}) {
|
|
22
|
+
const url = new URL(req.url);
|
|
23
|
+
const body = await tryDrainJsonBody(req, opts);
|
|
24
|
+
return {
|
|
25
|
+
method: req.method,
|
|
26
|
+
url: url.pathname + url.search,
|
|
27
|
+
headers: headersToRecord(req.headers),
|
|
28
|
+
body,
|
|
29
|
+
remoteAddress: require_utils.getClientIp(req, opts.clientIpPolicy)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read the request body as a UTF-8 string when JSON and the caller
|
|
34
|
+
* has opted in (default). Returns `null` on any failure — the
|
|
35
|
+
* orchestrator handles `null` as "no body present" (→ PlainHttp).
|
|
36
|
+
*
|
|
37
|
+
* Clone-first means the original `req.body` ReadableStream stays
|
|
38
|
+
* unconsumed and downstream handlers can re-read it. Without the
|
|
39
|
+
* clone, calling `req.text()` in middleware would block any route
|
|
40
|
+
* handler that needs the body.
|
|
41
|
+
*/
|
|
42
|
+
async function tryDrainJsonBody(req, opts) {
|
|
43
|
+
if (opts.drainJsonBody === false) return null;
|
|
44
|
+
if (!(req.headers.get("content-type") ?? "").toLowerCase().includes("application/json")) return null;
|
|
45
|
+
try {
|
|
46
|
+
return await req.clone().text();
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert a `Headers` instance into a lowercase-keyed plain object.
|
|
53
|
+
* HTTP header names are case-insensitive (RFC 9110 § 5.1); the
|
|
54
|
+
* orchestrator does case-sensitive lookups, so we normalise to
|
|
55
|
+
* lowercase here. Multi-value headers (Set-Cookie, Accept) are
|
|
56
|
+
* surfaced as their `Headers.get()` view — a single string with
|
|
57
|
+
* comma-joined values, matching what other host adapters produce.
|
|
58
|
+
*/
|
|
59
|
+
function headersToRecord(headers) {
|
|
60
|
+
const out = {};
|
|
61
|
+
headers.forEach((value, key) => {
|
|
62
|
+
out[key.toLowerCase()] = value;
|
|
63
|
+
});
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/middleware-core.ts
|
|
69
|
+
/**
|
|
70
|
+
* The Next.js side of the shared request pipeline
|
|
71
|
+
* (`@kya-os/checkpoint-wasm-runtime/pipeline`). Node, bundler and Edge hosts
|
|
72
|
+
* inject their engine and Cedar compiler; runtime-specific WASM initialization
|
|
73
|
+
* stays in each host entry. Public withCheckpoint exports live there too.
|
|
74
|
+
*/
|
|
75
|
+
/** npm package name this SDK self-reports to the detection reporter. */
|
|
76
|
+
const SDK_NAME = "@kya-os/checkpoint-nextjs";
|
|
77
|
+
/**
|
|
78
|
+
* Installed SDK version, self-reported to the detection reporter so the
|
|
79
|
+
* dashboard can version-gate "composed policy enforces here". MUST equal
|
|
80
|
+
* `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
|
|
81
|
+
* drifted). Re-exported as `VERSION` from the package index.
|
|
82
|
+
*/
|
|
83
|
+
const VERSION = "1.12.0";
|
|
84
|
+
/**
|
|
85
|
+
* Build the Checkpoint middleware. Returns a function `(req) => NextResponse`
|
|
86
|
+
* suitable for `export default withCheckpoint({...})` in `middleware.ts`.
|
|
87
|
+
*
|
|
88
|
+
* Every verification decision flows through the Rust `kya-os-engine`
|
|
89
|
+
* via WASM. The TS layer translates request shape, runs the shared
|
|
90
|
+
* pipeline, and translates the verdict to `NextResponse`. No
|
|
91
|
+
* verification logic lives in this file.
|
|
92
|
+
*
|
|
93
|
+
* It never throws. An error in the configuration or in loading the engine
|
|
94
|
+
* would otherwise fail the middleware module, and a Next.js middleware that
|
|
95
|
+
* fails to load can let requests through unchecked. Every such error is
|
|
96
|
+
* answered 503 instead (fail closed) and logged.
|
|
97
|
+
*/
|
|
98
|
+
function makeNextMiddleware(config, host) {
|
|
99
|
+
try {
|
|
100
|
+
return makeMiddleware(config, host);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
return async function misconfiguredCheckpointMiddleware() {
|
|
103
|
+
console.error("[checkpoint] withCheckpoint is misconfigured; responding 503:", error);
|
|
104
|
+
return require_adapt.failClosedResponse();
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function makeMiddleware(config, host) {
|
|
109
|
+
const pipeline = (0, _kya_os_checkpoint_wasm_runtime_pipeline.makeCheckpointPipeline)(config, {
|
|
110
|
+
sdk: {
|
|
111
|
+
name: SDK_NAME,
|
|
112
|
+
version: VERSION,
|
|
113
|
+
runtime: host.runtime
|
|
114
|
+
},
|
|
115
|
+
loadEngine: host.loadEngine,
|
|
116
|
+
policyCompiler: host.policyCompiler,
|
|
117
|
+
start: host.start
|
|
118
|
+
});
|
|
119
|
+
const translateOpts = {
|
|
120
|
+
drainJsonBody: config.drainJsonBody,
|
|
121
|
+
clientIpPolicy: config.clientIpPolicy
|
|
122
|
+
};
|
|
123
|
+
return async function checkpointMiddleware(req, event) {
|
|
124
|
+
const waitUntil = event ? (promise) => event.waitUntil(promise) : _vercel_functions.waitUntil;
|
|
125
|
+
try {
|
|
126
|
+
const { rendered } = await pipeline({
|
|
127
|
+
request: req,
|
|
128
|
+
translate: () => nextRequestToHttpLike(req, translateOpts),
|
|
129
|
+
headers: req.headers,
|
|
130
|
+
path: req.nextUrl.pathname,
|
|
131
|
+
clientIp: () => require_utils.getClientIp(req, config.clientIpPolicy),
|
|
132
|
+
reportContext: () => extractReporterContext(req, config.clientIpPolicy),
|
|
133
|
+
waitUntil
|
|
134
|
+
});
|
|
135
|
+
return require_adapt.adaptToNextResponse(rendered, req);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
(0, _kya_os_checkpoint_wasm_runtime_pipeline.logPipelineFailure)(err, config.debug);
|
|
138
|
+
return require_adapt.failClosedResponse();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Pull the request context the dashboard's `/api/v1/log-detection`
|
|
144
|
+
* endpoint expects out of a `NextRequest`. Works under both Node and
|
|
145
|
+
* Edge runtimes — no runtime-specific APIs.
|
|
146
|
+
*/
|
|
147
|
+
function extractReporterContext(req, policy) {
|
|
148
|
+
return {
|
|
149
|
+
userAgent: req.headers.get("user-agent") ?? void 0,
|
|
150
|
+
ipAddress: require_utils.getClientIp(req, policy),
|
|
151
|
+
path: req.nextUrl.pathname,
|
|
152
|
+
url: req.nextUrl.href,
|
|
153
|
+
method: req.method
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//#endregion
|
|
158
|
+
Object.defineProperty(exports, 'VERSION', {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function () {
|
|
161
|
+
return VERSION;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(exports, 'makeNextMiddleware', {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function () {
|
|
167
|
+
return makeNextMiddleware;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import "./config-
|
|
1
|
+
import "./config-DkXvl4nH.js";
|
|
2
2
|
import { NextRequest, NextResponse } from "next/server.js";
|
|
3
|
-
import "@kya-os/checkpoint-wasm-runtime/
|
|
4
|
-
import { ComposedPolicyContext } from "@kya-os/checkpoint-wasm-runtime/composed-policy";
|
|
5
|
-
import { VerifyResult } from "@kya-os/checkpoint-wasm-runtime/engine";
|
|
6
|
-
import "@kya-os/checkpoint-wasm-runtime/orchestrator";
|
|
3
|
+
import "@kya-os/checkpoint-wasm-runtime/pipeline";
|
|
7
4
|
//#region src/middleware-core.d.ts
|
|
8
5
|
/**
|
|
9
6
|
* Installed SDK version, self-reported to the detection reporter so the
|
|
@@ -11,7 +8,7 @@ import "@kya-os/checkpoint-wasm-runtime/orchestrator";
|
|
|
11
8
|
* `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
|
|
12
9
|
* drifted). Re-exported as `VERSION` from the package index.
|
|
13
10
|
*/
|
|
14
|
-
declare const VERSION = "1.
|
|
11
|
+
declare const VERSION = "1.12.0";
|
|
15
12
|
//#endregion
|
|
16
13
|
export { VERSION as t };
|
|
17
|
-
//# sourceMappingURL=middleware-core-
|
|
14
|
+
//# sourceMappingURL=middleware-core-BmW2kH8J.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-core-BmW2kH8J.d.ts","names":[],"sources":["../src/middleware-core.ts"],"mappings":";;;;;;;;;;cA4Da"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import "./config-
|
|
2
|
-
import
|
|
1
|
+
import "./config-D7h2w_it.mjs";
|
|
2
|
+
import "@kya-os/checkpoint-wasm-runtime/pipeline";
|
|
3
3
|
import { NextRequest, NextResponse } from "next/server.js";
|
|
4
|
-
import "@kya-os/checkpoint-wasm-runtime/orchestrator/edge";
|
|
5
|
-
import { VerifyResult } from "@kya-os/checkpoint-wasm-runtime/engine";
|
|
6
|
-
import "@kya-os/checkpoint-wasm-runtime/orchestrator";
|
|
7
4
|
//#region src/middleware-core.d.ts
|
|
8
5
|
/**
|
|
9
6
|
* Installed SDK version, self-reported to the detection reporter so the
|
|
@@ -11,7 +8,7 @@ import "@kya-os/checkpoint-wasm-runtime/orchestrator";
|
|
|
11
8
|
* `package.json` version — pinned by a unit test (the old hardcoded `0.1.0` had
|
|
12
9
|
* drifted). Re-exported as `VERSION` from the package index.
|
|
13
10
|
*/
|
|
14
|
-
declare const VERSION = "1.
|
|
11
|
+
declare const VERSION = "1.12.0";
|
|
15
12
|
//#endregion
|
|
16
13
|
export { VERSION as t };
|
|
17
|
-
//# sourceMappingURL=middleware-core-
|
|
14
|
+
//# sourceMappingURL=middleware-core-CnPUoD2v.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-core-CnPUoD2v.d.mts","names":[],"sources":["../src/middleware-core.ts"],"mappings":";;;;;;;;;;cA4Da"}
|