@inrupt/solid-client-authn-browser 2.2.4 → 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ClientAuthentication.d.ts +0 -1
- package/dist/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.d.ts +0 -1
- package/dist/login/oidc/incomingRedirectHandler/ErrorOidcHandler.d.ts +0 -1
- package/dist/login/oidc/refresh/TokenRefresher.d.ts +0 -1
- package/package.json +5 -5
- package/rollup.config.mjs +1 -1
- package/src/login/oidc/ClientRegistrar.spec.ts +19 -12
- package/src/login/oidc/OidcLoginHandler.spec.ts +7 -5
- package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.spec.ts +1 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inrupt/solid-client-authn-browser",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"build-docs-preview-site": "npm run build-api-docs; cd docs/api; make html"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/node": "^
|
|
28
|
+
"@types/node": "^22.5.4",
|
|
29
29
|
"@types/uuid": "^10.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@inrupt/oidc-client-ext": "^2.2.
|
|
33
|
-
"@inrupt/solid-client-authn-core": "^2.2.
|
|
32
|
+
"@inrupt/oidc-client-ext": "^2.2.5",
|
|
33
|
+
"@inrupt/solid-client-authn-core": "^2.2.5",
|
|
34
34
|
"events": "^3.3.0",
|
|
35
35
|
"jose": "^5.1.3",
|
|
36
36
|
"uuid": "^10.0.0"
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "afb64c40f9f034e800c0c22db81492a5d8d6ceda"
|
|
42
42
|
}
|
package/rollup.config.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import commonjs from "@rollup/plugin-commonjs";
|
|
|
24
24
|
import terser from "@rollup/plugin-terser";
|
|
25
25
|
import createConfig, { createSharedConfig } from "@inrupt/base-rollup-config";
|
|
26
26
|
// eslint-disable-next-line import/extensions
|
|
27
|
-
import pkg from "./package.json"
|
|
27
|
+
import pkg from "./package.json" with { type: "json" };
|
|
28
28
|
|
|
29
29
|
export default [
|
|
30
30
|
...createConfig(pkg),
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
mockStorageUtility,
|
|
25
25
|
} from "@inrupt/solid-client-authn-core/mocks";
|
|
26
26
|
import { jest, it, describe, expect } from "@jest/globals";
|
|
27
|
+
import { randomUUID } from "crypto";
|
|
27
28
|
import ClientRegistrar from "./ClientRegistrar";
|
|
28
29
|
import { IssuerConfigFetcherFetchConfigResponse } from "./__mocks__/IssuerConfigFetcher";
|
|
29
30
|
|
|
@@ -42,14 +43,16 @@ describe("ClientRegistrar", () => {
|
|
|
42
43
|
|
|
43
44
|
describe("getClient", () => {
|
|
44
45
|
it("properly performs dynamic registration", async () => {
|
|
46
|
+
const clientId = randomUUID();
|
|
47
|
+
const clientSecret = randomUUID();
|
|
45
48
|
// FIXME: this should mock out oidc-client-ext, instead of mimicking the
|
|
46
49
|
// actual OIDC provider response.
|
|
47
50
|
const mockFetch = (jest.fn() as any).mockResolvedValueOnce(
|
|
48
51
|
/* eslint-disable camelcase */
|
|
49
52
|
new Response(
|
|
50
53
|
JSON.stringify({
|
|
51
|
-
client_id:
|
|
52
|
-
client_secret:
|
|
54
|
+
client_id: clientId,
|
|
55
|
+
client_secret: clientSecret,
|
|
53
56
|
redirect_uris: ["https://example.com"],
|
|
54
57
|
id_token_signed_response_alg: "RS256",
|
|
55
58
|
}),
|
|
@@ -73,8 +76,8 @@ describe("ClientRegistrar", () => {
|
|
|
73
76
|
},
|
|
74
77
|
),
|
|
75
78
|
).toMatchObject({
|
|
76
|
-
clientId
|
|
77
|
-
clientSecret
|
|
79
|
+
clientId,
|
|
80
|
+
clientSecret,
|
|
78
81
|
});
|
|
79
82
|
expect(mockFetch).toHaveBeenCalledWith(registrationUrl.toString(), {
|
|
80
83
|
method: "POST",
|
|
@@ -170,12 +173,14 @@ describe("ClientRegistrar", () => {
|
|
|
170
173
|
});
|
|
171
174
|
|
|
172
175
|
it("retrieves client id and secret from storage if they are present", async () => {
|
|
176
|
+
const clientId = randomUUID();
|
|
177
|
+
const clientSecret = randomUUID();
|
|
173
178
|
const clientRegistrar = getClientRegistrar({
|
|
174
179
|
storage: mockStorageUtility(
|
|
175
180
|
{
|
|
176
181
|
"solidClientAuthenticationUser:mySession": {
|
|
177
|
-
clientId
|
|
178
|
-
clientSecret
|
|
182
|
+
clientId,
|
|
183
|
+
clientSecret,
|
|
179
184
|
clientType: "dynamic",
|
|
180
185
|
},
|
|
181
186
|
},
|
|
@@ -191,17 +196,19 @@ describe("ClientRegistrar", () => {
|
|
|
191
196
|
...IssuerConfigFetcherFetchConfigResponse,
|
|
192
197
|
},
|
|
193
198
|
);
|
|
194
|
-
expect(client.clientId).toBe(
|
|
195
|
-
expect(client.clientSecret).toBe(
|
|
199
|
+
expect(client.clientId).toBe(clientId);
|
|
200
|
+
expect(client.clientSecret).toBe(clientSecret);
|
|
196
201
|
});
|
|
197
202
|
|
|
198
203
|
it("saves dynamic registration information", async () => {
|
|
204
|
+
const clientId = randomUUID();
|
|
205
|
+
const clientSecret = randomUUID();
|
|
199
206
|
const mockFetch = (jest.fn() as any).mockResolvedValueOnce(
|
|
200
207
|
/* eslint-disable camelcase */
|
|
201
208
|
new Response(
|
|
202
209
|
JSON.stringify({
|
|
203
|
-
client_id:
|
|
204
|
-
client_secret:
|
|
210
|
+
client_id: clientId,
|
|
211
|
+
client_secret: clientSecret,
|
|
205
212
|
redirect_uris: ["https://example.com"],
|
|
206
213
|
}),
|
|
207
214
|
),
|
|
@@ -227,10 +234,10 @@ describe("ClientRegistrar", () => {
|
|
|
227
234
|
|
|
228
235
|
await expect(
|
|
229
236
|
myStorage.getForUser("mySession", "clientId", { secure: false }),
|
|
230
|
-
).resolves.toBe(
|
|
237
|
+
).resolves.toBe(clientId);
|
|
231
238
|
await expect(
|
|
232
239
|
myStorage.getForUser("mySession", "clientSecret", { secure: false }),
|
|
233
|
-
).resolves.toBe(
|
|
240
|
+
).resolves.toBe(clientSecret);
|
|
234
241
|
});
|
|
235
242
|
});
|
|
236
243
|
});
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
StorageUtilityMock,
|
|
27
27
|
mockStorage,
|
|
28
28
|
} from "@inrupt/solid-client-authn-core/mocks";
|
|
29
|
+
import { randomUUID } from "crypto";
|
|
29
30
|
|
|
30
31
|
import { OidcHandlerMock } from "./__mocks__/IOidcHandler";
|
|
31
32
|
import {
|
|
@@ -108,8 +109,8 @@ describe("OidcLoginHandler", () => {
|
|
|
108
109
|
it("should lookup client ID if not provided, if not found do DCR", async () => {
|
|
109
110
|
const mockedOidcModule = jest.requireMock("@inrupt/oidc-client-ext") as any;
|
|
110
111
|
mockedOidcModule.registerClient = (jest.fn() as any).mockResolvedValue({
|
|
111
|
-
clientId:
|
|
112
|
-
clientSecret:
|
|
112
|
+
clientId: randomUUID(),
|
|
113
|
+
clientSecret: randomUUID(),
|
|
113
114
|
});
|
|
114
115
|
|
|
115
116
|
const mockedEmptyStorage = new StorageUtility(
|
|
@@ -135,10 +136,11 @@ describe("OidcLoginHandler", () => {
|
|
|
135
136
|
});
|
|
136
137
|
|
|
137
138
|
it("should perform DCR if a client WebID is provided, but the target IdP does not support Solid-OIDC", async () => {
|
|
139
|
+
const clientId = randomUUID();
|
|
138
140
|
const mockedOidcModule = jest.requireMock("@inrupt/oidc-client-ext") as any;
|
|
139
141
|
mockedOidcModule.registerClient = (jest.fn() as any).mockResolvedValue({
|
|
140
|
-
clientId
|
|
141
|
-
clientSecret:
|
|
142
|
+
clientId,
|
|
143
|
+
clientSecret: randomUUID(),
|
|
142
144
|
});
|
|
143
145
|
|
|
144
146
|
const mockedEmptyStorage = new StorageUtility(
|
|
@@ -165,7 +167,7 @@ describe("OidcLoginHandler", () => {
|
|
|
165
167
|
});
|
|
166
168
|
|
|
167
169
|
const calledWith = actualHandler.handle.mock.calls[0][0];
|
|
168
|
-
expect(calledWith.client.clientId).toBe(
|
|
170
|
+
expect(calledWith.client.clientId).toBe(clientId);
|
|
169
171
|
});
|
|
170
172
|
|
|
171
173
|
it("should save statically registered client ID if given one as an input option", async () => {
|
|
@@ -162,10 +162,7 @@ function mockOidcClient(
|
|
|
162
162
|
.mockImplementationOnce(
|
|
163
163
|
tokenType === "dpop"
|
|
164
164
|
? mockTokenEndpointDpopResponse
|
|
165
|
-
: () =>
|
|
166
|
-
new Promise<OidcClientExt.CodeExchangeResult>((resolve) => {
|
|
167
|
-
resolve(mockTokenEndpointBearerResponse());
|
|
168
|
-
}),
|
|
165
|
+
: () => Promise.resolve(mockTokenEndpointBearerResponse()),
|
|
169
166
|
);
|
|
170
167
|
mockedOidcClient.refresh = jest
|
|
171
168
|
.fn<typeof mockedOidcClient.refresh>()
|