cordova-digital-onboarding 1.1.0 → 1.2.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 CHANGED
@@ -1,280 +1,3 @@
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
1
  /** String that contains a Base64 encoded JPEG image */
279
2
  type Base64EncodedJPEG = string;
280
3
  /** Image of a document that can be sent to the backend for Identity Verification. */
@@ -327,13 +50,6 @@ declare enum WDODocumentType {
327
50
  /** Drivers license */
328
51
  driversLicense = "driversLicense"
329
52
  }
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
53
  /** Side of the document */
338
54
  declare enum WDODocumentSide {
339
55
  /** Front side of a document. Usually the one with the picture.
@@ -344,10 +60,6 @@ declare enum WDODocumentSide {
344
60
  /** Back side of a document */
345
61
  back = "back"
346
62
  }
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
63
 
352
64
  /** Describes the state of documents that need to be uploaded to the server. */
353
65
  declare class WDOVerificationScanProcess {
@@ -394,14 +106,14 @@ declare class Side {
394
106
  * Usage:
395
107
  *
396
108
  * ```
397
- * const state = await verificationService.status();
109
+ * const state = await verificationService.status()
398
110
  * if (state.type === WDOVerificationStateType.scanDocument ) {
399
111
  * // We are in the scan document state, access specific properties
400
- * const process = state.process;
112
+ * const process = state.process
401
113
  * }
402
114
  * ```
403
115
  */
404
- type WDOVerificationState = WDOIntroState | WDODocumentsToScanSelectState | WDOScanDocumentState | WDOProcessingState | WDOPresenceCheckState | WDOOtpState | WDOFailedState | WDOEndStateState | WDOSuccessState;
116
+ type WDOVerificationState = WDOIntroState | WDODocumentsToScanSelectState | WDOScanDocumentState | WDOProcessingState | WDOPresenceCheckState | WDOOtpState | WDOFinishActivation | WDOFailedState | WDOEndStateState | WDOSuccessState;
405
117
  /**
406
118
  * Show the verification introduction screen where the user can start the activation.
407
119
  *
@@ -462,6 +174,14 @@ interface WDOOtpState {
462
174
  /** Number of remaining attempts to enter the correct OTP */
463
175
  remainingAttempts?: number;
464
176
  }
177
+ /**
178
+ * Show "finish activation" with PIN prompt screen.
179
+ *
180
+ * The next step should be calling the `finishActivation` with user entered PIN.
181
+ */
182
+ interface WDOFinishActivation {
183
+ type: WDOVerificationStateType.finishActivation;
184
+ }
465
185
  /**
466
186
  * Verification failed and can be restarted
467
187
  *
@@ -529,6 +249,12 @@ declare enum WDOVerificationStateType {
529
249
  * The OTP is usually SMS or email.
530
250
  */
531
251
  otp = "otp",
252
+ /**
253
+ * Show "finish activation" with PIN prompt screen.
254
+ *
255
+ * The next step should be calling the `finishActivation` with user entered PIN.
256
+ */
257
+ finishActivation = "finishActivation",
532
258
  /**
533
259
  * Verification failed and can be restarted
534
260
  *
@@ -579,21 +305,40 @@ declare enum WDOStatusCheckReason {
579
305
  clientAccepted = "clientAccepted",
580
306
  verifyingPresence = "verifyingPresence"
581
307
  }
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
- */
308
+ /** Internal multiplatform PowerAuth representation */
309
+ interface WDOPowerAuth {
310
+ fetchActivationStatus(): Promise<WDOPowerAuthActivationStatus>;
311
+ validatePassword(password: WDOPowerAuthPassword | string): Promise<void>;
312
+ createActivation(activation: WDOPowerAuthActivation): Promise<WDOPowerAuthCreateActivationResult>;
313
+ persistActivation(authentication: WDOPowerAuthAuthentication): Promise<void>;
314
+ canStartActivation(): Promise<boolean>;
315
+ removeActivationLocal(): Promise<void>;
316
+ get instanceId(): string;
317
+ }
318
+ /** Internal multiplatform PowerAuthPassword representation */
319
+ interface WDOPowerAuthPassword {
320
+ clear(): Promise<void>;
321
+ }
322
+ /** Internal multiplatform WDOPowerAuthActivation representation */
323
+ interface WDOPowerAuthActivation {
324
+ }
325
+ /** Internal multiplatform WDOPowerAuthAuthentication representation */
326
+ interface WDOPowerAuthAuthentication {
327
+ }
328
+ /** Internal multiplatform WDOPowerAuthCreateActivationResult representation */
329
+ interface WDOPowerAuthCreateActivationResult {
330
+ activationFingerprint: string;
331
+ customAttributes?: any;
332
+ }
589
333
  /**
334
+ *
590
335
  * The `WDOPowerAuthActivationStatus` object represents complete status of the activation.
591
336
  */
592
337
  interface WDOPowerAuthActivationStatus {
593
338
  /**
594
339
  * State of the activation.
595
340
  */
596
- state: WDOPowerAuthActivationState;
341
+ state: "CREATED" | "PENDING_COMMIT" | "ACTIVE" | "BLOCKED" | "REMOVED" | "DEADLOCK";
597
342
  /**
598
343
  * Number of failed authentication attempts in a row.
599
344
  */
@@ -611,38 +356,6 @@ interface WDOPowerAuthActivationStatus {
611
356
  */
612
357
  customObject?: any;
613
358
  }
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
359
 
647
360
  /**
648
361
  * Listener of the Verification Service that can listen on Verification Status and PowerAuth Status changes.
@@ -654,9 +367,9 @@ interface WDOVerificationServiceListener {
654
367
  * Note that this happens only when error is returned in some of the Verification endpoints and this error indicates PowerAuth status change. For
655
368
  * example when the service finds out during the API call that the PowerAuth activation was removed or blocked on the server
656
369
  */
657
- powerAuthActivationStatusChanged(sender: WDOBaseVerificationService, status: WDOPowerAuthActivationStatus): void;
370
+ powerAuthActivationStatusChanged(senderService: any, status: WDOPowerAuthActivationStatus): void;
658
371
  /** Called when state of the verification has changed. */
659
- verificationStatusChanged(sender: WDOBaseVerificationService, status: WDOVerificationState): void;
372
+ verificationStatusChanged(senderService: any, status: WDOVerificationState): void;
660
373
  }
661
374
  /** Possible results of the user consent. */
662
375
  declare enum WDOConsentResponse {
@@ -675,7 +388,19 @@ declare enum WDOConsentResponse {
675
388
  *
676
389
  * 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
390
  */
678
- declare abstract class WDOBaseVerificationService {
391
+ declare abstract class WDOBaseVerificationService<TPowerAuth extends WDOPowerAuth, TPowerAuthPassword extends WDOPowerAuthPassword> {
392
+ /** Checks if verification is required based on PowerAuth activation status */
393
+ protected static isVerificationRequiredInternal(paStatus: WDOPowerAuthActivationStatus): boolean;
394
+ /** PowerAuth instance */
395
+ readonly powerauth: TPowerAuth;
396
+ private readonly api;
397
+ /**
398
+ * Creates service instance
399
+ *
400
+ * @param powerauth Configured PowerAuth instance. This instance needs to be without valid activation.
401
+ * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
402
+ */
403
+ constructor(powerauth: TPowerAuth, baseUrl: string);
679
404
  /**
680
405
  * Accept language for the outgoing requests headers.
681
406
  * Default value is "en".
@@ -761,56 +486,31 @@ declare abstract class WDOBaseVerificationService {
761
486
  */
762
487
  verifyOTP(otp: string): Promise<WDOVerificationState>;
763
488
  /**
764
- * Request OTP resend.
489
+ * Finishes verification by creating a new PowerAuth activation on given `newPowerAuthInstance`.
765
490
  *
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
491
+ * Needs to be called when "activationFinish" next step is returned from the `status()` call.
785
492
  *
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.
493
+ * The method verifies that the provided `password` is the same as used in the original activation
494
+ * (if `validatePassword` is set to `true`), then it calls the server API to finish
495
+ * the verification and obtain the activation code for the new activation. Finally, it creates
496
+ * a new activation on `newPowerAuthInstance` using the obtained activation code and persists it
497
+ * with the provided `newPassword`.
796
498
  *
797
- * @param processType Type of the process for which to fetch configuration.
798
- * @returns Configuration response from the server.
499
+ * After successful completion, the original PowerAuth instance becomes invalid (`REMOVED` state) and cannot be used anymore.
500
+ *
501
+ * @param newPowerAuthInstance PowerAuth instance where to create new activation. This instance must not have an existing activation.
502
+ * @param newActivationName Name of the new activation to be created on `newPowerAuthInstance`.
503
+ * @param newPassword Password to protect the new activation. In case `validatePassword` is `true`, this password must match the password of the original activation and must be reusable (not destroyed on use).
504
+ * @param validatePassword If set to `true`, the method verifies that the provided `newPassword` matches the password of the original activation.
505
+ * @param userIdentification Optional user identification object to be sent to the server during the finish activation process.
799
506
  */
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;
507
+ finishActivation(newPowerAuthInstance: TPowerAuth, newActivationName: string, newPassword: TPowerAuthPassword, validatePassword: boolean, userIdentification?: any): Promise<WDOVerificationState>;
807
508
  /**
808
- * Creates service instance
509
+ * Request OTP resend.
809
510
  *
810
- * @param powerauth Configured PowerAuth instance.
811
- * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
511
+ * Since SMS or emails can fail to deliver, use this to send the OTP again.
812
512
  */
813
- constructor(powerauth: PowerAuth, baseUrl: string);
513
+ resendOTP(): Promise<void>;
814
514
  }
815
515
 
816
516
  /** Log levels for Wultra Digital Onboarding. */
@@ -833,6 +533,48 @@ interface WDOLoggerListener {
833
533
  log(level: WDOLogLevel, message: string): void;
834
534
  }
835
535
 
536
+ /** Status of the onboarding */
537
+ declare enum WDOOnboardingStatus {
538
+ /** Activation part of the process is in progress */
539
+ activationInProgress = "ACTIVATION_IN_PROGRESS",
540
+ /** Verification part of the process is in progress */
541
+ verificationInProgress = "VERIFICATION_IN_PROGRESS",
542
+ /** Onboarding process has failed */
543
+ failed = "FAILED",
544
+ /** Onboarding process is completed */
545
+ finished = "FINISHED"
546
+ }
547
+ /** Configuration for a document */
548
+ interface WDOConfigurationDocument {
549
+ /** Type of the document */
550
+ type: string;
551
+ /** Number of sides the document has */
552
+ sideCount: number;
553
+ }
554
+ /** Group of documents in the configuration */
555
+ interface WDOConfigurationDocumentGroup {
556
+ /** Number of required documents in the group */
557
+ requiredDocumentsCount: number;
558
+ /** Documents in the group */
559
+ items: Array<WDOConfigurationDocument>;
560
+ }
561
+ /** Configuration for the onboarding process */
562
+ interface WDOConfigurationResponse {
563
+ /** Is the onboarding process enabled */
564
+ enabled: boolean;
565
+ /** Is OTP required for the first part - identification/activation. */
566
+ otpForIdentification: boolean;
567
+ /** Is OTP required for the second part - identity verification. */
568
+ otpForIdentityVerification: boolean;
569
+ /** Documents required for identity verification. */
570
+ documents: {
571
+ /** Number of total required documents */
572
+ totalRequiredDocumentsCount: number;
573
+ /** Groups of documents */
574
+ groups: Array<WDOConfigurationDocumentGroup>;
575
+ };
576
+ }
577
+
836
578
  /** Represent error thrown from a WDO library */
837
579
  declare class WDOError {
838
580
  /** Reason for the error */
@@ -868,10 +610,139 @@ declare enum WDOErrorReason {
868
610
  processNotInProgress = "PROCESS_NOT_IN_PROGRESS",
869
611
  /** The PowerAuth instance is already activated when trying to activate it again */
870
612
  powerauthAlreadyActivated = "POWERAUTH_ALREADY_ACTIVATED",
613
+ /** The PowerAuth instance is not configured properly */
614
+ powerAuthNotConfigured = "POWERAUTH_NOT_CONFIGURED",
871
615
  /** The PowerAuth instance is not activated when trying to use it */
872
616
  powerauthNotActivated = "POWERAUTH_NOT_ACTIVATED",
873
617
  /** OTP verification failed */
874
- otpFailed = "OTP_FAILED"
618
+ otpFailed = "OTP_FAILED",
619
+ /** Invalid parameter */
620
+ invalidParameter = "INVALID_PARAMETER"
621
+ }
622
+
623
+ /**
624
+ * Service that can activate PowerAuth instance by user weak credentials (like his email, phone number or client ID) + optional SMS OTP.
625
+ *
626
+ * When the PowerAuth is activated with this service, `WDOVerificationService.isVerificationRequired` will be `true`
627
+ * and you will need to verify the PowerAuth instance via `WDOVerificationService`.
628
+ *
629
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
630
+ */
631
+ declare abstract class WDOBaseActivationService<TPowerAuth extends WDOPowerAuth> {
632
+ /** PowerAuth instance */
633
+ readonly powerauth: TPowerAuth;
634
+ /**
635
+ * Creates service instance
636
+ *
637
+ * @param powerauth Configured PowerAuth instance. This instance needs to be without valid activation.
638
+ * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
639
+ */
640
+ constructor(powerauth: TPowerAuth, baseUrl: string);
641
+ /**
642
+ * If the activation process is in progress.
643
+ *
644
+ * Note that even if this property is `true` it can be already discontinued on the server.
645
+ * Calling `status()` after the app is launched is recommended.
646
+ */
647
+ hasActiveProcess(): Promise<boolean>;
648
+ /**
649
+ * Accept language for the outgoing requests headers.
650
+ * Default value is "en".
651
+ *
652
+ * Standard RFC "Accept-Language" https://tools.ietf.org/html/rfc7231#section-5.3.5
653
+ * Response texts are based on this setting. For example when "de" is set, server
654
+ * will return error texts and other in german (if available).
655
+ */
656
+ changeAcceptLanguage(language: string): void;
657
+ /**
658
+ * Retrieves status of the onboarding activation.
659
+ *
660
+ * @return Promise resolved with onboarding status.
661
+ */
662
+ status(): Promise<WDOOnboardingStatus>;
663
+ /**
664
+ * Start onboarding activation with user credentials.
665
+ *
666
+ * For example, when you require email and birth date, your object would look like this:
667
+ * ```
668
+ * {
669
+ * email: "<user_email>",
670
+ * birthdate: "<user_birth_date>"
671
+ * }
672
+ * ```
673
+ * @param credentials Object with credentials. Which credentials are needed should be provided by a system/backend provider.
674
+ * @param processType The process type identification. If not specified, the default process type will be used.
675
+ */
676
+ start(credentials: any, processType?: string): Promise<void>;
677
+ /**
678
+ * Cancel the activation process (issues a cancel request to the backend and clears the local process ID).
679
+ *
680
+ * @param forceCancel When true, the process will be canceled in the SDK even when fails on backend. `true` by default.
681
+ */
682
+ cancel(forceCancel?: boolean): Promise<void>;
683
+ /** Clear the stored data (without networking call). */
684
+ clear(): Promise<void>;
685
+ /**
686
+ * OTP resend request.
687
+ *
688
+ * This is intended to be displayed for the user to use in case of the OTP is not received.
689
+ * For example, when the user does not receive SMS after some time, there should be a button to "send again".
690
+ * There is a server-side rate limit applied to this operation to prevent abuse; it is good practice to disable the button temporarily while the OTP is being sent.
691
+ */
692
+ resendOTP(): Promise<void>;
693
+ /**
694
+ * Activate the PowerAuth instance that was passed in the initializer.
695
+ *
696
+ * @param activationName Name of the activation. Usually something like John's iPhone or similar.
697
+ * @param otp OTP code received by the user (via SMS or email). Optional when not required.
698
+ * @return Promise resolved with activation result.
699
+ */
700
+ activate(activationName: string, otp?: string): Promise<WDOPowerAuthCreateActivationResult>;
701
+ }
702
+
703
+ /** Service that provides configuration for the Wultra Digital Onboarding SDK. */
704
+ declare abstract class WDOBaseConfigurationService<TPowerAuth extends WDOPowerAuth> {
705
+ /** PowerAuth instance */
706
+ readonly powerauth: TPowerAuth;
707
+ /**
708
+ * Creates service instance
709
+ *
710
+ * @param powerauth Configured PowerAuth instance.
711
+ * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
712
+ */
713
+ constructor(powerauth: TPowerAuth, baseUrl: string);
714
+ /**
715
+ * Fetches configuration for the given process type from the server.
716
+ *
717
+ * @param processType Type of the process for which to fetch configuration.
718
+ * @returns Configuration response from the server.
719
+ */
720
+ getConfiguration(processType: string): Promise<WDOConfigurationResponse>;
721
+ }
722
+
723
+ /**
724
+ * Service that can activate PowerAuth instance by user weak credentials (like his email, phone number or client ID) + optional SMS OTP.
725
+ *
726
+ * When the PowerAuth is activated with this service, `WDOVerificationService.isVerificationRequired` will be `true`
727
+ * and you will need to verify the PowerAuth instance via `WDOVerificationService`.
728
+ *
729
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
730
+ */
731
+ declare class WDOActivationService extends WDOBaseActivationService<PowerAuth> {
732
+ }
733
+ /**
734
+ * Service that can verify previously activated PowerAuth instance.
735
+ *
736
+ * When PowerAuth instance was activated with weak credentials via `WDOActivationService`, user needs to verify his genuine presence.
737
+ *
738
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
739
+ */
740
+ declare class WDOVerificationService extends WDOBaseVerificationService<PowerAuth, PowerAuthPassword> {
741
+ /** Checks if verification is required based on PowerAuth activation status */
742
+ static isVerificationRequired(paStatus: PowerAuthActivationStatus): boolean;
743
+ }
744
+ /** Service that provides configuration for the Wultra Digital Onboarding SDK. */
745
+ declare class WDOConfigurationService extends WDOBaseConfigurationService<PowerAuth> {
875
746
  }
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 };
747
+ export { Side, UploadState, WDOActivationService, WDOConfigurationService, WDOConsentResponse, WDODocumentFile, WDODocumentSide, WDODocumentType, WDOEndStateReason, WDOError, WDOErrorReason, WDOLogLevel, WDOLogger, WDOOnboardingStatus, WDOScannedDocument, WDOStatusCheckReason, WDOVerificationScanProcess, WDOVerificationService, WDOVerificationStateType };
748
+ export type { Base64EncodedJPEG, WDOConfigurationDocument, WDOConfigurationDocumentGroup, WDOConfigurationResponse, WDODocumentsToScanSelectState, WDOEndStateState, WDOFailedState, WDOFinishActivation, WDOIntroState, WDOLoggerListener, WDOOtpState, WDOPresenceCheckState, WDOProcessingState, WDOScanDocumentState, WDOSuccessState, WDOVerificationServiceListener, WDOVerificationState };