react-native-kalapa-ekyc 1.2.8 → 1.2.10
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 -271
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/reactnativekalapaekyc/KalapaEkycModule.java +55 -43
- package/ios/KalapaEkyc.m +39 -17
- 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 +66 -34
- package/android/.gradle/8.9/checksums/checksums.lock +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/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- 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', 35)
|
|
23
23
|
defaultConfig {
|
|
24
24
|
minSdkVersion safeExtGet('KalapaEkyc_minSdkVersion', 24)
|
|
25
|
-
targetSdkVersion safeExtGet('KalapaEkyc_targetSdkVersion',
|
|
25
|
+
targetSdkVersion safeExtGet('KalapaEkyc_targetSdkVersion', 35)
|
|
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.11.
|
|
59
|
+
implementation 'vn.kalapa:ekyc:2.11.8'
|
|
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,37 +34,49 @@ public class KalapaEkycModule extends ReactContextBaseJavaModule {
|
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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;
|
|
40
|
+
}
|
|
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);
|
|
46
45
|
}
|
|
47
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
|
-
int livenessVersion =
|
|
61
|
-
|
|
62
|
-
String
|
|
63
|
-
String
|
|
64
|
-
String
|
|
65
|
-
|
|
66
|
-
boolean
|
|
67
|
-
boolean
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
|
|
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)
|
|
72
80
|
.withBaseURL(domain)
|
|
73
81
|
.withMainColor(mainColor)
|
|
74
82
|
.withBackgroundColor(background)
|
|
@@ -81,19 +89,19 @@ public class KalapaEkycModule extends ReactContextBaseJavaModule {
|
|
|
81
89
|
.withAllowMRZRescanOnNFCMismatch(allowMrzRescanOnNfcMismatch)
|
|
82
90
|
.skipConfirm(!withConfirmScreen)
|
|
83
91
|
.requireQRCode(requireQr)
|
|
92
|
+
.withSpecificLanguageForCustomer(customerLanguage)
|
|
84
93
|
.build();
|
|
85
|
-
|
|
86
|
-
KalapaSDK.KalapaSDKBuilder builder = new KalapaSDK.KalapaSDKBuilder(
|
|
87
|
-
if (
|
|
88
|
-
if (
|
|
89
|
-
if (
|
|
90
|
-
if (
|
|
94
|
+
|
|
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);
|
|
91
100
|
|
|
92
101
|
builder.build().start(session, flow, new KalapaHandler() {
|
|
93
102
|
@Override
|
|
94
103
|
public void onExpired() {
|
|
95
104
|
promise.reject("EXPIRED", "Session expired");
|
|
96
|
-
// promise.reject("401", "EXPIRED");
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
@Override
|
|
@@ -101,7 +109,6 @@ public class KalapaEkycModule extends ReactContextBaseJavaModule {
|
|
|
101
109
|
String resultMap = kalapaResult.toJson();
|
|
102
110
|
WritableMap res = new WritableNativeMap();
|
|
103
111
|
res.putString("kalapa_result", resultMap);
|
|
104
|
-
// callback.invoke(res);
|
|
105
112
|
promise.resolve(res);
|
|
106
113
|
}
|
|
107
114
|
|
|
@@ -110,28 +117,33 @@ public class KalapaEkycModule extends ReactContextBaseJavaModule {
|
|
|
110
117
|
switch (kalapaSDKResultCode) {
|
|
111
118
|
case USER_LEAVE:
|
|
112
119
|
promise.reject("CANCELED", message);
|
|
120
|
+
break;
|
|
113
121
|
case DEVICE_NOT_SUPPORTED:
|
|
114
122
|
promise.reject("UNSUPPORTED", message);
|
|
123
|
+
break;
|
|
115
124
|
case CONFIGURATION_NOT_ACCEPTABLE:
|
|
116
125
|
promise.reject("CONFIG_ERROR", message);
|
|
126
|
+
break;
|
|
117
127
|
case INVALID_NFC:
|
|
118
128
|
promise.reject("MRZ_INVALID", message);
|
|
129
|
+
break;
|
|
119
130
|
case WRONG_CCCDID:
|
|
120
131
|
promise.reject("NFC_NOT_MATCH", message);
|
|
132
|
+
break;
|
|
121
133
|
case PERMISSION_DENIED:
|
|
122
134
|
promise.reject("PERMISSION_DENIED", message);
|
|
135
|
+
break;
|
|
123
136
|
case VIRTUAL_CAMERA_DETECTED:
|
|
124
137
|
case ROOTED_DEVICE_DETECTED:
|
|
125
138
|
case EMULATOR_DETECTED:
|
|
126
139
|
promise.reject("DEVICE_NOT_ACCEPTABLE", message);
|
|
140
|
+
break;
|
|
127
141
|
default:
|
|
128
142
|
promise.reject("OTHER", message);
|
|
143
|
+
break;
|
|
129
144
|
}
|
|
130
145
|
}
|
|
131
146
|
});
|
|
132
|
-
}
|
|
133
|
-
Toast.makeText(getReactApplicationContext(), "Activity is null", Toast.LENGTH_LONG).show();
|
|
147
|
+
});
|
|
134
148
|
}
|
|
135
|
-
|
|
136
|
-
public static native int nativeMultiply(int a, int b);
|
|
137
149
|
}
|
package/ios/KalapaEkyc.m
CHANGED
|
@@ -27,6 +27,7 @@ RCT_EXPORT_METHOD(start:(NSString *)session
|
|
|
27
27
|
|
|
28
28
|
NSString *faceData = data[@"face_data"];
|
|
29
29
|
NSString *mrz = data[@"mrz"];
|
|
30
|
+
NSString *customerLanguage = data[@"customer_language"];
|
|
30
31
|
NSString *sessionID = data[@"session_id"];
|
|
31
32
|
id val = data[@"allow_mrz_rescan_on_nfc_mismatch"];
|
|
32
33
|
BOOL allowMRZRescanOnNfcMismatch = [val isKindOfClass:NSNumber.class] ? [val boolValue] : NO;
|
|
@@ -53,6 +54,7 @@ RCT_EXPORT_METHOD(start:(NSString *)session
|
|
|
53
54
|
livenessVersion:livenessVersion
|
|
54
55
|
appearance:klpAppearance
|
|
55
56
|
mrz:mrz
|
|
57
|
+
customerLanguage:customerLanguage
|
|
56
58
|
faceData:faceData
|
|
57
59
|
allowMRZRescanOnNfcMismatch:allowMRZRescanOnNfcMismatch
|
|
58
60
|
withShowConfirmScreen:withConfirmScreen
|
|
@@ -68,7 +70,7 @@ RCT_EXPORT_METHOD(start:(NSString *)session
|
|
|
68
70
|
reject(@"CANCELED", @"Người dùng hủy bỏ xác thực", nil);
|
|
69
71
|
break;
|
|
70
72
|
case EventSessionExpired:
|
|
71
|
-
reject(@"
|
|
73
|
+
reject(@"EXPIRED", @"Phiên xác thực đã hết hạn, vui lòng thử lại", nil);
|
|
72
74
|
break;
|
|
73
75
|
default:
|
|
74
76
|
reject(@"OTHER", @"Đã có lỗi xảy ra", nil);
|
|
@@ -105,13 +107,15 @@ RCT_EXPORT_METHOD(start:(NSString *)session
|
|
|
105
107
|
livenessVersion:(NSInteger)livenessVersion
|
|
106
108
|
appearance:(KLPAppearance *)appearance
|
|
107
109
|
mrz:(NSString *)mrz
|
|
110
|
+
customerLanguage:(NSString *)customerLanguage
|
|
108
111
|
faceData:(NSString *)faceData
|
|
109
112
|
allowMRZRescanOnNfcMismatch:(BOOL)allowMRZRescanOnNfcMismatch
|
|
110
113
|
withShowConfirmScreen:(BOOL)withConfirmScreen {
|
|
111
|
-
KLPConfig *config = [[[[[[[KLPConfig BuilderWithSession:session]
|
|
114
|
+
KLPConfig *config = [[[[[[[[KLPConfig BuilderWithSession:session]
|
|
112
115
|
withBaseUrl:domain]
|
|
113
116
|
withLivenessVersion:livenessVersion]
|
|
114
117
|
withAppearance:appearance]
|
|
118
|
+
withCustomerLanguage:customerLanguage]
|
|
115
119
|
withMRZ:mrz]
|
|
116
120
|
withFaceDataBase64:faceData]
|
|
117
121
|
withShowConfirmScreen:withConfirmScreen];
|
|
@@ -122,32 +126,50 @@ RCT_EXPORT_METHOD(start:(NSString *)session
|
|
|
122
126
|
NSDictionary<NSString *, id> *resultJson = [result toDictionary];
|
|
123
127
|
NSDictionary<NSString *, id> *rawJson = [result rawJson];
|
|
124
128
|
NSDictionary *fields = rawJson[@"ocr_data"][@"data"][@"fields"];
|
|
125
|
-
|
|
126
|
-
NSMutableDictionary *json = [NSMutableDictionary dictionaryWithDictionary:fields];
|
|
129
|
+
|
|
130
|
+
NSMutableDictionary *json = [NSMutableDictionary dictionaryWithDictionary:fields ?: @{}];
|
|
127
131
|
json[@"session"] = rawJson[@"session"] ?: @"";
|
|
128
132
|
json[@"decision"] = resultJson[@"decision"] ?: @"";
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
|
|
134
|
+
id nfcData = rawJson[@"nfc_data"];
|
|
135
|
+
if (nfcData && nfcData != (id)[NSNull null]) {
|
|
136
|
+
json[@"nfc_data"] = nfcData;
|
|
137
|
+
}
|
|
138
|
+
|
|
131
139
|
NSDictionary *selfieData = rawJson[@"selfie_data"][@"data"];
|
|
132
140
|
if (selfieData && selfieData != (id)[NSNull null]) {
|
|
141
|
+
id isMatched = selfieData[@"is_matched"];
|
|
142
|
+
id matchingScore = selfieData[@"matching_score"];
|
|
133
143
|
json[@"selfie_data"] = @{
|
|
134
|
-
@"is_matched":
|
|
135
|
-
@"matching_score":
|
|
144
|
+
@"is_matched": isMatched && isMatched != (id)[NSNull null] ? isMatched : @NO,
|
|
145
|
+
@"matching_score": matchingScore && matchingScore != (id)[NSNull null] ? matchingScore : @0
|
|
136
146
|
};
|
|
137
147
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
148
|
+
|
|
149
|
+
id mrzData = rawJson[@"ocr_data"][@"data"][@"mrz_data"];
|
|
150
|
+
if (mrzData && mrzData != (id)[NSNull null]) {
|
|
151
|
+
json[@"mrz_data"] = mrzData;
|
|
152
|
+
}
|
|
153
|
+
|
|
141
154
|
NSDictionary *qrCodeData = rawJson[@"ocr_data"][@"data"][@"qr_code"];
|
|
142
155
|
if (qrCodeData && qrCodeData != (id)[NSNull null] && qrCodeData[@"data"]) {
|
|
143
|
-
|
|
156
|
+
json[@"qr_code"] = @{
|
|
157
|
+
@"data": @{@"decoded_text": qrCodeData[@"data"][@"decoded_text"] ?: @""}
|
|
158
|
+
};
|
|
144
159
|
}
|
|
145
|
-
|
|
146
|
-
if (resultJson[@"decision_detail"] &&
|
|
160
|
+
|
|
161
|
+
if (resultJson[@"decision_detail"] && resultJson[@"decision_detail"] != (id)[NSNull null]) {
|
|
147
162
|
json[@"decision_detail"] = resultJson[@"decision_detail"];
|
|
148
163
|
}
|
|
149
|
-
|
|
150
|
-
|
|
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
|
+
}
|
|
151
173
|
|
|
152
174
|
NSError *error;
|
|
153
175
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:json options:NSJSONWritingPrettyPrinted error:&error];
|
|
@@ -157,4 +179,4 @@ RCT_EXPORT_METHOD(start:(NSString *)session
|
|
|
157
179
|
}
|
|
158
180
|
|
|
159
181
|
|
|
160
|
-
@end
|
|
182
|
+
@end
|
|
@@ -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.2.
|
|
3
|
+
"version": "1.2.10",
|
|
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,72 @@
|
|
|
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
|
+
const ExtendedKalapaEkyc = {
|
|
55
|
+
...KalapaEkyc,
|
|
56
|
+
|
|
57
|
+
start: async (
|
|
58
|
+
session: string,
|
|
59
|
+
flow: KalapaEkycFlow,
|
|
60
|
+
config: KalapaEkycConfig = {}
|
|
61
|
+
): Promise<KalapaEkycResponse> => {
|
|
62
|
+
const result = await KalapaEkyc.start(session, flow, config);
|
|
63
|
+
const parsedJson = JSON.parse(result.kalapa_result);
|
|
64
|
+
return {
|
|
65
|
+
...result,
|
|
66
|
+
kalapa_result: KalapaResult.fromRawResult(parsedJson),
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
39
71
|
export { KalapaResult };
|
|
40
72
|
export default ExtendedKalapaEkyc;
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|