@edx/frontend-platform 3.6.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analytics/MockAnalyticsService.js +6 -19
- package/analytics/MockAnalyticsService.js.map +1 -1
- package/analytics/SegmentAnalyticsService.js +53 -57
- package/analytics/SegmentAnalyticsService.js.map +1 -1
- package/analytics/index.js.map +1 -1
- package/analytics/interface.js +9 -9
- package/analytics/interface.js.map +1 -1
- package/auth/AxiosCsrfTokenService.js +36 -58
- package/auth/AxiosCsrfTokenService.js.map +1 -1
- package/auth/AxiosJwtAuthService.js +105 -150
- package/auth/AxiosJwtAuthService.js.map +1 -1
- package/auth/AxiosJwtTokenService.js +101 -148
- package/auth/AxiosJwtTokenService.js.map +1 -1
- package/auth/LocalForageCache.js +89 -108
- package/auth/LocalForageCache.js.map +1 -1
- package/auth/MockAuthService.js +10 -35
- package/auth/MockAuthService.js.map +1 -1
- package/auth/index.js.map +1 -1
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js +35 -50
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createJwtTokenProviderInterceptor.js +33 -47
- package/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +15 -27
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -1
- package/auth/interceptors/createRetryInterceptor.js +75 -105
- package/auth/interceptors/createRetryInterceptor.js.map +1 -1
- package/auth/interface.js +41 -58
- package/auth/interface.js.map +1 -1
- package/auth/utils.js +22 -40
- package/auth/utils.js.map +1 -1
- package/config.js +6 -7
- package/config.js.map +1 -1
- package/constants.js +8 -8
- package/constants.js.map +1 -1
- package/i18n/countries.js +9 -15
- package/i18n/countries.js.map +1 -1
- package/i18n/index.js +1 -0
- package/i18n/index.js.map +1 -1
- package/i18n/injectIntlWithShim.js +4 -28
- package/i18n/injectIntlWithShim.js.map +1 -1
- package/i18n/languages.js +11 -17
- package/i18n/languages.js.map +1 -1
- package/i18n/lib.js +64 -56
- package/i18n/lib.js.map +1 -1
- package/i18n/scripts/transifex-utils.js +5 -20
- package/i18n/scripts/transifex-utils.js.map +1 -1
- package/index.js.map +1 -1
- package/initialize.js +176 -228
- package/initialize.js.map +1 -1
- package/logging/MockLoggingService.js +5 -9
- package/logging/MockLoggingService.js.map +1 -1
- package/logging/NewRelicLoggingService.js +9 -33
- package/logging/NewRelicLoggingService.js.map +1 -1
- package/logging/index.js.map +1 -1
- package/logging/interface.js +7 -6
- package/logging/interface.js.map +1 -1
- package/package.json +4 -4
- package/pubSub.js +4 -3
- package/pubSub.js.map +1 -1
- package/react/AppContext.js +1 -1
- package/react/AppContext.js.map +1 -1
- package/react/AppProvider.js +13 -23
- package/react/AppProvider.js.map +1 -1
- package/react/AuthenticatedPageRoute.js +5 -13
- package/react/AuthenticatedPageRoute.js.map +1 -1
- package/react/ErrorBoundary.js +4 -21
- package/react/ErrorBoundary.js.map +1 -1
- package/react/ErrorPage.js +7 -17
- package/react/ErrorPage.js.map +1 -1
- package/react/LoginRedirect.js +1 -1
- package/react/LoginRedirect.js.map +1 -1
- package/react/OptionalReduxProvider.js +2 -4
- package/react/OptionalReduxProvider.js.map +1 -1
- package/react/PageRoute.js +3 -3
- package/react/PageRoute.js.map +1 -1
- package/react/hooks.js +2 -6
- package/react/hooks.js.map +1 -1
- package/react/index.js +1 -0
- package/react/index.js.map +1 -1
- package/testing/index.js +1 -0
- package/testing/index.js.map +1 -1
- package/testing/initializeMockApp.js +11 -11
- package/testing/initializeMockApp.js.map +1 -1
- package/testing/mockMessages.js.map +1 -1
- package/utils.js +15 -24
- package/utils.js.map +1 -1
package/auth/interface.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
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
|
-
|
|
2
|
+
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, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $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 defineProperty(generator, "_invoke", { value: makeInvokeMethod(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; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(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); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), 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 (val) { var object = Object(val), 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; }
|
|
5
3
|
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); } }
|
|
6
|
-
|
|
7
4
|
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); }); }; }
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
6
|
* #### Import members from **@edx/frontend-platform/auth**
|
|
11
7
|
*
|
|
@@ -44,12 +40,13 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
44
40
|
*/
|
|
45
41
|
import PropTypes from 'prop-types';
|
|
46
42
|
import { publish } from '../pubSub';
|
|
43
|
+
|
|
47
44
|
/**
|
|
48
45
|
* @constant
|
|
49
46
|
* @private
|
|
50
47
|
*/
|
|
51
|
-
|
|
52
48
|
export var AUTHENTICATED_USER_TOPIC = 'AUTHENTICATED_USER';
|
|
49
|
+
|
|
53
50
|
/**
|
|
54
51
|
* Published when the authenticated user data changes. This can happen when the authentication
|
|
55
52
|
* service determines that the user is authenticated or anonymous, as well as when we fetch
|
|
@@ -59,7 +56,6 @@ export var AUTHENTICATED_USER_TOPIC = 'AUTHENTICATED_USER';
|
|
|
59
56
|
* @event
|
|
60
57
|
* @see {@link module:Initialization~initialize}
|
|
61
58
|
*/
|
|
62
|
-
|
|
63
59
|
export var AUTHENTICATED_USER_CHANGED = "".concat(AUTHENTICATED_USER_TOPIC, ".CHANGED");
|
|
64
60
|
var optionsShape = {
|
|
65
61
|
config: PropTypes.shape({
|
|
@@ -90,39 +86,39 @@ var serviceShape = {
|
|
|
90
86
|
hydrateAuthenticatedUser: PropTypes.func.isRequired
|
|
91
87
|
};
|
|
92
88
|
var service;
|
|
89
|
+
|
|
93
90
|
/**
|
|
94
91
|
*
|
|
95
92
|
* @param {class} AuthService
|
|
96
93
|
* @param {*} options
|
|
97
94
|
* @returns {AuthService}
|
|
98
95
|
*/
|
|
99
|
-
|
|
100
96
|
export function configure(AuthService, options) {
|
|
101
97
|
PropTypes.checkPropTypes(optionsShape, options, 'property', 'Auth');
|
|
102
98
|
service = new AuthService(options);
|
|
103
99
|
PropTypes.checkPropTypes(serviceShape, service, 'property', 'AuthService');
|
|
104
100
|
return service;
|
|
105
101
|
}
|
|
102
|
+
|
|
106
103
|
/**
|
|
107
104
|
*
|
|
108
105
|
*
|
|
109
106
|
* @returns {AuthService}
|
|
110
107
|
*/
|
|
111
|
-
|
|
112
108
|
export function getAuthService() {
|
|
113
109
|
if (!service) {
|
|
114
110
|
throw Error('You must first configure the auth service.');
|
|
115
111
|
}
|
|
116
|
-
|
|
117
112
|
return service;
|
|
118
113
|
}
|
|
114
|
+
|
|
119
115
|
/**
|
|
120
116
|
*
|
|
121
117
|
*/
|
|
122
|
-
|
|
123
118
|
export function resetAuthService() {
|
|
124
119
|
service = null;
|
|
125
120
|
}
|
|
121
|
+
|
|
126
122
|
/**
|
|
127
123
|
* Gets the authenticated HTTP client for the service.
|
|
128
124
|
*
|
|
@@ -131,11 +127,11 @@ export function resetAuthService() {
|
|
|
131
127
|
*
|
|
132
128
|
* @returns {HttpClient}
|
|
133
129
|
*/
|
|
134
|
-
|
|
135
130
|
export function getAuthenticatedHttpClient() {
|
|
136
131
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
137
132
|
return service.getAuthenticatedHttpClient(options);
|
|
138
133
|
}
|
|
134
|
+
|
|
139
135
|
/**
|
|
140
136
|
* Gets the unauthenticated HTTP client for the service.
|
|
141
137
|
*
|
|
@@ -144,11 +140,11 @@ export function getAuthenticatedHttpClient() {
|
|
|
144
140
|
*
|
|
145
141
|
* @returns {HttpClient}
|
|
146
142
|
*/
|
|
147
|
-
|
|
148
143
|
export function getHttpClient() {
|
|
149
144
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
150
145
|
return service.getHttpClient(options);
|
|
151
146
|
}
|
|
147
|
+
|
|
152
148
|
/**
|
|
153
149
|
* Builds a URL to the login page with a post-login redirect URL attached as a query parameter.
|
|
154
150
|
*
|
|
@@ -159,19 +155,19 @@ export function getHttpClient() {
|
|
|
159
155
|
*
|
|
160
156
|
* @param {string} redirectUrl The URL the user should be redirected to after logging in.
|
|
161
157
|
*/
|
|
162
|
-
|
|
163
158
|
export function getLoginRedirectUrl(redirectUrl) {
|
|
164
159
|
return service.getLoginRedirectUrl(redirectUrl);
|
|
165
160
|
}
|
|
161
|
+
|
|
166
162
|
/**
|
|
167
163
|
* Redirects the user to the login page.
|
|
168
164
|
*
|
|
169
165
|
* @param {string} redirectUrl The URL the user should be redirected to after logging in.
|
|
170
166
|
*/
|
|
171
|
-
|
|
172
167
|
export function redirectToLogin(redirectUrl) {
|
|
173
168
|
return service.redirectToLogin(redirectUrl);
|
|
174
169
|
}
|
|
170
|
+
|
|
175
171
|
/**
|
|
176
172
|
* Builds a URL to the logout page with a post-logout redirect URL attached as a query parameter.
|
|
177
173
|
*
|
|
@@ -182,40 +178,40 @@ export function redirectToLogin(redirectUrl) {
|
|
|
182
178
|
*
|
|
183
179
|
* @param {string} redirectUrl The URL the user should be redirected to after logging out.
|
|
184
180
|
*/
|
|
185
|
-
|
|
186
181
|
export function getLogoutRedirectUrl(redirectUrl) {
|
|
187
182
|
return service.getLogoutRedirectUrl(redirectUrl);
|
|
188
183
|
}
|
|
184
|
+
|
|
189
185
|
/**
|
|
190
186
|
* Redirects the user to the logout page.
|
|
191
187
|
*
|
|
192
188
|
* @param {string} redirectUrl The URL the user should be redirected to after logging out.
|
|
193
189
|
*/
|
|
194
|
-
|
|
195
190
|
export function redirectToLogout(redirectUrl) {
|
|
196
191
|
return service.redirectToLogout(redirectUrl);
|
|
197
192
|
}
|
|
193
|
+
|
|
198
194
|
/**
|
|
199
195
|
* If it exists, returns the user data representing the currently authenticated user. If the
|
|
200
196
|
* user is anonymous, returns null.
|
|
201
197
|
*
|
|
202
198
|
* @returns {UserData|null}
|
|
203
199
|
*/
|
|
204
|
-
|
|
205
200
|
export function getAuthenticatedUser() {
|
|
206
201
|
return service.getAuthenticatedUser();
|
|
207
202
|
}
|
|
203
|
+
|
|
208
204
|
/**
|
|
209
205
|
* Sets the authenticated user to the provided value.
|
|
210
206
|
*
|
|
211
207
|
* @param {UserData} authUser
|
|
212
208
|
* @emits AUTHENTICATED_USER_CHANGED
|
|
213
209
|
*/
|
|
214
|
-
|
|
215
210
|
export function setAuthenticatedUser(authUser) {
|
|
216
211
|
service.setAuthenticatedUser(authUser);
|
|
217
212
|
publish(AUTHENTICATED_USER_CHANGED);
|
|
218
213
|
}
|
|
214
|
+
|
|
219
215
|
/**
|
|
220
216
|
* Reads the authenticated user's access token. Resolves to null if the user is
|
|
221
217
|
* unauthenticated.
|
|
@@ -223,10 +219,10 @@ export function setAuthenticatedUser(authUser) {
|
|
|
223
219
|
* @returns {Promise<UserData>|Promise<null>} Resolves to the user's access token if they are
|
|
224
220
|
* logged in.
|
|
225
221
|
*/
|
|
226
|
-
|
|
227
222
|
export function fetchAuthenticatedUser() {
|
|
228
223
|
return _fetchAuthenticatedUser.apply(this, arguments);
|
|
229
224
|
}
|
|
225
|
+
|
|
230
226
|
/**
|
|
231
227
|
* Ensures a user is authenticated. It will redirect to login when not
|
|
232
228
|
* authenticated.
|
|
@@ -235,31 +231,27 @@ export function fetchAuthenticatedUser() {
|
|
|
235
231
|
* authenticated.
|
|
236
232
|
* @returns {Promise<UserData>}
|
|
237
233
|
*/
|
|
238
|
-
|
|
239
234
|
function _fetchAuthenticatedUser() {
|
|
240
235
|
_fetchAuthenticatedUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
241
236
|
var options,
|
|
242
|
-
|
|
237
|
+
_args = arguments;
|
|
243
238
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
244
|
-
while (1) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
case "end":
|
|
252
|
-
return _context.stop();
|
|
253
|
-
}
|
|
239
|
+
while (1) switch (_context.prev = _context.next) {
|
|
240
|
+
case 0:
|
|
241
|
+
options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
242
|
+
return _context.abrupt("return", service.fetchAuthenticatedUser(options));
|
|
243
|
+
case 2:
|
|
244
|
+
case "end":
|
|
245
|
+
return _context.stop();
|
|
254
246
|
}
|
|
255
247
|
}, _callee);
|
|
256
248
|
}));
|
|
257
249
|
return _fetchAuthenticatedUser.apply(this, arguments);
|
|
258
250
|
}
|
|
259
|
-
|
|
260
251
|
export function ensureAuthenticatedUser(_x) {
|
|
261
252
|
return _ensureAuthenticatedUser.apply(this, arguments);
|
|
262
253
|
}
|
|
254
|
+
|
|
263
255
|
/**
|
|
264
256
|
* Fetches additional user account information for the authenticated user and merges it into the
|
|
265
257
|
* existing authenticatedUser object, available via getAuthenticatedUser().
|
|
@@ -273,28 +265,24 @@ export function ensureAuthenticatedUser(_x) {
|
|
|
273
265
|
*
|
|
274
266
|
* @emits AUTHENTICATED_USER_CHANGED
|
|
275
267
|
*/
|
|
276
|
-
|
|
277
268
|
function _ensureAuthenticatedUser() {
|
|
278
269
|
_ensureAuthenticatedUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(redirectUrl) {
|
|
279
270
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
280
|
-
while (1) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
case "end":
|
|
287
|
-
return _context2.stop();
|
|
288
|
-
}
|
|
271
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
272
|
+
case 0:
|
|
273
|
+
return _context2.abrupt("return", service.ensureAuthenticatedUser(redirectUrl));
|
|
274
|
+
case 1:
|
|
275
|
+
case "end":
|
|
276
|
+
return _context2.stop();
|
|
289
277
|
}
|
|
290
278
|
}, _callee2);
|
|
291
279
|
}));
|
|
292
280
|
return _ensureAuthenticatedUser.apply(this, arguments);
|
|
293
281
|
}
|
|
294
|
-
|
|
295
282
|
export function hydrateAuthenticatedUser() {
|
|
296
283
|
return _hydrateAuthenticatedUser.apply(this, arguments);
|
|
297
284
|
}
|
|
285
|
+
|
|
298
286
|
/**
|
|
299
287
|
* @name AuthService
|
|
300
288
|
* @interface
|
|
@@ -351,23 +339,18 @@ export function hydrateAuthenticatedUser() {
|
|
|
351
339
|
* @property {Array} roles
|
|
352
340
|
* @property {boolean} administrator
|
|
353
341
|
*/
|
|
354
|
-
|
|
355
342
|
function _hydrateAuthenticatedUser() {
|
|
356
343
|
_hydrateAuthenticatedUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
357
344
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
358
|
-
while (1) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
case 3:
|
|
368
|
-
case "end":
|
|
369
|
-
return _context3.stop();
|
|
370
|
-
}
|
|
345
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
346
|
+
case 0:
|
|
347
|
+
_context3.next = 2;
|
|
348
|
+
return service.hydrateAuthenticatedUser();
|
|
349
|
+
case 2:
|
|
350
|
+
publish(AUTHENTICATED_USER_CHANGED);
|
|
351
|
+
case 3:
|
|
352
|
+
case "end":
|
|
353
|
+
return _context3.stop();
|
|
371
354
|
}
|
|
372
355
|
}, _callee3);
|
|
373
356
|
}));
|
package/auth/interface.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","names":["PropTypes","publish","AUTHENTICATED_USER_TOPIC","AUTHENTICATED_USER_CHANGED","optionsShape","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","serviceShape","getAuthenticatedHttpClient","getHttpClient","getLoginRedirectUrl","redirectToLogin","getLogoutRedirectUrl","redirectToLogout","getAuthenticatedUser","setAuthenticatedUser","fetchAuthenticatedUser","ensureAuthenticatedUser","hydrateAuthenticatedUser","service","configure","AuthService","options","checkPropTypes","getAuthService","Error","resetAuthService","redirectUrl","authUser"],"sources":["../../src/auth/interface.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform/auth**\n *\n * Simplifies the process of making authenticated API requests to backend edX services by providing\n * common authN/authZ client code that enables the login/logout flow and handles ensuring the\n * presence of a valid [JWT cookie](https://github.com/openedx/edx-platform/blob/master/openedx/core/djangoapps/oauth_dispatch/docs/decisions/0009-jwt-in-session-cookie.rst).\n *\n * The `initialize` function performs much of the auth configuration for you. If, however, you're\n * not using the `initialize` function, an authenticated API client can be created via:\n *\n * ```\n * import {\n * configure,\n * fetchAuthenticatedUser,\n * getAuthenticatedHttpClient\n * } from '@edx/frontend-platform/auth';\n * import { getConfig } from '@edx/frontend-platform';\n * import { getLoggingService } from '@edx/frontend-platform/logging';\n *\n * configure({\n * loggingService: getLoggingService(),\n * config: getConfig(),\n * });\n *\n * const authenticatedUser = await fetchAuthenticatedUser(); // validates and decodes JWT token\n * const authenticatedHttpClient = getAuthenticatedHttpClient();\n * const response = await getAuthenticatedHttpClient().get(`https://example.com/api/user/data/${authenticatedUser.username}`); // fetching from an authenticated API using user data\n * ```\n *\n * As shown in this example, auth depends on the configuration document and logging.\n *\n * NOTE: The documentation for AxiosJwtAuthService is nearly the same as that for the top-level\n * auth interface, except that it contains some Axios-specific details.\n *\n * @module Auth\n */\nimport PropTypes from 'prop-types';\nimport { publish } from '../pubSub';\n\n/**\n * @constant\n * @private\n */\nexport const AUTHENTICATED_USER_TOPIC = 'AUTHENTICATED_USER';\n\n/**\n * Published when the authenticated user data changes. This can happen when the authentication\n * service determines that the user is authenticated or anonymous, as well as when we fetch\n * additional user account data if the `hydrateAuthenticatedUser` flag has been set in the\n * `initialize` function.\n *\n * @event\n * @see {@link module:Initialization~initialize}\n */\nexport const AUTHENTICATED_USER_CHANGED = `${AUTHENTICATED_USER_TOPIC}.CHANGED`;\n\nconst optionsShape = {\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\nconst serviceShape = {\n getAuthenticatedHttpClient: PropTypes.func.isRequired,\n getHttpClient: PropTypes.func.isRequired,\n getLoginRedirectUrl: PropTypes.func.isRequired,\n redirectToLogin: PropTypes.func.isRequired,\n getLogoutRedirectUrl: PropTypes.func.isRequired,\n redirectToLogout: PropTypes.func.isRequired,\n getAuthenticatedUser: PropTypes.func.isRequired,\n setAuthenticatedUser: PropTypes.func.isRequired,\n fetchAuthenticatedUser: PropTypes.func.isRequired,\n ensureAuthenticatedUser: PropTypes.func.isRequired,\n hydrateAuthenticatedUser: PropTypes.func.isRequired,\n};\n\nlet service;\n\n/**\n *\n * @param {class} AuthService\n * @param {*} options\n * @returns {AuthService}\n */\nexport function configure(AuthService, options) {\n PropTypes.checkPropTypes(optionsShape, options, 'property', 'Auth');\n service = new AuthService(options);\n PropTypes.checkPropTypes(serviceShape, service, 'property', 'AuthService');\n return service;\n}\n\n/**\n *\n *\n * @returns {AuthService}\n */\nexport function getAuthService() {\n if (!service) {\n throw Error('You must first configure the auth service.');\n }\n\n return service;\n}\n\n/**\n *\n */\nexport function resetAuthService() {\n service = null;\n}\n\n/**\n * Gets the authenticated HTTP client for the service.\n *\n * @param {Object} [options] Optional options for how to configure the authenticated HTTP client\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made with the returned client\n *\n * @returns {HttpClient}\n */\nexport function getAuthenticatedHttpClient(options = {}) {\n return service.getAuthenticatedHttpClient(options);\n}\n\n/**\n * Gets the unauthenticated HTTP client for the service.\n *\n * @param {Object} [options] Optional options for how to configure the authenticated HTTP client\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made with the returned client\n *\n * @returns {HttpClient}\n */\nexport function getHttpClient(options = {}) {\n return service.getHttpClient(options);\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 */\nexport function getLoginRedirectUrl(redirectUrl) {\n return service.getLoginRedirectUrl(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 */\nexport function redirectToLogin(redirectUrl) {\n return service.redirectToLogin(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?redirect_url=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\nexport function getLogoutRedirectUrl(redirectUrl) {\n return service.getLogoutRedirectUrl(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 */\nexport function redirectToLogout(redirectUrl) {\n return service.redirectToLogout(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 */\nexport function getAuthenticatedUser() {\n return service.getAuthenticatedUser();\n}\n\n/**\n * Sets the authenticated user to the provided value.\n *\n * @param {UserData} authUser\n * @emits AUTHENTICATED_USER_CHANGED\n */\nexport function setAuthenticatedUser(authUser) {\n service.setAuthenticatedUser(authUser);\n publish(AUTHENTICATED_USER_CHANGED);\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 */\nexport async function fetchAuthenticatedUser(options = {}) {\n return service.fetchAuthenticatedUser(options);\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 */\nexport async function ensureAuthenticatedUser(redirectUrl) {\n return service.ensureAuthenticatedUser(redirectUrl);\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 * @emits AUTHENTICATED_USER_CHANGED\n */\nexport async function hydrateAuthenticatedUser() {\n await service.hydrateAuthenticatedUser();\n publish(AUTHENTICATED_USER_CHANGED);\n}\n\n/**\n * @name AuthService\n * @interface\n * @memberof module:Auth\n * @property {function} getAuthenticatedHttpClient\n * @property {function} getHttpClient\n * @property {function} getLoginRedirectUrl\n * @property {function} redirectToLogin\n * @property {function} getLogoutRedirectUrl\n * @property {function} redirectToLogout\n * @property {function} getAuthenticatedUser\n * @property {function} setAuthenticatedUser\n * @property {function} fetchAuthenticatedUser\n * @property {function} ensureAuthenticatedUser\n * @property {function} hydrateAuthenticatedUser\n */\n\n/**\n * A configured axios client. See axios docs for more\n * info https://github.com/axios/axios. All the functions\n * below accept isPublic and isCsrfExempt in the request\n * config options. Setting these to true will prevent this\n * client from attempting to refresh the jwt access token\n * or a csrf token respectively.\n *\n * ```\n * // A public endpoint (no jwt token refresh)\n * apiClient.get('/path/to/endpoint', { isPublic: true });\n * ```\n *\n * ```\n * // A csrf exempt endpoint\n * apiClient.post('/path/to/endpoint', { data }, { isCsrfExempt: true });\n * ```\n *\n * @name HttpClient\n * @interface\n * @memberof module:Auth\n * @property {function} get\n * @property {function} head\n * @property {function} options\n * @property {function} delete (csrf protected)\n * @property {function} post (csrf protected)\n * @property {function} put (csrf protected)\n * @property {function} patch (csrf protected)\n */\n\n/**\n * @name UserData\n * @interface\n * @memberof module:Auth\n * @property {string} userId\n * @property {string} username\n * @property {Array} roles\n * @property {boolean} administrator\n */\n"],"mappings":";;+CACA,oJ;;;;;;AADA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,YAAtB;AACA,SAASC,OAAT,QAAwB,WAAxB;AAEA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,wBAAwB,GAAG,oBAAjC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,0BAA0B,aAAMD,wBAAN,aAAhC;AAEP,IAAME,YAAY,GAAG;EACnBC,MAAM,EAAEL,SAAS,CAACM,KAAV,CAAgB;IACtBC,QAAQ,EAAEP,SAAS,CAACQ,MAAV,CAAiBC,UADL;IAEtBC,YAAY,EAAEV,SAAS,CAACQ,MAAV,CAAiBC,UAFT;IAGtBE,SAAS,EAAEX,SAAS,CAACQ,MAAV,CAAiBC,UAHN;IAItBG,UAAU,EAAEZ,SAAS,CAACQ,MAAV,CAAiBC,UAJP;IAKtBI,6BAA6B,EAAEb,SAAS,CAACQ,MAAV,CAAiBC,UAL1B;IAMtBK,wBAAwB,EAAEd,SAAS,CAACQ,MAAV,CAAiBC,UANrB;IAOtBM,mBAAmB,EAAEf,SAAS,CAACQ,MAAV,CAAiBC;EAPhB,CAAhB,EAQLA,UATgB;EAUnBO,cAAc,EAAEhB,SAAS,CAACM,KAAV,CAAgB;IAC9BW,QAAQ,EAAEjB,SAAS,CAACkB,IAAV,CAAeT,UADK;IAE9BU,OAAO,EAAEnB,SAAS,CAACkB,IA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AACE,0BAAD,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,gBAAsB0B,sBAAtB;EAAA;AAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;uFAXO;IAAA;IAAA;IAAA;MAAA;QAAA;UAAA;YAAsCM,OAAtC,2DAAgD,EAAhD;YAAA,iCACEH,OAAO,CAACH,sBAAR,CAA+BM,OAA/B,CADF;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C;;;;AAYP,gBAAsBL,uBAAtB;EAAA;AAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;wFAhBO,kBAAuCU,WAAvC;IAAA;MAAA;QAAA;UAAA;YAAA,kCACER,OAAO,CAACF,uBAAR,CAAgCU,WAAhC,CADF;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C;;;;AAiBP,gBAAsBT,wBAAtB;EAAA;AAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;yFA5DO;IAAA;MAAA;QAAA;UAAA;YAAA;YAAA,OACCC,OAAO,CAACD,wBAAR,EADD;;UAAA;YAEL9B,OAAO,CAACE,0BAAD,CAAP;;UAFK;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C"}
|
|
1
|
+
{"version":3,"file":"interface.js","names":["_regeneratorRuntime","exports","Op","Object","prototype","hasOwn","hasOwnProperty","defineProperty","obj","key","desc","value","$Symbol","Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","define","enumerable","configurable","writable","err","wrap","innerFn","outerFn","self","tryLocsList","protoGenerator","Generator","generator","create","context","Context","makeInvokeMethod","tryCatch","fn","arg","type","call","ContinueSentinel","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","forEach","method","_invoke","AsyncIterator","PromiseImpl","invoke","resolve","reject","record","result","_typeof","__await","then","unwrapped","error","previousPromise","callInvokeWithMethodAndArg","state","Error","doneResult","delegate","delegateResult","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","done","methodName","undefined","TypeError","info","resultName","next","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","length","i","displayName","isGeneratorFunction","genFun","ctor","constructor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","iter","keys","val","object","reverse","pop","skipTempReset","prev","charAt","slice","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","_catch","thrown","delegateYield","asyncGeneratorStep","gen","_next","_throw","_asyncToGenerator","args","arguments","apply","PropTypes","publish","AUTHENTICATED_USER_TOPIC","AUTHENTICATED_USER_CHANGED","concat","optionsShape","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","serviceShape","getAuthenticatedHttpClient","getHttpClient","getLoginRedirectUrl","redirectToLogin","getLogoutRedirectUrl","redirectToLogout","getAuthenticatedUser","setAuthenticatedUser","fetchAuthenticatedUser","ensureAuthenticatedUser","hydrateAuthenticatedUser","service","configure","AuthService","options","checkPropTypes","getAuthService","resetAuthService","redirectUrl","authUser","_fetchAuthenticatedUser","_callee","_args","_callee$","_context","_x","_ensureAuthenticatedUser","_callee2","_callee2$","_context2","_hydrateAuthenticatedUser","_callee3","_callee3$","_context3"],"sources":["../../src/auth/interface.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform/auth**\n *\n * Simplifies the process of making authenticated API requests to backend edX services by providing\n * common authN/authZ client code that enables the login/logout flow and handles ensuring the\n * presence of a valid [JWT cookie](https://github.com/openedx/edx-platform/blob/master/openedx/core/djangoapps/oauth_dispatch/docs/decisions/0009-jwt-in-session-cookie.rst).\n *\n * The `initialize` function performs much of the auth configuration for you. If, however, you're\n * not using the `initialize` function, an authenticated API client can be created via:\n *\n * ```\n * import {\n * configure,\n * fetchAuthenticatedUser,\n * getAuthenticatedHttpClient\n * } from '@edx/frontend-platform/auth';\n * import { getConfig } from '@edx/frontend-platform';\n * import { getLoggingService } from '@edx/frontend-platform/logging';\n *\n * configure({\n * loggingService: getLoggingService(),\n * config: getConfig(),\n * });\n *\n * const authenticatedUser = await fetchAuthenticatedUser(); // validates and decodes JWT token\n * const authenticatedHttpClient = getAuthenticatedHttpClient();\n * const response = await getAuthenticatedHttpClient().get(`https://example.com/api/user/data/${authenticatedUser.username}`); // fetching from an authenticated API using user data\n * ```\n *\n * As shown in this example, auth depends on the configuration document and logging.\n *\n * NOTE: The documentation for AxiosJwtAuthService is nearly the same as that for the top-level\n * auth interface, except that it contains some Axios-specific details.\n *\n * @module Auth\n */\nimport PropTypes from 'prop-types';\nimport { publish } from '../pubSub';\n\n/**\n * @constant\n * @private\n */\nexport const AUTHENTICATED_USER_TOPIC = 'AUTHENTICATED_USER';\n\n/**\n * Published when the authenticated user data changes. This can happen when the authentication\n * service determines that the user is authenticated or anonymous, as well as when we fetch\n * additional user account data if the `hydrateAuthenticatedUser` flag has been set in the\n * `initialize` function.\n *\n * @event\n * @see {@link module:Initialization~initialize}\n */\nexport const AUTHENTICATED_USER_CHANGED = `${AUTHENTICATED_USER_TOPIC}.CHANGED`;\n\nconst optionsShape = {\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\nconst serviceShape = {\n getAuthenticatedHttpClient: PropTypes.func.isRequired,\n getHttpClient: PropTypes.func.isRequired,\n getLoginRedirectUrl: PropTypes.func.isRequired,\n redirectToLogin: PropTypes.func.isRequired,\n getLogoutRedirectUrl: PropTypes.func.isRequired,\n redirectToLogout: PropTypes.func.isRequired,\n getAuthenticatedUser: PropTypes.func.isRequired,\n setAuthenticatedUser: PropTypes.func.isRequired,\n fetchAuthenticatedUser: PropTypes.func.isRequired,\n ensureAuthenticatedUser: PropTypes.func.isRequired,\n hydrateAuthenticatedUser: PropTypes.func.isRequired,\n};\n\nlet service;\n\n/**\n *\n * @param {class} AuthService\n * @param {*} options\n * @returns {AuthService}\n */\nexport function configure(AuthService, options) {\n PropTypes.checkPropTypes(optionsShape, options, 'property', 'Auth');\n service = new AuthService(options);\n PropTypes.checkPropTypes(serviceShape, service, 'property', 'AuthService');\n return service;\n}\n\n/**\n *\n *\n * @returns {AuthService}\n */\nexport function getAuthService() {\n if (!service) {\n throw Error('You must first configure the auth service.');\n }\n\n return service;\n}\n\n/**\n *\n */\nexport function resetAuthService() {\n service = null;\n}\n\n/**\n * Gets the authenticated HTTP client for the service.\n *\n * @param {Object} [options] Optional options for how to configure the authenticated HTTP client\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made with the returned client\n *\n * @returns {HttpClient}\n */\nexport function getAuthenticatedHttpClient(options = {}) {\n return service.getAuthenticatedHttpClient(options);\n}\n\n/**\n * Gets the unauthenticated HTTP client for the service.\n *\n * @param {Object} [options] Optional options for how to configure the authenticated HTTP client\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made with the returned client\n *\n * @returns {HttpClient}\n */\nexport function getHttpClient(options = {}) {\n return service.getHttpClient(options);\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 */\nexport function getLoginRedirectUrl(redirectUrl) {\n return service.getLoginRedirectUrl(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 */\nexport function redirectToLogin(redirectUrl) {\n return service.redirectToLogin(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?redirect_url=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging out.\n */\nexport function getLogoutRedirectUrl(redirectUrl) {\n return service.getLogoutRedirectUrl(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 */\nexport function redirectToLogout(redirectUrl) {\n return service.redirectToLogout(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 */\nexport function getAuthenticatedUser() {\n return service.getAuthenticatedUser();\n}\n\n/**\n * Sets the authenticated user to the provided value.\n *\n * @param {UserData} authUser\n * @emits AUTHENTICATED_USER_CHANGED\n */\nexport function setAuthenticatedUser(authUser) {\n service.setAuthenticatedUser(authUser);\n publish(AUTHENTICATED_USER_CHANGED);\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 */\nexport async function fetchAuthenticatedUser(options = {}) {\n return service.fetchAuthenticatedUser(options);\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 */\nexport async function ensureAuthenticatedUser(redirectUrl) {\n return service.ensureAuthenticatedUser(redirectUrl);\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 * @emits AUTHENTICATED_USER_CHANGED\n */\nexport async function hydrateAuthenticatedUser() {\n await service.hydrateAuthenticatedUser();\n publish(AUTHENTICATED_USER_CHANGED);\n}\n\n/**\n * @name AuthService\n * @interface\n * @memberof module:Auth\n * @property {function} getAuthenticatedHttpClient\n * @property {function} getHttpClient\n * @property {function} getLoginRedirectUrl\n * @property {function} redirectToLogin\n * @property {function} getLogoutRedirectUrl\n * @property {function} redirectToLogout\n * @property {function} getAuthenticatedUser\n * @property {function} setAuthenticatedUser\n * @property {function} fetchAuthenticatedUser\n * @property {function} ensureAuthenticatedUser\n * @property {function} hydrateAuthenticatedUser\n */\n\n/**\n * A configured axios client. See axios docs for more\n * info https://github.com/axios/axios. All the functions\n * below accept isPublic and isCsrfExempt in the request\n * config options. Setting these to true will prevent this\n * client from attempting to refresh the jwt access token\n * or a csrf token respectively.\n *\n * ```\n * // A public endpoint (no jwt token refresh)\n * apiClient.get('/path/to/endpoint', { isPublic: true });\n * ```\n *\n * ```\n * // A csrf exempt endpoint\n * apiClient.post('/path/to/endpoint', { data }, { isCsrfExempt: true });\n * ```\n *\n * @name HttpClient\n * @interface\n * @memberof module:Auth\n * @property {function} get\n * @property {function} head\n * @property {function} options\n * @property {function} delete (csrf protected)\n * @property {function} post (csrf protected)\n * @property {function} put (csrf protected)\n * @property {function} patch (csrf protected)\n */\n\n/**\n * @name UserData\n * @interface\n * @memberof module:Auth\n * @property {string} userId\n * @property {string} username\n * @property {Array} roles\n * @property {boolean} administrator\n */\n"],"mappings":";+CACA,qJAAAA,mBAAA,YAAAA,oBAAA,WAAAC,OAAA,SAAAA,OAAA,OAAAC,EAAA,GAAAC,MAAA,CAAAC,SAAA,EAAAC,MAAA,GAAAH,EAAA,CAAAI,cAAA,EAAAC,cAAA,GAAAJ,MAAA,CAAAI,cAAA,cAAAC,GAAA,EAAAC,GAAA,EAAAC,IAAA,IAAAF,GAAA,CAAAC,GAAA,IAAAC,IAAA,CAAAC,KAAA,KAAAC,OAAA,wBAAAC,MAAA,GAAAA,MAAA,OAAAC,cAAA,GAAAF,OAAA,CAAAG,QAAA,kBAAAC,mBAAA,GAAAJ,OAAA,CAAAK,aAAA,uBAAAC,iBAAA,GAAAN,OAAA,CAAAO,WAAA,8BAAAC,OAAAZ,GAAA,EAAAC,GAAA,EAAAE,KAAA,WAAAR,MAAA,CAAAI,cAAA,CAAAC,GAAA,EAAAC,GAAA,IAAAE,KAAA,EAAAA,KAAA,EAAAU,UAAA,MAAAC,YAAA,MAAAC,QAAA,SAAAf,GAAA,CAAAC,GAAA,WAAAW,MAAA,mBAAAI,GAAA,IAAAJ,MAAA,YAAAA,OAAAZ,GAAA,EAAAC,GAAA,EAAAE,KAAA,WAAAH,GAAA,CAAAC,GAAA,IAAAE,KAAA,gBAAAc,KAAAC,OAAA,EAAAC,OAAA,EAAAC,IAAA,EAAAC,WAAA,QAAAC,cAAA,GAAAH,OAAA,IAAAA,OAAA,CAAAvB,SAAA,YAAA2B,SAAA,GAAAJ,OAAA,GAAAI,SAAA,EAAAC,SAAA,GAAA7B,MAAA,CAAA8B,MAAA,CAAAH,cAAA,CAAA1B,SAAA,GAAA8B,OAAA,OAAAC,OAAA,CAAAN,WAAA,gBAAAtB,c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A,CACpD;EAAA,OAAAD,wBAAA,CAAAjD,KAAA,OAAAD,SAAA;AAAA;AAeD,gBAAsBkC,wBAAwBA,CAAA;EAAA,OAAAoB,yBAAA,CAAArD,KAAA,OAAAD,SAAA;AAAA;;AAK9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARA,SAAAsD,0BAAA;EAAAA,yBAAA,GAAAxD,iBAAA,eAAAjJ,mBAAA,GAAA8G,IAAA,CApDO,SAAA4F,SAAA;IAAA,OAAA1M,mBAAA,GAAAyB,IAAA,UAAAkL,UAAAC,SAAA;MAAA,kBAAAA,SAAA,CAAAjF,IAAA,GAAAiF,SAAA,CAAAvH,IAAA;QAAA;UAAAuH,SAAA,CAAAvH,IAAA;UAAA,OACCiG,OAAO,CAACD,wBAAwB,EAAE;QAAA;UACxC/B,OAAO,CAACE,0BAA0B,CAAC;QAAC;QAAA;UAAA,OAAAoD,SAAA,CAAA9E,IAAA;MAAA;IAAA,GAAA4E,QAAA;EAAA,CACrC;EAAA,OAAAD,yBAAA,CAAArD,KAAA,OAAAD,SAAA;AAAA"}
|
package/auth/utils.js
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
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); }
|
|
1
2
|
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
|
-
|
|
3
3
|
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
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
|
|
9
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
|
|
11
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
16
|
-
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
17
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
|
|
19
13
|
// Lifted from here: https://regexr.com/3ok5o
|
|
20
14
|
var urlRegex = /([a-z]{1,2}tps?):\/\/((?:(?!(?:\/|#|\?|&)).)+)(?:(\/(?:(?:(?:(?!(?:#|\?|&)).)+\/))?))?(?:((?:(?!(?:\.|$|\?|#)).)+))?(?:(\.(?:(?!(?:\?|$|#)).)+))?(?:(\?(?:(?!(?:$|#)).)+))?(?:(#.+))?/;
|
|
21
|
-
|
|
22
15
|
var getUrlParts = function getUrlParts(url) {
|
|
23
16
|
var found = url.match(urlRegex);
|
|
24
|
-
|
|
25
17
|
try {
|
|
26
18
|
var _found = _slicedToArray(found, 8),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
fullUrl = _found[0],
|
|
20
|
+
protocol = _found[1],
|
|
21
|
+
domain = _found[2],
|
|
22
|
+
path = _found[3],
|
|
23
|
+
endFilename = _found[4],
|
|
24
|
+
endFileExtension = _found[5],
|
|
25
|
+
query = _found[6],
|
|
26
|
+
hash = _found[7];
|
|
36
27
|
return {
|
|
37
28
|
fullUrl: fullUrl,
|
|
38
29
|
protocol: protocol,
|
|
@@ -47,38 +38,32 @@ var getUrlParts = function getUrlParts(url) {
|
|
|
47
38
|
throw new Error("Could not find url parts from ".concat(url, "."));
|
|
48
39
|
}
|
|
49
40
|
};
|
|
50
|
-
|
|
51
41
|
var logFrontendAuthError = function logFrontendAuthError(loggingService, error) {
|
|
52
42
|
var prefixedMessageError = Object.create(error);
|
|
53
43
|
prefixedMessageError.message = "[frontend-auth] ".concat(error.message);
|
|
54
44
|
loggingService.logError(prefixedMessageError, prefixedMessageError.customAttributes);
|
|
55
45
|
};
|
|
56
|
-
|
|
57
46
|
var processAxiosError = function processAxiosError(axiosErrorObject) {
|
|
58
47
|
var error = Object.create(axiosErrorObject);
|
|
59
48
|
var request = error.request,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
response = error.response,
|
|
50
|
+
config = error.config;
|
|
63
51
|
if (!config) {
|
|
64
52
|
error.customAttributes = _objectSpread(_objectSpread({}, error.customAttributes), {}, {
|
|
65
53
|
httpErrorType: 'unknown-api-request-error'
|
|
66
54
|
});
|
|
67
55
|
return error;
|
|
68
56
|
}
|
|
69
|
-
|
|
70
57
|
var httpErrorRequestUrl = config.url,
|
|
71
|
-
|
|
58
|
+
httpErrorRequestMethod = config.method;
|
|
72
59
|
/* istanbul ignore else: difficult to enter the request-only error case in a unit test */
|
|
73
|
-
|
|
74
60
|
if (response) {
|
|
75
61
|
var status = response.status,
|
|
76
|
-
|
|
62
|
+
data = response.data;
|
|
77
63
|
var stringifiedData = JSON.stringify(data) || '(empty response)';
|
|
78
|
-
var responseIsHTML = stringifiedData.includes('<!DOCTYPE html>');
|
|
79
|
-
|
|
64
|
+
var responseIsHTML = stringifiedData.includes('<!DOCTYPE html>');
|
|
65
|
+
// Don't include data if it is just an HTML document, like a 500 error page.
|
|
80
66
|
/* istanbul ignore next */
|
|
81
|
-
|
|
82
67
|
var httpErrorResponseData = responseIsHTML ? '<Response is HTML>' : stringifiedData;
|
|
83
68
|
error.customAttributes = _objectSpread(_objectSpread({}, error.customAttributes), {}, {
|
|
84
69
|
httpErrorType: 'api-response-error',
|
|
@@ -94,9 +79,9 @@ var processAxiosError = function processAxiosError(axiosErrorObject) {
|
|
|
94
79
|
httpErrorMessage: error.message,
|
|
95
80
|
httpErrorRequestUrl: httpErrorRequestUrl,
|
|
96
81
|
httpErrorRequestMethod: httpErrorRequestMethod
|
|
97
|
-
});
|
|
82
|
+
});
|
|
83
|
+
// This case occurs most likely because of intermittent internet connection issues
|
|
98
84
|
// but it also, though less often, catches CORS or server configuration problems.
|
|
99
|
-
|
|
100
85
|
error.message = "Axios Error (Request): ".concat(error.message, " (possible local connectivity issue) ").concat(httpErrorRequestMethod, " ").concat(httpErrorRequestUrl);
|
|
101
86
|
} else {
|
|
102
87
|
error.customAttributes = _objectSpread(_objectSpread({}, error.customAttributes), {}, {
|
|
@@ -107,13 +92,10 @@ var processAxiosError = function processAxiosError(axiosErrorObject) {
|
|
|
107
92
|
});
|
|
108
93
|
error.message = "Axios Error (Config): ".concat(error.message, " ").concat(httpErrorRequestMethod, " ").concat(httpErrorRequestUrl);
|
|
109
94
|
}
|
|
110
|
-
|
|
111
95
|
return error;
|
|
112
96
|
};
|
|
113
|
-
|
|
114
97
|
var processAxiosErrorAndThrow = function processAxiosErrorAndThrow(axiosErrorObject) {
|
|
115
98
|
throw processAxiosError(axiosErrorObject);
|
|
116
99
|
};
|
|
117
|
-
|
|
118
100
|
export { getUrlParts, logFrontendAuthError, processAxiosError, processAxiosErrorAndThrow };
|
|
119
101
|
//# sourceMappingURL=utils.js.map
|
package/auth/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["urlRegex","getUrlParts","url","found","match","fullUrl","protocol","domain","path","endFilename","endFileExtension","query","hash","e","Error","logFrontendAuthError","loggingService","error","prefixedMessageError","Object","create","message","logError","customAttributes","processAxiosError","axiosErrorObject","request","response","config","httpErrorType","httpErrorRequestUrl","httpErrorRequestMethod","method","status","data","stringifiedData","JSON","stringify","responseIsHTML","includes","httpErrorResponseData","httpErrorStatus","httpErrorMessage","processAxiosErrorAndThrow"],"sources":["../../src/auth/utils.js"],"sourcesContent":["// Lifted from here: https://regexr.com/3ok5o\nconst urlRegex = /([a-z]{1,2}tps?):\\/\\/((?:(?!(?:\\/|#|\\?|&)).)+)(?:(\\/(?:(?:(?:(?!(?:#|\\?|&)).)+\\/))?))?(?:((?:(?!(?:\\.|$|\\?|#)).)+))?(?:(\\.(?:(?!(?:\\?|$|#)).)+))?(?:(\\?(?:(?!(?:$|#)).)+))?(?:(#.+))?/;\nconst getUrlParts = (url) => {\n const found = url.match(urlRegex);\n try {\n const [\n fullUrl,\n protocol,\n domain,\n path,\n endFilename,\n endFileExtension,\n query,\n hash,\n ] = found;\n\n return {\n fullUrl,\n protocol,\n domain,\n path,\n endFilename,\n endFileExtension,\n query,\n hash,\n };\n } catch (e) {\n throw new Error(`Could not find url parts from ${url}.`);\n }\n};\n\nconst logFrontendAuthError = (loggingService, error) => {\n const prefixedMessageError = Object.create(error);\n prefixedMessageError.message = `[frontend-auth] ${error.message}`;\n loggingService.logError(prefixedMessageError, prefixedMessageError.customAttributes);\n};\n\nconst processAxiosError = (axiosErrorObject) => {\n const error = Object.create(axiosErrorObject);\n const { request, response, config } = error;\n\n if (!config) {\n error.customAttributes = {\n ...error.customAttributes,\n httpErrorType: 'unknown-api-request-error',\n };\n return error;\n }\n\n const {\n url: httpErrorRequestUrl,\n method: httpErrorRequestMethod,\n } = config;\n /* istanbul ignore else: difficult to enter the request-only error case in a unit test */\n if (response) {\n const { status, data } = response;\n const stringifiedData = JSON.stringify(data) || '(empty response)';\n const responseIsHTML = stringifiedData.includes('<!DOCTYPE html>');\n // Don't include data if it is just an HTML document, like a 500 error page.\n /* istanbul ignore next */\n const httpErrorResponseData = responseIsHTML ? '<Response is HTML>' : stringifiedData;\n error.customAttributes = {\n ...error.customAttributes,\n httpErrorType: 'api-response-error',\n httpErrorStatus: status,\n httpErrorResponseData,\n httpErrorRequestUrl,\n httpErrorRequestMethod,\n };\n error.message = `Axios Error (Response): ${status} ${httpErrorRequestUrl} ${httpErrorResponseData}`;\n } else if (request) {\n error.customAttributes = {\n ...error.customAttributes,\n httpErrorType: 'api-request-error',\n httpErrorMessage: error.message,\n httpErrorRequestUrl,\n httpErrorRequestMethod,\n };\n // This case occurs most likely because of intermittent internet connection issues\n // but it also, though less often, catches CORS or server configuration problems.\n error.message = `Axios Error (Request): ${error.message} (possible local connectivity issue) ${httpErrorRequestMethod} ${httpErrorRequestUrl}`;\n } else {\n error.customAttributes = {\n ...error.customAttributes,\n httpErrorType: 'api-request-config-error',\n httpErrorMessage: error.message,\n httpErrorRequestUrl,\n httpErrorRequestMethod,\n };\n error.message = `Axios Error (Config): ${error.message} ${httpErrorRequestMethod} ${httpErrorRequestUrl}`;\n }\n\n return error;\n};\n\nconst processAxiosErrorAndThrow = (axiosErrorObject) => {\n throw processAxiosError(axiosErrorObject);\n};\n\nexport {\n getUrlParts,\n logFrontendAuthError,\n processAxiosError,\n processAxiosErrorAndThrow,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["urlRegex","getUrlParts","url","found","match","_found","_slicedToArray","fullUrl","protocol","domain","path","endFilename","endFileExtension","query","hash","e","Error","concat","logFrontendAuthError","loggingService","error","prefixedMessageError","Object","create","message","logError","customAttributes","processAxiosError","axiosErrorObject","request","response","config","_objectSpread","httpErrorType","httpErrorRequestUrl","httpErrorRequestMethod","method","status","data","stringifiedData","JSON","stringify","responseIsHTML","includes","httpErrorResponseData","httpErrorStatus","httpErrorMessage","processAxiosErrorAndThrow"],"sources":["../../src/auth/utils.js"],"sourcesContent":["// Lifted from here: https://regexr.com/3ok5o\nconst urlRegex = /([a-z]{1,2}tps?):\\/\\/((?:(?!(?:\\/|#|\\?|&)).)+)(?:(\\/(?:(?:(?:(?!(?:#|\\?|&)).)+\\/))?))?(?:((?:(?!(?:\\.|$|\\?|#)).)+))?(?:(\\.(?:(?!(?:\\?|$|#)).)+))?(?:(\\?(?:(?!(?:$|#)).)+))?(?:(#.+))?/;\nconst getUrlParts = (url) => {\n const found = url.match(urlRegex);\n try {\n const [\n fullUrl,\n protocol,\n domain,\n path,\n endFilename,\n endFileExtension,\n query,\n hash,\n ] = found;\n\n return {\n fullUrl,\n protocol,\n domain,\n path,\n endFilename,\n endFileExtension,\n query,\n hash,\n };\n } catch (e) {\n throw new Error(`Could not find url parts from ${url}.`);\n }\n};\n\nconst logFrontendAuthError = (loggingService, error) => {\n const prefixedMessageError = Object.create(error);\n prefixedMessageError.message = `[frontend-auth] ${error.message}`;\n loggingService.logError(prefixedMessageError, prefixedMessageError.customAttributes);\n};\n\nconst processAxiosError = (axiosErrorObject) => {\n const error = Object.create(axiosErrorObject);\n const { request, response, config } = error;\n\n if (!config) {\n error.customAttributes = {\n ...error.customAttributes,\n httpErrorType: 'unknown-api-request-error',\n };\n return error;\n }\n\n const {\n url: httpErrorRequestUrl,\n method: httpErrorRequestMethod,\n } = config;\n /* istanbul ignore else: difficult to enter the request-only error case in a unit test */\n if (response) {\n const { status, data } = response;\n const stringifiedData = JSON.stringify(data) || '(empty response)';\n const responseIsHTML = stringifiedData.includes('<!DOCTYPE html>');\n // Don't include data if it is just an HTML document, like a 500 error page.\n /* istanbul ignore next */\n const httpErrorResponseData = responseIsHTML ? '<Response is HTML>' : stringifiedData;\n error.customAttributes = {\n ...error.customAttributes,\n httpErrorType: 'api-response-error',\n httpErrorStatus: status,\n httpErrorResponseData,\n httpErrorRequestUrl,\n httpErrorRequestMethod,\n };\n error.message = `Axios Error (Response): ${status} ${httpErrorRequestUrl} ${httpErrorResponseData}`;\n } else if (request) {\n error.customAttributes = {\n ...error.customAttributes,\n httpErrorType: 'api-request-error',\n httpErrorMessage: error.message,\n httpErrorRequestUrl,\n httpErrorRequestMethod,\n };\n // This case occurs most likely because of intermittent internet connection issues\n // but it also, though less often, catches CORS or server configuration problems.\n error.message = `Axios Error (Request): ${error.message} (possible local connectivity issue) ${httpErrorRequestMethod} ${httpErrorRequestUrl}`;\n } else {\n error.customAttributes = {\n ...error.customAttributes,\n httpErrorType: 'api-request-config-error',\n httpErrorMessage: error.message,\n httpErrorRequestUrl,\n httpErrorRequestMethod,\n };\n error.message = `Axios Error (Config): ${error.message} ${httpErrorRequestMethod} ${httpErrorRequestUrl}`;\n }\n\n return error;\n};\n\nconst processAxiosErrorAndThrow = (axiosErrorObject) => {\n throw processAxiosError(axiosErrorObject);\n};\n\nexport {\n getUrlParts,\n logFrontendAuthError,\n processAxiosError,\n processAxiosErrorAndThrow,\n};\n"],"mappings":";;;;;;;;;;;;AAAA;AACA,IAAMA,QAAQ,GAAG,uLAAuL;AACxM,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAIC,GAAG,EAAK;EAC3B,IAAMC,KAAK,GAAGD,GAAG,CAACE,KAAK,CAACJ,QAAQ,CAAC;EACjC,IAAI;IACF,IAAAK,MAAA,GAAAC,cAAA,CASIH,KAAK;MARPI,OAAO,GAAAF,MAAA;MACPG,QAAQ,GAAAH,MAAA;MACRI,MAAM,GAAAJ,MAAA;MACNK,IAAI,GAAAL,MAAA;MACJM,WAAW,GAAAN,MAA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