oro-sdk-apis 5.17.0 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/oro-sdk-apis.cjs.development.js +96 -56
- package/dist/oro-sdk-apis.cjs.development.js.map +1 -1
- package/dist/oro-sdk-apis.cjs.production.min.js +1 -1
- package/dist/oro-sdk-apis.cjs.production.min.js.map +1 -1
- package/dist/oro-sdk-apis.esm.js +96 -56
- package/dist/oro-sdk-apis.esm.js.map +1 -1
- package/dist/services/apisPracticeManager.d.ts +6 -0
- package/dist/services/guard.d.ts +6 -0
- package/package.json +1 -1
- package/src/services/apisPracticeManager.ts +22 -18
- package/src/services/guard.ts +9 -0
@@ -650,6 +650,9 @@ var ApisPracticeManager = /*#__PURE__*/function () {
|
|
650
650
|
this.getAuthTokenCbk = getAuthTokenCbk;
|
651
651
|
this.useLocalStorage = useLocalStorage;
|
652
652
|
this.practiceInstances = new Map();
|
653
|
+
// 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
|
654
|
+
var newPracticeInstance = init(this.serviceCollReq, undefined, this.useLocalStorage);
|
655
|
+
this.practiceInstances.set('refreshInstance', newPracticeInstance);
|
653
656
|
}
|
654
657
|
/**
|
655
658
|
* This function is used to get a `ServiceCollection` associated to a practice. If missing, it will initialize a new `ServiceCollection`.
|
@@ -660,64 +663,76 @@ var ApisPracticeManager = /*#__PURE__*/function () {
|
|
660
663
|
_proto.get =
|
661
664
|
/*#__PURE__*/
|
662
665
|
function () {
|
663
|
-
var _get = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
666
|
+
var _get = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(practiceUuid) {
|
664
667
|
var _this = this;
|
665
|
-
var cacheKey, practiceInstance, newPracticeInstance
|
666
|
-
return _regeneratorRuntime().wrap(function
|
667
|
-
while (1) switch (
|
668
|
+
var cacheKey, practiceInstance, newPracticeInstance;
|
669
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
670
|
+
while (1) switch (_context.prev = _context.next) {
|
668
671
|
case 0:
|
669
672
|
cacheKey = practiceUuid != null ? practiceUuid : 'none';
|
670
673
|
practiceInstance = this.practiceInstances.get(cacheKey);
|
671
674
|
if (!practiceInstance) {
|
672
|
-
|
675
|
+
_context.next = 4;
|
673
676
|
break;
|
674
677
|
}
|
675
|
-
return
|
678
|
+
return _context.abrupt("return", practiceInstance);
|
676
679
|
case 4:
|
677
|
-
newPracticeInstance = init(this.serviceCollReq, undefined, this.useLocalStorage);
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
while (1) switch (_context.prev = _context.next) {
|
682
|
-
case 0:
|
683
|
-
if (!newPracticeInstance.guardService) {
|
684
|
-
_context.next = 7;
|
685
|
-
break;
|
686
|
-
}
|
687
|
-
console.log("\x1B[36m[Auth] Refresh auth called (practiceUuid: " + practiceUuid + ")\x1B[36m");
|
688
|
-
_context.next = 4;
|
689
|
-
return _this.getAuthTokenCbk(newPracticeInstance.guardService, practiceUuid);
|
690
|
-
case 4:
|
691
|
-
return _context.abrupt("return", _context.sent);
|
692
|
-
case 7:
|
693
|
-
throw Error('[Auth] Unable to refresh token guard service is undefined');
|
694
|
-
case 8:
|
695
|
-
case "end":
|
696
|
-
return _context.stop();
|
697
|
-
}
|
698
|
-
}, _callee);
|
699
|
-
}));
|
700
|
-
return function authTokenFunc() {
|
701
|
-
return _ref.apply(this, arguments);
|
702
|
-
};
|
703
|
-
}(); // Initialize the M2M token
|
704
|
-
_context2.next = 8;
|
705
|
-
return authTokenFunc();
|
706
|
-
case 8:
|
707
|
-
// Set the refresh tokens callback
|
708
|
-
newPracticeInstance.apiService.setAuthRefreshFn(authTokenFunc);
|
680
|
+
newPracticeInstance = init(this.serviceCollReq, undefined, this.useLocalStorage);
|
681
|
+
newPracticeInstance.apiService.setAuthRefreshFn(function () {
|
682
|
+
return _this.authTokenFunc(practiceUuid);
|
683
|
+
});
|
709
684
|
this.practiceInstances.set(cacheKey, newPracticeInstance);
|
710
|
-
return
|
711
|
-
case
|
685
|
+
return _context.abrupt("return", newPracticeInstance);
|
686
|
+
case 8:
|
712
687
|
case "end":
|
713
|
-
return
|
688
|
+
return _context.stop();
|
714
689
|
}
|
715
|
-
},
|
690
|
+
}, _callee, this);
|
716
691
|
}));
|
717
692
|
function get(_x) {
|
718
693
|
return _get.apply(this, arguments);
|
719
694
|
}
|
720
695
|
return get;
|
696
|
+
}()
|
697
|
+
/**
|
698
|
+
* Uses the refresh intance to fetch a new auth token for the given practice
|
699
|
+
* @param practiceUuid the uuid of the practice or key of a specific instance
|
700
|
+
* @returns a new authentication token
|
701
|
+
*/
|
702
|
+
;
|
703
|
+
_proto.authTokenFunc =
|
704
|
+
/*#__PURE__*/
|
705
|
+
function () {
|
706
|
+
var _authTokenFunc = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(practiceUuidOrInstanceName) {
|
707
|
+
var newPracticeInstance;
|
708
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
709
|
+
while (1) switch (_context2.prev = _context2.next) {
|
710
|
+
case 0:
|
711
|
+
_context2.next = 2;
|
712
|
+
return this.get('refreshInstance');
|
713
|
+
case 2:
|
714
|
+
newPracticeInstance = _context2.sent;
|
715
|
+
if (!newPracticeInstance.guardService) {
|
716
|
+
_context2.next = 10;
|
717
|
+
break;
|
718
|
+
}
|
719
|
+
console.log("\x1B[36m[Auth] Refresh auth called (practiceUuid: " + practiceUuidOrInstanceName + ")\x1B[36m");
|
720
|
+
_context2.next = 7;
|
721
|
+
return this.getAuthTokenCbk(newPracticeInstance.guardService, practiceUuidOrInstanceName);
|
722
|
+
case 7:
|
723
|
+
return _context2.abrupt("return", _context2.sent);
|
724
|
+
case 10:
|
725
|
+
throw Error('[Auth] Unable to refresh token guard service is undefined');
|
726
|
+
case 11:
|
727
|
+
case "end":
|
728
|
+
return _context2.stop();
|
729
|
+
}
|
730
|
+
}, _callee2, this);
|
731
|
+
}));
|
732
|
+
function authTokenFunc(_x2) {
|
733
|
+
return _authTokenFunc.apply(this, arguments);
|
734
|
+
}
|
735
|
+
return authTokenFunc;
|
721
736
|
}();
|
722
737
|
return ApisPracticeManager;
|
723
738
|
}();
|
@@ -1830,6 +1845,31 @@ var GuardService = /*#__PURE__*/function () {
|
|
1830
1845
|
}
|
1831
1846
|
return identitySendConfirmEmail;
|
1832
1847
|
}()
|
1848
|
+
/**
|
1849
|
+
* Notifies the guard and confirms the phishing attempt
|
1850
|
+
* @param attemptUuid the guard logged attempt id
|
1851
|
+
* @returns void
|
1852
|
+
*/
|
1853
|
+
;
|
1854
|
+
_proto.authConfirmPhishingAttempts =
|
1855
|
+
/*#__PURE__*/
|
1856
|
+
function () {
|
1857
|
+
var _authConfirmPhishingAttempts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(attemptUuid) {
|
1858
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
1859
|
+
while (1) switch (_context12.prev = _context12.next) {
|
1860
|
+
case 0:
|
1861
|
+
return _context12.abrupt("return", this.api.put(this.baseURL + "/v1/auth/attempts/" + attemptUuid, {}));
|
1862
|
+
case 1:
|
1863
|
+
case "end":
|
1864
|
+
return _context12.stop();
|
1865
|
+
}
|
1866
|
+
}, _callee12, this);
|
1867
|
+
}));
|
1868
|
+
function authConfirmPhishingAttempts(_x14) {
|
1869
|
+
return _authConfirmPhishingAttempts.apply(this, arguments);
|
1870
|
+
}
|
1871
|
+
return authConfirmPhishingAttempts;
|
1872
|
+
}()
|
1833
1873
|
/**
|
1834
1874
|
* Get an identity using a customer email (format: customer+[b64Hash]@orohealth.me)
|
1835
1875
|
*
|
@@ -1840,18 +1880,18 @@ var GuardService = /*#__PURE__*/function () {
|
|
1840
1880
|
_proto.identityGetByCustomerEmail =
|
1841
1881
|
/*#__PURE__*/
|
1842
1882
|
function () {
|
1843
|
-
var _identityGetByCustomerEmail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
1844
|
-
return _regeneratorRuntime().wrap(function
|
1845
|
-
while (1) switch (
|
1883
|
+
var _identityGetByCustomerEmail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(email) {
|
1884
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
1885
|
+
while (1) switch (_context13.prev = _context13.next) {
|
1846
1886
|
case 0:
|
1847
|
-
return
|
1887
|
+
return _context13.abrupt("return", this.identityGetByHash(email.substring(email.indexOf('+') + 1, email.indexOf('@'))));
|
1848
1888
|
case 1:
|
1849
1889
|
case "end":
|
1850
|
-
return
|
1890
|
+
return _context13.stop();
|
1851
1891
|
}
|
1852
|
-
},
|
1892
|
+
}, _callee13, this);
|
1853
1893
|
}));
|
1854
|
-
function identityGetByCustomerEmail(
|
1894
|
+
function identityGetByCustomerEmail(_x15) {
|
1855
1895
|
return _identityGetByCustomerEmail.apply(this, arguments);
|
1856
1896
|
}
|
1857
1897
|
return identityGetByCustomerEmail;
|
@@ -1866,18 +1906,18 @@ var GuardService = /*#__PURE__*/function () {
|
|
1866
1906
|
_proto.identityGetByHash =
|
1867
1907
|
/*#__PURE__*/
|
1868
1908
|
function () {
|
1869
|
-
var _identityGetByHash = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
1870
|
-
return _regeneratorRuntime().wrap(function
|
1871
|
-
while (1) switch (
|
1909
|
+
var _identityGetByHash = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(b64Hash) {
|
1910
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
1911
|
+
while (1) switch (_context14.prev = _context14.next) {
|
1872
1912
|
case 0:
|
1873
|
-
return
|
1913
|
+
return _context14.abrupt("return", this.identityGet(b64Hash.replace(/\+/g, '-').replace(/\//g, '_')));
|
1874
1914
|
case 1:
|
1875
1915
|
case "end":
|
1876
|
-
return
|
1916
|
+
return _context14.stop();
|
1877
1917
|
}
|
1878
|
-
},
|
1918
|
+
}, _callee14, this);
|
1879
1919
|
}));
|
1880
|
-
function identityGetByHash(
|
1920
|
+
function identityGetByHash(_x16) {
|
1881
1921
|
return _identityGetByHash.apply(this, arguments);
|
1882
1922
|
}
|
1883
1923
|
return identityGetByHash;
|