react-native-ts-accountprotection
v0.1.2
Published
Wrapper for the Transmit Security Account Protection SDK
Downloads
4
Maintainers
Readme
React Native - Transmit Security Account Protection SDK
Detect risk in customer interactions on digital channels, and enable informed identity and trust decisions across the consumer experience.
About Account Protection SDK
The React Native Detection and Response SDK Wrapper is a versatile tool designed to seamlessly integrate the powerful capabilities of the Detection and Response services into your React Native applications. By encapsulating the APIs of the native SDKs for both iOS and Android platforms, this wrapper empowers enterprises to confidently enhance security measures while maintaining a smooth user experience.
Using this module, you can easily integrate our Account Protection SDK into your React Native app. Learn more on our website.
Understand the flows
We recommended that you read more about the native Account Protection SDKs as described in our iOS documentation and Android documentation
Configure your app
To integrate this module, you'll need to configure an application in our portal.
Example project setup
- In your project, navigate to
example/src/config.ts
and configure the clientId and secret using the configuration obtained from the Transmit portal. - Ensure you have all the necessary dependencies by running
yarn
in both the module's root folder and the example root folder. - Run the example app on a real device using Xcode or Android Studio. Alternatively, execute
yarn example ios
oryarn example android
.
Important Security Note: Never store your
secret
in a front-end application.The example app utilizes a mock server to manage communication with the authentication platform. This mock server employs the
secret
you have specified inexample/src/config.ts
exclusively for demonstration purposes. It is paramount that you safeguard yoursecret
in a secure and confidential location.
Installation
npm install react-native-ts-accountprotection
iOS Setup
You might need to execute pod install
in your project's /ios
folder.
Android Setup
Add to app/build.gradle
under repositories
repositories {
google()
maven {
url('https://transmit.jfrog.io/artifactory/transmit-security-gradle-release-local/')
}
}
dependencies {
implementation("com.ts.sdk:accountprotection:2.1.+")
}
Module Setup
Initialize the Android SDK
First, update your strings.xml
by adding
<resources>
<!-- Transmit Security Credentials -->
<string name="transmit_security_client_id">"CLIENT_ID"</string>
<string name="transmit_security_base_url">https://api.transmitsecurity.io/</string>
</resources>
Next open your MainApplication.kt
file in your React Native android
project, and add:
override fun onCreate() {
super.onCreate()
TSAccountProtection.initializeSDK(this.applicationContext) // initialize the SDK
...
}
Initialize the iOS SDK
First, Create a filed named TransmitSecurity.plist
in your native iOS Xcode project:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>credentials</key>
<dict>
<key>baseUrl</key>
<string>https://api.transmitsecurity.io/</string>
<key>clientId</key>
<string>[CLIENT_ID]</string>
</dict>
</dict>
</plist>
Next initialize the SDK whe your app component is ready
import TSAccountProtectionSDKModule, { TSAccountProtectionSDK } from 'react-native-ts-accountprotection';
componentDidMount(): void {
// Setup the module as soon your component is ready
await TSAccountProtectionSDKModule.initializeSDK();
}
Module API
Set UserID after authentication
await TSAccountProtectionSDKModule.setUserId(username);
Trigger Action
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
await TSAccountProtectionSDKModule.clearUser();
Important
Please take note that the example application uses a client-side mock server. In a production environment, a real server is required. Additionally, it is crucial to emphasize that storing the client secret in your front-end application is strictly discouraged for security reasons.
Support
Author
Transmit Security, https://github.com/TransmitSecurity
License
This project is licensed under the MIT license. See the LICENSE file for more info.