oro-sdk-apis 1.8.3 → 1.9.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.
@@ -1796,6 +1796,7 @@ var GuardService = /*#__PURE__*/function () {
1796
1796
  this.api = api;
1797
1797
  this.baseURL = baseURL;
1798
1798
  this.api.setAuthRefreshFn(this.authRefresh.bind(this));
1799
+ this.identityCache = {};
1799
1800
  this.whoAmICache = {};
1800
1801
  }
1801
1802
  /**
@@ -2075,6 +2076,7 @@ var GuardService = /*#__PURE__*/function () {
2075
2076
  * without authentication
2076
2077
  *
2077
2078
  * @param identityID Unique id of the identity to retrieve
2079
+ * @param skipCache (default: false) will skip identity cache (not even update it)
2078
2080
  * @returns IdentityResponse
2079
2081
  */
2080
2082
  ;
@@ -2082,18 +2084,46 @@ var GuardService = /*#__PURE__*/function () {
2082
2084
  _proto.identityGet =
2083
2085
  /*#__PURE__*/
2084
2086
  function () {
2085
- var _identityGet = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(identityID) {
2087
+ var _identityGet = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(identityID, skipCache) {
2088
+ var _tokens$accessToken, _tokens$refreshToken;
2089
+
2090
+ var tokens, cacheKey, identity;
2086
2091
  return runtime_1.wrap(function _callee6$(_context6) {
2087
2092
  while (1) {
2088
2093
  switch (_context6.prev = _context6.next) {
2089
2094
  case 0:
2090
- _context6.next = 2;
2095
+ if (skipCache === void 0) {
2096
+ skipCache = false;
2097
+ }
2098
+
2099
+ tokens = this.api.getTokens();
2100
+ cacheKey = ((_tokens$accessToken = tokens.accessToken) != null ? _tokens$accessToken : '') + ((_tokens$refreshToken = tokens.refreshToken) != null ? _tokens$refreshToken : '') + identityID;
2101
+
2102
+ if (!(skipCache || !tokens.accessToken || !this.identityCache[cacheKey])) {
2103
+ _context6.next = 10;
2104
+ break;
2105
+ }
2106
+
2107
+ _context6.next = 6;
2091
2108
  return this.api.get(this.baseURL + "/v1/identities/" + identityID);
2092
2109
 
2093
- case 2:
2094
- return _context6.abrupt("return", _context6.sent);
2110
+ case 6:
2111
+ identity = _context6.sent;
2095
2112
 
2096
- case 3:
2113
+ if (!skipCache) {
2114
+ _context6.next = 9;
2115
+ break;
2116
+ }
2117
+
2118
+ return _context6.abrupt("return", identity);
2119
+
2120
+ case 9:
2121
+ this.identityCache[cacheKey] = identity;
2122
+
2123
+ case 10:
2124
+ return _context6.abrupt("return", this.identityCache[cacheKey]);
2125
+
2126
+ case 11:
2097
2127
  case "end":
2098
2128
  return _context6.stop();
2099
2129
  }
@@ -2101,7 +2131,7 @@ var GuardService = /*#__PURE__*/function () {
2101
2131
  }, _callee6, this);
2102
2132
  }));
2103
2133
 
2104
- function identityGet(_x5) {
2134
+ function identityGet(_x5, _x6) {
2105
2135
  return _identityGet.apply(this, arguments);
2106
2136
  }
2107
2137
 
@@ -2154,7 +2184,7 @@ var GuardService = /*#__PURE__*/function () {
2154
2184
  }, _callee7, this);
2155
2185
  }));
2156
2186
 
2157
- function whoAmI(_x6) {
2187
+ function whoAmI(_x7) {
2158
2188
  return _whoAmI.apply(this, arguments);
2159
2189
  }
2160
2190
 
@@ -2187,7 +2217,7 @@ var GuardService = /*#__PURE__*/function () {
2187
2217
  }, _callee8, this);
2188
2218
  }));
2189
2219
 
2190
- function identityUpdate(_x7, _x8) {
2220
+ function identityUpdate(_x8, _x9) {
2191
2221
  return _identityUpdate.apply(this, arguments);
2192
2222
  }
2193
2223
 
@@ -2229,7 +2259,7 @@ var GuardService = /*#__PURE__*/function () {
2229
2259
  }, _callee9, this);
2230
2260
  }));
2231
2261
 
2232
- function identityMFAQRCode(_x9, _x10) {
2262
+ function identityMFAQRCode(_x10, _x11) {
2233
2263
  return _identityMFAQRCode.apply(this, arguments);
2234
2264
  }
2235
2265
 
@@ -2261,7 +2291,7 @@ var GuardService = /*#__PURE__*/function () {
2261
2291
  }, _callee10, this);
2262
2292
  }));
2263
2293
 
2264
- function identitySendConfirmEmail(_x11) {
2294
+ function identitySendConfirmEmail(_x12) {
2265
2295
  return _identitySendConfirmEmail.apply(this, arguments);
2266
2296
  }
2267
2297