unpeek 3.0.0 → 4.0.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 (68) hide show
  1. package/README.md +27 -13
  2. package/README.tr.md +37 -23
  3. package/dist/adapters/esbuild.cjs +5 -5
  4. package/dist/adapters/esbuild.d.cts +3 -1
  5. package/dist/adapters/esbuild.d.ts +2 -2
  6. package/dist/adapters/esbuild.js +5 -3
  7. package/dist/adapters/next/adapter.cjs +7 -6
  8. package/dist/adapters/next/adapter.d.cts +1 -1
  9. package/dist/adapters/next/adapter.d.ts +1 -1
  10. package/dist/adapters/next/adapter.js +6 -5
  11. package/dist/adapters/next/index.cjs +7 -6
  12. package/dist/adapters/next/index.js +6 -5
  13. package/dist/adapters/rollup.cjs +5 -5
  14. package/dist/adapters/rollup.d.cts +3 -1
  15. package/dist/adapters/rollup.d.ts +2 -2
  16. package/dist/adapters/rollup.js +5 -3
  17. package/dist/adapters/rspack.cjs +5 -4
  18. package/dist/adapters/rspack.d.cts +1 -1
  19. package/dist/adapters/rspack.d.ts +1 -1
  20. package/dist/adapters/rspack.js +3 -2
  21. package/dist/adapters/vite.cjs +5 -5
  22. package/dist/adapters/vite.d.cts +3 -1
  23. package/dist/adapters/vite.d.ts +2 -2
  24. package/dist/adapters/vite.js +5 -3
  25. package/dist/adapters/webpack.cjs +5 -5
  26. package/dist/adapters/webpack.d.cts +3 -1
  27. package/dist/adapters/webpack.d.ts +2 -2
  28. package/dist/adapters/webpack.js +5 -3
  29. package/dist/browser.cjs +3 -3
  30. package/dist/browser.d.cts +20 -17
  31. package/dist/browser.d.ts +20 -17
  32. package/dist/browser.js +2 -2
  33. package/dist/{chunk-BPRSCRUZ.js → chunk-2JU3V7HW.js} +6 -3
  34. package/dist/chunk-3LWXEJU6.cjs +1054 -0
  35. package/dist/{chunk-IZIWDJRF.js → chunk-4FNZNIBW.js} +2675 -651
  36. package/dist/chunk-7HXLHLLQ.cjs +503 -0
  37. package/dist/chunk-ADKRENAP.js +1054 -0
  38. package/dist/{chunk-FCF2EGPM.js → chunk-EN6QVR6P.js} +12 -3
  39. package/dist/chunk-HHC7BUCK.js +503 -0
  40. package/dist/{chunk-IAD5DV3D.cjs → chunk-KLYFNMKS.cjs} +2812 -788
  41. package/dist/{chunk-IEBVL5BT.cjs → chunk-URPPSTHZ.cjs} +12 -3
  42. package/dist/chunk-VG4Y26ZN.cjs +429 -0
  43. package/dist/{chunk-IICVBTR2.js → chunk-W77DAC3H.js} +22 -3
  44. package/dist/{chunk-ONM2CSTU.cjs → chunk-X6EETCO6.cjs} +64 -45
  45. package/dist/chunk-YCRMTXOE.js +429 -0
  46. package/dist/{chunk-6TDCSIRZ.cjs → chunk-ZG7BIAUI.cjs} +9 -6
  47. package/dist/cli/index.js +3693 -1141
  48. package/dist/{config-CfXY_iDD.d.ts → config-Y6JwVGwX.d.cts} +15 -1
  49. package/dist/{config-CfXY_iDD.d.cts → config-Y6JwVGwX.d.ts} +15 -1
  50. package/dist/config.cjs +3 -3
  51. package/dist/config.d.cts +1 -1
  52. package/dist/config.d.ts +1 -1
  53. package/dist/config.js +2 -2
  54. package/dist/{index-CjRTNPlj.d.cts → index-0O1WSfVP.d.ts} +7 -1
  55. package/dist/{index-Cm1IloVm.d.ts → index-COVHErnx.d.cts} +7 -1
  56. package/dist/index.cjs +65 -264
  57. package/dist/index.d.cts +4 -4
  58. package/dist/index.d.ts +4 -4
  59. package/dist/index.js +59 -258
  60. package/dist/plugins/unplugin.cjs +4 -3
  61. package/dist/plugins/unplugin.js +3 -2
  62. package/dist/{types-DYQIzGf6.d.cts → types-CMtZnV8C.d.ts} +3 -3
  63. package/dist/{types-ZHAFdOd3.d.ts → types-D93PuOOl.d.cts} +3 -3
  64. package/package.json +1 -1
  65. package/dist/chunk-APWMNVAZ.js +0 -764
  66. package/dist/chunk-DUK2SECY.js +0 -83
  67. package/dist/chunk-I6GXEHFR.cjs +0 -764
  68. package/dist/chunk-RXUY3MPH.cjs +0 -83
@@ -12,6 +12,7 @@ interface ShieldPayload {
12
12
  expectedHash: number;
13
13
  windowKeySymbol?: string;
14
14
  expectedDelta?: number;
15
+ stateKeySymbol?: string;
15
16
  }
16
17
 
17
18
  type UnpeekProfile = 'minimal' | 'recommended' | 'strict';
@@ -21,8 +22,14 @@ declare function loadUnpeekConfig(cwd?: string, explicitConfig?: UnpeekConfig):
21
22
 
22
23
  type UnpeekFramework = 'nextjs' | 'vite' | 'webpack' | 'vanilla';
23
24
  type ConfigTarget = 'browser' | 'worker' | 'universal';
25
+ type UnpeekTier = 'Tier 1' | 'Tier 2' | 'Tier 3';
24
26
  type PatternInput = RegExp | string;
25
27
 
28
+ interface CriticalConfig {
29
+ include?: PatternInput[];
30
+ annotation?: string;
31
+ maxFunctionsPerChunk?: number;
32
+ }
26
33
  interface FilterConfig {
27
34
  include?: string[];
28
35
  exclude?: string[];
@@ -78,12 +85,15 @@ interface UnpeekConfig {
78
85
  framework?: UnpeekFramework;
79
86
  target?: ConfigTarget;
80
87
  profile?: UnpeekProfile;
88
+ tier?: UnpeekTier;
89
+ coldFlow?: boolean;
81
90
  outDir?: string;
82
91
  extensions?: string[];
83
92
  publicDirs?: string[];
84
93
  scrubPaths?: boolean;
85
94
  filter?: FilterConfig;
86
95
  hotPath?: HotPathConfig;
96
+ critical?: CriticalConfig;
87
97
  vault?: VaultConfig;
88
98
  mangler?: ManglerConfig;
89
99
  shield?: ShieldOptionsConfig;
@@ -106,6 +116,10 @@ interface BaseProtectionOptions {
106
116
  aggressive?: boolean;
107
117
  /** Protection preset profile */
108
118
  profile?: UnpeekProfile;
119
+ /** Explicit protection tier override */
120
+ tier?: UnpeekTier;
121
+ /** Tier 3 enclave targeting configuration (@unpeek-critical / include patterns) */
122
+ critical?: CriticalConfig;
109
123
  /** Optional Unpeek configuration */
110
124
  config?: UnpeekConfig;
111
125
  }
@@ -116,4 +130,4 @@ interface UnpeekPluginOptions extends BaseProtectionOptions {
116
130
  declare function defineConfig<const T extends UnpeekConfig>(config: T): T;
117
131
 
118
132
  export { PRESETS as P, defineConfig as j, loadUnpeekConfig as l };
119
- export type { BaseProtectionOptions as B, ConfigTarget as C, DeterrentMode as D, FilterConfig as F, HotPathConfig as H, ManglerConfig as M, NextConfigOptions as N, ShieldConfig as S, UnpeekConfig as U, VaultConfig as V, ShieldPayload as a, PatternInput as b, SemanticAnchorsConfig as c, ShieldOptionsConfig as d, SourcemapsConfig as e, UnpeekFramework as f, UnpeekPluginOptions as g, UnpeekProfile as h, ViteConfigOptions as i };
133
+ export type { BaseProtectionOptions as B, ConfigTarget as C, DeterrentMode as D, FilterConfig as F, HotPathConfig as H, ManglerConfig as M, NextConfigOptions as N, ShieldConfig as S, UnpeekConfig as U, VaultConfig as V, ShieldPayload as a, PatternInput as b, SemanticAnchorsConfig as c, ShieldOptionsConfig as d, SourcemapsConfig as e, UnpeekFramework as f, UnpeekPluginOptions as g, UnpeekProfile as h, ViteConfigOptions as i, CriticalConfig as k, UnpeekTier as m };
@@ -12,6 +12,7 @@ interface ShieldPayload {
12
12
  expectedHash: number;
13
13
  windowKeySymbol?: string;
14
14
  expectedDelta?: number;
15
+ stateKeySymbol?: string;
15
16
  }
16
17
 
17
18
  type UnpeekProfile = 'minimal' | 'recommended' | 'strict';
@@ -21,8 +22,14 @@ declare function loadUnpeekConfig(cwd?: string, explicitConfig?: UnpeekConfig):
21
22
 
22
23
  type UnpeekFramework = 'nextjs' | 'vite' | 'webpack' | 'vanilla';
23
24
  type ConfigTarget = 'browser' | 'worker' | 'universal';
25
+ type UnpeekTier = 'Tier 1' | 'Tier 2' | 'Tier 3';
24
26
  type PatternInput = RegExp | string;
25
27
 
28
+ interface CriticalConfig {
29
+ include?: PatternInput[];
30
+ annotation?: string;
31
+ maxFunctionsPerChunk?: number;
32
+ }
26
33
  interface FilterConfig {
27
34
  include?: string[];
28
35
  exclude?: string[];
@@ -78,12 +85,15 @@ interface UnpeekConfig {
78
85
  framework?: UnpeekFramework;
79
86
  target?: ConfigTarget;
80
87
  profile?: UnpeekProfile;
88
+ tier?: UnpeekTier;
89
+ coldFlow?: boolean;
81
90
  outDir?: string;
82
91
  extensions?: string[];
83
92
  publicDirs?: string[];
84
93
  scrubPaths?: boolean;
85
94
  filter?: FilterConfig;
86
95
  hotPath?: HotPathConfig;
96
+ critical?: CriticalConfig;
87
97
  vault?: VaultConfig;
88
98
  mangler?: ManglerConfig;
89
99
  shield?: ShieldOptionsConfig;
@@ -106,6 +116,10 @@ interface BaseProtectionOptions {
106
116
  aggressive?: boolean;
107
117
  /** Protection preset profile */
108
118
  profile?: UnpeekProfile;
119
+ /** Explicit protection tier override */
120
+ tier?: UnpeekTier;
121
+ /** Tier 3 enclave targeting configuration (@unpeek-critical / include patterns) */
122
+ critical?: CriticalConfig;
109
123
  /** Optional Unpeek configuration */
110
124
  config?: UnpeekConfig;
111
125
  }
@@ -116,4 +130,4 @@ interface UnpeekPluginOptions extends BaseProtectionOptions {
116
130
  declare function defineConfig<const T extends UnpeekConfig>(config: T): T;
117
131
 
118
132
  export { PRESETS as P, defineConfig as j, loadUnpeekConfig as l };
119
- export type { BaseProtectionOptions as B, ConfigTarget as C, DeterrentMode as D, FilterConfig as F, HotPathConfig as H, ManglerConfig as M, NextConfigOptions as N, ShieldConfig as S, UnpeekConfig as U, VaultConfig as V, ShieldPayload as a, PatternInput as b, SemanticAnchorsConfig as c, ShieldOptionsConfig as d, SourcemapsConfig as e, UnpeekFramework as f, UnpeekPluginOptions as g, UnpeekProfile as h, ViteConfigOptions as i };
133
+ export type { BaseProtectionOptions as B, ConfigTarget as C, DeterrentMode as D, FilterConfig as F, HotPathConfig as H, ManglerConfig as M, NextConfigOptions as N, ShieldConfig as S, UnpeekConfig as U, VaultConfig as V, ShieldPayload as a, PatternInput as b, SemanticAnchorsConfig as c, ShieldOptionsConfig as d, SourcemapsConfig as e, UnpeekFramework as f, UnpeekPluginOptions as g, UnpeekProfile as h, ViteConfigOptions as i, CriticalConfig as k, UnpeekTier as m };
package/dist/config.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkONM2CSTUcjs = require('./chunk-ONM2CSTU.cjs');
5
- require('./chunk-IEBVL5BT.cjs');
4
+ var _chunkX6EETCO6cjs = require('./chunk-X6EETCO6.cjs');
5
+ require('./chunk-URPPSTHZ.cjs');
6
6
  require('./chunk-L6BOM5VS.cjs');
7
7
 
8
8
 
9
9
 
10
- exports.defineConfig = _chunkONM2CSTUcjs.defineConfig; exports.loadUnpeekConfig = _chunkONM2CSTUcjs.loadUnpeekConfig;
10
+ exports.defineConfig = _chunkX6EETCO6cjs.defineConfig; exports.loadUnpeekConfig = _chunkX6EETCO6cjs.loadUnpeekConfig;
package/dist/config.d.cts CHANGED
@@ -1 +1 @@
1
- export { B as BaseProtectionOptions, C as ConfigTarget, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, b as PatternInput, c as SemanticAnchorsConfig, d as ShieldOptionsConfig, e as SourcemapsConfig, U as UnpeekConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, V as VaultConfig, i as ViteConfigOptions, j as defineConfig, l as loadUnpeekConfig } from './config-CfXY_iDD.cjs';
1
+ export { B as BaseProtectionOptions, C as ConfigTarget, k as CriticalConfig, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, b as PatternInput, c as SemanticAnchorsConfig, d as ShieldOptionsConfig, e as SourcemapsConfig, U as UnpeekConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, m as UnpeekTier, V as VaultConfig, i as ViteConfigOptions, j as defineConfig, l as loadUnpeekConfig } from './config-Y6JwVGwX.cjs';
package/dist/config.d.ts CHANGED
@@ -1 +1 @@
1
- export { B as BaseProtectionOptions, C as ConfigTarget, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, b as PatternInput, c as SemanticAnchorsConfig, d as ShieldOptionsConfig, e as SourcemapsConfig, U as UnpeekConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, V as VaultConfig, i as ViteConfigOptions, j as defineConfig, l as loadUnpeekConfig } from './config-CfXY_iDD.js';
1
+ export { B as BaseProtectionOptions, C as ConfigTarget, k as CriticalConfig, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, b as PatternInput, c as SemanticAnchorsConfig, d as ShieldOptionsConfig, e as SourcemapsConfig, U as UnpeekConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, m as UnpeekTier, V as VaultConfig, i as ViteConfigOptions, j as defineConfig, l as loadUnpeekConfig } from './config-Y6JwVGwX.js';
package/dist/config.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  defineConfig,
3
3
  loadUnpeekConfig
4
- } from "./chunk-IICVBTR2.js";
5
- import "./chunk-FCF2EGPM.js";
4
+ } from "./chunk-W77DAC3H.js";
5
+ import "./chunk-EN6QVR6P.js";
6
6
  import "./chunk-LA6J3BT3.js";
7
7
  export {
8
8
  defineConfig,
@@ -1,4 +1,4 @@
1
- import { B as BaseProtectionOptions } from './config-CfXY_iDD.cjs';
1
+ import { B as BaseProtectionOptions, k as CriticalConfig } from './config-Y6JwVGwX.js';
2
2
 
3
3
  interface HotPathReport {
4
4
  totalFunctions: number;
@@ -13,6 +13,12 @@ interface ScrubberOptions {
13
13
  }
14
14
  interface TransformOptions extends BaseProtectionOptions {
15
15
  filename?: string;
16
+ /** Project root directory stripped by the CWE-540 path scrubber */
17
+ rootDir?: string;
18
+ /** Tier 3 critical enclave targeting overrides */
19
+ critical?: CriticalConfig;
20
+ /** Generate an M2 Source Map v3 alongside the transformed output */
21
+ map?: boolean;
16
22
  /** Throw UnpeekError on JavaScript parse failures instead of returning input unchanged */
17
23
  strict?: boolean;
18
24
  /** Scrub local filesystem paths and residual dev metadata (CWE-540) */
@@ -1,4 +1,4 @@
1
- import { B as BaseProtectionOptions } from './config-CfXY_iDD.js';
1
+ import { B as BaseProtectionOptions, k as CriticalConfig } from './config-Y6JwVGwX.cjs';
2
2
 
3
3
  interface HotPathReport {
4
4
  totalFunctions: number;
@@ -13,6 +13,12 @@ interface ScrubberOptions {
13
13
  }
14
14
  interface TransformOptions extends BaseProtectionOptions {
15
15
  filename?: string;
16
+ /** Project root directory stripped by the CWE-540 path scrubber */
17
+ rootDir?: string;
18
+ /** Tier 3 critical enclave targeting overrides */
19
+ critical?: CriticalConfig;
20
+ /** Generate an M2 Source Map v3 alongside the transformed output */
21
+ map?: boolean;
16
22
  /** Throw UnpeekError on JavaScript parse failures instead of returning input unchanged */
17
23
  strict?: boolean;
18
24
  /** Scrub local filesystem paths and residual dev metadata (CWE-540) */
package/dist/index.cjs CHANGED
@@ -1,22 +1,27 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
+ var _chunk7HXLHLLQcjs = require('./chunk-7HXLHLLQ.cjs');
4
5
 
5
6
 
6
7
 
8
+ var _chunkX6EETCO6cjs = require('./chunk-X6EETCO6.cjs');
7
9
 
8
10
 
9
- var _chunkI6GXEHFRcjs = require('./chunk-I6GXEHFR.cjs');
11
+ var _chunkURPPSTHZcjs = require('./chunk-URPPSTHZ.cjs');
10
12
 
11
13
 
12
14
 
13
- var _chunkONM2CSTUcjs = require('./chunk-ONM2CSTU.cjs');
14
15
 
15
16
 
16
- var _chunkIEBVL5BTcjs = require('./chunk-IEBVL5BT.cjs');
17
17
 
18
18
 
19
- var _chunkIAD5DV3Dcjs = require('./chunk-IAD5DV3D.cjs');
19
+
20
+
21
+ var _chunk3LWXEJU6cjs = require('./chunk-3LWXEJU6.cjs');
22
+
23
+
24
+ var _chunkKLYFNMKScjs = require('./chunk-KLYFNMKS.cjs');
20
25
 
21
26
 
22
27
 
@@ -91,7 +96,7 @@ export default withUnpeek(nextConfig);
91
96
  function initProject(cwd = process.cwd(), options = {}) {
92
97
  const dryRun = typeof options === "boolean" ? options : _nullishCoalesce(options.dryRun, () => ( false));
93
98
  const rootDir = _path2.default.resolve(cwd);
94
- const { framework } = _chunkI6GXEHFRcjs.detectTargetFramework.call(void 0, rootDir);
99
+ const { framework } = _chunk3LWXEJU6cjs.detectTargetFramework.call(void 0, rootDir);
95
100
  const pkgPath = _path2.default.join(rootDir, "package.json");
96
101
  let updatedPackageJson = false;
97
102
  let updatedGitignore = false;
@@ -124,7 +129,7 @@ function initProject(cwd = process.cwd(), options = {}) {
124
129
  const rawNext = _nullishCoalesce(_optionalChain([deps, 'optionalAccess', _ => _.next]), () => ( _optionalChain([devDeps, 'optionalAccess', _2 => _2.next])));
125
130
  nextVersion = typeof rawNext === "string" ? rawNext : void 0;
126
131
  }
127
- if (framework === "nextjs" && _chunkI6GXEHFRcjs.isNext16OrAbove.call(void 0, nextVersion)) {
132
+ if (framework === "nextjs" && _chunk7HXLHLLQcjs.isNext16OrAbove.call(void 0, nextVersion)) {
128
133
  isNext16 = true;
129
134
  const configRes = wireNextConfig(rootDir, dryRun);
130
135
  updatedNextConfig = configRes.updated;
@@ -197,7 +202,7 @@ function initProject(cwd = process.cwd(), options = {}) {
197
202
  var _acorn = require('acorn'); var acorn = _interopRequireWildcard(_acorn);
198
203
  var _acornwalk = require('acorn-walk');
199
204
  function walkPublicMaps(currentDir, rootOutDir, found) {
200
- if (_chunkI6GXEHFRcjs.hasNextServerSegment.call(void 0, currentDir, rootOutDir)) {
205
+ if (_chunk3LWXEJU6cjs.hasNextServerSegment.call(void 0, currentDir, rootOutDir)) {
201
206
  return;
202
207
  }
203
208
  let entries;
@@ -212,7 +217,7 @@ function walkPublicMaps(currentDir, rootOutDir, found) {
212
217
  if (entry.name === "node_modules" || entry.name === ".unpeek-maps") {
213
218
  continue;
214
219
  }
215
- if (_chunkI6GXEHFRcjs.hasNextServerSegment.call(void 0, fullPath, rootOutDir)) {
220
+ if (_chunk3LWXEJU6cjs.hasNextServerSegment.call(void 0, fullPath, rootOutDir)) {
216
221
  continue;
217
222
  }
218
223
  walkPublicMaps(fullPath, rootOutDir, found);
@@ -272,8 +277,8 @@ function findEvalOrFunctionCalls(code) {
272
277
  }
273
278
  async function checkProject(options = {}) {
274
279
  const cwd = _path2.default.resolve(_nullishCoalesce(options.cwd, () => ( process.cwd())));
275
- const config = await _chunkONM2CSTUcjs.loadUnpeekConfig.call(void 0, cwd);
276
- const { outDir } = _chunkI6GXEHFRcjs.detectTargetFramework.call(void 0, cwd, options.outDir, config);
280
+ const config = await _chunkX6EETCO6cjs.loadUnpeekConfig.call(void 0, cwd);
281
+ const { outDir } = _chunk3LWXEJU6cjs.detectTargetFramework.call(void 0, cwd, options.outDir, config);
277
282
  const resolvedOutDir = _path2.default.resolve(outDir);
278
283
  const privateMapsDir = _nullishCoalesce(_nullishCoalesce(options.privateMapsDir, () => ( _optionalChain([config, 'access', _3 => _3.sourcemaps, 'optionalAccess', _4 => _4.vaultDir]))), () => ( ".unpeek-maps"));
279
284
  const maxGzipDelta = _nullishCoalesce(options.maxGzipDelta, () => ( 15));
@@ -293,7 +298,8 @@ async function checkProject(options = {}) {
293
298
  file: rel
294
299
  });
295
300
  }
296
- const clientFiles = _chunkI6GXEHFRcjs.scanClientBundles.call(void 0, resolvedOutDir, config);
301
+ const vaultDir = _path2.default.resolve(cwd, privateMapsDir);
302
+ const clientFiles = _chunk3LWXEJU6cjs.scanClientBundles.call(void 0, resolvedOutDir, config);
297
303
  for (const filePath of clientFiles) {
298
304
  const rel = _path2.default.relative(resolvedOutDir, filePath).replace(/\\/g, "/");
299
305
  let content;
@@ -302,8 +308,8 @@ async function checkProject(options = {}) {
302
308
  } catch (e5) {
303
309
  continue;
304
310
  }
305
- _chunkI6GXEHFRcjs.SOURCE_MAP_COMMENT_REGEX.lastIndex = 0;
306
- if (_chunkI6GXEHFRcjs.SOURCE_MAP_COMMENT_REGEX.test(content)) {
311
+ _chunk3LWXEJU6cjs.SOURCE_MAP_COMMENT_REGEX.lastIndex = 0;
312
+ if (_chunk3LWXEJU6cjs.SOURCE_MAP_COMMENT_REGEX.test(content)) {
307
313
  violations.push({
308
314
  rule: "sourcemap-comment",
309
315
  severity: "error",
@@ -311,6 +317,49 @@ async function checkProject(options = {}) {
311
317
  file: rel
312
318
  });
313
319
  }
320
+ const jsDebugId = _chunk3LWXEJU6cjs.extractDebugId.call(void 0, content);
321
+ const decodedRel = _chunk3LWXEJU6cjs.safeDecodeURIComponent.call(void 0, rel);
322
+ const mapCandidates = [
323
+ _path2.default.join(vaultDir, `${rel}.map`),
324
+ ...decodedRel !== rel ? [_path2.default.join(vaultDir, `${decodedRel}.map`)] : []
325
+ ];
326
+ const vaultedMapPath = mapCandidates.find((p) => _fs2.default.existsSync(p));
327
+ if (vaultedMapPath) {
328
+ try {
329
+ const mapJson = JSON.parse(_fs2.default.readFileSync(vaultedMapPath, "utf8"));
330
+ const rawMapDebugId = typeof mapJson.debugId === "string" ? mapJson.debugId : typeof mapJson.debug_id === "string" ? mapJson.debug_id : void 0;
331
+ if (jsDebugId && rawMapDebugId && jsDebugId !== rawMapDebugId) {
332
+ violations.push({
333
+ rule: "debugid-mismatch",
334
+ severity: "error",
335
+ message: `debugId mismatch for "${rel}": JS has "${jsDebugId}" while vaulted map has "${rawMapDebugId}".`,
336
+ file: rel
337
+ });
338
+ } else if (jsDebugId && !rawMapDebugId) {
339
+ warnings.push({
340
+ rule: "debugid-mismatch",
341
+ severity: "warning",
342
+ message: `JS bundle "${rel}" has debugId "${jsDebugId}" but vaulted source map is missing debugId.`,
343
+ file: rel
344
+ });
345
+ } else if (!jsDebugId && rawMapDebugId) {
346
+ warnings.push({
347
+ rule: "debugid-mismatch",
348
+ severity: "warning",
349
+ message: `Vaulted source map for "${rel}" has debugId "${rawMapDebugId}" but JS bundle is missing //# debugId=.`,
350
+ file: rel
351
+ });
352
+ }
353
+ } catch (e6) {
354
+ }
355
+ } else if (jsDebugId) {
356
+ warnings.push({
357
+ rule: "debugid-mismatch",
358
+ severity: "warning",
359
+ message: `JS bundle "${rel}" has debugId "${jsDebugId}" but no vaulted source map found at "${rel}.map".`,
360
+ file: rel
361
+ });
362
+ }
314
363
  const evalHits = findEvalOrFunctionCalls(content);
315
364
  if (evalHits.length > 0) {
316
365
  const violation = {
@@ -326,10 +375,9 @@ async function checkProject(options = {}) {
326
375
  }
327
376
  }
328
377
  }
329
- const vaultDir = _path2.default.resolve(cwd, privateMapsDir);
330
378
  const relVault = _path2.default.relative(cwd, vaultDir).replace(/\\/g, "/");
331
379
  const ignoreEntry = relVault && !relVault.startsWith("..") ? `${relVault}/` : ".unpeek-maps/";
332
- const roots = _chunkI6GXEHFRcjs.findMonorepoRoots.call(void 0, cwd);
380
+ const roots = _chunk3LWXEJU6cjs.findMonorepoRoots.call(void 0, cwd);
333
381
  let foundGitignore = false;
334
382
  let gitignoreProtected = false;
335
383
  let foundDockerignore = false;
@@ -381,7 +429,7 @@ async function checkProject(options = {}) {
381
429
  message: `Bundle Gzip delta (${manifest.gzipDeltaPercent}%) exceeds maxGzipDelta (${maxGzipDelta}%).`
382
430
  });
383
431
  }
384
- } catch (e6) {
432
+ } catch (e7) {
385
433
  }
386
434
  }
387
435
  return {
@@ -393,253 +441,6 @@ async function checkProject(options = {}) {
393
441
  };
394
442
  }
395
443
 
396
- // src/core/vlq.ts
397
-
398
-
399
- var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
400
- var BASE64_MAP = /* @__PURE__ */ new Map();
401
- for (let i = 0; i < BASE64_CHARS.length; i++) {
402
- BASE64_MAP.set(BASE64_CHARS[i], i);
403
- }
404
- var VLQ_BASE_SHIFT = 5;
405
- var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
406
- var VLQ_BASE_MASK = VLQ_BASE - 1;
407
- var VLQ_CONTINUATION_BIT = VLQ_BASE;
408
- function decodeVlq(segment, startIndex) {
409
- let result = 0;
410
- let shift = 0;
411
- let index = startIndex;
412
- while (index < segment.length) {
413
- const digit = BASE64_MAP.get(segment[index]);
414
- if (digit === void 0) {
415
- return null;
416
- }
417
- index++;
418
- const continuation = (digit & VLQ_CONTINUATION_BIT) !== 0;
419
- result += (digit & VLQ_BASE_MASK) << shift;
420
- shift += VLQ_BASE_SHIFT;
421
- if (!continuation) {
422
- const isNegative = (result & 1) === 1;
423
- const shifted = result >> 1;
424
- return {
425
- value: isNegative ? -shifted : shifted,
426
- nextIndex: index
427
- };
428
- }
429
- if (shift > 30) {
430
- return null;
431
- }
432
- }
433
- return null;
434
- }
435
- function decodeMappings(mappingsStr) {
436
- const mappings = [];
437
- let malformedCount = 0;
438
- if (!mappingsStr) {
439
- return { mappings, malformedCount };
440
- }
441
- let sourceIndex = 0;
442
- let originalLine = 0;
443
- let originalColumn = 0;
444
- let nameIndex = 0;
445
- const lines = mappingsStr.split(";");
446
- for (let genLine = 0; genLine < lines.length; genLine++) {
447
- const lineStr = lines[genLine];
448
- if (!lineStr) continue;
449
- let genCol = 0;
450
- const segments = lineStr.split(",");
451
- for (const seg of segments) {
452
- if (!seg) continue;
453
- const values = [];
454
- let idx = 0;
455
- let valid = true;
456
- while (idx < seg.length) {
457
- const decoded = decodeVlq(seg, idx);
458
- if (!decoded) {
459
- valid = false;
460
- break;
461
- }
462
- values.push(decoded.value);
463
- idx = decoded.nextIndex;
464
- }
465
- if (!valid || values.length !== 1 && values.length !== 4 && values.length !== 5) {
466
- malformedCount++;
467
- continue;
468
- }
469
- genCol += values[0];
470
- if (values.length >= 4) {
471
- sourceIndex += values[1];
472
- originalLine += values[2];
473
- originalColumn += values[3];
474
- const mapping = {
475
- generatedLine: genLine,
476
- generatedColumn: genCol,
477
- sourceIndex,
478
- originalLine,
479
- originalColumn
480
- };
481
- if (values.length === 5) {
482
- nameIndex += values[4];
483
- mapping.nameIndex = nameIndex;
484
- }
485
- mappings.push(mapping);
486
- }
487
- }
488
- }
489
- return { mappings, malformedCount };
490
- }
491
- function findMappingAt(mappings, line0, col0) {
492
- let lo = 0;
493
- let hi = mappings.length - 1;
494
- let best;
495
- while (lo <= hi) {
496
- const mid = lo + hi >> 1;
497
- const m = mappings[mid];
498
- if (m.generatedLine < line0 || m.generatedLine === line0 && m.generatedColumn <= col0) {
499
- if (m.generatedLine === line0) {
500
- best = m;
501
- }
502
- lo = mid + 1;
503
- } else {
504
- hi = mid - 1;
505
- }
506
- }
507
- return best;
508
- }
509
- function resolvePosition(map, line1Based, column1Based) {
510
- const { mappings, malformedCount } = decodeMappings(map.mappings);
511
- const match = findMappingAt(mappings, Math.max(0, line1Based - 1), Math.max(0, column1Based - 1));
512
- if (!match) {
513
- return { malformedCount };
514
- }
515
- const rawSource = map.sources[match.sourceIndex];
516
- const source = map.sourceRoot && rawSource && !rawSource.startsWith(map.sourceRoot) ? `${map.sourceRoot.replace(/\/$/, "")}/${rawSource.replace(/^\//, "")}` : rawSource;
517
- return {
518
- source,
519
- line: match.originalLine + 1,
520
- column: match.originalColumn + 1,
521
- name: match.nameIndex !== void 0 ? map.names[match.nameIndex] : void 0,
522
- malformedCount
523
- };
524
- }
525
- function collectMapFiles(mapsDir) {
526
- if (!_fs2.default.existsSync(mapsDir)) return [];
527
- const results = [];
528
- const walk = (dir) => {
529
- let entries;
530
- try {
531
- entries = _fs2.default.readdirSync(dir, { withFileTypes: true });
532
- } catch (e7) {
533
- return;
534
- }
535
- for (const entry of entries) {
536
- const fullPath = _path2.default.join(dir, entry.name);
537
- if (entry.isDirectory()) {
538
- walk(fullPath);
539
- } else if (entry.isFile() && entry.name.endsWith(".map")) {
540
- results.push(fullPath);
541
- }
542
- }
543
- };
544
- walk(mapsDir);
545
- return results;
546
- }
547
- function findMatchingMapFile(fileRef, mapsDir, allMaps) {
548
- let cleanRef = fileRef.trim();
549
- try {
550
- if (/^https?:\/\//i.test(cleanRef)) {
551
- cleanRef = new URL(cleanRef).pathname;
552
- }
553
- } catch (e8) {
554
- }
555
- cleanRef = cleanRef.split("?")[0].split("#")[0].replace(/\\/g, "/").replace(/^\/+/, "");
556
- const targetMapName = `${_path2.default.posix.basename(cleanRef)}.map`;
557
- const exactCandidate = _path2.default.join(mapsDir, `${cleanRef}.map`);
558
- if (_fs2.default.existsSync(exactCandidate)) {
559
- return exactCandidate;
560
- }
561
- for (const mapPath of allMaps) {
562
- const rel = _path2.default.relative(mapsDir, mapPath).replace(/\\/g, "/");
563
- if (rel === `${cleanRef}.map` || rel.endsWith(`/${cleanRef}.map`) || cleanRef.endsWith(`/${rel.slice(0, -4)}`)) {
564
- return mapPath;
565
- }
566
- }
567
- return allMaps.find((m) => _path2.default.basename(m) === targetMapName);
568
- }
569
- var STACK_FRAME_REGEX = /(?:at\s+(?:[^(]+\s+\()?|\@)([^\s()]+?):(\d+):(\d+)\)?/;
570
- async function symbolicateStackTrace(options) {
571
- const cwd = _path2.default.resolve(_nullishCoalesce(options.cwd, () => ( process.cwd())));
572
- const mapsDir = _path2.default.resolve(cwd, _nullishCoalesce(options.mapsDir, () => ( ".unpeek-maps")));
573
- const allMaps = collectMapFiles(mapsDir);
574
- const warnings = [];
575
- const mapCache = /* @__PURE__ */ new Map();
576
- if (allMaps.length === 0) {
577
- warnings.push(`No .map files found in "${mapsDir}".`);
578
- }
579
- const lines = options.stackTrace.split(/\r?\n/);
580
- const frames = [];
581
- const outputLines = [];
582
- for (const rawLine of lines) {
583
- const match = rawLine.match(STACK_FRAME_REGEX);
584
- if (!match) {
585
- frames.push({ raw: rawLine, resolved: false });
586
- outputLines.push(rawLine);
587
- continue;
588
- }
589
- const fileRef = match[1];
590
- const lineNum = Number(match[2]);
591
- const colNum = Number(match[3]);
592
- const mapPath = findMatchingMapFile(fileRef, mapsDir, allMaps);
593
- if (!mapPath) {
594
- frames.push({ raw: rawLine, file: fileRef, line: lineNum, column: colNum, resolved: false });
595
- outputLines.push(rawLine);
596
- continue;
597
- }
598
- let parsedMap = mapCache.get(mapPath);
599
- if (parsedMap === void 0) {
600
- try {
601
- parsedMap = JSON.parse(_fs2.default.readFileSync(mapPath, "utf8"));
602
- } catch (e9) {
603
- parsedMap = null;
604
- warnings.push(`Failed to parse source map "${mapPath}".`);
605
- }
606
- mapCache.set(mapPath, parsedMap);
607
- }
608
- if (!parsedMap || typeof parsedMap.mappings !== "string" || !Array.isArray(parsedMap.sources)) {
609
- frames.push({ raw: rawLine, file: fileRef, line: lineNum, column: colNum, resolved: false });
610
- outputLines.push(rawLine);
611
- continue;
612
- }
613
- const pos = resolvePosition(parsedMap, lineNum, colNum);
614
- if (pos.malformedCount > 0) {
615
- warnings.push(`Skipped ${pos.malformedCount} malformed VLQ segment(s) in "${_path2.default.basename(mapPath)}".`);
616
- }
617
- if (!pos.source || pos.line === void 0 || pos.column === void 0) {
618
- frames.push({ raw: rawLine, file: fileRef, line: lineNum, column: colNum, resolved: false });
619
- outputLines.push(rawLine);
620
- continue;
621
- }
622
- frames.push({
623
- raw: rawLine,
624
- file: fileRef,
625
- line: lineNum,
626
- column: colNum,
627
- originalSource: pos.source,
628
- originalLine: pos.line,
629
- originalColumn: pos.column,
630
- originalName: pos.name,
631
- resolved: true
632
- });
633
- const fnPrefix = pos.name ? `${pos.name} ` : "";
634
- outputLines.push(` at ${fnPrefix}(${pos.source}:${pos.line}:${pos.column})`);
635
- }
636
- return {
637
- stackTrace: outputLines.join("\n"),
638
- frames,
639
- warnings: Array.from(new Set(warnings))
640
- };
641
- }
642
-
643
444
 
644
445
 
645
446
 
@@ -650,4 +451,4 @@ async function symbolicateStackTrace(options) {
650
451
 
651
452
 
652
453
 
653
- exports.PRESETS = _chunkIEBVL5BTcjs.PRESETS; exports.UnpeekError = _chunkL6BOM5VScjs.UnpeekError; exports.checkProject = checkProject; exports.defineConfig = _chunkONM2CSTUcjs.defineConfig; exports.initProject = initProject; exports.isUnpeekError = _chunkL6BOM5VScjs.isUnpeekError; exports.loadUnpeekConfig = _chunkONM2CSTUcjs.loadUnpeekConfig; exports.protectProject = _chunkI6GXEHFRcjs.protectProject; exports.symbolicateStackTrace = symbolicateStackTrace; exports.transformJavaScript = _chunkIAD5DV3Dcjs.transformJavaScript;
454
+ exports.PRESETS = _chunkURPPSTHZcjs.PRESETS; exports.UnpeekError = _chunkL6BOM5VScjs.UnpeekError; exports.checkProject = checkProject; exports.defineConfig = _chunkX6EETCO6cjs.defineConfig; exports.initProject = initProject; exports.isUnpeekError = _chunkL6BOM5VScjs.isUnpeekError; exports.loadUnpeekConfig = _chunkX6EETCO6cjs.loadUnpeekConfig; exports.protectProject = _chunk7HXLHLLQcjs.protectProject; exports.symbolicateStackTrace = _chunk3LWXEJU6cjs.symbolicateStackTrace; exports.transformJavaScript = _chunkKLYFNMKScjs.transformJavaScript;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- export { B as BaseProtectionOptions, C as ConfigTarget, D as DeterrentMode, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, P as PRESETS, b as PatternInput, c as SemanticAnchorsConfig, S as ShieldConfig, d as ShieldOptionsConfig, a as ShieldPayload, e as SourcemapsConfig, U as UnpeekConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, V as VaultConfig, i as ViteConfigOptions, j as defineConfig, l as loadUnpeekConfig } from './config-CfXY_iDD.cjs';
2
- export { H as HotPathReport, S as ScrubberOptions, T as TransformOptions, a as TransformResult, b as TransformSkippedReason, U as UnpeekError, c as UnpeekErrorCode, i as isUnpeekError, t as transformJavaScript } from './index-CjRTNPlj.cjs';
3
- import { I as InitOptions, b as InitResult, a as ProtectOptions, P as ProtectSummary, C as CheckOptions, c as CheckResult, S as SymbolicateOptions, d as SymbolicateResult } from './types-DYQIzGf6.cjs';
4
- export { e as CheckViolation, f as SourceMapVaultResult, g as SymbolicateFrame, U as UnpeekDiagnostic, h as UnpeekDiagnosticSeverity } from './types-DYQIzGf6.cjs';
1
+ export { B as BaseProtectionOptions, C as ConfigTarget, D as DeterrentMode, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, P as PRESETS, b as PatternInput, c as SemanticAnchorsConfig, S as ShieldConfig, d as ShieldOptionsConfig, a as ShieldPayload, e as SourcemapsConfig, U as UnpeekConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, V as VaultConfig, i as ViteConfigOptions, j as defineConfig, l as loadUnpeekConfig } from './config-Y6JwVGwX.cjs';
2
+ export { H as HotPathReport, S as ScrubberOptions, T as TransformOptions, a as TransformResult, b as TransformSkippedReason, U as UnpeekError, c as UnpeekErrorCode, i as isUnpeekError, t as transformJavaScript } from './index-COVHErnx.cjs';
3
+ import { I as InitOptions, b as InitResult, a as ProtectOptions, P as ProtectSummary, C as CheckOptions, c as CheckResult, S as SymbolicateOptions, d as SymbolicateResult } from './types-D93PuOOl.cjs';
4
+ export { e as CheckViolation, f as SourceMapVaultResult, g as SymbolicateFrame, U as UnpeekDiagnostic, h as UnpeekDiagnosticSeverity } from './types-D93PuOOl.cjs';
5
5
 
6
6
  declare function initProject(cwd?: string, options?: InitOptions): InitResult;
7
7
  /**
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { B as BaseProtectionOptions, C as ConfigTarget, D as DeterrentMode, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, P as PRESETS, b as PatternInput, c as SemanticAnchorsConfig, S as ShieldConfig, d as ShieldOptionsConfig, a as ShieldPayload, e as SourcemapsConfig, U as UnpeekConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, V as VaultConfig, i as ViteConfigOptions, j as defineConfig, l as loadUnpeekConfig } from './config-CfXY_iDD.js';
2
- export { H as HotPathReport, S as ScrubberOptions, T as TransformOptions, a as TransformResult, b as TransformSkippedReason, U as UnpeekError, c as UnpeekErrorCode, i as isUnpeekError, t as transformJavaScript } from './index-Cm1IloVm.js';
3
- import { I as InitOptions, b as InitResult, a as ProtectOptions, P as ProtectSummary, C as CheckOptions, c as CheckResult, S as SymbolicateOptions, d as SymbolicateResult } from './types-ZHAFdOd3.js';
4
- export { e as CheckViolation, f as SourceMapVaultResult, g as SymbolicateFrame, U as UnpeekDiagnostic, h as UnpeekDiagnosticSeverity } from './types-ZHAFdOd3.js';
1
+ export { B as BaseProtectionOptions, C as ConfigTarget, D as DeterrentMode, F as FilterConfig, H as HotPathConfig, M as ManglerConfig, N as NextConfigOptions, P as PRESETS, b as PatternInput, c as SemanticAnchorsConfig, S as ShieldConfig, d as ShieldOptionsConfig, a as ShieldPayload, e as SourcemapsConfig, U as UnpeekConfig, f as UnpeekFramework, g as UnpeekPluginOptions, h as UnpeekProfile, V as VaultConfig, i as ViteConfigOptions, j as defineConfig, l as loadUnpeekConfig } from './config-Y6JwVGwX.js';
2
+ export { H as HotPathReport, S as ScrubberOptions, T as TransformOptions, a as TransformResult, b as TransformSkippedReason, U as UnpeekError, c as UnpeekErrorCode, i as isUnpeekError, t as transformJavaScript } from './index-0O1WSfVP.js';
3
+ import { I as InitOptions, b as InitResult, a as ProtectOptions, P as ProtectSummary, C as CheckOptions, c as CheckResult, S as SymbolicateOptions, d as SymbolicateResult } from './types-CMtZnV8C.js';
4
+ export { e as CheckViolation, f as SourceMapVaultResult, g as SymbolicateFrame, U as UnpeekDiagnostic, h as UnpeekDiagnosticSeverity } from './types-CMtZnV8C.js';
5
5
 
6
6
  declare function initProject(cwd?: string, options?: InitOptions): InitResult;
7
7
  /**