@inrupt/solid-client-authn-browser 1.16.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,4 +1,4 @@
|
|
|
1
|
-
import { IStorage } from "@inrupt/solid-client-authn-core";
|
|
1
|
+
import type { IStorage } from "@inrupt/solid-client-authn-core";
|
|
2
2
|
export default class BrowserStorage implements IStorage {
|
|
3
3
|
get storage(): typeof window.localStorage;
|
|
4
4
|
get(key: string): Promise<string | undefined>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { IStorage
|
|
1
|
+
import type { IStorage } from "@inrupt/solid-client-authn-core";
|
|
2
|
+
import { StorageUtility } from "@inrupt/solid-client-authn-core";
|
|
2
3
|
export default class StorageUtilityBrowser extends StorageUtility {
|
|
3
4
|
constructor(secureStorage: IStorage, insecureStorage: IStorage);
|
|
4
5
|
}
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inrupt/solid-client-authn-browser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"types": "dist/index",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
6
|
"browser": "dist/index.js",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.mjs",
|
|
8
9
|
"bundle": "dist/solid-client-authn.bundle.js",
|
|
9
10
|
"repository": {
|
|
10
11
|
"url": "https://github.com/inrupt/solid-client-authn"
|
|
11
12
|
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"require": "./dist/index.js",
|
|
16
|
+
"import": "./dist/index.mjs",
|
|
17
|
+
"types": "./dist/index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
12
20
|
"scripts": {
|
|
13
21
|
"prepublishOnly": "npm run build",
|
|
14
|
-
"
|
|
15
|
-
"clean-module": "rimraf ./dist",
|
|
16
|
-
"clean-browser": "rimraf ./browserDist",
|
|
17
|
-
"build": "npm run build-module && npm run build-browser",
|
|
18
|
-
"build-module": "npm run clean-module && tsc -p tsconfig.json",
|
|
19
|
-
"build-browser": "npm run clean-browser && webpack --config webpack.browser.js",
|
|
22
|
+
"build": "rollup --config rollup.config.mjs",
|
|
20
23
|
"licenses:check": "license-checker --production --out license.csv --failOn \"AGPL-1.0-only; AGPL-1.0-or-later; AGPL-3.0-only; AGPL-3.0-or-later; Beerware; CC-BY-NC-1.0; CC-BY-NC-2.0; CC-BY-NC-2.5; CC-BY-NC-3.0; CC-BY-NC-4.0; CC-BY-NC-ND-1.0; CC-BY-NC-ND-2.0; CC-BY-NC-ND-2.5; CC-BY-NC-ND-3.0; CC-BY-NC-ND-4.0; CC-BY-NC-SA-1.0; CC-BY-NC-SA-2.0; CC-BY-NC-SA-2.5; CC-BY-NC-SA-3.0; CC-BY-NC-SA-4.0; CPAL-1.0; EUPL-1.0; EUPL-1.1; EUPL-1.1; GPL-1.0-only; GPL-1.0-or-later; GPL-2.0-only; GPL-2.0-or-later; GPL-3.0; GPL-3.0-only; GPL-3.0-or-later; SISSL; SISSL-1.2; WTFPL\"",
|
|
21
24
|
"build-api-docs": "npx typedoc --out docs/api/source/api --readme none",
|
|
22
25
|
"build-docs-preview-site": "npm run build-api-docs; cd docs/api; make html"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
|
-
"
|
|
28
|
+
"@types/node": "^20.1.0",
|
|
29
|
+
"@types/uuid": "^9.0.1"
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"@inrupt/oidc-client-ext": "^1.
|
|
29
|
-
"@inrupt/solid-client-authn-core": "^1.
|
|
30
|
-
"@inrupt/universal-fetch": "^1.0.
|
|
31
|
-
"@types/lodash.clonedeep": "^4.5.6",
|
|
32
|
-
"@types/node": "^20.1.0",
|
|
33
|
-
"@types/uuid": "^9.0.1",
|
|
32
|
+
"@inrupt/oidc-client-ext": "^1.17.0",
|
|
33
|
+
"@inrupt/solid-client-authn-core": "^1.17.0",
|
|
34
|
+
"@inrupt/universal-fetch": "^1.0.2",
|
|
34
35
|
"events": "^3.3.0",
|
|
35
36
|
"jose": "^4.3.7",
|
|
36
|
-
"lodash.clonedeep": "^4.5.0",
|
|
37
37
|
"uuid": "^9.0.0"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "0f5275fe71f0d4d868d9918f231e7af49640e509"
|
|
43
43
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// The following is only possible from Node 18 onwards
|
|
2
|
+
// import pkg from "./package.json" assert { type: "json" };
|
|
3
|
+
|
|
4
|
+
// Until we only support Node 18+, this should be used instead
|
|
5
|
+
// (see https://rollupjs.org/guide/en/#importing-packagejson)
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
8
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
9
|
+
import terser from '@rollup/plugin-terser';
|
|
10
|
+
import createConfig, { createSharedConfig } from '../../rollup.common.mjs';
|
|
11
|
+
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const pkg = require("./package.json");
|
|
14
|
+
|
|
15
|
+
export default [
|
|
16
|
+
...createConfig(pkg),
|
|
17
|
+
{
|
|
18
|
+
input: "./src/index.ts",
|
|
19
|
+
output: [
|
|
20
|
+
{
|
|
21
|
+
file: pkg.bundle,
|
|
22
|
+
format: "iife",
|
|
23
|
+
name: "solidClientAuthentication",
|
|
24
|
+
sourcemap: true,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
...createSharedConfig(pkg),
|
|
28
|
+
external: [],
|
|
29
|
+
plugins: [
|
|
30
|
+
...createSharedConfig(pkg).plugins,
|
|
31
|
+
// Locate modules using the Node resolution algorithm, for using third party modules in node_modules
|
|
32
|
+
// to bundle them into the browser build
|
|
33
|
+
nodeResolve({
|
|
34
|
+
// Use browser exports from dependencies where available
|
|
35
|
+
browser: true,
|
|
36
|
+
// Bundles in the events library from the node_modules
|
|
37
|
+
// rather than trying to use the node events library
|
|
38
|
+
preferBuiltins: false
|
|
39
|
+
}),
|
|
40
|
+
// Adds support for importing cjs libraries such as the 'events' library
|
|
41
|
+
commonjs(),
|
|
42
|
+
// Minifies the browser bundle
|
|
43
|
+
terser(),
|
|
44
|
+
]
|
|
45
|
+
},
|
|
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
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import { jest, it, describe, expect, beforeEach } from "@jest/globals";
|
|
23
23
|
import { EventEmitter } from "events";
|
|
24
|
-
import * as SolidClientAuthnCore from "@inrupt/solid-client-authn-core";
|
|
24
|
+
import type * as SolidClientAuthnCore from "@inrupt/solid-client-authn-core";
|
|
25
25
|
|
|
26
26
|
import {
|
|
27
27
|
StorageUtility,
|
|
@@ -34,13 +34,13 @@ import {
|
|
|
34
34
|
mockStorage,
|
|
35
35
|
mockIncomingRedirectHandler,
|
|
36
36
|
mockHandleIncomingRedirect,
|
|
37
|
+
mockLogoutHandler,
|
|
37
38
|
} from "@inrupt/solid-client-authn-core/mocks";
|
|
38
39
|
|
|
39
40
|
import { fetch } from "@inrupt/universal-fetch";
|
|
40
|
-
import * as UniversalFetch from "@inrupt/universal-fetch";
|
|
41
|
+
import type * as UniversalFetch from "@inrupt/universal-fetch";
|
|
41
42
|
|
|
42
43
|
import { mockLoginHandler } from "./login/__mocks__/LoginHandler";
|
|
43
|
-
import { mockLogoutHandler } from "./logout/__mocks__/LogoutHandler";
|
|
44
44
|
import {
|
|
45
45
|
mockSessionInfoManager,
|
|
46
46
|
SessionCreatorCreateResponse,
|
|
@@ -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,39 +24,23 @@
|
|
|
24
24
|
* @packageDocumentation
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import {
|
|
28
|
-
ILoginHandler,
|
|
29
|
-
ILogoutHandler,
|
|
30
|
-
IIncomingRedirectHandler,
|
|
27
|
+
import type {
|
|
31
28
|
ISessionInfo,
|
|
32
|
-
ISessionInfoManager,
|
|
33
|
-
IIssuerConfigFetcher,
|
|
34
29
|
ISessionInternalInfo,
|
|
35
30
|
ILoginOptions,
|
|
31
|
+
} from "@inrupt/solid-client-authn-core";
|
|
32
|
+
import {
|
|
36
33
|
EVENTS,
|
|
37
34
|
isValidRedirectUrl,
|
|
35
|
+
ClientAuthentication as ClientAuthenticationBase,
|
|
38
36
|
} from "@inrupt/solid-client-authn-core";
|
|
39
|
-
import { fetch } from "@inrupt/universal-fetch";
|
|
40
37
|
import { removeOidcQueryParam } from "@inrupt/oidc-client-ext";
|
|
41
|
-
import { EventEmitter } from "events";
|
|
42
|
-
|
|
43
|
-
// By only referring to `window` at runtime, apps that do server-side rendering
|
|
44
|
-
// won't run into errors when rendering code that instantiates a
|
|
45
|
-
// ClientAuthentication:
|
|
46
|
-
const globalFetch: typeof fetch = (request, init) => fetch(request, init);
|
|
38
|
+
import type { EventEmitter } from "events";
|
|
47
39
|
|
|
48
40
|
/**
|
|
49
41
|
* @hidden
|
|
50
42
|
*/
|
|
51
|
-
export default class ClientAuthentication {
|
|
52
|
-
constructor(
|
|
53
|
-
private loginHandler: ILoginHandler,
|
|
54
|
-
private redirectHandler: IIncomingRedirectHandler,
|
|
55
|
-
private logoutHandler: ILogoutHandler,
|
|
56
|
-
private sessionInfoManager: ISessionInfoManager,
|
|
57
|
-
private issuerConfigFetcher: IIssuerConfigFetcher
|
|
58
|
-
) {}
|
|
59
|
-
|
|
43
|
+
export default class ClientAuthentication extends ClientAuthenticationBase {
|
|
60
44
|
// Define these functions as properties so that they don't get accidentally re-bound.
|
|
61
45
|
// Isn't Javascript fun?
|
|
62
46
|
login = async (
|
|
@@ -93,28 +77,6 @@ export default class ClientAuthentication {
|
|
|
93
77
|
});
|
|
94
78
|
};
|
|
95
79
|
|
|
96
|
-
// By default, our fetch() resolves to the environment fetch() function.
|
|
97
|
-
fetch = globalFetch;
|
|
98
|
-
|
|
99
|
-
logout = async (sessionId: string): Promise<void> => {
|
|
100
|
-
await this.logoutHandler.handle(sessionId);
|
|
101
|
-
|
|
102
|
-
// Restore our fetch() function back to the environment fetch(), effectively
|
|
103
|
-
// leaving us with un-authenticated fetches from now on.
|
|
104
|
-
this.fetch = globalFetch;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
getSessionInfo = async (
|
|
108
|
-
sessionId: string
|
|
109
|
-
): Promise<(ISessionInfo & ISessionInternalInfo) | undefined> => {
|
|
110
|
-
// TODO complete
|
|
111
|
-
return this.sessionInfoManager.get(sessionId);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
getAllSessionInfo = async (): Promise<ISessionInfo[]> => {
|
|
115
|
-
return this.sessionInfoManager.getAll();
|
|
116
|
-
};
|
|
117
|
-
|
|
118
80
|
// Collects session information from storage, and returns them. Returns null
|
|
119
81
|
// if the expected information cannot be found.
|
|
120
82
|
// Note that the ID token is not stored, which means the session information
|
|
@@ -144,6 +106,7 @@ export default class ClientAuthentication {
|
|
|
144
106
|
// ClientAuthentication, to avoid the following error:
|
|
145
107
|
// > 'fetch' called on an object that does not implement interface Window.
|
|
146
108
|
this.fetch = redirectInfo.fetch.bind(window);
|
|
109
|
+
this.boundLogout = redirectInfo.getLogoutUrl;
|
|
147
110
|
|
|
148
111
|
// Strip the oauth params:
|
|
149
112
|
this.cleanUrlAfterRedirect(url);
|
package/src/Session.spec.ts
CHANGED
|
@@ -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,21 +20,21 @@
|
|
|
20
20
|
//
|
|
21
21
|
|
|
22
22
|
import { jest, it, describe, expect } from "@jest/globals";
|
|
23
|
+
import type { ISessionInfo } from "@inrupt/solid-client-authn-core";
|
|
23
24
|
import {
|
|
24
25
|
EVENTS,
|
|
25
|
-
ISessionInfo,
|
|
26
26
|
StorageUtility,
|
|
27
27
|
USER_SESSION_PREFIX,
|
|
28
28
|
} from "@inrupt/solid-client-authn-core";
|
|
29
29
|
import { mockStorage } from "@inrupt/solid-client-authn-core/mocks";
|
|
30
30
|
import { fetch } from "@inrupt/universal-fetch";
|
|
31
|
-
import * as UniversalFetch from "@inrupt/universal-fetch";
|
|
31
|
+
import type * as UniversalFetch from "@inrupt/universal-fetch";
|
|
32
32
|
import { mockClientAuthentication } from "./__mocks__/ClientAuthentication";
|
|
33
33
|
import { Session } from "./Session";
|
|
34
34
|
import { LocalStorageMock } from "./storage/__mocks__/LocalStorage";
|
|
35
35
|
import { mockSessionInfoManager } from "./sessionInfo/__mocks__/SessionInfoManager";
|
|
36
36
|
import { KEY_CURRENT_SESSION, KEY_CURRENT_URL } from "./constant";
|
|
37
|
-
import ClientAuthentication from "./ClientAuthentication";
|
|
37
|
+
import type ClientAuthentication from "./ClientAuthentication";
|
|
38
38
|
|
|
39
39
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
40
40
|
|
package/src/Session.ts
CHANGED
|
@@ -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,19 +22,19 @@
|
|
|
22
22
|
/**
|
|
23
23
|
* @hidden
|
|
24
24
|
*/
|
|
25
|
-
import {
|
|
26
|
-
EVENTS,
|
|
25
|
+
import type {
|
|
27
26
|
ILoginInputOptions,
|
|
28
27
|
ISessionInfo,
|
|
29
28
|
IStorage,
|
|
30
29
|
IHasSessionEventListener,
|
|
31
30
|
ISessionEventListener,
|
|
32
|
-
|
|
31
|
+
ILogoutOptions,
|
|
33
32
|
} from "@inrupt/solid-client-authn-core";
|
|
34
|
-
import {
|
|
33
|
+
import { EVENTS, buildProxyHandler } from "@inrupt/solid-client-authn-core";
|
|
34
|
+
import type { fetch } from "@inrupt/universal-fetch";
|
|
35
35
|
import { v4 } from "uuid";
|
|
36
36
|
import EventEmitter from "events";
|
|
37
|
-
import ClientAuthentication from "./ClientAuthentication";
|
|
37
|
+
import type ClientAuthentication from "./ClientAuthentication";
|
|
38
38
|
import { getClientAuthenticationWithDependencies } from "./dependencies";
|
|
39
39
|
import { KEY_CURRENT_SESSION, KEY_CURRENT_URL } from "./constant";
|
|
40
40
|
|
|
@@ -252,9 +252,8 @@ export class Session extends EventEmitter implements IHasSessionEventListener {
|
|
|
252
252
|
* @param url The URL from which data should be fetched.
|
|
253
253
|
* @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/).
|
|
254
254
|
*/
|
|
255
|
-
fetch: typeof fetch =
|
|
256
|
-
|
|
257
|
-
};
|
|
255
|
+
fetch: typeof fetch = (url, init) =>
|
|
256
|
+
this.clientAuthentication.fetch(url, init);
|
|
258
257
|
|
|
259
258
|
/**
|
|
260
259
|
* An internal logout function, to control whether or not the logout signal
|
|
@@ -263,12 +262,15 @@ export class Session extends EventEmitter implements IHasSessionEventListener {
|
|
|
263
262
|
*
|
|
264
263
|
* @hidden
|
|
265
264
|
*/
|
|
266
|
-
private internalLogout = async (
|
|
265
|
+
private internalLogout = async (
|
|
266
|
+
emitSignal: boolean,
|
|
267
|
+
options?: ILogoutOptions
|
|
268
|
+
): Promise<void> => {
|
|
267
269
|
// Clearing this value means that silent refresh will no longer be attempted.
|
|
268
270
|
// In particular, in the case of a silent authentication error it prevents
|
|
269
271
|
// from getting stuck in an authentication retries loop.
|
|
270
272
|
window.localStorage.removeItem(KEY_CURRENT_SESSION);
|
|
271
|
-
await this.clientAuthentication.logout(this.info.sessionId);
|
|
273
|
+
await this.clientAuthentication.logout(this.info.sessionId, options);
|
|
272
274
|
this.info.isLoggedIn = false;
|
|
273
275
|
if (emitSignal) {
|
|
274
276
|
(this.events as EventEmitter).emit(EVENTS.LOGOUT);
|
|
@@ -276,9 +278,38 @@ export class Session extends EventEmitter implements IHasSessionEventListener {
|
|
|
276
278
|
};
|
|
277
279
|
|
|
278
280
|
/**
|
|
279
|
-
* Logs the user out of the application.
|
|
281
|
+
* Logs the user out of the application.
|
|
282
|
+
*
|
|
283
|
+
* There are 2 types of logout supported by this library,
|
|
284
|
+
* `app` logout and `idp` logout.
|
|
285
|
+
*
|
|
286
|
+
* App logout will log the user out within the application
|
|
287
|
+
* by clearing any session data from the browser. It does
|
|
288
|
+
* not log the user out of their Solid identity provider,
|
|
289
|
+
* and should not redirect the user away.
|
|
290
|
+
* App logout can be performed as follows:
|
|
291
|
+
* ```typescript
|
|
292
|
+
* await session.logout({ logoutType: 'app' });
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* IDP logout will log the user out of their Solid identity provider,
|
|
296
|
+
* and will redirect the user away from the application to do so.
|
|
297
|
+
* IDP logout can be performed as follows:
|
|
298
|
+
* ```typescript
|
|
299
|
+
* await session.logout({
|
|
300
|
+
* logoutType: 'idp',
|
|
301
|
+
* // An optional URL to redirect to after logout has completed;
|
|
302
|
+
* // this MUST match a logout URL listed in the clientId of
|
|
303
|
+
* // the application that is logged in.
|
|
304
|
+
* postLogoutUrl: 'https://example.com/logout',
|
|
305
|
+
* // An optional value to be included in the query parameters
|
|
306
|
+
* // when the IDP provider redirects the user to the postLogoutRedirectUrl.
|
|
307
|
+
* state: "my-state"
|
|
308
|
+
* });
|
|
309
|
+
* ```
|
|
280
310
|
*/
|
|
281
|
-
logout = async (): Promise<void> =>
|
|
311
|
+
logout = async (options?: ILogoutOptions): Promise<void> =>
|
|
312
|
+
this.internalLogout(true, options);
|
|
282
313
|
|
|
283
314
|
/**
|
|
284
315
|
* Completes the login process by processing the information provided by the
|
|
@@ -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
|
IIssuerConfigFetcher,
|
|
24
24
|
ILoginHandler,
|
|
25
25
|
ILogoutHandler,
|
|
@@ -30,12 +30,12 @@ import {
|
|
|
30
30
|
import {
|
|
31
31
|
mockStorageUtility,
|
|
32
32
|
mockIncomingRedirectHandler,
|
|
33
|
+
mockLogoutHandler,
|
|
33
34
|
} from "@inrupt/solid-client-authn-core/mocks";
|
|
34
35
|
|
|
35
36
|
import ClientAuthentication from "../ClientAuthentication";
|
|
36
37
|
import { IssuerConfigFetcherMock } from "../login/oidc/__mocks__/IssuerConfigFetcher";
|
|
37
38
|
import { mockLoginHandler } from "../login/__mocks__/LoginHandler";
|
|
38
|
-
import { mockLogoutHandler } from "../logout/__mocks__/LogoutHandler";
|
|
39
39
|
import { mockSessionInfoManager } from "../sessionInfo/__mocks__/SessionInfoManager";
|
|
40
40
|
|
|
41
41
|
type ClientAuthnDependencies = {
|
package/src/constant.ts
CHANGED
package/src/defaultSession.ts
CHANGED
|
@@ -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
|
|
@@ -67,8 +67,10 @@ export const login: Session["login"] = (...args) => {
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* Logs the user out of the application.
|
|
71
|
-
*
|
|
70
|
+
* Logs the user out of the application.
|
|
71
|
+
*
|
|
72
|
+
* By default this does not log the user out of their Solid identity provider.
|
|
73
|
+
* In order to do so, you must set the logoutType to `idp`.
|
|
72
74
|
*
|
|
73
75
|
* @since 1.3.0
|
|
74
76
|
*/
|
package/src/dependencies.spec.ts
CHANGED
package/src/dependencies.ts
CHANGED
|
@@ -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,14 +27,17 @@
|
|
|
27
27
|
/**
|
|
28
28
|
* Top Level core document. Responsible for setting up the dependency graph
|
|
29
29
|
*/
|
|
30
|
-
import { IStorage
|
|
30
|
+
import type { IStorage } from "@inrupt/solid-client-authn-core";
|
|
31
|
+
import {
|
|
32
|
+
InMemoryStorage,
|
|
33
|
+
IWaterfallLogoutHandler,
|
|
34
|
+
} from "@inrupt/solid-client-authn-core";
|
|
31
35
|
import StorageUtilityBrowser from "./storage/StorageUtility";
|
|
32
36
|
import ClientAuthentication from "./ClientAuthentication";
|
|
33
37
|
import OidcLoginHandler from "./login/oidc/OidcLoginHandler";
|
|
34
38
|
import AuthorizationCodeWithPkceOidcHandler from "./login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler";
|
|
35
39
|
import IssuerConfigFetcher from "./login/oidc/IssuerConfigFetcher";
|
|
36
40
|
import { FallbackRedirectHandler } from "./login/oidc/incomingRedirectHandler/FallbackRedirectHandler";
|
|
37
|
-
import GeneralLogoutHandler from "./logout/GeneralLogoutHandler";
|
|
38
41
|
import { SessionInfoManager } from "./sessionInfo/SessionInfoManager";
|
|
39
42
|
import { AuthCodeRedirectHandler } from "./login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler";
|
|
40
43
|
import AggregateRedirectHandler from "./login/oidc/AggregateRedirectHandler";
|
|
@@ -73,10 +76,12 @@ export function getClientAuthenticationWithDependencies(dependencies: {
|
|
|
73
76
|
clientRegistrar
|
|
74
77
|
);
|
|
75
78
|
|
|
79
|
+
const redirector = new Redirector();
|
|
80
|
+
|
|
76
81
|
// make new handler for redirect and login
|
|
77
82
|
const loginHandler = new OidcLoginHandler(
|
|
78
83
|
storageUtility,
|
|
79
|
-
new AuthorizationCodeWithPkceOidcHandler(storageUtility,
|
|
84
|
+
new AuthorizationCodeWithPkceOidcHandler(storageUtility, redirector),
|
|
80
85
|
issuerConfigFetcher,
|
|
81
86
|
clientRegistrar
|
|
82
87
|
);
|
|
@@ -98,7 +103,7 @@ export function getClientAuthenticationWithDependencies(dependencies: {
|
|
|
98
103
|
return new ClientAuthentication(
|
|
99
104
|
loginHandler,
|
|
100
105
|
redirectHandler,
|
|
101
|
-
new
|
|
106
|
+
new IWaterfallLogoutHandler(sessionInfoManager, redirector),
|
|
102
107
|
sessionInfoManager,
|
|
103
108
|
issuerConfigFetcher
|
|
104
109
|
);
|
package/src/index.browser.ts
CHANGED
package/src/index.spec.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -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
|
ILoginOptions,
|
|
24
24
|
ILoginHandler,
|
|
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,10 +19,8 @@
|
|
|
19
19
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
//
|
|
21
21
|
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
AggregateHandler,
|
|
25
|
-
} from "@inrupt/solid-client-authn-core";
|
|
22
|
+
import type { IOidcHandler } from "@inrupt/solid-client-authn-core";
|
|
23
|
+
import { AggregateHandler } from "@inrupt/solid-client-authn-core";
|
|
26
24
|
import { jest, it, describe, expect } from "@jest/globals";
|
|
27
25
|
import AggregateOidcHandler from "./AggregateOidcHandler";
|
|
28
26
|
|
|
@@ -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 selecting the correct OidcHandler to handle the provided OIDC Options
|
|
29
29
|
*/
|
|
30
|
-
import {
|
|
30
|
+
import type {
|
|
31
31
|
IOidcHandler,
|
|
32
32
|
IOidcOptions,
|
|
33
|
-
AggregateHandler,
|
|
34
33
|
LoginResult,
|
|
35
34
|
} from "@inrupt/solid-client-authn-core";
|
|
35
|
+
import { AggregateHandler } from "@inrupt/solid-client-authn-core";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @hidden
|
|
@@ -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 selecting the correct OidcHandler to handle the provided OIDC Options
|
|
29
29
|
*/
|
|
30
|
-
import {
|
|
30
|
+
import type {
|
|
31
31
|
IIncomingRedirectHandler,
|
|
32
|
-
AggregateHandler,
|
|
33
32
|
IncomingRedirectInput,
|
|
34
33
|
IncomingRedirectResult,
|
|
35
34
|
} from "@inrupt/solid-client-authn-core";
|
|
35
|
+
import { AggregateHandler } from "@inrupt/solid-client-authn-core";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @hidden
|
|
@@ -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
|
IStorageUtility,
|
|
29
29
|
IClientRegistrar,
|
|
30
30
|
IIssuerConfig,
|