-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
index.ts
555 lines (514 loc) · 14 KB
/
index.ts
1
2
3
4
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
import { Injectable } from '@angular/core';
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export class JumioNetverifyConfig {
/**
* Enable ID verification
*/
enableVerification: boolean;
/**
* Specify an URL for individual transactions
*/
callbackUrl: string;
/**
* Enable face match during the ID verification for a specific transaction
*/
enableIdentityVerification: boolean;
/**
* Specify the issuing country (ISO 3166-1 alpha-3 country code)
*/
preselectedCountry: string;
/**
* Allows you to identify the scan (max. 100 characters)
*/
customerInternalReference: string;
/**
* Use this option to identify the scan in your reports (max. 100 characters)
*/
reportingCriteria: string;
/**
* Set a customer identifier (max. 100 characters)
*/
userReference: string;
/**
* Send debug information to Jumio.
*/
sendDebugInfoToJumio: boolean;
/**
* Limit data extraction to be done on device only
*/
dataExtractionOnMobileOnly: boolean;
/**
* Which camera is used by default. Can be FRONT or BACK.
*/
cameraPosition: string;
/**
* Which types of document variants are available. Can be PAPER or PLASTIC
*/
preselectedDocumentVariant: string;
/**
* An array of accepted document types: Available document types: PASSPORT, DRIVER_LICENSE, IDENTITY_CARD, VISA
*/
documentTypes: string[];
/**
* Enables Jumio Screening. Can be ENABLED, DISABLED or DEFAULT (when not specified reverts to DEFAULT)
*/
enableWatchlistScreening: string;
/**
* Specifies specific profile of watchlist
*/
watchlistSearchProfile: string;
constructor(config?: {
enableVerification?: boolean;
callbackUrl?: string;
enableIdentityVerification?: boolean;
preselectedCountry?: string;
customerInternalReference?: string;
reportingCriteria?: string;
userReference?: string;
sendDebugInfoToJumio?: boolean;
dataExtractionOnMobileOnly?: boolean;
cameraPosition?: string;
preselectedDocumentVariant?: string;
documentTypes?: string[];
enableWatchlistScreening?: string;
watchlistSearchProfile?: string;
}) {
if (config) {
Object.assign(this, config);
}
}
}
export class JumioDocVerificationConfig {
/**
* See the list at https://github.com/Jumio/mobile-cordova
*/
type: string;
/**
* Set a customer identifier (max. 100 characters)
*/
userReference: string;
/**
* Set the country (ISO-3166-1 alpha-3 code)
*/
country: string;
/**
* Allows you to identify the scan (max. 100 characters)
*/
customerInternalReference: string;
/**
* Use this option to identify the scan in your reports (max. 100 characters)
*/
reportingCriteria: string;
/**
* Specify an URL for individual transactions
*/
callbackUrl: string;
/**
* Override the document label on the help screen
*/
documentName: string;
/**
* Set your custom document code (set in the merchant backend under "Settings" - "Multi Documents" - "Custom"
*/
customDocumentCode: string;
/**
* Which camera is used by default. Can be FRONT or BACK.
*/
cameraPosition: string;
/**
* Enable/disable data extraction for documents
*/
enableExtraction: boolean;
constructor(config?: {
type: string;
userReference: string;
country: string;
customerInternalReference: string;
reportingCriteria?: string;
callbackUrl?: string;
documentName?: string;
customDocumentCode?: string;
cameraPosition?: string;
enableExtraction?: boolean;
}) {
if (config) {
Object.assign(this, config);
}
}
}
class JumioAuthenticationConfig {
/**
* The reference of the enrollment scan to authenticate for
*/
enrollmentTransactionReference: string;
/**
* The reference of the authentication scan to authenticate for
*/
authenticationTransactionReference: string;
/**
* Set a customer identifier (max. 100 characters)
*/
userReference: string;
/**
* Specify an URL for callback
*/
callbackUrl: string;
constructor(config?: {
enrollmentTransactionReference: string;
authenticationTransactionReference: string;
userReference: string;
callbackUrl?: string;
}) {
if (config) {
Object.assign(this, config);
}
}
}
class BAMConfig {
cardHolderNameRequired: boolean;
sortCodeAndAccountNumberRequired: boolean;
expiryRequired: boolean;
cvvRequired: boolean;
expiryEditable: boolean;
cardHolderNameEditable: boolean;
/**
* Overwrite your specified reporting criteria to identify each scan attempt in your reports (max. 100 characters)
*/
merchantReportingCriteria: string;
vibrationEffectEnabled: boolean;
enableFlashOnScanStart: boolean;
cardNumberMaskingEnabled: boolean;
/**
* In your Jumio merchant backend on the "Settings" page under "API credentials" you can find your Offline token. In case you use your
* offline token, you must not set the API token and secret
*/
offlineToken: string;
/**
* Which camera is used by default. Can be FRONT or BACK.
*/
cameraPosition: string;
/**
* An array of accepted card types. Available card types: VISA, MASTER_CARD, AMERICAN_EXPRESS, CHINA_UNIONPAY, DINERS_CLUB, DISCOVER, JCB
*/
cardTypes: string[];
constructor(config?: {
cardHolderNameRequired?: boolean;
sortCodeAndAccountNumberRequired?: boolean;
expiryRequired?: boolean;
cvvRequired?: boolean;
expiryEditable?: boolean;
cardHolderNameEditable?: boolean;
merchantReportingCriteria?: string;
vibrationEffectEnabled?: boolean;
enableFlashOnScanStart?: boolean;
cardNumberMaskingEnabled?: boolean;
offlineToken?: string;
cameraPosition?: string;
cardTypes?: string[];
}) {
if (config) {
Object.assign(this, config);
}
}
}
export class NetverifyDocumentData {
/**
* Jumio unique scan reference ID
*/
scanReference: string;
/**
* Country of issue as (ISO 3166-1 alpha-3) country code
*/
issuingCountry: string;
idNumber: string;
firstName: string;
lastName: string;
/**
* Date of Birth (GMT)
*/
dob: Date;
/**
* Country of origin as (ISO 3166-1 alpha-3) country code
*/
selectedCountry: string;
issuingDate: Date; // GMT
expiryDate: Date; // GMT
/**
* MRZ, OCR, BARCODE, BARCODE_OCR or NONE
*/
extractionMethod: string;
/**
* PASSPORT, DRIVER_LICENSE, IDENTITY_CARD or VISA
*/
selectedDocumentType: string;
/**
* m, f or x (M, F or X iOS)
*/
gender: string;
/**
* maxlength 3, Country of origin as (ISO 3166-1 alpha-3) country code
*/
originatingCountry: string;
/**
* maxlength 64, Street name
*/
addressLine: string;
/**
* maxlength 64, City
*/
city: string;
/**
* maxlength 3, Last three characters of ISO 3166-2:US state code
*/
subdivision: string;
/**
* maxlength 15, Postal code
*/
postCode: string;
mrzData: MRZData;
/**
* maxlength 50, Optional field of MRZ line 1
*/
optionalData1: string;
/**
* maxlength 50, Optional field of MRZ line 2
*/
optionalData2: string;
/**
* maxlength 255, Place of Birth
*/
placeOfBirth: string;
}
export class MRZData {
/**
* Max length 8, MRP, TD1, TD2, CNIS, MRVA, MRVB or UNKNOWN
*/
format: string;
/**
* Max length 50, MRZ line 1
*/
line1: string;
/**
* Max length 50, MRZ line 2
*/
line2: string;
/**
* Max length 50, MRZ line 3
*/
line3: string;
/**
* True if ID number check digit is valid, otherwise false
*/
idNumberValid: boolean;
/**
* True if date of birth check digit is valid, otherwise false
*/
dobValid: boolean;
/**
* True if date of expiry check digit is valid or not available, otherwise false
*/
expiryDateValid: boolean;
/**
* True if personal number check digit is valid or not available, otherwise false
*/
personalNumberValid: boolean;
/**
* True if composite check digit is valid, otherwise false
*/
compositeValid: boolean;
}
export class BAMCardInformation {
/**
* maxlength 16, VISA, MASTER_CARD, AMERICAN_EXPRESS, CHINA_UNIONPAY, DINERS_CLUB, DISCOVER, JCB or STARBUCKS
*/
cardType: string;
/**
* maxlength 16, Full credit card number
*/
cardNumber: string;
/**
* maxlength 19, Grouped credit card number
*/
cardNumberGrouped: string;
/**
* maxlength 19, First 6 and last 4 digits of the grouped credit card number, other digits are masked with "X"
*/
cardNumberMasked: string;
/**
* maxlength 2, Month card expires if enabled and readable
*/
cardExpiryMonth: string;
/**
* maxlength 2, Year card expires if enabled and readable
*/
CardExpiryYear: string;
/**
* maxlength 5, Date card expires in the format MM/yy if enabled and readable
*/
cardExpiryDate: string;
/**
* maxlength 4, Entered CVV if enabled
*/
cardCVV: string;
/**
* maxlength 100, Name of the card holder in capital letters if enabled and readable, or as entered if editable
*/
cardHolderName: string;
/**
* maxlength 8, Sort code in the format xx-xx-xx or xxxxxx if enabled, available and readable
*/
cardSortCode: string;
/**
* maxlength 8, Account number if enabled, available and readable
*/
cardAccountNumber: string;
/**
* True if sort code valid, otherwise false
*/
cardSortCodeValid: boolean;
/**
* True if account number code valid, otherwise false
*/
cardAccountNumberValid: boolean;
}
/**
* @name Jumio
* @description Check out [example with Angular 9.1 & Capacitor 2.1](https://github.com/zendigital/jumio-ionic-demo)
*
* [Platform Customization](https://github.com/Jumio/mobile-cordova#customization) is possible
*
* Original source: [Jumio mobile-cordova](https://github.com/Jumio/mobile-cordova) Plugin for Apache Cordova
* @usage
* ```typescript
* import {
* Jumio,
* JumioNetverifyConfig,
* JumioDocVerificationConfig,
* NetverifyDocumentData
* DocVerificationDocumentData
* } from '@ionic-native/jumio/ngx';
*
*
* constructor(private jumio: Jumio) { }
*
* ...
*
* this.jumio.initNetverify("API_TOKEN", "API_SECRET", "US", {
* requireVerification: false,
* userReference: "USER_REFERENCE",
* preselectedCountry: "USA",
* cameraPosition: "BACK",
* documentTypes: ["DRIVER_LICENSE", "PASSPORT", "IDENTITY_CARD", "VISA"],
* enableWatchlistScreening: "ENABLED",
* watchlistSearchProfile: "YOUR_PROFILE_NAME"
* });
*
* let documentData: NetverifyDocumentData = await this.jumio.startNetverify();
*
* ```
*/
@Plugin({
pluginName: 'Jumio',
plugin: 'jumio-cordova',
pluginRef: 'Jumio',
repo: 'https://github.com/danielzen/jumio-cordova',
platforms: ['Android', 'iOS'],
})
@Injectable()
export class Jumio extends IonicNativePlugin {
/**
* Initialize Netverify
* @param apiToken Specifies the API token of the Jumio merchant account
* @param apiSecret Specifies the API Secret of the Jumio merchant account
* @param dataCenter Specifies the data center of the Jumio server (US, EU or SG)
* @param netverifyConfig JumioNetverifyConfig
* @return Returns a promise that resolves when something happens
*/
@Cordova()
initNetverify(
apiToken: string,
apiSecret: string,
dataCenter: string,
netverifyConfig: JumioNetverifyConfig
): Promise<any> {
return; // We add return; here to avoid any IDE / Compiler errors
}
/**
* Start Netverify
* @return Returns a promise that resolves to Netverify document data
*/
@Cordova({ callbackOrder: 'reverse' })
startNetverify(): Promise<NetverifyDocumentData> {
return;
}
/**
* Initialize DocumentVerification
* @param apiToken Specifies the API token of the Jumio merchant account
* @param apiSecret Specifies the API Secret of the Jumio merchant account
* @param dataCenter Specifies the data center of the Jumio server (US, EU or SG)
* @param docVerificationConfig JumioDocVerificationConfig
* @return Returns a promise that resolves when something happens
*/
@Cordova()
initDocumentVerification(
apiToken: string,
apiSecret: string,
dataCenter: string,
docVerificationConfig: JumioDocVerificationConfig
): Promise<any> {
return; // We add return; here to avoid any IDE / Compiler errors
}
/**
* Start DocumentVerification
* @return Returns a promise that resolves to DocVerification document data
*/
@Cordova({ callbackOrder: 'reverse' })
startDocumentVerification(): Promise<any> {
return;
}
/**
* Initialize Authentication
* @param apiToken Specifies the API token of the Jumio merchant account
* @param apiSecret Specifies the API Secret of the Jumio merchant account
* @param dataCenter Specifies the data center of the Jumio server (US, EU or SG)
* @param authenticationConfig JumioAuthenticationConfig
* @return Returns a promise that resolves when something happens
*/
@Cordova()
initAuthentication(
apiToken: string,
apiSecret: string,
dataCenter: string,
authenticationConfig: JumioAuthenticationConfig
): Promise<any> {
return; // We add return; here to avoid any IDE / Compiler errors
}
/**
* Start Authentication
* @return Returns a promise that resolves when something happens
*/
@Cordova({ callbackOrder: 'reverse' })
startAuthentication(): Promise<any> {
return;
}
/**
* Initialize BAM
* @param apiToken Specifies the API token of the Jumio merchant account
* @param apiSecret Specifies the API Secret of the Jumio merchant account
* @param dataCenter Specifies the data center of the Jumio server (US, EU or SG)
* @param bamConfig BAMConfig
* @return Returns a promise that resolves when something happens
*/
@Cordova()
initBAM(apiToken: string, apiSecret: string, dataCenter: string, bamConfig: BAMConfig): Promise<any> {
return; // We add return; here to avoid any IDE / Compiler errors
}
/**
* Start BAM
* @return Returns a promise that resolves to BAMCardInformation
*/
@Cordova({ callbackOrder: 'reverse' })
startBAM(): Promise<BAMCardInformation> {
return;
}
}