Trustbuilder MFA SDK for React Native. Provides multi-factor authentication capabilities including activation, OTP generation, biometric authentication, push notifications, and transaction sealing.
npm install react-native-mfa-trustbuildercd ios && pod installNo additional steps required.
import { trustbuilder, TrustbuilderError } from 'react-native-mfa-trustbuilder';
// Initialize (call once at app startup)
const result = trustbuilder.initialize({
macId: 'your_maccess_id',
server: 'https://www.myinwebo.com',
hostVersion: 'my-app-1.0.0',
});
// Restore saved state
const storedData = trustbuilder.getStorageData();
if (storedData) {
trustbuilder.setStorageData(storedData);
}
// Check activation status
if (trustbuilder.isActivated()) {
// Generate online OTP
const { otp, remainingTime } = await trustbuilder.generateOnlineOtp('1234');
}Initialize the Trustbuilder SDK.
trustbuilder.initialize({
macId: 'your_maccess_id', // Required
server: 'https://www.myinwebo.com', // Default
hostVersion: 'my-app-1.0.0', // Default: 'react-native-mfa-trustbuilder-0.1.0'
timeout: 60000, // Default: 60000ms
lang: 'en', // 'en' | 'fr', Default: 'en'
});Start the device activation process.
Finalize device activation.
Convenience method that calls both start and finalize.
Unlock a blocked device with an unlock code.
Synchronize device state with Trustbuilder servers.
Update the user's PIN code.
Register a biometric key.
Reset all registered biometric keys.
Generate an OTP via server call.
Generate an OTP locally without network.
Register device for push notifications.
Check for pending push notification.
Subscribe to push notification events.
generateOnlineSeal(pin: string, sealData: string, serviceIndex?: number, keyType?: KeyType): Promise<SealResult>
Generate an online seal.
Generate an offline seal.
Check if device is activated.
Check if device is blocked.
Get service information.
Get SDK version information.
Save internal state if it has changed. Call after each operation.
All methods throw TrustbuilderError on failure:
try {
await trustbuilder.generateOnlineOtp('1234');
} catch (error) {
if (error instanceof TrustbuilderError) {
console.log(error.code); // Numeric error code
console.log(error.codeName); // e.g., 'NETWORK', 'CODE', 'ACCESS'
console.log(error.message); // Human-readable message
}
}| Code | Name | Description |
|---|---|---|
| 0 | OK | No error |
| 1 | NETWORK | Network or server unreachable |
| 2 | CODE | Activation code is incorrect |
| 3 | SN | Syntax error |
| 4 | ACCESS | Access refused |
| 5 | VERSION | Version error |
| 7 | BLOCKED | Account is blocked |
| 14 | FORBIDDEN | Forbidden operation |
| 15 | PINREFUSED | Bad PIN format |
| 16 | TIMEOUT | Timeout expired |
| 26 | BIOKEY | Device locked due to biokey errors |
| 27 | DESYNCHRONIZED | Device desynchronized |
| 999 | OTHER | Unknown error |
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT