cmc-ekyc-react-native
v1.0.3
Published
SDK wrapper for CMC eKYC
Readme
CMC eKYC SDK for React Native
A comprehensive React Native wrapper for eKYC services, starting with Kalapa integration and built to support multiple providers (e.g., QTS in the future). This SDK standardizes output contracts, error handling, and configuration across different native SDKs.
Installation
npm install cmc-ekyc-react-native
# or
yarn add cmc-ekyc-react-nativeAndroid Setup
- Update
AndroidManifest.xmlwith permissions:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.NFC" />Usage
import CmcEkycSDK, {
CmcEkycConfig,
CmcEkycSdkResultCode,
CmcEkycSdkMediaType,
} from 'cmc-ekyc-react-native';
const startEkyc = async () => {
const config: CmcEkycConfig = {
appId: "YOUR_APP_ID",
session: "SESSION_KEY",
token_CA: "TOKEN_CA",
flow: "nfc_ekyc", // or 'ekyc', 'nfc_only'
documentType: CmcEkycSdkMediaType.FRONT,
// Add other config parameters as needed
};
try {
const result = await CmcEkycSDK.start(config);
console.log("eKYC Success:", result);
// Result follows the standardized CmcEkycResult interface. For example:
// {
// code: CmcEkycSdkResultCode.SUCCESS,
// data: { ... },
// nfc_data: { face_image: "..." },
// }
} catch (error: any) {
if (error.code === CmcEkycSdkResultCode.USER_LEAVE) {
console.log("User cancelled the process.");
} else {
console.error("eKYC Error:", error.message, error.code);
}
}
}
};
### Receiving raw data from the SDK
Some flows (e.g. NFC) allow consuming intermediate data such as images or
NFC records. The example app demonstrates implementing
`CmcRawDataDelegate` and passing it to the SDK:
```tsx
import { CmcRawDataDelegate } from 'cmc-ekyc-react-native/lib/typescript/src/providers/kalapa/KalapaAdapter';
class NFCDataProcessor implements CmcRawDataDelegate {
async processBackImage(image: Uint8Array): Promise<any> {
console.log('processing back side image');
}
async processFrontImage(image: Uint8Array): Promise<any> {
console.log('processing front side image');
}
async processSelfieImage(image: Uint8Array): Promise<any> {
console.log('processing selfie image');
}
async processNFCData(sod: string, dg1: string, dg2: string, dg13: string): Promise<any> {
console.log(`Processing NFC data with sod: ${sod}`);
}
}
// when calling start():
const rawDataDelegate = new NFCDataProcessor();
const result = await CmcEkycSDK.start({ ...config, rawDataDelegate });The delegate hooks are optional; if you don't need raw data you can omit
rawDataDelegate entirely.
Running the example application
Clone or pull the repository and run
yarn installat the root.Navigate to the
example/folder and install dependencies:cd example yarnStart the Metro bundler and run on a device/emulator:
yarn android # or yarn iosThe sample app demonstrates a simple UI with a "Start eKYC" button that triggers the SDK using hard‑coded configuration values. Use it as a reference for how your application should integrate the library.
Configuration options
The CmcEkycConfig interface includes (but is not limited to) the
following fields:
| Property | Type | Description |
|-----------------|----------|-------------|
| appId | string | Application identifier issued by backend |
| session | string | Session token for eKYC transaction |
| token_CA | string | Authentication token for CA gateway |
| baseUrl | string | Base URL for eKYC API |
| baseUrl_CA | string | CA gateway URL |
| token_CA_KALA | string | Kalapa-specific CA token |
| flow | string | One of nfc_ekyc,nfc_only,ekyc. |
| livenessVersion | number | Liveness check version (0 = default) |
| rawDataDelegate | object? | Delegate for receiving raw images/data |
| isUseCmcGateway | boolean | When set to true the SDK will route requests through the CMC gateway service|
This README should serve as the primary developer reference; copy or modify sections as needed for your project's own documentation.
License
MIT
