@inrupt/solid-client-authn-browser 1.15.0 → 1.17.0
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/ClientAuthentication.d.ts +4 -13
- package/dist/Session.d.ts +4 -4
- package/dist/dependencies.d.ts +1 -1
- package/dist/index.js +772 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +745 -0
- package/dist/index.mjs.map +1 -0
- package/dist/login/oidc/AggregateOidcHandler.d.ts +2 -1
- package/dist/login/oidc/AggregateRedirectHandler.d.ts +2 -1
- package/dist/login/oidc/ClientRegistrar.d.ts +1 -1
- package/dist/login/oidc/IssuerConfigFetcher.d.ts +1 -1
- package/dist/login/oidc/OidcLoginHandler.d.ts +1 -1
- package/dist/login/oidc/Redirector.d.ts +1 -1
- package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.d.ts +3 -6
- package/dist/login/oidc/incomingRedirectHandler/ErrorOidcHandler.d.ts +1 -1
- package/dist/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.d.ts +1 -1
- package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.d.ts +3 -6
- package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.d.ts +1 -1
- package/dist/login/oidc/refresh/TokenRefresher.d.ts +2 -2
- package/dist/logout/buildRpInitiatedLogout.d.ts +2 -0
- package/dist/sessionInfo/SessionInfoManager.d.ts +4 -13
- package/dist/solid-client-authn.bundle.js +32 -2
- package/dist/solid-client-authn.bundle.js.map +1 -0
- package/dist/storage/BrowserStorage.d.ts +1 -1
- package/dist/storage/StorageUtility.d.ts +2 -1
- package/package.json +17 -17
- package/rollup.config.mjs +46 -0
- package/src/ClientAuthentication.spec.ts +4 -4
- package/src/ClientAuthentication.ts +8 -45
- package/src/Session.spec.ts +4 -4
- package/src/Session.ts +44 -13
- package/src/__mocks__/ClientAuthentication.ts +3 -3
- package/src/constant.ts +1 -1
- package/src/defaultSession.spec.ts +1 -1
- package/src/defaultSession.ts +5 -3
- package/src/dependencies.node.spec.ts +1 -1
- package/src/dependencies.spec.ts +1 -1
- package/src/dependencies.ts +10 -5
- package/src/index.browser.spec.ts +1 -1
- package/src/index.browser.ts +1 -1
- package/src/index.spec.ts +1 -1
- package/src/index.ts +1 -1
- package/src/login/__mocks__/LoginHandler.ts +2 -2
- package/src/login/oidc/AggregateOidcHandler.spec.ts +3 -5
- package/src/login/oidc/AggregateOidcHandler.ts +3 -3
- package/src/login/oidc/AggregateRedirectHandler.ts +3 -3
- package/src/login/oidc/ClientRegistrar.spec.ts +1 -1
- package/src/login/oidc/ClientRegistrar.ts +2 -2
- package/src/login/oidc/IssuerConfigFetcher.spec.ts +8 -4
- package/src/login/oidc/IssuerConfigFetcher.ts +7 -3
- package/src/login/oidc/OidcLoginHandler.spec.ts +3 -5
- package/src/login/oidc/OidcLoginHandler.ts +5 -3
- package/src/login/oidc/Redirector.spec.ts +1 -1
- package/src/login/oidc/Redirector.ts +2 -2
- package/src/login/oidc/__mocks__/ClientRegistrar.ts +2 -2
- package/src/login/oidc/__mocks__/IOidcHandler.ts +2 -2
- package/src/login/oidc/__mocks__/IOidcOptions.ts +2 -2
- package/src/login/oidc/__mocks__/IssuerConfigFetcher.ts +2 -2
- package/src/login/oidc/__mocks__/Redirector.ts +2 -2
- package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.spec.ts +37 -39
- package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.ts +17 -13
- package/src/login/oidc/incomingRedirectHandler/ErrorOidcHandler.spec.ts +3 -4
- package/src/login/oidc/incomingRedirectHandler/ErrorOidcHandler.ts +3 -3
- package/src/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.spec.ts +3 -4
- package/src/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.ts +2 -2
- package/src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.spec.ts +3 -3
- package/src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.ts +13 -51
- package/src/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.ts +2 -2
- package/src/login/oidc/refresh/TokenRefresher.spec.ts +7 -6
- package/src/login/oidc/refresh/TokenRefresher.ts +6 -4
- package/src/login/oidc/refresh/__mocks__/TokenRefresher.ts +2 -2
- package/src/logout/{GeneralLogoutHandler.ts → buildRpInitiatedLogout.ts} +21 -20
- package/src/sessionInfo/SessionInfoManager.spec.ts +2 -2
- package/src/sessionInfo/SessionInfoManager.ts +13 -91
- package/src/sessionInfo/__mocks__/SessionInfoManager.ts +2 -2
- package/src/storage/BrowserStorage.spec.ts +1 -1
- package/src/storage/BrowserStorage.ts +2 -2
- package/src/storage/StorageUtility.ts +3 -2
- package/src/storage/__mocks__/LocalStorage.ts +1 -1
- package/src/util/UUIDGenerator.spec.ts +1 -1
- package/src/util/UuidGenerator.ts +1 -1
- package/src/util/__mocks__/UuidGenerator.ts +2 -2
- package/dist/ClientAuthentication.js +0 -80
- package/dist/ClientAuthentication.js.map +0 -1
- package/dist/Session.js +0 -150
- package/dist/Session.js.map +0 -1
- package/dist/constant.js +0 -7
- package/dist/constant.js.map +0 -1
- package/dist/defaultSession.js +0 -52
- package/dist/defaultSession.js.map +0 -1
- package/dist/dependencies.js +0 -41
- package/dist/dependencies.js.map +0 -1
- package/dist/index.browser.js +0 -28
- package/dist/index.browser.js.map +0 -1
- package/dist/login/oidc/AggregateOidcHandler.js +0 -10
- package/dist/login/oidc/AggregateOidcHandler.js.map +0 -1
- package/dist/login/oidc/AggregateRedirectHandler.js +0 -10
- package/dist/login/oidc/AggregateRedirectHandler.js.map +0 -1
- package/dist/login/oidc/ClientRegistrar.js +0 -47
- package/dist/login/oidc/ClientRegistrar.js.map +0 -1
- package/dist/login/oidc/IssuerConfigFetcher.js +0 -124
- package/dist/login/oidc/IssuerConfigFetcher.js.map +0 -1
- package/dist/login/oidc/OidcLoginHandler.js +0 -40
- package/dist/login/oidc/OidcLoginHandler.js.map +0 -1
- package/dist/login/oidc/Redirector.js +0 -17
- package/dist/login/oidc/Redirector.js.map +0 -1
- package/dist/login/oidc/__mocks__/IOidcOptions.d.ts +0 -2
- package/dist/login/oidc/__mocks__/IOidcOptions.js +0 -25
- package/dist/login/oidc/__mocks__/IOidcOptions.js.map +0 -1
- package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.js +0 -91
- package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.js.map +0 -1
- package/dist/login/oidc/incomingRedirectHandler/ErrorOidcHandler.js +0 -26
- package/dist/login/oidc/incomingRedirectHandler/ErrorOidcHandler.js.map +0 -1
- package/dist/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.js +0 -20
- package/dist/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.js.map +0 -1
- package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.js +0 -56
- package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.js.map +0 -1
- package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.js +0 -47
- package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.js.map +0 -1
- package/dist/login/oidc/refresh/TokenRefresher.js +0 -31
- package/dist/login/oidc/refresh/TokenRefresher.js.map +0 -1
- package/dist/logout/GeneralLogoutHandler.d.ts +0 -7
- package/dist/logout/GeneralLogoutHandler.js +0 -15
- package/dist/logout/GeneralLogoutHandler.js.map +0 -1
- package/dist/sessionInfo/SessionInfoManager.js +0 -96
- package/dist/sessionInfo/SessionInfoManager.js.map +0 -1
- package/dist/solid-client-authn.bundle.js.LICENSE.txt +0 -17
- package/dist/storage/BrowserStorage.js +0 -18
- package/dist/storage/BrowserStorage.js.map +0 -1
- package/dist/storage/StorageUtility.js +0 -10
- package/dist/storage/StorageUtility.js.map +0 -1
- package/dist/util/UuidGenerator.js +0 -10
- package/dist/util/UuidGenerator.js.map +0 -1
- package/licenses.csv +0 -147
- package/src/logout/GeneralLogoutHandler.spec.ts +0 -72
- package/src/logout/__mocks__/LogoutHandler.ts +0 -38
- package/webpack.browser.js +0 -39
- package/webpack.common.js +0 -42
- package/webpack.config.js +0 -28
- package/webpack.dev.js +0 -37
- package/webpack.prod.js +0 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
import { jest, it, describe, expect } from "@jest/globals";
|
|
23
23
|
import { mockStorageUtility } from "@inrupt/solid-client-authn-core";
|
|
24
|
-
import {
|
|
25
|
-
import * as UniversalFetch from "@inrupt/universal-fetch";
|
|
24
|
+
import { Response as NodeResponse } from "@inrupt/universal-fetch";
|
|
25
|
+
import type * as UniversalFetch from "@inrupt/universal-fetch";
|
|
26
26
|
import IssuerConfigFetcher from "./IssuerConfigFetcher";
|
|
27
27
|
|
|
28
28
|
jest.mock("@inrupt/universal-fetch", () => {
|
|
@@ -31,7 +31,7 @@ jest.mock("@inrupt/universal-fetch", () => {
|
|
|
31
31
|
) as typeof UniversalFetch;
|
|
32
32
|
return {
|
|
33
33
|
...fetchModule,
|
|
34
|
-
fetch: jest.fn<typeof fetch>(),
|
|
34
|
+
fetch: jest.fn<(typeof UniversalFetch)["fetch"]>(),
|
|
35
35
|
};
|
|
36
36
|
});
|
|
37
37
|
|
|
@@ -65,6 +65,7 @@ describe("IssuerConfigFetcher", () => {
|
|
|
65
65
|
// eslint-disable-next-line camelcase
|
|
66
66
|
claim_types_supported: "oidc",
|
|
67
67
|
bleepBloop: "Meep Moop",
|
|
68
|
+
end_session_endpoint: "https://example.com/endSessionEndpoint",
|
|
68
69
|
})
|
|
69
70
|
)
|
|
70
71
|
);
|
|
@@ -75,6 +76,9 @@ describe("IssuerConfigFetcher", () => {
|
|
|
75
76
|
expect(fetchedConfig.issuer).toBe("https://example.com");
|
|
76
77
|
expect((fetchedConfig as any).claim_types_supported).toBeUndefined();
|
|
77
78
|
expect(fetchedConfig.claimTypesSupported).toBe("oidc");
|
|
79
|
+
expect(fetchedConfig.endSessionEndpoint).toBe(
|
|
80
|
+
"https://example.com/endSessionEndpoint"
|
|
81
|
+
);
|
|
78
82
|
expect((fetchedConfig as any).bleepBloop).toBeUndefined();
|
|
79
83
|
});
|
|
80
84
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
/**
|
|
28
28
|
* Responsible for fetching an IDP configuration
|
|
29
29
|
*/
|
|
30
|
-
import {
|
|
30
|
+
import type {
|
|
31
31
|
IIssuerConfig,
|
|
32
32
|
IIssuerConfigFetcher,
|
|
33
33
|
IStorageUtility,
|
|
34
|
-
ConfigurationError,
|
|
35
34
|
} from "@inrupt/solid-client-authn-core";
|
|
35
|
+
import { ConfigurationError } from "@inrupt/solid-client-authn-core";
|
|
36
36
|
import { fetch } from "@inrupt/universal-fetch";
|
|
37
37
|
|
|
38
38
|
export const WELL_KNOWN_OPENID_CONFIG = ".well-known/openid-configuration";
|
|
@@ -66,6 +66,10 @@ const issuerConfigKeyMap: Record<
|
|
|
66
66
|
toKey: "registrationEndpoint",
|
|
67
67
|
convertToUrl: true,
|
|
68
68
|
},
|
|
69
|
+
end_session_endpoint: {
|
|
70
|
+
toKey: "endSessionEndpoint",
|
|
71
|
+
convertToUrl: true,
|
|
72
|
+
},
|
|
69
73
|
scopes_supported: { toKey: "scopesSupported" },
|
|
70
74
|
response_types_supported: { toKey: "responseTypesSupported" },
|
|
71
75
|
response_modes_supported: { toKey: "responseModesSupported" },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -20,10 +20,8 @@
|
|
|
20
20
|
//
|
|
21
21
|
|
|
22
22
|
import { jest, it, describe, expect } from "@jest/globals";
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
StorageUtility,
|
|
26
|
-
} from "@inrupt/solid-client-authn-core";
|
|
23
|
+
import type { IIssuerConfigFetcher } from "@inrupt/solid-client-authn-core";
|
|
24
|
+
import { StorageUtility } from "@inrupt/solid-client-authn-core";
|
|
27
25
|
import {
|
|
28
26
|
StorageUtilityMock,
|
|
29
27
|
mockStorage,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* Handles Common Oidc login functions (Like fetching the configuration)
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
import {
|
|
31
|
+
import type {
|
|
32
32
|
IClientRegistrar,
|
|
33
33
|
IIssuerConfig,
|
|
34
34
|
IIssuerConfigFetcher,
|
|
@@ -37,8 +37,10 @@ import {
|
|
|
37
37
|
IOidcHandler,
|
|
38
38
|
IOidcOptions,
|
|
39
39
|
IStorageUtility,
|
|
40
|
-
ConfigurationError,
|
|
41
40
|
LoginResult,
|
|
41
|
+
} from "@inrupt/solid-client-authn-core";
|
|
42
|
+
import {
|
|
43
|
+
ConfigurationError,
|
|
42
44
|
handleRegistration,
|
|
43
45
|
} from "@inrupt/solid-client-authn-core";
|
|
44
46
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @packageDocumentation
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import {
|
|
27
|
+
import type {
|
|
28
28
|
IRedirector,
|
|
29
29
|
IRedirectorOptions,
|
|
30
30
|
} from "@inrupt/solid-client-authn-core";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
//
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import type {
|
|
23
23
|
IClient,
|
|
24
24
|
IClientRegistrar,
|
|
25
25
|
IClientRegistrarOptions,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
//
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import type {
|
|
23
23
|
IOidcHandler,
|
|
24
24
|
IOidcOptions,
|
|
25
25
|
ISessionInfo,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
//
|
|
21
21
|
|
|
22
|
-
import { IOidcOptions } from "@inrupt/solid-client-authn-core";
|
|
22
|
+
import type { IOidcOptions } from "@inrupt/solid-client-authn-core";
|
|
23
23
|
import { jest } from "@jest/globals";
|
|
24
24
|
|
|
25
25
|
export const standardOidcOptions: IOidcOptions = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
//
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import type {
|
|
23
23
|
IIssuerConfig,
|
|
24
24
|
IIssuerConfigFetcher,
|
|
25
25
|
} from "@inrupt/solid-client-authn-core";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
//
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import type {
|
|
23
23
|
IRedirector,
|
|
24
24
|
IRedirectorOptions,
|
|
25
25
|
} from "@inrupt/solid-client-authn-core";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -19,26 +19,27 @@
|
|
|
19
19
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
//
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import type {
|
|
23
23
|
IClient,
|
|
24
24
|
IClientRegistrar,
|
|
25
25
|
IClientRegistrarOptions,
|
|
26
26
|
IIssuerConfigFetcher,
|
|
27
|
-
USER_SESSION_PREFIX,
|
|
28
27
|
IIssuerConfig,
|
|
28
|
+
buildAuthenticatedFetch,
|
|
29
29
|
} from "@inrupt/solid-client-authn-core";
|
|
30
|
+
import { USER_SESSION_PREFIX } from "@inrupt/solid-client-authn-core";
|
|
30
31
|
import {
|
|
31
32
|
StorageUtilityMock,
|
|
32
33
|
mockStorageUtility,
|
|
33
34
|
} from "@inrupt/solid-client-authn-core/mocks";
|
|
34
|
-
import type * as SolidClientAuthnCore from "@inrupt/solid-client-authn-core";
|
|
35
35
|
import { jest, it, describe, expect } from "@jest/globals";
|
|
36
|
-
import {
|
|
36
|
+
import { getBearerToken } from "@inrupt/oidc-client-ext";
|
|
37
37
|
import type * as OidcClientExt from "@inrupt/oidc-client-ext";
|
|
38
38
|
import { fetch, Response, Headers } from "@inrupt/universal-fetch";
|
|
39
|
-
import * as UniversalFetch from "@inrupt/universal-fetch";
|
|
40
|
-
import { JWK
|
|
41
|
-
import {
|
|
39
|
+
import type * as UniversalFetch from "@inrupt/universal-fetch";
|
|
40
|
+
import type { JWK } from "jose";
|
|
41
|
+
import { importJWK } from "jose";
|
|
42
|
+
import type { KeyObject } from "crypto";
|
|
42
43
|
import { AuthCodeRedirectHandler } from "./AuthCodeRedirectHandler";
|
|
43
44
|
import { SessionInfoManagerMock } from "../../../sessionInfo/__mocks__/SessionInfoManager";
|
|
44
45
|
import { LocalStorageMock } from "../../../storage/__mocks__/LocalStorage";
|
|
@@ -116,31 +117,33 @@ const mockAccessTokenDpop = (): AccessJwt => {
|
|
|
116
117
|
const mockAccessTokenBearer = (): string => "some token";
|
|
117
118
|
|
|
118
119
|
const MOCK_EXPIRE_TIME = 1337;
|
|
119
|
-
const mockTokenEndpointBearerResponse =
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
const mockTokenEndpointBearerResponse =
|
|
121
|
+
(): OidcClientExt.CodeExchangeResult => {
|
|
122
|
+
return {
|
|
123
|
+
accessToken: mockAccessTokenBearer(),
|
|
124
|
+
idToken: mockIdToken(),
|
|
125
|
+
webId: mockWebId(),
|
|
126
|
+
expiresIn: MOCK_EXPIRE_TIME,
|
|
127
|
+
refreshToken: "some refresh token",
|
|
128
|
+
};
|
|
126
129
|
};
|
|
127
|
-
};
|
|
128
130
|
|
|
129
|
-
const mockTokenEndpointDpopResponse =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
131
|
+
const mockTokenEndpointDpopResponse =
|
|
132
|
+
async (): Promise<OidcClientExt.CodeExchangeResult> => {
|
|
133
|
+
return {
|
|
134
|
+
accessToken: JSON.stringify(mockAccessTokenDpop()),
|
|
135
|
+
idToken: mockIdToken(),
|
|
136
|
+
webId: mockWebId(),
|
|
137
|
+
dpopKey: {
|
|
138
|
+
privateKey: (await importJWK(mockJwk())) as KeyObject,
|
|
139
|
+
// Note that here for convenience the private key is also used as public key.
|
|
140
|
+
// Obviously, this should never be done in non-test code.
|
|
141
|
+
publicKey: mockJwk(),
|
|
142
|
+
},
|
|
143
|
+
expiresIn: MOCK_EXPIRE_TIME,
|
|
144
|
+
refreshToken: "some DPoP-bound refresh token",
|
|
145
|
+
};
|
|
142
146
|
};
|
|
143
|
-
};
|
|
144
147
|
|
|
145
148
|
const mockLocalStorage = (stored: Record<string, string>) => {
|
|
146
149
|
// Kinda weird: `(window as any).localStorage = new LocalStorageMock(stored)` does
|
|
@@ -154,11 +157,6 @@ const mockLocalStorage = (stored: Record<string, string>) => {
|
|
|
154
157
|
};
|
|
155
158
|
|
|
156
159
|
jest.mock("@inrupt/oidc-client-ext");
|
|
157
|
-
// jest.mock("cross-fetch", () => ({
|
|
158
|
-
// ...(jest.requireActual("cross-fetch") as typeof CrossFetch),
|
|
159
|
-
// default: jest.fn<typeof fetch>(),
|
|
160
|
-
// fetch: jest.fn<typeof fetch>(),
|
|
161
|
-
// }));
|
|
162
160
|
|
|
163
161
|
jest.useFakeTimers();
|
|
164
162
|
|
|
@@ -558,7 +556,7 @@ describe("AuthCodeRedirectHandler", () => {
|
|
|
558
556
|
mockRedirectUrl()
|
|
559
557
|
);
|
|
560
558
|
|
|
561
|
-
expect(sessionInfo.expirationDate).
|
|
559
|
+
expect(sessionInfo.expirationDate).toBeUndefined();
|
|
562
560
|
});
|
|
563
561
|
|
|
564
562
|
it("clears the oidc-client specific session information", async () => {
|
|
@@ -580,9 +578,9 @@ describe("AuthCodeRedirectHandler", () => {
|
|
|
580
578
|
it("returns a fetch that supports the refresh flow", async () => {
|
|
581
579
|
mockOidcClient();
|
|
582
580
|
const mockedStorage = mockDefaultStorageUtility();
|
|
583
|
-
const coreModule = jest.requireActual<
|
|
584
|
-
|
|
585
|
-
);
|
|
581
|
+
const coreModule = jest.requireActual<{
|
|
582
|
+
buildAuthenticatedFetch: typeof buildAuthenticatedFetch;
|
|
583
|
+
}>("@inrupt/solid-client-authn-core");
|
|
586
584
|
const mockAuthenticatedFetchBuild = jest.spyOn(
|
|
587
585
|
coreModule,
|
|
588
586
|
"buildAuthenticatedFetch"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -29,25 +29,25 @@
|
|
|
29
29
|
|
|
30
30
|
import { fetch } from "@inrupt/universal-fetch";
|
|
31
31
|
|
|
32
|
-
import {
|
|
33
|
-
buildAuthenticatedFetch,
|
|
32
|
+
import type {
|
|
34
33
|
IClient,
|
|
35
34
|
IClientRegistrar,
|
|
36
35
|
IIssuerConfigFetcher,
|
|
37
36
|
IIncomingRedirectHandler,
|
|
38
|
-
ISessionInfo,
|
|
39
37
|
ISessionInfoManager,
|
|
40
38
|
IStorageUtility,
|
|
41
39
|
ITokenRefresher,
|
|
42
|
-
loadOidcContextFromStorage,
|
|
43
40
|
RefreshOptions,
|
|
41
|
+
IncomingRedirectResult,
|
|
44
42
|
} from "@inrupt/solid-client-authn-core";
|
|
45
43
|
import {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
} from "@inrupt/
|
|
50
|
-
import {
|
|
44
|
+
buildAuthenticatedFetch,
|
|
45
|
+
loadOidcContextFromStorage,
|
|
46
|
+
maybeBuildRpInitiatedLogout,
|
|
47
|
+
} from "@inrupt/solid-client-authn-core";
|
|
48
|
+
import type { CodeExchangeResult } from "@inrupt/oidc-client-ext";
|
|
49
|
+
import { getDpopToken, getBearerToken } from "@inrupt/oidc-client-ext";
|
|
50
|
+
import type { EventEmitter } from "events";
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* @hidden
|
|
@@ -78,7 +78,7 @@ export class AuthCodeRedirectHandler implements IIncomingRedirectHandler {
|
|
|
78
78
|
async handle(
|
|
79
79
|
redirectUrl: string,
|
|
80
80
|
eventEmitter?: EventEmitter
|
|
81
|
-
): Promise<
|
|
81
|
+
): Promise<IncomingRedirectResult> {
|
|
82
82
|
if (!(await this.canHandle(redirectUrl))) {
|
|
83
83
|
throw new Error(
|
|
84
84
|
`AuthCodeRedirectHandler cannot handle [${redirectUrl}]: it is missing one of [code, state].`
|
|
@@ -185,10 +185,14 @@ export class AuthCodeRedirectHandler implements IIncomingRedirectHandler {
|
|
|
185
185
|
|
|
186
186
|
return Object.assign(sessionInfo, {
|
|
187
187
|
fetch: authFetch,
|
|
188
|
+
getLogoutUrl: maybeBuildRpInitiatedLogout({
|
|
189
|
+
idTokenHint: tokens.idToken,
|
|
190
|
+
endSessionEndpoint: issuerConfig.endSessionEndpoint,
|
|
191
|
+
}),
|
|
188
192
|
expirationDate:
|
|
189
193
|
typeof tokens.expiresIn === "number"
|
|
190
194
|
? tokenCreatedAt + tokens.expiresIn * 1000
|
|
191
|
-
:
|
|
192
|
-
});
|
|
195
|
+
: undefined,
|
|
196
|
+
} as IncomingRedirectResult);
|
|
193
197
|
}
|
|
194
198
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
import { jest, it, describe, expect } from "@jest/globals";
|
|
23
23
|
import { EventEmitter } from "events";
|
|
24
24
|
import { EVENTS } from "@inrupt/solid-client-authn-core";
|
|
25
|
-
import
|
|
26
|
-
import * as UniversalFetch from "@inrupt/universal-fetch";
|
|
25
|
+
import type * as UniversalFetch from "@inrupt/universal-fetch";
|
|
27
26
|
import { ErrorOidcHandler } from "./ErrorOidcHandler";
|
|
28
27
|
|
|
29
28
|
jest.mock("@inrupt/universal-fetch", () => {
|
|
@@ -32,7 +31,7 @@ jest.mock("@inrupt/universal-fetch", () => {
|
|
|
32
31
|
) as typeof UniversalFetch;
|
|
33
32
|
return {
|
|
34
33
|
...fetchModule,
|
|
35
|
-
fetch: jest.fn<typeof fetch>(),
|
|
34
|
+
fetch: jest.fn<(typeof UniversalFetch)["fetch"]>(),
|
|
36
35
|
};
|
|
37
36
|
});
|
|
38
37
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
* @packageDocumentation
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import {
|
|
28
|
-
EVENTS,
|
|
27
|
+
import type {
|
|
29
28
|
IIncomingRedirectHandler,
|
|
30
29
|
ISessionInfo,
|
|
31
30
|
} from "@inrupt/solid-client-authn-core";
|
|
31
|
+
import { EVENTS } from "@inrupt/solid-client-authn-core";
|
|
32
32
|
import type { EventEmitter } from "events";
|
|
33
33
|
|
|
34
34
|
import { getUnauthenticatedSession } from "../../../sessionInfo/SessionInfoManager";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
//
|
|
21
21
|
|
|
22
22
|
import { jest, it, describe, expect } from "@jest/globals";
|
|
23
|
-
import
|
|
24
|
-
import * as UniversalFetch from "@inrupt/universal-fetch";
|
|
23
|
+
import type * as UniversalFetch from "@inrupt/universal-fetch";
|
|
25
24
|
import { FallbackRedirectHandler } from "./FallbackRedirectHandler";
|
|
26
25
|
|
|
27
26
|
jest.mock("@inrupt/universal-fetch", () => {
|
|
@@ -30,7 +29,7 @@ jest.mock("@inrupt/universal-fetch", () => {
|
|
|
30
29
|
) as typeof UniversalFetch;
|
|
31
30
|
return {
|
|
32
31
|
...fetchModule,
|
|
33
|
-
fetch: jest.fn<typeof fetch>(),
|
|
32
|
+
fetch: jest.fn<(typeof UniversalFetch)["fetch"]>(),
|
|
34
33
|
};
|
|
35
34
|
});
|
|
36
35
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @packageDocumentation
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import {
|
|
27
|
+
import type {
|
|
28
28
|
IIncomingRedirectHandler,
|
|
29
29
|
ISessionInfo,
|
|
30
30
|
} from "@inrupt/solid-client-authn-core";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -25,11 +25,11 @@ import mockConsole from "jest-mock-console";
|
|
|
25
25
|
/**
|
|
26
26
|
* Test for AuthorizationCodeWithPkceOidcHandler
|
|
27
27
|
*/
|
|
28
|
-
import {
|
|
28
|
+
import type {
|
|
29
29
|
IOidcOptions,
|
|
30
30
|
IRedirectorOptions,
|
|
31
|
-
StorageUtility,
|
|
32
31
|
} from "@inrupt/solid-client-authn-core";
|
|
32
|
+
import { StorageUtility } from "@inrupt/solid-client-authn-core";
|
|
33
33
|
import {
|
|
34
34
|
StorageUtilityMock,
|
|
35
35
|
mockStorage,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -27,13 +27,14 @@
|
|
|
27
27
|
/**
|
|
28
28
|
* Handler for the Authorization Code with PKCE Flow
|
|
29
29
|
*/
|
|
30
|
-
import {
|
|
30
|
+
import type {
|
|
31
31
|
IOidcHandler,
|
|
32
32
|
IOidcOptions,
|
|
33
|
-
IRedirector,
|
|
34
|
-
IStorageUtility,
|
|
35
33
|
LoginResult,
|
|
34
|
+
} from "@inrupt/solid-client-authn-core";
|
|
35
|
+
import {
|
|
36
36
|
DEFAULT_SCOPES,
|
|
37
|
+
AuthorizationCodeWithPkceOidcHandlerBase,
|
|
37
38
|
} from "@inrupt/solid-client-authn-core";
|
|
38
39
|
import { OidcClient } from "@inrupt/oidc-client-ext";
|
|
39
40
|
|
|
@@ -43,22 +44,9 @@ import { OidcClient } from "@inrupt/oidc-client-ext";
|
|
|
43
44
|
* PKCE: https://tools.ietf.org/html/rfc7636
|
|
44
45
|
*/
|
|
45
46
|
export default class AuthorizationCodeWithPkceOidcHandler
|
|
47
|
+
extends AuthorizationCodeWithPkceOidcHandlerBase
|
|
46
48
|
implements IOidcHandler
|
|
47
49
|
{
|
|
48
|
-
constructor(
|
|
49
|
-
private storageUtility: IStorageUtility,
|
|
50
|
-
private redirector: IRedirector
|
|
51
|
-
) {}
|
|
52
|
-
|
|
53
|
-
async canHandle(oidcLoginOptions: IOidcOptions): Promise<boolean> {
|
|
54
|
-
return !!(
|
|
55
|
-
oidcLoginOptions.issuerConfiguration.grantTypesSupported &&
|
|
56
|
-
oidcLoginOptions.issuerConfiguration.grantTypesSupported.indexOf(
|
|
57
|
-
"authorization_code"
|
|
58
|
-
) > -1
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
50
|
async handle(oidcLoginOptions: IOidcOptions): Promise<LoginResult> {
|
|
63
51
|
/* eslint-disable camelcase */
|
|
64
52
|
const oidcOptions = {
|
|
@@ -81,42 +69,16 @@ export default class AuthorizationCodeWithPkceOidcHandler
|
|
|
81
69
|
|
|
82
70
|
const oidcClientLibrary = new OidcClient(oidcOptions);
|
|
83
71
|
|
|
84
|
-
const { redirector } = this;
|
|
85
|
-
const storage = this.storageUtility;
|
|
86
|
-
|
|
87
72
|
try {
|
|
88
73
|
const signingRequest = await oidcClientLibrary.createSigninRequest();
|
|
89
|
-
await
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// 'cos we'll need to lookup our session information again when the
|
|
93
|
-
// browser is redirected back to us (i.e. the OAuth client
|
|
94
|
-
// application) from the Authorization Server.
|
|
95
|
-
// We don't want to use our session ID as the OAuth 'state' value, as
|
|
96
|
-
// that session ID can be any developer-specified value, and therefore
|
|
97
|
-
// may not be appropriate (since the OAuth 'state' value should really
|
|
98
|
-
// be an unguessable crypto-random value).
|
|
74
|
+
// Make sure to await the promise before returning so that the error is caught.
|
|
75
|
+
return await this.handleRedirect({
|
|
76
|
+
oidcLoginOptions,
|
|
99
77
|
// eslint-disable-next-line no-underscore-dangle
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// Store our login-process state using the session ID as the key.
|
|
105
|
-
// Strictly speaking, this indirection from our OAuth state value to
|
|
106
|
-
// our session ID is unnecessary, but it provides a slightly cleaner
|
|
107
|
-
// separation of concerns.
|
|
108
|
-
storage.setForUser(oidcLoginOptions.sessionId, {
|
|
109
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
110
|
-
codeVerifier: signingRequest.state._code_verifier,
|
|
111
|
-
issuer: oidcLoginOptions.issuer.toString(),
|
|
112
|
-
// The redirect URL is read after redirect, so it must be stored now.
|
|
113
|
-
redirectUrl: oidcLoginOptions.redirectUrl,
|
|
114
|
-
dpop: oidcLoginOptions.dpop ? "true" : "false",
|
|
115
|
-
}),
|
|
116
|
-
]);
|
|
117
|
-
|
|
118
|
-
redirector.redirect(signingRequest.url.toString(), {
|
|
119
|
-
handleRedirect: oidcLoginOptions.handleRedirect,
|
|
78
|
+
state: signingRequest.state._id,
|
|
79
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
80
|
+
codeVerifier: signingRequest.state._code_verifier,
|
|
81
|
+
targetUrl: signingRequest.url.toString(),
|
|
120
82
|
});
|
|
121
83
|
} catch (err: unknown) {
|
|
122
84
|
// eslint-disable-next-line no-console
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
3
|
//
|
|
4
4
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
// of this software and associated documentation files (the "Software"), to deal in
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
//
|
|
21
21
|
|
|
22
|
-
import { IOidcOptions } from "@inrupt/solid-client-authn-core";
|
|
22
|
+
import type { IOidcOptions } from "@inrupt/solid-client-authn-core";
|
|
23
23
|
import { standardOidcOptions } from "../__mocks__/IOidcOptions";
|
|
24
24
|
|
|
25
25
|
const canHandleTests: {
|