@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.es.js CHANGED
@@ -1,6 +1,7 @@
1
- import { StorageUtility, determineSigningAlg, PREFERRED_SIGNING_ALG, getWebidFromTokenPayload, createDpopHeader, OidcProviderError, InvalidResponseError, generateDpopKeyPair, EVENTS, ConfigurationError, handleRegistration, isSupportedTokenType, loadOidcContextFromStorage, buildAuthenticatedFetch, AggregateHandler, InMemoryStorage, SOLID_CLIENT_AUTHN_KEY_PREFIX } from '@inrupt/solid-client-authn-core';
1
+ import { StorageUtility, EVENTS, ConfigurationError, handleRegistration, isSupportedTokenType, loadOidcContextFromStorage, buildAuthenticatedFetch, AggregateHandler, InMemoryStorage, SOLID_CLIENT_AUTHN_KEY_PREFIX } from '@inrupt/solid-client-authn-core';
2
2
  export { ConfigurationError, InMemoryStorage, NotImplementedError } from '@inrupt/solid-client-authn-core';
3
- import { OidcClient, WebStorageStateStore } from '@inrupt/oidc-client';
3
+ import { v4 } from 'uuid';
4
+ import { removeOidcQueryParam, OidcClient, clearOidcPersistentStorage, getDpopToken, getBearerToken, registerClient, refresh } from '@inrupt/oidc-client-ext';
4
5
 
5
6
  var domain;
6
7
 
@@ -474,362 +475,12 @@ function unwrapListeners(arr) {
474
475
  return ret;
475
476
  }
476
477
 
477
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
478
- // require the crypto API and do not support built-in fallback to lower quality random number
479
- // generators (like Math.random()).
480
- var getRandomValues;
481
- var rnds8 = new Uint8Array(16);
482
- function rng() {
483
- // lazy load so that environments that need to polyfill have a chance to do so
484
- if (!getRandomValues) {
485
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
486
- // find the complete implementation of crypto (msCrypto) on IE11.
487
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
488
-
489
- if (!getRandomValues) {
490
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
491
- }
492
- }
493
-
494
- return getRandomValues(rnds8);
495
- }
496
-
497
- 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;
498
-
499
- function validate(uuid) {
500
- return typeof uuid === 'string' && REGEX.test(uuid);
501
- }
502
-
503
- /**
504
- * Convert array of 16 byte values to UUID string format of the form:
505
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
506
- */
507
-
508
- var byteToHex = [];
509
-
510
- for (var i = 0; i < 256; ++i) {
511
- byteToHex.push((i + 0x100).toString(16).substr(1));
512
- }
513
-
514
- function stringify(arr) {
515
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
516
- // Note: Be careful editing this code! It's been tuned for performance
517
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
518
- 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
519
- // of the following:
520
- // - One or more input array values don't map to a hex octet (leading to
521
- // "undefined" in the uuid)
522
- // - Invalid input values for the RFC `version` or `variant` fields
523
-
524
- if (!validate(uuid)) {
525
- throw TypeError('Stringified UUID is invalid');
526
- }
527
-
528
- return uuid;
529
- }
530
-
531
- function v4(options, buf, offset) {
532
- options = options || {};
533
- var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
534
-
535
- rnds[6] = rnds[6] & 0x0f | 0x40;
536
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
537
-
538
- if (buf) {
539
- offset = offset || 0;
540
-
541
- for (var i = 0; i < 16; ++i) {
542
- buf[offset + i] = rnds[i];
543
- }
544
-
545
- return buf;
546
- }
547
-
548
- return stringify(rnds);
549
- }
550
-
551
478
  class StorageUtilityBrowser extends StorageUtility {
552
479
  constructor(secureStorage, insecureStorage) {
553
480
  super(secureStorage, insecureStorage);
554
481
  }
555
482
  }
556
483
 
557
- function processErrorResponse(responseBody, options) {
558
- var _a, _b, _c, _d;
559
- if (responseBody.error === "invalid_redirect_uri") {
560
- 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 : ""}`);
561
- }
562
- if (responseBody.error === "invalid_client_metadata") {
563
- 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 : ""}`);
564
- }
565
- throw new Error(`Dynamic client registration failed: ${responseBody.error} - ${(_d = responseBody.error_description) !== null && _d !== void 0 ? _d : ""}`);
566
- }
567
- function validateRegistrationResponse(responseBody, options) {
568
- if (responseBody.client_id === undefined) {
569
- throw new Error(`Dynamic client registration failed: no client_id has been found on ${JSON.stringify(responseBody)}`);
570
- }
571
- if (options.redirectUrl &&
572
- (responseBody.redirect_uris === undefined ||
573
- responseBody.redirect_uris[0] !== options.redirectUrl.toString())) {
574
- throw new Error(`Dynamic client registration failed: the returned redirect URIs ${JSON.stringify(responseBody.redirect_uris)} don't match the provided ${JSON.stringify([
575
- options.redirectUrl.toString(),
576
- ])}`);
577
- }
578
- }
579
- async function registerClient(options, issuerConfig) {
580
- var _a;
581
- if (!issuerConfig.registrationEndpoint) {
582
- throw new Error("Dynamic Registration could not be completed because the issuer has no registration endpoint.");
583
- }
584
- if (!Array.isArray(issuerConfig.idTokenSigningAlgValuesSupported)) {
585
- throw new Error("The OIDC issuer discovery profile is missing the 'id_token_signing_alg_values_supported' value, which is mandatory.");
586
- }
587
- const signingAlg = determineSigningAlg(issuerConfig.idTokenSigningAlgValuesSupported, PREFERRED_SIGNING_ALG);
588
- const config = {
589
- client_name: options.clientName,
590
- application_type: "web",
591
- redirect_uris: [(_a = options.redirectUrl) === null || _a === void 0 ? void 0 : _a.toString()],
592
- subject_type: "public",
593
- token_endpoint_auth_method: "client_secret_basic",
594
- id_token_signed_response_alg: signingAlg,
595
- grant_types: ["authorization_code", "refresh_token"],
596
- };
597
- const headers = {
598
- "Content-Type": "application/json",
599
- };
600
- if (options.registrationAccessToken) {
601
- headers.Authorization = `Bearer ${options.registrationAccessToken}`;
602
- }
603
- const registerResponse = await fetch(issuerConfig.registrationEndpoint.toString(), {
604
- method: "POST",
605
- headers,
606
- body: JSON.stringify(config),
607
- });
608
- if (registerResponse.ok) {
609
- const responseBody = await registerResponse.json();
610
- validateRegistrationResponse(responseBody, options);
611
- return {
612
- clientId: responseBody.client_id,
613
- clientSecret: responseBody.client_secret,
614
- idTokenSignedResponseAlg: responseBody.id_token_signed_response_alg,
615
- clientType: "dynamic",
616
- };
617
- }
618
- if (registerResponse.status === 400) {
619
- processErrorResponse(await registerResponse.json(), options);
620
- }
621
- throw new Error(`Dynamic client registration failed: the server returned ${registerResponse.status} ${registerResponse.statusText} - ${await registerResponse.text()}`);
622
- }
623
-
624
- function hasError(value) {
625
- return value.error !== undefined && typeof value.error === "string";
626
- }
627
- function hasErrorDescription(value) {
628
- return (value.error_description !== undefined &&
629
- typeof value.error_description === "string");
630
- }
631
- function hasErrorUri(value) {
632
- return value.error_uri !== undefined && typeof value.error_uri === "string";
633
- }
634
- function hasAccessToken(value) {
635
- return (value.access_token !== undefined && typeof value.access_token === "string");
636
- }
637
- function hasIdToken(value) {
638
- return value.id_token !== undefined && typeof value.id_token === "string";
639
- }
640
- function hasRefreshToken(value) {
641
- return (value.refresh_token !== undefined && typeof value.refresh_token === "string");
642
- }
643
- function hasTokenType(value) {
644
- return value.token_type !== undefined && typeof value.token_type === "string";
645
- }
646
- function hasExpiresIn(value) {
647
- return value.expires_in === undefined || typeof value.expires_in === "number";
648
- }
649
- function validatePreconditions(issuer, data) {
650
- if (data.grantType &&
651
- (!issuer.grantTypesSupported ||
652
- !issuer.grantTypesSupported.includes(data.grantType))) {
653
- throw new Error(`The issuer [${issuer.issuer}] does not support the [${data.grantType}] grant`);
654
- }
655
- if (!issuer.tokenEndpoint) {
656
- throw new Error(`This issuer [${issuer.issuer}] does not have a token endpoint`);
657
- }
658
- }
659
- function validateTokenEndpointResponse(tokenResponse, dpop) {
660
- if (hasError(tokenResponse)) {
661
- throw new OidcProviderError(`Token endpoint returned error [${tokenResponse.error}]${hasErrorDescription(tokenResponse)
662
- ? `: ${tokenResponse.error_description}`
663
- : ""}${hasErrorUri(tokenResponse) ? ` (see ${tokenResponse.error_uri})` : ""}`, tokenResponse.error, hasErrorDescription(tokenResponse)
664
- ? tokenResponse.error_description
665
- : undefined);
666
- }
667
- if (!hasAccessToken(tokenResponse)) {
668
- throw new InvalidResponseError(["access_token"]);
669
- }
670
- if (!hasIdToken(tokenResponse)) {
671
- throw new InvalidResponseError(["id_token"]);
672
- }
673
- if (!hasTokenType(tokenResponse)) {
674
- throw new InvalidResponseError(["token_type"]);
675
- }
676
- if (!hasExpiresIn(tokenResponse)) {
677
- throw new InvalidResponseError(["expires_in"]);
678
- }
679
- if (!dpop && tokenResponse.token_type.toLowerCase() !== "bearer") {
680
- throw new Error(`Invalid token endpoint response: requested a [Bearer] token, but got a 'token_type' value of [${tokenResponse.token_type}].`);
681
- }
682
- return tokenResponse;
683
- }
684
- async function getTokens(issuer, client, data, dpop) {
685
- validatePreconditions(issuer, data);
686
- const headers = {
687
- "content-type": "application/x-www-form-urlencoded",
688
- };
689
- let dpopKey;
690
- if (dpop) {
691
- dpopKey = await generateDpopKeyPair();
692
- headers.DPoP = await createDpopHeader(issuer.tokenEndpoint, "POST", dpopKey);
693
- }
694
- if (client.clientSecret) {
695
- headers.Authorization = `Basic ${btoa(`${client.clientId}:${client.clientSecret}`)}`;
696
- }
697
- const requestBody = {
698
- grant_type: data.grantType,
699
- redirect_uri: data.redirectUrl,
700
- code: data.code,
701
- code_verifier: data.codeVerifier,
702
- client_id: client.clientId,
703
- };
704
- const tokenRequestInit = {
705
- method: "POST",
706
- headers,
707
- body: new URLSearchParams(requestBody).toString(),
708
- };
709
- const rawTokenResponse = await await fetch(issuer.tokenEndpoint, tokenRequestInit);
710
- const jsonTokenResponse = (await rawTokenResponse.json());
711
- const tokenResponse = validateTokenEndpointResponse(jsonTokenResponse, dpop);
712
- const webId = await getWebidFromTokenPayload(tokenResponse.id_token, issuer.jwksUri, issuer.issuer, client.clientId);
713
- return {
714
- accessToken: tokenResponse.access_token,
715
- idToken: tokenResponse.id_token,
716
- refreshToken: hasRefreshToken(tokenResponse)
717
- ? tokenResponse.refresh_token
718
- : undefined,
719
- webId,
720
- dpopKey,
721
- expiresIn: tokenResponse.expires_in,
722
- };
723
- }
724
- async function getBearerToken(redirectUrl) {
725
- let signinResponse;
726
- try {
727
- const client = new OidcClient({
728
- response_mode: "query",
729
- loadUserInfo: false,
730
- });
731
- signinResponse = await client.processSigninResponse(redirectUrl);
732
- if (client.settings.metadata === undefined) {
733
- throw new Error("Cannot retrieve issuer metadata from client information in storage.");
734
- }
735
- if (client.settings.metadata.jwks_uri === undefined) {
736
- throw new Error("Missing some issuer metadata from client information in storage: 'jwks_uri' is undefined");
737
- }
738
- if (client.settings.metadata.issuer === undefined) {
739
- throw new Error("Missing some issuer metadata from client information in storage: 'issuer' is undefined");
740
- }
741
- if (client.settings.client_id === undefined) {
742
- throw new Error("Missing some client information in storage: 'client_id' is undefined");
743
- }
744
- const webId = await getWebidFromTokenPayload(signinResponse.id_token, client.settings.metadata.jwks_uri, client.settings.metadata.issuer, client.settings.client_id);
745
- return {
746
- accessToken: signinResponse.access_token,
747
- idToken: signinResponse.id_token,
748
- webId,
749
- refreshToken: signinResponse.refresh_token,
750
- };
751
- }
752
- catch (err) {
753
- throw new Error(`Problem handling Auth Code Grant (Flow) redirect - URL [${redirectUrl}]: ${err}`);
754
- }
755
- }
756
- async function getDpopToken(issuer, client, data) {
757
- return getTokens(issuer, client, data, true);
758
- }
759
-
760
- async function refresh(refreshToken, issuer, client, dpopKey) {
761
- const requestBody = {
762
- grant_type: "refresh_token",
763
- refresh_token: refreshToken,
764
- scope: "openid offline_access",
765
- };
766
- let dpopHeader = {};
767
- if (dpopKey !== undefined) {
768
- dpopHeader = {
769
- DPoP: await createDpopHeader(issuer.tokenEndpoint, "POST", dpopKey),
770
- };
771
- }
772
- let authHeader = {};
773
- if (client.clientSecret !== undefined) {
774
- authHeader = {
775
- Authorization: `Basic ${btoa(`${client.clientId}:${client.clientSecret}`)}`,
776
- };
777
- }
778
- const rawResponse = await fetch(issuer.tokenEndpoint, {
779
- method: "POST",
780
- body: new URLSearchParams(requestBody).toString(),
781
- headers: {
782
- ...dpopHeader,
783
- ...authHeader,
784
- "Content-Type": "application/x-www-form-urlencoded",
785
- },
786
- });
787
- let response;
788
- try {
789
- response = await rawResponse.json();
790
- }
791
- catch (e) {
792
- throw new Error(`The token endpoint of issuer ${issuer.issuer} returned a malformed response.`);
793
- }
794
- const validatedResponse = validateTokenEndpointResponse(response, dpopKey !== undefined);
795
- const webId = await getWebidFromTokenPayload(validatedResponse.id_token, issuer.jwksUri, issuer.issuer, client.clientId);
796
- return {
797
- accessToken: validatedResponse.access_token,
798
- idToken: validatedResponse.id_token,
799
- refreshToken: typeof validatedResponse.refresh_token === "string"
800
- ? validatedResponse.refresh_token
801
- : undefined,
802
- webId,
803
- dpopKey,
804
- expiresIn: validatedResponse.expires_in,
805
- };
806
- }
807
-
808
- function removeOidcQueryParam(redirectUrl) {
809
- const cleanedUrl = new URL(redirectUrl);
810
- cleanedUrl.searchParams.delete("code");
811
- cleanedUrl.searchParams.delete("state");
812
- cleanedUrl.hash = "";
813
- return cleanedUrl.toString();
814
- }
815
- async function clearOidcPersistentStorage() {
816
- const client = new OidcClient({
817
- response_mode: "query",
818
- });
819
- await client.clearStaleState(new WebStorageStateStore({}));
820
- const myStorage = window.localStorage;
821
- const itemsToRemove = [];
822
- for (let i = 0; i <= myStorage.length; i += 1) {
823
- const key = myStorage.key(i);
824
- if (key &&
825
- (key.match(/^oidc\..+$/) ||
826
- key.match(/^solidClientAuthenticationUser:.+$/))) {
827
- itemsToRemove.push(key);
828
- }
829
- }
830
- itemsToRemove.forEach((key) => myStorage.removeItem(key));
831
- }
832
-
833
484
  const globalFetch = (request, init) => window.fetch(request, init);
834
485
  class ClientAuthentication {
835
486
  constructor(loginHandler, redirectHandler, logoutHandler, sessionInfoManager, issuerConfigFetcher) {
@@ -1691,3 +1342,4 @@ const onSessionRestore = (...args) => {
1691
1342
  };
1692
1343
 
1693
1344
  export { Session, fetch$1 as fetch, getClientAuthenticationWithDependencies, getDefaultSession, handleIncomingRedirect, login, logout, onLogin, onLogout, onSessionRestore };
1345
+ //# sourceMappingURL=index.es.js.map