@bytehide/react-native-shield
Advanced tools
Comparing version
13
bin.js
@@ -39,2 +39,15 @@ #!/usr/bin/env node | ||
if (argv.replace) { | ||
console.log('Warning: original files will be replaced with obfuscated ones!'); | ||
} | ||
if (excludePatterns.length) { | ||
console.log('Excluding the following patterns from obfuscation:', excludePatterns); | ||
} | ||
if (!argv.projectToken || argv.projectToken === 'your_project_token') { | ||
console.error('Error: project token is required. Please provide it as an argument.'); | ||
process.exit(1); | ||
} | ||
shield | ||
@@ -41,0 +54,0 @@ .obfuscate( |
{ | ||
"name": "@bytehide/react-native-shield", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "React Native plugin for ByteHide Shield obfuscation.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,5 +0,5 @@ | ||
# ByteHide React Native Shield Plugin | ||
This README provides step-by-step instructions for integrating and using the ByteHide React Native Shield Plugin for obfuscating your React Native project's source code. | ||
This README provides step-by-step instructions for integrating and using the ByteHide React Native Shield Plugin for | ||
obfuscating your React Native project's source code. | ||
@@ -22,13 +22,15 @@ ## Installation | ||
```javascript | ||
const shield = require('@bytehide/react-native-shield'); | ||
```javascript | ||
const shield = require('@bytehide/react-native-shield'); | ||
const srcPath = './src'; // Path to source files | ||
const destPath = './dist'; // Path to destination | ||
const projectToken = 'your_project_token'; // Project token | ||
const distDir = './dist'; // Path to the dist directory | ||
const projectToken = 'your_project_token'; // Project token | ||
const replace = true; // Whether to replace the original files or save as new files | ||
const excludePatterns = []; // Patterns to exclude from obfuscation | ||
const obfuscatedExtension = '.obf'; // Extension for obfuscated files | ||
shield | ||
.obfuscate(srcPath, destPath, projectToken) | ||
.then(() => console.log('Obfuscation completed successfully!')) | ||
.catch((err) => console.error('Error during obfuscation:', err)); | ||
shield | ||
.obfuscate(distDir, projectToken, replace, excludePatterns, obfuscatedExtension) | ||
.then(() => console.log('Obfuscation completed successfully!')) | ||
.catch((err) => console.error('Error during obfuscation:', err)); | ||
``` | ||
@@ -89,23 +91,32 @@ | ||
```javascript | ||
```javascript | ||
module.exports = { | ||
commands: [ | ||
{ | ||
name: 'obfuscate', | ||
func: () => { | ||
const shield = require('@bytehide/react-native-shield'); | ||
const srcPath = './src'; | ||
const destPath = './dist'; | ||
const projectToken = 'your_project_token'; | ||
commands: [ | ||
{ | ||
name: 'obfuscate', | ||
func: () => { | ||
const shield = require('@bytehide/react-native-shield'); | ||
const distDir = './dist'; // Path to the dist directory | ||
const projectToken = process.env.BYTEHIDE_PROJECT_TOKEN || 'your_project_token'; | ||
shield | ||
.obfuscate(srcPath, destPath, projectToken) | ||
.then(() => console.log('Obfuscation completed successfully!')) | ||
.catch((err) => console.error('Error during obfuscation:', err)); | ||
}, | ||
}, | ||
], | ||
}; | ||
``` | ||
if (projectToken === 'your_project_token') { | ||
console.error('Project token is required. Please provide it as an argument or set the BYTEHIDE_PROJECT_TOKEN environment variable.'); | ||
process.exit(1); | ||
} | ||
// Optional parameters: replace, excludePatterns, obfuscatedExtension | ||
const replace = false; // If true, the original files will be replaced with the obfuscated files | ||
const excludePatterns = []; // Patterns to exclude from obfuscation | ||
const obfuscatedExtension = '.obf'; // Extension for obfuscated files | ||
shield | ||
.obfuscate(distDir, projectToken, replace, excludePatterns, obfuscatedExtension) | ||
.then(() => console.log('Obfuscation completed successfully!')) | ||
.catch((err) => console.error('Error during obfuscation:', err)); | ||
}, | ||
}, | ||
], | ||
}; | ||
``` | ||
2. Run the command: | ||
@@ -122,6 +133,9 @@ | ||
```bash | ||
npx @bytehide/react-native-shield obfuscate --src ./src --dest ./dist --token your_project_token | ||
npx @bytehide/react-native-shield obfuscate --src ./src --token your_project_token --replace true --obfuscatedExtension .min.js --exclude "*.test.js,*.spec.js" | ||
node obfuscate.js --src ./src --token your_project_token --replace true --obfuscatedExtension .min.js --exclude "*.test.js,*.spec.js" | ||
``` | ||
This command will obfuscate the source files in the `./src` directory and save the obfuscated files in the `./dist` directory. | ||
This command will obfuscate the source files in the `./src` directory and save the obfuscated files in the `./dist` | ||
directory. | ||
## License | ||
@@ -128,0 +142,0 @@ |
10698
18.77%158
6.76%144
10.77%