@inrupt/solid-client-authn-browser 1.17.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.
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/solid-client-authn.bundle.js +2 -2
- package/dist/solid-client-authn.bundle.js.map +1 -1
- package/package.json +4 -4
- package/src/login/oidc/IssuerConfigFetcher.ts +5 -2
- package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.ts +14 -7
package/dist/index.js
CHANGED
|
@@ -250,7 +250,7 @@ class IssuerConfigFetcher {
|
|
|
250
250
|
async fetchConfig(issuer) {
|
|
251
251
|
let issuerConfig;
|
|
252
252
|
const openIdConfigUrl = new URL(WELL_KNOWN_OPENID_CONFIG, issuer.endsWith("/") ? issuer : `${issuer}/`).href;
|
|
253
|
-
const issuerConfigRequestBody = await universalFetch.fetch(openIdConfigUrl);
|
|
253
|
+
const issuerConfigRequestBody = await universalFetch.fetch.call(globalThis, openIdConfigUrl);
|
|
254
254
|
try {
|
|
255
255
|
issuerConfig = processConfig(await issuerConfigRequestBody.json());
|
|
256
256
|
}
|
|
@@ -334,6 +334,7 @@ class FallbackRedirectHandler {
|
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
const globalFetch = (...args) => universalFetch.fetch.call(globalThis, ...args);
|
|
337
338
|
class AuthCodeRedirectHandler {
|
|
338
339
|
constructor(storageUtility, sessionInfoManager, issuerConfigFetcher, clientRegistrar, tokerRefresher) {
|
|
339
340
|
this.storageUtility = storageUtility;
|
|
@@ -395,7 +396,7 @@ class AuthCodeRedirectHandler {
|
|
|
395
396
|
tokenRefresher: this.tokerRefresher,
|
|
396
397
|
};
|
|
397
398
|
}
|
|
398
|
-
const authFetch = await solidClientAuthnCore.buildAuthenticatedFetch(
|
|
399
|
+
const authFetch = await solidClientAuthnCore.buildAuthenticatedFetch(globalFetch, tokens.accessToken, {
|
|
399
400
|
dpopKey: tokens.dpopKey,
|
|
400
401
|
refreshOptions,
|
|
401
402
|
eventEmitter,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/storage/StorageUtility.ts","../src/ClientAuthentication.ts","../src/login/oidc/OidcLoginHandler.ts","../src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.ts","../src/login/oidc/IssuerConfigFetcher.ts","../src/sessionInfo/SessionInfoManager.ts","../src/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.ts","../src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.ts","../src/login/oidc/AggregateRedirectHandler.ts","../src/storage/BrowserStorage.ts","../src/login/oidc/Redirector.ts","../src/login/oidc/ClientRegistrar.ts","../src/login/oidc/incomingRedirectHandler/ErrorOidcHandler.ts","../src/login/oidc/refresh/TokenRefresher.ts","../src/dependencies.ts","../src/constant.ts","../src/Session.ts","../src/defaultSession.ts"],"sourcesContent":["//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * A helper class that will validate items taken from local storage\n */\nimport type { IStorage } from \"@inrupt/solid-client-authn-core\";\nimport { StorageUtility } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * This class in a no-value-added extension of StorageUtility from the core module.\n * The reason it has to be declared is for TSyringe to find the decorators in the\n * same modules as where the dependency container is declared (in this case,\n * the browser module, with the dependancy container in dependencies.ts).\n * @hidden\n */\nexport default class StorageUtilityBrowser extends StorageUtility {\n constructor(secureStorage: IStorage, insecureStorage: IStorage) {\n super(secureStorage, insecureStorage);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n ISessionInfo,\n ISessionInternalInfo,\n ILoginOptions,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n EVENTS,\n isValidRedirectUrl,\n ClientAuthentication as ClientAuthenticationBase,\n} from \"@inrupt/solid-client-authn-core\";\nimport { removeOidcQueryParam } from \"@inrupt/oidc-client-ext\";\nimport type { EventEmitter } from \"events\";\n\n/**\n * @hidden\n */\nexport default class ClientAuthentication extends ClientAuthenticationBase {\n // Define these functions as properties so that they don't get accidentally re-bound.\n // Isn't Javascript fun?\n login = async (\n options: ILoginOptions,\n eventEmitter: EventEmitter\n ): Promise<void> => {\n // In order to get a clean start, make sure that the session is logged out\n // on login.\n // But we may want to preserve our client application info, particularly if\n // we used Dynamic Client Registration to register (since we don't\n // necessarily want the user to have to register this app each time they\n // login).\n await this.sessionInfoManager.clear(options.sessionId);\n\n // In the case of the user hitting the 'back' button in their browser, they\n // could return to a previous redirect URL that contains OIDC params that\n // are now longer valid. To be safe, strip relevant params now.\n // If the user is providing a redirect IRI, it should not be modified, so\n // normalization only applies if we default to the current location (which is\n // a bad practice and should be discouraged).\n const redirectUrl =\n options.redirectUrl ?? removeOidcQueryParam(window.location.href);\n if (!isValidRedirectUrl(redirectUrl)) {\n throw new Error(\n `${redirectUrl} is not a valid redirect URL, it is either a malformed IRI or it includes a hash fragment.`\n );\n }\n await this.loginHandler.handle({\n ...options,\n redirectUrl,\n // If no clientName is provided, the clientId may be used instead.\n clientName: options.clientName ?? options.clientId,\n eventEmitter,\n });\n };\n\n // Collects session information from storage, and returns them. Returns null\n // if the expected information cannot be found.\n // Note that the ID token is not stored, which means the session information\n // cannot be validated at this point.\n validateCurrentSession = async (\n currentSessionId: string\n ): Promise<(ISessionInfo & ISessionInternalInfo) | null> => {\n const sessionInfo = await this.sessionInfoManager.get(currentSessionId);\n if (\n sessionInfo === undefined ||\n sessionInfo.clientAppId === undefined ||\n sessionInfo.issuer === undefined\n ) {\n return null;\n }\n return sessionInfo;\n };\n\n handleIncomingRedirect = async (\n url: string,\n eventEmitter: EventEmitter\n ): Promise<ISessionInfo | undefined> => {\n try {\n const redirectInfo = await this.redirectHandler.handle(url, eventEmitter);\n // The `FallbackRedirectHandler` directly returns the global `fetch` for\n // his value, so we should ensure it's bound to `window` rather than to\n // ClientAuthentication, to avoid the following error:\n // > 'fetch' called on an object that does not implement interface Window.\n this.fetch = redirectInfo.fetch.bind(window);\n this.boundLogout = redirectInfo.getLogoutUrl;\n\n // Strip the oauth params:\n this.cleanUrlAfterRedirect(url);\n\n return {\n isLoggedIn: redirectInfo.isLoggedIn,\n webId: redirectInfo.webId,\n sessionId: redirectInfo.sessionId,\n expirationDate: redirectInfo.expirationDate,\n };\n } catch (err) {\n // Strip the oauth params:\n this.cleanUrlAfterRedirect(url);\n\n // FIXME: EVENTS.ERROR should be errorCode, errorDescription\n //\n // I'm not sure if \"redirect\" is a good error code, and in theory `err`\n // maybe an Error object and not a string; Maybe we want to just hardcode\n // a description instead?\n eventEmitter.emit(EVENTS.ERROR, \"redirect\", err);\n\n return undefined;\n }\n };\n\n private cleanUrlAfterRedirect(url: string): void {\n const cleanedUpUrl = new URL(url);\n cleanedUpUrl.searchParams.delete(\"state\");\n // For auth code flow\n cleanedUpUrl.searchParams.delete(\"code\");\n // For implicit flow\n cleanedUpUrl.searchParams.delete(\"id_token\");\n cleanedUpUrl.searchParams.delete(\"access_token\");\n // For login error\n cleanedUpUrl.searchParams.delete(\"error\");\n cleanedUpUrl.searchParams.delete(\"error_description\");\n cleanedUpUrl.searchParams.delete(\"iss\");\n\n // Remove OAuth-specific query params (since the login flow finishes with\n // the browser being redirected back with OAuth2 query params (e.g. for\n // 'code' and 'state'), and so if the user simply refreshes this page our\n // authentication library will be called again with what are now invalid\n // query parameters!).\n window.history.replaceState(null, \"\", cleanedUpUrl.toString());\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Handles Common Oidc login functions (Like fetching the configuration)\n */\n\nimport type {\n IClientRegistrar,\n IIssuerConfig,\n IIssuerConfigFetcher,\n ILoginOptions,\n ILoginHandler,\n IOidcHandler,\n IOidcOptions,\n IStorageUtility,\n LoginResult,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n ConfigurationError,\n handleRegistration,\n} from \"@inrupt/solid-client-authn-core\";\n\nfunction hasIssuer(\n options: ILoginOptions\n): options is ILoginOptions & { oidcIssuer: string } {\n return typeof options.oidcIssuer === \"string\";\n}\n\nfunction hasRedirectUrl(\n options: ILoginOptions\n): options is ILoginOptions & { redirectUrl: string } {\n return typeof options.redirectUrl === \"string\";\n}\n\n/**\n * @hidden\n */\nexport default class OidcLoginHandler implements ILoginHandler {\n constructor(\n private storageUtility: IStorageUtility,\n private oidcHandler: IOidcHandler,\n private issuerConfigFetcher: IIssuerConfigFetcher,\n private clientRegistrar: IClientRegistrar\n ) {}\n\n async canHandle(options: ILoginOptions): Promise<boolean> {\n return hasIssuer(options) && hasRedirectUrl(options);\n }\n\n async handle(options: ILoginOptions): Promise<LoginResult> {\n if (!hasIssuer(options)) {\n throw new ConfigurationError(\n `OidcLoginHandler requires an OIDC issuer: missing property 'oidcIssuer' in ${JSON.stringify(\n options\n )}`\n );\n }\n if (!hasRedirectUrl(options)) {\n throw new ConfigurationError(\n `OidcLoginHandler requires a redirect URL: missing property 'redirectUrl' in ${JSON.stringify(\n options\n )}`\n );\n }\n\n // Fetch issuer config.\n const issuerConfig: IIssuerConfig =\n await this.issuerConfigFetcher.fetchConfig(options.oidcIssuer);\n\n const clientRegistration = await handleRegistration(\n options,\n issuerConfig,\n this.storageUtility,\n this.clientRegistrar\n );\n\n // Construct OIDC Options\n const OidcOptions: IOidcOptions = {\n // Note that here, the issuer is not the one from the received options, but\n // from the issuer's config. This enforces the canonical URL is used and stored,\n // which is also the one present in the ID token, so storing a technically\n // valid, but different issuer URL (e.g. using a trailing slash or not) now\n // could prevent from validating the ID token later.\n issuer: issuerConfig.issuer,\n // TODO: differentiate if DPoP should be true\n dpop: options.tokenType.toLowerCase() === \"dpop\",\n ...options,\n issuerConfiguration: issuerConfig,\n client: clientRegistration,\n };\n\n // Call proper OIDC Handler\n return this.oidcHandler.handle(OidcOptions);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Handler for the Authorization Code with PKCE Flow\n */\nimport type {\n IOidcHandler,\n IOidcOptions,\n LoginResult,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n DEFAULT_SCOPES,\n AuthorizationCodeWithPkceOidcHandlerBase,\n} from \"@inrupt/solid-client-authn-core\";\nimport { OidcClient } from \"@inrupt/oidc-client-ext\";\n\n/**\n * @hidden\n * Authorization code flow spec: https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth\n * PKCE: https://tools.ietf.org/html/rfc7636\n */\nexport default class AuthorizationCodeWithPkceOidcHandler\n extends AuthorizationCodeWithPkceOidcHandlerBase\n implements IOidcHandler\n{\n async handle(oidcLoginOptions: IOidcOptions): Promise<LoginResult> {\n /* eslint-disable camelcase */\n const oidcOptions = {\n authority: oidcLoginOptions.issuer.toString(),\n client_id: oidcLoginOptions.client.clientId,\n client_secret: oidcLoginOptions.client.clientSecret,\n redirect_uri: oidcLoginOptions.redirectUrl.toString(),\n post_logout_redirect_uri: oidcLoginOptions.redirectUrl.toString(),\n response_type: \"code\",\n scope: DEFAULT_SCOPES,\n filterProtocolClaims: true,\n // The userinfo endpoint on NSS fails, so disable this for now\n // Note that in Solid, information should be retrieved from the\n // profile referenced by the WebId.\n loadUserInfo: false,\n code_verifier: true,\n prompt: oidcLoginOptions.prompt ?? \"consent\",\n };\n /* eslint-enable camelcase */\n\n const oidcClientLibrary = new OidcClient(oidcOptions);\n\n try {\n const signingRequest = await oidcClientLibrary.createSigninRequest();\n // Make sure to await the promise before returning so that the error is caught.\n return await this.handleRedirect({\n oidcLoginOptions,\n // eslint-disable-next-line no-underscore-dangle\n state: signingRequest.state._id,\n // eslint-disable-next-line no-underscore-dangle\n codeVerifier: signingRequest.state._code_verifier,\n targetUrl: signingRequest.url.toString(),\n });\n } catch (err: unknown) {\n // eslint-disable-next-line no-console\n console.error(err);\n }\n\n // The login is only completed AFTER redirect, so nothing to return here.\n return undefined;\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Responsible for fetching an IDP configuration\n */\nimport type {\n IIssuerConfig,\n IIssuerConfigFetcher,\n IStorageUtility,\n} from \"@inrupt/solid-client-authn-core\";\nimport { ConfigurationError } from \"@inrupt/solid-client-authn-core\";\nimport { fetch } from \"@inrupt/universal-fetch\";\n\nexport const WELL_KNOWN_OPENID_CONFIG = \".well-known/openid-configuration\";\n\n/* eslint-disable camelcase */\nconst issuerConfigKeyMap: Record<\n string,\n { toKey: string; convertToUrl?: boolean }\n> = {\n issuer: {\n toKey: \"issuer\",\n convertToUrl: true,\n },\n authorization_endpoint: {\n toKey: \"authorizationEndpoint\",\n convertToUrl: true,\n },\n token_endpoint: {\n toKey: \"tokenEndpoint\",\n convertToUrl: true,\n },\n userinfo_endpoint: {\n toKey: \"userinfoEndpoint\",\n convertToUrl: true,\n },\n jwks_uri: {\n toKey: \"jwksUri\",\n convertToUrl: true,\n },\n registration_endpoint: {\n toKey: \"registrationEndpoint\",\n convertToUrl: true,\n },\n end_session_endpoint: {\n toKey: \"endSessionEndpoint\",\n convertToUrl: true,\n },\n scopes_supported: { toKey: \"scopesSupported\" },\n response_types_supported: { toKey: \"responseTypesSupported\" },\n response_modes_supported: { toKey: \"responseModesSupported\" },\n grant_types_supported: { toKey: \"grantTypesSupported\" },\n acr_values_supported: { toKey: \"acrValuesSupported\" },\n subject_types_supported: { toKey: \"subjectTypesSupported\" },\n id_token_signing_alg_values_supported: {\n toKey: \"idTokenSigningAlgValuesSupported\",\n },\n id_token_encryption_alg_values_supported: {\n toKey: \"idTokenEncryptionAlgValuesSupported\",\n },\n id_token_encryption_enc_values_supported: {\n toKey: \"idTokenEncryptionEncValuesSupported\",\n },\n userinfo_signing_alg_values_supported: {\n toKey: \"userinfoSigningAlgValuesSupported\",\n },\n userinfo_encryption_alg_values_supported: {\n toKey: \"userinfoEncryptionAlgValuesSupported\",\n },\n userinfo_encryption_enc_values_supported: {\n toKey: \"userinfoEncryptionEncValuesSupported\",\n },\n request_object_signing_alg_values_supported: {\n toKey: \"requestObjectSigningAlgValuesSupported\",\n },\n request_object_encryption_alg_values_supported: {\n toKey: \"requestObjectEncryptionAlgValuesSupported\",\n },\n request_object_encryption_enc_values_supported: {\n toKey: \"requestObjectEncryptionEncValuesSupported\",\n },\n token_endpoint_auth_methods_supported: {\n toKey: \"tokenEndpointAuthMethodsSupported\",\n },\n token_endpoint_auth_signing_alg_values_supported: {\n toKey: \"tokenEndpointAuthSigningAlgValuesSupported\",\n },\n display_values_supported: { toKey: \"displayValuesSupported\" },\n claim_types_supported: { toKey: \"claimTypesSupported\" },\n claims_supported: { toKey: \"claimsSupported\" },\n service_documentation: { toKey: \"serviceDocumentation\" },\n claims_locales_supported: { toKey: \"claimsLocalesSupported\" },\n ui_locales_supported: { toKey: \"uiLocalesSupported\" },\n claims_parameter_supported: { toKey: \"claimsParameterSupported\" },\n request_parameter_supported: { toKey: \"requestParameterSupported\" },\n request_uri_parameter_supported: { toKey: \"requestUriParameterSupported\" },\n require_request_uri_registration: { toKey: \"requireRequestUriRegistration\" },\n op_policy_uri: {\n toKey: \"opPolicyUri\",\n convertToUrl: true,\n },\n op_tos_uri: {\n toKey: \"opTosUri\",\n convertToUrl: true,\n },\n};\n/* eslint-enable camelcase */\n\nfunction processConfig(\n config: Record<string, string | string[]>\n): IIssuerConfig {\n const parsedConfig: Record<string, string | string[]> = {};\n Object.keys(config).forEach((key) => {\n if (issuerConfigKeyMap[key]) {\n // TODO: PMcB55: Validate URL if \"issuerConfigKeyMap[key].convertToUrl\"\n // if (issuerConfigKeyMap[key].convertToUrl) {\n // validateUrl(config[key]);\n // }\n parsedConfig[issuerConfigKeyMap[key].toKey] = config[key];\n }\n });\n if (!Array.isArray(parsedConfig.scopesSupported)) {\n parsedConfig.scopesSupported = [\"openid\"];\n }\n return parsedConfig as unknown as IIssuerConfig;\n}\n\n/**\n * @hidden\n */\nexport default class IssuerConfigFetcher implements IIssuerConfigFetcher {\n constructor(private storageUtility: IStorageUtility) {}\n\n // This method needs no state (so can be static), and can be exposed to allow\n // callers to know where this implementation puts state it needs.\n public static getLocalStorageKey(issuer: string): string {\n return `issuerConfig:${issuer}`;\n }\n\n async fetchConfig(issuer: string): Promise<IIssuerConfig> {\n let issuerConfig: IIssuerConfig;\n\n const openIdConfigUrl = new URL(\n WELL_KNOWN_OPENID_CONFIG,\n // Make sure to append a slash at issuer URL, so that the .well-known URL\n // includes the full issuer path. See https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig.\n issuer.endsWith(\"/\") ? issuer : `${issuer}/`\n ).href;\n const issuerConfigRequestBody = await fetch(openIdConfigUrl);\n // Check the validity of the fetched config\n try {\n issuerConfig = processConfig(await issuerConfigRequestBody.json());\n } catch (err) {\n throw new ConfigurationError(\n `[${issuer.toString()}] has an invalid configuration: ${\n (err as { message: string }).message\n }`\n );\n }\n\n // Update store with fetched config\n await this.storageUtility.set(\n IssuerConfigFetcher.getLocalStorageKey(issuer),\n JSON.stringify(issuerConfig)\n );\n\n return issuerConfig;\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n ISessionInfo,\n ISessionInfoManager,\n ISessionInternalInfo,\n IStorageUtility,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n isSupportedTokenType,\n clear as clearBase,\n SessionInfoManagerBase,\n} from \"@inrupt/solid-client-authn-core\";\nimport { clearOidcPersistentStorage } from \"@inrupt/oidc-client-ext\";\n\nexport { getUnauthenticatedSession } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @param sessionId\n * @param storage\n * @hidden\n */\nexport async function clear(\n sessionId: string,\n storage: IStorageUtility\n): Promise<void> {\n await clearBase(sessionId, storage);\n await clearOidcPersistentStorage();\n}\n\n/**\n * @hidden\n */\nexport class SessionInfoManager\n extends SessionInfoManagerBase\n implements ISessionInfoManager\n{\n async get(\n sessionId: string\n ): Promise<(ISessionInfo & ISessionInternalInfo) | undefined> {\n const isLoggedIn = await this.storageUtility.getForUser(\n sessionId,\n \"isLoggedIn\",\n {\n secure: true,\n }\n );\n\n const webId = await this.storageUtility.getForUser(sessionId, \"webId\", {\n secure: true,\n });\n\n const clientId = await this.storageUtility.getForUser(\n sessionId,\n \"clientId\",\n {\n secure: false,\n }\n );\n\n const clientSecret = await this.storageUtility.getForUser(\n sessionId,\n \"clientSecret\",\n {\n secure: false,\n }\n );\n\n const redirectUrl = await this.storageUtility.getForUser(\n sessionId,\n \"redirectUrl\",\n {\n secure: false,\n }\n );\n\n const refreshToken = await this.storageUtility.getForUser(\n sessionId,\n \"refreshToken\",\n {\n secure: true,\n }\n );\n\n const issuer = await this.storageUtility.getForUser(sessionId, \"issuer\", {\n secure: false,\n });\n\n const tokenType =\n (await this.storageUtility.getForUser(sessionId, \"tokenType\", {\n secure: false,\n })) ?? \"DPoP\";\n\n if (!isSupportedTokenType(tokenType)) {\n throw new Error(`Tokens of type [${tokenType}] are not supported.`);\n }\n\n if (\n clientId === undefined &&\n isLoggedIn === undefined &&\n webId === undefined &&\n refreshToken === undefined\n ) {\n return undefined;\n }\n\n return {\n sessionId,\n webId,\n isLoggedIn: isLoggedIn === \"true\",\n redirectUrl,\n refreshToken,\n issuer,\n clientAppId: clientId,\n clientAppSecret: clientSecret,\n tokenType,\n };\n }\n\n /**\n * This function removes all session-related information from storage.\n * @param sessionId the session identifier\n * @param storage the storage where session info is stored\n * @hidden\n */\n async clear(sessionId: string): Promise<void> {\n return clear(sessionId, this.storageUtility);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IIncomingRedirectHandler,\n ISessionInfo,\n} from \"@inrupt/solid-client-authn-core\";\n\nimport { getUnauthenticatedSession } from \"../../../sessionInfo/SessionInfoManager\";\n\n/**\n * This class handles redirect IRIs without any query params, and returns an unauthenticated\n * session. It serves as a fallback so that consuming libraries don't have to test\n * for the query params themselves, and can always try to use them as a redirect IRI.\n * @hidden\n */\nexport class FallbackRedirectHandler implements IIncomingRedirectHandler {\n async canHandle(redirectUrl: string): Promise<boolean> {\n try {\n // The next URL object is built for validating it.\n // eslint-disable-next-line no-new\n new URL(redirectUrl);\n return true;\n } catch (e) {\n throw new Error(\n `[${redirectUrl}] is not a valid URL, and cannot be used as a redirect URL: ${e}`\n );\n }\n }\n\n async handle(\n // The argument is ignored, but must be present to implement the interface\n _redirectUrl: string\n ): Promise<ISessionInfo & { fetch: typeof fetch }> {\n return getUnauthenticatedSession();\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n// FIXME: The following doesn't work in the browser, it results in all the fetches\n// being unauthenticated. This should be looked into when migrating to universal-fetch.\n// import { fetch } from \"cross-fetch\";\n\nimport { fetch } from \"@inrupt/universal-fetch\";\n\nimport type {\n IClient,\n IClientRegistrar,\n IIssuerConfigFetcher,\n IIncomingRedirectHandler,\n ISessionInfoManager,\n IStorageUtility,\n ITokenRefresher,\n RefreshOptions,\n IncomingRedirectResult,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n buildAuthenticatedFetch,\n loadOidcContextFromStorage,\n maybeBuildRpInitiatedLogout,\n} from \"@inrupt/solid-client-authn-core\";\nimport type { CodeExchangeResult } from \"@inrupt/oidc-client-ext\";\nimport { getDpopToken, getBearerToken } from \"@inrupt/oidc-client-ext\";\nimport type { EventEmitter } from \"events\";\n\n/**\n * @hidden\n */\nexport class AuthCodeRedirectHandler implements IIncomingRedirectHandler {\n constructor(\n private storageUtility: IStorageUtility,\n private sessionInfoManager: ISessionInfoManager,\n private issuerConfigFetcher: IIssuerConfigFetcher,\n private clientRegistrar: IClientRegistrar,\n private tokerRefresher: ITokenRefresher\n ) {}\n\n async canHandle(redirectUrl: string): Promise<boolean> {\n try {\n const myUrl = new URL(redirectUrl);\n return (\n myUrl.searchParams.get(\"code\") !== null &&\n myUrl.searchParams.get(\"state\") !== null\n );\n } catch (e) {\n throw new Error(\n `[${redirectUrl}] is not a valid URL, and cannot be used as a redirect URL: ${e}`\n );\n }\n }\n\n async handle(\n redirectUrl: string,\n eventEmitter?: EventEmitter\n ): Promise<IncomingRedirectResult> {\n if (!(await this.canHandle(redirectUrl))) {\n throw new Error(\n `AuthCodeRedirectHandler cannot handle [${redirectUrl}]: it is missing one of [code, state].`\n );\n }\n\n const url = new URL(redirectUrl);\n const oauthState = url.searchParams.get(\"state\") as string;\n\n const storedSessionId = (await this.storageUtility.getForUser(\n oauthState,\n \"sessionId\",\n {\n errorIfNull: true,\n }\n )) as string;\n\n const {\n issuerConfig,\n codeVerifier,\n redirectUrl: storedRedirectIri,\n dpop: isDpop,\n } = await loadOidcContextFromStorage(\n storedSessionId,\n this.storageUtility,\n this.issuerConfigFetcher\n );\n\n const iss = url.searchParams.get(\"iss\");\n\n if (typeof iss === \"string\" && iss !== issuerConfig.issuer) {\n throw new Error(\n `The value of the iss parameter (${iss}) does not match the issuer identifier of the authorization server (${issuerConfig.issuer}). See [rfc9207](https://www.rfc-editor.org/rfc/rfc9207.html#section-2.3-3.1.1)`\n );\n }\n\n if (codeVerifier === undefined) {\n throw new Error(\n `The code verifier for session ${storedSessionId} is missing from storage.`\n );\n }\n\n if (storedRedirectIri === undefined) {\n throw new Error(\n `The redirect URL for session ${storedSessionId} is missing from storage.`\n );\n }\n\n const client: IClient = await this.clientRegistrar.getClient(\n { sessionId: storedSessionId },\n issuerConfig\n );\n\n let tokens: CodeExchangeResult;\n const tokenCreatedAt = Date.now();\n\n if (isDpop) {\n tokens = await getDpopToken(issuerConfig, client, {\n grantType: \"authorization_code\",\n // We rely on our 'canHandle' function checking that the OAuth 'code'\n // parameter is present in our query string.\n code: url.searchParams.get(\"code\") as string,\n codeVerifier,\n redirectUrl: storedRedirectIri,\n });\n\n // Delete oidc-client-specific session information from storage. This is\n // done automatically when retrieving a bearer token, but since the DPoP\n // binding uses our custom code, this needs to be done manually.\n window.localStorage.removeItem(`oidc.${oauthState}`);\n } else {\n tokens = await getBearerToken(url.toString());\n }\n\n let refreshOptions: RefreshOptions | undefined;\n if (tokens.refreshToken !== undefined) {\n refreshOptions = {\n sessionId: storedSessionId,\n refreshToken: tokens.refreshToken,\n tokenRefresher: this.tokerRefresher,\n };\n }\n\n const authFetch = await buildAuthenticatedFetch(fetch, tokens.accessToken, {\n dpopKey: tokens.dpopKey,\n refreshOptions,\n eventEmitter,\n expiresIn: tokens.expiresIn,\n });\n\n await this.storageUtility.setForUser(\n storedSessionId,\n {\n webId: tokens.webId,\n isLoggedIn: \"true\",\n },\n { secure: true }\n );\n\n const sessionInfo = await this.sessionInfoManager.get(storedSessionId);\n if (!sessionInfo) {\n throw new Error(`Could not retrieve session: [${storedSessionId}].`);\n }\n\n return Object.assign(sessionInfo, {\n fetch: authFetch,\n getLogoutUrl: maybeBuildRpInitiatedLogout({\n idTokenHint: tokens.idToken,\n endSessionEndpoint: issuerConfig.endSessionEndpoint,\n }),\n expirationDate:\n typeof tokens.expiresIn === \"number\"\n ? tokenCreatedAt + tokens.expiresIn * 1000\n : undefined,\n } as IncomingRedirectResult);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Responsible for selecting the correct OidcHandler to handle the provided OIDC Options\n */\nimport type {\n IIncomingRedirectHandler,\n IncomingRedirectInput,\n IncomingRedirectResult,\n} from \"@inrupt/solid-client-authn-core\";\nimport { AggregateHandler } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @hidden\n */\nexport default class AggregateRedirectHandler\n extends AggregateHandler<IncomingRedirectInput, IncomingRedirectResult>\n implements IIncomingRedirectHandler\n{\n constructor(redirectHandlers: IIncomingRedirectHandler[]) {\n super(redirectHandlers);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type { IStorage } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @hidden\n */\nexport default class BrowserStorage implements IStorage {\n get storage(): typeof window.localStorage {\n return window.localStorage;\n }\n\n async get(key: string): Promise<string | undefined> {\n return this.storage.getItem(key) || undefined;\n }\n\n async set(key: string, value: string): Promise<void> {\n this.storage.setItem(key, value);\n }\n\n async delete(key: string): Promise<void> {\n this.storage.removeItem(key);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IRedirector,\n IRedirectorOptions,\n} from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @hidden\n */\nexport default class Redirector implements IRedirector {\n redirect(redirectUrl: string, options?: IRedirectorOptions): void {\n if (options && options.handleRedirect) {\n options.handleRedirect(redirectUrl);\n } else if (options && options.redirectByReplacingState) {\n window.history.replaceState({}, \"\", redirectUrl);\n } else {\n window.location.href = redirectUrl;\n }\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IStorageUtility,\n IClientRegistrar,\n IIssuerConfig,\n IClient,\n IClientRegistrarOptions,\n} from \"@inrupt/solid-client-authn-core\";\nimport { registerClient } from \"@inrupt/oidc-client-ext\";\n\n/**\n * @hidden\n */\nexport default class ClientRegistrar implements IClientRegistrar {\n constructor(private storageUtility: IStorageUtility) {}\n\n async getClient(\n options: IClientRegistrarOptions,\n issuerConfig: IIssuerConfig\n ): Promise<IClient> {\n // If client secret and/or client id are stored in storage, use those.\n const [\n storedClientId,\n storedClientSecret,\n // storedClientName,\n ] = await Promise.all([\n this.storageUtility.getForUser(options.sessionId, \"clientId\", {\n secure: false,\n }),\n this.storageUtility.getForUser(options.sessionId, \"clientSecret\", {\n secure: false,\n }),\n // this.storageUtility.getForUser(options.sessionId, \"clientName\", {\n // // FIXME: figure out how to persist secure storage at reload\n // secure: false,\n // }),\n ]);\n if (storedClientId) {\n return {\n clientId: storedClientId,\n clientSecret: storedClientSecret,\n clientType: \"dynamic\",\n };\n }\n\n try {\n const registeredClient = await registerClient(options, issuerConfig);\n // Save info\n const infoToSave: Record<string, string> = {\n clientId: registeredClient.clientId,\n };\n if (registeredClient.clientSecret) {\n infoToSave.clientSecret = registeredClient.clientSecret;\n }\n if (registeredClient.idTokenSignedResponseAlg) {\n infoToSave.idTokenSignedResponseAlg =\n registeredClient.idTokenSignedResponseAlg;\n }\n await this.storageUtility.setForUser(options.sessionId, infoToSave, {\n // FIXME: figure out how to persist secure storage at reload\n // Otherwise, the client info cannot be retrieved from storage, and\n // the lib tries to re-register the client on each fetch\n secure: false,\n });\n return registeredClient;\n } catch (error) {\n throw new Error(`Client registration failed: [${error}]`);\n }\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IIncomingRedirectHandler,\n ISessionInfo,\n} from \"@inrupt/solid-client-authn-core\";\nimport { EVENTS } from \"@inrupt/solid-client-authn-core\";\nimport type { EventEmitter } from \"events\";\n\nimport { getUnauthenticatedSession } from \"../../../sessionInfo/SessionInfoManager\";\n\n/**\n * This class handles redirect IRIs without any query params, and returns an unauthenticated\n * session. It serves as a fallback so that consuming libraries don't have to test\n * for the query params themselves, and can always try to use them as a redirect IRI.\n * @hidden\n */\nexport class ErrorOidcHandler implements IIncomingRedirectHandler {\n async canHandle(redirectUrl: string): Promise<boolean> {\n try {\n // eslint-disable-next-line no-new\n return new URL(redirectUrl).searchParams.has(\"error\");\n } catch (e) {\n throw new Error(\n `[${redirectUrl}] is not a valid URL, and cannot be used as a redirect URL: ${e}`\n );\n }\n }\n\n async handle(\n redirectUrl: string,\n eventEmitter?: EventEmitter\n ): Promise<ISessionInfo & { fetch: typeof fetch }> {\n if (eventEmitter !== undefined) {\n const url = new URL(redirectUrl);\n const errorUrl = url.searchParams.get(\"error\");\n const errorDescriptionUrl = url.searchParams.get(\"error_description\");\n eventEmitter.emit(EVENTS.ERROR, errorUrl, errorDescriptionUrl);\n }\n return getUnauthenticatedSession();\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IClient,\n IClientRegistrar,\n IIssuerConfigFetcher,\n IStorageUtility,\n KeyPair,\n ITokenRefresher,\n TokenEndpointResponse,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n loadOidcContextFromStorage,\n EVENTS,\n} from \"@inrupt/solid-client-authn-core\";\nimport { refresh } from \"@inrupt/oidc-client-ext\";\nimport type { EventEmitter } from \"events\";\n\n// Some identifiers are not in camelcase on purpose, as they are named using the\n// official names from the OIDC/OAuth2 specifications.\n/* eslint-disable camelcase */\n\n/**\n * @hidden\n */\nexport default class TokenRefresher implements ITokenRefresher {\n constructor(\n private storageUtility: IStorageUtility,\n private issuerConfigFetcher: IIssuerConfigFetcher,\n private clientRegistrar: IClientRegistrar\n ) {}\n\n async refresh(\n sessionId: string,\n refreshToken?: string,\n dpopKey?: KeyPair,\n eventEmitter?: EventEmitter\n ): Promise<TokenEndpointResponse> {\n const oidcContext = await loadOidcContextFromStorage(\n sessionId,\n this.storageUtility,\n this.issuerConfigFetcher\n );\n // This should also retrieve the client from storage\n const clientInfo: IClient = await this.clientRegistrar.getClient(\n { sessionId },\n oidcContext.issuerConfig\n );\n\n if (refreshToken === undefined) {\n // TODO: in a next PR, look up storage for a refresh token\n throw new Error(\n `Session [${sessionId}] has no refresh token to allow it to refresh its access token.`\n );\n }\n\n if (oidcContext.dpop && dpopKey === undefined) {\n throw new Error(\n `For session [${sessionId}], the key bound to the DPoP access token must be provided to refresh said access token.`\n );\n }\n\n const tokenSet = await refresh(\n refreshToken,\n oidcContext.issuerConfig,\n clientInfo,\n dpopKey\n );\n\n if (tokenSet.refreshToken !== undefined) {\n eventEmitter?.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);\n await this.storageUtility.setForUser(sessionId, {\n refreshToken: tokenSet.refreshToken,\n });\n }\n return tokenSet;\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Top Level core document. Responsible for setting up the dependency graph\n */\nimport type { IStorage } from \"@inrupt/solid-client-authn-core\";\nimport {\n InMemoryStorage,\n IWaterfallLogoutHandler,\n} from \"@inrupt/solid-client-authn-core\";\nimport StorageUtilityBrowser from \"./storage/StorageUtility\";\nimport ClientAuthentication from \"./ClientAuthentication\";\nimport OidcLoginHandler from \"./login/oidc/OidcLoginHandler\";\nimport AuthorizationCodeWithPkceOidcHandler from \"./login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler\";\nimport IssuerConfigFetcher from \"./login/oidc/IssuerConfigFetcher\";\nimport { FallbackRedirectHandler } from \"./login/oidc/incomingRedirectHandler/FallbackRedirectHandler\";\nimport { SessionInfoManager } from \"./sessionInfo/SessionInfoManager\";\nimport { AuthCodeRedirectHandler } from \"./login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler\";\nimport AggregateRedirectHandler from \"./login/oidc/AggregateRedirectHandler\";\nimport BrowserStorage from \"./storage/BrowserStorage\";\nimport Redirector from \"./login/oidc/Redirector\";\nimport ClientRegistrar from \"./login/oidc/ClientRegistrar\";\nimport { ErrorOidcHandler } from \"./login/oidc/incomingRedirectHandler/ErrorOidcHandler\";\nimport TokenRefresher from \"./login/oidc/refresh/TokenRefresher\";\n\n/**\n *\n * @param dependencies\n * @deprecated This function will be removed from the external API in an upcoming release.\n */\nexport function getClientAuthenticationWithDependencies(dependencies: {\n secureStorage?: IStorage;\n insecureStorage?: IStorage;\n}): ClientAuthentication {\n const inMemoryStorage = new InMemoryStorage();\n const secureStorage = dependencies.secureStorage || inMemoryStorage;\n const insecureStorage = dependencies.insecureStorage || new BrowserStorage();\n\n const storageUtility = new StorageUtilityBrowser(\n secureStorage,\n insecureStorage\n );\n\n const issuerConfigFetcher = new IssuerConfigFetcher(storageUtility);\n const clientRegistrar = new ClientRegistrar(storageUtility);\n\n const sessionInfoManager = new SessionInfoManager(storageUtility);\n\n const tokenRefresher = new TokenRefresher(\n storageUtility,\n issuerConfigFetcher,\n clientRegistrar\n );\n\n const redirector = new Redirector();\n\n // make new handler for redirect and login\n const loginHandler = new OidcLoginHandler(\n storageUtility,\n new AuthorizationCodeWithPkceOidcHandler(storageUtility, redirector),\n issuerConfigFetcher,\n clientRegistrar\n );\n\n const redirectHandler = new AggregateRedirectHandler([\n new ErrorOidcHandler(),\n new AuthCodeRedirectHandler(\n storageUtility,\n sessionInfoManager,\n issuerConfigFetcher,\n clientRegistrar,\n tokenRefresher\n ),\n // This catch-all class will always be able to handle the\n // redirect IRI, so it must be registered last.\n new FallbackRedirectHandler(),\n ]);\n\n return new ClientAuthentication(\n loginHandler,\n redirectHandler,\n new IWaterfallLogoutHandler(sessionInfoManager, redirector),\n sessionInfoManager,\n issuerConfigFetcher\n );\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\nimport { SOLID_CLIENT_AUTHN_KEY_PREFIX } from \"@inrupt/solid-client-authn-core\";\n\nexport const KEY_CURRENT_SESSION = `${SOLID_CLIENT_AUTHN_KEY_PREFIX}currentSession`;\n\nexport const KEY_CURRENT_URL = `${SOLID_CLIENT_AUTHN_KEY_PREFIX}currentUrl`;\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n */\nimport type {\n ILoginInputOptions,\n ISessionInfo,\n IStorage,\n IHasSessionEventListener,\n ISessionEventListener,\n ILogoutOptions,\n} from \"@inrupt/solid-client-authn-core\";\nimport { EVENTS, buildProxyHandler } from \"@inrupt/solid-client-authn-core\";\nimport type { fetch } from \"@inrupt/universal-fetch\";\nimport { v4 } from \"uuid\";\nimport EventEmitter from \"events\";\nimport type ClientAuthentication from \"./ClientAuthentication\";\nimport { getClientAuthenticationWithDependencies } from \"./dependencies\";\nimport { KEY_CURRENT_SESSION, KEY_CURRENT_URL } from \"./constant\";\n\nexport interface ISessionOptions {\n /**\n * A private storage, unreachable to other scripts on the page. Typically in-memory.\n */\n secureStorage: IStorage;\n /**\n * A storage where non-sensitive information may be stored, potentially longer-lived than the secure storage.\n */\n insecureStorage: IStorage;\n /**\n * Details about the current session\n */\n sessionInfo: ISessionInfo;\n /**\n * An instance of the library core. Typically obtained using `getClientAuthenticationWithDependencies`.\n */\n clientAuthentication: ClientAuthentication;\n}\n\nexport interface IHandleIncomingRedirectOptions {\n /**\n * If the user has signed in before, setting this to `true` will automatically\n * redirect them to their Solid Identity Provider, which will then attempt to\n * re-activate the session and send the user back to your app without\n * requiring user interaction.\n * If your app's access has not expired yet and re-activation completed\n * successfully, a `sessionRestore` event will be fired with the URL the user\n * was at before they were redirected to their Solid Identity Provider.\n * {@see onSessionRestore}\n */\n restorePreviousSession?: boolean;\n\n /**\n * Inrupt's Enterprise Solid Server can set a cookie to allow the browser to\n * access private resources on a Pod. In order to mitigate the logout-on-refresh\n * issue on the short term, the server also implemented a session endpoint\n * enabling the client app to know whether the cookie is set. When a user\n * logs in to a server that has that capability enabled, applications that set\n * this option to `true` will be able to make use of it.\n *\n * If your app supports the newest session restore approach, and `restorePreviousSession`\n * is set to true, this option is automatically set to false, but your app will\n * not be logged out when reloaded.\n *\n * `useEssSession` defaults to false and will be removed in the future; to\n * preserve sessions across page reloads, use of `restorePreviousSession` is\n * recommended.\n *\n * @deprecated unreleased\n */\n useEssSession?: boolean;\n /**\n * The URL of the page handling the redirect, including the query\n * parameters — these contain the information to process the login.\n * Note: as a convenience, if no URL value is specified here, we default to\n * using the browser's current location.\n */\n url?: string;\n}\n\nexport async function silentlyAuthenticate(\n sessionId: string,\n clientAuthn: ClientAuthentication,\n session: Session\n): Promise<boolean> {\n const storedSessionInfo = await clientAuthn.validateCurrentSession(sessionId);\n if (storedSessionInfo !== null) {\n // It can be really useful to save the user's current browser location,\n // so that we can restore it after completing the silent authentication\n // on incoming redirect. This way, the user is eventually redirected back\n // to the page they were on and not to the app's redirect page.\n window.localStorage.setItem(KEY_CURRENT_URL, window.location.href);\n await clientAuthn.login(\n {\n sessionId,\n prompt: \"none\",\n oidcIssuer: storedSessionInfo.issuer,\n redirectUrl: storedSessionInfo.redirectUrl,\n clientId: storedSessionInfo.clientAppId,\n clientSecret: storedSessionInfo.clientAppSecret,\n tokenType: storedSessionInfo.tokenType ?? \"DPoP\",\n },\n session.events\n );\n return true;\n }\n return false;\n}\n\nfunction isLoggedIn(\n sessionInfo?: ISessionInfo\n): sessionInfo is ISessionInfo & { isLoggedIn: true } {\n return !!sessionInfo?.isLoggedIn;\n}\n\n/**\n * A {@link Session} object represents a user's session on an application. The session holds state, as it stores information enabling acces to private resources after login for instance.\n */\nexport class Session extends EventEmitter implements IHasSessionEventListener {\n /**\n * Information regarding the current session.\n */\n public readonly info: ISessionInfo;\n\n /**\n * Session attribute exposing the EventEmitter interface, to listen on session\n * events such as login, logout, etc.\n * @since 1.15.0\n */\n public readonly events: ISessionEventListener;\n\n private clientAuthentication: ClientAuthentication;\n\n private tokenRequestInProgress = false;\n\n /**\n * Session object constructor. Typically called as follows:\n *\n * ```typescript\n * const session = new Session();\n * ```\n *\n * See also [getDefaultSession](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-browser/functions.html#getdefaultsession).\n *\n * @param sessionOptions The options enabling the correct instantiation of\n * the session. Either both storages or clientAuthentication are required. For\n * more information, see {@link ISessionOptions}.\n * @param sessionId A string uniquely identifying the session.\n *\n */\n constructor(\n sessionOptions: Partial<ISessionOptions> = {},\n sessionId: string | undefined = undefined\n ) {\n super();\n // Until Session no longer implements EventEmitter, this.events is just a proxy\n // to this (with some interface filtering). When we make the breaking change,\n // this.events will be a regular EventEmitter (implementing ISessionEventEmitter):\n // this.events = new EventEmitter();\n this.events = new Proxy(\n this,\n buildProxyHandler(\n Session.prototype,\n \"events only implements ISessionEventListener\"\n )\n );\n if (sessionOptions.clientAuthentication) {\n this.clientAuthentication = sessionOptions.clientAuthentication;\n } else if (sessionOptions.secureStorage && sessionOptions.insecureStorage) {\n this.clientAuthentication = getClientAuthenticationWithDependencies({\n secureStorage: sessionOptions.secureStorage,\n insecureStorage: sessionOptions.insecureStorage,\n });\n } else {\n this.clientAuthentication = getClientAuthenticationWithDependencies({});\n }\n\n if (sessionOptions.sessionInfo) {\n this.info = {\n sessionId: sessionOptions.sessionInfo.sessionId,\n isLoggedIn: false,\n webId: sessionOptions.sessionInfo.webId,\n };\n } else {\n this.info = {\n sessionId: sessionId ?? v4(),\n isLoggedIn: false,\n };\n }\n\n // When a session is logged in, we want to track its ID in local storage to\n // enable silent refresh. The current session ID specifically stored in 'localStorage'\n // (as opposed to using our storage abstraction layer) because it is only\n // used in a browser-specific mechanism.\n this.events.on(EVENTS.LOGIN, () =>\n window.localStorage.setItem(KEY_CURRENT_SESSION, this.info.sessionId)\n );\n\n this.events.on(EVENTS.SESSION_EXPIRED, () => this.internalLogout(false));\n\n this.events.on(EVENTS.ERROR, () => this.internalLogout(false));\n }\n\n /**\n * Triggers the login process. Note that this method will redirect the user away from your app.\n *\n * @param options Parameter to customize the login behaviour. In particular, two options are mandatory: `options.oidcIssuer`, the user's identity provider, and `options.redirectUrl`, the URL to which the user will be redirected after logging in their identity provider.\n * @returns This method should redirect the user away from the app: it does not return anything. The login process is completed by {@linkcode handleIncomingRedirect}.\n */\n // Define these functions as properties so that they don't get accidentally re-bound.\n // Isn't Javascript fun?\n login = async (options: ILoginInputOptions): Promise<void> => {\n await this.clientAuthentication.login(\n {\n sessionId: this.info.sessionId,\n ...options,\n // Defaults the token type to DPoP\n tokenType: options.tokenType ?? \"DPoP\",\n },\n this.events\n );\n // `login` redirects the user away from the app,\n // so unless it throws an error, there is no code that should run afterwards\n // (since there is no \"after\" in the lifetime of the script).\n // Hence, this Promise never resolves:\n return new Promise(() => {});\n };\n\n /**\n * Fetches data using available login information. If the user is not logged in, this will behave as a regular `fetch`. The signature of this method is identical to the [canonical `fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).\n *\n * @param url The URL from which data should be fetched.\n * @param init Optional parameters customizing the request, by specifying an HTTP method, headers, a body, etc. Follows the [WHATWG Fetch Standard](https://fetch.spec.whatwg.org/).\n */\n fetch: typeof fetch = (url, init) =>\n this.clientAuthentication.fetch(url, init);\n\n /**\n * An internal logout function, to control whether or not the logout signal\n * should be sent, i.e. if the logout was user-initiated or is the result of\n * an external event.\n *\n * @hidden\n */\n private internalLogout = async (\n emitSignal: boolean,\n options?: ILogoutOptions\n ): Promise<void> => {\n // Clearing this value means that silent refresh will no longer be attempted.\n // In particular, in the case of a silent authentication error it prevents\n // from getting stuck in an authentication retries loop.\n window.localStorage.removeItem(KEY_CURRENT_SESSION);\n await this.clientAuthentication.logout(this.info.sessionId, options);\n this.info.isLoggedIn = false;\n if (emitSignal) {\n (this.events as EventEmitter).emit(EVENTS.LOGOUT);\n }\n };\n\n /**\n * Logs the user out of the application.\n *\n * There are 2 types of logout supported by this library,\n * `app` logout and `idp` logout.\n *\n * App logout will log the user out within the application\n * by clearing any session data from the browser. It does\n * not log the user out of their Solid identity provider,\n * and should not redirect the user away.\n * App logout can be performed as follows:\n * ```typescript\n * await session.logout({ logoutType: 'app' });\n * ```\n *\n * IDP logout will log the user out of their Solid identity provider,\n * and will redirect the user away from the application to do so.\n * IDP logout can be performed as follows:\n * ```typescript\n * await session.logout({\n * logoutType: 'idp',\n * // An optional URL to redirect to after logout has completed;\n * // this MUST match a logout URL listed in the clientId of\n * // the application that is logged in.\n * postLogoutUrl: 'https://example.com/logout',\n * // An optional value to be included in the query parameters\n * // when the IDP provider redirects the user to the postLogoutRedirectUrl.\n * state: \"my-state\"\n * });\n * ```\n */\n logout = async (options?: ILogoutOptions): Promise<void> =>\n this.internalLogout(true, options);\n\n /**\n * Completes the login process by processing the information provided by the\n * Solid identity provider through redirect.\n *\n * @param options See {@see IHandleIncomingRedirectOptions}.\n */\n handleIncomingRedirect = async (\n inputOptions: string | IHandleIncomingRedirectOptions = {}\n ): Promise<ISessionInfo | undefined> => {\n if (this.info.isLoggedIn) {\n return this.info;\n }\n\n if (this.tokenRequestInProgress) {\n return undefined;\n }\n const options =\n typeof inputOptions === \"string\" ? { url: inputOptions } : inputOptions;\n const url = options.url ?? window.location.href;\n\n this.tokenRequestInProgress = true;\n const sessionInfo = await this.clientAuthentication.handleIncomingRedirect(\n url,\n this.events\n );\n if (isLoggedIn(sessionInfo)) {\n this.setSessionInfo(sessionInfo);\n const currentUrl = window.localStorage.getItem(KEY_CURRENT_URL);\n if (currentUrl === null) {\n // The login event can only be triggered **after** the user has been\n // redirected from the IdP with access and ID tokens.\n (this.events as EventEmitter).emit(EVENTS.LOGIN);\n } else {\n // If an URL is stored in local storage, we are being logged in after a\n // silent authentication, so remove our currently stored URL location\n // to clean up our state now that we are completing the re-login process.\n window.localStorage.removeItem(KEY_CURRENT_URL);\n (this.events as EventEmitter).emit(EVENTS.SESSION_RESTORED, currentUrl);\n }\n } else if (options.restorePreviousSession === true) {\n // Silent authentication happens after a refresh, which means there are no\n // OAuth params in the current location IRI. It can only succeed if a session\n // was previously logged in, in which case its ID will be present with a known\n // identifier in local storage.\n // Check if we have a locally stored session ID...\n const storedSessionId = window.localStorage.getItem(KEY_CURRENT_SESSION);\n // ...if not, then there is no ID token, and so silent authentication cannot happen, but\n // if we do have a stored session ID, attempt to re-authenticate now silently.\n if (storedSessionId !== null) {\n const attemptedSilentAuthentication = await silentlyAuthenticate(\n storedSessionId,\n this.clientAuthentication,\n this\n );\n // At this point, we know that the main window will imminently be redirected.\n // However, this redirect is asynchronous and there is no way to halt execution\n // until it happens precisely. That's why the current Promise simply does not\n // resolve.\n if (attemptedSilentAuthentication) {\n return new Promise(() => {});\n }\n }\n }\n this.tokenRequestInProgress = false;\n return sessionInfo;\n };\n\n /**\n * Register a callback function to be called when a user completes login.\n *\n * The callback is called when {@link handleIncomingRedirect} completes successfully.\n *\n * @param callback The function called when a user completes login.\n * @deprecated Prefer session.events.on(EVENTS.LOGIN, callback)\n */\n onLogin(callback: () => unknown): void {\n this.events.on(EVENTS.LOGIN, callback);\n }\n\n /**\n * Register a callback function to be called when a user logs out:\n *\n * @param callback The function called when a user completes logout.\n * @deprecated Prefer session.events.on(EVENTS.LOGOUT, callback)\n */\n onLogout(callback: () => unknown): void {\n this.events.on(EVENTS.LOGOUT, callback);\n }\n\n /**\n * Register a callback function to be called when a user logs out:\n *\n * @param callback The function called when an error occurs.\n * @since 1.11.0\n * @deprecated Prefer session.events.on(EVENTS.ERROR, callback)\n */\n onError(\n callback: (\n error: string | null,\n errorDescription?: string | null\n ) => unknown\n ): void {\n this.events.on(EVENTS.ERROR, callback);\n }\n\n /**\n * Register a callback function to be called when a session is restored.\n *\n * Note: the callback will be called with the saved value of the 'current URL'\n * at the time the session was restored.\n *\n * @param callback The function called when a user's already logged-in session is restored, e.g., after a silent authentication is completed after a page refresh.\n * @deprecated Prefer session.events.on(EVENTS.SESSION_RESTORED, callback)\n */\n onSessionRestore(callback: (currentUrl: string) => unknown): void {\n this.events.on(EVENTS.SESSION_RESTORED, callback);\n }\n\n /**\n * Register a callback that runs when the session expires and can no longer\n * make authenticated requests, but following a user logout.\n * @param callback The function that runs on session expiration.\n * @since 1.11.0\n * @deprecated Prefer session.events.on(EVENTS.SESSION_EXPIRED, callback)\n */\n onSessionExpiration(callback: () => unknown): void {\n this.events.on(EVENTS.SESSION_EXPIRED, callback);\n }\n\n private setSessionInfo(\n sessionInfo: ISessionInfo & { isLoggedIn: true }\n ): void {\n this.info.isLoggedIn = sessionInfo.isLoggedIn;\n this.info.webId = sessionInfo.webId;\n this.info.sessionId = sessionInfo.sessionId;\n this.info.expirationDate = sessionInfo.expirationDate;\n this.events.on(EVENTS.SESSION_EXTENDED, (expiresIn: number) => {\n this.info.expirationDate = Date.now() + expiresIn * 1000;\n });\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\nimport { Session } from \"./Session\";\n\nlet defaultSession: Session | undefined;\n\n/**\n * Obtain the {@link Session} used when not explicitly instantiating one yourself.\n *\n * When using the top-level exports {@link fetch}, {@link login}, {@link logout},\n * {@link handleIncomingRedirect}, {@link onLogin} and {@link onLogout}, these apply to an\n * implicitly-instantiated {@link Session}.\n * This function returns a reference to that Session in order to obtain e.g. the current user's\n * WebID.\n * @since 1.3.0\n */\nexport function getDefaultSession(): Session {\n if (typeof defaultSession === \"undefined\") {\n defaultSession = new Session();\n }\n return defaultSession;\n}\n\n/**\n * This function's signature is equal to `window.fetch`, but if the current user is authenticated\n * (see [[login]] and [[handleIncomingRedirect]]), requests made using it will include that user's\n * credentials. If not, this will behave just like the regular `window.fetch`.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch}\n * @since 1.3.0\n */\n/* eslint-disable-next-line no-shadow */\nexport const fetch: Session[\"fetch\"] = (...args) => {\n const session = getDefaultSession();\n return session.fetch(...args);\n};\n\n/**\n * Triggers the login process. Note that this method will redirect the user away from your app.\n *\n * @param options Parameter to customize the login behaviour. In particular, two options are mandatory: `options.oidcIssuer`, the user's identity provider, and `options.redirectUrl`, the URL to which the user will be redirected after logging in their identity provider.\n * @returns This method should redirect the user away from the app: it does not return anything. The login process is completed by [[handleIncomingRedirect]].\n * @since 1.3.0\n */\nexport const login: Session[\"login\"] = (...args) => {\n const session = getDefaultSession();\n return session.login(...args);\n};\n\n/**\n * Logs the user out of the application.\n *\n * By default this does not log the user out of their Solid identity provider.\n * In order to do so, you must set the logoutType to `idp`.\n *\n * @since 1.3.0\n */\nexport const logout: Session[\"logout\"] = (...args) => {\n const session = getDefaultSession();\n return session.logout(...args);\n};\n\n/**\n * Completes the login process by processing the information provided by the Solid identity provider through redirect.\n *\n * @param url The URL of the page handling the redirect, including the query parameters — these contain the information to process the login.\n * @since 1.3.0\n */\nexport const handleIncomingRedirect: Session[\"handleIncomingRedirect\"] = (\n ...args\n) => {\n const session = getDefaultSession();\n return session.handleIncomingRedirect(...args);\n};\n\n/**\n * Register a callback function to be called when a user completes login.\n *\n * The callback is called when {@link handleIncomingRedirect} completes successfully.\n * @since 1.3.0\n *\n * @param callback The function called when a user completes login.\n * @deprecated Prefer events.on(EVENTS.LOGIN, callback)\n\n */\nexport const onLogin: Session[\"onLogin\"] = (...args) => {\n const session = getDefaultSession();\n return session.onLogin(...args);\n};\n\n/**\n * Register a callback function to be called when a user logs out:\n *\n * @param callback The function called when a user completes logout.\n * @since 1.3.0\n * @deprecated Prefer events.on(EVENTS.LOGOUT, callback)\n\n */\nexport const onLogout: Session[\"onLogout\"] = (...args) => {\n const session = getDefaultSession();\n return session.onLogout(...args);\n};\n\n/**\n * Register a callback function to be called when a session is restored:\n *\n * @param callback The function called when a session is restored.\n * @since 1.3.0\n * @deprecated Prefer events.on(EVENTS.SESSION_RESTORED, callback)\n */\nexport const onSessionRestore: Session[\"onSessionRestore\"] = (...args) => {\n const session = getDefaultSession();\n return session.onSessionRestore(...args);\n};\n\n/**\n * {@link SessionEventEmitter} instance to subscribe to events by the default session.\n *\n * @since Unreleased\n */\nexport const events = (): Session[\"events\"] => {\n return getDefaultSession().events;\n};\n"],"names":["StorageUtility","ClientAuthenticationBase","removeOidcQueryParam","isValidRedirectUrl","EVENTS","ConfigurationError","handleRegistration","AuthorizationCodeWithPkceOidcHandlerBase","DEFAULT_SCOPES","OidcClient","fetch","clearBase","clearOidcPersistentStorage","SessionInfoManagerBase","isSupportedTokenType","getUnauthenticatedSession","loadOidcContextFromStorage","getDpopToken","getBearerToken","buildAuthenticatedFetch","maybeBuildRpInitiatedLogout","AggregateHandler","registerClient","refresh","InMemoryStorage","IWaterfallLogoutHandler","SOLID_CLIENT_AUTHN_KEY_PREFIX","buildProxyHandler","v4"],"mappings":";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AA,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;AACpC,IAAA,OAAO,OAAO,CAAC,sBAAsB,CAAC,GAAG,IAAI,CAAC,CAAC;AACjD,EAAE;MAYW,OAAO,GAAuB,CAAC,GAAG,IAAI,KAAI;AACrD,IAAA,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;AACpC,IAAA,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AAClC,EAAE;MAUW,QAAQ,GAAwB,CAAC,GAAG,IAAI,KAAI;AACvD,IAAA,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;AACpC,IAAA,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;AACnC,EAAE;MASW,gBAAgB,GAAgC,CAAC,GAAG,IAAI,KAAI;AACvE,IAAA,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;AACpC,IAAA,OAAO,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC;AAC3C,EAAE;AAOK,MAAM,MAAM,GAAG,MAAwB;AAC5C,IAAA,OAAO,iBAAiB,EAAE,CAAC,MAAM,CAAC;AACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/storage/StorageUtility.ts","../src/ClientAuthentication.ts","../src/login/oidc/OidcLoginHandler.ts","../src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.ts","../src/login/oidc/IssuerConfigFetcher.ts","../src/sessionInfo/SessionInfoManager.ts","../src/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.ts","../src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.ts","../src/login/oidc/AggregateRedirectHandler.ts","../src/storage/BrowserStorage.ts","../src/login/oidc/Redirector.ts","../src/login/oidc/ClientRegistrar.ts","../src/login/oidc/incomingRedirectHandler/ErrorOidcHandler.ts","../src/login/oidc/refresh/TokenRefresher.ts","../src/dependencies.ts","../src/constant.ts","../src/Session.ts","../src/defaultSession.ts"],"sourcesContent":["//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * A helper class that will validate items taken from local storage\n */\nimport type { IStorage } from \"@inrupt/solid-client-authn-core\";\nimport { StorageUtility } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * This class in a no-value-added extension of StorageUtility from the core module.\n * The reason it has to be declared is for TSyringe to find the decorators in the\n * same modules as where the dependency container is declared (in this case,\n * the browser module, with the dependancy container in dependencies.ts).\n * @hidden\n */\nexport default class StorageUtilityBrowser extends StorageUtility {\n constructor(secureStorage: IStorage, insecureStorage: IStorage) {\n super(secureStorage, insecureStorage);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n ISessionInfo,\n ISessionInternalInfo,\n ILoginOptions,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n EVENTS,\n isValidRedirectUrl,\n ClientAuthentication as ClientAuthenticationBase,\n} from \"@inrupt/solid-client-authn-core\";\nimport { removeOidcQueryParam } from \"@inrupt/oidc-client-ext\";\nimport type { EventEmitter } from \"events\";\n\n/**\n * @hidden\n */\nexport default class ClientAuthentication extends ClientAuthenticationBase {\n // Define these functions as properties so that they don't get accidentally re-bound.\n // Isn't Javascript fun?\n login = async (\n options: ILoginOptions,\n eventEmitter: EventEmitter\n ): Promise<void> => {\n // In order to get a clean start, make sure that the session is logged out\n // on login.\n // But we may want to preserve our client application info, particularly if\n // we used Dynamic Client Registration to register (since we don't\n // necessarily want the user to have to register this app each time they\n // login).\n await this.sessionInfoManager.clear(options.sessionId);\n\n // In the case of the user hitting the 'back' button in their browser, they\n // could return to a previous redirect URL that contains OIDC params that\n // are now longer valid. To be safe, strip relevant params now.\n // If the user is providing a redirect IRI, it should not be modified, so\n // normalization only applies if we default to the current location (which is\n // a bad practice and should be discouraged).\n const redirectUrl =\n options.redirectUrl ?? removeOidcQueryParam(window.location.href);\n if (!isValidRedirectUrl(redirectUrl)) {\n throw new Error(\n `${redirectUrl} is not a valid redirect URL, it is either a malformed IRI or it includes a hash fragment.`\n );\n }\n await this.loginHandler.handle({\n ...options,\n redirectUrl,\n // If no clientName is provided, the clientId may be used instead.\n clientName: options.clientName ?? options.clientId,\n eventEmitter,\n });\n };\n\n // Collects session information from storage, and returns them. Returns null\n // if the expected information cannot be found.\n // Note that the ID token is not stored, which means the session information\n // cannot be validated at this point.\n validateCurrentSession = async (\n currentSessionId: string\n ): Promise<(ISessionInfo & ISessionInternalInfo) | null> => {\n const sessionInfo = await this.sessionInfoManager.get(currentSessionId);\n if (\n sessionInfo === undefined ||\n sessionInfo.clientAppId === undefined ||\n sessionInfo.issuer === undefined\n ) {\n return null;\n }\n return sessionInfo;\n };\n\n handleIncomingRedirect = async (\n url: string,\n eventEmitter: EventEmitter\n ): Promise<ISessionInfo | undefined> => {\n try {\n const redirectInfo = await this.redirectHandler.handle(url, eventEmitter);\n // The `FallbackRedirectHandler` directly returns the global `fetch` for\n // his value, so we should ensure it's bound to `window` rather than to\n // ClientAuthentication, to avoid the following error:\n // > 'fetch' called on an object that does not implement interface Window.\n this.fetch = redirectInfo.fetch.bind(window);\n this.boundLogout = redirectInfo.getLogoutUrl;\n\n // Strip the oauth params:\n this.cleanUrlAfterRedirect(url);\n\n return {\n isLoggedIn: redirectInfo.isLoggedIn,\n webId: redirectInfo.webId,\n sessionId: redirectInfo.sessionId,\n expirationDate: redirectInfo.expirationDate,\n };\n } catch (err) {\n // Strip the oauth params:\n this.cleanUrlAfterRedirect(url);\n\n // FIXME: EVENTS.ERROR should be errorCode, errorDescription\n //\n // I'm not sure if \"redirect\" is a good error code, and in theory `err`\n // maybe an Error object and not a string; Maybe we want to just hardcode\n // a description instead?\n eventEmitter.emit(EVENTS.ERROR, \"redirect\", err);\n\n return undefined;\n }\n };\n\n private cleanUrlAfterRedirect(url: string): void {\n const cleanedUpUrl = new URL(url);\n cleanedUpUrl.searchParams.delete(\"state\");\n // For auth code flow\n cleanedUpUrl.searchParams.delete(\"code\");\n // For implicit flow\n cleanedUpUrl.searchParams.delete(\"id_token\");\n cleanedUpUrl.searchParams.delete(\"access_token\");\n // For login error\n cleanedUpUrl.searchParams.delete(\"error\");\n cleanedUpUrl.searchParams.delete(\"error_description\");\n cleanedUpUrl.searchParams.delete(\"iss\");\n\n // Remove OAuth-specific query params (since the login flow finishes with\n // the browser being redirected back with OAuth2 query params (e.g. for\n // 'code' and 'state'), and so if the user simply refreshes this page our\n // authentication library will be called again with what are now invalid\n // query parameters!).\n window.history.replaceState(null, \"\", cleanedUpUrl.toString());\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Handles Common Oidc login functions (Like fetching the configuration)\n */\n\nimport type {\n IClientRegistrar,\n IIssuerConfig,\n IIssuerConfigFetcher,\n ILoginOptions,\n ILoginHandler,\n IOidcHandler,\n IOidcOptions,\n IStorageUtility,\n LoginResult,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n ConfigurationError,\n handleRegistration,\n} from \"@inrupt/solid-client-authn-core\";\n\nfunction hasIssuer(\n options: ILoginOptions\n): options is ILoginOptions & { oidcIssuer: string } {\n return typeof options.oidcIssuer === \"string\";\n}\n\nfunction hasRedirectUrl(\n options: ILoginOptions\n): options is ILoginOptions & { redirectUrl: string } {\n return typeof options.redirectUrl === \"string\";\n}\n\n/**\n * @hidden\n */\nexport default class OidcLoginHandler implements ILoginHandler {\n constructor(\n private storageUtility: IStorageUtility,\n private oidcHandler: IOidcHandler,\n private issuerConfigFetcher: IIssuerConfigFetcher,\n private clientRegistrar: IClientRegistrar\n ) {}\n\n async canHandle(options: ILoginOptions): Promise<boolean> {\n return hasIssuer(options) && hasRedirectUrl(options);\n }\n\n async handle(options: ILoginOptions): Promise<LoginResult> {\n if (!hasIssuer(options)) {\n throw new ConfigurationError(\n `OidcLoginHandler requires an OIDC issuer: missing property 'oidcIssuer' in ${JSON.stringify(\n options\n )}`\n );\n }\n if (!hasRedirectUrl(options)) {\n throw new ConfigurationError(\n `OidcLoginHandler requires a redirect URL: missing property 'redirectUrl' in ${JSON.stringify(\n options\n )}`\n );\n }\n\n // Fetch issuer config.\n const issuerConfig: IIssuerConfig =\n await this.issuerConfigFetcher.fetchConfig(options.oidcIssuer);\n\n const clientRegistration = await handleRegistration(\n options,\n issuerConfig,\n this.storageUtility,\n this.clientRegistrar\n );\n\n // Construct OIDC Options\n const OidcOptions: IOidcOptions = {\n // Note that here, the issuer is not the one from the received options, but\n // from the issuer's config. This enforces the canonical URL is used and stored,\n // which is also the one present in the ID token, so storing a technically\n // valid, but different issuer URL (e.g. using a trailing slash or not) now\n // could prevent from validating the ID token later.\n issuer: issuerConfig.issuer,\n // TODO: differentiate if DPoP should be true\n dpop: options.tokenType.toLowerCase() === \"dpop\",\n ...options,\n issuerConfiguration: issuerConfig,\n client: clientRegistration,\n };\n\n // Call proper OIDC Handler\n return this.oidcHandler.handle(OidcOptions);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Handler for the Authorization Code with PKCE Flow\n */\nimport type {\n IOidcHandler,\n IOidcOptions,\n LoginResult,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n DEFAULT_SCOPES,\n AuthorizationCodeWithPkceOidcHandlerBase,\n} from \"@inrupt/solid-client-authn-core\";\nimport { OidcClient } from \"@inrupt/oidc-client-ext\";\n\n/**\n * @hidden\n * Authorization code flow spec: https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth\n * PKCE: https://tools.ietf.org/html/rfc7636\n */\nexport default class AuthorizationCodeWithPkceOidcHandler\n extends AuthorizationCodeWithPkceOidcHandlerBase\n implements IOidcHandler\n{\n async handle(oidcLoginOptions: IOidcOptions): Promise<LoginResult> {\n /* eslint-disable camelcase */\n const oidcOptions = {\n authority: oidcLoginOptions.issuer.toString(),\n client_id: oidcLoginOptions.client.clientId,\n client_secret: oidcLoginOptions.client.clientSecret,\n redirect_uri: oidcLoginOptions.redirectUrl.toString(),\n post_logout_redirect_uri: oidcLoginOptions.redirectUrl.toString(),\n response_type: \"code\",\n scope: DEFAULT_SCOPES,\n filterProtocolClaims: true,\n // The userinfo endpoint on NSS fails, so disable this for now\n // Note that in Solid, information should be retrieved from the\n // profile referenced by the WebId.\n loadUserInfo: false,\n code_verifier: true,\n prompt: oidcLoginOptions.prompt ?? \"consent\",\n };\n /* eslint-enable camelcase */\n\n const oidcClientLibrary = new OidcClient(oidcOptions);\n\n try {\n const signingRequest = await oidcClientLibrary.createSigninRequest();\n // Make sure to await the promise before returning so that the error is caught.\n return await this.handleRedirect({\n oidcLoginOptions,\n // eslint-disable-next-line no-underscore-dangle\n state: signingRequest.state._id,\n // eslint-disable-next-line no-underscore-dangle\n codeVerifier: signingRequest.state._code_verifier,\n targetUrl: signingRequest.url.toString(),\n });\n } catch (err: unknown) {\n // eslint-disable-next-line no-console\n console.error(err);\n }\n\n // The login is only completed AFTER redirect, so nothing to return here.\n return undefined;\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Responsible for fetching an IDP configuration\n */\nimport type {\n IIssuerConfig,\n IIssuerConfigFetcher,\n IStorageUtility,\n} from \"@inrupt/solid-client-authn-core\";\nimport { ConfigurationError } from \"@inrupt/solid-client-authn-core\";\nimport { fetch as uniFetch } from \"@inrupt/universal-fetch\";\n\nexport const WELL_KNOWN_OPENID_CONFIG = \".well-known/openid-configuration\";\n\n/* eslint-disable camelcase */\nconst issuerConfigKeyMap: Record<\n string,\n { toKey: string; convertToUrl?: boolean }\n> = {\n issuer: {\n toKey: \"issuer\",\n convertToUrl: true,\n },\n authorization_endpoint: {\n toKey: \"authorizationEndpoint\",\n convertToUrl: true,\n },\n token_endpoint: {\n toKey: \"tokenEndpoint\",\n convertToUrl: true,\n },\n userinfo_endpoint: {\n toKey: \"userinfoEndpoint\",\n convertToUrl: true,\n },\n jwks_uri: {\n toKey: \"jwksUri\",\n convertToUrl: true,\n },\n registration_endpoint: {\n toKey: \"registrationEndpoint\",\n convertToUrl: true,\n },\n end_session_endpoint: {\n toKey: \"endSessionEndpoint\",\n convertToUrl: true,\n },\n scopes_supported: { toKey: \"scopesSupported\" },\n response_types_supported: { toKey: \"responseTypesSupported\" },\n response_modes_supported: { toKey: \"responseModesSupported\" },\n grant_types_supported: { toKey: \"grantTypesSupported\" },\n acr_values_supported: { toKey: \"acrValuesSupported\" },\n subject_types_supported: { toKey: \"subjectTypesSupported\" },\n id_token_signing_alg_values_supported: {\n toKey: \"idTokenSigningAlgValuesSupported\",\n },\n id_token_encryption_alg_values_supported: {\n toKey: \"idTokenEncryptionAlgValuesSupported\",\n },\n id_token_encryption_enc_values_supported: {\n toKey: \"idTokenEncryptionEncValuesSupported\",\n },\n userinfo_signing_alg_values_supported: {\n toKey: \"userinfoSigningAlgValuesSupported\",\n },\n userinfo_encryption_alg_values_supported: {\n toKey: \"userinfoEncryptionAlgValuesSupported\",\n },\n userinfo_encryption_enc_values_supported: {\n toKey: \"userinfoEncryptionEncValuesSupported\",\n },\n request_object_signing_alg_values_supported: {\n toKey: \"requestObjectSigningAlgValuesSupported\",\n },\n request_object_encryption_alg_values_supported: {\n toKey: \"requestObjectEncryptionAlgValuesSupported\",\n },\n request_object_encryption_enc_values_supported: {\n toKey: \"requestObjectEncryptionEncValuesSupported\",\n },\n token_endpoint_auth_methods_supported: {\n toKey: \"tokenEndpointAuthMethodsSupported\",\n },\n token_endpoint_auth_signing_alg_values_supported: {\n toKey: \"tokenEndpointAuthSigningAlgValuesSupported\",\n },\n display_values_supported: { toKey: \"displayValuesSupported\" },\n claim_types_supported: { toKey: \"claimTypesSupported\" },\n claims_supported: { toKey: \"claimsSupported\" },\n service_documentation: { toKey: \"serviceDocumentation\" },\n claims_locales_supported: { toKey: \"claimsLocalesSupported\" },\n ui_locales_supported: { toKey: \"uiLocalesSupported\" },\n claims_parameter_supported: { toKey: \"claimsParameterSupported\" },\n request_parameter_supported: { toKey: \"requestParameterSupported\" },\n request_uri_parameter_supported: { toKey: \"requestUriParameterSupported\" },\n require_request_uri_registration: { toKey: \"requireRequestUriRegistration\" },\n op_policy_uri: {\n toKey: \"opPolicyUri\",\n convertToUrl: true,\n },\n op_tos_uri: {\n toKey: \"opTosUri\",\n convertToUrl: true,\n },\n};\n/* eslint-enable camelcase */\n\nfunction processConfig(\n config: Record<string, string | string[]>\n): IIssuerConfig {\n const parsedConfig: Record<string, string | string[]> = {};\n Object.keys(config).forEach((key) => {\n if (issuerConfigKeyMap[key]) {\n // TODO: PMcB55: Validate URL if \"issuerConfigKeyMap[key].convertToUrl\"\n // if (issuerConfigKeyMap[key].convertToUrl) {\n // validateUrl(config[key]);\n // }\n parsedConfig[issuerConfigKeyMap[key].toKey] = config[key];\n }\n });\n if (!Array.isArray(parsedConfig.scopesSupported)) {\n parsedConfig.scopesSupported = [\"openid\"];\n }\n return parsedConfig as unknown as IIssuerConfig;\n}\n\n/**\n * @hidden\n */\nexport default class IssuerConfigFetcher implements IIssuerConfigFetcher {\n constructor(private storageUtility: IStorageUtility) {}\n\n // This method needs no state (so can be static), and can be exposed to allow\n // callers to know where this implementation puts state it needs.\n public static getLocalStorageKey(issuer: string): string {\n return `issuerConfig:${issuer}`;\n }\n\n async fetchConfig(issuer: string): Promise<IIssuerConfig> {\n let issuerConfig: IIssuerConfig;\n\n const openIdConfigUrl = new URL(\n WELL_KNOWN_OPENID_CONFIG,\n // Make sure to append a slash at issuer URL, so that the .well-known URL\n // includes the full issuer path. See https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig.\n issuer.endsWith(\"/\") ? issuer : `${issuer}/`\n ).href;\n const issuerConfigRequestBody = await uniFetch.call(\n globalThis,\n openIdConfigUrl\n );\n // Check the validity of the fetched config\n try {\n issuerConfig = processConfig(await issuerConfigRequestBody.json());\n } catch (err) {\n throw new ConfigurationError(\n `[${issuer.toString()}] has an invalid configuration: ${\n (err as { message: string }).message\n }`\n );\n }\n\n // Update store with fetched config\n await this.storageUtility.set(\n IssuerConfigFetcher.getLocalStorageKey(issuer),\n JSON.stringify(issuerConfig)\n );\n\n return issuerConfig;\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n ISessionInfo,\n ISessionInfoManager,\n ISessionInternalInfo,\n IStorageUtility,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n isSupportedTokenType,\n clear as clearBase,\n SessionInfoManagerBase,\n} from \"@inrupt/solid-client-authn-core\";\nimport { clearOidcPersistentStorage } from \"@inrupt/oidc-client-ext\";\n\nexport { getUnauthenticatedSession } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @param sessionId\n * @param storage\n * @hidden\n */\nexport async function clear(\n sessionId: string,\n storage: IStorageUtility\n): Promise<void> {\n await clearBase(sessionId, storage);\n await clearOidcPersistentStorage();\n}\n\n/**\n * @hidden\n */\nexport class SessionInfoManager\n extends SessionInfoManagerBase\n implements ISessionInfoManager\n{\n async get(\n sessionId: string\n ): Promise<(ISessionInfo & ISessionInternalInfo) | undefined> {\n const isLoggedIn = await this.storageUtility.getForUser(\n sessionId,\n \"isLoggedIn\",\n {\n secure: true,\n }\n );\n\n const webId = await this.storageUtility.getForUser(sessionId, \"webId\", {\n secure: true,\n });\n\n const clientId = await this.storageUtility.getForUser(\n sessionId,\n \"clientId\",\n {\n secure: false,\n }\n );\n\n const clientSecret = await this.storageUtility.getForUser(\n sessionId,\n \"clientSecret\",\n {\n secure: false,\n }\n );\n\n const redirectUrl = await this.storageUtility.getForUser(\n sessionId,\n \"redirectUrl\",\n {\n secure: false,\n }\n );\n\n const refreshToken = await this.storageUtility.getForUser(\n sessionId,\n \"refreshToken\",\n {\n secure: true,\n }\n );\n\n const issuer = await this.storageUtility.getForUser(sessionId, \"issuer\", {\n secure: false,\n });\n\n const tokenType =\n (await this.storageUtility.getForUser(sessionId, \"tokenType\", {\n secure: false,\n })) ?? \"DPoP\";\n\n if (!isSupportedTokenType(tokenType)) {\n throw new Error(`Tokens of type [${tokenType}] are not supported.`);\n }\n\n if (\n clientId === undefined &&\n isLoggedIn === undefined &&\n webId === undefined &&\n refreshToken === undefined\n ) {\n return undefined;\n }\n\n return {\n sessionId,\n webId,\n isLoggedIn: isLoggedIn === \"true\",\n redirectUrl,\n refreshToken,\n issuer,\n clientAppId: clientId,\n clientAppSecret: clientSecret,\n tokenType,\n };\n }\n\n /**\n * This function removes all session-related information from storage.\n * @param sessionId the session identifier\n * @param storage the storage where session info is stored\n * @hidden\n */\n async clear(sessionId: string): Promise<void> {\n return clear(sessionId, this.storageUtility);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IIncomingRedirectHandler,\n ISessionInfo,\n} from \"@inrupt/solid-client-authn-core\";\n\nimport { getUnauthenticatedSession } from \"../../../sessionInfo/SessionInfoManager\";\n\n/**\n * This class handles redirect IRIs without any query params, and returns an unauthenticated\n * session. It serves as a fallback so that consuming libraries don't have to test\n * for the query params themselves, and can always try to use them as a redirect IRI.\n * @hidden\n */\nexport class FallbackRedirectHandler implements IIncomingRedirectHandler {\n async canHandle(redirectUrl: string): Promise<boolean> {\n try {\n // The next URL object is built for validating it.\n // eslint-disable-next-line no-new\n new URL(redirectUrl);\n return true;\n } catch (e) {\n throw new Error(\n `[${redirectUrl}] is not a valid URL, and cannot be used as a redirect URL: ${e}`\n );\n }\n }\n\n async handle(\n // The argument is ignored, but must be present to implement the interface\n _redirectUrl: string\n ): Promise<ISessionInfo & { fetch: typeof fetch }> {\n return getUnauthenticatedSession();\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n// FIXME: The following doesn't work in the browser, it results in all the fetches\n// being unauthenticated. This should be looked into when migrating to universal-fetch.\n// import { fetch } from \"cross-fetch\";\n\nimport { fetch as uniFetch } from \"@inrupt/universal-fetch\";\n\nimport type {\n IClient,\n IClientRegistrar,\n IIssuerConfigFetcher,\n IIncomingRedirectHandler,\n ISessionInfoManager,\n IStorageUtility,\n ITokenRefresher,\n RefreshOptions,\n IncomingRedirectResult,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n buildAuthenticatedFetch,\n loadOidcContextFromStorage,\n maybeBuildRpInitiatedLogout,\n} from \"@inrupt/solid-client-authn-core\";\nimport type { CodeExchangeResult } from \"@inrupt/oidc-client-ext\";\nimport { getDpopToken, getBearerToken } from \"@inrupt/oidc-client-ext\";\nimport type { EventEmitter } from \"events\";\n\nconst globalFetch: typeof uniFetch = (...args) =>\n uniFetch.call(globalThis, ...args);\n\n/**\n * @hidden\n */\nexport class AuthCodeRedirectHandler implements IIncomingRedirectHandler {\n constructor(\n private storageUtility: IStorageUtility,\n private sessionInfoManager: ISessionInfoManager,\n private issuerConfigFetcher: IIssuerConfigFetcher,\n private clientRegistrar: IClientRegistrar,\n private tokerRefresher: ITokenRefresher\n ) {}\n\n async canHandle(redirectUrl: string): Promise<boolean> {\n try {\n const myUrl = new URL(redirectUrl);\n return (\n myUrl.searchParams.get(\"code\") !== null &&\n myUrl.searchParams.get(\"state\") !== null\n );\n } catch (e) {\n throw new Error(\n `[${redirectUrl}] is not a valid URL, and cannot be used as a redirect URL: ${e}`\n );\n }\n }\n\n async handle(\n redirectUrl: string,\n eventEmitter?: EventEmitter\n ): Promise<IncomingRedirectResult> {\n if (!(await this.canHandle(redirectUrl))) {\n throw new Error(\n `AuthCodeRedirectHandler cannot handle [${redirectUrl}]: it is missing one of [code, state].`\n );\n }\n\n const url = new URL(redirectUrl);\n const oauthState = url.searchParams.get(\"state\") as string;\n\n const storedSessionId = (await this.storageUtility.getForUser(\n oauthState,\n \"sessionId\",\n {\n errorIfNull: true,\n }\n )) as string;\n\n const {\n issuerConfig,\n codeVerifier,\n redirectUrl: storedRedirectIri,\n dpop: isDpop,\n } = await loadOidcContextFromStorage(\n storedSessionId,\n this.storageUtility,\n this.issuerConfigFetcher\n );\n\n const iss = url.searchParams.get(\"iss\");\n\n if (typeof iss === \"string\" && iss !== issuerConfig.issuer) {\n throw new Error(\n `The value of the iss parameter (${iss}) does not match the issuer identifier of the authorization server (${issuerConfig.issuer}). See [rfc9207](https://www.rfc-editor.org/rfc/rfc9207.html#section-2.3-3.1.1)`\n );\n }\n\n if (codeVerifier === undefined) {\n throw new Error(\n `The code verifier for session ${storedSessionId} is missing from storage.`\n );\n }\n\n if (storedRedirectIri === undefined) {\n throw new Error(\n `The redirect URL for session ${storedSessionId} is missing from storage.`\n );\n }\n\n const client: IClient = await this.clientRegistrar.getClient(\n { sessionId: storedSessionId },\n issuerConfig\n );\n\n let tokens: CodeExchangeResult;\n const tokenCreatedAt = Date.now();\n\n if (isDpop) {\n tokens = await getDpopToken(issuerConfig, client, {\n grantType: \"authorization_code\",\n // We rely on our 'canHandle' function checking that the OAuth 'code'\n // parameter is present in our query string.\n code: url.searchParams.get(\"code\") as string,\n codeVerifier,\n redirectUrl: storedRedirectIri,\n });\n\n // Delete oidc-client-specific session information from storage. This is\n // done automatically when retrieving a bearer token, but since the DPoP\n // binding uses our custom code, this needs to be done manually.\n window.localStorage.removeItem(`oidc.${oauthState}`);\n } else {\n tokens = await getBearerToken(url.toString());\n }\n\n let refreshOptions: RefreshOptions | undefined;\n if (tokens.refreshToken !== undefined) {\n refreshOptions = {\n sessionId: storedSessionId,\n refreshToken: tokens.refreshToken,\n tokenRefresher: this.tokerRefresher,\n };\n }\n\n const authFetch = await buildAuthenticatedFetch(\n globalFetch,\n tokens.accessToken,\n {\n dpopKey: tokens.dpopKey,\n refreshOptions,\n eventEmitter,\n expiresIn: tokens.expiresIn,\n }\n );\n\n await this.storageUtility.setForUser(\n storedSessionId,\n {\n webId: tokens.webId,\n isLoggedIn: \"true\",\n },\n { secure: true }\n );\n\n const sessionInfo = await this.sessionInfoManager.get(storedSessionId);\n if (!sessionInfo) {\n throw new Error(`Could not retrieve session: [${storedSessionId}].`);\n }\n\n return Object.assign(sessionInfo, {\n fetch: authFetch,\n getLogoutUrl: maybeBuildRpInitiatedLogout({\n idTokenHint: tokens.idToken,\n endSessionEndpoint: issuerConfig.endSessionEndpoint,\n }),\n expirationDate:\n typeof tokens.expiresIn === \"number\"\n ? tokenCreatedAt + tokens.expiresIn * 1000\n : undefined,\n } as IncomingRedirectResult);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Responsible for selecting the correct OidcHandler to handle the provided OIDC Options\n */\nimport type {\n IIncomingRedirectHandler,\n IncomingRedirectInput,\n IncomingRedirectResult,\n} from \"@inrupt/solid-client-authn-core\";\nimport { AggregateHandler } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @hidden\n */\nexport default class AggregateRedirectHandler\n extends AggregateHandler<IncomingRedirectInput, IncomingRedirectResult>\n implements IIncomingRedirectHandler\n{\n constructor(redirectHandlers: IIncomingRedirectHandler[]) {\n super(redirectHandlers);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type { IStorage } from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @hidden\n */\nexport default class BrowserStorage implements IStorage {\n get storage(): typeof window.localStorage {\n return window.localStorage;\n }\n\n async get(key: string): Promise<string | undefined> {\n return this.storage.getItem(key) || undefined;\n }\n\n async set(key: string, value: string): Promise<void> {\n this.storage.setItem(key, value);\n }\n\n async delete(key: string): Promise<void> {\n this.storage.removeItem(key);\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IRedirector,\n IRedirectorOptions,\n} from \"@inrupt/solid-client-authn-core\";\n\n/**\n * @hidden\n */\nexport default class Redirector implements IRedirector {\n redirect(redirectUrl: string, options?: IRedirectorOptions): void {\n if (options && options.handleRedirect) {\n options.handleRedirect(redirectUrl);\n } else if (options && options.redirectByReplacingState) {\n window.history.replaceState({}, \"\", redirectUrl);\n } else {\n window.location.href = redirectUrl;\n }\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IStorageUtility,\n IClientRegistrar,\n IIssuerConfig,\n IClient,\n IClientRegistrarOptions,\n} from \"@inrupt/solid-client-authn-core\";\nimport { registerClient } from \"@inrupt/oidc-client-ext\";\n\n/**\n * @hidden\n */\nexport default class ClientRegistrar implements IClientRegistrar {\n constructor(private storageUtility: IStorageUtility) {}\n\n async getClient(\n options: IClientRegistrarOptions,\n issuerConfig: IIssuerConfig\n ): Promise<IClient> {\n // If client secret and/or client id are stored in storage, use those.\n const [\n storedClientId,\n storedClientSecret,\n // storedClientName,\n ] = await Promise.all([\n this.storageUtility.getForUser(options.sessionId, \"clientId\", {\n secure: false,\n }),\n this.storageUtility.getForUser(options.sessionId, \"clientSecret\", {\n secure: false,\n }),\n // this.storageUtility.getForUser(options.sessionId, \"clientName\", {\n // // FIXME: figure out how to persist secure storage at reload\n // secure: false,\n // }),\n ]);\n if (storedClientId) {\n return {\n clientId: storedClientId,\n clientSecret: storedClientSecret,\n clientType: \"dynamic\",\n };\n }\n\n try {\n const registeredClient = await registerClient(options, issuerConfig);\n // Save info\n const infoToSave: Record<string, string> = {\n clientId: registeredClient.clientId,\n };\n if (registeredClient.clientSecret) {\n infoToSave.clientSecret = registeredClient.clientSecret;\n }\n if (registeredClient.idTokenSignedResponseAlg) {\n infoToSave.idTokenSignedResponseAlg =\n registeredClient.idTokenSignedResponseAlg;\n }\n await this.storageUtility.setForUser(options.sessionId, infoToSave, {\n // FIXME: figure out how to persist secure storage at reload\n // Otherwise, the client info cannot be retrieved from storage, and\n // the lib tries to re-register the client on each fetch\n secure: false,\n });\n return registeredClient;\n } catch (error) {\n throw new Error(`Client registration failed: [${error}]`);\n }\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IIncomingRedirectHandler,\n ISessionInfo,\n} from \"@inrupt/solid-client-authn-core\";\nimport { EVENTS } from \"@inrupt/solid-client-authn-core\";\nimport type { EventEmitter } from \"events\";\n\nimport { getUnauthenticatedSession } from \"../../../sessionInfo/SessionInfoManager\";\n\n/**\n * This class handles redirect IRIs without any query params, and returns an unauthenticated\n * session. It serves as a fallback so that consuming libraries don't have to test\n * for the query params themselves, and can always try to use them as a redirect IRI.\n * @hidden\n */\nexport class ErrorOidcHandler implements IIncomingRedirectHandler {\n async canHandle(redirectUrl: string): Promise<boolean> {\n try {\n // eslint-disable-next-line no-new\n return new URL(redirectUrl).searchParams.has(\"error\");\n } catch (e) {\n throw new Error(\n `[${redirectUrl}] is not a valid URL, and cannot be used as a redirect URL: ${e}`\n );\n }\n }\n\n async handle(\n redirectUrl: string,\n eventEmitter?: EventEmitter\n ): Promise<ISessionInfo & { fetch: typeof fetch }> {\n if (eventEmitter !== undefined) {\n const url = new URL(redirectUrl);\n const errorUrl = url.searchParams.get(\"error\");\n const errorDescriptionUrl = url.searchParams.get(\"error_description\");\n eventEmitter.emit(EVENTS.ERROR, errorUrl, errorDescriptionUrl);\n }\n return getUnauthenticatedSession();\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\nimport type {\n IClient,\n IClientRegistrar,\n IIssuerConfigFetcher,\n IStorageUtility,\n KeyPair,\n ITokenRefresher,\n TokenEndpointResponse,\n} from \"@inrupt/solid-client-authn-core\";\nimport {\n loadOidcContextFromStorage,\n EVENTS,\n} from \"@inrupt/solid-client-authn-core\";\nimport { refresh } from \"@inrupt/oidc-client-ext\";\nimport type { EventEmitter } from \"events\";\n\n// Some identifiers are not in camelcase on purpose, as they are named using the\n// official names from the OIDC/OAuth2 specifications.\n/* eslint-disable camelcase */\n\n/**\n * @hidden\n */\nexport default class TokenRefresher implements ITokenRefresher {\n constructor(\n private storageUtility: IStorageUtility,\n private issuerConfigFetcher: IIssuerConfigFetcher,\n private clientRegistrar: IClientRegistrar\n ) {}\n\n async refresh(\n sessionId: string,\n refreshToken?: string,\n dpopKey?: KeyPair,\n eventEmitter?: EventEmitter\n ): Promise<TokenEndpointResponse> {\n const oidcContext = await loadOidcContextFromStorage(\n sessionId,\n this.storageUtility,\n this.issuerConfigFetcher\n );\n // This should also retrieve the client from storage\n const clientInfo: IClient = await this.clientRegistrar.getClient(\n { sessionId },\n oidcContext.issuerConfig\n );\n\n if (refreshToken === undefined) {\n // TODO: in a next PR, look up storage for a refresh token\n throw new Error(\n `Session [${sessionId}] has no refresh token to allow it to refresh its access token.`\n );\n }\n\n if (oidcContext.dpop && dpopKey === undefined) {\n throw new Error(\n `For session [${sessionId}], the key bound to the DPoP access token must be provided to refresh said access token.`\n );\n }\n\n const tokenSet = await refresh(\n refreshToken,\n oidcContext.issuerConfig,\n clientInfo,\n dpopKey\n );\n\n if (tokenSet.refreshToken !== undefined) {\n eventEmitter?.emit(EVENTS.NEW_REFRESH_TOKEN, tokenSet.refreshToken);\n await this.storageUtility.setForUser(sessionId, {\n refreshToken: tokenSet.refreshToken,\n });\n }\n return tokenSet;\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n * @packageDocumentation\n */\n\n/**\n * Top Level core document. Responsible for setting up the dependency graph\n */\nimport type { IStorage } from \"@inrupt/solid-client-authn-core\";\nimport {\n InMemoryStorage,\n IWaterfallLogoutHandler,\n} from \"@inrupt/solid-client-authn-core\";\nimport StorageUtilityBrowser from \"./storage/StorageUtility\";\nimport ClientAuthentication from \"./ClientAuthentication\";\nimport OidcLoginHandler from \"./login/oidc/OidcLoginHandler\";\nimport AuthorizationCodeWithPkceOidcHandler from \"./login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler\";\nimport IssuerConfigFetcher from \"./login/oidc/IssuerConfigFetcher\";\nimport { FallbackRedirectHandler } from \"./login/oidc/incomingRedirectHandler/FallbackRedirectHandler\";\nimport { SessionInfoManager } from \"./sessionInfo/SessionInfoManager\";\nimport { AuthCodeRedirectHandler } from \"./login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler\";\nimport AggregateRedirectHandler from \"./login/oidc/AggregateRedirectHandler\";\nimport BrowserStorage from \"./storage/BrowserStorage\";\nimport Redirector from \"./login/oidc/Redirector\";\nimport ClientRegistrar from \"./login/oidc/ClientRegistrar\";\nimport { ErrorOidcHandler } from \"./login/oidc/incomingRedirectHandler/ErrorOidcHandler\";\nimport TokenRefresher from \"./login/oidc/refresh/TokenRefresher\";\n\n/**\n *\n * @param dependencies\n * @deprecated This function will be removed from the external API in an upcoming release.\n */\nexport function getClientAuthenticationWithDependencies(dependencies: {\n secureStorage?: IStorage;\n insecureStorage?: IStorage;\n}): ClientAuthentication {\n const inMemoryStorage = new InMemoryStorage();\n const secureStorage = dependencies.secureStorage || inMemoryStorage;\n const insecureStorage = dependencies.insecureStorage || new BrowserStorage();\n\n const storageUtility = new StorageUtilityBrowser(\n secureStorage,\n insecureStorage\n );\n\n const issuerConfigFetcher = new IssuerConfigFetcher(storageUtility);\n const clientRegistrar = new ClientRegistrar(storageUtility);\n\n const sessionInfoManager = new SessionInfoManager(storageUtility);\n\n const tokenRefresher = new TokenRefresher(\n storageUtility,\n issuerConfigFetcher,\n clientRegistrar\n );\n\n const redirector = new Redirector();\n\n // make new handler for redirect and login\n const loginHandler = new OidcLoginHandler(\n storageUtility,\n new AuthorizationCodeWithPkceOidcHandler(storageUtility, redirector),\n issuerConfigFetcher,\n clientRegistrar\n );\n\n const redirectHandler = new AggregateRedirectHandler([\n new ErrorOidcHandler(),\n new AuthCodeRedirectHandler(\n storageUtility,\n sessionInfoManager,\n issuerConfigFetcher,\n clientRegistrar,\n tokenRefresher\n ),\n // This catch-all class will always be able to handle the\n // redirect IRI, so it must be registered last.\n new FallbackRedirectHandler(),\n ]);\n\n return new ClientAuthentication(\n loginHandler,\n redirectHandler,\n new IWaterfallLogoutHandler(sessionInfoManager, redirector),\n sessionInfoManager,\n issuerConfigFetcher\n );\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\nimport { SOLID_CLIENT_AUTHN_KEY_PREFIX } from \"@inrupt/solid-client-authn-core\";\n\nexport const KEY_CURRENT_SESSION = `${SOLID_CLIENT_AUTHN_KEY_PREFIX}currentSession`;\n\nexport const KEY_CURRENT_URL = `${SOLID_CLIENT_AUTHN_KEY_PREFIX}currentUrl`;\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\n/**\n * @hidden\n */\nimport type {\n ILoginInputOptions,\n ISessionInfo,\n IStorage,\n IHasSessionEventListener,\n ISessionEventListener,\n ILogoutOptions,\n} from \"@inrupt/solid-client-authn-core\";\nimport { EVENTS, buildProxyHandler } from \"@inrupt/solid-client-authn-core\";\nimport type { fetch } from \"@inrupt/universal-fetch\";\nimport { v4 } from \"uuid\";\nimport EventEmitter from \"events\";\nimport type ClientAuthentication from \"./ClientAuthentication\";\nimport { getClientAuthenticationWithDependencies } from \"./dependencies\";\nimport { KEY_CURRENT_SESSION, KEY_CURRENT_URL } from \"./constant\";\n\nexport interface ISessionOptions {\n /**\n * A private storage, unreachable to other scripts on the page. Typically in-memory.\n */\n secureStorage: IStorage;\n /**\n * A storage where non-sensitive information may be stored, potentially longer-lived than the secure storage.\n */\n insecureStorage: IStorage;\n /**\n * Details about the current session\n */\n sessionInfo: ISessionInfo;\n /**\n * An instance of the library core. Typically obtained using `getClientAuthenticationWithDependencies`.\n */\n clientAuthentication: ClientAuthentication;\n}\n\nexport interface IHandleIncomingRedirectOptions {\n /**\n * If the user has signed in before, setting this to `true` will automatically\n * redirect them to their Solid Identity Provider, which will then attempt to\n * re-activate the session and send the user back to your app without\n * requiring user interaction.\n * If your app's access has not expired yet and re-activation completed\n * successfully, a `sessionRestore` event will be fired with the URL the user\n * was at before they were redirected to their Solid Identity Provider.\n * {@see onSessionRestore}\n */\n restorePreviousSession?: boolean;\n\n /**\n * Inrupt's Enterprise Solid Server can set a cookie to allow the browser to\n * access private resources on a Pod. In order to mitigate the logout-on-refresh\n * issue on the short term, the server also implemented a session endpoint\n * enabling the client app to know whether the cookie is set. When a user\n * logs in to a server that has that capability enabled, applications that set\n * this option to `true` will be able to make use of it.\n *\n * If your app supports the newest session restore approach, and `restorePreviousSession`\n * is set to true, this option is automatically set to false, but your app will\n * not be logged out when reloaded.\n *\n * `useEssSession` defaults to false and will be removed in the future; to\n * preserve sessions across page reloads, use of `restorePreviousSession` is\n * recommended.\n *\n * @deprecated unreleased\n */\n useEssSession?: boolean;\n /**\n * The URL of the page handling the redirect, including the query\n * parameters — these contain the information to process the login.\n * Note: as a convenience, if no URL value is specified here, we default to\n * using the browser's current location.\n */\n url?: string;\n}\n\nexport async function silentlyAuthenticate(\n sessionId: string,\n clientAuthn: ClientAuthentication,\n session: Session\n): Promise<boolean> {\n const storedSessionInfo = await clientAuthn.validateCurrentSession(sessionId);\n if (storedSessionInfo !== null) {\n // It can be really useful to save the user's current browser location,\n // so that we can restore it after completing the silent authentication\n // on incoming redirect. This way, the user is eventually redirected back\n // to the page they were on and not to the app's redirect page.\n window.localStorage.setItem(KEY_CURRENT_URL, window.location.href);\n await clientAuthn.login(\n {\n sessionId,\n prompt: \"none\",\n oidcIssuer: storedSessionInfo.issuer,\n redirectUrl: storedSessionInfo.redirectUrl,\n clientId: storedSessionInfo.clientAppId,\n clientSecret: storedSessionInfo.clientAppSecret,\n tokenType: storedSessionInfo.tokenType ?? \"DPoP\",\n },\n session.events\n );\n return true;\n }\n return false;\n}\n\nfunction isLoggedIn(\n sessionInfo?: ISessionInfo\n): sessionInfo is ISessionInfo & { isLoggedIn: true } {\n return !!sessionInfo?.isLoggedIn;\n}\n\n/**\n * A {@link Session} object represents a user's session on an application. The session holds state, as it stores information enabling acces to private resources after login for instance.\n */\nexport class Session extends EventEmitter implements IHasSessionEventListener {\n /**\n * Information regarding the current session.\n */\n public readonly info: ISessionInfo;\n\n /**\n * Session attribute exposing the EventEmitter interface, to listen on session\n * events such as login, logout, etc.\n * @since 1.15.0\n */\n public readonly events: ISessionEventListener;\n\n private clientAuthentication: ClientAuthentication;\n\n private tokenRequestInProgress = false;\n\n /**\n * Session object constructor. Typically called as follows:\n *\n * ```typescript\n * const session = new Session();\n * ```\n *\n * See also [getDefaultSession](https://docs.inrupt.com/developer-tools/api/javascript/solid-client-authn-browser/functions.html#getdefaultsession).\n *\n * @param sessionOptions The options enabling the correct instantiation of\n * the session. Either both storages or clientAuthentication are required. For\n * more information, see {@link ISessionOptions}.\n * @param sessionId A string uniquely identifying the session.\n *\n */\n constructor(\n sessionOptions: Partial<ISessionOptions> = {},\n sessionId: string | undefined = undefined\n ) {\n super();\n // Until Session no longer implements EventEmitter, this.events is just a proxy\n // to this (with some interface filtering). When we make the breaking change,\n // this.events will be a regular EventEmitter (implementing ISessionEventEmitter):\n // this.events = new EventEmitter();\n this.events = new Proxy(\n this,\n buildProxyHandler(\n Session.prototype,\n \"events only implements ISessionEventListener\"\n )\n );\n if (sessionOptions.clientAuthentication) {\n this.clientAuthentication = sessionOptions.clientAuthentication;\n } else if (sessionOptions.secureStorage && sessionOptions.insecureStorage) {\n this.clientAuthentication = getClientAuthenticationWithDependencies({\n secureStorage: sessionOptions.secureStorage,\n insecureStorage: sessionOptions.insecureStorage,\n });\n } else {\n this.clientAuthentication = getClientAuthenticationWithDependencies({});\n }\n\n if (sessionOptions.sessionInfo) {\n this.info = {\n sessionId: sessionOptions.sessionInfo.sessionId,\n isLoggedIn: false,\n webId: sessionOptions.sessionInfo.webId,\n };\n } else {\n this.info = {\n sessionId: sessionId ?? v4(),\n isLoggedIn: false,\n };\n }\n\n // When a session is logged in, we want to track its ID in local storage to\n // enable silent refresh. The current session ID specifically stored in 'localStorage'\n // (as opposed to using our storage abstraction layer) because it is only\n // used in a browser-specific mechanism.\n this.events.on(EVENTS.LOGIN, () =>\n window.localStorage.setItem(KEY_CURRENT_SESSION, this.info.sessionId)\n );\n\n this.events.on(EVENTS.SESSION_EXPIRED, () => this.internalLogout(false));\n\n this.events.on(EVENTS.ERROR, () => this.internalLogout(false));\n }\n\n /**\n * Triggers the login process. Note that this method will redirect the user away from your app.\n *\n * @param options Parameter to customize the login behaviour. In particular, two options are mandatory: `options.oidcIssuer`, the user's identity provider, and `options.redirectUrl`, the URL to which the user will be redirected after logging in their identity provider.\n * @returns This method should redirect the user away from the app: it does not return anything. The login process is completed by {@linkcode handleIncomingRedirect}.\n */\n // Define these functions as properties so that they don't get accidentally re-bound.\n // Isn't Javascript fun?\n login = async (options: ILoginInputOptions): Promise<void> => {\n await this.clientAuthentication.login(\n {\n sessionId: this.info.sessionId,\n ...options,\n // Defaults the token type to DPoP\n tokenType: options.tokenType ?? \"DPoP\",\n },\n this.events\n );\n // `login` redirects the user away from the app,\n // so unless it throws an error, there is no code that should run afterwards\n // (since there is no \"after\" in the lifetime of the script).\n // Hence, this Promise never resolves:\n return new Promise(() => {});\n };\n\n /**\n * Fetches data using available login information. If the user is not logged in, this will behave as a regular `fetch`. The signature of this method is identical to the [canonical `fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).\n *\n * @param url The URL from which data should be fetched.\n * @param init Optional parameters customizing the request, by specifying an HTTP method, headers, a body, etc. Follows the [WHATWG Fetch Standard](https://fetch.spec.whatwg.org/).\n */\n fetch: typeof fetch = (url, init) =>\n this.clientAuthentication.fetch(url, init);\n\n /**\n * An internal logout function, to control whether or not the logout signal\n * should be sent, i.e. if the logout was user-initiated or is the result of\n * an external event.\n *\n * @hidden\n */\n private internalLogout = async (\n emitSignal: boolean,\n options?: ILogoutOptions\n ): Promise<void> => {\n // Clearing this value means that silent refresh will no longer be attempted.\n // In particular, in the case of a silent authentication error it prevents\n // from getting stuck in an authentication retries loop.\n window.localStorage.removeItem(KEY_CURRENT_SESSION);\n await this.clientAuthentication.logout(this.info.sessionId, options);\n this.info.isLoggedIn = false;\n if (emitSignal) {\n (this.events as EventEmitter).emit(EVENTS.LOGOUT);\n }\n };\n\n /**\n * Logs the user out of the application.\n *\n * There are 2 types of logout supported by this library,\n * `app` logout and `idp` logout.\n *\n * App logout will log the user out within the application\n * by clearing any session data from the browser. It does\n * not log the user out of their Solid identity provider,\n * and should not redirect the user away.\n * App logout can be performed as follows:\n * ```typescript\n * await session.logout({ logoutType: 'app' });\n * ```\n *\n * IDP logout will log the user out of their Solid identity provider,\n * and will redirect the user away from the application to do so.\n * IDP logout can be performed as follows:\n * ```typescript\n * await session.logout({\n * logoutType: 'idp',\n * // An optional URL to redirect to after logout has completed;\n * // this MUST match a logout URL listed in the clientId of\n * // the application that is logged in.\n * postLogoutUrl: 'https://example.com/logout',\n * // An optional value to be included in the query parameters\n * // when the IDP provider redirects the user to the postLogoutRedirectUrl.\n * state: \"my-state\"\n * });\n * ```\n */\n logout = async (options?: ILogoutOptions): Promise<void> =>\n this.internalLogout(true, options);\n\n /**\n * Completes the login process by processing the information provided by the\n * Solid identity provider through redirect.\n *\n * @param options See {@see IHandleIncomingRedirectOptions}.\n */\n handleIncomingRedirect = async (\n inputOptions: string | IHandleIncomingRedirectOptions = {}\n ): Promise<ISessionInfo | undefined> => {\n if (this.info.isLoggedIn) {\n return this.info;\n }\n\n if (this.tokenRequestInProgress) {\n return undefined;\n }\n const options =\n typeof inputOptions === \"string\" ? { url: inputOptions } : inputOptions;\n const url = options.url ?? window.location.href;\n\n this.tokenRequestInProgress = true;\n const sessionInfo = await this.clientAuthentication.handleIncomingRedirect(\n url,\n this.events\n );\n if (isLoggedIn(sessionInfo)) {\n this.setSessionInfo(sessionInfo);\n const currentUrl = window.localStorage.getItem(KEY_CURRENT_URL);\n if (currentUrl === null) {\n // The login event can only be triggered **after** the user has been\n // redirected from the IdP with access and ID tokens.\n (this.events as EventEmitter).emit(EVENTS.LOGIN);\n } else {\n // If an URL is stored in local storage, we are being logged in after a\n // silent authentication, so remove our currently stored URL location\n // to clean up our state now that we are completing the re-login process.\n window.localStorage.removeItem(KEY_CURRENT_URL);\n (this.events as EventEmitter).emit(EVENTS.SESSION_RESTORED, currentUrl);\n }\n } else if (options.restorePreviousSession === true) {\n // Silent authentication happens after a refresh, which means there are no\n // OAuth params in the current location IRI. It can only succeed if a session\n // was previously logged in, in which case its ID will be present with a known\n // identifier in local storage.\n // Check if we have a locally stored session ID...\n const storedSessionId = window.localStorage.getItem(KEY_CURRENT_SESSION);\n // ...if not, then there is no ID token, and so silent authentication cannot happen, but\n // if we do have a stored session ID, attempt to re-authenticate now silently.\n if (storedSessionId !== null) {\n const attemptedSilentAuthentication = await silentlyAuthenticate(\n storedSessionId,\n this.clientAuthentication,\n this\n );\n // At this point, we know that the main window will imminently be redirected.\n // However, this redirect is asynchronous and there is no way to halt execution\n // until it happens precisely. That's why the current Promise simply does not\n // resolve.\n if (attemptedSilentAuthentication) {\n return new Promise(() => {});\n }\n }\n }\n this.tokenRequestInProgress = false;\n return sessionInfo;\n };\n\n /**\n * Register a callback function to be called when a user completes login.\n *\n * The callback is called when {@link handleIncomingRedirect} completes successfully.\n *\n * @param callback The function called when a user completes login.\n * @deprecated Prefer session.events.on(EVENTS.LOGIN, callback)\n */\n onLogin(callback: () => unknown): void {\n this.events.on(EVENTS.LOGIN, callback);\n }\n\n /**\n * Register a callback function to be called when a user logs out:\n *\n * @param callback The function called when a user completes logout.\n * @deprecated Prefer session.events.on(EVENTS.LOGOUT, callback)\n */\n onLogout(callback: () => unknown): void {\n this.events.on(EVENTS.LOGOUT, callback);\n }\n\n /**\n * Register a callback function to be called when a user logs out:\n *\n * @param callback The function called when an error occurs.\n * @since 1.11.0\n * @deprecated Prefer session.events.on(EVENTS.ERROR, callback)\n */\n onError(\n callback: (\n error: string | null,\n errorDescription?: string | null\n ) => unknown\n ): void {\n this.events.on(EVENTS.ERROR, callback);\n }\n\n /**\n * Register a callback function to be called when a session is restored.\n *\n * Note: the callback will be called with the saved value of the 'current URL'\n * at the time the session was restored.\n *\n * @param callback The function called when a user's already logged-in session is restored, e.g., after a silent authentication is completed after a page refresh.\n * @deprecated Prefer session.events.on(EVENTS.SESSION_RESTORED, callback)\n */\n onSessionRestore(callback: (currentUrl: string) => unknown): void {\n this.events.on(EVENTS.SESSION_RESTORED, callback);\n }\n\n /**\n * Register a callback that runs when the session expires and can no longer\n * make authenticated requests, but following a user logout.\n * @param callback The function that runs on session expiration.\n * @since 1.11.0\n * @deprecated Prefer session.events.on(EVENTS.SESSION_EXPIRED, callback)\n */\n onSessionExpiration(callback: () => unknown): void {\n this.events.on(EVENTS.SESSION_EXPIRED, callback);\n }\n\n private setSessionInfo(\n sessionInfo: ISessionInfo & { isLoggedIn: true }\n ): void {\n this.info.isLoggedIn = sessionInfo.isLoggedIn;\n this.info.webId = sessionInfo.webId;\n this.info.sessionId = sessionInfo.sessionId;\n this.info.expirationDate = sessionInfo.expirationDate;\n this.events.on(EVENTS.SESSION_EXTENDED, (expiresIn: number) => {\n this.info.expirationDate = Date.now() + expiresIn * 1000;\n });\n }\n}\n","//\n// Copyright Inrupt Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal in\n// the Software without restriction, including without limitation the rights to use,\n// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the\n// Software, and to permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n//\n\nimport { Session } from \"./Session\";\n\nlet defaultSession: Session | undefined;\n\n/**\n * Obtain the {@link Session} used when not explicitly instantiating one yourself.\n *\n * When using the top-level exports {@link fetch}, {@link login}, {@link logout},\n * {@link handleIncomingRedirect}, {@link onLogin} and {@link onLogout}, these apply to an\n * implicitly-instantiated {@link Session}.\n * This function returns a reference to that Session in order to obtain e.g. the current user's\n * WebID.\n * @since 1.3.0\n */\nexport function getDefaultSession(): Session {\n if (typeof defaultSession === \"undefined\") {\n defaultSession = new Session();\n }\n return defaultSession;\n}\n\n/**\n * This function's signature is equal to `window.fetch`, but if the current user is authenticated\n * (see [[login]] and [[handleIncomingRedirect]]), requests made using it will include that user's\n * credentials. If not, this will behave just like the regular `window.fetch`.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch}\n * @since 1.3.0\n */\n/* eslint-disable-next-line no-shadow */\nexport const fetch: Session[\"fetch\"] = (...args) => {\n const session = getDefaultSession();\n return session.fetch(...args);\n};\n\n/**\n * Triggers the login process. Note that this method will redirect the user away from your app.\n *\n * @param options Parameter to customize the login behaviour. In particular, two options are mandatory: `options.oidcIssuer`, the user's identity provider, and `options.redirectUrl`, the URL to which the user will be redirected after logging in their identity provider.\n * @returns This method should redirect the user away from the app: it does not return anything. The login process is completed by [[handleIncomingRedirect]].\n * @since 1.3.0\n */\nexport const login: Session[\"login\"] = (...args) => {\n const session = getDefaultSession();\n return session.login(...args);\n};\n\n/**\n * Logs the user out of the application.\n *\n * By default this does not log the user out of their Solid identity provider.\n * In order to do so, you must set the logoutType to `idp`.\n *\n * @since 1.3.0\n */\nexport const logout: Session[\"logout\"] = (...args) => {\n const session = getDefaultSession();\n return session.logout(...args);\n};\n\n/**\n * Completes the login process by processing the information provided by the Solid identity provider through redirect.\n *\n * @param url The URL of the page handling the redirect, including the query parameters — these contain the information to process the login.\n * @since 1.3.0\n */\nexport const handleIncomingRedirect: Session[\"handleIncomingRedirect\"] = (\n ...args\n) => {\n const session = getDefaultSession();\n return session.handleIncomingRedirect(...args);\n};\n\n/**\n * Register a callback function to be called when a user completes login.\n *\n * The callback is called when {@link handleIncomingRedirect} completes successfully.\n * @since 1.3.0\n *\n * @param callback The function called when a user completes login.\n * @deprecated Prefer events.on(EVENTS.LOGIN, callback)\n\n */\nexport const onLogin: Session[\"onLogin\"] = (...args) => {\n const session = getDefaultSession();\n return session.onLogin(...args);\n};\n\n/**\n * Register a callback function to be called when a user logs out:\n *\n * @param callback The function called when a user completes logout.\n * @since 1.3.0\n * @deprecated Prefer events.on(EVENTS.LOGOUT, callback)\n\n */\nexport const onLogout: Session[\"onLogout\"] = (...args) => {\n const session = getDefaultSession();\n return session.onLogout(...args);\n};\n\n/**\n * Register a callback function to be called when a session is restored:\n *\n * @param callback The function called when a session is restored.\n * @since 1.3.0\n * @deprecated Prefer events.on(EVENTS.SESSION_RESTORED, callback)\n */\nexport const onSessionRestore: Session[\"onSessionRestore\"] = (...args) => {\n const session = getDefaultSession();\n return session.onSessionRestore(...args);\n};\n\n/**\n * {@link SessionEventEmitter} instance to subscribe to events by the default session.\n *\n * @since Unreleased\n */\nexport const events = (): Session[\"events\"] => {\n return getDefaultSession().events;\n};\n"],"names":["StorageUtility","ClientAuthenticationBase","removeOidcQueryParam","isValidRedirectUrl","EVENTS","ConfigurationError","handleRegistration","AuthorizationCodeWithPkceOidcHandlerBase","DEFAULT_SCOPES","OidcClient","uniFetch","clearBase","clearOidcPersistentStorage","SessionInfoManagerBase","isSupportedTokenType","getUnauthenticatedSession","loadOidcContextFromStorage","getDpopToken","getBearerToken","buildAuthenticatedFetch","maybeBuildRpInitiatedLogout","AggregateHandler","registerClient","refresh","InMemoryStorage","IWaterfallLogoutHandler","SOLID_CLIENT_AUTHN_KEY_PREFIX","buildProxyHandler","v4"],"mappings":";;;;;;;;AAuCqB,MAAA,qBAAsB,SAAQA,mCAAc,CAAA;IAC/D,WAAY,CAAA,aAAuB,EAAE,eAAyB,EAAA;AAC5D,QAAA,KAAK,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;KACvC;AACF;;ACDoB,MAAA,oBAAqB,SAAQC,yCAAwB,CAAA;AAA1E,IAAA,WAAA,GAAA;;AAGE,QAAA,IAAA,CAAA,KAAK,GAAG,OACN,OAAsB,EACtB,YAA0B,KACT;;YAOjB,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAQvD,YAAA,MAAM,WAAW,GACf,CAAA,EAAA,GAAA,OAAO,CAAC,WAAW,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAA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AAiB,EAAE,CAAC;AACpC,IAAA,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;AACnC,EAAE;MASW,gBAAgB,GAAgC,CAAC,GAAG,IAAI,KAAI;AACvE,IAAA,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;AACpC,IAAA,OAAO,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC;AAC3C,EAAE;AAOK,MAAM,MAAM,GAAG,MAAwB;AAC5C,IAAA,OAAO,iBAAiB,EAAE,CAAC,MAAM,CAAC;AACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -249,7 +249,7 @@ class IssuerConfigFetcher {
|
|
|
249
249
|
async fetchConfig(issuer) {
|
|
250
250
|
let issuerConfig;
|
|
251
251
|
const openIdConfigUrl = new URL(WELL_KNOWN_OPENID_CONFIG, issuer.endsWith("/") ? issuer : `${issuer}/`).href;
|
|
252
|
-
const issuerConfigRequestBody = await fetch$1(openIdConfigUrl);
|
|
252
|
+
const issuerConfigRequestBody = await fetch$1.call(globalThis, openIdConfigUrl);
|
|
253
253
|
try {
|
|
254
254
|
issuerConfig = processConfig(await issuerConfigRequestBody.json());
|
|
255
255
|
}
|
|
@@ -333,6 +333,7 @@ class FallbackRedirectHandler {
|
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
const globalFetch = (...args) => fetch$1.call(globalThis, ...args);
|
|
336
337
|
class AuthCodeRedirectHandler {
|
|
337
338
|
constructor(storageUtility, sessionInfoManager, issuerConfigFetcher, clientRegistrar, tokerRefresher) {
|
|
338
339
|
this.storageUtility = storageUtility;
|
|
@@ -394,7 +395,7 @@ class AuthCodeRedirectHandler {
|
|
|
394
395
|
tokenRefresher: this.tokerRefresher,
|
|
395
396
|
};
|
|
396
397
|
}
|
|
397
|
-
const authFetch = await buildAuthenticatedFetch(
|
|
398
|
+
const authFetch = await buildAuthenticatedFetch(globalFetch, tokens.accessToken, {
|
|
398
399
|
dpopKey: tokens.dpopKey,
|
|
399
400
|
refreshOptions,
|
|
400
401
|
eventEmitter,
|