cordova-digital-onboarding 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -135,14 +135,85 @@ var WDOLogger = /** @class */ (function () {
135
135
  *
136
136
  * SPDX-License-Identifier: Apache-2.0
137
137
  */
138
- // TODO: add ERROR codes
138
+ /** Represent error thrown from a WDO library */
139
139
  var WDOError = /** @class */ (function () {
140
- function WDOError(message, additionalInfo) {
140
+ /* @internal */
141
+ function WDOError(reason, message, additionalInfo) {
142
+ /** Helper to identify this object as a WDOError */
143
+ this.isWdoError = true;
144
+ this.reason = reason;
141
145
  this.message = message;
142
146
  this.additionalInfo = additionalInfo;
143
147
  }
148
+ Object.defineProperty(WDOError.prototype, "allowOnboardingOtpRetry", {
149
+ /**
150
+ * Whether retrying OTP is allowed based on remaining attempts.
151
+ *
152
+ * This may be filled only when the error reason is `WDOErrorReason.activationFailed`.
153
+ */
154
+ get: function () { return this.onboardingOtpRemainingAttempts !== undefined && this.onboardingOtpRemainingAttempts > 0; },
155
+ enumerable: false,
156
+ configurable: true
157
+ });
158
+ Object.defineProperty(WDOError.prototype, "onboardingOtpRemainingAttempts", {
159
+ /**
160
+ * Number of remaining OTP attempts during onboarding
161
+ *
162
+ * This may be filled only when the error reason is `WDOErrorReason.activationFailed`.
163
+ */
164
+ get: function () {
165
+ var _a, _b, _c, _d;
166
+ 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) {
167
+ try {
168
+ var parsedResponse = JSON.parse(this.additionalInfo.originalException.userInfo.responseBody);
169
+ return (_d = parsedResponse.remainingAttempts) !== null && _d !== void 0 ? _d : undefined;
170
+ }
171
+ catch (_e) {
172
+ WDOLogger.error("WDOError.onboardingOtpRemainingAttempts: failed to parse response body");
173
+ return undefined;
174
+ }
175
+ }
176
+ else {
177
+ return undefined;
178
+ }
179
+ },
180
+ enumerable: false,
181
+ configurable: true
182
+ });
144
183
  return WDOError;
145
184
  }());
185
+ /** Reasons for WDO errors */
186
+ exports.WDOErrorReason = void 0;
187
+ (function (WDOErrorReason) {
188
+ /** Network error occurred */
189
+ WDOErrorReason["networkError"] = "NETWORK_ERROR";
190
+ /** Activation failed */
191
+ WDOErrorReason["activationFailed"] = "ACTIVATION_FAILED";
192
+ /** Process is already in progress - happens when start() is called twice */
193
+ WDOErrorReason["processAlreadyInProgress"] = "PROCESS_ALREADY_IN_PROGRESS";
194
+ /** No process is in progress - happens when an operation requires an active process */
195
+ WDOErrorReason["processNotInProgress"] = "PROCESS_NOT_IN_PROGRESS";
196
+ /** The PowerAuth instance is already activated when trying to activate it again */
197
+ WDOErrorReason["powerauthAlreadyActivated"] = "POWERAUTH_ALREADY_ACTIVATED";
198
+ /** The PowerAuth instance is not activated when trying to use it */
199
+ WDOErrorReason["powerauthNotActivated"] = "POWERAUTH_NOT_ACTIVATED";
200
+ /** OTP verification failed */
201
+ WDOErrorReason["otpFailed"] = "OTP_FAILED";
202
+ })(exports.WDOErrorReason || (exports.WDOErrorReason = {}));
203
+
204
+ /**
205
+ * Copyright Wultra s.r.o.
206
+ *
207
+ * This source code is licensed under the Apache License, Version 2.0 license
208
+ * found in the LICENSE file in the root directory of this source tree.
209
+ *
210
+ * SPDX-License-Identifier: Apache-2.0
211
+ */
212
+ var WDODefaultCache = /** @class */ (function () {
213
+ function WDODefaultCache() {
214
+ }
215
+ return WDODefaultCache;
216
+ }());
146
217
 
147
218
  /**
148
219
  * Copyright Wultra s.r.o.
@@ -163,17 +234,20 @@ var WDOError = /** @class */ (function () {
163
234
  var WDOBaseActivationService = /** @class */ (function () {
164
235
  function WDOBaseActivationService() {
165
236
  }
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
- });
237
+ /**
238
+ * If the activation process is in progress.
239
+ *
240
+ * Note that even if this property is `true` it can be already discontinued on the server.
241
+ * Calling `status()` for example after the app is launched in this case is recommended.
242
+ */
243
+ WDOBaseActivationService.prototype.hasActiveProcess = function () {
244
+ return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
245
+ switch (_a.label) {
246
+ case 0: return [4 /*yield*/, this.getCachedProcessData()];
247
+ case 1: return [2 /*return*/, !!(_a.sent())];
248
+ }
249
+ }); });
250
+ };
177
251
  /**
178
252
  * Accept language for the outgoing requests headers.
179
253
  * Default value is "en".
@@ -185,12 +259,47 @@ var WDOBaseActivationService = /** @class */ (function () {
185
259
  WDOBaseActivationService.prototype.changeAcceptLanguage = function (language) {
186
260
  this.changeAcceptLanguageImpl(language);
187
261
  };
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
- });
262
+ /* @internal */
263
+ WDOBaseActivationService.prototype.cacheKey = function () { return "wdopd_".concat(this.getPAInstanceId()); };
264
+ /* @internal */
265
+ WDOBaseActivationService.prototype.setCachedProcessData = function (data) {
266
+ return __awaiter(this, void 0, void 0, function () {
267
+ return __generator(this, function (_a) {
268
+ switch (_a.label) {
269
+ case 0: return [4 /*yield*/, WDODefaultCache.instance.set(this.cacheKey(), JSON.stringify(data))];
270
+ case 1:
271
+ _a.sent();
272
+ return [2 /*return*/];
273
+ }
274
+ });
275
+ });
276
+ };
277
+ /* @internal */
278
+ WDOBaseActivationService.prototype.getCachedProcessData = function () {
279
+ return __awaiter(this, void 0, void 0, function () {
280
+ var data;
281
+ return __generator(this, function (_a) {
282
+ switch (_a.label) {
283
+ case 0: return [4 /*yield*/, WDODefaultCache.instance.get(this.cacheKey())];
284
+ case 1:
285
+ data = _a.sent();
286
+ if (!data) {
287
+ return [2 /*return*/, undefined];
288
+ }
289
+ return [2 /*return*/, JSON.parse(data)];
290
+ }
291
+ });
292
+ });
293
+ };
294
+ /* @internal */
295
+ WDOBaseActivationService.prototype.processId = function () {
296
+ return __awaiter(this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
297
+ switch (_b.label) {
298
+ case 0: return [4 /*yield*/, this.getCachedProcessData()];
299
+ case 1: return [2 /*return*/, (_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.processId];
300
+ }
301
+ }); });
302
+ };
194
303
  // PUBLIC API
195
304
  /**
196
305
  * Retrieves status of the onboarding activation.
@@ -199,18 +308,24 @@ var WDOBaseActivationService = /** @class */ (function () {
199
308
  */
200
309
  WDOBaseActivationService.prototype.status = function () {
201
310
  return __awaiter(this, void 0, void 0, function () {
202
- var pid, result;
203
- return __generator(this, function (_a) {
204
- switch (_a.label) {
311
+ var _a, _b, _c, pid, result;
312
+ return __generator(this, function (_d) {
313
+ switch (_d.label) {
205
314
  case 0:
206
- WDOLogger.debug("Getting activation status for processId=".concat(this.processId));
207
- return [4 /*yield*/, this.verifyCanStartProcess()];
315
+ _b = (_a = WDOLogger).debug;
316
+ _c = "Getting activation status for processId=".concat;
317
+ return [4 /*yield*/, this.processId()];
208
318
  case 1:
209
- _a.sent();
210
- pid = this.verifyHasActiveProcess();
211
- return [4 /*yield*/, this.api.activationGetStatus(pid)];
319
+ _b.apply(_a, [_c.apply("Getting activation status for processId=", [_d.sent()])]);
320
+ return [4 /*yield*/, this.verifyCanStartActivation()];
212
321
  case 2:
213
- result = _a.sent();
322
+ _d.sent();
323
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
324
+ case 3:
325
+ pid = _d.sent();
326
+ return [4 /*yield*/, this.api.activationGetStatus(pid)];
327
+ case 4:
328
+ result = _d.sent();
214
329
  return [2 /*return*/, result.onboardingStatus];
215
330
  }
216
331
  });
@@ -236,18 +351,22 @@ var WDOBaseActivationService = /** @class */ (function () {
236
351
  switch (_a.label) {
237
352
  case 0:
238
353
  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()];
354
+ return [4 /*yield*/, this.processId()];
243
355
  case 1:
356
+ if (_a.sent()) {
357
+ throw new WDOError(exports.WDOErrorReason.processAlreadyInProgress, "Cannot start the process - processId already obtained, cancel first.");
358
+ }
359
+ return [4 /*yield*/, this.verifyCanStartActivation()];
360
+ case 2:
244
361
  _a.sent();
245
362
  return [4 /*yield*/, this.api.activationStart(credentials, processType)];
246
- case 2:
363
+ case 3:
247
364
  result = _a.sent();
248
365
  WDOLogger.info("WDOActivationService.start success");
249
366
  WDOLogger.debug(" - processId: ".concat(result.processId));
250
- this.processData = { processId: result.processId, activationCode: result.activationCode };
367
+ return [4 /*yield*/, this.setCachedProcessData({ processId: result.processId, activationCode: result.activationCode })];
368
+ case 4:
369
+ _a.sent();
251
370
  return [2 /*return*/];
252
371
  }
253
372
  });
@@ -260,41 +379,58 @@ var WDOBaseActivationService = /** @class */ (function () {
260
379
  */
261
380
  WDOBaseActivationService.prototype.cancel = function () {
262
381
  return __awaiter(this, arguments, void 0, function (forceCancel) {
263
- var pid, error_1;
382
+ var _a, _b, _c, pid, error_1;
264
383
  if (forceCancel === void 0) { forceCancel = true; }
265
- return __generator(this, function (_a) {
266
- switch (_a.label) {
384
+ return __generator(this, function (_d) {
385
+ switch (_d.label) {
267
386
  case 0:
268
- WDOLogger.debug("Canceling activation for processId=".concat(this.processId, ", forceCancel=").concat(forceCancel));
269
- pid = this.verifyHasActiveProcess();
270
- _a.label = 1;
387
+ _b = (_a = WDOLogger).debug;
388
+ _c = "Canceling activation for processId=".concat;
389
+ return [4 /*yield*/, this.processId()];
271
390
  case 1:
272
- _a.trys.push([1, 3, , 4]);
273
- return [4 /*yield*/, this.api.activationCancel(pid)];
391
+ _b.apply(_a, [_c.apply("Canceling activation for processId=", [_d.sent(), ", forceCancel="]).concat(forceCancel)]);
392
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
274
393
  case 2:
275
- _a.sent();
276
- this.processData = undefined;
277
- WDOLogger.info("WDOActivationService.cancel success");
278
- return [3 /*break*/, 4];
394
+ pid = _d.sent();
395
+ _d.label = 3;
279
396
  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*/];
397
+ _d.trys.push([3, 6, , 10]);
398
+ return [4 /*yield*/, this.api.activationCancel(pid)];
399
+ case 4:
400
+ _d.sent();
401
+ return [4 /*yield*/, this.setCachedProcessData(undefined)];
402
+ case 5:
403
+ _d.sent();
404
+ WDOLogger.info("WDOActivationService.cancel success");
405
+ return [3 /*break*/, 10];
406
+ case 6:
407
+ error_1 = _d.sent();
408
+ if (!forceCancel) return [3 /*break*/, 8];
409
+ // pretend it was successful and just log the error
410
+ WDOLogger.debug("Process canceled (but the request failed) - ".concat(error_1, "."));
411
+ return [4 /*yield*/, this.setCachedProcessData(undefined)];
412
+ case 7:
413
+ _d.sent();
414
+ return [3 /*break*/, 9];
415
+ case 8: throw error_1; // rethrow
416
+ case 9: return [3 /*break*/, 10];
417
+ case 10: return [2 /*return*/];
291
418
  }
292
419
  });
293
420
  });
294
421
  };
295
422
  /** Clear the stored data (without networking call). */
296
423
  WDOBaseActivationService.prototype.clear = function () {
297
- this.processData = undefined;
424
+ return __awaiter(this, void 0, void 0, function () {
425
+ return __generator(this, function (_a) {
426
+ switch (_a.label) {
427
+ case 0: return [4 /*yield*/, this.setCachedProcessData(undefined)];
428
+ case 1:
429
+ _a.sent();
430
+ return [2 /*return*/];
431
+ }
432
+ });
433
+ });
298
434
  };
299
435
  /**
300
436
  * OTP resend request.
@@ -309,12 +445,14 @@ var WDOBaseActivationService = /** @class */ (function () {
309
445
  switch (_a.label) {
310
446
  case 0:
311
447
  WDOLogger.debug("Activation: resending OTP");
312
- pid = this.verifyHasActiveProcess();
313
- return [4 /*yield*/, this.verifyCanStartProcess()];
448
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
314
449
  case 1:
450
+ pid = _a.sent();
451
+ return [4 /*yield*/, this.verifyCanStartActivation()];
452
+ case 2:
315
453
  _a.sent();
316
454
  return [4 /*yield*/, this.api.activationResendOTP(pid)];
317
- case 2:
455
+ case 3:
318
456
  _a.sent();
319
457
  return [2 /*return*/];
320
458
  }
@@ -334,9 +472,11 @@ var WDOBaseActivationService = /** @class */ (function () {
334
472
  switch (_a.label) {
335
473
  case 0:
336
474
  WDOLogger.debug("Activation: getting OTP from server (only for testing purposes)");
337
- pid = this.verifyHasActiveProcess();
475
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
476
+ case 1:
477
+ pid = _a.sent();
338
478
  return [4 /*yield*/, this.api.activationGetOTP(pid, "ACTIVATION")];
339
- case 1: return [2 /*return*/, (_a.sent()).otpCode];
479
+ case 2: return [2 /*return*/, (_a.sent()).otpCode];
340
480
  }
341
481
  });
342
482
  });
@@ -344,39 +484,53 @@ var WDOBaseActivationService = /** @class */ (function () {
344
484
  /**
345
485
  * Activate the PowerAuth instance that was passed in the initializer.
346
486
  *
347
- * @param activationName Name of the activation. Device name by default (usually something like John's iPhone or similar).
487
+ * @param activationName Name of the activation. Usually something like John's iPhone or similar.
348
488
  * @param otp OTP code received by the user (via SMS or email). Optional when not required.
349
489
  * @return Promise resolved with activation result.
350
490
  */
351
491
  WDOBaseActivationService.prototype.activate = function (activationName, otp) {
352
492
  return __awaiter(this, void 0, void 0, function () {
353
- var pid, code, result, identityAttributes;
493
+ var pid, code, result, identityAttributes, error_2;
354
494
  var _a;
355
495
  return __generator(this, function (_b) {
356
496
  switch (_b.label) {
357
497
  case 0:
358
498
  WDOLogger.debug("Activating the PowerAuth with activation name '".concat(activationName, "'"));
359
- return [4 /*yield*/, this.verifyCanStartProcess()];
499
+ return [4 /*yield*/, this.verifyCanStartActivation()];
360
500
  case 1:
361
501
  _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];
502
+ return [4 /*yield*/, this.verifyHasActiveProcess()];
503
+ case 2:
504
+ pid = _b.sent();
505
+ return [4 /*yield*/, this.getCachedProcessData()];
506
+ case 3:
507
+ code = (_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.activationCode;
508
+ _b.label = 4;
509
+ case 4:
510
+ _b.trys.push([4, 9, , 10]);
511
+ if (!code) return [3 /*break*/, 6];
365
512
  WDOLogger.info("Activating PowerAuth using activation code from the onboarding process");
366
513
  return [4 /*yield*/, this.activatePowerAuthWithCode(code, otp, activationName)];
367
- case 2:
514
+ case 5:
368
515
  result = _b.sent();
369
- return [3 /*break*/, 5];
370
- case 3:
516
+ return [3 /*break*/, 8];
517
+ case 6:
371
518
  WDOLogger.info("Activating PowerAuth using identity attributes from the onboarding process");
372
519
  identityAttributes = { processId: pid, otpCode: otp, credentialsType: "ONBOARDING" };
373
520
  return [4 /*yield*/, this.activatePowerAuth(identityAttributes, activationName)];
374
- case 4:
521
+ case 7:
375
522
  result = _b.sent();
376
- _b.label = 5;
377
- case 5:
523
+ _b.label = 8;
524
+ case 8: return [3 /*break*/, 10];
525
+ case 9:
526
+ error_2 = _b.sent();
527
+ throw new WDOError(exports.WDOErrorReason.activationFailed, "Activation failed", error_2);
528
+ case 10:
529
+ // Clear process ID after activation attempt
530
+ return [4 /*yield*/, this.setCachedProcessData(undefined)];
531
+ case 11:
378
532
  // Clear process ID after activation attempt
379
- this.processData = undefined;
533
+ _b.sent();
380
534
  return [2 /*return*/, result];
381
535
  }
382
536
  });
@@ -384,30 +538,40 @@ var WDOBaseActivationService = /** @class */ (function () {
384
538
  };
385
539
  // PRIVATE METHODS
386
540
  /* @internal */
387
- WDOBaseActivationService.prototype.verifyCanStartProcess = function () {
541
+ WDOBaseActivationService.prototype.verifyCanStartActivation = function () {
388
542
  return __awaiter(this, void 0, void 0, function () {
389
543
  return __generator(this, function (_a) {
390
544
  switch (_a.label) {
391
545
  case 0: return [4 /*yield*/, this.api.canStartActivation()];
392
546
  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*/];
547
+ if (!!(_a.sent())) return [3 /*break*/, 3];
548
+ WDOLogger.error("PowerAuth is already activated - Activation cannot be started/processed.");
549
+ return [4 /*yield*/, this.setCachedProcessData(undefined)];
550
+ case 2:
551
+ _a.sent();
552
+ throw new WDOError(exports.WDOErrorReason.powerauthAlreadyActivated, "PowerAuth is already activated");
553
+ case 3: return [2 /*return*/];
399
554
  }
400
555
  });
401
556
  });
402
557
  };
403
558
  /* @internal */
404
559
  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;
560
+ return __awaiter(this, void 0, void 0, function () {
561
+ var pid;
562
+ return __generator(this, function (_a) {
563
+ switch (_a.label) {
564
+ case 0: return [4 /*yield*/, this.processId()];
565
+ case 1:
566
+ pid = _a.sent();
567
+ if (!pid) {
568
+ WDOLogger.warn("Cannot proceed (processId not available).");
569
+ throw new WDOError(exports.WDOErrorReason.processNotInProgress, "No active activation process");
570
+ }
571
+ return [2 /*return*/, pid];
572
+ }
573
+ });
574
+ });
411
575
  };
412
576
  return WDOBaseActivationService;
413
577
  }());
@@ -484,13 +648,6 @@ var WDOVerificationEndpoints = /** @class */ (function () {
484
648
  e2eeScope: "ACTIVATION",
485
649
  returnsData: true
486
650
  };
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
651
  WDOVerificationEndpoints.v2submitDocuments = {
495
652
  path: "/api/v2/identity/document/submit",
496
653
  tokenName: "possession_universal",
@@ -580,18 +737,18 @@ var WDOBaseApi = /** @class */ (function () {
580
737
  return this.callApi(requestObject, WDOVerificationEndpoints.cancel);
581
738
  };
582
739
  WDOBaseApi.prototype.verificationGetConsentText = function (processId) {
583
- var requestObject = { processId: processId, consentType: "GDPR" }; // TODO: hardcoded type
740
+ var requestObject = { processId: processId, consentType: "GDPR" };
584
741
  return this.callApi(requestObject, WDOVerificationEndpoints.consentText);
585
742
  };
586
743
  WDOBaseApi.prototype.verificationResolveConsent = function (processId, approved) {
587
- var requestObject = { processId: processId, approved: approved, consentType: "GDPR" }; // TODO: hardcoded type
744
+ var requestObject = { processId: processId, approved: approved, consentType: "GDPR" };
588
745
  return this.callApi(requestObject, WDOVerificationEndpoints.consentApprove);
589
746
  };
590
747
  WDOBaseApi.prototype.verificationInitScanSDK = function (processId, challenge) {
591
748
  var requestObject = { processId: processId, attributes: { 'sdk-init-token': challenge } };
592
749
  return this.callApi(requestObject, WDOVerificationEndpoints.documentScanSdkInit);
593
750
  };
594
- WDOBaseApi.prototype.verificationSubmitDocumentsV2 = function (processId, resubmit, documents) {
751
+ WDOBaseApi.prototype.verificationSubmitDocuments = function (processId, resubmit, documents) {
595
752
  var requestObject = {
596
753
  processId: processId,
597
754
  resubmit: resubmit,
@@ -600,11 +757,6 @@ var WDOBaseApi = /** @class */ (function () {
600
757
  // TODO: there should be longer timeout!
601
758
  return this.callApi(requestObject, WDOVerificationEndpoints.v2submitDocuments);
602
759
  };
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
760
  WDOBaseApi.prototype.verificationDocumentsStatus = function (processId) {
609
761
  var requestObject = { processId: processId };
610
762
  // TODO: longer timeout?
@@ -657,14 +809,14 @@ var WDOApi = /** @class */ (function (_super) {
657
809
  return result.responseObject;
658
810
  }
659
811
  else if (result.responseError) {
660
- throw new WDOError("Server API error: ".concat(result.responseError.code, ", ").concat(result.responseError.message), result.responseError);
812
+ throw new WDOError(exports.WDOErrorReason.networkError, "Server API error: ".concat(result.responseError.code, ", ").concat(result.responseError.message), result.responseError);
661
813
  }
662
814
  else if (!endpoint.returnsData) {
663
815
  // for void responses
664
816
  return {};
665
817
  }
666
818
  else {
667
- throw new WDOError("Failed to retrieve activation data");
819
+ throw new WDOError(exports.WDOErrorReason.networkError, "Failed to retrieve server data");
668
820
  }
669
821
  });
670
822
  };
@@ -743,6 +895,10 @@ var WDOActivationService = /** @class */ (function (_super) {
743
895
  WDOActivationService.prototype.changeAcceptLanguageImpl = function (language) {
744
896
  this.api.networking.acceptLanguage = language;
745
897
  };
898
+ /* @internal */
899
+ WDOActivationService.prototype.getPAInstanceId = function () {
900
+ return this.powerauth.instanceId;
901
+ };
746
902
  return WDOActivationService;
747
903
  }(WDOBaseActivationService));
748
904
 
@@ -788,86 +944,6 @@ var WDOPowerAuthActivationState;
788
944
  WDOPowerAuthActivationState["DEADLOCK"] = "DEADLOCK";
789
945
  })(WDOPowerAuthActivationState || (WDOPowerAuthActivationState = {}));
790
946
 
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.
809
- */
810
- function WDODocumentFile(data, type, side, originalDocumentId, dataSignature) {
811
- this.data = data;
812
- this.dataSignature = dataSignature;
813
- this.type = type;
814
- this.side = side;
815
- this.originalDocumentId = originalDocumentId;
816
- }
817
- /**
818
- * Create the document file from an image that can be sent to the backend for Identity Verification.
819
- *
820
- * @param scannedDocument Document to upload.
821
- * @param side The side of the document that the image captures.
822
- * @param data Raw image data. Make sure that the data aren't too big, hundreds of kbs should be enough.
823
- * @param dataSignature Signature of the image data. Optional, use only when the scan SDK supports this. `undefined` by default.
824
- * @returns Document file to upload.
825
- */
826
- WDODocumentFile.fromScannedDocument = function (scannedDocument, side, data, dataSignature) {
827
- var _a;
828
- var originalDocumentId = (_a = scannedDocument.sides.find(function (s) { return s.type === side; })) === null || _a === void 0 ? void 0 : _a.serverId;
829
- return new WDODocumentFile(data, scannedDocument.type, side, originalDocumentId, dataSignature);
830
- };
831
- return WDODocumentFile;
832
- }());
833
- /** Type of the document. */
834
- exports.WDODocumentType = void 0;
835
- (function (WDODocumentType) {
836
- /** National ID card */
837
- WDODocumentType["idCard"] = "idCard";
838
- /** Passport */
839
- WDODocumentType["passport"] = "passport";
840
- /** Drivers license */
841
- WDODocumentType["driversLicense"] = "driversLicense";
842
- })(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
- /** Side of the document */
860
- exports.WDODocumentSide = void 0;
861
- (function (WDODocumentSide) {
862
- /** Front side of a document. Usually the one with the picture.
863
- *
864
- * When a document has more than one side but only one side is used (for example passport), then such side is considered to be front.
865
- */
866
- WDODocumentSide["front"] = "front";
867
- /** Back side of a document */
868
- WDODocumentSide["back"] = "back";
869
- })(exports.WDODocumentSide || (exports.WDODocumentSide = {}));
870
-
871
947
  /**
872
948
  * Copyright Wultra s.r.o.
873
949
  *
@@ -877,7 +953,7 @@ exports.WDODocumentSide = void 0;
877
953
  * SPDX-License-Identifier: Apache-2.0
878
954
  */
879
955
  /** Status of the onboarding */
880
- var WDOOnboardingStatus;
956
+ exports.WDOOnboardingStatus = void 0;
881
957
  (function (WDOOnboardingStatus) {
882
958
  /** Activation part of the process is in progress */
883
959
  WDOOnboardingStatus["activationInProgress"] = "ACTIVATION_IN_PROGRESS";
@@ -887,9 +963,9 @@ var WDOOnboardingStatus;
887
963
  WDOOnboardingStatus["failed"] = "FAILED";
888
964
  /** Onboarding process is completed */
889
965
  WDOOnboardingStatus["finished"] = "FINISHED";
890
- })(WDOOnboardingStatus || (WDOOnboardingStatus = {}));
966
+ })(exports.WDOOnboardingStatus || (exports.WDOOnboardingStatus = {}));
891
967
  /** Status of the current identity verification */
892
- var WDOIdentityVerificationStatus;
968
+ exports.WDOIdentityVerificationStatus = void 0;
893
969
  (function (WDOIdentityVerificationStatus) {
894
970
  /** Identity verification is waiting for initialization */
895
971
  WDOIdentityVerificationStatus["notInitialized"] = "NOT_INITIALIZED";
@@ -903,9 +979,9 @@ var WDOIdentityVerificationStatus;
903
979
  WDOIdentityVerificationStatus["failed"] = "FAILED";
904
980
  /** Identity verification was rejected */
905
981
  WDOIdentityVerificationStatus["rejected"] = "REJECTED";
906
- })(WDOIdentityVerificationStatus || (WDOIdentityVerificationStatus = {}));
982
+ })(exports.WDOIdentityVerificationStatus || (exports.WDOIdentityVerificationStatus = {}));
907
983
  /** Phase of the current identity verification */
908
- var WDOIdentityVerificationPhase;
984
+ exports.WDOIdentityVerificationPhase = void 0;
909
985
  (function (WDOIdentityVerificationPhase) {
910
986
  /** Document upload is in progress */
911
987
  WDOIdentityVerificationPhase["documentUpload"] = "DOCUMENT_UPLOAD";
@@ -921,9 +997,9 @@ var WDOIdentityVerificationPhase;
921
997
  WDOIdentityVerificationPhase["otp"] = "OTP_VERIFICATION";
922
998
  /** Completed */
923
999
  WDOIdentityVerificationPhase["completed"] = "COMPLETED";
924
- })(WDOIdentityVerificationPhase || (WDOIdentityVerificationPhase = {}));
1000
+ })(exports.WDOIdentityVerificationPhase || (exports.WDOIdentityVerificationPhase = {}));
925
1001
  /** Types of available documents */
926
- var WDODocumentSubmitFileType;
1002
+ exports.WDODocumentSubmitFileType = void 0;
927
1003
  (function (WDODocumentSubmitFileType) {
928
1004
  /** National ID card */
929
1005
  WDODocumentSubmitFileType["idCard"] = "ID_CARD";
@@ -933,17 +1009,17 @@ var WDODocumentSubmitFileType;
933
1009
  WDODocumentSubmitFileType["driversLicense"] = "DRIVING_LICENSE";
934
1010
  /** Selfie photo */
935
1011
  WDODocumentSubmitFileType["selfiePhoto"] = "SELFIE_PHOTO";
936
- })(WDODocumentSubmitFileType || (WDODocumentSubmitFileType = {}));
1012
+ })(exports.WDODocumentSubmitFileType || (exports.WDODocumentSubmitFileType = {}));
937
1013
  /** Side of the file */
938
- var WDODocumentSubmitFileSide;
1014
+ exports.WDODocumentSubmitFileSide = void 0;
939
1015
  (function (WDODocumentSubmitFileSide) {
940
1016
  /** Front side of an document. Usually the one with the picture */
941
1017
  WDODocumentSubmitFileSide["front"] = "FRONT";
942
1018
  /** Back side of an document */
943
1019
  WDODocumentSubmitFileSide["back"] = "BACK";
944
- })(WDODocumentSubmitFileSide || (WDODocumentSubmitFileSide = {}));
1020
+ })(exports.WDODocumentSubmitFileSide || (exports.WDODocumentSubmitFileSide = {}));
945
1021
  /** Status of the document */
946
- var WDODocumentStatus;
1022
+ exports.WDODocumentStatus = void 0;
947
1023
  (function (WDODocumentStatus) {
948
1024
  /** Document was accepted */
949
1025
  WDODocumentStatus["accepted"] = "ACCEPTED";
@@ -959,27 +1035,7 @@ var WDODocumentStatus;
959
1035
  WDODocumentStatus["rejected"] = "REJECTED";
960
1036
  /** Verification of the document failed */
961
1037
  WDODocumentStatus["failed"] = "FAILED";
962
- })(WDODocumentStatus || (WDODocumentStatus = {}));
963
- /** Converts WDODocumentType to DocumentSubmitFileType */
964
- function WDOCreateDocumentSubmitFileType(type) {
965
- switch (type) {
966
- case exports.WDODocumentType.idCard:
967
- return WDODocumentSubmitFileType.idCard;
968
- case exports.WDODocumentType.passport:
969
- return WDODocumentSubmitFileType.passport;
970
- case exports.WDODocumentType.driversLicense:
971
- return WDODocumentSubmitFileType.driversLicense;
972
- }
973
- }
974
- /** Converts WDODocumentSide to DocumentSubmitFileSide */
975
- function WDOCreateDocumentSubmitFileSide(side) {
976
- switch (side) {
977
- case exports.WDODocumentSide.front:
978
- return WDODocumentSubmitFileSide.front;
979
- case exports.WDODocumentSide.back:
980
- return WDODocumentSubmitFileSide.back;
981
- }
982
- }
1038
+ })(exports.WDODocumentStatus || (exports.WDODocumentStatus = {}));
983
1039
 
984
1040
  /**
985
1041
  * Copyright Wultra s.r.o.
@@ -995,17 +1051,9 @@ exports.WDOVerificationStateType = void 0;
995
1051
  /**
996
1052
  * Show the verification introduction screen where the user can start the activation.
997
1053
  *
998
- * The next step should be calling the `consentGet()`.
1054
+ * The next step should be calling the `start()`.
999
1055
  */
1000
1056
  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
1057
  /**
1010
1058
  * Show document selection to the user. Which documents are available and how many
1011
1059
  * can the user select is up to your backend configuration.
@@ -1093,6 +1141,106 @@ exports.WDOStatusCheckReason = void 0;
1093
1141
  WDOStatusCheckReason["verifyingPresence"] = "verifyingPresence";
1094
1142
  })(exports.WDOStatusCheckReason || (exports.WDOStatusCheckReason = {}));
1095
1143
 
1144
+ /**
1145
+ * Copyright Wultra s.r.o.
1146
+ *
1147
+ * This source code is licensed under the Apache License, Version 2.0 license
1148
+ * found in the LICENSE file in the root directory of this source tree.
1149
+ *
1150
+ * SPDX-License-Identifier: Apache-2.0
1151
+ */
1152
+ /** Image of a document that can be sent to the backend for Identity Verification. */
1153
+ var WDODocumentFile = /** @class */ (function () {
1154
+ /**
1155
+ * Image of a document that can be sent to the backend for Identity Verification.
1156
+ *
1157
+ * @param data Raw image data. Make sure that the data aren't too big, hundreds of kbs should be enough.
1158
+ * @param type Type of the document.
1159
+ * @param side The side of the document that the image captures.
1160
+ * @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.
1161
+ * @param dataSignature Signature of the image data. Optional, use only when the scan SDK supports this. `undefined` by default.
1162
+ */
1163
+ function WDODocumentFile(data, type, side, originalDocumentId, dataSignature) {
1164
+ this.data = data;
1165
+ this.dataSignature = dataSignature;
1166
+ this.type = type;
1167
+ this.side = side;
1168
+ this.originalDocumentId = originalDocumentId;
1169
+ }
1170
+ /**
1171
+ * Create the document file from an image that can be sent to the backend for Identity Verification.
1172
+ *
1173
+ * @param scannedDocument Document to upload.
1174
+ * @param side The side of the document that the image captures.
1175
+ * @param data Raw image data. Make sure that the data aren't too big, hundreds of kbs should be enough.
1176
+ * @param dataSignature Signature of the image data. Optional, use only when the scan SDK supports this. `undefined` by default.
1177
+ * @returns Document file to upload.
1178
+ */
1179
+ WDODocumentFile.fromScannedDocument = function (scannedDocument, side, data, dataSignature) {
1180
+ var _a;
1181
+ var originalDocumentId = (_a = scannedDocument.sides.find(function (s) { return s.type === side; })) === null || _a === void 0 ? void 0 : _a.serverId;
1182
+ return new WDODocumentFile(data, scannedDocument.type, side, originalDocumentId, dataSignature);
1183
+ };
1184
+ return WDODocumentFile;
1185
+ }());
1186
+ /** Type of the document. */
1187
+ exports.WDODocumentType = void 0;
1188
+ (function (WDODocumentType) {
1189
+ /** National ID card */
1190
+ WDODocumentType["idCard"] = "idCard";
1191
+ /** Passport */
1192
+ WDODocumentType["passport"] = "passport";
1193
+ /** Drivers license */
1194
+ WDODocumentType["driversLicense"] = "driversLicense";
1195
+ })(exports.WDODocumentType || (exports.WDODocumentType = {}));
1196
+ /**
1197
+ * Available sides of the document
1198
+ *
1199
+ * Front and back for ID card.
1200
+ * For passport and drivers license front only.
1201
+ */
1202
+ function WDODocumentTypeSides(type) {
1203
+ switch (type) {
1204
+ case exports.WDODocumentType.idCard:
1205
+ return [exports.WDODocumentSide.front, exports.WDODocumentSide.back];
1206
+ case exports.WDODocumentType.passport:
1207
+ return [exports.WDODocumentSide.front];
1208
+ case exports.WDODocumentType.driversLicense:
1209
+ return [exports.WDODocumentSide.front];
1210
+ }
1211
+ }
1212
+ /** Side of the document */
1213
+ exports.WDODocumentSide = void 0;
1214
+ (function (WDODocumentSide) {
1215
+ /** Front side of a document. Usually the one with the picture.
1216
+ *
1217
+ * When a document has more than one side but only one side is used (for example passport), then such side is considered to be front.
1218
+ */
1219
+ WDODocumentSide["front"] = "front";
1220
+ /** Back side of a document */
1221
+ WDODocumentSide["back"] = "back";
1222
+ })(exports.WDODocumentSide || (exports.WDODocumentSide = {}));
1223
+ /** Converts WDODocumentType to WDODocumentSubmitFileType */
1224
+ function WDODocumentTypeToSubmitType(type) {
1225
+ switch (type) {
1226
+ case exports.WDODocumentType.idCard:
1227
+ return exports.WDODocumentSubmitFileType.idCard;
1228
+ case exports.WDODocumentType.passport:
1229
+ return exports.WDODocumentSubmitFileType.passport;
1230
+ case exports.WDODocumentType.driversLicense:
1231
+ return exports.WDODocumentSubmitFileType.driversLicense;
1232
+ }
1233
+ }
1234
+ /** Converts WDODocumentSide to DocumentSubmitFileSide */
1235
+ function WDOCreateDocumentSubmitFileSide(side) {
1236
+ switch (side) {
1237
+ case exports.WDODocumentSide.front:
1238
+ return exports.WDODocumentSubmitFileSide.front;
1239
+ case exports.WDODocumentSide.back:
1240
+ return exports.WDODocumentSubmitFileSide.back;
1241
+ }
1242
+ }
1243
+
1096
1244
  /**
1097
1245
  * Copyright Wultra s.r.o.
1098
1246
  *
@@ -1126,10 +1274,27 @@ var WDOVerificationScanProcess = /** @class */ (function () {
1126
1274
  }, new Map());
1127
1275
  groups.forEach(function (docs, type) {
1128
1276
  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);
1277
+ (_a = _this.documents.find(function (d) { return WDODocumentTypeToSubmitType(d.type) === type; })) === null || _a === void 0 ? void 0 : _a.processServerData(docs);
1131
1278
  });
1132
1279
  };
1280
+ /* @internal */
1281
+ WDOVerificationScanProcess.fromCachedData = function (data) {
1282
+ var split = data.split(":");
1283
+ if (split.length != 2) {
1284
+ WDOLogger.error("WDOVerificationScanProcess.fromCachedData: invalid cached data format");
1285
+ return undefined;
1286
+ }
1287
+ if (split[0] !== "v1") {
1288
+ WDOLogger.error("WDOVerificationScanProcess.fromCachedData: unsupported cached data version");
1289
+ return undefined;
1290
+ }
1291
+ var types = split[1].split(",").map(function (s) { return s; });
1292
+ return new WDOVerificationScanProcess(types);
1293
+ };
1294
+ /* @internal */
1295
+ WDOVerificationScanProcess.prototype.dataForCache = function () {
1296
+ return "v1:".concat(this.documents.map(function (d) { return d.type; }).join(","));
1297
+ };
1133
1298
  return WDOVerificationScanProcess;
1134
1299
  }());
1135
1300
  /** Document that needs to be scanned during process. */
@@ -1167,7 +1332,7 @@ var WDOScannedDocument = /** @class */ (function () {
1167
1332
  });
1168
1333
  /* @internal */
1169
1334
  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); });
1335
+ 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); });
1171
1336
  };
1172
1337
  return WDOScannedDocument;
1173
1338
  }());
@@ -1200,6 +1365,16 @@ var Side = /** @class */ (function () {
1200
1365
  *
1201
1366
  * SPDX-License-Identifier: Apache-2.0
1202
1367
  */
1368
+ /** Possible results of the user consent. */
1369
+ exports.WDOConsentResponse = void 0;
1370
+ (function (WDOConsentResponse) {
1371
+ /** User approved the consent. */
1372
+ WDOConsentResponse[WDOConsentResponse["approved"] = 0] = "approved";
1373
+ /** User declined the consent. */
1374
+ WDOConsentResponse[WDOConsentResponse["declined"] = 1] = "declined";
1375
+ /** Consent is not required. */
1376
+ WDOConsentResponse[WDOConsentResponse["notRequired"] = 2] = "notRequired";
1377
+ })(exports.WDOConsentResponse || (exports.WDOConsentResponse = {}));
1203
1378
  /**
1204
1379
  * Service that can verify previously activated PowerAuth instance.
1205
1380
  *
@@ -1212,9 +1387,39 @@ var WDOBaseVerificationService = /** @class */ (function () {
1212
1387
  function WDOBaseVerificationService() {
1213
1388
  /* @internal */
1214
1389
  this.lastStatus = undefined;
1215
- /* @internal */
1216
- this.cachedProcess = undefined; // TODO: persistence?
1217
1390
  }
1391
+ /* @internal */
1392
+ WDOBaseVerificationService.prototype.cacheKey = function () { return "wdocp_".concat(this.getPAInstanceId()); };
1393
+ /* @internal */
1394
+ WDOBaseVerificationService.prototype.setCachedProcess = function (process) {
1395
+ return __awaiter(this, void 0, void 0, function () {
1396
+ return __generator(this, function (_a) {
1397
+ switch (_a.label) {
1398
+ case 0: return [4 /*yield*/, WDODefaultCache.instance.set(this.cacheKey(), process === null || process === void 0 ? void 0 : process.dataForCache())];
1399
+ case 1:
1400
+ _a.sent();
1401
+ return [2 /*return*/];
1402
+ }
1403
+ });
1404
+ });
1405
+ };
1406
+ /* @internal */
1407
+ WDOBaseVerificationService.prototype.getCachedProcess = function () {
1408
+ return __awaiter(this, void 0, void 0, function () {
1409
+ var data;
1410
+ return __generator(this, function (_a) {
1411
+ switch (_a.label) {
1412
+ case 0: return [4 /*yield*/, WDODefaultCache.instance.get(this.cacheKey())];
1413
+ case 1:
1414
+ data = _a.sent();
1415
+ if (!data) {
1416
+ return [2 /*return*/, undefined];
1417
+ }
1418
+ return [2 /*return*/, WDOVerificationScanProcess.fromCachedData(data)];
1419
+ }
1420
+ });
1421
+ });
1422
+ };
1218
1423
  // PUBLIC API
1219
1424
  /**
1220
1425
  * Accept language for the outgoing requests headers.
@@ -1241,50 +1446,62 @@ var WDOBaseVerificationService = /** @class */ (function () {
1241
1446
  */
1242
1447
  WDOBaseVerificationService.prototype.status = function () {
1243
1448
  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) {
1449
+ var response, _a, vf, _b, docsResponse, documents, cachedProcess, error_1;
1450
+ var _c, _d;
1451
+ return __generator(this, function (_e) {
1452
+ switch (_e.label) {
1248
1453
  case 0:
1249
- _c.trys.push([0, 12, , 13]);
1454
+ _e.trys.push([0, 17, , 18]);
1250
1455
  return [4 /*yield*/, this.api.verificationStatus()];
1251
1456
  case 1:
1252
- response = _c.sent();
1457
+ response = _e.sent();
1458
+ response.consentRequired = (_c = response.consentRequired) !== null && _c !== void 0 ? _c : false; // when undefined, assume false
1253
1459
  WDOLogger.info("Verification status successfully retrieved.");
1254
1460
  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;
1461
+ _a = response.identityVerificationStatus;
1462
+ switch (_a) {
1463
+ case exports.WDOIdentityVerificationStatus.failed: return [3 /*break*/, 2];
1464
+ case exports.WDOIdentityVerificationStatus.rejected: return [3 /*break*/, 2];
1465
+ case exports.WDOIdentityVerificationStatus.notInitialized: return [3 /*break*/, 2];
1466
+ case exports.WDOIdentityVerificationStatus.accepted: return [3 /*break*/, 2];
1263
1467
  }
1468
+ return [3 /*break*/, 4];
1469
+ case 2:
1470
+ WDOLogger.debug("Status ".concat(response.identityVerificationStatus, " - clearing cache"));
1471
+ return [4 /*yield*/, this.setCachedProcess(undefined)];
1472
+ case 3:
1473
+ _e.sent();
1474
+ return [3 /*break*/, 5];
1475
+ case 4:
1476
+ // no-op
1477
+ return [3 /*break*/, 5];
1478
+ case 5:
1264
1479
  this.lastStatus = response;
1265
1480
  vf = new WDOVerificationStatus(response);
1266
1481
  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];
1482
+ _b = vf.nextStep;
1483
+ switch (_b) {
1484
+ case WDONextStep.intro: return [3 /*break*/, 6];
1485
+ case WDONextStep.documentScan: return [3 /*break*/, 7];
1486
+ case WDONextStep.presenceCheck: return [3 /*break*/, 10];
1487
+ case WDONextStep.otp: return [3 /*break*/, 11];
1488
+ case WDONextStep.statusCheck: return [3 /*break*/, 12];
1489
+ case WDONextStep.failed: return [3 /*break*/, 13];
1490
+ case WDONextStep.rejected: return [3 /*break*/, 14];
1491
+ case WDONextStep.success: return [3 /*break*/, 15];
1277
1492
  }
1278
- return [3 /*break*/, 11];
1279
- case 2: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.intro })];
1280
- case 3:
1493
+ return [3 /*break*/, 16];
1494
+ case 6: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.intro, consentRequired: response.consentRequired })];
1495
+ case 7:
1281
1496
  WDOLogger.debug("Verifying documents status");
1282
1497
  return [4 /*yield*/, this.api.verificationDocumentsStatus(response.processId)];
1283
- case 4:
1284
- docsResponse = _c.sent();
1498
+ case 8:
1499
+ docsResponse = _e.sent();
1285
1500
  WDOLogger.debug("Documents status: ".concat(JSON.stringify(docsResponse)));
1286
1501
  documents = docsResponse.documents;
1287
- cachedProcess = this.cachedProcess;
1502
+ return [4 /*yield*/, this.getCachedProcess()];
1503
+ case 9:
1504
+ cachedProcess = _e.sent();
1288
1505
  if (cachedProcess) {
1289
1506
  cachedProcess.feedServerData(docsResponse.documents);
1290
1507
  if (documents.some(function (d) { return documentAction(d) === "error"; }) || documents.some(function (d) { return d.errors != undefined && d.errors.length > 0; })) {
@@ -1315,19 +1532,19 @@ var WDOBaseVerificationService = /** @class */ (function () {
1315
1532
  return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.failed })];
1316
1533
  }
1317
1534
  }
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();
1535
+ case 10: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.presenceCheck })];
1536
+ case 11: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.otp })];
1537
+ case 12: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: (_d = vf.statusCheckReason) !== null && _d !== void 0 ? _d : exports.WDOStatusCheckReason.unknown })];
1538
+ case 13: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.failed })];
1539
+ case 14: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.endState, reason: exports.WDOEndStateReason.rejected })];
1540
+ case 15: return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.success })];
1541
+ case 16: return [3 /*break*/, 18];
1542
+ case 17:
1543
+ error_1 = _e.sent();
1327
1544
  WDOLogger.error("Error fetching verification status: ".concat(JSON.stringify(error_1)));
1328
1545
  this.lastStatus = undefined;
1329
1546
  throw this.processError(error_1);
1330
- case 13: return [2 /*return*/];
1547
+ case 18: return [2 /*return*/];
1331
1548
  }
1332
1549
  });
1333
1550
  });
@@ -1347,27 +1564,49 @@ var WDOBaseVerificationService = /** @class */ (function () {
1347
1564
  return [4 /*yield*/, this.handleError(this.api.verificationGetConsentText(pid))];
1348
1565
  case 1:
1349
1566
  response = _a.sent();
1350
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.consent, body: response.consentText })];
1567
+ return [2 /*return*/, response.consentText];
1351
1568
  }
1352
1569
  });
1353
1570
  });
1354
1571
  };
1355
1572
  /**
1356
- * Approves the consent for this process and starts the activation.
1573
+ * Start the identity verification after user approved the consent (if required)
1574
+ *
1575
+ * @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`).
1357
1576
  */
1358
- WDOBaseVerificationService.prototype.consentApprove = function () {
1577
+ WDOBaseVerificationService.prototype.start = function (consentApprovedByUser) {
1359
1578
  return __awaiter(this, void 0, void 0, function () {
1360
- var pid;
1361
- return __generator(this, function (_a) {
1362
- switch (_a.label) {
1579
+ var pid, _a;
1580
+ var _b, _c;
1581
+ return __generator(this, function (_d) {
1582
+ switch (_d.label) {
1363
1583
  case 0:
1364
1584
  pid = this.verifyHasActiveProcess();
1365
- return [4 /*yield*/, this.handleError(this.api.verificationResolveConsent(pid, true))];
1585
+ _a = consentApprovedByUser;
1586
+ switch (_a) {
1587
+ case exports.WDOConsentResponse.approved: return [3 /*break*/, 1];
1588
+ case exports.WDOConsentResponse.declined: return [3 /*break*/, 3];
1589
+ case exports.WDOConsentResponse.notRequired: return [3 /*break*/, 5];
1590
+ }
1591
+ return [3 /*break*/, 6];
1366
1592
  case 1:
1367
- _a.sent();
1368
- return [4 /*yield*/, this.handleError(this.api.verificationStart(pid))];
1593
+ WDOLogger.info("User approved consent - resolving on server");
1594
+ return [4 /*yield*/, this.handleError(this.api.verificationResolveConsent(pid, true))];
1369
1595
  case 2:
1370
- _a.sent();
1596
+ _d.sent();
1597
+ return [3 /*break*/, 6];
1598
+ case 3:
1599
+ WDOLogger.info("User declined consent - returning to intro state");
1600
+ return [4 /*yield*/, this.handleError(this.api.verificationResolveConsent(pid, false))];
1601
+ case 4:
1602
+ _d.sent();
1603
+ 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?
1604
+ case 5:
1605
+ WDOLogger.info("Consent not required - proceeding");
1606
+ _d.label = 6;
1607
+ case 6: return [4 /*yield*/, this.handleError(this.api.verificationStart(pid))];
1608
+ case 7:
1609
+ _d.sent();
1371
1610
  return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.documentsToScanSelect })];
1372
1611
  }
1373
1612
  });
@@ -1382,7 +1621,7 @@ var WDOBaseVerificationService = /** @class */ (function () {
1382
1621
  */
1383
1622
  WDOBaseVerificationService.prototype.documentsInitSDK = function (challenge) {
1384
1623
  return __awaiter(this, void 0, void 0, function () {
1385
- var pid, response;
1624
+ var pid, response, blinkID, zenId;
1386
1625
  return __generator(this, function (_a) {
1387
1626
  switch (_a.label) {
1388
1627
  case 0:
@@ -1391,7 +1630,9 @@ var WDOBaseVerificationService = /** @class */ (function () {
1391
1630
  case 1:
1392
1631
  response = _a.sent() // TODO: is "-" acceptable?
1393
1632
  ;
1394
- return [2 /*return*/, response];
1633
+ blinkID = response.attributes["license-key"];
1634
+ zenId = response.attributes["zenid-sdk-init-response"];
1635
+ return [2 /*return*/, { blinkIDKey: blinkID, zenIDToken: zenId }];
1395
1636
  }
1396
1637
  });
1397
1638
  });
@@ -1406,49 +1647,20 @@ var WDOBaseVerificationService = /** @class */ (function () {
1406
1647
  WDOBaseVerificationService.prototype.documentsSetSelectedTypes = function (types) {
1407
1648
  return __awaiter(this, void 0, void 0, function () {
1408
1649
  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
- });
1416
- };
1417
- /**
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.
1422
- *
1423
- * @param files Document files to upload.
1424
- */
1425
- WDOBaseVerificationService.prototype.documentsSubmit = function (files) {
1426
- return __awaiter(this, void 0, void 0, function () {
1427
- var pid, resubmit, submitFiles;
1428
1650
  return __generator(this, function (_a) {
1429
1651
  switch (_a.label) {
1430
1652
  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))];
1653
+ WDOLogger.debug("Submitting selected document types: ".concat(types));
1654
+ process = new WDOVerificationScanProcess(types);
1655
+ return [4 /*yield*/, this.setCachedProcess(process)];
1443
1656
  case 1:
1444
1657
  _a.sent();
1445
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.documentUpload })];
1658
+ return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.scanDocument, process: process })];
1446
1659
  }
1447
1660
  });
1448
1661
  });
1449
1662
  };
1450
1663
  /**
1451
- * @internal
1452
1664
  * Upload document files to the server. The order of the documents is up to you.
1453
1665
  * Make sure that uploaded document are reasonable size so you're not uploading large files.
1454
1666
  *
@@ -1456,7 +1668,7 @@ var WDOBaseVerificationService = /** @class */ (function () {
1456
1668
  *
1457
1669
  * @param files Document files to upload.
1458
1670
  */
1459
- WDOBaseVerificationService.prototype.documentsSubmitDemo = function (files, zipFolderNameDemo, base64zipDemo) {
1671
+ WDOBaseVerificationService.prototype.documentsSubmit = function (files) {
1460
1672
  return __awaiter(this, void 0, void 0, function () {
1461
1673
  var pid, resubmit, submitFiles;
1462
1674
  return __generator(this, function (_a) {
@@ -1466,13 +1678,14 @@ var WDOBaseVerificationService = /** @class */ (function () {
1466
1678
  resubmit = files.some(function (f) { return f.originalDocumentId != undefined; });
1467
1679
  submitFiles = files.map(function (f) {
1468
1680
  return {
1469
- filename: "".concat(zipFolderNameDemo, "/").concat(f.type.toLowerCase(), "_").concat(f.side.toLowerCase(), ".jpg"),
1470
- type: WDOCreateDocumentSubmitFileType(f.type),
1681
+ filename: "".concat(f.type.toLowerCase(), "_").concat(f.side.toLowerCase(), ".jpg"),
1682
+ type: WDODocumentTypeToSubmitType(f.type),
1471
1683
  side: WDOCreateDocumentSubmitFileSide(f.side),
1472
- originalDocumentId: f.originalDocumentId
1684
+ originalDocumentId: f.originalDocumentId,
1685
+ data: f.data
1473
1686
  };
1474
1687
  });
1475
- return [4 /*yield*/, this.handleError(this.api.verificationSubmitDocuments(pid, base64zipDemo, resubmit, submitFiles))];
1688
+ return [4 /*yield*/, this.handleError(this.api.verificationSubmitDocuments(pid, resubmit, submitFiles))];
1476
1689
  case 1:
1477
1690
  _a.sent();
1478
1691
  return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.processing, item: exports.WDOStatusCheckReason.documentUpload })];
@@ -1529,9 +1742,14 @@ var WDOBaseVerificationService = /** @class */ (function () {
1529
1742
  return [4 /*yield*/, this.handleError(this.api.verificationCleanup(pid))];
1530
1743
  case 1:
1531
1744
  _a.sent();
1532
- this.cachedProcess = undefined;
1745
+ return [4 /*yield*/, this.setCachedProcess(undefined)];
1746
+ case 2:
1747
+ _a.sent();
1533
1748
  WDOLogger.info("Verification process restarted.");
1534
- return [2 /*return*/, this.processSuccess({ type: exports.WDOVerificationStateType.intro })];
1749
+ return [4 /*yield*/, this.status()];
1750
+ case 3:
1751
+ // return new status
1752
+ return [2 /*return*/, _a.sent()];
1535
1753
  }
1536
1754
  });
1537
1755
  });
@@ -1550,7 +1768,9 @@ var WDOBaseVerificationService = /** @class */ (function () {
1550
1768
  return [4 /*yield*/, this.handleError(this.api.verificationCleanup(pid))];
1551
1769
  case 1:
1552
1770
  _a.sent();
1553
- this.cachedProcess = undefined;
1771
+ return [4 /*yield*/, this.setCachedProcess(undefined)];
1772
+ case 2:
1773
+ _a.sent();
1554
1774
  WDOLogger.info("Verification process canceled.");
1555
1775
  return [2 /*return*/];
1556
1776
  }
@@ -1583,7 +1803,7 @@ var WDOBaseVerificationService = /** @class */ (function () {
1583
1803
  }
1584
1804
  else {
1585
1805
  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"));
1806
+ throw this.processError(new WDOError(exports.WDOErrorReason.otpFailed, "OTP verification failed, no remaining attempts or OTP expired"));
1587
1807
  }
1588
1808
  }
1589
1809
  }
@@ -1637,7 +1857,7 @@ var WDOBaseVerificationService = /** @class */ (function () {
1637
1857
  var pid = (_a = this.lastStatus) === null || _a === void 0 ? void 0 : _a.processId;
1638
1858
  if (!pid) {
1639
1859
  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?");
1860
+ throw new WDOError(exports.WDOErrorReason.processNotInProgress, "Process id not available - did you start the verification process and fetched the status?");
1641
1861
  }
1642
1862
  return pid;
1643
1863
  };
@@ -1674,7 +1894,7 @@ var WDOBaseVerificationService = /** @class */ (function () {
1674
1894
  if (status_1.state !== WDOPowerAuthActivationState.ACTIVE) {
1675
1895
  WDOLogger.error("PowerAuth status is not active (status".concat(status_1.state, ") - notifying the delegate and returning and error."));
1676
1896
  (_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")];
1897
+ return [2 /*return*/, new WDOError(exports.WDOErrorReason.powerauthNotActivated, "PowerAuth activation is not active anymore")];
1678
1898
  }
1679
1899
  return [3 /*break*/, 4];
1680
1900
  case 3:
@@ -1702,123 +1922,123 @@ var WDOVerificationStatus = /** @class */ (function () {
1702
1922
  // UNDEFINED PHASE
1703
1923
  if (phase == undefined) {
1704
1924
  switch (status) {
1705
- case WDOIdentityVerificationStatus.notInitialized:
1925
+ case exports.WDOIdentityVerificationStatus.notInitialized:
1706
1926
  nextStep = WDONextStep.intro;
1707
1927
  break;
1708
- case WDOIdentityVerificationStatus.failed:
1928
+ case exports.WDOIdentityVerificationStatus.failed:
1709
1929
  nextStep = WDONextStep.failed;
1710
1930
  break;
1711
1931
  }
1712
1932
  }
1713
1933
  // DOCUMENT UPLOAD PHASE
1714
- else if (phase === WDOIdentityVerificationPhase.documentUpload) {
1934
+ else if (phase === exports.WDOIdentityVerificationPhase.documentUpload) {
1715
1935
  switch (status) {
1716
- case WDOIdentityVerificationStatus.inProgress:
1936
+ case exports.WDOIdentityVerificationStatus.inProgress:
1717
1937
  nextStep = WDONextStep.documentScan;
1718
1938
  break;
1719
- case WDOIdentityVerificationStatus.verificationPending:
1939
+ case exports.WDOIdentityVerificationStatus.verificationPending:
1720
1940
  nextStep = WDONextStep.statusCheck;
1721
1941
  statusCheckReason = exports.WDOStatusCheckReason.documentVerification;
1722
1942
  break;
1723
- case WDOIdentityVerificationStatus.failed:
1943
+ case exports.WDOIdentityVerificationStatus.failed:
1724
1944
  nextStep = WDONextStep.failed;
1725
1945
  break;
1726
1946
  }
1727
1947
  }
1728
1948
  // DOCUMENT VERIFICATION PHASE
1729
- else if (phase === WDOIdentityVerificationPhase.documentVerification) {
1949
+ else if (phase === exports.WDOIdentityVerificationPhase.documentVerification) {
1730
1950
  switch (status) {
1731
- case WDOIdentityVerificationStatus.accepted:
1951
+ case exports.WDOIdentityVerificationStatus.accepted:
1732
1952
  nextStep = WDONextStep.statusCheck;
1733
1953
  statusCheckReason = exports.WDOStatusCheckReason.documentAccepted;
1734
1954
  break;
1735
- case WDOIdentityVerificationStatus.inProgress:
1955
+ case exports.WDOIdentityVerificationStatus.inProgress:
1736
1956
  nextStep = WDONextStep.statusCheck;
1737
1957
  statusCheckReason = exports.WDOStatusCheckReason.documentVerification;
1738
1958
  break;
1739
- case WDOIdentityVerificationStatus.failed:
1959
+ case exports.WDOIdentityVerificationStatus.failed:
1740
1960
  nextStep = WDONextStep.failed;
1741
1961
  break;
1742
- case WDOIdentityVerificationStatus.rejected:
1962
+ case exports.WDOIdentityVerificationStatus.rejected:
1743
1963
  nextStep = WDONextStep.rejected;
1744
1964
  break;
1745
1965
  }
1746
1966
  }
1747
1967
  // DOCUMENT VERIFICATION FINAL PHASE
1748
- else if (phase === WDOIdentityVerificationPhase.documentVerificationFinal) {
1968
+ else if (phase === exports.WDOIdentityVerificationPhase.documentVerificationFinal) {
1749
1969
  switch (status) {
1750
- case WDOIdentityVerificationStatus.accepted:
1970
+ case exports.WDOIdentityVerificationStatus.accepted:
1751
1971
  nextStep = WDONextStep.statusCheck;
1752
1972
  statusCheckReason = exports.WDOStatusCheckReason.documentsCrossVerification;
1753
1973
  break;
1754
- case WDOIdentityVerificationStatus.inProgress:
1974
+ case exports.WDOIdentityVerificationStatus.inProgress:
1755
1975
  nextStep = WDONextStep.statusCheck;
1756
1976
  statusCheckReason = exports.WDOStatusCheckReason.documentsCrossVerification;
1757
1977
  break;
1758
- case WDOIdentityVerificationStatus.failed:
1978
+ case exports.WDOIdentityVerificationStatus.failed:
1759
1979
  nextStep = WDONextStep.failed;
1760
1980
  break;
1761
- case WDOIdentityVerificationStatus.rejected:
1981
+ case exports.WDOIdentityVerificationStatus.rejected:
1762
1982
  nextStep = WDONextStep.rejected;
1763
1983
  break;
1764
1984
  }
1765
1985
  }
1766
1986
  // CLIENT EVALUATION PHASE
1767
- else if (phase === WDOIdentityVerificationPhase.clientEvaluation) {
1987
+ else if (phase === exports.WDOIdentityVerificationPhase.clientEvaluation) {
1768
1988
  switch (status) {
1769
- case WDOIdentityVerificationStatus.inProgress:
1989
+ case exports.WDOIdentityVerificationStatus.inProgress:
1770
1990
  nextStep = WDONextStep.statusCheck;
1771
1991
  statusCheckReason = exports.WDOStatusCheckReason.clientVerification;
1772
1992
  break;
1773
- case WDOIdentityVerificationStatus.accepted:
1993
+ case exports.WDOIdentityVerificationStatus.accepted:
1774
1994
  nextStep = WDONextStep.statusCheck;
1775
1995
  statusCheckReason = exports.WDOStatusCheckReason.clientAccepted;
1776
1996
  break;
1777
- case WDOIdentityVerificationStatus.rejected:
1997
+ case exports.WDOIdentityVerificationStatus.rejected:
1778
1998
  nextStep = WDONextStep.rejected;
1779
1999
  break;
1780
- case WDOIdentityVerificationStatus.failed:
2000
+ case exports.WDOIdentityVerificationStatus.failed:
1781
2001
  nextStep = WDONextStep.failed;
1782
2002
  break;
1783
2003
  }
1784
2004
  }
1785
2005
  // PRESENCE CHECK PHASE
1786
- else if (phase === WDOIdentityVerificationPhase.presenceCheck) {
2006
+ else if (phase === exports.WDOIdentityVerificationPhase.presenceCheck) {
1787
2007
  switch (status) {
1788
- case WDOIdentityVerificationStatus.notInitialized:
1789
- case WDOIdentityVerificationStatus.inProgress:
2008
+ case exports.WDOIdentityVerificationStatus.notInitialized:
2009
+ case exports.WDOIdentityVerificationStatus.inProgress:
1790
2010
  nextStep = WDONextStep.presenceCheck;
1791
2011
  break;
1792
- case WDOIdentityVerificationStatus.verificationPending:
2012
+ case exports.WDOIdentityVerificationStatus.verificationPending:
1793
2013
  nextStep = WDONextStep.statusCheck;
1794
2014
  statusCheckReason = exports.WDOStatusCheckReason.verifyingPresence;
1795
2015
  break;
1796
- case WDOIdentityVerificationStatus.failed:
2016
+ case exports.WDOIdentityVerificationStatus.failed:
1797
2017
  nextStep = WDONextStep.failed;
1798
2018
  break;
1799
- case WDOIdentityVerificationStatus.rejected:
2019
+ case exports.WDOIdentityVerificationStatus.rejected:
1800
2020
  nextStep = WDONextStep.rejected;
1801
2021
  break;
1802
2022
  }
1803
2023
  }
1804
2024
  // OTP PHASE
1805
- else if (phase === WDOIdentityVerificationPhase.otp) {
2025
+ else if (phase === exports.WDOIdentityVerificationPhase.otp) {
1806
2026
  switch (status) {
1807
- case WDOIdentityVerificationStatus.verificationPending:
2027
+ case exports.WDOIdentityVerificationStatus.verificationPending:
1808
2028
  nextStep = WDONextStep.otp;
1809
2029
  break;
1810
2030
  }
1811
2031
  }
1812
2032
  // COMPLETED PHASE
1813
- else if (phase === WDOIdentityVerificationPhase.completed) {
2033
+ else if (phase === exports.WDOIdentityVerificationPhase.completed) {
1814
2034
  switch (status) {
1815
- case WDOIdentityVerificationStatus.accepted:
2035
+ case exports.WDOIdentityVerificationStatus.accepted:
1816
2036
  nextStep = WDONextStep.success;
1817
2037
  break;
1818
- case WDOIdentityVerificationStatus.failed:
2038
+ case exports.WDOIdentityVerificationStatus.failed:
1819
2039
  nextStep = WDONextStep.failed;
1820
2040
  break;
1821
- case WDOIdentityVerificationStatus.rejected:
2041
+ case exports.WDOIdentityVerificationStatus.rejected:
1822
2042
  nextStep = WDONextStep.rejected;
1823
2043
  break;
1824
2044
  }
@@ -1853,15 +2073,15 @@ var WDONextStep;
1853
2073
  })(WDONextStep || (WDONextStep = {}));
1854
2074
  function documentAction(document) {
1855
2075
  switch (document.status) {
1856
- case WDODocumentStatus.accepted:
2076
+ case exports.WDODocumentStatus.accepted:
1857
2077
  return "proceed";
1858
- case WDODocumentStatus.uploadInProgress:
1859
- case WDODocumentStatus.inProgress:
1860
- case WDODocumentStatus.verificationPending:
1861
- case WDODocumentStatus.verificationInProgress:
2078
+ case exports.WDODocumentStatus.uploadInProgress:
2079
+ case exports.WDODocumentStatus.inProgress:
2080
+ case exports.WDODocumentStatus.verificationPending:
2081
+ case exports.WDODocumentStatus.verificationInProgress:
1862
2082
  return "wait";
1863
- case WDODocumentStatus.rejected:
1864
- case WDODocumentStatus.failed:
2083
+ case exports.WDODocumentStatus.rejected:
2084
+ case exports.WDODocumentStatus.failed:
1865
2085
  return "error";
1866
2086
  }
1867
2087
  WDOLogger.debug("Unknown document status: ".concat(document.status, " for document ID: ").concat(document.id));
@@ -1928,6 +2148,10 @@ var WDOVerificationService = /** @class */ (function (_super) {
1928
2148
  WDOVerificationService.prototype.changeAcceptLanguageImpl = function (language) {
1929
2149
  this.api.networking.acceptLanguage = language;
1930
2150
  };
2151
+ /* @internal */
2152
+ WDOVerificationService.prototype.getPAInstanceId = function () {
2153
+ return this.powerauth.instanceId;
2154
+ };
1931
2155
  return WDOVerificationService;
1932
2156
  }(WDOBaseVerificationService));
1933
2157
 
@@ -1989,11 +2213,53 @@ var WDOConfigurationService = /** @class */ (function (_super) {
1989
2213
  return WDOConfigurationService;
1990
2214
  }(WDOBaseConfigurationService));
1991
2215
 
2216
+ /**
2217
+ * Copyright Wultra s.r.o.
2218
+ *
2219
+ * This source code is licensed under the Apache License, Version 2.0 license
2220
+ * found in the LICENSE file in the root directory of this source tree.
2221
+ *
2222
+ * SPDX-License-Identifier: Apache-2.0
2223
+ */
2224
+
2225
+ var WDOCordovaCache = /** @class */ (function () {
2226
+ function WDOCordovaCache() {
2227
+ }
2228
+ WDOCordovaCache.prototype.set = function (key, value) {
2229
+ if (value) {
2230
+ return PowerAuthStorageUtils.setString(key, value, PowerAuthStorageType.SECURE);
2231
+ }
2232
+ else {
2233
+ return PowerAuthStorageUtils.remove(key, PowerAuthStorageType.SECURE).then(function () { });
2234
+ }
2235
+ };
2236
+ WDOCordovaCache.prototype.get = function (key) {
2237
+ return PowerAuthStorageUtils.getString(key, PowerAuthStorageType.SECURE);
2238
+ };
2239
+ WDOCordovaCache.prototype.has = function (key) {
2240
+ return PowerAuthStorageUtils.exists(key, PowerAuthStorageType.SECURE);
2241
+ };
2242
+ return WDOCordovaCache;
2243
+ }());
2244
+
2245
+ /**
2246
+ * Copyright Wultra s.r.o.
2247
+ *
2248
+ * This source code is licensed under the Apache License, Version 2.0 license
2249
+ * found in the LICENSE file in the root directory of this source tree.
2250
+ *
2251
+ * SPDX-License-Identifier: Apache-2.0
2252
+ */
2253
+ WDODefaultCache.instance = new WDOCordovaCache();
2254
+
1992
2255
  exports.Side = Side;
1993
2256
  exports.WDOActivationService = WDOActivationService;
1994
2257
  exports.WDOConfigurationService = WDOConfigurationService;
2258
+ exports.WDOCreateDocumentSubmitFileSide = WDOCreateDocumentSubmitFileSide;
1995
2259
  exports.WDODocumentFile = WDODocumentFile;
1996
2260
  exports.WDODocumentTypeSides = WDODocumentTypeSides;
2261
+ exports.WDODocumentTypeToSubmitType = WDODocumentTypeToSubmitType;
2262
+ exports.WDOError = WDOError;
1997
2263
  exports.WDOLogger = WDOLogger;
1998
2264
  exports.WDOScannedDocument = WDOScannedDocument;
1999
2265
  exports.WDOVerificationScanProcess = WDOVerificationScanProcess;