unpeek 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +278 -246
- package/README.tr.md +260 -0
- package/bin/unpeek.mjs +7 -7
- package/dist/ast/index.cjs +802 -0
- package/dist/ast/index.cjs.map +1 -0
- package/dist/ast/index.d.cts +9 -0
- package/dist/ast/index.d.ts +9 -4
- package/dist/ast/index.js +762 -52
- package/dist/ast/index.js.map +1 -0
- package/dist/browser.cjs +816 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +3 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +773 -0
- package/dist/browser.js.map +1 -0
- package/dist/bundler/detector.cjs +180 -0
- package/dist/bundler/detector.cjs.map +1 -0
- package/dist/bundler/detector.d.cts +9 -0
- package/dist/bundler/detector.d.ts +6 -3
- package/dist/bundler/detector.js +130 -135
- package/dist/bundler/detector.js.map +1 -0
- package/dist/bundler/sourcemap-vault.cjs +210 -0
- package/dist/bundler/sourcemap-vault.cjs.map +1 -0
- package/dist/bundler/sourcemap-vault.d.cts +6 -0
- package/dist/bundler/sourcemap-vault.d.ts +6 -2
- package/dist/bundler/sourcemap-vault.js +161 -85
- package/dist/bundler/sourcemap-vault.js.map +1 -0
- package/dist/bundler/unplugin.cjs +848 -0
- package/dist/bundler/unplugin.cjs.map +1 -0
- package/dist/bundler/unplugin.d.cts +14 -0
- package/dist/bundler/unplugin.d.ts +14 -7
- package/dist/bundler/unplugin.js +805 -51
- package/dist/bundler/unplugin.js.map +1 -0
- package/dist/cli/index.cjs +1361 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +3 -0
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +1300 -85
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.cjs +200 -0
- package/dist/cli/init.cjs.map +1 -0
- package/dist/cli/init.d.cts +13 -0
- package/dist/cli/init.d.ts +10 -2
- package/dist/cli/init.js +162 -46
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/protect.cjs +1147 -0
- package/dist/cli/protect.cjs.map +1 -0
- package/dist/cli/protect.d.cts +5 -0
- package/dist/cli/protect.d.ts +5 -2
- package/dist/cli/protect.js +1107 -83
- package/dist/cli/protect.js.map +1 -0
- package/dist/esbuild.cjs +844 -0
- package/dist/esbuild.cjs.map +1 -0
- package/dist/esbuild.d.cts +11 -0
- package/dist/esbuild.d.ts +11 -0
- package/dist/esbuild.js +807 -0
- package/dist/esbuild.js.map +1 -0
- package/dist/index.cjs +1453 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +1395 -8
- package/dist/index.js.map +1 -0
- package/dist/rollup.cjs +844 -0
- package/dist/rollup.cjs.map +1 -0
- package/dist/rollup.d.cts +11 -0
- package/dist/rollup.d.ts +11 -0
- package/dist/rollup.js +807 -0
- package/dist/rollup.js.map +1 -0
- package/dist/runtime/index.cjs +88 -0
- package/dist/runtime/index.cjs.map +1 -0
- package/dist/runtime/index.d.cts +23 -0
- package/dist/runtime/index.d.ts +23 -4
- package/dist/runtime/index.js +57 -15
- package/dist/runtime/index.js.map +1 -0
- package/dist/{types.d.ts → types-BTMkXmVE.d.cts} +14 -12
- package/dist/types-BTMkXmVE.d.ts +73 -0
- package/dist/vite.cjs +844 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +11 -0
- package/dist/vite.d.ts +11 -0
- package/dist/vite.js +807 -0
- package/dist/vite.js.map +1 -0
- package/dist/webpack.cjs +844 -0
- package/dist/webpack.cjs.map +1 -0
- package/dist/webpack.d.cts +11 -0
- package/dist/webpack.d.ts +11 -0
- package/dist/webpack.js +807 -0
- package/dist/webpack.js.map +1 -0
- package/package.json +164 -67
- package/dist/ast/cold-flow-guard.d.ts +0 -2
- package/dist/ast/cold-flow-guard.js +0 -39
- package/dist/ast/hot-path-detector.d.ts +0 -10
- package/dist/ast/hot-path-detector.js +0 -235
- package/dist/ast/polymorphic-mangler.d.ts +0 -2
- package/dist/ast/polymorphic-mangler.js +0 -270
- package/dist/ast/string-vault.d.ts +0 -7
- package/dist/ast/string-vault.js +0 -139
- package/dist/runtime/devtools-deterrent.d.ts +0 -7
- package/dist/runtime/devtools-deterrent.js +0 -27
- package/dist/runtime/integrity-guard.d.ts +0 -11
- package/dist/runtime/integrity-guard.js +0 -25
- package/dist/types.js +0 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Efe Arabacı & unpeek contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Efe Arabacı & unpeek contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,246 +1,278 @@
|
|
|
1
|
-
# unpeek
|
|
2
|
-
|
|
3
|
-
**Zero-config, call-graph-aware polymorphic JavaScript protection and runtime anti-tamper toolkit with <2% CPU overhead.**
|
|
4
|
-
|
|
5
|
-
[](LICENSE)
|
|
6
|
-
[](packages/unpeek/benchmarks/overhead.bench.ts)
|
|
7
|
-
[](packages/unpeek/benchmarks/overhead.bench.ts)
|
|
8
|
-
[](https://woffluon.github.io/unpeek)
|
|
9
|
-
|
|
10
|
-
English | [Türkçe](./README.tr.md) · [Live Interactive Playground](https://woffluon.github.io/unpeek) · [Agent Architecture Guide](./AGENTS.md) · [AI Skill](./skills/unpeek/SKILL.md)
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
| **
|
|
29
|
-
| **
|
|
30
|
-
| **
|
|
31
|
-
| **
|
|
32
|
-
| **
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
import
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
#
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
```bash
|
|
219
|
-
#
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
1
|
+
# unpeek
|
|
2
|
+
|
|
3
|
+
**Zero-config, call-graph-aware polymorphic JavaScript protection and runtime anti-tamper toolkit with <2% CPU overhead.**
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](packages/unpeek/benchmarks/overhead.bench.ts)
|
|
7
|
+
[](packages/unpeek/benchmarks/overhead.bench.ts)
|
|
8
|
+
[](https://woffluon.github.io/unpeek)
|
|
9
|
+
|
|
10
|
+
English | [Türkçe](./README.tr.md) · [Live Interactive Playground](https://woffluon.github.io/unpeek) · [Agent Architecture Guide](./AGENTS.md) · [AI Skill](./skills/unpeek/SKILL.md)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Why unpeek?
|
|
15
|
+
|
|
16
|
+
Deploying a web application built with Next.js, Vite, or Webpack exposes client-side business logic, internal API endpoints, feature flags, and proprietary algorithms to anyone who opens browser developer tools or runs automated AST deobfuscators like `webcrack` or `synchrony`.
|
|
17
|
+
|
|
18
|
+
Existing tools force an uncomfortable trade-off:
|
|
19
|
+
- **Standard minifiers (`esbuild`, `SWC`, `Terser`):** Compress whitespace and shorten variable names, leaving string literals, endpoint URLs, and control flow readable after a single click on the DevTools Pretty-Print (`{}`) button.
|
|
20
|
+
- **Legacy AST obfuscators (`javascript-obfuscator`):** Apply indiscriminate control-flow flattening, `eval` traps, and eager string-array rotation across every function in the bundle. This inflates bundle sizes by 40% to 300%, degrades V8 TurboFan JIT inlining in 60fps UI rendering loops, and triggers browser freezes.
|
|
21
|
+
|
|
22
|
+
`unpeek` resolves this trade-off by combining static call-graph analysis with polymorphic compile-time encryption:
|
|
23
|
+
|
|
24
|
+
| Capability | Standard Minifiers (`Terser` / `SWC`) | Legacy AST Obfuscators | `unpeek` |
|
|
25
|
+
| :--- | :--- | :--- | :--- |
|
|
26
|
+
| **Runtime CPU Overhead** | ~0% | 15% to 85% (throttles UI loops) | **< 2.0%** (Call-Graph Hot-Path Exemption) |
|
|
27
|
+
| **Gzip Bundle Growth** | 0% (Baseline) | +45% to +300% | **< 15%** (O(1) Lazy String Vault) |
|
|
28
|
+
| **String & Endpoint Encryption** | Plaintext in bundle | Eager array rotation (high CPU) | **Polymorphic XOR + O(1) Memoized Vault** |
|
|
29
|
+
| **DevTools Pretty-Print (`{}`) Defense** | None | `debugger` infinite loops (easily bypassed) | **`Function.prototype.toString()` FNV-1a Integrity** |
|
|
30
|
+
| **Source Map Isolation** | Manual CI scripts | Manual configuration | **Automatic `.unpeek-maps/` Vault + Comment Strip** |
|
|
31
|
+
| **Static Deobfuscator Resistance** | None | Fixed templates (fingerprinted by deobfuscators) | **Per-Build Polymorphic AST Seed** |
|
|
32
|
+
| **SSR / Next.js Compatibility** | Native | Frequently breaks server hydration | **Client-Only Auto-Detection + SSR Guard** |
|
|
33
|
+
|
|
34
|
+
### Core Architecture
|
|
35
|
+
|
|
36
|
+
```mermaid
|
|
37
|
+
flowchart TD
|
|
38
|
+
A["Client Build Output (.next/static, dist/assets, build/static)"] --> B["Framework Detector (detectTargetFramework)"]
|
|
39
|
+
B --> C["Source Map Vault (relocateSourceMaps)"]
|
|
40
|
+
C -->|Extract .map and strip sourceMappingURL| D[".unpeek-maps/ (Private Vault)"]
|
|
41
|
+
C --> E["Client JS Bundles (.js, .mjs)"]
|
|
42
|
+
E --> F["AST Hot-Path Traversal (detectHotPaths)"]
|
|
43
|
+
F -->|Loops, Array Callbacks, UI Renders| G["Hot Path: 0% Tax (Skip Opaque Predicates)"]
|
|
44
|
+
F -->|Cold Functions: Auth, Licensing, Signers| H["Cold Path: Opaque Control-Flow Predicates"]
|
|
45
|
+
G --> I["Polymorphic String Vault (O(1) Lazy XOR)"]
|
|
46
|
+
H --> I
|
|
47
|
+
I --> J["Identifier and Symbol Mangling"]
|
|
48
|
+
J --> K["Runtime Integrity Shield (FNV-1a Checksum)"]
|
|
49
|
+
K --> L["Hardened Production Bundles"]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
1. **Call-Graph Hot-Path Exemption (`<2%` CPU Budget)**
|
|
53
|
+
Before modifying an AST node, [`detectHotPaths`](packages/unpeek/src/ast/index.ts) traverses the file call graph. Functions containing loops (`for`, `while`, `do-while`, `for-of`), array higher-order callbacks (`.map`, `.filter`, `.reduce`, `.forEach`), `requestAnimationFrame` tickers, and React/UI render components (`useState`, `useEffect`, `createElement`) are flagged as hot paths. `unpeek` mangles identifiers and encrypts string constants across the entire bundle, while injecting opaque control-flow predicates exclusively into cold functions (such as license checks, request signers, and auth validators). V8 JIT optimization inside hot loops remains untouched.
|
|
54
|
+
2. **O(1) Lazy String Vault (`<15%` Gzip Budget)**
|
|
55
|
+
Plaintext string literals (`minStringLength >= 4`) are encrypted at build time with a polymorphic XOR stream cipher keyed by a per-build 32-bit seed. Instead of decrypting every string on page startup, the injected vault helper decodes each string lazily on its first access and caches the plaintext result in its array slot. Subsequent reads resolve in O(1) time through direct array indexing.
|
|
56
|
+
3. **Self-Defending `Function.prototype.toString()` Integrity and Passive Deterrent**
|
|
57
|
+
When an analyst formats a protected chunk using DevTools Pretty-Print (`{}`) or edits a branch instruction in the Sources panel, the formatted source alters `Function.prototype.toString()`. [`verifyCodeIntegrity`](packages/unpeek/src/runtime/index.ts) validates a seeded 32-bit FNV-1a checksum against the function source representation with zero false positives on untouched minified code, triggering gradual state degradation (`deterrentMode: 'gradual'`) rather than an obvious crash point that attackers can patch out.
|
|
58
|
+
4. **Automatic Source Map Vault (`.unpeek-maps/`)**
|
|
59
|
+
Leaving `.js.map` files in a public build directory reconstructs your original TypeScript project tree inside DevTools. [`protectProject`](packages/unpeek/src/cli/protect.ts) extracts `.map` files from your public build directory into a private `.unpeek-maps/` folder and strips `//# sourceMappingURL=` comments from every client bundle so you can upload maps to Sentry or Datadog without serving them to end users.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
### 1. Project Setup (`npx unpeek init`)
|
|
66
|
+
|
|
67
|
+
Run the initializer from your project root (Next.js, Vite, Webpack, or vanilla JS):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx unpeek init
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This command performs three setup actions:
|
|
74
|
+
1. Detects your framework (`nextjs`, `vite`, `webpack`, or `vanilla`) from `package.json` and build config files.
|
|
75
|
+
2. Adds `"postbuild": "unpeek protect"` to your `package.json` scripts so every production build is automatically protected.
|
|
76
|
+
3. Appends `.unpeek-maps/` to `.gitignore` so extracted source maps stay out of version control.
|
|
77
|
+
|
|
78
|
+
### 2. CLI Usage (`unpeek protect`)
|
|
79
|
+
|
|
80
|
+
Install `unpeek` as a development dependency and run it directly in CI/CD or local builds:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm install -D unpeek
|
|
84
|
+
npx unpeek protect
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### CLI Commands & Options
|
|
88
|
+
|
|
89
|
+
| Command / Flag | Description | Default |
|
|
90
|
+
| :--- | :--- | :--- |
|
|
91
|
+
| `init [--dry-run]` | Automatically detect project framework, configure `postbuild` script, and create `.unpeek-maps/` vault | |
|
|
92
|
+
| `protect` | Protect production client bundles in-place (default command) | |
|
|
93
|
+
| `--out-dir <path>` | Explicit client output directory override (e.g., `dist/assets`, `.next/static/chunks`) | Auto-detected from project framework |
|
|
94
|
+
| `--seed <number>` | Deterministic 32-bit polymorphic build seed | Random per build |
|
|
95
|
+
| `--passive` | Use passive deterrent mode instead of gradual state degradation | Default: gradual degradation |
|
|
96
|
+
| `--no-maps` | Permanently delete `.map` files instead of moving them to `.unpeek-maps/` | Moves to `.unpeek-maps/` |
|
|
97
|
+
| `--min-string-length <num>` | Minimum string length for lazy encryption vault | `4` |
|
|
98
|
+
| `--private-maps-dir <dir>` | Directory to store vaulted private source maps | `.unpeek-maps` |
|
|
99
|
+
| `--no-shield` | Do not inject runtime anti-tamper deterrent shield | Shield injected into entry chunks |
|
|
100
|
+
| `-h, --help` | Show CLI help message | |
|
|
101
|
+
| `-v, --version` | Show CLI version number | |
|
|
102
|
+
|
|
103
|
+
> [!NOTE]
|
|
104
|
+
> Programmatic execution through `protectProject(options)` supports additional fine-grained options, including `minStringLength`, `privateMapsDir`, `injectRuntimeShield`, and `cwd`.
|
|
105
|
+
|
|
106
|
+
> [!IMPORTANT]
|
|
107
|
+
> **CommonJS Users (Dynamic `import()`):**
|
|
108
|
+
> Because `unpeek` is distributed with native ECMAScript Modules (`"type": "module"`), in CommonJS environments (`.cjs` files or `require()` scripts) load `unpeek` using dynamic `import()`:
|
|
109
|
+
> ```javascript
|
|
110
|
+
> // CommonJS (next.config.js / webpack.config.js / scripts)
|
|
111
|
+
> const unpeek = (await import('unpeek/unplugin')).default;
|
|
112
|
+
> const { protectProject, transformJavaScript } = await import('unpeek');
|
|
113
|
+
> ```
|
|
114
|
+
|
|
115
|
+
### 3. Universal Bundler Plugin (`unpeek/unplugin`)
|
|
116
|
+
|
|
117
|
+
For in-memory chunk transformations during the bundler build lifecycle rather than a post-build CLI pass, use [`unpeek/unplugin`](packages/unpeek/src/bundler/unplugin.ts):
|
|
118
|
+
|
|
119
|
+
#### Vite (`vite.config.ts`)
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import { defineConfig } from 'vite';
|
|
123
|
+
import unpeek from 'unpeek/unplugin';
|
|
124
|
+
|
|
125
|
+
export default defineConfig({
|
|
126
|
+
plugins: [
|
|
127
|
+
unpeek.vite({
|
|
128
|
+
deterrentMode: 'gradual',
|
|
129
|
+
}),
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Next.js (`next.config.mjs`)
|
|
135
|
+
|
|
136
|
+
Scope the plugin to client bundles (`!isServer`) so Node.js server chunks keep their native stack traces:
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
import unpeek from 'unpeek/unplugin';
|
|
140
|
+
|
|
141
|
+
/** @type {import('next').NextConfig} */
|
|
142
|
+
const nextConfig = {
|
|
143
|
+
webpack(config, { dev, isServer }) {
|
|
144
|
+
if (!dev && !isServer) {
|
|
145
|
+
config.plugins.push(
|
|
146
|
+
unpeek.webpack({
|
|
147
|
+
deterrentMode: 'gradual',
|
|
148
|
+
})
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
return config;
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default nextConfig;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### Programmatic API
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { transformJavaScript, protectProject } from 'unpeek';
|
|
162
|
+
|
|
163
|
+
// Transform an individual JavaScript string in memory
|
|
164
|
+
const result = transformJavaScript(sourceCode, {
|
|
165
|
+
seed: 0x7f3a91,
|
|
166
|
+
minStringLength: 4,
|
|
167
|
+
injectRuntimeShield: true,
|
|
168
|
+
deterrentMode: 'gradual',
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
console.log(result.hotPathReport);
|
|
172
|
+
// { totalFunctions: 12, hotFunctionsSkipped: ['renderLoop'], coldFunctionsProtected: ['signRequest'] }
|
|
173
|
+
|
|
174
|
+
// Or protect an entire build directory
|
|
175
|
+
const summary = await protectProject({
|
|
176
|
+
cwd: process.cwd(),
|
|
177
|
+
keepPrivateMaps: true,
|
|
178
|
+
privateMapsDir: '.unpeek-maps',
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## `.unpeek-maps/` Source Map Vault & Sentry Workflow
|
|
185
|
+
|
|
186
|
+
When `keepPrivateMaps` is enabled (the default), `unpeek` relocates all `.js.map` files from your public output directory into `.unpeek-maps/` while preserving relative filenames, and strips `//# sourceMappingURL=` directives from public `.js` chunks.
|
|
187
|
+
|
|
188
|
+
To retain full stack-trace symbolication in production error trackers:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# 1. Build your app and run unpeek (automatically triggered if wired via postbuild)
|
|
192
|
+
npm run build
|
|
193
|
+
|
|
194
|
+
# 2. Upload the private source maps from .unpeek-maps/ to Sentry or Datadog
|
|
195
|
+
npx @sentry/cli sourcemaps upload .unpeek-maps --release="$GIT_COMMIT_SHA"
|
|
196
|
+
|
|
197
|
+
# 3. Deploy your public build folder (.next/, dist/, or build/)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Official AI Agent Skill Installation
|
|
203
|
+
|
|
204
|
+
`unpeek` ships with an official, token-optimized AI Agent Skill ([`skills/unpeek/SKILL.md`](skills/unpeek/SKILL.md)) following Agent Skills Discovery Optimization (SDO) standards. Installing this skill teaches your coding agent (Claude Code, Cursor, Antigravity, OpenAI Codex, or Gemini CLI) how to configure `unpeek`, guard SSR chunks, and wire `.unpeek-maps/` into CI/CD pipelines.
|
|
205
|
+
|
|
206
|
+
### Project-Scoped Installation (Shared with Team via Git)
|
|
207
|
+
|
|
208
|
+
Copy the skill into your repository `.agents/skills/unpeek/` directory:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
mkdir -p .agents/skills/unpeek
|
|
212
|
+
curl -fsSL https://raw.githubusercontent.com/Woffluon/unpeek/main/skills/unpeek/SKILL.md \
|
|
213
|
+
-o .agents/skills/unpeek/SKILL.md
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Global Machine Installation (Antigravity / Gemini CLI / Claude Code)
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Antigravity & Gemini CLI
|
|
220
|
+
mkdir -p ~/.gemini/config/skills/unpeek
|
|
221
|
+
curl -fsSL https://raw.githubusercontent.com/Woffluon/unpeek/main/skills/unpeek/SKILL.md \
|
|
222
|
+
-o ~/.gemini/config/skills/unpeek/SKILL.md
|
|
223
|
+
|
|
224
|
+
# Cross-agent standard (~/.agents/skills)
|
|
225
|
+
mkdir -p ~/.agents/skills/unpeek
|
|
226
|
+
curl -fsSL https://raw.githubusercontent.com/Woffluon/unpeek/main/skills/unpeek/SKILL.md \
|
|
227
|
+
-o ~/.agents/skills/unpeek/SKILL.md
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Verification, Testing & Benchmarks
|
|
233
|
+
|
|
234
|
+
This monorepo is managed with `pnpm` and verified against strict semantic equivalence, deobfuscation resistance, and runtime overhead budgets:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Install workspace dependencies
|
|
238
|
+
pnpm install
|
|
239
|
+
|
|
240
|
+
# Run unit and reverse-engineering resistance test suites (Vitest)
|
|
241
|
+
pnpm test
|
|
242
|
+
|
|
243
|
+
# Run unit tests with V8 code coverage report
|
|
244
|
+
pnpm --filter unpeek run test:coverage
|
|
245
|
+
|
|
246
|
+
# Run the V8 VM CPU overhead (<2%) and Gzip delta (<15%) benchmark
|
|
247
|
+
pnpm bench
|
|
248
|
+
|
|
249
|
+
# Run strict TypeScript typechecking across packages/unpeek and apps/web
|
|
250
|
+
pnpm typecheck
|
|
251
|
+
|
|
252
|
+
# Build the core package and static interactive web playground
|
|
253
|
+
pnpm build
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Monorepo Scripts & Release Integrity
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Verify Conventional Commit version calculation
|
|
260
|
+
powershell -File scripts/test-versioning.ps1
|
|
261
|
+
|
|
262
|
+
# Validate release readiness against planned commit message
|
|
263
|
+
powershell -File scripts/validate-version.ps1 -Message "fix: description"
|
|
264
|
+
|
|
265
|
+
# Stage release artifacts and compute SHA-256 manifests
|
|
266
|
+
powershell -File scripts/stage-release.ps1
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Benchmark Output Reference ([`packages/unpeek/benchmarks/overhead.bench.ts`](packages/unpeek/benchmarks/overhead.bench.ts))
|
|
270
|
+
|
|
271
|
+
- **Build / Transform Time:** `< 3000 ms`
|
|
272
|
+
- **Gzip Size Delta:** `< 15%` on production application bundles
|
|
273
|
+
- **Runtime CPU Overhead:** `< 2.00%` (interleaved multi-round V8 JIT benchmark)
|
|
274
|
+
- **Plaintext Leak Rate:** `0%` for string literals meeting `minStringLength`
|
|
275
|
+
|
|
276
|
+
## License
|
|
277
|
+
|
|
278
|
+
Released under the [MIT License](./LICENSE).
|