Wrapper for the Transmit Security Account Protection SDK
npm install react-native-ts-accountprotectionUsing this module, you can easily integrate our Account Protection SDK into your React Native app.
Learn more on our website.
example/src/config.ts and configure the clientId and secret using the configuration obtained from the Transmit portal.yarn in both the module's root folder and the example root folder.yarn example ios or yarn example android.secret in a front-end application.secret you have specified in example/src/config.ts exclusively for demonstration purposes. It is paramount that you safeguard your secret in a secure and confidential location.``sh`
npm install react-native-ts-accountprotectionpod install
#### iOS Setup
You might need to execute in your project's /ios folder.
#### Android Setup
Add to app/build.gradle under repositories
`gradle
repositories {
google()
maven {
url('https://transmit.jfrog.io/artifactory/transmit-security-gradle-release-local/')
}
}
dependencies {
implementation("com.ts.sdk:accountprotection:2.1.+")
}
`
by adding
`xml
"CLIENT_ID"
https://api.transmitsecurity.io/
`Next open your
MainApplication.kt file in your React Native android project, and add:`kt
class Application : Application() {
override fun onCreate() {
super.onCreate()
TSAccountProtection.initializeSDK(this.applicationContext) // initialize the SDK
...
}
}
`$3
First, Create a filed named TransmitSecurity.plist in your native iOS Xcode project:
`xml
credentials
baseUrl
https://api.transmitsecurity.io/
clientId
[CLIENT_ID]
`Next initialize the SDK when your app component is ready
`js
import TSAccountProtectionSDKModule, { TSAccountProtectionSDK } from 'react-native-ts-accountprotection';componentDidMount(): void {
// Setup the module as soon your component is ready
await TSAccountProtectionSDKModule.initializeSDKIOS();
}
`Module API
#### Set UserID after authentication
`js
await TSAccountProtectionSDKModule.setUserId(username);
`#### Trigger Action
`js
private handleTriggerActionLoginExample = async () => {
const triggerActionResponse = await TSAccountProtectionSDKModule.triggerAction(
TSAccountProtectionSDK.TSAction.login,
{
correlationId: "CORRELATION_ID",
claimUserId: "CLAIM_USER_ID",
referenceUserId: "REFERENCE_USER_ID",
transactionData: undefined
}
)
const actionToken = triggerActionResponse.actionToken;
console.log("Action Token: ", actionToken); // Use the action token to invoke the recommendation API.
}
`#### Clear User ID
`js
await TSAccountProtectionSDKModule.clearUser();
`#### Set Log Level (Optional)
Enable or disable SDK debug logging:
`js
await TSAccountProtectionSDKModule.setLogLevel(true); // Enable debug logging
await TSAccountProtectionSDKModule.setLogLevel(false); // Disable debug logging
``Transmit Security, https://github.com/TransmitSecurity
This project is licensed under the MIT license. See the LICENSE file for more info.