@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inrupt/solid-client-authn-browser",
3
- "version": "1.17.3",
3
+ "version": "1.17.5",
4
4
  "license": "MIT",
5
5
  "types": "dist/index.d.ts",
6
6
  "browser": "dist/index.js",
@@ -29,15 +29,15 @@
29
29
  "@types/uuid": "^9.0.4"
30
30
  },
31
31
  "dependencies": {
32
- "@inrupt/oidc-client-ext": "^1.17.3",
33
- "@inrupt/solid-client-authn-core": "^1.17.3",
32
+ "@inrupt/oidc-client-ext": "^1.17.5",
33
+ "@inrupt/solid-client-authn-core": "^1.17.5",
34
34
  "@inrupt/universal-fetch": "^1.0.2",
35
35
  "events": "^3.3.0",
36
- "jose": "^4.14.6",
36
+ "jose": "^4.15.4",
37
37
  "uuid": "^9.0.1"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "ef10e8366ee8511f726b6cf5918f9e9c6653c6cc"
42
+ "gitHead": "a34357598cc218be116e38f66a983e391dc1d6b2"
43
43
  }
@@ -493,25 +493,6 @@ describe("ClientAuthentication", () => {
493
493
  );
494
494
  });
495
495
 
496
- it("clears the current IRI from OAuth query parameters in the implicit flow", async () => {
497
- window.history.replaceState = jest
498
- .fn<typeof window.history.replaceState>()
499
- .mockImplementationOnce((_data, _unused, url) => {
500
- // Pretend the current location is updated
501
- window.location.href = url as string;
502
- });
503
- const clientAuthn = getClientAuthentication();
504
- const url =
505
- "https://coolapp.com/redirect?state=someState&id_token=idToken&access_token=accessToken";
506
- await clientAuthn.handleIncomingRedirect(url, mockEmitter);
507
- expect(window.history.replaceState).toHaveBeenCalledWith(
508
- null,
509
- "",
510
- "https://coolapp.com/redirect",
511
- );
512
- expect(mockEmitter.emit).not.toHaveBeenCalled();
513
- });
514
-
515
496
  it("preserves non-OAuth query strings", async () => {
516
497
  window.history.replaceState = jest
517
498
  .fn<typeof window.history.replaceState>()
@@ -33,8 +33,9 @@ import {
33
33
  EVENTS,
34
34
  isValidRedirectUrl,
35
35
  ClientAuthentication as ClientAuthenticationBase,
36
+ removeOpenIdParams,
36
37
  } from "@inrupt/solid-client-authn-core";
37
- import { removeOidcQueryParam } from "@inrupt/oidc-client-ext";
38
+ import { normalizeCallbackUrl } from "@inrupt/oidc-client-ext";
38
39
  import type { EventEmitter } from "events";
39
40
 
40
41
  /**
@@ -62,7 +63,7 @@ export default class ClientAuthentication extends ClientAuthenticationBase {
62
63
  // normalization only applies if we default to the current location (which is
63
64
  // a bad practice and should be discouraged).
64
65
  const redirectUrl =
65
- options.redirectUrl ?? removeOidcQueryParam(window.location.href);
66
+ options.redirectUrl ?? normalizeCallbackUrl(window.location.href);
66
67
  if (!isValidRedirectUrl(redirectUrl)) {
67
68
  throw new Error(
68
69
  `${redirectUrl} is not a valid redirect URL, it is either a malformed IRI, includes a hash fragment, or reserved query parameters ('code' or 'state').`,
@@ -133,25 +134,15 @@ export default class ClientAuthentication extends ClientAuthenticationBase {
133
134
  };
134
135
 
135
136
  private async cleanUrlAfterRedirect(url: string): Promise<void> {
136
- const cleanedUpUrl = new URL(url);
137
- cleanedUpUrl.searchParams.delete("state");
138
- // For auth code flow
139
- cleanedUpUrl.searchParams.delete("code");
140
- // For implicit flow
141
- cleanedUpUrl.searchParams.delete("id_token");
142
- cleanedUpUrl.searchParams.delete("access_token");
143
- // For login error
144
- cleanedUpUrl.searchParams.delete("error");
145
- cleanedUpUrl.searchParams.delete("error_description");
146
- cleanedUpUrl.searchParams.delete("iss");
137
+ const cleanedUpUrl = removeOpenIdParams(url).href;
147
138
 
148
139
  // Remove OAuth-specific query params (since the login flow finishes with
149
140
  // the browser being redirected back with OAuth2 query params (e.g. for
150
141
  // 'code' and 'state'), and so if the user simply refreshes this page our
151
142
  // authentication library will be called again with what are now invalid
152
143
  // query parameters!).
153
- window.history.replaceState(null, "", cleanedUpUrl.toString());
154
- while (window.location.href !== cleanedUpUrl.href) {
144
+ window.history.replaceState(null, "", cleanedUpUrl);
145
+ while (window.location.href !== cleanedUpUrl) {
155
146
  // Poll the current URL every ms. Active polling is required because
156
147
  // window.history.replaceState is asynchronous, but the associated
157
148
  // 'popstate' event which should be listened to is only sent on active