Skip to content
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

Not working in Expo standalone #4

Open
blocksolution opened this issue Nov 17, 2021 · 12 comments
Open

Not working in Expo standalone #4

blocksolution opened this issue Nov 17, 2021 · 12 comments
Labels
expo good first issue Good for newcomers

Comments

@blocksolution
Copy link

Even if it's possible in expo standalone apps to use metro.config.js, this plugin simply do nothing.

Any clue on how to debug it?

@AnzeBlaBla
Copy link

The plugin seems to get some values (like the final bundle path) from process.argv, which are not supplied when running with expo (expo export --platform android --dev -p http://localhost:8000 for example).

I suggest for @whoami-shubham to add all the options the plugin takes from argv as runOptions and if they're not present, use argv.

I might make a pull request to implement this if I have the time.

@whoami-shubham
Copy link
Owner

@AnzeBlaBla Thanks for the suggestion, a PR would be appreciated, I don't use expo, so I might not be able to recreate and test the fix for this issue.

@AnzeBlaBla
Copy link

We decided not to implement obfuscation yet, but when we do, I'll make a PR to be able to use this plugin

@TowhidKashem
Copy link

TowhidKashem commented Aug 15, 2022

It worked for me on a managed expo app using a custom dev-client when I built a stand alone app for IOS through eas build command. Confirmed using https://github.com/nomi9995/react-native-decompiler. The other main react native ofuscator plugin on the other hand didn't do anything. This one works if you add a metro.config.js file (if you are ejected you should have one already) at the root with the following contents:

require('dotenv').config();
const { mergeConfig } = require('metro-config');
const { getDefaultConfig } = require('expo/metro-config');
const metroObfuscator = require('obfuscator-io-metro-plugin');

const defaultConfig = getDefaultConfig(__dirname);

let metroConfig = defaultConfig;

if (process.env.ENVIRONMENT === 'production') {
  const obfuscator = metroObfuscator(
    {
      // see: https://github.com/javascript-obfuscator/javascript-obfuscator#options
      compact: false,
      sourceMap: false,
      controlFlowFlattening: true,
      controlFlowFlatteningThreshold: 1,
      numbersToExpressions: true,
      simplify: true,
      stringArrayShuffle: true,
      splitStrings: true,
      stringArrayThreshold: 1
    },
    {
      runInDev: false,
      logObfuscatedFiles: false
    }
  );

  metroConfig = mergeConfig(defaultConfig, obfuscator); // right side value takes precedence
}

module.exports = metroConfig;

@whoami-shubham thanks for the plugin, it saved my day! The only issue I have now is it doesn't support json files, if I paste the same json files on the online editor here https://obfuscator.io/ it obfuscates it just fine so I know the underlying lib supports it. Would be great if this wrapper could pass those json files through as well!

@whoami-shubham
Copy link
Owner

whoami-shubham commented Aug 16, 2022

Hi @TowhidKashem can you try this exact version 2.1.0 https://www.npmjs.com/package/obfuscator-io-metro-plugin/v/2.1.0, I tried some fix for JSON, but it wasn't fully tested so I reverted the change in next version.
exts: "/.(j|t)s(x)?$/" is extra option that was added in run config.

@AlenToma
Copy link

AlenToma commented Dec 9, 2022

for json, try to use a library I build togather with this one node.data.obfuscator

@F170x
Copy link

F170x commented Feb 14, 2023

I've the same issue, I'm trying to use it with an ejected expo project (bare workflow).

@TowhidKashem I applied your config to metro.config.js, but when I do expo export --dump-sourcemap --public-url ... I have the following warning:

warning: Obfuscation SKIPPED [Not a bundle command]

I found that the warning comes from here: https://github.com/whoami-shubham/obfuscator-io-metro-plugin/blob/master/lib/utils.js#L28

Anyone know what I'm doing wrong?

Note: I verified the bundle created and, as expected, it's not obfuscated.

@CostasCF
Copy link

@F170x any updates? I get warning: Obfuscation SKIPPED [Not a bundle command] as well

@F170x
Copy link

F170x commented Mar 31, 2023

@CostasCF no updates, I don't know how to use it with Expo

@CostasCF
Copy link

CostasCF commented Mar 31, 2023

@CostasCF no updates, I don't know how to use it with Expo

I used proguard instead for Android, checked the bundle created and indeed it was working.

However, I am going to try to use this tool again and update you if I find anything.

@ColeTownsend
Copy link

@CostasCF any luck?

@CostasCF
Copy link

@CostasCF any luck?

Unfortunately not. It doesn't seem to be working with Expo at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expo good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

8 participants