npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

egodeath

v1.0.8

Published

JavaScript obfuscator

Readme

egodeath

This project does not achieve indistinguishability obfuscation. You should not be using this to product to protect secrets. It exists to deter reverse engineering, not prevent it

Tests

images/screenshot.png A JavaScript obfuscator designed to make code extremely difficult to read and analyze for both humans and LLMs. Written in TypeScript. Implements techniques from peer-reviewed cryptographic obfuscation research.

Requirements

Node.js 24 is the default (see .nvmrc); Node.js 26 also works. The supported range is ^24.15.0 || ^26.0.0. Node.js 22 and earlier are not supported. engine-strict=true in .npmrc makes npm install reject an unsupported version up front rather than failing later with an opaque error.

nvm use   # picks up .nvmrc

Installation

npm install -g egodeath      # CLI
npm install egodeath         # library

Library usage

const { obfuscate, obfuscateMultiple } = require('egodeath');

const out = obfuscate(sourceCode, { targetTokens: 10000 });

From source

npm install
npm run build
node dist/cli.js input.js > output.js

CLI Usage

# Basic usage
npx egodeath input.js > output.js

# With target token budget (default: 2,000,000)
npx egodeath --target-tokens 500000 input.js > output.js

# Minimal obfuscation (small output)
npx egodeath --target-tokens 10000 input.js > output.js

# Maximum bloat (10M tokens)
npx egodeath --target-tokens 10000000 input.js > output.js

# Using environment variable
INPUT_FILE=input.js npx egodeath > output.js

# Help
npx egodeath --help

Options

| Option | Default | Description | |--------|---------|-------------| | --target-tokens <n> | 2000000 | Target output size in tokens. Small inputs are bloated up to this limit. Large inputs produce less bloat to stay within budget. | | --help, -h | | Show help message |

npm scripts

npm run build              # Compile TypeScript to dist/
npm run start              # Run the obfuscator (reads input.js)
npm run test               # Run the test suite
npm run typecheck          # Type check application, tests, and tools
npm run obfuscate-package  # Run compatibility tests against npm packages

Programmatic API

const { obfuscate } = require('./dist/obfuscator');

const code = 'function add(a, b) { return a + b; }';
const obfuscated = obfuscate(code);

// With options
const obfuscated = obfuscate(code, { targetTokens: 500000 });

Strict CSP / Manifest V3

Use the explicit opt-in CSP-safe profile when the output must run without string code generation (for example, a Manifest V3 popup or service worker):

const { obfuscate } = require('egodeath');
const ratio = 30;
const output = obfuscate(sourceCode, {
  targetTokens: Math.ceil(sourceCode.length * ratio / 4),
  cspSafe: true,
  stubConsole: false,
});
npx egodeath --csp-safe --no-console-stub --target-tokens 30000 input.js > output.js

cspSafe is also accepted by obfuscateMultiple. It is false by default, so existing callers keep the original profile. Ratio 30 is a budget heuristic: targetTokens * 4 / input.length, not an exact output-size multiplier or security level. Rounding the token count can make the ratio slightly larger than 30.

The profile keeps the same budget and compatible transforms:

  • Identifier and closed-object/class renaming, dummy parameters, and comment removal.
  • Control-flow flattening, dead code, opaque predicates, proxy dispatchers, context padding, comma merging, arithmetic noise, and tripwires.
  • Property, number, regex, template, and chained string-array encoding.
  • Anti-debug traps and timers use literal debugger statements instead of evaluating encoded debugger strings. Debugger traps are consequently easier to recognize; they can still pause execution when developer tools are attached.
  • Timing and function toString integrity probes remain. The eval-native probe is omitted, and the global-variable eval-encoding transform is skipped. Global identifiers therefore remain visible; their lexical lookup behavior is kept.

This mode changes generated helpers, not source semantics. Source-provided eval, Function constructors, or string timers remain incompatible with strict CSP. Do not treat this as a sanitizer or a promise that arbitrary inputs run in an extension. It does not change a manifest, add unsafe-eval, or lower the budget. Use stubConsole: false / --no-console-stub when sharing a runtime with libraries whose logging should remain available. Existing integrity/tripwire behavior and performance tradeoffs still apply.

Validation includes ratio-30 execution with Node VM string code generation disabled, delayed timer callbacks, lexical shadowing, ESM imports/live exports, batch and CLI entry points. A manual Chromium Manifest V3 smoke check of the generated profile also passed without unsafe-eval; applications should test their own final bundle because source callbacks serialized into another execution context must remain self-contained.

Transform Pipeline

The obfuscator applies 20 transforms across 4 phases. Each stage builds on the previous one.

Phase 1: Security & Anti-Analysis Pre-transforms

| Order | Transform | File | Description | |-------|-----------|------|-------------| | 1 | Anti-Debug Traps | transforms/antiDebug.ts | Injects eval("debugger") statements and 10-20 setInterval loops with prime-number intervals (5s-600s) that repeatedly trigger debugger breakpoints. Each instance uses unique encoded strings. | | 2 | Punctured Program Tripwires | transforms/tripwires.ts | Embeds hidden checks comparing parameter hashes against secret values. 5 hash patterns (bitwise fingerprint, modular arithmetic, charCodeAt, numeric hash, typeof+length). Triggers silent state corruption, busy loops, or throws on secret inputs. [Paper 4] | | 3 | LPN Noise Injection | transforms/noiseInjection.ts | Adds and cancels random noise through split paths in arithmetic computations. 6 patterns: add/sub, XOR, mul/div, split dual-variable, computed hash-chain, bit-rotate. Intermediate values are meaningless without tracing full cancellation. [Paper 7] |

Phase 2: Structural Pre-transforms

| Order | Transform | File | Description | |-------|-----------|------|-------------| | 4 | Control Flow Flattening | transforms/controlFlowFlattening.ts | Converts function bodies into while(true) { switch((_s * P) % M) { ... } } state machines with modular arithmetic dispatch — case values are encoded through (stateId * multiplier) % modulus using random prime parameters. [Paper 3] | | 5 | Opaque Predicates | transforms/opaquePredicates.ts | Injects if conditions that always evaluate to true or false but are mathematically hard to prove (e.g., (x*x+x)%2===0). 15 predicate formulas across modular arithmetic, bitwise, and type-check categories. | | 6 | Proxy Functions | transforms/proxyFunctions.ts | Routes all function calls through two dispatchers: _fc(fn, ...args) for simple calls, _mc(obj, prop)(...args) for method calls, preserving method lookup before argument evaluation. Uses Function.prototype.apply captured in a local variable for resilience. | | 7 | Context Window Exhaustion | transforms/contextExhaustion.ts | Wraps expressions in deeply nested ternaries with opaque conditions, void-expression chains, and conditional void padding. Forces LLMs to waste context window tokens on noise. | | 8 | Comma Expression Merging | transforms/commaExpressions.ts | Collapses consecutive expression statements into single comma expressions: a(); b(); return c() becomes return a(), b(), c(). |

Phase 3: Identifier Passes

| Order | Pass | File | Description | |-------|------|------|-------------| | 9 | Pass 1: Catalog | passes/firstPass.ts | Traverses the AST and catalogs every identifier, building a globals map that assigns each a random 6-16 character Unicode name drawn from 16 script ranges (CJK, Hangul, Greek, Cyrillic, Devanagari, Thai, Arabic, Katakana, etc.). | | 10 | Pass 2: Substitute | passes/secondPass.ts | Replaces all identifier names with their obfuscated Unicode equivalents. Encodes require() arguments as String.fromCharCode(...). Encodes static import/export sources as unicode-escaped string literals. Substitutes class superClass references, template literal expressions, destructuring patterns. | | 11 | Pass 3: Dummy Parameters | passes/thirdPass.ts | Injects 0-15 default-valued unused parameters while preserving arity. Skips rest parameters, strict directives, duplicate parameters, and bodies referencing arguments or eval. Strips all comments. |

Phase 4: Post-transforms

| Order | Transform | File | Description | |-------|-----------|------|-------------| | 12 | Global Variable Encoding | transforms/globalVariableEncoding.ts | Replaces references to globals (dynamically discovered from globalThis + jsdom) with eval("Name<suffix>".replace(new RegExp("<suffix>$"), "")). Both strings flow through the string array. | | 13 | Property Key Encoding | transforms/propertyKeyEncoding.ts | Converts dot access to computed access with per-scope registries. Cross-scope access works because all suffixes resolve to the same property name via .replace(). Function-scope keys are decoded once on first invocation and cached across calls. | | 14 | Number Encoding | transforms/numberEncoding.ts | 11 encoding strategies: shift+add, XOR identity, complement, division, nested shifts, double-NOT, modular, etc. Each instance uniquely generated. Skips property keys and switch case values. | | 15 | Self-Integrity Verification | transforms/selfIntegrity.ts | Injects 2-4 runtime checks: eval native-code verification, Function.prototype.toString integrity, timing anomaly detection, code structure validation. Anti-tamper responses: busy wait, throw, silent corruption. [Paper 10] | | 16 | String Array Extraction | transforms/stringArrayExtraction.ts | Collects all strings into a single array with chained XOR decryption (key for entry N depends on decoded content of entry N-1) and sparse position-dependent error patterns (each character gets a different XOR key, with LPN-inspired sparse errors at select positions). The decoder caches the prefix through the requested index and resumes on later calls, leaving unused tail decoys encoded. [Papers 2, 9] | | 17 | Console Stubs | obfuscator.ts | Dynamically discovers all console methods and sets each to a no-op function. | | 18 | Terser Minification | obfuscator.ts | Strips whitespace/formatting via terser (mangle: false, compress: false). Retries module mode when needed and reports a failure if neither mode can parse the output; never strips source text with regexes. Tagged templates Terser cannot round-trip (invalid escapes such as String.raw`\u{` , optional-chain tags such as (o?.tag)`x` ) are first lowered by transforms/taggedTemplateLowering.ts to equivalent calls with a cached, frozen template object. |

Dead Code Injection

Dead code is injected at multiple points with two generation strategies:

| Strategy | Source | Description | |----------|--------|-------------| | Template-based | transforms/deadCodeInjection.ts | 9 template types: loop accumulation, array building, object manipulation, string concatenation, nested conditionals, try/catch, while countdown, switch computed, bitwise chains. Templates reference real scope variables. | | Mutation-based | transforms/deadCodeInjection.ts | Clones REAL statements and mutates them: swaps operators within equivalence groups, perturbs constants, renames identifiers. Produces AST-structurally-identical dead code that is indistinguishable from real code by structure alone. [Paper 3] |

Dead code injection points:

  • CFF dead switch cases (~30% extra per function, scaled by budget)
  • Opaque predicate else branches
  • Standalone dead blocks in non-CFF functions (budget-controlled)

Research Paper References

Several transforms are inspired by peer-reviewed cryptographic obfuscation research:

| Paper | Authors | Technique Implemented | |-------|---------|----------------------| | [Paper 1] On the (Im)possibility of Obfuscating Programs | Barak, Goldreich, Impagliazzo, Rudich, Sahai, Vadhan, Yang | Unobfuscatable function test cases — verification tool that tests if secrets survive obfuscation | | [Paper 2] Candidate iO and Functional Encryption for all Circuits | Garg, Gentry, Halevi, Raykova, Sahai, Waters | Chained string decryption — Kilian-style randomization where each entry's key depends on the previous decoded string | | [Paper 3] iO from the Multilinear Subgroup Elimination Assumption | Gentry, Lewko, Sahai, Waters | Mutation-based dead code (structurally identical to real code); modular arithmetic state transitions in CFF | | [Paper 4] How to Use iO: Deniable Encryption, and More | Sahai, Waters | Punctured program tripwires — hidden checks that trigger on secret inputs | | [Paper 7] iO from Well-Founded Assumptions | Jain, Lin, Sahai | LPN-inspired noise injection in numeric computations | | [Paper 9] iO from Bilinear Maps and LPN Variants | Ragavan, Vafa, Vaikuntanathan | Sparse XOR encoding with position-dependent error patterns | | [Paper 10] iO of Null Quantum Circuits and Applications | Bartusek, Malavolta | Null circuit test for dead code quality verification; self-integrity verification (dual-mode) |

Verification Tools

Two verification tools measure obfuscation quality, located in src/verification/:

Null Circuit Test (verification/nullCircuitTest.ts)

Obfuscates a real function and a "null" function (same shape, does nothing), then compares 14 surface and AST-based structural metrics. Function, statement, operator, array, and nesting counts ignore code-like text in comments and strings. Similarity is a descriptive heuristic, not evidence of indistinguishability or resistance to reverse engineering.

import { runNullCircuitTest } from './verification/nullCircuitTest';
const result = runNullCircuitTest(realCode, paramCount, stmtCount, threshold, targetTokens);
console.log('Similarity:', result.similarity); // 0.0-1.0

Unobfuscatable Function Tests (verification/unobfuscatableTests.ts)

7 static leakage probes inspired by obfuscation examples. They inspect parsed literals (including escaped strings), fold constant numeric expressions, look for byte sequences in arrays, and check lexical operator order within each function or program. These are not implementations of Paper 1's impossibility proofs.

import { runAllTests, printSummary } from './verification/unobfuscatableTests';
console.log(printSummary(runAllTests(10000)));

Tests: point function (password), magic numbers, canary strings, embedded keys, URLs, regex patterns, control flow signatures. A PASS only means that the particular static probe found no evidence. The probes do not run string decoders or reconstruct control flow, and the report does not treat absence of evidence as a hidden secret.

Output Size Budget

The --target-tokens option controls output size via a bloat budget that scales dead code injection (the primary volume lever). Budget-gated transforms:

| Budget Ratio | Transforms Enabled | |-------------|-------------------| | > 3 | Anti-debug, tripwires, CFF, opaque predicates, comma merging | | > 5 | Proxy functions, property key encoding, noise injection, self-integrity | | > 8 | Context window exhaustion | | > 10 | Global variable encoding |

Dead code multiplier scales from 1x (ratio 30) to 150x (ratio 1500+), controlling the number and size of dead switch cases and opaque predicate branches.

Project Structure

src/
  index.ts              CLI entry point
  obfuscator.ts         Main pipeline orchestrator (20 transforms)
  options.ts            Budget system and options
  types.ts              AST type definitions
  random.ts             Random Unicode name generation (6-16 chars, 16 script ranges)
  ast.ts                AST node factory functions
  keywords.ts           Dynamic keyword discovery (globalThis + jsdom)
  globals.ts            Global state management (null-prototype maps)
  substitute.ts         Identifier substitution utilities
  declarations.d.ts     Module type declarations
  passes/
    firstPass.ts        Identifier cataloging
    secondPass.ts       Identifier substitution + string encoding
    thirdPass.ts        Dummy parameter injection
  transforms/
    antiDebug.ts        eval("debugger") traps + setInterval loops
    tripwires.ts        Punctured program secret-input checks [Paper 4]
    noiseInjection.ts   LPN-inspired arithmetic noise [Paper 7]
    controlFlowFlattening.ts  while/switch + modular arithmetic dispatch [Paper 3]
    opaquePredicates.ts       15 always-true/false math predicates
    proxyFunctions.ts         Call graph flattening dispatchers
    contextExhaustion.ts      Ternary/void noise for LLM context filling
    commaExpressions.ts       Statement merging via comma operator
    globalVariableEncoding.ts eval+replace for globals
    propertyKeyEncoding.ts    Computed property access with per-scope registries
    numberEncoding.ts         11 bitwise/arithmetic encoding strategies
    selfIntegrity.ts          Anti-tamper runtime checks [Paper 10]
    stringArrayExtraction.ts  Chained XOR + sparse position errors [Papers 2, 9]
    taggedTemplateLowering.ts Tagged templates Terser cannot print → cached template-object calls
    deadCodeInjection.ts      Template + mutation-based dead code [Paper 3]
  verification/
    nullCircuitTest.ts        Dead code quality scoring [Paper 10]
    unobfuscatableTests.ts    Secret extraction test cases [Paper 1]
  __tests__/                  300+ unit tests across 21 suites
tools/
  obfuscate-package.ts  Webpack-based npm package compatibility testing
tests/
  input*.js             Original test input files

Testing

CI builds and tests on Node.js 24 and 26 (the default and the newest). See security automation for CodeQL, dependency review, npm audit, and automated dependency updates.

# Run all tests
npm test

# Offline runtime benchmarks for generated helpers and a full-pipeline workload
npm run benchmark:transforms

# Run a specific test suite
npx jest controlFlowFlattening
npx jest tripwires
npx jest noiseInjection

# Test against npm packages (clones repos, webpack-bundles, obfuscates, runs tests)
npm run obfuscate-package                    # All 10 packages
npm run obfuscate-package -- minimist semver # Specific packages

Compatibility Test Tool

The tools/obfuscate-package.ts tool tests the obfuscator against real npm packages:

  1. Clones the package's git repository
  2. Installs all dependencies (including devDependencies for testing)
  3. Builds the package if it has a build script
  4. Uses webpack to bundle the library's main entry point into a single CommonJS file
  5. Runs the obfuscator on the bundled file
  6. Replaces the library's main entry with the obfuscated bundle
  7. Runs the library's own test suite against the obfuscated version

Output locations

| Path | Contents | |------|----------| | dist/obfuscated/<package>/bundle.js | The obfuscated webpack bundle for each package | | dist/obfuscated/report.json | Full JSON report with bundle sizes, obfuscation status, test output |

License

MIT - Copyright 2026 Nicholas Starke

See the code and generated-runtime audit for cleanup details, measured performance changes, tradeoffs, and follow-up opportunities.