unpeek 1.4.0 → 1.6.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 (64) hide show
  1. package/README.md +10 -10
  2. package/README.tr.md +10 -10
  3. package/assets/banner-dark.svg +22 -0
  4. package/assets/banner-light.svg +22 -0
  5. package/assets/banner.svg +24 -7
  6. package/dist/ast/index.cjs +154 -46
  7. package/dist/ast/index.cjs.map +1 -1
  8. package/dist/ast/index.js +154 -46
  9. package/dist/ast/index.js.map +1 -1
  10. package/dist/browser.cjs +154 -46
  11. package/dist/browser.cjs.map +1 -1
  12. package/dist/browser.d.cts +1 -1
  13. package/dist/browser.d.ts +1 -1
  14. package/dist/browser.js +154 -46
  15. package/dist/browser.js.map +1 -1
  16. package/dist/bundler/unplugin.cjs +154 -46
  17. package/dist/bundler/unplugin.cjs.map +1 -1
  18. package/dist/bundler/unplugin.js +154 -46
  19. package/dist/bundler/unplugin.js.map +1 -1
  20. package/dist/cli/index.cjs +155 -47
  21. package/dist/cli/index.cjs.map +1 -1
  22. package/dist/cli/index.js +155 -47
  23. package/dist/cli/index.js.map +1 -1
  24. package/dist/cli/protect.cjs +154 -46
  25. package/dist/cli/protect.cjs.map +1 -1
  26. package/dist/cli/protect.js +154 -46
  27. package/dist/cli/protect.js.map +1 -1
  28. package/dist/esbuild.cjs +154 -46
  29. package/dist/esbuild.cjs.map +1 -1
  30. package/dist/esbuild.d.cts +1 -1
  31. package/dist/esbuild.d.ts +1 -1
  32. package/dist/esbuild.js +154 -46
  33. package/dist/esbuild.js.map +1 -1
  34. package/dist/index.cjs +155 -47
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +155 -47
  39. package/dist/index.js.map +1 -1
  40. package/dist/rollup.cjs +154 -46
  41. package/dist/rollup.cjs.map +1 -1
  42. package/dist/rollup.d.cts +1 -1
  43. package/dist/rollup.d.ts +1 -1
  44. package/dist/rollup.js +154 -46
  45. package/dist/rollup.js.map +1 -1
  46. package/dist/runtime/index.cjs +4 -2
  47. package/dist/runtime/index.cjs.map +1 -1
  48. package/dist/runtime/index.js +4 -2
  49. package/dist/runtime/index.js.map +1 -1
  50. package/dist/{types-BTMkXmVE.d.cts → types-D-lVfaDU.d.cts} +1 -1
  51. package/dist/{types-BTMkXmVE.d.ts → types-D-lVfaDU.d.ts} +1 -1
  52. package/dist/vite.cjs +154 -46
  53. package/dist/vite.cjs.map +1 -1
  54. package/dist/vite.d.cts +1 -1
  55. package/dist/vite.d.ts +1 -1
  56. package/dist/vite.js +154 -46
  57. package/dist/vite.js.map +1 -1
  58. package/dist/webpack.cjs +154 -46
  59. package/dist/webpack.cjs.map +1 -1
  60. package/dist/webpack.d.cts +1 -1
  61. package/dist/webpack.d.ts +1 -1
  62. package/dist/webpack.js +154 -46
  63. package/dist/webpack.js.map +1 -1
  64. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  <p align="center">
2
2
  <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner.svg">
4
- <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner.svg">
5
- <img src="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner.svg" alt="unpeek - call-graph aware client-side javascript protection" width="100%">
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner-dark.svg">
4
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner-light.svg">
5
+ <img src="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner-light.svg" alt="unpeek - call-graph aware client-side javascript protection" width="100%">
6
6
  </picture>
7
7
  </p>
8
8
 
@@ -35,8 +35,8 @@ Existing tools force an uncomfortable trade-off:
35
35
  | Capability | Standard Minifiers (`Terser` / `SWC`) | Legacy AST Obfuscators | `unpeek` |
36
36
  | :--- | :--- | :--- | :--- |
37
37
  | **Runtime CPU Overhead** | ~0% | 15% to 85% (throttles UI loops) | **< 2.0%** (Call-Graph Hot-Path Exemption) |
38
- | **Gzip Bundle Growth** | 0% (Baseline) | +45% to +300% | **< 15%** (O(1) Lazy String Vault) |
39
- | **String & Endpoint Encryption** | Plaintext in bundle | Eager array rotation (high CPU) | **Polymorphic XOR + O(1) Memoized Vault** |
38
+ | **Gzip Bundle Growth** | 0% (Baseline) | +45% to +300% | **< 15%** (O(1) `kConst` String Vault) |
39
+ | **String & Endpoint Encryption** | Plaintext in bundle | Eager array rotation (high CPU) | **Polymorphic Period-2 XOR + O(1) `kConst` Vault** |
40
40
  | **DevTools Pretty-Print (`{}`) Defense** | None | `debugger` infinite loops (easily bypassed) | **`Function.prototype.toString()` FNV-1a Integrity** |
41
41
  | **Source Map Isolation** | Manual CI scripts | Manual configuration | **Automatic `.unpeek-maps/` Vault + Comment Strip** |
42
42
  | **Static Deobfuscator Resistance** | None | Fixed templates (fingerprinted by deobfuscators) | **Per-Build Polymorphic AST Seed** |
@@ -53,7 +53,7 @@ flowchart TD
53
53
  E --> F["AST Hot-Path Traversal (detectHotPaths)"]
54
54
  F -->|Loops, Array Callbacks, UI Renders| G["Hot Path: 0% Tax (Skip Opaque Predicates)"]
55
55
  F -->|Cold Functions: Auth, Licensing, Signers| H["Cold Path: Opaque Control-Flow Predicates"]
56
- G --> I["Polymorphic String Vault (O(1) Lazy XOR)"]
56
+ G --> I["Polymorphic String Vault (O(1) kConst XOR)"]
57
57
  H --> I
58
58
  I --> J["Identifier and Symbol Mangling"]
59
59
  J --> K["Runtime Integrity Shield (FNV-1a Checksum)"]
@@ -61,9 +61,9 @@ flowchart TD
61
61
  ```
62
62
 
63
63
  1. **Call-Graph Hot-Path Exemption (`<2%` CPU Budget)**
64
- 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.
65
- 2. **O(1) Lazy String Vault (`<15%` Gzip Budget)**
66
- 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.
64
+ Before modifying an AST node, [`detectHotPaths`](packages/unpeek/src/ast/index.ts) traverses the file call graph bidirectionally. Functions containing loops (`for`, `while`, `do-while`, `for-of`), array higher-order callbacks (`.map`, `.filter`, `.reduce`, `.forEach`), `requestAnimationFrame` tickers, React/UI render components (`useState`, `useEffect`, `createElement`), and all helper callees invoked from hot loops are flagged as hot paths. `unpeek` exempts hot loops and their callees from both opaque control-flow predicates and string vault rewriting, while protecting cold functions (such as license checks, request signers, and auth validators). V8 JIT optimization inside hot loops remains untouched.
65
+ 2. **O(1) Const-Array String Vault & Tamper Entanglement (`<15%` Gzip Budget)**
66
+ Cold string literals (`minStringLength >= 4`) are encrypted at build time with a period-2 polymorphic XOR stream cipher keyed by a per-build 32-bit seed that preserves LZ77/Gzip compressibility. At module initialization, the injected `const _uC` vault decodes strings once into a V8 `kConst` array slot so every subsequent read resolves in O(1) constant time via direct array indexing, while dual-entangling the XOR key with both the runtime integrity state (`String.prototype._u`) and self-verifying decoder formatting (`/\n/.test(f)`).
67
67
  3. **Self-Defending `Function.prototype.toString()` Integrity and Passive Deterrent**
68
68
  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.
69
69
  4. **Automatic Source Map Vault (`.unpeek-maps/`)**
@@ -105,7 +105,7 @@ npx unpeek protect
105
105
  | `--seed <number>` | Deterministic 32-bit polymorphic build seed | Random per build |
106
106
  | `--passive` | Use passive deterrent mode instead of gradual state degradation | Default: gradual degradation |
107
107
  | `--no-maps` | Permanently delete `.map` files instead of moving them to `.unpeek-maps/` | Moves to `.unpeek-maps/` |
108
- | `--min-string-length <num>` | Minimum string length for lazy encryption vault | `4` |
108
+ | `--min-string-length <num>` | Minimum string length for O(1) `kConst` encryption vault | `4` |
109
109
  | `--private-maps-dir <dir>` | Directory to store vaulted private source maps | `.unpeek-maps` |
110
110
  | `--no-shield` | Do not inject runtime anti-tamper deterrent shield | Shield injected into entry chunks |
111
111
  | `-h, --help` | Show CLI help message | |
package/README.tr.md CHANGED
@@ -1,8 +1,8 @@
1
1
  <p align="center">
2
2
  <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner.svg">
4
- <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner.svg">
5
- <img src="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner.svg" alt="unpeek - call-graph aware client-side javascript protection" width="100%">
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner-dark.svg">
4
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner-light.svg">
5
+ <img src="https://raw.githubusercontent.com/Woffluon/unpeek/main/assets/banner-light.svg" alt="unpeek - call-graph aware client-side javascript protection" width="100%">
6
6
  </picture>
7
7
  </p>
8
8
 
@@ -35,8 +35,8 @@ Mevcut araçlar geliştiricileri zor bir ödünleşime zorlar:
35
35
  | Yetenek | Standart Küçültücüler (`Terser` / `SWC`) | Geleneksel AST Karmaşıklaştırıcılar | `unpeek` |
36
36
  | :--- | :--- | :--- | :--- |
37
37
  | **Ç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) |
38
- | **Gzip Paket Büyümesi** | %0 (Referans) | +%45 ile +%300 | **< %15** (O(1) Tembel Metin Kasası) |
39
- | **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** |
38
+ | **Gzip Paket Büyümesi** | %0 (Referans) | +%45 ile +%300 | **< %15** (O(1) `kConst` Sabit-Dizi Metin Kasası) |
39
+ | **Metin ve API Uç Noktası Şifreleme** | Pakette düz metin (plaintext) | Başlangıçta tam dizi çözme (yüksek CPU) | **Polimorfik Periyot-2 XOR + O(1) `kConst` Kasa** |
40
40
  | **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ı** |
41
41
  | **Source Map Yalıtımı** | Manuel CI betikleri | Manuel yapılandırma | **Otomatik `.unpeek-maps/` Kasası + Yorum Temizliği** |
42
42
  | **Statik Deobfuscator Direnci** | Yok | Sabit şablonlar (`webcrack` tarafından tanınır) | **Derleme Başına Polimorfik AST Tohumu (Seed)** |
@@ -53,7 +53,7 @@ flowchart TD
53
53
  E --> F["AST Sıcak Yol Analizi (detectHotPaths)"]
54
54
  F -->|Döngüler, Dizi Fonksiyonları, UI Render| G["Sıcak Yol: %0 Vergi (Opak Akış Atlanır)"]
55
55
  F -->|Soğuk Fonksiyonlar: Yetki, Lisans, İmza| H["Soğuk Yol: Opak Kontrol Akışı Koruması"]
56
- G --> I["Polimorfik Metin Kasası (O(1) Tembel XOR)"]
56
+ G --> I["Polimorfik Metin Kasası (O(1) kConst XOR)"]
57
57
  H --> I
58
58
  I --> J["Tanımlayıcı ve Sembol Maskeleme"]
59
59
  J --> K["Çalışma Zamanı Bütünlük Kalkanı (FNV-1a Özeti)"]
@@ -61,9 +61,9 @@ flowchart TD
61
61
  ```
62
62
 
63
63
  1. **Çağrı Grafiği (Call-Graph) Hot-Path Muafiyeti (`<%2` CPU Bütçesi)**
64
- [`detectHotPaths`](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.
65
- 2. **O(1) Tembel Metin Kasası (Lazy String Vault, `<%15` Gzip Bütçesi)**
66
- 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.
64
+ [`detectHotPaths`](packages/unpeek/src/ast/index.ts), tek bir AST düğümünü değiştirmeden önce dosyanın çağrı grafiğini çift yönlü 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ı, React/UI bileşenleri (`useState`, `useEffect`, `createElement`) ve sıcak döngülerden çağrılan tüm yardımcı fonksiyonlar sıcak yol (hot path) olarak işaretlenir. `unpeek` sıcak döngüleri ve yardımcılarını hem opak kontrol akışı korumalarından hem de metin kasası dönüşümünden muaf tutar; korumayı yalnızca soğuk fonksiyonlara (lisans doğrulama, istek imzalama, yetki kontrolü gibi) uygular. Sıcak döngülerdeki V8 JIT optimizasyonu doğal hızında çalışmayı sürdürür.
65
+ 2. **O(1) Sabit-Dizi Metin Kasası ve Kalkan Dolanıklığı (`<%15` Gzip Bütçesi)**
66
+ Soğuk metin sabitleri (`minStringLength >= 4`), derleme zamanında LZ77/Gzip sıkıştırılabilirliğini koruyan periyot-2 polimorfik bir XOR akış şifresiyle kodlanır. Modül başlangıcında enjekte edilen `const _uC` kasası metinleri tek seferde V8 `kConst` sabit dizi hücrelerine çözer ve XOR anahtarını hem çalışma zamanı bütünlük kalkanına (`String.prototype._u`) hem de çözücü fonksiyonun kendi biçimlendirme kontrolüne (`/\n/.test(f)`) ikili olarak bağlar. Sonraki tüm okumalar doğrudan dizi indeksleme ile O(1) sürede tamamlanır.
67
67
  3. **Öz-Savunmalı `Function.prototype.toString()` Bütünlük Kontrolü ve Pasif Caydırıcı**
68
68
  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`](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.
69
69
  4. **Otomatik Source Map Kasası (`.unpeek-maps/`)**
@@ -105,7 +105,7 @@ npx unpeek protect
105
105
  | `--seed <sayı>` | Deterministik 32-bit polimorfik derleme tohumu (seed) | Derleme başına rastgele |
106
106
  | `--passive` | Kademeli bozulma yerine pasif telemetri caydırıcı modunu kullan | Varsayılan: kademeli bozulma (`gradual`) |
107
107
  | `--no-maps` | `.map` dosyalarını `.unpeek-maps/` klasörüne taşımak yerine kalıcı olarak sil | `.unpeek-maps/` içine taşır |
108
- | `--min-string-length <sayı>` | Tembel şifreleme kasasına alınacak minimum metin uzunluğu | `4` |
108
+ | `--min-string-length <sayı>` | O(1) `kConst` şifreleme kasasına alınacak minimum metin uzunluğu | `4` |
109
109
  | `--private-maps-dir <dizin>` | Kaynak haritalarının taşınacağı özel kasa klasörü | `.unpeek-maps` |
110
110
  | `--no-shield` | Çalışma zamanı anti-tamper kalkanının enjekte edilmesini devre dışı bırak | Giriş paketlerine kalkan eklenir |
111
111
  | `-h, --help` | Yardım iletisini göster | |
@@ -0,0 +1,22 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 200" width="100%" height="auto" fill="none">
2
+ <!-- Minimalist Carbon Canvas -->
3
+ <rect width="960" height="200" rx="6" fill="#111111" />
4
+ <rect x="0.5" y="0.5" width="959" height="199" rx="5.5" stroke="#2A2A28" />
5
+
6
+ <!-- Signal Orange Top Line -->
7
+ <rect x="0" y="0" width="960" height="2" fill="#FF3300" />
8
+
9
+ <!-- Iconic Brand Mark (Sealed block with open hot-path cut) -->
10
+ <g transform="translate(458, 30) scale(1.833)">
11
+ <path d="M2 2h15l5 5v15H2V2Z" fill="#EDEAE1" />
12
+ <rect x="0" y="10.5" width="24" height="3" fill="#FF3300" />
13
+ </g>
14
+
15
+ <!-- Wordmark -->
16
+ <text x="480" y="122" text-anchor="middle" fill="#EDEAE1" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="38" font-weight="700" letter-spacing="-0.035em">unpeek</text>
17
+
18
+ <!-- Tagline -->
19
+ <text x="480" y="154" text-anchor="middle" fill="#8E8A7E" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="14" font-weight="400" letter-spacing="-0.01em">
20
+ Nothing to peek at. <tspan fill="#EDEAE1">Nothing to slow down.</tspan>
21
+ </text>
22
+ </svg>
@@ -0,0 +1,22 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 200" width="100%" height="auto" fill="none">
2
+ <!-- Minimalist Paper Canvas (Matches Website Light Theme) -->
3
+ <rect width="960" height="200" rx="6" fill="#F2F0E9" />
4
+ <rect x="0.5" y="0.5" width="959" height="199" rx="5.5" stroke="#D5D0C2" />
5
+
6
+ <!-- Signal Orange Top Line -->
7
+ <rect x="0" y="0" width="960" height="2" fill="#FF3300" />
8
+
9
+ <!-- Iconic Brand Mark (Sealed block with open hot-path cut) -->
10
+ <g transform="translate(458, 30) scale(1.833)">
11
+ <path d="M2 2h15l5 5v15H2V2Z" fill="#111111" />
12
+ <rect x="0" y="10.5" width="24" height="3" fill="#FF3300" />
13
+ </g>
14
+
15
+ <!-- Wordmark -->
16
+ <text x="480" y="122" text-anchor="middle" fill="#111111" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="38" font-weight="700" letter-spacing="-0.035em">unpeek</text>
17
+
18
+ <!-- Tagline -->
19
+ <text x="480" y="154" text-anchor="middle" fill="#5C594F" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="14" font-weight="400" letter-spacing="-0.01em">
20
+ Nothing to peek at. <tspan fill="#111111">Nothing to slow down.</tspan>
21
+ </text>
22
+ </svg>
package/assets/banner.svg CHANGED
@@ -1,22 +1,39 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 200" width="100%" height="auto" fill="none">
2
- <!-- Minimalist Carbon Canvas -->
3
- <rect width="960" height="200" rx="6" fill="#111111" />
4
- <rect x="0.5" y="0.5" width="959" height="199" rx="5.5" stroke="#2A2A28" />
2
+ <style>
3
+ .bg { fill: #F2F0E9; }
4
+ .border { stroke: #D5D0C2; }
5
+ .mark { fill: #111111; }
6
+ .wordmark { fill: #111111; }
7
+ .tagline-muted { fill: #5C594F; }
8
+ .tagline-strong { fill: #111111; }
9
+ @media (prefers-color-scheme: dark) {
10
+ .bg { fill: #111111; }
11
+ .border { stroke: #2A2A28; }
12
+ .mark { fill: #EDEAE1; }
13
+ .wordmark { fill: #EDEAE1; }
14
+ .tagline-muted { fill: #8E8A7E; }
15
+ .tagline-strong { fill: #EDEAE1; }
16
+ }
17
+ </style>
18
+
19
+ <!-- Adaptive Paper (Light) / Carbon (Dark) Canvas -->
20
+ <rect class="bg" width="960" height="200" rx="6" />
21
+ <rect class="border" x="0.5" y="0.5" width="959" height="199" rx="5.5" />
5
22
 
6
23
  <!-- Signal Orange Top Line -->
7
24
  <rect x="0" y="0" width="960" height="2" fill="#FF3300" />
8
25
 
9
26
  <!-- Iconic Brand Mark (Sealed block with open hot-path cut) -->
10
27
  <g transform="translate(458, 30) scale(1.833)">
11
- <path d="M2 2h15l5 5v15H2V2Z" fill="#EDEAE1" />
28
+ <path class="mark" d="M2 2h15l5 5v15H2V2Z" />
12
29
  <rect x="0" y="10.5" width="24" height="3" fill="#FF3300" />
13
30
  </g>
14
31
 
15
32
  <!-- Wordmark -->
16
- <text x="480" y="122" text-anchor="middle" fill="#EDEAE1" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="38" font-weight="700" letter-spacing="-0.035em">unpeek</text>
33
+ <text class="wordmark" x="480" y="122" text-anchor="middle" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="38" font-weight="700" letter-spacing="-0.035em">unpeek</text>
17
34
 
18
35
  <!-- Tagline -->
19
- <text x="480" y="154" text-anchor="middle" fill="#8E8A7E" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="14" font-weight="400" letter-spacing="-0.01em">
20
- Nothing to peek at. <tspan fill="#EDEAE1">Nothing to slow down.</tspan>
36
+ <text class="tagline-muted" x="480" y="154" text-anchor="middle" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="14" font-weight="400" letter-spacing="-0.01em">
37
+ Nothing to peek at. <tspan class="tagline-strong">Nothing to slow down.</tspan>
21
38
  </text>
22
39
  </svg>
@@ -47,6 +47,7 @@ var ARRAY_HOF_METHODS = /* @__PURE__ */ new Set([
47
47
  "forEach",
48
48
  "flatMap",
49
49
  "find",
50
+ "findIndex",
50
51
  "some",
51
52
  "every"
52
53
  ]);
@@ -62,7 +63,8 @@ var UI_HOOK_OR_RENDER_CALLS = /* @__PURE__ */ new Set([
62
63
  "_jsx",
63
64
  "_jsxs",
64
65
  "createElement",
65
- "requestAnimationFrame"
66
+ "requestAnimationFrame",
67
+ "cancelAnimationFrame"
66
68
  ]);
67
69
  var FUNCTION_NODE_TYPES = /* @__PURE__ */ new Set([
68
70
  "FunctionDeclaration",
@@ -112,43 +114,94 @@ function getFunctionLabel(node, ancestors) {
112
114
  function isPascalCaseComponent(name) {
113
115
  return /^[A-Z][a-zA-Z0-9]*$/.test(name);
114
116
  }
117
+ function findEnclosingScopeNode(ancestors, selfNode) {
118
+ for (let i = ancestors.length - 1; i >= 0; i--) {
119
+ const anc = ancestors[i];
120
+ if (anc !== selfNode && (FUNCTION_NODE_TYPES.has(anc.type) || anc.type === "Program")) {
121
+ return anc;
122
+ }
123
+ }
124
+ return ancestors[0];
125
+ }
115
126
  function analyzeAstHotPaths(ast) {
116
127
  const hotFunctionNodes = /* @__PURE__ */ new WeakSet();
117
128
  const coldFunctionNodes = /* @__PURE__ */ new WeakSet();
129
+ const hotExemptNodes = /* @__PURE__ */ new WeakSet();
130
+ const directHotNodes = /* @__PURE__ */ new Set();
118
131
  const allFunctions = [];
119
132
  const fnByName = /* @__PURE__ */ new Map();
133
+ const scopeFunctions = /* @__PURE__ */ new Map();
134
+ const fnScopeChain = /* @__PURE__ */ new Map();
120
135
  const callerToCallees = /* @__PURE__ */ new Map();
136
+ function registerFunctionNode(node, ancestors) {
137
+ const name = getFunctionLabel(node, ancestors);
138
+ allFunctions.push({ node, name });
139
+ fnByName.set(name, node);
140
+ const enclosingScope = findEnclosingScopeNode(ancestors, node);
141
+ let localMap = scopeFunctions.get(enclosingScope);
142
+ if (!localMap) {
143
+ localMap = /* @__PURE__ */ new Map();
144
+ scopeFunctions.set(enclosingScope, localMap);
145
+ }
146
+ localMap.set(name, node);
147
+ const parent = ancestors[ancestors.length - 2];
148
+ const grandParent = ancestors[ancestors.length - 3];
149
+ const greatGrandParent = ancestors[ancestors.length - 4];
150
+ if (parent?.type === "Property" && parent.key?.type === "Identifier" && grandParent?.type === "ObjectExpression" && greatGrandParent?.type === "VariableDeclarator" && greatGrandParent.id?.type === "Identifier") {
151
+ const qualified = `${greatGrandParent.id.name}.${parent.key.name}`;
152
+ fnByName.set(qualified, node);
153
+ localMap.set(qualified, node);
154
+ }
155
+ const chain = [];
156
+ for (let i = ancestors.length - 1; i >= 0; i--) {
157
+ if (FUNCTION_NODE_TYPES.has(ancestors[i].type) || ancestors[i].type === "Program") {
158
+ chain.push(ancestors[i]);
159
+ }
160
+ }
161
+ fnScopeChain.set(node, chain);
162
+ if (isPascalCaseComponent(name)) {
163
+ hotFunctionNodes.add(node);
164
+ directHotNodes.add(node);
165
+ }
166
+ }
167
+ function resolveCalleeNode(callerNode, calleeKey) {
168
+ const chain = fnScopeChain.get(callerNode);
169
+ if (chain) {
170
+ for (const scopeNode of chain) {
171
+ const localMap = scopeFunctions.get(scopeNode);
172
+ const found = localMap?.get(calleeKey);
173
+ if (found) return found;
174
+ }
175
+ }
176
+ return fnByName.get(calleeKey);
177
+ }
121
178
  walk.ancestor(ast, {
122
179
  FunctionDeclaration(node, _state, ancestors) {
123
- const name = getFunctionLabel(node, ancestors);
124
- allFunctions.push({ node, name });
125
- fnByName.set(name, node);
126
- if (isPascalCaseComponent(name)) {
127
- hotFunctionNodes.add(node);
128
- }
180
+ registerFunctionNode(node, ancestors);
129
181
  },
130
182
  FunctionExpression(node, _state, ancestors) {
131
- const name = getFunctionLabel(node, ancestors);
132
- allFunctions.push({ node, name });
133
- fnByName.set(name, node);
134
- if (isPascalCaseComponent(name)) {
135
- hotFunctionNodes.add(node);
136
- }
183
+ registerFunctionNode(node, ancestors);
137
184
  },
138
185
  ArrowFunctionExpression(node, _state, ancestors) {
139
- const name = getFunctionLabel(node, ancestors);
140
- allFunctions.push({ node, name });
141
- fnByName.set(name, node);
142
- if (isPascalCaseComponent(name)) {
143
- hotFunctionNodes.add(node);
144
- }
186
+ registerFunctionNode(node, ancestors);
145
187
  },
146
188
  CallExpression(node, _state, ancestors) {
147
189
  const callee = node.callee;
148
190
  let calleeName = "";
149
191
  let memberProp = "";
192
+ let qualifiedCall = "";
150
193
  if (callee?.type === "Identifier") {
151
194
  calleeName = callee.name;
195
+ qualifiedCall = calleeName;
196
+ } else if (callee?.type === "MemberExpression" && !callee.computed && callee.property?.type === "Identifier") {
197
+ memberProp = callee.property.name;
198
+ if (callee.object?.type === "Identifier") {
199
+ qualifiedCall = `${callee.object.name}.${memberProp}`;
200
+ } else if (callee.object?.type === "ThisExpression") {
201
+ qualifiedCall = memberProp;
202
+ }
203
+ }
204
+ if (qualifiedCall || memberProp) {
152
205
  for (let i = ancestors.length - 1; i >= 0; i--) {
153
206
  if (FUNCTION_NODE_TYPES.has(ancestors[i].type)) {
154
207
  let set = callerToCallees.get(ancestors[i]);
@@ -156,17 +209,20 @@ function analyzeAstHotPaths(ast) {
156
209
  set = /* @__PURE__ */ new Set();
157
210
  callerToCallees.set(ancestors[i], set);
158
211
  }
159
- set.add(calleeName);
212
+ if (qualifiedCall) set.add(qualifiedCall);
213
+ if (memberProp && !ARRAY_HOF_METHODS.has(memberProp)) {
214
+ set.add(memberProp);
215
+ }
160
216
  break;
161
217
  }
162
218
  }
163
- } else if (callee?.type === "MemberExpression" && !callee.computed && callee.property?.type === "Identifier") {
164
- memberProp = callee.property.name;
165
219
  }
166
- if (ARRAY_HOF_METHODS.has(memberProp) || calleeName === "requestAnimationFrame" || memberProp === "requestAnimationFrame") {
220
+ if (ARRAY_HOF_METHODS.has(memberProp) || calleeName === "requestAnimationFrame" || memberProp === "requestAnimationFrame" || calleeName === "cancelAnimationFrame" || memberProp === "cancelAnimationFrame") {
167
221
  for (const arg of node.arguments || []) {
168
222
  if (FUNCTION_NODE_TYPES.has(arg.type)) {
169
223
  hotFunctionNodes.add(arg);
224
+ directHotNodes.add(arg);
225
+ hotExemptNodes.add(arg);
170
226
  }
171
227
  }
172
228
  }
@@ -174,34 +230,58 @@ function analyzeAstHotPaths(ast) {
174
230
  for (let i = ancestors.length - 1; i >= 0; i--) {
175
231
  if (FUNCTION_NODE_TYPES.has(ancestors[i].type)) {
176
232
  hotFunctionNodes.add(ancestors[i]);
233
+ directHotNodes.add(ancestors[i]);
177
234
  break;
178
235
  }
179
236
  }
180
237
  }
181
238
  },
182
- ForStatement(_node, _state, ancestors) {
183
- markEnclosingFunctionHot(ancestors, hotFunctionNodes);
239
+ ForStatement(node, _state, ancestors) {
240
+ hotExemptNodes.add(node);
241
+ markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
184
242
  },
185
- ForInStatement(_node, _state, ancestors) {
186
- markEnclosingFunctionHot(ancestors, hotFunctionNodes);
243
+ ForInStatement(node, _state, ancestors) {
244
+ hotExemptNodes.add(node);
245
+ markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
187
246
  },
188
- ForOfStatement(_node, _state, ancestors) {
189
- markEnclosingFunctionHot(ancestors, hotFunctionNodes);
247
+ ForOfStatement(node, _state, ancestors) {
248
+ hotExemptNodes.add(node);
249
+ markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
190
250
  },
191
- WhileStatement(_node, _state, ancestors) {
192
- markEnclosingFunctionHot(ancestors, hotFunctionNodes);
251
+ WhileStatement(node, _state, ancestors) {
252
+ hotExemptNodes.add(node);
253
+ markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
193
254
  },
194
- DoWhileStatement(_node, _state, ancestors) {
195
- markEnclosingFunctionHot(ancestors, hotFunctionNodes);
255
+ DoWhileStatement(node, _state, ancestors) {
256
+ hotExemptNodes.add(node);
257
+ markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
196
258
  }
197
259
  });
260
+ const forwardHotSet = new Set(directHotNodes);
261
+ let forwardChanged = true;
262
+ while (forwardChanged) {
263
+ forwardChanged = false;
264
+ for (const callerNode of Array.from(forwardHotSet)) {
265
+ const calleeNames = callerToCallees.get(callerNode);
266
+ if (!calleeNames) continue;
267
+ for (const cName of calleeNames) {
268
+ const targetNode = resolveCalleeNode(callerNode, cName);
269
+ if (targetNode && !forwardHotSet.has(targetNode)) {
270
+ forwardHotSet.add(targetNode);
271
+ hotFunctionNodes.add(targetNode);
272
+ hotExemptNodes.add(targetNode);
273
+ forwardChanged = true;
274
+ }
275
+ }
276
+ }
277
+ }
198
278
  let changed = true;
199
279
  while (changed) {
200
280
  changed = false;
201
281
  for (const [callerNode, calleeNames] of callerToCallees.entries()) {
202
282
  if (hotFunctionNodes.has(callerNode)) continue;
203
283
  for (const cName of calleeNames) {
204
- const targetNode = fnByName.get(cName);
284
+ const targetNode = resolveCalleeNode(callerNode, cName);
205
285
  if (targetNode && hotFunctionNodes.has(targetNode)) {
206
286
  hotFunctionNodes.add(callerNode);
207
287
  changed = true;
@@ -227,13 +307,17 @@ function analyzeAstHotPaths(ast) {
227
307
  coldFunctionsProtected
228
308
  },
229
309
  hotFunctionNodes,
230
- coldFunctionNodes
310
+ coldFunctionNodes,
311
+ hotExemptNodes
231
312
  };
232
313
  }
233
- function markEnclosingFunctionHot(ancestors, hotSet) {
314
+ function markEnclosingFunctionHot(ancestors, hotSet, directHotSet) {
234
315
  for (let i = ancestors.length - 1; i >= 0; i--) {
235
316
  if (FUNCTION_NODE_TYPES.has(ancestors[i].type)) {
236
317
  hotSet.add(ancestors[i]);
318
+ if (directHotSet) {
319
+ directHotSet.add(ancestors[i]);
320
+ }
237
321
  break;
238
322
  }
239
323
  }
@@ -260,10 +344,10 @@ var DIRECTIVE_STRINGS = /* @__PURE__ */ new Set([
260
344
  "use asm"
261
345
  ]);
262
346
  var HELPER_TEMPLATE = acorn2.parse(
263
- `const _ = [].map(function(a) {
347
+ `const _ = [].map(function f(a) {
264
348
  var s = "";
265
349
  for (var j = 0; j < a.length; j++) {
266
- s += String.fromCharCode(a.charCodeAt(j) ^ (((0 ^ ((j & 1) * 0)) & 30) | 1));
350
+ s += String.fromCharCode(a.charCodeAt(j) ^ (((0 ^ ((a._u || /\\n/.test(f) * 14) | ((j & 1) * 0))) & 30) | 1));
267
351
  }
268
352
  return s;
269
353
  });`,
@@ -284,8 +368,8 @@ function createVaultHelperAst(cacheVarName, encryptedPayloads, mask, step) {
284
368
  const innerLeft = binaryXor.right.left.left;
285
369
  innerLeft.left.value = mask;
286
370
  innerLeft.left.raw = String(mask);
287
- innerLeft.right.right.value = step;
288
- innerLeft.right.right.raw = String(step);
371
+ innerLeft.right.right.right.value = step;
372
+ innerLeft.right.right.right.raw = String(step);
289
373
  return node;
290
374
  }
291
375
  function computeFnv1aHash(input, seed = 2166136261) {
@@ -305,7 +389,7 @@ function encodeStringWithSeed(str, mask, step) {
305
389
  }
306
390
  return out;
307
391
  }
308
- function applyStringVault(ast, seed = 2654435769, minStringLength = 4) {
392
+ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes) {
309
393
  const suffix = ((seed >>> 0) % 255).toString(36);
310
394
  const cacheVarName = `_uC${suffix}`;
311
395
  const mask = seed >>> 0 & 30 | 3;
@@ -319,6 +403,13 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4) {
319
403
  const val = node.value;
320
404
  if (val.length < minStringLength) return;
321
405
  if (DIRECTIVE_STRINGS.has(val)) return;
406
+ if (hotExemptNodes) {
407
+ for (let i = ancestors.length - 2; i >= 0; i--) {
408
+ if (hotExemptNodes.has(ancestors[i])) {
409
+ return;
410
+ }
411
+ }
412
+ }
322
413
  const parent = ancestors[ancestors.length - 2];
323
414
  if (!parent) return;
324
415
  if (parent.type === "ExpressionStatement" && parent.directive) return;
@@ -651,7 +742,17 @@ function createOpaqueGuardStatement(seed, fnIndex) {
651
742
  type: "BinaryExpression",
652
743
  operator: "^",
653
744
  left: { type: "Literal", value: a, raw: String(a) },
654
- right: { type: "Literal", value: b, raw: String(b) }
745
+ right: {
746
+ type: "BinaryExpression",
747
+ operator: "|",
748
+ left: { type: "Literal", value: b, raw: String(b) },
749
+ right: {
750
+ type: "UnaryExpression",
751
+ operator: "!",
752
+ prefix: true,
753
+ argument: { type: "Identifier", name: "String" }
754
+ }
755
+ }
655
756
  },
656
757
  right: { type: "Literal", value: 7, raw: "7" }
657
758
  },
@@ -708,6 +809,7 @@ function deriveLocalVar(label, seed) {
708
809
  }
709
810
  function createDeterrentSnippet(config) {
710
811
  const seed = config.seed >>> 0;
812
+ const expectedToken = (config.expectedIntegrityHash ?? seed) >>> 0;
711
813
  const deterrentMode = config.deterrentMode ?? "passive";
712
814
  const fnName = deriveIntegrityFnName(seed);
713
815
  const strVar = deriveLocalVar("s", seed);
@@ -716,9 +818,10 @@ function createDeterrentSnippet(config) {
716
818
  const methodsVar = deriveLocalVar("m", seed);
717
819
  const idxVar = deriveLocalVar("i", seed);
718
820
  const errVar = deriveLocalVar("e", seed);
821
+ const tokenBit = expectedToken & 1;
719
822
  const gradualConsoleSilence = deterrentMode === "gradual" ? `if(typeof console!=='undefined'){var ${noopVar}=function(){},${methodsVar}=['log','debug','info','table','dir'];for(var ${idxVar}=0;${idxVar}<${methodsVar}.length;${idxVar}++){try{console[${methodsVar}[${idxVar}]]=${noopVar};}catch(${errVar}){}}}` : "";
720
- const tamperDispatch = `if(typeof window.dispatchEvent==='function'&&typeof CustomEvent==='function'){try{window.dispatchEvent(new CustomEvent('unpeek:tamper'));}catch(${errVar}){}}`;
721
- return `(function ${fnName}(){if(typeof window!=='undefined'){try{var ${strVar}=Function.prototype.toString,${tamperVar}=${strVar}.call(${strVar}).indexOf('[native code]')===-1||${strVar}.call(${fnName}).indexOf('\\n')!==-1||${strVar}.call(${fnName}).indexOf('\\r')!==-1;if(${tamperVar}){window.__unpeek_tampered=!0;${tamperDispatch}${gradualConsoleSilence}}}catch(${errVar}){}}})();`;
823
+ const tamperDispatch = `if(window.dispatchEvent&&typeof CustomEvent!=='undefined'){try{window.dispatchEvent(new CustomEvent('unpeek:tamper'));}catch(${errVar}){}}`;
824
+ return `(function ${fnName}(){if(typeof window!=='undefined'){try{var ${strVar}=Function.prototype.toString,${tamperVar}=${strVar}.call(${strVar}).indexOf('[native code]')<${tokenBit - 1}||/[\\r\\n]/.test(${strVar}.call(${fnName}));if(${tamperVar}){window.__unpeek_tampered=!0;${tamperDispatch}${gradualConsoleSilence}String.prototype._u=14;}}catch(${errVar}){}}})();`;
722
825
  }
723
826
 
724
827
  // src/runtime/index.ts
@@ -764,13 +867,18 @@ function transformJavaScript(code, options = {}) {
764
867
  integrityToken: computeFnv1aHash(code, seed)
765
868
  };
766
869
  }
767
- const { report: hotPathReport, coldFunctionNodes } = analyzeAstHotPaths(ast);
870
+ const {
871
+ report: hotPathReport,
872
+ coldFunctionNodes,
873
+ hotExemptNodes
874
+ } = analyzeAstHotPaths(ast);
768
875
  applyColdFlowGuard(ast, coldFunctionNodes, seed);
769
876
  const mangledSymbolsCount = applyPolymorphicMangler(ast, seed);
770
877
  const { encryptedStringsCount, integrityToken } = applyStringVault(
771
878
  ast,
772
879
  seed,
773
- minStringLength
880
+ minStringLength,
881
+ hotExemptNodes
774
882
  );
775
883
  const outputCode = (0, import_astring.generate)(ast, { indent: "", lineEnd: "" });
776
884
  let finalCode = outputCode;