@inrupt/solid-client-authn-browser 1.13.4 → 1.15.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.
Files changed (38) hide show
  1. package/dist/ClientAuthentication.d.ts +1 -1
  2. package/dist/ClientAuthentication.js +2 -1
  3. package/dist/ClientAuthentication.js.map +1 -1
  4. package/dist/Session.d.ts +5 -3
  5. package/dist/Session.js +21 -17
  6. package/dist/Session.js.map +1 -1
  7. package/dist/defaultSession.d.ts +1 -0
  8. package/dist/defaultSession.js +5 -1
  9. package/dist/defaultSession.js.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +2 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/login/oidc/IssuerConfigFetcher.js +2 -1
  14. package/dist/login/oidc/IssuerConfigFetcher.js.map +1 -1
  15. package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.d.ts +1 -0
  16. package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.js +2 -1
  17. package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.js.map +1 -1
  18. package/dist/sessionInfo/SessionInfoManager.d.ts +1 -0
  19. package/dist/sessionInfo/SessionInfoManager.js +2 -1
  20. package/dist/sessionInfo/SessionInfoManager.js.map +1 -1
  21. package/dist/solid-client-authn.bundle.js +1 -1
  22. package/package.json +5 -7
  23. package/src/ClientAuthentication.spec.ts +15 -8
  24. package/src/ClientAuthentication.ts +2 -2
  25. package/src/Session.spec.ts +255 -119
  26. package/src/Session.ts +44 -18
  27. package/src/defaultSession.spec.ts +28 -19
  28. package/src/defaultSession.ts +15 -1
  29. package/src/index.ts +1 -0
  30. package/src/login/oidc/ClientRegistrar.spec.ts +1 -1
  31. package/src/login/oidc/IssuerConfigFetcher.spec.ts +60 -40
  32. package/src/login/oidc/IssuerConfigFetcher.ts +2 -1
  33. package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.spec.ts +27 -22
  34. package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.ts +2 -0
  35. package/src/login/oidc/incomingRedirectHandler/ErrorOidcHandler.spec.ts +12 -3
  36. package/src/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.spec.ts +12 -1
  37. package/src/sessionInfo/SessionInfoManager.ts +1 -0
  38. package/tsconfig.json +2 -1
@@ -22,8 +22,20 @@
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 { fetch } from "@inrupt/universal-fetch";
26
+ import * as UniversalFetch from "@inrupt/universal-fetch";
25
27
  import { ErrorOidcHandler } from "./ErrorOidcHandler";
26
28
 
29
+ jest.mock("@inrupt/universal-fetch", () => {
30
+ const fetchModule = jest.requireActual(
31
+ "@inrupt/universal-fetch"
32
+ ) as typeof UniversalFetch;
33
+ return {
34
+ ...fetchModule,
35
+ fetch: jest.fn<typeof fetch>(),
36
+ };
37
+ });
38
+
27
39
  describe("ErrorOidcHandler", () => {
28
40
  describe("canHandle", () => {
29
41
  it("Does not handle IRIs without an error parameter", async () => {
@@ -62,14 +74,12 @@ describe("ErrorOidcHandler", () => {
62
74
 
63
75
  describe("handle", () => {
64
76
  it("returns an unauthenticated session", async () => {
65
- window.fetch = jest.fn<typeof fetch>();
66
77
  const redirectHandler = new ErrorOidcHandler();
67
78
  const mySession = await redirectHandler.handle("https://my.app");
68
79
  expect(mySession.isLoggedIn).toBe(false);
69
80
  expect(mySession.webId).toBeUndefined();
70
81
  });
71
82
  it("calls the onError callback if given with both parameters", async () => {
72
- window.fetch = jest.fn<typeof fetch>();
73
83
  const mockEmitter = new EventEmitter();
74
84
  // error events must be handled: https://nodejs.org/dist/latest-v16.x/docs/api/events.html#error-events
75
85
  mockEmitter.on(EVENTS.ERROR, jest.fn());
@@ -90,7 +100,6 @@ describe("ErrorOidcHandler", () => {
90
100
  });
91
101
 
92
102
  it("calls the onError callback if given with just error parameters if no description is provided", async () => {
93
- window.fetch = jest.fn<typeof fetch>();
94
103
  const mockEmitter = new EventEmitter();
95
104
  const mockEmit = jest.spyOn(mockEmitter, "emit");
96
105
  // error events must be handled: https://nodejs.org/dist/latest-v16.x/docs/api/events.html#error-events
@@ -20,8 +20,20 @@
20
20
  //
21
21
 
22
22
  import { jest, it, describe, expect } from "@jest/globals";
23
+ import { fetch } from "@inrupt/universal-fetch";
24
+ import * as UniversalFetch from "@inrupt/universal-fetch";
23
25
  import { FallbackRedirectHandler } from "./FallbackRedirectHandler";
24
26
 
27
+ jest.mock("@inrupt/universal-fetch", () => {
28
+ const fetchModule = jest.requireActual(
29
+ "@inrupt/universal-fetch"
30
+ ) as typeof UniversalFetch;
31
+ return {
32
+ ...fetchModule,
33
+ fetch: jest.fn<typeof fetch>(),
34
+ };
35
+ });
36
+
25
37
  describe("FallbackRedirectHandler", () => {
26
38
  describe("canHandle", () => {
27
39
  it("always accept the given IRI", async () => {
@@ -51,7 +63,6 @@ describe("FallbackRedirectHandler", () => {
51
63
 
52
64
  describe("handle", () => {
53
65
  it("returns an unauthenticated session", async () => {
54
- window.fetch = jest.fn<typeof fetch>();
55
66
  const redirectHandler = new FallbackRedirectHandler();
56
67
  const mySession = await redirectHandler.handle("https://my.app");
57
68
  expect(mySession.isLoggedIn).toBe(false);
@@ -34,6 +34,7 @@ import {
34
34
  } from "@inrupt/solid-client-authn-core";
35
35
  import { v4 } from "uuid";
36
36
  import { clearOidcPersistentStorage } from "@inrupt/oidc-client-ext";
37
+ import { fetch } from "@inrupt/universal-fetch";
37
38
 
38
39
  export function getUnauthenticatedSession(): ISessionInfo & {
39
40
  fetch: typeof fetch;
package/tsconfig.json CHANGED
@@ -9,8 +9,9 @@
9
9
  "typedocOptions": {
10
10
  "out": "website/docs/api/browser",
11
11
  "entryPoints": ["./src/index.ts"],
12
- "entryDocument": "index.md",
12
+ "entryDocument": "index.rst",
13
13
  "hideInPageTOC": true,
14
+ "plugin": ["typedoc-plugin-markdown"]
14
15
  },
15
16
 
16
17
  "include": ["src/**/*"],