Skip to content

support for RN >= 0.56 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2019
Merged

Conversation

jes-carr
Copy link

@jes-carr jes-carr commented Oct 6, 2018

No description provided.

@jes-carr
Copy link
Author

jes-carr commented Dec 4, 2018

Would you have a look into this and merge?

Copy link

@robertpaul01 robertpaul01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require("metro/src/reactNativeTransformer") is needed.

Also, the documentation should be updated to

module.exports = ({
  transformer: {
    babelTransformerPath: require.resolve("./transformer")
  },
});

@jes-carr
Copy link
Author

Yes babelTransformerPath: require.resolve("./transformer") is in line 48 https://github.com/javascript-obfuscator/react-native-obfuscating-transformer/pull/7/files#diff-f48aafff6e296a5dab713b5ffbce17f5R48

I just commited the updated documentation

@@ -16,8 +16,8 @@ or

```diff
module.exports = {
+ getTransformModulePath() {
+ return require.resolve("./transformer")
+ transformer {
Copy link

@marsinearth marsinearth Jan 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transformer: {

missed a colon

@marsinearth
Copy link

marsinearth commented Jan 8, 2019

I used this pull request with yarn add javascript-obfuscator/react-native-obfuscating-transformer#7/head but keep getting cannot find module 'react-native-obfuscating-transformer' when react-native run-ios

@xkrsz
Copy link

xkrsz commented Jan 23, 2019

@marsinearth it doesn't work, because you have to compile typescript first. Checkout to this branch, run yarn, tsc, and you should be good to go.

@sytler
Copy link

sytler commented Jan 31, 2019

@krszwsk so the upstream transformer is broken here?

@xkrsz
Copy link

xkrsz commented Jan 31, 2019

@sytler No, you just have to compile TS first in order to use the package from the repository directly.

@sytler
Copy link

sytler commented Feb 1, 2019

@krszwsk have you tried this transformer on 0.57.7+? (metro@0.48.5)

@xkrsz
Copy link

xkrsz commented Feb 1, 2019

@sytler yup, I ran it on 0.57.8

@sytler
Copy link

sytler commented Feb 1, 2019

@krszwsk which version of javascript-obfuscator are u using? try to run yarn why javascript-obfuscator

@sytler
Copy link

sytler commented Feb 1, 2019

Im using this config and somehow it is not working (it works in older project, with RN 0.55.4 (metro 0.30.2))

rn-cli.config.js

const { getDefaultConfig } = require("metro-config");

module.exports = (async () => {
  const {
    resolver: { sourceExts }
  } = await getDefaultConfig();
  return {
    transformer: {
      babelTransformerPath: require.resolve('./transformer'),
    },
    resolver: {
      sourceExts: [...sourceExts]
    }
  };
})();

transformer.js

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

module.exports = obfuscatingTransformer({
  upstreamTransformer: typescriptTransformer,
  obfuscatorOptions: {
    compact: true,
    // controlFlowFlattening: true,
    // controlFlowFlatteningThreshold: 0.75,
    // deadCodeInjection: true,
    // deadCodeInjectionThreshold: 0.4,
    debugProtection: false,
    disableConsoleOutput: true,
    identifierNamesGenerator: "hexadecimal",
    log: true,
    reservedStrings: ['import', 'require', 'class declaration', 'export'],
    rotateStringArray: true,
    seed: 1,
    selfDefending: false,
    sourceMap: true,
    sourceMapMode: "separate",
    stringArray: true,
    stringArrayEncoding: 'base64',
    stringArrayThreshold: 0.8,
    transformObjectKeys: false,
    unicodeEscapeSequence: true,
  },
  trace: true,
  emitObfuscatedFiles: false,
  enableInDevelopment: true,
});

error

SyntaxError in src/api/client/index.ts: Unexpected token, expected , (1:3748)

SyntaxError: Unexpected token, expected , (1:3748)
    at Parser.pp$5.raise (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:4454:13)
    at Parser.pp.unexpected (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:1761:8)
    at Parser.pp.expect (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:1749:33)
    at Parser.pp$3.parseExprList (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:4296:12)
    at Parser.pp$3.parseNew (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:3916:27)
    at Parser.pp$3.parseExprAtom (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:3733:19)
    at Parser.pp$3.parseExprSubscripts (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:3494:19)
    at Parser.pp$3.parseMaybeUnary (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:3474:19)
    at Parser.pp$3.parseExprOps (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:3404:19)
    at Parser.pp$3.parseMaybeConditional (/Users/user/Desktop/Projects/REPO/project/node_modules/babylon/lib/index.js:3381:19)

@ds300 ds300 merged commit a1dbbc8 into javascript-obfuscator:master Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants