@cybavo/react-native-auth-service
v1.0.80
Published
React version of CYBAVO AUTH SDK
Downloads
3
Maintainers
Readme
CYBAVO Auth SDK
React-native version of CYBAVO Ayth SDK. Learn more on our website: https://www.cybavo.com/
Getting started
Install dependency
$ npm install @cybavo/react-native-auth-service --save
Link native modules (before React Native 0.60)
React Native >= 0.60
React Native 0.60 introduced autolinking, manual linking should not be necessary
React Native < 0.60
$ react-native link @cybavo/react-native-auth-service
Setup native SDK repository
Android
Edit android/build.gradle
to setup CYBAVO private maven repository
allprojects {
repositories {
// other repositories...
// add CYBAVO private maven repository
maven {
url {CYBAVO_MAVEN_REPO_URL}
credentials {
username = {CYBAVO_MAVEN_REPO_USRENAME}
password = {CYBAVO_MAVEN_REPO_USRENAME}
}
}
}
}
iOS
Append this line in
Podfile
:source 'https://bitbucket.org/cybavo/specs_501.git'
if using Xcode 10.2.1, Xcode 10.3source 'https://bitbucket.org/cybavo/specs_512.git'
if using >= Xcode 11.2Go to ./ios, run
pod install
to install all dependencies.Open
./ios/{{your project}}.xcworkspace
in XCodeIn XCode, run your project (
Cmd+R
)<
Upgrade SDK
Upgrade React-Native SDK
yarn upgrade @cybavo/react-native-auth-service
Since React-Native SDK is built upon native SDKs, you may need to upgrade native SDKs by the following method:
Android
Gradle has a cache mechanism so it may not always upgrade native dependency to latest version. Run the following command when necessary to force Gradle to upgrade Android native dependency to latest.
cd android; ./gradlew assembleDebug --refresh-dependencies
iOS
$ cd ios $ rm -rf Podfile.lock $ pod update
Usage
import { createAuthenticator } from '@cybavo/react-native-auth-service';
// create Authenticator instance
const authenticator = createAuthenticator(SERVICE_ENDPOINT, SREVICE_API_CODE);
// pair device
authenticator.pair(...);
// observe pairing state
authenticator.addPairingStateListener(pairings -> {
// update pairing list
});
// fetch 2-FA actions
authenticator.getTwoFactorAuthentications(...)
.then(actions => {
// display actions
});
// approve 2-FA action
authenticator.approve(...);
// reject 2-FA action
authenticator.reject(...);
// unpair devices
authenticator.unapir([deviceId]);
Check documents of individual module for detail usage
Sample app
Check our sample app on GitHub: https://github.com/CYBAVO/auth-sdk_react-native_example