unpeek 1.0.1 → 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/README.md +82 -50
- package/README.tr.md +260 -0
- 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 +1309 -94
- 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 +104 -7
- 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/README.md
CHANGED
|
@@ -11,83 +11,110 @@ English | [Türkçe](./README.tr.md) · [Live Interactive Playground](https://wo
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
<baglam>
|
|
15
|
-
|
|
16
14
|
## Why unpeek?
|
|
17
15
|
|
|
18
|
-
|
|
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`.
|
|
19
17
|
|
|
20
18
|
Existing tools force an uncomfortable trade-off:
|
|
21
|
-
- **Standard minifiers (`esbuild`, `SWC`, `Terser`)
|
|
22
|
-
- **Legacy AST obfuscators (`javascript-obfuscator`)
|
|
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.
|
|
23
21
|
|
|
24
22
|
`unpeek` resolves this trade-off by combining static call-graph analysis with polymorphic compile-time encryption:
|
|
25
23
|
|
|
26
24
|
| Capability | Standard Minifiers (`Terser` / `SWC`) | Legacy AST Obfuscators | `unpeek` |
|
|
27
25
|
| :--- | :--- | :--- | :--- |
|
|
28
|
-
| **Runtime CPU Overhead** | ~0% | 15%
|
|
29
|
-
| **Gzip Bundle Growth** | 0% (Baseline) | +45%
|
|
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) |
|
|
30
28
|
| **String & Endpoint Encryption** | Plaintext in bundle | Eager array rotation (high CPU) | **Polymorphic XOR + O(1) Memoized Vault** |
|
|
31
29
|
| **DevTools Pretty-Print (`{}`) Defense** | None | `debugger` infinite loops (easily bypassed) | **`Function.prototype.toString()` FNV-1a Integrity** |
|
|
32
30
|
| **Source Map Isolation** | Manual CI scripts | Manual configuration | **Automatic `.unpeek-maps/` Vault + Comment Strip** |
|
|
33
|
-
| **Static Deobfuscator Resistance** | None | Fixed templates (fingerprinted by
|
|
31
|
+
| **Static Deobfuscator Resistance** | None | Fixed templates (fingerprinted by deobfuscators) | **Per-Build Polymorphic AST Seed** |
|
|
34
32
|
| **SSR / Next.js Compatibility** | Native | Frequently breaks server hydration | **Client-Only Auto-Detection + SSR Guard** |
|
|
35
33
|
|
|
36
34
|
### Core Architecture
|
|
37
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
|
+
|
|
38
52
|
1. **Call-Graph Hot-Path Exemption (`<2%` CPU Budget)**
|
|
39
|
-
Before modifying
|
|
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.
|
|
40
54
|
2. **O(1) Lazy String Vault (`<15%` Gzip Budget)**
|
|
41
|
-
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
|
|
42
|
-
3. **Self-Defending `Function.prototype.toString()` Integrity
|
|
43
|
-
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
|
|
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.
|
|
44
58
|
4. **Automatic Source Map Vault (`.unpeek-maps/`)**
|
|
45
|
-
Leaving `.js.map` files in a public build directory reconstructs your original TypeScript project tree inside DevTools. [`
|
|
46
|
-
|
|
47
|
-
</baglam>
|
|
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.
|
|
48
60
|
|
|
49
61
|
---
|
|
50
62
|
|
|
51
|
-
<talimat>
|
|
52
|
-
|
|
53
63
|
## Quick Start
|
|
54
64
|
|
|
55
|
-
### 1.
|
|
65
|
+
### 1. Project Setup (`npx unpeek init`)
|
|
56
66
|
|
|
57
|
-
Run the initializer from your project root (Next.js, Vite, Webpack, or vanilla):
|
|
67
|
+
Run the initializer from your project root (Next.js, Vite, Webpack, or vanilla JS):
|
|
58
68
|
|
|
59
69
|
```bash
|
|
60
70
|
npx unpeek init
|
|
61
71
|
```
|
|
62
72
|
|
|
63
|
-
This command performs three
|
|
73
|
+
This command performs three setup actions:
|
|
64
74
|
1. Detects your framework (`nextjs`, `vite`, `webpack`, or `vanilla`) from `package.json` and build config files.
|
|
65
75
|
2. Adds `"postbuild": "unpeek protect"` to your `package.json` scripts so every production build is automatically protected.
|
|
66
76
|
3. Appends `.unpeek-maps/` to `.gitignore` so extracted source maps stay out of version control.
|
|
67
77
|
|
|
68
78
|
### 2. CLI Usage (`unpeek protect`)
|
|
69
79
|
|
|
70
|
-
|
|
80
|
+
Install `unpeek` as a development dependency and run it directly in CI/CD or local builds:
|
|
71
81
|
|
|
72
82
|
```bash
|
|
73
83
|
npm install -D unpeek
|
|
74
84
|
npx unpeek protect
|
|
75
85
|
```
|
|
76
86
|
|
|
77
|
-
#### CLI Options
|
|
87
|
+
#### CLI Commands & Options
|
|
78
88
|
|
|
79
|
-
| Flag | Description | Default |
|
|
89
|
+
| Command / Flag | Description | Default |
|
|
80
90
|
| :--- | :--- | :--- |
|
|
81
|
-
|
|
|
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 |
|
|
82
94
|
| `--seed <number>` | Deterministic 32-bit polymorphic build seed | Random per build |
|
|
83
|
-
| `--
|
|
84
|
-
| `--
|
|
85
|
-
| `--
|
|
86
|
-
| `--
|
|
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
|
+
> ```
|
|
87
114
|
|
|
88
115
|
### 3. Universal Bundler Plugin (`unpeek/unplugin`)
|
|
89
116
|
|
|
90
|
-
|
|
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):
|
|
91
118
|
|
|
92
119
|
#### Vite (`vite.config.ts`)
|
|
93
120
|
|
|
@@ -96,13 +123,9 @@ import { defineConfig } from 'vite';
|
|
|
96
123
|
import unpeek from 'unpeek/unplugin';
|
|
97
124
|
|
|
98
125
|
export default defineConfig({
|
|
99
|
-
build: {
|
|
100
|
-
sourcemap: true, // Extracted into .unpeek-maps/ automatically
|
|
101
|
-
},
|
|
102
126
|
plugins: [
|
|
103
127
|
unpeek.vite({
|
|
104
128
|
deterrentMode: 'gradual',
|
|
105
|
-
keepPrivateMaps: true,
|
|
106
129
|
}),
|
|
107
130
|
],
|
|
108
131
|
});
|
|
@@ -122,7 +145,6 @@ const nextConfig = {
|
|
|
122
145
|
config.plugins.push(
|
|
123
146
|
unpeek.webpack({
|
|
124
147
|
deterrentMode: 'gradual',
|
|
125
|
-
keepPrivateMaps: true,
|
|
126
148
|
})
|
|
127
149
|
);
|
|
128
150
|
}
|
|
@@ -136,7 +158,7 @@ export default nextConfig;
|
|
|
136
158
|
#### Programmatic API
|
|
137
159
|
|
|
138
160
|
```ts
|
|
139
|
-
import { transformJavaScript,
|
|
161
|
+
import { transformJavaScript, protectProject } from 'unpeek';
|
|
140
162
|
|
|
141
163
|
// Transform an individual JavaScript string in memory
|
|
142
164
|
const result = transformJavaScript(sourceCode, {
|
|
@@ -150,7 +172,7 @@ console.log(result.hotPathReport);
|
|
|
150
172
|
// { totalFunctions: 12, hotFunctionsSkipped: ['renderLoop'], coldFunctionsProtected: ['signRequest'] }
|
|
151
173
|
|
|
152
174
|
// Or protect an entire build directory
|
|
153
|
-
const summary = await
|
|
175
|
+
const summary = await protectProject({
|
|
154
176
|
cwd: process.cwd(),
|
|
155
177
|
keepPrivateMaps: true,
|
|
156
178
|
privateMapsDir: '.unpeek-maps',
|
|
@@ -161,7 +183,7 @@ const summary = await protectDirectory({
|
|
|
161
183
|
|
|
162
184
|
## `.unpeek-maps/` Source Map Vault & Sentry Workflow
|
|
163
185
|
|
|
164
|
-
When `keepPrivateMaps` is enabled (the default), `unpeek` relocates all `.js.map` files from your public output directory into `.unpeek-maps/` while preserving
|
|
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.
|
|
165
187
|
|
|
166
188
|
To retain full stack-trace symbolication in production error trackers:
|
|
167
189
|
|
|
@@ -183,7 +205,7 @@ npx @sentry/cli sourcemaps upload .unpeek-maps --release="$GIT_COMMIT_SHA"
|
|
|
183
205
|
|
|
184
206
|
### Project-Scoped Installation (Shared with Team via Git)
|
|
185
207
|
|
|
186
|
-
Copy the skill into your repository
|
|
208
|
+
Copy the skill into your repository `.agents/skills/unpeek/` directory:
|
|
187
209
|
|
|
188
210
|
```bash
|
|
189
211
|
mkdir -p .agents/skills/unpeek
|
|
@@ -205,12 +227,8 @@ curl -fsSL https://raw.githubusercontent.com/Woffluon/unpeek/main/skills/unpeek/
|
|
|
205
227
|
-o ~/.agents/skills/unpeek/SKILL.md
|
|
206
228
|
```
|
|
207
229
|
|
|
208
|
-
</talimat>
|
|
209
|
-
|
|
210
230
|
---
|
|
211
231
|
|
|
212
|
-
<dogrulama>
|
|
213
|
-
|
|
214
232
|
## Verification, Testing & Benchmarks
|
|
215
233
|
|
|
216
234
|
This monorepo is managed with `pnpm` and verified against strict semantic equivalence, deobfuscation resistance, and runtime overhead budgets:
|
|
@@ -219,10 +237,13 @@ This monorepo is managed with `pnpm` and verified against strict semantic equiva
|
|
|
219
237
|
# Install workspace dependencies
|
|
220
238
|
pnpm install
|
|
221
239
|
|
|
222
|
-
# Run unit
|
|
240
|
+
# Run unit and reverse-engineering resistance test suites (Vitest)
|
|
223
241
|
pnpm test
|
|
224
242
|
|
|
225
|
-
# Run
|
|
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
|
|
226
247
|
pnpm bench
|
|
227
248
|
|
|
228
249
|
# Run strict TypeScript typechecking across packages/unpeek and apps/web
|
|
@@ -232,14 +253,25 @@ pnpm typecheck
|
|
|
232
253
|
pnpm build
|
|
233
254
|
```
|
|
234
255
|
|
|
235
|
-
###
|
|
256
|
+
### Monorepo Scripts & Release Integrity
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Verify Conventional Commit version calculation
|
|
260
|
+
powershell -File scripts/test-versioning.ps1
|
|
236
261
|
|
|
237
|
-
|
|
238
|
-
-
|
|
239
|
-
|
|
240
|
-
|
|
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))
|
|
241
270
|
|
|
242
|
-
|
|
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`
|
|
243
275
|
|
|
244
276
|
## License
|
|
245
277
|
|
package/README.tr.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# unpeek
|
|
2
|
+
|
|
3
|
+
**Sıfır yapılandırma gerektiren, çağrı grafiği (call-graph) farkındalıklı, <%2 CPU ek yüküne sahip polimorfik JavaScript koruma ve çalışma zamanı (runtime) müdahale önleme aracı.**
|
|
4
|
+
|
|
5
|
+
[](https://github.com/Woffluon/unpeek/blob/main/LICENSE)
|
|
6
|
+
[](https://github.com/Woffluon/unpeek/blob/main/packages/unpeek/benchmarks/overhead.bench.ts)
|
|
7
|
+
[](https://github.com/Woffluon/unpeek/blob/main/packages/unpeek/benchmarks/overhead.bench.ts)
|
|
8
|
+
[](https://woffluon.github.io/unpeek)
|
|
9
|
+
|
|
10
|
+
[English](./README.md) | Türkçe · [Canlı İnteraktif Playground](https://woffluon.github.io/unpeek) · [Ajan Mimari Kılavuzu](https://github.com/Woffluon/unpeek/blob/main/AGENTS.md) · [Yapay Zeka Becerisi (SKILL.md)](https://github.com/Woffluon/unpeek/blob/main/skills/unpeek/SKILL.md)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Neden unpeek?
|
|
15
|
+
|
|
16
|
+
Next.js, Vite veya Webpack ile geliştirilen modern bir web uygulamasını yayına aldığınızda; istemci tarafındaki iş mantığı, iç API uç noktaları, özellik bayrakları (feature flags) ve algoritmalar Chrome DevTools veya `webcrack` / `synchrony` gibi otomatik AST çözücüler aracılığıyla açıkça okunabilir.
|
|
17
|
+
|
|
18
|
+
Mevcut araçlar geliştiricileri zor bir ödünleşime zorlar:
|
|
19
|
+
- **Standart küçültücüler (`esbuild`, `SWC`, `Terser`):** Yalnızca boşlukları siler ve değişken adlarını kısaltır. DevTools içerisindeki Pretty-Print (`{}`) düğmesine tek bir tıklamayla metin sabitleri, API adresleri ve kontrol akışı yeniden okunabilir hale gelir.
|
|
20
|
+
- **Geleneksel AST karmaşıklaştırıcılar (`javascript-obfuscator`):** Paketteki her fonksiyona ayrım gözetmeksizin ağır kontrol akışı düzleştirme (control-flow flattening), `eval` tuzakları ve dizi döndürme işlemleri uygular. Bu yaklaşım paket boyutunu %40 ile %300 oranında şişirir, V8 TurboFan JIT derleyicisinin 60fps arayüz döngülerindeki satır içi optimizasyonlarını bozar ve tarayıcıda donmalara yol açar.
|
|
21
|
+
|
|
22
|
+
`unpeek`, statik çağrı grafiği analizini derleme zamanı polimorfik şifreleme ile birleştirerek bu sorunu çözer:
|
|
23
|
+
|
|
24
|
+
| Yetenek | Standart Küçültücüler (`Terser` / `SWC`) | Geleneksel AST Karmaşıklaştırıcılar | `unpeek` |
|
|
25
|
+
| :--- | :--- | :--- | :--- |
|
|
26
|
+
| **Çalışma Zamanı CPU Ek Yükü** | ~%0 | %15 ile %85 (arayüz döngülerini yavaşlatır) | **< %2.0** (Çağrı Grafiği Hot-Path Muafiyeti) |
|
|
27
|
+
| **Gzip Paket Büyümesi** | %0 (Referans) | +%45 ile +%300 | **< %15** (O(1) Tembel Metin Kasası) |
|
|
28
|
+
| **Metin ve API Uç Noktası Şifreleme** | Pakette düz metin (plaintext) | Başlangıçta tam dizi çözme (yüksek CPU) | **Polimorfik XOR + O(1) Önbellekli Kasa** |
|
|
29
|
+
| **DevTools Pretty-Print (`{}`) Koruması** | Yok | `debugger` döngüleri (kolayca devre dışı bırakılır) | **`Function.prototype.toString()` FNV-1a Bütünlük Doğrulaması** |
|
|
30
|
+
| **Source Map Yalıtımı** | Manuel CI betikleri | Manuel yapılandırma | **Otomatik `.unpeek-maps/` Kasası + Yorum Temizliği** |
|
|
31
|
+
| **Statik Deobfuscator Direnci** | Yok | Sabit şablonlar (`webcrack` tarafından tanınır) | **Derleme Başına Polimorfik AST Tohumu (Seed)** |
|
|
32
|
+
| **SSR / Next.js Uyumluluğu** | Doğal | Sunucu hidrasyonunu (hydration) sıklıkla bozar | **Yalnızca İstemci Otomatik Tespiti + SSR Koruması** |
|
|
33
|
+
|
|
34
|
+
### Temel Mimari
|
|
35
|
+
|
|
36
|
+
```mermaid
|
|
37
|
+
flowchart TD
|
|
38
|
+
A["İstemci Derleme Çıktısı (.next/static, dist/assets, build/static)"] --> B["Framework Dedektörü (detectTargetFramework)"]
|
|
39
|
+
B --> C["Source Map Kasası (relocateSourceMaps)"]
|
|
40
|
+
C -->|Haritaları taşı ve sourceMappingURL kaldır| D[".unpeek-maps/ (Özel Kasa)"]
|
|
41
|
+
C --> E["İstemci JS Paketleri (.js, .mjs)"]
|
|
42
|
+
E --> F["AST Sıcak Yol Analizi (detectHotPaths)"]
|
|
43
|
+
F -->|Döngüler, Dizi Fonksiyonları, UI Render| G["Sıcak Yol: %0 Vergi (Opak Akış Atlanır)"]
|
|
44
|
+
F -->|Soğuk Fonksiyonlar: Yetki, Lisans, İmza| H["Soğuk Yol: Opak Kontrol Akışı Koruması"]
|
|
45
|
+
G --> I["Polimorfik Metin Kasası (O(1) Tembel XOR)"]
|
|
46
|
+
H --> I
|
|
47
|
+
I --> J["Tanımlayıcı ve Sembol Maskeleme"]
|
|
48
|
+
J --> K["Çalışma Zamanı Bütünlük Kalkanı (FNV-1a Özeti)"]
|
|
49
|
+
K --> L["Güçlendirilmiş Üretim Paketleri"]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
1. **Çağrı Grafiği (Call-Graph) Hot-Path Muafiyeti (`<%2` CPU Bütçesi)**
|
|
53
|
+
[`detectHotPaths`](https://github.com/Woffluon/unpeek/blob/main/packages/unpeek/src/ast/index.ts), tek bir AST düğümünü değiştirmeden önce dosyanın çağrı grafiğini tarar. Döngü içeren fonksiyonlar (`for`, `while`, `do-while`, `for-of`), dizi yüksek mertebe geri çağrıları (`.map`, `.filter`, `.reduce`, `.forEach`), `requestAnimationFrame` zamanlayıcıları ve React/UI bileşenleri (`useState`, `useEffect`, `createElement`) sıcak yol (hot path) olarak işaretlenir. `unpeek` tüm paketteki yerel tanımlayıcıları maskeler ve metin sabitlerini şifreler; opak kontrol akışı korumalarını ise yalnızca soğuk fonksiyonlara (lisans doğrulama, istek imzalama, yetki kontrolü gibi) enjekte eder. Sıcak döngülerdeki V8 JIT optimizasyonu doğal hızında çalışmayı sürdürür.
|
|
54
|
+
2. **O(1) Tembel Metin Kasası (Lazy String Vault, `<%15` Gzip Bütçesi)**
|
|
55
|
+
Düz metin sabitleri (`minStringLength >= 4`), derleme zamanında 32-bitlik polimorfik bir tohum (seed) ile anahtarlanan XOR akış şifresiyle kodlanır. Sayfa açılışında tüm metinleri aynı anda çözmek yerine, enjekte edilen kasa yardımcısı her metni ilk erişildiğinde tembel (lazy) olarak çözer ve düz metin sonucunu kendi dizi hücresine önbellekler. Sonraki tüm okumalar doğrudan dizi indeksleme ile O(1) sürede tamamlanır.
|
|
56
|
+
3. **Öz-Savunmalı `Function.prototype.toString()` Bütünlük Kontrolü ve Pasif Caydırıcı**
|
|
57
|
+
Bir analist korumalı bir dosyayı DevTools Pretty-Print (`{}`) ile biçimlendirdiğinde veya Sources panelinde bir koşulu değiştirdiğinde, biçimlendirilen kod `Function.prototype.toString()` çıktısını değiştirir. [`verifyCodeIntegrity`](https://github.com/Woffluon/unpeek/blob/main/packages/unpeek/src/runtime/index.ts), dokunulmamış küçültülmüş kodda sıfır yanlış pozitif oranıyla 32-bit FNV-1a özetini doğrular ve saldırganların doğrudan yamayabileceği ani bir çökme yerine kademeli durum bozulması (`deterrentMode: 'gradual'`) başlatır.
|
|
58
|
+
4. **Otomatik Source Map Kasası (`.unpeek-maps/`)**
|
|
59
|
+
Üretim çıktısında `.js.map` dosyalarını bırakmak, orijinal TypeScript proje ağacınızın DevTools içinde birebir yeniden oluşturulmasına yol açar. [`protectProject`](https://github.com/Woffluon/unpeek/blob/main/packages/unpeek/src/cli/protect.ts), `.map` dosyalarını genel çıktı dizininden özel `.unpeek-maps/` klasörüne taşır ve tüm istemci paketlerinden `//# sourceMappingURL=` yorumlarını temizler. Böylece haritaları son kullanıcılara sunmadan Sentry veya Datadog gibi platformlara yükleyebilirsiniz.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Hızlı Başlangıç
|
|
64
|
+
|
|
65
|
+
### 1. Proje Kurulumu (`npx unpeek init`)
|
|
66
|
+
|
|
67
|
+
Proje kök dizininizde (Next.js, Vite, Webpack veya yalın JS) başlatıcıyı çalıştırın:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx unpeek init
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Bu komut üç hazırlık adımını tamamlar:
|
|
74
|
+
1. `package.json` ve yapılandırma dosyalarından çatınızı (`nextjs`, `vite`, `webpack` veya `vanilla`) otomatik tespit eder.
|
|
75
|
+
2. Her üretim derlemesinin otomatik olarak korunması için `package.json` betiklerine `"postbuild": "unpeek protect"` satırını ekler.
|
|
76
|
+
3. Çıkarılan kaynak haritalarının (source maps) git geçmişine girmemesi için `.gitignore` dosyasına `.unpeek-maps/` dizinini ekler.
|
|
77
|
+
|
|
78
|
+
### 2. CLI Kullanımı (`unpeek protect`)
|
|
79
|
+
|
|
80
|
+
`unpeek` paketini geliştirme bağımlılığı olarak kurup CI/CD süreçlerinde veya yerel derlemelerde doğrudan çalıştırabilirsiniz:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm install -D unpeek
|
|
84
|
+
npx unpeek protect
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### CLI Komutları ve Seçenekleri
|
|
88
|
+
|
|
89
|
+
| Komut / Bayrak | Açıklama | Varsayılan |
|
|
90
|
+
| :--- | :--- | :--- |
|
|
91
|
+
| `init [--dry-run]` | Proje çerçevesini otomatik algılar, `postbuild` kancasını ve `.unpeek-maps/` kasasını yapılandırır | |
|
|
92
|
+
| `protect` | Üretim istemci paketlerini yerinde korur (varsayılan komut) | |
|
|
93
|
+
| `--out-dir <yol>` | İstemci çıktı klasörünü açıkça belirtir (ör. `dist/assets`, `.next/static/chunks`) | Proje framework'ünden otomatik tespit |
|
|
94
|
+
| `--seed <sayı>` | Deterministik 32-bit polimorfik derleme tohumu (seed) | Derleme başına rastgele |
|
|
95
|
+
| `--passive` | Kademeli bozulma yerine pasif telemetri caydırıcı modunu kullan | Varsayılan: kademeli bozulma (`gradual`) |
|
|
96
|
+
| `--no-maps` | `.map` dosyalarını `.unpeek-maps/` klasörüne taşımak yerine kalıcı olarak sil | `.unpeek-maps/` içine taşır |
|
|
97
|
+
| `--min-string-length <sayı>` | Tembel şifreleme kasasına alınacak minimum metin uzunluğu | `4` |
|
|
98
|
+
| `--private-maps-dir <dizin>` | Kaynak haritalarının taşınacağı özel kasa klasörü | `.unpeek-maps` |
|
|
99
|
+
| `--no-shield` | Çalışma zamanı anti-tamper kalkanının enjekte edilmesini devre dışı bırak | Giriş paketlerine kalkan eklenir |
|
|
100
|
+
| `-h, --help` | Yardım iletisini göster | |
|
|
101
|
+
| `-v, --version` | Sürüm numarasını göster | |
|
|
102
|
+
|
|
103
|
+
> [!NOTE]
|
|
104
|
+
> `protectProject(options)` üzerinden programatik kullanım; `minStringLength`, `privateMapsDir`, `injectRuntimeShield` ve `cwd` gibi ek yapılandırma seçeneklerini destekler.
|
|
105
|
+
|
|
106
|
+
> [!IMPORTANT]
|
|
107
|
+
> **CommonJS Kullanıcıları İçin Dinamik `import()` Uyarısı:**
|
|
108
|
+
> `unpeek` varsayılan olarak yerel ECMAScript Modülleri (`"type": "module"`) ile dağıtılmaktadır. CommonJS kullanan projelerde (`require()` veya `.cjs` yapılandırma dosyaları) `unpeek` modüllerini dinamik `import()` ile yükleyiniz:
|
|
109
|
+
> ```javascript
|
|
110
|
+
> // CommonJS (next.config.js / webpack.config.js / betikler)
|
|
111
|
+
> const unpeek = (await import('unpeek/unplugin')).default;
|
|
112
|
+
> const { protectProject, transformJavaScript } = await import('unpeek');
|
|
113
|
+
> ```
|
|
114
|
+
|
|
115
|
+
### 3. Evrensel Paketleyici Eklentisi (`unpeek/unplugin`)
|
|
116
|
+
|
|
117
|
+
Derleme sonrası CLI adımı yerine paketleyicinin `renderChunk` yaşam döngüsü sırasında bellek içi dönüşüm yapmak isterseniz [`unpeek/unplugin`](https://github.com/Woffluon/unpeek/blob/main/packages/unpeek/src/bundler/unplugin.ts) modülünü kullanabilirsiniz:
|
|
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
|
+
Node.js sunucu paketlerinin özgün yığın izlerini (stack traces) koruması için eklentiyi istemci paketleriyle (`!isServer`) sınırlandırın:
|
|
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
|
+
#### Programatik API
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { transformJavaScript, protectProject } from 'unpeek';
|
|
162
|
+
|
|
163
|
+
// Tek bir JavaScript kod dizesini bellek içinde dönüştürün
|
|
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
|
+
// Veya tüm derleme dizinini koruyun
|
|
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 Kasası ve Sentry İş Akışı
|
|
185
|
+
|
|
186
|
+
`keepPrivateMaps` etkinleştirildiğinde (varsayılan), `unpeek` genel çıktı dizininizdeki tüm `.js.map` dosyalarını göreli dosya adlarını koruyarak `.unpeek-maps/` dizinine taşır ve genel `.js` dosyalarından `//# sourceMappingURL=` yönergelerini temizler.
|
|
187
|
+
|
|
188
|
+
Üretim hata izleme sistemlerinde tam yığın izi çözümlemesini (symbolication) korumak için:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# 1. Uygulamanızı derleyin ve unpeek'i çalıştırın (postbuild ile otomatik tetiklenir)
|
|
192
|
+
npm run build
|
|
193
|
+
|
|
194
|
+
# 2. .unpeek-maps/ klasöründeki gizli kaynak haritalarını Sentry veya Datadog'a yükleyin
|
|
195
|
+
npx @sentry/cli sourcemaps upload .unpeek-maps --release="$GIT_COMMIT_SHA"
|
|
196
|
+
|
|
197
|
+
# 3. Genel derleme klasörünüzü (.next/, dist/ veya build/) dağıtın
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Resmi Yapay Zeka Ajan Becerisi (Skill) Kurulumu
|
|
203
|
+
|
|
204
|
+
`unpeek`, Ajan Becerileri Keşif Optimizasyonu (SDO) standartlarını izleyen resmi ve belirteç optimizasyonlu bir Yapay Zeka Becerisi ([`skills/unpeek/SKILL.md`](https://github.com/Woffluon/unpeek/blob/main/skills/unpeek/SKILL.md)) sunar. Bu beceriyi eklemek; kodlama ajanınıza (Claude Code, Cursor, Antigravity, OpenAI Codex veya Gemini CLI) `unpeek` yapılandırmasını, SSR paketlerinin korunmasını ve `.unpeek-maps/` kasasının CI/CD hatlarına bağlanmasını öğretir.
|
|
205
|
+
|
|
206
|
+
### Proje Kapsamında Kurulum (Git ile Takımla Paylaşılır)
|
|
207
|
+
|
|
208
|
+
Beceriyi deponuzun `.agents/skills/unpeek/` dizinine kopyalayın:
|
|
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
|
+
### Genel Makine Kurulumu (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
|
+
# Ajanlar arası standart (~/.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
|
+
## Doğrulama, Testler ve Benchmarklar
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# Çalışma alanı bağımlılıklarını kurun
|
|
236
|
+
pnpm install
|
|
237
|
+
|
|
238
|
+
# Birim ve tersine mühendislik direnç testlerini çalıştırın (Vitest)
|
|
239
|
+
pnpm test
|
|
240
|
+
|
|
241
|
+
# V8 kod kapsamı raporu ile birim testlerini çalıştırın
|
|
242
|
+
pnpm --filter unpeek run test:coverage
|
|
243
|
+
|
|
244
|
+
# V8 VM CPU ek yükü (<%2) ve Gzip artışı (<%15) benchmark testini çalıştırın
|
|
245
|
+
pnpm bench
|
|
246
|
+
|
|
247
|
+
# Katı TypeScript tip kontrolü yapın
|
|
248
|
+
pnpm typecheck
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Benchmark Çıktı Referansı ([`benchmarks/overhead.bench.ts`](https://github.com/Woffluon/unpeek/blob/main/packages/unpeek/benchmarks/overhead.bench.ts))
|
|
252
|
+
|
|
253
|
+
- **Derleme / Dönüşüm Süresi:** `< 3000 ms`
|
|
254
|
+
- **Gzip Boyut Artışı:** `< %15` (üretim uygulama paketlerinde)
|
|
255
|
+
- **Çalışma Zamanı CPU Ek Yükü:** `< %2.00` (aralıklı çok turlu V8 JIT testi)
|
|
256
|
+
- **Düz Metin Sızıntı Oranı:** `%0` (`minStringLength` kuralını karşılayan metin sabitleri için)
|
|
257
|
+
|
|
258
|
+
## Lisans
|
|
259
|
+
|
|
260
|
+
[MIT Lisansı](https://github.com/Woffluon/unpeek/blob/main/LICENSE) kapsamında yayınlanmıştır.
|