cordova-digital-onboarding 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts ADDED
@@ -0,0 +1,877 @@
1
+ /** For request that needs to identify the current process. */
2
+ interface WDOProcessRequest {
3
+ processId: string;
4
+ }
5
+ /** Onboarding process response */
6
+ interface WDOProcessResponse {
7
+ /** ID of the process */
8
+ processId: string;
9
+ /** Status of the process */
10
+ onboardingStatus: WDOOnboardingStatus;
11
+ /**
12
+ * Activation code used during the activation process.
13
+ * If not present, the activation is created later on in the onboarding process.
14
+ */
15
+ activationCode?: string;
16
+ }
17
+ /** Status of the onboarding */
18
+ declare enum WDOOnboardingStatus {
19
+ /** Activation part of the process is in progress */
20
+ activationInProgress = "ACTIVATION_IN_PROGRESS",
21
+ /** Verification part of the process is in progress */
22
+ verificationInProgress = "VERIFICATION_IN_PROGRESS",
23
+ /** Onboarding process has failed */
24
+ failed = "FAILED",
25
+ /** Onboarding process is completed */
26
+ finished = "FINISHED"
27
+ }
28
+ interface WDOIdentityStatusResponse {
29
+ processId: string;
30
+ identityVerificationStatus: WDOIdentityVerificationStatus;
31
+ identityVerificationPhase?: WDOIdentityVerificationPhase;
32
+ config: WDOIdentityConfig;
33
+ consentRequired: boolean;
34
+ }
35
+ /** Configuration for identity verification */
36
+ interface WDOIdentityConfig {
37
+ /** Period after which the OTP can be resent, in seconds */
38
+ otpResendPeriodSeconds: number;
39
+ }
40
+ /** Status of the current identity verification */
41
+ declare enum WDOIdentityVerificationStatus {
42
+ /** Identity verification is waiting for initialization */
43
+ notInitialized = "NOT_INITIALIZED",
44
+ /** All submitted documents are waiting for verification */
45
+ verificationPending = "VERIFICATION_PENDING",
46
+ /** Identity verification is in progress */
47
+ inProgress = "IN_PROGRESS",
48
+ /** Identity verification was successfully completed */
49
+ accepted = "ACCEPTED",
50
+ /** Identity verification has failed, an error occurred */
51
+ failed = "FAILED",
52
+ /** Identity verification was rejected */
53
+ rejected = "REJECTED"
54
+ }
55
+ /** Phase of the current identity verification */
56
+ declare enum WDOIdentityVerificationPhase {
57
+ /** Document upload is in progress */
58
+ documentUpload = "DOCUMENT_UPLOAD",
59
+ /** Presence check is in progress */
60
+ presenceCheck = "PRESENCE_CHECK",
61
+ /** Backend is verifying documents */
62
+ clientEvaluation = "CLIENT_EVALUATION",
63
+ /** Document verification is in progress */
64
+ documentVerification = "DOCUMENT_VERIFICATION",
65
+ /** Cross check on documents is in progress */
66
+ documentVerificationFinal = "DOCUMENT_VERIFICATION_FINAL",
67
+ /** OTP verification needed */
68
+ otp = "OTP_VERIFICATION",
69
+ /** Completed */
70
+ completed = "COMPLETED"
71
+ }
72
+ /** Types of available documents */
73
+ declare enum WDODocumentSubmitFileType {
74
+ /** National ID card */
75
+ idCard = "ID_CARD",
76
+ /** Passport */
77
+ passport = "PASSPORT",
78
+ /** Driving license */
79
+ driversLicense = "DRIVING_LICENSE",
80
+ /** Selfie photo */
81
+ selfiePhoto = "SELFIE_PHOTO"
82
+ }
83
+ /** Side of the file */
84
+ declare enum WDODocumentSubmitFileSide {
85
+ /** Front side of an document. Usually the one with the picture */
86
+ front = "FRONT",
87
+ /** Back side of an document */
88
+ back = "BACK"
89
+ }
90
+ /** Submitted document metadata */
91
+ interface WDODocument {
92
+ /** Name of the file (with path within the submit ZIP file). */
93
+ filename: string;
94
+ /** Unique ID of the file */
95
+ id: string;
96
+ /** Type of the file */
97
+ type: WDODocumentSubmitFileType;
98
+ /** Side of the file */
99
+ side: WDODocumentSubmitFileSide;
100
+ /** Status of the processing */
101
+ status: WDODocumentStatus;
102
+ /** Possible errors */
103
+ errors?: string[];
104
+ }
105
+ /** Status of the document */
106
+ declare enum WDODocumentStatus {
107
+ /** Document was accepted */
108
+ accepted = "ACCEPTED",
109
+ /** Document is being uploaded to the verification system by the backend */
110
+ uploadInProgress = "UPLOAD_IN_PROGRESS",
111
+ /** Document are being processed */
112
+ inProgress = "IN_PROGRESS",
113
+ /** Document is pending verification */
114
+ verificationPending = "VERIFICATION_PENDING",
115
+ /** Document is being verified */
116
+ verificationInProgress = "VERIFICATION_IN_PROGRESS",
117
+ /** Document was rejected */
118
+ rejected = "REJECTED",
119
+ /** Verification of the document failed */
120
+ failed = "FAILED"
121
+ }
122
+ /** Metadata for file inside ZIP (in `DocumentSubmitRequest.data`). */
123
+ interface WDODocumentSubmitFile {
124
+ /** Name of the file (with path) */
125
+ filename: string;
126
+ /** Type of the document */
127
+ type: WDODocumentSubmitFileType;
128
+ /** Side of the document (for example front side of the ID card) */
129
+ side: WDODocumentSubmitFileSide;
130
+ /** Original document ID in case of re-upload */
131
+ originalDocumentId?: string;
132
+ /** Base64 encoded data image. */
133
+ data: Base64URLString;
134
+ }
135
+ /** Status of the documents */
136
+ interface WDODocumentStatusResponse {
137
+ /** Overall status */
138
+ status: WDODocumentStatus;
139
+ /** Status for each document. */
140
+ documents: WDODocument[];
141
+ }
142
+ /** Response of the OTP verify */
143
+ interface WDOVerifyOTPResponse {
144
+ /** ID of the process */
145
+ processId: string;
146
+ /** Current onboarding status */
147
+ onboardingStatus: WDOOnboardingStatus;
148
+ /** Was OTP verified? */
149
+ verified: boolean;
150
+ /** Is OTP expired */
151
+ expired: boolean;
152
+ /** How many attempts are remaining */
153
+ remainingAttempts: number;
154
+ }
155
+ /** Configuration for a document */
156
+ interface WDOConfigurationDocument {
157
+ /** Type of the document */
158
+ type: string;
159
+ /** Is the document mandatory */
160
+ mandatory: boolean;
161
+ /** Number of sides the document has */
162
+ sideCount: number;
163
+ }
164
+ /** Configuration for the onboarding process */
165
+ interface WDOConfigurationResponse {
166
+ /** Is the onboarding process enabled */
167
+ enabled: boolean;
168
+ /** Is OTP required for the first part - identification/activation. */
169
+ otpForIdentification: boolean;
170
+ /** Is OTP required for the second part - identity verification. */
171
+ otpForIdentityVerification: boolean;
172
+ /** Documents required for identity verification. */
173
+ documents: {
174
+ /** Number of required documents */
175
+ requiredDocumentsCount: number;
176
+ /** List of documents */
177
+ items: Array<WDOConfigurationDocument>;
178
+ };
179
+ }
180
+
181
+ /** Duck-typed PowerAuthActivationResult for WDO space */
182
+ interface WDOPowerAuthActivationResult {
183
+ /** Decimalized fingerprint calculated from device's and server's public keys. */
184
+ activationFingerprint: string;
185
+ /** When available, contents of this object depends of your enrollment server configuration. */
186
+ customAttributes?: any;
187
+ }
188
+ /**
189
+ * Service that can activate PowerAuth instance by user weak credentials (like his email, phone number or client ID) + optional SMS OTP.
190
+ *
191
+ * When the PowerAuth is activated with this service, `WDOVerificationService.isVerificationRequired` will be `true`
192
+ * and you will need to verify the PowerAuth instance via `WDOVerificationService`.
193
+ *
194
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
195
+ */
196
+ declare abstract class WDOBaseActivationService {
197
+ /**
198
+ * If the activation process is in progress.
199
+ *
200
+ * Note that even if this property is `true` it can be already discontinued on the server.
201
+ * Calling `status()` for example after the app is launched in this case is recommended.
202
+ */
203
+ hasActiveProcess(): Promise<boolean>;
204
+ /**
205
+ * Accept language for the outgoing requests headers.
206
+ * Default value is "en".
207
+ *
208
+ * Standard RFC "Accept-Language" https://tools.ietf.org/html/rfc7231#section-5.3.5
209
+ * Response texts are based on this setting. For example when "de" is set, server
210
+ * will return error texts and other in german (if available).
211
+ */
212
+ changeAcceptLanguage(language: string): void;
213
+ /**
214
+ * Retrieves status of the onboarding activation.
215
+ *
216
+ * @return Promise resolved with onboarding status.
217
+ */
218
+ status(): Promise<WDOOnboardingStatus>;
219
+ /**
220
+ * Start onboarding activation with user credentials.
221
+ *
222
+ * For example, when you require email and birth date, your object would look like this:
223
+ * ```
224
+ * {
225
+ * email: "<user_email>",
226
+ * birthdate: "<user_birth_date>"
227
+ * }
228
+ * ```
229
+ * @param credentials Object with credentials. Which credentials are needed should be provided by a system/backend provider.
230
+ * @param processType The process type identification. If not specified, the default process type will be used.
231
+ */
232
+ start(credentials: any, processType?: string): Promise<void>;
233
+ /**
234
+ * Cancel the activation process (issues a cancel request to the backend and clears the local process ID).
235
+ *
236
+ * @param forceCancel When true, the process will be canceled in the SDK even when fails on backend. `true` by default.
237
+ */
238
+ cancel(forceCancel?: boolean): Promise<void>;
239
+ /** Clear the stored data (without networking call). */
240
+ clear(): Promise<void>;
241
+ /**
242
+ * OTP resend request.
243
+ *
244
+ * This is intended to be displayed for the user to use in case of the OTP is not received.
245
+ * For example, when the user does not receive SMS after some time, there should be a button to "send again".
246
+ */
247
+ resendOTP(): Promise<void>;
248
+ /**
249
+ * Activate the PowerAuth instance that was passed in the initializer.
250
+ *
251
+ * @param activationName Name of the activation. Usually something like John's iPhone or similar.
252
+ * @param otp OTP code received by the user (via SMS or email). Optional when not required.
253
+ * @return Promise resolved with activation result.
254
+ */
255
+ activate(activationName: string, otp?: string): Promise<WDOPowerAuthActivationResult>;
256
+ }
257
+
258
+ /**
259
+ * Service that can activate PowerAuth instance by user weak credentials (like his email, phone number or client ID) + optional SMS OTP.
260
+ *
261
+ * When the PowerAuth is activated with this service, `WDOVerificationService.isVerificationRequired` will be `true`
262
+ * and you will need to verify the PowerAuth instance via `WDOVerificationService`.
263
+ *
264
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
265
+ */
266
+ declare class WDOActivationService extends WDOBaseActivationService {
267
+ /** PowerAuth instance */
268
+ readonly powerauth: PowerAuth;
269
+ /**
270
+ * Creates service instance
271
+ *
272
+ * @param powerauth Configured PowerAuth instance. This instance needs to be without valid activation.
273
+ * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
274
+ */
275
+ constructor(powerauth: PowerAuth, baseUrl: string);
276
+ }
277
+
278
+ /** String that contains a Base64 encoded JPEG image */
279
+ type Base64EncodedJPEG = string;
280
+ /** Image of a document that can be sent to the backend for Identity Verification. */
281
+ declare class WDODocumentFile {
282
+ /** Raw data to upload. Make sure that the data aren't too big, hundreds of kbs should be enough. */
283
+ data: Base64EncodedJPEG;
284
+ /**
285
+ * Image signature.
286
+ *
287
+ * Optional, use only when the scan SDK supports this.
288
+ */
289
+ dataSignature: string | undefined;
290
+ /** Type of the document. */
291
+ type: WDODocumentType;
292
+ /** Side of the document (`front` if the document is one-sided or only one side is expected). */
293
+ side: WDODocumentSide;
294
+ /**
295
+ * For image reuploading when the previous file of the same document was rejected.
296
+ *
297
+ * Without specifying this value, the document side won't be overwritten.
298
+ */
299
+ originalDocumentId: string | undefined;
300
+ /**
301
+ * Create the document file from an image that can be sent to the backend for Identity Verification.
302
+ *
303
+ * @param scannedDocument Document to upload.
304
+ * @param side The side of the document that the image captures.
305
+ * @param data Raw image data. Make sure that the data aren't too big, hundreds of kbs should be enough.
306
+ * @param dataSignature Signature of the image data. Optional, use only when the scan SDK supports this. `undefined` by default.
307
+ * @returns Document file to upload.
308
+ */
309
+ static fromScannedDocument(scannedDocument: WDOScannedDocument, side: WDODocumentSide, data: Base64EncodedJPEG, dataSignature?: string): WDODocumentFile;
310
+ /**
311
+ * Image of a document that can be sent to the backend for Identity Verification.
312
+ *
313
+ * @param data Raw image data. Make sure that the data aren't too big, hundreds of kbs should be enough.
314
+ * @param type Type of the document.
315
+ * @param side The side of the document that the image captures.
316
+ * @param originalDocumentId Original document ID In case of a reupload. If you've previously uploaded this type and side and won't specify the previous ID, the image won't be overwritten.
317
+ * @param dataSignature Signature of the image data. Optional, use only when the scan SDK supports this. `undefined` by default.
318
+ */
319
+ constructor(data: Base64EncodedJPEG, type: WDODocumentType, side: WDODocumentSide, originalDocumentId?: string, dataSignature?: string);
320
+ }
321
+ /** Type of the document. */
322
+ declare enum WDODocumentType {
323
+ /** National ID card */
324
+ idCard = "idCard",
325
+ /** Passport */
326
+ passport = "passport",
327
+ /** Drivers license */
328
+ driversLicense = "driversLicense"
329
+ }
330
+ /**
331
+ * Available sides of the document
332
+ *
333
+ * Front and back for ID card.
334
+ * For passport and drivers license front only.
335
+ */
336
+ declare function WDODocumentTypeSides(type: WDODocumentType): WDODocumentSide[];
337
+ /** Side of the document */
338
+ declare enum WDODocumentSide {
339
+ /** Front side of a document. Usually the one with the picture.
340
+ *
341
+ * When a document has more than one side but only one side is used (for example passport), then such side is considered to be front.
342
+ */
343
+ front = "front",
344
+ /** Back side of a document */
345
+ back = "back"
346
+ }
347
+ /** Converts WDODocumentType to WDODocumentSubmitFileType */
348
+ declare function WDODocumentTypeToSubmitType(type: WDODocumentType): WDODocumentSubmitFileType;
349
+ /** Converts WDODocumentSide to DocumentSubmitFileSide */
350
+ declare function WDOCreateDocumentSubmitFileSide(side: WDODocumentSide): WDODocumentSubmitFileSide;
351
+
352
+ /** Describes the state of documents that need to be uploaded to the server. */
353
+ declare class WDOVerificationScanProcess {
354
+ /** All documents that need to be scanned. */
355
+ documents: WDOScannedDocument[];
356
+ /** Which document should be scanned next. `undefined` when all documents are uploaded and accepted. */
357
+ get nextDocumentToScan(): WDOScannedDocument | undefined;
358
+ }
359
+ /** Document that needs to be scanned during process. */
360
+ declare class WDOScannedDocument {
361
+ /** Type of the document. */
362
+ type: WDODocumentType;
363
+ /** Upload state. */
364
+ get uploadState(): UploadState;
365
+ /** Sides of the document that were uploaded on the server. */
366
+ get sides(): Side[];
367
+ }
368
+ /** State of the document on the server. */
369
+ declare enum UploadState {
370
+ /** The document was not uploaded yet. */
371
+ notUploaded = 0,
372
+ /** The document was accepted by the server. */
373
+ accepted = 1,
374
+ /** The document was rejected and needs to be re-uploaded. */
375
+ rejected = 2
376
+ }
377
+ /** Side of the uploaded document. */
378
+ declare class Side {
379
+ /** Type of the side. */
380
+ type: WDODocumentSide;
381
+ /** ID on the server. Use this ID in case of an reupload */
382
+ serverId: string;
383
+ /** Upload state of the document */
384
+ uploadState: UploadState;
385
+ }
386
+
387
+ /**
388
+ * State which should be presented to the user.
389
+ * Each state represents a separate screen UI that should be presented to the user.
390
+ *
391
+ * This type is an "tagged union" type, where each interface has a `type` property
392
+ * that uniquely identifies the state type.
393
+ *
394
+ * Usage:
395
+ *
396
+ * ```
397
+ * const state = await verificationService.status();
398
+ * if (state.type === WDOVerificationStateType.scanDocument ) {
399
+ * // We are in the scan document state, access specific properties
400
+ * const process = state.process;
401
+ * }
402
+ * ```
403
+ */
404
+ type WDOVerificationState = WDOIntroState | WDODocumentsToScanSelectState | WDOScanDocumentState | WDOProcessingState | WDOPresenceCheckState | WDOOtpState | WDOFailedState | WDOEndStateState | WDOSuccessState;
405
+ /**
406
+ * Show the verification introduction screen where the user can start the activation.
407
+ *
408
+ * The next step should be calling the `start`.
409
+ */
410
+ interface WDOIntroState {
411
+ type: WDOVerificationStateType.intro;
412
+ /** Indicates whether the user consent is required to proceed */
413
+ consentRequired: boolean;
414
+ }
415
+ /**
416
+ * Show document selection to the user. Which documents are available and how many
417
+ * can the user select is up to your backend configuration.
418
+ *
419
+ * The next step should be calling the `documentsSetSelectedTypes`.
420
+ */
421
+ interface WDODocumentsToScanSelectState {
422
+ type: WDOVerificationStateType.documentsToScanSelect;
423
+ }
424
+ /**
425
+ * User should scan documents - display UI for the user to scan all necessary documents.
426
+ *
427
+ * The next step should be calling the `documentsSubmit`.
428
+ */
429
+ interface WDOScanDocumentState {
430
+ type: WDOVerificationStateType.scanDocument;
431
+ /** Scanning process that helps with the document scanning */
432
+ process: WDOVerificationScanProcess;
433
+ }
434
+ /**
435
+ * The system is processing data - show loading with text hint from provided `WDOStatusCheckReason`.
436
+ *
437
+ * The next step should be calling the `status`.
438
+ */
439
+ interface WDOProcessingState {
440
+ type: WDOVerificationStateType.processing;
441
+ /** Reason for the current processing state */
442
+ item: WDOStatusCheckReason;
443
+ }
444
+ /**
445
+ * The user should be presented with a presence check.
446
+ * Presence check is handled by third-party SDK based on the project setup.
447
+ *
448
+ * The next step should be calling the `presenceCheckInit` to start the check and `presenceCheckSubmit` to
449
+ * mark it finished. Note that these methods won't change the status and it's up to the app to handle the process of the presence check.
450
+ */
451
+ interface WDOPresenceCheckState {
452
+ type: WDOVerificationStateType.presenceCheck;
453
+ }
454
+ /**
455
+ * Show enter OTP screen with resend button.
456
+ *
457
+ * The next step should be calling the `verifyOTP` with user-entered OTP.
458
+ * The OTP is usually SMS or email.
459
+ */
460
+ interface WDOOtpState {
461
+ type: WDOVerificationStateType.otp;
462
+ /** Number of remaining attempts to enter the correct OTP */
463
+ remainingAttempts?: number;
464
+ }
465
+ /**
466
+ * Verification failed and can be restarted
467
+ *
468
+ * The next step should be calling the `restartVerification` or `cancelWholeProcess` based on
469
+ * the user's decision if he wants to try it again or cancel the process.
470
+ */
471
+ interface WDOFailedState {
472
+ type: WDOVerificationStateType.failed;
473
+ }
474
+ /**
475
+ * Verification is canceled and the user needs to start again with a new PowerAuth activation.
476
+ *
477
+ * The next step should be calling the `PowerAuth.removeActivationLocal()` and starting activation from scratch.
478
+ */
479
+ interface WDOEndStateState {
480
+ type: WDOVerificationStateType.endState;
481
+ /** Reason for the end state */
482
+ reason: WDOEndStateReason;
483
+ }
484
+ /**
485
+ * Verification was successfully ended. Continue into your app flow.
486
+ */
487
+ interface WDOSuccessState {
488
+ type: WDOVerificationStateType.success;
489
+ }
490
+ /** Types of the verification state */
491
+ declare enum WDOVerificationStateType {
492
+ /**
493
+ * Show the verification introduction screen where the user can start the activation.
494
+ *
495
+ * The next step should be calling the `start()`.
496
+ */
497
+ intro = "intro",
498
+ /**
499
+ * Show document selection to the user. Which documents are available and how many
500
+ * can the user select is up to your backend configuration.
501
+ *
502
+ * The next step should be calling the `documentsSetSelectedTypes`.
503
+ */
504
+ documentsToScanSelect = "documentsToScanSelect",
505
+ /**
506
+ * User should scan documents - display UI for the user to scan all necessary documents.
507
+ *
508
+ * The next step should be calling the `documentsSubmit`.
509
+ */
510
+ scanDocument = "scanDocument",
511
+ /**
512
+ * The system is processing data - show loading with text hint from provided `WDOStatusCheckReason`.
513
+ *
514
+ * The next step should be calling the `status`.
515
+ */
516
+ processing = "processing",
517
+ /**
518
+ * The user should be presented with a presence check.
519
+ * Presence check is handled by third-party SDK based on the project setup.
520
+ *
521
+ * The next step should be calling the `presenceCheckInit` to start the check and `presenceCheckSubmit` to
522
+ * mark it finished. Note that these methods won't change the status and it's up to the app to handle the process of the presence check.
523
+ */
524
+ presenceCheck = "presenceCheck",
525
+ /**
526
+ * Show enter OTP screen with resend button.
527
+ *
528
+ * The next step should be calling the `verifyOTP` with user-entered OTP.
529
+ * The OTP is usually SMS or email.
530
+ */
531
+ otp = "otp",
532
+ /**
533
+ * Verification failed and can be restarted
534
+ *
535
+ * The next step should be calling the `restartVerification` or `cancelWholeProcess` based on
536
+ * the user's decision if he wants to try it again or cancel the process.
537
+ */
538
+ failed = "failed",
539
+ /**
540
+ * Verification is canceled and the user needs to start again with a new PowerAuth activation.
541
+ *
542
+ * The next step should be calling the `PowerAuth.removeActivationLocal()` and starting activation from scratch.
543
+ */
544
+ endState = "endState",
545
+ /**
546
+ * Verification was successfully ended. Continue into your app flow.
547
+ */
548
+ success = "success"
549
+ }
550
+ /** The reason why the process ended in a non-recoverable state. */
551
+ declare enum WDOEndStateReason {
552
+ /**
553
+ * The verification was rejected by the system
554
+ *
555
+ * eg: Fake information, fraud detection, or user is trying repeatedly in a short time.
556
+ * The real reason is not presented to the user and is only audited on the server.
557
+ */
558
+ rejected = "rejected",
559
+ /**
560
+ * The limit of repeat tries was reached. There is a fixed number of tries that the user can reach
561
+ * before the system stops the process.
562
+ */
563
+ limitReached = "limitReached",
564
+ /** An unknown reason. */
565
+ other = "other"
566
+ }
567
+ /**
568
+ * The reason for what we are waiting for. For example, we can wait for documents to be OCRed and matched against the database.
569
+ * Use these values for better loading texts to tell the user what is happening - some tasks may take some time
570
+ * and it would be frustrating to just show a generic loading indicator.
571
+ */
572
+ declare enum WDOStatusCheckReason {
573
+ unknown = "unknown",
574
+ documentUpload = "documentUpload",
575
+ documentVerification = "documentVerification",
576
+ documentAccepted = "documentAccepted",
577
+ documentsCrossVerification = "documentsCrossVerification",
578
+ clientVerification = "clientVerification",
579
+ clientAccepted = "clientAccepted",
580
+ verifyingPresence = "verifyingPresence"
581
+ }
582
+
583
+ /**
584
+ * ######################################
585
+ * This file contains duck-typed representation of PowerAuthActivationStatus
586
+ * to avoid direct dependency on PowerAuth types in the shared library.
587
+ * ######################################
588
+ */
589
+ /**
590
+ * The `WDOPowerAuthActivationStatus` object represents complete status of the activation.
591
+ */
592
+ interface WDOPowerAuthActivationStatus {
593
+ /**
594
+ * State of the activation.
595
+ */
596
+ state: WDOPowerAuthActivationState;
597
+ /**
598
+ * Number of failed authentication attempts in a row.
599
+ */
600
+ failCount: number;
601
+ /**
602
+ * Maximum number of allowed failed authentication attempts in a row.
603
+ */
604
+ maxFailCount: number;
605
+ /**
606
+ * Contains `(maxFailCount - failCount)` if state is `ACTIVE`, otherwise 0.
607
+ */
608
+ remainingAttempts: number;
609
+ /**
610
+ * Contains custom object returned from the server. The value is optional and PowerAuth Application Server must support this custom object.
611
+ */
612
+ customObject?: any;
613
+ }
614
+ /**
615
+ * The `WDOPowerAuthActivationState` enum defines all possible states of activation.
616
+ * The state is a part of information received together with the rest
617
+ * of the `WDOPowerAuthActivationStatus` object.
618
+ */
619
+ declare enum WDOPowerAuthActivationState {
620
+ /**
621
+ * The activation is just created.
622
+ */
623
+ CREATED = "CREATED",
624
+ /**
625
+ * The activation is not completed yet on the server.
626
+ */
627
+ PENDING_COMMIT = "PENDING_COMMIT",
628
+ /**
629
+ * The shared secure context is valid and active.
630
+ */
631
+ ACTIVE = "ACTIVE",
632
+ /**
633
+ * The activation is blocked.
634
+ */
635
+ BLOCKED = "BLOCKED",
636
+ /**
637
+ * The activation doesn't exist anymore.
638
+ */
639
+ REMOVED = "REMOVED",
640
+ /**
641
+ * The activation is technically blocked. You cannot use it anymore
642
+ * for the signature calculations.
643
+ */
644
+ DEADLOCK = "DEADLOCK"
645
+ }
646
+
647
+ /**
648
+ * Listener of the Verification Service that can listen on Verification Status and PowerAuth Status changes.
649
+ */
650
+ interface WDOVerificationServiceListener {
651
+ /**
652
+ * Called when PowerAuth activation status changed.
653
+ *
654
+ * Note that this happens only when error is returned in some of the Verification endpoints and this error indicates PowerAuth status change. For
655
+ * example when the service finds out during the API call that the PowerAuth activation was removed or blocked on the server
656
+ */
657
+ powerAuthActivationStatusChanged(sender: WDOBaseVerificationService, status: WDOPowerAuthActivationStatus): void;
658
+ /** Called when state of the verification has changed. */
659
+ verificationStatusChanged(sender: WDOBaseVerificationService, status: WDOVerificationState): void;
660
+ }
661
+ /** Possible results of the user consent. */
662
+ declare enum WDOConsentResponse {
663
+ /** User approved the consent. */
664
+ approved = 0,
665
+ /** User declined the consent. */
666
+ declined = 1,
667
+ /** Consent is not required. */
668
+ notRequired = 2
669
+ }
670
+ /**
671
+ * Service that can verify previously activated PowerAuth instance.
672
+ *
673
+ * When PowerAuth instance was activated with weak credentials via `WDOActivationService`, user needs to verify his genuine presence.
674
+ * This can be confirmed in the `WDOVerificationService.isVerificationRequired` which will be `true`.
675
+ *
676
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
677
+ */
678
+ declare abstract class WDOBaseVerificationService {
679
+ /**
680
+ * Accept language for the outgoing requests headers.
681
+ * Default value is "en".
682
+ *
683
+ * Standard RFC "Accept-Language" https://tools.ietf.org/html/rfc7231#section-5.3.5
684
+ * Response texts are based on this setting. For example when "de" is set, server
685
+ * will return error texts and other in german (if available).
686
+ */
687
+ changeAcceptLanguage(language: string): void;
688
+ /** Time in seconds that user needs to wait between OTP resend calls */
689
+ get otpResendPeriodSeconds(): number | undefined;
690
+ /**
691
+ * Listener that retrieves information about the verification and activation changes.
692
+ */
693
+ listener?: WDOVerificationServiceListener;
694
+ /**
695
+ * Status of the verification.
696
+ */
697
+ status(): Promise<WDOVerificationState>;
698
+ /**
699
+ * Returns consent text for user to approve. The content of the text depends on the server configuration and might be plain text or HTML.
700
+ *
701
+ * Consent text explains how the service will handle his document photos or selfie scans.
702
+ */
703
+ consentGet(): Promise<string>;
704
+ /**
705
+ * Start the identity verification after user approved the consent (if required)
706
+ *
707
+ * @param consentApprovedByUser Response of the user to the consent. The hint can be obtained in the `status()` call (`consentRequired` property when the result is `intro`).
708
+ */
709
+ start(consentApprovedByUser: WDOConsentResponse): Promise<WDOVerificationState>;
710
+ /**
711
+ * Get the token for the document scanning SDK, when required.
712
+ *
713
+ * This is needed for example for ZenID or BlinkID provider.
714
+ *
715
+ * @param challenge Optional challenge provided by the scanning SDK.
716
+ */
717
+ documentsInitSDK(challenge?: string): Promise<{
718
+ blinkIDKey?: string;
719
+ zenIDToken?: string;
720
+ }>;
721
+ /**
722
+ * Set which documents will be scanned.
723
+ *
724
+ * Note that this needs to be in sync what server expects based on the configuration.
725
+ *
726
+ * @param types Types of documents to scan.
727
+ */
728
+ documentsSetSelectedTypes(types: WDODocumentType[]): Promise<WDOVerificationState>;
729
+ /**
730
+ * Upload document files to the server. The order of the documents is up to you.
731
+ * Make sure that uploaded document are reasonable size so you're not uploading large files.
732
+ *
733
+ * If you're uploading the same document file again, you need to include the `originalDocumentId` otherwise it will be rejected by the server.
734
+ *
735
+ * @param files Document files to upload.
736
+ */
737
+ documentsSubmit(files: WDODocumentFile[]): Promise<WDOVerificationState>;
738
+ /**
739
+ * Initiates the presence check. This returns attributes that are needed to start the 3rd party SDK (if needed).
740
+ */
741
+ presenceCheckInit(): Promise<{
742
+ iProovVerificationToken?: string;
743
+ }>;
744
+ /**
745
+ * Call when presence check was finished in the 3rd party SDK.
746
+ */
747
+ presenceCheckSubmit(): Promise<WDOVerificationState>;
748
+ /**
749
+ * Verification restart. When sucessfully called, intro screen should be presented.
750
+ */
751
+ restartVerification(): Promise<WDOVerificationState>;
752
+ /**
753
+ * Cancel the whole activation/verification. After this it's no longer possible to call
754
+ * any API of this library and PowerAuth activation should be removed and activation started again.
755
+ */
756
+ cancelWholeProcess(): Promise<void>;
757
+ /**
758
+ * Verify OTP that user entered as a last step of the verification.
759
+ *
760
+ * @param otp OTP that user obtained via other channel (usually SMS or email).
761
+ */
762
+ verifyOTP(otp: string): Promise<WDOVerificationState>;
763
+ /**
764
+ * Request OTP resend.
765
+ *
766
+ * Since SMS or emails can fail to deliver, use this to send the OTP again.
767
+ */
768
+ resendOTP(): Promise<void>;
769
+ }
770
+
771
+ /**
772
+ * Service that can verify previously activated PowerAuth instance.
773
+ *
774
+ * When PowerAuth instance was activated with weak credentials via `WDOActivationService`, user needs to verify his genuine presence.
775
+ *
776
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
777
+ */
778
+ declare class WDOVerificationService extends WDOBaseVerificationService {
779
+ /** PowerAuth instance */
780
+ readonly powerauth: PowerAuth;
781
+ /** Checks if verification is required based on PowerAuth activation status */
782
+ static isVerificationRequired(paStatus: PowerAuthActivationStatus): boolean;
783
+ /**
784
+ * Creates service instance
785
+ *
786
+ * @param powerauth Configured PowerAuth instance. This instance needs to be without valid activation.
787
+ * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
788
+ */
789
+ constructor(powerauth: PowerAuth, baseUrl: string);
790
+ }
791
+
792
+ /** Service that provides configuration for the Wultra Digital Onboarding SDK. */
793
+ declare abstract class WDOBaseConfigurationService {
794
+ /**
795
+ * Fetches configuration for the given process type from the server.
796
+ *
797
+ * @param processType Type of the process for which to fetch configuration.
798
+ * @returns Configuration response from the server.
799
+ */
800
+ getConfiguration(processType: string): Promise<WDOConfigurationResponse>;
801
+ }
802
+
803
+ /** Service that provides configuration for the Wultra Digital Onboarding SDK. */
804
+ declare class WDOConfigurationService extends WDOBaseConfigurationService {
805
+ /** PowerAuth instance */
806
+ readonly powerauth: PowerAuth;
807
+ /**
808
+ * Creates service instance
809
+ *
810
+ * @param powerauth Configured PowerAuth instance.
811
+ * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
812
+ */
813
+ constructor(powerauth: PowerAuth, baseUrl: string);
814
+ }
815
+
816
+ /** Log levels for Wultra Digital Onboarding. */
817
+ declare enum WDOLogLevel {
818
+ NONE = 0,
819
+ ERROR = 1,
820
+ WARN = 2,
821
+ INFO = 3,
822
+ DEBUG = 4
823
+ }
824
+ /** Simple logger utility for Wultra Digital Onboarding SDK. */
825
+ declare class WDOLogger {
826
+ /** Current log level. Messages with a level higher than this will not be logged. */
827
+ static logLevel: WDOLogLevel;
828
+ /** Listener for custom logging implementation */
829
+ static listener: WDOLoggerListener | null;
830
+ }
831
+ /** Log listener for your custom logging implementation */
832
+ interface WDOLoggerListener {
833
+ log(level: WDOLogLevel, message: string): void;
834
+ }
835
+
836
+ /** Represent error thrown from a WDO library */
837
+ declare class WDOError {
838
+ /** Reason for the error */
839
+ readonly reason: WDOErrorReason;
840
+ /** Error message */
841
+ readonly message: string;
842
+ /** Additional info about the error (eg. original error object) */
843
+ readonly additionalInfo?: any;
844
+ /** Helper to identify this object as a WDOError */
845
+ readonly isWdoError = true;
846
+ /**
847
+ * Whether retrying OTP is allowed based on remaining attempts.
848
+ *
849
+ * This may be filled only when the error reason is `WDOErrorReason.activationFailed`.
850
+ */
851
+ get allowOnboardingOtpRetry(): boolean;
852
+ /**
853
+ * Number of remaining OTP attempts during onboarding
854
+ *
855
+ * This may be filled only when the error reason is `WDOErrorReason.activationFailed`.
856
+ */
857
+ get onboardingOtpRemainingAttempts(): number | undefined;
858
+ }
859
+ /** Reasons for WDO errors */
860
+ declare enum WDOErrorReason {
861
+ /** Network error occurred */
862
+ networkError = "NETWORK_ERROR",
863
+ /** Activation failed */
864
+ activationFailed = "ACTIVATION_FAILED",
865
+ /** Process is already in progress - happens when start() is called twice */
866
+ processAlreadyInProgress = "PROCESS_ALREADY_IN_PROGRESS",
867
+ /** No process is in progress - happens when an operation requires an active process */
868
+ processNotInProgress = "PROCESS_NOT_IN_PROGRESS",
869
+ /** The PowerAuth instance is already activated when trying to activate it again */
870
+ powerauthAlreadyActivated = "POWERAUTH_ALREADY_ACTIVATED",
871
+ /** The PowerAuth instance is not activated when trying to use it */
872
+ powerauthNotActivated = "POWERAUTH_NOT_ACTIVATED",
873
+ /** OTP verification failed */
874
+ otpFailed = "OTP_FAILED"
875
+ }
876
+ export { Side, UploadState, WDOActivationService, WDOConfigurationService, WDOConsentResponse, WDOCreateDocumentSubmitFileSide, WDODocumentFile, WDODocumentSide, WDODocumentStatus, WDODocumentSubmitFileSide, WDODocumentSubmitFileType, WDODocumentType, WDODocumentTypeSides, WDODocumentTypeToSubmitType, WDOEndStateReason, WDOError, WDOErrorReason, WDOIdentityVerificationPhase, WDOIdentityVerificationStatus, WDOLogLevel, WDOLogger, WDOOnboardingStatus, WDOScannedDocument, WDOStatusCheckReason, WDOVerificationScanProcess, WDOVerificationService, WDOVerificationStateType };
877
+ export type { Base64EncodedJPEG, WDOConfigurationDocument, WDOConfigurationResponse, WDODocument, WDODocumentStatusResponse, WDODocumentSubmitFile, WDODocumentsToScanSelectState, WDOEndStateState, WDOFailedState, WDOIdentityConfig, WDOIdentityStatusResponse, WDOIntroState, WDOLoggerListener, WDOOtpState, WDOPresenceCheckState, WDOProcessRequest, WDOProcessResponse, WDOProcessingState, WDOScanDocumentState, WDOSuccessState, WDOVerificationServiceListener, WDOVerificationState, WDOVerifyOTPResponse };