react-native-kalapa-ekyc 1.2.9 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +274 -273
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/reactnativekalapaekyc/KalapaEkycModule.java +53 -43
- package/ios/KalapaEkyc.m +33 -15
- package/lib/typescript/src/KalapaResult.d.ts +107 -0
- package/lib/typescript/src/index.d.ts +26 -0
- package/package.json +7 -7
- package/src/KalapaResult.ts +10 -19
- package/src/index.tsx +75 -34
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/9.0-milestone-1/checksums/checksums.lock +0 -0
- package/android/.gradle/9.0-milestone-1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/9.0-milestone-1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.0-milestone-1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.0-milestone-1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/config.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -1510
- package/android/.idea/gradle.xml +0 -12
- package/android/.idea/material_theme_project_new.xml +0 -10
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/android/src/main/java/com/reactnativekalapaekyc/kUtils.java +0 -66
- package/ios/KalapaEkyc.xcodeproj/project.pbxproj +0 -167
- package/ios/KalapaEkyc.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/KalapaEkyc.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/KalapaEkyc.xcodeproj/project.xcworkspace/xcuserdata/iosdev.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/KalapaEkyc.xcodeproj/project.xcworkspace/xcuserdata/leo.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/KalapaEkyc.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/android/build.gradle
CHANGED
|
@@ -19,10 +19,10 @@ def safeExtGet(prop, fallback) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
android {
|
|
22
|
-
compileSdkVersion safeExtGet('KalapaEkyc_compileSdkVersion',
|
|
22
|
+
compileSdkVersion safeExtGet('KalapaEkyc_compileSdkVersion', 36)
|
|
23
23
|
defaultConfig {
|
|
24
24
|
minSdkVersion safeExtGet('KalapaEkyc_minSdkVersion', 24)
|
|
25
|
-
targetSdkVersion safeExtGet('KalapaEkyc_targetSdkVersion',
|
|
25
|
+
targetSdkVersion safeExtGet('KalapaEkyc_targetSdkVersion', 36)
|
|
26
26
|
versionCode 1
|
|
27
27
|
versionName "1.8"
|
|
28
28
|
|
|
@@ -56,5 +56,5 @@ dependencies {
|
|
|
56
56
|
//noinspection GradleDynamicVersion
|
|
57
57
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
58
58
|
//kalapasdk
|
|
59
|
-
implementation 'vn.kalapa:ekyc:2.
|
|
59
|
+
implementation 'vn.kalapa:ekyc:2.12.0'
|
|
60
60
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.reactnativekalapaekyc;
|
|
2
2
|
|
|
3
|
-
import android.
|
|
4
|
-
import android.widget.Toast;
|
|
3
|
+
import android.app.Activity;
|
|
5
4
|
|
|
6
5
|
import androidx.annotation.NonNull;
|
|
7
6
|
|
|
@@ -10,13 +9,10 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
10
9
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
10
|
import com.facebook.react.bridge.ReactMethod;
|
|
12
11
|
import com.facebook.react.module.annotations.ReactModule;
|
|
13
|
-
import com.facebook.react.bridge.Callback;
|
|
14
12
|
import com.facebook.react.bridge.ReadableMap;
|
|
15
13
|
import com.facebook.react.bridge.WritableMap;
|
|
16
14
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
17
15
|
|
|
18
|
-
import java.util.Objects;
|
|
19
|
-
|
|
20
16
|
import vn.kalapa.ekyc.KalapaHandler;
|
|
21
17
|
import vn.kalapa.ekyc.KalapaSDK;
|
|
22
18
|
import vn.kalapa.ekyc.KalapaSDKConfig;
|
|
@@ -38,38 +34,49 @@ public class KalapaEkycModule extends ReactContextBaseJavaModule {
|
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
public void multiply(int a, int b, Promise promise) {
|
|
45
|
-
promise.resolve(a * b);
|
|
37
|
+
private String getStr(ReadableMap map, String key, String fallback) {
|
|
38
|
+
if (!map.hasKey(key) || map.isNull(key)) return fallback;
|
|
39
|
+
return map.getString(key) != null ? map.getString(key) : fallback;
|
|
46
40
|
}
|
|
47
41
|
|
|
42
|
+
private boolean getBool(ReadableMap map, String key, boolean fallback) {
|
|
43
|
+
if (!map.hasKey(key) || map.isNull(key)) return fallback;
|
|
44
|
+
return map.getBoolean(key);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private int getInt(ReadableMap map, String key, int fallback) {
|
|
48
|
+
if (!map.hasKey(key) || map.isNull(key)) return fallback;
|
|
49
|
+
return map.getInt(key);
|
|
50
|
+
}
|
|
48
51
|
|
|
49
52
|
@ReactMethod
|
|
50
53
|
public void start(String session, String flow, ReadableMap data, Promise promise) {
|
|
51
|
-
|
|
52
|
-
String
|
|
53
|
-
String
|
|
54
|
-
String
|
|
55
|
-
String
|
|
56
|
-
String
|
|
57
|
-
String
|
|
58
|
-
String
|
|
59
|
-
String
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
String
|
|
64
|
-
String
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
boolean
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
54
|
+
String domain = getStr(data, "domain", "https://ekyc-sdk.kalapa.vn");
|
|
55
|
+
String mainColor = getStr(data, "main_color", "#1F69E6");
|
|
56
|
+
String successColor = getStr(data, "success_color", "#388E3C");
|
|
57
|
+
String failureColor = getStr(data, "failure_color", "#F44336");
|
|
58
|
+
String background = getStr(data, "background_color", "#FFFFFF");
|
|
59
|
+
String mainTextColor = getStr(data, "main_text_color", "#000000");
|
|
60
|
+
String btnTextColor = getStr(data, "btn_text_color", "#FFFFFF");
|
|
61
|
+
String language = getStr(data, "language", "en");
|
|
62
|
+
String customerLanguage = getStr(data, "customer_language", "");
|
|
63
|
+
int livenessVersion = getInt(data, "liveness_version", 0);
|
|
64
|
+
String faceData = getStr(data, "face_data", "");
|
|
65
|
+
String mrzData = getStr(data, "mrz", "");
|
|
66
|
+
String qrCode = getStr(data, "qr_code", "");
|
|
67
|
+
String sessionId = getStr(data, "session_id", "");
|
|
68
|
+
boolean allowMrzRescanOnNfcMismatch = getBool(data, "allow_mrz_rescan_on_nfc_mismatch", false);
|
|
69
|
+
boolean withConfirmScreen = getBool(data, "with_confirm_screen", false);
|
|
70
|
+
boolean requireQr = getBool(data, "require_qr", false);
|
|
71
|
+
|
|
72
|
+
Activity activity = getCurrentActivity();
|
|
73
|
+
if (activity == null) {
|
|
74
|
+
promise.reject("ACTIVITY_NULL", "Current Activity is null");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
activity.runOnUiThread(() -> {
|
|
79
|
+
KalapaSDKConfig klpConfig = new KalapaSDKConfig.KalapaSDKConfigBuilder(activity)
|
|
73
80
|
.withBaseURL(domain)
|
|
74
81
|
.withMainColor(mainColor)
|
|
75
82
|
.withBackgroundColor(background)
|
|
@@ -85,17 +92,16 @@ public class KalapaEkycModule extends ReactContextBaseJavaModule {
|
|
|
85
92
|
.withSpecificLanguageForCustomer(customerLanguage)
|
|
86
93
|
.build();
|
|
87
94
|
|
|
88
|
-
KalapaSDK.KalapaSDKBuilder builder = new KalapaSDK.KalapaSDKBuilder(
|
|
89
|
-
if (
|
|
90
|
-
if (
|
|
91
|
-
if (
|
|
92
|
-
if (
|
|
95
|
+
KalapaSDK.KalapaSDKBuilder builder = new KalapaSDK.KalapaSDKBuilder(activity, klpConfig);
|
|
96
|
+
if (!qrCode.isEmpty()) builder.withRawQRCode(qrCode);
|
|
97
|
+
if (!faceData.isEmpty()) builder.withFaceData(faceData);
|
|
98
|
+
if (!mrzData.isEmpty()) builder.withMrz(mrzData);
|
|
99
|
+
if (!sessionId.isEmpty()) builder.withLeftoverSession(sessionId);
|
|
93
100
|
|
|
94
101
|
builder.build().start(session, flow, new KalapaHandler() {
|
|
95
102
|
@Override
|
|
96
103
|
public void onExpired() {
|
|
97
104
|
promise.reject("EXPIRED", "Session expired");
|
|
98
|
-
// promise.reject("401", "EXPIRED");
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
@Override
|
|
@@ -103,7 +109,6 @@ public class KalapaEkycModule extends ReactContextBaseJavaModule {
|
|
|
103
109
|
String resultMap = kalapaResult.toJson();
|
|
104
110
|
WritableMap res = new WritableNativeMap();
|
|
105
111
|
res.putString("kalapa_result", resultMap);
|
|
106
|
-
// callback.invoke(res);
|
|
107
112
|
promise.resolve(res);
|
|
108
113
|
}
|
|
109
114
|
|
|
@@ -112,28 +117,33 @@ public class KalapaEkycModule extends ReactContextBaseJavaModule {
|
|
|
112
117
|
switch (kalapaSDKResultCode) {
|
|
113
118
|
case USER_LEAVE:
|
|
114
119
|
promise.reject("CANCELED", message);
|
|
120
|
+
break;
|
|
115
121
|
case DEVICE_NOT_SUPPORTED:
|
|
116
122
|
promise.reject("UNSUPPORTED", message);
|
|
123
|
+
break;
|
|
117
124
|
case CONFIGURATION_NOT_ACCEPTABLE:
|
|
118
125
|
promise.reject("CONFIG_ERROR", message);
|
|
126
|
+
break;
|
|
119
127
|
case INVALID_NFC:
|
|
120
128
|
promise.reject("MRZ_INVALID", message);
|
|
129
|
+
break;
|
|
121
130
|
case WRONG_CCCDID:
|
|
122
131
|
promise.reject("NFC_NOT_MATCH", message);
|
|
132
|
+
break;
|
|
123
133
|
case PERMISSION_DENIED:
|
|
124
134
|
promise.reject("PERMISSION_DENIED", message);
|
|
135
|
+
break;
|
|
125
136
|
case VIRTUAL_CAMERA_DETECTED:
|
|
126
137
|
case ROOTED_DEVICE_DETECTED:
|
|
127
138
|
case EMULATOR_DETECTED:
|
|
128
139
|
promise.reject("DEVICE_NOT_ACCEPTABLE", message);
|
|
140
|
+
break;
|
|
129
141
|
default:
|
|
130
142
|
promise.reject("OTHER", message);
|
|
143
|
+
break;
|
|
131
144
|
}
|
|
132
145
|
}
|
|
133
146
|
});
|
|
134
|
-
}
|
|
135
|
-
Toast.makeText(getReactApplicationContext(), "Activity is null", Toast.LENGTH_LONG).show();
|
|
147
|
+
});
|
|
136
148
|
}
|
|
137
|
-
|
|
138
|
-
public static native int nativeMultiply(int a, int b);
|
|
139
149
|
}
|
package/ios/KalapaEkyc.m
CHANGED
|
@@ -70,7 +70,7 @@ RCT_EXPORT_METHOD(start:(NSString *)session
|
|
|
70
70
|
reject(@"CANCELED", @"Người dùng hủy bỏ xác thực", nil);
|
|
71
71
|
break;
|
|
72
72
|
case EventSessionExpired:
|
|
73
|
-
reject(@"
|
|
73
|
+
reject(@"EXPIRED", @"Phiên xác thực đã hết hạn, vui lòng thử lại", nil);
|
|
74
74
|
break;
|
|
75
75
|
default:
|
|
76
76
|
reject(@"OTHER", @"Đã có lỗi xảy ra", nil);
|
|
@@ -126,32 +126,50 @@ RCT_EXPORT_METHOD(start:(NSString *)session
|
|
|
126
126
|
NSDictionary<NSString *, id> *resultJson = [result toDictionary];
|
|
127
127
|
NSDictionary<NSString *, id> *rawJson = [result rawJson];
|
|
128
128
|
NSDictionary *fields = rawJson[@"ocr_data"][@"data"][@"fields"];
|
|
129
|
-
|
|
130
|
-
NSMutableDictionary *json = [NSMutableDictionary dictionaryWithDictionary:fields];
|
|
129
|
+
|
|
130
|
+
NSMutableDictionary *json = [NSMutableDictionary dictionaryWithDictionary:fields ?: @{}];
|
|
131
131
|
json[@"session"] = rawJson[@"session"] ?: @"";
|
|
132
132
|
json[@"decision"] = resultJson[@"decision"] ?: @"";
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
|
|
134
|
+
id nfcData = rawJson[@"nfc_data"];
|
|
135
|
+
if (nfcData && nfcData != (id)[NSNull null]) {
|
|
136
|
+
json[@"nfc_data"] = nfcData;
|
|
137
|
+
}
|
|
138
|
+
|
|
135
139
|
NSDictionary *selfieData = rawJson[@"selfie_data"][@"data"];
|
|
136
140
|
if (selfieData && selfieData != (id)[NSNull null]) {
|
|
141
|
+
id isMatched = selfieData[@"is_matched"];
|
|
142
|
+
id matchingScore = selfieData[@"matching_score"];
|
|
137
143
|
json[@"selfie_data"] = @{
|
|
138
|
-
@"is_matched":
|
|
139
|
-
@"matching_score":
|
|
144
|
+
@"is_matched": isMatched && isMatched != (id)[NSNull null] ? isMatched : @NO,
|
|
145
|
+
@"matching_score": matchingScore && matchingScore != (id)[NSNull null] ? matchingScore : @0
|
|
140
146
|
};
|
|
141
147
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
|
|
149
|
+
id mrzData = rawJson[@"ocr_data"][@"data"][@"mrz_data"];
|
|
150
|
+
if (mrzData && mrzData != (id)[NSNull null]) {
|
|
151
|
+
json[@"mrz_data"] = mrzData;
|
|
152
|
+
}
|
|
153
|
+
|
|
145
154
|
NSDictionary *qrCodeData = rawJson[@"ocr_data"][@"data"][@"qr_code"];
|
|
146
155
|
if (qrCodeData && qrCodeData != (id)[NSNull null] && qrCodeData[@"data"]) {
|
|
147
|
-
|
|
156
|
+
json[@"qr_code"] = @{
|
|
157
|
+
@"data": @{@"decoded_text": qrCodeData[@"data"][@"decoded_text"] ?: @""}
|
|
158
|
+
};
|
|
148
159
|
}
|
|
149
|
-
|
|
150
|
-
if (resultJson[@"decision_detail"] &&
|
|
160
|
+
|
|
161
|
+
if (resultJson[@"decision_detail"] && resultJson[@"decision_detail"] != (id)[NSNull null]) {
|
|
151
162
|
json[@"decision_detail"] = resultJson[@"decision_detail"];
|
|
152
163
|
}
|
|
153
|
-
|
|
154
|
-
|
|
164
|
+
|
|
165
|
+
id residentEntities = fields[@"resident_entities"];
|
|
166
|
+
if (residentEntities && residentEntities != (id)[NSNull null]) {
|
|
167
|
+
json[@"resident_entities"] = residentEntities;
|
|
168
|
+
}
|
|
169
|
+
id homeEntities = fields[@"home_entities"];
|
|
170
|
+
if (homeEntities && homeEntities != (id)[NSNull null]) {
|
|
171
|
+
json[@"home_entities"] = homeEntities;
|
|
172
|
+
}
|
|
155
173
|
|
|
156
174
|
NSError *error;
|
|
157
175
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:json options:NSJSONWritingPrettyPrinted error:&error];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export interface SelfieData {
|
|
2
|
+
is_matched: boolean;
|
|
3
|
+
matching_score: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface NfcData {
|
|
7
|
+
name: string;
|
|
8
|
+
id_number: string;
|
|
9
|
+
old_id_number: string;
|
|
10
|
+
date_of_birth: string;
|
|
11
|
+
date_of_expiry: string;
|
|
12
|
+
date_of_issuance: string;
|
|
13
|
+
gender: string;
|
|
14
|
+
nationality: string;
|
|
15
|
+
nation: string;
|
|
16
|
+
address: string;
|
|
17
|
+
hometown: string;
|
|
18
|
+
father_name: string;
|
|
19
|
+
mother_name: string;
|
|
20
|
+
spouse_name: string;
|
|
21
|
+
religion: string;
|
|
22
|
+
personal_identification: string;
|
|
23
|
+
face_image: string;
|
|
24
|
+
mrz: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface AddressEntities {
|
|
28
|
+
district: string;
|
|
29
|
+
ward: string;
|
|
30
|
+
province: string;
|
|
31
|
+
unknown: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface MrzDataFields {
|
|
35
|
+
birthday?: string;
|
|
36
|
+
doe?: string;
|
|
37
|
+
gender?: string;
|
|
38
|
+
id_number?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface MrzData {
|
|
43
|
+
data?: {
|
|
44
|
+
fields?: MrzDataFields;
|
|
45
|
+
raw_mrz?: string;
|
|
46
|
+
};
|
|
47
|
+
error?: {
|
|
48
|
+
code: number;
|
|
49
|
+
message: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface QrCode {
|
|
54
|
+
data?: {
|
|
55
|
+
decoded_text?: string;
|
|
56
|
+
stage?: number;
|
|
57
|
+
};
|
|
58
|
+
error?: {
|
|
59
|
+
code: number;
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type DecisionType = 'APPROVED' | 'MANUAL' | 'REJECTED' | 'UNKNOWN';
|
|
65
|
+
|
|
66
|
+
export declare class KalapaResult {
|
|
67
|
+
birthday: string;
|
|
68
|
+
country: string;
|
|
69
|
+
decision: DecisionType;
|
|
70
|
+
doe: string;
|
|
71
|
+
doi: string;
|
|
72
|
+
ethnicity: string;
|
|
73
|
+
features: string;
|
|
74
|
+
gender: string;
|
|
75
|
+
home: string;
|
|
76
|
+
home_entities: AddressEntities;
|
|
77
|
+
id_number: string;
|
|
78
|
+
mrz_data: MrzData | null;
|
|
79
|
+
name: string;
|
|
80
|
+
national: string;
|
|
81
|
+
nfc_data: NfcData;
|
|
82
|
+
poi: string;
|
|
83
|
+
qr_code: QrCode | null;
|
|
84
|
+
religion: string;
|
|
85
|
+
resident: string;
|
|
86
|
+
resident_entities: AddressEntities;
|
|
87
|
+
selfie_data: SelfieData;
|
|
88
|
+
session: string;
|
|
89
|
+
type: string;
|
|
90
|
+
rawResult: any;
|
|
91
|
+
|
|
92
|
+
constructor(rawResult: any);
|
|
93
|
+
static fromRawResult(rawResult: any): KalapaResult;
|
|
94
|
+
|
|
95
|
+
isApproved(): boolean;
|
|
96
|
+
isManualReview(): boolean;
|
|
97
|
+
isRejected(): boolean;
|
|
98
|
+
isFaceMatched(): boolean;
|
|
99
|
+
getFaceMatchingScore(): number;
|
|
100
|
+
getDisplayName(): string;
|
|
101
|
+
getIdNumber(): string;
|
|
102
|
+
getDateOfBirth(): string;
|
|
103
|
+
getFaceImage(): string;
|
|
104
|
+
toJSON(): object;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default KalapaResult;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import KalapaResult from './KalapaResult';
|
|
2
|
+
|
|
3
|
+
export { KalapaResult };
|
|
4
|
+
export type {
|
|
5
|
+
SelfieData,
|
|
6
|
+
NfcData,
|
|
7
|
+
AddressEntities,
|
|
8
|
+
MrzDataFields,
|
|
9
|
+
MrzData,
|
|
10
|
+
QrCode,
|
|
11
|
+
DecisionType,
|
|
12
|
+
} from './KalapaResult';
|
|
13
|
+
|
|
14
|
+
export interface KalapaEkycResponse {
|
|
15
|
+
kalapa_result: KalapaResult;
|
|
16
|
+
session?: string;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface KalapaEkycModule {
|
|
21
|
+
start(session: string, flow: string, config: any): Promise<KalapaEkycResponse>;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare const KalapaEkyc: KalapaEkycModule;
|
|
26
|
+
export default KalapaEkyc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-kalapa-ekyc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "React Native SDK for Kalapa eKYC integration",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"!**/__tests__",
|
|
14
14
|
"!**/__fixtures__",
|
|
15
15
|
"!**/__mocks__",
|
|
16
|
-
"android",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
16
|
+
"android/src",
|
|
17
|
+
"android/build.gradle",
|
|
18
|
+
"ios/*.h",
|
|
19
|
+
"ios/*.m",
|
|
19
20
|
"react-native-kalapa-ekyc.podspec",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"!ios/build"
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
25
|
"test": "jest",
|
package/src/KalapaResult.ts
CHANGED
|
@@ -193,32 +193,23 @@ export class KalapaResult {
|
|
|
193
193
|
// Parse NFC data (core fields available on both platforms)
|
|
194
194
|
const nfcRaw = kalapaData.nfc_data || {};
|
|
195
195
|
this.nfc_data = {
|
|
196
|
-
// Personal Information
|
|
197
196
|
name: nfcRaw.name || '',
|
|
198
|
-
id_number: nfcRaw.id_number || '',
|
|
199
|
-
old_id_number: nfcRaw.old_id_number || '',
|
|
200
|
-
date_of_birth: nfcRaw.date_of_birth || '',
|
|
201
|
-
date_of_expiry: nfcRaw.date_of_expiry || '',
|
|
202
|
-
date_of_issuance: nfcRaw.date_of_issuance || '',
|
|
197
|
+
id_number: nfcRaw.id_number || nfcRaw.idNumber || '',
|
|
198
|
+
old_id_number: nfcRaw.old_id_number || nfcRaw.oldIdNumber || '',
|
|
199
|
+
date_of_birth: nfcRaw.date_of_birth || nfcRaw.dateOfBirth || '',
|
|
200
|
+
date_of_expiry: nfcRaw.date_of_expiry || nfcRaw.dateOfExpiry || '',
|
|
201
|
+
date_of_issuance: nfcRaw.date_of_issuance || nfcRaw.dateOfIssuance || '',
|
|
203
202
|
gender: nfcRaw.gender || '',
|
|
204
203
|
nationality: nfcRaw.nationality || '',
|
|
205
204
|
nation: nfcRaw.nation || '',
|
|
206
|
-
|
|
207
|
-
// Address Information
|
|
208
205
|
address: nfcRaw.address || '',
|
|
209
206
|
hometown: nfcRaw.hometown || '',
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
mother_name: nfcRaw.mother_name || '',
|
|
214
|
-
spouse_name: nfcRaw.spouse_name || '',
|
|
215
|
-
|
|
216
|
-
// Additional Information
|
|
207
|
+
father_name: nfcRaw.father_name || nfcRaw.fatherName || '',
|
|
208
|
+
mother_name: nfcRaw.mother_name || nfcRaw.motherName || '',
|
|
209
|
+
spouse_name: nfcRaw.spouse_name || nfcRaw.spouseName || '',
|
|
217
210
|
religion: nfcRaw.religion || '',
|
|
218
|
-
personal_identification: nfcRaw.personal_identification || '',
|
|
219
|
-
|
|
220
|
-
// Technical Data
|
|
221
|
-
face_image: nfcRaw.face_image || '', // Base64 image from NFC chip
|
|
211
|
+
personal_identification: nfcRaw.personal_identification || nfcRaw.personalIdentification || '',
|
|
212
|
+
face_image: nfcRaw.face_image || nfcRaw.faceImage || '',
|
|
222
213
|
mrz: nfcRaw.mrz || '',
|
|
223
214
|
};
|
|
224
215
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,40 +1,81 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
2
|
import KalapaResult from './KalapaResult';
|
|
3
3
|
|
|
4
4
|
const { KalapaEkyc } = NativeModules;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
6
|
+
if (!KalapaEkyc) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
'KalapaEkyc native module is not linked. ' +
|
|
9
|
+
(Platform.OS === 'ios'
|
|
10
|
+
? 'Run `pod install` in your iOS project directory.'
|
|
11
|
+
: 'Check Android autolinking or rebuild the project.')
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type KalapaEkycFlow = 'ekyc' | 'nfc_ekyc' | 'nfc_only';
|
|
16
|
+
|
|
17
|
+
export type KalapaEkycErrorCode =
|
|
18
|
+
| 'EXPIRED'
|
|
19
|
+
| 'CANCELED'
|
|
20
|
+
| 'UNSUPPORTED'
|
|
21
|
+
| 'CONFIG_ERROR'
|
|
22
|
+
| 'MRZ_INVALID'
|
|
23
|
+
| 'NFC_NOT_MATCH'
|
|
24
|
+
| 'PERMISSION_DENIED'
|
|
25
|
+
| 'DEVICE_NOT_ACCEPTABLE'
|
|
26
|
+
| 'ACTIVITY_NULL'
|
|
27
|
+
| 'OTHER';
|
|
28
|
+
|
|
29
|
+
export interface KalapaEkycConfig {
|
|
30
|
+
domain?: string;
|
|
31
|
+
main_color?: string;
|
|
32
|
+
main_text_color?: string;
|
|
33
|
+
btn_text_color?: string;
|
|
34
|
+
background_color?: string;
|
|
35
|
+
success_color?: string;
|
|
36
|
+
failure_color?: string;
|
|
37
|
+
language?: 'vi' | 'en';
|
|
38
|
+
customer_language?: string;
|
|
39
|
+
liveness_version?: 1 | 2 | 3;
|
|
40
|
+
face_data?: string;
|
|
41
|
+
mrz?: string;
|
|
42
|
+
qr_code?: string;
|
|
43
|
+
allow_mrz_rescan_on_nfc_mismatch?: boolean;
|
|
44
|
+
with_confirm_screen?: boolean;
|
|
45
|
+
require_qr?: boolean;
|
|
46
|
+
session_id?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface KalapaEkycResponse {
|
|
50
|
+
kalapa_result: KalapaResult;
|
|
51
|
+
session?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface KalapaEkycModule {
|
|
55
|
+
start: (
|
|
56
|
+
session: string,
|
|
57
|
+
flow: KalapaEkycFlow,
|
|
58
|
+
config?: KalapaEkycConfig
|
|
59
|
+
) => Promise<KalapaEkycResponse>;
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const ExtendedKalapaEkyc: KalapaEkycModule = {
|
|
64
|
+
...KalapaEkyc,
|
|
65
|
+
|
|
66
|
+
start: async (
|
|
67
|
+
session: string,
|
|
68
|
+
flow: KalapaEkycFlow,
|
|
69
|
+
config: KalapaEkycConfig = {}
|
|
70
|
+
): Promise<KalapaEkycResponse> => {
|
|
71
|
+
const result = await KalapaEkyc.start(session, flow, config);
|
|
72
|
+
const parsedJson = JSON.parse(result.kalapa_result);
|
|
73
|
+
return {
|
|
74
|
+
...result,
|
|
75
|
+
kalapa_result: KalapaResult.fromRawResult(parsedJson),
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
39
80
|
export { KalapaResult };
|
|
40
81
|
export default ExtendedKalapaEkyc;
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|