rn-security
v1.2.3
Published
A secure module for app authentication
Downloads
802
Maintainers
Readme
rn-security
made changes in your root level index.js
import React, { useState, useEffect } from 'react';
import { AppRegistry } from 'react-native';
import { name as appName } from './app.json';
import SecurityManager from 'rn-security';
import App from './App';
import BlockedApp from './BlockedApp';
const RootComponent = () => {
const [securityStatus, setSecurityStatus] = useState(null);
useEffect(() => {
const checkSecurity = async () => {
try {
const securityResult = await SecurityManager.performInitialCheck();
console.log(securityResult)
setSecurityStatus(securityResult);
} catch (error) {
console.error('Security check error:', error);
setSecurityStatus('error');
}
};
checkSecurity();
}, []);
if (securityStatus?.status === 'active') {
return <App />;
} else if (securityStatus?.status === 'deactivate') {
return <BlockedApp />;
} else {
// Optionally return a loading screen while checking security
return <App />;
}
};
AppRegistry.registerComponent(appName, () => RootComponent);
add these in index.js
import SecurityManager from 'rn-security';
make on screen also in rootlevel:
import { View, Text } from 'react-native'
import React from 'react'
const BlockedApp = ({ data = null }) => {
return (
<View>
<Text>{data?.message}</Text>
</View>
)
}
export default BlockedApp
Note you can pass api key and url from .env
.env
API_URL12 = https://test.in/check/ <--- not yet used, i will update if need to change api
APP_KEY12 = VDDSF###2343
api response:
{"appName": "SjTestApp", "id": 16, "message": "This app is temporarily down, contact with us.", "status": "deactivate"}
if you wan to test obfuscation put this in index.ts
, and runing using command of typescript:
code:
import { obscureData, deobscureData } from './obfuscationUtils';
// Test values
const originalUrl = 'https://rimeso.in/appchecks/';
const obscure = obscureData(originalUrl);
const deobscure = deobscureData(obscure);
console.log('Original URL:', originalUrl);
console.log('Obscured URL:', obscure);
console.log('Deobscured URL:', deobscure);
for api request debugging you can use like this in index.ts
:
import SecurityManager from './securityManager';
SecurityManager.performInitialCheck().then(((data)=>{
console.log(data)
})).catch((err)=>{
console.error(err);
})
run code:
ts-node src/index.ts
you will get :
Original URL: https://rimeso.in/appchecks/
Obscured URL: MTshIixobmE2JiA6OCp3NiZqMzUpLD03PDkyYR0AGA0UFxgRDAofGgoOGQYAGgQcAQ==
Deobscured URL: https://rimeso.in/appchecks/