@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.
Files changed (210) hide show
  1. package/CHANGELOG.md +245 -0
  2. package/README.md +205 -31
  3. package/dist/{adapt.mjs → adapt-BdQ9R7Iw.mjs} +15 -4
  4. package/dist/adapt-BdQ9R7Iw.mjs.map +1 -0
  5. package/dist/{adapt.js → adapt-CCSKGjVH.js} +34 -13
  6. package/dist/api-client-JHOrRUA_.d.mts +222 -0
  7. package/dist/api-client-JHOrRUA_.d.mts.map +1 -0
  8. package/dist/api-client-JHOrRUA_.d.ts +222 -0
  9. package/dist/api-client-JHOrRUA_.d.ts.map +1 -0
  10. package/dist/api-client.d.mts +2 -204
  11. package/dist/api-client.d.ts +2 -204
  12. package/dist/api-client.js +19 -18
  13. package/dist/api-client.mjs +20 -16
  14. package/dist/api-client.mjs.map +1 -1
  15. package/dist/api-middleware-BWjokNis.d.mts +131 -0
  16. package/dist/api-middleware-BWjokNis.d.mts.map +1 -0
  17. package/dist/{api-middleware-CDSh3TSE.js → api-middleware-Bf3xmM9W.js} +75 -63
  18. package/dist/{api-middleware-CMDRoQik.mjs → api-middleware-C-ngFX_8.mjs} +68 -38
  19. package/dist/api-middleware-C-ngFX_8.mjs.map +1 -0
  20. package/dist/api-middleware-DyLDqOYF.d.ts +131 -0
  21. package/dist/api-middleware-DyLDqOYF.d.ts.map +1 -0
  22. package/dist/api-middleware.d.mts +2 -152
  23. package/dist/api-middleware.d.ts +2 -152
  24. package/dist/api-middleware.js +1 -5
  25. package/dist/api-middleware.mjs +2 -3
  26. package/dist/cedar-wasm.d.mts +20 -0
  27. package/dist/cedar-wasm.d.mts.map +1 -0
  28. package/dist/cedar-wasm.d.ts +19 -0
  29. package/dist/cedar-wasm.d.ts.map +1 -0
  30. package/dist/cedar-wasm.js +24 -0
  31. package/dist/cedar-wasm.mjs +23 -0
  32. package/dist/cedar-wasm.mjs.map +1 -0
  33. package/dist/{config-Doe0Tn53.d.mts → config-CPP1RV0f.d.mts} +65 -29
  34. package/dist/config-CPP1RV0f.d.mts.map +1 -0
  35. package/dist/{config-CbAg2mze.d.ts → config-DVgOFxJs.d.ts} +66 -30
  36. package/dist/config-DVgOFxJs.d.ts.map +1 -0
  37. package/dist/engine-wasm.d.mts +20 -0
  38. package/dist/engine-wasm.d.mts.map +1 -0
  39. package/dist/engine-wasm.d.ts +19 -0
  40. package/dist/engine-wasm.d.ts.map +1 -0
  41. package/dist/engine-wasm.js +24 -0
  42. package/dist/engine-wasm.mjs +23 -0
  43. package/dist/engine-wasm.mjs.map +1 -0
  44. package/dist/index-edge.d.mts +8 -0
  45. package/dist/index-edge.d.ts +8 -0
  46. package/dist/index-edge.js +14 -0
  47. package/dist/index-edge.mjs +7 -0
  48. package/dist/index.d.mts +8 -10
  49. package/dist/index.d.ts +8 -10
  50. package/dist/index.js +20 -49
  51. package/dist/index.mjs +21 -8
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/middleware-bundler.d.mts +1 -1
  54. package/dist/middleware-bundler.d.mts.map +1 -1
  55. package/dist/middleware-bundler.d.ts +1 -1
  56. package/dist/middleware-bundler.d.ts.map +1 -1
  57. package/dist/middleware-bundler.js +4 -4
  58. package/dist/middleware-bundler.mjs +4 -4
  59. package/dist/middleware-bundler.mjs.map +1 -1
  60. package/dist/middleware-core-B0jf5_Hm.mjs +264 -0
  61. package/dist/middleware-core-B0jf5_Hm.mjs.map +1 -0
  62. package/dist/middleware-core-Bol44X9C.d.ts +17 -0
  63. package/dist/middleware-core-Bol44X9C.d.ts.map +1 -0
  64. package/dist/middleware-core-CMc-2QkU.js +274 -0
  65. package/dist/middleware-core-DycsbHUd.d.mts +17 -0
  66. package/dist/middleware-core-DycsbHUd.d.mts.map +1 -0
  67. package/dist/middleware-edge.d.mts +11 -3
  68. package/dist/middleware-edge.d.mts.map +1 -1
  69. package/dist/middleware-edge.d.ts +11 -3
  70. package/dist/middleware-edge.d.ts.map +1 -1
  71. package/dist/middleware-edge.js +77 -24
  72. package/dist/middleware-edge.mjs +74 -23
  73. package/dist/middleware-edge.mjs.map +1 -1
  74. package/dist/{middleware-node-context-rgnc7UNR.js → middleware-node-context-591KsiYg.js} +8 -7
  75. package/dist/{middleware-node-context-BqPbf-fI.mjs → middleware-node-context-D_ZyUEcA.mjs} +6 -5
  76. package/dist/middleware-node-context-D_ZyUEcA.mjs.map +1 -0
  77. package/dist/middleware-node.d.mts +12 -3
  78. package/dist/middleware-node.d.mts.map +1 -0
  79. package/dist/middleware-node.d.ts +12 -3
  80. package/dist/middleware-node.d.ts.map +1 -0
  81. package/dist/middleware-node.js +13 -5
  82. package/dist/middleware-node.mjs +13 -5
  83. package/dist/middleware-node.mjs.map +1 -1
  84. package/dist/posture-outcome-Ccujx_9V.d.mts +14 -0
  85. package/dist/posture-outcome-Ccujx_9V.d.mts.map +1 -0
  86. package/dist/posture-outcome-Ccujx_9V.d.ts +14 -0
  87. package/dist/posture-outcome-Ccujx_9V.d.ts.map +1 -0
  88. package/dist/posture-outcome-DQ4fdMfq.mjs +21 -0
  89. package/dist/posture-outcome-DQ4fdMfq.mjs.map +1 -0
  90. package/dist/posture-outcome-DddsJtL8.js +25 -0
  91. package/dist/public-api-CYsHrTQI.d.ts +5 -0
  92. package/dist/public-api-DkG7pRE0.d.mts +5 -0
  93. package/dist/rolldown-runtime-C24Yb2bl.js +33 -0
  94. package/dist/utils-Cnwg0VrY.mjs +88 -0
  95. package/dist/utils-Cnwg0VrY.mjs.map +1 -0
  96. package/dist/utils-dyFxqlFI.js +104 -0
  97. package/package.json +27 -62
  98. package/EDGE_RUNTIME_WASM_SETUP.md +0 -342
  99. package/bin/setup-edge-wasm.js +0 -513
  100. package/dist/adapt.d.mts +0 -11
  101. package/dist/adapt.d.mts.map +0 -1
  102. package/dist/adapt.d.ts +0 -11
  103. package/dist/adapt.d.ts.map +0 -1
  104. package/dist/adapt.mjs.map +0 -1
  105. package/dist/api-client.d.mts.map +0 -1
  106. package/dist/api-client.d.ts.map +0 -1
  107. package/dist/api-middleware-CMDRoQik.mjs.map +0 -1
  108. package/dist/api-middleware.d.mts.map +0 -1
  109. package/dist/api-middleware.d.ts.map +0 -1
  110. package/dist/composed-policy-BCaNiVHv.d.mts +0 -98
  111. package/dist/composed-policy-BCaNiVHv.d.mts.map +0 -1
  112. package/dist/composed-policy-zzJYNFTb.d.ts +0 -98
  113. package/dist/composed-policy-zzJYNFTb.d.ts.map +0 -1
  114. package/dist/composed-policy.d.mts +0 -2
  115. package/dist/composed-policy.d.ts +0 -2
  116. package/dist/composed-policy.js +0 -136
  117. package/dist/composed-policy.mjs +0 -132
  118. package/dist/composed-policy.mjs.map +0 -1
  119. package/dist/config-CbAg2mze.d.ts.map +0 -1
  120. package/dist/config-Doe0Tn53.d.mts.map +0 -1
  121. package/dist/create-middleware.d.mts +0 -11
  122. package/dist/create-middleware.d.mts.map +0 -1
  123. package/dist/create-middleware.d.ts +0 -11
  124. package/dist/create-middleware.d.ts.map +0 -1
  125. package/dist/create-middleware.js +0 -39
  126. package/dist/create-middleware.mjs +0 -38
  127. package/dist/create-middleware.mjs.map +0 -1
  128. package/dist/edge/index.d.mts +0 -88
  129. package/dist/edge/index.d.mts.map +0 -1
  130. package/dist/edge/index.d.ts +0 -88
  131. package/dist/edge/index.d.ts.map +0 -1
  132. package/dist/edge/index.js +0 -362
  133. package/dist/edge/index.mjs +0 -362
  134. package/dist/edge/index.mjs.map +0 -1
  135. package/dist/edge-runtime-loader.d.mts +0 -49
  136. package/dist/edge-runtime-loader.d.mts.map +0 -1
  137. package/dist/edge-runtime-loader.d.ts +0 -49
  138. package/dist/edge-runtime-loader.d.ts.map +0 -1
  139. package/dist/edge-runtime-loader.js +0 -297
  140. package/dist/edge-runtime-loader.mjs +0 -292
  141. package/dist/edge-runtime-loader.mjs.map +0 -1
  142. package/dist/edge-wasm-middleware.d.mts +0 -43
  143. package/dist/edge-wasm-middleware.d.mts.map +0 -1
  144. package/dist/edge-wasm-middleware.d.ts +0 -43
  145. package/dist/edge-wasm-middleware.d.ts.map +0 -1
  146. package/dist/edge-wasm-middleware.js +0 -37
  147. package/dist/edge-wasm-middleware.mjs +0 -35
  148. package/dist/edge-wasm-middleware.mjs.map +0 -1
  149. package/dist/middleware-core-BYQP9FND.mjs +0 -165
  150. package/dist/middleware-core-BYQP9FND.mjs.map +0 -1
  151. package/dist/middleware-core-D6TijE6P.js +0 -175
  152. package/dist/middleware-node-CE4GevYs.d.ts +0 -20
  153. package/dist/middleware-node-CE4GevYs.d.ts.map +0 -1
  154. package/dist/middleware-node-DtyOuPta.d.mts +0 -20
  155. package/dist/middleware-node-DtyOuPta.d.mts.map +0 -1
  156. package/dist/middleware-node-context-BqPbf-fI.mjs.map +0 -1
  157. package/dist/middleware.d.mts +0 -25
  158. package/dist/middleware.d.mts.map +0 -1
  159. package/dist/middleware.d.ts +0 -25
  160. package/dist/middleware.d.ts.map +0 -1
  161. package/dist/middleware.js +0 -53
  162. package/dist/middleware.mjs +0 -51
  163. package/dist/middleware.mjs.map +0 -1
  164. package/dist/nodejs-wasm-loader.d.mts +0 -42
  165. package/dist/nodejs-wasm-loader.d.mts.map +0 -1
  166. package/dist/nodejs-wasm-loader.d.ts +0 -42
  167. package/dist/nodejs-wasm-loader.d.ts.map +0 -1
  168. package/dist/nodejs-wasm-loader.js +0 -70
  169. package/dist/nodejs-wasm-loader.mjs +0 -66
  170. package/dist/nodejs-wasm-loader.mjs.map +0 -1
  171. package/dist/policy.d.mts +0 -138
  172. package/dist/policy.d.mts.map +0 -1
  173. package/dist/policy.d.ts +0 -138
  174. package/dist/policy.d.ts.map +0 -1
  175. package/dist/policy.js +0 -236
  176. package/dist/policy.mjs +0 -205
  177. package/dist/policy.mjs.map +0 -1
  178. package/dist/session-tracker.d.mts +0 -50
  179. package/dist/session-tracker.d.mts.map +0 -1
  180. package/dist/session-tracker.d.ts +0 -50
  181. package/dist/session-tracker.d.ts.map +0 -1
  182. package/dist/session-tracker.js +0 -148
  183. package/dist/session-tracker.mjs +0 -147
  184. package/dist/session-tracker.mjs.map +0 -1
  185. package/dist/translate.d.mts +0 -48
  186. package/dist/translate.d.mts.map +0 -1
  187. package/dist/translate.d.ts +0 -48
  188. package/dist/translate.d.ts.map +0 -1
  189. package/dist/translate.js +0 -79
  190. package/dist/translate.mjs +0 -79
  191. package/dist/translate.mjs.map +0 -1
  192. package/dist/types-C0SkqLMM.d.mts +0 -102
  193. package/dist/types-C0SkqLMM.d.mts.map +0 -1
  194. package/dist/types-C7DNSCTO.d.ts +0 -102
  195. package/dist/types-C7DNSCTO.d.ts.map +0 -1
  196. package/dist/utils-Cj4XNhIY.mjs +0 -35
  197. package/dist/utils-Cj4XNhIY.mjs.map +0 -1
  198. package/dist/utils-DAisnYnI.js +0 -45
  199. package/dist/wasm-setup.d.mts +0 -47
  200. package/dist/wasm-setup.d.mts.map +0 -1
  201. package/dist/wasm-setup.d.ts +0 -47
  202. package/dist/wasm-setup.d.ts.map +0 -1
  203. package/dist/wasm-setup.js +0 -91
  204. package/dist/wasm-setup.mjs +0 -95
  205. package/dist/wasm-setup.mjs.map +0 -1
  206. package/wasm/agentshield_wasm.d.ts +0 -479
  207. package/wasm/agentshield_wasm.js +0 -1536
  208. package/wasm/agentshield_wasm_bg.wasm +0 -0
  209. package/wasm/package.json +0 -30
  210. package/wasm.d.ts +0 -21
@@ -1,53 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- let next_server = require("next/server");
3
-
4
- //#region src/middleware.ts
5
- /**
6
- * @deprecated Phase D — legacy TS-pattern-matching middleware path is
7
- * gone. This file now exists only to preserve the historical export
8
- * surface (`createAgentShieldMiddleware`, `agentShield`) at compile
9
- * time. Calling either function throws a clear migration error.
10
- *
11
- * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`
12
- * (Node runtime) or `@kya-os/checkpoint-nextjs/edge` (Edge runtime).
13
- * The new factory accepts a `CheckpointConfig` and routes every
14
- * verification through the Rust `kya-os-engine` via WASM. See the
15
- * package CHANGELOG for the recipe.
16
- *
17
- * Architect Q10 deletion ratification — the 600-line TS pattern
18
- * matcher (`edge-detector-wrapper.ts`) was removed in Phase D's
19
- * cutover. The new path is structurally simpler and decisive: one
20
- * engine, one verdict, every runtime.
21
- */
22
- const MIGRATION_ERROR = "@kya-os/checkpoint-nextjs's `createAgentShieldMiddleware` / `agentShield` were deleted in Phase D (engine consolidation). The 600-line TS pattern matcher that backed them is gone. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` (Node runtime) or `@kya-os/checkpoint-nextjs/edge` (Edge runtime). See packages/checkpoint-nextjs/CHANGELOG.md (1.0.0) for the recipe.";
23
- /**
24
- * @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
25
- * Throws on invocation; surface exists only so static analysis sees
26
- * the historical export.
27
- */
28
- function createAgentShieldMiddleware(_config = {}) {
29
- throw new Error(MIGRATION_ERROR);
30
- }
31
- /**
32
- * @deprecated Alias of the deprecated `createAgentShieldMiddleware`.
33
- * Migrate to `withCheckpoint`.
34
- */
35
- function agentShield(config = {}) {
36
- return createAgentShieldMiddleware(config);
37
- }
38
- /**
39
- * Pass-through export required by Next.js 16+ middleware file validation.
40
- * Next.js requires any file named `middleware.ts` to export a function named
41
- * `middleware` or a default function. This stub satisfies that constraint so
42
- * consumers that still reference the `./middleware` subpath can build.
43
- *
44
- * @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
45
- */
46
- function middleware(_request) {
47
- return next_server.NextResponse.next();
48
- }
49
-
50
- //#endregion
51
- exports.agentShield = agentShield;
52
- exports.createAgentShieldMiddleware = createAgentShieldMiddleware;
53
- exports.middleware = middleware;
@@ -1,51 +0,0 @@
1
- import { NextResponse } from "next/server";
2
-
3
- //#region src/middleware.ts
4
- /**
5
- * @deprecated Phase D — legacy TS-pattern-matching middleware path is
6
- * gone. This file now exists only to preserve the historical export
7
- * surface (`createAgentShieldMiddleware`, `agentShield`) at compile
8
- * time. Calling either function throws a clear migration error.
9
- *
10
- * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`
11
- * (Node runtime) or `@kya-os/checkpoint-nextjs/edge` (Edge runtime).
12
- * The new factory accepts a `CheckpointConfig` and routes every
13
- * verification through the Rust `kya-os-engine` via WASM. See the
14
- * package CHANGELOG for the recipe.
15
- *
16
- * Architect Q10 deletion ratification — the 600-line TS pattern
17
- * matcher (`edge-detector-wrapper.ts`) was removed in Phase D's
18
- * cutover. The new path is structurally simpler and decisive: one
19
- * engine, one verdict, every runtime.
20
- */
21
- const MIGRATION_ERROR = "@kya-os/checkpoint-nextjs's `createAgentShieldMiddleware` / `agentShield` were deleted in Phase D (engine consolidation). The 600-line TS pattern matcher that backed them is gone. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` (Node runtime) or `@kya-os/checkpoint-nextjs/edge` (Edge runtime). See packages/checkpoint-nextjs/CHANGELOG.md (1.0.0) for the recipe.";
22
- /**
23
- * @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
24
- * Throws on invocation; surface exists only so static analysis sees
25
- * the historical export.
26
- */
27
- function createAgentShieldMiddleware(_config = {}) {
28
- throw new Error(MIGRATION_ERROR);
29
- }
30
- /**
31
- * @deprecated Alias of the deprecated `createAgentShieldMiddleware`.
32
- * Migrate to `withCheckpoint`.
33
- */
34
- function agentShield(config = {}) {
35
- return createAgentShieldMiddleware(config);
36
- }
37
- /**
38
- * Pass-through export required by Next.js 16+ middleware file validation.
39
- * Next.js requires any file named `middleware.ts` to export a function named
40
- * `middleware` or a default function. This stub satisfies that constraint so
41
- * consumers that still reference the `./middleware` subpath can build.
42
- *
43
- * @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.
44
- */
45
- function middleware(_request) {
46
- return NextResponse.next();
47
- }
48
-
49
- //#endregion
50
- export { agentShield, createAgentShieldMiddleware, middleware };
51
- //# sourceMappingURL=middleware.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware.mjs","names":[],"sources":["../src/middleware.ts"],"sourcesContent":["/**\n * @deprecated Phase D — legacy TS-pattern-matching middleware path is\n * gone. This file now exists only to preserve the historical export\n * surface (`createAgentShieldMiddleware`, `agentShield`) at compile\n * time. Calling either function throws a clear migration error.\n *\n * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`\n * (Node runtime) or `@kya-os/checkpoint-nextjs/edge` (Edge runtime).\n * The new factory accepts a `CheckpointConfig` and routes every\n * verification through the Rust `kya-os-engine` via WASM. See the\n * package CHANGELOG for the recipe.\n *\n * Architect Q10 deletion ratification — the 600-line TS pattern\n * matcher (`edge-detector-wrapper.ts`) was removed in Phase D's\n * cutover. The new path is structurally simpler and decisive: one\n * engine, one verdict, every runtime.\n */\n\nimport { NextResponse } from 'next/server';\nimport type { NextRequest } from 'next/server';\n\nimport type { NextJSMiddlewareConfig } from './types';\n\nconst MIGRATION_ERROR =\n \"@kya-os/checkpoint-nextjs's `createAgentShieldMiddleware` / `agentShield` \" +\n 'were deleted in Phase D (engine consolidation). The 600-line TS pattern ' +\n 'matcher that backed them is gone. Migrate to `withCheckpoint` from ' +\n '`@kya-os/checkpoint-nextjs` (Node runtime) or ' +\n '`@kya-os/checkpoint-nextjs/edge` (Edge runtime). ' +\n 'See packages/checkpoint-nextjs/CHANGELOG.md (1.0.0) for the recipe.';\n\n/**\n * @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.\n * Throws on invocation; surface exists only so static analysis sees\n * the historical export.\n */\nexport function createAgentShieldMiddleware(\n _config: Partial<NextJSMiddlewareConfig> = {}\n): (request: NextRequest) => Promise<NextResponse> {\n throw new Error(MIGRATION_ERROR);\n}\n\n/**\n * @deprecated Alias of the deprecated `createAgentShieldMiddleware`.\n * Migrate to `withCheckpoint`.\n */\nexport function agentShield(\n config: Partial<NextJSMiddlewareConfig> = {}\n): (request: NextRequest) => Promise<NextResponse> {\n return createAgentShieldMiddleware(config);\n}\n\n/**\n * Pass-through export required by Next.js 16+ middleware file validation.\n * Next.js requires any file named `middleware.ts` to export a function named\n * `middleware` or a default function. This stub satisfies that constraint so\n * consumers that still reference the `./middleware` subpath can build.\n *\n * @deprecated Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs`.\n */\nexport function middleware(_request: NextRequest) {\n return NextResponse.next();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,kBACJ;;;;;;AAYF,SAAgB,4BACd,UAA2C,CAAC,GACK;CACjD,MAAM,IAAI,MAAM,eAAe;AACjC;;;;;AAMA,SAAgB,YACd,SAA0C,CAAC,GACM;CACjD,OAAO,4BAA4B,MAAM;AAC3C;;;;;;;;;AAUA,SAAgB,WAAW,UAAuB;CAChD,OAAO,aAAa,KAAK;AAC3B"}
@@ -1,42 +0,0 @@
1
- //#region src/nodejs-wasm-loader.d.ts
2
- /**
3
- * @deprecated Phase-D.9a — legacy Node.js WASM loader for the retired
4
- * `agentshield-wasm` Rust crate. This file used `fs.readFileSync` to
5
- * locate + load the legacy detector's WASM binary into the legacy
6
- * detection class. Both the WASM crate (Phase-D.9a/D.9b) and the
7
- * detection class (removed in AgentDetector-Deletion-2) are retired.
8
- *
9
- * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — it
10
- * loads the canonical `kya-os-engine` WASM automatically via
11
- * `@kya-os/checkpoint-wasm-runtime`'s loaders. No manual `fs.readFileSync`
12
- * needed; the runtime handles bundler resolution across Next.js Node +
13
- * Edge runtimes.
14
- */
15
- /** @internal — test-only reset for the one-shot warn latch. */
16
- export declare function __resetNodejsWasmWarningForTests(): void;
17
- /**
18
- * @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
19
- * `@kya-os/checkpoint-nextjs` — it auto-loads `kya-os-engine` WASM
20
- * via `@kya-os/checkpoint-wasm-runtime`. Throws on invocation; surface
21
- * exists only so static analysis sees the historical export.
22
- */
23
- export declare function loadWasmNodejs(): Promise<boolean>;
24
- /**
25
- * @deprecated Removed in Phase-D.9a. The runtime guard is no longer
26
- * needed; `@kya-os/checkpoint-wasm-runtime`'s loaders auto-detect
27
- * runtime via the `"node"` / `"edge-runtime"` export conditions.
28
- * Throws on invocation; surface exists only for export-compatibility.
29
- */
30
- export declare function isNodejsRuntime(): boolean;
31
- /**
32
- * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
33
- * Throws on invocation; surface exists only for export-compatibility.
34
- */
35
- export declare function getWasmModule(): WebAssembly.Module | null;
36
- /**
37
- * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
38
- * Throws on invocation; surface exists only for export-compatibility.
39
- */
40
- export declare function isWasmInitialized(): boolean;
41
- //#endregion
42
- //# sourceMappingURL=nodejs-wasm-loader.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodejs-wasm-loader.d.mts","names":[],"sources":["../src/nodejs-wasm-loader.ts"],"mappings":";;;;;;;;;;;;;;;wBAkCgB;;;;;;;wBAUM,kBAAkB;;;;;;;wBAWxB;;;;;wBASA,iBAAiB,YAAY;;;;;wBAS7B"}
@@ -1,42 +0,0 @@
1
- //#region src/nodejs-wasm-loader.d.ts
2
- /**
3
- * @deprecated Phase-D.9a — legacy Node.js WASM loader for the retired
4
- * `agentshield-wasm` Rust crate. This file used `fs.readFileSync` to
5
- * locate + load the legacy detector's WASM binary into the legacy
6
- * detection class. Both the WASM crate (Phase-D.9a/D.9b) and the
7
- * detection class (removed in AgentDetector-Deletion-2) are retired.
8
- *
9
- * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — it
10
- * loads the canonical `kya-os-engine` WASM automatically via
11
- * `@kya-os/checkpoint-wasm-runtime`'s loaders. No manual `fs.readFileSync`
12
- * needed; the runtime handles bundler resolution across Next.js Node +
13
- * Edge runtimes.
14
- */
15
- /** @internal — test-only reset for the one-shot warn latch. */
16
- export declare function __resetNodejsWasmWarningForTests(): void;
17
- /**
18
- * @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
19
- * `@kya-os/checkpoint-nextjs` — it auto-loads `kya-os-engine` WASM
20
- * via `@kya-os/checkpoint-wasm-runtime`. Throws on invocation; surface
21
- * exists only so static analysis sees the historical export.
22
- */
23
- export declare function loadWasmNodejs(): Promise<boolean>;
24
- /**
25
- * @deprecated Removed in Phase-D.9a. The runtime guard is no longer
26
- * needed; `@kya-os/checkpoint-wasm-runtime`'s loaders auto-detect
27
- * runtime via the `"node"` / `"edge-runtime"` export conditions.
28
- * Throws on invocation; surface exists only for export-compatibility.
29
- */
30
- export declare function isNodejsRuntime(): boolean;
31
- /**
32
- * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
33
- * Throws on invocation; surface exists only for export-compatibility.
34
- */
35
- export declare function getWasmModule(): WebAssembly.Module | null;
36
- /**
37
- * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
38
- * Throws on invocation; surface exists only for export-compatibility.
39
- */
40
- export declare function isWasmInitialized(): boolean;
41
- //#endregion
42
- //# sourceMappingURL=nodejs-wasm-loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodejs-wasm-loader.d.ts","names":[],"sources":["../src/nodejs-wasm-loader.ts"],"mappings":";;;;;;;;;;;;;;;wBAkCgB;;;;;;;wBAUM,kBAAkB;;;;;;;wBAWxB;;;;;wBASA,iBAAiB,YAAY;;;;;wBAS7B"}
@@ -1,70 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- //#region src/nodejs-wasm-loader.ts
3
- /**
4
- * @deprecated Phase-D.9a — legacy Node.js WASM loader for the retired
5
- * `agentshield-wasm` Rust crate. This file used `fs.readFileSync` to
6
- * locate + load the legacy detector's WASM binary into the legacy
7
- * detection class. Both the WASM crate (Phase-D.9a/D.9b) and the
8
- * detection class (removed in AgentDetector-Deletion-2) are retired.
9
- *
10
- * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — it
11
- * loads the canonical `kya-os-engine` WASM automatically via
12
- * `@kya-os/checkpoint-wasm-runtime`'s loaders. No manual `fs.readFileSync`
13
- * needed; the runtime handles bundler resolution across Next.js Node +
14
- * Edge runtimes.
15
- */
16
- const MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy detection class they fed was removed in AgentDetector-Deletion-2. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
17
- let _nodejsWasmWarned = false;
18
- function warnNodejsWasmDeprecated() {
19
- if (_nodejsWasmWarned) return;
20
- _nodejsWasmWarned = true;
21
- if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
22
- console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);
23
- }
24
- /** @internal — test-only reset for the one-shot warn latch. */
25
- function __resetNodejsWasmWarningForTests() {
26
- _nodejsWasmWarned = false;
27
- }
28
- /**
29
- * @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
30
- * `@kya-os/checkpoint-nextjs` — it auto-loads `kya-os-engine` WASM
31
- * via `@kya-os/checkpoint-wasm-runtime`. Throws on invocation; surface
32
- * exists only so static analysis sees the historical export.
33
- */
34
- async function loadWasmNodejs() {
35
- warnNodejsWasmDeprecated();
36
- throw new Error(MIGRATION_ERROR);
37
- }
38
- /**
39
- * @deprecated Removed in Phase-D.9a. The runtime guard is no longer
40
- * needed; `@kya-os/checkpoint-wasm-runtime`'s loaders auto-detect
41
- * runtime via the `"node"` / `"edge-runtime"` export conditions.
42
- * Throws on invocation; surface exists only for export-compatibility.
43
- */
44
- function isNodejsRuntime() {
45
- warnNodejsWasmDeprecated();
46
- throw new Error(MIGRATION_ERROR);
47
- }
48
- /**
49
- * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
50
- * Throws on invocation; surface exists only for export-compatibility.
51
- */
52
- function getWasmModule() {
53
- warnNodejsWasmDeprecated();
54
- throw new Error(MIGRATION_ERROR);
55
- }
56
- /**
57
- * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
58
- * Throws on invocation; surface exists only for export-compatibility.
59
- */
60
- function isWasmInitialized() {
61
- warnNodejsWasmDeprecated();
62
- throw new Error(MIGRATION_ERROR);
63
- }
64
-
65
- //#endregion
66
- exports.__resetNodejsWasmWarningForTests = __resetNodejsWasmWarningForTests;
67
- exports.getWasmModule = getWasmModule;
68
- exports.isNodejsRuntime = isNodejsRuntime;
69
- exports.isWasmInitialized = isWasmInitialized;
70
- exports.loadWasmNodejs = loadWasmNodejs;
@@ -1,66 +0,0 @@
1
- //#region src/nodejs-wasm-loader.ts
2
- /**
3
- * @deprecated Phase-D.9a — legacy Node.js WASM loader for the retired
4
- * `agentshield-wasm` Rust crate. This file used `fs.readFileSync` to
5
- * locate + load the legacy detector's WASM binary into the legacy
6
- * detection class. Both the WASM crate (Phase-D.9a/D.9b) and the
7
- * detection class (removed in AgentDetector-Deletion-2) are retired.
8
- *
9
- * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — it
10
- * loads the canonical `kya-os-engine` WASM automatically via
11
- * `@kya-os/checkpoint-wasm-runtime`'s loaders. No manual `fs.readFileSync`
12
- * needed; the runtime handles bundler resolution across Next.js Node +
13
- * Edge runtimes.
14
- */
15
- const MIGRATION_ERROR = "`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / `getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a (legacy `agentshield-wasm` Rust crate retirement). The legacy detection class they fed was removed in AgentDetector-Deletion-2. Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — engine-backed via the Rust `kya-os-engine` crate, with automatic WASM loading via `@kya-os/checkpoint-wasm-runtime`. See packages/checkpoint-nextjs/README.md for the canonical recipe.";
16
- let _nodejsWasmWarned = false;
17
- function warnNodejsWasmDeprecated() {
18
- if (_nodejsWasmWarned) return;
19
- _nodejsWasmWarned = true;
20
- if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
21
- console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);
22
- }
23
- /** @internal — test-only reset for the one-shot warn latch. */
24
- function __resetNodejsWasmWarningForTests() {
25
- _nodejsWasmWarned = false;
26
- }
27
- /**
28
- * @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
29
- * `@kya-os/checkpoint-nextjs` — it auto-loads `kya-os-engine` WASM
30
- * via `@kya-os/checkpoint-wasm-runtime`. Throws on invocation; surface
31
- * exists only so static analysis sees the historical export.
32
- */
33
- async function loadWasmNodejs() {
34
- warnNodejsWasmDeprecated();
35
- throw new Error(MIGRATION_ERROR);
36
- }
37
- /**
38
- * @deprecated Removed in Phase-D.9a. The runtime guard is no longer
39
- * needed; `@kya-os/checkpoint-wasm-runtime`'s loaders auto-detect
40
- * runtime via the `"node"` / `"edge-runtime"` export conditions.
41
- * Throws on invocation; surface exists only for export-compatibility.
42
- */
43
- function isNodejsRuntime() {
44
- warnNodejsWasmDeprecated();
45
- throw new Error(MIGRATION_ERROR);
46
- }
47
- /**
48
- * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
49
- * Throws on invocation; surface exists only for export-compatibility.
50
- */
51
- function getWasmModule() {
52
- warnNodejsWasmDeprecated();
53
- throw new Error(MIGRATION_ERROR);
54
- }
55
- /**
56
- * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
57
- * Throws on invocation; surface exists only for export-compatibility.
58
- */
59
- function isWasmInitialized() {
60
- warnNodejsWasmDeprecated();
61
- throw new Error(MIGRATION_ERROR);
62
- }
63
-
64
- //#endregion
65
- export { __resetNodejsWasmWarningForTests, getWasmModule, isNodejsRuntime, isWasmInitialized, loadWasmNodejs };
66
- //# sourceMappingURL=nodejs-wasm-loader.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodejs-wasm-loader.mjs","names":[],"sources":["../src/nodejs-wasm-loader.ts"],"sourcesContent":["/**\n * @deprecated Phase-D.9a — legacy Node.js WASM loader for the retired\n * `agentshield-wasm` Rust crate. This file used `fs.readFileSync` to\n * locate + load the legacy detector's WASM binary into the legacy\n * detection class. Both the WASM crate (Phase-D.9a/D.9b) and the\n * detection class (removed in AgentDetector-Deletion-2) are retired.\n *\n * Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — it\n * loads the canonical `kya-os-engine` WASM automatically via\n * `@kya-os/checkpoint-wasm-runtime`'s loaders. No manual `fs.readFileSync`\n * needed; the runtime handles bundler resolution across Next.js Node +\n * Edge runtimes.\n */\n\nconst MIGRATION_ERROR =\n \"`@kya-os/checkpoint-nextjs`'s `loadWasmNodejs` / `isNodejsRuntime` / \" +\n '`getWasmModule` / `isWasmInitialized` were deprecated in Phase-D.9a ' +\n '(legacy `agentshield-wasm` Rust crate retirement). The legacy ' +\n 'detection class they fed was removed in AgentDetector-Deletion-2. ' +\n 'Migrate to `withCheckpoint` from `@kya-os/checkpoint-nextjs` — ' +\n 'engine-backed via the Rust `kya-os-engine` crate, with automatic ' +\n 'WASM loading via `@kya-os/checkpoint-wasm-runtime`. See ' +\n 'packages/checkpoint-nextjs/README.md for the canonical recipe.';\n\n// One-shot dev-only deprecation warning. Suppressed in production.\nlet _nodejsWasmWarned = false;\nfunction warnNodejsWasmDeprecated(): void {\n if (_nodejsWasmWarned) return;\n _nodejsWasmWarned = true;\n if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'production') return;\n console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);\n}\n\n/** @internal — test-only reset for the one-shot warn latch. */\nexport function __resetNodejsWasmWarningForTests(): void {\n _nodejsWasmWarned = false;\n}\n\n/**\n * @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from\n * `@kya-os/checkpoint-nextjs` — it auto-loads `kya-os-engine` WASM\n * via `@kya-os/checkpoint-wasm-runtime`. Throws on invocation; surface\n * exists only so static analysis sees the historical export.\n */\nexport async function loadWasmNodejs(): Promise<boolean> {\n warnNodejsWasmDeprecated();\n throw new Error(MIGRATION_ERROR);\n}\n\n/**\n * @deprecated Removed in Phase-D.9a. The runtime guard is no longer\n * needed; `@kya-os/checkpoint-wasm-runtime`'s loaders auto-detect\n * runtime via the `\"node\"` / `\"edge-runtime\"` export conditions.\n * Throws on invocation; surface exists only for export-compatibility.\n */\nexport function isNodejsRuntime(): boolean {\n warnNodejsWasmDeprecated();\n throw new Error(MIGRATION_ERROR);\n}\n\n/**\n * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.\n * Throws on invocation; surface exists only for export-compatibility.\n */\nexport function getWasmModule(): WebAssembly.Module | null {\n warnNodejsWasmDeprecated();\n throw new Error(MIGRATION_ERROR);\n}\n\n/**\n * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.\n * Throws on invocation; surface exists only for export-compatibility.\n */\nexport function isWasmInitialized(): boolean {\n warnNodejsWasmDeprecated();\n throw new Error(MIGRATION_ERROR);\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,kBACJ;AAUF,IAAI,oBAAoB;AACxB,SAAS,2BAAiC;CACxC,IAAI,mBAAmB;CACvB,oBAAoB;CACpB,IAAI,OAAO,YAAY,eAAe,QAAQ,KAAK,aAAa,cAAc;CAC9E,QAAQ,KAAK,gBAAgB,iBAAiB;AAChD;;AAGA,SAAgB,mCAAyC;CACvD,oBAAoB;AACtB;;;;;;;AAQA,eAAsB,iBAAmC;CACvD,yBAAyB;CACzB,MAAM,IAAI,MAAM,eAAe;AACjC;;;;;;;AAQA,SAAgB,kBAA2B;CACzC,yBAAyB;CACzB,MAAM,IAAI,MAAM,eAAe;AACjC;;;;;AAMA,SAAgB,gBAA2C;CACzD,yBAAyB;CACzB,MAAM,IAAI,MAAM,eAAe;AACjC;;;;;AAMA,SAAgB,oBAA6B;CAC3C,yBAAyB;CACzB,MAAM,IAAI,MAAM,eAAe;AACjC"}
package/dist/policy.d.mts DELETED
@@ -1,138 +0,0 @@
1
- import { DEFAULT_POLICY, DetectionResult, ENFORCEMENT_ACTIONS, PolicyConfig, PolicyConfig as PolicyConfig$1, PolicyEvaluationContext, PolicyEvaluationContext as PolicyEvaluationContext$1, PolicyEvaluationResult, PolicyEvaluationResult as PolicyEvaluationResult$1, createEvaluationContext, evaluatePolicy } from "@kya-os/checkpoint-shared";
2
- import { NextRequest, NextResponse } from "next/server";
3
- //#region src/policy.d.ts
4
- /**
5
- * Policy middleware configuration
6
- */
7
- export interface PolicyMiddlewareConfig {
8
- /**
9
- * Local policy configuration (static)
10
- * If provided, this policy is used instead of fetching from API
11
- */
12
- policy?: Partial<PolicyConfig$1>;
13
- /**
14
- * Fetch policy from AgentShield API
15
- * Requires projectId and optionally an apiKey
16
- */
17
- fetchPolicy?: {
18
- /** Project ID to fetch policy for */
19
- projectId: string;
20
- /** API base URL (defaults to production) */
21
- apiUrl?: string;
22
- /** API key for authentication */
23
- apiKey?: string;
24
- /** Cache TTL in seconds (default: 300) */
25
- cacheTtlSeconds?: number;
26
- };
27
- /**
28
- * Fallback policy to use when fetch fails
29
- * Defaults to DEFAULT_POLICY (allow all)
30
- */
31
- fallbackPolicy?: Partial<PolicyConfig$1>;
32
- /**
33
- * Custom blocked response
34
- */
35
- blockedResponse?: {
36
- status?: number;
37
- message?: string;
38
- headers?: Record<string, string>;
39
- };
40
- /**
41
- * Default redirect URL for redirect actions
42
- */
43
- redirectUrl?: string;
44
- /**
45
- * Callback when policy decision is made
46
- */
47
- onPolicyDecision?: (request: NextRequest, decision: PolicyEvaluationResult$1, context: PolicyEvaluationContext$1) => void | Promise<void>;
48
- /**
49
- * Custom response builder for blocked requests
50
- */
51
- customBlockedResponse?: (request: NextRequest, decision: PolicyEvaluationResult$1) => NextResponse | Promise<NextResponse>;
52
- /**
53
- * Whether to fail open (allow) on policy evaluation errors
54
- * Default: true (recommended for production)
55
- */
56
- failOpen?: boolean;
57
- /**
58
- * Enable debug logging
59
- */
60
- debug?: boolean;
61
- }
62
- /**
63
- * Combined middleware configuration with policy support
64
- */
65
- export interface NextJSPolicyMiddlewareConfig extends PolicyMiddlewareConfig {
66
- /**
67
- * Paths to skip (in addition to policy excludedPaths)
68
- */
69
- skipPaths?: string[];
70
- /**
71
- * Only enforce on these paths (overrides policy includedPaths)
72
- */
73
- includePaths?: string[];
74
- }
75
- /**
76
- * Create policy evaluation context from detection result and request
77
- */
78
- export declare function createContextFromDetection(detection: DetectionResult, request: NextRequest): PolicyEvaluationContext$1;
79
- /**
80
- * Evaluate policy for a detection result
81
- */
82
- export declare function evaluatePolicyForDetection(detection: DetectionResult, request: NextRequest, policy: PolicyConfig$1): PolicyEvaluationResult$1;
83
- /**
84
- * Build blocked response based on policy decision
85
- */
86
- export declare function buildBlockedResponse(decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig): NextResponse;
87
- /**
88
- * Build redirect response based on policy decision
89
- */
90
- export declare function buildRedirectResponse(request: NextRequest, decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig, detection?: {
91
- detectedAgent?: {
92
- name?: string;
93
- };
94
- }): NextResponse;
95
- /**
96
- * Build challenge response (placeholder - future implementation)
97
- */
98
- export declare function buildChallengeResponse(request: NextRequest, decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig, detection?: {
99
- detectedAgent?: {
100
- name?: string;
101
- };
102
- }): NextResponse;
103
- /**
104
- * Handle policy decision and return appropriate response
105
- */
106
- export declare function handlePolicyDecision(request: NextRequest, decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig, detection?: {
107
- detectedAgent?: {
108
- name?: string;
109
- };
110
- }): Promise<NextResponse | null>;
111
- /**
112
- * Get policy (local, fetched, or fallback)
113
- */
114
- export declare function getPolicy(config: PolicyMiddlewareConfig): Promise<PolicyConfig$1>;
115
- /**
116
- * Apply policy to a detection result
117
- *
118
- * This function can be used standalone to evaluate policy after detection.
119
- * Supports extended config with skipPaths and includePaths for path-based filtering.
120
- *
121
- * @example
122
- * ```typescript
123
- * const result = await detector.analyze(context);
124
- * const response = await applyPolicy(request, result, {
125
- * policy: { thresholds: { confidenceThreshold: 80 } },
126
- * skipPaths: ['/health', '/api/public/*'],
127
- * includePaths: ['/api/*'],
128
- * });
129
- *
130
- * if (response) {
131
- * return response; // Policy blocked the request
132
- * }
133
- * ```
134
- */
135
- export declare function applyPolicy(request: NextRequest, detection: DetectionResult, config: NextJSPolicyMiddlewareConfig): Promise<NextResponse | null>;
136
- //#endregion
137
- export { DEFAULT_POLICY, ENFORCEMENT_ACTIONS, type PolicyConfig, type PolicyEvaluationContext, type PolicyEvaluationResult, createEvaluationContext, evaluatePolicy };
138
- //# sourceMappingURL=policy.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"policy.d.mts","names":[],"sources":["../src/policy.ts"],"mappings":";;;;;;iBA2DiB;;;;;EAKf,SAAS,QAAQ;;;;;EAMjB;;IAEE;;IAEA;;IAEA;;IAEA;;;;;;EAOF,iBAAiB,QAAQ;;;;EAKzB;IACE;IACA;IACA,UAAU;;;;;EAMZ;;;;EAKA,oBACE,SAAS,aACT,UAAU,0BACV,SAAS,qCACC;;;;EAKZ,yBACE,SAAS,aACT,UAAU,6BACP,eAAe,QAAQ;;;;;EAM5B;;;;EAKA;;;;;iBAMe,qCAAqC;;;;EAIpD;;;;EAKA;;;;;wBAUc,2BACd,WAAW,iBACX,SAAS,cACR;;;;wBA8Ba,2BACd,WAAW,iBACX,SAAS,aACT,QAAQ,iBACP;;;;wBAYa,qBACd,UAAU,0BACV,QAAQ,yBACP;;;;wBAiCa,sBACd,SAAS,aACT,UAAU,0BACV,QAAQ,wBACR;EAAc;IAAkB;;IAC/B;;;;wBAoBa,uBACd,SAAS,aACT,UAAU,0BACV,QAAQ,wBACR;EAAc;IAAkB;;IAC/B;;;;wBAWmB,qBACpB,SAAS,aACT,UAAU,0BACV,QAAQ,wBACR;EAAc;IAAkB;;IAC/B,QAAQ;;;;wBA2EW,UAAU,QAAQ,yBAAyB,QAAQ;;;;;;;;;;;;;;;;;;;;;wBAmDnD,YACpB,SAAS,aACT,WAAW,iBACX,QAAQ,+BACP,QAAQ"}
package/dist/policy.d.ts DELETED
@@ -1,138 +0,0 @@
1
- import { NextRequest, NextResponse } from "next/server";
2
- import { DEFAULT_POLICY, DetectionResult, ENFORCEMENT_ACTIONS, PolicyConfig, PolicyConfig as PolicyConfig$1, PolicyEvaluationContext, PolicyEvaluationContext as PolicyEvaluationContext$1, PolicyEvaluationResult, PolicyEvaluationResult as PolicyEvaluationResult$1, createEvaluationContext, evaluatePolicy } from "@kya-os/checkpoint-shared";
3
- //#region src/policy.d.ts
4
- /**
5
- * Policy middleware configuration
6
- */
7
- export interface PolicyMiddlewareConfig {
8
- /**
9
- * Local policy configuration (static)
10
- * If provided, this policy is used instead of fetching from API
11
- */
12
- policy?: Partial<PolicyConfig$1>;
13
- /**
14
- * Fetch policy from AgentShield API
15
- * Requires projectId and optionally an apiKey
16
- */
17
- fetchPolicy?: {
18
- /** Project ID to fetch policy for */
19
- projectId: string;
20
- /** API base URL (defaults to production) */
21
- apiUrl?: string;
22
- /** API key for authentication */
23
- apiKey?: string;
24
- /** Cache TTL in seconds (default: 300) */
25
- cacheTtlSeconds?: number;
26
- };
27
- /**
28
- * Fallback policy to use when fetch fails
29
- * Defaults to DEFAULT_POLICY (allow all)
30
- */
31
- fallbackPolicy?: Partial<PolicyConfig$1>;
32
- /**
33
- * Custom blocked response
34
- */
35
- blockedResponse?: {
36
- status?: number;
37
- message?: string;
38
- headers?: Record<string, string>;
39
- };
40
- /**
41
- * Default redirect URL for redirect actions
42
- */
43
- redirectUrl?: string;
44
- /**
45
- * Callback when policy decision is made
46
- */
47
- onPolicyDecision?: (request: NextRequest, decision: PolicyEvaluationResult$1, context: PolicyEvaluationContext$1) => void | Promise<void>;
48
- /**
49
- * Custom response builder for blocked requests
50
- */
51
- customBlockedResponse?: (request: NextRequest, decision: PolicyEvaluationResult$1) => NextResponse | Promise<NextResponse>;
52
- /**
53
- * Whether to fail open (allow) on policy evaluation errors
54
- * Default: true (recommended for production)
55
- */
56
- failOpen?: boolean;
57
- /**
58
- * Enable debug logging
59
- */
60
- debug?: boolean;
61
- }
62
- /**
63
- * Combined middleware configuration with policy support
64
- */
65
- export interface NextJSPolicyMiddlewareConfig extends PolicyMiddlewareConfig {
66
- /**
67
- * Paths to skip (in addition to policy excludedPaths)
68
- */
69
- skipPaths?: string[];
70
- /**
71
- * Only enforce on these paths (overrides policy includedPaths)
72
- */
73
- includePaths?: string[];
74
- }
75
- /**
76
- * Create policy evaluation context from detection result and request
77
- */
78
- export declare function createContextFromDetection(detection: DetectionResult, request: NextRequest): PolicyEvaluationContext$1;
79
- /**
80
- * Evaluate policy for a detection result
81
- */
82
- export declare function evaluatePolicyForDetection(detection: DetectionResult, request: NextRequest, policy: PolicyConfig$1): PolicyEvaluationResult$1;
83
- /**
84
- * Build blocked response based on policy decision
85
- */
86
- export declare function buildBlockedResponse(decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig): NextResponse;
87
- /**
88
- * Build redirect response based on policy decision
89
- */
90
- export declare function buildRedirectResponse(request: NextRequest, decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig, detection?: {
91
- detectedAgent?: {
92
- name?: string;
93
- };
94
- }): NextResponse;
95
- /**
96
- * Build challenge response (placeholder - future implementation)
97
- */
98
- export declare function buildChallengeResponse(request: NextRequest, decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig, detection?: {
99
- detectedAgent?: {
100
- name?: string;
101
- };
102
- }): NextResponse;
103
- /**
104
- * Handle policy decision and return appropriate response
105
- */
106
- export declare function handlePolicyDecision(request: NextRequest, decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig, detection?: {
107
- detectedAgent?: {
108
- name?: string;
109
- };
110
- }): Promise<NextResponse | null>;
111
- /**
112
- * Get policy (local, fetched, or fallback)
113
- */
114
- export declare function getPolicy(config: PolicyMiddlewareConfig): Promise<PolicyConfig$1>;
115
- /**
116
- * Apply policy to a detection result
117
- *
118
- * This function can be used standalone to evaluate policy after detection.
119
- * Supports extended config with skipPaths and includePaths for path-based filtering.
120
- *
121
- * @example
122
- * ```typescript
123
- * const result = await detector.analyze(context);
124
- * const response = await applyPolicy(request, result, {
125
- * policy: { thresholds: { confidenceThreshold: 80 } },
126
- * skipPaths: ['/health', '/api/public/*'],
127
- * includePaths: ['/api/*'],
128
- * });
129
- *
130
- * if (response) {
131
- * return response; // Policy blocked the request
132
- * }
133
- * ```
134
- */
135
- export declare function applyPolicy(request: NextRequest, detection: DetectionResult, config: NextJSPolicyMiddlewareConfig): Promise<NextResponse | null>;
136
- //#endregion
137
- export { DEFAULT_POLICY, ENFORCEMENT_ACTIONS, type PolicyConfig, type PolicyEvaluationContext, type PolicyEvaluationResult, createEvaluationContext, evaluatePolicy };
138
- //# sourceMappingURL=policy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"policy.d.ts","names":[],"sources":["../src/policy.ts"],"mappings":";;;;;;iBA2DiB;;;;;EAKf,SAAS,QAAQ;;;;;EAMjB;;IAEE;;IAEA;;IAEA;;IAEA;;;;;;EAOF,iBAAiB,QAAQ;;;;EAKzB;IACE;IACA;IACA,UAAU;;;;;EAMZ;;;;EAKA,oBACE,SAAS,aACT,UAAU,0BACV,SAAS,qCACC;;;;EAKZ,yBACE,SAAS,aACT,UAAU,6BACP,eAAe,QAAQ;;;;;EAM5B;;;;EAKA;;;;;iBAMe,qCAAqC;;;;EAIpD;;;;EAKA;;;;;wBAUc,2BACd,WAAW,iBACX,SAAS,cACR;;;;wBA8Ba,2BACd,WAAW,iBACX,SAAS,aACT,QAAQ,iBACP;;;;wBAYa,qBACd,UAAU,0BACV,QAAQ,yBACP;;;;wBAiCa,sBACd,SAAS,aACT,UAAU,0BACV,QAAQ,wBACR;EAAc;IAAkB;;IAC/B;;;;wBAoBa,uBACd,SAAS,aACT,UAAU,0BACV,QAAQ,wBACR;EAAc;IAAkB;;IAC/B;;;;wBAWmB,qBACpB,SAAS,aACT,UAAU,0BACV,QAAQ,wBACR;EAAc;IAAkB;;IAC/B,QAAQ;;;;wBA2EW,UAAU,QAAQ,yBAAyB,QAAQ;;;;;;;;;;;;;;;;;;;;;wBAmDnD,YACpB,SAAS,aACT,WAAW,iBACX,QAAQ,+BACP,QAAQ"}