@inrupt/solid-client-authn-browser 1.17.3 → 1.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { StorageUtility, ClientAuthentication as ClientAuthentication$1, isValidRedirectUrl, EVENTS, ConfigurationError, handleRegistration, AuthorizationCodeWithPkceOidcHandlerBase, DEFAULT_SCOPES, SessionInfoManagerBase, isSupportedTokenType, clear as clear$1, getUnauthenticatedSession, loadOidcContextFromStorage, buildAuthenticatedFetch, maybeBuildRpInitiatedLogout, AggregateHandler, InMemoryStorage, IWaterfallLogoutHandler, SOLID_CLIENT_AUTHN_KEY_PREFIX, buildProxyHandler } from '@inrupt/solid-client-authn-core';
1
+ import { StorageUtility, ClientAuthentication as ClientAuthentication$1, isValidRedirectUrl, EVENTS, removeOpenIdParams, ConfigurationError, handleRegistration, AuthorizationCodeWithPkceOidcHandlerBase, DEFAULT_SCOPES, SessionInfoManagerBase, isSupportedTokenType, clear as clear$1, getUnauthenticatedSession, loadOidcContextFromStorage, buildAuthenticatedFetch, maybeBuildRpInitiatedLogout, AggregateHandler, InMemoryStorage, IWaterfallLogoutHandler, SOLID_CLIENT_AUTHN_KEY_PREFIX, buildProxyHandler } from '@inrupt/solid-client-authn-core';
2
2
  export { ConfigurationError, EVENTS, InMemoryStorage, NotImplementedError } from '@inrupt/solid-client-authn-core';
3
3
  import { v4 } from 'uuid';
4
4
  import EventEmitter from 'events';
5
- import { removeOidcQueryParam, OidcClient, clearOidcPersistentStorage, getDpopToken, getBearerToken, registerClient, refresh } from '@inrupt/oidc-client-ext';
5
+ import { normalizeCallbackUrl, OidcClient, clearOidcPersistentStorage, getDpopToken, getBearerToken, registerClient, refresh } from '@inrupt/oidc-client-ext';
6
6
  import { fetch as fetch$1 } from '@inrupt/universal-fetch';
7
7
 
8
8
  //
@@ -81,7 +81,7 @@ class ClientAuthentication extends ClientAuthentication$1 {
81
81
  // If the user is providing a redirect IRI, it should not be modified, so
82
82
  // normalization only applies if we default to the current location (which is
83
83
  // a bad practice and should be discouraged).
84
- const redirectUrl = (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : removeOidcQueryParam(window.location.href);
84
+ const redirectUrl = (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : normalizeCallbackUrl(window.location.href);
85
85
  if (!isValidRedirectUrl(redirectUrl)) {
86
86
  throw new Error(`${redirectUrl} is not a valid redirect URL, it is either a malformed IRI, includes a hash fragment, or reserved query parameters ('code' or 'state').`);
87
87
  }
@@ -138,24 +138,14 @@ class ClientAuthentication extends ClientAuthentication$1 {
138
138
  };
139
139
  }
140
140
  async cleanUrlAfterRedirect(url) {
141
- const cleanedUpUrl = new URL(url);
142
- cleanedUpUrl.searchParams.delete("state");
143
- // For auth code flow
144
- cleanedUpUrl.searchParams.delete("code");
145
- // For implicit flow
146
- cleanedUpUrl.searchParams.delete("id_token");
147
- cleanedUpUrl.searchParams.delete("access_token");
148
- // For login error
149
- cleanedUpUrl.searchParams.delete("error");
150
- cleanedUpUrl.searchParams.delete("error_description");
151
- cleanedUpUrl.searchParams.delete("iss");
141
+ const cleanedUpUrl = removeOpenIdParams(url).href;
152
142
  // Remove OAuth-specific query params (since the login flow finishes with
153
143
  // the browser being redirected back with OAuth2 query params (e.g. for
154
144
  // 'code' and 'state'), and so if the user simply refreshes this page our
155
145
  // authentication library will be called again with what are now invalid
156
146
  // query parameters!).
157
- window.history.replaceState(null, "", cleanedUpUrl.toString());
158
- while (window.location.href !== cleanedUpUrl.href) {
147
+ window.history.replaceState(null, "", cleanedUpUrl);
148
+ while (window.location.href !== cleanedUpUrl) {
159
149
  // Poll the current URL every ms. Active polling is required because
160
150
  // window.history.replaceState is asynchronous, but the associated
161
151
  // 'popstate' event which should be listened to is only sent on active