@edx/frontend-platform 2.5.1 → 2.5.2

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.
Files changed (36) hide show
  1. package/auth/AxiosCsrfTokenService.js +6 -2
  2. package/auth/AxiosCsrfTokenService.js.map +1 -1
  3. package/auth/AxiosJwtAuthService.js +10 -6
  4. package/auth/AxiosJwtAuthService.js.map +1 -1
  5. package/auth/AxiosJwtTokenService.js +8 -4
  6. package/auth/AxiosJwtTokenService.js.map +1 -1
  7. package/auth/LocalForageCache.js +8 -4
  8. package/auth/LocalForageCache.js.map +1 -1
  9. package/auth/MockAuthService.js.map +1 -1
  10. package/auth/interceptors/createCsrfTokenProviderInterceptor.js +6 -2
  11. package/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -1
  12. package/auth/interceptors/createJwtTokenProviderInterceptor.js +6 -2
  13. package/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -1
  14. package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +6 -2
  15. package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -1
  16. package/auth/interceptors/createRetryInterceptor.js +9 -5
  17. package/auth/interceptors/createRetryInterceptor.js.map +1 -1
  18. package/auth/interface.js +10 -6
  19. package/auth/interface.js.map +1 -1
  20. package/i18n/countries.js +13 -13
  21. package/i18n/countries.js.map +1 -1
  22. package/i18n/injectIntlWithShim.js +3 -3
  23. package/i18n/languages.js +5 -5
  24. package/i18n/languages.js.map +1 -1
  25. package/initialize.js +16 -12
  26. package/initialize.js.map +1 -1
  27. package/package.json +2 -2
  28. package/react/AppProvider.js +10 -7
  29. package/react/AppProvider.js.map +1 -1
  30. package/react/ErrorBoundary.js +2 -2
  31. package/react/OptionalReduxProvider.js +1 -1
  32. package/react/OptionalReduxProvider.js.map +1 -1
  33. package/react/PageRoute.js +2 -1
  34. package/react/PageRoute.js.map +1 -1
  35. package/react/hooks.js +1 -1
  36. package/react/hooks.js.map +1 -1
@@ -1,3 +1,7 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+
1
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
6
 
3
7
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -30,12 +34,12 @@ var AxiosCsrfTokenService = /*#__PURE__*/function () {
30
34
  _createClass(AxiosCsrfTokenService, [{
31
35
  key: "getCsrfToken",
32
36
  value: function () {
33
- var _getCsrfToken = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url) {
37
+ var _getCsrfToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
34
38
  var _this = this;
35
39
 
36
40
  var urlParts, _urlParts, protocol, domain, csrfToken;
37
41
 
38
- return regeneratorRuntime.wrap(function _callee$(_context) {
42
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
39
43
  while (1) {
40
44
  switch (_context.prev = _context.next) {
41
45
  case 0:
@@ -1 +1 @@
1
- {"version":3,"file":"AxiosCsrfTokenService.js","names":["axios","getUrlParts","processAxiosErrorAndThrow","AxiosCsrfTokenService","csrfTokenApiPath","httpClient","create","defaults","withCredentials","headers","common","csrfTokenCache","csrfTokenRequestPromises","url","urlParts","e","global","location","origin","protocol","domain","csrfToken","get","then","response","data"],"sources":["../../src/auth/AxiosCsrfTokenService.js"],"sourcesContent":["import axios from 'axios';\nimport { getUrlParts, processAxiosErrorAndThrow } from './utils';\n\nexport default class AxiosCsrfTokenService {\n constructor(csrfTokenApiPath) {\n this.csrfTokenApiPath = csrfTokenApiPath;\n this.httpClient = axios.create();\n // Set withCredentials to true. Enables cross-site Access-Control requests\n // to be made using cookies, authorization headers or TLS client\n // certificates. More on MDN:\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials\n this.httpClient.defaults.withCredentials = true;\n this.httpClient.defaults.headers.common['USE-JWT-COOKIE'] = true;\n\n this.csrfTokenCache = {};\n this.csrfTokenRequestPromises = {};\n }\n\n async getCsrfToken(url) {\n let urlParts;\n try {\n urlParts = getUrlParts(url);\n } catch (e) {\n // If the url is not parsable it's likely because a relative\n // path was supplied as the url. This is acceptable and in\n // this case we should use the current origin of the page.\n urlParts = getUrlParts(global.location.origin);\n }\n\n const { protocol, domain } = urlParts;\n const csrfToken = this.csrfTokenCache[domain];\n\n if (csrfToken) {\n return csrfToken;\n }\n\n if (!this.csrfTokenRequestPromises[domain]) {\n this.csrfTokenRequestPromises[domain] = this.httpClient\n .get(`${protocol}://${domain}${this.csrfTokenApiPath}`)\n .then((response) => {\n this.csrfTokenCache[domain] = response.data.csrfToken;\n return this.csrfTokenCache[domain];\n })\n .catch(processAxiosErrorAndThrow)\n .finally(() => {\n delete this.csrfTokenRequestPromises[domain];\n });\n }\n\n return this.csrfTokenRequestPromises[domain];\n }\n\n clearCsrfTokenCache() {\n this.csrfTokenCache = {};\n }\n\n getHttpClient() {\n return this.httpClient;\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,WAAT,EAAsBC,yBAAtB,QAAuD,SAAvD;;IAEqBC,qB;EACnB,+BAAYC,gBAAZ,EAA8B;IAAA;;IAC5B,KAAKA,gBAAL,GAAwBA,gBAAxB;IACA,KAAKC,UAAL,GAAkBL,KAAK,CAACM,MAAN,EAAlB,CAF4B,CAG5B;IACA;IACA;IACA;;IACA,KAAKD,UAAL,CAAgBE,QAAhB,CAAyBC,eAAzB,GAA2C,IAA3C;IACA,KAAKH,UAAL,CAAgBE,QAAhB,CAAyBE,OAAzB,CAAiCC,MAAjC,CAAwC,gBAAxC,IAA4D,IAA5D;IAEA,KAAKC,cAAL,GAAsB,EAAtB;IACA,KAAKC,wBAAL,GAAgC,EAAhC;EACD;;;;;kFAED,iBAAmBC,GAAnB;QAAA;;QAAA;;QAAA;UAAA;YA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iPath","httpClient","create","defaults","withCredentials","headers","common","csrfTokenCache","csrfTokenRequestPromises","url","urlParts","e","global","location","origin","protocol","domain","csrfToken","get","then","response","data"],"sources":["../../src/auth/AxiosCsrfTokenService.js"],"sourcesContent":["import axios from 'axios';\nimport { getUrlParts, processAxiosErrorAndThrow } from './utils';\n\nexport default class AxiosCsrfTokenService {\n constructor(csrfTokenApiPath) {\n this.csrfTokenApiPath = csrfTokenApiPath;\n this.httpClient = axios.create();\n // Set withCredentials to true. Enables cross-site Access-Control requests\n // to be made using cookies, authorization headers or TLS client\n // certificates. More on MDN:\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials\n this.httpClient.defaults.withCredentials = true;\n this.httpClient.defaults.headers.common['USE-JWT-COOKIE'] = true;\n\n this.csrfTokenCache = {};\n this.csrfTokenRequestPromises = {};\n }\n\n async getCsrfToken(url) {\n let urlParts;\n try {\n urlParts = getUrlParts(url);\n } catch (e) {\n // If the url is not parsable it's likely because a relative\n // path was supplied as the url. This is acceptable and in\n // this case we should use the current origin of the page.\n urlParts = getUrlParts(global.location.origin);\n }\n\n const { protocol, domain } = urlParts;\n const csrfToken = this.csrfTokenCache[domain];\n\n if (csrfToken) {\n return csrfToken;\n }\n\n if (!this.csrfTokenRequestPromises[domain]) {\n this.csrfTokenRequestPromises[domain] = this.httpClient\n .get(`${protocol}://${domain}${this.csrfTokenApiPath}`)\n .then((response) => {\n this.csrfTokenCache[domain] = response.data.csrfToken;\n return this.csrfTokenCache[domain];\n })\n .catch(processAxiosErrorAndThrow)\n .finally(() => {\n delete this.csrfTokenRequestPromises[domain];\n });\n }\n\n return this.csrfTokenRequestPromises[domain];\n }\n\n clearCsrfTokenCache() {\n this.csrfTokenCache = {};\n }\n\n getHttpClient() {\n return this.httpClient;\n }\n}\n"],"mappings":";;+CACA,oJ;;;;;;;;;;;;AADA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,WAAT,EAAsBC,yBAAtB,QAAuD,SAAvD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B,CAAP;kBACD,CALqC,WAM/BlB,yBAN+B,aAO7B,YAAM;oBACb,OAAO,KAAI,CAACU,wBAAL,CAA8BQ,MAA9B,CAAP;kBACD,CATqC,CAAxC;gBAUD;;gBA7BH,iCA+BS,KAAKR,wBAAL,CAA8BQ,MAA9B,CA/BT;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;WAkCA,+BAAsB;MACpB,KAAKT,cAAL,GAAsB,EAAtB;IACD;;;WAED,yBAAgB;MACd,OAAO,KAAKN,UAAZ;IACD;;;;;;SAvDkBF,qB"}
@@ -1,9 +1,13 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
1
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
4
 
3
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
6
 
5
7
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
8
 
9
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
10
+
7
11
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
8
12
 
9
13
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -267,11 +271,11 @@ var AxiosJwtAuthService = /*#__PURE__*/function () {
267
271
  }, {
268
272
  key: "fetchAuthenticatedUser",
269
273
  value: function () {
270
- var _fetchAuthenticatedUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
274
+ var _fetchAuthenticatedUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
271
275
  var options,
272
276
  decodedAccessToken,
273
277
  _args = arguments;
274
- return regeneratorRuntime.wrap(function _callee$(_context) {
278
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
275
279
  while (1) {
276
280
  switch (_context.prev = _context.next) {
277
281
  case 0:
@@ -323,13 +327,13 @@ var AxiosJwtAuthService = /*#__PURE__*/function () {
323
327
  }, {
324
328
  key: "ensureAuthenticatedUser",
325
329
  value: function () {
326
- var _ensureAuthenticatedUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
330
+ var _ensureAuthenticatedUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
327
331
  var redirectUrl,
328
332
  isRedirectFromLoginPage,
329
333
  redirectLoopError,
330
334
  unauthorizedError,
331
335
  _args2 = arguments;
332
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
336
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
333
337
  while (1) {
334
338
  switch (_context2.prev = _context2.next) {
335
339
  case 0:
@@ -395,9 +399,9 @@ var AxiosJwtAuthService = /*#__PURE__*/function () {
395
399
  }, {
396
400
  key: "hydrateAuthenticatedUser",
397
401
  value: function () {
398
- var _hydrateAuthenticatedUser = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
402
+ var _hydrateAuthenticatedUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
399
403
  var user, response;
400
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
404
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
401
405
  while (1) {
402
406
  switch (_context3.prev = _context3.next) {
403
407
  case 0:
@@ -1 +1 @@
1
- {"version":3,"file":"AxiosJwtAuthService.js","names":["axios","PropTypes","logFrontendAuthError","camelCaseObject","ensureDefinedConfig","createJwtTokenProviderInterceptor","createCsrfTokenProviderInterceptor","createProcessAxiosRequestErrorInterceptor","AxiosJwtTokenService","AxiosCsrfTokenService","configureCache","optionsPropTypes","config","shape","BASE_URL","string","isRequired","LMS_BASE_URL","LOGIN_URL","LOGOUT_URL","REFRESH_ACCESS_TOKEN_ENDPOINT","ACCESS_TOKEN_COOKIE_NAME","CSRF_TOKEN_API_PATH","loggingService","logError","func","logInfo","AxiosJwtAuthService","options","authenticatedHttpClient","httpClient","cachedAuthenticatedHttpClient","cachedHttpClient","authenticatedUser","checkPropTypes","jwtTokenService","csrfTokenService","addAuthenticationToHttpClient","create","then","cachedAxiosClient","e","message","middleware","applyMiddleware","clients","forEach","middlewareFn","client","error","useCache","redirectUrl","encodeURIComponent","global","location","assign","getLoginRedirectUrl","getLogoutRedirectUrl","authUser","getJwtToken","forceRefresh","decodedAccessToken","setAuthenticatedUser","email","userId","user_id","username","preferred_username","roles","administrator","name","getAuthenticatedUser","fetchAuthenticatedUser","isRedirectFromLoginPage","document","referrer","startsWith","redirectLoopError","Error","redirectToLogin","unauthorizedError","isRedirecting","user","get","response","data","newHttpClient","Object","defaults","withCredentials","refreshAccessTokenInterceptor","shouldSkip","axiosRequestConfig","isPublic","attachCsrfTokenInterceptor","method","isCsrfExempt","CSRF_PROTECTED_METHODS","includes","processAxiosRequestErrorInterceptor","interceptors","request","use"],"sources":["../../src/auth/AxiosJwtAuthService.js"],"sourcesContent":["import axios from 'axios';\nimport PropTypes from 'prop-types';\nimport { logFrontendAuthError } from './utils';\nimport { camelCaseObject, ensureDefinedConfig } from '../utils';\nimport createJwtTokenProviderInterceptor from './interceptors/createJwtTokenProviderInterceptor';\nimport createCsrfTokenProviderInterceptor from './interceptors/createCsrfTokenProviderInterceptor';\nimport createProcessAxiosRequestErrorInterceptor from './interceptors/createProcessAxiosRequestErrorInterceptor';\nimport AxiosJwtTokenService from './AxiosJwtTokenService';\nimport AxiosCsrfTokenService from './AxiosCsrfTokenService';\nimport configureCache from './LocalForageCache';\n\nconst optionsPropTypes = {\n config: PropTypes.shape({\n BASE_URL: PropTypes.string.isRequired,\n LMS_BASE_URL: PropTypes.string.isRequired,\n LOGIN_URL: PropTypes.string.isRequired,\n LOGOUT_URL: PropTypes.string.isRequired,\n REFRESH_ACCESS_TOKEN_ENDPOINT: PropTypes.string.isRequired,\n ACCESS_TOKEN_COOKIE_NAME: PropTypes.string.isRequired,\n CSRF_TOKEN_API_PATH: PropTypes.string.isRequired,\n }).isRequired,\n loggingService: PropTypes.shape({\n logError: PropTypes.func.isRequired,\n logInfo: PropTypes.func.isRequired,\n }).isRequired,\n};\n\n/**\n * @implements {AuthService}\n * @memberof module:Auth\n */\nclass AxiosJwtAuthService {\n /**\n * @param {Object} options\n * @param {Object} options.config\n * @param {string} options.config.BASE_URL\n * @param {string} options.config.LMS_BASE_URL\n * @param {string} options.config.LOGIN_URL\n * @param {string} options.config.LOGOUT_URL\n * @param {string} options.config.REFRESH_ACCESS_TOKEN_ENDPOINT\n * @param {string} options.config.ACCESS_TOKEN_COOKIE_NAME\n * @param {string} options.config.CSRF_TOKEN_API_PATH\n * @param {Object} options.loggingService requires logError and logInfo methods\n */\n constructor(options) {\n this.authenticatedHttpClient = null;\n this.httpClient = null;\n this.cachedAuthenticatedHttpClient = null;\n this.cachedHttpClient = null;\n this.authenticatedUser = null;\n\n ensureDefinedConfig(options, 'AuthService');\n PropTypes.checkPropTypes(optionsPropTypes, options, 'options', 'AuthService');\n\n this.config = options.config;\n this.loggingService = options.loggingService;\n this.jwtTokenService = new AxiosJwtTokenService(\n this.loggingService,\n this.config.ACCESS_TOKEN_COOKIE_NAME,\n this.config.REFRESH_ACCESS_TOKEN_ENDPOINT,\n );\n this.csrfTokenService = new AxiosCsrfTokenService(this.config.CSRF_TOKEN_API_PATH);\n this.authenticatedHttpClient = this.addAuthenticationToHttpClient(axios.create());\n this.httpClient = axios.create();\n configureCache()\n .then((cachedAxiosClient) => {\n this.cachedAuthenticatedHttpClient = this.addAuthenticationToHttpClient(cachedAxiosClient);\n this.cachedHttpClient = cachedAxiosClient;\n })\n .catch((e) => {\n // fallback to non-cached HTTP clients and log error\n this.cachedAuthenticatedHttpClient = this.authenticatedHttpClient;\n this.cachedHttpClient = this.httpClient;\n logFrontendAuthError(this.loggingService, `configureCache failed with error: ${e.message}`);\n });\n\n this.middleware = options.middleware;\n this.applyMiddleware(options.middleware);\n }\n\n /**\n * Applies middleware to the axios instances in this service.\n *\n * @param {Array} middleware Middleware to apply.\n */\n applyMiddleware(middleware = []) {\n const clients = [\n this.authenticatedHttpClient, this.httpClient,\n this.cachedAuthenticatedHttpClient, this.cachedHttpClient,\n ];\n try {\n (middleware).forEach((middlewareFn) => {\n clients.forEach((client) => client && middlewareFn(client));\n });\n } catch (error) {\n logFrontendAuthError(this.loggingService, error);\n throw error;\n }\n }\n\n /**\n * Gets the authenticated HTTP client for the service. This is an axios instance.\n *\n * @param {Object} [options] Optional options for how the HTTP client should be configured.\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made\n * with the returned client.\n *\n * @returns {HttpClient} A configured axios http client which can be used for authenticated\n * requests.\n */\n getAuthenticatedHttpClient(options = {}) {\n if (options.useCache) {\n return this.cachedAuthenticatedHttpClient;\n }\n\n return this.authenticatedHttpClient;\n }\n\n /**\n * Gets the unauthenticated HTTP client for the service. This is an axios instance.\n *\n * @param {Object} [options] Optional options for how the HTTP client should be configured.\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made\n * with the returned client.\n * @returns {HttpClient} A configured axios http client.\n */\n getHttpClient(options = {}) {\n if (options.useCache) {\n return this.cachedHttpClient;\n }\n\n return this.httpClient;\n }\n\n /**\n * Used primarily for testing.\n *\n * @ignore\n */\n getJwtTokenService() {\n return this.jwtTokenService;\n }\n\n /**\n * Used primarily for testing.\n *\n * @ignore\n */\n getCsrfTokenService() {\n return this.csrfTokenService;\n }\n\n /**\n * Builds a URL to the login page with a post-login redirect URL attached as a query parameter.\n *\n * ```\n * const url = getLoginRedirectUrl('http://localhost/mypage');\n * console.log(url); // http://localhost/login?next=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging in.\n */\n getLoginRedirectUrl(redirectUrl = this.config.BASE_URL) {\n return `${this.config.LOGIN_URL}?next=${encodeURIComponent(redirectUrl)}`;\n }\n\n /**\n * Redirects the user to the login page.\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging in.\n */\n redirectToLogin(redirectUrl = this.config.BASE_URL) {\n global.location.assign(this.getLoginRedirectUrl(redirectUrl));\n }\n\n /**\n * Builds a URL to the logout page with a post-logout redirect URL attached as a query parameter.\n *\n * ```\n * const url = getLogoutRedirectUrl('http://localhost/mypage');\n * console.log(url); // http://localhost/logout?next=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\n getLogoutRedirectUrl(redirectUrl = this.config.BASE_URL) {\n return `${this.config.LOGOUT_URL}?redirect_url=${encodeURIComponent(redirectUrl)}`;\n }\n\n /**\n * Redirects the user to the logout page.\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\n redirectToLogout(redirectUrl = this.config.BASE_URL) {\n global.location.assign(this.getLogoutRedirectUrl(redirectUrl));\n }\n\n /**\n * If it exists, returns the user data representing the currently authenticated user. If the\n * user is anonymous, returns null.\n *\n * @returns {UserData|null}\n */\n getAuthenticatedUser() {\n return this.authenticatedUser;\n }\n\n /**\n * Sets the authenticated user to the provided value.\n *\n * @param {UserData} authUser\n */\n setAuthenticatedUser(authUser) {\n this.authenticatedUser = authUser;\n }\n\n /**\n * Reads the authenticated user's access token. Resolves to null if the user is\n * unauthenticated.\n *\n * @returns {Promise<UserData>|Promise<null>} Resolves to the user's access token if they are\n * logged in.\n */\n async fetchAuthenticatedUser(options = {}) {\n const decodedAccessToken = await this.jwtTokenService.getJwtToken(options.forceRefresh || false);\n\n if (decodedAccessToken !== null) {\n this.setAuthenticatedUser({\n email: decodedAccessToken.email,\n userId: decodedAccessToken.user_id,\n username: decodedAccessToken.preferred_username,\n roles: decodedAccessToken.roles || [],\n administrator: decodedAccessToken.administrator,\n name: decodedAccessToken.name,\n });\n } else {\n this.setAuthenticatedUser(null);\n }\n\n return this.getAuthenticatedUser();\n }\n\n /**\n * Ensures a user is authenticated. It will redirect to login when not\n * authenticated.\n *\n * @param {string} [redirectUrl=config.BASE_URL] to return user after login when not\n * authenticated.\n * @returns {Promise<UserData>}\n */\n async ensureAuthenticatedUser(redirectUrl = this.config.BASE_URL) {\n await this.fetchAuthenticatedUser();\n\n if (this.getAuthenticatedUser() === null) {\n const isRedirectFromLoginPage = global.document.referrer\n && global.document.referrer.startsWith(this.config.LOGIN_URL);\n\n if (isRedirectFromLoginPage) {\n const redirectLoopError = new Error('Redirect from login page. Rejecting to avoid infinite redirect loop.');\n logFrontendAuthError(this.loggingService, redirectLoopError);\n throw redirectLoopError;\n }\n\n // The user is not authenticated, send them to the login page.\n this.redirectToLogin(redirectUrl);\n\n const unauthorizedError = new Error('Failed to ensure the user is authenticated');\n unauthorizedError.isRedirecting = true;\n throw unauthorizedError;\n }\n\n return this.getAuthenticatedUser();\n }\n\n /**\n * Fetches additional user account information for the authenticated user and merges it into the\n * existing authenticatedUser object, available via getAuthenticatedUser().\n *\n * ```\n * console.log(authenticatedUser); // Will be sparse and only contain basic information.\n * await hydrateAuthenticatedUser()\n * const authenticatedUser = getAuthenticatedUser();\n * console.log(authenticatedUser); // Will contain additional user information\n * ```\n *\n * @returns {Promise<null>}\n */\n async hydrateAuthenticatedUser() {\n const user = this.getAuthenticatedUser();\n if (user !== null) {\n const response = await this.authenticatedHttpClient\n .get(`${this.config.LMS_BASE_URL}/api/user/v1/accounts/${user.username}`);\n this.setAuthenticatedUser({ ...user, ...camelCaseObject(response.data) });\n }\n }\n\n /**\n * Adds authentication defaults and interceptors to an HTTP client instance.\n *\n * @param {HttpClient} newHttpClient\n * @param {Object} config\n * @param {string} [config.REFRESH_ACCESS_TOKEN_ENDPOINT]\n * @param {string} [config.ACCESS_TOKEN_COOKIE_NAME]\n * @param {string} [config.CSRF_TOKEN_API_PATH]\n * @returns {HttpClient} A configured Axios HTTP client.\n */\n addAuthenticationToHttpClient(newHttpClient) {\n const httpClient = Object.create(newHttpClient);\n // Set withCredentials to true. Enables cross-site Access-Control requests\n // to be made using cookies, authorization headers or TLS client\n // certificates. More on MDN:\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials\n httpClient.defaults.withCredentials = true;\n\n // Axios interceptors\n\n // The JWT access token interceptor attempts to refresh the user's jwt token\n // before any request unless the isPublic flag is set on the request config.\n const refreshAccessTokenInterceptor = createJwtTokenProviderInterceptor({\n jwtTokenService: this.jwtTokenService,\n shouldSkip: axiosRequestConfig => axiosRequestConfig.isPublic,\n });\n // The CSRF token intercepter fetches and caches a csrf token for any post,\n // put, patch, or delete request. That token is then added to the request\n // headers.\n const attachCsrfTokenInterceptor = createCsrfTokenProviderInterceptor({\n csrfTokenService: this.csrfTokenService,\n CSRF_TOKEN_API_PATH: this.config.CSRF_TOKEN_API_PATH,\n shouldSkip: (axiosRequestConfig) => {\n const { method, isCsrfExempt } = axiosRequestConfig;\n const CSRF_PROTECTED_METHODS = ['post', 'put', 'patch', 'delete'];\n return isCsrfExempt || !CSRF_PROTECTED_METHODS.includes(method);\n },\n });\n\n const processAxiosRequestErrorInterceptor = createProcessAxiosRequestErrorInterceptor({\n loggingService: this.loggingService,\n });\n\n // Request interceptors: Axios runs the interceptors in reverse order from\n // how they are listed. After fetching csrf tokens no longer require jwt\n // authentication, it won't matter which happens first. This change is\n // coming soon in edx-platform. Nov. 2019\n httpClient.interceptors.request.use(attachCsrfTokenInterceptor);\n httpClient.interceptors.request.use(refreshAccessTokenInterceptor);\n\n // Response interceptor: moves axios response error data into the error\n // object at error.customAttributes\n httpClient.interceptors.response.use(\n response => response,\n processAxiosRequestErrorInterceptor,\n );\n\n return httpClient;\n }\n}\n\nexport default AxiosJwtAuthService;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,oBAAT,QAAqC,SAArC;AACA,SAASC,eAAT,EAA0BC,mBAA1B,QAAqD,UAArD;AACA,OAAOC,iCAAP,MAA8C,kDAA9C;AACA,OAAOC,kCAAP,MAA+C,mDAA/C;AACA,OAAOC,yCAAP,MAAsD,0DAAtD;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEA,IAAMC,gBAAgB,GAAG;EACvBC,MAAM,EAAEX,SAAS,CAACY,KAAV,CAAgB;IACtBC,QAAQ,EAAEb,SAAS,CAACc,MAAV,CAAiBC,UADL;IAEtBC,YAAY,EAAEhB,SAAS,CAACc,MAAV,CAAiBC,UAFT;IAGtBE,SAAS,EAAEjB,SAAS,CAACc,MAAV,CAAiBC,UAHN;IAItBG,UAAU,EAAElB,SAAS,CAACc,MAAV,CAAiBC,UAJP;IAKtBI,6BAA6B,EAAEnB,SAAS,CAACc,MAAV,CAAiBC,UAL1B;IAMtBK,wBAAwB,EAAEpB,SAAS,CAACc,MAAV,CAAiBC,UANrB;IAOtBM,mBAAmB,EAAErB,SAAS,CAACc,MAAV,CAAiBC;EAPhB,CAAhB,EAQLA,UAToB;EAUvBO,cAAc,EAAEtB,SAAS,CAACY,KAAV,CAAgB;IAC9BW,QAAQ,EAAEvB,SAAS,CAACwB,IAAV,CAAeT,UADK;IAE9BU,OAAO,EAAEzB,SAAS,CAACwB,IAAV,CAAeT;EAFM,CAAhB,EAGbA;AAboB,CAAzB;AAgBA;AACA;AACA;AACA;;IACMW,mB;EACJ;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AR;UAAA,IAAgBC,YAAhB,GAAiCJ,kBAAjC,CAAgBI,YAAhB;UACA,IAAMC,sBAAsB,GAAG,CAAC,MAAD,EAAS,KAAT,EAAgB,OAAhB,EAAyB,QAAzB,CAA/B;UACA,OAAOD,YAAY,IAAI,CAACC,sBAAsB,CAACC,QAAvB,CAAgCH,MAAhC,CAAxB;QACD;MAPmE,CAAD,CAArE;MAUA,IAAMI,mCAAmC,GAAG5F,yCAAyC,CAAC;QACpFgB,cAAc,EAAE,KAAKA;MAD+D,CAAD,CAArF,CA7B2C,CAiC3C;MACA;MACA;MACA;;MACAO,UAAU,CAACsE,YAAX,CAAwBC,OAAxB,CAAgCC,GAAhC,CAAoCR,0BAApC;MACAhE,UAAU,CAACsE,YAAX,CAAwBC,OAAxB,CAAgCC,GAAhC,CAAoCZ,6BAApC,EAtC2C,CAwC3C;MACA;;MACA5D,UAAU,CAACsE,YAAX,CAAwBhB,QAAxB,CAAiCkB,GAAjC,CACE,UAAAlB,QAAQ;QAAA,OAAIA,QAAJ;MAAA,CADV,EAEEe,mCAFF;MAKA,OAAOrE,UAAP;IACD;;;;;;AAGH,eAAeH,mBAAf"}
1
+ {"version":3,"file":"AxiosJwtAuthService.js","names":["axios","PropTypes","logFrontendAuthError","camelCaseObject","ensureDefinedConfig","createJwtTokenProviderInterceptor","createCsrfTokenProviderInterceptor","createProcessAxiosRequestErrorInterceptor","AxiosJwtTokenService","AxiosCsrfTokenService","configureCache","optionsPropTypes","config","shape","BASE_URL","string","isRequired","LMS_BASE_URL","LOGIN_URL","LOGOUT_URL","REFRESH_ACCESS_TOKEN_ENDPOINT","ACCESS_TOKEN_COOKIE_NAME","CSRF_TOKEN_API_PATH","loggingService","logError","func","logInfo","AxiosJwtAuthService","options","authenticatedHttpClient","httpClient","cachedAuthenticatedHttpClient","cachedHttpClient","authenticatedUser","checkPropTypes","jwtTokenService","csrfTokenService","addAuthenticationToHttpClient","create","then","cachedAxiosClient","e","message","middleware","applyMiddleware","clients","forEach","middlewareFn","client","error","useCache","redirectUrl","encodeURIComponent","global","location","assign","getLoginRedirectUrl","getLogoutRedirectUrl","authUser","getJwtToken","forceRefresh","decodedAccessToken","setAuthenticatedUser","email","userId","user_id","username","preferred_username","roles","administrator","name","getAuthenticatedUser","fetchAuthenticatedUser","isRedirectFromLoginPage","document","referrer","startsWith","redirectLoopError","Error","redirectToLogin","unauthorizedError","isRedirecting","user","get","response","data","newHttpClient","Object","defaults","withCredentials","refreshAccessTokenInterceptor","shouldSkip","axiosRequestConfig","isPublic","attachCsrfTokenInterceptor","method","isCsrfExempt","CSRF_PROTECTED_METHODS","includes","processAxiosRequestErrorInterceptor","interceptors","request","use"],"sources":["../../src/auth/AxiosJwtAuthService.js"],"sourcesContent":["import axios from 'axios';\nimport PropTypes from 'prop-types';\nimport { logFrontendAuthError } from './utils';\nimport { camelCaseObject, ensureDefinedConfig } from '../utils';\nimport createJwtTokenProviderInterceptor from './interceptors/createJwtTokenProviderInterceptor';\nimport createCsrfTokenProviderInterceptor from './interceptors/createCsrfTokenProviderInterceptor';\nimport createProcessAxiosRequestErrorInterceptor from './interceptors/createProcessAxiosRequestErrorInterceptor';\nimport AxiosJwtTokenService from './AxiosJwtTokenService';\nimport AxiosCsrfTokenService from './AxiosCsrfTokenService';\nimport configureCache from './LocalForageCache';\n\nconst optionsPropTypes = {\n config: PropTypes.shape({\n BASE_URL: PropTypes.string.isRequired,\n LMS_BASE_URL: PropTypes.string.isRequired,\n LOGIN_URL: PropTypes.string.isRequired,\n LOGOUT_URL: PropTypes.string.isRequired,\n REFRESH_ACCESS_TOKEN_ENDPOINT: PropTypes.string.isRequired,\n ACCESS_TOKEN_COOKIE_NAME: PropTypes.string.isRequired,\n CSRF_TOKEN_API_PATH: PropTypes.string.isRequired,\n }).isRequired,\n loggingService: PropTypes.shape({\n logError: PropTypes.func.isRequired,\n logInfo: PropTypes.func.isRequired,\n }).isRequired,\n};\n\n/**\n * @implements {AuthService}\n * @memberof module:Auth\n */\nclass AxiosJwtAuthService {\n /**\n * @param {Object} options\n * @param {Object} options.config\n * @param {string} options.config.BASE_URL\n * @param {string} options.config.LMS_BASE_URL\n * @param {string} options.config.LOGIN_URL\n * @param {string} options.config.LOGOUT_URL\n * @param {string} options.config.REFRESH_ACCESS_TOKEN_ENDPOINT\n * @param {string} options.config.ACCESS_TOKEN_COOKIE_NAME\n * @param {string} options.config.CSRF_TOKEN_API_PATH\n * @param {Object} options.loggingService requires logError and logInfo methods\n */\n constructor(options) {\n this.authenticatedHttpClient = null;\n this.httpClient = null;\n this.cachedAuthenticatedHttpClient = null;\n this.cachedHttpClient = null;\n this.authenticatedUser = null;\n\n ensureDefinedConfig(options, 'AuthService');\n PropTypes.checkPropTypes(optionsPropTypes, options, 'options', 'AuthService');\n\n this.config = options.config;\n this.loggingService = options.loggingService;\n this.jwtTokenService = new AxiosJwtTokenService(\n this.loggingService,\n this.config.ACCESS_TOKEN_COOKIE_NAME,\n this.config.REFRESH_ACCESS_TOKEN_ENDPOINT,\n );\n this.csrfTokenService = new AxiosCsrfTokenService(this.config.CSRF_TOKEN_API_PATH);\n this.authenticatedHttpClient = this.addAuthenticationToHttpClient(axios.create());\n this.httpClient = axios.create();\n configureCache()\n .then((cachedAxiosClient) => {\n this.cachedAuthenticatedHttpClient = this.addAuthenticationToHttpClient(cachedAxiosClient);\n this.cachedHttpClient = cachedAxiosClient;\n })\n .catch((e) => {\n // fallback to non-cached HTTP clients and log error\n this.cachedAuthenticatedHttpClient = this.authenticatedHttpClient;\n this.cachedHttpClient = this.httpClient;\n logFrontendAuthError(this.loggingService, `configureCache failed with error: ${e.message}`);\n });\n\n this.middleware = options.middleware;\n this.applyMiddleware(options.middleware);\n }\n\n /**\n * Applies middleware to the axios instances in this service.\n *\n * @param {Array} middleware Middleware to apply.\n */\n applyMiddleware(middleware = []) {\n const clients = [\n this.authenticatedHttpClient, this.httpClient,\n this.cachedAuthenticatedHttpClient, this.cachedHttpClient,\n ];\n try {\n (middleware).forEach((middlewareFn) => {\n clients.forEach((client) => client && middlewareFn(client));\n });\n } catch (error) {\n logFrontendAuthError(this.loggingService, error);\n throw error;\n }\n }\n\n /**\n * Gets the authenticated HTTP client for the service. This is an axios instance.\n *\n * @param {Object} [options] Optional options for how the HTTP client should be configured.\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made\n * with the returned client.\n *\n * @returns {HttpClient} A configured axios http client which can be used for authenticated\n * requests.\n */\n getAuthenticatedHttpClient(options = {}) {\n if (options.useCache) {\n return this.cachedAuthenticatedHttpClient;\n }\n\n return this.authenticatedHttpClient;\n }\n\n /**\n * Gets the unauthenticated HTTP client for the service. This is an axios instance.\n *\n * @param {Object} [options] Optional options for how the HTTP client should be configured.\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made\n * with the returned client.\n * @returns {HttpClient} A configured axios http client.\n */\n getHttpClient(options = {}) {\n if (options.useCache) {\n return this.cachedHttpClient;\n }\n\n return this.httpClient;\n }\n\n /**\n * Used primarily for testing.\n *\n * @ignore\n */\n getJwtTokenService() {\n return this.jwtTokenService;\n }\n\n /**\n * Used primarily for testing.\n *\n * @ignore\n */\n getCsrfTokenService() {\n return this.csrfTokenService;\n }\n\n /**\n * Builds a URL to the login page with a post-login redirect URL attached as a query parameter.\n *\n * ```\n * const url = getLoginRedirectUrl('http://localhost/mypage');\n * console.log(url); // http://localhost/login?next=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging in.\n */\n getLoginRedirectUrl(redirectUrl = this.config.BASE_URL) {\n return `${this.config.LOGIN_URL}?next=${encodeURIComponent(redirectUrl)}`;\n }\n\n /**\n * Redirects the user to the login page.\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging in.\n */\n redirectToLogin(redirectUrl = this.config.BASE_URL) {\n global.location.assign(this.getLoginRedirectUrl(redirectUrl));\n }\n\n /**\n * Builds a URL to the logout page with a post-logout redirect URL attached as a query parameter.\n *\n * ```\n * const url = getLogoutRedirectUrl('http://localhost/mypage');\n * console.log(url); // http://localhost/logout?next=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\n getLogoutRedirectUrl(redirectUrl = this.config.BASE_URL) {\n return `${this.config.LOGOUT_URL}?redirect_url=${encodeURIComponent(redirectUrl)}`;\n }\n\n /**\n * Redirects the user to the logout page.\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\n redirectToLogout(redirectUrl = this.config.BASE_URL) {\n global.location.assign(this.getLogoutRedirectUrl(redirectUrl));\n }\n\n /**\n * If it exists, returns the user data representing the currently authenticated user. If the\n * user is anonymous, returns null.\n *\n * @returns {UserData|null}\n */\n getAuthenticatedUser() {\n return this.authenticatedUser;\n }\n\n /**\n * Sets the authenticated user to the provided value.\n *\n * @param {UserData} authUser\n */\n setAuthenticatedUser(authUser) {\n this.authenticatedUser = authUser;\n }\n\n /**\n * Reads the authenticated user's access token. Resolves to null if the user is\n * unauthenticated.\n *\n * @returns {Promise<UserData>|Promise<null>} Resolves to the user's access token if they are\n * logged in.\n */\n async fetchAuthenticatedUser(options = {}) {\n const decodedAccessToken = await this.jwtTokenService.getJwtToken(options.forceRefresh || false);\n\n if (decodedAccessToken !== null) {\n this.setAuthenticatedUser({\n email: decodedAccessToken.email,\n userId: decodedAccessToken.user_id,\n username: decodedAccessToken.preferred_username,\n roles: decodedAccessToken.roles || [],\n administrator: decodedAccessToken.administrator,\n name: decodedAccessToken.name,\n });\n } else {\n this.setAuthenticatedUser(null);\n }\n\n return this.getAuthenticatedUser();\n }\n\n /**\n * Ensures a user is authenticated. It will redirect to login when not\n * authenticated.\n *\n * @param {string} [redirectUrl=config.BASE_URL] to return user after login when not\n * authenticated.\n * @returns {Promise<UserData>}\n */\n async ensureAuthenticatedUser(redirectUrl = this.config.BASE_URL) {\n await this.fetchAuthenticatedUser();\n\n if (this.getAuthenticatedUser() === null) {\n const isRedirectFromLoginPage = global.document.referrer\n && global.document.referrer.startsWith(this.config.LOGIN_URL);\n\n if (isRedirectFromLoginPage) {\n const redirectLoopError = new Error('Redirect from login page. Rejecting to avoid infinite redirect loop.');\n logFrontendAuthError(this.loggingService, redirectLoopError);\n throw redirectLoopError;\n }\n\n // The user is not authenticated, send them to the login page.\n this.redirectToLogin(redirectUrl);\n\n const unauthorizedError = new Error('Failed to ensure the user is authenticated');\n unauthorizedError.isRedirecting = true;\n throw unauthorizedError;\n }\n\n return this.getAuthenticatedUser();\n }\n\n /**\n * Fetches additional user account information for the authenticated user and merges it into the\n * existing authenticatedUser object, available via getAuthenticatedUser().\n *\n * ```\n * console.log(authenticatedUser); // Will be sparse and only contain basic information.\n * await hydrateAuthenticatedUser()\n * const authenticatedUser = getAuthenticatedUser();\n * console.log(authenticatedUser); // Will contain additional user information\n * ```\n *\n * @returns {Promise<null>}\n */\n async hydrateAuthenticatedUser() {\n const user = this.getAuthenticatedUser();\n if (user !== null) {\n const response = await this.authenticatedHttpClient\n .get(`${this.config.LMS_BASE_URL}/api/user/v1/accounts/${user.username}`);\n this.setAuthenticatedUser({ ...user, ...camelCaseObject(response.data) });\n }\n }\n\n /**\n * Adds authentication defaults and interceptors to an HTTP client instance.\n *\n * @param {HttpClient} newHttpClient\n * @param {Object} config\n * @param {string} [config.REFRESH_ACCESS_TOKEN_ENDPOINT]\n * @param {string} [config.ACCESS_TOKEN_COOKIE_NAME]\n * @param {string} [config.CSRF_TOKEN_API_PATH]\n * @returns {HttpClient} A configured Axios HTTP client.\n */\n addAuthenticationToHttpClient(newHttpClient) {\n const httpClient = Object.create(newHttpClient);\n // Set withCredentials to true. Enables cross-site Access-Control requests\n // to be made using cookies, authorization headers or TLS client\n // certificates. More on MDN:\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials\n httpClient.defaults.withCredentials = true;\n\n // Axios interceptors\n\n // The JWT access token interceptor attempts to refresh the user's jwt token\n // before any request unless the isPublic flag is set on the request config.\n const refreshAccessTokenInterceptor = createJwtTokenProviderInterceptor({\n jwtTokenService: this.jwtTokenService,\n shouldSkip: axiosRequestConfig => axiosRequestConfig.isPublic,\n });\n // The CSRF token intercepter fetches and caches a csrf token for any post,\n // put, patch, or delete request. That token is then added to the request\n // headers.\n const attachCsrfTokenInterceptor = createCsrfTokenProviderInterceptor({\n csrfTokenService: this.csrfTokenService,\n CSRF_TOKEN_API_PATH: this.config.CSRF_TOKEN_API_PATH,\n shouldSkip: (axiosRequestConfig) => {\n const { method, isCsrfExempt } = axiosRequestConfig;\n const CSRF_PROTECTED_METHODS = ['post', 'put', 'patch', 'delete'];\n return isCsrfExempt || !CSRF_PROTECTED_METHODS.includes(method);\n },\n });\n\n const processAxiosRequestErrorInterceptor = createProcessAxiosRequestErrorInterceptor({\n loggingService: this.loggingService,\n });\n\n // Request interceptors: Axios runs the interceptors in reverse order from\n // how they are listed. After fetching csrf tokens no longer require jwt\n // authentication, it won't matter which happens first. This change is\n // coming soon in edx-platform. Nov. 2019\n httpClient.interceptors.request.use(attachCsrfTokenInterceptor);\n httpClient.interceptors.request.use(refreshAccessTokenInterceptor);\n\n // Response interceptor: moves axios response error data into the error\n // object at error.customAttributes\n httpClient.interceptors.response.use(\n response => response,\n processAxiosRequestErrorInterceptor,\n );\n\n return httpClient;\n }\n}\n\nexport default AxiosJwtAuthService;\n"],"mappings":";;;;;;;;+CACA,oJ;;;;;;;;;;;;AADA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,oBAAT,QAAqC,SAArC;AACA,SAASC,eAAT,EAA0BC,mBAA1B,QAAqD,UAArD;AACA,OAAOC,iCAAP,MAA8C,kDAA9C;AACA,OAAOC,kCAAP,MAA+C,mDAA/C;AACA,OAAOC,yCAAP,MAAsD,0DAAtD;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEA,IAAMC,gBAAgB,GA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CAAoCZ,6BAApC,EAtC2C,CAwC3C;MACA;;MACA5D,UAAU,CAACsE,YAAX,CAAwBhB,QAAxB,CAAiCkB,GAAjC,CACE,UAAAlB,QAAQ;QAAA,OAAIA,QAAJ;MAAA,CADV,EAEEe,mCAFF;MAKA,OAAOrE,UAAP;IACD;;;;;;AAGH,eAAeH,mBAAf"}
@@ -1,3 +1,7 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+
1
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
6
 
3
7
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -71,10 +75,10 @@ var AxiosJwtTokenService = /*#__PURE__*/function () {
71
75
 
72
76
  if (this.refreshRequestPromises[this.tokenCookieName] === undefined) {
73
77
  var makeRefreshRequest = /*#__PURE__*/function () {
74
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
78
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
75
79
  var axiosResponse, userIsUnauthenticated, _decodedJwtToken, browserEpochSeconds, browserDriftSeconds, decodedJwtToken, error;
76
80
 
77
- return regeneratorRuntime.wrap(function _callee$(_context) {
81
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
78
82
  while (1) {
79
83
  switch (_context.prev = _context.next) {
80
84
  case 0:
@@ -171,11 +175,11 @@ var AxiosJwtTokenService = /*#__PURE__*/function () {
171
175
  }, {
172
176
  key: "getJwtToken",
173
177
  value: function () {
174
- var _getJwtToken = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
178
+ var _getJwtToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
175
179
  var forceRefresh,
176
180
  decodedJwtToken,
177
181
  _args2 = arguments;
178
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
182
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
179
183
  while (1) {
180
184
  switch (_context2.prev = _context2.next) {
181
185
  case 0:
@@ -1 +1 @@
1
- {"version":3,"file":"AxiosJwtTokenService.js","names":["Cookies","jwtDecode","axios","logFrontendAuthError","processAxiosErrorAndThrow","createRetryInterceptor","AxiosJwtTokenService","loggingService","tokenCookieName","tokenRefreshEndpoint","httpClient","create","defaults","withCredentials","interceptors","response","use","cookies","refreshRequestPromises","cookieValue","get","e","error","Object","message","customAttributes","responseServerEpochSeconds","undefined","makeRefreshRequest","post","axiosResponse","data","response_epoch_seconds","userIsUnauthenticated","status","remove","decodedJwtToken","browserEpochSeconds","Date","now","browserDriftSeconds","Math","abs","decodeJwtCookie","Error","forceRefresh","isTokenExpired","refresh","token","exp"],"sources":["../../src/auth/AxiosJwtTokenService.js"],"sourcesContent":["import Cookies from 'universal-cookie';\nimport jwtDecode from 'jwt-decode';\nimport axios from 'axios';\nimport { logFrontendAuthError, processAxiosErrorAndThrow } from './utils';\nimport createRetryInterceptor from './interceptors/createRetryInterceptor';\n\nexport default class AxiosJwtTokenService {\n static isTokenExpired(token) {\n return !token || token.exp < Date.now() / 1000;\n }\n\n constructor(loggingService, tokenCookieName, tokenRefreshEndpoint) {\n this.loggingService = loggingService;\n this.tokenCookieName = tokenCookieName;\n this.tokenRefreshEndpoint = tokenRefreshEndpoint;\n\n this.httpClient = axios.create();\n // Set withCredentials to true. Enables cross-site Access-Control requests\n // to be made using cookies, authorization headers or TLS client\n // certificates. More on MDN:\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials\n this.httpClient.defaults.withCredentials = true;\n // Add retries to this axios instance\n this.httpClient.interceptors.response.use(\n response => response,\n createRetryInterceptor({ httpClient: this.httpClient }),\n );\n\n this.cookies = new Cookies();\n this.refreshRequestPromises = {};\n }\n\n getHttpClient() {\n return this.httpClient;\n }\n\n decodeJwtCookie() {\n const cookieValue = this.cookies.get(this.tokenCookieName);\n\n if (cookieValue) {\n try {\n return jwtDecode(cookieValue);\n } catch (e) {\n const error = Object.create(e);\n error.message = 'Error decoding JWT token';\n error.customAttributes = { cookieValue };\n throw error;\n }\n }\n\n return null;\n }\n\n refresh() {\n let responseServerEpochSeconds = 0;\n\n if (this.refreshRequestPromises[this.tokenCookieName] === undefined) {\n const makeRefreshRequest = async () => {\n let axiosResponse;\n try {\n try {\n axiosResponse = await this.httpClient.post(this.tokenRefreshEndpoint);\n // eslint-disable-next-line max-len\n if (axiosResponse.data && axiosResponse.data.response_epoch_seconds) {\n responseServerEpochSeconds = axiosResponse.data.response_epoch_seconds;\n }\n } catch (error) {\n processAxiosErrorAndThrow(error);\n }\n } catch (error) {\n const userIsUnauthenticated = error.response && error.response.status === 401;\n if (userIsUnauthenticated) {\n // Clean up the cookie if it exists to eliminate any situation\n // where the cookie is not expired but the jwt is expired.\n this.cookies.remove(this.tokenCookieName);\n const decodedJwtToken = null;\n return decodedJwtToken;\n }\n\n // TODO: Network timeouts and other problems will end up in\n // this block of code. We could add logic for retrying token\n // refreshes if we wanted to.\n throw error;\n }\n\n const browserEpochSeconds = Date.now() / 1000;\n const browserDriftSeconds = responseServerEpochSeconds > 0\n ? Math.abs(browserEpochSeconds - responseServerEpochSeconds)\n : null;\n\n const decodedJwtToken = this.decodeJwtCookie();\n\n if (!decodedJwtToken) {\n // This is an unexpected case. The refresh endpoint should set the\n // cookie that is needed.\n // For more details, see:\n // docs/decisions/0005-token-null-after-successful-refresh.rst\n const error = new Error('Access token is still null after successful refresh.');\n error.customAttributes = { axiosResponse, browserDriftSeconds, browserEpochSeconds };\n throw error;\n }\n\n return decodedJwtToken;\n };\n\n this.refreshRequestPromises[this.tokenCookieName] = makeRefreshRequest().finally(() => {\n delete this.refreshRequestPromises[this.tokenCookieName];\n });\n }\n\n return this.refreshRequestPromises[this.tokenCookieName];\n }\n\n async getJwtToken(forceRefresh = false) {\n try {\n const decodedJwtToken = this.decodeJwtCookie(this.tokenCookieName);\n if (!AxiosJwtTokenService.isTokenExpired(decodedJwtToken) && !forceRefresh) {\n return decodedJwtToken;\n }\n } catch (e) {\n // Log unexpected error and continue with attempt to refresh it.\n // TODO: Fix these. They're still using loggingService as a singleton.\n logFrontendAuthError(this.loggingService, e);\n }\n\n try {\n return await this.refresh();\n } catch (e) {\n // TODO: Fix these. They're still using loggingService as a singleton.\n logFrontendAuthError(this.loggingService, e);\n throw e;\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,OAAP,MAAoB,kBAApB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,oBAAT,EAA+BC,yBAA/B,QAAgE,SAAhE;AACA,OAAOC,sBAAP,MAAmC,uCAAnC;;IAEqBC,oB;EAKnB,8BAAYC,cAAZ,EAA4BC,eAA5B,EAA6CC,oBAA7C,EAAmE;IAAA;;IACjE,KAAKF,cAAL,GAAsBA,cAAtB;IACA,KAAKC,eAAL,GAAuBA,eAAvB;IACA,KAAKC,oBAAL,GAA4BA,oBAA5B;IAEA,KAAKC,UAAL,GAAkBR,KAAK,CAACS,MAAN,EAAlB,CALiE,CAMjE;IACA;IACA;IACA;;IACA,KAAKD,UAAL,CAAgBE,QAAhB,CAAyBC,eAAzB,GAA2C,IAA3C,CAViE,CAWjE;;IACA,KAAKH,UAAL,CAAgBI,YAAhB,CAA6BC,QAA7B,CAAsCC,GAAtC,CACE,UAAAD,QAAQ;MAAA,OAAIA,QAAJ;IAAA,CADV,EAEEV,sBAAsB,CAAC;MAAEK,UAAU,EAAE,KAAKA;IAAnB,CAAD,CAFxB;IAKA,KAAKO,OAAL,GAAe,IAAIjB,OAAJ,EAAf;IACA,KAAKkB,sBAAL,GAA8B,EAA9B;EACD;;;;WAED,yBAAgB;MACd,OAAO,KAAKR,UAAZ;IACD;;;WAED,2BAAkB;MAChB,IAAMS,WAAW,GAAG,KAAKF,OAAL,CAAaG,GAAb,CAAiB,KAAKZ,eAAtB,C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;gBAAA;gBAAA;gBAOI;gBACA;gBACAjC,oBAAoB,CAAC,KAAKI,cAAN,eAApB;;cATJ;gBAAA;gBAAA;gBAAA,OAaiB,KAAKwC,OAAL,EAbjB;;cAAA;gBAAA;;cAAA;gBAAA;gBAAA;gBAeI;gBACA5C,oBAAoB,CAAC,KAAKI,cAAN,eAApB;gBAhBJ;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;WA1GA,wBAAsByC,KAAtB,EAA6B;MAC3B,OAAO,CAACA,KAAD,IAAUA,KAAK,CAACC,GAAN,GAAYX,IAAI,CAACC,GAAL,KAAa,IAA1C;IACD;;;;;;SAHkBjC,oB"}
1
+ {"version":3,"file":"AxiosJwtTokenService.js","names":["Cookies","jwtDecode","axios","logFrontendAuthError","processAxiosErrorAndThrow","createRetryInterceptor","AxiosJwtTokenService","loggingService","tokenCookieName","tokenRefreshEndpoint","httpClient","create","defaults","withCredentials","interceptors","response","use","cookies","refreshRequestPromises","cookieValue","get","e","error","Object","message","customAttributes","responseServerEpochSeconds","undefined","makeRefreshRequest","post","axiosResponse","data","response_epoch_seconds","userIsUnauthenticated","status","remove","decodedJwtToken","browserEpochSeconds","Date","now","browserDriftSeconds","Math","abs","decodeJwtCookie","Error","forceRefresh","isTokenExpired","refresh","token","exp"],"sources":["../../src/auth/AxiosJwtTokenService.js"],"sourcesContent":["import Cookies from 'universal-cookie';\nimport jwtDecode from 'jwt-decode';\nimport axios from 'axios';\nimport { logFrontendAuthError, processAxiosErrorAndThrow } from './utils';\nimport createRetryInterceptor from './interceptors/createRetryInterceptor';\n\nexport default class AxiosJwtTokenService {\n static isTokenExpired(token) {\n return !token || token.exp < Date.now() / 1000;\n }\n\n constructor(loggingService, tokenCookieName, tokenRefreshEndpoint) {\n this.loggingService = loggingService;\n this.tokenCookieName = tokenCookieName;\n this.tokenRefreshEndpoint = tokenRefreshEndpoint;\n\n this.httpClient = axios.create();\n // Set withCredentials to true. Enables cross-site Access-Control requests\n // to be made using cookies, authorization headers or TLS client\n // certificates. More on MDN:\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials\n this.httpClient.defaults.withCredentials = true;\n // Add retries to this axios instance\n this.httpClient.interceptors.response.use(\n response => response,\n createRetryInterceptor({ httpClient: this.httpClient }),\n );\n\n this.cookies = new Cookies();\n this.refreshRequestPromises = {};\n }\n\n getHttpClient() {\n return this.httpClient;\n }\n\n decodeJwtCookie() {\n const cookieValue = this.cookies.get(this.tokenCookieName);\n\n if (cookieValue) {\n try {\n return jwtDecode(cookieValue);\n } catch (e) {\n const error = Object.create(e);\n error.message = 'Error decoding JWT token';\n error.customAttributes = { cookieValue };\n throw error;\n }\n }\n\n return null;\n }\n\n refresh() {\n let responseServerEpochSeconds = 0;\n\n if (this.refreshRequestPromises[this.tokenCookieName] === undefined) {\n const makeRefreshRequest = async () => {\n let axiosResponse;\n try {\n try {\n axiosResponse = await this.httpClient.post(this.tokenRefreshEndpoint);\n // eslint-disable-next-line max-len\n if (axiosResponse.data && axiosResponse.data.response_epoch_seconds) {\n responseServerEpochSeconds = axiosResponse.data.response_epoch_seconds;\n }\n } catch (error) {\n processAxiosErrorAndThrow(error);\n }\n } catch (error) {\n const userIsUnauthenticated = error.response && error.response.status === 401;\n if (userIsUnauthenticated) {\n // Clean up the cookie if it exists to eliminate any situation\n // where the cookie is not expired but the jwt is expired.\n this.cookies.remove(this.tokenCookieName);\n const decodedJwtToken = null;\n return decodedJwtToken;\n }\n\n // TODO: Network timeouts and other problems will end up in\n // this block of code. We could add logic for retrying token\n // refreshes if we wanted to.\n throw error;\n }\n\n const browserEpochSeconds = Date.now() / 1000;\n const browserDriftSeconds = responseServerEpochSeconds > 0\n ? Math.abs(browserEpochSeconds - responseServerEpochSeconds)\n : null;\n\n const decodedJwtToken = this.decodeJwtCookie();\n\n if (!decodedJwtToken) {\n // This is an unexpected case. The refresh endpoint should set the\n // cookie that is needed.\n // For more details, see:\n // docs/decisions/0005-token-null-after-successful-refresh.rst\n const error = new Error('Access token is still null after successful refresh.');\n error.customAttributes = { axiosResponse, browserDriftSeconds, browserEpochSeconds };\n throw error;\n }\n\n return decodedJwtToken;\n };\n\n this.refreshRequestPromises[this.tokenCookieName] = makeRefreshRequest().finally(() => {\n delete this.refreshRequestPromises[this.tokenCookieName];\n });\n }\n\n return this.refreshRequestPromises[this.tokenCookieName];\n }\n\n async getJwtToken(forceRefresh = false) {\n try {\n const decodedJwtToken = this.decodeJwtCookie(this.tokenCookieName);\n if (!AxiosJwtTokenService.isTokenExpired(decodedJwtToken) && !forceRefresh) {\n return decodedJwtToken;\n }\n } catch (e) {\n // Log unexpected error and continue with attempt to refresh it.\n // TODO: Fix these. They're still using loggingService as a singleton.\n logFrontendAuthError(this.loggingService, e);\n }\n\n try {\n return await this.refresh();\n } catch (e) {\n // TODO: Fix these. They're still using loggingService as a singleton.\n logFrontendAuthError(this.loggingService, e);\n throw e;\n }\n }\n}\n"],"mappings":";;+CACA,oJ;;;;;;;;;;;;AADA,OAAOA,OAAP,MAAoB,kBAApB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAASC,oBAAT,EAA+BC,yBAA/B,QAAgE,SAAhE;AACA,OAAOC,sBAAP,MAAmC,uCAAnC;;IAEqBC,oB;EAKnB,8BAAYC,cAAZ,EAA4BC,eAA5B,EAA6CC,oBAA7C,EAAmE;IAAA;;IACjE,KAAKF,cAAL,GAAsBA,cAAtB;IACA,KAAKC,eAAL,GAAuBA,eAAvB;IACA,KAAKC,oBAAL,GAA4BA,oBAA5B;IAEA,KAAKC,UAAL,GAAkBR,KAAK,CAACS,MAAN,EAAlB,CALiE,CAMjE;IACA;IACA;IACA;;IACA,KAAKD,UAAL,CAAgBE,QAAhB,CAAyBC,eAAzB,GAA2C,IAA3C,CAViE,CAWjE;;IACA,KAAKH,UAAL,CAAgBI,YAAhB,CAA6BC,QAA7B,CAAsCC,GAAtC,CACE,UAAA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V,eAAjC,CAAP;IACD;;;;oFAED;QAAA;QAAA;QAAA;QAAA;UAAA;YAAA;cAAA;gBAAkBqC,YAAlB,8DAAiC,KAAjC;gBAAA;gBAEUT,eAFV,GAE4B,KAAKO,eAAL,CAAqB,KAAKnC,eAA1B,CAF5B;;gBAAA,MAGQ,CAACF,oBAAoB,CAACwC,cAArB,CAAoCV,eAApC,CAAD,IAAyD,CAACS,YAHlE;kBAAA;kBAAA;gBAAA;;gBAAA,kCAIaT,eAJb;;cAAA;gBAAA;gBAAA;;cAAA;gBAAA;gBAAA;gBAOI;gBACA;gBACAjC,oBAAoB,CAAC,KAAKI,cAAN,eAApB;;cATJ;gBAAA;gBAAA;gBAAA,OAaiB,KAAKwC,OAAL,EAbjB;;cAAA;gBAAA;;cAAA;gBAAA;gBAAA;gBAeI;gBACA5C,oBAAoB,CAAC,KAAKI,cAAN,eAApB;gBAhBJ;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;WA1GA,wBAAsByC,KAAtB,EAA6B;MAC3B,OAAO,CAACA,KAAD,IAAUA,KAAK,CAACC,GAAN,GAAYX,IAAI,CAACC,GAAL,KAAa,IAA1C;IACD;;;;;;SAHkBjC,oB"}
@@ -1,3 +1,7 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+
1
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
6
 
3
7
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -18,9 +22,9 @@ export default function configureCache() {
18
22
  }
19
23
 
20
24
  function _configureCache() {
21
- _configureCache = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
25
+ _configureCache = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
22
26
  var forageStore;
23
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
27
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
24
28
  while (1) {
25
29
  switch (_context2.prev = _context2.next) {
26
30
  case 0:
@@ -43,8 +47,8 @@ function _configureCache() {
43
47
  query: false
44
48
  },
45
49
  invalidate: function () {
46
- var _invalidate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(config, request) {
47
- return regeneratorRuntime.wrap(function _callee$(_context) {
50
+ var _invalidate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, request) {
51
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
48
52
  while (1) {
49
53
  switch (_context.prev = _context.next) {
50
54
  case 0:
@@ -1 +1 @@
1
- {"version":3,"file":"LocalForageCache.js","names":["localforage","memoryDriver","setup","configureCache","defineDriver","forageStore","createInstance","driver","INDEXEDDB","LOCALSTORAGE","_driver","name","cache","maxAge","store","exclude","query","invalidate","config","request","clearCacheEntry","removeItem","uuid"],"sources":["../../src/auth/LocalForageCache.js"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\nimport localforage from 'localforage';\nimport memoryDriver from 'localforage-memoryStorageDriver';\nimport { setup } from 'axios-cache-adapter';\n\n/**\n * Async function to configure localforage and setup the cache\n *\n * @returns {Promise} A promise that, when resolved, returns an axios instance configured to\n * use localforage as a cache.\n */\nexport default async function configureCache() {\n // Register the imported `memoryDriver` to `localforage`\n await localforage.defineDriver(memoryDriver);\n\n // Create `localforage` instance\n const forageStore = localforage.createInstance({\n // List of drivers used\n driver: [\n localforage.INDEXEDDB,\n localforage.LOCALSTORAGE,\n memoryDriver._driver,\n ],\n name: 'edx-cache',\n });\n\n // Set up the cache with a default maxAge of 5 minutes and using localforage as the storage source\n return setup({\n cache: {\n maxAge: 5 * 60 * 1000,\n store: forageStore,\n exclude: { query: false },\n invalidate: async (config, request) => {\n if (request.clearCacheEntry) {\n await config.store.removeItem(config.uuid);\n }\n },\n },\n });\n}\n"],"mappings":";;;;AAAA;AACA,OAAOA,WAAP,MAAwB,aAAxB;AACA,OAAOC,YAAP,MAAyB,iCAAzB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,wBAA8BC,cAA9B;EAAA;AAAA;;;4EAAe;IAAA;IAAA;MAAA;QAAA;UAAA;YAAA;YAAA,OAEPH,WAAW,CAACI,YAAZ,CAAyBH,YAAzB,CAFO;;UAAA;YAIb;YACMI,WALO,GAKOL,WAAW,CAACM,cAAZ,CAA2B;cAC7C;cACAC,MAAM,EAAE,CACNP,WAAW,CAACQ,SADN,EAENR,WAAW,CAACS,YAFN,EAGNR,YAAY,CAACS,OAHP,CAFqC;cAO7CC,IAAI,EAAE;YAPuC,CAA3B,CALP,EAeb;;YAfa,kCAgBNT,KAAK,CAAC;cACXU,KAAK,EAAE;gBACLC,MAAM,EAAE,IAAI,EAAJ,GAAS,IADZ;gBAELC,KAAK,EAAET,WAFF;gBAGLU,OAAO,EAAE;kBAAEC,KAAK,EAAE;gBAAT,CAHJ;gBAILC,UAAU;kBAAA,0EAAE,iBAAOC,MAAP,EAAeC,OAAf;oBAAA;sBAAA;wBAAA;0BAAA;4BAAA,KACNA,OAAO,CAACC,eADF;8BAAA;8BAAA;4BAAA;;4BAAA;4BAAA,OAEFF,MAAM,CAACJ,KAAP,CAAaO,UAAb,CAAwBH,MAAM,CAACI,IAA/B,CAFE;;0BAAA;0BAAA;4BAAA;wBAAA;sBAAA;oBAAA;kBAAA,CAAF;;kBAAA;oBAAA;kBAAA;;kBAAA;gBAAA;cAJL;YADI,CAAD,CAhBC;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C"}
1
+ {"version":3,"file":"LocalForageCache.js","names":["localforage","memoryDriver","setup","configureCache","defineDriver","forageStore","createInstance","driver","INDEXEDDB","LOCALSTORAGE","_driver","name","cache","maxAge","store","exclude","query","invalidate","config","request","clearCacheEntry","removeItem","uuid"],"sources":["../../src/auth/LocalForageCache.js"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\nimport localforage from 'localforage';\nimport memoryDriver from 'localforage-memoryStorageDriver';\nimport { setup } from 'axios-cache-adapter';\n\n/**\n * Async function to configure localforage and setup the cache\n *\n * @returns {Promise} A promise that, when resolved, returns an axios instance configured to\n * use localforage as a cache.\n */\nexport default async function configureCache() {\n // Register the imported `memoryDriver` to `localforage`\n await localforage.defineDriver(memoryDriver);\n\n // Create `localforage` instance\n const forageStore = localforage.createInstance({\n // List of drivers used\n driver: [\n localforage.INDEXEDDB,\n localforage.LOCALSTORAGE,\n memoryDriver._driver,\n ],\n name: 'edx-cache',\n });\n\n // Set up the cache with a default maxAge of 5 minutes and using localforage as the storage source\n return setup({\n cache: {\n maxAge: 5 * 60 * 1000,\n store: forageStore,\n exclude: { query: false },\n invalidate: async (config, request) => {\n if (request.clearCacheEntry) {\n await config.store.removeItem(config.uuid);\n }\n },\n },\n });\n}\n"],"mappings":";;+CACA,oJ;;;;;;AADA;AACA,OAAOA,WAAP,MAAwB,aAAxB;AACA,OAAOC,YAAP,MAAyB,iCAAzB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,wBAA8BC,cAA9B;EAAA;AAAA;;;+EAAe;IAAA;IAAA;MAAA;QAAA;UAAA;YAAA;YAAA,OAEPH,WAAW,CAACI,YAAZ,CAAyBH,YAAzB,CAFO;;UAAA;YAIb;YACMI,WALO,GAKOL,WAAW,CAACM,cAAZ,CAA2B;cAC7C;cACAC,MAAM,EAAE,CACNP,WAAW,CAACQ,SADN,EAENR,WAAW,CAACS,YAFN,EAGNR,YAAY,CAACS,OAHP,CAFqC;cAO7CC,IAAI,EAAE;YAPuC,CAA3B,CALP,EAeb;;YAfa,kCAgBNT,KAAK,CAAC;cACXU,KAAK,EAAE;gBACLC,MAAM,EAAE,IAAI,EAAJ,GAAS,IADZ;gBAELC,KAAK,EAAET,WAFF;gBAGLU,OAAO,EAAE;kBAAEC,KAAK,EAAE;gBAAT,CAHJ;gBAILC,UAAU;kBAAA,6EAAE,iBAAOC,MAAP,EAAeC,OAAf;oBAAA;sBAAA;wBAAA;0BAAA;4BAAA,KACNA,OAAO,CAACC,eADF;8BAAA;8BAAA;4BAAA;;4BAAA;4BAAA,OAEFF,MAAM,CAACJ,KAAP,CAAaO,UAAb,CAAwBH,MAAM,CAACI,IAA/B,CAFE;;0BAAA;0BAAA;4BAAA;wBAAA;sBAAA;oBAAA;kBAAA,CAAF;;kBAAA;oBAAA;kBAAA;;kBAAA;gBAAA;cAJL;YADI,CAAD,CAhBC;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"MockAuthService.js","names":["axios","PropTypes","ensureDefinedConfig","userPropTypes","shape","userId","string","isRequired","username","roles","arrayOf","administrator","optionsPropTypes","config","BASE_URL","LMS_BASE_URL","LOGIN_URL","LOGOUT_URL","REFRESH_ACCESS_TOKEN_ENDPOINT","ACCESS_TOKEN_COOKIE_NAME","CSRF_TOKEN_API_PATH","loggingService","logError","func","logInfo","authenticatedUser","hydratedAuthenticatedUser","MockAuthService","options","jest","fn","authenticatedHttpClient","httpClient","redirectUrl","encodeURIComponent","getLoginRedirectUrl","getLogoutRedirectUrl","authUser","getAuthenticatedUser","fetchAuthenticatedUser","redirectToLogin","user","setAuthenticatedUser","checkPropTypes","create","middleware","clients","cachedAuthenticatedHttpClient","cachedHttpClient","forEach","middlewareFn","client","error","Error","message"],"sources":["../../src/auth/MockAuthService.js"],"sourcesContent":["import axios from 'axios';\nimport PropTypes from 'prop-types';\nimport { ensureDefinedConfig } from '../utils';\n\nconst userPropTypes = PropTypes.shape({\n userId: PropTypes.string.isRequired,\n username: PropTypes.string.isRequired,\n roles: PropTypes.arrayOf(PropTypes.string),\n administrator: PropTypes.boolean,\n});\n\nconst optionsPropTypes = {\n config: PropTypes.shape({\n BASE_URL: PropTypes.string.isRequired,\n LMS_BASE_URL: PropTypes.string.isRequired,\n LOGIN_URL: PropTypes.string.isRequired,\n LOGOUT_URL: PropTypes.string.isRequired,\n REFRESH_ACCESS_TOKEN_ENDPOINT: PropTypes.string.isRequired,\n ACCESS_TOKEN_COOKIE_NAME: PropTypes.string.isRequired,\n CSRF_TOKEN_API_PATH: PropTypes.string.isRequired,\n }).isRequired,\n loggingService: PropTypes.shape({\n logError: PropTypes.func.isRequired,\n logInfo: PropTypes.func.isRequired,\n }).isRequired,\n // The absence of authenticatedUser means the user is anonymous.\n authenticatedUser: userPropTypes,\n // Must be at least a valid user, but may have other fields.\n hydratedAuthenticatedUser: userPropTypes,\n};\n\n/**\n * The MockAuthService class mocks authenticated user-fetching logic and allows for manually\n * setting user data. It is compatible with axios-mock-adapter to wrap its HttpClients so that\n * they can be mocked for testing.\n *\n * It wraps all methods of the service with Jest mock functions (jest.fn()). This allows test code\n * to assert expectations on all functions of the service while preserving sensible behaviors. For\n * instance, the login/logout methods related to redirecting maintain their real behavior.\n *\n * This service is NOT suitable for use in an application itself - only tests. It depends on Jest,\n * which should only be a dev dependency of your project. You don't want to pull the entire suite\n * of test dependencies into your application at runtime, probably even in your dev server.\n *\n * In a test where you would like to mock out API requests - perhaps from a redux-thunk function -\n * you could do the following to set up a MockAuthService for your test:\n *\n * ```\n * import { getConfig, mergeConfig } from '@edx/frontend-platform';\n * import { configure, MockAuthService } from '@edx/frontend-platform/auth';\n * import MockAdapter from 'axios-mock-adapter';\n *\n * const mockLoggingService = {\n * logInfo: jest.fn(),\n * logError: jest.fn(),\n * };\n * mergeConfig({\n * authenticatedUser: {\n * userId: 'abc123',\n * username: 'Mock User',\n * roles: [],\n * administrator: false,\n * },\n * });\n * configure(MockAuthService, { config: getConfig(), loggingService: mockLoggingService });\n * const mockAdapter = new MockAdapter(getAuthenticatedHttpClient());\n * // Mock calls for your tests. This configuration can be done in any sort of test setup.\n * mockAdapter.onGet(...);\n * ```\n *\n * Also see the `initializeMockApp` function which also automatically uses mock services for\n * Logging and Analytics.\n *\n * @implements {AuthService}\n * @memberof module:Auth\n */\nclass MockAuthService {\n /**\n * @param {Object} options\n * @param {Object} options.config\n * @param {string} options.config.BASE_URL\n * @param {string} options.config.LMS_BASE_URL\n * @param {string} options.config.LOGIN_URL\n * @param {string} options.config.LOGOUT_URL\n * @param {string} options.config.REFRESH_ACCESS_TOKEN_ENDPOINT\n * @param {string} options.config.ACCESS_TOKEN_COOKIE_NAME\n * @param {string} options.config.CSRF_TOKEN_API_PATH\n * @param {Object} options.config.hydratedAuthenticatedUser\n * @param {Object} options.config.authenticatedUser\n * @param {Object} options.loggingService requires logError and logInfo methods\n */\n constructor(options) {\n this.authenticatedHttpClient = null;\n this.httpClient = null;\n\n ensureDefinedConfig(options, 'AuthService');\n PropTypes.checkPropTypes(optionsPropTypes, options, 'options', 'AuthService');\n\n this.config = options.config;\n this.loggingService = options.loggingService;\n\n // Mock user\n this.authenticatedUser = this.config.authenticatedUser ? this.config.authenticatedUser : null;\n this.hydratedAuthenticatedUser = this.config.hydratedAuthenticatedUser\n ? this.config.hydratedAuthenticatedUser\n : {};\n\n this.authenticatedHttpClient = axios.create();\n this.httpClient = axios.create();\n }\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Applies middleware to the axios instances in this service.\n *\n * @param {Array} middleware Middleware to apply.\n */\n applyMiddleware(middleware = []) {\n const clients = [\n this.authenticatedHttpClient, this.httpClient,\n this.cachedAuthenticatedHttpClient, this.cachedHttpClient,\n ];\n try {\n (middleware).forEach((middlewareFn) => {\n clients.forEach((client) => client && middlewareFn(client));\n });\n } catch (error) {\n throw new Error(`Failed to apply middleware: ${error.message}.`);\n }\n }\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Gets the authenticated HTTP client instance, which is an axios client wrapped in\n * MockAdapter from axios-mock-adapter.\n *\n * @returns {HttpClient} An HttpClient wrapped in MockAdapter.\n */\n getAuthenticatedHttpClient = jest.fn(() => this.authenticatedHttpClient);\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Gets the unauthenticated HTTP client instance, which is an axios client wrapped in\n * MockAdapter from axios-mock-adapter.\n *\n * @returns {HttpClient} An HttpClient wrapped in MockAdapter.\n */\n getHttpClient = jest.fn(() => this.httpClient);\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Builds a URL to the login page with a post-login redirect URL attached as a query parameter.\n *\n * ```\n * const url = getLoginRedirectUrl('http://localhost/mypage');\n * console.log(url); // http://localhost/login?next=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging in.\n */\n getLoginRedirectUrl = jest.fn(\n (redirectUrl = this.config.BASE_URL) => `${this.config.LOGIN_URL}?next=${encodeURIComponent(redirectUrl)}`,\n );\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Redirects the user to the logout page in the real implementation. Is a no-op here.\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging in.\n */\n redirectToLogin = jest.fn((redirectUrl = this.config.BASE_URL) => {\n // Do nothing after getting the URL - this preserves the calls properly, but doesn't redirect.\n this.getLoginRedirectUrl(redirectUrl);\n });\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Builds a URL to the logout page with a post-logout redirect URL attached as a query parameter.\n *\n * ```\n * const url = getLogoutRedirectUrl('http://localhost/mypage');\n * console.log(url); // http://localhost/logout?next=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\n getLogoutRedirectUrl = jest.fn((redirectUrl = this.config.BASE_URL) => `${this.config.LOGOUT_URL}?redirect_url=${encodeURIComponent(redirectUrl)}`);\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Redirects the user to the logout page in the real implementation. Is a no-op here.\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\n redirectToLogout = jest.fn((redirectUrl = this.config.BASE_URL) => {\n // Do nothing after getting the URL - this preserves the calls properly, but doesn't redirect.\n this.getLogoutRedirectUrl(redirectUrl);\n });\n\n /**\n * A Jest mock function (jest.fn())\n *\n * If it exists, returns the user data representing the currently authenticated user. If the\n * user is anonymous, returns null.\n *\n * @returns {UserData|null}\n */\n getAuthenticatedUser = jest.fn(() => this.authenticatedUser);\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Sets the authenticated user to the provided value.\n *\n * @param {UserData} authUser\n */\n setAuthenticatedUser = jest.fn((authUser) => {\n this.authenticatedUser = authUser;\n });\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Returns the current authenticated user details, as supplied in the `authenticatedUser` field\n * of the config options. Resolves to null if the user is unauthenticated / the config option\n * has not been set.\n *\n * @returns {UserData|null} Resolves to the user's access token if they are\n * logged in.\n */\n fetchAuthenticatedUser = jest.fn(() => this.getAuthenticatedUser());\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Ensures a user is authenticated. It will redirect to login when not authenticated.\n *\n * @param {string} [redirectUrl=config.BASE_URL] to return user after login when not\n * authenticated.\n * @returns {UserData|null} Resolves to the user's access token if they are\n * logged in.\n */\n ensureAuthenticatedUser = jest.fn((redirectUrl = this.config.BASE_URL) => {\n this.fetchAuthenticatedUser();\n\n if (this.getAuthenticatedUser() === null) {\n // The user is not authenticated, send them to the login page.\n this.redirectToLogin(redirectUrl);\n }\n\n return this.getAuthenticatedUser();\n })\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Adds the user data supplied in the `hydratedAuthenticatedUser` config option into the object\n * returned by `getAuthenticatedUser`. This emulates the behavior of a real auth service which\n * would make a request to fetch this data prior to merging it in.\n *\n * ```\n * console.log(authenticatedUser); // Will be sparse and only contain basic information.\n * await hydrateAuthenticatedUser()\n * const authenticatedUser = getAuthenticatedUser();\n * console.log(authenticatedUser); // Will contain additional user information\n * ```\n *\n * @returns {Promise<null>}\n */\n hydrateAuthenticatedUser = jest.fn(() => {\n const user = this.getAuthenticatedUser();\n if (user !== null) {\n this.setAuthenticatedUser({ ...user, ...this.hydratedAuthenticatedUser });\n }\n });\n}\n\nexport default MockAuthService;\n"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB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MAAL,CAAYa,yBAAZ,GAC7B,KAAKb,MAAL,CAAYa,yBADiB,GAE7B,EAFJ;IAIA,KAAKK,uBAAL,GAA+B/B,KAAK,CAAC4C,MAAN,EAA/B;IACA,KAAKZ,UAAL,GAAkBhC,KAAK,CAAC4C,MAAN,EAAlB;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;;;;;WACE,2BAAiC;MAAA,IAAjBC,UAAiB,uEAAJ,EAAI;MAC/B,IAAMC,OAAO,GAAG,CACd,KAAKf,uBADS,EACgB,KAAKC,UADrB,EAEd,KAAKe,6BAFS,EAEsB,KAAKC,gBAF3B,CAAhB;;MAIA,IAAI;QACDH,UAAD,CAAaI,OAAb,CAAqB,UAACC,YAAD,EAAkB;UACrCJ,OAAO,CAACG,OAAR,CAAgB,UAACE,MAAD;YAAA,OAAYA,MAAM,IAAID,YAAY,CAACC,MAAD,CAAlC;UAAA,CAAhB;QACD,CAFD;MAGD,CAJD,CAIE,OAAOC,KAAP,EAAc;QACd,MAAM,IAAIC,KAAJ,uCAAyCD,KAAK,CAACE,OAA/C,OAAN;MACD;IACF;IAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AAiJA,eAAe3B,eAAf"}
1
+ {"version":3,"file":"MockAuthService.js","names":["axios","PropTypes","ensureDefinedConfig","userPropTypes","shape","userId","string","isRequired","username","roles","arrayOf","administrator","optionsPropTypes","config","BASE_URL","LMS_BASE_URL","LOGIN_URL","LOGOUT_URL","REFRESH_ACCESS_TOKEN_ENDPOINT","ACCESS_TOKEN_COOKIE_NAME","CSRF_TOKEN_API_PATH","loggingService","logError","func","logInfo","authenticatedUser","hydratedAuthenticatedUser","MockAuthService","options","jest","fn","authenticatedHttpClient","httpClient","redirectUrl","encodeURIComponent","getLoginRedirectUrl","getLogoutRedirectUrl","authUser","getAuthenticatedUser","fetchAuthenticatedUser","redirectToLogin","user","setAuthenticatedUser","checkPropTypes","create","middleware","clients","cachedAuthenticatedHttpClient","cachedHttpClient","forEach","middlewareFn","client","error","Error","message"],"sources":["../../src/auth/MockAuthService.js"],"sourcesContent":["import axios from 'axios';\nimport PropTypes from 'prop-types';\nimport { ensureDefinedConfig } from '../utils';\n\nconst userPropTypes = PropTypes.shape({\n userId: PropTypes.string.isRequired,\n username: PropTypes.string.isRequired,\n roles: PropTypes.arrayOf(PropTypes.string),\n administrator: PropTypes.boolean,\n});\n\nconst optionsPropTypes = {\n config: PropTypes.shape({\n BASE_URL: PropTypes.string.isRequired,\n LMS_BASE_URL: PropTypes.string.isRequired,\n LOGIN_URL: PropTypes.string.isRequired,\n LOGOUT_URL: PropTypes.string.isRequired,\n REFRESH_ACCESS_TOKEN_ENDPOINT: PropTypes.string.isRequired,\n ACCESS_TOKEN_COOKIE_NAME: PropTypes.string.isRequired,\n CSRF_TOKEN_API_PATH: PropTypes.string.isRequired,\n }).isRequired,\n loggingService: PropTypes.shape({\n logError: PropTypes.func.isRequired,\n logInfo: PropTypes.func.isRequired,\n }).isRequired,\n // The absence of authenticatedUser means the user is anonymous.\n authenticatedUser: userPropTypes,\n // Must be at least a valid user, but may have other fields.\n hydratedAuthenticatedUser: userPropTypes,\n};\n\n/**\n * The MockAuthService class mocks authenticated user-fetching logic and allows for manually\n * setting user data. It is compatible with axios-mock-adapter to wrap its HttpClients so that\n * they can be mocked for testing.\n *\n * It wraps all methods of the service with Jest mock functions (jest.fn()). This allows test code\n * to assert expectations on all functions of the service while preserving sensible behaviors. For\n * instance, the login/logout methods related to redirecting maintain their real behavior.\n *\n * This service is NOT suitable for use in an application itself - only tests. It depends on Jest,\n * which should only be a dev dependency of your project. You don't want to pull the entire suite\n * of test dependencies into your application at runtime, probably even in your dev server.\n *\n * In a test where you would like to mock out API requests - perhaps from a redux-thunk function -\n * you could do the following to set up a MockAuthService for your test:\n *\n * ```\n * import { getConfig, mergeConfig } from '@edx/frontend-platform';\n * import { configure, MockAuthService } from '@edx/frontend-platform/auth';\n * import MockAdapter from 'axios-mock-adapter';\n *\n * const mockLoggingService = {\n * logInfo: jest.fn(),\n * logError: jest.fn(),\n * };\n * mergeConfig({\n * authenticatedUser: {\n * userId: 'abc123',\n * username: 'Mock User',\n * roles: [],\n * administrator: false,\n * },\n * });\n * configure(MockAuthService, { config: getConfig(), loggingService: mockLoggingService });\n * const mockAdapter = new MockAdapter(getAuthenticatedHttpClient());\n * // Mock calls for your tests. This configuration can be done in any sort of test setup.\n * mockAdapter.onGet(...);\n * ```\n *\n * Also see the `initializeMockApp` function which also automatically uses mock services for\n * Logging and Analytics.\n *\n * @implements {AuthService}\n * @memberof module:Auth\n */\nclass MockAuthService {\n /**\n * @param {Object} options\n * @param {Object} options.config\n * @param {string} options.config.BASE_URL\n * @param {string} options.config.LMS_BASE_URL\n * @param {string} options.config.LOGIN_URL\n * @param {string} options.config.LOGOUT_URL\n * @param {string} options.config.REFRESH_ACCESS_TOKEN_ENDPOINT\n * @param {string} options.config.ACCESS_TOKEN_COOKIE_NAME\n * @param {string} options.config.CSRF_TOKEN_API_PATH\n * @param {Object} options.config.hydratedAuthenticatedUser\n * @param {Object} options.config.authenticatedUser\n * @param {Object} options.loggingService requires logError and logInfo methods\n */\n constructor(options) {\n this.authenticatedHttpClient = null;\n this.httpClient = null;\n\n ensureDefinedConfig(options, 'AuthService');\n PropTypes.checkPropTypes(optionsPropTypes, options, 'options', 'AuthService');\n\n this.config = options.config;\n this.loggingService = options.loggingService;\n\n // Mock user\n this.authenticatedUser = this.config.authenticatedUser ? this.config.authenticatedUser : null;\n this.hydratedAuthenticatedUser = this.config.hydratedAuthenticatedUser\n ? this.config.hydratedAuthenticatedUser\n : {};\n\n this.authenticatedHttpClient = axios.create();\n this.httpClient = axios.create();\n }\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Applies middleware to the axios instances in this service.\n *\n * @param {Array} middleware Middleware to apply.\n */\n applyMiddleware(middleware = []) {\n const clients = [\n this.authenticatedHttpClient, this.httpClient,\n this.cachedAuthenticatedHttpClient, this.cachedHttpClient,\n ];\n try {\n (middleware).forEach((middlewareFn) => {\n clients.forEach((client) => client && middlewareFn(client));\n });\n } catch (error) {\n throw new Error(`Failed to apply middleware: ${error.message}.`);\n }\n }\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Gets the authenticated HTTP client instance, which is an axios client wrapped in\n * MockAdapter from axios-mock-adapter.\n *\n * @returns {HttpClient} An HttpClient wrapped in MockAdapter.\n */\n getAuthenticatedHttpClient = jest.fn(() => this.authenticatedHttpClient);\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Gets the unauthenticated HTTP client instance, which is an axios client wrapped in\n * MockAdapter from axios-mock-adapter.\n *\n * @returns {HttpClient} An HttpClient wrapped in MockAdapter.\n */\n getHttpClient = jest.fn(() => this.httpClient);\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Builds a URL to the login page with a post-login redirect URL attached as a query parameter.\n *\n * ```\n * const url = getLoginRedirectUrl('http://localhost/mypage');\n * console.log(url); // http://localhost/login?next=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging in.\n */\n getLoginRedirectUrl = jest.fn(\n (redirectUrl = this.config.BASE_URL) => `${this.config.LOGIN_URL}?next=${encodeURIComponent(redirectUrl)}`,\n );\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Redirects the user to the logout page in the real implementation. Is a no-op here.\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging in.\n */\n redirectToLogin = jest.fn((redirectUrl = this.config.BASE_URL) => {\n // Do nothing after getting the URL - this preserves the calls properly, but doesn't redirect.\n this.getLoginRedirectUrl(redirectUrl);\n });\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Builds a URL to the logout page with a post-logout redirect URL attached as a query parameter.\n *\n * ```\n * const url = getLogoutRedirectUrl('http://localhost/mypage');\n * console.log(url); // http://localhost/logout?next=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\n getLogoutRedirectUrl = jest.fn((redirectUrl = this.config.BASE_URL) => `${this.config.LOGOUT_URL}?redirect_url=${encodeURIComponent(redirectUrl)}`);\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Redirects the user to the logout page in the real implementation. Is a no-op here.\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\n redirectToLogout = jest.fn((redirectUrl = this.config.BASE_URL) => {\n // Do nothing after getting the URL - this preserves the calls properly, but doesn't redirect.\n this.getLogoutRedirectUrl(redirectUrl);\n });\n\n /**\n * A Jest mock function (jest.fn())\n *\n * If it exists, returns the user data representing the currently authenticated user. If the\n * user is anonymous, returns null.\n *\n * @returns {UserData|null}\n */\n getAuthenticatedUser = jest.fn(() => this.authenticatedUser);\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Sets the authenticated user to the provided value.\n *\n * @param {UserData} authUser\n */\n setAuthenticatedUser = jest.fn((authUser) => {\n this.authenticatedUser = authUser;\n });\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Returns the current authenticated user details, as supplied in the `authenticatedUser` field\n * of the config options. Resolves to null if the user is unauthenticated / the config option\n * has not been set.\n *\n * @returns {UserData|null} Resolves to the user's access token if they are\n * logged in.\n */\n fetchAuthenticatedUser = jest.fn(() => this.getAuthenticatedUser());\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Ensures a user is authenticated. It will redirect to login when not authenticated.\n *\n * @param {string} [redirectUrl=config.BASE_URL] to return user after login when not\n * authenticated.\n * @returns {UserData|null} Resolves to the user's access token if they are\n * logged in.\n */\n ensureAuthenticatedUser = jest.fn((redirectUrl = this.config.BASE_URL) => {\n this.fetchAuthenticatedUser();\n\n if (this.getAuthenticatedUser() === null) {\n // The user is not authenticated, send them to the login page.\n this.redirectToLogin(redirectUrl);\n }\n\n return this.getAuthenticatedUser();\n });\n\n /**\n * A Jest mock function (jest.fn())\n *\n * Adds the user data supplied in the `hydratedAuthenticatedUser` config option into the object\n * returned by `getAuthenticatedUser`. This emulates the behavior of a real auth service which\n * would make a request to fetch this data prior to merging it in.\n *\n * ```\n * console.log(authenticatedUser); // Will be sparse and only contain basic information.\n * await hydrateAuthenticatedUser()\n * const authenticatedUser = getAuthenticatedUser();\n * console.log(authenticatedUser); // Will contain additional user information\n * ```\n *\n * @returns {Promise<null>}\n */\n hydrateAuthenticatedUser = jest.fn(() => {\n const user = this.getAuthenticatedUser();\n if (user !== null) {\n this.setAuthenticatedUser({ ...user, ...this.hydratedAuthenticatedUser });\n }\n });\n}\n\nexport default MockAuthService;\n"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,mBAAT,QAAoC,UAApC;AAEA,IAAMC,aAAa,GAAGF,SAAS,CAACG,KAAV,CAAgB;EACpCC,MAAM,EAAEJ,SAAS,CAACK,MAAV,CAAiBC,UADW;EAEpCC,QAAQ,EAAEP,SAAS,CAACK,MAAV,CAAiBC,UAFS;EAGpCE,KAAK,EAAER,SAAS,CAACS,OAAV,CAAkBT,SAAS,CAACK,MAA5B,CAH6B;EAIpCK,aAAa,EAAEV,SAAS;AAJY,CAAhB,CAAtB;AAOA,IAAMW,gBAAgB,GAAG;EACvBC,MAAM,EAAEZ,SAAS,CAACG,KAAV,CAAgB;IACtBU,QAAQ,EAAEb,SAAS,CAACK,MAAV,CAAiBC,UADL;IAEtBQ,YAAY,EAAEd,SAAS,CAACK,MAAV,CAAiBC,UAFT;IAGtBS,SAAS,EAAEf,SAAS,CAACK,MAAV,CAAiBC,UAHN;IAItBU,UAAU,EAAEhB,SAAS,CAACK,MAAV,CAAiBC,UAJP;IAKtBW,6BAA6B,EAAEjB,SAAS,CAACK,MAAV,CAAiBC,UAL1B;IAMtBY,wBAAwB,EAAElB,SAAS,CAACK,MAAV,CAAiBC,UANrB;IAOtBa,mBAAmB,EAAEnB,SAAS,CAACK,MAAV,CAAiBC;EAPhB,CAAhB,EAQLA,UAToB;EAUvBc,cAAc,EAAEpB,SAAS,CAACG,KAAV,C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AAV,CAAnB;IACA3B,SAAS,CAAC0C,cAAV,CAAyB/B,gBAAzB,EAA2CgB,OAA3C,EAAoD,SAApD,EAA+D,aAA/D;IAEA,KAAKf,MAAL,GAAce,OAAO,CAACf,MAAtB;IACA,KAAKQ,cAAL,GAAsBO,OAAO,CAACP,cAA9B,CARmB,CAUnB;;IACA,KAAKI,iBAAL,GAAyB,KAAKZ,MAAL,CAAYY,iBAAZ,GAAgC,KAAKZ,MAAL,CAAYY,iBAA5C,GAAgE,IAAzF;IACA,KAAKC,yBAAL,GAAiC,KAAKb,MAAL,CAAYa,yBAAZ,GAC7B,KAAKb,MAAL,CAAYa,yBADiB,GAE7B,EAFJ;IAIA,KAAKK,uBAAL,GAA+B/B,KAAK,CAAC4C,MAAN,EAA/B;IACA,KAAKZ,UAAL,GAAkBhC,KAAK,CAAC4C,MAAN,EAAlB;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;;;;;WACE,2BAAiC;MAAA,IAAjBC,UAAiB,uEAAJ,EAAI;MAC/B,IAAMC,OAAO,GAAG,CACd,KAAKf,uBADS,EACgB,KAAKC,UADrB,EAEd,KAAKe,6BAFS,EAEsB,KAAKC,gBAF3B,CAAhB;;MAIA,IAAI;QACDH,UAAD,CAAaI,OAAb,CAAqB,UAACC,YAAD,EAAkB;UACrCJ,OAAO,CAACG,OAAR,CAAgB,UAACE,MAAD;YAAA,OAAYA,MAAM,IAAID,YAAY,CAACC,MAAD,CAAlC;UAAA,CAAhB;QACD,CAFD;MAGD,CAJD,CAIE,OAAOC,KAAP,EAAc;QACd,MAAM,IAAIC,KAAJ,uCAAyCD,KAAK,CAACE,OAA/C,OAAN;MACD;IACF;IAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AAiJA,eAAe3B,eAAf"}
@@ -1,3 +1,7 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+
1
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
6
 
3
7
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -9,9 +13,9 @@ var createCsrfTokenProviderInterceptor = function createCsrfTokenProviderInterce
9
13
  // maintain reference to the options supplied.
10
14
 
11
15
  var interceptor = /*#__PURE__*/function () {
12
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(axiosRequestConfig) {
16
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(axiosRequestConfig) {
13
17
  var url, csrfToken, requestError, CSRF_HEADER_NAME;
14
- return regeneratorRuntime.wrap(function _callee$(_context) {
18
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
15
19
  while (1) {
16
20
  switch (_context.prev = _context.next) {
17
21
  case 0: