GithubHelp home page GithubHelp logo

sytler / react-native-obfuscating-transformer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jesucarr/react-native-obfuscating-transformer

1.0 2.0 0.0 181 KB

Obfuscation for React Native bundles

License: MIT License

TypeScript 99.02% JavaScript 0.98%

react-native-obfuscating-transformer's Introduction

react-native-obfuscating-transformer

Obfuscate selected source files when building for React Native.

Installation

yarn add react-native-obfuscating-transformer --dev

or

npm install react-native-obfuscating-transformer --save-dev

Usage

/rn-cli.config.js

 module.exports = {
+  getTransformModulePath() {
+    return require.resolve("./transformer")
+  },
 }

/transformer.js

const obfuscatingTransformer = require("react-native-obfuscating-transformer")

module.exports = obfuscatingTransformer({
  /* options */
})

Configuration

Options are:

upstreamTransformer: MetroTransformer

Defines what the first pass of code transformation is. If you don't use a custom transformer already, you don't need to set this option.

TypeScript example:

 const obfuscatingTransformer = require('react-native-obfuscating-transformer')
+ const typescriptTransformer = require('react-native-typescript-transformer')

 module.exports = obfuscatingTransformer({
+  upstreamTransformer: typescriptTransformer
 })

Default value: require('metro/src/transformer')

filter: (filename: string, source: string) => boolean

Returns true for any files that should be obfuscated and false for any files which should not be obfuscated.

By default, it obfuscates all files in src/**/*

obfuscatorOptions: ObfuscatorOptions

Warning โ€” Not all options are guaranteed to produce working code. In particular, stringArray definitely breaks builds.

See the javascript-obfuscator docs for more info about what each option does.

interface ObfuscatorOptions {
  compact?: boolean
  controlFlowFlattening?: boolean
  controlFlowFlatteningThreshold?: 0.75
  deadCodeInjection?: boolean
  deadCodeInjectionThreshold?: 0.4
  debugProtection?: boolean
  debugProtectionInterval?: boolean
  disableConsoleOutput?: boolean
  domainLock?: string[]
  identifierNamesGenerator?: "hexadecimal" | "mangled"
  log?: boolean
  renameGlobals?: boolean
  reservedNames?: string[]
  rotateStringArray?: true
  seed?: 0
  selfDefending?: boolean
  sourceMap?: boolean
  sourceMapBaseUrl?: string
  sourceMapFileName?: string
  sourceMapMode?: "separate" | "inline"
  stringArray?: boolean
  stringArrayEncoding?: boolean
  stringArrayThreshold?: 0.75
  target?: "browser" | "extension" | "node"
  unicodeEscapeSequence?: boolean
}

trace: boolean

Iff true, prints a list of files being obfuscated

Default value: false

emitObfuscatedFiles: boolean

Iff true, emits the obfuscated versions of files alongside their originals, for comparison.

Default value: false

enableInDevelopment: boolean

Iff true, enables obfuscation in development mode.

Default value: false

License

MIT

react-native-obfuscating-transformer's People

Contributors

ds300 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.