@idnow/react-idcheckio 7.1.11
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/.gitattributes +1 -0
- package/README.md +234 -0
- package/ReactIdcheckio.podspec +15 -0
- package/android/.project +17 -0
- package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/build.gradle +51 -0
- package/android/src/main/AndroidManifest.xml +10 -0
- package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioActivity.java +133 -0
- package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioConst.java +39 -0
- package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioModule.java +189 -0
- package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioPackage.java +22 -0
- package/android/src/main/java/com/ariadnext/idcheckio/ParameterUtils.java +251 -0
- package/idcheckio_params.js +343 -0
- package/index.js +6 -0
- package/ios/Idcheckio.h +11 -0
- package/ios/Idcheckio.m +301 -0
- package/ios/Idcheckio.xcodeproj/project.pbxproj +340 -0
- package/ios/Idcheckio.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/Idcheckio.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/IdcheckioKeys.h +49 -0
- package/ios/IdcheckioSdk+Utils.swift +35 -0
- package/package.json +22 -0
- package/release-public.sh +89 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
export class IDCheckioParams {
|
|
2
|
+
constructor({docType, orientation, confirmationType, useHd, integrityCheck, scanBothSides, sideOneExtraction, sideTwoExtraction,
|
|
3
|
+
language, manualButtonTimer, feedbackLevel, adjustCrop, maxPictureFilesize, token, confirmAbort, onlineConfig, captureMode, theme}={}){
|
|
4
|
+
this.docType = docType
|
|
5
|
+
this.orientation = orientation
|
|
6
|
+
this.confirmationType = confirmationType
|
|
7
|
+
this.useHd = useHd
|
|
8
|
+
this.integrityCheck = integrityCheck
|
|
9
|
+
this.scanBothSides = scanBothSides
|
|
10
|
+
this.sideOneExtraction = sideOneExtraction
|
|
11
|
+
this.sideTwoExtraction = sideTwoExtraction
|
|
12
|
+
this.language = language
|
|
13
|
+
this.manualButtonTimer = manualButtonTimer
|
|
14
|
+
this.feedbackLevel = feedbackLevel
|
|
15
|
+
this.adjustCrop = adjustCrop
|
|
16
|
+
this.maxPictureFilesize = maxPictureFilesize
|
|
17
|
+
this.token = token
|
|
18
|
+
this.confirmAbort = confirmAbort
|
|
19
|
+
this.onlineConfig = onlineConfig
|
|
20
|
+
this.captureMode = captureMode
|
|
21
|
+
this.theme = theme
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class IDCheckioParamsBuilder {
|
|
26
|
+
constructor() {}
|
|
27
|
+
|
|
28
|
+
setDocType(docType){
|
|
29
|
+
if(Object.values(DocumentType).includes(docType)){
|
|
30
|
+
this.docType = docType
|
|
31
|
+
return this
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error("DocumentType value is incorrect")
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
setOrientation(orientation){
|
|
38
|
+
if(Object.values(IDCheckioOrientation).includes(orientation)){
|
|
39
|
+
this.orientation = orientation
|
|
40
|
+
return this
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error("IDCheckioOrientation value is incorrect")
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setConfirmationType(confirmationType){
|
|
47
|
+
if(Object.values(ConfirmationType).includes(confirmationType)){
|
|
48
|
+
this.confirmationType = confirmationType
|
|
49
|
+
return this
|
|
50
|
+
} else {
|
|
51
|
+
throw new Error("ConfirmationType value is incorrect")
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setUseHd(useHd){
|
|
56
|
+
if(typeof useHd == "boolean"){
|
|
57
|
+
this.useHd = useHd
|
|
58
|
+
return this
|
|
59
|
+
} else {
|
|
60
|
+
throw new Error("useHd must be a boolean")
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setIntegrityCheck(integrityCheck){
|
|
65
|
+
if(typeof integrityCheck == "object"){
|
|
66
|
+
this.integrityCheck = integrityCheck
|
|
67
|
+
return this
|
|
68
|
+
} else {
|
|
69
|
+
throw new Error("integrityCheck must be an IntegrityCheck")
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setScanBothSides(scanBothSides){
|
|
74
|
+
if(Object.values(ScanBothSides).includes(scanBothSides)){
|
|
75
|
+
this.scanBothSides = scanBothSides
|
|
76
|
+
return this
|
|
77
|
+
} else {
|
|
78
|
+
throw new Error("ScanBothSides value is incorrect")
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setSideOneExtraction(sideOneExtraction){
|
|
83
|
+
if(typeof sideOneExtraction == "object"){
|
|
84
|
+
this.sideOneExtraction = sideOneExtraction
|
|
85
|
+
return this
|
|
86
|
+
} else {
|
|
87
|
+
throw new Error("sideOneExtraction must be an Extraction ")
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setSideTwoExtraction(sideTwoExtraction){
|
|
92
|
+
if(typeof sideTwoExtraction == "object"){
|
|
93
|
+
this.sideTwoExtraction = sideTwoExtraction
|
|
94
|
+
return this
|
|
95
|
+
} else {
|
|
96
|
+
throw new Error("sideTwoExtraction must be an Extraction ")
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setLanguage(language){
|
|
101
|
+
if(Object.values(Language).includes(language)){
|
|
102
|
+
this.language = language
|
|
103
|
+
return this
|
|
104
|
+
} else {
|
|
105
|
+
throw new Error("Language value is incorrect")
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setManualButtonTimer(manualButtonTimer){
|
|
110
|
+
if(typeof manualButtonTimer == "number"){
|
|
111
|
+
this.manualButtonTimer = manualButtonTimer
|
|
112
|
+
return this
|
|
113
|
+
} else {
|
|
114
|
+
throw new Error("manualButtonTimer must be a number")
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setFeedbackLevel(feedbackLevel){
|
|
119
|
+
if(Object.values(FeedbackLevel).includes(feedbackLevel)){
|
|
120
|
+
this.feedbackLevel = feedbackLevel
|
|
121
|
+
return this
|
|
122
|
+
} else {
|
|
123
|
+
throw new Error("FeedbackLevel value is incorrect")
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
setAdjustCrop(adjustCrop){
|
|
128
|
+
if(typeof adjustCrop == "boolean"){
|
|
129
|
+
this.adjustCrop = adjustCrop
|
|
130
|
+
return this
|
|
131
|
+
} else {
|
|
132
|
+
throw new Error("adjustCrop must be a boolean")
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
setMaxPictureFilesize(maxPictureFilesize){
|
|
137
|
+
if(Object.values(FileSize).includes(maxPictureFilesize)){
|
|
138
|
+
this.maxPictureFilesize = maxPictureFilesize
|
|
139
|
+
return this
|
|
140
|
+
} else {
|
|
141
|
+
throw new Error("FileSize value is incorrect")
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
setToken(token){
|
|
146
|
+
if(typeof token == "string"){
|
|
147
|
+
this.token = token
|
|
148
|
+
return this
|
|
149
|
+
} else {
|
|
150
|
+
throw new Error("token must be a string")
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
setConfirmAbort(confirmAbort){
|
|
155
|
+
if(typeof confirmAbort == "boolean"){
|
|
156
|
+
this.confirmAbort = confirmAbort
|
|
157
|
+
return this
|
|
158
|
+
} else {
|
|
159
|
+
throw new Error("confirmAbort must be a boolean")
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setOnlineConfig(onlineConfig){
|
|
164
|
+
if(typeof onlineConfig == "object"){
|
|
165
|
+
this.onlineConfig = onlineConfig
|
|
166
|
+
return this
|
|
167
|
+
} else {
|
|
168
|
+
throw new Error("onlineConfig must be an OnlineConfig")
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
setCaptureMode(captureMode){
|
|
173
|
+
if(Object.values(CaptureMode).includes(captureMode)){
|
|
174
|
+
this.captureMode = captureMode
|
|
175
|
+
return this
|
|
176
|
+
} else {
|
|
177
|
+
throw new Error("CaptureMode value is incorrect")
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
build() {
|
|
182
|
+
return new IDCheckioParams({ docType: this.docType, adjustCrop: this.adjustCrop, confirmAbort: this.confirmAbort, feedbackLevel: this.feedbackLevel, confirmationType: this.confirmationType,
|
|
183
|
+
integrityCheck: this.integrityCheck, language: this.language, manualButtonTimer: this.manualButtonTimer, maxPictureFilesize: this.maxPictureFilesize, onlineConfig: this.onlineConfig,
|
|
184
|
+
orientation: this.orientation, scanBothSides: this.scanBothSides, sideOneExtraction: this.sideOneExtraction, sideTwoExtraction: this.sideTwoExtraction, token: this.token, useHd: this.useHd,
|
|
185
|
+
captureMode: this.captureMode
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export class Extraction {
|
|
191
|
+
constructor(codeline, faceDetection){
|
|
192
|
+
if(Object.values(Codeline).includes(codeline)){
|
|
193
|
+
this.codeline = codeline
|
|
194
|
+
} else {
|
|
195
|
+
throw new Error("Codeline value is incorrect")
|
|
196
|
+
}
|
|
197
|
+
if(Object.values(FaceDetection).includes(faceDetection)){
|
|
198
|
+
this.faceDetection = faceDetection
|
|
199
|
+
} else {
|
|
200
|
+
throw new Error("FaceDetection value is incorrect")
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export class IntegrityCheck {
|
|
206
|
+
constructor({readEmrtd = false, docLiveness = false}={}){
|
|
207
|
+
this.readEmrtd = readEmrtd
|
|
208
|
+
this.docLiveness = docLiveness
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export class OnlineConfig {
|
|
213
|
+
constructor({
|
|
214
|
+
isReferenceDocument = false,
|
|
215
|
+
cisType = null,
|
|
216
|
+
folderUid = null,
|
|
217
|
+
biometricConsent = null,
|
|
218
|
+
enableManualAnalysis = false
|
|
219
|
+
}={}){
|
|
220
|
+
this.isReferenceDocument = isReferenceDocument
|
|
221
|
+
this.cisType = cisType
|
|
222
|
+
this.folderUid = folderUid
|
|
223
|
+
this.biometricConsent = biometricConsent
|
|
224
|
+
this.enableManualAnalysis = enableManualAnalysis
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export class IDCheckTheme {
|
|
229
|
+
constructor({
|
|
230
|
+
primaryColor = null,
|
|
231
|
+
foregroundColor = null,
|
|
232
|
+
backgroundColor = null,
|
|
233
|
+
borderColor = null,
|
|
234
|
+
textColor = null,
|
|
235
|
+
titleColor = null
|
|
236
|
+
}={}){
|
|
237
|
+
this.primaryColor = primaryColor
|
|
238
|
+
this.foregroundColor = foregroundColor
|
|
239
|
+
this.backgroundColor = backgroundColor
|
|
240
|
+
this.borderColor = borderColor
|
|
241
|
+
this.textColor = textColor
|
|
242
|
+
this.titleColor = titleColor
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/*
|
|
247
|
+
* Enumeration
|
|
248
|
+
*/
|
|
249
|
+
export const DocumentType = {
|
|
250
|
+
DISABLED:"DISABLED",
|
|
251
|
+
ID:"ID",
|
|
252
|
+
LIVENESS:"LIVENESS",
|
|
253
|
+
A4:"A4",
|
|
254
|
+
FRENCH_HEALTH_CARD:"FRENCH_HEALTH_CARD",
|
|
255
|
+
BANK_CHECK:"BANK_CHECK",
|
|
256
|
+
OLD_DL_FR:"OLD_DL_FR",
|
|
257
|
+
PHOTO:"PHOTO",
|
|
258
|
+
VEHICLE_REGISTRATION:"VEHICLE_REGISTRATION",
|
|
259
|
+
SELFIE:"SELFIE"
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export const Environment = {
|
|
263
|
+
DEMO:"DEMO",
|
|
264
|
+
PROD:"PROD"
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export const IDCheckioOrientation = {
|
|
268
|
+
PORTRAIT:"PORTRAIT",
|
|
269
|
+
LANDSCAPE:"LANDSCAPE"
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export const ConfirmationType = {
|
|
273
|
+
DATA_OR_PICTURE:"DATA_OR_PICTURE",
|
|
274
|
+
CROPPED_PICTURE:"CROPPED_PICTURE",
|
|
275
|
+
NONE:"NONE"
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export const ScanBothSides = {
|
|
279
|
+
ENABLED:"ENABLED",
|
|
280
|
+
FORCED:"FORCED",
|
|
281
|
+
DISABLED:"DISABLED"
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export const Codeline = {
|
|
285
|
+
DISABLED:"DISABLED",
|
|
286
|
+
ANY:"ANY",
|
|
287
|
+
DECODED:"DECODED",
|
|
288
|
+
VALID:"VALID",
|
|
289
|
+
REJECT:"REJECT"
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export const FaceDetection = {
|
|
293
|
+
ENABLED:"ENABLED",
|
|
294
|
+
DISABLED:"DISABLED"
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export const Language = {
|
|
298
|
+
fr:"fr",
|
|
299
|
+
en:"en",
|
|
300
|
+
pl:"pl",
|
|
301
|
+
es:"es",
|
|
302
|
+
ro:"ro",
|
|
303
|
+
cs:"cs",
|
|
304
|
+
pt:"pt",
|
|
305
|
+
de:"de",
|
|
306
|
+
it:"it",
|
|
307
|
+
nl:"nl",
|
|
308
|
+
ar:"ar"
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export const FeedbackLevel = {
|
|
312
|
+
ALL:"ALL",
|
|
313
|
+
GUIDELINE:"GUIDELINE",
|
|
314
|
+
ERROR:"ERROR"
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export const FileSize = {
|
|
318
|
+
ONE_MEGA_BYTE:"ONE_MEGA_BYTE",
|
|
319
|
+
TWO_MEGA_BYTES:"TWO_MEGA_BYTES",
|
|
320
|
+
THREE_MEGA_BYTES:"THREE_MEGA_BYTES",
|
|
321
|
+
FOUR_MEGA_BYTES:"FOUR_MEGA_BYTES",
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export const CISType = {
|
|
325
|
+
ID:"ID",
|
|
326
|
+
IBAN:"IBAN",
|
|
327
|
+
CHEQUE:"CHEQUE",
|
|
328
|
+
TAX_SHEET:"TAX_SHEET",
|
|
329
|
+
PAY_SLIP:"PAY_SLIP",
|
|
330
|
+
ADDRESS_PROOF:"ADDRESS_PROOF",
|
|
331
|
+
CREDIT_CARD:"CREDIT_CARD",
|
|
332
|
+
PORTRAIT:"PORTRAIT",
|
|
333
|
+
LEGAL_ENTITY:"LEGAL_ENTITY",
|
|
334
|
+
CAR_REGISTRATION:"CAR_REGISTRATION",
|
|
335
|
+
LIVENESS:"LIVENESS",
|
|
336
|
+
OTHER:"OTHER"
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export const CaptureMode = {
|
|
340
|
+
CAMERA:"CAMERA",
|
|
341
|
+
PROMPT:"PROMPT",
|
|
342
|
+
UPLOAD:"UPLOAD"
|
|
343
|
+
}
|
package/index.js
ADDED
package/ios/Idcheckio.h
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#if __has_include("RCTBridgeModule.h")
|
|
2
|
+
#import "RCTBridgeModule.h"
|
|
3
|
+
#else
|
|
4
|
+
#import <React/RCTBridgeModule.h>
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
#import <IDCheckIOSDK/IDCheckIOSDK-Swift.h>
|
|
8
|
+
|
|
9
|
+
@interface IdcheckioModule : NSObject <RCTBridgeModule, IdcheckioDelegate>
|
|
10
|
+
|
|
11
|
+
@end
|
package/ios/Idcheckio.m
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
#import "Idcheckio.h"
|
|
2
|
+
#import "IdcheckioKeys.h"
|
|
3
|
+
#import <ReactIdcheckio/ReactIdcheckio-Swift.h>
|
|
4
|
+
|
|
5
|
+
@implementation IdcheckioModule
|
|
6
|
+
|
|
7
|
+
RCTPromiseResolveBlock captureResolver;
|
|
8
|
+
RCTPromiseRejectBlock captureRejecter;
|
|
9
|
+
|
|
10
|
+
RCT_EXPORT_MODULE(IdcheckioModule);
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_METHOD(preload:(BOOL)extractData){
|
|
13
|
+
[Idcheckio.shared preloadWithExtractData:extractData];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
RCT_EXPORT_METHOD(activate:(NSString*)idToken
|
|
17
|
+
extractData:(BOOL)extractData
|
|
18
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
19
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
20
|
+
[Idcheckio.shared activateWithToken:idToken extractData:extractData onComplete:^(NSError* error){
|
|
21
|
+
if(error == nil){
|
|
22
|
+
resolve(@"");
|
|
23
|
+
} else {
|
|
24
|
+
reject(@"0", [IdcheckioObjcUtil getErrorJson:error], error);
|
|
25
|
+
}
|
|
26
|
+
}];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
RCT_EXPORT_METHOD(start:(NSDictionary*)params
|
|
30
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
31
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
32
|
+
captureResolver = resolve;
|
|
33
|
+
captureRejecter = reject;
|
|
34
|
+
SDKParams* sdkParams = [self getParamsFromDictionnary:params];
|
|
35
|
+
|
|
36
|
+
NSError* error;
|
|
37
|
+
[Idcheckio.shared setParams:sdkParams error:&error];
|
|
38
|
+
if(error != nil){
|
|
39
|
+
reject(@"0", [IdcheckioObjcUtil getErrorJson:error], error);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
43
|
+
IdcheckioViewController *idcheckioViewController = [[IdcheckioViewController alloc] init];
|
|
44
|
+
idcheckioViewController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
45
|
+
idcheckioViewController.isOnlineSession = false;
|
|
46
|
+
[idcheckioViewController setResultCompletion:^(IdcheckioResult *result, NSError *error) {
|
|
47
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
48
|
+
[[[UIApplication sharedApplication] keyWindow].rootViewController dismissViewControllerAnimated:true completion:^{}];
|
|
49
|
+
});
|
|
50
|
+
if(result != nil){
|
|
51
|
+
captureResolver([IdcheckioObjcUtil resultToJSON:result]);
|
|
52
|
+
} else if(error != nil){
|
|
53
|
+
captureRejecter(@"0", [IdcheckioObjcUtil getErrorJson:error], error);
|
|
54
|
+
}
|
|
55
|
+
}];
|
|
56
|
+
[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:idcheckioViewController animated:true completion:nil];
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
RCT_EXPORT_METHOD(startOnline:(NSDictionary*)params
|
|
61
|
+
cis:(NSDictionary*)cis
|
|
62
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
63
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
64
|
+
captureResolver = resolve;
|
|
65
|
+
captureRejecter = reject;
|
|
66
|
+
SDKParams* sdkParams = [self getParamsFromDictionnary:params];
|
|
67
|
+
OnlineContext* onlineContext = [self getOnlineContextFromJson:cis];
|
|
68
|
+
NSError* error;
|
|
69
|
+
[Idcheckio.shared setParams:sdkParams error:&error];
|
|
70
|
+
if(error != nil){
|
|
71
|
+
reject(@"0", [IdcheckioObjcUtil getErrorJson:error], error);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
75
|
+
IdcheckioViewController *idcheckioViewController = [[IdcheckioViewController alloc] init];
|
|
76
|
+
idcheckioViewController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
77
|
+
idcheckioViewController.isOnlineSession = true;
|
|
78
|
+
idcheckioViewController.onlineContext = onlineContext;
|
|
79
|
+
[idcheckioViewController setResultCompletion:^(IdcheckioResult *result, NSError *error) {
|
|
80
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
81
|
+
[[[UIApplication sharedApplication] keyWindow].rootViewController dismissViewControllerAnimated:true completion:^{
|
|
82
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
83
|
+
if(result != nil){
|
|
84
|
+
captureResolver([IdcheckioObjcUtil resultToJSON:result]);
|
|
85
|
+
} else if(error != nil){
|
|
86
|
+
captureRejecter(@"0", [IdcheckioObjcUtil getErrorJson:error], error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}];
|
|
90
|
+
});
|
|
91
|
+
}];
|
|
92
|
+
[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:idcheckioViewController animated:true completion:nil];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
RCT_EXPORT_METHOD(startIps:(NSString*)folderUid
|
|
97
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
98
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
99
|
+
if([folderUid length] == 0){
|
|
100
|
+
reject(@"0", [IdcheckioObjcUtil missingFolderUid], nil);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
IpsTheme *ipsTheme = [[IpsTheme alloc] init];
|
|
104
|
+
[ipsTheme setOrientation:@"automatic"];
|
|
105
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
106
|
+
[Idcheckio startIpsWith:folderUid from:[[UIApplication sharedApplication] keyWindow].rootViewController ipsTheme:ipsTheme token:nil completion:^(NSError* error){
|
|
107
|
+
if(error != nil) {
|
|
108
|
+
reject(@"0", [IdcheckioObjcUtil getErrorJson:error], error);
|
|
109
|
+
} else {
|
|
110
|
+
resolve(@"{}");
|
|
111
|
+
}
|
|
112
|
+
}];
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
RCT_EXPORT_METHOD(analyze:(NSDictionary*)params
|
|
117
|
+
side1Image:(NSString*)side1Image
|
|
118
|
+
side2Image:(NSString*)side2Image
|
|
119
|
+
online:(BOOL)online
|
|
120
|
+
context:(NSDictionary*)context
|
|
121
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
122
|
+
rejecter:(RCTPromiseRejectBlock)reject){
|
|
123
|
+
captureResolver = resolve;
|
|
124
|
+
captureRejecter = reject;
|
|
125
|
+
NSError* error;
|
|
126
|
+
SDKParams* sdkParams = [self getParamsFromDictionnary:params];
|
|
127
|
+
OnlineContext* onlineContext = [self getOnlineContextFromJson:context];
|
|
128
|
+
[Idcheckio.shared setParams:sdkParams error:&error];
|
|
129
|
+
if(error != nil){
|
|
130
|
+
reject(@"0", [IdcheckioObjcUtil getErrorJson:error], error);
|
|
131
|
+
}
|
|
132
|
+
Idcheckio.shared.delegate = self;
|
|
133
|
+
NSURL *url1 = [NSURL URLWithString:[side1Image stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
|
|
134
|
+
NSURL *url2 = [NSURL URLWithString:[side2Image stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
|
|
135
|
+
UIImage *side1 = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:url1]];
|
|
136
|
+
UIImage *side2 = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:url2]];
|
|
137
|
+
[Idcheckio.shared analyzeWithSide1Image:side1 side2Image:side2 online:online onlineContext:onlineContext];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
- (OnlineContext*) getOnlineContextFromJson:(NSDictionary*)cis{
|
|
141
|
+
if (cis == nil) {
|
|
142
|
+
return nil;
|
|
143
|
+
}
|
|
144
|
+
NSError * err;
|
|
145
|
+
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:cis options:0 error:&err];
|
|
146
|
+
NSString * myString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
147
|
+
if (err == nil) {
|
|
148
|
+
return [OnlineContext fromJson:myString];
|
|
149
|
+
}
|
|
150
|
+
return nil;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
- (SDKParams*) getParamsFromDictionnary:(NSDictionary*)params {
|
|
154
|
+
SDKParams* sdkParams = [[SDKParams alloc] init];
|
|
155
|
+
SDKExtraParams* extraParams = [[SDKExtraParams alloc] init];
|
|
156
|
+
Theme* theme = [[Theme alloc] init];
|
|
157
|
+
for(NSString* key in [params allKeys]){
|
|
158
|
+
if([key isEqualToString:docTypeKey]){
|
|
159
|
+
[sdkParams setDocumentType:[params objectForKey:key]];
|
|
160
|
+
} else if ([key isEqualToString:orientationKey]) {
|
|
161
|
+
[sdkParams setOrientation:[params objectForKey:key]];
|
|
162
|
+
} else if ([key isEqualToString:confirmationTypeKey]) {
|
|
163
|
+
[sdkParams setConfirmType:[params objectForKey:key]];
|
|
164
|
+
} else if ([key isEqualToString:sideOneExtractionKey]) {
|
|
165
|
+
id paramsSide1 = [params objectForKey:key];
|
|
166
|
+
Extraction* extractSide1 = [[Extraction alloc] init];
|
|
167
|
+
[extractSide1 setFace:[paramsSide1 objectForKey:faceDetectionKey]];
|
|
168
|
+
[extractSide1 setCodeline:[paramsSide1 objectForKey:codelineKey]];
|
|
169
|
+
[sdkParams setSide1Extraction:extractSide1];
|
|
170
|
+
} else if ([key isEqualToString:sideTwoExtractionKey]) {
|
|
171
|
+
id paramsSide2 = [params objectForKey:key];
|
|
172
|
+
Extraction* extractSide2 = [[Extraction alloc] init];
|
|
173
|
+
[extractSide2 setFace:[paramsSide2 objectForKey:faceDetectionKey]];
|
|
174
|
+
[extractSide2 setCodeline:[paramsSide2 objectForKey:codelineKey]];
|
|
175
|
+
[sdkParams setSide2Extraction:extractSide2];
|
|
176
|
+
} else if ([key isEqualToString:integrityCheckKey]) {
|
|
177
|
+
id paramIntegrityCheck = [params objectForKey:key];
|
|
178
|
+
IntegrityCheck *integrity = [[IntegrityCheck alloc] init];
|
|
179
|
+
integrity.readEmrtd = [paramIntegrityCheck objectForKey:readEmrtdKey];
|
|
180
|
+
integrity.docLiveness = [paramIntegrityCheck objectForKey:docLivenessKey];
|
|
181
|
+
[sdkParams setIntegrityCheck: integrity];
|
|
182
|
+
} else if ([key isEqualToString:onlineConfigKey]){
|
|
183
|
+
id onlineConfigParams = [params objectForKey:key];
|
|
184
|
+
OnlineConfig *onlineConfig = [sdkParams onlineConfig];
|
|
185
|
+
onlineConfig.isReferenceDocument = [[onlineConfigParams objectForKey:isReferenceDocumentKey] boolValue];
|
|
186
|
+
if ([onlineConfigParams objectForKey:cisTypeKey] != [NSNull null]) {
|
|
187
|
+
[onlineConfig setCisType:[onlineConfigParams objectForKey:cisTypeKey]];
|
|
188
|
+
}
|
|
189
|
+
if ([onlineConfigParams objectForKey:folderUidKey] != [NSNull null]) {
|
|
190
|
+
onlineConfig.folderUid = [onlineConfigParams objectForKey:folderUidKey];
|
|
191
|
+
}
|
|
192
|
+
if ([onlineConfigParams objectForKey:biometricConsentKey] != [NSNull null]) {
|
|
193
|
+
[onlineConfig setBiometricConsentWithBiometricConsent:[[onlineConfigParams objectForKey:biometricConsentKey] boolValue]];
|
|
194
|
+
}
|
|
195
|
+
onlineConfig.enableManualAnalysis = [[onlineConfigParams objectForKey:enableManualAnalysisKey] boolValue];
|
|
196
|
+
} else if ([key isEqualToString:scanBothSidesKey]) {
|
|
197
|
+
[sdkParams setScanBothSides:[params objectForKey:key]];
|
|
198
|
+
} else if ([key isEqualToString:useHdKey]) {
|
|
199
|
+
[sdkParams setUseHD: [[params objectForKey:key] boolValue]];
|
|
200
|
+
} else if([key isEqualToString:languageKey]){
|
|
201
|
+
[extraParams setLanguage:[params objectForKey:key]];
|
|
202
|
+
} else if([key isEqualToString:manualButtonTimerKey]){
|
|
203
|
+
[extraParams setManualButtonTimer:[[params objectForKey:key] doubleValue]];
|
|
204
|
+
} else if([key isEqualToString:maxPictureFilesizeKey]){
|
|
205
|
+
[extraParams setMaxPictureFilesize:[params objectForKey:key]];
|
|
206
|
+
} else if([key isEqualToString:feedbackLevelKey]){
|
|
207
|
+
[extraParams setFeedbackLevel:[params objectForKey:key]];
|
|
208
|
+
} else if([key isEqualToString:confirmAbortKey]){
|
|
209
|
+
[extraParams setConfirmAbort:[[params objectForKey:key] boolValue]];
|
|
210
|
+
} else if([key isEqualToString:adjustCropKey]){
|
|
211
|
+
[extraParams setAdjustCrop:[[params objectForKey:key] boolValue]];
|
|
212
|
+
} else if([key isEqualToString:captureModeKey]){
|
|
213
|
+
[extraParams setCaptureMode:[params objectForKey:key]];
|
|
214
|
+
} else if([key isEqualToString:themeKey]){
|
|
215
|
+
id themeParams = [params objectForKey:key];
|
|
216
|
+
if ([themeParams objectForKey:primaryColorKey] != [NSNull null]) {
|
|
217
|
+
[theme setPrimaryColor:[self colorWithHexString:[themeParams objectForKey:primaryColorKey]]];
|
|
218
|
+
}
|
|
219
|
+
if ([themeParams objectForKey:foregroundColorKey] != [NSNull null]) {
|
|
220
|
+
[theme setForegroundColor:[self colorWithHexString:[themeParams objectForKey:foregroundColorKey]]];
|
|
221
|
+
}
|
|
222
|
+
if ([themeParams objectForKey:backgroundColorKey] != [NSNull null]) {
|
|
223
|
+
[theme setBackgroundColor:[self colorWithHexString:[themeParams objectForKey:backgroundColorKey]]];
|
|
224
|
+
}
|
|
225
|
+
if ([themeParams objectForKey:borderColorKey] != [NSNull null]) {
|
|
226
|
+
[theme setBorderColor:[self colorWithHexString:[themeParams objectForKey:borderColorKey]]];
|
|
227
|
+
}
|
|
228
|
+
if ([themeParams objectForKey:textColorKey] != [NSNull null]) {
|
|
229
|
+
[theme setTextColor:[self colorWithHexString:[themeParams objectForKey:textColorKey]]];
|
|
230
|
+
}
|
|
231
|
+
if ([themeParams objectForKey:titleColorKey] != [NSNull null]) {
|
|
232
|
+
[theme setTitleColor:[self colorWithHexString:[themeParams objectForKey:titleColorKey]]];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
[Idcheckio.shared setExtraParams:extraParams error:nil];
|
|
236
|
+
[Idcheckio.shared setTheme:theme];
|
|
237
|
+
}
|
|
238
|
+
return sdkParams;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
- (BOOL) getBooleanFromString:(NSString*)string {
|
|
242
|
+
if ([string isEqualToString:@"false"] || [string isEqualToString:@"NO"]){
|
|
243
|
+
return NO;
|
|
244
|
+
}
|
|
245
|
+
return YES;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
- (void)idcheckioFinishedWithResult:(IdcheckioResult * _Nullable)result error:(NSError * _Nullable)error {
|
|
249
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
250
|
+
if(result != nil){
|
|
251
|
+
captureResolver([IdcheckioObjcUtil resultToJSON:result]);
|
|
252
|
+
} else if(error != nil){
|
|
253
|
+
captureRejecter(@"0", [IdcheckioObjcUtil getErrorJson:error], error);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
- (UIColor *) colorWithHexString: (NSString *) hexString {
|
|
259
|
+
NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString];
|
|
260
|
+
CGFloat alpha, red, blue, green;
|
|
261
|
+
switch ([colorString length]) {
|
|
262
|
+
case 3: // #RGB
|
|
263
|
+
alpha = 1.0f;
|
|
264
|
+
red = [self colorComponentFrom: colorString start: 0 length: 1];
|
|
265
|
+
green = [self colorComponentFrom: colorString start: 1 length: 1];
|
|
266
|
+
blue = [self colorComponentFrom: colorString start: 2 length: 1];
|
|
267
|
+
break;
|
|
268
|
+
case 4: // #ARGB
|
|
269
|
+
alpha = [self colorComponentFrom: colorString start: 0 length: 1];
|
|
270
|
+
red = [self colorComponentFrom: colorString start: 1 length: 1];
|
|
271
|
+
green = [self colorComponentFrom: colorString start: 2 length: 1];
|
|
272
|
+
blue = [self colorComponentFrom: colorString start: 3 length: 1];
|
|
273
|
+
break;
|
|
274
|
+
case 6: // #RRGGBB
|
|
275
|
+
alpha = 1.0f;
|
|
276
|
+
red = [self colorComponentFrom: colorString start: 0 length: 2];
|
|
277
|
+
green = [self colorComponentFrom: colorString start: 2 length: 2];
|
|
278
|
+
blue = [self colorComponentFrom: colorString start: 4 length: 2];
|
|
279
|
+
break;
|
|
280
|
+
case 8: // #AARRGGBB
|
|
281
|
+
alpha = [self colorComponentFrom: colorString start: 0 length: 2];
|
|
282
|
+
red = [self colorComponentFrom: colorString start: 2 length: 2];
|
|
283
|
+
green = [self colorComponentFrom: colorString start: 4 length: 2];
|
|
284
|
+
blue = [self colorComponentFrom: colorString start: 6 length: 2];
|
|
285
|
+
break;
|
|
286
|
+
default:
|
|
287
|
+
[NSException raise:@"Invalid color value" format: @"Color value %@ is invalid. It should be a hex value of the form #RBG, #ARGB, #RRGGBB, or #AARRGGBB", hexString];
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
return [UIColor colorWithRed: red green: green blue: blue alpha: alpha];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
- (CGFloat) colorComponentFrom: (NSString *) string start: (NSUInteger) start length: (NSUInteger) length {
|
|
294
|
+
NSString *substring = [string substringWithRange: NSMakeRange(start, length)];
|
|
295
|
+
NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring];
|
|
296
|
+
unsigned hexComponent;
|
|
297
|
+
[[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent];
|
|
298
|
+
return hexComponent / 255.0;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
@end
|