@inrupt/solid-client-authn-browser 1.11.7 → 1.11.8-alpha.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/Session.d.ts +0 -1
- package/dist/Session.js +2 -45
- package/dist/Session.js.map +1 -1
- package/dist/login/oidc/redirectHandler/AuthCodeRedirectHandler.d.ts +0 -1
- package/dist/login/oidc/redirectHandler/AuthCodeRedirectHandler.js +1 -23
- package/dist/login/oidc/redirectHandler/AuthCodeRedirectHandler.js.map +1 -1
- package/dist/sessionInfo/SessionInfoManager.js +0 -8
- package/dist/sessionInfo/SessionInfoManager.js.map +1 -1
- package/dist/solid-client-authn.bundle.js +1 -1
- package/examples/demoClientApp/package-lock.json +18 -18
- package/examples/single/bundle/package-lock.json +18 -18
- package/jest.config.js +4 -0
- package/package.json +7 -22
- package/src/Session.spec.ts +0 -224
- package/src/Session.ts +8 -88
- package/src/login/oidc/__mocks__/Redirector.ts +9 -9
- package/src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.spec.ts +41 -18
- package/src/login/oidc/redirectHandler/AuthCodeRedirectHandler.spec.ts +3 -171
- package/src/login/oidc/redirectHandler/AuthCodeRedirectHandler.ts +0 -68
- package/src/sessionInfo/SessionInfoManager.spec.ts +0 -27
- package/src/sessionInfo/SessionInfoManager.ts +0 -10
|
@@ -19,23 +19,32 @@
|
|
|
19
19
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
import {
|
|
23
|
+
jest,
|
|
24
|
+
it,
|
|
25
|
+
describe,
|
|
26
|
+
expect,
|
|
27
|
+
beforeEach,
|
|
28
|
+
afterEach,
|
|
29
|
+
} from "@jest/globals";
|
|
30
|
+
import mockConsole, { RestoreConsole } from "jest-mock-console";
|
|
31
|
+
|
|
22
32
|
/**
|
|
23
33
|
* Test for AuthorizationCodeWithPkceOidcHandler
|
|
24
34
|
*/
|
|
25
35
|
import {
|
|
26
36
|
IOidcOptions,
|
|
27
|
-
IRedirector,
|
|
28
37
|
IRedirectorOptions,
|
|
29
38
|
mockStorage,
|
|
30
39
|
StorageUtility,
|
|
31
40
|
StorageUtilityMock,
|
|
32
41
|
} from "@inrupt/solid-client-authn-core";
|
|
33
|
-
|
|
42
|
+
|
|
34
43
|
import AuthorizationCodeWithPkceOidcHandler from "./AuthorizationCodeWithPkceOidcHandler";
|
|
35
44
|
import canHandleTests from "./OidcHandlerCanHandleTest";
|
|
36
45
|
import { SessionInfoManagerMock } from "../../../sessionInfo/__mocks__/SessionInfoManager";
|
|
37
46
|
import { standardOidcOptions } from "../__mocks__/IOidcOptions";
|
|
38
|
-
import {
|
|
47
|
+
import { mockedRedirect, mockRedirector } from "../__mocks__/Redirector";
|
|
39
48
|
|
|
40
49
|
jest.mock("@inrupt/oidc-client-ext");
|
|
41
50
|
|
|
@@ -57,10 +66,14 @@ const mockOidcModule = (
|
|
|
57
66
|
};
|
|
58
67
|
|
|
59
68
|
describe("AuthorizationCodeWithPkceOidcHandler", () => {
|
|
69
|
+
afterEach(() => {
|
|
70
|
+
jest.resetAllMocks();
|
|
71
|
+
});
|
|
72
|
+
|
|
60
73
|
const defaultMocks = {
|
|
61
74
|
sessionCreator: SessionInfoManagerMock,
|
|
62
75
|
storageUtility: StorageUtilityMock,
|
|
63
|
-
redirector:
|
|
76
|
+
redirector: mockRedirector(),
|
|
64
77
|
};
|
|
65
78
|
|
|
66
79
|
function getAuthorizationCodeWithPkceOidcHandler(
|
|
@@ -91,20 +104,18 @@ describe("AuthorizationCodeWithPkceOidcHandler", () => {
|
|
|
91
104
|
describe("handle", () => {
|
|
92
105
|
it("swallows any redirector exceptions", async () => {
|
|
93
106
|
mockOidcModule();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
mockConsole("error");
|
|
108
|
+
|
|
109
|
+
mockedRedirect.mockImplementation(
|
|
110
|
+
(redirectUrl: string, redirectOptions: IRedirectorOptions) => {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Redirecting to [${redirectUrl}] with options [${redirectOptions}] throws...`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
103
116
|
|
|
104
117
|
const authorizationCodeWithPkceOidcHandler =
|
|
105
|
-
getAuthorizationCodeWithPkceOidcHandler(
|
|
106
|
-
redirector: redirectorThatThrowsMock,
|
|
107
|
-
});
|
|
118
|
+
getAuthorizationCodeWithPkceOidcHandler();
|
|
108
119
|
|
|
109
120
|
const oidcOptions: IOidcOptions = {
|
|
110
121
|
...standardOidcOptions,
|
|
@@ -115,8 +126,20 @@ describe("AuthorizationCodeWithPkceOidcHandler", () => {
|
|
|
115
126
|
grantTypesSupported: ["authorization_code"],
|
|
116
127
|
},
|
|
117
128
|
};
|
|
118
|
-
|
|
119
|
-
expect(
|
|
129
|
+
|
|
130
|
+
await expect(
|
|
131
|
+
authorizationCodeWithPkceOidcHandler.handle(oidcOptions)
|
|
132
|
+
).resolves.toBeUndefined();
|
|
133
|
+
|
|
134
|
+
expect(mockedRedirect).toHaveBeenCalledTimes(1);
|
|
135
|
+
|
|
136
|
+
// Test the error was even printed to the console Note: this matcher is
|
|
137
|
+
// pretty nasty due to an Error instance being logged without being
|
|
138
|
+
// converted to a string:
|
|
139
|
+
expect(console.error).toHaveBeenCalledTimes(1);
|
|
140
|
+
expect(
|
|
141
|
+
(console as jest.Mocked<Console>).error.mock.calls[0][0].toString()
|
|
142
|
+
).toMatch(/Error: Redirecting to \[[^\]]+\] with options/);
|
|
120
143
|
});
|
|
121
144
|
|
|
122
145
|
it("handles login properly with PKCE", async () => {
|
|
@@ -35,11 +35,8 @@ import { CodeExchangeResult, getBearerToken } from "@inrupt/oidc-client-ext";
|
|
|
35
35
|
import { Response } from "cross-fetch";
|
|
36
36
|
import { JWK, importJWK } from "jose";
|
|
37
37
|
import { KeyObject } from "crypto";
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
DEFAULT_LIFESPAN,
|
|
41
|
-
} from "./AuthCodeRedirectHandler";
|
|
42
|
-
import { RedirectorMock } from "../__mocks__/Redirector";
|
|
38
|
+
import { AuthCodeRedirectHandler } from "./AuthCodeRedirectHandler";
|
|
39
|
+
import { mockRedirector } from "../__mocks__/Redirector";
|
|
43
40
|
import { SessionInfoManagerMock } from "../../../sessionInfo/__mocks__/SessionInfoManager";
|
|
44
41
|
import { LocalStorageMock } from "../../../storage/__mocks__/LocalStorage";
|
|
45
42
|
import {
|
|
@@ -211,7 +208,7 @@ const mockFetch = (response: Response) => {
|
|
|
211
208
|
|
|
212
209
|
const defaultMocks = {
|
|
213
210
|
storageUtility: StorageUtilityMock,
|
|
214
|
-
redirector:
|
|
211
|
+
redirector: mockRedirector(),
|
|
215
212
|
sessionInfoManager: SessionInfoManagerMock,
|
|
216
213
|
clientRegistrar: mockClientRegistrar(mockClient()),
|
|
217
214
|
issuerConfigFetcher: mockIssuerConfigFetcher(mockIssuer()),
|
|
@@ -514,15 +511,11 @@ describe("AuthCodeRedirectHandler", () => {
|
|
|
514
511
|
it("returns the expiration time normalised to the current time", async () => {
|
|
515
512
|
mockOidcClient();
|
|
516
513
|
window.fetch = jest.fn();
|
|
517
|
-
mockLocalStorage({
|
|
518
|
-
"tmp-resource-server-session-enabled": "false",
|
|
519
|
-
});
|
|
520
514
|
const MOCK_TIMESTAMP = 10000;
|
|
521
515
|
Date.now = jest
|
|
522
516
|
.fn()
|
|
523
517
|
// Date.now is called twice: once to be able to calculate the auth token expiry time,
|
|
524
518
|
// and once to set the cookie expiry. We only care about the second in this test.
|
|
525
|
-
.mockReturnValueOnce(MOCK_TIMESTAMP)
|
|
526
519
|
.mockReturnValueOnce(MOCK_TIMESTAMP) as typeof Date.now;
|
|
527
520
|
|
|
528
521
|
const authCodeRedirectHandler = getAuthCodeRedirectHandler({
|
|
@@ -541,9 +534,6 @@ describe("AuthCodeRedirectHandler", () => {
|
|
|
541
534
|
it("returns null for the expiration time if none was provided", async () => {
|
|
542
535
|
const mockedOidcClient = mockOidcClient();
|
|
543
536
|
window.fetch = jest.fn();
|
|
544
|
-
mockLocalStorage({
|
|
545
|
-
"tmp-resource-server-session-enabled": "false",
|
|
546
|
-
});
|
|
547
537
|
mockedOidcClient.getBearerToken = jest
|
|
548
538
|
.fn(getBearerToken)
|
|
549
539
|
.mockResolvedValueOnce({
|
|
@@ -582,165 +572,7 @@ describe("AuthCodeRedirectHandler", () => {
|
|
|
582
572
|
});
|
|
583
573
|
});
|
|
584
574
|
|
|
585
|
-
it("stores information about the resource server cookie in local storage on successful authentication", async () => {
|
|
586
|
-
mockOidcClient();
|
|
587
|
-
|
|
588
|
-
// This mocks the fetch to the Resource Server session endpoint
|
|
589
|
-
// Note: Currently, the endpoint only returns the webid in plain/text, it could
|
|
590
|
-
// be extended later to also provide the cookie expiration.
|
|
591
|
-
mockFetch(
|
|
592
|
-
new Response("https://my.webid", {
|
|
593
|
-
status: 200,
|
|
594
|
-
})
|
|
595
|
-
);
|
|
596
|
-
|
|
597
|
-
const MOCK_TIMESTAMP = 10000;
|
|
598
|
-
Date.now = jest
|
|
599
|
-
.fn()
|
|
600
|
-
// Date.now is called twice: once to be able to calculate the auth token expiry time,
|
|
601
|
-
// and once to set the cookie expiry. We only care about the second in this test.
|
|
602
|
-
.mockReturnValueOnce(MOCK_TIMESTAMP)
|
|
603
|
-
.mockReturnValueOnce(MOCK_TIMESTAMP) as typeof Date.now;
|
|
604
|
-
|
|
605
|
-
const mockedStorage = mockDefaultStorageUtility();
|
|
606
|
-
|
|
607
|
-
const authCodeRedirectHandler = getAuthCodeRedirectHandler({
|
|
608
|
-
storageUtility: mockedStorage,
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
await authCodeRedirectHandler.handle(mockRedirectUrl());
|
|
612
|
-
expect(
|
|
613
|
-
JSON.parse(
|
|
614
|
-
(await mockedStorage.get("tmp-resource-server-session-info")) as string
|
|
615
|
-
)
|
|
616
|
-
).toEqual({
|
|
617
|
-
webId: "https://my.webid",
|
|
618
|
-
sessions: {
|
|
619
|
-
"https://my.webid": {
|
|
620
|
-
expiration: MOCK_TIMESTAMP + DEFAULT_LIFESPAN,
|
|
621
|
-
},
|
|
622
|
-
},
|
|
623
|
-
});
|
|
624
|
-
});
|
|
625
|
-
|
|
626
|
-
it("does not look the session endpoint up if the ESS cookie workaround has been disabled", async () => {
|
|
627
|
-
mockOidcClient();
|
|
628
|
-
mockLocalStorage({
|
|
629
|
-
"tmp-resource-server-session-enabled": "false",
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
// This mocks the fetch to the Resource Server session endpoint
|
|
633
|
-
// Note: Currently, the endpoint only returns the webid in plain/text, it could
|
|
634
|
-
// be extended later to also provide the cookie expiration.
|
|
635
|
-
mockFetch(
|
|
636
|
-
new Response("https://my.webid", {
|
|
637
|
-
status: 200,
|
|
638
|
-
})
|
|
639
|
-
);
|
|
640
|
-
|
|
641
|
-
const MOCK_TIMESTAMP = 10000;
|
|
642
|
-
Date.now = jest
|
|
643
|
-
.fn()
|
|
644
|
-
// Date.now is called twice: once to be able to calculate the auth token expiry time,
|
|
645
|
-
// and once to set the cookie expiry. We only care about the second in this test.
|
|
646
|
-
.mockReturnValueOnce(MOCK_TIMESTAMP)
|
|
647
|
-
.mockReturnValueOnce(MOCK_TIMESTAMP) as typeof Date.now;
|
|
648
|
-
|
|
649
|
-
const mockedStorage = mockDefaultStorageUtility();
|
|
650
|
-
|
|
651
|
-
const authCodeRedirectHandler = getAuthCodeRedirectHandler({
|
|
652
|
-
storageUtility: mockedStorage,
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
await authCodeRedirectHandler.handle(mockRedirectUrl());
|
|
656
|
-
expect(
|
|
657
|
-
JSON.parse(
|
|
658
|
-
(await mockedStorage.get("tmp-resource-server-session-info")) ?? "{}"
|
|
659
|
-
)
|
|
660
|
-
).toEqual({});
|
|
661
|
-
});
|
|
662
|
-
|
|
663
|
-
it("store nothing if the resource server has no session endpoint", async () => {
|
|
664
|
-
mockOidcClient();
|
|
665
|
-
mockLocalStorage({});
|
|
666
|
-
// This mocks the fetch to the Resource Server session endpoint
|
|
667
|
-
// Note: Currently, the endpoint only returns the WebID in plain/text, it could
|
|
668
|
-
// be extended later to also provide the cookie expiration.
|
|
669
|
-
mockFetch(
|
|
670
|
-
new Response("", {
|
|
671
|
-
status: 404,
|
|
672
|
-
})
|
|
673
|
-
);
|
|
674
|
-
|
|
675
|
-
const mockedStorage = mockDefaultStorageUtility();
|
|
676
|
-
|
|
677
|
-
const authCodeRedirectHandler = getAuthCodeRedirectHandler({
|
|
678
|
-
storageUtility: mockedStorage,
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
await authCodeRedirectHandler.handle(mockRedirectUrl());
|
|
682
|
-
expect(
|
|
683
|
-
JSON.parse(
|
|
684
|
-
(await mockedStorage.get("tmp-resource-server-session-info")) ?? "{}"
|
|
685
|
-
)
|
|
686
|
-
).toEqual({});
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
it("swallows the exception if the fetch to the session endpoint fails", async () => {
|
|
690
|
-
mockOidcClient();
|
|
691
|
-
mockLocalStorage({});
|
|
692
|
-
window.fetch = (jest.fn() as any)
|
|
693
|
-
.mockResolvedValueOnce(
|
|
694
|
-
new Response("https://my.webid", {
|
|
695
|
-
status: 200,
|
|
696
|
-
})
|
|
697
|
-
)
|
|
698
|
-
.mockRejectedValueOnce("Some error");
|
|
699
|
-
|
|
700
|
-
const mockedStorage = mockDefaultStorageUtility();
|
|
701
|
-
|
|
702
|
-
const authCodeRedirectHandler = getAuthCodeRedirectHandler({
|
|
703
|
-
storageUtility: mockedStorage,
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
await authCodeRedirectHandler.handle(mockRedirectUrl());
|
|
707
|
-
expect(
|
|
708
|
-
JSON.parse(
|
|
709
|
-
(await mockedStorage.get("tmp-resource-server-session-info")) ?? "{}"
|
|
710
|
-
)
|
|
711
|
-
).toEqual({});
|
|
712
|
-
});
|
|
713
|
-
|
|
714
|
-
it("store nothing if the resource server does not recognize the user", async () => {
|
|
715
|
-
mockOidcClient();
|
|
716
|
-
mockLocalStorage({});
|
|
717
|
-
// This mocks the fetch to the Resource Server session endpoint
|
|
718
|
-
// Note: Currently, the endpoint only returns the WebID in plain/text, it could
|
|
719
|
-
// be extended later to also provide the cookie expiration.
|
|
720
|
-
mockFetch(
|
|
721
|
-
new Response("", {
|
|
722
|
-
status: 401,
|
|
723
|
-
})
|
|
724
|
-
);
|
|
725
|
-
|
|
726
|
-
const mockedStorage = mockDefaultStorageUtility({ dpop: false });
|
|
727
|
-
|
|
728
|
-
const authCodeRedirectHandler = getAuthCodeRedirectHandler({
|
|
729
|
-
storageUtility: mockedStorage,
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
await authCodeRedirectHandler.handle(mockRedirectUrl());
|
|
733
|
-
expect(
|
|
734
|
-
JSON.parse(
|
|
735
|
-
(await mockedStorage.get("tmp-resource-server-session-info")) ?? "{}"
|
|
736
|
-
)
|
|
737
|
-
).toEqual({});
|
|
738
|
-
});
|
|
739
|
-
|
|
740
575
|
it("returns a fetch that supports the refresh flow", async () => {
|
|
741
|
-
mockLocalStorage({
|
|
742
|
-
"tmp-resource-server-session-enabled": "false",
|
|
743
|
-
});
|
|
744
576
|
mockOidcClient();
|
|
745
577
|
const mockedStorage = mockDefaultStorageUtility();
|
|
746
578
|
const coreModule = jest.requireActual(
|
|
@@ -44,62 +44,6 @@ import {
|
|
|
44
44
|
} from "@inrupt/oidc-client-ext";
|
|
45
45
|
import { EventEmitter } from "events";
|
|
46
46
|
|
|
47
|
-
// A lifespan of 30 minutes is ESS's default. This could be removed if we
|
|
48
|
-
// configure the server to return the remaining lifespan of the cookie.
|
|
49
|
-
export const DEFAULT_LIFESPAN = 30 * 60 * 1000;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Stores the resource server session information in local storage, so that they
|
|
53
|
-
* can be used on refresh.
|
|
54
|
-
* @param webId
|
|
55
|
-
* @param authenticatedFetch
|
|
56
|
-
* @param storageUtility
|
|
57
|
-
*/
|
|
58
|
-
async function setupResourceServerSession(
|
|
59
|
-
webId: string,
|
|
60
|
-
authenticatedFetch: typeof fetch,
|
|
61
|
-
storageUtility: IStorageUtility
|
|
62
|
-
): Promise<void> {
|
|
63
|
-
const webIdAsUrl = new URL(webId);
|
|
64
|
-
const resourceServerIri = webIdAsUrl.origin;
|
|
65
|
-
// Querying the /session endpoint does not set the cookie, but issuing an
|
|
66
|
-
// authenticated request to any actual resource (even public ones) does,
|
|
67
|
-
// so we fetch the user's WebID before checking the /session endpoint.
|
|
68
|
-
await authenticatedFetch(webId);
|
|
69
|
-
try {
|
|
70
|
-
const resourceServerResponse = await authenticatedFetch(
|
|
71
|
-
`${resourceServerIri}/session`
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
if (resourceServerResponse.status === 200) {
|
|
75
|
-
await storageUtility.storeResourceServerSessionInfo(
|
|
76
|
-
webId,
|
|
77
|
-
resourceServerIri,
|
|
78
|
-
// Note that here, if the lifespan of the cookie was returned by the
|
|
79
|
-
// server, we'd expect a relative value (the remaining time of validity)
|
|
80
|
-
// rather than an absolute one (the moment when the cookie expires).
|
|
81
|
-
Date.now() + DEFAULT_LIFESPAN
|
|
82
|
-
);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
// In this case, the resource server either:
|
|
86
|
-
// - does not have the expected endpoint, or
|
|
87
|
-
// - does not recognize the user
|
|
88
|
-
// Either way, no cookie is expected to be set there, and any existing
|
|
89
|
-
// session information should be cleared.
|
|
90
|
-
await storageUtility.clearResourceServerSessionInfo(resourceServerIri);
|
|
91
|
-
} catch (_e) {
|
|
92
|
-
// Setting the `credentials=include` option on fetch, which is required in
|
|
93
|
-
// the current approach based on a RS cookie, may result in an error if
|
|
94
|
-
// attempting to access an URL, depending on the CORS policies.
|
|
95
|
-
// Since this internal fetch is necessary, and out of control of the
|
|
96
|
-
// calling library, there is no other solution but to swallow the exception.
|
|
97
|
-
// This may happen depending on how the target RS handles a request to the
|
|
98
|
-
// /session endpoint.
|
|
99
|
-
await storageUtility.clearResourceServerSessionInfo(resourceServerIri);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
47
|
/**
|
|
104
48
|
* @hidden
|
|
105
49
|
*/
|
|
@@ -233,18 +177,6 @@ export class AuthCodeRedirectHandler implements IRedirectHandler {
|
|
|
233
177
|
secure: false,
|
|
234
178
|
}
|
|
235
179
|
);
|
|
236
|
-
// TODO: This is a temporary workaround. When deprecating the cookie-based auth,
|
|
237
|
-
// this should be all cleared.
|
|
238
|
-
const essWorkaroundDisabled =
|
|
239
|
-
window.localStorage.getItem("tmp-resource-server-session-enabled") ===
|
|
240
|
-
"false";
|
|
241
|
-
if (!essWorkaroundDisabled) {
|
|
242
|
-
await setupResourceServerSession(
|
|
243
|
-
tokens.webId,
|
|
244
|
-
authFetch,
|
|
245
|
-
this.storageUtility
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
180
|
|
|
249
181
|
const sessionInfo = await this.sessionInfoManager.get(storedSessionId);
|
|
250
182
|
if (!sessionInfo) {
|
|
@@ -274,33 +274,6 @@ describe("SessionInfoManager", () => {
|
|
|
274
274
|
await mockedStorage.getForUser("mySession", "key", { secure: false })
|
|
275
275
|
).toBeUndefined();
|
|
276
276
|
});
|
|
277
|
-
|
|
278
|
-
it("clears resource server session info from local storage", async () => {
|
|
279
|
-
const mockedStorage = mockStorageUtility(
|
|
280
|
-
{
|
|
281
|
-
"solidClientAuthenticationUser:mySession": {
|
|
282
|
-
webId: "https://my.pod/profile#me",
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
true
|
|
286
|
-
);
|
|
287
|
-
await mockedStorage.storeResourceServerSessionInfo(
|
|
288
|
-
"https://my.pod/profile#me",
|
|
289
|
-
"https://my.pod",
|
|
290
|
-
10000
|
|
291
|
-
);
|
|
292
|
-
const sessionManager = getSessionInfoManager({
|
|
293
|
-
storageUtility: mockedStorage,
|
|
294
|
-
});
|
|
295
|
-
await sessionManager.clear("mySession");
|
|
296
|
-
expect(
|
|
297
|
-
JSON.parse(
|
|
298
|
-
(await mockedStorage.get("tmp-resource-server-session-info", {
|
|
299
|
-
secure: false,
|
|
300
|
-
})) ?? ""
|
|
301
|
-
)
|
|
302
|
-
).toEqual({});
|
|
303
|
-
});
|
|
304
277
|
});
|
|
305
278
|
|
|
306
279
|
describe("getAll", () => {
|
|
@@ -54,16 +54,6 @@ export async function clear(
|
|
|
54
54
|
sessionId: string,
|
|
55
55
|
storage: IStorageUtility
|
|
56
56
|
): Promise<void> {
|
|
57
|
-
const storedSessionCookieReference = await storage.get(
|
|
58
|
-
"tmp-resource-server-session-info"
|
|
59
|
-
);
|
|
60
|
-
const reference = JSON.parse(storedSessionCookieReference ?? "{}");
|
|
61
|
-
const { webId } = reference;
|
|
62
|
-
if (webId !== undefined) {
|
|
63
|
-
const webIdAsUrl = new URL(webId);
|
|
64
|
-
const resourceServerIri = webIdAsUrl.origin;
|
|
65
|
-
await storage.clearResourceServerSessionInfo(resourceServerIri);
|
|
66
|
-
}
|
|
67
57
|
await Promise.all([
|
|
68
58
|
storage.deleteAllUserData(sessionId, { secure: false }),
|
|
69
59
|
storage.deleteAllUserData(sessionId, { secure: true }),
|