@openedx/frontend-base 1.0.0-alpha.9 → 1.0.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.
Files changed (895) hide show
  1. package/README.md +27 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +4 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/runtime/analytics/MockAnalyticsService.d.ts +50 -0
  6. package/dist/runtime/analytics/MockAnalyticsService.js +64 -0
  7. package/dist/runtime/analytics/MockAnalyticsService.js.map +1 -0
  8. package/dist/runtime/analytics/SegmentAnalyticsService.d.ts +64 -0
  9. package/dist/runtime/analytics/SegmentAnalyticsService.js +218 -0
  10. package/dist/runtime/analytics/SegmentAnalyticsService.js.map +1 -0
  11. package/dist/runtime/analytics/index.d.ts +3 -0
  12. package/dist/runtime/analytics/index.js +4 -0
  13. package/dist/runtime/analytics/index.js.map +1 -0
  14. package/dist/runtime/analytics/interface.d.ts +53 -0
  15. package/dist/runtime/analytics/interface.js +133 -0
  16. package/dist/runtime/analytics/interface.js.map +1 -0
  17. package/dist/runtime/auth/AxiosCsrfTokenService.d.ts +10 -0
  18. package/dist/runtime/auth/AxiosCsrfTokenService.js +64 -0
  19. package/dist/runtime/auth/AxiosCsrfTokenService.js.map +1 -0
  20. package/dist/runtime/auth/AxiosJwtAuthService.d.ts +182 -0
  21. package/dist/runtime/auth/AxiosJwtAuthService.js +339 -0
  22. package/dist/runtime/auth/AxiosJwtAuthService.js.map +1 -0
  23. package/dist/runtime/auth/AxiosJwtTokenService.d.ts +16 -0
  24. package/dist/runtime/auth/AxiosJwtTokenService.js +130 -0
  25. package/dist/runtime/auth/AxiosJwtTokenService.js.map +1 -0
  26. package/dist/runtime/auth/LocalForageCache.d.ts +7 -0
  27. package/dist/runtime/auth/LocalForageCache.js +78 -0
  28. package/dist/runtime/auth/LocalForageCache.js.map +1 -0
  29. package/dist/runtime/auth/MockAuthService.d.ts +209 -0
  30. package/dist/runtime/auth/MockAuthService.js +256 -0
  31. package/dist/runtime/auth/MockAuthService.js.map +1 -0
  32. package/dist/runtime/auth/index.d.ts +3 -0
  33. package/dist/runtime/auth/index.js +4 -0
  34. package/dist/runtime/auth/index.js.map +1 -0
  35. package/dist/runtime/auth/interceptors/createCsrfTokenProviderInterceptor.d.ts +2 -0
  36. package/dist/runtime/auth/interceptors/createCsrfTokenProviderInterceptor.js +42 -0
  37. package/dist/runtime/auth/interceptors/createCsrfTokenProviderInterceptor.js.map +1 -0
  38. package/dist/runtime/auth/interceptors/createJwtTokenProviderInterceptor.d.ts +2 -0
  39. package/dist/runtime/auth/interceptors/createJwtTokenProviderInterceptor.js +40 -0
  40. package/dist/runtime/auth/interceptors/createJwtTokenProviderInterceptor.js.map +1 -0
  41. package/dist/runtime/auth/interceptors/createProcessAxiosRequestErrorInterceptor.d.ts +2 -0
  42. package/dist/runtime/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +26 -0
  43. package/dist/runtime/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +1 -0
  44. package/dist/runtime/auth/interceptors/createRetryInterceptor.d.ts +3 -0
  45. package/dist/runtime/auth/interceptors/createRetryInterceptor.js +67 -0
  46. package/dist/runtime/auth/interceptors/createRetryInterceptor.js.map +1 -0
  47. package/dist/runtime/auth/interface.d.ts +133 -0
  48. package/dist/runtime/auth/interface.js +302 -0
  49. package/dist/runtime/auth/interface.js.map +1 -0
  50. package/dist/runtime/auth/utils.d.ts +13 -0
  51. package/dist/runtime/auth/utils.js +66 -0
  52. package/dist/runtime/auth/utils.js.map +1 -0
  53. package/dist/runtime/babel.config.d.ts +2 -0
  54. package/dist/runtime/babel.config.js +4 -0
  55. package/dist/runtime/babel.config.js.map +1 -0
  56. package/dist/runtime/config/index.d.ts +216 -0
  57. package/dist/runtime/config/index.js +428 -0
  58. package/dist/runtime/config/index.js.map +1 -0
  59. package/dist/runtime/constants.d.ts +57 -0
  60. package/dist/runtime/constants.js +58 -0
  61. package/dist/runtime/constants.js.map +1 -0
  62. package/dist/runtime/i18n/index.d.ts +3 -0
  63. package/dist/runtime/i18n/index.js +78 -0
  64. package/dist/runtime/i18n/index.js.map +1 -0
  65. package/dist/runtime/i18n/injectIntlWithShim.d.ts +11 -0
  66. package/dist/runtime/i18n/injectIntlWithShim.js +45 -0
  67. package/dist/runtime/i18n/injectIntlWithShim.js.map +1 -0
  68. package/dist/runtime/i18n/lib.d.ts +113 -0
  69. package/dist/runtime/i18n/lib.js +223 -0
  70. package/dist/runtime/i18n/lib.js.map +1 -0
  71. package/dist/runtime/index.d.ts +14 -0
  72. package/dist/runtime/index.js +15 -0
  73. package/dist/runtime/index.js.map +1 -0
  74. package/dist/runtime/initialize.d.ts +87 -0
  75. package/dist/runtime/initialize.js +305 -0
  76. package/dist/runtime/initialize.js.map +1 -0
  77. package/dist/runtime/jest.config.d.ts +16 -0
  78. package/dist/runtime/jest.config.js +34 -0
  79. package/dist/runtime/jest.config.js.map +1 -0
  80. package/dist/runtime/logging/MockLoggingService.d.ts +28 -0
  81. package/dist/runtime/logging/MockLoggingService.js +31 -0
  82. package/dist/runtime/logging/MockLoggingService.js.map +1 -0
  83. package/dist/runtime/logging/NewRelicLoggingService.d.ts +67 -0
  84. package/dist/runtime/logging/NewRelicLoggingService.js +175 -0
  85. package/dist/runtime/logging/NewRelicLoggingService.js.map +1 -0
  86. package/dist/runtime/logging/index.d.ts +3 -0
  87. package/dist/runtime/logging/index.js +4 -0
  88. package/dist/runtime/logging/index.js.map +1 -0
  89. package/dist/runtime/logging/interface.d.ts +38 -0
  90. package/dist/runtime/logging/interface.js +99 -0
  91. package/dist/runtime/logging/interface.js.map +1 -0
  92. package/dist/runtime/logging/types.d.ts +4 -0
  93. package/dist/runtime/logging/types.js +2 -0
  94. package/dist/runtime/logging/types.js.map +1 -0
  95. package/dist/runtime/react/AuthenticatedPageRoute.d.ts +30 -0
  96. package/dist/runtime/react/AuthenticatedPageRoute.js +38 -0
  97. package/dist/runtime/react/AuthenticatedPageRoute.js.map +1 -0
  98. package/dist/runtime/react/CombinedAppProvider.d.ts +6 -0
  99. package/dist/runtime/react/CombinedAppProvider.js +20 -0
  100. package/dist/runtime/react/CombinedAppProvider.js.map +1 -0
  101. package/dist/runtime/react/CurrentAppContext.d.ts +20 -0
  102. package/dist/runtime/react/CurrentAppContext.js +21 -0
  103. package/dist/runtime/react/CurrentAppContext.js.map +1 -0
  104. package/dist/runtime/react/CurrentAppProvider.d.ts +23 -0
  105. package/dist/runtime/react/CurrentAppProvider.js +33 -0
  106. package/dist/runtime/react/CurrentAppProvider.js.map +1 -0
  107. package/dist/runtime/react/Divider.d.ts +1 -0
  108. package/dist/runtime/react/Divider.js +5 -0
  109. package/dist/runtime/react/Divider.js.map +1 -0
  110. package/dist/runtime/react/ErrorBoundary.d.ts +32 -0
  111. package/dist/runtime/react/ErrorBoundary.js +40 -0
  112. package/dist/runtime/react/ErrorBoundary.js.map +1 -0
  113. package/dist/runtime/react/ErrorPage.d.ts +17 -0
  114. package/dist/runtime/react/ErrorPage.js +29 -0
  115. package/dist/runtime/react/ErrorPage.js.map +1 -0
  116. package/dist/runtime/react/LoginRedirect.d.ts +8 -0
  117. package/dist/runtime/react/LoginRedirect.js +16 -0
  118. package/dist/runtime/react/LoginRedirect.js.map +1 -0
  119. package/dist/runtime/react/NotFoundPage.d.ts +2 -0
  120. package/dist/runtime/react/NotFoundPage.js +14 -0
  121. package/dist/runtime/react/NotFoundPage.js.map +1 -0
  122. package/dist/runtime/react/PageWrap.d.ts +8 -0
  123. package/dist/runtime/react/PageWrap.js +21 -0
  124. package/dist/runtime/react/PageWrap.js.map +1 -0
  125. package/dist/runtime/react/SiteContext.d.ts +24 -0
  126. package/dist/runtime/react/SiteContext.js +26 -0
  127. package/dist/runtime/react/SiteContext.js.map +1 -0
  128. package/dist/runtime/react/SiteProvider.d.ts +29 -0
  129. package/dist/runtime/react/SiteProvider.js +69 -0
  130. package/dist/runtime/react/SiteProvider.js.map +1 -0
  131. package/dist/runtime/react/constants.d.ts +3 -0
  132. package/dist/runtime/react/constants.js +4 -0
  133. package/dist/runtime/react/constants.js.map +1 -0
  134. package/dist/runtime/react/hooks/index.d.ts +7 -0
  135. package/dist/runtime/react/hooks/index.js +8 -0
  136. package/dist/runtime/react/hooks/index.js.map +1 -0
  137. package/dist/runtime/react/hooks/theme/index.js +3 -0
  138. package/dist/runtime/react/hooks/theme/index.js.map +1 -0
  139. package/dist/runtime/react/hooks/theme/useTheme.d.ts +35 -0
  140. package/dist/runtime/react/hooks/theme/useTheme.js +153 -0
  141. package/dist/runtime/react/hooks/theme/useTheme.js.map +1 -0
  142. package/dist/runtime/react/hooks/theme/useThemeConfig.d.ts +16 -0
  143. package/dist/runtime/react/hooks/theme/useThemeConfig.js +29 -0
  144. package/dist/runtime/react/hooks/theme/useThemeConfig.js.map +1 -0
  145. package/dist/runtime/react/hooks/theme/useThemeCore.d.ts +10 -0
  146. package/dist/runtime/react/hooks/theme/useThemeCore.js +48 -0
  147. package/dist/runtime/react/hooks/theme/useThemeCore.js.map +1 -0
  148. package/dist/runtime/react/hooks/theme/useThemeVariants.d.ts +17 -0
  149. package/dist/runtime/react/hooks/theme/useThemeVariants.js +90 -0
  150. package/dist/runtime/react/hooks/theme/useThemeVariants.js.map +1 -0
  151. package/dist/runtime/react/hooks/theme/useTrackColorSchemeChoice.d.ts +8 -0
  152. package/dist/runtime/react/hooks/theme/useTrackColorSchemeChoice.js +30 -0
  153. package/dist/runtime/react/hooks/theme/useTrackColorSchemeChoice.js.map +1 -0
  154. package/dist/runtime/react/hooks/theme/utils.d.ts +6 -0
  155. package/dist/runtime/react/hooks/theme/utils.js +11 -0
  156. package/dist/runtime/react/hooks/theme/utils.js.map +1 -0
  157. package/dist/runtime/react/hooks/useActiveRoles.d.ts +2 -0
  158. package/dist/runtime/react/hooks/useActiveRoles.js +16 -0
  159. package/dist/runtime/react/hooks/useActiveRoles.js.map +1 -0
  160. package/dist/runtime/react/hooks/useActiveRouteRoleWatcher.d.ts +2 -0
  161. package/dist/runtime/react/hooks/useActiveRouteRoleWatcher.js +22 -0
  162. package/dist/runtime/react/hooks/useActiveRouteRoleWatcher.js.map +1 -0
  163. package/dist/runtime/react/hooks/useAppConfig.d.ts +2 -0
  164. package/dist/runtime/react/hooks/useAppConfig.js +8 -0
  165. package/dist/runtime/react/hooks/useAppConfig.js.map +1 -0
  166. package/dist/runtime/react/hooks/useAuthenticatedUser.d.ts +2 -0
  167. package/dist/runtime/react/hooks/useAuthenticatedUser.js +8 -0
  168. package/dist/runtime/react/hooks/useAuthenticatedUser.js.map +1 -0
  169. package/dist/runtime/react/hooks/useSiteConfig.d.ts +2 -0
  170. package/dist/runtime/react/hooks/useSiteConfig.js +8 -0
  171. package/dist/runtime/react/hooks/useSiteConfig.js.map +1 -0
  172. package/dist/runtime/react/hooks/useSiteEvent.d.ts +12 -0
  173. package/dist/runtime/react/hooks/useSiteEvent.js +22 -0
  174. package/dist/runtime/react/hooks/useSiteEvent.js.map +1 -0
  175. package/dist/runtime/react/index.d.ts +19 -0
  176. package/dist/runtime/react/index.js +20 -0
  177. package/dist/runtime/react/index.js.map +1 -0
  178. package/dist/runtime/react/reducers.d.ts +11 -0
  179. package/dist/runtime/react/reducers.js +28 -0
  180. package/dist/runtime/react/reducers.js.map +1 -0
  181. package/dist/runtime/routing/authenticatedLoader.d.ts +2 -0
  182. package/dist/runtime/routing/authenticatedLoader.js +27 -0
  183. package/dist/runtime/routing/authenticatedLoader.js.map +1 -0
  184. package/dist/runtime/routing/index.d.ts +2 -0
  185. package/dist/runtime/routing/index.js +3 -0
  186. package/dist/runtime/routing/index.js.map +1 -0
  187. package/dist/runtime/routing/utils.d.ts +4 -0
  188. package/dist/runtime/routing/utils.js +43 -0
  189. package/dist/runtime/routing/utils.js.map +1 -0
  190. package/dist/runtime/scripts/index.d.ts +1 -0
  191. package/dist/runtime/scripts/index.js +14 -0
  192. package/dist/runtime/scripts/index.js.map +1 -0
  193. package/dist/runtime/setupTest.d.ts +1 -0
  194. package/dist/runtime/setupTest.js +12 -0
  195. package/dist/runtime/setupTest.js.map +1 -0
  196. package/dist/runtime/slots/Slot.d.ts +11 -0
  197. package/dist/runtime/slots/Slot.js +37 -0
  198. package/dist/runtime/slots/Slot.js.map +1 -0
  199. package/dist/runtime/slots/SlotContext.d.ts +8 -0
  200. package/dist/runtime/slots/SlotContext.js +7 -0
  201. package/dist/runtime/slots/SlotContext.js.map +1 -0
  202. package/dist/runtime/slots/hooks.d.ts +11 -0
  203. package/dist/runtime/slots/hooks.js +19 -0
  204. package/dist/runtime/slots/hooks.js.map +1 -0
  205. package/dist/runtime/slots/index.js +7 -0
  206. package/dist/runtime/slots/index.js.map +1 -0
  207. package/dist/runtime/slots/layout/DefaultSlotLayout.d.ts +1 -0
  208. package/dist/runtime/slots/layout/DefaultSlotLayout.js +7 -0
  209. package/dist/runtime/slots/layout/DefaultSlotLayout.js.map +1 -0
  210. package/dist/runtime/slots/layout/hooks.d.ts +9 -0
  211. package/dist/runtime/slots/layout/hooks.js +52 -0
  212. package/dist/runtime/slots/layout/hooks.js.map +1 -0
  213. package/dist/runtime/slots/layout/index.js +5 -0
  214. package/dist/runtime/slots/layout/index.js.map +1 -0
  215. package/dist/runtime/slots/layout/types.d.ts +30 -0
  216. package/dist/runtime/slots/layout/types.js +12 -0
  217. package/dist/runtime/slots/layout/types.js.map +1 -0
  218. package/dist/runtime/slots/layout/utils.d.ts +5 -0
  219. package/dist/runtime/slots/layout/utils.js +11 -0
  220. package/dist/runtime/slots/layout/utils.js.map +1 -0
  221. package/dist/runtime/slots/types.d.ts +18 -0
  222. package/dist/runtime/slots/types.js +7 -0
  223. package/dist/runtime/slots/types.js.map +1 -0
  224. package/dist/runtime/slots/utils.d.ts +3 -0
  225. package/dist/runtime/slots/utils.js +65 -0
  226. package/dist/runtime/slots/utils.js.map +1 -0
  227. package/dist/runtime/slots/widget/WidgetContext.d.ts +6 -0
  228. package/dist/runtime/slots/widget/WidgetContext.js +8 -0
  229. package/dist/runtime/slots/widget/WidgetContext.js.map +1 -0
  230. package/dist/runtime/slots/widget/WidgetProvider.d.ts +9 -0
  231. package/dist/runtime/slots/widget/WidgetProvider.js +18 -0
  232. package/dist/runtime/slots/widget/WidgetProvider.js.map +1 -0
  233. package/dist/runtime/slots/widget/hooks.d.ts +12 -0
  234. package/dist/runtime/slots/widget/hooks.js +84 -0
  235. package/dist/runtime/slots/widget/hooks.js.map +1 -0
  236. package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.d.ts +10 -0
  237. package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.js +42 -0
  238. package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.js.map +1 -0
  239. package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.messages.d.ts +13 -0
  240. package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.messages.js +15 -0
  241. package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.messages.js.map +1 -0
  242. package/dist/runtime/slots/widget/iframe/IFrameWidget.d.ts +6 -0
  243. package/dist/runtime/slots/widget/iframe/IFrameWidget.js +32 -0
  244. package/dist/runtime/slots/widget/iframe/IFrameWidget.js.map +1 -0
  245. package/dist/runtime/slots/widget/iframe/constants.d.ts +15 -0
  246. package/dist/runtime/slots/widget/iframe/constants.js +17 -0
  247. package/dist/runtime/slots/widget/iframe/constants.js.map +1 -0
  248. package/dist/runtime/slots/widget/iframe/hooks.d.ts +64 -0
  249. package/dist/runtime/slots/widget/iframe/hooks.js +144 -0
  250. package/dist/runtime/slots/widget/iframe/hooks.js.map +1 -0
  251. package/dist/runtime/slots/widget/iframe/index.d.ts +3 -0
  252. package/dist/runtime/slots/widget/iframe/index.js +3 -0
  253. package/dist/runtime/slots/widget/iframe/index.js.map +1 -0
  254. package/dist/runtime/slots/widget/iframe/types.d.ts +5 -0
  255. package/dist/runtime/slots/widget/iframe/types.js +3 -0
  256. package/dist/runtime/slots/widget/iframe/types.js.map +1 -0
  257. package/dist/runtime/slots/widget/index.js +6 -0
  258. package/dist/runtime/slots/widget/index.js.map +1 -0
  259. package/dist/runtime/slots/widget/types.d.ts +108 -0
  260. package/dist/runtime/slots/widget/types.js +41 -0
  261. package/dist/runtime/slots/widget/types.js.map +1 -0
  262. package/dist/runtime/slots/widget/utils.d.ts +22 -0
  263. package/dist/runtime/slots/widget/utils.js +181 -0
  264. package/dist/runtime/slots/widget/utils.js.map +1 -0
  265. package/dist/runtime/subscriptions.d.ts +24 -0
  266. package/dist/runtime/subscriptions.js +48 -0
  267. package/dist/runtime/subscriptions.js.map +1 -0
  268. package/dist/runtime/testing/index.d.ts +8 -0
  269. package/dist/runtime/testing/index.js +9 -0
  270. package/dist/runtime/testing/index.js.map +1 -0
  271. package/dist/runtime/testing/initializeMockApp.d.ts +46 -0
  272. package/dist/runtime/testing/initializeMockApp.js +71 -0
  273. package/dist/runtime/testing/initializeMockApp.js.map +1 -0
  274. package/dist/runtime/testing/mockMessages.d.ts +22 -0
  275. package/dist/runtime/testing/mockMessages.js +23 -0
  276. package/dist/runtime/testing/mockMessages.js.map +1 -0
  277. package/dist/runtime/utils.d.ts +95 -0
  278. package/dist/runtime/utils.js +163 -0
  279. package/dist/runtime/utils.js.map +1 -0
  280. package/dist/shell/DefaultLayout.d.ts +1 -0
  281. package/dist/shell/DefaultLayout.js +7 -0
  282. package/dist/shell/DefaultLayout.js.map +1 -0
  283. package/dist/shell/DefaultMain.d.ts +1 -0
  284. package/dist/shell/DefaultMain.js +6 -0
  285. package/dist/shell/DefaultMain.js.map +1 -0
  286. package/dist/shell/Logo.d.ts +6 -0
  287. package/dist/shell/Logo.js +16 -0
  288. package/dist/shell/Logo.js.map +1 -0
  289. package/dist/shell/Shell.d.ts +1 -0
  290. package/dist/shell/Shell.js +10 -0
  291. package/dist/shell/Shell.js.map +1 -0
  292. package/dist/shell/Shell.messages.d.ts +63 -0
  293. package/dist/shell/Shell.messages.js +65 -0
  294. package/dist/shell/Shell.messages.js.map +1 -0
  295. package/dist/shell/app.d.ts +3 -0
  296. package/dist/shell/app.js +43 -0
  297. package/dist/shell/app.js.map +1 -0
  298. package/dist/shell/babel.config.d.ts +2 -0
  299. package/dist/shell/babel.config.js +4 -0
  300. package/dist/shell/babel.config.js.map +1 -0
  301. package/dist/shell/constants.d.ts +2 -0
  302. package/dist/shell/constants.js +3 -0
  303. package/dist/shell/constants.js.map +1 -0
  304. package/dist/shell/dev/devFooter/app.d.ts +3 -0
  305. package/dist/shell/dev/devFooter/app.js +36 -0
  306. package/dist/shell/dev/devFooter/app.js.map +1 -0
  307. package/dist/shell/dev/devFooter/index.js +2 -0
  308. package/dist/shell/dev/devFooter/index.js.map +1 -0
  309. package/dist/shell/dev/devHeader/BarContext.d.ts +7 -0
  310. package/dist/shell/dev/devHeader/BarContext.js +8 -0
  311. package/dist/shell/dev/devHeader/BarContext.js.map +1 -0
  312. package/dist/shell/dev/devHeader/BarLink.d.ts +1 -0
  313. package/dist/shell/dev/devHeader/BarLink.js +10 -0
  314. package/dist/shell/dev/devHeader/BarLink.js.map +1 -0
  315. package/dist/shell/dev/devHeader/BarProvider.d.ts +6 -0
  316. package/dist/shell/dev/devHeader/BarProvider.js +16 -0
  317. package/dist/shell/dev/devHeader/BarProvider.js.map +1 -0
  318. package/dist/shell/dev/devHeader/CoursesLink.d.ts +1 -0
  319. package/dist/shell/dev/devHeader/CoursesLink.js +10 -0
  320. package/dist/shell/dev/devHeader/CoursesLink.js.map +1 -0
  321. package/dist/shell/dev/devHeader/FooContext.d.ts +7 -0
  322. package/dist/shell/dev/devHeader/FooContext.js +8 -0
  323. package/dist/shell/dev/devHeader/FooContext.js.map +1 -0
  324. package/dist/shell/dev/devHeader/FooLink.d.ts +1 -0
  325. package/dist/shell/dev/devHeader/FooLink.js +10 -0
  326. package/dist/shell/dev/devHeader/FooLink.js.map +1 -0
  327. package/dist/shell/dev/devHeader/FooProvider.d.ts +6 -0
  328. package/dist/shell/dev/devHeader/FooProvider.js +16 -0
  329. package/dist/shell/dev/devHeader/FooProvider.js.map +1 -0
  330. package/dist/shell/dev/devHeader/app.d.ts +3 -0
  331. package/dist/shell/dev/devHeader/app.js +34 -0
  332. package/dist/shell/dev/devHeader/app.js.map +1 -0
  333. package/dist/shell/dev/devHeader/index.js +2 -0
  334. package/dist/shell/dev/devHeader/index.js.map +1 -0
  335. package/dist/shell/dev/devHeader/providers.d.ts +3 -0
  336. package/dist/shell/dev/devHeader/providers.js +8 -0
  337. package/dist/shell/dev/devHeader/providers.js.map +1 -0
  338. package/dist/shell/dev/devHome/HomePage.d.ts +1 -0
  339. package/dist/shell/dev/devHome/HomePage.js +14 -0
  340. package/dist/shell/dev/devHome/HomePage.js.map +1 -0
  341. package/dist/shell/dev/devHome/app.d.ts +3 -0
  342. package/dist/shell/dev/devHome/app.js +15 -0
  343. package/dist/shell/dev/devHome/app.js.map +1 -0
  344. package/dist/shell/dev/devHome/index.js +2 -0
  345. package/dist/shell/dev/devHome/index.js.map +1 -0
  346. package/dist/shell/dev/devHome/messages.d.ts +8 -0
  347. package/dist/shell/dev/devHome/messages.js +10 -0
  348. package/dist/shell/dev/devHome/messages.js.map +1 -0
  349. package/dist/shell/dev/index.d.ts +4 -0
  350. package/dist/shell/dev/index.js +5 -0
  351. package/dist/shell/dev/index.js.map +1 -0
  352. package/dist/shell/dev/slotShowcase/HorizontalSlotLayout.d.ts +1 -0
  353. package/dist/shell/dev/slotShowcase/HorizontalSlotLayout.js +8 -0
  354. package/dist/shell/dev/slotShowcase/HorizontalSlotLayout.js.map +1 -0
  355. package/dist/shell/dev/slotShowcase/LayoutWithOptions.d.ts +1 -0
  356. package/dist/shell/dev/slotShowcase/LayoutWithOptions.js +9 -0
  357. package/dist/shell/dev/slotShowcase/LayoutWithOptions.js.map +1 -0
  358. package/dist/shell/dev/slotShowcase/SlotShowcase.scss +50 -0
  359. package/dist/shell/dev/slotShowcase/SlotShowcasePage.d.ts +2 -0
  360. package/dist/shell/dev/slotShowcase/SlotShowcasePage.js +17 -0
  361. package/dist/shell/dev/slotShowcase/SlotShowcasePage.js.map +1 -0
  362. package/dist/shell/dev/slotShowcase/ToggleByRoleLayout.d.ts +1 -0
  363. package/dist/shell/dev/slotShowcase/ToggleByRoleLayout.js +11 -0
  364. package/dist/shell/dev/slotShowcase/ToggleByRoleLayout.js.map +1 -0
  365. package/dist/shell/dev/slotShowcase/WidgetWithOptions.d.ts +1 -0
  366. package/dist/shell/dev/slotShowcase/WidgetWithOptions.js +8 -0
  367. package/dist/shell/dev/slotShowcase/WidgetWithOptions.js.map +1 -0
  368. package/dist/shell/dev/slotShowcase/app.d.ts +3 -0
  369. package/dist/shell/dev/slotShowcase/app.js +372 -0
  370. package/dist/shell/dev/slotShowcase/app.js.map +1 -0
  371. package/dist/shell/dev/slotShowcase/index.js +2 -0
  372. package/dist/shell/dev/slotShowcase/index.js.map +1 -0
  373. package/dist/shell/footer/CenterLinks.d.ts +1 -0
  374. package/dist/shell/footer/CenterLinks.js +7 -0
  375. package/dist/shell/footer/CenterLinks.js.map +1 -0
  376. package/dist/shell/footer/CopyrightNotice.d.ts +10 -0
  377. package/dist/shell/footer/CopyrightNotice.js +10 -0
  378. package/dist/shell/footer/CopyrightNotice.js.map +1 -0
  379. package/dist/shell/footer/DesktopFooterLayout.d.ts +1 -0
  380. package/dist/shell/footer/DesktopFooterLayout.js +12 -0
  381. package/dist/shell/footer/DesktopFooterLayout.js.map +1 -0
  382. package/dist/shell/footer/Footer.d.ts +1 -0
  383. package/dist/shell/footer/Footer.js +6 -0
  384. package/dist/shell/footer/Footer.js.map +1 -0
  385. package/dist/shell/footer/LabeledLinkColumn.d.ts +1 -0
  386. package/dist/shell/footer/LabeledLinkColumn.js +11 -0
  387. package/dist/shell/footer/LabeledLinkColumn.js.map +1 -0
  388. package/dist/shell/footer/LanguageMenu.d.ts +1 -0
  389. package/dist/shell/footer/LanguageMenu.js +16 -0
  390. package/dist/shell/footer/LanguageMenu.js.map +1 -0
  391. package/dist/shell/footer/LanguageMenuItem.d.ts +8 -0
  392. package/dist/shell/footer/LanguageMenuItem.js +11 -0
  393. package/dist/shell/footer/LanguageMenuItem.js.map +1 -0
  394. package/dist/shell/footer/LeftLinks.d.ts +1 -0
  395. package/dist/shell/footer/LeftLinks.js +7 -0
  396. package/dist/shell/footer/LeftLinks.js.map +1 -0
  397. package/dist/shell/footer/LegalNotices.d.ts +1 -0
  398. package/dist/shell/footer/LegalNotices.js +10 -0
  399. package/dist/shell/footer/LegalNotices.js.map +1 -0
  400. package/dist/shell/footer/PoweredBy.d.ts +1 -0
  401. package/dist/shell/footer/PoweredBy.js +9 -0
  402. package/dist/shell/footer/PoweredBy.js.map +1 -0
  403. package/dist/shell/footer/RevealLinks.d.ts +1 -0
  404. package/dist/shell/footer/RevealLinks.js +16 -0
  405. package/dist/shell/footer/RevealLinks.js.map +1 -0
  406. package/dist/shell/footer/RightLinks.d.ts +1 -0
  407. package/dist/shell/footer/RightLinks.js +7 -0
  408. package/dist/shell/footer/RightLinks.js.map +1 -0
  409. package/dist/shell/footer/app.d.ts +3 -0
  410. package/dist/shell/footer/app.js +67 -0
  411. package/dist/shell/footer/app.js.map +1 -0
  412. package/dist/shell/footer/data/api.d.ts +1 -0
  413. package/dist/shell/footer/data/api.js +45 -0
  414. package/dist/shell/footer/data/api.js.map +1 -0
  415. package/dist/shell/footer/index.js +3 -0
  416. package/dist/shell/footer/index.js.map +1 -0
  417. package/dist/shell/header/AuthenticatedMenu.d.ts +5 -0
  418. package/dist/shell/header/AuthenticatedMenu.js +9 -0
  419. package/dist/shell/header/AuthenticatedMenu.js.map +1 -0
  420. package/dist/shell/header/Header.d.ts +1 -0
  421. package/dist/shell/header/Header.js +8 -0
  422. package/dist/shell/header/Header.js.map +1 -0
  423. package/dist/shell/header/HelpButton.d.ts +5 -0
  424. package/dist/shell/header/HelpButton.js +10 -0
  425. package/dist/shell/header/HelpButton.js.map +1 -0
  426. package/dist/shell/header/anonymous-menu/AnonymousMenu.d.ts +5 -0
  427. package/dist/shell/header/anonymous-menu/AnonymousMenu.js +7 -0
  428. package/dist/shell/header/anonymous-menu/AnonymousMenu.js.map +1 -0
  429. package/dist/shell/header/anonymous-menu/LoginButton.d.ts +3 -0
  430. package/dist/shell/header/anonymous-menu/LoginButton.js +22 -0
  431. package/dist/shell/header/anonymous-menu/LoginButton.js.map +1 -0
  432. package/dist/shell/header/anonymous-menu/RegisterButton.d.ts +3 -0
  433. package/dist/shell/header/anonymous-menu/RegisterButton.js +22 -0
  434. package/dist/shell/header/anonymous-menu/RegisterButton.js.map +1 -0
  435. package/dist/shell/header/app.d.ts +4 -0
  436. package/dist/shell/header/app.js +157 -0
  437. package/dist/shell/header/app.js.map +1 -0
  438. package/dist/shell/header/app.scss +20 -0
  439. package/dist/shell/header/constants.d.ts +3 -0
  440. package/dist/shell/header/constants.js +4 -0
  441. package/dist/shell/header/constants.js.map +1 -0
  442. package/dist/shell/header/course-bar/data/service.d.ts +11 -0
  443. package/dist/shell/header/course-bar/data/service.js +49 -0
  444. package/dist/shell/header/course-bar/data/service.js.map +1 -0
  445. package/dist/shell/header/course-bar/masquerade/MasqueradeBar.d.ts +1 -0
  446. package/dist/shell/header/course-bar/masquerade/MasqueradeBar.js +22 -0
  447. package/dist/shell/header/course-bar/masquerade/MasqueradeBar.js.map +1 -0
  448. package/dist/shell/header/course-bar/masquerade/MasqueradeContext.d.ts +3 -0
  449. package/dist/shell/header/course-bar/masquerade/MasqueradeContext.js +10 -0
  450. package/dist/shell/header/course-bar/masquerade/MasqueradeContext.js.map +1 -0
  451. package/dist/shell/header/course-bar/masquerade/StudioLink.d.ts +6 -0
  452. package/dist/shell/header/course-bar/masquerade/StudioLink.js +27 -0
  453. package/dist/shell/header/course-bar/masquerade/StudioLink.js.map +1 -0
  454. package/dist/shell/header/course-bar/masquerade/data/api.d.ts +29 -0
  455. package/dist/shell/header/course-bar/masquerade/data/api.js +33 -0
  456. package/dist/shell/header/course-bar/masquerade/data/api.js.map +1 -0
  457. package/dist/shell/header/course-bar/masquerade/hooks.d.ts +20 -0
  458. package/dist/shell/header/course-bar/masquerade/hooks.js +203 -0
  459. package/dist/shell/header/course-bar/masquerade/hooks.js.map +1 -0
  460. package/dist/shell/header/course-bar/masquerade/index.d.ts +1 -0
  461. package/dist/shell/header/course-bar/masquerade/index.js +2 -0
  462. package/dist/shell/header/course-bar/masquerade/index.js.map +1 -0
  463. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeUserNameInput.d.ts +7 -0
  464. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeUserNameInput.js +18 -0
  465. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeUserNameInput.js.map +1 -0
  466. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidget.d.ts +1 -0
  467. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidget.js +16 -0
  468. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidget.js.map +1 -0
  469. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidgetOption.d.ts +6 -0
  470. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidgetOption.js +18 -0
  471. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidgetOption.js.map +1 -0
  472. package/dist/shell/header/course-bar/masquerade/masquerade-widget/index.d.ts +2 -0
  473. package/dist/shell/header/course-bar/masquerade/masquerade-widget/index.js +3 -0
  474. package/dist/shell/header/course-bar/masquerade/masquerade-widget/index.js.map +1 -0
  475. package/dist/shell/header/course-bar/masquerade/masquerade-widget/messages.d.ts +28 -0
  476. package/dist/shell/header/course-bar/masquerade/masquerade-widget/messages.js +30 -0
  477. package/dist/shell/header/course-bar/masquerade/masquerade-widget/messages.js.map +1 -0
  478. package/dist/shell/header/course-bar/masquerade/messages.d.ts +28 -0
  479. package/dist/shell/header/course-bar/masquerade/messages.js +30 -0
  480. package/dist/shell/header/course-bar/masquerade/messages.js.map +1 -0
  481. package/dist/shell/header/course-bar/navigation/CourseTabsNavigation.d.ts +3 -0
  482. package/dist/shell/header/course-bar/navigation/CourseTabsNavigation.js +39 -0
  483. package/dist/shell/header/course-bar/navigation/CourseTabsNavigation.js.map +1 -0
  484. package/dist/shell/header/course-bar/navigation/course-tabs-navigation.scss +7 -0
  485. package/dist/shell/header/course-bar/navigation/messages.d.ts +8 -0
  486. package/dist/shell/header/course-bar/navigation/messages.js +10 -0
  487. package/dist/shell/header/course-bar/navigation/messages.js.map +1 -0
  488. package/dist/shell/header/course-bar/utils.d.ts +3 -0
  489. package/dist/shell/header/course-bar/utils.js +54 -0
  490. package/dist/shell/header/course-bar/utils.js.map +1 -0
  491. package/dist/shell/header/desktop/DesktopLayout.d.ts +1 -0
  492. package/dist/shell/header/desktop/DesktopLayout.js +10 -0
  493. package/dist/shell/header/desktop/DesktopLayout.js.map +1 -0
  494. package/dist/shell/header/desktop/PrimaryNavLinks.d.ts +1 -0
  495. package/dist/shell/header/desktop/PrimaryNavLinks.js +7 -0
  496. package/dist/shell/header/desktop/PrimaryNavLinks.js.map +1 -0
  497. package/dist/shell/header/desktop/SecondaryNavLinks.d.ts +1 -0
  498. package/dist/shell/header/desktop/SecondaryNavLinks.js +7 -0
  499. package/dist/shell/header/desktop/SecondaryNavLinks.js.map +1 -0
  500. package/dist/shell/header/helpButtonSlotOperation.d.ts +6 -0
  501. package/dist/shell/header/helpButtonSlotOperation.js +14 -0
  502. package/dist/shell/header/helpButtonSlotOperation.js.map +1 -0
  503. package/dist/shell/header/index.d.ts +5 -0
  504. package/dist/shell/header/index.js +6 -0
  505. package/dist/shell/header/index.js.map +1 -0
  506. package/dist/shell/header/mobile/MobileLayout.d.ts +1 -0
  507. package/dist/shell/header/mobile/MobileLayout.js +17 -0
  508. package/dist/shell/header/mobile/MobileLayout.js.map +1 -0
  509. package/dist/shell/header/mobile/MobileNavLinks.d.ts +1 -0
  510. package/dist/shell/header/mobile/MobileNavLinks.js +7 -0
  511. package/dist/shell/header/mobile/MobileNavLinks.js.map +1 -0
  512. package/dist/shell/index.d.ts +8 -0
  513. package/dist/shell/index.js +9 -0
  514. package/dist/shell/index.js.map +1 -0
  515. package/dist/shell/jest.config.d.ts +15 -0
  516. package/dist/shell/jest.config.js +32 -0
  517. package/dist/shell/jest.config.js.map +1 -0
  518. package/dist/shell/layer-order.scss +1 -0
  519. package/dist/shell/menus/LinkMenuItem.d.ts +9 -0
  520. package/dist/shell/menus/LinkMenuItem.js +38 -0
  521. package/dist/shell/menus/LinkMenuItem.js.map +1 -0
  522. package/dist/shell/menus/NavDropdownMenuSlot.d.ts +7 -0
  523. package/dist/shell/menus/NavDropdownMenuSlot.js +14 -0
  524. package/dist/shell/menus/NavDropdownMenuSlot.js.map +1 -0
  525. package/dist/shell/menus/ProfileLinkMenuItem.d.ts +8 -0
  526. package/dist/shell/menus/ProfileLinkMenuItem.js +16 -0
  527. package/dist/shell/menus/ProfileLinkMenuItem.js.map +1 -0
  528. package/dist/shell/menus/data/utils.d.ts +4 -0
  529. package/dist/shell/menus/data/utils.js +13 -0
  530. package/dist/shell/menus/data/utils.js.map +1 -0
  531. package/dist/shell/router/createRouter.d.ts +1 -0
  532. package/dist/shell/router/createRouter.js +26 -0
  533. package/dist/shell/router/createRouter.js.map +1 -0
  534. package/dist/shell/router/getAppRoutes.d.ts +2 -0
  535. package/dist/shell/router/getAppRoutes.js +27 -0
  536. package/dist/shell/router/getAppRoutes.js.map +1 -0
  537. package/dist/shell/setupTest.d.ts +1 -0
  538. package/dist/shell/setupTest.js +12 -0
  539. package/dist/shell/setupTest.js.map +1 -0
  540. package/dist/shell/site.config.dev.d.ts +4 -0
  541. package/dist/shell/site.config.dev.js +43 -0
  542. package/dist/shell/site.config.dev.js.map +1 -0
  543. package/dist/shell/site.d.ts +1 -0
  544. package/dist/shell/site.js +45 -0
  545. package/dist/shell/site.js.map +1 -0
  546. package/dist/shell/style.d.ts +3 -0
  547. package/dist/shell/style.js +10 -0
  548. package/dist/shell/style.js.map +1 -0
  549. package/dist/shell/style.scss +147 -0
  550. package/dist/tools/babel/babel.config.d.ts +12 -0
  551. package/dist/tools/babel.config.d.ts +2 -0
  552. package/dist/tools/babel.config.js +3 -0
  553. package/dist/tools/cli/commands/serve.d.ts +1 -0
  554. package/dist/tools/cli/commands/translations.d.ts +2 -0
  555. package/dist/tools/cli/commands/translations.js +20 -0
  556. package/dist/tools/cli/openedx.d.ts +2 -0
  557. package/dist/tools/cli/openedx.js +111 -0
  558. package/dist/tools/cli/utils/ensureConfigFilenameOption.d.ts +2 -0
  559. package/dist/tools/cli/utils/formatter.d.ts +1 -0
  560. package/dist/tools/cli/utils/formatter.js +3 -0
  561. package/dist/tools/cli/utils/getResolvedConfigPath.d.ts +2 -0
  562. package/dist/tools/cli/utils/prettyPrintTitle.d.ts +1 -0
  563. package/dist/tools/cli/utils/printUsage.d.ts +1 -0
  564. package/dist/tools/cli/utils/printUsage.js +47 -0
  565. package/dist/tools/cli/utils/translations/index.d.ts +2 -0
  566. package/dist/tools/cli/utils/translations/index.js +7 -0
  567. package/dist/tools/cli/utils/translations/messagesObject.d.ts +26 -0
  568. package/dist/tools/cli/utils/translations/messagesObject.js +66 -0
  569. package/dist/tools/cli/utils/translations/prepare.d.ts +5 -0
  570. package/dist/tools/cli/utils/translations/prepare.js +98 -0
  571. package/dist/tools/cli/utils/translations/pull.d.ts +6 -0
  572. package/dist/tools/cli/utils/translations/pull.js +102 -0
  573. package/dist/tools/config-helpers/createConfig.d.ts +2 -0
  574. package/dist/tools/config-helpers/createLintConfig.d.ts +2 -0
  575. package/dist/tools/config-helpers/getBaseConfig.d.ts +2 -0
  576. package/dist/tools/defaultConfigPaths.d.ts +8 -0
  577. package/dist/tools/eslint/base.eslint.config.d.ts +3 -0
  578. package/dist/tools/eslint/base.eslint.config.js +114 -0
  579. package/dist/tools/eslint.config.d.ts +3 -0
  580. package/dist/tools/index.d.ts +3 -0
  581. package/dist/tools/jest/jest.config.d.ts +14 -0
  582. package/dist/tools/jest.config.d.ts +8 -0
  583. package/dist/tools/types.d.ts +20 -0
  584. package/dist/tools/types.js +25 -0
  585. package/dist/tools/typescript/tsconfig.json +33 -0
  586. package/dist/tools/webpack/common-config/all/getCodeRules.d.ts +2 -0
  587. package/dist/tools/webpack/common-config/all/getFileLoaderRules.d.ts +11 -0
  588. package/dist/tools/webpack/common-config/all/getImageMinimizer.d.ts +5 -0
  589. package/dist/tools/webpack/common-config/all/getStylesheetRule.d.ts +12 -0
  590. package/dist/tools/webpack/common-config/all/getStylesheetRule.js +150 -0
  591. package/dist/tools/webpack/common-config/all/postcssWrapLayer.d.ts +4 -0
  592. package/dist/tools/webpack/common-config/all/postcssWrapLayer.js +32 -0
  593. package/dist/tools/webpack/common-config/dev/getDevServer.d.ts +2 -0
  594. package/dist/tools/webpack/common-config/dev/getDevServer.js +36 -0
  595. package/dist/tools/webpack/common-config/index.d.ts +7 -0
  596. package/dist/tools/webpack/common-config/index.js +20 -0
  597. package/dist/tools/webpack/common-config/site/getHtmlWebpackPlugin.d.ts +2 -0
  598. package/dist/tools/webpack/common-config/site/getHtmlWebpackPlugin.js +24 -0
  599. package/dist/tools/webpack/common-config/site/getI18nMessagesFallbackPlugin/emptyI18n.d.ts +2 -0
  600. package/dist/tools/webpack/common-config/site/getI18nMessagesFallbackPlugin/emptyI18n.js +3 -0
  601. package/dist/tools/webpack/common-config/site/getI18nMessagesFallbackPlugin/index.d.ts +2 -0
  602. package/dist/tools/webpack/common-config/site/getI18nMessagesFallbackPlugin/index.js +26 -0
  603. package/dist/tools/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.d.ts +16 -0
  604. package/dist/tools/webpack/plugins/html-webpack-new-relic-plugin/index.d.ts +2 -0
  605. package/dist/tools/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.d.ts +1 -0
  606. package/dist/tools/webpack/utils/getPublicPath.d.ts +1 -0
  607. package/dist/tools/webpack/utils/getPublicPath.js +6 -0
  608. package/dist/tools/webpack/utils/getResolvedSiteConfigPath.d.ts +1 -0
  609. package/dist/tools/webpack/utils/getResolvedSiteI18nPath.d.ts +1 -0
  610. package/dist/tools/webpack/utils/getResolvedSiteI18nPath.js +25 -0
  611. package/dist/tools/webpack/webpack.config.build.d.ts +3 -0
  612. package/dist/tools/webpack/webpack.config.build.js +78 -0
  613. package/dist/tools/webpack/webpack.config.dev.d.ts +3 -0
  614. package/dist/tools/webpack/webpack.config.dev.js +78 -0
  615. package/dist/tools/webpack/webpack.config.dev.shell.d.ts +3 -0
  616. package/dist/tools/webpack/webpack.config.dev.shell.js +105 -0
  617. package/dist/types.d.ts +93 -0
  618. package/dist/types.js +7 -0
  619. package/dist/types.js.map +1 -0
  620. package/package.json +45 -32
  621. package/config/eslint/base.eslint.config.js +0 -113
  622. package/config/tsconfig.json +0 -32
  623. package/config/types.js +0 -23
  624. package/config/webpack/common-config/all/getIgnoreWarnings.js +0 -14
  625. package/config/webpack/common-config/all/getStylesheetRule.js +0 -112
  626. package/config/webpack/common-config/dev/getDevServer.js +0 -38
  627. package/config/webpack/common-config/index.js +0 -18
  628. package/config/webpack/common-config/site/getHtmlWebpackPlugin.js +0 -16
  629. package/config/webpack/plugins/html-webpack-new-relic-plugin/test/HtmlWebpackNewRelicPlugin.test.js +0 -66
  630. package/config/webpack/utils/getLocalAliases.js +0 -65
  631. package/config/webpack/utils/getPublicPath.js +0 -6
  632. package/config/webpack/webpack.config.build.js +0 -69
  633. package/config/webpack/webpack.config.dev.js +0 -69
  634. package/config/webpack/webpack.config.dev.shell.js +0 -103
  635. package/index.ts +0 -7
  636. package/runtime/__mocks__/file.js +0 -1
  637. package/runtime/__mocks__/svg.js +0 -1
  638. package/runtime/__mocks__/universal-cookie.js +0 -6
  639. package/runtime/analytics/MockAnalyticsService.js +0 -71
  640. package/runtime/analytics/SegmentAnalyticsService.js +0 -243
  641. package/runtime/analytics/index.ts +0 -12
  642. package/runtime/analytics/interface.js +0 -145
  643. package/runtime/analytics/interface.test.js +0 -242
  644. package/runtime/auth/AxiosCsrfTokenService.js +0 -60
  645. package/runtime/auth/AxiosJwtAuthService.js +0 -363
  646. package/runtime/auth/AxiosJwtAuthService.test.jsx +0 -1076
  647. package/runtime/auth/AxiosJwtTokenService.js +0 -134
  648. package/runtime/auth/LocalForageCache.js +0 -76
  649. package/runtime/auth/MockAuthService.js +0 -278
  650. package/runtime/auth/index.ts +0 -19
  651. package/runtime/auth/interceptors/createCsrfTokenProviderInterceptor.js +0 -36
  652. package/runtime/auth/interceptors/createJwtTokenProviderInterceptor.js +0 -37
  653. package/runtime/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +0 -20
  654. package/runtime/auth/interceptors/createRetryInterceptor.js +0 -74
  655. package/runtime/auth/interceptors/createRetryInterceptor.test.js +0 -23
  656. package/runtime/auth/interface.js +0 -309
  657. package/runtime/auth/utils.js +0 -105
  658. package/runtime/babel.config.js +0 -3
  659. package/runtime/config/getExternalLinkUrl.test.js +0 -76
  660. package/runtime/config/index.ts +0 -294
  661. package/runtime/constants.ts +0 -68
  662. package/runtime/i18n/index.js +0 -118
  663. package/runtime/i18n/injectIntlWithShim.jsx +0 -48
  664. package/runtime/i18n/lib.test.js +0 -230
  665. package/runtime/i18n/lib.ts +0 -272
  666. package/runtime/index.ts +0 -139
  667. package/runtime/initialize.async.function.config.test.js +0 -43
  668. package/runtime/initialize.const.config.test.js +0 -41
  669. package/runtime/initialize.function.config.test.js +0 -41
  670. package/runtime/initialize.js +0 -352
  671. package/runtime/initialize.test.js +0 -356
  672. package/runtime/jest.config.js +0 -33
  673. package/runtime/logging/MockLoggingService.js +0 -31
  674. package/runtime/logging/NewRelicLoggingService.js +0 -184
  675. package/runtime/logging/NewRelicLoggingService.test.js +0 -214
  676. package/runtime/logging/index.ts +0 -9
  677. package/runtime/logging/interface.js +0 -109
  678. package/runtime/logging/types.ts +0 -4
  679. package/runtime/react/AuthenticatedPageRoute.jsx +0 -43
  680. package/runtime/react/AuthenticatedPageRoute.test.jsx +0 -135
  681. package/runtime/react/CombinedAppProvider.tsx +0 -46
  682. package/runtime/react/CurrentAppContext.tsx +0 -25
  683. package/runtime/react/CurrentAppProvider.tsx +0 -46
  684. package/runtime/react/Divider.tsx +0 -5
  685. package/runtime/react/ErrorBoundary.jsx +0 -47
  686. package/runtime/react/ErrorBoundary.test.jsx +0 -83
  687. package/runtime/react/ErrorPage.jsx +0 -72
  688. package/runtime/react/LoginRedirect.jsx +0 -16
  689. package/runtime/react/PageWrap.jsx +0 -24
  690. package/runtime/react/SiteContext.tsx +0 -32
  691. package/runtime/react/SiteProvider.test.jsx +0 -66
  692. package/runtime/react/SiteProvider.tsx +0 -101
  693. package/runtime/react/constants.ts +0 -3
  694. package/runtime/react/hooks/index.ts +0 -8
  695. package/runtime/react/hooks/theme/useTheme.test.ts +0 -221
  696. package/runtime/react/hooks/theme/useTheme.ts +0 -179
  697. package/runtime/react/hooks/theme/useThemeConfig.test.ts +0 -107
  698. package/runtime/react/hooks/theme/useThemeConfig.ts +0 -34
  699. package/runtime/react/hooks/theme/useThemeCore.test.ts +0 -65
  700. package/runtime/react/hooks/theme/useThemeCore.ts +0 -52
  701. package/runtime/react/hooks/theme/useThemeVariants.test.ts +0 -97
  702. package/runtime/react/hooks/theme/useThemeVariants.ts +0 -116
  703. package/runtime/react/hooks/theme/useTrackColorSchemeChoice.test.ts +0 -54
  704. package/runtime/react/hooks/theme/useTrackColorSchemeChoice.ts +0 -30
  705. package/runtime/react/hooks/theme/utils.ts +0 -11
  706. package/runtime/react/hooks/useActiveRoles.ts +0 -15
  707. package/runtime/react/hooks/useActiveRouteRoleWatcher.ts +0 -31
  708. package/runtime/react/hooks/useAppConfig.ts +0 -9
  709. package/runtime/react/hooks/useAuthenticatedUser.test.tsx +0 -41
  710. package/runtime/react/hooks/useAuthenticatedUser.ts +0 -9
  711. package/runtime/react/hooks/useSiteConfig.test.tsx +0 -13
  712. package/runtime/react/hooks/useSiteConfig.ts +0 -9
  713. package/runtime/react/hooks/useSiteEvent.ts +0 -24
  714. package/runtime/react/index.ts +0 -19
  715. package/runtime/react/reducers.ts +0 -40
  716. package/runtime/routing/index.ts +0 -1
  717. package/runtime/routing/utils.test.ts +0 -7
  718. package/runtime/routing/utils.ts +0 -34
  719. package/runtime/scripts/GoogleAnalyticsLoader.test.ts +0 -77
  720. package/runtime/scripts/GoogleAnalyticsLoader.ts +0 -59
  721. package/runtime/scripts/index.ts +0 -1
  722. package/runtime/setupTest.js +0 -14
  723. package/runtime/site.config.test.tsx +0 -33
  724. package/runtime/slots/Slot.test.tsx +0 -40
  725. package/runtime/slots/Slot.tsx +0 -32
  726. package/runtime/slots/SlotContext.tsx +0 -8
  727. package/runtime/slots/hooks.ts +0 -35
  728. package/runtime/slots/layout/DefaultSlotLayout.test.tsx +0 -31
  729. package/runtime/slots/layout/DefaultSlotLayout.tsx +0 -9
  730. package/runtime/slots/layout/hooks.test.tsx +0 -178
  731. package/runtime/slots/layout/hooks.ts +0 -65
  732. package/runtime/slots/layout/types.ts +0 -45
  733. package/runtime/slots/layout/utils.test.ts +0 -67
  734. package/runtime/slots/layout/utils.ts +0 -14
  735. package/runtime/slots/types.ts +0 -24
  736. package/runtime/slots/utils.test.ts +0 -64
  737. package/runtime/slots/utils.ts +0 -78
  738. package/runtime/slots/widget/WidgetContext.tsx +0 -9
  739. package/runtime/slots/widget/WidgetProvider.tsx +0 -30
  740. package/runtime/slots/widget/hooks.ts +0 -105
  741. package/runtime/slots/widget/iframe/IFrameContentWrapper.messages.tsx +0 -16
  742. package/runtime/slots/widget/iframe/IFrameContentWrapper.tsx +0 -84
  743. package/runtime/slots/widget/iframe/IFrameWidget.tsx +0 -59
  744. package/runtime/slots/widget/iframe/constants.ts +0 -19
  745. package/runtime/slots/widget/iframe/hooks.ts +0 -179
  746. package/runtime/slots/widget/iframe/index.ts +0 -6
  747. package/runtime/slots/widget/iframe/types.ts +0 -7
  748. package/runtime/slots/widget/types.ts +0 -134
  749. package/runtime/slots/widget/utils.tsx +0 -201
  750. package/runtime/subscriptions.ts +0 -60
  751. package/runtime/testing/index.ts +0 -9
  752. package/runtime/testing/initializeMockApp.test.ts +0 -66
  753. package/runtime/testing/initializeMockApp.ts +0 -86
  754. package/runtime/testing/mockMessages.ts +0 -23
  755. package/runtime/utils.js +0 -178
  756. package/runtime/utils.test.js +0 -116
  757. package/shell/DefaultLayout.tsx +0 -18
  758. package/shell/DefaultMain.tsx +0 -7
  759. package/shell/Logo.test.tsx +0 -32
  760. package/shell/Logo.tsx +0 -28
  761. package/shell/Shell.messages.ts +0 -61
  762. package/shell/Shell.tsx +0 -18
  763. package/shell/__mocks__/file.js +0 -1
  764. package/shell/__mocks__/svg.js +0 -1
  765. package/shell/__mocks__/universal-cookie.js +0 -6
  766. package/shell/app.scss +0 -150
  767. package/shell/app.ts +0 -38
  768. package/shell/babel.config.js +0 -3
  769. package/shell/dev/devFooter/app.tsx +0 -43
  770. package/shell/dev/devHeader/BarContext.tsx +0 -13
  771. package/shell/dev/devHeader/BarLink.tsx +0 -16
  772. package/shell/dev/devHeader/BarProvider.tsx +0 -25
  773. package/shell/dev/devHeader/CoursesLink.tsx +0 -16
  774. package/shell/dev/devHeader/FooContext.tsx +0 -13
  775. package/shell/dev/devHeader/FooLink.tsx +0 -16
  776. package/shell/dev/devHeader/FooProvider.tsx +0 -25
  777. package/shell/dev/devHeader/app.tsx +0 -53
  778. package/shell/dev/devHeader/providers.tsx +0 -11
  779. package/shell/dev/devHome/HomePage.tsx +0 -28
  780. package/shell/dev/devHome/app.ts +0 -18
  781. package/shell/dev/devHome/i18n/index.ts +0 -27
  782. package/shell/dev/devHome/messages.ts +0 -11
  783. package/shell/dev/devUser/app.tsx +0 -24
  784. package/shell/dev/devUser/index.ts +0 -1
  785. package/shell/dev/index.ts +0 -5
  786. package/shell/dev/slotShowcase/HorizontalSlotLayout.tsx +0 -11
  787. package/shell/dev/slotShowcase/LayoutWithOptions.tsx +0 -17
  788. package/shell/dev/slotShowcase/SlotShowcasePage.tsx +0 -66
  789. package/shell/dev/slotShowcase/WidgetWithOptions.tsx +0 -11
  790. package/shell/dev/slotShowcase/app.tsx +0 -373
  791. package/shell/footer/CenterLinks.tsx +0 -11
  792. package/shell/footer/CopyrightNotice.tsx +0 -36
  793. package/shell/footer/Footer.tsx +0 -34
  794. package/shell/footer/LabeledLinkColumn.tsx +0 -19
  795. package/shell/footer/LanguageMenu.tsx +0 -35
  796. package/shell/footer/LanguageMenuItem.tsx +0 -23
  797. package/shell/footer/LeftLinks.tsx +0 -11
  798. package/shell/footer/LegalNotices.tsx +0 -17
  799. package/shell/footer/PoweredBy.tsx +0 -17
  800. package/shell/footer/RevealLinks.tsx +0 -43
  801. package/shell/footer/RightLinks.tsx +0 -11
  802. package/shell/footer/app.tsx +0 -73
  803. package/shell/footer/data/api.ts +0 -48
  804. package/shell/header/AuthenticatedMenu.tsx +0 -32
  805. package/shell/header/Header.tsx +0 -17
  806. package/shell/header/anonymous-menu/AnonymousMenu.tsx +0 -14
  807. package/shell/header/anonymous-menu/LoginButton.tsx +0 -14
  808. package/shell/header/anonymous-menu/RegisterButton.tsx +0 -15
  809. package/shell/header/app.tsx +0 -142
  810. package/shell/header/desktop/DesktopLayout.tsx +0 -22
  811. package/shell/header/desktop/PrimaryNavLinks.tsx +0 -10
  812. package/shell/header/desktop/SecondaryNavLinks.tsx +0 -10
  813. package/shell/header/index.ts +0 -2
  814. package/shell/header/mobile/MobileLayout.tsx +0 -47
  815. package/shell/header/mobile/MobileNavLinks.tsx +0 -10
  816. package/shell/i18n/index.ts +0 -25
  817. package/shell/index.ts +0 -7
  818. package/shell/jest.config.js +0 -31
  819. package/shell/menus/LinkMenuItem.tsx +0 -64
  820. package/shell/menus/NavDropdownMenuSlot.tsx +0 -29
  821. package/shell/menus/ProfileLinkMenuItem.tsx +0 -33
  822. package/shell/menus/data/utils.ts +0 -19
  823. package/shell/public/index.html +0 -10
  824. package/shell/router/createRouter.test.tsx +0 -50
  825. package/shell/router/createRouter.ts +0 -17
  826. package/shell/router/getAppRoutes.test.tsx +0 -59
  827. package/shell/router/getAppRoutes.ts +0 -21
  828. package/shell/setupTest.js +0 -13
  829. package/shell/site.config.dev.tsx +0 -49
  830. package/shell/site.config.test.tsx +0 -16
  831. package/shell/site.tsx +0 -41
  832. package/tools/dist/babel/babel.config.js +0 -28
  833. package/tools/dist/cli/intl-imports.js +0 -233
  834. package/tools/dist/cli/intl-imports.test.js +0 -146
  835. package/tools/dist/cli/openedx.js +0 -86
  836. package/tools/dist/cli/transifex-utils.js +0 -68
  837. package/tools/dist/cli/utils/formatter.js +0 -10
  838. package/tools/dist/cli/utils/printUsage.js +0 -39
  839. package/tools/dist/config-helpers/createConfig.js +0 -13
  840. package/tools/dist/config-helpers/createLintConfig.js +0 -16
  841. package/tools/dist/config-helpers/getBaseConfig.js +0 -12
  842. package/tools/dist/defaultConfigPaths.js +0 -35
  843. package/tools/dist/eslint/base.eslint.config.js +0 -113
  844. package/tools/dist/index.js +0 -12
  845. package/tools/dist/jest/jest.config.js +0 -30
  846. package/tools/dist/types.js +0 -23
  847. package/tools/dist/typescript/tsconfig.json +0 -32
  848. package/tools/dist/webpack/common-config/all/getCodeRules.js +0 -52
  849. package/tools/dist/webpack/common-config/all/getFileLoaderRules.js +0 -26
  850. package/tools/dist/webpack/common-config/all/getIgnoreWarnings.js +0 -14
  851. package/tools/dist/webpack/common-config/all/getImageMinimizer.js +0 -25
  852. package/tools/dist/webpack/common-config/all/getStylesheetRule.js +0 -112
  853. package/tools/dist/webpack/common-config/dev/getDevServer.js +0 -38
  854. package/tools/dist/webpack/common-config/index.js +0 -18
  855. package/tools/dist/webpack/common-config/site/getHtmlWebpackPlugin.js +0 -16
  856. package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.js +0 -91
  857. package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/index.js +0 -7
  858. package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/test/HtmlWebpackNewRelicPlugin.test.js +0 -66
  859. package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.js +0 -3
  860. package/tools/dist/webpack/utils/getLocalAliases.js +0 -65
  861. package/tools/dist/webpack/utils/getPublicPath.js +0 -6
  862. package/tools/dist/webpack/utils/getResolvedSiteConfigPath.js +0 -32
  863. package/tools/dist/webpack/webpack.config.build.js +0 -69
  864. package/tools/dist/webpack/webpack.config.dev.js +0 -69
  865. package/tools/dist/webpack/webpack.config.dev.shell.js +0 -103
  866. package/types.ts +0 -119
  867. /package/{runtime/react/hooks/theme/index.ts → dist/runtime/react/hooks/theme/index.d.ts} +0 -0
  868. /package/{runtime/slots/index.ts → dist/runtime/slots/index.d.ts} +0 -0
  869. /package/{runtime/slots/layout/index.ts → dist/runtime/slots/layout/index.d.ts} +0 -0
  870. /package/{runtime/slots/widget/index.ts → dist/runtime/slots/widget/index.d.ts} +0 -0
  871. /package/{shell/dev/devFooter/index.ts → dist/shell/dev/devFooter/index.d.ts} +0 -0
  872. /package/{shell/dev/devHeader/index.ts → dist/shell/dev/devHeader/index.d.ts} +0 -0
  873. /package/{shell/dev/devHome/index.ts → dist/shell/dev/devHome/index.d.ts} +0 -0
  874. /package/{shell/dev/slotShowcase/index.ts → dist/shell/dev/slotShowcase/index.d.ts} +0 -0
  875. /package/{shell/footer/index.ts → dist/shell/footer/index.d.ts} +0 -0
  876. /package/{config → dist/tools}/babel/babel.config.js +0 -0
  877. /package/{tools/dist → dist/tools}/cli/commands/serve.js +0 -0
  878. /package/{tools/dist → dist/tools}/cli/utils/ensureConfigFilenameOption.js +0 -0
  879. /package/{tools/dist → dist/tools}/cli/utils/getResolvedConfigPath.js +0 -0
  880. /package/{tools/dist → dist/tools}/cli/utils/prettyPrintTitle.js +0 -0
  881. /package/{config → dist/tools}/config-helpers/createConfig.js +0 -0
  882. /package/{config → dist/tools}/config-helpers/createLintConfig.js +0 -0
  883. /package/{config → dist/tools}/config-helpers/getBaseConfig.js +0 -0
  884. /package/{config → dist/tools}/defaultConfigPaths.js +0 -0
  885. /package/{tools/dist → dist/tools}/eslint.config.js +0 -0
  886. /package/{config → dist/tools}/index.js +0 -0
  887. /package/{config → dist/tools}/jest/jest.config.js +0 -0
  888. /package/{tools/dist → dist/tools}/jest.config.js +0 -0
  889. /package/{config → dist/tools}/webpack/common-config/all/getCodeRules.js +0 -0
  890. /package/{config → dist/tools}/webpack/common-config/all/getFileLoaderRules.js +0 -0
  891. /package/{config → dist/tools}/webpack/common-config/all/getImageMinimizer.js +0 -0
  892. /package/{config → dist/tools}/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.js +0 -0
  893. /package/{config → dist/tools}/webpack/plugins/html-webpack-new-relic-plugin/index.js +0 -0
  894. /package/{config → dist/tools}/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.js +0 -0
  895. /package/{config → dist/tools}/webpack/utils/getResolvedSiteConfigPath.js +0 -0
@@ -0,0 +1,339 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import axios from 'axios';
11
+ import PropTypes from 'prop-types';
12
+ import { camelCaseObject } from '../utils';
13
+ import AxiosCsrfTokenService from './AxiosCsrfTokenService';
14
+ import AxiosJwtTokenService from './AxiosJwtTokenService';
15
+ import createCsrfTokenProviderInterceptor from './interceptors/createCsrfTokenProviderInterceptor';
16
+ import createJwtTokenProviderInterceptor from './interceptors/createJwtTokenProviderInterceptor';
17
+ import createProcessAxiosRequestErrorInterceptor from './interceptors/createProcessAxiosRequestErrorInterceptor';
18
+ import configureCache from './LocalForageCache';
19
+ import { logFrontendAuthError } from './utils';
20
+ const optionsPropTypes = {
21
+ config: PropTypes.shape({
22
+ baseUrl: PropTypes.string.isRequired,
23
+ lmsBaseUrl: PropTypes.string.isRequired,
24
+ loginUrl: PropTypes.string.isRequired,
25
+ logoutUrl: PropTypes.string.isRequired,
26
+ refreshAccessTokenApiPath: PropTypes.string.isRequired,
27
+ accessTokenCookieName: PropTypes.string.isRequired,
28
+ csrfTokenApiPath: PropTypes.string.isRequired,
29
+ }).isRequired,
30
+ loggingService: PropTypes.shape({
31
+ logError: PropTypes.func.isRequired,
32
+ logInfo: PropTypes.func.isRequired,
33
+ }).isRequired,
34
+ };
35
+ /**
36
+ * @implements {AuthService}
37
+ * @memberof module:Auth
38
+ */
39
+ class AxiosJwtAuthService {
40
+ /**
41
+ * @param {Object} options
42
+ * @param {Object} options.config
43
+ * @param {string} options.config.baseUrl
44
+ * @param {string} options.config.lmsBaseUrl
45
+ * @param {string} options.config.loginUrl
46
+ * @param {string} options.config.logoutUrl
47
+ * @param {string} options.config.refreshAccessTokenApiPath
48
+ * @param {string} options.config.accessTokenCookieName
49
+ * @param {string} options.config.csrfTokenApiPath
50
+ * @param {Object} options.loggingService requires logError and logInfo methods
51
+ */
52
+ constructor(options) {
53
+ this.authenticatedHttpClient = null;
54
+ this.httpClient = null;
55
+ this.cachedAuthenticatedHttpClient = null;
56
+ this.cachedHttpClient = null;
57
+ this.authenticatedUser = null;
58
+ PropTypes.checkPropTypes(optionsPropTypes, options, 'options', 'AuthService');
59
+ this.config = options.config;
60
+ this.loggingService = options.loggingService;
61
+ this.jwtTokenService = new AxiosJwtTokenService(this.loggingService, this.config.accessTokenCookieName, this.config.lmsBaseUrl, this.config.refreshAccessTokenApiPath);
62
+ this.csrfTokenService = new AxiosCsrfTokenService(this.config.csrfTokenApiPath);
63
+ this.authenticatedHttpClient = this.addAuthenticationToHttpClient(axios.create());
64
+ this.httpClient = axios.create();
65
+ configureCache()
66
+ .then((cachedAxiosClient) => {
67
+ this.cachedAuthenticatedHttpClient = this.addAuthenticationToHttpClient(cachedAxiosClient);
68
+ this.cachedHttpClient = cachedAxiosClient;
69
+ })
70
+ .catch((e) => {
71
+ // fallback to non-cached HTTP clients and log error
72
+ this.cachedAuthenticatedHttpClient = this.authenticatedHttpClient;
73
+ this.cachedHttpClient = this.httpClient;
74
+ logFrontendAuthError(this.loggingService, `configureCache failed with error: ${e.message}`);
75
+ }).finally(() => {
76
+ this.middleware = options.middleware;
77
+ this.applyMiddleware(options.middleware);
78
+ });
79
+ }
80
+ /**
81
+ * Applies middleware to the axios instances in this service.
82
+ *
83
+ * @param {Array} middleware Middleware to apply.
84
+ */
85
+ applyMiddleware(middleware = []) {
86
+ const clients = [
87
+ this.authenticatedHttpClient, this.httpClient,
88
+ this.cachedAuthenticatedHttpClient, this.cachedHttpClient,
89
+ ];
90
+ try {
91
+ (middleware).forEach((middlewareFn) => {
92
+ clients.forEach((client) => client && middlewareFn(client));
93
+ });
94
+ }
95
+ catch (error) {
96
+ logFrontendAuthError(this.loggingService, error);
97
+ throw error;
98
+ }
99
+ }
100
+ /**
101
+ * Gets the authenticated HTTP client for the service. This is an axios instance.
102
+ *
103
+ * @param {Object} [options] Optional options for how the HTTP client should be configured.
104
+ * @param {boolean} [options.useCache] Whether to use front end caching for all requests made
105
+ * with the returned client.
106
+ *
107
+ * @returns {HttpClient} A configured axios http client which can be used for authenticated
108
+ * requests.
109
+ */
110
+ getAuthenticatedHttpClient(options = {}) {
111
+ if (options.useCache) {
112
+ return this.cachedAuthenticatedHttpClient;
113
+ }
114
+ return this.authenticatedHttpClient;
115
+ }
116
+ /**
117
+ * Gets the unauthenticated HTTP client for the service. This is an axios instance.
118
+ *
119
+ * @param {Object} [options] Optional options for how the HTTP client should be configured.
120
+ * @param {boolean} [options.useCache] Whether to use front end caching for all requests made
121
+ * with the returned client.
122
+ * @returns {HttpClient} A configured axios http client.
123
+ */
124
+ getHttpClient(options = {}) {
125
+ if (options.useCache) {
126
+ return this.cachedHttpClient;
127
+ }
128
+ return this.httpClient;
129
+ }
130
+ /**
131
+ * Used primarily for testing.
132
+ *
133
+ * @ignore
134
+ */
135
+ getJwtTokenService() {
136
+ return this.jwtTokenService;
137
+ }
138
+ /**
139
+ * Used primarily for testing.
140
+ *
141
+ * @ignore
142
+ */
143
+ getCsrfTokenService() {
144
+ return this.csrfTokenService;
145
+ }
146
+ /**
147
+ * Builds a URL to the login page with a post-login redirect URL attached as a query parameter.
148
+ *
149
+ * ```
150
+ * const url = getLoginRedirectUrl('http://localhost/mypage');
151
+ * console.log(url); // http://localhost/login?next=http%3A%2F%2Flocalhost%2Fmypage
152
+ * ```
153
+ *
154
+ * @param {string} redirectUrl The URL the user should be redirected to after logging in.
155
+ */
156
+ getLoginRedirectUrl(redirectUrl = this.config.baseUrl) {
157
+ return `${this.config.loginUrl}?next=${encodeURIComponent(redirectUrl)}`;
158
+ }
159
+ /**
160
+ * Redirects the user to the login page.
161
+ *
162
+ * @param {string} redirectUrl The URL the user should be redirected to after logging in.
163
+ */
164
+ redirectToLogin(redirectUrl = this.config.baseUrl) {
165
+ global.location.assign(this.getLoginRedirectUrl(redirectUrl));
166
+ }
167
+ /**
168
+ * Builds a URL to the logout page with a post-logout redirect URL attached as a query parameter.
169
+ *
170
+ * ```
171
+ * const url = getLogoutRedirectUrl('http://localhost/mypage');
172
+ * console.log(url); // http://localhost/logout?next=http%3A%2F%2Flocalhost%2Fmypage
173
+ * ```
174
+ *
175
+ * @param {string} redirectUrl The URL the user should be redirected to after logging out.
176
+ */
177
+ getLogoutRedirectUrl(redirectUrl = this.config.baseUrl) {
178
+ return `${this.config.logoutUrl}?redirect_url=${encodeURIComponent(redirectUrl)}`;
179
+ }
180
+ /**
181
+ * Redirects the user to the logout page.
182
+ *
183
+ * @param {string} redirectUrl The URL the user should be redirected to after logging out.
184
+ */
185
+ redirectToLogout(redirectUrl = this.config.baseUrl) {
186
+ global.location.assign(this.getLogoutRedirectUrl(redirectUrl));
187
+ }
188
+ /**
189
+ * If it exists, returns the user data representing the currently authenticated user. If the
190
+ * user is anonymous, returns null.
191
+ *
192
+ * @returns {UserData|null}
193
+ */
194
+ getAuthenticatedUser() {
195
+ return this.authenticatedUser;
196
+ }
197
+ /**
198
+ * Sets the authenticated user to the provided value.
199
+ *
200
+ * @param {UserData} authUser
201
+ */
202
+ setAuthenticatedUser(authUser) {
203
+ this.authenticatedUser = authUser;
204
+ }
205
+ /**
206
+ * Reads the authenticated user's access token. Resolves to null if the user is
207
+ * unauthenticated.
208
+ *
209
+ * @returns {Promise<UserData>|Promise<null>} Resolves to the user's access token if they are
210
+ * logged in.
211
+ */
212
+ fetchAuthenticatedUser() {
213
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
214
+ const decodedAccessToken = yield this.jwtTokenService.getJwtToken(options.forceRefresh || false);
215
+ if (decodedAccessToken !== null) {
216
+ this.setAuthenticatedUser({
217
+ email: decodedAccessToken.email,
218
+ userId: decodedAccessToken.user_id,
219
+ username: decodedAccessToken.preferred_username,
220
+ roles: decodedAccessToken.roles || [],
221
+ administrator: decodedAccessToken.administrator,
222
+ name: decodedAccessToken.name,
223
+ });
224
+ // Sets userId as a custom attribute that will be included with all subsequent log messages.
225
+ // Very helpful for debugging.
226
+ this.loggingService.setCustomAttribute('userId', decodedAccessToken.user_id);
227
+ }
228
+ else {
229
+ this.setAuthenticatedUser(null);
230
+ // Intentionally not setting `userId` in the logging service here because it would be useful
231
+ // to know the previously logged in user for debugging refresh issues.
232
+ }
233
+ return this.getAuthenticatedUser();
234
+ });
235
+ }
236
+ /**
237
+ * Ensures a user is authenticated. It will redirect to login when not
238
+ * authenticated.
239
+ *
240
+ * @param {string} [redirectUrl=config.baseUrl] to return user after login when not
241
+ * authenticated.
242
+ * @returns {Promise<UserData>}
243
+ */
244
+ ensureAuthenticatedUser() {
245
+ return __awaiter(this, arguments, void 0, function* (redirectUrl = this.config.baseUrl) {
246
+ var _a;
247
+ yield this.fetchAuthenticatedUser();
248
+ if (this.getAuthenticatedUser() === null) {
249
+ const isRedirectFromLoginPage = (_a = global.document.referrer) === null || _a === void 0 ? void 0 : _a.startsWith(this.config.loginUrl);
250
+ if (isRedirectFromLoginPage) {
251
+ const redirectLoopError = new Error('Redirect from login page. Rejecting to avoid infinite redirect loop.');
252
+ logFrontendAuthError(this.loggingService, redirectLoopError);
253
+ throw redirectLoopError;
254
+ }
255
+ // The user is not authenticated, send them to the login page.
256
+ this.redirectToLogin(redirectUrl);
257
+ const unauthorizedError = new Error('Failed to ensure the user is authenticated');
258
+ unauthorizedError.isRedirecting = true;
259
+ throw unauthorizedError;
260
+ }
261
+ return this.getAuthenticatedUser();
262
+ });
263
+ }
264
+ /**
265
+ * Fetches additional user account information for the authenticated user and merges it into the
266
+ * existing authenticatedUser object, available via getAuthenticatedUser().
267
+ *
268
+ * ```
269
+ * console.log(authenticatedUser); // Will be sparse and only contain basic information.
270
+ * await hydrateAuthenticatedUser()
271
+ * const authenticatedUser = getAuthenticatedUser();
272
+ * console.log(authenticatedUser); // Will contain additional user information
273
+ * ```
274
+ *
275
+ * @returns {Promise<null>}
276
+ */
277
+ hydrateAuthenticatedUser() {
278
+ return __awaiter(this, void 0, void 0, function* () {
279
+ const user = this.getAuthenticatedUser();
280
+ if (user !== null) {
281
+ const response = yield this.authenticatedHttpClient
282
+ .get(`${this.config.lmsBaseUrl}/api/user/v1/accounts/${user.username}`);
283
+ this.setAuthenticatedUser(Object.assign(Object.assign({}, user), camelCaseObject(response.data)));
284
+ }
285
+ });
286
+ }
287
+ /**
288
+ * Adds authentication defaults and interceptors to an HTTP client instance.
289
+ *
290
+ * @param {HttpClient} newHttpClient
291
+ * @param {Object} config
292
+ * @param {string} [config.refreshAccessTokenApiPath]
293
+ * @param {string} [config.accessTokenCookieName]
294
+ * @param {string} [config.csrfTokenApiPath]
295
+ * @returns {HttpClient} A configured Axios HTTP client.
296
+ */
297
+ addAuthenticationToHttpClient(newHttpClient) {
298
+ const httpClient = Object.create(newHttpClient);
299
+ // Set withCredentials to true. Enables cross-site Access-Control requests
300
+ // to be made using cookies, authorization headers or TLS client
301
+ // certificates. More on MDN:
302
+ // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials
303
+ httpClient.defaults.withCredentials = true;
304
+ // Axios interceptors
305
+ // The JWT access token interceptor attempts to refresh the user's jwt token
306
+ // before any request unless the isPublic flag is set on the request config.
307
+ const refreshAccessTokenInterceptor = createJwtTokenProviderInterceptor({
308
+ jwtTokenService: this.jwtTokenService,
309
+ shouldSkip: axiosRequestConfig => axiosRequestConfig.isPublic,
310
+ });
311
+ // The CSRF token intercepter fetches and caches a csrf token for any post,
312
+ // put, patch, or delete request. That token is then added to the request
313
+ // headers.
314
+ const attachCsrfTokenInterceptor = createCsrfTokenProviderInterceptor({
315
+ csrfTokenService: this.csrfTokenService,
316
+ csrfTokenApiPath: this.config.csrfTokenApiPath,
317
+ shouldSkip: (axiosRequestConfig) => {
318
+ const { method, isCsrfExempt } = axiosRequestConfig;
319
+ const CSRF_PROTECTED_METHODS = ['post', 'put', 'patch', 'delete'];
320
+ return isCsrfExempt || !CSRF_PROTECTED_METHODS.includes(method);
321
+ },
322
+ });
323
+ const processAxiosRequestErrorInterceptor = createProcessAxiosRequestErrorInterceptor({
324
+ loggingService: this.loggingService,
325
+ });
326
+ // Request interceptors: Axios runs the interceptors in reverse order from
327
+ // how they are listed. After fetching csrf tokens no longer require jwt
328
+ // authentication, it won't matter which happens first. This change is
329
+ // coming soon in edx-platform. Nov. 2019
330
+ httpClient.interceptors.request.use(attachCsrfTokenInterceptor);
331
+ httpClient.interceptors.request.use(refreshAccessTokenInterceptor);
332
+ // Response interceptor: moves axios response error data into the error
333
+ // object at error.customAttributes
334
+ httpClient.interceptors.response.use(response => response, processAxiosRequestErrorInterceptor);
335
+ return httpClient;
336
+ }
337
+ }
338
+ export default AxiosJwtAuthService;
339
+ //# sourceMappingURL=AxiosJwtAuthService.js.map
@@ -0,0 +1 @@
1
+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BAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;YAC9C,UAAU,EAAE,CAAC,kBAAkB,EAAE,EAAE;gBACjC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAAC;gBACpD,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;gBAClE,OAAO,YAAY,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAClE,CAAC;SACF,CAAC,CAAC;QAEH,MAAM,mCAAmC,GAAG,yCAAyC,CAAC;YACpF,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC,CAAC;QAEH,0EAA0E;QAC1E,wEAAwE;QACxE,sEAAsE;QACtE,yCAAyC;QACzC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QAChE,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAEnE,uEAAuE;QACvE,mCAAmC;QACnC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EACpB,mCAAmC,CACpC,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["import axios from 'axios';\nimport PropTypes from 'prop-types';\nimport { camelCaseObject } from '../utils';\nimport AxiosCsrfTokenService from './AxiosCsrfTokenService';\nimport AxiosJwtTokenService from './AxiosJwtTokenService';\nimport createCsrfTokenProviderInterceptor from './interceptors/createCsrfTokenProviderInterceptor';\nimport createJwtTokenProviderInterceptor from './interceptors/createJwtTokenProviderInterceptor';\nimport createProcessAxiosRequestErrorInterceptor from './interceptors/createProcessAxiosRequestErrorInterceptor';\nimport configureCache from './LocalForageCache';\nimport { logFrontendAuthError } from './utils';\n\nconst optionsPropTypes = {\n config: PropTypes.shape({\n baseUrl: PropTypes.string.isRequired,\n lmsBaseUrl: PropTypes.string.isRequired,\n loginUrl: PropTypes.string.isRequired,\n logoutUrl: PropTypes.string.isRequired,\n refreshAccessTokenApiPath: PropTypes.string.isRequired,\n accessTokenCookieName: PropTypes.string.isRequired,\n csrfTokenApiPath: 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.baseUrl\n * @param {string} options.config.lmsBaseUrl\n * @param {string} options.config.loginUrl\n * @param {string} options.config.logoutUrl\n * @param {string} options.config.refreshAccessTokenApiPath\n * @param {string} options.config.accessTokenCookieName\n * @param {string} options.config.csrfTokenApiPath\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 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.accessTokenCookieName,\n this.config.lmsBaseUrl,\n this.config.refreshAccessTokenApiPath,\n );\n this.csrfTokenService = new AxiosCsrfTokenService(this.config.csrfTokenApiPath);\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 }).finally(() => {\n this.middleware = options.middleware;\n this.applyMiddleware(options.middleware);\n });\n }\n\n /**\n * Applies middleware to the axios instances in this service.\n *\n * @param {Array} middleware Middleware to apply.\n */\n applyMiddleware(middleware = []) {\n const clients = [\n this.authenticatedHttpClient, this.httpClient,\n this.cachedAuthenticatedHttpClient, this.cachedHttpClient,\n ];\n try {\n (middleware).forEach((middlewareFn) => {\n clients.forEach((client) => client && middlewareFn(client));\n });\n } catch (error) {\n logFrontendAuthError(this.loggingService, error);\n throw error;\n }\n }\n\n /**\n * Gets the authenticated HTTP client for the service. This is an axios instance.\n *\n * @param {Object} [options] Optional options for how the HTTP client should be configured.\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made\n * with the returned client.\n *\n * @returns {HttpClient} A configured axios http client which can be used for authenticated\n * requests.\n */\n getAuthenticatedHttpClient(options = {}) {\n if (options.useCache) {\n return this.cachedAuthenticatedHttpClient;\n }\n\n return this.authenticatedHttpClient;\n }\n\n /**\n * Gets the unauthenticated HTTP client for the service. This is an axios instance.\n *\n * @param {Object} [options] Optional options for how the HTTP client should be configured.\n * @param {boolean} [options.useCache] Whether to use front end caching for all requests made\n * with the returned client.\n * @returns {HttpClient} A configured axios http client.\n */\n getHttpClient(options = {}) {\n if (options.useCache) {\n return this.cachedHttpClient;\n }\n\n return this.httpClient;\n }\n\n /**\n * Used primarily for testing.\n *\n * @ignore\n */\n getJwtTokenService() {\n return this.jwtTokenService;\n }\n\n /**\n * Used primarily for testing.\n *\n * @ignore\n */\n getCsrfTokenService() {\n return this.csrfTokenService;\n }\n\n /**\n * Builds a URL to the login page with a post-login redirect URL attached as a query parameter.\n *\n * ```\n * const url = getLoginRedirectUrl('http://localhost/mypage');\n * console.log(url); // http://localhost/login?next=http%3A%2F%2Flocalhost%2Fmypage\n * ```\n *\n * @param {string} redirectUrl The URL the user should be redirected to after logging in.\n */\n getLoginRedirectUrl(redirectUrl = this.config.baseUrl) {\n return `${this.config.loginUrl}?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.baseUrl) {\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.baseUrl) {\n return `${this.config.logoutUrl}?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.baseUrl) {\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 // Sets userId as a custom attribute that will be included with all subsequent log messages.\n // Very helpful for debugging.\n this.loggingService.setCustomAttribute('userId', decodedAccessToken.user_id);\n } else {\n this.setAuthenticatedUser(null);\n // Intentionally not setting `userId` in the logging service here because it would be useful\n // to know the previously logged in user for debugging refresh issues.\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.baseUrl] to return user after login when not\n * authenticated.\n * @returns {Promise<UserData>}\n */\n async ensureAuthenticatedUser(redirectUrl = this.config.baseUrl) {\n await this.fetchAuthenticatedUser();\n\n if (this.getAuthenticatedUser() === null) {\n const isRedirectFromLoginPage = global.document.referrer?.startsWith(this.config.loginUrl);\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.lmsBaseUrl}/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.refreshAccessTokenApiPath]\n * @param {string} [config.accessTokenCookieName]\n * @param {string} [config.csrfTokenApiPath]\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 csrfTokenApiPath: this.config.csrfTokenApiPath,\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"]}
@@ -0,0 +1,16 @@
1
+ export default class AxiosJwtTokenService {
2
+ static isTokenExpired(token: any): boolean;
3
+ constructor(loggingService: any, tokenCookieName: any, tokenRefreshBaseUrl: any, tokenRefreshPath: any);
4
+ loggingService: any;
5
+ tokenCookieName: any;
6
+ tokenRefreshBaseUrl: any;
7
+ tokenRefreshPath: any;
8
+ httpClient: import("axios").AxiosInstance;
9
+ cookies: Cookies;
10
+ refreshRequestPromises: {};
11
+ getHttpClient(): import("axios").AxiosInstance;
12
+ decodeJwtCookie(): unknown;
13
+ refresh(): any;
14
+ getJwtToken(forceRefresh?: boolean): Promise<any>;
15
+ }
16
+ import Cookies from 'universal-cookie';
@@ -0,0 +1,130 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import axios from 'axios';
11
+ import jwtDecode from 'jwt-decode';
12
+ import Cookies from 'universal-cookie';
13
+ import createRetryInterceptor from './interceptors/createRetryInterceptor';
14
+ import { logFrontendAuthError, processAxiosErrorAndThrow } from './utils';
15
+ export default class AxiosJwtTokenService {
16
+ static isTokenExpired(token) {
17
+ return !token || token.exp < Date.now() / 1000;
18
+ }
19
+ constructor(loggingService, tokenCookieName, tokenRefreshBaseUrl, tokenRefreshPath) {
20
+ this.loggingService = loggingService;
21
+ this.tokenCookieName = tokenCookieName;
22
+ this.tokenRefreshBaseUrl = tokenRefreshBaseUrl;
23
+ this.tokenRefreshPath = tokenRefreshPath;
24
+ this.httpClient = axios.create();
25
+ // Set withCredentials to true. Enables cross-site Access-Control requests
26
+ // to be made using cookies, authorization headers or TLS client
27
+ // certificates. More on MDN:
28
+ // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials
29
+ this.httpClient.defaults.withCredentials = true;
30
+ // Add retries to this axios instance
31
+ this.httpClient.interceptors.response.use(response => response, createRetryInterceptor({ httpClient: this.httpClient }));
32
+ this.cookies = new Cookies();
33
+ this.refreshRequestPromises = {};
34
+ }
35
+ getHttpClient() {
36
+ return this.httpClient;
37
+ }
38
+ decodeJwtCookie() {
39
+ const cookieValue = this.cookies.get(this.tokenCookieName);
40
+ if (cookieValue) {
41
+ try {
42
+ return jwtDecode(cookieValue);
43
+ }
44
+ catch (e) {
45
+ const error = Object.create(e);
46
+ error.message = 'Error decoding JWT token';
47
+ error.customAttributes = { cookieValue };
48
+ throw error;
49
+ }
50
+ }
51
+ return null;
52
+ }
53
+ refresh() {
54
+ let responseServerEpochSeconds = 0;
55
+ if (this.refreshRequestPromises[this.tokenCookieName] === undefined) {
56
+ const makeRefreshRequest = () => __awaiter(this, void 0, void 0, function* () {
57
+ var _a;
58
+ let axiosResponse;
59
+ try {
60
+ try {
61
+ axiosResponse = yield this.httpClient.post(`${this.tokenRefreshBaseUrl}${this.tokenRefreshPath}`);
62
+ if ((_a = axiosResponse.data) === null || _a === void 0 ? void 0 : _a.response_epoch_seconds) {
63
+ responseServerEpochSeconds = axiosResponse.data.response_epoch_seconds;
64
+ }
65
+ }
66
+ catch (error) {
67
+ processAxiosErrorAndThrow(error);
68
+ }
69
+ }
70
+ catch (error) {
71
+ const userIsUnauthenticated = error.response && error.response.status === 401;
72
+ if (userIsUnauthenticated) {
73
+ // Clean up the cookie if it exists to eliminate any situation
74
+ // where the cookie is not expired but the jwt is expired.
75
+ this.cookies.remove(this.tokenCookieName);
76
+ const decodedJwtToken = null;
77
+ return decodedJwtToken;
78
+ }
79
+ // TODO: Network timeouts and other problems will end up in
80
+ // this block of code. We could add logic for retrying token
81
+ // refreshes if we wanted to.
82
+ throw error;
83
+ }
84
+ const browserEpochSeconds = Date.now() / 1000;
85
+ const browserDriftSeconds = responseServerEpochSeconds > 0
86
+ ? Math.abs(browserEpochSeconds - responseServerEpochSeconds)
87
+ : null;
88
+ const decodedJwtToken = this.decodeJwtCookie();
89
+ if (!decodedJwtToken) {
90
+ // This is an unexpected case. The refresh endpoint should set the
91
+ // cookie that is needed.
92
+ // For more details, see:
93
+ // docs/decisions/0005-token-null-after-successful-refresh.rst
94
+ const error = new Error('Access token is still null after successful refresh.');
95
+ error.customAttributes = { axiosResponse, browserDriftSeconds, browserEpochSeconds };
96
+ throw error;
97
+ }
98
+ return decodedJwtToken;
99
+ });
100
+ this.refreshRequestPromises[this.tokenCookieName] = makeRefreshRequest().finally(() => {
101
+ delete this.refreshRequestPromises[this.tokenCookieName];
102
+ });
103
+ }
104
+ return this.refreshRequestPromises[this.tokenCookieName];
105
+ }
106
+ getJwtToken() {
107
+ return __awaiter(this, arguments, void 0, function* (forceRefresh = false) {
108
+ try {
109
+ const decodedJwtToken = this.decodeJwtCookie(this.tokenCookieName);
110
+ if (!AxiosJwtTokenService.isTokenExpired(decodedJwtToken) && !forceRefresh) {
111
+ return decodedJwtToken;
112
+ }
113
+ }
114
+ catch (e) {
115
+ // Log unexpected error and continue with attempt to refresh it.
116
+ // TODO: Fix these. They're still using loggingService as a singleton.
117
+ logFrontendAuthError(this.loggingService, e);
118
+ }
119
+ try {
120
+ return yield this.refresh();
121
+ }
122
+ catch (e) {
123
+ // TODO: Fix these. They're still using loggingService as a singleton.
124
+ logFrontendAuthError(this.loggingService, e);
125
+ throw e;
126
+ }
127
+ });
128
+ }
129
+ }
130
+ //# sourceMappingURL=AxiosJwtTokenService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AxiosJwtTokenService.js","sourceRoot":"","sources":["../../../runtime/auth/AxiosJwtTokenService.js"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO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AAC,eAAe,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;oBAC3E,OAAO,eAAe,CAAC;gBACzB,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,gEAAgE;gBAChE,uEAAuE;gBACvE,oBAAoB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;YAC/C,CAAC;YAED,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YAC9B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,uEAAuE;gBACvE,oBAAoB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;gBAC7C,MAAM,CAAC,CAAC;YACV,CAAC;QACH,CAAC;KAAA;CACF","sourcesContent":["import axios from 'axios';\nimport jwtDecode from 'jwt-decode';\nimport Cookies from 'universal-cookie';\nimport createRetryInterceptor from './interceptors/createRetryInterceptor';\nimport { logFrontendAuthError, processAxiosErrorAndThrow } from './utils';\n\nexport default class AxiosJwtTokenService {\n static isTokenExpired(token) {\n return !token || token.exp < Date.now() / 1000;\n }\n\n constructor(loggingService, tokenCookieName, tokenRefreshBaseUrl, tokenRefreshPath) {\n this.loggingService = loggingService;\n this.tokenCookieName = tokenCookieName;\n this.tokenRefreshBaseUrl = tokenRefreshBaseUrl;\n this.tokenRefreshPath = tokenRefreshPath;\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.tokenRefreshBaseUrl}${this.tokenRefreshPath}`);\n if (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"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Async function to configure localforage and setup the cache
3
+ *
4
+ * @returns {Promise} A promise that, when resolved, returns an axios instance configured to
5
+ * use localforage as a cache.
6
+ */
7
+ export default function configureCache(): Promise<any>;
@@ -0,0 +1,78 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import axios from 'axios';
11
+ import { buildStorage, defaultHeaderInterpreter, defaultKeyGenerator, setupCache, } from 'axios-cache-interceptor';
12
+ import localforage from 'localforage';
13
+ import memoryDriver from 'localforage-memoryStorageDriver';
14
+ /**
15
+ * Async function to configure localforage and setup the cache
16
+ *
17
+ * @returns {Promise} A promise that, when resolved, returns an axios instance configured to
18
+ * use localforage as a cache.
19
+ */
20
+ export default function configureCache() {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ // Register the imported `memoryDriver` to `localforage`
23
+ yield localforage.defineDriver(memoryDriver);
24
+ // Create `localforage` instance
25
+ const forageStore = localforage.createInstance({
26
+ // List of drivers used
27
+ driver: [
28
+ localforage.INDEXEDDB,
29
+ localforage.LOCALSTORAGE,
30
+ memoryDriver._driver,
31
+ ],
32
+ name: 'edx-cache',
33
+ });
34
+ const forageStoreAdapter = buildStorage({
35
+ find(key) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const result = yield forageStore.getItem(`axios-cache:${key}`);
38
+ return JSON.parse(result);
39
+ });
40
+ },
41
+ set(key, value) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ yield forageStore.setItem(`axios-cache:${key}`, JSON.stringify(value));
44
+ });
45
+ },
46
+ remove(key) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ yield forageStore.removeItem(`axios-cache:${key}`);
49
+ });
50
+ },
51
+ });
52
+ // only GET methods are cached by default
53
+ return setupCache(
54
+ // axios instance
55
+ axios.create(), {
56
+ ttl: 5 * 60 * 1000, // default maxAge of 5 minutes
57
+ // The storage to save the cache data. There are more available by default.
58
+ //
59
+ // https://axios-cache-interceptor.js.org/#/pages/storages
60
+ storage: forageStoreAdapter,
61
+ // The mechanism to generate a unique key for each request.
62
+ //
63
+ // https://axios-cache-interceptor.js.org/#/pages/request-id
64
+ generateKey: defaultKeyGenerator,
65
+ // The mechanism to interpret headers (when cache.interpretHeader is true).
66
+ //
67
+ // https://axios-cache-interceptor.js.org/#/pages/global-configuration?id=headerinterpreter
68
+ headerInterpreter: defaultHeaderInterpreter,
69
+ // The function that will receive debug information.
70
+ // NOTE: For this to work, you need to enable development mode.
71
+ //
72
+ // https://axios-cache-interceptor.js.org/#/pages/development-mode
73
+ // https://axios-cache-interceptor.js.org/#/pages/global-configuration?id=debug
74
+ debug: console.log,
75
+ });
76
+ });
77
+ }
78
+ //# sourceMappingURL=LocalForageCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalForageCache.js","sourceRoot":"","sources":["../../../runtime/auth/LocalForageCache.js"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,mBAA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YAC5D,WAAW,EAAE,mBAAmB;YAEhC,2EAA2E;YAC3E,EAAE;YACF,2FAA2F;YAC3F,iBAAiB,EAAE,wBAAwB;YAE3C,oDAAoD;YACpD,+DAA+D;YAC/D,EAAE;YACF,kEAAkE;YAClE,+EAA+E;YAC/E,KAAK,EAAE,OAAO,CAAC,GAAG;SACnB,CACF,CAAC;IACJ,CAAC;CAAA","sourcesContent":["import axios from 'axios';\nimport {\n buildStorage,\n defaultHeaderInterpreter,\n defaultKeyGenerator,\n setupCache,\n} from 'axios-cache-interceptor';\nimport localforage from 'localforage';\nimport memoryDriver from 'localforage-memoryStorageDriver';\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 const forageStoreAdapter = buildStorage({\n async find(key) {\n const result = await forageStore.getItem(`axios-cache:${key}`);\n return JSON.parse(result);\n },\n\n async set(key, value) {\n await forageStore.setItem(`axios-cache:${key}`, JSON.stringify(value));\n },\n\n async remove(key) {\n await forageStore.removeItem(`axios-cache:${key}`);\n },\n });\n\n // only GET methods are cached by default\n return setupCache(\n // axios instance\n axios.create(),\n {\n ttl: 5 * 60 * 1000, // default maxAge of 5 minutes\n // The storage to save the cache data. There are more available by default.\n //\n // https://axios-cache-interceptor.js.org/#/pages/storages\n storage: forageStoreAdapter,\n\n // The mechanism to generate a unique key for each request.\n //\n // https://axios-cache-interceptor.js.org/#/pages/request-id\n generateKey: defaultKeyGenerator,\n\n // The mechanism to interpret headers (when cache.interpretHeader is true).\n //\n // https://axios-cache-interceptor.js.org/#/pages/global-configuration?id=headerinterpreter\n headerInterpreter: defaultHeaderInterpreter,\n\n // The function that will receive debug information.\n // NOTE: For this to work, you need to enable development mode.\n //\n // https://axios-cache-interceptor.js.org/#/pages/development-mode\n // https://axios-cache-interceptor.js.org/#/pages/global-configuration?id=debug\n debug: console.log,\n },\n );\n}\n"]}