@inrupt/solid-client-authn-browser 1.11.9-alpha.1 → 1.11.9-alpha.4

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 (262) hide show
  1. package/dist/index.es.js +4 -352
  2. package/dist/index.es.js.map +1 -0
  3. package/dist/index.js +12 -360
  4. package/dist/index.js.map +1 -1
  5. package/dist/solid-client-authn.bundle.js +14 -363
  6. package/dist/solid-client-authn.bundle.js.map +1 -0
  7. package/package.json +8 -5
  8. package/.eslintrc.js +0 -16
  9. package/NOTICE +0 -5
  10. package/coverage/clover.xml +0 -547
  11. package/coverage/coverage-final.json +0 -28
  12. package/coverage/lcov-report/base.css +0 -224
  13. package/coverage/lcov-report/block-navigation.js +0 -87
  14. package/coverage/lcov-report/favicon.png +0 -0
  15. package/coverage/lcov-report/index.html +0 -266
  16. package/coverage/lcov-report/prettify.css +0 -1
  17. package/coverage/lcov-report/prettify.js +0 -2
  18. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  19. package/coverage/lcov-report/sorter.js +0 -196
  20. package/coverage/lcov-report/src/ClientAuthentication.ts.html +0 -631
  21. package/coverage/lcov-report/src/Session.ts.html +0 -1435
  22. package/coverage/lcov-report/src/constant.ts.html +0 -163
  23. package/coverage/lcov-report/src/defaultSession.ts.html +0 -460
  24. package/coverage/lcov-report/src/dependencies.ts.html +0 -400
  25. package/coverage/lcov-report/src/iframe.ts.html +0 -394
  26. package/coverage/lcov-report/src/index.browser.ts.html +0 -157
  27. package/coverage/lcov-report/src/index.html +0 -206
  28. package/coverage/lcov-report/src/login/AggregateLoginHandler.ts.html +0 -226
  29. package/coverage/lcov-report/src/login/index.html +0 -116
  30. package/coverage/lcov-report/src/login/oidc/AggregateOidcHandler.ts.html +0 -226
  31. package/coverage/lcov-report/src/login/oidc/ClientRegistrar.ts.html +0 -415
  32. package/coverage/lcov-report/src/login/oidc/IssuerConfigFetcher.ts.html +0 -646
  33. package/coverage/lcov-report/src/login/oidc/OidcLoginHandler.ts.html +0 -436
  34. package/coverage/lcov-report/src/login/oidc/Redirector.ts.html +0 -229
  35. package/coverage/lcov-report/src/login/oidc/index.html +0 -176
  36. package/coverage/lcov-report/src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.ts.html +0 -478
  37. package/coverage/lcov-report/src/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.ts.html +0 -319
  38. package/coverage/lcov-report/src/login/oidc/oidcHandlers/index.html +0 -131
  39. package/coverage/lcov-report/src/login/oidc/redirectHandler/AggregateRedirectHandler.ts.html +0 -226
  40. package/coverage/lcov-report/src/login/oidc/redirectHandler/AuthCodeRedirectHandler.ts.html +0 -667
  41. package/coverage/lcov-report/src/login/oidc/redirectHandler/ErrorOidcHandler.ts.html +0 -283
  42. package/coverage/lcov-report/src/login/oidc/redirectHandler/FallbackRedirectHandler.ts.html +0 -265
  43. package/coverage/lcov-report/src/login/oidc/redirectHandler/index.html +0 -161
  44. package/coverage/lcov-report/src/login/oidc/refresh/TokenRefresher.ts.html +0 -385
  45. package/coverage/lcov-report/src/login/oidc/refresh/index.html +0 -116
  46. package/coverage/lcov-report/src/login/webid/WebIdLoginHandler.ts.html +0 -250
  47. package/coverage/lcov-report/src/login/webid/index.html +0 -116
  48. package/coverage/lcov-report/src/logout/GeneralLogoutHandler.ts.html +0 -220
  49. package/coverage/lcov-report/src/logout/index.html +0 -116
  50. package/coverage/lcov-report/src/sessionInfo/SessionInfoManager.ts.html +0 -775
  51. package/coverage/lcov-report/src/sessionInfo/index.html +0 -116
  52. package/coverage/lcov-report/src/storage/BrowserStorage.ts.html +0 -229
  53. package/coverage/lcov-report/src/storage/StorageUtility.ts.html +0 -214
  54. package/coverage/lcov-report/src/storage/index.html +0 -131
  55. package/coverage/lcov-report/src/util/UuidGenerator.ts.html +0 -226
  56. package/coverage/lcov-report/src/util/index.html +0 -131
  57. package/coverage/lcov-report/src/util/urlPath.ts.html +0 -208
  58. package/coverage/lcov.info +0 -1001
  59. package/dist/ClientAuthentication.js +0 -64
  60. package/dist/ClientAuthentication.js.map +0 -1
  61. package/dist/Session.js +0 -165
  62. package/dist/Session.js.map +0 -1
  63. package/dist/constant.js +0 -7
  64. package/dist/constant.js.map +0 -1
  65. package/dist/defaultSession.js +0 -48
  66. package/dist/defaultSession.js.map +0 -1
  67. package/dist/dependencies.js +0 -41
  68. package/dist/dependencies.js.map +0 -1
  69. package/dist/iframe.js +0 -43
  70. package/dist/iframe.js.map +0 -1
  71. package/dist/index.browser.d.ts +0 -1
  72. package/dist/index.browser.js +0 -28
  73. package/dist/index.browser.js.map +0 -1
  74. package/dist/login/AggregateLoginHandler.js +0 -10
  75. package/dist/login/AggregateLoginHandler.js.map +0 -1
  76. package/dist/login/oidc/AggregateOidcHandler.js +0 -10
  77. package/dist/login/oidc/AggregateOidcHandler.js.map +0 -1
  78. package/dist/login/oidc/ClientRegistrar.js +0 -51
  79. package/dist/login/oidc/ClientRegistrar.js.map +0 -1
  80. package/dist/login/oidc/IssuerConfigFetcher.js +0 -124
  81. package/dist/login/oidc/IssuerConfigFetcher.js.map +0 -1
  82. package/dist/login/oidc/OidcLoginHandler.js +0 -40
  83. package/dist/login/oidc/OidcLoginHandler.js.map +0 -1
  84. package/dist/login/oidc/Redirector.js +0 -21
  85. package/dist/login/oidc/Redirector.js.map +0 -1
  86. package/dist/login/oidc/__mocks__/IOidcOptions.d.ts +0 -2
  87. package/dist/login/oidc/__mocks__/IOidcOptions.js +0 -25
  88. package/dist/login/oidc/__mocks__/IOidcOptions.js.map +0 -1
  89. package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.js +0 -56
  90. package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.js.map +0 -1
  91. package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.js +0 -47
  92. package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.js.map +0 -1
  93. package/dist/login/oidc/redirectHandler/AggregateRedirectHandler.js +0 -10
  94. package/dist/login/oidc/redirectHandler/AggregateRedirectHandler.js.map +0 -1
  95. package/dist/login/oidc/redirectHandler/AuthCodeRedirectHandler.js +0 -92
  96. package/dist/login/oidc/redirectHandler/AuthCodeRedirectHandler.js.map +0 -1
  97. package/dist/login/oidc/redirectHandler/ErrorOidcHandler.js +0 -26
  98. package/dist/login/oidc/redirectHandler/ErrorOidcHandler.js.map +0 -1
  99. package/dist/login/oidc/redirectHandler/FallbackRedirectHandler.js +0 -20
  100. package/dist/login/oidc/redirectHandler/FallbackRedirectHandler.js.map +0 -1
  101. package/dist/login/oidc/refresh/TokenRefresher.js +0 -31
  102. package/dist/login/oidc/refresh/TokenRefresher.js.map +0 -1
  103. package/dist/login/webid/WebIdLoginHandler.js +0 -12
  104. package/dist/login/webid/WebIdLoginHandler.js.map +0 -1
  105. package/dist/logout/GeneralLogoutHandler.js +0 -15
  106. package/dist/logout/GeneralLogoutHandler.js.map +0 -1
  107. package/dist/sessionInfo/SessionInfoManager.js +0 -95
  108. package/dist/sessionInfo/SessionInfoManager.js.map +0 -1
  109. package/dist/solid-client-authn.bundle.js.LICENSE.txt +0 -17
  110. package/dist/storage/BrowserStorage.js +0 -18
  111. package/dist/storage/BrowserStorage.js.map +0 -1
  112. package/dist/storage/StorageUtility.js +0 -10
  113. package/dist/storage/StorageUtility.js.map +0 -1
  114. package/dist/util/UuidGenerator.js +0 -10
  115. package/dist/util/UuidGenerator.js.map +0 -1
  116. package/dist/util/urlPath.js +0 -11
  117. package/dist/util/urlPath.js.map +0 -1
  118. package/docs/api/Makefile +0 -76
  119. package/docs/api/README.md +0 -46
  120. package/docs/api/build/docs-assets/README.md +0 -183
  121. package/docs/api/build/docs-assets/_static/css/inrupt.css +0 -349
  122. package/docs/api/build/docs-assets/_templates/breadcrumb-navigation.html +0 -10
  123. package/docs/api/build/docs-assets/_templates/copyright.html +0 -3
  124. package/docs/api/build/docs-assets/_templates/docs-sidebar.html +0 -32
  125. package/docs/api/build/docs-assets/_templates/docs-version-selector.html +0 -21
  126. package/docs/api/build/docs-assets/_templates/jira-feedback.html +0 -21
  127. package/docs/api/build/docs-assets/_templates/layout.html +0 -34
  128. package/docs/api/build/docs-assets/_templates/matomo.html +0 -18
  129. package/docs/api/build/docs-assets/_templates/navbar-logo.html +0 -5
  130. package/docs/api/build/docs-assets/_templates/navbar-nav.html +0 -44
  131. package/docs/api/build/docs-assets/_templates/prev-next.html +0 -19
  132. package/docs/api/build/docs-assets/_templates/versioned-canonical.html +0 -8
  133. package/docs/api/build/docs-assets/themes/inrupt/theme.conf +0 -18
  134. package/docs/api/build/doctrees/classes/ConfigurationError.doctree +0 -0
  135. package/docs/api/build/doctrees/classes/InMemoryStorage.doctree +0 -0
  136. package/docs/api/build/doctrees/classes/NotImplementedError.doctree +0 -0
  137. package/docs/api/build/doctrees/classes/Session.doctree +0 -0
  138. package/docs/api/build/doctrees/environment.pickle +0 -0
  139. package/docs/api/build/doctrees/functions.doctree +0 -0
  140. package/docs/api/build/doctrees/index.doctree +0 -0
  141. package/docs/api/build/doctrees/interfaces/ILoginInputOptions.doctree +0 -0
  142. package/docs/api/build/doctrees/interfaces/ISessionInfo.doctree +0 -0
  143. package/docs/api/build/doctrees/interfaces/ISessionOptions.doctree +0 -0
  144. package/docs/api/build/doctrees/interfaces/IStorage.doctree +0 -0
  145. package/docs/api/build/html/.buildinfo +0 -4
  146. package/docs/api/build/html/_static/basic.css +0 -905
  147. package/docs/api/build/html/_static/css/blank.css +0 -2
  148. package/docs/api/build/html/_static/css/index.ff1ffe594081f20da1ef19478df9384b.css +0 -6
  149. package/docs/api/build/html/_static/css/inrupt.css +0 -349
  150. package/docs/api/build/html/_static/css/theme.css +0 -120
  151. package/docs/api/build/html/_static/doctools.js +0 -323
  152. package/docs/api/build/html/_static/documentation_options.js +0 -12
  153. package/docs/api/build/html/_static/file.png +0 -0
  154. package/docs/api/build/html/_static/jquery-3.5.1.js +0 -10872
  155. package/docs/api/build/html/_static/jquery.js +0 -2
  156. package/docs/api/build/html/_static/js/index.be7d3bbb2ef33a8344ce.js +0 -32
  157. package/docs/api/build/html/_static/language_data.js +0 -297
  158. package/docs/api/build/html/_static/minus.png +0 -0
  159. package/docs/api/build/html/_static/plus.png +0 -0
  160. package/docs/api/build/html/_static/pygments.css +0 -74
  161. package/docs/api/build/html/_static/searchtools.js +0 -529
  162. package/docs/api/build/html/_static/underscore-1.13.1.js +0 -2042
  163. package/docs/api/build/html/_static/underscore.js +0 -6
  164. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/LICENSE.txt +0 -34
  165. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/css/all.min.css +0 -5
  166. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.eot +0 -0
  167. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.svg +0 -3570
  168. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.ttf +0 -0
  169. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff +0 -0
  170. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2 +0 -0
  171. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.eot +0 -0
  172. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.svg +0 -803
  173. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.ttf +0 -0
  174. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.woff +0 -0
  175. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.woff2 +0 -0
  176. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.eot +0 -0
  177. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.svg +0 -4938
  178. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.ttf +0 -0
  179. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff +0 -0
  180. package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2 +0 -0
  181. package/docs/api/build/html/_static/webpack-macros.html +0 -25
  182. package/docs/api/build/html/classes/ConfigurationError.html +0 -726
  183. package/docs/api/build/html/classes/InMemoryStorage.html +0 -636
  184. package/docs/api/build/html/classes/NotImplementedError.html +0 -726
  185. package/docs/api/build/html/classes/Session.html +0 -2428
  186. package/docs/api/build/html/functions.html +0 -834
  187. package/docs/api/build/html/genindex.html +0 -311
  188. package/docs/api/build/html/index.html +0 -342
  189. package/docs/api/build/html/interfaces/ILoginInputOptions.html +0 -595
  190. package/docs/api/build/html/interfaces/ISessionInfo.html +0 -481
  191. package/docs/api/build/html/interfaces/ISessionOptions.html +0 -463
  192. package/docs/api/build/html/interfaces/IStorage.html +0 -531
  193. package/docs/api/build/html/objects.inv +0 -0
  194. package/docs/api/build/html/search.html +0 -340
  195. package/docs/api/build/html/searchindex.js +0 -1
  196. package/docs/api/build/source/classes/ConfigurationError.md +0 -159
  197. package/docs/api/build/source/classes/InMemoryStorage.md +0 -112
  198. package/docs/api/build/source/classes/NotImplementedError.md +0 -159
  199. package/docs/api/build/source/classes/Session.md +0 -907
  200. package/docs/api/build/source/functions.md +0 -235
  201. package/docs/api/build/source/index.rst +0 -13
  202. package/docs/api/build/source/interfaces/ILoginInputOptions.md +0 -109
  203. package/docs/api/build/source/interfaces/ISessionInfo.md +0 -63
  204. package/docs/api/build/source/interfaces/ISessionOptions.md +0 -60
  205. package/docs/api/build/source/interfaces/IStorage.md +0 -76
  206. package/docs/api/conf.py +0 -135
  207. package/docs/api/redirects.txt +0 -41
  208. package/docs/api/requirements.txt +0 -5
  209. package/docs/api/source/api/.nojekyll +0 -1
  210. package/docs/api/source/api/classes/ConfigurationError.md +0 -163
  211. package/docs/api/source/api/classes/InMemoryStorage.md +0 -112
  212. package/docs/api/source/api/classes/NotImplementedError.md +0 -163
  213. package/docs/api/source/api/classes/Session.md +0 -1426
  214. package/docs/api/source/api/index.md +0 -251
  215. package/docs/api/source/api/interfaces/ILoginInputOptions.md +0 -109
  216. package/docs/api/source/api/interfaces/ISessionInfo.md +0 -63
  217. package/docs/api/source/api/interfaces/ISessionOptions.md +0 -60
  218. package/docs/api/source/api/interfaces/IStorage.md +0 -76
  219. package/docs/api/source/functions.md +0 -3
  220. package/docs/api/source/index.rst +0 -13
  221. package/examples/demoAuthentiationMonitor/index.js +0 -34
  222. package/examples/demoAuthentiationMonitor/package-lock.json +0 -916
  223. package/examples/demoAuthentiationMonitor/package.json +0 -15
  224. package/examples/demoClientApp/.babelrc +0 -3
  225. package/examples/demoClientApp/package-lock.json +0 -11710
  226. package/examples/demoClientApp/package.json +0 -37
  227. package/examples/demoClientApp/src/DemoClientApp.js +0 -686
  228. package/examples/demoClientApp/src/index.html +0 -142
  229. package/examples/demoClientApp/src/index.js +0 -26
  230. package/examples/demoClientApp/webpack.config.js +0 -39
  231. package/examples/single/bundle/.babelrc +0 -3
  232. package/examples/single/bundle/README.md +0 -11
  233. package/examples/single/bundle/client-app-profile.ttl +0 -10
  234. package/examples/single/bundle/package-lock.json +0 -11196
  235. package/examples/single/bundle/package.json +0 -31
  236. package/examples/single/bundle/src/App.js +0 -123
  237. package/examples/single/bundle/src/index.html +0 -10
  238. package/examples/single/bundle/src/index.js +0 -26
  239. package/examples/single/bundle/webpack.config.js +0 -33
  240. package/examples/single/script/README.md +0 -11
  241. package/examples/single/script/index.html +0 -36
  242. package/examples/single/script/package-lock.json +0 -1293
  243. package/examples/single/script/package.json +0 -20
  244. package/examples/single/script/server.ts +0 -18
  245. package/jest.config.js +0 -10
  246. package/licenses.csv +0 -147
  247. package/rollup.config.js +0 -54
  248. package/sampleFlows/SolidAuthClientArchitecture.png +0 -0
  249. package/sampleFlows/authorization-code-with-pkce.png +0 -0
  250. package/sampleFlows/authorization-code-with-pkce.seqdiag +0 -46
  251. package/sampleFlows/authorization-code.png +0 -0
  252. package/sampleFlows/authorization-code.seqdiag +0 -50
  253. package/sampleFlows/client-credentials.png +0 -0
  254. package/sampleFlows/client-credentials.seqdiag +0 -38
  255. package/sampleFlows/legacy-implicit-flow.png +0 -0
  256. package/sampleFlows/legacy-implicit-flow.seqdiag +0 -43
  257. package/sampleFlows/self-signed.png +0 -0
  258. package/sampleFlows/self-signed.seqdiag +0 -49
  259. package/sampleFlows/signatory-access-control.seqdiag +0 -36
  260. package/sampleFlows/signatory-access-control.svg +0 -1
  261. package/tsconfig.eslint.json +0 -6
  262. package/tsconfig.json +0 -17
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAqBA,qCAAqD;AAA5C,kGAAA,OAAO,OAAA;AAEhB,+CAAyE;AAAhE,uIAAA,uCAAuC,OAAA;AAEhD,mDAAiC;AAIjC,2EAOyC;AAHvC,8HAAA,mBAAmB,OAAA;AACnB,6HAAA,kBAAkB,OAAA;AAClB,0HAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sources":["../src/storage/StorageUtility.ts","../src/ClientAuthentication.ts","../src/login/oidc/OidcLoginHandler.ts","../src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.ts","../src/util/urlPath.ts","../src/login/oidc/IssuerConfigFetcher.ts","../src/sessionInfo/SessionInfoManager.ts","../src/login/oidc/redirectHandler/FallbackRedirectHandler.ts","../src/logout/GeneralLogoutHandler.ts","../src/login/oidc/redirectHandler/AuthCodeRedirectHandler.ts","../src/login/oidc/redirectHandler/AggregateRedirectHandler.ts","../src/storage/BrowserStorage.ts","../src/iframe.ts","../src/login/oidc/Redirector.ts","../src/login/oidc/ClientRegistrar.ts","../src/login/oidc/redirectHandler/ErrorOidcHandler.ts","../src/login/oidc/refresh/TokenRefresher.ts","../src/dependencies.ts","../src/constant.ts","../src/Session.ts","../src/defaultSession.ts"],"sourcesContent":["/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * A helper class that will validate items taken from local storage\n */\nimport { IStorage, StorageUtility } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * This class in a no-value-added extension of StorageUtility from the core module.\n * The reason it has to be declared is for TSyringe to find the decorators in the\n * same modules as where the dependency container is declared (in this case,\n * the browser module, with the dependancy container in dependencies.ts).\n * @hidden\n */\nexport default class StorageUtilityBrowser extends StorageUtility {\n constructor(secureStorage: IStorage, insecureStorage: IStorage) {\n super(secureStorage, insecureStorage);\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport {\n ILoginHandler,\n ILogoutHandler,\n IRedirectHandler,\n ISessionInfo,\n ISessionInfoManager,\n IIssuerConfigFetcher,\n ISessionInternalInfo,\n ILoginOptions,\n EVENTS,\n} from \"@inrupt/solid-client-authn-core\";\nimport { removeOidcQueryParam } from \"@inrupt/oidc-client-ext\";\nimport { EventEmitter } from \"events\";\n\n// By only referring to `window` at runtime, apps that do server-side rendering\n// won't run into errors when rendering code that instantiates a\n// ClientAuthentication:\nconst globalFetch: typeof window.fetch = (request, init) =>\n window.fetch(request, init);\n\n/**\n * @hidden\n */\nexport default class ClientAuthentication {\n constructor(\n private loginHandler: ILoginHandler,\n private redirectHandler: IRedirectHandler,\n private logoutHandler: ILogoutHandler,\n private sessionInfoManager: ISessionInfoManager,\n private issuerConfigFetcher: IIssuerConfigFetcher\n ) {}\n\n // Define these functions as properties so that they don't get accidentally re-bound.\n // Isn't Javascript fun?\n login = async (\n options: ILoginOptions,\n eventEmitter: EventEmitter\n ): Promise<void> => {\n // In order to get a clean start, make sure that the session is logged out\n // on login.\n // But we may want to preserve our client application info, particularly if\n // we used Dynamic Client Registration to register (since we don't\n // necessarily want the user to have to register this app each time they\n // login).\n await this.sessionInfoManager.clear(options.sessionId);\n\n // In the case of the user hitting the 'back' button in their browser, they\n // could return to a previous redirect URL that contains OIDC params that\n // are now longer valid - so just to be safe, strip relevant params now.\n const redirectUrl = removeOidcQueryParam(\n options.redirectUrl ?? window.location.href\n );\n\n await this.loginHandler.handle({\n ...options,\n redirectUrl,\n // If no clientName is provided, the clientId may be used instead.\n clientName: options.clientName ?? options.clientId,\n eventEmitter,\n });\n };\n\n // By default, our fetch() resolves to the environment fetch() function.\n fetch = globalFetch;\n\n logout = async (sessionId: string): Promise<void> => {\n await this.logoutHandler.handle(sessionId);\n\n // Restore our fetch() function back to the environment fetch(), effectively\n // leaving us with un-authenticated fetches from now on.\n this.fetch = globalFetch;\n };\n\n getSessionInfo = async (\n sessionId: string\n ): Promise<(ISessionInfo & ISessionInternalInfo) | undefined> => {\n // TODO complete\n return this.sessionInfoManager.get(sessionId);\n };\n\n getAllSessionInfo = async (): Promise<ISessionInfo[]> => {\n return this.sessionInfoManager.getAll();\n };\n\n // Collects session information from storage, and returns them. Returns null\n // if the expected information cannot be found.\n // Note that the ID token is not stored, which means the session information\n // cannot be validated at this point.\n validateCurrentSession = async (\n currentSessionId: string\n ): Promise<(ISessionInfo & ISessionInternalInfo) | null> => {\n const sessionInfo = await this.sessionInfoManager.get(currentSessionId);\n if (\n sessionInfo === undefined ||\n sessionInfo.clientAppId === undefined ||\n sessionInfo.issuer === undefined\n ) {\n return null;\n }\n return sessionInfo;\n };\n\n handleIncomingRedirect = async (\n url: string,\n eventEmitter: EventEmitter\n ): Promise<ISessionInfo | undefined> => {\n try {\n const redirectInfo = await this.redirectHandler.handle(url, eventEmitter);\n // The `FallbackRedirectHandler` directly returns the global `fetch` for\n // his value, so we should ensure it's bound to `window` rather than to\n // ClientAuthentication, to avoid the following error:\n // > 'fetch' called on an object that does not implement interface Window.\n this.fetch = redirectInfo.fetch.bind(window);\n\n // Strip the oauth params:\n this.cleanUrlAfterRedirect(url);\n\n return {\n isLoggedIn: redirectInfo.isLoggedIn,\n webId: redirectInfo.webId,\n sessionId: redirectInfo.sessionId,\n expirationDate: redirectInfo.expirationDate,\n };\n } catch (err) {\n // Strip the oauth params:\n this.cleanUrlAfterRedirect(url);\n\n // FIXME: EVENTS.ERROR should be errorCode, errorDescription\n //\n // I'm not sure if \"redirect\" is a good error code, and in theory `err`\n // maybe an Error object and not a string; Maybe we want to just hardcode\n // a description instead?\n eventEmitter.emit(EVENTS.ERROR, \"redirect\", err);\n }\n };\n\n private cleanUrlAfterRedirect(url: string): void {\n const cleanedUpUrl = new URL(url);\n cleanedUpUrl.searchParams.delete(\"state\");\n // For auth code flow\n cleanedUpUrl.searchParams.delete(\"code\");\n // For implicit flow\n cleanedUpUrl.searchParams.delete(\"id_token\");\n cleanedUpUrl.searchParams.delete(\"access_token\");\n // For login error\n cleanedUpUrl.searchParams.delete(\"error\");\n cleanedUpUrl.searchParams.delete(\"error_description\");\n\n // Remove OAuth-specific query params (since the login flow finishes with\n // the browser being redirected back with OAuth2 query params (e.g. for\n // 'code' and 'state'), and so if the user simply refreshes this page our\n // authentication library will be called again with what are now invalid\n // query parameters!).\n window.history.replaceState(null, \"\", cleanedUpUrl.toString());\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Handles Common Oidc login functions (Like fetching the configuration)\n */\n\nimport {\n IClientRegistrar,\n IIssuerConfig,\n IIssuerConfigFetcher,\n ILoginOptions,\n ILoginHandler,\n IOidcHandler,\n IOidcOptions,\n IStorageUtility,\n ConfigurationError,\n LoginResult,\n handleRegistration,\n} from \"@inrupt/solid-client-authn-core\";\n\nfunction hasIssuer(\n options: ILoginOptions\n): options is ILoginOptions & { oidcIssuer: string } {\n return typeof options.oidcIssuer === \"string\";\n}\n\nfunction hasRedirectUrl(\n options: ILoginOptions\n): options is ILoginOptions & { redirectUrl: string } {\n return typeof options.redirectUrl === \"string\";\n}\n\n/**\n * @hidden\n */\nexport default class OidcLoginHandler implements ILoginHandler {\n constructor(\n private storageUtility: IStorageUtility,\n private oidcHandler: IOidcHandler,\n private issuerConfigFetcher: IIssuerConfigFetcher,\n private clientRegistrar: IClientRegistrar\n ) {}\n\n async canHandle(options: ILoginOptions): Promise<boolean> {\n return hasIssuer(options) && hasRedirectUrl(options);\n }\n\n async handle(options: ILoginOptions): Promise<LoginResult> {\n if (!hasIssuer(options)) {\n throw new ConfigurationError(\n `OidcLoginHandler requires an OIDC issuer: missing property 'oidcIssuer' in ${JSON.stringify(\n options\n )}`\n );\n }\n if (!hasRedirectUrl(options)) {\n throw new ConfigurationError(\n `OidcLoginHandler requires a redirect URL: missing property 'redirectUrl' in ${JSON.stringify(\n options\n )}`\n );\n }\n\n // Fetch issuer config.\n const issuerConfig: IIssuerConfig =\n await this.issuerConfigFetcher.fetchConfig(options.oidcIssuer);\n\n const clientRegistration = await handleRegistration(\n options,\n issuerConfig,\n this.storageUtility,\n this.clientRegistrar\n );\n\n // Construct OIDC Options\n const OidcOptions: IOidcOptions = {\n // Note that here, the issuer is not the one from the received options, but\n // from the issuer's config. This enforces the canonical URL is used and stored,\n // which is also the one present in the ID token, so storing a technically\n // valid, but different issuer URL (e.g. using a trailing slash or not) now\n // could prevent from validating the ID token later.\n issuer: issuerConfig.issuer,\n // TODO: differentiate if DPoP should be true\n dpop: options.tokenType.toLowerCase() === \"dpop\",\n ...options,\n issuerConfiguration: issuerConfig,\n client: clientRegistration,\n };\n\n // Call proper OIDC Handler\n return this.oidcHandler.handle(OidcOptions);\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Handler for the Authorization Code with PKCE Flow\n */\nimport {\n IOidcHandler,\n IOidcOptions,\n IRedirector,\n IStorageUtility,\n LoginResult,\n} from \"@inrupt/solid-client-authn-core\";\nimport { OidcClient } from \"@inrupt/oidc-client-ext\";\n\n/**\n * @hidden\n * Authorization code flow spec: https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth\n * PKCE: https://tools.ietf.org/html/rfc7636\n */\nexport default class AuthorizationCodeWithPkceOidcHandler\n implements IOidcHandler\n{\n constructor(\n private storageUtility: IStorageUtility,\n private redirector: IRedirector\n ) {}\n\n async canHandle(oidcLoginOptions: IOidcOptions): Promise<boolean> {\n return !!(\n oidcLoginOptions.issuerConfiguration.grantTypesSupported &&\n oidcLoginOptions.issuerConfiguration.grantTypesSupported.indexOf(\n \"authorization_code\"\n ) > -1\n );\n }\n\n async handle(oidcLoginOptions: IOidcOptions): Promise<LoginResult> {\n /* eslint-disable camelcase */\n const oidcOptions = {\n authority: oidcLoginOptions.issuer.toString(),\n client_id: oidcLoginOptions.client.clientId,\n client_secret: oidcLoginOptions.client.clientSecret,\n redirect_uri: oidcLoginOptions.redirectUrl.toString(),\n post_logout_redirect_uri: oidcLoginOptions.redirectUrl.toString(),\n response_type: \"code\",\n // The offline_access scope requests that a refresh token be returned.\n // The webid scope is required as per https://solid.github.io/solid-oidc/#webid-scope\n scope: \"openid offline_access webid\",\n filterProtocolClaims: true,\n // The userinfo endpoint on NSS fails, so disable this for now\n // Note that in Solid, information should be retrieved from the\n // profile referenced by the WebId.\n loadUserInfo: false,\n code_verifier: true,\n prompt: oidcLoginOptions.prompt ?? \"consent\",\n };\n /* eslint-enable camelcase */\n\n const oidcClientLibrary = new OidcClient(oidcOptions);\n\n const { redirector } = this;\n const storage = this.storageUtility;\n\n try {\n const signingRequest = await oidcClientLibrary.createSigninRequest();\n await Promise.all([\n // We use the OAuth 'state' value (which should be crypto-random) as\n // the key in our storage to store our actual SessionID. We do this\n // 'cos we'll need to lookup our session information again when the\n // browser is redirected back to us (i.e. the OAuth client\n // application) from the Authorization Server.\n // We don't want to use our session ID as the OAuth 'state' value, as\n // that session ID can be any developer-specified value, and therefore\n // may not be appropriate (since the OAuth 'state' value should really\n // be an unguessable crypto-random value).\n // eslint-disable-next-line no-underscore-dangle\n storage.setForUser(signingRequest.state._id, {\n sessionId: oidcLoginOptions.sessionId,\n }),\n\n // Store our login-process state using the session ID as the key.\n // Strictly speaking, this indirection from our OAuth state value to\n // our session ID is unnecessary, but it provides a slightly cleaner\n // separation of concerns.\n storage.setForUser(oidcLoginOptions.sessionId, {\n // eslint-disable-next-line no-underscore-dangle\n codeVerifier: signingRequest.state._code_verifier,\n issuer: oidcLoginOptions.issuer.toString(),\n // The redirect URL is read after redirect, so it must be stored now.\n redirectUrl: oidcLoginOptions.redirectUrl,\n dpop: oidcLoginOptions.dpop ? \"true\" : \"false\",\n }),\n ]);\n\n redirector.redirect(signingRequest.url.toString(), {\n handleRedirect: oidcLoginOptions.handleRedirect,\n redirectInIframe: oidcLoginOptions.inIframe,\n });\n } catch (err: unknown) {\n // eslint-disable-next-line no-console\n console.error(err);\n }\n\n // The login is only completed AFTER redirect, so nothing to return here.\n return undefined;\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Utility that appends the specified value to end of the specified URL's path.\n *\n * @param url the URL to whose path we append the specified value\n * @param append the value to append to the URL's path\n */\nexport function appendToUrlPathname(url: string, append: string): string {\n const parsedUrl = new URL(url);\n const path = parsedUrl.pathname;\n parsedUrl.pathname = `${path}${path.endsWith(\"/\") ? \"\" : \"/\"}${\n append.startsWith(\"/\") ? append.substring(1) : append\n }`;\n\n return parsedUrl.toString();\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Responsible for fetching an IDP configuration\n */\nimport {\n IIssuerConfig,\n IIssuerConfigFetcher,\n IStorageUtility,\n ConfigurationError,\n} from \"@inrupt/solid-client-authn-core\";\nimport { appendToUrlPathname } from \"../../util/urlPath\";\n\nexport const WELL_KNOWN_OPENID_CONFIG = \".well-known/openid-configuration\";\n\n/* eslint-disable camelcase */\nconst issuerConfigKeyMap: Record<\n string,\n { toKey: string; convertToUrl?: boolean }\n> = {\n issuer: {\n toKey: \"issuer\",\n convertToUrl: true,\n },\n authorization_endpoint: {\n toKey: \"authorizationEndpoint\",\n convertToUrl: true,\n },\n token_endpoint: {\n toKey: \"tokenEndpoint\",\n convertToUrl: true,\n },\n userinfo_endpoint: {\n toKey: \"userinfoEndpoint\",\n convertToUrl: true,\n },\n jwks_uri: {\n toKey: \"jwksUri\",\n convertToUrl: true,\n },\n registration_endpoint: {\n toKey: \"registrationEndpoint\",\n convertToUrl: true,\n },\n scopes_supported: { toKey: \"scopesSupported\" },\n response_types_supported: { toKey: \"responseTypesSupported\" },\n response_modes_supported: { toKey: \"responseModesSupported\" },\n grant_types_supported: { toKey: \"grantTypesSupported\" },\n acr_values_supported: { toKey: \"acrValuesSupported\" },\n subject_types_supported: { toKey: \"subjectTypesSupported\" },\n id_token_signing_alg_values_supported: {\n toKey: \"idTokenSigningAlgValuesSupported\",\n },\n id_token_encryption_alg_values_supported: {\n toKey: \"idTokenEncryptionAlgValuesSupported\",\n },\n id_token_encryption_enc_values_supported: {\n toKey: \"idTokenEncryptionEncValuesSupported\",\n },\n userinfo_signing_alg_values_supported: {\n toKey: \"userinfoSigningAlgValuesSupported\",\n },\n userinfo_encryption_alg_values_supported: {\n toKey: \"userinfoEncryptionAlgValuesSupported\",\n },\n userinfo_encryption_enc_values_supported: {\n toKey: \"userinfoEncryptionEncValuesSupported\",\n },\n request_object_signing_alg_values_supported: {\n toKey: \"requestObjectSigningAlgValuesSupported\",\n },\n request_object_encryption_alg_values_supported: {\n toKey: \"requestObjectEncryptionAlgValuesSupported\",\n },\n request_object_encryption_enc_values_supported: {\n toKey: \"requestObjectEncryptionEncValuesSupported\",\n },\n token_endpoint_auth_methods_supported: {\n toKey: \"tokenEndpointAuthMethodsSupported\",\n },\n token_endpoint_auth_signing_alg_values_supported: {\n toKey: \"tokenEndpointAuthSigningAlgValuesSupported\",\n },\n display_values_supported: { toKey: \"displayValuesSupported\" },\n claim_types_supported: { toKey: \"claimTypesSupported\" },\n claims_supported: { toKey: \"claimsSupported\" },\n service_documentation: { toKey: \"serviceDocumentation\" },\n claims_locales_supported: { toKey: \"claimsLocalesSupported\" },\n ui_locales_supported: { toKey: \"uiLocalesSupported\" },\n claims_parameter_supported: { toKey: \"claimsParameterSupported\" },\n request_parameter_supported: { toKey: \"requestParameterSupported\" },\n request_uri_parameter_supported: { toKey: \"requestUriParameterSupported\" },\n require_request_uri_registration: { toKey: \"requireRequestUriRegistration\" },\n op_policy_uri: {\n toKey: \"opPolicyUri\",\n convertToUrl: true,\n },\n op_tos_uri: {\n toKey: \"opTosUri\",\n convertToUrl: true,\n },\n};\n/* eslint-enable camelcase */\n\nfunction processConfig(\n config: Record<string, string | string[]>\n): IIssuerConfig {\n const parsedConfig: Record<string, string | string[]> = {};\n Object.keys(config).forEach((key) => {\n if (issuerConfigKeyMap[key]) {\n // TODO: PMcB55: Validate URL if \"issuerConfigKeyMap[key].convertToUrl\"\n // if (issuerConfigKeyMap[key].convertToUrl) {\n // validateUrl(config[key]);\n // }\n parsedConfig[issuerConfigKeyMap[key].toKey] = config[key];\n }\n });\n if (!Array.isArray(parsedConfig.scopesSupported)) {\n parsedConfig.scopesSupported = [\"openid\"];\n }\n return parsedConfig as unknown as IIssuerConfig;\n}\n\n/**\n * @hidden\n */\nexport default class IssuerConfigFetcher implements IIssuerConfigFetcher {\n constructor(private storageUtility: IStorageUtility) {}\n\n // This method needs no state (so can be static), and can be exposed to allow\n // callers to know where this implementation puts state it needs.\n public static getLocalStorageKey(issuer: string): string {\n return `issuerConfig:${issuer}`;\n }\n\n async fetchConfig(issuer: string): Promise<IIssuerConfig> {\n let issuerConfig: IIssuerConfig;\n\n const openIdConfigUrl = appendToUrlPathname(\n issuer,\n WELL_KNOWN_OPENID_CONFIG\n );\n const issuerConfigRequestBody = await window.fetch(openIdConfigUrl);\n // Check the validity of the fetched config\n try {\n issuerConfig = processConfig(await issuerConfigRequestBody.json());\n } catch (err) {\n throw new ConfigurationError(\n `[${issuer.toString()}] has an invalid configuration: ${\n (err as { message: string }).message\n }`\n );\n }\n\n // Update store with fetched config\n await this.storageUtility.set(\n IssuerConfigFetcher.getLocalStorageKey(issuer),\n JSON.stringify(issuerConfig)\n );\n\n return issuerConfig;\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport {\n ISessionInfo,\n ISessionInfoManager,\n ISessionInternalInfo,\n ISessionInfoManagerOptions,\n IStorageUtility,\n isSupportedTokenType,\n} from \"@inrupt/solid-client-authn-core\";\nimport { v4 } from \"uuid\";\nimport { clearOidcPersistentStorage } from \"@inrupt/oidc-client-ext\";\n\nexport function getUnauthenticatedSession(): ISessionInfo & {\n fetch: typeof fetch;\n} {\n return {\n isLoggedIn: false,\n sessionId: v4(),\n fetch,\n };\n}\n\n/**\n * @param sessionId\n * @param storage\n * @hidden\n */\nexport async function clear(\n sessionId: string,\n storage: IStorageUtility\n): Promise<void> {\n await Promise.all([\n storage.deleteAllUserData(sessionId, { secure: false }),\n storage.deleteAllUserData(sessionId, { secure: true }),\n // FIXME: This is needed until the DPoP key is stored safely\n storage.delete(\"clientKey\", { secure: false }),\n ]);\n await clearOidcPersistentStorage();\n}\n\n/**\n * @hidden\n */\nexport class SessionInfoManager implements ISessionInfoManager {\n constructor(private storageUtility: IStorageUtility) {}\n\n // eslint-disable-next-line class-methods-use-this\n update(\n _sessionId: string,\n _options: ISessionInfoManagerOptions\n ): Promise<void> {\n // const localUserId: string = options.localUserId || this.uuidGenerator.v4();\n // if (options.loggedIn) {\n // return {\n // sessionId,\n // loggedIn: true,\n // webId: options.webId as string,\n // neededAction: options.neededAction || { actionType: \"inaction\" },\n // state: options.state,\n // logout: async (): Promise<void> => {\n // // TODO: handle if webid isn't here\n // return this.logoutHandler.handle(localUserId);\n // },\n // fetch: (url: RequestInfo, init?: RequestInit): Promise<Response> => {\n // // TODO: handle if webid isn't here\n // return this.authenticatedFetcher.handle(\n // {\n // localUserId,\n // type: \"dpop\"\n // },\n // url,\n // init\n // );\n // }\n // };\n // } else {\n // return {\n // localUserId,\n // loggedIn: false,\n // neededAction: options.neededAction || { actionType: \"inaction\" }\n // };\n // }\n throw new Error(\"Not Implemented\");\n }\n\n async get(\n sessionId: string\n ): Promise<(ISessionInfo & ISessionInternalInfo) | undefined> {\n const isLoggedIn = await this.storageUtility.getForUser(\n sessionId,\n \"isLoggedIn\",\n {\n secure: true,\n }\n );\n\n const webId = await this.storageUtility.getForUser(sessionId, \"webId\", {\n secure: true,\n });\n\n const clientId = await this.storageUtility.getForUser(\n sessionId,\n \"clientId\",\n {\n secure: false,\n }\n );\n\n const clientSecret = await this.storageUtility.getForUser(\n sessionId,\n \"clientSecret\",\n {\n secure: false,\n }\n );\n\n const redirectUrl = await this.storageUtility.getForUser(\n sessionId,\n \"redirectUrl\",\n {\n secure: false,\n }\n );\n\n const refreshToken = await this.storageUtility.getForUser(\n sessionId,\n \"refreshToken\",\n {\n secure: true,\n }\n );\n\n const issuer = await this.storageUtility.getForUser(sessionId, \"issuer\", {\n secure: false,\n });\n\n const tokenType =\n (await this.storageUtility.getForUser(sessionId, \"tokenType\", {\n secure: false,\n })) ?? \"DPoP\";\n\n if (!isSupportedTokenType(tokenType)) {\n throw new Error(`Tokens of type [${tokenType}] are not supported.`);\n }\n\n if (\n clientId === undefined &&\n isLoggedIn === undefined &&\n webId === undefined &&\n refreshToken === undefined\n ) {\n return undefined;\n }\n\n return {\n sessionId,\n webId,\n isLoggedIn: isLoggedIn === \"true\",\n redirectUrl,\n refreshToken,\n issuer,\n clientAppId: clientId,\n clientAppSecret: clientSecret,\n tokenType,\n };\n }\n\n // eslint-disable-next-line class-methods-use-this\n async getAll(): Promise<(ISessionInfo & ISessionInternalInfo)[]> {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * This function removes all session-related information from storage.\n * @param sessionId the session identifier\n * @param storage the storage where session info is stored\n * @hidden\n */\n async clear(sessionId: string): Promise<void> {\n return clear(sessionId, this.storageUtility);\n }\n\n /**\n * Registers a new session, so that its ID can be retrieved.\n * @param sessionId\n */\n async register(_sessionId: string): Promise<void> {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Returns all the registered session IDs. Differs from getAll, which also\n * returns additional session information.\n */\n async getRegisteredSessionIdAll(): Promise<string[]> {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Deletes all information about all sessions, including their registrations.\n */\n async clearAll(): Promise<void> {\n throw new Error(\"Not implemented\");\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport {\n IRedirectHandler,\n ISessionInfo,\n} from \"@inrupt/solid-client-authn-core\";\n\nimport { getUnauthenticatedSession } from \"../../../sessionInfo/SessionInfoManager\";\n\n/**\n * This class handles redirect IRIs without any query params, and returns an unauthenticated\n * session. It serves as a fallback so that consuming libraries don't have to test\n * for the query params themselves, and can always try to use them as a redirect IRI.\n * @hidden\n */\nexport class FallbackRedirectHandler implements IRedirectHandler {\n async canHandle(redirectUrl: string): Promise<boolean> {\n try {\n // The next URL object is built for validating it.\n // eslint-disable-next-line no-new\n new URL(redirectUrl);\n return true;\n } catch (e) {\n throw new Error(\n `[${redirectUrl}] is not a valid URL, and cannot be used as a redirect URL: ${e}`\n );\n }\n }\n\n async handle(\n // The argument is ignored, but must be present to implement the interface\n _redirectUrl: string\n ): Promise<ISessionInfo & { fetch: typeof fetch }> {\n return getUnauthenticatedSession();\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport {\n ILogoutHandler,\n ISessionInfoManager,\n} from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @hidden\n */\nexport default class GeneralLogoutHandler implements ILogoutHandler {\n constructor(private sessionInfoManager: ISessionInfoManager) {}\n\n async canHandle(): Promise<boolean> {\n return true;\n }\n\n async handle(userId: string): Promise<void> {\n await this.sessionInfoManager.clear(userId);\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport {\n buildAuthenticatedFetch,\n IClient,\n IClientRegistrar,\n IIssuerConfigFetcher,\n IRedirectHandler,\n ISessionInfo,\n ISessionInfoManager,\n IStorageUtility,\n ITokenRefresher,\n loadOidcContextFromStorage,\n RefreshOptions,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n getDpopToken,\n getBearerToken,\n CodeExchangeResult,\n} from \"@inrupt/oidc-client-ext\";\nimport { EventEmitter } from \"events\";\n\n/**\n * @hidden\n */\nexport class AuthCodeRedirectHandler implements IRedirectHandler {\n constructor(\n private storageUtility: IStorageUtility,\n private sessionInfoManager: ISessionInfoManager,\n private issuerConfigFetcher: IIssuerConfigFetcher,\n private clientRegistrar: IClientRegistrar,\n private tokerRefresher: ITokenRefresher\n ) {}\n\n async canHandle(redirectUrl: string): Promise<boolean> {\n try {\n const myUrl = new URL(redirectUrl);\n return (\n myUrl.searchParams.get(\"code\") !== null &&\n myUrl.searchParams.get(\"state\") !== null\n );\n } catch (e) {\n throw new Error(\n `[${redirectUrl}] is not a valid URL, and cannot be used as a redirect URL: ${e}`\n );\n }\n }\n\n async handle(\n redirectUrl: string,\n eventEmitter?: EventEmitter\n ): Promise<ISessionInfo & { fetch: typeof fetch }> {\n if (!(await this.canHandle(redirectUrl))) {\n throw new Error(\n `AuthCodeRedirectHandler cannot handle [${redirectUrl}]: it is missing one of [code, state].`\n );\n }\n\n const url = new URL(redirectUrl);\n const oauthState = url.searchParams.get(\"state\") as string;\n\n const storedSessionId = (await this.storageUtility.getForUser(\n oauthState,\n \"sessionId\",\n {\n errorIfNull: true,\n }\n )) as string;\n\n const {\n issuerConfig,\n codeVerifier,\n redirectUrl: storedRedirectIri,\n dpop: isDpop,\n } = await loadOidcContextFromStorage(\n storedSessionId,\n this.storageUtility,\n this.issuerConfigFetcher\n );\n\n if (codeVerifier === undefined) {\n throw new Error(\n `The code verifier for session ${storedSessionId} is missing from storage.`\n );\n }\n\n if (storedRedirectIri === undefined) {\n throw new Error(\n `The redirect URL for session ${storedSessionId} is missing from storage.`\n );\n }\n\n const client: IClient = await this.clientRegistrar.getClient(\n { sessionId: storedSessionId },\n issuerConfig\n );\n\n let tokens: CodeExchangeResult;\n const tokenCreatedAt = Date.now();\n\n if (isDpop) {\n tokens = await getDpopToken(issuerConfig, client, {\n grantType: \"authorization_code\",\n // We rely on our 'canHandle' function checking that the OAuth 'code'\n // parameter is present in our query string.\n code: url.searchParams.get(\"code\") as string,\n codeVerifier,\n redirectUrl: storedRedirectIri,\n });\n\n // Delete oidc-client-specific session information from storage. This is\n // done automatically when retrieving a bearer token, but since the DPoP\n // binding uses our custom code, this needs to be done manually.\n window.localStorage.removeItem(`oidc.${oauthState}`);\n } else {\n tokens = await getBearerToken(url.toString());\n }\n\n let refreshOptions: RefreshOptions | undefined;\n if (tokens.refreshToken !== undefined) {\n refreshOptions = {\n sessionId: storedSessionId,\n refreshToken: tokens.refreshToken,\n tokenRefresher: this.tokerRefresher,\n };\n }\n\n const authFetch = await buildAuthenticatedFetch(fetch, tokens.accessToken, {\n dpopKey: tokens.dpopKey,\n refreshOptions,\n eventEmitter,\n expiresIn: tokens.expiresIn,\n });\n\n await this.storageUtility.setForUser(\n storedSessionId,\n {\n webId: tokens.webId,\n isLoggedIn: \"true\",\n },\n { secure: true }\n );\n // Clear the code query param from the redirect URL before storing it, but\n // preserve any state that my have been provided by the client and returned\n // by the IdP.\n url.searchParams.delete(\"code\");\n await this.storageUtility.setForUser(\n storedSessionId,\n {\n redirectUrl: url.toString(),\n },\n {\n secure: false,\n }\n );\n\n const sessionInfo = await this.sessionInfoManager.get(storedSessionId);\n if (!sessionInfo) {\n throw new Error(`Could not retrieve session: [${storedSessionId}].`);\n }\n\n return Object.assign(sessionInfo, {\n fetch: authFetch,\n expirationDate:\n typeof tokens.expiresIn === \"number\"\n ? tokenCreatedAt + tokens.expiresIn * 1000\n : null,\n });\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Responsible for selecting the correct OidcHandler to handle the provided OIDC Options\n */\nimport {\n IRedirectHandler,\n AggregateHandler,\n RedirectInput,\n RedirectResult,\n} from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @hidden\n */\nexport default class AggregateRedirectHandler\n extends AggregateHandler<RedirectInput, RedirectResult>\n implements IRedirectHandler\n{\n constructor(redirectHandlers: IRedirectHandler[]) {\n super(redirectHandlers);\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport { IStorage } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @hidden\n */\nexport default class BrowserStorage implements IStorage {\n get storage(): typeof window.localStorage {\n return window.localStorage;\n }\n\n async get(key: string): Promise<string | undefined> {\n return this.storage.getItem(key) || undefined;\n }\n\n async set(key: string, value: string): Promise<void> {\n this.storage.setItem(key, value);\n }\n\n async delete(key: string): Promise<void> {\n this.storage.removeItem(key);\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n// This is an internal variable used to share some state between `redirectInIframe`,\n// which initializes it, and `setupIframeListener`, which reads from it. It avoids\n// creating a DOM element with identifying attributes such as an ID which may clash\n// with some other element set up by the library user.\nlet redirectIframe: HTMLIFrameElement;\n\n// The iframe is dynamically created rather than on import,\n// to avoid accessing `window` when an app is doing server-side rendering:\nfunction getRedirectIframe(): HTMLIFrameElement {\n if (typeof redirectIframe === \"undefined\") {\n redirectIframe = window.document.createElement(\"iframe\");\n redirectIframe.setAttribute(\"hidden\", \"true\");\n redirectIframe.setAttribute(\"sandbox\", \"allow-scripts allow-same-origin\");\n }\n return redirectIframe;\n}\n\n/**\n * Redirects the browser to a provided IRI, but does such redirection in a child\n * iframe. This is used to have a front-channel interaction with the Solid Identity\n * Provider without having the user involved, and without refreshing the main window.\n *\n * @param redirectUrl The IRI to which the iframe should be redirected.\n */\nexport function redirectInIframe(redirectUrl: string): void {\n const iframe = getRedirectIframe();\n window.document.body.appendChild(iframe);\n iframe.src = redirectUrl;\n}\n\n/**\n * This function sets up an event listener that will receive iframe messages.\n * It is only listening to messages coming from iframes that could have been\n * opened by the library, and expects to be posted the IRI the iframe has been\n * redirected to by the Solid Identity Provider. This way, the top window can\n * perform the backchannel exchange to the token endpoint without performing\n * the front-channel redirection.\n *\n * @param handleIframeRedirect Redirect URL sent by the iframe\n */\nexport function setupIframeListener(\n handleIframeRedirect: (redirectUrl: string) => Promise<unknown>\n): void {\n // If an app is doing server-side rendering, setting up an iframe listener\n // is pointless (since there is no iframe, and there will be no expiring\n // session to renew) and might even throw a `window` not defined error, so\n // skip this in that case:\n /* istanbul ignore if (window is always defined in tests) */\n if (typeof window === \"undefined\") {\n return;\n }\n window.addEventListener(\"message\", async (evt: MessageEvent) => {\n const iframe = getRedirectIframe();\n if (\n evt.origin === window.location.origin &&\n evt.source === iframe.contentWindow\n ) {\n if (typeof evt.data.redirectUrl === \"string\") {\n // The top-level window handles the redirect that happened in the iframe.\n await handleIframeRedirect(evt.data.redirectUrl);\n }\n }\n // Clean up the iframe from the DOM\n if (window.document.body.contains(iframe)) {\n window.document.body.removeChild(iframe);\n }\n });\n}\n\n/**\n * This function bubbles up the result of the front-channel interaction with\n * the authorization endpoint to the parent window.\n */\nexport function postRedirectUrlToParent(redirectUrl: string): void {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n window.top!.postMessage(\n {\n redirectUrl,\n },\n window.location.origin\n );\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport {\n IRedirector,\n IRedirectorOptions,\n} from \"@inrupt/solid-client-authn-core\";\nimport { redirectInIframe } from \"../../iframe\";\n\n/**\n * @hidden\n */\nexport default class Redirector implements IRedirector {\n redirect(redirectUrl: string, options?: IRedirectorOptions): void {\n if (options && options.handleRedirect) {\n options.handleRedirect(redirectUrl);\n } else if (options && options.redirectByReplacingState) {\n window.history.replaceState({}, \"\", redirectUrl);\n } else if (options?.redirectInIframe) {\n redirectInIframe(redirectUrl);\n } else {\n window.location.href = redirectUrl;\n }\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport {\n IStorageUtility,\n IClientRegistrar,\n IIssuerConfig,\n IClient,\n IClientRegistrarOptions,\n} from \"@inrupt/solid-client-authn-core\";\nimport { registerClient } from \"@inrupt/oidc-client-ext\";\n\n/**\n * @hidden\n */\nexport default class ClientRegistrar implements IClientRegistrar {\n constructor(private storageUtility: IStorageUtility) {}\n\n async getClient(\n options: IClientRegistrarOptions,\n issuerConfig: IIssuerConfig\n ): Promise<IClient> {\n // If client secret and/or client id are stored in storage, use those.\n const [\n storedClientId,\n storedClientSecret,\n // storedClientName,\n ] = await Promise.all([\n this.storageUtility.getForUser(options.sessionId, \"clientId\", {\n secure: false,\n }),\n this.storageUtility.getForUser(options.sessionId, \"clientSecret\", {\n secure: false,\n }),\n // this.storageUtility.getForUser(options.sessionId, \"clientName\", {\n // // FIXME: figure out how to persist secure storage at reload\n // secure: false,\n // }),\n ]);\n if (storedClientId) {\n return {\n clientId: storedClientId,\n clientSecret: storedClientSecret,\n clientType: \"dynamic\",\n };\n }\n const extendedOptions = { ...options };\n // If registration access token is stored, use that.\n extendedOptions.registrationAccessToken =\n extendedOptions.registrationAccessToken ??\n (await this.storageUtility.getForUser(\n options.sessionId,\n \"registrationAccessToken\"\n ));\n\n try {\n const registeredClient = await registerClient(\n extendedOptions,\n issuerConfig\n );\n // Save info\n const infoToSave: Record<string, string> = {\n clientId: registeredClient.clientId,\n };\n if (registeredClient.clientSecret) {\n infoToSave.clientSecret = registeredClient.clientSecret;\n }\n if (registeredClient.idTokenSignedResponseAlg) {\n infoToSave.idTokenSignedResponseAlg =\n registeredClient.idTokenSignedResponseAlg;\n }\n await this.storageUtility.setForUser(\n extendedOptions.sessionId,\n infoToSave,\n {\n // FIXME: figure out how to persist secure storage at reload\n // Otherwise, the client info cannot be retrieved from storage, and\n // the lib tries to re-register the client on each fetch\n secure: false,\n }\n );\n return registeredClient;\n } catch (error) {\n throw new Error(`Client registration failed: [${error}]`);\n }\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport {\n EVENTS,\n IRedirectHandler,\n ISessionInfo,\n} from \"@inrupt/solid-client-authn-core\";\nimport type { EventEmitter } from \"events\";\n\nimport { getUnauthenticatedSession } from \"../../../sessionInfo/SessionInfoManager\";\n\n/**\n * This class handles redirect IRIs without any query params, and returns an unauthenticated\n * session. It serves as a fallback so that consuming libraries don't have to test\n * for the query params themselves, and can always try to use them as a redirect IRI.\n * @hidden\n */\nexport class ErrorOidcHandler implements IRedirectHandler {\n async canHandle(redirectUrl: string): Promise<boolean> {\n try {\n // eslint-disable-next-line no-new\n return new URL(redirectUrl).searchParams.has(\"error\");\n } catch (e) {\n throw new Error(\n `[${redirectUrl}] is not a valid URL, and cannot be used as a redirect URL: ${e}`\n );\n }\n }\n\n async handle(\n redirectUrl: string,\n eventEmitter?: EventEmitter\n ): Promise<ISessionInfo & { fetch: typeof fetch }> {\n if (eventEmitter !== undefined) {\n const url = new URL(redirectUrl);\n const errorUrl = url.searchParams.get(\"error\");\n const errorDescriptionUrl = url.searchParams.get(\"error_description\");\n eventEmitter.emit(EVENTS.ERROR, errorUrl, errorDescriptionUrl);\n }\n return getUnauthenticatedSession();\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport {\n IClient,\n IClientRegistrar,\n IIssuerConfigFetcher,\n IStorageUtility,\n loadOidcContextFromStorage,\n KeyPair,\n ITokenRefresher,\n TokenEndpointResponse,\n EVENTS,\n} from \"@inrupt/solid-client-authn-core\";\nimport { refresh } from \"@inrupt/oidc-client-ext\";\nimport { EventEmitter } from \"events\";\n\n// Some identifiers are not in camelcase on purpose, as they are named using the\n// official names from the OIDC/OAuth2 specifications.\n/* eslint-disable camelcase */\n\n/**\n * @hidden\n */\nexport default class TokenRefresher implements ITokenRefresher {\n constructor(\n private storageUtility: IStorageUtility,\n private issuerConfigFetcher: IIssuerConfigFetcher,\n private clientRegistrar: IClientRegistrar\n ) {}\n\n async refresh(\n sessionId: string,\n refreshToken?: string,\n dpopKey?: KeyPair,\n eventEmitter?: EventEmitter\n ): Promise<TokenEndpointResponse> {\n const oidcContext = await loadOidcContextFromStorage(\n sessionId,\n this.storageUtility,\n this.issuerConfigFetcher\n );\n // This should also retrieve the client from storage\n const clientInfo: IClient = await this.clientRegistrar.getClient(\n { sessionId },\n oidcContext.issuerConfig\n );\n\n if (refreshToken === undefined) {\n // TODO: in a next PR, look up storage for a refresh token\n throw new Error(\n `Session [${sessionId}] has no refresh token to allow it to refresh its access token.`\n );\n }\n\n if (oidcContext.dpop && dpopKey === undefined) {\n throw new Error(\n `For session [${sessionId}], the key bound to the DPoP access token must be provided to refresh said access token.`\n );\n }\n\n const tokenSet = await refresh(\n refreshToken,\n oidcContext.issuerConfig,\n clientInfo,\n dpopKey\n );\n\n if (tokenSet.refreshToken !== undefined) {\n eventEmitter?.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);\n await this.storageUtility.setForUser(sessionId, {\n refreshToken: tokenSet.refreshToken,\n });\n }\n return tokenSet;\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Top Level core document. Responsible for setting up the dependency graph\n */\nimport { IStorage, InMemoryStorage } from \"@inrupt/solid-client-authn-core\";\nimport StorageUtilityBrowser from \"./storage/StorageUtility\";\nimport ClientAuthentication from \"./ClientAuthentication\";\nimport OidcLoginHandler from \"./login/oidc/OidcLoginHandler\";\nimport AuthorizationCodeWithPkceOidcHandler from \"./login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler\";\nimport IssuerConfigFetcher from \"./login/oidc/IssuerConfigFetcher\";\nimport { FallbackRedirectHandler } from \"./login/oidc/redirectHandler/FallbackRedirectHandler\";\nimport GeneralLogoutHandler from \"./logout/GeneralLogoutHandler\";\nimport { SessionInfoManager } from \"./sessionInfo/SessionInfoManager\";\nimport { AuthCodeRedirectHandler } from \"./login/oidc/redirectHandler/AuthCodeRedirectHandler\";\nimport AggregateRedirectHandler from \"./login/oidc/redirectHandler/AggregateRedirectHandler\";\nimport BrowserStorage from \"./storage/BrowserStorage\";\nimport Redirector from \"./login/oidc/Redirector\";\nimport ClientRegistrar from \"./login/oidc/ClientRegistrar\";\nimport { ErrorOidcHandler } from \"./login/oidc/redirectHandler/ErrorOidcHandler\";\nimport TokenRefresher from \"./login/oidc/refresh/TokenRefresher\";\n\n/**\n *\n * @param dependencies\n * @deprecated This function will be removed from the external API in an upcoming release.\n */\nexport function getClientAuthenticationWithDependencies(dependencies: {\n secureStorage?: IStorage;\n insecureStorage?: IStorage;\n}): ClientAuthentication {\n const inMemoryStorage = new InMemoryStorage();\n const secureStorage = dependencies.secureStorage || inMemoryStorage;\n const insecureStorage = dependencies.insecureStorage || new BrowserStorage();\n\n const storageUtility = new StorageUtilityBrowser(\n secureStorage,\n insecureStorage\n );\n\n const issuerConfigFetcher = new IssuerConfigFetcher(storageUtility);\n const clientRegistrar = new ClientRegistrar(storageUtility);\n\n const sessionInfoManager = new SessionInfoManager(storageUtility);\n\n const tokenRefresher = new TokenRefresher(\n storageUtility,\n issuerConfigFetcher,\n clientRegistrar\n );\n\n // make new handler for redirect and login\n const loginHandler = new OidcLoginHandler(\n storageUtility,\n new AuthorizationCodeWithPkceOidcHandler(storageUtility, new Redirector()),\n issuerConfigFetcher,\n clientRegistrar\n );\n\n const redirectHandler = new AggregateRedirectHandler([\n new ErrorOidcHandler(),\n new AuthCodeRedirectHandler(\n storageUtility,\n sessionInfoManager,\n issuerConfigFetcher,\n clientRegistrar,\n tokenRefresher\n ),\n // This catch-all class will always be able to handle the\n // redirect IRI, so it must be registered last.\n new FallbackRedirectHandler(),\n ]);\n\n return new ClientAuthentication(\n loginHandler,\n redirectHandler,\n new GeneralLogoutHandler(sessionInfoManager),\n sessionInfoManager,\n issuerConfigFetcher\n );\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport { SOLID_CLIENT_AUTHN_KEY_PREFIX } from \"@inrupt/solid-client-authn-core\";\n\nexport const KEY_CURRENT_SESSION = `${SOLID_CLIENT_AUTHN_KEY_PREFIX}currentSession`;\n\nexport const KEY_CURRENT_URL = `${SOLID_CLIENT_AUTHN_KEY_PREFIX}currentUrl`;\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * @hidden\n */\nimport { EventEmitter } from \"events\";\nimport {\n EVENTS,\n ILoginInputOptions,\n ISessionInfo,\n IStorage,\n} from \"@inrupt/solid-client-authn-core\";\nimport { v4 } from \"uuid\";\nimport ClientAuthentication from \"./ClientAuthentication\";\nimport { getClientAuthenticationWithDependencies } from \"./dependencies\";\nimport { KEY_CURRENT_SESSION, KEY_CURRENT_URL } from \"./constant\";\nimport { postRedirectUrlToParent, setupIframeListener } from \"./iframe\";\n\nexport interface ISessionOptions {\n /**\n * A private storage, unreachable to other scripts on the page. Typically in-memory.\n */\n secureStorage: IStorage;\n /**\n * A storage where non-sensitive information may be stored, potentially longer-lived than the secure storage.\n */\n insecureStorage: IStorage;\n /**\n * Details about the current session\n */\n sessionInfo: ISessionInfo;\n /**\n * An instance of the library core. Typically obtained using `getClientAuthenticationWithDependencies`.\n */\n clientAuthentication: ClientAuthentication;\n}\n\nexport interface IHandleIncomingRedirectOptions {\n /**\n * If the user has signed in before, setting this to `true` will automatically\n * redirect them to their Solid Identity Provider, which will then attempt to\n * re-activate the session and send the user back to your app without\n * requiring user interaction.\n * If your app's access has not expired yet and re-activation completed\n * successfully, a `sessionRestore` event will be fired with the URL the user\n * was at before they were redirected to their Solid Identity Provider.\n * {@see onSessionRestore}\n */\n restorePreviousSession?: boolean;\n\n /**\n * Inrupt's Enterprise Solid Server can set a cookie to allow the browser to\n * access private resources on a Pod. In order to mitigate the logout-on-refresh\n * issue on the short term, the server also implemented a session endpoint\n * enabling the client app to know whether the cookie is set. When a user\n * logs in to a server that has that capability enabled, applications that set\n * this option to `true` will be able to make use of it.\n *\n * If your app supports the newest session restore approach, and `restorePreviousSession`\n * is set to true, this option is automatically set to false, but your app will\n * not be logged out when reloaded.\n *\n * `useEssSession` defaults to false and will be removed in the future; to\n * preserve sessions across page reloads, use of `restorePreviousSession` is\n * recommended.\n *\n * @deprecated unreleased\n */\n useEssSession?: boolean;\n /**\n * The URL of the page handling the redirect, including the query\n * parameters — these contain the information to process the login.\n * Note: as a convenience, if no URL value is specified here, we default to\n * using the browser's current location.\n */\n url?: string;\n}\n\nexport async function silentlyAuthenticate(\n sessionId: string,\n clientAuthn: ClientAuthentication,\n options: {\n inIframe?: boolean;\n } = {\n inIframe: false,\n },\n session: Session\n): Promise<boolean> {\n const storedSessionInfo = await clientAuthn.validateCurrentSession(sessionId);\n if (storedSessionInfo !== null) {\n // It can be really useful to save the user's current browser location,\n // so that we can restore it after completing the silent authentication\n // on incoming redirect. This way, the user is eventually redirected back\n // to the page they were on and not to the app's redirect page.\n window.localStorage.setItem(KEY_CURRENT_URL, window.location.href);\n await clientAuthn.login(\n {\n sessionId,\n prompt: \"none\",\n oidcIssuer: storedSessionInfo.issuer,\n redirectUrl: storedSessionInfo.redirectUrl,\n clientId: storedSessionInfo.clientAppId,\n clientSecret: storedSessionInfo.clientAppSecret,\n tokenType: storedSessionInfo.tokenType ?? \"DPoP\",\n inIframe: options.inIframe,\n },\n session\n );\n return true;\n }\n return false;\n}\n\nfunction isLoggedIn(\n sessionInfo?: ISessionInfo\n): sessionInfo is ISessionInfo & { isLoggedIn: true } {\n return !!sessionInfo?.isLoggedIn;\n}\n\n/**\n * A {@link Session} object represents a user's session on an application. The session holds state, as it stores information enabling acces to private resources after login for instance.\n */\nexport class Session extends EventEmitter {\n /**\n * Information regarding the current session.\n */\n public readonly info: ISessionInfo;\n\n private clientAuthentication: ClientAuthentication;\n\n private tokenRequestInProgress = false;\n\n /**\n * Session object constructor. Typically called as follows:\n *\n * ```typescript\n * const session = new Session();\n * ```\n *\n * See also [getDefaultSession](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-browser/functions.html#getdefaultsession).\n *\n * @param sessionOptions The options enabling the correct instantiation of\n * the session. Either both storages or clientAuthentication are required. For\n * more information, see {@link ISessionOptions}.\n * @param sessionId A string uniquely identifying the session.\n *\n */\n constructor(\n sessionOptions: Partial<ISessionOptions> = {},\n sessionId?: string\n ) {\n super();\n\n if (sessionOptions.clientAuthentication) {\n this.clientAuthentication = sessionOptions.clientAuthentication;\n } else if (sessionOptions.secureStorage && sessionOptions.insecureStorage) {\n this.clientAuthentication = getClientAuthenticationWithDependencies({\n secureStorage: sessionOptions.secureStorage,\n insecureStorage: sessionOptions.insecureStorage,\n });\n } else {\n this.clientAuthentication = getClientAuthenticationWithDependencies({});\n }\n\n if (sessionOptions.sessionInfo) {\n this.info = {\n sessionId: sessionOptions.sessionInfo.sessionId,\n isLoggedIn: false,\n webId: sessionOptions.sessionInfo.webId,\n };\n } else {\n this.info = {\n sessionId: sessionId ?? v4(),\n isLoggedIn: false,\n };\n }\n\n // Listen for messages from children iframes.\n setupIframeListener(async (redirectUrl: string) => {\n const sessionInfo =\n await this.clientAuthentication.handleIncomingRedirect(\n redirectUrl,\n this\n );\n\n // If silent authentication was not successful, do nothing;\n // the existing session might still be valid for a while,\n // and will expire by itself.\n if (!isLoggedIn(sessionInfo)) {\n return;\n }\n // After having revalidated the session,\n // make sure to apply the new expiration time:\n this.setSessionInfo(sessionInfo);\n });\n // Listen for the 'tokenRenewal' signal to trigger the silent token renewal.\n this.on(\"tokenRenewal\", () =>\n silentlyAuthenticate(\n this.info.sessionId,\n this.clientAuthentication,\n {\n inIframe: true,\n },\n this\n )\n );\n\n // When a session is logged in, we want to track its ID in local storage to\n // enable silent refresh. The current session ID specifically stored in 'localStorage'\n // (as opposed to using our storage abstraction layer) because it is only\n // used in a browser-specific mechanism.\n this.on(EVENTS.LOGIN, () =>\n window.localStorage.setItem(KEY_CURRENT_SESSION, this.info.sessionId)\n );\n\n this.on(EVENTS.SESSION_EXPIRED, () => this.internalLogout(false));\n\n this.on(EVENTS.ERROR, () => this.internalLogout(false));\n\n // @deprecated: Remove this when removing all support for the useEssSession parameter.\n // This intends at cleaning up local storage of applications from data related\n // to the resource server session workaround.\n window.localStorage.removeItem(\"tmp-resource-server-session-enabled\");\n }\n\n /**\n * Triggers the login process. Note that this method will redirect the user away from your app.\n *\n * @param options Parameter to customize the login behaviour. In particular, two options are mandatory: `options.oidcIssuer`, the user's identity provider, and `options.redirectUrl`, the URL to which the user will be redirected after logging in their identity provider.\n * @returns This method should redirect the user away from the app: it does not return anything. The login process is completed by {@linkcode handleIncomingRedirect}.\n */\n // Define these functions as properties so that they don't get accidentally re-bound.\n // Isn't Javascript fun?\n login = async (options: ILoginInputOptions): Promise<void> => {\n await this.clientAuthentication.login(\n {\n sessionId: this.info.sessionId,\n ...options,\n // Defaults the token type to DPoP\n tokenType: options.tokenType ?? \"DPoP\",\n },\n this\n );\n // `login` redirects the user away from the app,\n // so unless it throws an error, there is no code that should run afterwards\n // (since there is no \"after\" in the lifetime of the script).\n // Hence, this Promise never resolves:\n return new Promise(() => undefined);\n };\n\n /**\n * Fetches data using available login information. If the user is not logged in, this will behave as a regular `fetch`. The signature of this method is identical to the [canonical `fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).\n *\n * @param url The URL from which data should be fetched.\n * @param init Optional parameters customizing the request, by specifying an HTTP method, headers, a body, etc. Follows the [WHATWG Fetch Standard](https://fetch.spec.whatwg.org/).\n */\n fetch = async (url: RequestInfo, init?: RequestInit): Promise<Response> => {\n return this.clientAuthentication.fetch(url, init);\n };\n\n /**\n * An internal logout function, to control whether or not the logout signal\n * should be sent, i.e. if the logout was user-initiated or is the result of\n * an external event.\n *\n * @hidden\n */\n private internalLogout = async (emitSignal: boolean): Promise<void> => {\n // Clearing this value means that silent refresh will no longer be attempted.\n // In particular, in the case of a silent authentication error it prevents\n // from getting stuck in an authentication retries loop.\n window.localStorage.removeItem(KEY_CURRENT_SESSION);\n await this.clientAuthentication.logout(this.info.sessionId);\n this.info.isLoggedIn = false;\n if (emitSignal) {\n this.emit(EVENTS.LOGOUT);\n }\n };\n\n /**\n * Logs the user out of the application. This does not log the user out of their Solid identity provider, and should not redirect the user away.\n */\n logout = async (): Promise<void> => this.internalLogout(true);\n\n /**\n * Completes the login process by processing the information provided by the\n * Solid identity provider through redirect.\n *\n * @param options See {@see IHandleIncomingRedirectOptions}.\n */\n handleIncomingRedirect = async (\n inputOptions: string | IHandleIncomingRedirectOptions = {}\n ): Promise<ISessionInfo | undefined> => {\n if (this.info.isLoggedIn) {\n return this.info;\n }\n\n if (this.tokenRequestInProgress) {\n return undefined;\n }\n const options =\n typeof inputOptions === \"string\" ? { url: inputOptions } : inputOptions;\n const url = options.url ?? window.location.href;\n\n if (window.frameElement !== null) {\n // This is being loaded from an iframe, so send the redirect\n // URL to the parent window on the same origin.\n postRedirectUrlToParent(url);\n return undefined;\n }\n\n this.tokenRequestInProgress = true;\n const sessionInfo = await this.clientAuthentication.handleIncomingRedirect(\n url,\n this\n );\n if (isLoggedIn(sessionInfo)) {\n this.setSessionInfo(sessionInfo);\n const currentUrl = window.localStorage.getItem(KEY_CURRENT_URL);\n if (currentUrl === null) {\n // The login event can only be triggered **after** the user has been\n // redirected from the IdP with access and ID tokens.\n this.emit(EVENTS.LOGIN);\n } else {\n // If an URL is stored in local storage, we are being logged in after a\n // silent authentication, so remove our currently stored URL location\n // to clean up our state now that we are completing the re-login process.\n window.localStorage.removeItem(KEY_CURRENT_URL);\n this.emit(EVENTS.SESSION_RESTORED, currentUrl);\n }\n } else if (options.restorePreviousSession === true) {\n // Silent authentication happens after a refresh, which means there are no\n // OAuth params in the current location IRI. It can only succeed if a session\n // was previously logged in, in which case its ID will be present with a known\n // identifier in local storage.\n // Check if we have a locally stored session ID...\n const storedSessionId = window.localStorage.getItem(KEY_CURRENT_SESSION);\n // ...if not, then there is no ID token, and so silent authentication cannot happen, but\n // if we do have a stored session ID, attempt to re-authenticate now silently.\n if (storedSessionId !== null) {\n // TODO: iframe-based authentication being still experimental, it is disabled\n // by default here. When it settles down, the following could be set to true,\n // in which case the unresolving promise afterwards would need to be changed.\n const attemptedSilentAuthentication = await silentlyAuthenticate(\n storedSessionId,\n this.clientAuthentication,\n undefined,\n this\n );\n // At this point, we know that the main window will imminently be redirected.\n // However, this redirect is asynchronous and there is no way to halt execution\n // until it happens precisely. That's why the current Promise simply does not\n // resolve.\n if (attemptedSilentAuthentication) {\n return new Promise(() => {});\n }\n }\n }\n this.tokenRequestInProgress = false;\n return sessionInfo;\n };\n\n /**\n * Register a callback function to be called when a user completes login.\n *\n * The callback is called when {@link handleIncomingRedirect} completes successfully.\n *\n * @param callback The function called when a user completes login.\n */\n onLogin(callback: () => unknown): void {\n this.on(EVENTS.LOGIN, callback);\n }\n\n /**\n * Register a callback function to be called when a user logs out:\n *\n * @param callback The function called when a user completes logout.\n */\n onLogout(callback: () => unknown): void {\n this.on(EVENTS.LOGOUT, callback);\n }\n\n /**\n * Register a callback function to be called when a user logs out:\n *\n * @param callback The function called when an error occurs.\n * @since 1.11.0\n */\n onError(\n callback: (\n error: string | null,\n errorDescription?: string | null\n ) => unknown\n ): void {\n this.on(EVENTS.ERROR, callback);\n }\n\n /**\n * Register a callback function to be called when a session is restored.\n *\n * Note: the callback will be called with the saved value of the 'current URL'\n * at the time the session was restored.\n *\n * @param callback The function called when a user's already logged-in session is restored, e.g., after a silent authentication is completed after a page refresh.\n */\n onSessionRestore(callback: (currentUrl: string) => unknown): void {\n this.on(EVENTS.SESSION_RESTORED, callback);\n }\n\n /**\n * Register a callback that runs when the session expires and can no longer\n * make authenticated requests, but following a user logout.\n * @param callback The function that runs on session expiration.\n * @since 1.11.0\n */\n onSessionExpiration(callback: () => unknown): void {\n this.on(EVENTS.SESSION_EXPIRED, callback);\n }\n\n private setSessionInfo(\n sessionInfo: ISessionInfo & { isLoggedIn: true }\n ): void {\n this.info.isLoggedIn = sessionInfo.isLoggedIn;\n this.info.webId = sessionInfo.webId;\n this.info.sessionId = sessionInfo.sessionId;\n this.info.expirationDate = sessionInfo.expirationDate;\n this.on(EVENTS.SESSION_EXTENDED, (expiresIn: number) => {\n this.info.expirationDate = Date.now() + expiresIn * 1000;\n });\n }\n}\n","/*\n * Copyright 2022 Inrupt Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n * Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport { Session } from \"./Session\";\n\nlet defaultSession: Session;\n\n/**\n * Obtain the {@link Session} used when not explicitly instantiating one yourself.\n *\n * When using the top-level exports {@link fetch}, {@link login}, {@link logout},\n * {@link handleIncomingRedirect}, {@link onLogin} and {@link onLogout}, these apply to an\n * implicitly-instantiated {@link Session}.\n * This function returns a reference to that Session in order to obtain e.g. the current user's\n * WebID.\n * @since 1.3.0\n */\nexport function getDefaultSession(): Session {\n if (typeof defaultSession === \"undefined\") {\n defaultSession = new Session();\n }\n return defaultSession;\n}\n\n/**\n * This function's signature is equal to `window.fetch`, but if the current user is authenticated\n * (see [[login]] and [[handleIncomingRedirect]]), requests made using it will include that user's\n * credentials. If not, this will behave just like the regular `window.fetch`.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch}\n * @since 1.3.0\n */\nexport const fetch: Session[\"fetch\"] = (...args) => {\n const session = getDefaultSession();\n return session.fetch(...args);\n};\n\n/**\n * Triggers the login process. Note that this method will redirect the user away from your app.\n *\n * @param options Parameter to customize the login behaviour. In particular, two options are mandatory: `options.oidcIssuer`, the user's identity provider, and `options.redirectUrl`, the URL to which the user will be redirected after logging in their identity provider.\n * @returns This method should redirect the user away from the app: it does not return anything. The login process is completed by [[handleIncomingRedirect]].\n * @since 1.3.0\n */\nexport const login: Session[\"login\"] = (...args) => {\n const session = getDefaultSession();\n return session.login(...args);\n};\n\n/**\n * Logs the user out of the application. This does not log the user out of their\n * Solid identity provider, and should not redirect the user away.\n *\n * @since 1.3.0\n */\nexport const logout: Session[\"logout\"] = (...args) => {\n const session = getDefaultSession();\n return session.logout(...args);\n};\n\n/**\n * Completes the login process by processing the information provided by the Solid identity provider through redirect.\n *\n * @param url The URL of the page handling the redirect, including the query parameters — these contain the information to process the login.\n * @since 1.3.0\n */\nexport const handleIncomingRedirect: Session[\"handleIncomingRedirect\"] = (\n ...args\n) => {\n const session = getDefaultSession();\n return session.handleIncomingRedirect(...args);\n};\n\n/**\n * Register a callback function to be called when a user completes login.\n *\n * The callback is called when {@link handleIncomingRedirect} completes successfully.\n * @since 1.3.0\n *\n * @param callback The function called when a user completes login.\n */\nexport const onLogin: Session[\"onLogin\"] = (...args) => {\n const session = getDefaultSession();\n return session.onLogin(...args);\n};\n\n/**\n * Register a callback function to be called when a user logs out:\n *\n * @param callback The function called when a user completes logout.\n * @since 1.3.0\n */\nexport const onLogout: Session[\"onLogout\"] = (...args) => {\n const session = getDefaultSession();\n return session.onLogout(...args);\n};\n\n/**\n * Register a callback function to be called when a session is restored:\n *\n * @param callback The function called when a session is restored.\n * @since 1.3.0\n */\nexport const onSessionRestore: Session[\"onSessionRestore\"] = (...args) => {\n const session = getDefaultSession();\n return session.onSessionRestore(...args);\n};\n"],"names":["StorageUtility","removeOidcQueryParam","EVENTS","ConfigurationError","handleRegistration","OidcClient","v4","clearOidcPersistentStorage","isSupportedTokenType","loadOidcContextFromStorage","getDpopToken","getBearerToken","buildAuthenticatedFetch","AggregateHandler","registerClient","refresh","InMemoryStorage","SOLID_CLIENT_AUTHN_KEY_PREFIX","fetch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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