@inrupt/solid-client-authn-browser 1.11.9-alpha.2 → 1.11.9-alpha.5

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 +1 -0
  2. package/dist/index.es.js.map +1 -0
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/solid-client-authn.bundle.js +1 -0
  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
@@ -1,686 +0,0 @@
1
- import React, { Component } from "react";
2
- import "regenerator-runtime/runtime";
3
-
4
- // import {
5
- // Session,
6
- // getClientAuthenticationWithDependencies,
7
- // } from "@inrupt/solid-client-authn-browser";
8
- import {
9
- Session,
10
- getClientAuthenticationWithDependencies,
11
- } from "@inrupt/solid-client-authn-browser";
12
-
13
- const clientApplicationName = "S-C-A Browser Demo Client App";
14
- let snackBarTimeout = undefined;
15
- let identityProviderLogoutEndpointTimeout = null;
16
-
17
- const NSS_SERVER_URL = "https://inrupt.net/";
18
-
19
- const preconfiguedIdpList = [
20
- "https://openid.dev-next.inrupt.com",
21
- "https://broker.pod.inrupt.com",
22
- "https://broker.dev-ess.inrupt.com",
23
- "https://broker.demo-ess.inrupt.com",
24
- "https://inrupt.net",
25
- ];
26
-
27
- const defaultIssuer = preconfiguedIdpList[1];
28
-
29
- const style = {
30
- display: "block",
31
- background: "#A0C5E8",
32
- padding: "5px",
33
- margin: "0 0 1em 0",
34
- };
35
-
36
- // FIXME: temporary hack to get access to the clientAuthentication instance to retrieve the IdP URL
37
- // replace with getDefaultSession once the issuer is exposed in ISessionInfo
38
- let session, clientAuthentication;
39
- function getSession() {
40
- if (!session) {
41
- clientAuthentication = getClientAuthenticationWithDependencies({});
42
- session = new Session({
43
- clientAuthentication: clientAuthentication,
44
- });
45
- }
46
-
47
- return session;
48
- }
49
-
50
- function identityProviderConfigUrl(url) {
51
- return `${url}${
52
- url.endsWith("/") ? "" : "/"
53
- }.well-known/openid-configuration`;
54
- }
55
-
56
- // This exists in IssuerConfigFetcher, but isn't publicly accessible:
57
- async function fetchIdentityProviderConfig(idpConfigEndpoint) {
58
- return fetch(idpConfigEndpoint).then((response) => response.json());
59
- }
60
-
61
- /**
62
- * Very hacky attempt at splitting a WebID into 'components', such that:
63
- * prefix: is up to, but not including, the username part of the WebID.
64
- * identifier: is just the username part of the WebID.
65
- * suffix: is everything after the username part of the WebID.
66
- *
67
- * Example: https://ldp.demo-ess.inrupt.com/110592712913443799002/profile/card#me
68
- * prefix is "https://ldp.demo-ess.inrupt.com/".
69
- * identifier is "110592712913443799002".
70
- * suffix is "/profile/card#me".
71
- */
72
- function extractWebIdComponents(webId) {
73
- const webIdUrl = new URL(webId);
74
- const result = { prefix: null, identifier: null, suffix: null };
75
-
76
- result.prefix = new URL("/", webIdUrl).toString();
77
-
78
- if (webId.endsWith("/profile/card#me")) {
79
- // ESS 1.1:
80
- const suffixIndex = webIdUrl.pathname.indexOf("/profile/");
81
-
82
- result.identifier = webIdUrl.pathname.slice(1, suffixIndex);
83
- result.suffix = webIdUrl.pathname.slice(suffixIndex) + webIdUrl.hash;
84
- } else {
85
- // ESS 1.2:
86
- // There is no suffix for ESS 1.2 WebIds
87
- result.identifier = webIdUrl.pathname.substring(1);
88
- }
89
-
90
- // NSS on Inrupt.net uses subdomains, so we need to trim the trailing slash on the prefix:
91
- if (
92
- !result.identifier &&
93
- result.prefix &&
94
- result.suffix &&
95
- result.prefix.endsWith("/")
96
- ) {
97
- result.prefix = result.prefix.substring(0, result.prefix.length - 1);
98
- }
99
-
100
- return result;
101
- }
102
-
103
- function openNewWindow(url) {
104
- const top = (window.outerHeight - 500) / 2;
105
- const left = (window.outerWidth - 1200) / 2;
106
- window.open(
107
- url,
108
- "_blank",
109
- `height=500,width=1200,top=${top},left=${left},modal=yes,alwaysRaised=yes,toolbar=0,menubar=0`
110
- );
111
- }
112
-
113
- class DemoClientApp extends Component {
114
- constructor(props) {
115
- super(props);
116
-
117
- const session = getSession();
118
-
119
- session.onLogout(() => {
120
- this.setState({
121
- status: "login",
122
- fetchLoading: false,
123
- fetchBody: null,
124
- idpUserInfo: null,
125
- idpConfig: null,
126
- });
127
- });
128
-
129
- session.onSessionRestore(() => {
130
- this.onLoginOrRestore();
131
- });
132
-
133
- session.onLogin(() => {
134
- this.onLoginOrRestore();
135
- });
136
-
137
- this.state = {
138
- status: "loading",
139
- loginIssuer: defaultIssuer,
140
- clearClientRegistrationInfo: true,
141
- fetchRoute: "",
142
- fetchLoading: false,
143
- fetchBody: null,
144
- idpConfig: null,
145
- idpUserInfo: null,
146
- enableIdpButtons: false,
147
- };
148
-
149
- if (window.location.pathname === "/popup") {
150
- this.state.status = "popup";
151
- }
152
-
153
- this.handleLogin = this.handleLogin.bind(this);
154
- this.handleLogout = this.handleLogout.bind(this);
155
- this.handleFetchIdentityProviderConfig =
156
- this.handleFetchIdentityProviderConfig.bind(this);
157
- this.handleOpenIdentityProvider =
158
- this.handleOpenIdentityProvider.bind(this);
159
- this.handleLogoutIdentityProvider =
160
- this.handleLogoutIdentityProvider.bind(this);
161
- this.handleFetch = this.handleFetch.bind(this);
162
- }
163
-
164
- async componentDidMount() {
165
- if (window.location.pathname === "/popup") {
166
- this.state.status = "popup";
167
- setTimeout(() => window.close(), 2000);
168
- } else {
169
- const session = getSession();
170
-
171
- // restore the existing session or handle the redirect from login:
172
- await session.handleIncomingRedirect({
173
- restorePreviousSession: true,
174
- });
175
-
176
- if (!session.info.isLoggedIn) {
177
- this.setState({ status: "login" });
178
- } else {
179
- this.onLoginOrRestore();
180
- }
181
- }
182
- }
183
-
184
- async onLoginOrRestore() {
185
- const session = getSession();
186
-
187
- if (!session.info.isLoggedIn) {
188
- this.setState({ status: "login" });
189
- } else {
190
- // FIXME: remove once issuer is provided in ISessionInfo:
191
- const fullSessionInfo = await clientAuthentication.getSessionInfo(
192
- session.info.sessionId
193
- );
194
-
195
- this.setState({
196
- status: "dashboard",
197
- loginIssuer: fullSessionInfo.issuer,
198
- fetchRoute: "",
199
- });
200
-
201
- this.fetchIdentityProviderInfo(fullSessionInfo.issuer);
202
- }
203
- }
204
-
205
- async handleLogin(e, isPopup = false) {
206
- e.preventDefault();
207
- this.setState({ status: "loading" });
208
-
209
- if (this.state.clearClientRegistrationInfo) {
210
- window.localStorage.clear(
211
- "solidClientAuthenticationUser:clientApplicationRegistrationInfo"
212
- );
213
- }
214
-
215
- const session = getSession();
216
-
217
- await session.login({
218
- redirectUrl: document.location.href,
219
- oidcIssuer: this.state.loginIssuer,
220
- clientName: clientApplicationName,
221
- });
222
- }
223
-
224
- async handleFetchIdentityProviderConfig() {
225
- try {
226
- const config = await fetchIdentityProviderConfig(
227
- identityProviderConfigUrl(this.state.loginIssuer)
228
- );
229
-
230
- this.setState({ idpConfig: JSON.stringify(config, null, 2) });
231
- } catch (err) {
232
- this.setState({ idpConfig: `Error loading IdP config: ${err}` });
233
- }
234
- }
235
-
236
- handleOpenIdentityProvider(e) {
237
- e.preventDefault();
238
-
239
- console.log(
240
- `Opening new window for Identity Provider at: [${this.state.loginIssuer}]`
241
- );
242
-
243
- openNewWindow(this.state.loginIssuer);
244
- }
245
-
246
- async handleLogoutIdentityProvider(e) {
247
- e.preventDefault();
248
-
249
- const config = await fetchIdentityProviderConfig(
250
- identityProviderConfigUrl(this.state.loginIssuer)
251
- );
252
-
253
- // ESS 1.1 requires the `post_logout_redirect_uri` to be set:
254
- const redirectUri = new URL("/popup", document.location.href);
255
- const endSessionUrl = new URL(config.end_session_endpoint);
256
- endSessionUrl.searchParams.set(
257
- "post_logout_redirect_uri",
258
- redirectUri.toString()
259
- );
260
-
261
- console.log(
262
- `Opening new window for Identity Provider Logout at: [${endSessionUrl}]`
263
- );
264
-
265
- openNewWindow(endSessionUrl);
266
-
267
- // Calling explicitly because the logout happens in the popup:
268
- setTimeout(async () => {
269
- const session = getSession();
270
- await session.logout();
271
-
272
- this.setState({ enableIdpButtons: false });
273
- }, 1000);
274
- }
275
-
276
- handleLogout(e) {
277
- e.preventDefault();
278
- this.performLogout();
279
- }
280
-
281
- async performLogout() {
282
- this.setState({ status: "loading" });
283
-
284
- const session = getSession();
285
- await session.logout();
286
-
287
- this.hasIdentityProviderLogout(this.state.loginIssuer);
288
-
289
- this.setState({
290
- status: "login",
291
- idpConfig: null,
292
- fetchBody: null,
293
- });
294
- }
295
-
296
- async handleFetch(e) {
297
- e.preventDefault();
298
-
299
- this.setState({ fetchLoading: true });
300
-
301
- if (this.state.fetchRoute.startsWith("/")) {
302
- this.setState({
303
- fetchBody: "Error: please specify a full URL",
304
- fetchLoading: false,
305
- });
306
- return;
307
- }
308
-
309
- try {
310
- const session = getSession();
311
- const response = await (
312
- await session.fetch(this.state.fetchRoute, {})
313
- ).text();
314
-
315
- this.setState({ fetchBody: response, fetchLoading: false });
316
- this.fetchIdentityProviderInfo(this.state.loginIssuer);
317
- } catch (err) {
318
- this.setState({ fetchLoading: false });
319
- }
320
- }
321
-
322
- displaySnackBar(text) {
323
- const snackBar = document.getElementById("snackbar");
324
- snackBar.className = "show";
325
- snackBar.innerHTML = text;
326
- if (snackBarTimeout) {
327
- clearTimeout(snackBarTimeout);
328
- }
329
- snackBarTimeout = setTimeout(function () {
330
- snackBar.className = snackBar.className.replace("show", "");
331
- }, 3000);
332
- }
333
-
334
- hasIdentityProviderLogout(url) {
335
- if (identityProviderLogoutEndpointTimeout != null) {
336
- clearTimeout(identityProviderLogoutEndpointTimeout);
337
- }
338
-
339
- identityProviderLogoutEndpointTimeout = setTimeout(() => {
340
- identityProviderLogoutEndpointTimeout = null;
341
- this.fetchIdentityProviderInfo(url);
342
- }, 200);
343
- }
344
- async fetchIdentityProviderInfo(url) {
345
- const session = getSession();
346
- const idpConfigEndpoint = identityProviderConfigUrl(url);
347
-
348
- return fetchIdentityProviderConfig(idpConfigEndpoint)
349
- .then((result) => {
350
- this.setState({
351
- enableIdpButtons: !!result.end_session_endpoint,
352
- });
353
-
354
- if (result.userinfo_endpoint) {
355
- if (result.userinfo_endpoint.startsWith(NSS_SERVER_URL)) {
356
- const message = `Identity Provider is NSS, but it's support for user information is currently broken - so we can't verify the current \`id_token\` against the identity provider.`;
357
-
358
- this.setState({ idpUserInfo: message });
359
- } else {
360
- session
361
- .fetch(result.userinfo_endpoint)
362
- .then((response) => {
363
- if (response.status !== 200) {
364
- this.setState({
365
- idpUserInfo: `Failed to retrieve userinfo from identity provider, status: ${response.status}`,
366
- });
367
-
368
- return null;
369
- }
370
-
371
- return response.json();
372
- })
373
- .then((result) => {
374
- if (result) {
375
- const loggedInAs = result.sub;
376
- this.setState({
377
- idpUserInfo: `Logged into Identity Provider as user: ${loggedInAs}`,
378
- });
379
- }
380
- })
381
- .catch((error) => {
382
- this.setState({
383
- idpUserInfo: `Not logged into Identity Provider; Error: ${error}`,
384
- });
385
- });
386
- }
387
- } else {
388
- this.setState({
389
- idpUserInfo: `Identity Provider doesn't provide access to currently logged-in user information`,
390
- });
391
- }
392
- })
393
- .catch((error) => {
394
- console.error(
395
- `It appears that [${idpConfigEndpoint}] is not a valid Identity Provider configuration endpoint: ${error}`
396
- );
397
-
398
- this.setState({
399
- enableIdpButtons: false,
400
- idpUserInfo: `Endpoint does appear to be a valid Identity Provider: ${error}`,
401
- });
402
- });
403
- }
404
-
405
- renderLogin() {
406
- return (
407
- <div style={style}>
408
- <div>
409
- <div className="tooltip">
410
- <div>
411
- <span>Login with your Identity Provider:</span>
412
- &nbsp;<i className="fa fa-info-circle"></i>
413
- &nbsp;
414
- </div>
415
-
416
- <span className="tooltiptext">
417
- Your Identity Provider is who you trust to manage your identity.
418
- <p></p>
419
- Hover your mouse over the editbox and click the 'x' on the
420
- right-hand side of the field to clear it, and then use the 'down
421
- arrow' icon to select from various public Identity Provider
422
- options.
423
- </span>
424
- </div>
425
- <input
426
- data-testid="idp_input"
427
- list="preconfigued_idp_list"
428
- type="search"
429
- size="80"
430
- value={this.state.loginIssuer}
431
- onChange={(e) => {
432
- this.setState({ loginIssuer: e.target.value, idpConfig: null });
433
- this.hasIdentityProviderLogout(e.target.value);
434
- }}
435
- />
436
- <datalist id="preconfigued_idp_list">
437
- {preconfiguedIdpList.map((idp) => (
438
- <option value={idp} key={idp} />
439
- ))}
440
- </datalist>
441
- &nbsp;
442
- <button data-testid="idp_login_button" onClick={this.handleLogin}>
443
- Log In
444
- </button>
445
- </div>
446
-
447
- <div className="tooltip">
448
- <div>
449
- <input
450
- type="checkbox"
451
- data-testid="login_reauthorize"
452
- checked={this.state.clearClientRegistrationInfo}
453
- onChange={(e) => {
454
- this.setState({
455
- clearClientRegistrationInfo: e.target.checked,
456
- });
457
- this.displaySnackBar(
458
- e.target.checked
459
- ? "Login will force a re-authorization"
460
- : "Login will use existing authorizations (if any!)"
461
- );
462
- }}
463
- />
464
- <label>Re-authorize this client application on login</label>
465
- &nbsp;<i className="fa fa-info-circle"></i>
466
- </div>
467
-
468
- <span className="tooltiptext">
469
- Re-authorize this Client Application on login.
470
- <p></p>
471
- For example, to change the access permissions you may have already
472
- granted to this application.
473
- </span>
474
- </div>
475
- </div>
476
- );
477
- }
478
-
479
- renderFetchResource() {
480
- return (
481
- <div style={style}>
482
- <form>
483
- <strong>Resource: </strong>
484
- <input
485
- data-testid="fetch_uri_textbox"
486
- size="80"
487
- type="text"
488
- value={this.state.fetchRoute}
489
- onChange={(e) => this.setState({ fetchRoute: e.target.value })}
490
- />
491
- <button data-testid="fetch_button" onClick={this.handleFetch}>
492
- Fetch
493
- </button>
494
- </form>
495
-
496
- {this.state.fetchLoading ? (
497
- <span>Loading...</span>
498
- ) : (
499
- <pre
500
- data-testid="fetch_response_textbox"
501
- style={{ whiteSpace: "pre-wrap", overflowWrap: "anywhere" }}
502
- >
503
- {this.state.fetchBody || "not fetched"}
504
- </pre>
505
- )}
506
- </div>
507
- );
508
- }
509
-
510
- renderUserInfo() {
511
- const session = getSession();
512
- console.log(`Current logged in state: [${session.info.isLoggedIn}]`);
513
-
514
- return (
515
- <>
516
- <div style={style}>
517
- <div>
518
- <p>
519
- UserInfo:{" "}
520
- <span className="tooltip">
521
- <i className="fa fa-info-circle"></i>
522
- <span className="tooltiptext">
523
- Information on the currently logged-in user (if logged in!)
524
- from the 'UserInfo' endpoint of the Identity Provider.
525
- </span>
526
- </span>
527
- </p>
528
- <pre>
529
- <code id="idp_userinfo_text">{this.state.idpUserInfo}</code>
530
- </pre>
531
- </div>
532
- </div>
533
- <div style={style}>
534
- <h2>Identity Provider</h2>
535
-
536
- <div className="tooltip">
537
- <div>
538
- {/*<a target="_blank" href={this.state.loginIssuer}>*/}
539
- {/* {this.state.loginIssuer}*/}
540
- {/*</a>*/}
541
- <button
542
- onClick={this.handleOpenIdentityProvider}
543
- disabled={!this.state.enableIdpButtons}
544
- >
545
- Open Identity Provider Popup
546
- </button>
547
- &nbsp;<i className="fa fa-info-circle"></i>
548
- &nbsp;
549
- </div>
550
-
551
- <span className="tooltiptext">
552
- Allows you to see authorizations you've granted, and to log out
553
- (maybe you'd like to log in again using a different account).
554
- </span>
555
- </div>
556
-
557
- <div className="tooltip">
558
- <div>
559
- <button
560
- onClick={this.handleLogoutIdentityProvider}
561
- disabled={!this.state.enableIdpButtons}
562
- >
563
- Logout from Identity Provider
564
- </button>
565
- &nbsp;<i className="fa fa-info-circle"></i>
566
- &nbsp;
567
- </div>
568
-
569
- <span className="tooltiptext">
570
- Jump to 'Logout' endpoint for currently entered Identity Provider.
571
- <p></p>
572
- NOTE: This button is only enabled if the currently entered
573
- Identity Provider exposes an 'end_session_endpoint' value at: [
574
- {identityProviderConfigUrl(this.state.loginIssuer)}]
575
- </span>
576
- </div>
577
-
578
- <div className="tooltip">
579
- <button onClick={this.handleFetchIdentityProviderConfig}>
580
- Fetch Config from Identity Provider
581
- </button>
582
- </div>
583
-
584
- {this.state.idpConfig && (
585
- <div>
586
- <h2>IdP Config:</h2>
587
- <pre>
588
- <code>{this.state.idpConfig}</code>
589
- </pre>
590
- </div>
591
- )}
592
- </div>
593
- </>
594
- );
595
- }
596
-
597
- renderPopupMessage() {
598
- return (
599
- <>
600
- <h1>Popup Redirected</h1>
601
- <p>Will automatically close in 2 seconds</p>
602
- </>
603
- );
604
- }
605
- renderDashboard(session) {
606
- const webId = extractWebIdComponents(session.info.webId);
607
- return (
608
- <div>
609
- <div style={style}>
610
- <h2>Authenticated! Ready to browse...</h2>
611
- <p>
612
- <strong>Session Provider:</strong>{" "}
613
- <code>{this.state.loginIssuer}</code>
614
- </p>
615
- <p>
616
- <strong>WebID:</strong>{" "}
617
- <code>
618
- {webId.prefix}
619
- <span style={{ color: "darkblue" }}>
620
- <strong>{webId.identifier}</strong>
621
- </span>
622
- {webId.suffix}
623
- </code>
624
- </p>
625
- <div className="tooltip">
626
- <form>
627
- <button
628
- onClick={this.handleLogout}
629
- disabled={!session.info.isLoggedIn}
630
- >
631
- Log Out
632
- </button>
633
- &nbsp;<i className="fa fa-info-circle"></i>
634
- </form>
635
- <span className="tooltiptext">
636
- Log out of this client application.
637
- <br />
638
- <br />
639
- NOTE: This button is only enabled if you are currently logged in.
640
- </span>
641
- </div>
642
- </div>
643
-
644
- {this.renderFetchResource()}
645
-
646
- {this.renderUserInfo()}
647
- </div>
648
- );
649
- }
650
-
651
- renderUI() {
652
- switch (this.state.status) {
653
- case "popup":
654
- return this.renderPopupMessage();
655
- case "loading":
656
- return <h1>Loading...</h1>;
657
- case "login":
658
- return (
659
- <>
660
- {this.renderLogin()}
661
- {this.renderFetchResource()}
662
- </>
663
- );
664
- case "dashboard":
665
- return this.renderDashboard(getSession());
666
- default:
667
- return (
668
- <p>Something seems to have gone wrong, please reload the page</p>
669
- );
670
- }
671
- }
672
-
673
- render() {
674
- return (
675
- <>
676
- <h1>{clientApplicationName}</h1>
677
- <p>
678
- Status: <code data-testid="app-status">{this.state.status}</code>
679
- </p>
680
- {this.renderUI()}
681
- </>
682
- );
683
- }
684
- }
685
-
686
- export default DemoClientApp;