cidaas-javascript-sdk 3.0.5 → 3.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.
@@ -873,14 +873,14 @@ export declare class WebAuth {
873
873
  authenticateIVR(options: any): void;
874
874
  /**
875
875
  * @deprecated
876
- * authenticate backupcode - v1
876
+ * authenticate totp - v1
877
877
  * @param options
878
878
  */
879
- authenticateBackupcode(options: any): void;
879
+ authenticateTOTP(options: any): void;
880
880
  /**
881
881
  * @deprecated
882
- * authenticate totp - v1
882
+ * authenticate backupcode - v1
883
883
  * @param options
884
884
  */
885
- authenticateTOTP(options: any): void;
885
+ authenticateBackupcode(options: any): void;
886
886
  }
@@ -39,7 +39,6 @@ exports.__esModule = true;
39
39
  exports.WebAuth = void 0;
40
40
  var oidc_client_ts_1 = require("oidc-client-ts");
41
41
  var CryptoJS = require("crypto-js");
42
- var fingerprintjs_1 = require("@fingerprintjs/fingerprintjs");
43
42
  var authentication_1 = require("../authentication");
44
43
  var Helper_1 = require("./Helper");
45
44
  var LoginService_1 = require("./LoginService");
@@ -328,31 +327,8 @@ var WebAuth = /** @class */ (function () {
328
327
  * @returns
329
328
  */
330
329
  WebAuth.prototype.getMissingFields = function (options) {
331
- return new Promise(function (resolve, reject) {
332
- try {
333
- var http = new XMLHttpRequest();
334
- var _serviceURL = window.webAuthSettings.authority + "/public-srv/public/trackinfo/" + options.requestId + "/" + options.trackId;
335
- http.onreadystatechange = function () {
336
- if (http.readyState == 4) {
337
- if (http.responseText) {
338
- resolve(JSON.parse(http.responseText));
339
- }
340
- else {
341
- resolve(false);
342
- }
343
- }
344
- };
345
- http.open("GET", _serviceURL, true);
346
- http.setRequestHeader("Content-type", "application/json");
347
- if (window.localeSettings) {
348
- http.setRequestHeader("accept-language", window.localeSettings);
349
- }
350
- http.send();
351
- }
352
- catch (ex) {
353
- reject(ex);
354
- }
355
- });
330
+ var _serviceURL = window.webAuthSettings.authority + "/public-srv/public/trackinfo/" + options.requestId + "/" + options.trackId;
331
+ return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
356
332
  };
357
333
  ;
358
334
  /**
@@ -360,31 +336,8 @@ var WebAuth = /** @class */ (function () {
360
336
  * @returns
361
337
  */
362
338
  WebAuth.prototype.getTenantInfo = function () {
363
- return new Promise(function (resolve, reject) {
364
- try {
365
- var http = new XMLHttpRequest();
366
- var _serviceURL = window.webAuthSettings.authority + "/public-srv/tenantinfo/basic";
367
- http.onreadystatechange = function () {
368
- if (http.readyState == 4) {
369
- if (http.responseText) {
370
- resolve(JSON.parse(http.responseText));
371
- }
372
- else {
373
- resolve(false);
374
- }
375
- }
376
- };
377
- http.open("GET", _serviceURL, true);
378
- http.setRequestHeader("Content-type", "application/json");
379
- if (window.localeSettings) {
380
- http.setRequestHeader("accept-language", window.localeSettings);
381
- }
382
- http.send();
383
- }
384
- catch (ex) {
385
- reject(ex);
386
- }
387
- });
339
+ var _serviceURL = window.webAuthSettings.authority + "/public-srv/tenantinfo/basic";
340
+ return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
388
341
  };
389
342
  ;
390
343
  /**
@@ -406,31 +359,8 @@ var WebAuth = /** @class */ (function () {
406
359
  * @returns
407
360
  */
408
361
  WebAuth.prototype.getClientInfo = function (options) {
409
- return new Promise(function (resolve, reject) {
410
- try {
411
- var http = new XMLHttpRequest();
412
- var _serviceURL = window.webAuthSettings.authority + "/public-srv/public/" + options.requestId;
413
- http.onreadystatechange = function () {
414
- if (http.readyState == 4) {
415
- if (http.responseText) {
416
- resolve(JSON.parse(http.responseText));
417
- }
418
- else {
419
- resolve(false);
420
- }
421
- }
422
- };
423
- http.open("GET", _serviceURL, true);
424
- http.setRequestHeader("Content-type", "application/json");
425
- if (window.localeSettings) {
426
- http.setRequestHeader("accept-language", window.localeSettings);
427
- }
428
- http.send();
429
- }
430
- catch (ex) {
431
- reject(ex);
432
- }
433
- });
362
+ var _serviceURL = window.webAuthSettings.authority + "/public-srv/public/" + options.requestId;
363
+ return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
434
364
  };
435
365
  ;
436
366
  /**
@@ -439,35 +369,12 @@ var WebAuth = /** @class */ (function () {
439
369
  * @returns
440
370
  */
441
371
  WebAuth.prototype.getDevicesInfo = function (options) {
442
- return new Promise(function (resolve, reject) {
443
- try {
444
- var http = new XMLHttpRequest();
445
- var _serviceURL = window.webAuthSettings.authority + "/device-srv/devices";
446
- options.userAgent = window.navigator.userAgent;
447
- http.onreadystatechange = function () {
448
- if (http.readyState == 4) {
449
- if (http.responseText) {
450
- resolve(JSON.parse(http.responseText));
451
- }
452
- else {
453
- resolve(false);
454
- }
455
- }
456
- };
457
- http.open("GET", _serviceURL, true);
458
- http.setRequestHeader("Content-type", "application/json");
459
- if (window.localeSettings) {
460
- http.setRequestHeader("accept-language", window.localeSettings);
461
- }
462
- if (window.navigator.userAgent) {
463
- http.send(JSON.stringify(options));
464
- }
465
- http.send();
466
- }
467
- catch (ex) {
468
- reject(ex);
469
- }
470
- });
372
+ options.userAgent = window.navigator.userAgent;
373
+ var _serviceURL = window.webAuthSettings.authority + "/device-srv/devices";
374
+ if (window.navigator.userAgent) {
375
+ return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "GET");
376
+ }
377
+ return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
471
378
  };
472
379
  ;
473
380
  /**
@@ -476,35 +383,12 @@ var WebAuth = /** @class */ (function () {
476
383
  * @returns
477
384
  */
478
385
  WebAuth.prototype.deleteDevice = function (options) {
479
- return new Promise(function (resolve, reject) {
480
- try {
481
- var http = new XMLHttpRequest();
482
- var _serviceURL = window.webAuthSettings.authority + "/device-srv/device/" + options.device_id;
483
- options.userAgent = window.navigator.userAgent;
484
- http.onreadystatechange = function () {
485
- if (http.readyState == 4) {
486
- if (http.responseText) {
487
- resolve(JSON.parse(http.responseText));
488
- }
489
- else {
490
- resolve(false);
491
- }
492
- }
493
- };
494
- http.open("DELETE", _serviceURL, true);
495
- http.setRequestHeader("Content-type", "application/json");
496
- if (window.localeSettings) {
497
- http.setRequestHeader("accept-language", window.localeSettings);
498
- }
499
- if (window.navigator.userAgent) {
500
- http.send(JSON.stringify(options));
501
- }
502
- http.send();
503
- }
504
- catch (ex) {
505
- reject(ex);
506
- }
507
- });
386
+ var _serviceURL = window.webAuthSettings.authority + "/device-srv/device/" + options.device_id;
387
+ options.userAgent = window.navigator.userAgent;
388
+ if (window.navigator.userAgent) {
389
+ return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "DELETE");
390
+ }
391
+ return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "DELETE");
508
392
  };
509
393
  ;
510
394
  /**
@@ -551,32 +435,8 @@ var WebAuth = /** @class */ (function () {
551
435
  * @returns
552
436
  */
553
437
  WebAuth.prototype.getUnreviewedDevices = function (access_token, sub) {
554
- return new Promise(function (resolve, reject) {
555
- try {
556
- var http = new XMLHttpRequest();
557
- var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/unreviewlist/" + sub;
558
- http.onreadystatechange = function () {
559
- if (http.readyState == 4) {
560
- if (http.responseText) {
561
- resolve(JSON.parse(http.responseText));
562
- }
563
- else {
564
- resolve(false);
565
- }
566
- }
567
- };
568
- http.open("GET", _serviceURL, true);
569
- http.setRequestHeader("Content-type", "application/json");
570
- http.setRequestHeader("Authorization", "Bearer ".concat(access_token));
571
- if (window.localeSettings) {
572
- http.setRequestHeader("accept-language", window.localeSettings);
573
- }
574
- http.send();
575
- }
576
- catch (ex) {
577
- throw new Helper_1.CustomException(ex, 417);
578
- }
579
- });
438
+ var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/unreviewlist/" + sub;
439
+ return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET", access_token);
580
440
  };
581
441
  ;
582
442
  /**
@@ -586,32 +446,8 @@ var WebAuth = /** @class */ (function () {
586
446
  * @returns
587
447
  */
588
448
  WebAuth.prototype.getReviewedDevices = function (access_token, sub) {
589
- return new Promise(function (resolve, reject) {
590
- try {
591
- var http = new XMLHttpRequest();
592
- var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/reviewlist/" + sub;
593
- http.onreadystatechange = function () {
594
- if (http.readyState == 4) {
595
- if (http.responseText) {
596
- resolve(JSON.parse(http.responseText));
597
- }
598
- else {
599
- resolve(false);
600
- }
601
- }
602
- };
603
- http.open("GET", _serviceURL, true);
604
- http.setRequestHeader("Content-type", "application/json");
605
- http.setRequestHeader("Authorization", "Bearer ".concat(access_token));
606
- if (window.localeSettings) {
607
- http.setRequestHeader("accept-language", window.localeSettings);
608
- }
609
- http.send();
610
- }
611
- catch (ex) {
612
- throw new Helper_1.CustomException(ex, 417);
613
- }
614
- });
449
+ var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/reviewlist/" + sub;
450
+ return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET", access_token);
615
451
  };
616
452
  ;
617
453
  /**
@@ -621,32 +457,8 @@ var WebAuth = /** @class */ (function () {
621
457
  * @returns
622
458
  */
623
459
  WebAuth.prototype.reviewDevice = function (options, access_token) {
624
- return new Promise(function (resolve, reject) {
625
- try {
626
- var http = new XMLHttpRequest();
627
- var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/updatereview";
628
- http.onreadystatechange = function () {
629
- if (http.readyState == 4) {
630
- if (http.responseText) {
631
- resolve(JSON.parse(http.responseText));
632
- }
633
- else {
634
- resolve(false);
635
- }
636
- }
637
- };
638
- http.open("PUT", _serviceURL, true);
639
- http.setRequestHeader("Content-type", "application/json");
640
- http.setRequestHeader("Authorization", "Bearer ".concat(access_token));
641
- if (window.localeSettings) {
642
- http.setRequestHeader("accept-language", window.localeSettings);
643
- }
644
- http.send(JSON.stringify(options));
645
- }
646
- catch (ex) {
647
- throw new Helper_1.CustomException(ex, 417);
648
- }
649
- });
460
+ var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/updatereview";
461
+ return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "PUT", access_token);
650
462
  };
651
463
  ;
652
464
  /**
@@ -658,36 +470,26 @@ var WebAuth = /** @class */ (function () {
658
470
  return new Promise(function (resolve, reject) {
659
471
  try {
660
472
  var value = ('; ' + document.cookie).split("; cidaas_dr=").pop().split(';')[0];
661
- var fpPromise = fingerprintjs_1["default"].load();
662
- var options = { fingerprint: "", userAgent: "" };
473
+ var options = { userAgent: "" };
663
474
  if (!value) {
664
475
  (function () { return __awaiter(_this, void 0, void 0, function () {
665
- var fp, result, http, _serviceURL;
476
+ var http, _serviceURL;
666
477
  return __generator(this, function (_a) {
667
- switch (_a.label) {
668
- case 0: return [4 /*yield*/, fpPromise];
669
- case 1:
670
- fp = _a.sent();
671
- return [4 /*yield*/, fp.get()];
672
- case 2:
673
- result = _a.sent();
674
- options.fingerprint = result.visitorId;
675
- options.userAgent = window.navigator.userAgent;
676
- http = new XMLHttpRequest();
677
- _serviceURL = window.webAuthSettings.authority + "/device-srv/deviceinfo";
678
- http.onreadystatechange = function () {
679
- if (http.readyState == 4) {
680
- resolve(JSON.parse(http.responseText));
681
- }
682
- };
683
- http.open("POST", _serviceURL, true);
684
- http.setRequestHeader("Content-type", "application/json");
685
- if (window.localeSettings) {
686
- http.setRequestHeader("accept-language", window.localeSettings);
687
- }
688
- http.send(JSON.stringify(options));
689
- return [2 /*return*/];
478
+ options.userAgent = window.navigator.userAgent;
479
+ http = new XMLHttpRequest();
480
+ _serviceURL = window.webAuthSettings.authority + "/device-srv/deviceinfo";
481
+ http.onreadystatechange = function () {
482
+ if (http.readyState == 4) {
483
+ resolve(JSON.parse(http.responseText));
484
+ }
485
+ };
486
+ http.open("POST", _serviceURL, true);
487
+ http.setRequestHeader("Content-type", "application/json");
488
+ if (window.localeSettings) {
489
+ http.setRequestHeader("accept-language", window.localeSettings);
690
490
  }
491
+ http.send(JSON.stringify(options));
492
+ return [2 /*return*/];
691
493
  });
692
494
  }); })();
693
495
  }
@@ -1050,7 +852,7 @@ var WebAuth = /** @class */ (function () {
1050
852
  */
1051
853
  WebAuth.prototype.getUserActivities = function (options, access_token) {
1052
854
  var _serviceURL = window.webAuthSettings.authority + "/useractivity-srv/latestactivity";
1053
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, access_token);
855
+ return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST", access_token);
1054
856
  };
1055
857
  ;
1056
858
  /**
@@ -1109,7 +911,7 @@ var WebAuth = /** @class */ (function () {
1109
911
  */
1110
912
  WebAuth.prototype.updateProfileImage = function (options, access_token) {
1111
913
  var _serviceURL = window.webAuthSettings.authority + "/image-srv/profile/upload";
1112
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, access_token);
914
+ return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST", access_token);
1113
915
  };
1114
916
  ;
1115
917
  /**
@@ -1731,21 +1533,21 @@ var WebAuth = /** @class */ (function () {
1731
1533
  ;
1732
1534
  /**
1733
1535
  * @deprecated
1734
- * authenticate backupcode - v1
1536
+ * authenticate totp - v1
1735
1537
  * @param options
1736
1538
  */
1737
- WebAuth.prototype.authenticateBackupcode = function (options) {
1738
- var verificationType = "BACKUPCODE";
1539
+ WebAuth.prototype.authenticateTOTP = function (options) {
1540
+ var verificationType = "TOTP";
1739
1541
  this.authenticateMfaV1(options, verificationType);
1740
1542
  };
1741
1543
  ;
1742
1544
  /**
1743
1545
  * @deprecated
1744
- * authenticate totp - v1
1546
+ * authenticate backupcode - v1
1745
1547
  * @param options
1746
1548
  */
1747
- WebAuth.prototype.authenticateTOTP = function (options) {
1748
- var verificationType = "TOTP";
1549
+ WebAuth.prototype.authenticateBackupcode = function (options) {
1550
+ var verificationType = "BACKUPCODE";
1749
1551
  this.authenticateMfaV1(options, verificationType);
1750
1552
  };
1751
1553
  ;