@inrupt/solid-client-authn-browser 1.16.0 → 1.17.1

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 (141) hide show
  1. package/dist/ClientAuthentication.d.ts +4 -13
  2. package/dist/Session.d.ts +4 -4
  3. package/dist/dependencies.d.ts +1 -1
  4. package/dist/index.js +773 -28
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +746 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/login/oidc/AggregateOidcHandler.d.ts +2 -1
  9. package/dist/login/oidc/AggregateRedirectHandler.d.ts +2 -1
  10. package/dist/login/oidc/ClientRegistrar.d.ts +1 -1
  11. package/dist/login/oidc/IssuerConfigFetcher.d.ts +1 -1
  12. package/dist/login/oidc/OidcLoginHandler.d.ts +1 -1
  13. package/dist/login/oidc/Redirector.d.ts +1 -1
  14. package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.d.ts +3 -6
  15. package/dist/login/oidc/incomingRedirectHandler/ErrorOidcHandler.d.ts +1 -1
  16. package/dist/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.d.ts +1 -1
  17. package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.d.ts +3 -6
  18. package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.d.ts +1 -1
  19. package/dist/login/oidc/refresh/TokenRefresher.d.ts +2 -2
  20. package/dist/logout/buildRpInitiatedLogout.d.ts +2 -0
  21. package/dist/sessionInfo/SessionInfoManager.d.ts +4 -13
  22. package/dist/solid-client-authn.bundle.js +32 -2
  23. package/dist/solid-client-authn.bundle.js.map +1 -0
  24. package/dist/storage/BrowserStorage.d.ts +1 -1
  25. package/dist/storage/StorageUtility.d.ts +2 -1
  26. package/package.json +17 -17
  27. package/rollup.config.mjs +46 -0
  28. package/src/ClientAuthentication.spec.ts +4 -4
  29. package/src/ClientAuthentication.ts +8 -45
  30. package/src/Session.spec.ts +4 -4
  31. package/src/Session.ts +44 -13
  32. package/src/__mocks__/ClientAuthentication.ts +3 -3
  33. package/src/constant.ts +1 -1
  34. package/src/defaultSession.spec.ts +1 -1
  35. package/src/defaultSession.ts +5 -3
  36. package/src/dependencies.node.spec.ts +1 -1
  37. package/src/dependencies.spec.ts +1 -1
  38. package/src/dependencies.ts +10 -5
  39. package/src/index.browser.spec.ts +1 -1
  40. package/src/index.browser.ts +1 -1
  41. package/src/index.spec.ts +1 -1
  42. package/src/index.ts +1 -1
  43. package/src/login/__mocks__/LoginHandler.ts +2 -2
  44. package/src/login/oidc/AggregateOidcHandler.spec.ts +3 -5
  45. package/src/login/oidc/AggregateOidcHandler.ts +3 -3
  46. package/src/login/oidc/AggregateRedirectHandler.ts +3 -3
  47. package/src/login/oidc/ClientRegistrar.spec.ts +1 -1
  48. package/src/login/oidc/ClientRegistrar.ts +2 -2
  49. package/src/login/oidc/IssuerConfigFetcher.spec.ts +8 -4
  50. package/src/login/oidc/IssuerConfigFetcher.ts +12 -5
  51. package/src/login/oidc/OidcLoginHandler.spec.ts +3 -5
  52. package/src/login/oidc/OidcLoginHandler.ts +5 -3
  53. package/src/login/oidc/Redirector.spec.ts +1 -1
  54. package/src/login/oidc/Redirector.ts +2 -2
  55. package/src/login/oidc/__mocks__/ClientRegistrar.ts +2 -2
  56. package/src/login/oidc/__mocks__/IOidcHandler.ts +2 -2
  57. package/src/login/oidc/__mocks__/IOidcOptions.ts +2 -2
  58. package/src/login/oidc/__mocks__/IssuerConfigFetcher.ts +2 -2
  59. package/src/login/oidc/__mocks__/Redirector.ts +2 -2
  60. package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.spec.ts +37 -39
  61. package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.ts +31 -20
  62. package/src/login/oidc/incomingRedirectHandler/ErrorOidcHandler.spec.ts +3 -4
  63. package/src/login/oidc/incomingRedirectHandler/ErrorOidcHandler.ts +3 -3
  64. package/src/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.spec.ts +3 -4
  65. package/src/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.ts +2 -2
  66. package/src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.spec.ts +3 -3
  67. package/src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.ts +13 -51
  68. package/src/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.ts +2 -2
  69. package/src/login/oidc/refresh/TokenRefresher.spec.ts +7 -6
  70. package/src/login/oidc/refresh/TokenRefresher.ts +6 -4
  71. package/src/login/oidc/refresh/__mocks__/TokenRefresher.ts +2 -2
  72. package/src/logout/{GeneralLogoutHandler.ts → buildRpInitiatedLogout.ts} +21 -20
  73. package/src/sessionInfo/SessionInfoManager.spec.ts +2 -2
  74. package/src/sessionInfo/SessionInfoManager.ts +13 -91
  75. package/src/sessionInfo/__mocks__/SessionInfoManager.ts +2 -2
  76. package/src/storage/BrowserStorage.spec.ts +1 -1
  77. package/src/storage/BrowserStorage.ts +2 -2
  78. package/src/storage/StorageUtility.ts +3 -2
  79. package/src/storage/__mocks__/LocalStorage.ts +1 -1
  80. package/src/util/UUIDGenerator.spec.ts +1 -1
  81. package/src/util/UuidGenerator.ts +1 -1
  82. package/src/util/__mocks__/UuidGenerator.ts +2 -2
  83. package/dist/ClientAuthentication.js +0 -80
  84. package/dist/ClientAuthentication.js.map +0 -1
  85. package/dist/Session.js +0 -150
  86. package/dist/Session.js.map +0 -1
  87. package/dist/constant.js +0 -7
  88. package/dist/constant.js.map +0 -1
  89. package/dist/defaultSession.js +0 -52
  90. package/dist/defaultSession.js.map +0 -1
  91. package/dist/dependencies.js +0 -41
  92. package/dist/dependencies.js.map +0 -1
  93. package/dist/index.browser.js +0 -28
  94. package/dist/index.browser.js.map +0 -1
  95. package/dist/login/oidc/AggregateOidcHandler.js +0 -10
  96. package/dist/login/oidc/AggregateOidcHandler.js.map +0 -1
  97. package/dist/login/oidc/AggregateRedirectHandler.js +0 -10
  98. package/dist/login/oidc/AggregateRedirectHandler.js.map +0 -1
  99. package/dist/login/oidc/ClientRegistrar.js +0 -47
  100. package/dist/login/oidc/ClientRegistrar.js.map +0 -1
  101. package/dist/login/oidc/IssuerConfigFetcher.js +0 -124
  102. package/dist/login/oidc/IssuerConfigFetcher.js.map +0 -1
  103. package/dist/login/oidc/OidcLoginHandler.js +0 -40
  104. package/dist/login/oidc/OidcLoginHandler.js.map +0 -1
  105. package/dist/login/oidc/Redirector.js +0 -17
  106. package/dist/login/oidc/Redirector.js.map +0 -1
  107. package/dist/login/oidc/__mocks__/IOidcOptions.d.ts +0 -2
  108. package/dist/login/oidc/__mocks__/IOidcOptions.js +0 -25
  109. package/dist/login/oidc/__mocks__/IOidcOptions.js.map +0 -1
  110. package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.js +0 -91
  111. package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.js.map +0 -1
  112. package/dist/login/oidc/incomingRedirectHandler/ErrorOidcHandler.js +0 -26
  113. package/dist/login/oidc/incomingRedirectHandler/ErrorOidcHandler.js.map +0 -1
  114. package/dist/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.js +0 -20
  115. package/dist/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.js.map +0 -1
  116. package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.js +0 -56
  117. package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.js.map +0 -1
  118. package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.js +0 -47
  119. package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.js.map +0 -1
  120. package/dist/login/oidc/refresh/TokenRefresher.js +0 -31
  121. package/dist/login/oidc/refresh/TokenRefresher.js.map +0 -1
  122. package/dist/logout/GeneralLogoutHandler.d.ts +0 -7
  123. package/dist/logout/GeneralLogoutHandler.js +0 -15
  124. package/dist/logout/GeneralLogoutHandler.js.map +0 -1
  125. package/dist/sessionInfo/SessionInfoManager.js +0 -96
  126. package/dist/sessionInfo/SessionInfoManager.js.map +0 -1
  127. package/dist/solid-client-authn.bundle.js.LICENSE.txt +0 -17
  128. package/dist/storage/BrowserStorage.js +0 -18
  129. package/dist/storage/BrowserStorage.js.map +0 -1
  130. package/dist/storage/StorageUtility.js +0 -10
  131. package/dist/storage/StorageUtility.js.map +0 -1
  132. package/dist/util/UuidGenerator.js +0 -10
  133. package/dist/util/UuidGenerator.js.map +0 -1
  134. package/licenses.csv +0 -147
  135. package/src/logout/GeneralLogoutHandler.spec.ts +0 -72
  136. package/src/logout/__mocks__/LogoutHandler.ts +0 -38
  137. package/webpack.browser.js +0 -39
  138. package/webpack.common.js +0 -42
  139. package/webpack.config.js +0 -28
  140. package/webpack.dev.js +0 -37
  141. package/webpack.prod.js +0 -23
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -27,13 +27,14 @@
27
27
  /**
28
28
  * Handler for the Authorization Code with PKCE Flow
29
29
  */
30
- import {
30
+ import type {
31
31
  IOidcHandler,
32
32
  IOidcOptions,
33
- IRedirector,
34
- IStorageUtility,
35
33
  LoginResult,
34
+ } from "@inrupt/solid-client-authn-core";
35
+ import {
36
36
  DEFAULT_SCOPES,
37
+ AuthorizationCodeWithPkceOidcHandlerBase,
37
38
  } from "@inrupt/solid-client-authn-core";
38
39
  import { OidcClient } from "@inrupt/oidc-client-ext";
39
40
 
@@ -43,22 +44,9 @@ import { OidcClient } from "@inrupt/oidc-client-ext";
43
44
  * PKCE: https://tools.ietf.org/html/rfc7636
44
45
  */
45
46
  export default class AuthorizationCodeWithPkceOidcHandler
47
+ extends AuthorizationCodeWithPkceOidcHandlerBase
46
48
  implements IOidcHandler
47
49
  {
48
- constructor(
49
- private storageUtility: IStorageUtility,
50
- private redirector: IRedirector
51
- ) {}
52
-
53
- async canHandle(oidcLoginOptions: IOidcOptions): Promise<boolean> {
54
- return !!(
55
- oidcLoginOptions.issuerConfiguration.grantTypesSupported &&
56
- oidcLoginOptions.issuerConfiguration.grantTypesSupported.indexOf(
57
- "authorization_code"
58
- ) > -1
59
- );
60
- }
61
-
62
50
  async handle(oidcLoginOptions: IOidcOptions): Promise<LoginResult> {
63
51
  /* eslint-disable camelcase */
64
52
  const oidcOptions = {
@@ -81,42 +69,16 @@ export default class AuthorizationCodeWithPkceOidcHandler
81
69
 
82
70
  const oidcClientLibrary = new OidcClient(oidcOptions);
83
71
 
84
- const { redirector } = this;
85
- const storage = this.storageUtility;
86
-
87
72
  try {
88
73
  const signingRequest = await oidcClientLibrary.createSigninRequest();
89
- await Promise.all([
90
- // We use the OAuth 'state' value (which should be crypto-random) as
91
- // the key in our storage to store our actual SessionID. We do this
92
- // 'cos we'll need to lookup our session information again when the
93
- // browser is redirected back to us (i.e. the OAuth client
94
- // application) from the Authorization Server.
95
- // We don't want to use our session ID as the OAuth 'state' value, as
96
- // that session ID can be any developer-specified value, and therefore
97
- // may not be appropriate (since the OAuth 'state' value should really
98
- // be an unguessable crypto-random value).
74
+ // Make sure to await the promise before returning so that the error is caught.
75
+ return await this.handleRedirect({
76
+ oidcLoginOptions,
99
77
  // eslint-disable-next-line no-underscore-dangle
100
- storage.setForUser(signingRequest.state._id, {
101
- sessionId: oidcLoginOptions.sessionId,
102
- }),
103
-
104
- // Store our login-process state using the session ID as the key.
105
- // Strictly speaking, this indirection from our OAuth state value to
106
- // our session ID is unnecessary, but it provides a slightly cleaner
107
- // separation of concerns.
108
- storage.setForUser(oidcLoginOptions.sessionId, {
109
- // eslint-disable-next-line no-underscore-dangle
110
- codeVerifier: signingRequest.state._code_verifier,
111
- issuer: oidcLoginOptions.issuer.toString(),
112
- // The redirect URL is read after redirect, so it must be stored now.
113
- redirectUrl: oidcLoginOptions.redirectUrl,
114
- dpop: oidcLoginOptions.dpop ? "true" : "false",
115
- }),
116
- ]);
117
-
118
- redirector.redirect(signingRequest.url.toString(), {
119
- handleRedirect: oidcLoginOptions.handleRedirect,
78
+ state: signingRequest.state._id,
79
+ // eslint-disable-next-line no-underscore-dangle
80
+ codeVerifier: signingRequest.state._code_verifier,
81
+ targetUrl: signingRequest.url.toString(),
120
82
  });
121
83
  } catch (err: unknown) {
122
84
  // eslint-disable-next-line no-console
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -19,7 +19,7 @@
19
19
  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
  //
21
21
 
22
- import { IOidcOptions } from "@inrupt/solid-client-authn-core";
22
+ import type { IOidcOptions } from "@inrupt/solid-client-authn-core";
23
23
  import { standardOidcOptions } from "../__mocks__/IOidcOptions";
24
24
 
25
25
  const canHandleTests: {
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -20,19 +20,20 @@
20
20
  //
21
21
 
22
22
  import { jest, it, describe, expect } from "@jest/globals";
23
- import {
24
- EVENTS,
23
+ import type {
25
24
  KeyPair,
26
25
  TokenEndpointResponse,
27
26
  } from "@inrupt/solid-client-authn-core";
27
+ import { EVENTS } from "@inrupt/solid-client-authn-core";
28
28
  import {
29
29
  StorageUtilityMock,
30
30
  mockStorageUtility,
31
31
  } from "@inrupt/solid-client-authn-core/mocks";
32
- import { JWK, importJWK } from "jose";
33
- import { refresh } from "@inrupt/oidc-client-ext";
32
+ import type { JWK } from "jose";
33
+ import { importJWK } from "jose";
34
+ import type { refresh } from "@inrupt/oidc-client-ext";
34
35
  import { EventEmitter } from "events";
35
- import { KeyObject } from "crypto";
36
+ import type { KeyObject } from "crypto";
36
37
  import TokenRefresher from "./TokenRefresher";
37
38
  import {
38
39
  mockDefaultIssuerConfigFetcher,
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -24,19 +24,21 @@
24
24
  * @packageDocumentation
25
25
  */
26
26
 
27
- import {
27
+ import type {
28
28
  IClient,
29
29
  IClientRegistrar,
30
30
  IIssuerConfigFetcher,
31
31
  IStorageUtility,
32
- loadOidcContextFromStorage,
33
32
  KeyPair,
34
33
  ITokenRefresher,
35
34
  TokenEndpointResponse,
35
+ } from "@inrupt/solid-client-authn-core";
36
+ import {
37
+ loadOidcContextFromStorage,
36
38
  EVENTS,
37
39
  } from "@inrupt/solid-client-authn-core";
38
40
  import { refresh } from "@inrupt/oidc-client-ext";
39
- import { EventEmitter } from "events";
41
+ import type { EventEmitter } from "events";
40
42
 
41
43
  // Some identifiers are not in camelcase on purpose, as they are named using the
42
44
  // official names from the OIDC/OAuth2 specifications.
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -20,7 +20,7 @@
20
20
  //
21
21
 
22
22
  import { jest } from "@jest/globals";
23
- import {
23
+ import type {
24
24
  ITokenRefresher,
25
25
  TokenEndpointResponse,
26
26
  } from "@inrupt/solid-client-authn-core";
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -18,28 +18,29 @@
18
18
  // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19
19
  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
  //
21
-
22
- /**
23
- * @hidden
24
- * @packageDocumentation
25
- */
26
-
27
- import {
28
- ILogoutHandler,
29
- ISessionInfoManager,
21
+ import type {
22
+ IEndSessionOptions,
23
+ IRpLogoutOptions,
30
24
  } from "@inrupt/solid-client-authn-core";
25
+ import { getEndSessionUrl } from "@inrupt/solid-client-authn-core";
31
26
 
32
27
  /**
28
+ * @param options.endSessionEndpoint The end_session_endpoint advertised by the server
29
+ * @param options.idTokenHint The idToken supplied by the server after logging in
30
+ * Redirects the window to the location required to perform RP initiated logout
31
+ *
33
32
  * @hidden
34
33
  */
35
- export default class GeneralLogoutHandler implements ILogoutHandler {
36
- constructor(private sessionInfoManager: ISessionInfoManager) {}
37
-
38
- async canHandle(): Promise<boolean> {
39
- return true;
40
- }
41
-
42
- async handle(userId: string): Promise<void> {
43
- await this.sessionInfoManager.clear(userId);
44
- }
34
+ export function buildRpInitiatedLogout({
35
+ endSessionEndpoint,
36
+ idTokenHint,
37
+ }: Omit<IEndSessionOptions, keyof IRpLogoutOptions>) {
38
+ return function logout({ state, postLogoutUrl }: IRpLogoutOptions) {
39
+ window.location.href = getEndSessionUrl({
40
+ endSessionEndpoint,
41
+ idTokenHint,
42
+ state,
43
+ postLogoutRedirectUri: postLogoutUrl,
44
+ });
45
+ };
45
46
  }
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -24,10 +24,10 @@ import {
24
24
  StorageUtility,
25
25
  mockStorage,
26
26
  } from "@inrupt/solid-client-authn-core";
27
+ import { mockLogoutHandler } from "@inrupt/solid-client-authn-core/mocks";
27
28
  import { jest, it, describe, expect } from "@jest/globals";
28
29
 
29
30
  import { UuidGeneratorMock } from "../util/__mocks__/UuidGenerator";
30
- import { mockLogoutHandler } from "../logout/__mocks__/LogoutHandler";
31
31
  import { SessionInfoManager } from "./SessionInfoManager";
32
32
 
33
33
  const mockClearFunction = jest.fn();
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -24,27 +24,20 @@
24
24
  * @packageDocumentation
25
25
  */
26
26
 
27
- import {
27
+ import type {
28
28
  ISessionInfo,
29
29
  ISessionInfoManager,
30
30
  ISessionInternalInfo,
31
- ISessionInfoManagerOptions,
32
31
  IStorageUtility,
32
+ } from "@inrupt/solid-client-authn-core";
33
+ import {
33
34
  isSupportedTokenType,
35
+ clear as clearBase,
36
+ SessionInfoManagerBase,
34
37
  } from "@inrupt/solid-client-authn-core";
35
- import { v4 } from "uuid";
36
38
  import { clearOidcPersistentStorage } from "@inrupt/oidc-client-ext";
37
- import { fetch } from "@inrupt/universal-fetch";
38
-
39
- export function getUnauthenticatedSession(): ISessionInfo & {
40
- fetch: typeof fetch;
41
- } {
42
- return {
43
- isLoggedIn: false,
44
- sessionId: v4(),
45
- fetch,
46
- };
47
- }
39
+
40
+ export { getUnauthenticatedSession } from "@inrupt/solid-client-authn-core";
48
41
 
49
42
  /**
50
43
  * @param sessionId
@@ -55,60 +48,17 @@ export async function clear(
55
48
  sessionId: string,
56
49
  storage: IStorageUtility
57
50
  ): Promise<void> {
58
- await Promise.all([
59
- storage.deleteAllUserData(sessionId, { secure: false }),
60
- storage.deleteAllUserData(sessionId, { secure: true }),
61
- // FIXME: This is needed until the DPoP key is stored safely
62
- storage.delete("clientKey", { secure: false }),
63
- ]);
51
+ await clearBase(sessionId, storage);
64
52
  await clearOidcPersistentStorage();
65
53
  }
66
54
 
67
55
  /**
68
56
  * @hidden
69
57
  */
70
- export class SessionInfoManager implements ISessionInfoManager {
71
- constructor(private storageUtility: IStorageUtility) {}
72
-
73
- // eslint-disable-next-line class-methods-use-this
74
- update(
75
- _sessionId: string,
76
- _options: ISessionInfoManagerOptions
77
- ): Promise<void> {
78
- // const localUserId: string = options.localUserId || this.uuidGenerator.v4();
79
- // if (options.loggedIn) {
80
- // return {
81
- // sessionId,
82
- // loggedIn: true,
83
- // webId: options.webId as string,
84
- // neededAction: options.neededAction || { actionType: "inaction" },
85
- // state: options.state,
86
- // logout: async (): Promise<void> => {
87
- // // TODO: handle if webid isn't here
88
- // return this.logoutHandler.handle(localUserId);
89
- // },
90
- // fetch: (url: RequestInfo, init?: RequestInit): Promise<Response> => {
91
- // // TODO: handle if webid isn't here
92
- // return this.authenticatedFetcher.handle(
93
- // {
94
- // localUserId,
95
- // type: "dpop"
96
- // },
97
- // url,
98
- // init
99
- // );
100
- // }
101
- // };
102
- // } else {
103
- // return {
104
- // localUserId,
105
- // loggedIn: false,
106
- // neededAction: options.neededAction || { actionType: "inaction" }
107
- // };
108
- // }
109
- throw new Error("Not Implemented");
110
- }
111
-
58
+ export class SessionInfoManager
59
+ extends SessionInfoManagerBase
60
+ implements ISessionInfoManager
61
+ {
112
62
  async get(
113
63
  sessionId: string
114
64
  ): Promise<(ISessionInfo & ISessionInternalInfo) | undefined> {
@@ -191,11 +141,6 @@ export class SessionInfoManager implements ISessionInfoManager {
191
141
  };
192
142
  }
193
143
 
194
- // eslint-disable-next-line class-methods-use-this
195
- async getAll(): Promise<(ISessionInfo & ISessionInternalInfo)[]> {
196
- throw new Error("Not implemented");
197
- }
198
-
199
144
  /**
200
145
  * This function removes all session-related information from storage.
201
146
  * @param sessionId the session identifier
@@ -205,27 +150,4 @@ export class SessionInfoManager implements ISessionInfoManager {
205
150
  async clear(sessionId: string): Promise<void> {
206
151
  return clear(sessionId, this.storageUtility);
207
152
  }
208
-
209
- /**
210
- * Registers a new session, so that its ID can be retrieved.
211
- * @param sessionId
212
- */
213
- async register(_sessionId: string): Promise<void> {
214
- throw new Error("Not implemented");
215
- }
216
-
217
- /**
218
- * Returns all the registered session IDs. Differs from getAll, which also
219
- * returns additional session information.
220
- */
221
- async getRegisteredSessionIdAll(): Promise<string[]> {
222
- throw new Error("Not implemented");
223
- }
224
-
225
- /**
226
- * Deletes all information about all sessions, including their registrations.
227
- */
228
- async clearAll(): Promise<void> {
229
- throw new Error("Not implemented");
230
- }
231
153
  }
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -19,7 +19,7 @@
19
19
  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
  //
21
21
 
22
- import {
22
+ import type {
23
23
  ISessionInfo,
24
24
  ISessionInfoManager,
25
25
  ISessionInfoManagerOptions,
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -24,7 +24,7 @@
24
24
  * @packageDocumentation
25
25
  */
26
26
 
27
- import { IStorage } from "@inrupt/solid-client-authn-core";
27
+ import type { IStorage } from "@inrupt/solid-client-authn-core";
28
28
 
29
29
  /**
30
30
  * @hidden
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -27,7 +27,8 @@
27
27
  /**
28
28
  * A helper class that will validate items taken from local storage
29
29
  */
30
- import { IStorage, StorageUtility } from "@inrupt/solid-client-authn-core";
30
+ import type { IStorage } from "@inrupt/solid-client-authn-core";
31
+ import { StorageUtility } from "@inrupt/solid-client-authn-core";
31
32
 
32
33
  /**
33
34
  * This class in a no-value-added extension of StorageUtility from the core module.
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -1,5 +1,5 @@
1
1
  //
2
- // Copyright 2022 Inrupt Inc.
2
+ // Copyright Inrupt Inc.
3
3
  //
4
4
  // Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  // of this software and associated documentation files (the "Software"), to deal in
@@ -20,7 +20,7 @@
20
20
  //
21
21
 
22
22
  import { jest } from "@jest/globals";
23
- import { IUuidGenerator } from "../UuidGenerator";
23
+ import type { IUuidGenerator } from "../UuidGenerator";
24
24
 
25
25
  export const UuidGeneratorMockResponse = "fee3fa53-a6a9-475c-a0da-b1343a4fff76";
26
26
 
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const solid_client_authn_core_1 = require("@inrupt/solid-client-authn-core");
4
- const universal_fetch_1 = require("@inrupt/universal-fetch");
5
- const oidc_client_ext_1 = require("@inrupt/oidc-client-ext");
6
- const globalFetch = (request, init) => (0, universal_fetch_1.fetch)(request, init);
7
- class ClientAuthentication {
8
- constructor(loginHandler, redirectHandler, logoutHandler, sessionInfoManager, issuerConfigFetcher) {
9
- this.loginHandler = loginHandler;
10
- this.redirectHandler = redirectHandler;
11
- this.logoutHandler = logoutHandler;
12
- this.sessionInfoManager = sessionInfoManager;
13
- this.issuerConfigFetcher = issuerConfigFetcher;
14
- this.login = async (options, eventEmitter) => {
15
- var _a, _b;
16
- await this.sessionInfoManager.clear(options.sessionId);
17
- const redirectUrl = (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : (0, oidc_client_ext_1.removeOidcQueryParam)(window.location.href);
18
- if (!(0, solid_client_authn_core_1.isValidRedirectUrl)(redirectUrl)) {
19
- throw new Error(`${redirectUrl} is not a valid redirect URL, it is either a malformed IRI or it includes a hash fragment.`);
20
- }
21
- await this.loginHandler.handle({
22
- ...options,
23
- redirectUrl,
24
- clientName: (_b = options.clientName) !== null && _b !== void 0 ? _b : options.clientId,
25
- eventEmitter,
26
- });
27
- };
28
- this.fetch = globalFetch;
29
- this.logout = async (sessionId) => {
30
- await this.logoutHandler.handle(sessionId);
31
- this.fetch = globalFetch;
32
- };
33
- this.getSessionInfo = async (sessionId) => {
34
- return this.sessionInfoManager.get(sessionId);
35
- };
36
- this.getAllSessionInfo = async () => {
37
- return this.sessionInfoManager.getAll();
38
- };
39
- this.validateCurrentSession = async (currentSessionId) => {
40
- const sessionInfo = await this.sessionInfoManager.get(currentSessionId);
41
- if (sessionInfo === undefined ||
42
- sessionInfo.clientAppId === undefined ||
43
- sessionInfo.issuer === undefined) {
44
- return null;
45
- }
46
- return sessionInfo;
47
- };
48
- this.handleIncomingRedirect = async (url, eventEmitter) => {
49
- try {
50
- const redirectInfo = await this.redirectHandler.handle(url, eventEmitter);
51
- this.fetch = redirectInfo.fetch.bind(window);
52
- this.cleanUrlAfterRedirect(url);
53
- return {
54
- isLoggedIn: redirectInfo.isLoggedIn,
55
- webId: redirectInfo.webId,
56
- sessionId: redirectInfo.sessionId,
57
- expirationDate: redirectInfo.expirationDate,
58
- };
59
- }
60
- catch (err) {
61
- this.cleanUrlAfterRedirect(url);
62
- eventEmitter.emit(solid_client_authn_core_1.EVENTS.ERROR, "redirect", err);
63
- return undefined;
64
- }
65
- };
66
- }
67
- cleanUrlAfterRedirect(url) {
68
- const cleanedUpUrl = new URL(url);
69
- cleanedUpUrl.searchParams.delete("state");
70
- cleanedUpUrl.searchParams.delete("code");
71
- cleanedUpUrl.searchParams.delete("id_token");
72
- cleanedUpUrl.searchParams.delete("access_token");
73
- cleanedUpUrl.searchParams.delete("error");
74
- cleanedUpUrl.searchParams.delete("error_description");
75
- cleanedUpUrl.searchParams.delete("iss");
76
- window.history.replaceState(null, "", cleanedUpUrl.toString());
77
- }
78
- }
79
- exports.default = ClientAuthentication;
80
- //# sourceMappingURL=ClientAuthentication.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClientAuthentication.js","sourceRoot":"","sources":["../src/ClientAuthentication.ts"],"names":[],"mappings":";;AA0BA,6EAWyC;AACzC,6DAAgD;AAChD,6DAA+D;AAM/D,MAAM,WAAW,GAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,IAAA,uBAAK,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAK1E,MAAqB,oBAAoB;IACvC,YACU,YAA2B,EAC3B,eAAyC,EACzC,aAA6B,EAC7B,kBAAuC,EACvC,mBAAyC;QAJzC,iBAAY,GAAZ,YAAY,CAAe;QAC3B,oBAAe,GAAf,eAAe,CAA0B;QACzC,kBAAa,GAAb,aAAa,CAAgB;QAC7B,uBAAkB,GAAlB,kBAAkB,CAAqB;QACvC,wBAAmB,GAAnB,mBAAmB,CAAsB;QAKnD,UAAK,GAAG,KAAK,EACX,OAAsB,EACtB,YAA0B,EACX,EAAE;;YAOjB,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAA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