@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 CHANGED
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var solidClientAuthnCore = require('@inrupt/solid-client-authn-core');
6
- var oidcClient = require('@inrupt/oidc-client');
6
+ var uuid = require('uuid');
7
+ var oidcClientExt = require('@inrupt/oidc-client-ext');
7
8
 
8
9
  var domain;
9
10
 
@@ -477,362 +478,12 @@ function unwrapListeners(arr) {
477
478
  return ret;
478
479
  }
479
480
 
480
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
481
- // require the crypto API and do not support built-in fallback to lower quality random number
482
- // generators (like Math.random()).
483
- var getRandomValues;
484
- var rnds8 = new Uint8Array(16);
485
- function rng() {
486
- // lazy load so that environments that need to polyfill have a chance to do so
487
- if (!getRandomValues) {
488
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
489
- // find the complete implementation of crypto (msCrypto) on IE11.
490
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
491
-
492
- if (!getRandomValues) {
493
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
494
- }
495
- }
496
-
497
- return getRandomValues(rnds8);
498
- }
499
-
500
- var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
501
-
502
- function validate(uuid) {
503
- return typeof uuid === 'string' && REGEX.test(uuid);
504
- }
505
-
506
- /**
507
- * Convert array of 16 byte values to UUID string format of the form:
508
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
509
- */
510
-
511
- var byteToHex = [];
512
-
513
- for (var i = 0; i < 256; ++i) {
514
- byteToHex.push((i + 0x100).toString(16).substr(1));
515
- }
516
-
517
- function stringify(arr) {
518
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
519
- // Note: Be careful editing this code! It's been tuned for performance
520
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
521
- var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
522
- // of the following:
523
- // - One or more input array values don't map to a hex octet (leading to
524
- // "undefined" in the uuid)
525
- // - Invalid input values for the RFC `version` or `variant` fields
526
-
527
- if (!validate(uuid)) {
528
- throw TypeError('Stringified UUID is invalid');
529
- }
530
-
531
- return uuid;
532
- }
533
-
534
- function v4(options, buf, offset) {
535
- options = options || {};
536
- var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
537
-
538
- rnds[6] = rnds[6] & 0x0f | 0x40;
539
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
540
-
541
- if (buf) {
542
- offset = offset || 0;
543
-
544
- for (var i = 0; i < 16; ++i) {
545
- buf[offset + i] = rnds[i];
546
- }
547
-
548
- return buf;
549
- }
550
-
551
- return stringify(rnds);
552
- }
553
-
554
481
  class StorageUtilityBrowser extends solidClientAuthnCore.StorageUtility {
555
482
  constructor(secureStorage, insecureStorage) {
556
483
  super(secureStorage, insecureStorage);
557
484
  }
558
485
  }
559
486
 
560
- function processErrorResponse(responseBody, options) {
561
- var _a, _b, _c, _d;
562
- if (responseBody.error === "invalid_redirect_uri") {
563
- throw new Error(`Dynamic client registration failed: the provided redirect uri [${(_a = options.redirectUrl) === null || _a === void 0 ? void 0 : _a.toString()}] is invalid - ${(_b = responseBody.error_description) !== null && _b !== void 0 ? _b : ""}`);
564
- }
565
- if (responseBody.error === "invalid_client_metadata") {
566
- throw new Error(`Dynamic client registration failed: the provided client metadata ${JSON.stringify(options)} is invalid - ${(_c = responseBody.error_description) !== null && _c !== void 0 ? _c : ""}`);
567
- }
568
- throw new Error(`Dynamic client registration failed: ${responseBody.error} - ${(_d = responseBody.error_description) !== null && _d !== void 0 ? _d : ""}`);
569
- }
570
- function validateRegistrationResponse(responseBody, options) {
571
- if (responseBody.client_id === undefined) {
572
- throw new Error(`Dynamic client registration failed: no client_id has been found on ${JSON.stringify(responseBody)}`);
573
- }
574
- if (options.redirectUrl &&
575
- (responseBody.redirect_uris === undefined ||
576
- responseBody.redirect_uris[0] !== options.redirectUrl.toString())) {
577
- throw new Error(`Dynamic client registration failed: the returned redirect URIs ${JSON.stringify(responseBody.redirect_uris)} don't match the provided ${JSON.stringify([
578
- options.redirectUrl.toString(),
579
- ])}`);
580
- }
581
- }
582
- async function registerClient(options, issuerConfig) {
583
- var _a;
584
- if (!issuerConfig.registrationEndpoint) {
585
- throw new Error("Dynamic Registration could not be completed because the issuer has no registration endpoint.");
586
- }
587
- if (!Array.isArray(issuerConfig.idTokenSigningAlgValuesSupported)) {
588
- throw new Error("The OIDC issuer discovery profile is missing the 'id_token_signing_alg_values_supported' value, which is mandatory.");
589
- }
590
- const signingAlg = solidClientAuthnCore.determineSigningAlg(issuerConfig.idTokenSigningAlgValuesSupported, solidClientAuthnCore.PREFERRED_SIGNING_ALG);
591
- const config = {
592
- client_name: options.clientName,
593
- application_type: "web",
594
- redirect_uris: [(_a = options.redirectUrl) === null || _a === void 0 ? void 0 : _a.toString()],
595
- subject_type: "public",
596
- token_endpoint_auth_method: "client_secret_basic",
597
- id_token_signed_response_alg: signingAlg,
598
- grant_types: ["authorization_code", "refresh_token"],
599
- };
600
- const headers = {
601
- "Content-Type": "application/json",
602
- };
603
- if (options.registrationAccessToken) {
604
- headers.Authorization = `Bearer ${options.registrationAccessToken}`;
605
- }
606
- const registerResponse = await fetch(issuerConfig.registrationEndpoint.toString(), {
607
- method: "POST",
608
- headers,
609
- body: JSON.stringify(config),
610
- });
611
- if (registerResponse.ok) {
612
- const responseBody = await registerResponse.json();
613
- validateRegistrationResponse(responseBody, options);
614
- return {
615
- clientId: responseBody.client_id,
616
- clientSecret: responseBody.client_secret,
617
- idTokenSignedResponseAlg: responseBody.id_token_signed_response_alg,
618
- clientType: "dynamic",
619
- };
620
- }
621
- if (registerResponse.status === 400) {
622
- processErrorResponse(await registerResponse.json(), options);
623
- }
624
- throw new Error(`Dynamic client registration failed: the server returned ${registerResponse.status} ${registerResponse.statusText} - ${await registerResponse.text()}`);
625
- }
626
-
627
- function hasError(value) {
628
- return value.error !== undefined && typeof value.error === "string";
629
- }
630
- function hasErrorDescription(value) {
631
- return (value.error_description !== undefined &&
632
- typeof value.error_description === "string");
633
- }
634
- function hasErrorUri(value) {
635
- return value.error_uri !== undefined && typeof value.error_uri === "string";
636
- }
637
- function hasAccessToken(value) {
638
- return (value.access_token !== undefined && typeof value.access_token === "string");
639
- }
640
- function hasIdToken(value) {
641
- return value.id_token !== undefined && typeof value.id_token === "string";
642
- }
643
- function hasRefreshToken(value) {
644
- return (value.refresh_token !== undefined && typeof value.refresh_token === "string");
645
- }
646
- function hasTokenType(value) {
647
- return value.token_type !== undefined && typeof value.token_type === "string";
648
- }
649
- function hasExpiresIn(value) {
650
- return value.expires_in === undefined || typeof value.expires_in === "number";
651
- }
652
- function validatePreconditions(issuer, data) {
653
- if (data.grantType &&
654
- (!issuer.grantTypesSupported ||
655
- !issuer.grantTypesSupported.includes(data.grantType))) {
656
- throw new Error(`The issuer [${issuer.issuer}] does not support the [${data.grantType}] grant`);
657
- }
658
- if (!issuer.tokenEndpoint) {
659
- throw new Error(`This issuer [${issuer.issuer}] does not have a token endpoint`);
660
- }
661
- }
662
- function validateTokenEndpointResponse(tokenResponse, dpop) {
663
- if (hasError(tokenResponse)) {
664
- throw new solidClientAuthnCore.OidcProviderError(`Token endpoint returned error [${tokenResponse.error}]${hasErrorDescription(tokenResponse)
665
- ? `: ${tokenResponse.error_description}`
666
- : ""}${hasErrorUri(tokenResponse) ? ` (see ${tokenResponse.error_uri})` : ""}`, tokenResponse.error, hasErrorDescription(tokenResponse)
667
- ? tokenResponse.error_description
668
- : undefined);
669
- }
670
- if (!hasAccessToken(tokenResponse)) {
671
- throw new solidClientAuthnCore.InvalidResponseError(["access_token"]);
672
- }
673
- if (!hasIdToken(tokenResponse)) {
674
- throw new solidClientAuthnCore.InvalidResponseError(["id_token"]);
675
- }
676
- if (!hasTokenType(tokenResponse)) {
677
- throw new solidClientAuthnCore.InvalidResponseError(["token_type"]);
678
- }
679
- if (!hasExpiresIn(tokenResponse)) {
680
- throw new solidClientAuthnCore.InvalidResponseError(["expires_in"]);
681
- }
682
- if (!dpop && tokenResponse.token_type.toLowerCase() !== "bearer") {
683
- throw new Error(`Invalid token endpoint response: requested a [Bearer] token, but got a 'token_type' value of [${tokenResponse.token_type}].`);
684
- }
685
- return tokenResponse;
686
- }
687
- async function getTokens(issuer, client, data, dpop) {
688
- validatePreconditions(issuer, data);
689
- const headers = {
690
- "content-type": "application/x-www-form-urlencoded",
691
- };
692
- let dpopKey;
693
- if (dpop) {
694
- dpopKey = await solidClientAuthnCore.generateDpopKeyPair();
695
- headers.DPoP = await solidClientAuthnCore.createDpopHeader(issuer.tokenEndpoint, "POST", dpopKey);
696
- }
697
- if (client.clientSecret) {
698
- headers.Authorization = `Basic ${btoa(`${client.clientId}:${client.clientSecret}`)}`;
699
- }
700
- const requestBody = {
701
- grant_type: data.grantType,
702
- redirect_uri: data.redirectUrl,
703
- code: data.code,
704
- code_verifier: data.codeVerifier,
705
- client_id: client.clientId,
706
- };
707
- const tokenRequestInit = {
708
- method: "POST",
709
- headers,
710
- body: new URLSearchParams(requestBody).toString(),
711
- };
712
- const rawTokenResponse = await await fetch(issuer.tokenEndpoint, tokenRequestInit);
713
- const jsonTokenResponse = (await rawTokenResponse.json());
714
- const tokenResponse = validateTokenEndpointResponse(jsonTokenResponse, dpop);
715
- const webId = await solidClientAuthnCore.getWebidFromTokenPayload(tokenResponse.id_token, issuer.jwksUri, issuer.issuer, client.clientId);
716
- return {
717
- accessToken: tokenResponse.access_token,
718
- idToken: tokenResponse.id_token,
719
- refreshToken: hasRefreshToken(tokenResponse)
720
- ? tokenResponse.refresh_token
721
- : undefined,
722
- webId,
723
- dpopKey,
724
- expiresIn: tokenResponse.expires_in,
725
- };
726
- }
727
- async function getBearerToken(redirectUrl) {
728
- let signinResponse;
729
- try {
730
- const client = new oidcClient.OidcClient({
731
- response_mode: "query",
732
- loadUserInfo: false,
733
- });
734
- signinResponse = await client.processSigninResponse(redirectUrl);
735
- if (client.settings.metadata === undefined) {
736
- throw new Error("Cannot retrieve issuer metadata from client information in storage.");
737
- }
738
- if (client.settings.metadata.jwks_uri === undefined) {
739
- throw new Error("Missing some issuer metadata from client information in storage: 'jwks_uri' is undefined");
740
- }
741
- if (client.settings.metadata.issuer === undefined) {
742
- throw new Error("Missing some issuer metadata from client information in storage: 'issuer' is undefined");
743
- }
744
- if (client.settings.client_id === undefined) {
745
- throw new Error("Missing some client information in storage: 'client_id' is undefined");
746
- }
747
- const webId = await solidClientAuthnCore.getWebidFromTokenPayload(signinResponse.id_token, client.settings.metadata.jwks_uri, client.settings.metadata.issuer, client.settings.client_id);
748
- return {
749
- accessToken: signinResponse.access_token,
750
- idToken: signinResponse.id_token,
751
- webId,
752
- refreshToken: signinResponse.refresh_token,
753
- };
754
- }
755
- catch (err) {
756
- throw new Error(`Problem handling Auth Code Grant (Flow) redirect - URL [${redirectUrl}]: ${err}`);
757
- }
758
- }
759
- async function getDpopToken(issuer, client, data) {
760
- return getTokens(issuer, client, data, true);
761
- }
762
-
763
- async function refresh(refreshToken, issuer, client, dpopKey) {
764
- const requestBody = {
765
- grant_type: "refresh_token",
766
- refresh_token: refreshToken,
767
- scope: "openid offline_access",
768
- };
769
- let dpopHeader = {};
770
- if (dpopKey !== undefined) {
771
- dpopHeader = {
772
- DPoP: await solidClientAuthnCore.createDpopHeader(issuer.tokenEndpoint, "POST", dpopKey),
773
- };
774
- }
775
- let authHeader = {};
776
- if (client.clientSecret !== undefined) {
777
- authHeader = {
778
- Authorization: `Basic ${btoa(`${client.clientId}:${client.clientSecret}`)}`,
779
- };
780
- }
781
- const rawResponse = await fetch(issuer.tokenEndpoint, {
782
- method: "POST",
783
- body: new URLSearchParams(requestBody).toString(),
784
- headers: {
785
- ...dpopHeader,
786
- ...authHeader,
787
- "Content-Type": "application/x-www-form-urlencoded",
788
- },
789
- });
790
- let response;
791
- try {
792
- response = await rawResponse.json();
793
- }
794
- catch (e) {
795
- throw new Error(`The token endpoint of issuer ${issuer.issuer} returned a malformed response.`);
796
- }
797
- const validatedResponse = validateTokenEndpointResponse(response, dpopKey !== undefined);
798
- const webId = await solidClientAuthnCore.getWebidFromTokenPayload(validatedResponse.id_token, issuer.jwksUri, issuer.issuer, client.clientId);
799
- return {
800
- accessToken: validatedResponse.access_token,
801
- idToken: validatedResponse.id_token,
802
- refreshToken: typeof validatedResponse.refresh_token === "string"
803
- ? validatedResponse.refresh_token
804
- : undefined,
805
- webId,
806
- dpopKey,
807
- expiresIn: validatedResponse.expires_in,
808
- };
809
- }
810
-
811
- function removeOidcQueryParam(redirectUrl) {
812
- const cleanedUrl = new URL(redirectUrl);
813
- cleanedUrl.searchParams.delete("code");
814
- cleanedUrl.searchParams.delete("state");
815
- cleanedUrl.hash = "";
816
- return cleanedUrl.toString();
817
- }
818
- async function clearOidcPersistentStorage() {
819
- const client = new oidcClient.OidcClient({
820
- response_mode: "query",
821
- });
822
- await client.clearStaleState(new oidcClient.WebStorageStateStore({}));
823
- const myStorage = window.localStorage;
824
- const itemsToRemove = [];
825
- for (let i = 0; i <= myStorage.length; i += 1) {
826
- const key = myStorage.key(i);
827
- if (key &&
828
- (key.match(/^oidc\..+$/) ||
829
- key.match(/^solidClientAuthenticationUser:.+$/))) {
830
- itemsToRemove.push(key);
831
- }
832
- }
833
- itemsToRemove.forEach((key) => myStorage.removeItem(key));
834
- }
835
-
836
487
  const globalFetch = (request, init) => window.fetch(request, init);
837
488
  class ClientAuthentication {
838
489
  constructor(loginHandler, redirectHandler, logoutHandler, sessionInfoManager, issuerConfigFetcher) {
@@ -844,7 +495,7 @@ class ClientAuthentication {
844
495
  this.login = async (options, eventEmitter) => {
845
496
  var _a, _b;
846
497
  await this.sessionInfoManager.clear(options.sessionId);
847
- const redirectUrl = removeOidcQueryParam((_a = options.redirectUrl) !== null && _a !== void 0 ? _a : window.location.href);
498
+ const redirectUrl = oidcClientExt.removeOidcQueryParam((_a = options.redirectUrl) !== null && _a !== void 0 ? _a : window.location.href);
848
499
  await this.loginHandler.handle({
849
500
  ...options,
850
501
  redirectUrl,
@@ -962,7 +613,7 @@ class AuthorizationCodeWithPkceOidcHandler {
962
613
  code_verifier: true,
963
614
  prompt: (_a = oidcLoginOptions.prompt) !== null && _a !== void 0 ? _a : "consent",
964
615
  };
965
- const oidcClientLibrary = new oidcClient.OidcClient(oidcOptions);
616
+ const oidcClientLibrary = new oidcClientExt.OidcClient(oidcOptions);
966
617
  const { redirector } = this;
967
618
  const storage = this.storageUtility;
968
619
  try {
@@ -1118,7 +769,7 @@ class IssuerConfigFetcher {
1118
769
  function getUnauthenticatedSession() {
1119
770
  return {
1120
771
  isLoggedIn: false,
1121
- sessionId: v4(),
772
+ sessionId: uuid.v4(),
1122
773
  fetch,
1123
774
  };
1124
775
  }
@@ -1128,7 +779,7 @@ async function clear(sessionId, storage) {
1128
779
  storage.deleteAllUserData(sessionId, { secure: true }),
1129
780
  storage.delete("clientKey", { secure: false }),
1130
781
  ]);
1131
- await clearOidcPersistentStorage();
782
+ await oidcClientExt.clearOidcPersistentStorage();
1132
783
  }
1133
784
  class SessionInfoManager {
1134
785
  constructor(storageUtility) {
@@ -1266,7 +917,7 @@ class AuthCodeRedirectHandler {
1266
917
  let tokens;
1267
918
  const tokenCreatedAt = Date.now();
1268
919
  if (isDpop) {
1269
- tokens = await getDpopToken(issuerConfig, client, {
920
+ tokens = await oidcClientExt.getDpopToken(issuerConfig, client, {
1270
921
  grantType: "authorization_code",
1271
922
  code: url.searchParams.get("code"),
1272
923
  codeVerifier,
@@ -1275,7 +926,7 @@ class AuthCodeRedirectHandler {
1275
926
  window.localStorage.removeItem(`oidc.${oauthState}`);
1276
927
  }
1277
928
  else {
1278
- tokens = await getBearerToken(url.toString());
929
+ tokens = await oidcClientExt.getBearerToken(url.toString());
1279
930
  }
1280
931
  let refreshOptions;
1281
932
  if (tokens.refreshToken !== undefined) {
@@ -1414,7 +1065,7 @@ class ClientRegistrar {
1414
1065
  extendedOptions.registrationAccessToken =
1415
1066
  (_a = extendedOptions.registrationAccessToken) !== null && _a !== void 0 ? _a : (await this.storageUtility.getForUser(options.sessionId, "registrationAccessToken"));
1416
1067
  try {
1417
- const registeredClient = await registerClient(extendedOptions, issuerConfig);
1068
+ const registeredClient = await oidcClientExt.registerClient(extendedOptions, issuerConfig);
1418
1069
  const infoToSave = {
1419
1070
  clientId: registeredClient.clientId,
1420
1071
  };
@@ -1471,7 +1122,7 @@ class TokenRefresher {
1471
1122
  if (oidcContext.dpop && dpopKey === undefined) {
1472
1123
  throw new Error(`For session [${sessionId}], the key bound to the DPoP access token must be provided to refresh said access token.`);
1473
1124
  }
1474
- const tokenSet = await refresh(refreshToken, oidcContext.issuerConfig, clientInfo, dpopKey);
1125
+ const tokenSet = await oidcClientExt.refresh(refreshToken, oidcContext.issuerConfig, clientInfo, dpopKey);
1475
1126
  if (tokenSet.refreshToken !== undefined) {
1476
1127
  eventEmitter === null || eventEmitter === void 0 ? void 0 : eventEmitter.emit(solidClientAuthnCore.EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);
1477
1128
  await this.storageUtility.setForUser(sessionId, {
@@ -1612,7 +1263,7 @@ class Session extends EventEmitter {
1612
1263
  }
1613
1264
  else {
1614
1265
  this.info = {
1615
- sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : v4(),
1266
+ sessionId: sessionId !== null && sessionId !== void 0 ? sessionId : uuid.v4(),
1616
1267
  isLoggedIn: false,
1617
1268
  };
1618
1269
  }
@@ -1715,3 +1366,4 @@ exports.logout = logout;
1715
1366
  exports.onLogin = onLogin;
1716
1367
  exports.onLogout = onLogout;
1717
1368
  exports.onSessionRestore = onSessionRestore;
1369
+ //# sourceMappingURL=index.js.map