@kya-os/checkpoint-nextjs 1.9.0 → 1.10.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 (153) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/dist/adapt.d.mts +6 -34
  3. package/dist/adapt.d.mts.map +1 -0
  4. package/dist/adapt.d.ts +6 -34
  5. package/dist/adapt.d.ts.map +1 -0
  6. package/dist/adapt.js +78 -51
  7. package/dist/adapt.mjs +77 -48
  8. package/dist/adapt.mjs.map +1 -0
  9. package/dist/api-client.d.mts +150 -159
  10. package/dist/api-client.d.mts.map +1 -0
  11. package/dist/api-client.d.ts +150 -159
  12. package/dist/api-client.d.ts.map +1 -0
  13. package/dist/api-client.js +218 -204
  14. package/dist/api-client.mjs +217 -201
  15. package/dist/api-client.mjs.map +1 -0
  16. package/dist/api-middleware-CDSh3TSE.js +379 -0
  17. package/dist/api-middleware-CMDRoQik.mjs +357 -0
  18. package/dist/api-middleware-CMDRoQik.mjs.map +1 -0
  19. package/dist/api-middleware.d.mts +117 -131
  20. package/dist/api-middleware.d.mts.map +1 -0
  21. package/dist/api-middleware.d.ts +117 -131
  22. package/dist/api-middleware.d.ts.map +1 -0
  23. package/dist/api-middleware.js +8 -527
  24. package/dist/api-middleware.mjs +3 -521
  25. package/dist/composed-policy-BCaNiVHv.d.mts +98 -0
  26. package/dist/composed-policy-BCaNiVHv.d.mts.map +1 -0
  27. package/dist/composed-policy-zzJYNFTb.d.ts +98 -0
  28. package/dist/composed-policy-zzJYNFTb.d.ts.map +1 -0
  29. package/dist/composed-policy.d.mts +2 -115
  30. package/dist/composed-policy.d.ts +2 -115
  31. package/dist/composed-policy.js +122 -89
  32. package/dist/composed-policy.mjs +121 -86
  33. package/dist/composed-policy.mjs.map +1 -0
  34. package/dist/config-CbAg2mze.d.ts +255 -0
  35. package/dist/config-CbAg2mze.d.ts.map +1 -0
  36. package/dist/config-Doe0Tn53.d.mts +255 -0
  37. package/dist/config-Doe0Tn53.d.mts.map +1 -0
  38. package/dist/create-middleware.d.mts +7 -18
  39. package/dist/create-middleware.d.mts.map +1 -0
  40. package/dist/create-middleware.d.ts +7 -18
  41. package/dist/create-middleware.d.ts.map +1 -0
  42. package/dist/create-middleware.js +36 -31
  43. package/dist/create-middleware.mjs +35 -28
  44. package/dist/create-middleware.mjs.map +1 -0
  45. package/dist/edge/index.d.mts +64 -88
  46. package/dist/edge/index.d.mts.map +1 -0
  47. package/dist/edge/index.d.ts +64 -88
  48. package/dist/edge/index.d.ts.map +1 -0
  49. package/dist/edge/index.js +349 -264
  50. package/dist/edge/index.mjs +348 -261
  51. package/dist/edge/index.mjs.map +1 -0
  52. package/dist/edge-runtime-loader.d.mts +37 -65
  53. package/dist/edge-runtime-loader.d.mts.map +1 -0
  54. package/dist/edge-runtime-loader.d.ts +37 -65
  55. package/dist/edge-runtime-loader.d.ts.map +1 -0
  56. package/dist/edge-runtime-loader.js +268 -213
  57. package/dist/edge-runtime-loader.mjs +267 -210
  58. package/dist/edge-runtime-loader.mjs.map +1 -0
  59. package/dist/edge-wasm-middleware.d.mts +27 -46
  60. package/dist/edge-wasm-middleware.d.mts.map +1 -0
  61. package/dist/edge-wasm-middleware.d.ts +27 -46
  62. package/dist/edge-wasm-middleware.d.ts.map +1 -0
  63. package/dist/edge-wasm-middleware.js +26 -15
  64. package/dist/edge-wasm-middleware.mjs +25 -12
  65. package/dist/edge-wasm-middleware.mjs.map +1 -0
  66. package/dist/index.d.mts +10 -17
  67. package/dist/index.d.ts +10 -17
  68. package/dist/index.js +55 -1265
  69. package/dist/index.mjs +16 -1234
  70. package/dist/index.mjs.map +1 -0
  71. package/dist/middleware-bundler.d.mts +6 -12
  72. package/dist/middleware-bundler.d.mts.map +1 -0
  73. package/dist/middleware-bundler.d.ts +6 -12
  74. package/dist/middleware-bundler.d.ts.map +1 -0
  75. package/dist/middleware-bundler.js +12 -350
  76. package/dist/middleware-bundler.mjs +11 -347
  77. package/dist/middleware-bundler.mjs.map +1 -0
  78. package/dist/middleware-core-BYQP9FND.mjs +165 -0
  79. package/dist/middleware-core-BYQP9FND.mjs.map +1 -0
  80. package/dist/middleware-core-D6TijE6P.js +175 -0
  81. package/dist/middleware-edge.d.mts +8 -14
  82. package/dist/middleware-edge.d.mts.map +1 -0
  83. package/dist/middleware-edge.d.ts +8 -14
  84. package/dist/middleware-edge.d.ts.map +1 -0
  85. package/dist/middleware-edge.js +41 -355
  86. package/dist/middleware-edge.mjs +39 -347
  87. package/dist/middleware-edge.mjs.map +1 -0
  88. package/dist/middleware-node-CE4GevYs.d.ts +20 -0
  89. package/dist/middleware-node-CE4GevYs.d.ts.map +1 -0
  90. package/dist/middleware-node-DtyOuPta.d.mts +20 -0
  91. package/dist/middleware-node-DtyOuPta.d.mts.map +1 -0
  92. package/dist/middleware-node-context-BqPbf-fI.mjs +34 -0
  93. package/dist/middleware-node-context-BqPbf-fI.mjs.map +1 -0
  94. package/dist/middleware-node-context-rgnc7UNR.js +38 -0
  95. package/dist/middleware-node.d.mts +3 -27
  96. package/dist/middleware-node.d.ts +3 -27
  97. package/dist/middleware-node.js +13 -351
  98. package/dist/middleware-node.mjs +11 -347
  99. package/dist/middleware-node.mjs.map +1 -0
  100. package/dist/middleware.d.mts +8 -28
  101. package/dist/middleware.d.mts.map +1 -0
  102. package/dist/middleware.d.ts +8 -28
  103. package/dist/middleware.d.ts.map +1 -0
  104. package/dist/middleware.js +43 -9
  105. package/dist/middleware.mjs +42 -6
  106. package/dist/middleware.mjs.map +1 -0
  107. package/dist/nodejs-wasm-loader.d.mts +8 -7
  108. package/dist/nodejs-wasm-loader.d.mts.map +1 -0
  109. package/dist/nodejs-wasm-loader.d.ts +8 -7
  110. package/dist/nodejs-wasm-loader.d.ts.map +1 -0
  111. package/dist/nodejs-wasm-loader.js +53 -19
  112. package/dist/nodejs-wasm-loader.mjs +52 -16
  113. package/dist/nodejs-wasm-loader.mjs.map +1 -0
  114. package/dist/policy.d.mts +86 -110
  115. package/dist/policy.d.mts.map +1 -0
  116. package/dist/policy.d.ts +86 -110
  117. package/dist/policy.d.ts.map +1 -0
  118. package/dist/policy.js +203 -165
  119. package/dist/policy.mjs +183 -152
  120. package/dist/policy.mjs.map +1 -0
  121. package/dist/session-tracker.d.mts +42 -47
  122. package/dist/session-tracker.d.mts.map +1 -0
  123. package/dist/session-tracker.d.ts +42 -47
  124. package/dist/session-tracker.d.ts.map +1 -0
  125. package/dist/session-tracker.js +141 -165
  126. package/dist/session-tracker.mjs +140 -162
  127. package/dist/session-tracker.mjs.map +1 -0
  128. package/dist/translate.d.mts +17 -32
  129. package/dist/translate.d.mts.map +1 -0
  130. package/dist/translate.d.ts +17 -32
  131. package/dist/translate.d.ts.map +1 -0
  132. package/dist/translate.js +69 -34
  133. package/dist/translate.mjs +68 -31
  134. package/dist/translate.mjs.map +1 -0
  135. package/dist/types-C0SkqLMM.d.mts +102 -0
  136. package/dist/types-C0SkqLMM.d.mts.map +1 -0
  137. package/dist/types-C7DNSCTO.d.ts +102 -0
  138. package/dist/types-C7DNSCTO.d.ts.map +1 -0
  139. package/dist/utils-Cj4XNhIY.mjs +35 -0
  140. package/dist/utils-Cj4XNhIY.mjs.map +1 -0
  141. package/dist/utils-DAisnYnI.js +45 -0
  142. package/dist/wasm-setup.d.mts +6 -5
  143. package/dist/wasm-setup.d.mts.map +1 -0
  144. package/dist/wasm-setup.d.ts +6 -5
  145. package/dist/wasm-setup.d.ts.map +1 -0
  146. package/dist/wasm-setup.js +82 -113
  147. package/dist/wasm-setup.mjs +85 -108
  148. package/dist/wasm-setup.mjs.map +1 -0
  149. package/package.json +8 -8
  150. package/dist/config-CleTeeoW.d.mts +0 -233
  151. package/dist/config-XMOIkxFN.d.ts +0 -233
  152. package/dist/types-Chgi5TFC.d.mts +0 -105
  153. package/dist/types-Chgi5TFC.d.ts +0 -105
@@ -1,3 +1,4 @@
1
+ //#region src/nodejs-wasm-loader.d.ts
1
2
  /**
2
3
  * @deprecated Phase-D.9a — legacy Node.js WASM loader for the retired
3
4
  * `agentshield-wasm` Rust crate. This file used `fs.readFileSync` to
@@ -12,30 +13,30 @@
12
13
  * Edge runtimes.
13
14
  */
14
15
  /** @internal — test-only reset for the one-shot warn latch. */
15
- declare function __resetNodejsWasmWarningForTests(): void;
16
+ export declare function __resetNodejsWasmWarningForTests(): void;
16
17
  /**
17
18
  * @deprecated Removed in Phase-D.9a. Use `withCheckpoint` from
18
19
  * `@kya-os/checkpoint-nextjs` — it auto-loads `kya-os-engine` WASM
19
20
  * via `@kya-os/checkpoint-wasm-runtime`. Throws on invocation; surface
20
21
  * exists only so static analysis sees the historical export.
21
22
  */
22
- declare function loadWasmNodejs(): Promise<boolean>;
23
+ export declare function loadWasmNodejs(): Promise<boolean>;
23
24
  /**
24
25
  * @deprecated Removed in Phase-D.9a. The runtime guard is no longer
25
26
  * needed; `@kya-os/checkpoint-wasm-runtime`'s loaders auto-detect
26
27
  * runtime via the `"node"` / `"edge-runtime"` export conditions.
27
28
  * Throws on invocation; surface exists only for export-compatibility.
28
29
  */
29
- declare function isNodejsRuntime(): boolean;
30
+ export declare function isNodejsRuntime(): boolean;
30
31
  /**
31
32
  * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
32
33
  * Throws on invocation; surface exists only for export-compatibility.
33
34
  */
34
- declare function getWasmModule(): WebAssembly.Module | null;
35
+ export declare function getWasmModule(): WebAssembly.Module | null;
35
36
  /**
36
37
  * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
37
38
  * Throws on invocation; surface exists only for export-compatibility.
38
39
  */
39
- declare function isWasmInitialized(): boolean;
40
-
41
- export { __resetNodejsWasmWarningForTests, getWasmModule, isNodejsRuntime, isWasmInitialized, loadWasmNodejs };
40
+ export declare function isWasmInitialized(): boolean;
41
+ //#endregion
42
+ //# sourceMappingURL=nodejs-wasm-loader.d.ts.map
@@ -0,0 +1 @@
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,36 +1,70 @@
1
- 'use strict';
2
-
3
- // src/nodejs-wasm-loader.ts
4
- var 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` \u2014 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.";
5
- var _nodejsWasmWarned = false;
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;
6
18
  function warnNodejsWasmDeprecated() {
7
- if (_nodejsWasmWarned) return;
8
- _nodejsWasmWarned = true;
9
- if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
10
- console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);
19
+ if (_nodejsWasmWarned) return;
20
+ _nodejsWasmWarned = true;
21
+ if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
22
+ console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);
11
23
  }
24
+ /** @internal — test-only reset for the one-shot warn latch. */
12
25
  function __resetNodejsWasmWarningForTests() {
13
- _nodejsWasmWarned = false;
26
+ _nodejsWasmWarned = false;
14
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
+ */
15
34
  async function loadWasmNodejs() {
16
- warnNodejsWasmDeprecated();
17
- throw new Error(MIGRATION_ERROR);
35
+ warnNodejsWasmDeprecated();
36
+ throw new Error(MIGRATION_ERROR);
18
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
+ */
19
44
  function isNodejsRuntime() {
20
- warnNodejsWasmDeprecated();
21
- throw new Error(MIGRATION_ERROR);
45
+ warnNodejsWasmDeprecated();
46
+ throw new Error(MIGRATION_ERROR);
22
47
  }
48
+ /**
49
+ * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
50
+ * Throws on invocation; surface exists only for export-compatibility.
51
+ */
23
52
  function getWasmModule() {
24
- warnNodejsWasmDeprecated();
25
- throw new Error(MIGRATION_ERROR);
53
+ warnNodejsWasmDeprecated();
54
+ throw new Error(MIGRATION_ERROR);
26
55
  }
56
+ /**
57
+ * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
58
+ * Throws on invocation; surface exists only for export-compatibility.
59
+ */
27
60
  function isWasmInitialized() {
28
- warnNodejsWasmDeprecated();
29
- throw new Error(MIGRATION_ERROR);
61
+ warnNodejsWasmDeprecated();
62
+ throw new Error(MIGRATION_ERROR);
30
63
  }
31
64
 
65
+ //#endregion
32
66
  exports.__resetNodejsWasmWarningForTests = __resetNodejsWasmWarningForTests;
33
67
  exports.getWasmModule = getWasmModule;
34
68
  exports.isNodejsRuntime = isNodejsRuntime;
35
69
  exports.isWasmInitialized = isWasmInitialized;
36
- exports.loadWasmNodejs = loadWasmNodejs;
70
+ exports.loadWasmNodejs = loadWasmNodejs;
@@ -1,30 +1,66 @@
1
- // src/nodejs-wasm-loader.ts
2
- var 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` \u2014 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.";
3
- var _nodejsWasmWarned = false;
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;
4
17
  function warnNodejsWasmDeprecated() {
5
- if (_nodejsWasmWarned) return;
6
- _nodejsWasmWarned = true;
7
- if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
8
- console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);
18
+ if (_nodejsWasmWarned) return;
19
+ _nodejsWasmWarned = true;
20
+ if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
21
+ console.warn(`[Checkpoint] ${MIGRATION_ERROR}`);
9
22
  }
23
+ /** @internal — test-only reset for the one-shot warn latch. */
10
24
  function __resetNodejsWasmWarningForTests() {
11
- _nodejsWasmWarned = false;
25
+ _nodejsWasmWarned = false;
12
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
+ */
13
33
  async function loadWasmNodejs() {
14
- warnNodejsWasmDeprecated();
15
- throw new Error(MIGRATION_ERROR);
34
+ warnNodejsWasmDeprecated();
35
+ throw new Error(MIGRATION_ERROR);
16
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
+ */
17
43
  function isNodejsRuntime() {
18
- warnNodejsWasmDeprecated();
19
- throw new Error(MIGRATION_ERROR);
44
+ warnNodejsWasmDeprecated();
45
+ throw new Error(MIGRATION_ERROR);
20
46
  }
47
+ /**
48
+ * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
49
+ * Throws on invocation; surface exists only for export-compatibility.
50
+ */
21
51
  function getWasmModule() {
22
- warnNodejsWasmDeprecated();
23
- throw new Error(MIGRATION_ERROR);
52
+ warnNodejsWasmDeprecated();
53
+ throw new Error(MIGRATION_ERROR);
24
54
  }
55
+ /**
56
+ * @deprecated Removed in Phase-D.9a. Migrate to `withCheckpoint`.
57
+ * Throws on invocation; surface exists only for export-compatibility.
58
+ */
25
59
  function isWasmInitialized() {
26
- warnNodejsWasmDeprecated();
27
- throw new Error(MIGRATION_ERROR);
60
+ warnNodejsWasmDeprecated();
61
+ throw new Error(MIGRATION_ERROR);
28
62
  }
29
63
 
64
+ //#endregion
30
65
  export { __resetNodejsWasmWarningForTests, getWasmModule, isNodejsRuntime, isWasmInitialized, loadWasmNodejs };
66
+ //# sourceMappingURL=nodejs-wasm-loader.mjs.map
@@ -0,0 +1 @@
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 CHANGED
@@ -1,142 +1,117 @@
1
- import { NextRequest, NextResponse } from 'next/server';
2
- import { PolicyConfig, PolicyEvaluationResult, PolicyEvaluationContext, DetectionResult } from '@kya-os/checkpoint-shared';
3
- export { DEFAULT_POLICY, ENFORCEMENT_ACTIONS, PolicyConfig, PolicyEvaluationContext, PolicyEvaluationResult, createEvaluationContext, evaluatePolicy } from '@kya-os/checkpoint-shared';
4
-
5
- /**
6
- * Policy Integration for agentshield-nextjs
7
- *
8
- * This module provides policy evaluation support for the Next.js middleware.
9
- * It can use:
10
- * - Local policy configuration (static)
11
- * - Fetched policy from AgentShield API (dynamic with caching)
12
- * - Fallback/default policies
13
- *
14
- * @example
15
- * ```typescript
16
- * import { createPolicyMiddleware } from '@kya-os/checkpoint-nextjs/policy';
17
- *
18
- * export default createPolicyMiddleware({
19
- * policy: {
20
- * enabled: true,
21
- * defaultAction: 'allow',
22
- * thresholds: { confidenceThreshold: 80, confidenceAction: 'block' },
23
- * allowList: [{ clientName: 'ChatGPT' }],
24
- * },
25
- * });
26
- * ```
27
- */
28
-
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
29
4
  /**
30
5
  * Policy middleware configuration
31
6
  */
32
- interface PolicyMiddlewareConfig {
33
- /**
34
- * Local policy configuration (static)
35
- * If provided, this policy is used instead of fetching from API
36
- */
37
- policy?: Partial<PolicyConfig>;
38
- /**
39
- * Fetch policy from AgentShield API
40
- * Requires projectId and optionally an apiKey
41
- */
42
- fetchPolicy?: {
43
- /** Project ID to fetch policy for */
44
- projectId: string;
45
- /** API base URL (defaults to production) */
46
- apiUrl?: string;
47
- /** API key for authentication */
48
- apiKey?: string;
49
- /** Cache TTL in seconds (default: 300) */
50
- cacheTtlSeconds?: number;
51
- };
52
- /**
53
- * Fallback policy to use when fetch fails
54
- * Defaults to DEFAULT_POLICY (allow all)
55
- */
56
- fallbackPolicy?: Partial<PolicyConfig>;
57
- /**
58
- * Custom blocked response
59
- */
60
- blockedResponse?: {
61
- status?: number;
62
- message?: string;
63
- headers?: Record<string, string>;
64
- };
65
- /**
66
- * Default redirect URL for redirect actions
67
- */
68
- redirectUrl?: string;
69
- /**
70
- * Callback when policy decision is made
71
- */
72
- onPolicyDecision?: (request: NextRequest, decision: PolicyEvaluationResult, context: PolicyEvaluationContext) => void | Promise<void>;
73
- /**
74
- * Custom response builder for blocked requests
75
- */
76
- customBlockedResponse?: (request: NextRequest, decision: PolicyEvaluationResult) => NextResponse | Promise<NextResponse>;
77
- /**
78
- * Whether to fail open (allow) on policy evaluation errors
79
- * Default: true (recommended for production)
80
- */
81
- failOpen?: boolean;
82
- /**
83
- * Enable debug logging
84
- */
85
- debug?: boolean;
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;
86
61
  }
87
62
  /**
88
63
  * Combined middleware configuration with policy support
89
64
  */
90
- interface NextJSPolicyMiddlewareConfig extends PolicyMiddlewareConfig {
91
- /**
92
- * Paths to skip (in addition to policy excludedPaths)
93
- */
94
- skipPaths?: string[];
95
- /**
96
- * Only enforce on these paths (overrides policy includedPaths)
97
- */
98
- includePaths?: string[];
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[];
99
74
  }
100
75
  /**
101
76
  * Create policy evaluation context from detection result and request
102
77
  */
103
- declare function createContextFromDetection(detection: DetectionResult, request: NextRequest): PolicyEvaluationContext;
78
+ export declare function createContextFromDetection(detection: DetectionResult, request: NextRequest): PolicyEvaluationContext$1;
104
79
  /**
105
80
  * Evaluate policy for a detection result
106
81
  */
107
- declare function evaluatePolicyForDetection(detection: DetectionResult, request: NextRequest, policy: PolicyConfig): PolicyEvaluationResult;
82
+ export declare function evaluatePolicyForDetection(detection: DetectionResult, request: NextRequest, policy: PolicyConfig$1): PolicyEvaluationResult$1;
108
83
  /**
109
84
  * Build blocked response based on policy decision
110
85
  */
111
- declare function buildBlockedResponse(decision: PolicyEvaluationResult, config: PolicyMiddlewareConfig): NextResponse;
86
+ export declare function buildBlockedResponse(decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig): NextResponse;
112
87
  /**
113
88
  * Build redirect response based on policy decision
114
89
  */
115
- declare function buildRedirectResponse(request: NextRequest, decision: PolicyEvaluationResult, config: PolicyMiddlewareConfig, detection?: {
116
- detectedAgent?: {
117
- name?: string;
118
- };
90
+ export declare function buildRedirectResponse(request: NextRequest, decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig, detection?: {
91
+ detectedAgent?: {
92
+ name?: string;
93
+ };
119
94
  }): NextResponse;
120
95
  /**
121
96
  * Build challenge response (placeholder - future implementation)
122
97
  */
123
- declare function buildChallengeResponse(request: NextRequest, decision: PolicyEvaluationResult, config: PolicyMiddlewareConfig, detection?: {
124
- detectedAgent?: {
125
- name?: string;
126
- };
98
+ export declare function buildChallengeResponse(request: NextRequest, decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig, detection?: {
99
+ detectedAgent?: {
100
+ name?: string;
101
+ };
127
102
  }): NextResponse;
128
103
  /**
129
104
  * Handle policy decision and return appropriate response
130
105
  */
131
- declare function handlePolicyDecision(request: NextRequest, decision: PolicyEvaluationResult, config: PolicyMiddlewareConfig, detection?: {
132
- detectedAgent?: {
133
- name?: string;
134
- };
106
+ export declare function handlePolicyDecision(request: NextRequest, decision: PolicyEvaluationResult$1, config: PolicyMiddlewareConfig, detection?: {
107
+ detectedAgent?: {
108
+ name?: string;
109
+ };
135
110
  }): Promise<NextResponse | null>;
136
111
  /**
137
112
  * Get policy (local, fetched, or fallback)
138
113
  */
139
- declare function getPolicy(config: PolicyMiddlewareConfig): Promise<PolicyConfig>;
114
+ export declare function getPolicy(config: PolicyMiddlewareConfig): Promise<PolicyConfig$1>;
140
115
  /**
141
116
  * Apply policy to a detection result
142
117
  *
@@ -157,6 +132,7 @@ declare function getPolicy(config: PolicyMiddlewareConfig): Promise<PolicyConfig
157
132
  * }
158
133
  * ```
159
134
  */
160
- declare function applyPolicy(request: NextRequest, detection: DetectionResult, config: NextJSPolicyMiddlewareConfig): Promise<NextResponse | null>;
161
-
162
- export { type NextJSPolicyMiddlewareConfig, type PolicyMiddlewareConfig, applyPolicy, buildBlockedResponse, buildChallengeResponse, buildRedirectResponse, createContextFromDetection, evaluatePolicyForDetection, getPolicy, handlePolicyDecision };
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
@@ -0,0 +1 @@
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"}