@inrupt/solid-client-authn-browser 1.17.1 → 1.17.2
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/constant.d.ts +2 -2
- package/dist/index.js +50 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -28
- package/dist/index.mjs.map +1 -1
- package/dist/solid-client-authn.bundle.js +7 -7
- package/dist/solid-client-authn.bundle.js.map +1 -1
- package/package.json +6 -6
- package/rollup.config.mjs +1 -1
- package/src/ClientAuthentication.spec.ts +66 -38
- package/src/ClientAuthentication.ts +4 -4
- package/src/Session.spec.ts +44 -44
- package/src/Session.ts +24 -18
- package/src/__mocks__/ClientAuthentication.ts +2 -2
- package/src/defaultSession.ts +4 -3
- package/src/dependencies.ts +5 -5
- package/src/login/oidc/ClientRegistrar.spec.ts +22 -22
- package/src/login/oidc/ClientRegistrar.ts +4 -2
- package/src/login/oidc/IssuerConfigFetcher.spec.ts +25 -25
- package/src/login/oidc/IssuerConfigFetcher.ts +8 -6
- package/src/login/oidc/OidcLoginHandler.spec.ts +15 -15
- package/src/login/oidc/OidcLoginHandler.ts +14 -9
- package/src/login/oidc/Redirector.spec.ts +1 -1
- package/src/login/oidc/__mocks__/ClientRegistrar.ts +3 -3
- package/src/login/oidc/__mocks__/IssuerConfigFetcher.ts +3 -3
- package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.spec.ts +42 -42
- package/src/login/oidc/incomingRedirectHandler/AuthCodeRedirectHandler.ts +19 -13
- package/src/login/oidc/incomingRedirectHandler/ErrorOidcHandler.spec.ts +12 -12
- package/src/login/oidc/incomingRedirectHandler/ErrorOidcHandler.ts +2 -2
- package/src/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.spec.ts +7 -7
- package/src/login/oidc/incomingRedirectHandler/FallbackRedirectHandler.ts +2 -2
- package/src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.spec.ts +17 -17
- package/src/login/oidc/refresh/TokenRefresher.spec.ts +14 -14
- package/src/login/oidc/refresh/TokenRefresher.ts +12 -8
- package/src/login/oidc/refresh/__mocks__/TokenRefresher.ts +1 -1
- package/src/sessionInfo/SessionInfoManager.spec.ts +37 -15
- package/src/sessionInfo/SessionInfoManager.ts +46 -50
- package/src/sessionInfo/__mocks__/SessionInfoManager.ts +3 -3
package/dist/constant.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const KEY_CURRENT_SESSION:
|
|
2
|
-
export declare const KEY_CURRENT_URL:
|
|
1
|
+
export declare const KEY_CURRENT_SESSION = "solidClientAuthn:currentSession";
|
|
2
|
+
export declare const KEY_CURRENT_URL = "solidClientAuthn:currentUrl";
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ class ClientAuthentication extends solidClientAuthnCore.ClientAuthentication {
|
|
|
20
20
|
await this.sessionInfoManager.clear(options.sessionId);
|
|
21
21
|
const redirectUrl = (_a = options.redirectUrl) !== null && _a !== void 0 ? _a : oidcClientExt.removeOidcQueryParam(window.location.href);
|
|
22
22
|
if (!solidClientAuthnCore.isValidRedirectUrl(redirectUrl)) {
|
|
23
|
-
throw new Error(`${redirectUrl} is not a valid redirect URL, it is either a malformed IRI
|
|
23
|
+
throw new Error(`${redirectUrl} is not a valid redirect URL, it is either a malformed IRI, includes a hash fragment, or reserved query parameters ('code' or 'state').`);
|
|
24
24
|
}
|
|
25
25
|
await this.loginHandler.handle({
|
|
26
26
|
...options,
|
|
@@ -83,6 +83,10 @@ class OidcLoginHandler {
|
|
|
83
83
|
this.oidcHandler = oidcHandler;
|
|
84
84
|
this.issuerConfigFetcher = issuerConfigFetcher;
|
|
85
85
|
this.clientRegistrar = clientRegistrar;
|
|
86
|
+
this.storageUtility = storageUtility;
|
|
87
|
+
this.oidcHandler = oidcHandler;
|
|
88
|
+
this.issuerConfigFetcher = issuerConfigFetcher;
|
|
89
|
+
this.clientRegistrar = clientRegistrar;
|
|
86
90
|
}
|
|
87
91
|
async canHandle(options) {
|
|
88
92
|
return hasIssuer(options) && hasRedirectUrl(options);
|
|
@@ -243,6 +247,7 @@ function processConfig(config) {
|
|
|
243
247
|
class IssuerConfigFetcher {
|
|
244
248
|
constructor(storageUtility) {
|
|
245
249
|
this.storageUtility = storageUtility;
|
|
250
|
+
this.storageUtility = storageUtility;
|
|
246
251
|
}
|
|
247
252
|
static getLocalStorageKey(issuer) {
|
|
248
253
|
return `issuerConfig:${issuer}`;
|
|
@@ -268,32 +273,40 @@ async function clear(sessionId, storage) {
|
|
|
268
273
|
}
|
|
269
274
|
class SessionInfoManager extends solidClientAuthnCore.SessionInfoManagerBase {
|
|
270
275
|
async get(sessionId) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
276
|
+
const [isLoggedIn, webId, clientId, clientSecret, redirectUrl, refreshToken, issuer, tokenType,] = await Promise.all([
|
|
277
|
+
this.storageUtility.getForUser(sessionId, "isLoggedIn", {
|
|
278
|
+
secure: true,
|
|
279
|
+
}),
|
|
280
|
+
this.storageUtility.getForUser(sessionId, "webId", {
|
|
281
|
+
secure: true,
|
|
282
|
+
}),
|
|
283
|
+
this.storageUtility.getForUser(sessionId, "clientId", {
|
|
284
|
+
secure: false,
|
|
285
|
+
}),
|
|
286
|
+
this.storageUtility.getForUser(sessionId, "clientSecret", {
|
|
287
|
+
secure: false,
|
|
288
|
+
}),
|
|
289
|
+
this.storageUtility.getForUser(sessionId, "redirectUrl", {
|
|
290
|
+
secure: false,
|
|
291
|
+
}),
|
|
292
|
+
this.storageUtility.getForUser(sessionId, "refreshToken", {
|
|
293
|
+
secure: true,
|
|
294
|
+
}),
|
|
295
|
+
this.storageUtility.getForUser(sessionId, "issuer", {
|
|
296
|
+
secure: false,
|
|
297
|
+
}),
|
|
298
|
+
this.storageUtility.getForUser(sessionId, "tokenType", {
|
|
299
|
+
secure: false,
|
|
300
|
+
}),
|
|
301
|
+
]);
|
|
302
|
+
if (typeof redirectUrl === "string" && !solidClientAuthnCore.isValidRedirectUrl(redirectUrl)) {
|
|
303
|
+
await Promise.all([
|
|
304
|
+
this.storageUtility.deleteAllUserData(sessionId, { secure: false }),
|
|
305
|
+
this.storageUtility.deleteAllUserData(sessionId, { secure: true }),
|
|
306
|
+
]);
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
if (tokenType !== undefined && !solidClientAuthnCore.isSupportedTokenType(tokenType)) {
|
|
297
310
|
throw new Error(`Tokens of type [${tokenType}] are not supported.`);
|
|
298
311
|
}
|
|
299
312
|
if (clientId === undefined &&
|
|
@@ -311,7 +324,7 @@ class SessionInfoManager extends solidClientAuthnCore.SessionInfoManagerBase {
|
|
|
311
324
|
issuer,
|
|
312
325
|
clientAppId: clientId,
|
|
313
326
|
clientAppSecret: clientSecret,
|
|
314
|
-
tokenType,
|
|
327
|
+
tokenType: tokenType !== null && tokenType !== void 0 ? tokenType : "DPoP",
|
|
315
328
|
};
|
|
316
329
|
}
|
|
317
330
|
async clear(sessionId) {
|
|
@@ -342,6 +355,11 @@ class AuthCodeRedirectHandler {
|
|
|
342
355
|
this.issuerConfigFetcher = issuerConfigFetcher;
|
|
343
356
|
this.clientRegistrar = clientRegistrar;
|
|
344
357
|
this.tokerRefresher = tokerRefresher;
|
|
358
|
+
this.storageUtility = storageUtility;
|
|
359
|
+
this.sessionInfoManager = sessionInfoManager;
|
|
360
|
+
this.issuerConfigFetcher = issuerConfigFetcher;
|
|
361
|
+
this.clientRegistrar = clientRegistrar;
|
|
362
|
+
this.tokerRefresher = tokerRefresher;
|
|
345
363
|
}
|
|
346
364
|
async canHandle(redirectUrl) {
|
|
347
365
|
try {
|
|
@@ -461,6 +479,7 @@ class Redirector {
|
|
|
461
479
|
class ClientRegistrar {
|
|
462
480
|
constructor(storageUtility) {
|
|
463
481
|
this.storageUtility = storageUtility;
|
|
482
|
+
this.storageUtility = storageUtility;
|
|
464
483
|
}
|
|
465
484
|
async getClient(options, issuerConfig) {
|
|
466
485
|
const [storedClientId, storedClientSecret,] = await Promise.all([
|
|
@@ -526,6 +545,9 @@ class TokenRefresher {
|
|
|
526
545
|
this.storageUtility = storageUtility;
|
|
527
546
|
this.issuerConfigFetcher = issuerConfigFetcher;
|
|
528
547
|
this.clientRegistrar = clientRegistrar;
|
|
548
|
+
this.storageUtility = storageUtility;
|
|
549
|
+
this.issuerConfigFetcher = issuerConfigFetcher;
|
|
550
|
+
this.clientRegistrar = clientRegistrar;
|
|
529
551
|
}
|
|
530
552
|
async refresh(sessionId, refreshToken, dpopKey, eventEmitter) {
|
|
531
553
|
const oidcContext = await solidClientAuthnCore.loadOidcContextFromStorage(sessionId, this.storageUtility, this.issuerConfigFetcher);
|