unpeek 1.15.0 → 2.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 (129) hide show
  1. package/README.md +68 -40
  2. package/README.tr.md +74 -46
  3. package/dist/ast/index.cjs +6 -4930
  4. package/dist/ast/index.d.cts +11 -72
  5. package/dist/ast/index.d.ts +11 -72
  6. package/dist/ast/index.js +12 -4888
  7. package/dist/browser.cjs +10 -4920
  8. package/dist/browser.d.cts +2 -3
  9. package/dist/browser.d.ts +2 -3
  10. package/dist/browser.js +16 -4883
  11. package/dist/bundler/unplugin.cjs +7 -4968
  12. package/dist/bundler/unplugin.d.cts +4 -2
  13. package/dist/bundler/unplugin.d.ts +1 -1
  14. package/dist/bundler/unplugin.js +12 -4934
  15. package/dist/chunk-24K5NDXH.cjs +370 -0
  16. package/dist/chunk-27HR647Q.js +190 -0
  17. package/dist/chunk-4TDLLEEU.cjs +15 -0
  18. package/dist/chunk-5LCMI2TL.js +575 -0
  19. package/dist/chunk-5M6Z7ZFT.cjs +83 -0
  20. package/dist/chunk-5QD6FZPB.js +197 -0
  21. package/dist/chunk-6N6S6WTQ.cjs +423 -0
  22. package/dist/chunk-7YVEHJVM.cjs +575 -0
  23. package/dist/chunk-GAVI2C44.cjs +197 -0
  24. package/dist/chunk-GZB7PFLY.js +370 -0
  25. package/dist/chunk-J5CGNZDM.cjs +190 -0
  26. package/dist/chunk-KQWNFKT2.js +423 -0
  27. package/dist/{cli/protect.cjs → chunk-LXP73HJC.cjs} +301 -1473
  28. package/dist/chunk-OOXSZTRV.js +18 -0
  29. package/dist/chunk-R6EBIR3T.cjs +14 -0
  30. package/dist/chunk-S4S2WXGC.js +14 -0
  31. package/dist/{cli/protect.js → chunk-UMPUYLLZ.js} +95 -1232
  32. package/dist/chunk-X5MKMFMX.js +83 -0
  33. package/dist/cli/index.cjs +169 -5956
  34. package/dist/cli/index.d.cts +20 -1
  35. package/dist/cli/index.d.ts +20 -1
  36. package/dist/cli/index.js +163 -5911
  37. package/dist/config.cjs +21 -342
  38. package/dist/config.d.cts +2 -2
  39. package/dist/config.d.ts +2 -2
  40. package/dist/config.js +12 -291
  41. package/dist/esbuild.cjs +10 -4972
  42. package/dist/esbuild.d.cts +2 -2
  43. package/dist/esbuild.d.ts +2 -2
  44. package/dist/esbuild.js +8 -4935
  45. package/dist/index.cjs +9 -6408
  46. package/dist/index.d.cts +26 -17
  47. package/dist/index.d.ts +26 -17
  48. package/dist/index.js +20 -6359
  49. package/dist/next/adapter.cjs +16 -5823
  50. package/dist/next/adapter.d.cts +6 -4
  51. package/dist/next/adapter.d.ts +3 -3
  52. package/dist/next/adapter.js +11 -5775
  53. package/dist/next/index.cjs +9 -5856
  54. package/dist/next/index.d.cts +24 -19
  55. package/dist/next/index.d.ts +24 -19
  56. package/dist/next/index.js +13 -5824
  57. package/dist/rollup.cjs +10 -4972
  58. package/dist/rollup.d.cts +2 -2
  59. package/dist/rollup.d.ts +2 -2
  60. package/dist/rollup.js +8 -4935
  61. package/dist/runtime/index.cjs +12 -435
  62. package/dist/runtime/index.d.cts +1 -1
  63. package/dist/runtime/index.d.ts +1 -1
  64. package/dist/runtime/index.js +9 -400
  65. package/dist/{types-CQYBNQND.d.ts → types-BBSRUEab.d.cts} +3 -7
  66. package/dist/{types-CQYBNQND.d.cts → types-BBSRUEab.d.ts} +3 -7
  67. package/dist/vite.cjs +10 -4972
  68. package/dist/vite.d.cts +2 -2
  69. package/dist/vite.d.ts +2 -2
  70. package/dist/vite.js +8 -4935
  71. package/dist/webpack.cjs +10 -4972
  72. package/dist/webpack.d.cts +2 -2
  73. package/dist/webpack.d.ts +2 -2
  74. package/dist/webpack.js +8 -4935
  75. package/package.json +54 -21
  76. package/dist/ast/index.cjs.map +0 -1
  77. package/dist/ast/index.js.map +0 -1
  78. package/dist/browser.cjs.map +0 -1
  79. package/dist/browser.js.map +0 -1
  80. package/dist/bundler/detector.cjs +0 -271
  81. package/dist/bundler/detector.cjs.map +0 -1
  82. package/dist/bundler/detector.d.cts +0 -13
  83. package/dist/bundler/detector.d.ts +0 -13
  84. package/dist/bundler/detector.js +0 -232
  85. package/dist/bundler/detector.js.map +0 -1
  86. package/dist/bundler/sourcemap-vault.cjs +0 -316
  87. package/dist/bundler/sourcemap-vault.cjs.map +0 -1
  88. package/dist/bundler/sourcemap-vault.d.cts +0 -7
  89. package/dist/bundler/sourcemap-vault.d.ts +0 -7
  90. package/dist/bundler/sourcemap-vault.js +0 -280
  91. package/dist/bundler/sourcemap-vault.js.map +0 -1
  92. package/dist/bundler/unplugin.cjs.map +0 -1
  93. package/dist/bundler/unplugin.js.map +0 -1
  94. package/dist/cli/index.cjs.map +0 -1
  95. package/dist/cli/index.js.map +0 -1
  96. package/dist/cli/init.cjs +0 -342
  97. package/dist/cli/init.cjs.map +0 -1
  98. package/dist/cli/init.d.cts +0 -16
  99. package/dist/cli/init.d.ts +0 -16
  100. package/dist/cli/init.js +0 -306
  101. package/dist/cli/init.js.map +0 -1
  102. package/dist/cli/protect.cjs.map +0 -1
  103. package/dist/cli/protect.d.cts +0 -5
  104. package/dist/cli/protect.d.ts +0 -5
  105. package/dist/cli/protect.js.map +0 -1
  106. package/dist/config.cjs.map +0 -1
  107. package/dist/config.js.map +0 -1
  108. package/dist/esbuild.cjs.map +0 -1
  109. package/dist/esbuild.js.map +0 -1
  110. package/dist/index.cjs.map +0 -1
  111. package/dist/index.js.map +0 -1
  112. package/dist/next/adapter.cjs.map +0 -1
  113. package/dist/next/adapter.js.map +0 -1
  114. package/dist/next/index.cjs.map +0 -1
  115. package/dist/next/index.js.map +0 -1
  116. package/dist/next/with-unpeek.cjs +0 -5865
  117. package/dist/next/with-unpeek.cjs.map +0 -1
  118. package/dist/next/with-unpeek.d.cts +0 -2
  119. package/dist/next/with-unpeek.d.ts +0 -2
  120. package/dist/next/with-unpeek.js +0 -5829
  121. package/dist/next/with-unpeek.js.map +0 -1
  122. package/dist/rollup.cjs.map +0 -1
  123. package/dist/rollup.js.map +0 -1
  124. package/dist/runtime/index.cjs.map +0 -1
  125. package/dist/runtime/index.js.map +0 -1
  126. package/dist/vite.cjs.map +0 -1
  127. package/dist/vite.js.map +0 -1
  128. package/dist/webpack.cjs.map +0 -1
  129. package/dist/webpack.js.map +0 -1
@@ -1,79 +1,18 @@
1
- import { HotPathReport, DeterrentMode, TransformOptions, TransformResult } from '../browser.cjs';
2
- import { UnpeekConfig } from '../index.cjs';
3
- import * as acorn from 'acorn';
4
-
5
- interface HotPathAnalysis {
6
- report: HotPathReport;
7
- hotFunctionNodes: WeakSet<acorn.Node>;
8
- coldFunctionNodes: WeakSet<acorn.Node>;
9
- hotExemptNodes: WeakSet<acorn.Node>;
10
- serializedFunctionNodes: WeakSet<acorn.Node>;
1
+ import { UnpeekConfig, HotPathReport, TransformOptions, TransformResult } from '../browser.cjs';
2
+
3
+ type UnpeekErrorCode = 'ERR_CONFIG_INVALID' | 'ERR_CONFIG_LOAD' | 'ERR_INIT_INVALID_PACKAGE_JSON' | 'ERR_SECURITY_PATH_TRAVERSAL' | 'ERR_CLI_INVALID_ARGS' | 'ERR_PARSE_FAILED' | 'ERR_NEXT_ADAPTER';
4
+ declare class UnpeekError extends Error {
5
+ readonly code: UnpeekErrorCode;
6
+ constructor(code: UnpeekErrorCode, message: string, options?: {
7
+ cause?: unknown;
8
+ });
11
9
  }
12
- declare function analyzeAstHotPaths(ast: acorn.Program, config?: UnpeekConfig): HotPathAnalysis;
13
- declare function detectHotPaths(code: string, config?: UnpeekConfig): HotPathReport;
14
10
 
15
11
  declare function computeFnv1aHash(input: string, seed?: number): number;
16
- interface StringVaultResult {
17
- encryptedStringsCount: number;
18
- integrityToken: number;
19
- shaderBuffersCount?: number;
20
- }
21
- declare function applyStringVault(ast: acorn.Program, seed?: number, minStringLength?: number, hotExemptNodes?: WeakSet<acorn.Node>, windowKeySymbol?: string, expectedDelta?: number, deterrentMode?: DeterrentMode, config?: UnpeekConfig, shieldCoupled?: boolean, detectHeadless?: boolean): StringVaultResult;
22
-
23
- declare function applyPolymorphicMangler(ast: acorn.Program, seed?: number, serializedFunctionNodes?: WeakSet<acorn.Node>, config?: UnpeekConfig): number;
24
-
25
- declare function applyColdFlowGuard(ast: acorn.Program, coldFunctionNodes: WeakSet<acorn.Node>, seed?: number, hotExemptNodes?: WeakSet<acorn.Node>): number;
26
-
27
- type PolymorphicRole = 'vault' | 'shield' | 'decoy' | 'shader' | 'vm' | 'wasm' | 'salted' | 'windowKey' | string;
28
- /**
29
- * Deterministically derives a short, collision-free, minify-friendly identifier
30
- * (_a0, $b1, etc.) for a given seed and role, eliminating fixed _uC and _u$ prefixes.
31
- */
32
- declare function derivePolymorphicIdent(seed: number, role: PolymorphicRole): string;
33
- /**
34
- * Generates compact, single-line JavaScript using custom astring rules to eliminate
35
- * redundant whitespace while preserving string literal contents and language semantics.
36
- */
37
- declare function generateCompactJs(ast: any): string;
38
12
 
39
- interface MicroVmResult {
40
- virtualizedCount: number;
41
- vmHelperName: string;
42
- }
43
- /**
44
- * Selective Bytecode Micro-VM virtualization for Layer 2 (--aggressive).
45
- * Selects qualifying cold functions (not serialized, no JSX, no super/yield/arguments/new.target/with, 15 <= N <= 80),
46
- * tracks enclosing AST lexical scopes to capture free local/module bindings as upvalues (OP_LDU/OP_STU),
47
- * transforms their bodies into stateful stream-encrypted bytecode calls, and injects the self-hashed interpreter once.
48
- */
49
- declare function applyMicroVm(ast: acorn.Program, coldFunctionNodes?: Set<acorn.Node> | WeakSet<acorn.Node>, serializedFunctionNodes?: WeakSet<acorn.Node>, seed?: number, windowKeySymbol?: string, expectedDelta?: number): MicroVmResult;
50
-
51
- interface WasmVaultInjectionResult {
52
- kdfFnName: string;
53
- wasmBytes: Uint8Array;
54
- wasmVarName: string;
55
- }
56
- /**
57
- * Injects the synchronous inline WebAssembly KDF key vault into the AST program.
58
- * Falls back transparently to Math.imul on strict CSP runtimes.
59
- */
60
- declare function injectWasmVault(ast: acorn.Program, seed?: number): WasmVaultInjectionResult;
61
-
62
- interface SaltedVaultResult {
63
- encryptedStringsCount: number;
64
- integrityToken: number;
65
- vaultVarName: string;
66
- decryptFnName: string;
67
- }
68
- /**
69
- * Applies idempotent call-site salted lazy string vaulting in Layer 2 (--aggressive).
70
- * Each eligible string access site receives a deterministic static salt constant and is transformed
71
- * into a _uD(idx, localSalt) call.
72
- * Operates with 100% idempotence and order-independence under React 19 Concurrent Mode
73
- * and StrictMode double-mounting.
74
- */
75
- declare function applySaltedStringVault(ast: acorn.Program, seed?: number, minStringLength?: number, hotExemptNodes?: WeakSet<acorn.Node>, config?: UnpeekConfig, windowKeySymbol?: string, expectedDelta?: number, deterrentMode?: DeterrentMode, shieldCoupled?: boolean, detectHeadless?: boolean): SaltedVaultResult;
13
+ declare function detectHotPaths(code: string, config?: UnpeekConfig): HotPathReport;
76
14
 
77
15
  declare function transformJavaScript(code: string, options?: TransformOptions): TransformResult;
78
16
 
79
- export { analyzeAstHotPaths, applyColdFlowGuard, applyMicroVm, applyPolymorphicMangler, applySaltedStringVault, applyStringVault, computeFnv1aHash, derivePolymorphicIdent, detectHotPaths, generateCompactJs, injectWasmVault, transformJavaScript };
17
+ export { UnpeekError, computeFnv1aHash, detectHotPaths, transformJavaScript };
18
+ export type { UnpeekErrorCode };
@@ -1,79 +1,18 @@
1
- import { HotPathReport, DeterrentMode, TransformOptions, TransformResult } from '../browser.js';
2
- import { UnpeekConfig } from '../index.js';
3
- import * as acorn from 'acorn';
4
-
5
- interface HotPathAnalysis {
6
- report: HotPathReport;
7
- hotFunctionNodes: WeakSet<acorn.Node>;
8
- coldFunctionNodes: WeakSet<acorn.Node>;
9
- hotExemptNodes: WeakSet<acorn.Node>;
10
- serializedFunctionNodes: WeakSet<acorn.Node>;
1
+ import { UnpeekConfig, HotPathReport, TransformOptions, TransformResult } from '../browser.js';
2
+
3
+ type UnpeekErrorCode = 'ERR_CONFIG_INVALID' | 'ERR_CONFIG_LOAD' | 'ERR_INIT_INVALID_PACKAGE_JSON' | 'ERR_SECURITY_PATH_TRAVERSAL' | 'ERR_CLI_INVALID_ARGS' | 'ERR_PARSE_FAILED' | 'ERR_NEXT_ADAPTER';
4
+ declare class UnpeekError extends Error {
5
+ readonly code: UnpeekErrorCode;
6
+ constructor(code: UnpeekErrorCode, message: string, options?: {
7
+ cause?: unknown;
8
+ });
11
9
  }
12
- declare function analyzeAstHotPaths(ast: acorn.Program, config?: UnpeekConfig): HotPathAnalysis;
13
- declare function detectHotPaths(code: string, config?: UnpeekConfig): HotPathReport;
14
10
 
15
11
  declare function computeFnv1aHash(input: string, seed?: number): number;
16
- interface StringVaultResult {
17
- encryptedStringsCount: number;
18
- integrityToken: number;
19
- shaderBuffersCount?: number;
20
- }
21
- declare function applyStringVault(ast: acorn.Program, seed?: number, minStringLength?: number, hotExemptNodes?: WeakSet<acorn.Node>, windowKeySymbol?: string, expectedDelta?: number, deterrentMode?: DeterrentMode, config?: UnpeekConfig, shieldCoupled?: boolean, detectHeadless?: boolean): StringVaultResult;
22
-
23
- declare function applyPolymorphicMangler(ast: acorn.Program, seed?: number, serializedFunctionNodes?: WeakSet<acorn.Node>, config?: UnpeekConfig): number;
24
-
25
- declare function applyColdFlowGuard(ast: acorn.Program, coldFunctionNodes: WeakSet<acorn.Node>, seed?: number, hotExemptNodes?: WeakSet<acorn.Node>): number;
26
-
27
- type PolymorphicRole = 'vault' | 'shield' | 'decoy' | 'shader' | 'vm' | 'wasm' | 'salted' | 'windowKey' | string;
28
- /**
29
- * Deterministically derives a short, collision-free, minify-friendly identifier
30
- * (_a0, $b1, etc.) for a given seed and role, eliminating fixed _uC and _u$ prefixes.
31
- */
32
- declare function derivePolymorphicIdent(seed: number, role: PolymorphicRole): string;
33
- /**
34
- * Generates compact, single-line JavaScript using custom astring rules to eliminate
35
- * redundant whitespace while preserving string literal contents and language semantics.
36
- */
37
- declare function generateCompactJs(ast: any): string;
38
12
 
39
- interface MicroVmResult {
40
- virtualizedCount: number;
41
- vmHelperName: string;
42
- }
43
- /**
44
- * Selective Bytecode Micro-VM virtualization for Layer 2 (--aggressive).
45
- * Selects qualifying cold functions (not serialized, no JSX, no super/yield/arguments/new.target/with, 15 <= N <= 80),
46
- * tracks enclosing AST lexical scopes to capture free local/module bindings as upvalues (OP_LDU/OP_STU),
47
- * transforms their bodies into stateful stream-encrypted bytecode calls, and injects the self-hashed interpreter once.
48
- */
49
- declare function applyMicroVm(ast: acorn.Program, coldFunctionNodes?: Set<acorn.Node> | WeakSet<acorn.Node>, serializedFunctionNodes?: WeakSet<acorn.Node>, seed?: number, windowKeySymbol?: string, expectedDelta?: number): MicroVmResult;
50
-
51
- interface WasmVaultInjectionResult {
52
- kdfFnName: string;
53
- wasmBytes: Uint8Array;
54
- wasmVarName: string;
55
- }
56
- /**
57
- * Injects the synchronous inline WebAssembly KDF key vault into the AST program.
58
- * Falls back transparently to Math.imul on strict CSP runtimes.
59
- */
60
- declare function injectWasmVault(ast: acorn.Program, seed?: number): WasmVaultInjectionResult;
61
-
62
- interface SaltedVaultResult {
63
- encryptedStringsCount: number;
64
- integrityToken: number;
65
- vaultVarName: string;
66
- decryptFnName: string;
67
- }
68
- /**
69
- * Applies idempotent call-site salted lazy string vaulting in Layer 2 (--aggressive).
70
- * Each eligible string access site receives a deterministic static salt constant and is transformed
71
- * into a _uD(idx, localSalt) call.
72
- * Operates with 100% idempotence and order-independence under React 19 Concurrent Mode
73
- * and StrictMode double-mounting.
74
- */
75
- declare function applySaltedStringVault(ast: acorn.Program, seed?: number, minStringLength?: number, hotExemptNodes?: WeakSet<acorn.Node>, config?: UnpeekConfig, windowKeySymbol?: string, expectedDelta?: number, deterrentMode?: DeterrentMode, shieldCoupled?: boolean, detectHeadless?: boolean): SaltedVaultResult;
13
+ declare function detectHotPaths(code: string, config?: UnpeekConfig): HotPathReport;
76
14
 
77
15
  declare function transformJavaScript(code: string, options?: TransformOptions): TransformResult;
78
16
 
79
- export { analyzeAstHotPaths, applyColdFlowGuard, applyMicroVm, applyPolymorphicMangler, applySaltedStringVault, applyStringVault, computeFnv1aHash, derivePolymorphicIdent, detectHotPaths, generateCompactJs, injectWasmVault, transformJavaScript };
17
+ export { UnpeekError, computeFnv1aHash, detectHotPaths, transformJavaScript };
18
+ export type { UnpeekErrorCode };