oro-sdk-apis 5.17.0 → 6.0.1

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.
@@ -644,6 +644,9 @@ var ApisPracticeManager = /*#__PURE__*/function () {
644
644
  this.getAuthTokenCbk = getAuthTokenCbk;
645
645
  this.useLocalStorage = useLocalStorage;
646
646
  this.practiceInstances = new Map();
647
+ // The refreshInstance will be a single instance that is used to refresh the tokens of others this way it will not interfere with requests made by other services
648
+ var newPracticeInstance = init(this.serviceCollReq, undefined, this.useLocalStorage);
649
+ this.practiceInstances.set('refreshInstance', newPracticeInstance);
647
650
  }
648
651
  /**
649
652
  * This function is used to get a `ServiceCollection` associated to a practice. If missing, it will initialize a new `ServiceCollection`.
@@ -654,64 +657,76 @@ var ApisPracticeManager = /*#__PURE__*/function () {
654
657
  _proto.get =
655
658
  /*#__PURE__*/
656
659
  function () {
657
- var _get = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(practiceUuid) {
660
+ var _get = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(practiceUuid) {
658
661
  var _this = this;
659
- var cacheKey, practiceInstance, newPracticeInstance, authTokenFunc;
660
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
661
- while (1) switch (_context2.prev = _context2.next) {
662
+ var cacheKey, practiceInstance, newPracticeInstance;
663
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
664
+ while (1) switch (_context.prev = _context.next) {
662
665
  case 0:
663
666
  cacheKey = practiceUuid != null ? practiceUuid : 'none';
664
667
  practiceInstance = this.practiceInstances.get(cacheKey);
665
668
  if (!practiceInstance) {
666
- _context2.next = 4;
669
+ _context.next = 4;
667
670
  break;
668
671
  }
669
- return _context2.abrupt("return", practiceInstance);
672
+ return _context.abrupt("return", practiceInstance);
670
673
  case 4:
671
- newPracticeInstance = init(this.serviceCollReq, undefined, this.useLocalStorage); // Create one auth token callback per practice since the practice uuid needs to change
672
- authTokenFunc = /*#__PURE__*/function () {
673
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
674
- return _regeneratorRuntime().wrap(function _callee$(_context) {
675
- while (1) switch (_context.prev = _context.next) {
676
- case 0:
677
- if (!newPracticeInstance.guardService) {
678
- _context.next = 7;
679
- break;
680
- }
681
- console.log("\x1B[36m[Auth] Refresh auth called (practiceUuid: " + practiceUuid + ")\x1B[36m");
682
- _context.next = 4;
683
- return _this.getAuthTokenCbk(newPracticeInstance.guardService, practiceUuid);
684
- case 4:
685
- return _context.abrupt("return", _context.sent);
686
- case 7:
687
- throw Error('[Auth] Unable to refresh token guard service is undefined');
688
- case 8:
689
- case "end":
690
- return _context.stop();
691
- }
692
- }, _callee);
693
- }));
694
- return function authTokenFunc() {
695
- return _ref.apply(this, arguments);
696
- };
697
- }(); // Initialize the M2M token
698
- _context2.next = 8;
699
- return authTokenFunc();
700
- case 8:
701
- // Set the refresh tokens callback
702
- newPracticeInstance.apiService.setAuthRefreshFn(authTokenFunc);
674
+ newPracticeInstance = init(this.serviceCollReq, undefined, this.useLocalStorage);
675
+ newPracticeInstance.apiService.setAuthRefreshFn(function () {
676
+ return _this.authTokenFunc(practiceUuid);
677
+ });
703
678
  this.practiceInstances.set(cacheKey, newPracticeInstance);
704
- return _context2.abrupt("return", newPracticeInstance);
705
- case 11:
679
+ return _context.abrupt("return", newPracticeInstance);
680
+ case 8:
706
681
  case "end":
707
- return _context2.stop();
682
+ return _context.stop();
708
683
  }
709
- }, _callee2, this);
684
+ }, _callee, this);
710
685
  }));
711
686
  function get(_x) {
712
687
  return _get.apply(this, arguments);
713
688
  }
714
689
  return get;
690
+ }()
691
+ /**
692
+ * Uses the refresh intance to fetch a new auth token for the given practice
693
+ * @param practiceUuid the uuid of the practice or key of a specific instance
694
+ * @returns a new authentication token
695
+ */
696
+ ;
697
+ _proto.authTokenFunc =
698
+ /*#__PURE__*/
699
+ function () {
700
+ var _authTokenFunc = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(practiceUuidOrInstanceName) {
701
+ var newPracticeInstance;
702
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
703
+ while (1) switch (_context2.prev = _context2.next) {
704
+ case 0:
705
+ _context2.next = 2;
706
+ return this.get('refreshInstance');
707
+ case 2:
708
+ newPracticeInstance = _context2.sent;
709
+ if (!newPracticeInstance.guardService) {
710
+ _context2.next = 10;
711
+ break;
712
+ }
713
+ console.log("\x1B[36m[Auth] Refresh auth called (practiceUuid: " + practiceUuidOrInstanceName + ")\x1B[36m");
714
+ _context2.next = 7;
715
+ return this.getAuthTokenCbk(newPracticeInstance.guardService, practiceUuidOrInstanceName);
716
+ case 7:
717
+ return _context2.abrupt("return", _context2.sent);
718
+ case 10:
719
+ throw Error('[Auth] Unable to refresh token guard service is undefined');
720
+ case 11:
721
+ case "end":
722
+ return _context2.stop();
723
+ }
724
+ }, _callee2, this);
725
+ }));
726
+ function authTokenFunc(_x2) {
727
+ return _authTokenFunc.apply(this, arguments);
728
+ }
729
+ return authTokenFunc;
715
730
  }();
716
731
  return ApisPracticeManager;
717
732
  }();
@@ -1874,6 +1889,31 @@ var GuardService = /*#__PURE__*/function () {
1874
1889
  }
1875
1890
  return identitySendConfirmEmail;
1876
1891
  }()
1892
+ /**
1893
+ * Notifies the guard and confirms the phishing attempt
1894
+ * @param attemptUuid the guard logged attempt id
1895
+ * @returns void
1896
+ */
1897
+ ;
1898
+ _proto.authConfirmPhishingAttempts =
1899
+ /*#__PURE__*/
1900
+ function () {
1901
+ var _authConfirmPhishingAttempts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(attemptUuid) {
1902
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1903
+ while (1) switch (_context12.prev = _context12.next) {
1904
+ case 0:
1905
+ return _context12.abrupt("return", this.api.put(this.baseURL + "/v1/auth/attempts/" + attemptUuid, {}));
1906
+ case 1:
1907
+ case "end":
1908
+ return _context12.stop();
1909
+ }
1910
+ }, _callee12, this);
1911
+ }));
1912
+ function authConfirmPhishingAttempts(_x14) {
1913
+ return _authConfirmPhishingAttempts.apply(this, arguments);
1914
+ }
1915
+ return authConfirmPhishingAttempts;
1916
+ }()
1877
1917
  /**
1878
1918
  * Get an identity using a customer email (format: customer+[b64Hash]@orohealth.me)
1879
1919
  *
@@ -1884,18 +1924,18 @@ var GuardService = /*#__PURE__*/function () {
1884
1924
  _proto.identityGetByCustomerEmail =
1885
1925
  /*#__PURE__*/
1886
1926
  function () {
1887
- var _identityGetByCustomerEmail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(email) {
1888
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1889
- while (1) switch (_context12.prev = _context12.next) {
1927
+ var _identityGetByCustomerEmail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(email) {
1928
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1929
+ while (1) switch (_context13.prev = _context13.next) {
1890
1930
  case 0:
1891
- return _context12.abrupt("return", this.identityGetByHash(email.substring(email.indexOf('+') + 1, email.indexOf('@'))));
1931
+ return _context13.abrupt("return", this.identityGetByHash(email.substring(email.indexOf('+') + 1, email.indexOf('@'))));
1892
1932
  case 1:
1893
1933
  case "end":
1894
- return _context12.stop();
1934
+ return _context13.stop();
1895
1935
  }
1896
- }, _callee12, this);
1936
+ }, _callee13, this);
1897
1937
  }));
1898
- function identityGetByCustomerEmail(_x14) {
1938
+ function identityGetByCustomerEmail(_x15) {
1899
1939
  return _identityGetByCustomerEmail.apply(this, arguments);
1900
1940
  }
1901
1941
  return identityGetByCustomerEmail;
@@ -1910,18 +1950,18 @@ var GuardService = /*#__PURE__*/function () {
1910
1950
  _proto.identityGetByHash =
1911
1951
  /*#__PURE__*/
1912
1952
  function () {
1913
- var _identityGetByHash = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(b64Hash) {
1914
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1915
- while (1) switch (_context13.prev = _context13.next) {
1953
+ var _identityGetByHash = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(b64Hash) {
1954
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1955
+ while (1) switch (_context14.prev = _context14.next) {
1916
1956
  case 0:
1917
- return _context13.abrupt("return", this.identityGet(b64Hash.replace(/\+/g, '-').replace(/\//g, '_')));
1957
+ return _context14.abrupt("return", this.identityGet(b64Hash.replace(/\+/g, '-').replace(/\//g, '_')));
1918
1958
  case 1:
1919
1959
  case "end":
1920
- return _context13.stop();
1960
+ return _context14.stop();
1921
1961
  }
1922
- }, _callee13, this);
1962
+ }, _callee14, this);
1923
1963
  }));
1924
- function identityGetByHash(_x15) {
1964
+ function identityGetByHash(_x16) {
1925
1965
  return _identityGetByHash.apply(this, arguments);
1926
1966
  }
1927
1967
  return identityGetByHash;