Package Exports
- @verisoul_ai/react-native-verisoul
Readme
React Native SDK
Overview
The purpose of this app is to demonstrate Verisoul's React Native SDK integration.
To run the app a Verisoul Project ID is required. Schedule a call here to get started.
Getting Started
You can install VerisoulSDK in your React Native project using either yarn or npm.
Installation
Install the package using yarn:
yarn add @verisoul_ai/react-native-verisoulor with npm:
npm install @verisoul_ai/react-native-verisoulSetup
Android
Add Revlum Maven Repository: In your Android project, navigate to your
android/build.gradlefile and ensure that the Verisoul Maven repository is added under theallprojectssection. It should look like this:allprojects { repositories { google() mavenCentral() maven { url = uri("https://us-central1-maven.pkg.dev/verisoul/android") } } }
iOS
- Add Entitlements:
To fully utilize VerisoulSDK, you must add the
App Attestcapability to your project. This capability allows the SDK to perform necessary checks and validations to ensure the integrity and security of your application.
Update your app’s entitlements file:
<key>com.apple.developer.devicecheck.appattest-environment</key>
<string>production/development (depending on your needs)</string>- Update the privacy manifest file :
<?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">
<!--
PrivacyInfo.xcprivacy
test
Created by Raine Scott on 1/30/25.
Copyright (c) 2025 ___ORGANIZATIONNAME___.
All rights reserved.
-->
<plist version="1.0">
<dict>
<!-- Privacy manifest file for Verisoul Fraud Prevention SDK for iOS -->
<key>NSPrivacyTracking</key>
<false/>
<!-- Privacy manifest file for Verisoul Fraud Prevention SDK for iOS -->
<key>NSPrivacyTrackingDomains</key>
<array/>
<!-- Privacy manifest file for Verisoul Fraud Prevention SDK for iOS -->
<key>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<!-- The value provided by Apple for 'Device ID' data type -->
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeDeviceID</string>
<!-- Verisoul Fraud Prevention SDK does not link the 'Device ID' with user's identity -->
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<!-- Verisoul Fraud Prevention SDK does not use 'Device ID' for tracking -->
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<!-- Verisoul Fraud Prevention SDK uses 'Device ID' for App Functionality
(prevent fraud and implement security measures) -->
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
</array>
<!-- Privacy manifest file for Verisoul Fraud Prevention SDK for iOS -->
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<!-- The value provided by Apple for 'System boot time APIs' -->
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<!-- Verisoul Fraud Prevention SDK uses 'System boot time APIs' to measure the amount of
time that has elapsed between events that occurred within the SDK -->
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>
</dict>
</plist>
Usage
1. Initialization
init(env: projectId)
Configure the Verisoul SDK by passing the environment and project ID. This function initializes the networking, device check, and device attestation components.
Parameters:
env (VerisoulEnvironment): The environment to configure the SDK with (VerisoulEnvironment.Dev,VerisoulEnvironment.Sandbox,VerisoulEnvironment.Prod).projectId (string): Your project's unique identifier.
Example Usage:
import { init } from '@verisoul_ai/react-native-verisoul';
import { VerisoulEnvironment } from '@verisoul_ai/react-native-verisoul';
init(VerisoulEnvironment.Prod, "your-project-id")
.then(() => console.log("Verisoul SDK initialized"))
.catch((error) => console.error("Failed to initialize Verisoul SDK:", error));
2. Get Session ID
getSessionId()
Once the minimum amount of data is gathered, the session ID becomes available. The session ID is needed to request a risk assessment from Verisoul's API. Note that session IDs are short-lived and expire after 24 hours.
import { getSessionId } from '@verisoul_ai/react-native-verisoul';
async function fetchSessionId() {
try {
const sessionId = await getSessionId();
console.log("Session ID:", sessionId);
} catch (error) {
console.error("Failed to fetch session ID:", error);
}
}
fetchSessionId();
3. Provide Touch Events (Android Only)
onTouchEvent(x, y, action)
In order to gather touch events and compare them to device accelerometer sensor data, the app needs to provide touch events to Verisoul. The following implementation captures touch events in React Native and forwards them to the Verisoul SDK on Android.
📌 Usage Example:
import { onTouchEvent } from '@verisoul_ai/react-native-verisoul';
import { MotionAction } from '@verisoul_ai/react-native-verisoul';
import { PanResponder, GestureResponderEvent, PanResponderGestureState } from 'react-native';
const panResponder = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onPanResponderGrant: (event: GestureResponderEvent, gestureState: PanResponderGestureState) => {
onTouchEvent(gestureState.x0, gestureState.y0, MotionAction.ACTION_DOWN);
},
onPanResponderMove: (event: GestureResponderEvent, gestureState: PanResponderGestureState) => {
onTouchEvent(gestureState.moveX, gestureState.moveY, MotionAction.ACTION_MOVE);
},
onPanResponderRelease: (event: GestureResponderEvent, gestureState: PanResponderGestureState) => {
onTouchEvent(gestureState.moveX, gestureState.moveY, MotionAction.ACTION_UP);
},
});
export default panResponder;
Questions and Feedback
Comprehensive documentation about Verisoul's iOS SDK and API can be found at docs.verisoul.ai. Additionally, reach out to Verisoul at help@verisoul.ai for any questions or feedback.