@au10tixorg/secureme-sdk
v4.7.1
Published
A React Native bridge for implementing Secure.me native functionality
Maintainers
Readme
SecureMe SDK
React Native library for SecureMe integration (iOS & Android).
Development
Prerequisites
- Node.js 14+ and npm
- React Native development environment
- For iOS: Xcode and CocoaPods
- For Android: Android Studio and Java
📖 Documentation
For a comprehensive overview of features, configuration options, and integration steps, please see the Integration Guide (GUIDE.md).
Building the Library
Clone the repository
git clone <repository-url> cd reactnative-secure.me-sdkInstall dependencies
yarn installBuild the library
npx react-native-builder-bob build
Clean Rebuild
To perform a complete clean rebuild:
# Clean all build artifacts and dependencies
rm -rf lib node_modules package-lock.json yarn.lock .yarn/cache .yarn/install-state.gz example/node_modules example/package-lock.json example/ios/Pods example/ios/Podfile.lock
# Reinstall and rebuild
yarn install
npx react-native-builder-bob buildAvailable Scripts
yarn run typescript- Type check with TypeScriptyarn run lint- Lint code with ESLintnpx react-native-builder-bob build- Build the library (via react-native-builder-bob)yarn test- Run testsyarn run example- Run commands in the example appyarn run pods- Install iOS pods for the example app
iOS Setup
1. Install Pods
Go to your project's iOS folder and install dependencies:
cd ios
pod installAndroid Setup
1. Minimum SDK Version
Ensure your android/build.gradle has minimum SDK version 21 or higher:
buildscript {
ext {
minSdkVersion = 21
}
}Usage
Here is a basic example of how to integrate the SDK into your application.
Note: Use Named Import with curly braces
{ SecuremeSdk }.
import React, { useEffect, useState } from 'react';
import {
SafeAreaView,
View,
Text,
Button,
StyleSheet,
Alert,
ActivityIndicator,
Linking,
Platform,
PermissionsAndroid,
} from 'react-native';
import { SecuremeSdk, SMFlow, SMConfig } from 'secureme-sdk';
// Define your flow configuration for both platforms
const smFlow: SMFlow = {
android: {
sdcFront: { enabled: true, showIntro: true, enableFileUpload: true },
sdcBack: { enabled: true, enableFileUpload: true, sendFeatureResult: true },
pfl: { enabled: true, showIntro: true, sendFeatureResult: true },
},
ios: {
sdcFront: {
showIntro: true,
enableFileUpload: true,
sendFeatureResult: true,
localClassification: false,
},
sdcBack: {
showIntro: true,
enableFileUpload: true,
sendFeatureResult: true,
},
pfl: {
showIntro: true,
sendFeatureResult: true,
},
},
};
// Define your configuration for both platforms
const smConfig: SMConfig = {
android: {
withPflDetectionDelay: false,
pflDelaySecs: 0,
sendResults: true,
},
ios: {
pflDetectionDelayEnabled: false,
pflDelay: 0.0,
sendResults: true,
voiceConsentSessionTime: 20,
},
};
// Your workflow data from the API
const WORKFLOW_DATA = `{
"sessionId": "YOUR_SESSION_ID",
"response": {
"session": "...",
"accessToken": "...",
"assets": [...]
},
"statusCode": 200
}`;
const App = () => {
const [isLoading, setIsLoading] = useState(true);
const [cameraStatus, setCameraStatus] = useState<boolean>(false);
const requestCameraAccess = async (): Promise<boolean> => {
if (Platform.OS === 'android') {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.CAMERA,
{
title: 'Camera Permission',
message: 'This app needs camera access for identity verification.',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
}
);
return granted === PermissionsAndroid.RESULTS.GRANTED;
} catch (err) {
console.warn(err);
return false;
}
} else {
// iOS - permission handled by SecuremeSdk
const hasPermission = await SecuremeSdk.requestCameraPermission();
return hasPermission;
}
};
useEffect(() => {
const setupSDK = async () => {
try {
console.log('🚀 Starting SDK Setup...');
const hasPermission = await requestCameraAccess();
console.log('📷 Camera Status:', hasPermission);
setCameraStatus(hasPermission);
} catch (error: any) {
console.error('❌ Setup Failed:', error);
Alert.alert('Setup Error', error.message || 'Unknown error');
} finally {
setIsLoading(false);
}
};
setupSDK();
}, []);
const handleStartKit = async () => {
if (!cameraStatus) {
Alert.alert(
'Camera Permission Required',
'We need camera access to verify your identity.',
[
{ text: 'Cancel', style: 'cancel' },
{ text: 'Open Settings', onPress: () => Linking.openSettings() },
]
);
return;
}
try {
console.log('📱 Opening SecureMe Kit...');
const result = await SecuremeSdk.start(WORKFLOW_DATA, smFlow, smConfig);
Alert.alert('Success', 'Verification was successful!');
console.log('🏁 Flow finished with result:', result);
} catch (error: any) {
console.error('❌ Failed to open Kit:', error);
Alert.alert('Error', error.message);
}
};
return (
<SafeAreaView style={styles.container}>
<View style={styles.content}>
<Text style={styles.title}>SecureMe Integration</Text>
{isLoading ? (
<View>
<ActivityIndicator size="large" color="#0000ff" />
<Text style={styles.loadingText}>
Checking permissions & initializing...
</Text>
</View>
) : (
<View style={styles.infoContainer}>
<Text style={styles.statusRow}>
Camera: {cameraStatus ? '✅ Allowed' : '❌ Denied'}
</Text>
<View style={styles.buttonContainer}>
<Button
title="Start SecureMe"
onPress={handleStartKit}
disabled={!cameraStatus}
/>
</View>
</View>
)}
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: { flex: 1, backgroundColor: '#F5F5F5' },
content: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
},
title: { fontSize: 24, fontWeight: 'bold', marginBottom: 30, color: '#333' },
loadingText: { marginTop: 10, color: '#666' },
infoContainer: { width: '100%', alignItems: 'center' },
statusRow: { fontSize: 16, marginBottom: 10, color: '#444' },
buttonContainer: { marginTop: 20, width: '100%', marginBottom: 10 },
});
export default App;API Reference
Methods
requestCameraPermission(): Promise<boolean>
Requests camera permission (iOS only - Android handles via PermissionsAndroid).
Returns: Promise<boolean> - true if permission granted, false otherwise.
const hasPermission = await SecuremeSdk.requestCameraPermission();start(workFlowResponse: string, flow: SMFlow, config: SMConfig): Promise<any>
Starts the SecureMe verification flow.
Parameters:
workFlowResponse(string): JSON string containing session data from your backendflow(SMFlow): Flow configuration for Android and/or iOSconfig(SMConfig): Additional configuration options for Android and/or iOS
Returns: Promise<any> - Result of the verification flow
const result = await SecuremeSdk.start(WORKFLOW_DATA, smFlow, smConfig);Types
SMFlow
interface SMFlow {
android?: AndroidSMFlow;
ios?: IOSSMFlow;
}SMConfig
interface SMConfig {
android?: AndroidSMConfig;
ios?: IOSSMConfig;
}For detailed type definitions, see types.ts.
Flow Features
Android Features
sdcFront- Front Document CapturesdcBack- Back Document Capturepfl- Passive Face Livenessnfc- NFC Passport Readingpoa- Proof of AddressvideoSession- Video SessionvoiceConsent- Voice Consent
iOS Features
sdcFront- Front Smart Document CapturesdcBack- Back Smart Document Capturepfl- Passive Face Livenessvc- Voice Consentvs- Video Sessionpoa- Proof of AddresssdcOcr- OCR Document Capture
Configuration Options
Android Config
{
pflDelaySecs?: number;
sendResults?: boolean;
suspiciousConfig?: AndroidSuspiciousConfigType;
videoSessionAskUserConsent?: boolean;
videoSessionConsentTime?: number;
videoSessionIDTime?: number;
voiceConsentSessionTime?: number;
voiceConsentText?: string;
withPflDetectionDelay?: boolean;
}iOS Config
{
pflDetectionDelayEnabled?: boolean;
pflDelay?: number;
sendResults?: boolean;
voiceConsentText?: string;
voiceConsentSessionTime?: number;
videoSessionText?: string;
videoSessionIdSessionDuration?: number;
videoSessionVoiceSessionDuration?: number;
}Troubleshooting
iOS
Issue: Pod install fails
Solution: Try cd ios && pod install --repo-update
Issue: Camera permission not working
Solution: Ensure NSCameraUsageDescription is added to Info.plist
Android
Issue: Build fails with dependency conflicts
Solution: Ensure your minSdkVersion is at least 21
Issue: Camera permission denied
Solution: Check that CAMERA permission is declared in AndroidManifest.xml
Error Handling
The SDK can throw the following errors:
Native Module Errors
- LinkingError — thrown when the native module is not properly linked (native binary missing or pods not installed).
- PermissionError — thrown when camera permissions are denied or unavailable.
- ValidationError — thrown when an invalid configuration or workflow payload is provided.
Session Errors
- SessionInitError — failed to initialize session with provided workflow data.
- NetworkError — failed to communicate with backend services or token validation failed.
Example Error Handling
Use guarded calls and inspect error messages or types to handle specific cases:
try {
const result = await SecuremeSdk.start(WORKFLOW_DATA, smFlow, smConfig);
// handle success result
} catch (error: any) {
const msg = error && error.message ? error.message.toLowerCase() : '';
if (msg.includes('link') || msg.includes('linking')) {
// Native linking problems
Alert.alert(
'Linking Error',
'Native module not linked. Run pod install and rebuild.'
);
} else if (msg.includes('permission')) {
// Permission issues
Alert.alert(
'Permission Required',
'Please enable camera access in settings.'
);
} else if (msg.includes('session') || msg.includes('workflow')) {
// Session / workflow validation
Alert.alert(
'Session Error',
'Invalid workflow data or session init failed.'
);
} else if (msg.includes('network') || msg.includes('timeout')) {
// Network problems
Alert.alert(
'Network Error',
'Communication with the backend failed. Try again later.'
);
} else {
// Fallback
Alert.alert('Error', error?.message || 'Unknown error occurred');
}
}Notes:
- Native linking errors typically indicate native code not built/installed. For iOS, run
cd example/ios && pod installand rebuild. - PermissionError means the user denied camera access — prompt to open app settings.
- ValidationError indicates the provided WORKFLOW data is invalid JSON or missing required fields; validate before calling SDK.
- Log errors on the native side (Xcode / Logcat) for deeper diagnostics.
License
MIT
Support
For issues and questions, please visit the repository issues page.
