assentify-sdk-react-native 0.0.1
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/LICENSE +3 -0
- package/README.md +65 -0
- package/android/build.gradle +111 -0
- package/android/gradle.properties +9 -0
- package/android/src/main/AndroidManifest.xml +55 -0
- package/android/src/main/java/com/assentifysdk/AndroidProgressBarModule.kt +33 -0
- package/android/src/main/java/com/assentifysdk/AssentifySdkBaseModule.kt +39 -0
- package/android/src/main/java/com/assentifysdk/AssentifySdkModule.kt +432 -0
- package/android/src/main/java/com/assentifysdk/AssentifySdkPackage.kt +19 -0
- package/android/src/main/java/com/assentifysdk/FaceMatchActivity.kt +309 -0
- package/android/src/main/java/com/assentifysdk/ImageToBase64Converter.kt +40 -0
- package/android/src/main/java/com/assentifysdk/ReactApplicationContextObject.kt +14 -0
- package/android/src/main/java/com/assentifysdk/ScanIDActivity.kt +431 -0
- package/android/src/main/java/com/assentifysdk/ScanOtherActivity.kt +328 -0
- package/android/src/main/java/com/assentifysdk/ScanPassportActivity.kt +364 -0
- package/android/src/main/java/com/assentifysdk/StepsKeys.kt +91 -0
- package/android/src/main/res/drawable/back_icon.png +0 -0
- package/android/src/main/res/drawable/button_rounded_background.xml +6 -0
- package/android/src/main/res/drawable/card.gif +0 -0
- package/android/src/main/res/drawable/expire.png +0 -0
- package/android/src/main/res/drawable/id.gif +0 -0
- package/android/src/main/res/drawable/id_warning.png +0 -0
- package/android/src/main/res/drawable/info_icon.png +0 -0
- package/android/src/main/res/drawable/info_rounded_background.xml +6 -0
- package/android/src/main/res/drawable/passport.gif +0 -0
- package/android/src/main/res/drawable/rounded_background.xml +3 -0
- package/android/src/main/res/drawable/sending.png +0 -0
- package/android/src/main/res/drawable/warning.png +0 -0
- package/android/src/main/res/drawable/zoom_in.png +0 -0
- package/android/src/main/res/drawable/zoom_out.png +0 -0
- package/android/src/main/res/layout/activity_face_scan.xml +242 -0
- package/android/src/main/res/layout/activity_scan.xml +297 -0
- package/android/src/main/res/raw/sending_video.MP4 +0 -0
- package/android/src/main/res/values/colors.xml +8 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/main/res/values/styles.xml +4 -0
- package/assentify-sdk.podspec +43 -0
- package/ios/AssentifySdkBaseModule.swift +15 -0
- package/ios/Info.plist +27 -0
- package/ios/NativeAssentifySdk-Bridging-Header.h +3 -0
- package/ios/NativeAssentifySdk.mm +45 -0
- package/ios/NativeAssentifySdk.swift +460 -0
- package/ios/Resources/card.gif +0 -0
- package/ios/Resources/expire.png +0 -0
- package/ios/Resources/id.gif +0 -0
- package/ios/Resources/id_warning.png +0 -0
- package/ios/Resources/info_icon.png +0 -0
- package/ios/Resources/passport.gif +0 -0
- package/ios/Resources/sending.png +0 -0
- package/ios/Resources/warning.png +0 -0
- package/ios/Resources/zoom_in.png +0 -0
- package/ios/Resources/zoom_out.png +0 -0
- package/ios/UIComponents/RNIOSProgressBar.h +4 -0
- package/ios/UIComponents/RNIOSProgressBar.m +34 -0
- package/ios/UIComponents/RNPassportScanner.m +26 -0
- package/ios/UIComponents/RNPassportScanner.swift +245 -0
- package/ios/UIComponents/RNTMapManager.h +4 -0
- package/ios/UIComponents/RNTMapManager.m +19 -0
- package/ios/View/DataDecoder.swift +469 -0
- package/ios/View/FaceMatchController.swift +258 -0
- package/ios/View/IDCardController.swift +360 -0
- package/ios/View/OtherController.swift +283 -0
- package/ios/View/PassportController.swift +302 -0
- package/ios/View/UI.swift +298 -0
- package/lib/commonjs/AssentifyProvider.js +202 -0
- package/lib/commonjs/AssentifyProvider.js.map +1 -0
- package/lib/commonjs/AssentifyWrapper.js +76 -0
- package/lib/commonjs/AssentifyWrapper.js.map +1 -0
- package/lib/commonjs/Language.js +27 -0
- package/lib/commonjs/Language.js.map +1 -0
- package/lib/commonjs/helpers/index.js +2 -0
- package/lib/commonjs/helpers/index.js.map +1 -0
- package/lib/commonjs/helpers/parsers/FaceMatchParser.js +27 -0
- package/lib/commonjs/helpers/parsers/FaceMatchParser.js.map +1 -0
- package/lib/commonjs/helpers/parsers/IDCardParser.js +25 -0
- package/lib/commonjs/helpers/parsers/IDCardParser.js.map +1 -0
- package/lib/commonjs/helpers/parsers/OtherIDParser.js +29 -0
- package/lib/commonjs/helpers/parsers/OtherIDParser.js.map +1 -0
- package/lib/commonjs/helpers/parsers/PassportParser.js +25 -0
- package/lib/commonjs/helpers/parsers/PassportParser.js.map +1 -0
- package/lib/commonjs/index.js +49 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types.js +42 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/AssentifyProvider.js +193 -0
- package/lib/module/AssentifyProvider.js.map +1 -0
- package/lib/module/AssentifyWrapper.js +70 -0
- package/lib/module/AssentifyWrapper.js.map +1 -0
- package/lib/module/Language.js +21 -0
- package/lib/module/Language.js.map +1 -0
- package/lib/module/helpers/index.js +2 -0
- package/lib/module/helpers/index.js.map +1 -0
- package/lib/module/helpers/parsers/FaceMatchParser.js +21 -0
- package/lib/module/helpers/parsers/FaceMatchParser.js.map +1 -0
- package/lib/module/helpers/parsers/IDCardParser.js +19 -0
- package/lib/module/helpers/parsers/IDCardParser.js.map +1 -0
- package/lib/module/helpers/parsers/OtherIDParser.js +23 -0
- package/lib/module/helpers/parsers/OtherIDParser.js.map +1 -0
- package/lib/module/helpers/parsers/PassportParser.js +19 -0
- package/lib/module/helpers/parsers/PassportParser.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +36 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/babel.config.d.ts +3 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/commitlint.config.d.ts +7 -0
- package/lib/typescript/commitlint.config.d.ts.map +1 -0
- package/lib/typescript/example/babel.config.d.ts +8 -0
- package/lib/typescript/example/babel.config.d.ts.map +1 -0
- package/lib/typescript/example/index.d.ts +2 -0
- package/lib/typescript/example/index.d.ts.map +1 -0
- package/lib/typescript/example/jest.config.d.ts +2 -0
- package/lib/typescript/example/jest.config.d.ts.map +1 -0
- package/lib/typescript/example/metro.config.d.ts +3 -0
- package/lib/typescript/example/metro.config.d.ts.map +1 -0
- package/lib/typescript/example/react-native.config.d.ts +6 -0
- package/lib/typescript/example/react-native.config.d.ts.map +1 -0
- package/lib/typescript/example/src/App.d.ts +3 -0
- package/lib/typescript/example/src/App.d.ts.map +1 -0
- package/lib/typescript/example/src/Home.d.ts +4 -0
- package/lib/typescript/example/src/Home.d.ts.map +1 -0
- package/lib/typescript/example/src/navigator.d.ts +4 -0
- package/lib/typescript/example/src/navigator.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts +3 -0
- package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts +11 -0
- package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Language.d.ts +22 -0
- package/lib/typescript/lib/commonjs/Language.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/helpers/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/FaceMatchParser.d.ts +12 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/IDCardParser.d.ts +11 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/IDCardParser.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/OtherIDParser.d.ts +13 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/OtherIDParser.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/PassportParser.d.ts +11 -0
- package/lib/typescript/lib/commonjs/helpers/parsers/PassportParser.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/types.d.ts +18 -0
- package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/lib/module/AssentifyProvider.d.ts +3 -0
- package/lib/typescript/lib/module/AssentifyProvider.d.ts.map +1 -0
- package/lib/typescript/lib/module/AssentifyWrapper.d.ts +10 -0
- package/lib/typescript/lib/module/AssentifyWrapper.d.ts.map +1 -0
- package/lib/typescript/lib/module/Language.d.ts +21 -0
- package/lib/typescript/lib/module/Language.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/index.d.ts +1 -0
- package/lib/typescript/lib/module/helpers/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/parsers/FaceMatchParser.d.ts +11 -0
- package/lib/typescript/lib/module/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/parsers/IDCardParser.d.ts +10 -0
- package/lib/typescript/lib/module/helpers/parsers/IDCardParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/parsers/OtherIDParser.d.ts +12 -0
- package/lib/typescript/lib/module/helpers/parsers/OtherIDParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/helpers/parsers/PassportParser.d.ts +10 -0
- package/lib/typescript/lib/module/helpers/parsers/PassportParser.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +12 -0
- package/lib/typescript/lib/module/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/types.d.ts +17 -0
- package/lib/typescript/lib/module/types.d.ts.map +1 -0
- package/lib/typescript/src/AssentifyProvider.d.ts +4 -0
- package/lib/typescript/src/AssentifyProvider.d.ts.map +1 -0
- package/lib/typescript/src/AssentifyWrapper.d.ts +12 -0
- package/lib/typescript/src/AssentifyWrapper.d.ts.map +1 -0
- package/lib/typescript/src/Language.d.ts +22 -0
- package/lib/typescript/src/Language.d.ts.map +1 -0
- package/lib/typescript/src/helpers/index.d.ts +1 -0
- package/lib/typescript/src/helpers/index.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/FaceMatchParser.d.ts +4 -0
- package/lib/typescript/src/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/IDCardParser.d.ts +4 -0
- package/lib/typescript/src/helpers/parsers/IDCardParser.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/OtherIDParser.d.ts +4 -0
- package/lib/typescript/src/helpers/parsers/OtherIDParser.d.ts.map +1 -0
- package/lib/typescript/src/helpers/parsers/PassportParser.d.ts +4 -0
- package/lib/typescript/src/helpers/parsers/PassportParser.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +12 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +308 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +201 -0
- package/src/AssentifyProvider.tsx +189 -0
- package/src/AssentifyWrapper.ts +142 -0
- package/src/Language.ts +22 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/parsers/FaceMatchParser.ts +28 -0
- package/src/helpers/parsers/IDCardParser.ts +27 -0
- package/src/helpers/parsers/OtherIDParser.ts +31 -0
- package/src/helpers/parsers/PassportParser.ts +27 -0
- package/src/index.ts +6 -0
- package/src/types.ts +373 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NativeModules,
|
|
3
|
+
NativeEventEmitter,
|
|
4
|
+
DeviceEventEmitter,
|
|
5
|
+
LogBox,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
import React, {
|
|
8
|
+
createContext,
|
|
9
|
+
useCallback,
|
|
10
|
+
useEffect,
|
|
11
|
+
useMemo,
|
|
12
|
+
useRef,
|
|
13
|
+
} from 'react';
|
|
14
|
+
import { merge } from 'lodash';
|
|
15
|
+
import {
|
|
16
|
+
type PassportExtractedModel,
|
|
17
|
+
type FaceExtractedModel,
|
|
18
|
+
type IDExtractedModel,
|
|
19
|
+
type OtherExtractedModel,
|
|
20
|
+
type TemplatesByCountry,
|
|
21
|
+
FAILED_RESULT,
|
|
22
|
+
type IdentificationDocumentCapture,
|
|
23
|
+
} from './types';
|
|
24
|
+
import JsonParserPassport from './helpers/parsers/PassportParser';
|
|
25
|
+
import JsonParserFaceMatch from './helpers/parsers/FaceMatchParser';
|
|
26
|
+
import JsonParserIdCard from './helpers/parsers/IDCardParser';
|
|
27
|
+
import JsonParserOtherID from './helpers/parsers/OtherIDParser';
|
|
28
|
+
|
|
29
|
+
const { NativeAssentifySdk } = NativeModules;
|
|
30
|
+
|
|
31
|
+
const AssentifyContext = createContext<undefined>(undefined);
|
|
32
|
+
|
|
33
|
+
LogBox.ignoreAllLogs();
|
|
34
|
+
const AssentifyProvider = () => {
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const emitter = new NativeEventEmitter(NativeAssentifySdk);
|
|
40
|
+
|
|
41
|
+
/// Initialize
|
|
42
|
+
const assentifySdkInit = emitter.addListener('AppResult', (result) => {
|
|
43
|
+
if(result?.assentifySdkInitSuccess!=null){
|
|
44
|
+
if (result?.assentifySdkInitSuccess) {
|
|
45
|
+
const templates = JSON.parse(result?.AssentifySdkHasTemplates ) as TemplatesByCountry[];
|
|
46
|
+
DeviceEventEmitter.emit('assentifySdkInit',{"status":true,"templates":templates});
|
|
47
|
+
}else{
|
|
48
|
+
DeviceEventEmitter.emit('assentifySdkInit',{"status":false});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/// onComplete
|
|
54
|
+
const onComplete = emitter.addListener('onComplete', (result) => {
|
|
55
|
+
if (result?.PassportDataModel) {
|
|
56
|
+
const response = JsonParserPassport(result?.PassportDataModel);
|
|
57
|
+
DeviceEventEmitter.emit('onCompletePassport',{"passportExtractedModel":response});
|
|
58
|
+
} else if (result?.FaceMatchDataModel) {
|
|
59
|
+
const response = JsonParserFaceMatch(result?.FaceMatchDataModel);
|
|
60
|
+
DeviceEventEmitter.emit('onCompleteFaceMatch',{"faceExtractedModel":response});
|
|
61
|
+
} else if (result?.IdDataModel) {
|
|
62
|
+
const response = JsonParserIdCard(result?.IdDataModel);
|
|
63
|
+
DeviceEventEmitter.emit('onCompleteIDCard',{"iDExtractedModel":response});
|
|
64
|
+
} else if (result?.OtherDataModel) {
|
|
65
|
+
const response = JsonParserOtherID(result?.OtherDataModel);
|
|
66
|
+
DeviceEventEmitter.emit('onCompleteOther',{"otherExtractedModel":response});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// General
|
|
71
|
+
const onSendEvent = emitter.addListener('onSend', (_result) => {
|
|
72
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onSend" });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const onRetryEvent = emitter.addListener('onRetry', (_result) => {
|
|
76
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onRetry" });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const onClipPreparationCompleteEvent = emitter.addListener('onClipPreparationComplete', (_result) => {
|
|
80
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onClipPreparationComplete" });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const onStatusUpdatedEvent = emitter.addListener('onStatusUpdated', (_result) => {
|
|
84
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onStatusUpdated" });
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const onUpdatedEvent = emitter.addListener('onUpdated', (_result) => {
|
|
88
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onUpdated" });
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const onLivenessUpdateEvent = emitter.addListener('onLivenessUpdate', (_result) => {
|
|
92
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onLivenessUpdate" });
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const onCardDetectedEvent = emitter.addListener('onCardDetected', (_result) => {
|
|
96
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onCardDetected" });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const onMrzExtractedEvent = emitter.addListener('onMrzExtracted', (_result) => {
|
|
100
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onMrzExtracted" });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const onMrzDetectedEvent = emitter.addListener('onMrzDetected', (_result) => {
|
|
104
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onMrzDetected" });
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const onNoMrzDetectedEvent = emitter.addListener('onNoMrzDetected', (_result) => {
|
|
108
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onNoMrzDetected" });
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const onFaceDetectedEvent = emitter.addListener('onFaceDetected', (_result) => {
|
|
112
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onFaceDetected" });
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const onNoFaceDetectedEvent = emitter.addListener('onNoFaceDetected', (_result) => {
|
|
116
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onNoFaceDetected" });
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const onFaceExtractedEvent = emitter.addListener('onFaceExtracted', (_result) => {
|
|
120
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onFaceExtracted" });
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const onQualityCheckAvailableEvent = emitter.addListener('onQualityCheckAvailable', (_result) => {
|
|
124
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onQualityCheckAvailable" });
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const onDocumentCapturedEvent = emitter.addListener('onDocumentCaptured', (_result) => {
|
|
128
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onDocumentCaptured" });
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const onDocumentCroppedEvent = emitter.addListener('onDocumentCropped', (_result) => {
|
|
132
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onDocumentCropped" });
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const onUploadFailedEvent = emitter.addListener('onUploadFailed', (_result) => {
|
|
136
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onUploadFailed" });
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const onWrongTemplate = emitter.addListener('onWrongTemplate', (_result) => {
|
|
140
|
+
DeviceEventEmitter.emit('EventResult', { "eventName": "onWrongTemplate" });
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
/// SubmitResult
|
|
145
|
+
const submitResult = emitter.addListener('SubmitResult', (result) => {
|
|
146
|
+
if(result != null){
|
|
147
|
+
if (result?.success) {
|
|
148
|
+
DeviceEventEmitter.emit('SubmitDataEvents',{"Success":true});
|
|
149
|
+
}else{
|
|
150
|
+
DeviceEventEmitter.emit('SubmitDataEvents',{"Success":false});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
return () => {
|
|
157
|
+
assentifySdkInit.remove();
|
|
158
|
+
onComplete.remove();
|
|
159
|
+
onSendEvent.remove();
|
|
160
|
+
onRetryEvent.remove();
|
|
161
|
+
onClipPreparationCompleteEvent.remove();
|
|
162
|
+
onStatusUpdatedEvent.remove();
|
|
163
|
+
onUpdatedEvent.remove();
|
|
164
|
+
onLivenessUpdateEvent.remove();
|
|
165
|
+
onCardDetectedEvent.remove();
|
|
166
|
+
onMrzExtractedEvent.remove();
|
|
167
|
+
onMrzDetectedEvent.remove();
|
|
168
|
+
onNoMrzDetectedEvent.remove();
|
|
169
|
+
onFaceDetectedEvent.remove();
|
|
170
|
+
onNoFaceDetectedEvent.remove();
|
|
171
|
+
onFaceExtractedEvent.remove();
|
|
172
|
+
onQualityCheckAvailableEvent.remove();
|
|
173
|
+
onDocumentCapturedEvent.remove();
|
|
174
|
+
onDocumentCroppedEvent.remove();
|
|
175
|
+
onUploadFailedEvent.remove();
|
|
176
|
+
onWrongTemplate.remove();
|
|
177
|
+
submitResult.remove();
|
|
178
|
+
};
|
|
179
|
+
}, [
|
|
180
|
+
]);
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<AssentifyContext.Provider value={undefined}>
|
|
184
|
+
</AssentifyContext.Provider>
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export { AssentifyProvider };
|
|
189
|
+
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { NativeModules, Platform, Alert, Linking } from 'react-native';
|
|
2
|
+
import { request, PERMISSIONS, RESULTS } from 'react-native-permissions';
|
|
3
|
+
import { type LanguageCode } from './Language';
|
|
4
|
+
import { type KycDocumentDetails } from './types';
|
|
5
|
+
|
|
6
|
+
const LINKING_ERROR =
|
|
7
|
+
`The package 'assentify-sdk-react-native-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
8
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
9
|
+
'- You rebuilt the app after installing the package\n' +
|
|
10
|
+
'- You are not using Expo Go\n';
|
|
11
|
+
|
|
12
|
+
const { NativeAssentifySdk } = NativeModules;
|
|
13
|
+
|
|
14
|
+
const AssentifySdk = NativeModules.NativeAssentifySdk
|
|
15
|
+
? NativeModules.NativeAssentifySdk
|
|
16
|
+
: new Proxy(
|
|
17
|
+
{},
|
|
18
|
+
{
|
|
19
|
+
get() {
|
|
20
|
+
throw new Error(LINKING_ERROR);
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const AssentifyWrapper = {
|
|
26
|
+
/// Initialize
|
|
27
|
+
initialize: function (
|
|
28
|
+
apiKey: string,
|
|
29
|
+
tenantIdentifier: string,
|
|
30
|
+
instanceHash: string,
|
|
31
|
+
processMrz?: boolean,
|
|
32
|
+
storeCapturedDocument?: boolean,
|
|
33
|
+
performLivenessDocument?: boolean,
|
|
34
|
+
performLivenessFace?: boolean,
|
|
35
|
+
storeImageStream?: boolean,
|
|
36
|
+
saveCapturedVideoID?: boolean,
|
|
37
|
+
saveCapturedVideoFace?: boolean,
|
|
38
|
+
ENV_CustomColor?: string,
|
|
39
|
+
enableDetect?: boolean,
|
|
40
|
+
enableGuide?: boolean
|
|
41
|
+
) {
|
|
42
|
+
request(
|
|
43
|
+
Platform.select({
|
|
44
|
+
android: PERMISSIONS.ANDROID.CAMERA,
|
|
45
|
+
ios: PERMISSIONS.IOS.CAMERA,
|
|
46
|
+
default: PERMISSIONS.ANDROID.CAMERA,
|
|
47
|
+
})
|
|
48
|
+
).then(
|
|
49
|
+
(result) => {
|
|
50
|
+
if (result === RESULTS.GRANTED) {
|
|
51
|
+
AssentifySdk.initialize(
|
|
52
|
+
apiKey,
|
|
53
|
+
tenantIdentifier,
|
|
54
|
+
instanceHash,
|
|
55
|
+
processMrz ?? true,
|
|
56
|
+
storeCapturedDocument ?? true,
|
|
57
|
+
performLivenessDocument ?? false,
|
|
58
|
+
performLivenessFace ?? false,
|
|
59
|
+
storeImageStream ?? true,
|
|
60
|
+
saveCapturedVideoID ?? true,
|
|
61
|
+
saveCapturedVideoFace ?? true,
|
|
62
|
+
ENV_CustomColor ?? '#f5a103',
|
|
63
|
+
enableDetect ?? true,
|
|
64
|
+
enableGuide ?? true
|
|
65
|
+
);
|
|
66
|
+
} else if (
|
|
67
|
+
result === RESULTS.UNAVAILABLE ||
|
|
68
|
+
result === RESULTS.DENIED ||
|
|
69
|
+
result === RESULTS.BLOCKED
|
|
70
|
+
) {
|
|
71
|
+
Alert.alert(
|
|
72
|
+
'Warning!',
|
|
73
|
+
'Please allow your camera permission in order to proceed further',
|
|
74
|
+
[
|
|
75
|
+
{
|
|
76
|
+
text: 'Open Settings',
|
|
77
|
+
onPress: () => {
|
|
78
|
+
Linking.openSettings();
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
text: 'Cancel',
|
|
83
|
+
onPress: () => {},
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
() => {
|
|
90
|
+
Alert.alert(
|
|
91
|
+
'Warning!',
|
|
92
|
+
'Please allow your camera permission in order to proceed further',
|
|
93
|
+
[
|
|
94
|
+
{
|
|
95
|
+
text: 'Open Settings',
|
|
96
|
+
onPress: () => {
|
|
97
|
+
Linking.openSettings();
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
text: 'Cancel',
|
|
102
|
+
onPress: () => {},
|
|
103
|
+
},
|
|
104
|
+
]
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
/// Passport
|
|
111
|
+
startScanPassport: function (language: LanguageCode,){
|
|
112
|
+
AssentifySdk.startScanPassport(language);
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/// Other
|
|
116
|
+
startScanOther: function (language: LanguageCode,){
|
|
117
|
+
AssentifySdk.startScanOtherIDPage(language);
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
/// ID
|
|
121
|
+
startScanIDCard: function (kycDocumentDetailsList: KycDocumentDetails[],language: LanguageCode,flippingCard: boolean){
|
|
122
|
+
AssentifySdk.startScanIDPage(JSON.stringify(kycDocumentDetailsList),language,flippingCard);
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
/// Face Match
|
|
126
|
+
startFaceMatch: function (imageUrl: String,showCountDown: boolean){
|
|
127
|
+
AssentifySdk.startFaceMatch(imageUrl,showCountDown);
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
/// Submit Data
|
|
132
|
+
submitData: function (dataMap:Record<string, string> ){
|
|
133
|
+
AssentifySdk.submitData(dataMap);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export default AssentifyWrapper;
|
package/src/Language.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const Language = {
|
|
2
|
+
English: "en",
|
|
3
|
+
Arabic: "ar",
|
|
4
|
+
Azerbaijani: "az",
|
|
5
|
+
Belarusian: "be",
|
|
6
|
+
Georgian: "ka",
|
|
7
|
+
Korean: "ko",
|
|
8
|
+
Latvian: "lv",
|
|
9
|
+
Lithuanian: "lt",
|
|
10
|
+
Punjabi: "pa",
|
|
11
|
+
Russian: "ru",
|
|
12
|
+
Sanskrit: "sa",
|
|
13
|
+
Sindhi: "sd",
|
|
14
|
+
Thai: "th",
|
|
15
|
+
Turkish: "tr",
|
|
16
|
+
Ukrainian: "uk",
|
|
17
|
+
Urdu: "ur",
|
|
18
|
+
Uyghur: "ug",
|
|
19
|
+
NON: "NON",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type LanguageCode = typeof Language[keyof typeof Language];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FaceExtractedModel,
|
|
3
|
+
IdentificationDocumentCapture,
|
|
4
|
+
} from '../../types';
|
|
5
|
+
|
|
6
|
+
const JsonParserFaceMatch = (jsonString: string): FaceExtractedModel => {
|
|
7
|
+
const jsonObject = JSON.parse(jsonString ?? '');
|
|
8
|
+
const outputProperties = jsonObject?.outputProperties;
|
|
9
|
+
const extractedData = jsonObject?.extractedData;
|
|
10
|
+
const baseImageFace = jsonObject?.baseImageFace;
|
|
11
|
+
const secondImageFace = jsonObject?.secondImageFace;
|
|
12
|
+
const isLive = !!jsonObject?.isLive;
|
|
13
|
+
const identificationDocumentCapture =
|
|
14
|
+
jsonObject?.identificationDocumentCapture as IdentificationDocumentCapture;
|
|
15
|
+
const percentageMatch = Number(jsonObject?.percentageMatch) ?? 0;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
outputProperties,
|
|
19
|
+
baseImageFace,
|
|
20
|
+
secondImageFace,
|
|
21
|
+
percentageMatch,
|
|
22
|
+
extractedData,
|
|
23
|
+
identificationDocumentCapture,
|
|
24
|
+
isLive,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default JsonParserFaceMatch;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Faces,
|
|
3
|
+
IDExtractedModel,
|
|
4
|
+
IdentificationDocumentCapture,
|
|
5
|
+
} from '../../types';
|
|
6
|
+
|
|
7
|
+
const JsonParserIdCard = (jsonString: string): IDExtractedModel => {
|
|
8
|
+
const jsonObject = JSON.parse(jsonString ?? '');
|
|
9
|
+
const outputProperties = jsonObject?.outputProperties;
|
|
10
|
+
const transformedProperties = jsonObject?.transformedProperties;
|
|
11
|
+
const extractedData = jsonObject?.extractedData;
|
|
12
|
+
const imageUrl = jsonObject?.imageUrl;
|
|
13
|
+
const faces = jsonObject?.faces as Faces[];
|
|
14
|
+
const identificationDocumentCapture =
|
|
15
|
+
jsonObject?.identificationDocumentCapture as IdentificationDocumentCapture;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
outputProperties,
|
|
19
|
+
transformedProperties,
|
|
20
|
+
extractedData,
|
|
21
|
+
imageUrl,
|
|
22
|
+
faces,
|
|
23
|
+
identificationDocumentCapture,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default JsonParserIdCard;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Faces,
|
|
3
|
+
IdentificationDocumentCapture,
|
|
4
|
+
OtherExtractedModel,
|
|
5
|
+
} from '../../types';
|
|
6
|
+
|
|
7
|
+
const JsonParserOtherID = (jsonString: string): OtherExtractedModel => {
|
|
8
|
+
const jsonObject = JSON.parse(jsonString ?? '');
|
|
9
|
+
const outputProperties = jsonObject?.outputProperties;
|
|
10
|
+
const transformedProperties = jsonObject?.transformedProperties;
|
|
11
|
+
const extractedData = jsonObject?.extractedData;
|
|
12
|
+
const additionalDetails = jsonObject?.additionalDetails;
|
|
13
|
+
const transformedDetails = jsonObject?.transformedDetails;
|
|
14
|
+
const imageUrl = jsonObject?.imageUrl;
|
|
15
|
+
const faces = jsonObject?.faces as Faces[];
|
|
16
|
+
const identificationDocumentCapture =
|
|
17
|
+
jsonObject?.identificationDocumentCapture as IdentificationDocumentCapture;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
outputProperties,
|
|
21
|
+
transformedProperties,
|
|
22
|
+
extractedData,
|
|
23
|
+
additionalDetails,
|
|
24
|
+
transformedDetails,
|
|
25
|
+
imageUrl,
|
|
26
|
+
faces,
|
|
27
|
+
identificationDocumentCapture,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default JsonParserOtherID;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Faces,
|
|
3
|
+
IdentificationDocumentCapture,
|
|
4
|
+
PassportExtractedModel,
|
|
5
|
+
} from '../../types';
|
|
6
|
+
|
|
7
|
+
const JsonParserPassport = (jsonString: string): PassportExtractedModel => {
|
|
8
|
+
const jsonObject = JSON.parse(jsonString ?? '');
|
|
9
|
+
const outputProperties = jsonObject?.outputProperties;
|
|
10
|
+
const transformedProperties = jsonObject?.transformedProperties;
|
|
11
|
+
const extractedData = jsonObject?.extractedData;
|
|
12
|
+
const imageUrl = jsonObject?.imageUrl;
|
|
13
|
+
const identificationDocumentCapture =
|
|
14
|
+
jsonObject?.identificationDocumentCapture as IdentificationDocumentCapture;
|
|
15
|
+
const faces = jsonObject?.faces as Faces[];
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
outputProperties,
|
|
19
|
+
transformedProperties,
|
|
20
|
+
extractedData,
|
|
21
|
+
imageUrl,
|
|
22
|
+
faces,
|
|
23
|
+
identificationDocumentCapture,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default JsonParserPassport;
|