cordova-digital-onboarding 1.0.1 → 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.js CHANGED
@@ -74,6 +74,232 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
74
74
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
75
75
  };
76
76
 
77
+ /**
78
+ * Copyright Wultra s.r.o.
79
+ *
80
+ * This source code is licensed under the Apache License, Version 2.0 license
81
+ * found in the LICENSE file in the root directory of this source tree.
82
+ *
83
+ * SPDX-License-Identifier: Apache-2.0
84
+ */
85
+ /** Types of the verification state */
86
+ exports.WDOVerificationStateType = void 0;
87
+ (function (WDOVerificationStateType) {
88
+ /**
89
+ * Show the verification introduction screen where the user can start the activation.
90
+ *
91
+ * The next step should be calling the `start()`.
92
+ */
93
+ WDOVerificationStateType["intro"] = "intro";
94
+ /**
95
+ * Show document selection to the user. Which documents are available and how many
96
+ * can the user select is up to your backend configuration.
97
+ *
98
+ * The next step should be calling the `documentsSetSelectedTypes`.
99
+ */
100
+ WDOVerificationStateType["documentsToScanSelect"] = "documentsToScanSelect";
101
+ /**
102
+ * User should scan documents - display UI for the user to scan all necessary documents.
103
+ *
104
+ * The next step should be calling the `documentsSubmit`.
105
+ */
106
+ WDOVerificationStateType["scanDocument"] = "scanDocument";
107
+ /**
108
+ * The system is processing data - show loading with text hint from provided `WDOStatusCheckReason`.
109
+ *
110
+ * The next step should be calling the `status`.
111
+ */
112
+ WDOVerificationStateType["processing"] = "processing";
113
+ /**
114
+ * The user should be presented with a presence check.
115
+ * Presence check is handled by third-party SDK based on the project setup.
116
+ *
117
+ * The next step should be calling the `presenceCheckInit` to start the check and `presenceCheckSubmit` to
118
+ * 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.
119
+ */
120
+ WDOVerificationStateType["presenceCheck"] = "presenceCheck";
121
+ /**
122
+ * Show enter OTP screen with resend button.
123
+ *
124
+ * The next step should be calling the `verifyOTP` with user-entered OTP.
125
+ * The OTP is usually SMS or email.
126
+ */
127
+ WDOVerificationStateType["otp"] = "otp";
128
+ /**
129
+ * Show "finish activation" with PIN prompt screen.
130
+ *
131
+ * The next step should be calling the `finishActivation` with user entered PIN.
132
+ */
133
+ WDOVerificationStateType["finishActivation"] = "finishActivation";
134
+ /**
135
+ * Verification failed and can be restarted
136
+ *
137
+ * The next step should be calling the `restartVerification` or `cancelWholeProcess` based on
138
+ * the user's decision if he wants to try it again or cancel the process.
139
+ */
140
+ WDOVerificationStateType["failed"] = "failed";
141
+ /**
142
+ * Verification is canceled and the user needs to start again with a new PowerAuth activation.
143
+ *
144
+ * The next step should be calling the `PowerAuth.removeActivationLocal()` and starting activation from scratch.
145
+ */
146
+ WDOVerificationStateType["endState"] = "endState";
147
+ /**
148
+ * Verification was successfully ended. Continue into your app flow.
149
+ */
150
+ WDOVerificationStateType["success"] = "success";
151
+ })(exports.WDOVerificationStateType || (exports.WDOVerificationStateType = {}));
152
+ /** The reason why the process ended in a non-recoverable state. */
153
+ exports.WDOEndStateReason = void 0;
154
+ (function (WDOEndStateReason) {
155
+ /**
156
+ * The verification was rejected by the system
157
+ *
158
+ * eg: Fake information, fraud detection, or user is trying repeatedly in a short time.
159
+ * The real reason is not presented to the user and is only audited on the server.
160
+ */
161
+ WDOEndStateReason["rejected"] = "rejected";
162
+ /**
163
+ * The limit of repeat tries was reached. There is a fixed number of tries that the user can reach
164
+ * before the system stops the process.
165
+ */
166
+ WDOEndStateReason["limitReached"] = "limitReached";
167
+ /** An unknown reason. */
168
+ WDOEndStateReason["other"] = "other";
169
+ })(exports.WDOEndStateReason || (exports.WDOEndStateReason = {}));
170
+ /**
171
+ * The reason for what we are waiting for. For example, we can wait for documents to be OCRed and matched against the database.
172
+ * Use these values for better loading texts to tell the user what is happening - some tasks may take some time
173
+ * and it would be frustrating to just show a generic loading indicator.
174
+ */
175
+ exports.WDOStatusCheckReason = void 0;
176
+ (function (WDOStatusCheckReason) {
177
+ WDOStatusCheckReason["unknown"] = "unknown";
178
+ WDOStatusCheckReason["documentUpload"] = "documentUpload";
179
+ WDOStatusCheckReason["documentVerification"] = "documentVerification";
180
+ WDOStatusCheckReason["documentAccepted"] = "documentAccepted";
181
+ WDOStatusCheckReason["documentsCrossVerification"] = "documentsCrossVerification";
182
+ WDOStatusCheckReason["clientVerification"] = "clientVerification";
183
+ WDOStatusCheckReason["clientAccepted"] = "clientAccepted";
184
+ WDOStatusCheckReason["verifyingPresence"] = "verifyingPresence";
185
+ })(exports.WDOStatusCheckReason || (exports.WDOStatusCheckReason = {}));
186
+
187
+ /**
188
+ * Copyright Wultra s.r.o.
189
+ *
190
+ * This source code is licensed under the Apache License, Version 2.0 license
191
+ * found in the LICENSE file in the root directory of this source tree.
192
+ *
193
+ * SPDX-License-Identifier: Apache-2.0
194
+ */
195
+ var WDOActivationEndpoints = /** @class */ (function () {
196
+ function WDOActivationEndpoints() {
197
+ }
198
+ WDOActivationEndpoints.start = {
199
+ path: "/api/onboarding/start",
200
+ e2eeScope: "APPLICATION",
201
+ returnsData: true
202
+ };
203
+ WDOActivationEndpoints.cancel = {
204
+ path: "/api/onboarding/cleanup",
205
+ e2eeScope: "APPLICATION",
206
+ returnsData: false
207
+ };
208
+ WDOActivationEndpoints.resendOTP = {
209
+ path: "/api/onboarding/otp/resend",
210
+ e2eeScope: "APPLICATION",
211
+ returnsData: false
212
+ };
213
+ WDOActivationEndpoints.getStatus = {
214
+ path: "/api/onboarding/status",
215
+ e2eeScope: "APPLICATION",
216
+ returnsData: true
217
+ };
218
+ return WDOActivationEndpoints;
219
+ }());
220
+ var WDOVerificationEndpoints = /** @class */ (function () {
221
+ function WDOVerificationEndpoints() {
222
+ }
223
+ WDOVerificationEndpoints.getStatus = {
224
+ path: "/api/identity/status",
225
+ e2eeScope: "NONE",
226
+ tokenName: "possession_universal",
227
+ returnsData: true
228
+ };
229
+ WDOVerificationEndpoints.init = {
230
+ path: "/api/identity/init",
231
+ uriId: "/api/identity/init",
232
+ e2eeScope: "NONE",
233
+ returnsData: false
234
+ };
235
+ WDOVerificationEndpoints.cancel = {
236
+ path: "/api/identity/cleanup",
237
+ uriId: "/api/identity/cleanup",
238
+ e2eeScope: "NONE",
239
+ returnsData: false
240
+ };
241
+ WDOVerificationEndpoints.consentText = {
242
+ path: "/api/identity/consent/text",
243
+ tokenName: "possession_universal",
244
+ e2eeScope: "NONE",
245
+ returnsData: true
246
+ };
247
+ WDOVerificationEndpoints.consentApprove = {
248
+ path: "/api/identity/consent/approve",
249
+ uriId: "/api/identity/consent/approve",
250
+ e2eeScope: "NONE",
251
+ returnsData: false
252
+ };
253
+ WDOVerificationEndpoints.documentScanSdkInit = {
254
+ path: "/api/identity/document/init-sdk",
255
+ uriId: "/api/identity/document/init-sdk",
256
+ e2eeScope: "ACTIVATION",
257
+ returnsData: true
258
+ };
259
+ WDOVerificationEndpoints.v2submitDocuments = {
260
+ path: "/api/v2/identity/document/submit",
261
+ tokenName: "possession_universal",
262
+ e2eeScope: "ACTIVATION",
263
+ returnsData: false
264
+ };
265
+ WDOVerificationEndpoints.documentsStatus = {
266
+ path: "/api/identity/document/status",
267
+ tokenName: "possession_universal",
268
+ e2eeScope: "NONE",
269
+ returnsData: true
270
+ };
271
+ WDOVerificationEndpoints.presenceCheckInit = {
272
+ path: "/api/identity/presence-check/init",
273
+ uriId: "/api/identity/presence-check/init",
274
+ e2eeScope: "ACTIVATION",
275
+ returnsData: true
276
+ };
277
+ WDOVerificationEndpoints.presenceCheckSubmit = {
278
+ path: "/api/identity/presence-check/submit",
279
+ uriId: "/api/identity/presence-check/submit",
280
+ e2eeScope: "NONE",
281
+ returnsData: false
282
+ };
283
+ WDOVerificationEndpoints.resendOTP = {
284
+ path: "/api/identity/otp/resend",
285
+ uriId: "/api/identity/otp/resend",
286
+ e2eeScope: "NONE",
287
+ returnsData: false
288
+ };
289
+ WDOVerificationEndpoints.verifyOTP = {
290
+ path: "/api/identity/otp/verify",
291
+ e2eeScope: "ACTIVATION",
292
+ returnsData: true
293
+ };
294
+ WDOVerificationEndpoints.finishActivation = {
295
+ path: "/api/identity/activation",
296
+ tokenName: "possession_universal",
297
+ e2eeScope: "ACTIVATION",
298
+ returnsData: true
299
+ };
300
+ return WDOVerificationEndpoints;
301
+ }());
302
+
77
303
  /**
78
304
  * Copyright Wultra s.r.o.
79
305
  *
@@ -135,14 +361,75 @@ var WDOLogger = /** @class */ (function () {
135
361
  *
136
362
  * SPDX-License-Identifier: Apache-2.0
137
363
  */
138
- // TODO: add ERROR codes
364
+ /** Represent error thrown from a WDO library */
139
365
  var WDOError = /** @class */ (function () {
140
- function WDOError(message, additionalInfo) {
366
+ /* @internal */
367
+ function WDOError(reason, message, additionalInfo) {
368
+ /** Helper to identify this object as a WDOError */
369
+ this.isWdoError = true;
370
+ this.reason = reason;
141
371
  this.message = message;
142
372
  this.additionalInfo = additionalInfo;
143
373
  }
374
+ Object.defineProperty(WDOError.prototype, "allowOnboardingOtpRetry", {
375
+ /**
376
+ * Whether retrying OTP is allowed based on remaining attempts.
377
+ *
378
+ * This may be filled only when the error reason is `WDOErrorReason.activationFailed`.
379
+ */
380
+ get: function () { return this.onboardingOtpRemainingAttempts !== undefined && this.onboardingOtpRemainingAttempts > 0; },
381
+ enumerable: false,
382
+ configurable: true
383
+ });
384
+ Object.defineProperty(WDOError.prototype, "onboardingOtpRemainingAttempts", {
385
+ /**
386
+ * Number of remaining OTP attempts during onboarding
387
+ *
388
+ * This may be filled only when the error reason is `WDOErrorReason.activationFailed`.
389
+ */
390
+ get: function () {
391
+ var _a, _b, _c, _d;
392
+ if ((_c = (_b = (_a = this.additionalInfo) === null || _a === void 0 ? void 0 : _a.originalException) === null || _b === void 0 ? void 0 : _b.userInfo) === null || _c === void 0 ? void 0 : _c.responseBody) {
393
+ try {
394
+ var parsedResponse = JSON.parse(this.additionalInfo.originalException.userInfo.responseBody);
395
+ return (_d = parsedResponse.remainingAttempts) !== null && _d !== void 0 ? _d : undefined;
396
+ }
397
+ catch (_e) {
398
+ WDOLogger.error("WDOError.onboardingOtpRemainingAttempts: failed to parse response body");
399
+ return undefined;
400
+ }
401
+ }
402
+ else {
403
+ return undefined;
404
+ }
405
+ },
406
+ enumerable: false,
407
+ configurable: true
408
+ });
144
409
  return WDOError;
145
410
  }());
411
+ /** Reasons for WDO errors */
412
+ exports.WDOErrorReason = void 0;
413
+ (function (WDOErrorReason) {
414
+ /** Network error occurred */
415
+ WDOErrorReason["networkError"] = "NETWORK_ERROR";
416
+ /** Activation failed */
417
+ WDOErrorReason["activationFailed"] = "ACTIVATION_FAILED";
418
+ /** Process is already in progress - happens when start() is called twice */
419
+ WDOErrorReason["processAlreadyInProgress"] = "PROCESS_ALREADY_IN_PROGRESS";
420
+ /** No process is in progress - happens when an operation requires an active process */
421
+ WDOErrorReason["processNotInProgress"] = "PROCESS_NOT_IN_PROGRESS";
422
+ /** The PowerAuth instance is already activated when trying to activate it again */
423
+ WDOErrorReason["powerauthAlreadyActivated"] = "POWERAUTH_ALREADY_ACTIVATED";
424
+ /** The PowerAuth instance is not configured properly */
425
+ WDOErrorReason["powerAuthNotConfigured"] = "POWERAUTH_NOT_CONFIGURED";
426
+ /** The PowerAuth instance is not activated when trying to use it */
427
+ WDOErrorReason["powerauthNotActivated"] = "POWERAUTH_NOT_ACTIVATED";
428
+ /** OTP verification failed */
429
+ WDOErrorReason["otpFailed"] = "OTP_FAILED";
430
+ /** Invalid parameter */
431
+ WDOErrorReason["invalidParameter"] = "INVALID_PARAMETER";
432
+ })(exports.WDOErrorReason || (exports.WDOErrorReason = {}));
146
433
 
147
434
  /**
148
435
  * Copyright Wultra s.r.o.
@@ -152,548 +439,157 @@ var WDOError = /** @class */ (function () {
152
439
  *
153
440
  * SPDX-License-Identifier: Apache-2.0
154
441
  */
442
+ var WDOPlatform = /** @class */ (function () {
443
+ function WDOPlatform() {
444
+ }
445
+ return WDOPlatform;
446
+ }());
447
+
155
448
  /**
156
- * Service that can activate PowerAuth instance by user weak credentials (like his email, phone number or client ID) + optional SMS OTP.
449
+ * Copyright Wultra s.r.o.
157
450
  *
158
- * When the PowerAuth is activated with this service, `WDOVerificationService.isVerificationRequired` will be `true`
159
- * and you will need to verify the PowerAuth instance via `WDOVerificationService`.
451
+ * This source code is licensed under the Apache License, Version 2.0 license
452
+ * found in the LICENSE file in the root directory of this source tree.
160
453
  *
161
- * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
454
+ * SPDX-License-Identifier: Apache-2.0
162
455
  */
163
- var WDOBaseActivationService = /** @class */ (function () {
164
- function WDOBaseActivationService() {
456
+ var WDOApi = /** @class */ (function () {
457
+ function WDOApi(powerauth, baseUrl) {
458
+ // TODO: additional configuration?
459
+ this.networking = WDOPlatform.networkingFactory.networking(powerauth, baseUrl);
165
460
  }
166
- Object.defineProperty(WDOBaseActivationService.prototype, "hasActiveProcess", {
167
- /**
168
- * If the activation process is in progress.
169
- *
170
- * Note that even if this property is `true` it can be already discontinued on the server.
171
- * Calling `status()` for example after the app is launched in this case is recommended.
172
- */
173
- get: function () { return !!this.processData; },
174
- enumerable: false,
175
- configurable: true
176
- });
177
- /**
178
- * Accept language for the outgoing requests headers.
179
- * Default value is "en".
180
- *
181
- * Standard RFC "Accept-Language" https://tools.ietf.org/html/rfc7231#section-5.3.5
182
- * Response texts are based on this setting. For example when "de" is set, server
183
- * will return error texts and other in german (if available).
184
- */
185
- WDOBaseActivationService.prototype.changeAcceptLanguage = function (language) {
186
- this.changeAcceptLanguageImpl(language);
461
+ // Configuration endpoints
462
+ WDOApi.prototype.getConfiguration = function (processType) {
463
+ var requestObject = { processType: processType };
464
+ return this.callApi(requestObject, { path: "/api/configuration", e2eeScope: "APPLICATION", returnsData: true });
187
465
  };
188
- Object.defineProperty(WDOBaseActivationService.prototype, "processId", {
189
- /* @internal */
190
- get: function () { var _a; return (_a = this.processData) === null || _a === void 0 ? void 0 : _a.processId; },
191
- enumerable: false,
192
- configurable: true
193
- });
194
- // PUBLIC API
195
- /**
196
- * Retrieves status of the onboarding activation.
197
- *
198
- * @return Promise resolved with onboarding status.
199
- */
200
- WDOBaseActivationService.prototype.status = function () {
201
- return __awaiter(this, void 0, void 0, function () {
202
- var pid, result;
203
- return __generator(this, function (_a) {
204
- switch (_a.label) {
205
- case 0:
206
- WDOLogger.debug("Getting activation status for processId=".concat(this.processId));
207
- return [4 /*yield*/, this.verifyCanStartProcess()];
208
- case 1:
209
- _a.sent();
210
- pid = this.verifyHasActiveProcess();
211
- return [4 /*yield*/, this.api.activationGetStatus(pid)];
212
- case 2:
213
- result = _a.sent();
214
- return [2 /*return*/, result.onboardingStatus];
215
- }
216
- });
217
- });
466
+ // Activation endpoints
467
+ WDOApi.prototype.activationStart = function (credentials, processType) {
468
+ var requestObject = { identification: credentials, processType: processType };
469
+ return this.callApi(requestObject, WDOActivationEndpoints.start);
218
470
  };
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
- WDOBaseActivationService.prototype.start = function (credentials, processType) {
233
- return __awaiter(this, void 0, void 0, function () {
234
- var result;
235
- return __generator(this, function (_a) {
236
- switch (_a.label) {
237
- case 0:
238
- WDOLogger.debug("Starting activation with credentials: ".concat(JSON.stringify(credentials)));
239
- if (this.processId) {
240
- throw new WDOError("Cannot start the process - processId already obtained, cancel first.");
241
- }
242
- return [4 /*yield*/, this.verifyCanStartProcess()];
243
- case 1:
244
- _a.sent();
245
- return [4 /*yield*/, this.api.activationStart(credentials, processType)];
246
- case 2:
247
- result = _a.sent();
248
- WDOLogger.info("WDOActivationService.start success");
249
- WDOLogger.debug(" - processId: ".concat(result.processId));
250
- this.processData = { processId: result.processId, activationCode: result.activationCode };
251
- return [2 /*return*/];
252
- }
253
- });
254
- });
471
+ WDOApi.prototype.activationCancel = function (processId) {
472
+ var requestObject = { processId: processId };
473
+ return this.callApi(requestObject, WDOActivationEndpoints.cancel);
255
474
  };
256
- /**
257
- * Cancel the activation process (issues a cancel request to the backend and clears the local process ID).
258
- *
259
- * @param forceCancel When true, the process will be canceled in the SDK even when fails on backend. `true` by default.
260
- */
261
- WDOBaseActivationService.prototype.cancel = function () {
262
- return __awaiter(this, arguments, void 0, function (forceCancel) {
263
- var pid, error_1;
264
- if (forceCancel === void 0) { forceCancel = true; }
265
- return __generator(this, function (_a) {
266
- switch (_a.label) {
267
- case 0:
268
- WDOLogger.debug("Canceling activation for processId=".concat(this.processId, ", forceCancel=").concat(forceCancel));
269
- pid = this.verifyHasActiveProcess();
270
- _a.label = 1;
271
- case 1:
272
- _a.trys.push([1, 3, , 4]);
273
- return [4 /*yield*/, this.api.activationCancel(pid)];
274
- case 2:
275
- _a.sent();
276
- this.processData = undefined;
277
- WDOLogger.info("WDOActivationService.cancel success");
278
- return [3 /*break*/, 4];
279
- case 3:
280
- error_1 = _a.sent();
281
- if (forceCancel) {
282
- // pretend it was successful and just log the error
283
- WDOLogger.debug("Process canceled (but the request failed) - ".concat(error_1, "."));
284
- this.processData = undefined;
285
- }
286
- else {
287
- throw error_1; // rethrow
288
- }
289
- return [3 /*break*/, 4];
290
- case 4: return [2 /*return*/];
291
- }
292
- });
293
- });
475
+ WDOApi.prototype.activationGetStatus = function (processId) {
476
+ var requestObject = { processId: processId };
477
+ return this.callApi(requestObject, WDOActivationEndpoints.getStatus);
294
478
  };
295
- /** Clear the stored data (without networking call). */
296
- WDOBaseActivationService.prototype.clear = function () {
297
- this.processData = undefined;
479
+ WDOApi.prototype.activationResendOTP = function (processId) {
480
+ var requestObject = { processId: processId };
481
+ return this.callApi(requestObject, WDOActivationEndpoints.resendOTP);
298
482
  };
299
- /**
300
- * OTP resend request.
301
- *
302
- * This is intended to be displayed for the user to use in case of the OTP is not received.
303
- * For example, when the user does not receive SMS after some time, there should be a button to "send again".
304
- */
305
- WDOBaseActivationService.prototype.resendOTP = function () {
306
- return __awaiter(this, void 0, void 0, function () {
307
- var pid;
308
- return __generator(this, function (_a) {
309
- switch (_a.label) {
310
- case 0:
311
- WDOLogger.debug("Activation: resending OTP");
312
- pid = this.verifyHasActiveProcess();
313
- return [4 /*yield*/, this.verifyCanStartProcess()];
314
- case 1:
315
- _a.sent();
316
- return [4 /*yield*/, this.api.activationResendOTP(pid)];
317
- case 2:
318
- _a.sent();
319
- return [2 /*return*/];
320
- }
321
- });
322
- });
483
+ WDOApi.prototype.activationGetOTP = function (processId, otpType) {
484
+ var requestObject = { processId: processId, otpType: otpType };
485
+ return this.callApi(requestObject, { path: "/api/onboarding/otp/detail", e2eeScope: "APPLICATION", returnsData: true });
323
486
  };
324
- /**
325
- * @internal
326
- * Demo endpoint available only in Wultra Demo systems.
327
- *
328
- * If the app is running against our demo server, you can retrieve the OTP without needing to send SMS or emails.
329
- */
330
- WDOBaseActivationService.prototype.getOTP = function () {
331
- return __awaiter(this, void 0, void 0, function () {
332
- var pid;
333
- return __generator(this, function (_a) {
334
- switch (_a.label) {
335
- case 0:
336
- WDOLogger.debug("Activation: getting OTP from server (only for testing purposes)");
337
- pid = this.verifyHasActiveProcess();
338
- return [4 /*yield*/, this.api.activationGetOTP(pid, "ACTIVATION")];
339
- case 1: return [2 /*return*/, (_a.sent()).otpCode];
340
- }
341
- });
342
- });
487
+ // Verification endpoints
488
+ WDOApi.prototype.verificationStatus = function () {
489
+ var requestObject = {};
490
+ return this.callApi(requestObject, WDOVerificationEndpoints.getStatus);
343
491
  };
344
- /**
345
- * Activate the PowerAuth instance that was passed in the initializer.
346
- *
347
- * @param activationName Name of the activation. Device name by default (usually something like John's iPhone or similar).
348
- * @param otp OTP code received by the user (via SMS or email). Optional when not required.
349
- * @return Promise resolved with activation result.
350
- */
351
- WDOBaseActivationService.prototype.activate = function (activationName, otp) {
352
- return __awaiter(this, void 0, void 0, function () {
353
- var pid, code, result, identityAttributes;
354
- var _a;
355
- return __generator(this, function (_b) {
356
- switch (_b.label) {
357
- case 0:
358
- WDOLogger.debug("Activating the PowerAuth with activation name '".concat(activationName, "'"));
359
- return [4 /*yield*/, this.verifyCanStartProcess()];
360
- case 1:
361
- _b.sent();
362
- pid = this.verifyHasActiveProcess();
363
- code = (_a = this.processData) === null || _a === void 0 ? void 0 : _a.activationCode;
364
- if (!code) return [3 /*break*/, 3];
365
- WDOLogger.info("Activating PowerAuth using activation code from the onboarding process");
366
- return [4 /*yield*/, this.activatePowerAuthWithCode(code, otp, activationName)];
367
- case 2:
368
- result = _b.sent();
369
- return [3 /*break*/, 5];
370
- case 3:
371
- WDOLogger.info("Activating PowerAuth using identity attributes from the onboarding process");
372
- identityAttributes = { processId: pid, otpCode: otp, credentialsType: "ONBOARDING" };
373
- return [4 /*yield*/, this.activatePowerAuth(identityAttributes, activationName)];
374
- case 4:
375
- result = _b.sent();
376
- _b.label = 5;
377
- case 5:
378
- // Clear process ID after activation attempt
379
- this.processData = undefined;
380
- return [2 /*return*/, result];
381
- }
382
- });
383
- });
492
+ WDOApi.prototype.verificationStart = function (processId) {
493
+ var requestObject = { processId: processId };
494
+ return this.callApi(requestObject, WDOVerificationEndpoints.init);
384
495
  };
385
- // PRIVATE METHODS
386
- /* @internal */
387
- WDOBaseActivationService.prototype.verifyCanStartProcess = function () {
388
- return __awaiter(this, void 0, void 0, function () {
389
- return __generator(this, function (_a) {
390
- switch (_a.label) {
391
- case 0: return [4 /*yield*/, this.api.canStartActivation()];
392
- case 1:
393
- if (!(_a.sent())) {
394
- WDOLogger.error("PowerAuth is already activated - Activation cannot be started/processed.");
395
- this.processData = undefined;
396
- throw new WDOError("PowerAuth is already activated");
397
- }
398
- return [2 /*return*/];
399
- }
400
- });
401
- });
496
+ WDOApi.prototype.verificationCleanup = function (processId) {
497
+ var requestObject = { processId: processId };
498
+ return this.callApi(requestObject, WDOVerificationEndpoints.cancel);
402
499
  };
403
- /* @internal */
404
- WDOBaseActivationService.prototype.verifyHasActiveProcess = function () {
405
- var pid = this.processId;
406
- if (!pid) {
407
- WDOLogger.warn("Cannot proceed (processId not available).");
408
- throw new WDOError("No active activation process");
409
- }
410
- return pid;
500
+ WDOApi.prototype.verificationGetConsentText = function (processId) {
501
+ var requestObject = { processId: processId, consentType: "GDPR" };
502
+ return this.callApi(requestObject, WDOVerificationEndpoints.consentText);
411
503
  };
412
- return WDOBaseActivationService;
413
- }());
414
-
415
- /**
416
- * Copyright Wultra s.r.o.
417
- *
418
- * This source code is licensed under the Apache License, Version 2.0 license
419
- * found in the LICENSE file in the root directory of this source tree.
420
- *
421
- * SPDX-License-Identifier: Apache-2.0
422
- */
423
- var WDOActivationEndpoints = /** @class */ (function () {
424
- function WDOActivationEndpoints() {
425
- }
426
- WDOActivationEndpoints.start = {
427
- path: "/api/onboarding/start",
428
- e2eeScope: "APPLICATION",
429
- returnsData: true
504
+ WDOApi.prototype.verificationResolveConsent = function (processId, approved) {
505
+ var requestObject = { processId: processId, approved: approved, consentType: "GDPR" };
506
+ return this.callApi(requestObject, WDOVerificationEndpoints.consentApprove);
430
507
  };
431
- WDOActivationEndpoints.cancel = {
432
- path: "/api/onboarding/cleanup",
433
- e2eeScope: "APPLICATION",
434
- returnsData: false
508
+ WDOApi.prototype.verificationInitScanSDK = function (processId, challenge) {
509
+ var requestObject = { processId: processId, attributes: { 'sdk-init-token': challenge } };
510
+ return this.callApi(requestObject, WDOVerificationEndpoints.documentScanSdkInit);
435
511
  };
436
- WDOActivationEndpoints.resendOTP = {
437
- path: "/api/onboarding/otp/resend",
438
- e2eeScope: "APPLICATION",
439
- returnsData: false
512
+ WDOApi.prototype.verificationSubmitDocuments = function (processId, resubmit, documents) {
513
+ var requestObject = {
514
+ processId: processId,
515
+ resubmit: resubmit,
516
+ documents: documents
517
+ };
518
+ // TODO: there should be longer timeout!
519
+ return this.callApi(requestObject, WDOVerificationEndpoints.v2submitDocuments);
440
520
  };
441
- WDOActivationEndpoints.getStatus = {
442
- path: "/api/onboarding/status",
443
- e2eeScope: "APPLICATION",
444
- returnsData: true
521
+ WDOApi.prototype.verificationDocumentsStatus = function (processId) {
522
+ var requestObject = { processId: processId };
523
+ // TODO: longer timeout?
524
+ return this.callApi(requestObject, WDOVerificationEndpoints.documentsStatus);
445
525
  };
446
- return WDOActivationEndpoints;
447
- }());
448
- var WDOVerificationEndpoints = /** @class */ (function () {
449
- function WDOVerificationEndpoints() {
450
- }
451
- WDOVerificationEndpoints.getStatus = {
452
- path: "/api/identity/status",
453
- e2eeScope: "NONE",
454
- tokenName: "possession_universal",
455
- returnsData: true
456
- };
457
- WDOVerificationEndpoints.init = {
458
- path: "/api/identity/init",
459
- uriId: "/api/identity/init",
460
- e2eeScope: "NONE",
461
- returnsData: false
462
- };
463
- WDOVerificationEndpoints.cancel = {
464
- path: "/api/identity/cleanup",
465
- uriId: "/api/identity/cleanup",
466
- e2eeScope: "NONE",
467
- returnsData: false
468
- };
469
- WDOVerificationEndpoints.consentText = {
470
- path: "/api/identity/consent/text",
471
- tokenName: "possession_universal",
472
- e2eeScope: "NONE",
473
- returnsData: true
474
- };
475
- WDOVerificationEndpoints.consentApprove = {
476
- path: "/api/identity/consent/approve",
477
- uriId: "/api/identity/consent/approve",
478
- e2eeScope: "NONE",
479
- returnsData: false
480
- };
481
- WDOVerificationEndpoints.documentScanSdkInit = {
482
- path: "/api/identity/document/init-sdk",
483
- uriId: "/api/identity/document/init-sdk",
484
- e2eeScope: "ACTIVATION",
485
- returnsData: true
486
- };
487
- // Legacy endpoint that required zip file upload
488
- WDOVerificationEndpoints.submitDocuments = {
489
- path: "/api/identity/document/submit",
490
- tokenName: "possession_universal",
491
- e2eeScope: "ACTIVATION",
492
- returnsData: false
493
- };
494
- WDOVerificationEndpoints.v2submitDocuments = {
495
- path: "/api/v2/identity/document/submit",
496
- tokenName: "possession_universal",
497
- e2eeScope: "ACTIVATION",
498
- returnsData: false
499
- };
500
- WDOVerificationEndpoints.documentsStatus = {
501
- path: "/api/identity/document/status",
502
- tokenName: "possession_universal",
503
- e2eeScope: "NONE",
504
- returnsData: true
505
- };
506
- WDOVerificationEndpoints.presenceCheckInit = {
507
- path: "/api/identity/presence-check/init",
508
- uriId: "/api/identity/presence-check/init",
509
- e2eeScope: "ACTIVATION",
510
- returnsData: true
511
- };
512
- WDOVerificationEndpoints.presenceCheckSubmit = {
513
- path: "/api/identity/presence-check/submit",
514
- uriId: "/api/identity/presence-check/submit",
515
- e2eeScope: "NONE",
516
- returnsData: false
517
- };
518
- WDOVerificationEndpoints.resendOTP = {
519
- path: "/api/identity/otp/resend",
520
- uriId: "/api/identity/otp/resend",
521
- e2eeScope: "NONE",
522
- returnsData: false
523
- };
524
- WDOVerificationEndpoints.verifyOTP = {
525
- path: "/api/identity/otp/verify",
526
- e2eeScope: "ACTIVATION",
527
- returnsData: true
528
- };
529
- return WDOVerificationEndpoints;
530
- }());
531
-
532
- /**
533
- * Copyright Wultra s.r.o.
534
- *
535
- * This source code is licensed under the Apache License, Version 2.0 license
536
- * found in the LICENSE file in the root directory of this source tree.
537
- *
538
- * SPDX-License-Identifier: Apache-2.0
539
- */
540
- var WDOBaseApi = /** @class */ (function () {
541
- function WDOBaseApi() {
542
- }
543
- // Configuration endpoints
544
- WDOBaseApi.prototype.getConfiguration = function (processType) {
545
- var requestObject = { processType: processType };
546
- return this.callApi(requestObject, { path: "/api/configuration", e2eeScope: "APPLICATION", returnsData: true });
547
- };
548
- // Activation endpoints
549
- WDOBaseApi.prototype.activationStart = function (credentials, processType) {
550
- var requestObject = { identification: credentials, processType: processType };
551
- return this.callApi(requestObject, WDOActivationEndpoints.start);
552
- };
553
- WDOBaseApi.prototype.activationCancel = function (processId) {
554
- var requestObject = { processId: processId };
555
- return this.callApi(requestObject, WDOActivationEndpoints.cancel);
556
- };
557
- WDOBaseApi.prototype.activationGetStatus = function (processId) {
558
- var requestObject = { processId: processId };
559
- return this.callApi(requestObject, WDOActivationEndpoints.getStatus);
560
- };
561
- WDOBaseApi.prototype.activationResendOTP = function (processId) {
562
- var requestObject = { processId: processId };
563
- return this.callApi(requestObject, WDOActivationEndpoints.resendOTP);
564
- };
565
- WDOBaseApi.prototype.activationGetOTP = function (processId, otpType) {
566
- var requestObject = { processId: processId, otpType: otpType };
567
- return this.callApi(requestObject, { path: "/api/onboarding/otp/detail", e2eeScope: "APPLICATION", returnsData: true });
568
- };
569
- // Verification endpoints
570
- WDOBaseApi.prototype.verificationStatus = function () {
571
- var requestObject = {};
572
- return this.callApi(requestObject, WDOVerificationEndpoints.getStatus);
573
- };
574
- WDOBaseApi.prototype.verificationStart = function (processId) {
575
- var requestObject = { processId: processId };
576
- return this.callApi(requestObject, WDOVerificationEndpoints.init);
577
- };
578
- WDOBaseApi.prototype.verificationCleanup = function (processId) {
579
- var requestObject = { processId: processId };
580
- return this.callApi(requestObject, WDOVerificationEndpoints.cancel);
581
- };
582
- WDOBaseApi.prototype.verificationGetConsentText = function (processId) {
583
- var requestObject = { processId: processId, consentType: "GDPR" }; // TODO: hardcoded type
584
- return this.callApi(requestObject, WDOVerificationEndpoints.consentText);
585
- };
586
- WDOBaseApi.prototype.verificationResolveConsent = function (processId, approved) {
587
- var requestObject = { processId: processId, approved: approved, consentType: "GDPR" }; // TODO: hardcoded type
588
- return this.callApi(requestObject, WDOVerificationEndpoints.consentApprove);
589
- };
590
- WDOBaseApi.prototype.verificationInitScanSDK = function (processId, challenge) {
591
- var requestObject = { processId: processId, attributes: { 'sdk-init-token': challenge } };
592
- return this.callApi(requestObject, WDOVerificationEndpoints.documentScanSdkInit);
593
- };
594
- WDOBaseApi.prototype.verificationSubmitDocumentsV2 = function (processId, resubmit, documents) {
595
- var requestObject = {
596
- processId: processId,
597
- resubmit: resubmit,
598
- documents: documents
599
- };
600
- // TODO: there should be longer timeout!
601
- return this.callApi(requestObject, WDOVerificationEndpoints.v2submitDocuments);
602
- };
603
- WDOBaseApi.prototype.verificationSubmitDocuments = function (processId, data, resubmit, documents) {
604
- var requestObject = { processId: processId, data: data, resubmit: resubmit, documents: documents };
605
- // TODO: there should be longer timeout!
606
- return this.callApi(requestObject, WDOVerificationEndpoints.submitDocuments);
607
- };
608
- WDOBaseApi.prototype.verificationDocumentsStatus = function (processId) {
609
- var requestObject = { processId: processId };
610
- // TODO: longer timeout?
611
- return this.callApi(requestObject, WDOVerificationEndpoints.documentsStatus);
612
- };
613
- WDOBaseApi.prototype.verificationPresenceCheckInit = function (processId) {
526
+ WDOApi.prototype.verificationPresenceCheckInit = function (processId) {
614
527
  var requestObject = { processId: processId };
615
528
  return this.callApi(requestObject, WDOVerificationEndpoints.presenceCheckInit);
616
529
  };
617
- WDOBaseApi.prototype.verificationPresenceCheckSubmit = function (processId) {
530
+ WDOApi.prototype.verificationPresenceCheckSubmit = function (processId) {
618
531
  var requestObject = { processId: processId };
619
532
  return this.callApi(requestObject, WDOVerificationEndpoints.presenceCheckSubmit);
620
533
  };
621
- WDOBaseApi.prototype.verificationResendOTP = function (processId) {
534
+ WDOApi.prototype.verificationResendOTP = function (processId) {
622
535
  var requestObject = { processId: processId };
623
536
  return this.callApi(requestObject, WDOVerificationEndpoints.resendOTP);
624
537
  };
625
- WDOBaseApi.prototype.verifyOTP = function (processId, otp) {
538
+ WDOApi.prototype.verifyOTP = function (processId, otp) {
626
539
  var requestObject = { processId: processId, otpCode: otp };
627
540
  return this.callApi(requestObject, WDOVerificationEndpoints.verifyOTP);
628
541
  };
629
- return WDOBaseApi;
630
- }());
631
-
632
- /**
633
- * Copyright Wultra s.r.o.
634
- *
635
- * This source code is licensed under the Apache License, Version 2.0 license
636
- * found in the LICENSE file in the root directory of this source tree.
637
- *
638
- * SPDX-License-Identifier: Apache-2.0
639
- */
640
-
641
-
642
- var WDOApi = /** @class */ (function (_super) {
643
- __extends(WDOApi, _super);
644
- function WDOApi(powerauth, baseUrl) {
645
- var _this = _super.call(this) || this;
646
- // TODO: additional configuration?
647
- _this.networking = new WPNNetworking(powerauth, baseUrl);
648
- _this.powerauth = powerauth;
649
- return _this;
650
- }
651
- WDOApi.prototype.callApi = function (requestObject, endpoint) {
542
+ WDOApi.prototype.verificationFinishActivation = function (processId, userIdentification) {
543
+ var requestObject = { processId: processId, identification: userIdentification };
544
+ return this.callApi(requestObject, WDOVerificationEndpoints.finishActivation);
545
+ };
546
+ WDOApi.prototype.callApi = function (requestObject, endpoint, authObject) {
547
+ if (authObject && !(authObject instanceof PowerAuthAuthentication)) {
548
+ throw new WDOError(exports.WDOErrorReason.invalidParameter, "The authObject parameter must be of type PowerAuthAuthentication.");
549
+ }
550
+ // set authentication to given authObject or to possession if endpoint is "signed"
551
+ var authentication = authObject || (endpoint.tokenName || endpoint.uriId ? PowerAuthAuthentication.possession() : undefined);
652
552
  return this.networking.call(
653
553
  // construct
654
- this.constructEndpoint(endpoint), { requestObject: requestObject }, endpoint.tokenName || endpoint.uriId ? PowerAuthAuthentication.possession() : undefined // if signed, use possession auth
655
- ).then(function (result) {
554
+ this.constructEndpoint(endpoint), { requestObject: requestObject }, authentication).then(function (result) {
656
555
  if (result.responseObject) {
657
556
  return result.responseObject;
658
557
  }
659
558
  else if (result.responseError) {
660
- throw new WDOError("Server API error: ".concat(result.responseError.code, ", ").concat(result.responseError.message), result.responseError);
559
+ throw new WDOError(exports.WDOErrorReason.networkError, "Server API error: ".concat(result.responseError.code, ", ").concat(result.responseError.message), result.responseError);
661
560
  }
662
561
  else if (!endpoint.returnsData) {
663
562
  // for void responses
664
563
  return {};
665
564
  }
666
565
  else {
667
- throw new WDOError("Failed to retrieve activation data");
566
+ throw new WDOError(exports.WDOErrorReason.networkError, "Failed to retrieve server data");
668
567
  }
669
568
  });
670
569
  };
671
- WDOApi.prototype.canStartActivation = function () {
672
- return this.powerauth.canStartActivation();
673
- };
674
570
  WDOApi.prototype.constructEndpoint = function (endpoint) {
675
571
  var scope;
676
572
  if (endpoint.e2eeScope === "ACTIVATION") {
677
- scope = WPNE2EEConfiguration.ACTIVATION_SCOPE;
573
+ scope = 1;
678
574
  }
679
575
  else if (endpoint.e2eeScope === "APPLICATION") {
680
- scope = WPNE2EEConfiguration.APPLICATION_SCOPE;
576
+ scope = 0;
681
577
  }
682
578
  else {
683
- scope = WPNE2EEConfiguration.NOT_ENCRYPTED;
579
+ scope = 2;
684
580
  }
685
581
  if (endpoint.uriId) {
686
- return WPNEndpoint.signed(endpoint.path, endpoint.uriId, undefined, scope);
582
+ return WDOPlatform.networkingFactory.signedEndpoint(endpoint.path, endpoint.uriId, undefined, scope);
687
583
  }
688
584
  else if (endpoint.tokenName) {
689
- return WPNEndpoint.signedWithToken(endpoint.path, endpoint.tokenName, undefined, scope);
585
+ return WDOPlatform.networkingFactory.signedWithTokenEndpoint(endpoint.path, endpoint.tokenName, undefined, scope);
690
586
  }
691
587
  else {
692
- return WPNEndpoint.unsigned(endpoint.path, undefined, scope);
588
+ return WDOPlatform.networkingFactory.unsignedEndpoint(endpoint.path, undefined, scope);
693
589
  }
694
590
  };
695
591
  return WDOApi;
696
- }(WDOBaseApi));
592
+ }());
697
593
 
698
594
  /**
699
595
  * Copyright Wultra s.r.o.
@@ -703,109 +599,111 @@ var WDOApi = /** @class */ (function (_super) {
703
599
  *
704
600
  * SPDX-License-Identifier: Apache-2.0
705
601
  */
602
+ /** Status of the onboarding */
603
+ exports.WDOOnboardingStatus = void 0;
604
+ (function (WDOOnboardingStatus) {
605
+ /** Activation part of the process is in progress */
606
+ WDOOnboardingStatus["activationInProgress"] = "ACTIVATION_IN_PROGRESS";
607
+ /** Verification part of the process is in progress */
608
+ WDOOnboardingStatus["verificationInProgress"] = "VERIFICATION_IN_PROGRESS";
609
+ /** Onboarding process has failed */
610
+ WDOOnboardingStatus["failed"] = "FAILED";
611
+ /** Onboarding process is completed */
612
+ WDOOnboardingStatus["finished"] = "FINISHED";
613
+ })(exports.WDOOnboardingStatus || (exports.WDOOnboardingStatus = {}));
614
+ /* @internal */
615
+ exports.WDOIdentityVerificationStatus = void 0;
616
+ (function (WDOIdentityVerificationStatus) {
617
+ /** Identity verification is waiting for initialization */
618
+ WDOIdentityVerificationStatus["notInitialized"] = "NOT_INITIALIZED";
619
+ /** All submitted documents are waiting for verification */
620
+ WDOIdentityVerificationStatus["verificationPending"] = "VERIFICATION_PENDING";
621
+ /** Identity verification is in progress */
622
+ WDOIdentityVerificationStatus["inProgress"] = "IN_PROGRESS";
623
+ /** Identity verification was successfully completed */
624
+ WDOIdentityVerificationStatus["accepted"] = "ACCEPTED";
625
+ /** Identity verification has failed, an error occurred */
626
+ WDOIdentityVerificationStatus["failed"] = "FAILED";
627
+ /** Identity verification was rejected */
628
+ WDOIdentityVerificationStatus["rejected"] = "REJECTED";
629
+ })(exports.WDOIdentityVerificationStatus || (exports.WDOIdentityVerificationStatus = {}));
630
+ /* @internal */
631
+ exports.WDOIdentityVerificationPhase = void 0;
632
+ (function (WDOIdentityVerificationPhase) {
633
+ /** Document upload is in progress */
634
+ WDOIdentityVerificationPhase["documentUpload"] = "DOCUMENT_UPLOAD";
635
+ /** Presence check is in progress */
636
+ WDOIdentityVerificationPhase["presenceCheck"] = "PRESENCE_CHECK";
637
+ /** Backend is verifying documents */
638
+ WDOIdentityVerificationPhase["clientEvaluation"] = "CLIENT_EVALUATION";
639
+ /** Document verification is in progress */
640
+ WDOIdentityVerificationPhase["documentVerification"] = "DOCUMENT_VERIFICATION";
641
+ /** Cross check on documents is in progress */
642
+ WDOIdentityVerificationPhase["documentVerificationFinal"] = "DOCUMENT_VERIFICATION_FINAL";
643
+ /** OTP verification needed */
644
+ WDOIdentityVerificationPhase["otp"] = "OTP_VERIFICATION";
645
+ /** Completed */
646
+ WDOIdentityVerificationPhase["completed"] = "COMPLETED";
647
+ /** Exchanging the temporary activation for the permanent one. */
648
+ WDOIdentityVerificationPhase["activationFinish"] = "ACTIVATION_FINISH";
649
+ })(exports.WDOIdentityVerificationPhase || (exports.WDOIdentityVerificationPhase = {}));
650
+ /* @internal */
651
+ exports.WDODocumentSubmitFileType = void 0;
652
+ (function (WDODocumentSubmitFileType) {
653
+ /** National ID card */
654
+ WDODocumentSubmitFileType["idCard"] = "ID_CARD";
655
+ /** Passport */
656
+ WDODocumentSubmitFileType["passport"] = "PASSPORT";
657
+ /** Driving license */
658
+ WDODocumentSubmitFileType["driversLicense"] = "DRIVING_LICENSE";
659
+ /** Selfie photo */
660
+ WDODocumentSubmitFileType["selfiePhoto"] = "SELFIE_PHOTO";
661
+ })(exports.WDODocumentSubmitFileType || (exports.WDODocumentSubmitFileType = {}));
662
+ /* @internal */
663
+ exports.WDODocumentSubmitFileSide = void 0;
664
+ (function (WDODocumentSubmitFileSide) {
665
+ /** Front side of an document. Usually the one with the picture */
666
+ WDODocumentSubmitFileSide["front"] = "FRONT";
667
+ /** Back side of an document */
668
+ WDODocumentSubmitFileSide["back"] = "BACK";
669
+ })(exports.WDODocumentSubmitFileSide || (exports.WDODocumentSubmitFileSide = {}));
670
+ /* @internal */
671
+ exports.WDODocumentStatus = void 0;
672
+ (function (WDODocumentStatus) {
673
+ /** Document was accepted */
674
+ WDODocumentStatus["accepted"] = "ACCEPTED";
675
+ /** Document is being uploaded to the verification system by the backend */
676
+ WDODocumentStatus["uploadInProgress"] = "UPLOAD_IN_PROGRESS";
677
+ /** Document are being processed */
678
+ WDODocumentStatus["inProgress"] = "IN_PROGRESS";
679
+ /** Document is pending verification */
680
+ WDODocumentStatus["verificationPending"] = "VERIFICATION_PENDING";
681
+ /** Document is being verified */
682
+ WDODocumentStatus["verificationInProgress"] = "VERIFICATION_IN_PROGRESS";
683
+ /** Document was rejected */
684
+ WDODocumentStatus["rejected"] = "REJECTED";
685
+ /** Verification of the document failed */
686
+ WDODocumentStatus["failed"] = "FAILED";
687
+ })(exports.WDODocumentStatus || (exports.WDODocumentStatus = {}));
706
688
 
707
689
  /**
708
- * Service that can activate PowerAuth instance by user weak credentials (like his email, phone number or client ID) + optional SMS OTP.
690
+ * Copyright Wultra s.r.o.
709
691
  *
710
- * When the PowerAuth is activated with this service, `WDOVerificationService.isVerificationRequired` will be `true`
711
- * and you will need to verify the PowerAuth instance via `WDOVerificationService`.
692
+ * This source code is licensed under the Apache License, Version 2.0 license
693
+ * found in the LICENSE file in the root directory of this source tree.
712
694
  *
713
- * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
695
+ * SPDX-License-Identifier: Apache-2.0
714
696
  */
715
- var WDOActivationService = /** @class */ (function (_super) {
716
- __extends(WDOActivationService, _super);
697
+ /** Image of a document that can be sent to the backend for Identity Verification. */
698
+ var WDODocumentFile = /** @class */ (function () {
717
699
  /**
718
- * Creates service instance
700
+ * Image of a document that can be sent to the backend for Identity Verification.
719
701
  *
720
- * @param powerauth Configured PowerAuth instance. This instance needs to be without valid activation.
721
- * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
722
- */
723
- function WDOActivationService(powerauth, baseUrl) {
724
- var _this = _super.call(this) || this;
725
- _this.api = new WDOApi(powerauth, baseUrl);
726
- _this.powerauth = powerauth;
727
- return _this;
728
- }
729
- /* @internal */
730
- WDOActivationService.prototype.activatePowerAuth = function (identityAttributes, activationName) {
731
- var activation = PowerAuthActivation.createWithIdentityAttributes(identityAttributes, activationName);
732
- return this.powerauth.createActivation(activation);
733
- };
734
- /* @internal */
735
- WDOActivationService.prototype.activatePowerAuthWithCode = function (activationCode, otp, activationName) {
736
- var activation = PowerAuthActivation.createWithActivationCode(activationCode, activationName);
737
- if (otp) {
738
- activation.additionalActivationOtp = otp;
739
- }
740
- return this.powerauth.createActivation(activation);
741
- };
742
- /* @internal */
743
- WDOActivationService.prototype.changeAcceptLanguageImpl = function (language) {
744
- this.api.networking.acceptLanguage = language;
745
- };
746
- return WDOActivationService;
747
- }(WDOBaseActivationService));
748
-
749
- /**
750
- * Copyright Wultra s.r.o.
751
- *
752
- * This source code is licensed under the Apache License, Version 2.0 license
753
- * found in the LICENSE file in the root directory of this source tree.
754
- *
755
- * SPDX-License-Identifier: Apache-2.0
756
- */
757
- /**
758
- * The `WDOPowerAuthActivationState` enum defines all possible states of activation.
759
- * The state is a part of information received together with the rest
760
- * of the `WDOPowerAuthActivationStatus` object.
761
- */
762
- var WDOPowerAuthActivationState;
763
- (function (WDOPowerAuthActivationState) {
764
- /**
765
- * The activation is just created.
766
- */
767
- WDOPowerAuthActivationState["CREATED"] = "CREATED";
768
- /**
769
- * The activation is not completed yet on the server.
770
- */
771
- WDOPowerAuthActivationState["PENDING_COMMIT"] = "PENDING_COMMIT";
772
- /**
773
- * The shared secure context is valid and active.
774
- */
775
- WDOPowerAuthActivationState["ACTIVE"] = "ACTIVE";
776
- /**
777
- * The activation is blocked.
778
- */
779
- WDOPowerAuthActivationState["BLOCKED"] = "BLOCKED";
780
- /**
781
- * The activation doesn't exist anymore.
782
- */
783
- WDOPowerAuthActivationState["REMOVED"] = "REMOVED";
784
- /**
785
- * The activation is technically blocked. You cannot use it anymore
786
- * for the signature calculations.
787
- */
788
- WDOPowerAuthActivationState["DEADLOCK"] = "DEADLOCK";
789
- })(WDOPowerAuthActivationState || (WDOPowerAuthActivationState = {}));
790
-
791
- /**
792
- * Copyright Wultra s.r.o.
793
- *
794
- * This source code is licensed under the Apache License, Version 2.0 license
795
- * found in the LICENSE file in the root directory of this source tree.
796
- *
797
- * SPDX-License-Identifier: Apache-2.0
798
- */
799
- /** Image of a document that can be sent to the backend for Identity Verification. */
800
- var WDODocumentFile = /** @class */ (function () {
801
- /**
802
- * Image of a document that can be sent to the backend for Identity Verification.
803
- *
804
- * @param data Raw image data. Make sure that the data aren't too big, hundreds of kbs should be enough.
805
- * @param type Type of the document.
806
- * @param side The side of the document that the image captures.
807
- * @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.
808
- * @param dataSignature Signature of the image data. Optional, use only when the scan SDK supports this. `undefined` by default.
702
+ * @param data Raw image data. Make sure that the data aren't too big, hundreds of kbs should be enough.
703
+ * @param type Type of the document.
704
+ * @param side The side of the document that the image captures.
705
+ * @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.
706
+ * @param dataSignature Signature of the image data. Optional, use only when the scan SDK supports this. `undefined` by default.
809
707
  */
810
708
  function WDODocumentFile(data, type, side, originalDocumentId, dataSignature) {
811
709
  this.data = data;
@@ -840,22 +738,6 @@ exports.WDODocumentType = void 0;
840
738
  /** Drivers license */
841
739
  WDODocumentType["driversLicense"] = "driversLicense";
842
740
  })(exports.WDODocumentType || (exports.WDODocumentType = {}));
843
- /**
844
- * Available sides of the document
845
- *
846
- * Front and back for ID card.
847
- * For passport and drivers license front only.
848
- */
849
- function WDODocumentTypeSides(type) {
850
- switch (type) {
851
- case exports.WDODocumentType.idCard:
852
- return [exports.WDODocumentSide.front, exports.WDODocumentSide.back];
853
- case exports.WDODocumentType.passport:
854
- return [exports.WDODocumentSide.front];
855
- case exports.WDODocumentType.driversLicense:
856
- return [exports.WDODocumentSide.front];
857
- }
858
- }
859
741
  /** Side of the document */
860
742
  exports.WDODocumentSide = void 0;
861
743
  (function (WDODocumentSide) {
@@ -867,232 +749,27 @@ exports.WDODocumentSide = void 0;
867
749
  /** Back side of a document */
868
750
  WDODocumentSide["back"] = "back";
869
751
  })(exports.WDODocumentSide || (exports.WDODocumentSide = {}));
870
-
871
- /**
872
- * Copyright Wultra s.r.o.
873
- *
874
- * This source code is licensed under the Apache License, Version 2.0 license
875
- * found in the LICENSE file in the root directory of this source tree.
876
- *
877
- * SPDX-License-Identifier: Apache-2.0
878
- */
879
- /** Status of the onboarding */
880
- var WDOOnboardingStatus;
881
- (function (WDOOnboardingStatus) {
882
- /** Activation part of the process is in progress */
883
- WDOOnboardingStatus["activationInProgress"] = "ACTIVATION_IN_PROGRESS";
884
- /** Verification part of the process is in progress */
885
- WDOOnboardingStatus["verificationInProgress"] = "VERIFICATION_IN_PROGRESS";
886
- /** Onboarding process has failed */
887
- WDOOnboardingStatus["failed"] = "FAILED";
888
- /** Onboarding process is completed */
889
- WDOOnboardingStatus["finished"] = "FINISHED";
890
- })(WDOOnboardingStatus || (WDOOnboardingStatus = {}));
891
- /** Status of the current identity verification */
892
- var WDOIdentityVerificationStatus;
893
- (function (WDOIdentityVerificationStatus) {
894
- /** Identity verification is waiting for initialization */
895
- WDOIdentityVerificationStatus["notInitialized"] = "NOT_INITIALIZED";
896
- /** All submitted documents are waiting for verification */
897
- WDOIdentityVerificationStatus["verificationPending"] = "VERIFICATION_PENDING";
898
- /** Identity verification is in progress */
899
- WDOIdentityVerificationStatus["inProgress"] = "IN_PROGRESS";
900
- /** Identity verification was successfully completed */
901
- WDOIdentityVerificationStatus["accepted"] = "ACCEPTED";
902
- /** Identity verification has failed, an error occurred */
903
- WDOIdentityVerificationStatus["failed"] = "FAILED";
904
- /** Identity verification was rejected */
905
- WDOIdentityVerificationStatus["rejected"] = "REJECTED";
906
- })(WDOIdentityVerificationStatus || (WDOIdentityVerificationStatus = {}));
907
- /** Phase of the current identity verification */
908
- var WDOIdentityVerificationPhase;
909
- (function (WDOIdentityVerificationPhase) {
910
- /** Document upload is in progress */
911
- WDOIdentityVerificationPhase["documentUpload"] = "DOCUMENT_UPLOAD";
912
- /** Presence check is in progress */
913
- WDOIdentityVerificationPhase["presenceCheck"] = "PRESENCE_CHECK";
914
- /** Backend is verifying documents */
915
- WDOIdentityVerificationPhase["clientEvaluation"] = "CLIENT_EVALUATION";
916
- /** Document verification is in progress */
917
- WDOIdentityVerificationPhase["documentVerification"] = "DOCUMENT_VERIFICATION";
918
- /** Cross check on documents is in progress */
919
- WDOIdentityVerificationPhase["documentVerificationFinal"] = "DOCUMENT_VERIFICATION_FINAL";
920
- /** OTP verification needed */
921
- WDOIdentityVerificationPhase["otp"] = "OTP_VERIFICATION";
922
- /** Completed */
923
- WDOIdentityVerificationPhase["completed"] = "COMPLETED";
924
- })(WDOIdentityVerificationPhase || (WDOIdentityVerificationPhase = {}));
925
- /** Types of available documents */
926
- var WDODocumentSubmitFileType;
927
- (function (WDODocumentSubmitFileType) {
928
- /** National ID card */
929
- WDODocumentSubmitFileType["idCard"] = "ID_CARD";
930
- /** Passport */
931
- WDODocumentSubmitFileType["passport"] = "PASSPORT";
932
- /** Driving license */
933
- WDODocumentSubmitFileType["driversLicense"] = "DRIVING_LICENSE";
934
- /** Selfie photo */
935
- WDODocumentSubmitFileType["selfiePhoto"] = "SELFIE_PHOTO";
936
- })(WDODocumentSubmitFileType || (WDODocumentSubmitFileType = {}));
937
- /** Side of the file */
938
- var WDODocumentSubmitFileSide;
939
- (function (WDODocumentSubmitFileSide) {
940
- /** Front side of an document. Usually the one with the picture */
941
- WDODocumentSubmitFileSide["front"] = "FRONT";
942
- /** Back side of an document */
943
- WDODocumentSubmitFileSide["back"] = "BACK";
944
- })(WDODocumentSubmitFileSide || (WDODocumentSubmitFileSide = {}));
945
- /** Status of the document */
946
- var WDODocumentStatus;
947
- (function (WDODocumentStatus) {
948
- /** Document was accepted */
949
- WDODocumentStatus["accepted"] = "ACCEPTED";
950
- /** Document is being uploaded to the verification system by the backend */
951
- WDODocumentStatus["uploadInProgress"] = "UPLOAD_IN_PROGRESS";
952
- /** Document are being processed */
953
- WDODocumentStatus["inProgress"] = "IN_PROGRESS";
954
- /** Document is pending verification */
955
- WDODocumentStatus["verificationPending"] = "VERIFICATION_PENDING";
956
- /** Document is being verified */
957
- WDODocumentStatus["verificationInProgress"] = "VERIFICATION_IN_PROGRESS";
958
- /** Document was rejected */
959
- WDODocumentStatus["rejected"] = "REJECTED";
960
- /** Verification of the document failed */
961
- WDODocumentStatus["failed"] = "FAILED";
962
- })(WDODocumentStatus || (WDODocumentStatus = {}));
963
- /** Converts WDODocumentType to DocumentSubmitFileType */
964
- function WDOCreateDocumentSubmitFileType(type) {
752
+ /* @internal */
753
+ function WDODocumentTypeToSubmitType(type) {
965
754
  switch (type) {
966
755
  case exports.WDODocumentType.idCard:
967
- return WDODocumentSubmitFileType.idCard;
756
+ return exports.WDODocumentSubmitFileType.idCard;
968
757
  case exports.WDODocumentType.passport:
969
- return WDODocumentSubmitFileType.passport;
758
+ return exports.WDODocumentSubmitFileType.passport;
970
759
  case exports.WDODocumentType.driversLicense:
971
- return WDODocumentSubmitFileType.driversLicense;
760
+ return exports.WDODocumentSubmitFileType.driversLicense;
972
761
  }
973
762
  }
974
- /** Converts WDODocumentSide to DocumentSubmitFileSide */
763
+ /* @internal */
975
764
  function WDOCreateDocumentSubmitFileSide(side) {
976
765
  switch (side) {
977
766
  case exports.WDODocumentSide.front:
978
- return WDODocumentSubmitFileSide.front;
767
+ return exports.WDODocumentSubmitFileSide.front;
979
768
  case exports.WDODocumentSide.back:
980
- return WDODocumentSubmitFileSide.back;
769
+ return exports.WDODocumentSubmitFileSide.back;
981
770
  }
982
771
  }
983
772
 
984
- /**
985
- * Copyright Wultra s.r.o.
986
- *
987
- * This source code is licensed under the Apache License, Version 2.0 license
988
- * found in the LICENSE file in the root directory of this source tree.
989
- *
990
- * SPDX-License-Identifier: Apache-2.0
991
- */
992
- /** Types of the verification state */
993
- exports.WDOVerificationStateType = void 0;
994
- (function (WDOVerificationStateType) {
995
- /**
996
- * Show the verification introduction screen where the user can start the activation.
997
- *
998
- * The next step should be calling the `consentGet()`.
999
- */
1000
- WDOVerificationStateType["intro"] = "intro";
1001
- /**
1002
- * Show approve/cancel user consent.
1003
- *
1004
- * The content of the text depends on the server configuration and might be plain text or HTML.
1005
- *
1006
- * The next step should be calling the `consentApprove`.
1007
- */
1008
- WDOVerificationStateType["consent"] = "consent";
1009
- /**
1010
- * Show document selection to the user. Which documents are available and how many
1011
- * can the user select is up to your backend configuration.
1012
- *
1013
- * The next step should be calling the `documentsSetSelectedTypes`.
1014
- */
1015
- WDOVerificationStateType["documentsToScanSelect"] = "documentsToScanSelect";
1016
- /**
1017
- * User should scan documents - display UI for the user to scan all necessary documents.
1018
- *
1019
- * The next step should be calling the `documentsSubmit`.
1020
- */
1021
- WDOVerificationStateType["scanDocument"] = "scanDocument";
1022
- /**
1023
- * The system is processing data - show loading with text hint from provided `WDOStatusCheckReason`.
1024
- *
1025
- * The next step should be calling the `status`.
1026
- */
1027
- WDOVerificationStateType["processing"] = "processing";
1028
- /**
1029
- * The user should be presented with a presence check.
1030
- * Presence check is handled by third-party SDK based on the project setup.
1031
- *
1032
- * The next step should be calling the `presenceCheckInit` to start the check and `presenceCheckSubmit` to
1033
- * 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.
1034
- */
1035
- WDOVerificationStateType["presenceCheck"] = "presenceCheck";
1036
- /**
1037
- * Show enter OTP screen with resend button.
1038
- *
1039
- * The next step should be calling the `verifyOTP` with user-entered OTP.
1040
- * The OTP is usually SMS or email.
1041
- */
1042
- WDOVerificationStateType["otp"] = "otp";
1043
- /**
1044
- * Verification failed and can be restarted
1045
- *
1046
- * The next step should be calling the `restartVerification` or `cancelWholeProcess` based on
1047
- * the user's decision if he wants to try it again or cancel the process.
1048
- */
1049
- WDOVerificationStateType["failed"] = "failed";
1050
- /**
1051
- * Verification is canceled and the user needs to start again with a new PowerAuth activation.
1052
- *
1053
- * The next step should be calling the `PowerAuth.removeActivationLocal()` and starting activation from scratch.
1054
- */
1055
- WDOVerificationStateType["endState"] = "endState";
1056
- /**
1057
- * Verification was successfully ended. Continue into your app flow.
1058
- */
1059
- WDOVerificationStateType["success"] = "success";
1060
- })(exports.WDOVerificationStateType || (exports.WDOVerificationStateType = {}));
1061
- /** The reason why the process ended in a non-recoverable state. */
1062
- exports.WDOEndStateReason = void 0;
1063
- (function (WDOEndStateReason) {
1064
- /**
1065
- * The verification was rejected by the system
1066
- *
1067
- * eg: Fake information, fraud detection, or user is trying repeatedly in a short time.
1068
- * The real reason is not presented to the user and is only audited on the server.
1069
- */
1070
- WDOEndStateReason["rejected"] = "rejected";
1071
- /**
1072
- * The limit of repeat tries was reached. There is a fixed number of tries that the user can reach
1073
- * before the system stops the process.
1074
- */
1075
- WDOEndStateReason["limitReached"] = "limitReached";
1076
- /** An unknown reason. */
1077
- WDOEndStateReason["other"] = "other";
1078
- })(exports.WDOEndStateReason || (exports.WDOEndStateReason = {}));
1079
- /**
1080
- * The reason for what we are waiting for. For example, we can wait for documents to be OCRed and matched against the database.
1081
- * Use these values for better loading texts to tell the user what is happening - some tasks may take some time
1082
- * and it would be frustrating to just show a generic loading indicator.
1083
- */
1084
- exports.WDOStatusCheckReason = void 0;
1085
- (function (WDOStatusCheckReason) {
1086
- WDOStatusCheckReason["unknown"] = "unknown";
1087
- WDOStatusCheckReason["documentUpload"] = "documentUpload";
1088
- WDOStatusCheckReason["documentVerification"] = "documentVerification";
1089
- WDOStatusCheckReason["documentAccepted"] = "documentAccepted";
1090
- WDOStatusCheckReason["documentsCrossVerification"] = "documentsCrossVerification";
1091
- WDOStatusCheckReason["clientVerification"] = "clientVerification";
1092
- WDOStatusCheckReason["clientAccepted"] = "clientAccepted";
1093
- WDOStatusCheckReason["verifyingPresence"] = "verifyingPresence";
1094
- })(exports.WDOStatusCheckReason || (exports.WDOStatusCheckReason = {}));
1095
-
1096
773
  /**
1097
774
  * Copyright Wultra s.r.o.
1098
775
  *
@@ -1126,10 +803,27 @@ var WDOVerificationScanProcess = /** @class */ (function () {
1126
803
  }, new Map());
1127
804
  groups.forEach(function (docs, type) {
1128
805
  var _a;
1129
- // TODO: type mismatch?
1130
- (_a = _this.documents.find(function (d) { return d.type === type; })) === null || _a === void 0 ? void 0 : _a.processServerData(docs);
806
+ (_a = _this.documents.find(function (d) { return WDODocumentTypeToSubmitType(d.type) === type; })) === null || _a === void 0 ? void 0 : _a.processServerData(docs);
1131
807
  });
1132
808
  };
809
+ /* @internal */
810
+ WDOVerificationScanProcess.fromCachedData = function (data) {
811
+ var split = data.split(":");
812
+ if (split.length != 2) {
813
+ WDOLogger.error("WDOVerificationScanProcess.fromCachedData: invalid cached data format");
814
+ return undefined;
815
+ }
816
+ if (split[0] !== "v1") {
817
+ WDOLogger.error("WDOVerificationScanProcess.fromCachedData: unsupported cached data version");
818
+ return undefined;
819
+ }
820
+ var types = split[1].split(",").map(function (s) { return s; });
821
+ return new WDOVerificationScanProcess(types);
822
+ };
823
+ /* @internal */
824
+ WDOVerificationScanProcess.prototype.dataForCache = function () {
825
+ return "v1:".concat(this.documents.map(function (d) { return d.type; }).join(","));
826
+ };
1133
827
  return WDOVerificationScanProcess;
1134
828
  }());
1135
829
  /** Document that needs to be scanned during process. */
@@ -1154,43 +848,871 @@ var WDOScannedDocument = /** @class */ (function () {
1154
848
  return exports.UploadState.rejected;
1155
849
  }
1156
850
  }
1157
- return exports.UploadState.accepted;
1158
- },
1159
- enumerable: false,
1160
- configurable: true
1161
- });
1162
- Object.defineProperty(WDOScannedDocument.prototype, "sides", {
1163
- /** Sides of the document that were uploaded on the server. */
1164
- get: function () { return this._sides; },
1165
- enumerable: false,
1166
- configurable: true
1167
- });
1168
- /* @internal */
1169
- WDOScannedDocument.prototype.processServerData = function (documents) {
1170
- this._sides = documents.map(function (doc) { var _a, _b; return new Side(doc.side == WDODocumentSubmitFileSide.front ? exports.WDODocumentSide.front : exports.WDODocumentSide.back, doc.id, ((_b = (_a = doc.errors) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ? exports.UploadState.rejected : exports.UploadState.accepted); });
851
+ return exports.UploadState.accepted;
852
+ },
853
+ enumerable: false,
854
+ configurable: true
855
+ });
856
+ Object.defineProperty(WDOScannedDocument.prototype, "sides", {
857
+ /** Sides of the document that were uploaded on the server. */
858
+ get: function () { return this._sides; },
859
+ enumerable: false,
860
+ configurable: true
861
+ });
862
+ /* @internal */
863
+ WDOScannedDocument.prototype.processServerData = function (documents) {
864
+ this._sides = documents.map(function (doc) { var _a, _b; return new Side(doc.side == exports.WDODocumentSubmitFileSide.front ? exports.WDODocumentSide.front : exports.WDODocumentSide.back, doc.id, ((_b = (_a = doc.errors) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ? exports.UploadState.rejected : exports.UploadState.accepted); });
865
+ };
866
+ return WDOScannedDocument;
867
+ }());
868
+ /** State of the document on the server. */
869
+ exports.UploadState = void 0;
870
+ (function (UploadState) {
871
+ /** The document was not uploaded yet. */
872
+ UploadState[UploadState["notUploaded"] = 0] = "notUploaded";
873
+ /** The document was accepted by the server. */
874
+ UploadState[UploadState["accepted"] = 1] = "accepted";
875
+ /** The document was rejected and needs to be re-uploaded. */
876
+ UploadState[UploadState["rejected"] = 2] = "rejected";
877
+ })(exports.UploadState || (exports.UploadState = {}));
878
+ /** Side of the uploaded document. */
879
+ var Side = /** @class */ (function () {
880
+ /* @internal */
881
+ function Side(type, serverId, uploadState) {
882
+ this.type = type;
883
+ this.serverId = serverId;
884
+ this.uploadState = uploadState;
885
+ }
886
+ return Side;
887
+ }());
888
+
889
+ /**
890
+ * Copyright Wultra s.r.o.
891
+ *
892
+ * This source code is licensed under the Apache License, Version 2.0 license
893
+ * found in the LICENSE file in the root directory of this source tree.
894
+ *
895
+ * SPDX-License-Identifier: Apache-2.0
896
+ */
897
+ /** Possible results of the user consent. */
898
+ exports.WDOConsentResponse = void 0;
899
+ (function (WDOConsentResponse) {
900
+ /** User approved the consent. */
901
+ WDOConsentResponse[WDOConsentResponse["approved"] = 0] = "approved";
902
+ /** User declined the consent. */
903
+ WDOConsentResponse[WDOConsentResponse["declined"] = 1] = "declined";
904
+ /** Consent is not required. */
905
+ WDOConsentResponse[WDOConsentResponse["notRequired"] = 2] = "notRequired";
906
+ })(exports.WDOConsentResponse || (exports.WDOConsentResponse = {}));
907
+ /**
908
+ * Service that can verify previously activated PowerAuth instance.
909
+ *
910
+ * When PowerAuth instance was activated with weak credentials via `WDOActivationService`, user needs to verify his genuine presence.
911
+ * This can be confirmed in the `WDOVerificationService.isVerificationRequired` which will be `true`.
912
+ *
913
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
914
+ */
915
+ var WDOBaseVerificationService = /** @class */ (function () {
916
+ /**
917
+ * Creates service instance
918
+ *
919
+ * @param powerauth Configured PowerAuth instance. This instance needs to be without valid activation.
920
+ * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
921
+ */
922
+ function WDOBaseVerificationService(powerauth, baseUrl) {
923
+ // --
924
+ /* @internal */
925
+ this.lastStatus = undefined;
926
+ this.powerauth = powerauth;
927
+ this.api = new WDOApi(powerauth, baseUrl);
928
+ }
929
+ /** Checks if verification is required based on PowerAuth activation status */
930
+ WDOBaseVerificationService.isVerificationRequiredInternal = function (paStatus) {
931
+ var _a;
932
+ var flags = (_a = paStatus.customObject) === null || _a === void 0 ? void 0 : _a.activationFlags;
933
+ return !!flags && flags.some(function (f) { return f === "VERIFICATION_PENDING" || f === "VERIFICATION_IN_PROGRESS"; });
934
+ };
935
+ /* @internal */
936
+ WDOBaseVerificationService.prototype.cacheKey = function () { return "wdocp_".concat(this.powerauth.instanceId); };
937
+ /* @internal */
938
+ WDOBaseVerificationService.prototype.setCachedProcess = function (process) {
939
+ return __awaiter(this, void 0, void 0, function () {
940
+ return __generator(this, function (_a) {
941
+ switch (_a.label) {
942
+ case 0: return [4 /*yield*/, WDOPlatform.cache.set(this.cacheKey(), process === null || process === void 0 ? void 0 : process.dataForCache())];
943
+ case 1:
944
+ _a.sent();
945
+ return [2 /*return*/];
946
+ }
947
+ });
948
+ });
949
+ };
950
+ /* @internal */
951
+ WDOBaseVerificationService.prototype.getCachedProcess = function () {
952
+ return __awaiter(this, void 0, void 0, function () {
953
+ var data;
954
+ return __generator(this, function (_a) {
955
+ switch (_a.label) {
956
+ case 0: return [4 /*yield*/, WDOPlatform.cache.get(this.cacheKey())];
957
+ case 1:
958
+ data = _a.sent();
959
+ if (!data) {
960
+ return [2 /*return*/, undefined];
961
+ }
962
+ return [2 /*return*/, WDOVerificationScanProcess.fromCachedData(data)];
963
+ }
964
+ });
965
+ });
966
+ };
967
+ // PUBLIC API
968
+ /**
969
+ * Accept language for the outgoing requests headers.
970
+ * Default value is "en".
971
+ *
972
+ * Standard RFC "Accept-Language" https://tools.ietf.org/html/rfc7231#section-5.3.5
973
+ * Response texts are based on this setting. For example when "de" is set, server
974
+ * will return error texts and other in german (if available).
975
+ */
976
+ WDOBaseVerificationService.prototype.changeAcceptLanguage = function (language) {
977
+ this.api.networking.acceptLanguage = language;
978
+ };
979
+ Object.defineProperty(WDOBaseVerificationService.prototype, "otpResendPeriodSeconds", {
980
+ /** Time in seconds that user needs to wait between OTP resend calls */
981
+ get: function () {
982
+ var _a, _b;
983
+ return (_b = (_a = this.lastStatus) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.otpResendPeriodSeconds;
984
+ },
985
+ enumerable: false,
986
+ configurable: true
987
+ });
988
+ /**
989
+ * Status of the verification.
990
+ */
991
+ WDOBaseVerificationService.prototype.status = function () {
992
+ return __awaiter(this, void 0, void 0, function () {
993
+ var response, _a, vf, _b, docsResponse, documents, cachedProcess, error_1;
994
+ var _c;
995
+ return __generator(this, function (_d) {
996
+ switch (_d.label) {
997
+ case 0:
998
+ _d.trys.push([0, 18, , 19]);
999
+ return [4 /*yield*/, this.api.verificationStatus()];
1000
+ case 1:
1001
+ response = _d.sent();
1002
+ WDOLogger.info("Verification status successfully retrieved.");
1003
+ WDOLogger.debug("Verification status: ".concat(JSON.stringify(response)));
1004
+ if (response.consentRequired == undefined) {
1005
+ WDOLogger.debug("Consent required flag not present in the response, assuming false");
1006
+ response.consentRequired = false;
1007
+ }
1008
+ _a = response.identityVerificationStatus;
1009
+ switch (_a) {
1010
+ case exports.WDOIdentityVerificationStatus.failed: return [3 /*break*/, 2];
1011
+ case exports.WDOIdentityVerificationStatus.rejected: return [3 /*break*/, 2];
1012
+ case exports.WDOIdentityVerificationStatus.notInitialized: return [3 /*break*/, 2];
1013
+ case exports.WDOIdentityVerificationStatus.accepted: return [3 /*break*/, 2];
1014
+ }
1015
+ return [3 /*break*/, 4];
1016
+ case 2:
1017
+ WDOLogger.debug("Status ".concat(response.identityVerificationStatus, " - clearing cache"));
1018
+ return [4 /*yield*/, this.setCachedProcess(undefined)];
1019
+ case 3:
1020
+ _d.sent();
1021
+ return [3 /*break*/, 5];
1022
+ case 4:
1023
+ // no-op
1024
+ return [3 /*break*/, 5];
1025
+ case 5:
1026
+ this.lastStatus = response;
1027
+ vf = new WDOVerificationStatus(response);
1028
+ WDOLogger.info("Verification next step: ".concat(vf.description()));
1029
+ _b = vf.nextStep;
1030
+ switch (_b) {
1031
+ case WDONextStep.intro: return [3 /*break*/, 6];
1032
+ case WDONextStep.documentScan: return [3 /*break*/, 7];
1033
+ case WDONextStep.presenceCheck: return [3 /*break*/, 10];
1034
+ case WDONextStep.otp: return [3 /*break*/, 11];
1035
+ case WDONextStep.statusCheck: return [3 /*break*/, 12];
1036
+ case WDONextStep.failed: return [3 /*break*/, 13];
1037
+ case WDONextStep.rejected: return [3 /*break*/, 14];
1038
+ case WDONextStep.success: return [3 /*break*/, 15];
1039
+ case WDONextStep.finishActivation: return [3 /*break*/, 16];
1040
+ }
1041
+ return [3 /*break*/, 17];
1042
+ case 6: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.intro, consentRequired: response.consentRequired })];
1043
+ case 7:
1044
+ WDOLogger.debug("Verifying documents status");
1045
+ return [4 /*yield*/, this.api.verificationDocumentsStatus(response.processId)];
1046
+ case 8:
1047
+ docsResponse = _d.sent();
1048
+ WDOLogger.debug("Documents status: ".concat(JSON.stringify(docsResponse)));
1049
+ documents = docsResponse.documents;
1050
+ return [4 /*yield*/, this.getCachedProcess()];
1051
+ case 9:
1052
+ cachedProcess = _d.sent();
1053
+ if (cachedProcess) {
1054
+ cachedProcess.feedServerData(docsResponse.documents);
1055
+ if (documents.some(function (d) { return documentAction(d) === "error"; }) || documents.some(function (d) { return d.errors != undefined && d.errors.length > 0; })) {
1056
+ WDOLogger.debug("At least one document in error state: ".concat(documents.some(function (d) { return documentAction(d) === "error"; }), ", ").concat(documents.some(function (d) { return d.errors != undefined && d.errors.length > 0; })));
1057
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.scanDocument, process: cachedProcess })];
1058
+ }
1059
+ else if (documents.every(function (d) { return documentAction(d) === "proceed"; })) {
1060
+ WDOLogger.debug("All documents accepted, proceeding");
1061
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.scanDocument, process: cachedProcess })];
1062
+ }
1063
+ else if (documents.some(function (d) { return documentAction(d) === "wait"; })) {
1064
+ WDOLogger.debug("At least one document still in progress, moving to processing");
1065
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.documentVerification })];
1066
+ }
1067
+ else if (documents.length == 0) {
1068
+ WDOLogger.debug("No documents scanned, scan documents...");
1069
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.scanDocument, process: cachedProcess })];
1070
+ }
1071
+ else {
1072
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.failed })];
1073
+ }
1074
+ }
1075
+ else {
1076
+ if (documents.length == 0) {
1077
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.documentsToScanSelect })];
1078
+ }
1079
+ else {
1080
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.failed })];
1081
+ }
1082
+ }
1083
+ case 10: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.presenceCheck })];
1084
+ case 11: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.otp })];
1085
+ case 12: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: (_c = vf.statusCheckReason) !== null && _c !== void 0 ? _c : exports.WDOStatusCheckReason.unknown })];
1086
+ case 13: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.failed })];
1087
+ case 14: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.endState, reason: exports.WDOEndStateReason.rejected })];
1088
+ case 15: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.success })];
1089
+ case 16: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.finishActivation })];
1090
+ case 17: return [3 /*break*/, 19];
1091
+ case 18:
1092
+ error_1 = _d.sent();
1093
+ WDOLogger.error("Error fetching verification status: ".concat(JSON.stringify(error_1)));
1094
+ this.lastStatus = undefined;
1095
+ throw this.processError(error_1);
1096
+ case 19: return [2 /*return*/];
1097
+ }
1098
+ });
1099
+ });
1100
+ };
1101
+ /**
1102
+ * Returns consent text for user to approve. The content of the text depends on the server configuration and might be plain text or HTML.
1103
+ *
1104
+ * Consent text explains how the service will handle his document photos or selfie scans.
1105
+ */
1106
+ WDOBaseVerificationService.prototype.consentGet = function () {
1107
+ return __awaiter(this, void 0, void 0, function () {
1108
+ var pid, response;
1109
+ return __generator(this, function (_a) {
1110
+ switch (_a.label) {
1111
+ case 0:
1112
+ pid = this.verifyHasActiveProcess();
1113
+ return [4 /*yield*/, this.handleError(this.api.verificationGetConsentText(pid))];
1114
+ case 1:
1115
+ response = _a.sent();
1116
+ return [2 /*return*/, response.consentText];
1117
+ }
1118
+ });
1119
+ });
1120
+ };
1121
+ /**
1122
+ * Start the identity verification after user approved the consent (if required)
1123
+ *
1124
+ * @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`).
1125
+ */
1126
+ WDOBaseVerificationService.prototype.start = function (consentApprovedByUser) {
1127
+ return __awaiter(this, void 0, void 0, function () {
1128
+ var pid, _a;
1129
+ var _b, _c;
1130
+ return __generator(this, function (_d) {
1131
+ switch (_d.label) {
1132
+ case 0:
1133
+ pid = this.verifyHasActiveProcess();
1134
+ _a = consentApprovedByUser;
1135
+ switch (_a) {
1136
+ case exports.WDOConsentResponse.approved: return [3 /*break*/, 1];
1137
+ case exports.WDOConsentResponse.declined: return [3 /*break*/, 3];
1138
+ case exports.WDOConsentResponse.notRequired: return [3 /*break*/, 5];
1139
+ }
1140
+ return [3 /*break*/, 6];
1141
+ case 1:
1142
+ WDOLogger.info("User approved consent - resolving on server");
1143
+ return [4 /*yield*/, this.handleError(this.api.verificationResolveConsent(pid, true))];
1144
+ case 2:
1145
+ _d.sent();
1146
+ return [3 /*break*/, 6];
1147
+ case 3:
1148
+ WDOLogger.info("User declined consent - returning to intro state");
1149
+ return [4 /*yield*/, this.handleError(this.api.verificationResolveConsent(pid, false))];
1150
+ case 4:
1151
+ _d.sent();
1152
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.intro, consentRequired: (_c = (_b = this.lastStatus) === null || _b === void 0 ? void 0 : _b.consentRequired) !== null && _c !== void 0 ? _c : true })]; // TODO: ok to assume true?
1153
+ case 5:
1154
+ WDOLogger.info("Consent not required - proceeding");
1155
+ _d.label = 6;
1156
+ case 6: return [4 /*yield*/, this.handleError(this.api.verificationStart(pid))];
1157
+ case 7:
1158
+ _d.sent();
1159
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.documentsToScanSelect })];
1160
+ }
1161
+ });
1162
+ });
1163
+ };
1164
+ /**
1165
+ * Get the token for the document scanning SDK, when required.
1166
+ *
1167
+ * This is needed for example for ZenID or BlinkID provider.
1168
+ *
1169
+ * @param challenge Optional challenge provided by the scanning SDK.
1170
+ */
1171
+ WDOBaseVerificationService.prototype.documentsInitSDK = function (challenge) {
1172
+ return __awaiter(this, void 0, void 0, function () {
1173
+ var pid, response, blinkID, zenId;
1174
+ return __generator(this, function (_a) {
1175
+ switch (_a.label) {
1176
+ case 0:
1177
+ pid = this.verifyHasActiveProcess();
1178
+ return [4 /*yield*/, this.handleError(this.api.verificationInitScanSDK(pid, challenge !== null && challenge !== void 0 ? challenge : "-"))]; // TODO: is "-" acceptable?
1179
+ case 1:
1180
+ response = _a.sent() // TODO: is "-" acceptable?
1181
+ ;
1182
+ blinkID = response.attributes["license-key"];
1183
+ zenId = response.attributes["zenid-sdk-init-response"];
1184
+ return [2 /*return*/, { blinkIDKey: blinkID, zenIDToken: zenId }];
1185
+ }
1186
+ });
1187
+ });
1188
+ };
1189
+ /**
1190
+ * Set which documents will be scanned.
1191
+ *
1192
+ * Note that this needs to be in sync what server expects based on the configuration.
1193
+ *
1194
+ * @param types Types of documents to scan.
1195
+ */
1196
+ WDOBaseVerificationService.prototype.documentsSetSelectedTypes = function (types) {
1197
+ return __awaiter(this, void 0, void 0, function () {
1198
+ var process;
1199
+ return __generator(this, function (_a) {
1200
+ switch (_a.label) {
1201
+ case 0:
1202
+ WDOLogger.debug("Submitting selected document types: ".concat(types));
1203
+ process = new WDOVerificationScanProcess(types);
1204
+ return [4 /*yield*/, this.setCachedProcess(process)];
1205
+ case 1:
1206
+ _a.sent();
1207
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.scanDocument, process: process })];
1208
+ }
1209
+ });
1210
+ });
1211
+ };
1212
+ /**
1213
+ * Upload document files to the server. The order of the documents is up to you.
1214
+ * Make sure that uploaded document are reasonable size so you're not uploading large files.
1215
+ *
1216
+ * If you're uploading the same document file again, you need to include the `originalDocumentId` otherwise it will be rejected by the server.
1217
+ *
1218
+ * @param files Document files to upload.
1219
+ */
1220
+ WDOBaseVerificationService.prototype.documentsSubmit = function (files) {
1221
+ return __awaiter(this, void 0, void 0, function () {
1222
+ var pid, resubmit, submitFiles;
1223
+ return __generator(this, function (_a) {
1224
+ switch (_a.label) {
1225
+ case 0:
1226
+ pid = this.verifyHasActiveProcess();
1227
+ resubmit = files.some(function (f) { return f.originalDocumentId != undefined; });
1228
+ submitFiles = files.map(function (f) {
1229
+ return {
1230
+ filename: "".concat(f.type.toLowerCase(), "_").concat(f.side.toLowerCase(), ".jpg"),
1231
+ type: WDODocumentTypeToSubmitType(f.type),
1232
+ side: WDOCreateDocumentSubmitFileSide(f.side),
1233
+ originalDocumentId: f.originalDocumentId,
1234
+ data: f.data
1235
+ };
1236
+ });
1237
+ return [4 /*yield*/, this.handleError(this.api.verificationSubmitDocuments(pid, resubmit, submitFiles))];
1238
+ case 1:
1239
+ _a.sent();
1240
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.documentUpload })];
1241
+ }
1242
+ });
1243
+ });
1244
+ };
1245
+ /**
1246
+ * Initiates the presence check. This returns attributes that are needed to start the 3rd party SDK (if needed).
1247
+ */
1248
+ WDOBaseVerificationService.prototype.presenceCheckInit = function () {
1249
+ return __awaiter(this, void 0, void 0, function () {
1250
+ var pid, response;
1251
+ return __generator(this, function (_a) {
1252
+ switch (_a.label) {
1253
+ case 0:
1254
+ pid = this.verifyHasActiveProcess();
1255
+ return [4 /*yield*/, this.handleError(this.api.verificationPresenceCheckInit(pid))];
1256
+ case 1:
1257
+ response = _a.sent();
1258
+ return [2 /*return*/, this.processSuccess(response.sessionAttributes)];
1259
+ }
1260
+ });
1261
+ });
1262
+ };
1263
+ /**
1264
+ * Call when presence check was finished in the 3rd party SDK.
1265
+ */
1266
+ WDOBaseVerificationService.prototype.presenceCheckSubmit = function () {
1267
+ return __awaiter(this, void 0, void 0, function () {
1268
+ var pid;
1269
+ return __generator(this, function (_a) {
1270
+ switch (_a.label) {
1271
+ case 0:
1272
+ pid = this.verifyHasActiveProcess();
1273
+ return [4 /*yield*/, this.handleError(this.api.verificationPresenceCheckSubmit(pid))];
1274
+ case 1:
1275
+ _a.sent();
1276
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.verifyingPresence })];
1277
+ }
1278
+ });
1279
+ });
1280
+ };
1281
+ /**
1282
+ * Verification restart. When sucessfully called, intro screen should be presented.
1283
+ */
1284
+ WDOBaseVerificationService.prototype.restartVerification = function () {
1285
+ return __awaiter(this, void 0, void 0, function () {
1286
+ var pid;
1287
+ return __generator(this, function (_a) {
1288
+ switch (_a.label) {
1289
+ case 0:
1290
+ pid = this.verifyHasActiveProcess();
1291
+ return [4 /*yield*/, this.handleError(this.api.verificationCleanup(pid))];
1292
+ case 1:
1293
+ _a.sent();
1294
+ return [4 /*yield*/, this.setCachedProcess(undefined)];
1295
+ case 2:
1296
+ _a.sent();
1297
+ WDOLogger.info("Verification process restarted.");
1298
+ return [4 /*yield*/, this.status()];
1299
+ case 3:
1300
+ // return new status
1301
+ return [2 /*return*/, _a.sent()];
1302
+ }
1303
+ });
1304
+ });
1305
+ };
1306
+ /**
1307
+ * Cancel the whole activation/verification. After this it's no longer possible to call
1308
+ * any API of this library and PowerAuth activation should be removed and activation started again.
1309
+ */
1310
+ WDOBaseVerificationService.prototype.cancelWholeProcess = function () {
1311
+ return __awaiter(this, void 0, void 0, function () {
1312
+ var pid;
1313
+ return __generator(this, function (_a) {
1314
+ switch (_a.label) {
1315
+ case 0:
1316
+ pid = this.verifyHasActiveProcess();
1317
+ return [4 /*yield*/, this.handleError(this.api.verificationCleanup(pid))];
1318
+ case 1:
1319
+ _a.sent();
1320
+ return [4 /*yield*/, this.setCachedProcess(undefined)];
1321
+ case 2:
1322
+ _a.sent();
1323
+ WDOLogger.info("Verification process canceled.");
1324
+ return [2 /*return*/];
1325
+ }
1326
+ });
1327
+ });
1328
+ };
1329
+ /**
1330
+ * Verify OTP that user entered as a last step of the verification.
1331
+ *
1332
+ * @param otp OTP that user obtained via other channel (usually SMS or email).
1333
+ */
1334
+ WDOBaseVerificationService.prototype.verifyOTP = function (otp) {
1335
+ return __awaiter(this, void 0, void 0, function () {
1336
+ var pid, response;
1337
+ return __generator(this, function (_a) {
1338
+ switch (_a.label) {
1339
+ case 0:
1340
+ pid = this.verifyHasActiveProcess();
1341
+ return [4 /*yield*/, this.handleError(this.api.verifyOTP(pid, otp))];
1342
+ case 1:
1343
+ response = _a.sent();
1344
+ if (response.verified) {
1345
+ WDOLogger.info("OTP verified successfully.");
1346
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.unknown })];
1347
+ }
1348
+ else {
1349
+ if (response.remainingAttempts > 0 && response.expired == false) {
1350
+ WDOLogger.error("OTP verification failed, remaining attempts: ".concat(response.remainingAttempts));
1351
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.otp, remainingAttempts: response.remainingAttempts })];
1352
+ }
1353
+ else {
1354
+ WDOLogger.error("OTP verification failed, no remaining attempts or OTP expired");
1355
+ throw this.processError(new WDOError(exports.WDOErrorReason.otpFailed, "OTP verification failed, no remaining attempts or OTP expired"));
1356
+ }
1357
+ }
1358
+ }
1359
+ });
1360
+ });
1361
+ };
1362
+ /**
1363
+ * Finishes verification by creating a new PowerAuth activation on given `newPowerAuthInstance`.
1364
+ *
1365
+ * Needs to be called when "activationFinish" next step is returned from the `status()` call.
1366
+ *
1367
+ * The method verifies that the provided `password` is the same as used in the original activation
1368
+ * (if `validatePassword` is set to `true`), then it calls the server API to finish
1369
+ * the verification and obtain the activation code for the new activation. Finally, it creates
1370
+ * a new activation on `newPowerAuthInstance` using the obtained activation code and persists it
1371
+ * with the provided `newPassword`.
1372
+ *
1373
+ * After successful completion, the original PowerAuth instance becomes invalid (`REMOVED` state) and cannot be used anymore.
1374
+ *
1375
+ * @param newPowerAuthInstance PowerAuth instance where to create new activation. This instance must not have an existing activation.
1376
+ * @param newActivationName Name of the new activation to be created on `newPowerAuthInstance`.
1377
+ * @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).
1378
+ * @param validatePassword If set to `true`, the method verifies that the provided `newPassword` matches the password of the original activation.
1379
+ * @param userIdentification Optional user identification object to be sent to the server during the finish activation process.
1380
+ */
1381
+ WDOBaseVerificationService.prototype.finishActivation = function (newPowerAuthInstance, newActivationName, newPassword, validatePassword, userIdentification) {
1382
+ return __awaiter(this, void 0, void 0, function () {
1383
+ var pid, response, activation, e_1;
1384
+ return __generator(this, function (_a) {
1385
+ switch (_a.label) {
1386
+ case 0:
1387
+ _a.trys.push([0, , 12, 14]);
1388
+ pid = this.verifyHasActiveProcess();
1389
+ if (!validatePassword) return [3 /*break*/, 2];
1390
+ // password must be reusable
1391
+ if (newPassword.destroyOnUse) { // TODO: ok? maybe make this property public in PowerAuthPassword?
1392
+ throw new WDOError(exports.WDOErrorReason.invalidParameter, "The provided PowerAuthPassword is configured to be destroyed on use, which is not supported in finishActivation with validatePassword=true. Please provide a reusable PowerAuthPassword instance. (with destroyOnUse=false)");
1393
+ }
1394
+ // validate password against original activation
1395
+ return [4 /*yield*/, this.powerauth.validatePassword(newPassword)];
1396
+ case 1:
1397
+ // validate password against original activation
1398
+ _a.sent();
1399
+ _a.label = 2;
1400
+ case 2: return [4 /*yield*/, this.handleError(this.api.verificationFinishActivation(pid, userIdentification))];
1401
+ case 3:
1402
+ response = _a.sent();
1403
+ _a.label = 4;
1404
+ case 4:
1405
+ _a.trys.push([4, 7, , 11]);
1406
+ activation = WDOPlatform.powerAuthFactory.activationWithActivationCode(response.activationCode, newActivationName, undefined);
1407
+ return [4 /*yield*/, newPowerAuthInstance.createActivation(activation)];
1408
+ case 5:
1409
+ _a.sent();
1410
+ return [4 /*yield*/, newPowerAuthInstance.persistActivation(WDOPlatform.powerAuthFactory.authenticationWithPassword(newPassword))];
1411
+ case 6:
1412
+ _a.sent();
1413
+ return [3 /*break*/, 11];
1414
+ case 7:
1415
+ e_1 = _a.sent();
1416
+ return [4 /*yield*/, newPowerAuthInstance.canStartActivation()];
1417
+ case 8:
1418
+ if (!((_a.sent()) == false)) return [3 /*break*/, 10];
1419
+ return [4 /*yield*/, newPowerAuthInstance.removeActivationLocal()];
1420
+ case 9:
1421
+ _a.sent();
1422
+ _a.label = 10;
1423
+ case 10: throw e_1; // rethrow
1424
+ case 11: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.success })];
1425
+ case 12: return [4 /*yield*/, newPassword.clear()]; // destroy the password after use
1426
+ case 13:
1427
+ _a.sent(); // destroy the password after use
1428
+ return [7 /*endfinally*/];
1429
+ case 14: return [2 /*return*/];
1430
+ }
1431
+ });
1432
+ });
1433
+ };
1434
+ /**
1435
+ * Request OTP resend.
1436
+ *
1437
+ * Since SMS or emails can fail to deliver, use this to send the OTP again.
1438
+ */
1439
+ WDOBaseVerificationService.prototype.resendOTP = function () {
1440
+ return __awaiter(this, void 0, void 0, function () {
1441
+ var pid;
1442
+ return __generator(this, function (_a) {
1443
+ switch (_a.label) {
1444
+ case 0:
1445
+ pid = this.verifyHasActiveProcess();
1446
+ return [4 /*yield*/, this.handleError(this.api.verificationResendOTP(pid))];
1447
+ case 1:
1448
+ _a.sent();
1449
+ return [2 /*return*/];
1450
+ }
1451
+ });
1452
+ });
1453
+ };
1454
+ /**
1455
+ * @internal
1456
+ * Demo endpoint available only in Wultra Demo systems.
1457
+ *
1458
+ * If the app is running against our demo server, you can retrieve the OTP without needing to send SMS or emails.
1459
+ */
1460
+ WDOBaseVerificationService.prototype.getOTP = function () {
1461
+ return __awaiter(this, void 0, void 0, function () {
1462
+ var pid;
1463
+ return __generator(this, function (_a) {
1464
+ switch (_a.label) {
1465
+ case 0:
1466
+ WDOLogger.debug("Activation: getting OTP from server (only for testing purposes)");
1467
+ pid = this.verifyHasActiveProcess();
1468
+ return [4 /*yield*/, this.api.activationGetOTP(pid, "USER_VERIFICATION")];
1469
+ case 1: return [2 /*return*/, (_a.sent()).otpCode];
1470
+ }
1471
+ });
1472
+ });
1473
+ };
1474
+ // PRIVATE METHODS
1475
+ /* @internal */
1476
+ WDOBaseVerificationService.prototype.verifyHasActiveProcess = function () {
1477
+ var _a;
1478
+ var pid = (_a = this.lastStatus) === null || _a === void 0 ? void 0 : _a.processId;
1479
+ if (!pid) {
1480
+ WDOLogger.error("Process id not available - did you start the verification process and fetched the status?");
1481
+ throw new WDOError(exports.WDOErrorReason.processNotInProgress, "Process id not available - did you start the verification process and fetched the status?");
1482
+ }
1483
+ return pid;
1484
+ };
1485
+ /* @internal */
1486
+ WDOBaseVerificationService.prototype.processSuccess = function (result) {
1487
+ var _a;
1488
+ if (result.type !== undefined) {
1489
+ (_a = this.listener) === null || _a === void 0 ? void 0 : _a.verificationStatusChanged(this, result);
1490
+ }
1491
+ return result;
1492
+ };
1493
+ /* @internal */
1494
+ WDOBaseVerificationService.prototype.handleError = function (promise) {
1495
+ var _this = this;
1496
+ return promise.catch(function (error) {
1497
+ throw _this.processError(error);
1498
+ });
1499
+ };
1500
+ /* @internal */
1501
+ WDOBaseVerificationService.prototype.processError = function (error) {
1502
+ return __awaiter(this, void 0, void 0, function () {
1503
+ var status_1;
1504
+ var _b;
1505
+ return __generator(this, function (_c) {
1506
+ switch (_c.label) {
1507
+ case 0:
1508
+ if (!(error.code === "AUTHENTICATION_ERROR")) return [3 /*break*/, 4];
1509
+ _c.label = 1;
1510
+ case 1:
1511
+ _c.trys.push([1, 3, , 4]);
1512
+ return [4 /*yield*/, this.powerauth.fetchActivationStatus()];
1513
+ case 2:
1514
+ status_1 = _c.sent();
1515
+ if (status_1.state !== "ACTIVE") {
1516
+ WDOLogger.error("PowerAuth status is not active (status".concat(status_1.state, ") - notifying the delegate and returning and error."));
1517
+ (_b = this.listener) === null || _b === void 0 ? void 0 : _b.powerAuthActivationStatusChanged(this, status_1);
1518
+ return [2 /*return*/, new WDOError(exports.WDOErrorReason.powerauthNotActivated, "PowerAuth activation is not active anymore")];
1519
+ }
1520
+ return [3 /*break*/, 4];
1521
+ case 3:
1522
+ _c.sent();
1523
+ return [3 /*break*/, 4];
1524
+ case 4: return [2 /*return*/, error];
1525
+ }
1526
+ });
1527
+ });
1528
+ };
1529
+ return WDOBaseVerificationService;
1530
+ }());
1531
+ // INTERNAL CLASSES
1532
+ /**
1533
+ @internal
1534
+ Internal status that works as a translation layer between server API and SDK API
1535
+ */
1536
+ var WDOVerificationStatus = /** @class */ (function () {
1537
+ /** Translation from server status to phone status. */
1538
+ function WDOVerificationStatus(serverResponse) {
1539
+ var phase = serverResponse.identityVerificationPhase;
1540
+ var status = serverResponse.identityVerificationStatus;
1541
+ var nextStep = undefined;
1542
+ var statusCheckReason = undefined;
1543
+ // UNDEFINED PHASE
1544
+ if (phase == undefined) {
1545
+ switch (status) {
1546
+ case exports.WDOIdentityVerificationStatus.notInitialized:
1547
+ nextStep = WDONextStep.intro;
1548
+ break;
1549
+ case exports.WDOIdentityVerificationStatus.failed:
1550
+ nextStep = WDONextStep.failed;
1551
+ break;
1552
+ }
1553
+ }
1554
+ // DOCUMENT UPLOAD PHASE
1555
+ else if (phase === exports.WDOIdentityVerificationPhase.documentUpload) {
1556
+ switch (status) {
1557
+ case exports.WDOIdentityVerificationStatus.inProgress:
1558
+ nextStep = WDONextStep.documentScan;
1559
+ break;
1560
+ case exports.WDOIdentityVerificationStatus.verificationPending:
1561
+ nextStep = WDONextStep.statusCheck;
1562
+ statusCheckReason = exports.WDOStatusCheckReason.documentVerification;
1563
+ break;
1564
+ case exports.WDOIdentityVerificationStatus.failed:
1565
+ nextStep = WDONextStep.failed;
1566
+ break;
1567
+ }
1568
+ }
1569
+ // DOCUMENT VERIFICATION PHASE
1570
+ else if (phase === exports.WDOIdentityVerificationPhase.documentVerification) {
1571
+ switch (status) {
1572
+ case exports.WDOIdentityVerificationStatus.accepted:
1573
+ nextStep = WDONextStep.statusCheck;
1574
+ statusCheckReason = exports.WDOStatusCheckReason.documentAccepted;
1575
+ break;
1576
+ case exports.WDOIdentityVerificationStatus.inProgress:
1577
+ nextStep = WDONextStep.statusCheck;
1578
+ statusCheckReason = exports.WDOStatusCheckReason.documentVerification;
1579
+ break;
1580
+ case exports.WDOIdentityVerificationStatus.failed:
1581
+ nextStep = WDONextStep.failed;
1582
+ break;
1583
+ case exports.WDOIdentityVerificationStatus.rejected:
1584
+ nextStep = WDONextStep.rejected;
1585
+ break;
1586
+ }
1587
+ }
1588
+ // DOCUMENT VERIFICATION FINAL PHASE
1589
+ else if (phase === exports.WDOIdentityVerificationPhase.documentVerificationFinal) {
1590
+ switch (status) {
1591
+ case exports.WDOIdentityVerificationStatus.accepted:
1592
+ nextStep = WDONextStep.statusCheck;
1593
+ statusCheckReason = exports.WDOStatusCheckReason.documentsCrossVerification;
1594
+ break;
1595
+ case exports.WDOIdentityVerificationStatus.inProgress:
1596
+ nextStep = WDONextStep.statusCheck;
1597
+ statusCheckReason = exports.WDOStatusCheckReason.documentsCrossVerification;
1598
+ break;
1599
+ case exports.WDOIdentityVerificationStatus.failed:
1600
+ nextStep = WDONextStep.failed;
1601
+ break;
1602
+ case exports.WDOIdentityVerificationStatus.rejected:
1603
+ nextStep = WDONextStep.rejected;
1604
+ break;
1605
+ }
1606
+ }
1607
+ // CLIENT EVALUATION PHASE
1608
+ else if (phase === exports.WDOIdentityVerificationPhase.clientEvaluation) {
1609
+ switch (status) {
1610
+ case exports.WDOIdentityVerificationStatus.inProgress:
1611
+ nextStep = WDONextStep.statusCheck;
1612
+ statusCheckReason = exports.WDOStatusCheckReason.clientVerification;
1613
+ break;
1614
+ case exports.WDOIdentityVerificationStatus.accepted:
1615
+ nextStep = WDONextStep.statusCheck;
1616
+ statusCheckReason = exports.WDOStatusCheckReason.clientAccepted;
1617
+ break;
1618
+ case exports.WDOIdentityVerificationStatus.rejected:
1619
+ nextStep = WDONextStep.rejected;
1620
+ break;
1621
+ case exports.WDOIdentityVerificationStatus.failed:
1622
+ nextStep = WDONextStep.failed;
1623
+ break;
1624
+ }
1625
+ }
1626
+ // PRESENCE CHECK PHASE
1627
+ else if (phase === exports.WDOIdentityVerificationPhase.presenceCheck) {
1628
+ switch (status) {
1629
+ case exports.WDOIdentityVerificationStatus.notInitialized:
1630
+ case exports.WDOIdentityVerificationStatus.inProgress:
1631
+ nextStep = WDONextStep.presenceCheck;
1632
+ break;
1633
+ case exports.WDOIdentityVerificationStatus.verificationPending:
1634
+ nextStep = WDONextStep.statusCheck;
1635
+ statusCheckReason = exports.WDOStatusCheckReason.verifyingPresence;
1636
+ break;
1637
+ case exports.WDOIdentityVerificationStatus.failed:
1638
+ nextStep = WDONextStep.failed;
1639
+ break;
1640
+ case exports.WDOIdentityVerificationStatus.rejected:
1641
+ nextStep = WDONextStep.rejected;
1642
+ break;
1643
+ }
1644
+ }
1645
+ // OTP PHASE
1646
+ else if (phase === exports.WDOIdentityVerificationPhase.otp) {
1647
+ switch (status) {
1648
+ case exports.WDOIdentityVerificationStatus.verificationPending:
1649
+ nextStep = WDONextStep.otp;
1650
+ break;
1651
+ }
1652
+ }
1653
+ // COMPLETED PHASE
1654
+ else if (phase === exports.WDOIdentityVerificationPhase.completed) {
1655
+ switch (status) {
1656
+ case exports.WDOIdentityVerificationStatus.accepted:
1657
+ nextStep = WDONextStep.success;
1658
+ break;
1659
+ case exports.WDOIdentityVerificationStatus.failed:
1660
+ nextStep = WDONextStep.failed;
1661
+ break;
1662
+ case exports.WDOIdentityVerificationStatus.rejected:
1663
+ nextStep = WDONextStep.rejected;
1664
+ break;
1665
+ }
1666
+ }
1667
+ else if (phase === exports.WDOIdentityVerificationPhase.activationFinish) {
1668
+ // TODO: handle status?
1669
+ nextStep = WDONextStep.finishActivation;
1670
+ }
1671
+ if (nextStep == undefined) {
1672
+ WDOLogger.error("Unknown phase/status combo: ".concat(phase !== null && phase !== void 0 ? phase : "nil", ", ").concat(status));
1673
+ nextStep = WDONextStep.failed;
1674
+ }
1675
+ this.nextStep = nextStep;
1676
+ this.statusCheckReason = statusCheckReason;
1677
+ }
1678
+ WDOVerificationStatus.prototype.description = function () {
1679
+ var result = this.nextStep.toString();
1680
+ if (this.statusCheckReason) {
1681
+ result += "(".concat(this.statusCheckReason, ")");
1682
+ }
1683
+ return result;
1171
1684
  };
1172
- return WDOScannedDocument;
1685
+ return WDOVerificationStatus;
1173
1686
  }());
1174
- /** State of the document on the server. */
1175
- exports.UploadState = void 0;
1176
- (function (UploadState) {
1177
- /** The document was not uploaded yet. */
1178
- UploadState[UploadState["notUploaded"] = 0] = "notUploaded";
1179
- /** The document was accepted by the server. */
1180
- UploadState[UploadState["accepted"] = 1] = "accepted";
1181
- /** The document was rejected and needs to be re-uploaded. */
1182
- UploadState[UploadState["rejected"] = 2] = "rejected";
1183
- })(exports.UploadState || (exports.UploadState = {}));
1184
- /** Side of the uploaded document. */
1185
- var Side = /** @class */ (function () {
1186
- /* @internal */
1187
- function Side(type, serverId, uploadState) {
1188
- this.type = type;
1189
- this.serverId = serverId;
1190
- this.uploadState = uploadState;
1687
+ /* @internal */
1688
+ var WDONextStep;
1689
+ (function (WDONextStep) {
1690
+ WDONextStep["intro"] = "intro";
1691
+ WDONextStep["documentScan"] = "documentScan";
1692
+ WDONextStep["statusCheck"] = "statusCheck";
1693
+ WDONextStep["presenceCheck"] = "presenceCheck";
1694
+ WDONextStep["otp"] = "otp";
1695
+ WDONextStep["finishActivation"] = "finishActivation";
1696
+ WDONextStep["failed"] = "failed";
1697
+ WDONextStep["rejected"] = "rejected";
1698
+ WDONextStep["success"] = "success";
1699
+ })(WDONextStep || (WDONextStep = {}));
1700
+ function documentAction(document) {
1701
+ switch (document.status) {
1702
+ case exports.WDODocumentStatus.accepted:
1703
+ return "proceed";
1704
+ case exports.WDODocumentStatus.uploadInProgress:
1705
+ case exports.WDODocumentStatus.inProgress:
1706
+ case exports.WDODocumentStatus.verificationPending:
1707
+ case exports.WDODocumentStatus.verificationInProgress:
1708
+ return "wait";
1709
+ case exports.WDODocumentStatus.rejected:
1710
+ case exports.WDODocumentStatus.failed:
1711
+ return "error";
1191
1712
  }
1192
- return Side;
1193
- }());
1713
+ WDOLogger.debug("Unknown document status: ".concat(document.status, " for document ID: ").concat(document.id));
1714
+ return "error"; // fallback
1715
+ }
1194
1716
 
1195
1717
  /**
1196
1718
  * Copyright Wultra s.r.o.
@@ -1200,410 +1722,314 @@ var Side = /** @class */ (function () {
1200
1722
  *
1201
1723
  * SPDX-License-Identifier: Apache-2.0
1202
1724
  */
1203
- /**
1204
- * Service that can verify previously activated PowerAuth instance.
1205
- *
1206
- * When PowerAuth instance was activated with weak credentials via `WDOActivationService`, user needs to verify his genuine presence.
1207
- * This can be confirmed in the `WDOVerificationService.isVerificationRequired` which will be `true`.
1208
- *
1209
- * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
1210
- */
1211
- var WDOBaseVerificationService = /** @class */ (function () {
1212
- function WDOBaseVerificationService() {
1213
- /* @internal */
1214
- this.lastStatus = undefined;
1215
- /* @internal */
1216
- this.cachedProcess = undefined; // TODO: persistence?
1725
+
1726
+
1727
+ var WDOCordovaCache = /** @class */ (function () {
1728
+ function WDOCordovaCache() {
1217
1729
  }
1218
- // PUBLIC API
1219
- /**
1220
- * Accept language for the outgoing requests headers.
1221
- * Default value is "en".
1222
- *
1223
- * Standard RFC "Accept-Language" https://tools.ietf.org/html/rfc7231#section-5.3.5
1224
- * Response texts are based on this setting. For example when "de" is set, server
1225
- * will return error texts and other in german (if available).
1226
- */
1227
- WDOBaseVerificationService.prototype.changeAcceptLanguage = function (language) {
1228
- this.changeAcceptLanguageImpl(language);
1730
+ WDOCordovaCache.prototype.set = function (key, value) {
1731
+ if (value) {
1732
+ return PowerAuthStorageUtils.setString(key, value, PowerAuthStorageType.SECURE);
1733
+ }
1734
+ else {
1735
+ return PowerAuthStorageUtils.remove(key, PowerAuthStorageType.SECURE).then(function () { });
1736
+ }
1229
1737
  };
1230
- Object.defineProperty(WDOBaseVerificationService.prototype, "otpResendPeriodSeconds", {
1231
- /** Time in seconds that user needs to wait between OTP resend calls */
1232
- get: function () {
1233
- var _a, _b;
1234
- return (_b = (_a = this.lastStatus) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.otpResendPeriodSeconds;
1235
- },
1236
- enumerable: false,
1237
- configurable: true
1238
- });
1239
- /**
1240
- * Status of the verification.
1241
- */
1242
- WDOBaseVerificationService.prototype.status = function () {
1243
- return __awaiter(this, void 0, void 0, function () {
1244
- var response, vf, _a, docsResponse, documents, cachedProcess, error_1;
1245
- var _b;
1246
- return __generator(this, function (_c) {
1247
- switch (_c.label) {
1248
- case 0:
1249
- _c.trys.push([0, 12, , 13]);
1250
- return [4 /*yield*/, this.api.verificationStatus()];
1251
- case 1:
1252
- response = _c.sent();
1253
- WDOLogger.info("Verification status successfully retrieved.");
1254
- WDOLogger.debug("Verification status: ".concat(JSON.stringify(response)));
1255
- switch (response.identityVerificationStatus) {
1256
- case WDOIdentityVerificationStatus.failed:
1257
- case WDOIdentityVerificationStatus.rejected:
1258
- case WDOIdentityVerificationStatus.notInitialized:
1259
- case WDOIdentityVerificationStatus.accepted:
1260
- WDOLogger.debug("Status ".concat(response.identityVerificationStatus, " - clearing cache"));
1261
- this.cachedProcess = undefined;
1262
- break;
1263
- }
1264
- this.lastStatus = response;
1265
- vf = new WDOVerificationStatus(response);
1266
- WDOLogger.info("Verification next step: ".concat(vf.description()));
1267
- _a = vf.nextStep;
1268
- switch (_a) {
1269
- case WDONextStep.intro: return [3 /*break*/, 2];
1270
- case WDONextStep.documentScan: return [3 /*break*/, 3];
1271
- case WDONextStep.presenceCheck: return [3 /*break*/, 5];
1272
- case WDONextStep.otp: return [3 /*break*/, 6];
1273
- case WDONextStep.statusCheck: return [3 /*break*/, 7];
1274
- case WDONextStep.failed: return [3 /*break*/, 8];
1275
- case WDONextStep.rejected: return [3 /*break*/, 9];
1276
- case WDONextStep.success: return [3 /*break*/, 10];
1277
- }
1278
- return [3 /*break*/, 11];
1279
- case 2: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.intro })];
1280
- case 3:
1281
- WDOLogger.debug("Verifying documents status");
1282
- return [4 /*yield*/, this.api.verificationDocumentsStatus(response.processId)];
1283
- case 4:
1284
- docsResponse = _c.sent();
1285
- WDOLogger.debug("Documents status: ".concat(JSON.stringify(docsResponse)));
1286
- documents = docsResponse.documents;
1287
- cachedProcess = this.cachedProcess;
1288
- if (cachedProcess) {
1289
- cachedProcess.feedServerData(docsResponse.documents);
1290
- if (documents.some(function (d) { return documentAction(d) === "error"; }) || documents.some(function (d) { return d.errors != undefined && d.errors.length > 0; })) {
1291
- WDOLogger.debug("At least one document in error state: ".concat(documents.some(function (d) { return documentAction(d) === "error"; }), ", ").concat(documents.some(function (d) { return d.errors != undefined && d.errors.length > 0; })));
1292
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.scanDocument, process: cachedProcess })];
1293
- }
1294
- else if (documents.every(function (d) { return documentAction(d) === "proceed"; })) {
1295
- WDOLogger.debug("All documents accepted, proceeding");
1296
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.scanDocument, process: cachedProcess })];
1297
- }
1298
- else if (documents.some(function (d) { return documentAction(d) === "wait"; })) {
1299
- WDOLogger.debug("At least one document still in progress, moving to processing");
1300
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.documentVerification })];
1301
- }
1302
- else if (documents.length == 0) {
1303
- WDOLogger.debug("No documents scanned, scan documents...");
1304
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.scanDocument, process: cachedProcess })];
1305
- }
1306
- else {
1307
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.failed })];
1308
- }
1309
- }
1310
- else {
1311
- if (documents.length == 0) {
1312
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.documentsToScanSelect })];
1313
- }
1314
- else {
1315
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.failed })];
1316
- }
1317
- }
1318
- case 5: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.presenceCheck })];
1319
- case 6: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.otp })];
1320
- case 7: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: (_b = vf.statusCheckReason) !== null && _b !== void 0 ? _b : exports.WDOStatusCheckReason.unknown })];
1321
- case 8: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.failed })];
1322
- case 9: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.endState, reason: exports.WDOEndStateReason.rejected })];
1323
- case 10: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.success })];
1324
- case 11: return [3 /*break*/, 13];
1325
- case 12:
1326
- error_1 = _c.sent();
1327
- WDOLogger.error("Error fetching verification status: ".concat(JSON.stringify(error_1)));
1328
- this.lastStatus = undefined;
1329
- throw this.processError(error_1);
1330
- case 13: return [2 /*return*/];
1331
- }
1332
- });
1333
- });
1738
+ WDOCordovaCache.prototype.get = function (key) {
1739
+ return PowerAuthStorageUtils.getString(key, PowerAuthStorageType.SECURE);
1334
1740
  };
1335
- /**
1336
- * Returns consent text for user to approve. The content of the text depends on the server configuration and might be plain text or HTML.
1337
- *
1338
- * Consent text explains how the service will handle his document photos or selfie scans.
1339
- */
1340
- WDOBaseVerificationService.prototype.consentGet = function () {
1341
- return __awaiter(this, void 0, void 0, function () {
1342
- var pid, response;
1343
- return __generator(this, function (_a) {
1344
- switch (_a.label) {
1345
- case 0:
1346
- pid = this.verifyHasActiveProcess();
1347
- return [4 /*yield*/, this.handleError(this.api.verificationGetConsentText(pid))];
1348
- case 1:
1349
- response = _a.sent();
1350
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.consent, body: response.consentText })];
1351
- }
1352
- });
1353
- });
1741
+ WDOCordovaCache.prototype.has = function (key) {
1742
+ return PowerAuthStorageUtils.exists(key, PowerAuthStorageType.SECURE);
1354
1743
  };
1355
- /**
1356
- * Approves the consent for this process and starts the activation.
1357
- */
1358
- WDOBaseVerificationService.prototype.consentApprove = function () {
1359
- return __awaiter(this, void 0, void 0, function () {
1360
- var pid;
1361
- return __generator(this, function (_a) {
1362
- switch (_a.label) {
1363
- case 0:
1364
- pid = this.verifyHasActiveProcess();
1365
- return [4 /*yield*/, this.handleError(this.api.verificationResolveConsent(pid, true))];
1366
- case 1:
1367
- _a.sent();
1368
- return [4 /*yield*/, this.handleError(this.api.verificationStart(pid))];
1369
- case 2:
1370
- _a.sent();
1371
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.documentsToScanSelect })];
1372
- }
1373
- });
1374
- });
1744
+ return WDOCordovaCache;
1745
+ }());
1746
+ var WDONetworkingFactoryCordova = /** @class */ (function () {
1747
+ function WDONetworkingFactoryCordova() {
1748
+ }
1749
+ WDONetworkingFactoryCordova.prototype.signedEndpoint = function (path, uriId, responseConfig, e2eeConfig) {
1750
+ return WPNEndpoint.signed(path, uriId, responseConfig, e2eeConfig);
1375
1751
  };
1376
- /**
1377
- * Get the token for the document scanning SDK, when required.
1378
- *
1379
- * This is needed for example for ZenID or BlinkID provider.
1380
- *
1381
- * @param challenge Optional challenge provided by the scanning SDK.
1382
- */
1383
- WDOBaseVerificationService.prototype.documentsInitSDK = function (challenge) {
1384
- return __awaiter(this, void 0, void 0, function () {
1385
- var pid, response;
1386
- return __generator(this, function (_a) {
1387
- switch (_a.label) {
1388
- case 0:
1389
- pid = this.verifyHasActiveProcess();
1390
- return [4 /*yield*/, this.handleError(this.api.verificationInitScanSDK(pid, challenge !== null && challenge !== void 0 ? challenge : "-"))]; // TODO: is "-" acceptable?
1391
- case 1:
1392
- response = _a.sent() // TODO: is "-" acceptable?
1393
- ;
1394
- return [2 /*return*/, response];
1395
- }
1396
- });
1397
- });
1752
+ WDONetworkingFactoryCordova.prototype.signedWithTokenEndpoint = function (path, tokenName, responseConfig, e2eeConfig) {
1753
+ return WPNEndpoint.signedWithToken(path, tokenName, responseConfig, e2eeConfig);
1398
1754
  };
1399
- /**
1400
- * Set which documents will be scanned.
1401
- *
1402
- * Note that this needs to be in sync what server expects based on the configuration.
1403
- *
1404
- * @param types Types of documents to scan.
1405
- */
1406
- WDOBaseVerificationService.prototype.documentsSetSelectedTypes = function (types) {
1407
- return __awaiter(this, void 0, void 0, function () {
1408
- var process;
1409
- return __generator(this, function (_a) {
1410
- WDOLogger.debug("Submitting selected document types: ".concat(types));
1411
- process = new WDOVerificationScanProcess(types);
1412
- this.cachedProcess = process;
1413
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.scanDocument, process: process })];
1414
- });
1415
- });
1755
+ WDONetworkingFactoryCordova.prototype.unsignedEndpoint = function (path, responseConfig, e2eeConfig) {
1756
+ return WPNEndpoint.unsigned(path, responseConfig, e2eeConfig);
1757
+ };
1758
+ WDONetworkingFactoryCordova.prototype.networking = function (powerAuth, baseUrl) {
1759
+ return new WPNNetworking(powerAuth, baseUrl);
1760
+ };
1761
+ return WDONetworkingFactoryCordova;
1762
+ }());
1763
+ var WDOPowerAuthFactoryCordova = /** @class */ (function () {
1764
+ function WDOPowerAuthFactoryCordova() {
1765
+ }
1766
+ WDOPowerAuthFactoryCordova.prototype.activationWithActivationCode = function (activationCode, activationName, otp) {
1767
+ var activation = PowerAuthActivation.createWithActivationCode(activationCode, activationName);
1768
+ if (otp) {
1769
+ activation.additionalActivationOtp = otp;
1770
+ }
1771
+ return activation;
1772
+ };
1773
+ WDOPowerAuthFactoryCordova.prototype.activationWithIdentityAttributes = function (identityAttributes, activationName) {
1774
+ return PowerAuthActivation.createWithIdentityAttributes(identityAttributes, activationName);
1775
+ };
1776
+ WDOPowerAuthFactoryCordova.prototype.authenticationWithPassword = function (password) {
1777
+ return PowerAuthAuthentication.password(password);
1416
1778
  };
1779
+ return WDOPowerAuthFactoryCordova;
1780
+ }());
1781
+
1782
+ /**
1783
+ * Copyright Wultra s.r.o.
1784
+ *
1785
+ * This source code is licensed under the Apache License, Version 2.0 license
1786
+ * found in the LICENSE file in the root directory of this source tree.
1787
+ *
1788
+ * SPDX-License-Identifier: Apache-2.0
1789
+ */
1790
+ /**
1791
+ * Service that can activate PowerAuth instance by user weak credentials (like his email, phone number or client ID) + optional SMS OTP.
1792
+ *
1793
+ * When the PowerAuth is activated with this service, `WDOVerificationService.isVerificationRequired` will be `true`
1794
+ * and you will need to verify the PowerAuth instance via `WDOVerificationService`.
1795
+ *
1796
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
1797
+ */
1798
+ var WDOBaseActivationService = /** @class */ (function () {
1799
+ // PUBLIC API
1417
1800
  /**
1418
- * Upload document files to the server. The order of the documents is up to you.
1419
- * Make sure that uploaded document are reasonable size so you're not uploading large files.
1420
- *
1421
- * If you're uploading the same document file again, you need to include the `originalDocumentId` otherwise it will be rejected by the server.
1801
+ * Creates service instance
1422
1802
  *
1423
- * @param files Document files to upload.
1803
+ * @param powerauth Configured PowerAuth instance. This instance needs to be without valid activation.
1804
+ * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
1424
1805
  */
1425
- WDOBaseVerificationService.prototype.documentsSubmit = function (files) {
1806
+ function WDOBaseActivationService(powerauth, baseUrl) {
1807
+ this.api = new WDOApi(powerauth, baseUrl);
1808
+ this.powerauth = powerauth;
1809
+ }
1810
+ Object.defineProperty(WDOBaseActivationService.prototype, "cacheKey", {
1811
+ /* @internal */
1812
+ get: function () { return "wdopd_".concat(this.powerauth.instanceId); },
1813
+ enumerable: false,
1814
+ configurable: true
1815
+ });
1816
+ /* @internal */
1817
+ WDOBaseActivationService.prototype.setCachedProcessData = function (data) {
1426
1818
  return __awaiter(this, void 0, void 0, function () {
1427
- var pid, resubmit, submitFiles;
1428
1819
  return __generator(this, function (_a) {
1429
1820
  switch (_a.label) {
1430
- case 0:
1431
- pid = this.verifyHasActiveProcess();
1432
- resubmit = files.some(function (f) { return f.originalDocumentId != undefined; });
1433
- submitFiles = files.map(function (f) {
1434
- return {
1435
- filename: "".concat(f.type.toLowerCase(), "_").concat(f.side.toLowerCase(), ".jpg"), // TODO: OK?
1436
- type: WDOCreateDocumentSubmitFileType(f.type),
1437
- side: WDOCreateDocumentSubmitFileSide(f.side),
1438
- originalDocumentId: f.originalDocumentId,
1439
- data: f.data
1440
- };
1441
- });
1442
- return [4 /*yield*/, this.handleError(this.api.verificationSubmitDocumentsV2(pid, resubmit, submitFiles))];
1821
+ case 0: return [4 /*yield*/, WDOPlatform.cache.set(this.cacheKey, JSON.stringify(data))];
1443
1822
  case 1:
1444
1823
  _a.sent();
1445
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.documentUpload })];
1824
+ return [2 /*return*/];
1446
1825
  }
1447
1826
  });
1448
1827
  });
1449
1828
  };
1450
- /**
1451
- * @internal
1452
- * Upload document files to the server. The order of the documents is up to you.
1453
- * Make sure that uploaded document are reasonable size so you're not uploading large files.
1454
- *
1455
- * If you're uploading the same document file again, you need to include the `originalDocumentId` otherwise it will be rejected by the server.
1456
- *
1457
- * @param files Document files to upload.
1458
- */
1459
- WDOBaseVerificationService.prototype.documentsSubmitDemo = function (files, zipFolderNameDemo, base64zipDemo) {
1829
+ /* @internal */
1830
+ WDOBaseActivationService.prototype.getCachedProcessData = function () {
1460
1831
  return __awaiter(this, void 0, void 0, function () {
1461
- var pid, resubmit, submitFiles;
1832
+ var data;
1462
1833
  return __generator(this, function (_a) {
1463
1834
  switch (_a.label) {
1464
- case 0:
1465
- pid = this.verifyHasActiveProcess();
1466
- resubmit = files.some(function (f) { return f.originalDocumentId != undefined; });
1467
- submitFiles = files.map(function (f) {
1468
- return {
1469
- filename: "".concat(zipFolderNameDemo, "/").concat(f.type.toLowerCase(), "_").concat(f.side.toLowerCase(), ".jpg"),
1470
- type: WDOCreateDocumentSubmitFileType(f.type),
1471
- side: WDOCreateDocumentSubmitFileSide(f.side),
1472
- originalDocumentId: f.originalDocumentId
1473
- };
1474
- });
1475
- return [4 /*yield*/, this.handleError(this.api.verificationSubmitDocuments(pid, base64zipDemo, resubmit, submitFiles))];
1835
+ case 0: return [4 /*yield*/, WDOPlatform.cache.get(this.cacheKey)];
1476
1836
  case 1:
1477
- _a.sent();
1478
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.documentUpload })];
1837
+ data = _a.sent();
1838
+ if (!data) {
1839
+ return [2 /*return*/, undefined];
1840
+ }
1841
+ return [2 /*return*/, JSON.parse(data)];
1479
1842
  }
1480
1843
  });
1481
1844
  });
1482
1845
  };
1846
+ /* @internal */
1847
+ WDOBaseActivationService.prototype.processId = function () {
1848
+ return __awaiter(this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
1849
+ switch (_b.label) {
1850
+ case 0: return [4 /*yield*/, this.getCachedProcessData()];
1851
+ case 1: return [2 /*return*/, (_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.processId];
1852
+ }
1853
+ }); });
1854
+ };
1483
1855
  /**
1484
- * Initiates the presence check. This returns attributes that are needed to start the 3rd party SDK (if needed).
1856
+ * If the activation process is in progress.
1857
+ *
1858
+ * Note that even if this property is `true` it can be already discontinued on the server.
1859
+ * Calling `status()` after the app is launched is recommended.
1485
1860
  */
1486
- WDOBaseVerificationService.prototype.presenceCheckInit = function () {
1487
- return __awaiter(this, void 0, void 0, function () {
1488
- var pid, response;
1489
- return __generator(this, function (_a) {
1490
- switch (_a.label) {
1491
- case 0:
1492
- pid = this.verifyHasActiveProcess();
1493
- return [4 /*yield*/, this.handleError(this.api.verificationPresenceCheckInit(pid))];
1494
- case 1:
1495
- response = _a.sent();
1496
- return [2 /*return*/, this.processSuccess(response.sessionAttributes)];
1497
- }
1498
- });
1499
- });
1861
+ WDOBaseActivationService.prototype.hasActiveProcess = function () {
1862
+ return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
1863
+ switch (_a.label) {
1864
+ case 0: return [4 /*yield*/, this.getCachedProcessData()];
1865
+ case 1: return [2 /*return*/, !!(_a.sent())];
1866
+ }
1867
+ }); });
1500
1868
  };
1501
1869
  /**
1502
- * Call when presence check was finished in the 3rd party SDK.
1870
+ * Accept language for the outgoing requests headers.
1871
+ * Default value is "en".
1872
+ *
1873
+ * Standard RFC "Accept-Language" https://tools.ietf.org/html/rfc7231#section-5.3.5
1874
+ * Response texts are based on this setting. For example when "de" is set, server
1875
+ * will return error texts and other in german (if available).
1503
1876
  */
1504
- WDOBaseVerificationService.prototype.presenceCheckSubmit = function () {
1877
+ WDOBaseActivationService.prototype.changeAcceptLanguage = function (language) {
1878
+ this.api.networking.acceptLanguage = language;
1879
+ };
1880
+ /**
1881
+ * Retrieves status of the onboarding activation.
1882
+ *
1883
+ * @return Promise resolved with onboarding status.
1884
+ */
1885
+ WDOBaseActivationService.prototype.status = function () {
1505
1886
  return __awaiter(this, void 0, void 0, function () {
1506
- var pid;
1507
- return __generator(this, function (_a) {
1508
- switch (_a.label) {
1887
+ var _a, _b, _c, pid, result;
1888
+ return __generator(this, function (_d) {
1889
+ switch (_d.label) {
1509
1890
  case 0:
1510
- pid = this.verifyHasActiveProcess();
1511
- return [4 /*yield*/, this.handleError(this.api.verificationPresenceCheckSubmit(pid))];
1891
+ _b = (_a = WDOLogger).debug;
1892
+ _c = "Getting activation status for processId=".concat;
1893
+ return [4 /*yield*/, this.processId()];
1512
1894
  case 1:
1513
- _a.sent();
1514
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.verifyingPresence })];
1895
+ _b.apply(_a, [_c.apply("Getting activation status for processId=", [_d.sent()])]);
1896
+ return [4 /*yield*/, this.verifyCanStartActivation()];
1897
+ case 2:
1898
+ _d.sent();
1899
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
1900
+ case 3:
1901
+ pid = _d.sent();
1902
+ return [4 /*yield*/, this.api.activationGetStatus(pid)];
1903
+ case 4:
1904
+ result = _d.sent();
1905
+ return [2 /*return*/, result.onboardingStatus];
1515
1906
  }
1516
1907
  });
1517
1908
  });
1518
1909
  };
1519
1910
  /**
1520
- * Verification restart. When sucessfully called, intro screen should be presented.
1911
+ * Start onboarding activation with user credentials.
1912
+ *
1913
+ * For example, when you require email and birth date, your object would look like this:
1914
+ * ```
1915
+ * {
1916
+ * email: "<user_email>",
1917
+ * birthdate: "<user_birth_date>"
1918
+ * }
1919
+ * ```
1920
+ * @param credentials Object with credentials. Which credentials are needed should be provided by a system/backend provider.
1921
+ * @param processType The process type identification. If not specified, the default process type will be used.
1521
1922
  */
1522
- WDOBaseVerificationService.prototype.restartVerification = function () {
1923
+ WDOBaseActivationService.prototype.start = function (credentials, processType) {
1523
1924
  return __awaiter(this, void 0, void 0, function () {
1524
- var pid;
1925
+ var result;
1525
1926
  return __generator(this, function (_a) {
1526
1927
  switch (_a.label) {
1527
1928
  case 0:
1528
- pid = this.verifyHasActiveProcess();
1529
- return [4 /*yield*/, this.handleError(this.api.verificationCleanup(pid))];
1929
+ WDOLogger.debug("Starting activation with credentials: ".concat(JSON.stringify(credentials)));
1930
+ return [4 /*yield*/, this.processId()];
1530
1931
  case 1:
1932
+ if (_a.sent()) {
1933
+ throw new WDOError(exports.WDOErrorReason.processAlreadyInProgress, "Cannot start the process - processId already obtained, cancel first.");
1934
+ }
1935
+ return [4 /*yield*/, this.verifyCanStartActivation()];
1936
+ case 2:
1531
1937
  _a.sent();
1532
- this.cachedProcess = undefined;
1533
- WDOLogger.info("Verification process restarted.");
1534
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.intro })];
1938
+ return [4 /*yield*/, this.api.activationStart(credentials, processType)];
1939
+ case 3:
1940
+ result = _a.sent();
1941
+ WDOLogger.info("WDOActivationService.start success");
1942
+ WDOLogger.debug(" - processId: ".concat(result.processId));
1943
+ return [4 /*yield*/, this.setCachedProcessData({ processId: result.processId, activationCode: result.activationCode })];
1944
+ case 4:
1945
+ _a.sent();
1946
+ return [2 /*return*/];
1535
1947
  }
1536
1948
  });
1537
1949
  });
1538
1950
  };
1539
1951
  /**
1540
- * Cancel the whole activation/verification. After this it's no longer possible to call
1541
- * any API of this library and PowerAuth activation should be removed and activation started again.
1952
+ * Cancel the activation process (issues a cancel request to the backend and clears the local process ID).
1953
+ *
1954
+ * @param forceCancel When true, the process will be canceled in the SDK even when fails on backend. `true` by default.
1542
1955
  */
1543
- WDOBaseVerificationService.prototype.cancelWholeProcess = function () {
1544
- return __awaiter(this, void 0, void 0, function () {
1545
- var pid;
1546
- return __generator(this, function (_a) {
1547
- switch (_a.label) {
1956
+ WDOBaseActivationService.prototype.cancel = function () {
1957
+ return __awaiter(this, arguments, void 0, function (forceCancel) {
1958
+ var _a, _b, _c, pid, error_1;
1959
+ if (forceCancel === void 0) { forceCancel = true; }
1960
+ return __generator(this, function (_d) {
1961
+ switch (_d.label) {
1548
1962
  case 0:
1549
- pid = this.verifyHasActiveProcess();
1550
- return [4 /*yield*/, this.handleError(this.api.verificationCleanup(pid))];
1963
+ _b = (_a = WDOLogger).debug;
1964
+ _c = "Canceling activation for processId=".concat;
1965
+ return [4 /*yield*/, this.processId()];
1551
1966
  case 1:
1552
- _a.sent();
1553
- this.cachedProcess = undefined;
1554
- WDOLogger.info("Verification process canceled.");
1555
- return [2 /*return*/];
1967
+ _b.apply(_a, [_c.apply("Canceling activation for processId=", [_d.sent(), ", forceCancel="]).concat(forceCancel)]);
1968
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
1969
+ case 2:
1970
+ pid = _d.sent();
1971
+ _d.label = 3;
1972
+ case 3:
1973
+ _d.trys.push([3, 6, , 10]);
1974
+ return [4 /*yield*/, this.api.activationCancel(pid)];
1975
+ case 4:
1976
+ _d.sent();
1977
+ return [4 /*yield*/, this.setCachedProcessData(undefined)];
1978
+ case 5:
1979
+ _d.sent();
1980
+ WDOLogger.info("WDOActivationService.cancel success");
1981
+ return [3 /*break*/, 10];
1982
+ case 6:
1983
+ error_1 = _d.sent();
1984
+ if (!forceCancel) return [3 /*break*/, 8];
1985
+ // pretend it was successful and just log the error
1986
+ WDOLogger.debug("Process canceled (but the request failed) - ".concat(error_1, "."));
1987
+ return [4 /*yield*/, this.setCachedProcessData(undefined)];
1988
+ case 7:
1989
+ _d.sent();
1990
+ return [3 /*break*/, 9];
1991
+ case 8: throw error_1; // rethrow
1992
+ case 9: return [3 /*break*/, 10];
1993
+ case 10: return [2 /*return*/];
1556
1994
  }
1557
1995
  });
1558
1996
  });
1559
1997
  };
1560
- /**
1561
- * Verify OTP that user entered as a last step of the verification.
1562
- *
1563
- * @param otp OTP that user obtained via other channel (usually SMS or email).
1564
- */
1565
- WDOBaseVerificationService.prototype.verifyOTP = function (otp) {
1998
+ /** Clear the stored data (without networking call). */
1999
+ WDOBaseActivationService.prototype.clear = function () {
1566
2000
  return __awaiter(this, void 0, void 0, function () {
1567
- var pid, response;
1568
2001
  return __generator(this, function (_a) {
1569
2002
  switch (_a.label) {
1570
- case 0:
1571
- pid = this.verifyHasActiveProcess();
1572
- return [4 /*yield*/, this.handleError(this.api.verifyOTP(pid, otp))];
2003
+ case 0: return [4 /*yield*/, this.setCachedProcessData(undefined)];
1573
2004
  case 1:
1574
- response = _a.sent();
1575
- if (response.verified) {
1576
- WDOLogger.info("OTP verified successfully.");
1577
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.unknown })];
1578
- }
1579
- else {
1580
- if (response.remainingAttempts > 0 && response.expired == false) {
1581
- WDOLogger.error("OTP verification failed, remaining attempts: ".concat(response.remainingAttempts));
1582
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.otp, remainingAttempts: response.remainingAttempts })];
1583
- }
1584
- else {
1585
- WDOLogger.error("OTP verification failed, no remaining attempts or OTP expired");
1586
- throw this.processError(new WDOError("OTP verification failed, no remaining attempts or OTP expired"));
1587
- }
1588
- }
2005
+ _a.sent();
2006
+ return [2 /*return*/];
1589
2007
  }
1590
2008
  });
1591
2009
  });
1592
2010
  };
1593
2011
  /**
1594
- * Request OTP resend.
2012
+ * OTP resend request.
1595
2013
  *
1596
- * Since SMS or emails can fail to deliver, use this to send the OTP again.
2014
+ * This is intended to be displayed for the user to use in case of the OTP is not received.
2015
+ * For example, when the user does not receive SMS after some time, there should be a button to "send again".
2016
+ * 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.
1597
2017
  */
1598
- WDOBaseVerificationService.prototype.resendOTP = function () {
2018
+ WDOBaseActivationService.prototype.resendOTP = function () {
1599
2019
  return __awaiter(this, void 0, void 0, function () {
1600
2020
  var pid;
1601
2021
  return __generator(this, function (_a) {
1602
2022
  switch (_a.label) {
1603
2023
  case 0:
1604
- pid = this.verifyHasActiveProcess();
1605
- return [4 /*yield*/, this.handleError(this.api.verificationResendOTP(pid))];
2024
+ WDOLogger.debug("Activation: resending OTP");
2025
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
1606
2026
  case 1:
2027
+ pid = _a.sent();
2028
+ return [4 /*yield*/, this.verifyCanStartActivation()];
2029
+ case 2:
2030
+ _a.sent();
2031
+ return [4 /*yield*/, this.api.activationResendOTP(pid)];
2032
+ case 3:
1607
2033
  _a.sent();
1608
2034
  return [2 /*return*/];
1609
2035
  }
@@ -1616,320 +2042,118 @@ var WDOBaseVerificationService = /** @class */ (function () {
1616
2042
  *
1617
2043
  * If the app is running against our demo server, you can retrieve the OTP without needing to send SMS or emails.
1618
2044
  */
1619
- WDOBaseVerificationService.prototype.getOTP = function () {
2045
+ WDOBaseActivationService.prototype.getOTP = function () {
1620
2046
  return __awaiter(this, void 0, void 0, function () {
1621
2047
  var pid;
1622
2048
  return __generator(this, function (_a) {
1623
2049
  switch (_a.label) {
1624
2050
  case 0:
1625
2051
  WDOLogger.debug("Activation: getting OTP from server (only for testing purposes)");
1626
- pid = this.verifyHasActiveProcess();
1627
- return [4 /*yield*/, this.api.activationGetOTP(pid, "USER_VERIFICATION")];
1628
- case 1: return [2 /*return*/, (_a.sent()).otpCode];
2052
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
2053
+ case 1:
2054
+ pid = _a.sent();
2055
+ return [4 /*yield*/, this.api.activationGetOTP(pid, "ACTIVATION")];
2056
+ case 2: return [2 /*return*/, (_a.sent()).otpCode];
1629
2057
  }
1630
2058
  });
1631
2059
  });
1632
2060
  };
1633
- // PRIVATE METHODS
1634
- /* @internal */
1635
- WDOBaseVerificationService.prototype.verifyHasActiveProcess = function () {
1636
- var _a;
1637
- var pid = (_a = this.lastStatus) === null || _a === void 0 ? void 0 : _a.processId;
1638
- if (!pid) {
1639
- WDOLogger.error("Process id not available - did you start the verification process and fetched the status?");
1640
- throw new WDOError("Process id not available - did you start the verification process and fetched the status?");
1641
- }
1642
- return pid;
1643
- };
1644
- /* @internal */
1645
- WDOBaseVerificationService.prototype.processSuccess = function (result) {
1646
- var _a;
1647
- if (result.type !== undefined) {
1648
- (_a = this.listener) === null || _a === void 0 ? void 0 : _a.verificationStatusChanged(this, result);
1649
- }
1650
- return result;
1651
- };
1652
- /* @internal */
1653
- WDOBaseVerificationService.prototype.handleError = function (promise) {
1654
- var _this = this;
1655
- return promise.catch(function (error) {
1656
- throw _this.processError(error);
2061
+ /**
2062
+ * Activate the PowerAuth instance that was passed in the initializer.
2063
+ *
2064
+ * @param activationName Name of the activation. Usually something like John's iPhone or similar.
2065
+ * @param otp OTP code received by the user (via SMS or email). Optional when not required.
2066
+ * @return Promise resolved with activation result.
2067
+ */
2068
+ WDOBaseActivationService.prototype.activate = function (activationName, otp) {
2069
+ return __awaiter(this, void 0, void 0, function () {
2070
+ var pid, code, result, activation, identityAttributes, activation, error_2;
2071
+ var _a;
2072
+ return __generator(this, function (_b) {
2073
+ switch (_b.label) {
2074
+ case 0:
2075
+ WDOLogger.debug("Activating the PowerAuth with activation name '".concat(activationName, "'"));
2076
+ return [4 /*yield*/, this.verifyCanStartActivation()];
2077
+ case 1:
2078
+ _b.sent();
2079
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
2080
+ case 2:
2081
+ pid = _b.sent();
2082
+ return [4 /*yield*/, this.getCachedProcessData()];
2083
+ case 3:
2084
+ code = (_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.activationCode;
2085
+ _b.label = 4;
2086
+ case 4:
2087
+ _b.trys.push([4, 9, , 10]);
2088
+ if (!code) return [3 /*break*/, 6];
2089
+ WDOLogger.info("Activating PowerAuth using activation code from the onboarding process");
2090
+ activation = WDOPlatform.powerAuthFactory.activationWithActivationCode(code, activationName, otp);
2091
+ return [4 /*yield*/, this.powerauth.createActivation(activation)];
2092
+ case 5:
2093
+ result = _b.sent();
2094
+ return [3 /*break*/, 8];
2095
+ case 6:
2096
+ WDOLogger.info("Activating PowerAuth using identity attributes from the onboarding process");
2097
+ identityAttributes = { processId: pid, otpCode: otp, credentialsType: "ONBOARDING" };
2098
+ activation = WDOPlatform.powerAuthFactory.activationWithIdentityAttributes(identityAttributes, activationName);
2099
+ return [4 /*yield*/, this.powerauth.createActivation(activation)];
2100
+ case 7:
2101
+ result = _b.sent();
2102
+ _b.label = 8;
2103
+ case 8: return [3 /*break*/, 10];
2104
+ case 9:
2105
+ error_2 = _b.sent();
2106
+ throw new WDOError(exports.WDOErrorReason.activationFailed, "Activation failed", error_2);
2107
+ case 10:
2108
+ // Clear process ID after activation attempt
2109
+ return [4 /*yield*/, this.setCachedProcessData(undefined)];
2110
+ case 11:
2111
+ // Clear process ID after activation attempt
2112
+ _b.sent();
2113
+ return [2 /*return*/, result];
2114
+ }
2115
+ });
1657
2116
  });
1658
2117
  };
2118
+ // PRIVATE METHODS
1659
2119
  /* @internal */
1660
- WDOBaseVerificationService.prototype.processError = function (error) {
2120
+ WDOBaseActivationService.prototype.verifyCanStartActivation = function () {
1661
2121
  return __awaiter(this, void 0, void 0, function () {
1662
- var status_1;
1663
- var _b;
1664
- return __generator(this, function (_c) {
1665
- switch (_c.label) {
1666
- case 0:
1667
- if (!(error.code === "AUTHENTICATION_ERROR")) return [3 /*break*/, 4];
1668
- _c.label = 1;
2122
+ return __generator(this, function (_a) {
2123
+ switch (_a.label) {
2124
+ case 0: return [4 /*yield*/, this.powerauth.canStartActivation()];
1669
2125
  case 1:
1670
- _c.trys.push([1, 3, , 4]);
1671
- return [4 /*yield*/, this.fetchActivationStatus()];
2126
+ if (!!(_a.sent())) return [3 /*break*/, 3];
2127
+ WDOLogger.error("PowerAuth is already activated - Activation cannot be started/processed.");
2128
+ return [4 /*yield*/, this.setCachedProcessData(undefined)];
1672
2129
  case 2:
1673
- status_1 = _c.sent();
1674
- if (status_1.state !== WDOPowerAuthActivationState.ACTIVE) {
1675
- WDOLogger.error("PowerAuth status is not active (status".concat(status_1.state, ") - notifying the delegate and returning and error."));
1676
- (_b = this.listener) === null || _b === void 0 ? void 0 : _b.powerAuthActivationStatusChanged(this, status_1);
1677
- return [2 /*return*/, new WDOError("PowerAuth activation is not active anymore")];
1678
- }
1679
- return [3 /*break*/, 4];
1680
- case 3:
1681
- _c.sent();
1682
- return [3 /*break*/, 4];
1683
- case 4: return [2 /*return*/, error];
2130
+ _a.sent();
2131
+ throw new WDOError(exports.WDOErrorReason.powerauthAlreadyActivated, "PowerAuth is already activated");
2132
+ case 3: return [2 /*return*/];
1684
2133
  }
1685
2134
  });
1686
2135
  });
1687
2136
  };
1688
- return WDOBaseVerificationService;
1689
- }());
1690
- // INTERNAL CLASSES
1691
- /**
1692
- @internal
1693
- Internal status that works as a translation layer between server API and SDK API
1694
- */
1695
- var WDOVerificationStatus = /** @class */ (function () {
1696
- /** Translation from server status to phone status. */
1697
- function WDOVerificationStatus(serverResponse) {
1698
- var phase = serverResponse.identityVerificationPhase;
1699
- var status = serverResponse.identityVerificationStatus;
1700
- var nextStep = undefined;
1701
- var statusCheckReason = undefined;
1702
- // UNDEFINED PHASE
1703
- if (phase == undefined) {
1704
- switch (status) {
1705
- case WDOIdentityVerificationStatus.notInitialized:
1706
- nextStep = WDONextStep.intro;
1707
- break;
1708
- case WDOIdentityVerificationStatus.failed:
1709
- nextStep = WDONextStep.failed;
1710
- break;
1711
- }
1712
- }
1713
- // DOCUMENT UPLOAD PHASE
1714
- else if (phase === WDOIdentityVerificationPhase.documentUpload) {
1715
- switch (status) {
1716
- case WDOIdentityVerificationStatus.inProgress:
1717
- nextStep = WDONextStep.documentScan;
1718
- break;
1719
- case WDOIdentityVerificationStatus.verificationPending:
1720
- nextStep = WDONextStep.statusCheck;
1721
- statusCheckReason = exports.WDOStatusCheckReason.documentVerification;
1722
- break;
1723
- case WDOIdentityVerificationStatus.failed:
1724
- nextStep = WDONextStep.failed;
1725
- break;
1726
- }
1727
- }
1728
- // DOCUMENT VERIFICATION PHASE
1729
- else if (phase === WDOIdentityVerificationPhase.documentVerification) {
1730
- switch (status) {
1731
- case WDOIdentityVerificationStatus.accepted:
1732
- nextStep = WDONextStep.statusCheck;
1733
- statusCheckReason = exports.WDOStatusCheckReason.documentAccepted;
1734
- break;
1735
- case WDOIdentityVerificationStatus.inProgress:
1736
- nextStep = WDONextStep.statusCheck;
1737
- statusCheckReason = exports.WDOStatusCheckReason.documentVerification;
1738
- break;
1739
- case WDOIdentityVerificationStatus.failed:
1740
- nextStep = WDONextStep.failed;
1741
- break;
1742
- case WDOIdentityVerificationStatus.rejected:
1743
- nextStep = WDONextStep.rejected;
1744
- break;
1745
- }
1746
- }
1747
- // DOCUMENT VERIFICATION FINAL PHASE
1748
- else if (phase === WDOIdentityVerificationPhase.documentVerificationFinal) {
1749
- switch (status) {
1750
- case WDOIdentityVerificationStatus.accepted:
1751
- nextStep = WDONextStep.statusCheck;
1752
- statusCheckReason = exports.WDOStatusCheckReason.documentsCrossVerification;
1753
- break;
1754
- case WDOIdentityVerificationStatus.inProgress:
1755
- nextStep = WDONextStep.statusCheck;
1756
- statusCheckReason = exports.WDOStatusCheckReason.documentsCrossVerification;
1757
- break;
1758
- case WDOIdentityVerificationStatus.failed:
1759
- nextStep = WDONextStep.failed;
1760
- break;
1761
- case WDOIdentityVerificationStatus.rejected:
1762
- nextStep = WDONextStep.rejected;
1763
- break;
1764
- }
1765
- }
1766
- // CLIENT EVALUATION PHASE
1767
- else if (phase === WDOIdentityVerificationPhase.clientEvaluation) {
1768
- switch (status) {
1769
- case WDOIdentityVerificationStatus.inProgress:
1770
- nextStep = WDONextStep.statusCheck;
1771
- statusCheckReason = exports.WDOStatusCheckReason.clientVerification;
1772
- break;
1773
- case WDOIdentityVerificationStatus.accepted:
1774
- nextStep = WDONextStep.statusCheck;
1775
- statusCheckReason = exports.WDOStatusCheckReason.clientAccepted;
1776
- break;
1777
- case WDOIdentityVerificationStatus.rejected:
1778
- nextStep = WDONextStep.rejected;
1779
- break;
1780
- case WDOIdentityVerificationStatus.failed:
1781
- nextStep = WDONextStep.failed;
1782
- break;
1783
- }
1784
- }
1785
- // PRESENCE CHECK PHASE
1786
- else if (phase === WDOIdentityVerificationPhase.presenceCheck) {
1787
- switch (status) {
1788
- case WDOIdentityVerificationStatus.notInitialized:
1789
- case WDOIdentityVerificationStatus.inProgress:
1790
- nextStep = WDONextStep.presenceCheck;
1791
- break;
1792
- case WDOIdentityVerificationStatus.verificationPending:
1793
- nextStep = WDONextStep.statusCheck;
1794
- statusCheckReason = exports.WDOStatusCheckReason.verifyingPresence;
1795
- break;
1796
- case WDOIdentityVerificationStatus.failed:
1797
- nextStep = WDONextStep.failed;
1798
- break;
1799
- case WDOIdentityVerificationStatus.rejected:
1800
- nextStep = WDONextStep.rejected;
1801
- break;
1802
- }
1803
- }
1804
- // OTP PHASE
1805
- else if (phase === WDOIdentityVerificationPhase.otp) {
1806
- switch (status) {
1807
- case WDOIdentityVerificationStatus.verificationPending:
1808
- nextStep = WDONextStep.otp;
1809
- break;
1810
- }
1811
- }
1812
- // COMPLETED PHASE
1813
- else if (phase === WDOIdentityVerificationPhase.completed) {
1814
- switch (status) {
1815
- case WDOIdentityVerificationStatus.accepted:
1816
- nextStep = WDONextStep.success;
1817
- break;
1818
- case WDOIdentityVerificationStatus.failed:
1819
- nextStep = WDONextStep.failed;
1820
- break;
1821
- case WDOIdentityVerificationStatus.rejected:
1822
- nextStep = WDONextStep.rejected;
1823
- break;
1824
- }
1825
- }
1826
- if (nextStep == undefined) {
1827
- WDOLogger.error("Unknown phase/status combo: ".concat(phase !== null && phase !== void 0 ? phase : "nil", ", ").concat(status));
1828
- nextStep = WDONextStep.failed;
1829
- }
1830
- this.nextStep = nextStep;
1831
- this.statusCheckReason = statusCheckReason;
1832
- }
1833
- WDOVerificationStatus.prototype.description = function () {
1834
- var result = this.nextStep.toString();
1835
- if (this.statusCheckReason) {
1836
- result += "(".concat(this.statusCheckReason, ")");
1837
- }
1838
- return result;
1839
- };
1840
- return WDOVerificationStatus;
1841
- }());
1842
- /* @internal */
1843
- var WDONextStep;
1844
- (function (WDONextStep) {
1845
- WDONextStep["intro"] = "intro";
1846
- WDONextStep["documentScan"] = "documentScan";
1847
- WDONextStep["statusCheck"] = "statusCheck";
1848
- WDONextStep["presenceCheck"] = "presenceCheck";
1849
- WDONextStep["otp"] = "otp";
1850
- WDONextStep["failed"] = "failed";
1851
- WDONextStep["rejected"] = "rejected";
1852
- WDONextStep["success"] = "success";
1853
- })(WDONextStep || (WDONextStep = {}));
1854
- function documentAction(document) {
1855
- switch (document.status) {
1856
- case WDODocumentStatus.accepted:
1857
- return "proceed";
1858
- case WDODocumentStatus.uploadInProgress:
1859
- case WDODocumentStatus.inProgress:
1860
- case WDODocumentStatus.verificationPending:
1861
- case WDODocumentStatus.verificationInProgress:
1862
- return "wait";
1863
- case WDODocumentStatus.rejected:
1864
- case WDODocumentStatus.failed:
1865
- return "error";
1866
- }
1867
- WDOLogger.debug("Unknown document status: ".concat(document.status, " for document ID: ").concat(document.id));
1868
- return "error"; // fallback
1869
- }
1870
-
1871
- /**
1872
- * Copyright Wultra s.r.o.
1873
- *
1874
- * This source code is licensed under the Apache License, Version 2.0 license
1875
- * found in the LICENSE file in the root directory of this source tree.
1876
- *
1877
- * SPDX-License-Identifier: Apache-2.0
1878
- */
1879
-
1880
- /**
1881
- * Service that can verify previously activated PowerAuth instance.
1882
- *
1883
- * When PowerAuth instance was activated with weak credentials via `WDOActivationService`, user needs to verify his genuine presence.
1884
- *
1885
- * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
1886
- */
1887
- var WDOVerificationService = /** @class */ (function (_super) {
1888
- __extends(WDOVerificationService, _super);
1889
- /**
1890
- * Creates service instance
1891
- *
1892
- * @param powerauth Configured PowerAuth instance. This instance needs to be without valid activation.
1893
- * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
1894
- */
1895
- function WDOVerificationService(powerauth, baseUrl) {
1896
- var _this = _super.call(this) || this;
1897
- _this.api = new WDOApi(powerauth, baseUrl);
1898
- _this.powerauth = powerauth;
1899
- return _this;
1900
- }
1901
- /** Checks if verification is required based on PowerAuth activation status */
1902
- WDOVerificationService.isVerificationRequired = function (paStatus) {
1903
- var _a;
1904
- var flags = (_a = paStatus.customObject) === null || _a === void 0 ? void 0 : _a.activationFlags;
1905
- return !!flags && flags.some(function (f) { return f === "VERIFICATION_PENDING" || f === "VERIFICATION_IN_PROGRESS"; });
1906
- };
1907
2137
  /* @internal */
1908
- WDOVerificationService.prototype.fetchActivationStatus = function () {
2138
+ WDOBaseActivationService.prototype.verifyHasActiveProcess = function () {
1909
2139
  return __awaiter(this, void 0, void 0, function () {
1910
- var result;
2140
+ var pid;
1911
2141
  return __generator(this, function (_a) {
1912
2142
  switch (_a.label) {
1913
- case 0: return [4 /*yield*/, this.powerauth.fetchActivationStatus()];
2143
+ case 0: return [4 /*yield*/, this.processId()];
1914
2144
  case 1:
1915
- result = _a.sent();
1916
- return [2 /*return*/, {
1917
- state: WDOPowerAuthActivationState[result.state],
1918
- failCount: result.failCount,
1919
- maxFailCount: result.maxFailCount,
1920
- remainingAttempts: result.remainingAttempts,
1921
- customObject: result.customObject
1922
- }];
2145
+ pid = _a.sent();
2146
+ if (!pid) {
2147
+ WDOLogger.warn("Cannot proceed (processId not available).");
2148
+ throw new WDOError(exports.WDOErrorReason.processNotInProgress, "No active activation process");
2149
+ }
2150
+ return [2 /*return*/, pid];
1923
2151
  }
1924
2152
  });
1925
2153
  });
1926
2154
  };
1927
- /* @internal */
1928
- WDOVerificationService.prototype.changeAcceptLanguageImpl = function (language) {
1929
- this.api.networking.acceptLanguage = language;
1930
- };
1931
- return WDOVerificationService;
1932
- }(WDOBaseVerificationService));
2155
+ return WDOBaseActivationService;
2156
+ }());
1933
2157
 
1934
2158
  /**
1935
2159
  * Copyright Wultra s.r.o.
@@ -1941,7 +2165,15 @@ var WDOVerificationService = /** @class */ (function (_super) {
1941
2165
  */
1942
2166
  /** Service that provides configuration for the Wultra Digital Onboarding SDK. */
1943
2167
  var WDOBaseConfigurationService = /** @class */ (function () {
1944
- function WDOBaseConfigurationService() {
2168
+ /**
2169
+ * Creates service instance
2170
+ *
2171
+ * @param powerauth Configured PowerAuth instance.
2172
+ * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
2173
+ */
2174
+ function WDOBaseConfigurationService(powerauth, baseUrl) {
2175
+ this.api = new WDOApi(powerauth, baseUrl);
2176
+ this.powerauth = powerauth;
1945
2177
  }
1946
2178
  /**
1947
2179
  * Fetches configuration for the given process type from the server.
@@ -1970,21 +2202,47 @@ var WDOBaseConfigurationService = /** @class */ (function () {
1970
2202
  *
1971
2203
  * SPDX-License-Identifier: Apache-2.0
1972
2204
  */
1973
-
2205
+ WDOPlatform.cache = new WDOCordovaCache();
2206
+ WDOPlatform.networkingFactory = new WDONetworkingFactoryCordova();
2207
+ WDOPlatform.powerAuthFactory = new WDOPowerAuthFactoryCordova();
2208
+ /**
2209
+ * Service that can activate PowerAuth instance by user weak credentials (like his email, phone number or client ID) + optional SMS OTP.
2210
+ *
2211
+ * When the PowerAuth is activated with this service, `WDOVerificationService.isVerificationRequired` will be `true`
2212
+ * and you will need to verify the PowerAuth instance via `WDOVerificationService`.
2213
+ *
2214
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
2215
+ */
2216
+ var WDOActivationService = /** @class */ (function (_super) {
2217
+ __extends(WDOActivationService, _super);
2218
+ function WDOActivationService() {
2219
+ return _super !== null && _super.apply(this, arguments) || this;
2220
+ }
2221
+ return WDOActivationService;
2222
+ }(WDOBaseActivationService));
2223
+ /**
2224
+ * Service that can verify previously activated PowerAuth instance.
2225
+ *
2226
+ * When PowerAuth instance was activated with weak credentials via `WDOActivationService`, user needs to verify his genuine presence.
2227
+ *
2228
+ * This service operates against Wultra Onboarding server (usually ending with `/enrollment-onboarding-server`) and you need to configure networking service with the right URL.
2229
+ */
2230
+ var WDOVerificationService = /** @class */ (function (_super) {
2231
+ __extends(WDOVerificationService, _super);
2232
+ function WDOVerificationService() {
2233
+ return _super !== null && _super.apply(this, arguments) || this;
2234
+ }
2235
+ /** Checks if verification is required based on PowerAuth activation status */
2236
+ WDOVerificationService.isVerificationRequired = function (paStatus) {
2237
+ return _super.isVerificationRequiredInternal.call(this, paStatus);
2238
+ };
2239
+ return WDOVerificationService;
2240
+ }(WDOBaseVerificationService));
1974
2241
  /** Service that provides configuration for the Wultra Digital Onboarding SDK. */
1975
2242
  var WDOConfigurationService = /** @class */ (function (_super) {
1976
2243
  __extends(WDOConfigurationService, _super);
1977
- /**
1978
- * Creates service instance
1979
- *
1980
- * @param powerauth Configured PowerAuth instance.
1981
- * @param baseUrl Base URL of the Wultra Digital Onboarding server. Usually ending with `/enrollment-onboarding-server`.
1982
- */
1983
- function WDOConfigurationService(powerauth, baseUrl) {
1984
- var _this = _super.call(this) || this;
1985
- _this.api = new WDOApi(powerauth, baseUrl);
1986
- _this.powerauth = powerauth;
1987
- return _this;
2244
+ function WDOConfigurationService() {
2245
+ return _super !== null && _super.apply(this, arguments) || this;
1988
2246
  }
1989
2247
  return WDOConfigurationService;
1990
2248
  }(WDOBaseConfigurationService));
@@ -1992,8 +2250,10 @@ var WDOConfigurationService = /** @class */ (function (_super) {
1992
2250
  exports.Side = Side;
1993
2251
  exports.WDOActivationService = WDOActivationService;
1994
2252
  exports.WDOConfigurationService = WDOConfigurationService;
2253
+ exports.WDOCreateDocumentSubmitFileSide = WDOCreateDocumentSubmitFileSide;
1995
2254
  exports.WDODocumentFile = WDODocumentFile;
1996
- exports.WDODocumentTypeSides = WDODocumentTypeSides;
2255
+ exports.WDODocumentTypeToSubmitType = WDODocumentTypeToSubmitType;
2256
+ exports.WDOError = WDOError;
1997
2257
  exports.WDOLogger = WDOLogger;
1998
2258
  exports.WDOScannedDocument = WDOScannedDocument;
1999
2259
  exports.WDOVerificationScanProcess = WDOVerificationScanProcess;