@edx/frontend-platform 1.15.5 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analytics/MockAnalyticsService.js.map +1 -1
- package/analytics/SegmentAnalyticsService.js.map +1 -1
- package/analytics/index.js.map +1 -1
- package/analytics/interface.js.map +1 -1
- package/auth/AxiosCsrfTokenService.js.map +1 -1
- package/auth/AxiosJwtAuthService.js.map +1 -1
- package/auth/AxiosJwtTokenService.js.map +1 -1
- package/auth/LocalForageCache.js +36 -8
- package/auth/LocalForageCache.js.map +1 -1
- package/auth/MockAuthService.js.map +1 -1
- package/auth/index.js.map +1 -1
- package/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -1
- package/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -1
- package/auth/interceptors/createRetryInterceptor.js.map +1 -1
- package/auth/interface.js.map +1 -1
- package/auth/utils.js.map +1 -1
- package/config.js.map +1 -1
- package/constants.js.map +1 -1
- package/i18n/countries.js.map +1 -1
- package/i18n/index.js +12 -18
- package/i18n/index.js.map +1 -1
- package/i18n/injectIntlWithShim.js +2 -2
- package/i18n/injectIntlWithShim.js.map +1 -1
- package/i18n/languages.js.map +1 -1
- package/i18n/lib.js +42 -17
- package/i18n/lib.js.map +1 -1
- package/i18n/scripts/transifex-utils.js.map +1 -1
- package/index.js.map +1 -1
- package/initialize.js.map +1 -1
- package/logging/MockLoggingService.js.map +1 -1
- package/logging/NewRelicLoggingService.js.map +1 -1
- package/logging/index.js.map +1 -1
- package/logging/interface.js.map +1 -1
- package/package.json +11 -8
- package/pubSub.js.map +1 -1
- package/react/AppContext.js.map +1 -1
- package/react/AppProvider.js +4 -4
- package/react/AppProvider.js.map +1 -1
- package/react/AuthenticatedPageRoute.js.map +1 -1
- package/react/ErrorBoundary.js.map +1 -1
- package/react/ErrorPage.js.map +1 -1
- package/react/LoginRedirect.js.map +1 -1
- package/react/OptionalReduxProvider.js.map +1 -1
- package/react/PageRoute.js.map +1 -1
- package/react/hooks.js.map +1 -1
- package/react/index.js.map +1 -1
- package/testing/index.js.map +1 -1
- package/testing/initializeMockApp.js.map +1 -1
- package/testing/mockMessages.js.map +1 -1
- package/utils.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"MockAnalyticsService.js","names":["MockAnalyticsService","httpClient","loggingService","jest","fn","hasIdentifyBeenCalled","logError","Promise","resolve","userId","Error","checkIdentifyCalled"],"sources":["../../src/analytics/MockAnalyticsService.js"],"sourcesContent":["/**\n * The MockAnalyticsService implements all functions of AnalyticsService as Jest mocks (jest.fn())).\n * It emulates the behavior of a real analytics service but witohut making any requests. It has no\n * other functionality.\n *\n * @implements {AnalyticsService}\n * @memberof module:Analytics\n */\nclass MockAnalyticsService {\n static hasIdentifyBeenCalled = false;\n\n constructor({ httpClient, loggingService }) {\n this.loggingService = loggingService;\n this.httpClient = httpClient;\n }\n\n checkIdentifyCalled = jest.fn(() => {\n if (!this.hasIdentifyBeenCalled) {\n this.loggingService.logError('Identify must be called before other tracking events.');\n }\n });\n\n /**\n * Returns a resolved promise.\n *\n * @returns {Promise} The promise returned by HttpClient.post.\n */\n sendTrackingLogEvent = jest.fn(() => Promise.resolve());\n\n /**\n * No-op, but records that identify has been called.\n *\n * @param {string} userId\n * @throws {Error} If userId argument is not supplied.\n */\n identifyAuthenticatedUser = jest.fn((userId) => {\n if (!userId) {\n throw new Error('UserId is required for identifyAuthenticatedUser.');\n }\n this.hasIdentifyBeenCalled = true;\n });\n\n /**\n * No-op, but records that it has been called to prevent double-identification.\n * @returns {Promise} A resolved promise.\n */\n identifyAnonymousUser = jest.fn(() => {\n this.hasIdentifyBeenCalled = true;\n return Promise.resolve();\n });\n\n /**\n * Logs the event to the console.\n *\n * Checks whether identify has been called, logging an error to the logging service if not.\n */\n sendTrackEvent = jest.fn(() => {\n this.checkIdentifyCalled();\n });\n\n /**\n * Logs the event to the console.\n *\n * Checks whether identify has been called, logging an error to the logging service if not.\n */\n sendPageEvent = jest.fn(() => {\n this.checkIdentifyCalled();\n });\n}\n\nexport default MockAnalyticsService;\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACMA,oB,6BAGJ,oCAA4C;EAAA;;EAAA,IAA9BC,UAA8B,QAA9BA,UAA8B;EAAA,IAAlBC,cAAkB,QAAlBA,cAAkB;;EAAA;;EAAA,6CAKtBC,IAAI,CAACC,EAAL,CAAQ,YAAM;IAClC,IAAI,CAAC,KAAI,CAACC,qBAAV,EAAiC;MAC/B,KAAI,CAACH,cAAL,CAAoBI,QAApB,CAA6B,uDAA7B;IACD;EACF,CAJqB,CALsB;;EAAA,8CAgBrBH,IAAI,CAACC,EAAL,CAAQ;IAAA,OAAMG,OAAO,CAACC,OAAR,EAAN;EAAA,CAAR,CAhBqB;;EAAA,mDAwBhBL,IAAI,CAACC,EAAL,CAAQ,UAACK,MAAD,EAAY;IAC9C,IAAI,CAACA,MAAL,EAAa;MACX,MAAM,IAAIC,KAAJ,CAAU,mDAAV,CAAN;IACD;;IACD,KAAI,CAACL,qBAAL,GAA6B,IAA7B;EACD,CAL2B,CAxBgB;;EAAA,+CAmCpBF,IAAI,CAACC,EAAL,CAAQ,YAAM;IACpC,KAAI,CAACC,qBAAL,GAA6B,IAA7B;IACA,OAAOE,OAAO,CAACC,OAAR,EAAP;EACD,CAHuB,CAnCoB;;EAAA,wCA6C3BL,IAAI,CAACC,EAAL,CAAQ,YAAM;IAC7B,KAAI,CAACO,mBAAL;EACD,CAFgB,CA7C2B;;EAAA,uCAsD5BR,IAAI,CAACC,EAAL,CAAQ,YAAM;IAC5B,KAAI,CAACO,mBAAL;EACD,CAFe,CAtD4B;;EAC1C,KAAKT,cAAL,GAAsBA,cAAtB;EACA,KAAKD,UAAL,GAAkBA,UAAlB;AACD,C;;gBANGD,oB,2BAC2B,K;;AA6DjC,eAAeA,oBAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/analytics/SegmentAnalyticsService.js"],"names":["formurlencoded","snakeCaseObject","SegmentAnalyticsService","httpClient","loggingService","config","trackingLogApiUrl","LMS_BASE_URL","segmentKey","SEGMENT_KEY","hasIdentifyBeenCalled","segmentInitialized","initializeSegment","global","analytics","initialize","invoked","methods","factory","method","args","unshift","push","forEach","key","load","options","script","document","createElement","type","onerror","event","Event","dispatchEvent","async","src","first","getElementsByTagName","parentNode","insertBefore","_loadOptions","SNIPPET_VERSION","logError","eventName","properties","snakeEventData","deep","serverData","event_type","JSON","stringify","page","location","href","post","headers","error","userId","traits","Error","identify","Promise","resolve","reject","ready","user","id","reset","addEventListener","setTimeout","ga","create","google_tag_manager","checkIdentifyCalled","track","category","name"],"mappings":";;;;;;AAAA,OAAOA,cAAP,MAA2B,iBAA3B;AACA,SAASC,eAAT,QAAgC,UAAhC;AAEA;AACA;AACA;AACA;;IACMC,uB;AACJ,yCAAoD;AAAA,QAAtCC,UAAsC,QAAtCA,UAAsC;AAAA,QAA1BC,cAA0B,QAA1BA,cAA0B;AAAA,QAAVC,MAAU,QAAVA,MAAU;;AAAA;;AAClD,SAAKD,cAAL,GAAsBA,cAAtB;AACA,SAAKD,UAAL,GAAkBA,UAAlB;AACA,SAAKG,iBAAL,aAA4BD,MAAM,CAACE,YAAnC;AACA,SAAKC,UAAL,GAAkBH,MAAM,CAACI,WAAzB;AACA,SAAKC,qBAAL,GAA6B,KAA7B;AACA,SAAKC,kBAAL,GAA0B,KAA1B;;AAEA,QAAI,KAAKH,UAAT,EAAqB;AACnB,WAAKI,iBAAL;AACD;AACF,G,CAED;AACA;AACA;AACA;AACA;AACA;;;;;WACA,6BAAoB;AAAA;;AAClB;AACAC,MAAAA,MAAM,CAACC,SAAP,GAAmBD,MAAM,CAACC,SAAP,IAAoB,EAAvC;AACA,oBAAsBD,MAAtB;AAAA,UAAQC,SAAR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AAAA,OAAO;AACR,SAPD,EADsC,CAUtC;AACA;AACA;;AACAnC,QAAAA,QAAQ,CAACyC,gBAAT,CAA0B,eAA1B,EAA2CN,OAA3C,EAbsC,CActC;AACA;;AACAO,QAAAA,UAAU,CAAC,YAAM;AACf,cAAI,CAACzD,MAAM,CAAC0D,EAAR,IAAc,CAAC1D,MAAM,CAAC0D,EAAP,CAAUC,MAAzB,IAAmC,CAAC3D,MAAM,CAAC4D,kBAA/C,EAAmE;AACjE,YAAA,MAAI,CAAC9D,kBAAL,GAA0B,KAA1B;AACAoD,YAAAA,OAAO;AACR;AACF,SALS,EAKP,IALO,CAAV;AAMD,OAtBM,CAAP;AAuBD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;;WACE,wBAAenB,SAAf,EAA0BC,UAA1B,EAAsC;AACpC,UAAI,CAAC,KAAKlC,kBAAV,EAA8B;AAC5B;AACD;;AACD,WAAK+D,mBAAL;AACA7D,MAAAA,MAAM,CAACC,SAAP,CAAiB6D,KAAjB,CAAuB/B,SAAvB,EAAkCC,UAAlC;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;;WACE,uBAAc+B,QAAd,EAAwBC,IAAxB,EAA8BhC,UAA9B,EAA0C;AACxC,UAAI,CAAC,KAAKlC,kBAAV,EAA8B;AAC5B;AACD;;AACD,WAAK+D,mBAAL;AACA7D,MAAAA,MAAM,CAACC,SAAP,CAAiBsC,IAAjB,CAAsBwB,QAAtB,EAAgCC,IAAhC,EAAsChC,UAAtC;AACD;;;;;;AAGH,eAAe3C,uBAAf","sourcesContent":["import formurlencoded from 'form-urlencoded';\nimport { snakeCaseObject } from '../utils';\n\n/**\n * @implements {AnalyticsService}\n * @memberof module:Analytics\n */\nclass SegmentAnalyticsService {\n constructor({ httpClient, loggingService, config }) {\n this.loggingService = loggingService;\n this.httpClient = httpClient;\n this.trackingLogApiUrl = `${config.LMS_BASE_URL}/event`;\n this.segmentKey = config.SEGMENT_KEY;\n this.hasIdentifyBeenCalled = false;\n this.segmentInitialized = false;\n\n if (this.segmentKey) {\n this.initializeSegment();\n }\n }\n\n // The code in this function is from Segment's website, with a few updates:\n // - It uses the segmentKey from the SegmentAnalyticsService instance.\n // - It also saves a \"segmentInitialized\" variable on the SegmentAnalyticsService instance so\n // that the service can keep track of its own initialization state.\n // Reference:\n // https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/\n initializeSegment() {\n // Create a queue, but don't obliterate an existing one!\n global.analytics = global.analytics || [];\n const { analytics } = global;\n\n // If the real analytics.js is already on the page return.\n if (analytics.initialize) {\n this.segmentInitialized = true;\n return;\n }\n\n // If the snippet was invoked do nothing.\n if (analytics.invoked) {\n this.segmentInitialized = true;\n return;\n }\n\n // Invoked flag, to make sure the snippet\n // is never invoked twice.\n analytics.invoked = true;\n\n // A list of the methods in Analytics.js to stub.\n analytics.methods = [\n 'trackSubmit',\n 'trackClick',\n 'trackLink',\n 'trackForm',\n 'pageview',\n 'identify',\n 'reset',\n 'group',\n 'track',\n 'ready',\n 'alias',\n 'debug',\n 'page',\n 'once',\n 'off',\n 'on',\n ];\n\n // Define a factory to create stubs. These are placeholders\n // for methods in Analytics.js so that you never have to wait\n // for it to load to actually record data. The `method` is\n // stored as the first argument, so we can replay the data.\n analytics.factory = method => ((...args) => {\n args.unshift(method);\n analytics.push(args);\n return analytics;\n });\n\n // For each of our methods, generate a queueing stub.\n analytics.methods.forEach((key) => {\n analytics[key] = analytics.factory(key);\n });\n\n // Define a method to load Analytics.js from our CDN,\n // and that will be sure to only ever load it once.\n analytics.load = (key, options) => {\n // Create an async script element based on your key.\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.onerror = () => {\n this.segmentInitialized = false;\n const event = new Event('segmentFailed');\n document.dispatchEvent(event);\n };\n script.async = true;\n script.src = `https://cdn.segment.com/analytics.js/v1/${key}/analytics.min.js`;\n\n // Insert our script next to the first script element.\n const first = document.getElementsByTagName('script')[0];\n first.parentNode.insertBefore(script, first);\n analytics._loadOptions = options; // eslint-disable-line no-underscore-dangle\n\n this.segmentInitialized = true;\n };\n\n // Add a version to keep track of what's in the wild.\n analytics.SNIPPET_VERSION = '4.1.0';\n\n // Load Analytics.js with your key, which will automatically\n // load the tools you've enabled for your account. Boosh!\n analytics.load(this.segmentKey);\n }\n\n /**\n * Checks that identify was first called. Otherwise, logs error.\n *\n */\n checkIdentifyCalled() {\n if (!this.hasIdentifyBeenCalled) {\n this.loggingService.logError('Identify must be called before other tracking events.');\n }\n }\n\n /**\n * Logs events to tracking log and downstream.\n * For tracking log event documentation, see\n * https://openedx.atlassian.net/wiki/spaces/AN/pages/13205895/Event+Design+and+Review+Process\n *\n * @param {string} eventName (event_type on backend, but named to match Segment api)\n * @param {Object} properties (event on backend, but named properties to match Segment api)\n * @returns {Promise} The promise returned by HttpClient.post.\n */\n sendTrackingLogEvent(eventName, properties) {\n const snakeEventData = snakeCaseObject(properties, { deep: true });\n const serverData = {\n event_type: eventName,\n event: JSON.stringify(snakeEventData),\n page: global.location.href,\n };\n return this.httpClient.post(\n this.trackingLogApiUrl,\n formurlencoded(serverData),\n {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n },\n ).catch((error) => {\n this.loggingService.logError(error);\n });\n }\n\n /**\n * * Send identify call to Segment.\n *\n * @param {string} userId\n * @param {*} [traits]\n */\n identifyAuthenticatedUser(userId, traits) {\n if (!userId) {\n throw new Error('UserId is required for identifyAuthenticatedUser.');\n }\n\n if (!this.segmentInitialized) {\n return;\n }\n global.analytics.identify(userId, traits);\n this.hasIdentifyBeenCalled = true;\n }\n\n /**\n * Send anonymous identify call to Segment's identify.\n *\n * @param {*} [traits]\n * @returns {Promise} Promise that will resolve once the document readyState is complete\n */\n identifyAnonymousUser(traits) {\n if (!this.segmentInitialized) {\n return Promise.resolve();\n }\n // if we do not have an authenticated user (indicated by being in this method),\n // but we still have a user id associated in segment, reset the local segment state\n // This has to be wrapped in the analytics.ready() callback because the analytics.user()\n // function isn't available until the analytics.js package has finished initializing.\n return new Promise((resolve, reject) => { // eslint-disable-line no-unused-vars\n global.analytics.ready(() => {\n if (global.analytics.user().id()) {\n global.analytics.reset();\n }\n global.analytics.identify(traits);\n this.hasIdentifyBeenCalled = true;\n resolve();\n });\n\n // this is added to handle a specific use-case where if a user has blocked the analytics\n // tools in their browser, this promise does not get resolved and user sees a blank\n // page. Dispatching this event in script.onerror callback in analytics.load.\n document.addEventListener('segmentFailed', resolve);\n // This is added to handle the google analytics blocked case which is injected into\n // the DOM by segment.min.js.\n setTimeout(() => {\n if (!global.ga || !global.ga.create || !global.google_tag_manager) {\n this.segmentInitialized = false;\n resolve();\n }\n }, 2000);\n });\n }\n\n /**\n * Sends a track event to Segment and downstream.\n * Note: For links and forms, you should use trackLink and trackForm instead.\n *\n * @param {*} eventName\n * @param {*} [properties]\n */\n sendTrackEvent(eventName, properties) {\n if (!this.segmentInitialized) {\n return;\n }\n this.checkIdentifyCalled();\n global.analytics.track(eventName, properties);\n }\n\n /**\n * Sends a page event to Segment and downstream.\n *\n * @param {*} [name] If only one string arg provided, assumed to be name.\n * @param {*} [category] Name is required to pass a category.\n * @param {*} [properties]\n */\n sendPageEvent(category, name, properties) {\n if (!this.segmentInitialized) {\n return;\n }\n this.checkIdentifyCalled();\n global.analytics.page(category, name, properties);\n }\n}\n\nexport default SegmentAnalyticsService;\n"],"file":"SegmentAnalyticsService.js"}
|
|
1
|
+
{"version":3,"file":"SegmentAnalyticsService.js","names":["formurlencoded","snakeCaseObject","SegmentAnalyticsService","httpClient","loggingService","config","trackingLogApiUrl","LMS_BASE_URL","segmentKey","SEGMENT_KEY","hasIdentifyBeenCalled","segmentInitialized","initializeSegment","global","analytics","initialize","invoked","methods","factory","method","args","unshift","push","forEach","key","load","options","script","document","createElement","type","onerror","event","Event","dispatchEvent","async","src","first","getElementsByTagName","parentNode","insertBefore","_loadOptions","SNIPPET_VERSION","logError","eventName","properties","snakeEventData","deep","serverData","event_type","JSON","stringify","page","location","href","post","headers","error","userId","traits","Error","identify","Promise","resolve","reject","ready","user","id","reset","addEventListener","setTimeout","ga","create","google_tag_manager","checkIdentifyCalled","track","category","name"],"sources":["../../src/analytics/SegmentAnalyticsService.js"],"sourcesContent":["import formurlencoded from 'form-urlencoded';\nimport { snakeCaseObject } from '../utils';\n\n/**\n * @implements {AnalyticsService}\n * @memberof module:Analytics\n */\nclass SegmentAnalyticsService {\n constructor({ httpClient, loggingService, config }) {\n this.loggingService = loggingService;\n this.httpClient = httpClient;\n this.trackingLogApiUrl = `${config.LMS_BASE_URL}/event`;\n this.segmentKey = config.SEGMENT_KEY;\n this.hasIdentifyBeenCalled = false;\n this.segmentInitialized = false;\n\n if (this.segmentKey) {\n this.initializeSegment();\n }\n }\n\n // The code in this function is from Segment's website, with a few updates:\n // - It uses the segmentKey from the SegmentAnalyticsService instance.\n // - It also saves a \"segmentInitialized\" variable on the SegmentAnalyticsService instance so\n // that the service can keep track of its own initialization state.\n // Reference:\n // https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/\n initializeSegment() {\n // Create a queue, but don't obliterate an existing one!\n global.analytics = global.analytics || [];\n const { analytics } = global;\n\n // If the real analytics.js is already on the page return.\n if (analytics.initialize) {\n this.segmentInitialized = true;\n return;\n }\n\n // If the snippet was invoked do nothing.\n if (analytics.invoked) {\n this.segmentInitialized = true;\n return;\n }\n\n // Invoked flag, to make sure the snippet\n // is never invoked twice.\n analytics.invoked = true;\n\n // A list of the methods in Analytics.js to stub.\n analytics.methods = [\n 'trackSubmit',\n 'trackClick',\n 'trackLink',\n 'trackForm',\n 'pageview',\n 'identify',\n 'reset',\n 'group',\n 'track',\n 'ready',\n 'alias',\n 'debug',\n 'page',\n 'once',\n 'off',\n 'on',\n ];\n\n // Define a factory to create stubs. These are placeholders\n // for methods in Analytics.js so that you never have to wait\n // for it to load to actually record data. The `method` is\n // stored as the first argument, so we can replay the data.\n analytics.factory = method => ((...args) => {\n args.unshift(method);\n analytics.push(args);\n return analytics;\n });\n\n // For each of our methods, generate a queueing stub.\n analytics.methods.forEach((key) => {\n analytics[key] = analytics.factory(key);\n });\n\n // Define a method to load Analytics.js from our CDN,\n // and that will be sure to only ever load it once.\n analytics.load = (key, options) => {\n // Create an async script element based on your key.\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.onerror = () => {\n this.segmentInitialized = false;\n const event = new Event('segmentFailed');\n document.dispatchEvent(event);\n };\n script.async = true;\n script.src = `https://cdn.segment.com/analytics.js/v1/${key}/analytics.min.js`;\n\n // Insert our script next to the first script element.\n const first = document.getElementsByTagName('script')[0];\n first.parentNode.insertBefore(script, first);\n analytics._loadOptions = options; // eslint-disable-line no-underscore-dangle\n\n this.segmentInitialized = true;\n };\n\n // Add a version to keep track of what's in the wild.\n analytics.SNIPPET_VERSION = '4.1.0';\n\n // Load Analytics.js with your key, which will automatically\n // load the tools you've enabled for your account. Boosh!\n analytics.load(this.segmentKey);\n }\n\n /**\n * Checks that identify was first called. Otherwise, logs error.\n *\n */\n checkIdentifyCalled() {\n if (!this.hasIdentifyBeenCalled) {\n this.loggingService.logError('Identify must be called before other tracking events.');\n }\n }\n\n /**\n * Logs events to tracking log and downstream.\n * For tracking log event documentation, see\n * https://openedx.atlassian.net/wiki/spaces/AN/pages/13205895/Event+Design+and+Review+Process\n *\n * @param {string} eventName (event_type on backend, but named to match Segment api)\n * @param {Object} properties (event on backend, but named properties to match Segment api)\n * @returns {Promise} The promise returned by HttpClient.post.\n */\n sendTrackingLogEvent(eventName, properties) {\n const snakeEventData = snakeCaseObject(properties, { deep: true });\n const serverData = {\n event_type: eventName,\n event: JSON.stringify(snakeEventData),\n page: global.location.href,\n };\n return this.httpClient.post(\n this.trackingLogApiUrl,\n formurlencoded(serverData),\n {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n },\n ).catch((error) => {\n this.loggingService.logError(error);\n });\n }\n\n /**\n * * Send identify call to Segment.\n *\n * @param {string} userId\n * @param {*} [traits]\n */\n identifyAuthenticatedUser(userId, traits) {\n if (!userId) {\n throw new Error('UserId is required for identifyAuthenticatedUser.');\n }\n\n if (!this.segmentInitialized) {\n return;\n }\n global.analytics.identify(userId, traits);\n this.hasIdentifyBeenCalled = true;\n }\n\n /**\n * Send anonymous identify call to Segment's identify.\n *\n * @param {*} [traits]\n * @returns {Promise} Promise that will resolve once the document readyState is complete\n */\n identifyAnonymousUser(traits) {\n if (!this.segmentInitialized) {\n return Promise.resolve();\n }\n // if we do not have an authenticated user (indicated by being in this method),\n // but we still have a user id associated in segment, reset the local segment state\n // This has to be wrapped in the analytics.ready() callback because the analytics.user()\n // function isn't available until the analytics.js package has finished initializing.\n return new Promise((resolve, reject) => { // eslint-disable-line no-unused-vars\n global.analytics.ready(() => {\n if (global.analytics.user().id()) {\n global.analytics.reset();\n }\n global.analytics.identify(traits);\n this.hasIdentifyBeenCalled = true;\n resolve();\n });\n\n // this is added to handle a specific use-case where if a user has blocked the analytics\n // tools in their browser, this promise does not get resolved and user sees a blank\n // page. Dispatching this event in script.onerror callback in analytics.load.\n document.addEventListener('segmentFailed', resolve);\n // This is added to handle the google analytics blocked case which is injected into\n // the DOM by segment.min.js.\n setTimeout(() => {\n if (!global.ga || !global.ga.create || !global.google_tag_manager) {\n this.segmentInitialized = false;\n resolve();\n }\n }, 2000);\n });\n }\n\n /**\n * Sends a track event to Segment and downstream.\n * Note: For links and forms, you should use trackLink and trackForm instead.\n *\n * @param {*} eventName\n * @param {*} [properties]\n */\n sendTrackEvent(eventName, properties) {\n if (!this.segmentInitialized) {\n return;\n }\n this.checkIdentifyCalled();\n global.analytics.track(eventName, properties);\n }\n\n /**\n * Sends a page event to Segment and downstream.\n *\n * @param {*} [name] If only one string arg provided, assumed to be name.\n * @param {*} [category] Name is required to pass a category.\n * @param {*} [properties]\n */\n sendPageEvent(category, name, properties) {\n if (!this.segmentInitialized) {\n return;\n }\n this.checkIdentifyCalled();\n global.analytics.page(category, name, properties);\n }\n}\n\nexport default SegmentAnalyticsService;\n"],"mappings":";;;;;;AAAA,O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ACD,KAAK+D,mBAAL;MACA7D,MAAM,CAACC,SAAP,CAAiBsC,IAAjB,CAAsBwB,QAAtB,EAAgCC,IAAhC,EAAsChC,UAAtC;IACD;;;;;;AAGH,eAAe3C,uBAAf"}
|
package/analytics/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["configure","identifyAnonymousUser","identifyAuthenticatedUser","sendPageEvent","sendTrackEvent","sendTrackingLogEvent","getAnalyticsService","resetAnalyticsService","default","SegmentAnalyticsService","MockAnalyticsService"],"sources":["../../src/analytics/index.js"],"sourcesContent":["export {\n configure,\n identifyAnonymousUser,\n identifyAuthenticatedUser,\n sendPageEvent,\n sendTrackEvent,\n sendTrackingLogEvent,\n getAnalyticsService,\n resetAnalyticsService,\n} from './interface';\nexport { default as SegmentAnalyticsService } from './SegmentAnalyticsService';\nexport { default as MockAnalyticsService } from './MockAnalyticsService';\n"],"mappings":"AAAA,SACEA,SADF,EAEEC,qBAFF,EAGEC,yBAHF,EAIEC,aAJF,EAKEC,cALF,EAMEC,oBANF,EAOEC,mBAPF,EAQEC,qBARF,QASO,aATP;AAUA,SAASC,OAAO,IAAIC,uBAApB,QAAmD,2BAAnD;AACA,SAASD,OAAO,IAAIE,oBAApB,QAAgD,wBAAhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"interface.js","names":["PropTypes","optionsShape","config","object","isRequired","httpClient","oneOfType","func","loggingService","shape","logError","logInfo","serviceShape","sendTrackingLogEvent","identifyAuthenticatedUser","identifyAnonymousUser","sendTrackEvent","sendPageEvent","service","configure","AnalyticsService","options","checkPropTypes","eventName","properties","userId","traits","category","name","getAnalyticsService","Error","resetAnalyticsService"],"sources":["../../src/analytics/interface.js"],"sourcesContent":["/**\n * #### Import members from **@edx/frontend-platform/analytics**\n *\n * Contains a shared interface for tracking events. Has a default implementation of\n * SegmentAnalyticsService, which supports Segment and the Tracking Log API (hosted in LMS).\n *\n * The `initialize` function performs much of the analytics configuration for you. If, however,\n * you're not using the `initialize` function, analytics can be configured via:\n *\n * ```\n * import { configure, SegmentAnalyticsService } from '@edx/frontend-platform/analytics';\n * import { getConfig } from '@edx/frontend-platform';\n * import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';\n * import { getLoggingService } from '@edx/frontend-platform/logging';\n *\n * configure(SegmentAnalyticsService, {\n * config: getConfig(),\n * loggingService: getLoggingService(),\n * httpClient: getAuthenticatedHttpClient(),\n * });\n * ```\n *\n * As shown in this example, analytics depends on the configuration document, logging, and having\n * an authenticated HTTP client.\n *\n * @module Analytics\n */\nimport PropTypes from 'prop-types';\n\nconst optionsShape = {\n config: PropTypes.object.isRequired,\n httpClient: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,\n loggingService: PropTypes.shape({\n logError: PropTypes.func.isRequired,\n logInfo: PropTypes.func.isRequired,\n }).isRequired,\n};\n\nconst serviceShape = {\n sendTrackingLogEvent: PropTypes.func.isRequired,\n identifyAuthenticatedUser: PropTypes.func.isRequired,\n identifyAnonymousUser: PropTypes.func.isRequired,\n sendTrackEvent: PropTypes.func.isRequired,\n sendPageEvent: PropTypes.func.isRequired,\n};\n\nlet service;\n\n/**\n *\n * @param {class} AnalyticsService\n * @param {*} options\n * @returns {AnalyticsService}\n */\nexport function configure(AnalyticsService, options) {\n PropTypes.checkPropTypes(optionsShape, options, 'property', 'Analytics');\n service = new AnalyticsService(options);\n PropTypes.checkPropTypes(serviceShape, service, 'property', 'AnalyticsService');\n return service;\n}\n\n/**\n *\n * @param {*} eventName\n * @param {*} properties\n * @returns {Promise}\n */\nexport function sendTrackingLogEvent(eventName, properties) {\n return service.sendTrackingLogEvent(eventName, properties);\n}\n\n/**\n *\n *\n * @param {*} userId\n * @param {*} traits\n */\nexport function identifyAuthenticatedUser(userId, traits) {\n service.identifyAuthenticatedUser(userId, traits);\n}\n\n/**\n *\n *\n * @param {*} traits\n * @returns {Promise}\n */\nexport function identifyAnonymousUser(traits) {\n return service.identifyAnonymousUser(traits);\n}\n\n/**\n *\n *\n * @param {*} eventName\n * @param {*} properties\n */\nexport function sendTrackEvent(eventName, properties) {\n service.sendTrackEvent(eventName, properties);\n}\n\n/**\n *\n *\n * @param {*} category\n * @param {*} name\n * @param {*} properties\n */\nexport function sendPageEvent(category, name, properties) {\n service.sendPageEvent(category, name, properties);\n}\n\n/**\n *\n *\n * @returns {AnalyticsService}\n */\nexport function getAnalyticsService() {\n if (!service) {\n throw Error('You must first configure the analytics service.');\n }\n\n return service;\n}\n\n/**\n *\n */\nexport function resetAnalyticsService() {\n service = null;\n}\n\n/**\n * @name AnalyticsService\n * @interface\n * @memberof module:Analytics\n * @property {function} identifyAnonymousUser\n * @property {function} identifyAuthenticatedUser\n * @property {function} sendPageEvent\n * @property {function} sendTrackEvent\n * @property {function} sendTrackingLogEvent\n */\n"],"mappings":"AAAA;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;AAEA,IAAMC,YAAY,GAAG;EACnBC,MAAM,EAAEF,SAAS,CAACG,MAAV,CAAiBC,UADN;EAEnBC,UAAU,EAAEL,SAAS,CAACM,SAAV,CAAoB,CAACN,SAAS,CAACO,IAAX,EAAiBP,SAAS,CAACG,MAA3B,CAApB,EAAwDC,UAFjD;EAGnBI,cAAc,EAAER,SAAS,CAACS,KAAV,CAAgB;IAC9BC,QAAQ,EAAEV,SAAS,CAACO,IAAV,CAAeH,UADK;IAE9BO,OAAO,EAAEX,SAAS,CAACO,IAAV,CAAeH;EAFM,CAAhB,EAGbA;AANgB,CAArB;AASA,IAAMQ,YAAY,GAAG;EACnBC,oBAAoB,EAAEb,SAAS,CAACO,IAAV,CAAeH,UADlB;EAEnBU,yBAAyB,EAAEd,SAAS,CAACO,IA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U,QAAvB,EAAiCC,IAAjC,EAAuCJ,UAAvC,EAAmD;EACxDN,OAAO,CAACD,aAAR,CAAsBU,QAAtB,EAAgCC,IAAhC,EAAsCJ,UAAtC;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,mBAAT,GAA+B;EACpC,IAAI,CAACX,OAAL,EAAc;IACZ,MAAMY,KAAK,CAAC,iDAAD,CAAX;EACD;;EAED,OAAOZ,OAAP;AACD;AAED;AACA;AACA;;AACA,OAAO,SAASa,qBAAT,GAAiC;EACtCb,OAAO,GAAG,IAAV;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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;YAAA;cAAA;gBAEE,IAAI;kBACFC,QAAQ,GAAGb,WAAW,CAACY,GAAD,CAAtB;gBACD,CAFD,CAEE,OAAOE,CAAP,EAAU;kBACV;kBACA;kBACA;kBACAD,QAAQ,GAAGb,WAAW,CAACe,MAAM,CAACC,QAAP,CAAgBC,MAAjB,CAAtB;gBACD;;gBATH,YAW+BJ,QAX/B,EAWUK,QAXV,aAWUA,QAXV,EAWoBC,MAXpB,aAWoBA,MAXpB;gBAYQC,SAZR,GAYoB,KAAKV,cAAL,CAAoBS,MAApB,CAZpB;;gBAAA,KAcMC,SAdN;kBAAA;kBAAA;gBAAA;;gBAAA,iCAeWA,SAfX;;cAAA;gBAkBE,IAAI,CAAC,KAAKT,wBAAL,CAA8BQ,MAA9B,CAAL,EAA4C;kBAC1C,KAAKR,wBAAL,CAA8BQ,MAA9B,IAAwC,KAAKf,UAAL,CACrCiB,GADqC,WAC9BH,QAD8B,gBAChBC,MADgB,SACP,KAAKhB,gBADE,GAErCmB,IAFqC,CAEhC,UAACC,QAAD,EAAc;oBAClB,KAAI,CAACb,cAAL,CAAoBS,MAApB,IAA8BI,QAAQ,CAACC,IAAT,CAAcJ,SAA5C;oBACA,OAAO,KAAI,CAACV,cAAL,CAAoBS,MAApB,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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/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","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"],"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;AACvBC,EAAAA,MAAM,EAAEX,SAAS,CAACY,KAAV,CAAgB;AACtBC,IAAAA,QAAQ,EAAEb,SAAS,CAACc,MAAV,CAAiBC,UADL;AAEtBC,IAAAA,YAAY,EAAEhB,SAAS,CAACc,MAAV,CAAiBC,UAFT;AAGtBE,IAAAA,SAAS,EAAEjB,SAAS,CA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CAAC;AACpE8B,QAAAA,gBAAgB,EAAE,KAAKA,gBAD6C;AAEpEd,QAAAA,mBAAmB,EAAE,KAAKV,MAAL,CAAYU,mBAFmC;AAGpE8D,QAAAA,UAAU,EAAE,oBAACC,kBAAD,EAAwB;AAClC,cAAQG,MAAR,GAAiCH,kBAAjC,CAAQG,MAAR;AAAA,cAAgBC,YAAhB,GAAiCJ,kBAAjC,CAAgBI,YAAhB;AACA,cAAMC,sBAAsB,GAAG,CAAC,MAAD,EAAS,KAAT,EAAgB,OAAhB,EAAyB,QAAzB,CAA/B;AACA,iBAAOD,YAAY,IAAI,CAACC,sBAAsB,CAACC,QAAvB,CAAgCH,MAAhC,CAAxB;AACD;AAPmE,OAAD,CAArE;AAUA,UAAMI,mCAAmC,GAAGrF,yCAAyC,CAAC;AACpFgB,QAAAA,cAAc,EAAE,KAAKA;AAD+D,OAAD,CAArF,CA7B2C,CAiC3C;AACA;AACA;AACA;;AACAO,MAAAA,UAAU,CAAC+D,YAAX,CAAwBC,OAAxB,CAAgCC,GAAhC,CAAoCR,0BAApC;AACAzD,MAAAA,UAAU,CAAC+D,YAAX,CAAwBC,OAAxB,CAAgCC,GAAhC,CAAoCZ,6BAApC,EAtC2C,CAwC3C;AACA;;AACArD,MAAAA,UAAU,CAAC+D,YAAX,CAAwBhB,QAAxB,CAAiCkB,GAAjC,CACE,UAAAlB,QAAQ;AAAA,eAAIA,QAAJ;AAAA,OADV,EAEEe,mCAFF;AAKA,aAAO9D,UAAP;AACD;;;;;;AAGH,eAAeH,mBAAf","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\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 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 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"],"file":"AxiosJwtAuthService.js"}
|
|
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","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\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 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 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,CAAg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FmC;QAGpE8D,UAAU,EAAE,oBAACC,kBAAD,EAAwB;UAClC,IAAQG,MAAR,GAAiCH,kBAAjC,CAAQG,MAAR;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,GAAGrF,yCAAyC,CAAC;QACpFgB,cAAc,EAAE,KAAKA;MAD+D,CAAD,CAArF,CA7B2C,CAiC3C;MACA;MACA;MACA;;MACAO,UAAU,CAAC+D,YAAX,CAAwBC,OAAxB,CAAgCC,GAAhC,CAAoCR,0BAApC;MACAzD,UAAU,CAAC+D,YAAX,CAAwBC,OAAxB,CAAgCC,GAAhC,CAAoCZ,6BAApC,EAtC2C,CAwC3C;MACA;;MACArD,UAAU,CAAC+D,YAAX,CAAwBhB,QAAxB,CAAiCkB,GAAjC,CACE,UAAAlB,QAAQ;QAAA,OAAIA,QAAJ;MAAA,CADV,EAEEe,mCAFF;MAKA,OAAO9D,UAAP;IACD;;;;;;AAGH,eAAeH,mBAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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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@@ export default function configureCache() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function _configureCache() {
|
|
21
|
-
_configureCache = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
21
|
+
_configureCache = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
22
22
|
var forageStore;
|
|
23
|
-
return regeneratorRuntime.wrap(function
|
|
23
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
24
24
|
while (1) {
|
|
25
|
-
switch (
|
|
25
|
+
switch (_context2.prev = _context2.next) {
|
|
26
26
|
case 0:
|
|
27
|
-
|
|
27
|
+
_context2.next = 2;
|
|
28
28
|
return localforage.defineDriver(memoryDriver);
|
|
29
29
|
|
|
30
30
|
case 2:
|
|
@@ -35,22 +35,50 @@ function _configureCache() {
|
|
|
35
35
|
name: 'edx-cache'
|
|
36
36
|
}); // Set up the cache with a default maxAge of 5 minutes and using localforage as the storage source
|
|
37
37
|
|
|
38
|
-
return
|
|
38
|
+
return _context2.abrupt("return", setup({
|
|
39
39
|
cache: {
|
|
40
40
|
maxAge: 5 * 60 * 1000,
|
|
41
41
|
store: forageStore,
|
|
42
42
|
exclude: {
|
|
43
43
|
query: false
|
|
44
|
-
}
|
|
44
|
+
},
|
|
45
|
+
invalidate: function () {
|
|
46
|
+
var _invalidate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(config, request) {
|
|
47
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
48
|
+
while (1) {
|
|
49
|
+
switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
if (!request.clearCacheEntry) {
|
|
52
|
+
_context.next = 3;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_context.next = 3;
|
|
57
|
+
return config.store.removeItem(config.uuid);
|
|
58
|
+
|
|
59
|
+
case 3:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, _callee);
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
function invalidate(_x, _x2) {
|
|
68
|
+
return _invalidate.apply(this, arguments);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return invalidate;
|
|
72
|
+
}()
|
|
45
73
|
}
|
|
46
74
|
}));
|
|
47
75
|
|
|
48
76
|
case 4:
|
|
49
77
|
case "end":
|
|
50
|
-
return
|
|
78
|
+
return _context2.stop();
|
|
51
79
|
}
|
|
52
80
|
}
|
|
53
|
-
},
|
|
81
|
+
}, _callee2);
|
|
54
82
|
}));
|
|
55
83
|
return _configureCache.apply(this, arguments);
|
|
56
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/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"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,mBAAT,QAAoC,UAApC;AAEA,IAAMC,aAAa,GAAGF,SAAS,CAACG,KAAV,CAAgB;AACpCC,EAAAA,MAAM,EAAEJ,SAAS,CAACK,MAAV,CAAiBC,UADW;AAEpCC,EAAAA,QAAQ,EAAEP,SAAS,CAACK,MAAV,CAAiBC,UAFS;AAGpCE,EAAAA,KAAK,EAAER,SAAS,CAACS,OAAV,CAAkBT,SAAS,CAACK,MAA5B,CAH6B;AAIpCK,EAAAA,aAAa,EAAEV,SAAS;AAJY,CAAhB,CAAtB;AAOA,IAAMW,gBAAgB,GAAG;AACvBC,EAAAA,MAAM,EAAEZ,SAAS,CAACG,KAAV,CAAgB;AACtBU,IAAAA,QAAQ,EAAEb,SAAS,CAACK,MAAV,CAAiBC,UADL;AAEtBQ,IAAAA,YAAY,EAAEd,SAAS,CAACK,MAAV,CAAiBC,UAFT;AAGtBS,IAAAA,SAAS,EAAEf,SAAS,CAACK,MAAV,CAAiBC,UAHN;AAItBU,IAAAA,UAAU,EAAEhB,SAAS,CAACK,MAAV,CAAiBC,UAJP;AAKtBW,IAAAA,6BAA6B,EAAEjB,SAAS,CAACK,MAAV,CAAiBC,UAL1B;AAMtBY,IAAAA,wBAAwB,EAAElB,SAAS,CAACK,MAAV,CAAiBC,UANrB;AAOtBa,IAAAA,mBAA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C,oBAAL,iCAA+BD,IAA/B,GAAwC,KAAI,CAACf,yBAA7C;AACD;AACF,GAL0B,CApKN;;AACnB,OAAKK,uBAAL,GAA+B,IAA/B;AACA,OAAKC,UAAL,GAAkB,IAAlB;AAEA9B,EAAAA,mBAAmB,CAAC0B,OAAD,EAAU,aAAV,CAAnB;AACA3B,EAAAA,SAAS,CAAC0C,cAAV,CAAyB/B,gBAAzB,EAA2CgB,OAA3C,EAAoD,SAApD,EAA+D,aAA/D;AAEA,OAAKf,MAAL,GAAce,OAAO,CAACf,MAAtB;AACA,OAAKQ,cAAL,GAAsBO,OAAO,CAACP,cAA9B,CARmB,CAUnB;;AACA,OAAKI,iBAAL,GAAyB,KAAKZ,MAAL,CAAYY,iBAAZ,GAAgC,KAAKZ,MAAL,CAAYY,iBAA5C,GAAgE,IAAzF;AACA,OAAKC,yBAAL,GAAiC,KAAKb,MAAL,CAAYa,yBAAZ,GAC7B,KAAKb,MAAL,CAAYa,yBADiB,GAE7B,EAFJ;AAIA,OAAKK,uBAAL,GAA+B/B,KAAK,CAAC4C,MAAN,EAA/B;AACA,OAAKZ,UAAL,GAAkBhC,KAAK,CAAC4C,MAAN,EAAlB;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;AAiJA,eAAejB,eAAf","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 * 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"],"file":"MockAuthService.js"}
|
|
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"],"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 * 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":";;;;;;;;;;;;A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AAKC,yBAAL,GAAiC,KAAKb,MAAL,CAAYa,yBAAZ,GAC7B,KAAKb,MAAL,CAAYa,yBADiB,GAE7B,EAFJ;EAIA,KAAKK,uBAAL,GAA+B/B,KAAK,CAAC4C,MAAN,EAA/B;EACA,KAAKZ,UAAL,GAAkBhC,KAAK,CAAC4C,MAAN,EAAlB;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;AAiJA,eAAejB,eAAf"}
|
package/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["AUTHENTICATED_USER_TOPIC","AUTHENTICATED_USER_CHANGED","configure","getAuthenticatedHttpClient","getAuthService","getHttpClient","getLoginRedirectUrl","redirectToLogin","getLogoutRedirectUrl","redirectToLogout","getAuthenticatedUser","setAuthenticatedUser","fetchAuthenticatedUser","ensureAuthenticatedUser","hydrateAuthenticatedUser","default","AxiosJwtAuthService","MockAuthService"],"sources":["../../src/auth/index.js"],"sourcesContent":["export {\n AUTHENTICATED_USER_TOPIC,\n AUTHENTICATED_USER_CHANGED,\n configure,\n getAuthenticatedHttpClient,\n getAuthService,\n getHttpClient,\n getLoginRedirectUrl,\n redirectToLogin,\n getLogoutRedirectUrl,\n redirectToLogout,\n getAuthenticatedUser,\n setAuthenticatedUser,\n fetchAuthenticatedUser,\n ensureAuthenticatedUser,\n hydrateAuthenticatedUser,\n} from './interface';\nexport { default as AxiosJwtAuthService } from './AxiosJwtAuthService';\nexport { default as MockAuthService } from './MockAuthService';\n"],"mappings":"AAAA,SACEA,wBADF,EAEEC,0BAFF,EAGEC,SAHF,EAIEC,0BAJF,EAKEC,cALF,EAMEC,aANF,EAOEC,mBAPF,EAQEC,eARF,EASEC,oBATF,EAUEC,gBAVF,EAWEC,oBAXF,EAYEC,oBAZF,EAaEC,sBAbF,EAcEC,uBAdF,EAeEC,wBAfF,QAgBO,aAhBP;AAiBA,SAASC,OAAO,IAAIC,mBAApB,QAA+C,uBAA/C;AACA,SAASD,OAAO,IAAIE,eAApB,QAA2C,mBAA3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createCsrfTokenProviderInterceptor.js","names":["createCsrfTokenProviderInterceptor","options","csrfTokenService","CSRF_TOKEN_API_PATH","shouldSkip","interceptor","axiosRequestConfig","url","getCsrfToken","csrfToken","requestError","Object","create","message","config","Promise","reject","CSRF_HEADER_NAME","headers"],"sources":["../../../src/auth/interceptors/createCsrfTokenProviderInterceptor.js"],"sourcesContent":["const createCsrfTokenProviderInterceptor = (options) => {\n const { csrfTokenService, CSRF_TOKEN_API_PATH, shouldSkip } = options;\n\n // Creating the interceptor inside this closure to\n // maintain reference to the options supplied.\n const interceptor = async (axiosRequestConfig) => {\n if (shouldSkip(axiosRequestConfig)) {\n return axiosRequestConfig;\n }\n const { url } = axiosRequestConfig;\n let csrfToken;\n\n // Important: the job of this interceptor is to get a csrf token and update\n // the original request configuration. Errors thrown getting the csrf token\n // should contain the original request config. This allows other interceptors\n // (namely our retry request interceptor below) to access the original request\n // and handle it appropriately\n try {\n csrfToken = await csrfTokenService.getCsrfToken(url, CSRF_TOKEN_API_PATH);\n } catch (error) {\n const requestError = Object.create(error);\n requestError.message = `[getCsrfToken] ${requestError.message}`;\n // Important: return the original axios request config\n requestError.config = axiosRequestConfig;\n return Promise.reject(requestError);\n }\n\n const CSRF_HEADER_NAME = 'X-CSRFToken';\n // eslint-disable-next-line no-param-reassign\n axiosRequestConfig.headers[CSRF_HEADER_NAME] = csrfToken;\n return axiosRequestConfig;\n };\n\n return interceptor;\n};\n\nexport default createCsrfTokenProviderInterceptor;\n"],"mappings":";;;;AAAA,IAAMA,kCAAkC,GAAG,SAArCA,kCAAqC,CAACC,OAAD,EAAa;EACtD,IAAQC,gBAAR,GAA8DD,OAA9D,CAAQC,gBAAR;EAAA,IAA0BC,mBAA1B,GAA8DF,OAA9D,CAA0BE,mBAA1B;EAAA,IAA+CC,UAA/C,GAA8DH,OAA9D,CAA+CG,UAA/C,CADsD,CAGtD;EACA;;EACA,IAAMC,WAAW;IAAA,mEAAG,iBAAOC,kBAAP;MAAA;MAAA;QAAA;UAAA;YAAA;cAAA,KACdF,UAAU,CAACE,kBAAD,CADI;gBAAA;gBAAA;cAAA;;cAAA,iCAETA,kBAFS;;YAAA;cAIVC,GAJU,GAIFD,kBAJE,CAIVC,GAJU;cAAA;cAAA;cAAA,OAaEL,gBAAgB,CAACM,YAAjB,CAA8BD,GAA9B,EAAmCJ,mBAAnC,CAbF;;YAAA;cAahBM,SAbgB;cAAA;cAAA;;YAAA;cAAA;cAAA;cAeVC,YAfU,GAeKC,MAAM,CAACC,MAAP,aAfL;cAgBhBF,YAAY,CAACG,OAAb,4BAAyCH,YAAY,CAACG,OAAtD,EAhBgB,CAiBhB;;cACAH,YAAY,CAACI,MAAb,GAAsBR,kBAAtB;cAlBgB,iCAmBTS,OAAO,CAACC,MAAR,CAAeN,YAAf,CAnBS;;YAAA;cAsBZO,gBAtBY,GAsBO,aAtBP,EAuBlB;;cACAX,kBAAkB,CAACY,OAAnB,CAA2BD,gBAA3B,IAA+CR,SAA/C;cAxBkB,iCAyBXH,kBAzBW;;YAAA;YAAA;cAAA;UAAA;QAAA;MAAA;IAAA,CAAH;;IAAA,gBAAXD,WAAW;MAAA;IAAA;EAAA,GAAjB;;EA4BA,OAAOA,WAAP;AACD,CAlCD;;AAoCA,eAAeL,kCAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createJwtTokenProviderInterceptor.js","names":["createJwtTokenProviderInterceptor","options","jwtTokenService","shouldSkip","interceptor","axiosRequestConfig","getJwtToken","requestError","Object","create","message","config","Promise","reject","headers","common"],"sources":["../../../src/auth/interceptors/createJwtTokenProviderInterceptor.js"],"sourcesContent":["const createJwtTokenProviderInterceptor = (options) => {\n const {\n jwtTokenService,\n shouldSkip,\n } = options;\n\n // Creating the interceptor inside this closure to\n // maintain reference to the options supplied.\n const interceptor = async (axiosRequestConfig) => {\n if (shouldSkip(axiosRequestConfig)) {\n return axiosRequestConfig;\n }\n\n // Important: the job of this interceptor is to refresh a jwt token and update\n // the original request configuration. Errors thrown from fetching the jwt\n // should contain the original request config. This allows other interceptors\n // (namely our retry request interceptor below) to access the original request\n // and handle it appropriately\n try {\n await jwtTokenService.getJwtToken();\n } catch (error) {\n const requestError = Object.create(error);\n requestError.message = `[getJwtToken] ${requestError.message}`;\n // Important: return the original axios request config\n requestError.config = axiosRequestConfig;\n return Promise.reject(requestError);\n }\n\n // Add the proper headers to tell the server to look for the jwt cookie\n // eslint-disable-next-line no-param-reassign\n axiosRequestConfig.headers.common['USE-JWT-COOKIE'] = true;\n return axiosRequestConfig;\n };\n\n return interceptor;\n};\n\nexport default createJwtTokenProviderInterceptor;\n"],"mappings":";;;;AAAA,IAAMA,iCAAiC,GAAG,SAApCA,iCAAoC,CAACC,OAAD,EAAa;EACrD,IACEC,eADF,GAGID,OAHJ,CACEC,eADF;EAAA,IAEEC,UAFF,GAGIF,OAHJ,CAEEE,UAFF,CADqD,CAMrD;EACA;;EACA,IAAMC,WAAW;IAAA,mEAAG,iBAAOC,kBAAP;MAAA;MAAA;QAAA;UAAA;YAAA;cAAA,KACdF,UAAU,CAACE,kBAAD,CADI;gBAAA;gBAAA;cAAA;;cAAA,iCAETA,kBAFS;;YAAA;cAAA;cAAA;cAAA,OAWVH,eAAe,CAACI,WAAhB,EAXU;;YAAA;cAAA;cAAA;;YAAA;cAAA;cAAA;cAaVC,YAbU,GAaKC,MAAM,CAACC,MAAP,aAbL;cAchBF,YAAY,CAACG,OAAb,2BAAwCH,YAAY,CAACG,OAArD,EAdgB,CAehB;;cACAH,YAAY,CAACI,MAAb,GAAsBN,kBAAtB;cAhBgB,iCAiBTO,OAAO,CAACC,MAAR,CAAeN,YAAf,CAjBS;;YAAA;cAoBlB;cACA;cACAF,kBAAkB,CAACS,OAAnB,CAA2BC,MAA3B,CAAkC,gBAAlC,IAAsD,IAAtD;cAtBkB,iCAuBXV,kBAvBW;;YAAA;YAAA;cAAA;UAAA;QAAA;MAAA;IAAA,CAAH;;IAAA,gBAAXD,WAAW;MAAA;IAAA;EAAA,GAAjB;;EA0BA,OAAOA,WAAP;AACD,CAnCD;;AAqCA,eAAeJ,iCAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createProcessAxiosRequestErrorInterceptor.js","names":["processAxiosError","createProcessAxiosRequestErrorInterceptor","options","loggingService","interceptor","error","processedError","httpErrorStatus","customAttributes","logInfo","message","Promise","reject"],"sources":["../../../src/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js"],"sourcesContent":["import { processAxiosError } from '../utils';\n\nconst createProcessAxiosRequestErrorInterceptor = (options) => {\n const { loggingService } = options;\n\n // Creating the interceptor inside this closure to\n // maintain reference to the options supplied.\n const interceptor = async (error) => {\n const processedError = processAxiosError(error);\n const { httpErrorStatus } = processedError.customAttributes;\n if (httpErrorStatus === 401 || httpErrorStatus === 403) {\n loggingService.logInfo(processedError.message, processedError.customAttributes);\n }\n return Promise.reject(processedError);\n };\n\n return interceptor;\n};\n\nexport default createProcessAxiosRequestErrorInterceptor;\n"],"mappings":";;;;AAAA,SAASA,iBAAT,QAAkC,UAAlC;;AAEA,IAAMC,yCAAyC,GAAG,SAA5CA,yCAA4C,CAACC,OAAD,EAAa;EAC7D,IAAQC,cAAR,GAA2BD,OAA3B,CAAQC,cAAR,CAD6D,CAG7D;EACA;;EACA,IAAMC,WAAW;IAAA,mEAAG,iBAAOC,KAAP;MAAA;MAAA;QAAA;UAAA;YAAA;cACZC,cADY,GACKN,iBAAiB,CAACK,KAAD,CADtB;cAEVE,eAFU,GAEUD,cAAc,CAACE,gBAFzB,CAEVD,eAFU;;cAGlB,IAAIA,eAAe,KAAK,GAApB,IAA2BA,eAAe,KAAK,GAAnD,EAAwD;gBACtDJ,cAAc,CAACM,OAAf,CAAuBH,cAAc,CAACI,OAAtC,EAA+CJ,cAAc,CAACE,gBAA9D;cACD;;cALiB,iCAMXG,OAAO,CAACC,MAAR,CAAeN,cAAf,CANW;;YAAA;YAAA;cAAA;UAAA;QAAA;MAAA;IAAA,CAAH;;IAAA,gBAAXF,WAAW;MAAA;IAAA;EAAA,GAAjB;;EASA,OAAOA,WAAP;AACD,CAfD;;AAiBA,eAAeH,yCAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createRetryInterceptor.js","names":["axios","defaultGetBackoffMilliseconds","nthRetry","maximumBackoffMilliseconds","exponentialBackoffSeconds","randomFractionOfASecond","Math","random","backoffSeconds","backoffMilliseconds","round","min","createRetryInterceptor","options","httpClient","create","getBackoffMilliseconds","shouldRetry","error","isRequestError","response","config","defaultMaxRetries","interceptor","Promise","reject","maxRetries","retryRequest","backoffDelay","resolve","setTimeout","request","retryResponse"],"sources":["../../../src/auth/interceptors/createRetryInterceptor.js"],"sourcesContent":["import axios from 'axios';\n\n// This default algorithm is a recreation of what is documented here\n// https://cloud.google.com/storage/docs/exponential-backoff\nconst defaultGetBackoffMilliseconds = (nthRetry, maximumBackoffMilliseconds = 16000) => {\n // Retry at exponential intervals (2, 4, 8, 16...)\n const exponentialBackoffSeconds = 2 ** nthRetry;\n // Add some randomness to avoid sending retries from separate requests all at once\n const randomFractionOfASecond = Math.random();\n const backoffSeconds = exponentialBackoffSeconds + randomFractionOfASecond;\n const backoffMilliseconds = Math.round(backoffSeconds * 1000);\n return Math.min(backoffMilliseconds, maximumBackoffMilliseconds);\n};\n\nconst createRetryInterceptor = (options = {}) => {\n const {\n httpClient = axios.create(),\n getBackoffMilliseconds = defaultGetBackoffMilliseconds,\n // By default only retry outbound request failures (not responses)\n shouldRetry = (error) => {\n const isRequestError = !error.response && error.config;\n return isRequestError;\n },\n // A per-request maxRetries can be specified in request config.\n defaultMaxRetries = 2,\n } = options;\n\n const interceptor = async (error) => {\n const { config } = error;\n\n // If no config exists there was some other error setting up the request\n if (!config) {\n return Promise.reject(error);\n }\n\n if (!shouldRetry(error)) {\n return Promise.reject(error);\n }\n\n const {\n maxRetries = defaultMaxRetries,\n } = config;\n\n const retryRequest = async (nthRetry) => {\n if (nthRetry > maxRetries) {\n // Reject with the original error\n return Promise.reject(error);\n }\n\n let retryResponse;\n\n try {\n const backoffDelay = getBackoffMilliseconds(nthRetry);\n // Delay (wrapped in a promise so we can await the setTimeout)\n await new Promise(resolve => setTimeout(resolve, backoffDelay));\n // Make retry request\n retryResponse = await httpClient.request(config);\n } catch (e) {\n return retryRequest(nthRetry + 1);\n }\n\n return retryResponse;\n };\n\n return retryRequest(1);\n };\n\n return interceptor;\n};\n\nexport default createRetryInterceptor;\nexport { defaultGetBackoffMilliseconds };\n"],"mappings":";;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB,C,CAEA;AACA;;AACA,IAAMC,6BAA6B,GAAG,SAAhCA,6BAAgC,CAACC,QAAD,EAAkD;EAAA,IAAvCC,0BAAuC,uEAAV,KAAU;EACtF;EACA,IAAMC,yBAAyB,YAAG,CAAH,EAAQF,QAAR,CAA/B,CAFsF,CAGtF;;EACA,IAAMG,uBAAuB,GAAGC,IAAI,CAACC,MAAL,EAAhC;EACA,IAAMC,cAAc,GAAGJ,yBAAyB,GAAGC,uBAAnD;EACA,IAAMI,mBAAmB,GAAGH,IAAI,CAACI,KAAL,CAAWF,cAAc,GAAG,IAA5B,CAA5B;EACA,OAAOF,IAAI,CAACK,GAAL,CAASF,mBAAT,EAA8BN,0BAA9B,CAAP;AACD,CARD;;AAUA,IAAMS,sBAAsB,GAAG,SAAzBA,sBAAyB,GAAkB;EAAA,IAAjBC,OAAiB,uEAAP,EAAO;EAC/C,0BAUIA,OAVJ,CACEC,UADF;EAAA,IACEA,UADF,oCACed,KAAK,CAACe,MAAN,EADf;EAAA,4BAUIF,OAVJ,CAEEG,sBAFF;EAAA,IAEEA,sBAFF,sCAE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