diff --git a/CHANGELOG.md b/CHANGELOG.md
index 12884a2e6..3f37312af 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,12 @@
# Changelog
-## 7.19.6
+## 7.20.0
+
+- [44d15be](https://github.com/AxaFrance/oidc-client/commit/44d15be1c4d8f5069f15ddc5351e546fc5eb7730) - fix(oidc): userInfo 401 on first login (release), 2024-03-22 by *Guillaume Chervet*
+- [c7793c9](https://github.com/AxaFrance/oidc-client/commit/c7793c9913128dbb82a60dff11261ca5b4749f0c) - feat(oidc-client): add dpop extras to claims (alpha), 2024-03-19 by *Guillaume Chervet*
+
+
+## v7.19.6
- [b7568f8](https://github.com/AxaFrance/oidc-client/commit/b7568f8d73d21ba1b7cd4890bff2ad30941696e2) - fix(oidc-service-worker): normalize userinfo endpoint in service worker (#1320) (release), 2024-03-13 by *meesvandongen*
@@ -314,9 +320,3 @@
- [56bde67](https://github.com/AxaFrance/oidc-client/commit/56bde67566f8203e9d62ae6e8b722c86a7b63cae) - doc(readme): Update README.md, 2023-11-27 by *Guillaume Chervet*
-## v7.9.3
-
-- [a80844c](https://github.com/AxaFrance/oidc-client/commit/a80844c2668066b083009043f1dd94fa196e1f18) - fix(service-worker): make sure URL is normalized when comparing with token endpoint and revocation endpoint (#1198) (release), 2023-11-24 by *meesvandongen*
-- [bf19dd0](https://github.com/AxaFrance/oidc-client/commit/bf19dd0cc975ea4524b0f68f9315625b3789801b) - fix(oidc-client): tokens refresh conflict multiple tabs (alpha), 2023-11-17 by *Guillaume Chervet*
-
-
diff --git a/examples/react-oidc-demo/src/configurations.ts b/examples/react-oidc-demo/src/configurations.ts
index 195191a54..eb1a58728 100644
--- a/examples/react-oidc-demo/src/configurations.ts
+++ b/examples/react-oidc-demo/src/configurations.ts
@@ -1,4 +1,4 @@
-import { TokenRenewMode } from '@axa-fr/react-oidc';
+import { TokenRenewMode, TokenAutomaticRenewMode } from '@axa-fr/react-oidc';
export const configurationIdentityServer = {
client_id: 'interactive.public.short',
@@ -16,6 +16,7 @@ export const configurationIdentityServer = {
// monitor_session: true,
extras: { youhou_demo: 'youhou' },
token_renew_mode: TokenRenewMode.access_token_invalid,
+ token_automatic_renew_mode: TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted,
demonstrating_proof_of_possession: false,
};
diff --git a/packages/oidc-client-service-worker/package.json b/packages/oidc-client-service-worker/package.json
index 0966c6fe4..fbc42813a 100644
--- a/packages/oidc-client-service-worker/package.json
+++ b/packages/oidc-client-service-worker/package.json
@@ -1,6 +1,6 @@
{
"name": "@axa-fr/oidc-client-service-worker",
- "version": "7.19.6",
+ "version": "7.20.0",
"type": "module",
"private": false,
"main": "dist/OidcServiceWorker.js",
diff --git a/packages/oidc-client-service-worker/src/version.ts b/packages/oidc-client-service-worker/src/version.ts
index 2ac453ee3..f4679c23b 100644
--- a/packages/oidc-client-service-worker/src/version.ts
+++ b/packages/oidc-client-service-worker/src/version.ts
@@ -1 +1 @@
-export default '7.19.6';
+export default '7.20.0';
diff --git a/packages/oidc-client/README.md b/packages/oidc-client/README.md
index be012d1a7..35d18b10d 100644
--- a/packages/oidc-client/README.md
+++ b/packages/oidc-client/README.md
@@ -161,7 +161,7 @@ oidcClient.tryKeepExistingSessionAsync().then(() => {
@axa-fr/oidc-client demo
Loading
`;
- return
+ return;
}
let tokens = oidcClient.tokens;
@@ -226,6 +226,10 @@ const configuration = {
authority_timeout_wellknowurl_in_millisecond: 10000, // Timeout in milliseconds of the openid well-known URL, default is 10 seconds, then an error is thrown
monitor_session: Boolean, // Add OpenID monitor session, default is false (more information https://openid.net/specs/openid-connect-session-1_0.html), if you need to set it to true consider https://infi.nl/nieuws/spa-necromancy/
token_renew_mode: String, // Optional, update tokens based on the selected token(s) lifetime: "access_token_or_id_token_invalid" (default), "access_token_invalid", "id_token_invalid"
+ token_automatic_renew_mode: TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted, // Optional, default is TokenAutomaticRenewMode.AutomaticBeforeTokensExpiration
+ // TokenAutomaticRenewMode.AutomaticBeforeTokensExpiration: renew tokens automatically before they expire
+ // TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted: renew tokens automatically only when fetch is executed
+ // It requires you to use fetch given by oidcClient.fetchWithTokens(fetch) or to use oidcClient.getValidTokenAsync()
logout_tokens_to_invalidate: Array, // Optional tokens to invalidate during logout, default: ['access_token', 'refresh_token']
location: ILOidcLocation, // Optional, default is window.location, you can inject your own location object respecting the ILOidcLocation interface
demonstrating_proof_of_possession: Boolean, // Optional, default is false, if true, the the Demonstrating Proof of Possession will be activated //https://www.rfc-editor.org/rfc/rfc9449.html#name-protected-resource-access
diff --git a/packages/oidc-client/package.json b/packages/oidc-client/package.json
index 81dd2c76d..95398f66f 100644
--- a/packages/oidc-client/package.json
+++ b/packages/oidc-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@axa-fr/oidc-client",
- "version": "7.19.6",
+ "version": "7.20.0",
"private": false,
"type": "module",
"main": "./dist/index.umd.cjs",
diff --git a/packages/oidc-client/src/events.ts b/packages/oidc-client/src/events.ts
index 5cb31c05e..9a902a0b3 100644
--- a/packages/oidc-client/src/events.ts
+++ b/packages/oidc-client/src/events.ts
@@ -26,4 +26,5 @@ export const eventNames = {
syncTokensAsync_lock_not_available: 'syncTokensAsync_lock_not_available',
syncTokensAsync_end: 'syncTokensAsync_end',
syncTokensAsync_error: 'syncTokensAsync_error',
+ tokensInvalidAndWaitingActionsToRefresh: 'tokensInvalidAndWaitingActionsToRefresh',
};
diff --git a/packages/oidc-client/src/fetch.ts b/packages/oidc-client/src/fetch.ts
index 1cdfcd6fe..5d1fdc72a 100644
--- a/packages/oidc-client/src/fetch.ts
+++ b/packages/oidc-client/src/fetch.ts
@@ -1,8 +1,9 @@
import {Fetch} from "./types";
import {OidcClient} from "./oidcClient";
+import {getValidTokenAsync} from "./parseTokens";
// @ts-ignore
-export const fetchWithTokens = (fetch: Fetch, oidcClient: OidcClient | null) : Fetch => async (...params: Parameters) :Promise => {
+export const fetchWithTokens = (fetch: Fetch, oidcClient: Oidc | null) : Fetch => async (...params: Parameters) :Promise => {
const [url, options, ...rest] = params;
const optionTmp = options ? { ...options } : { method: 'GET' };
let headers = new Headers();
@@ -14,9 +15,8 @@ export const fetchWithTokens = (fetch: Fetch, oidcClient: OidcClient | null) : F
const oidc = oidcClient;
// @ts-ignore
- const getValidToken = await oidc.getValidTokenAsync();
+ const getValidToken = await getValidTokenAsync(oidc);
const accessToken = getValidToken?.tokens?.accessToken;
-
if (!headers.has('Accept')) {
headers.set('Accept', 'application/json');
}
diff --git a/packages/oidc-client/src/index.ts b/packages/oidc-client/src/index.ts
index 2dc2a8c9c..4ad660aff 100644
--- a/packages/oidc-client/src/index.ts
+++ b/packages/oidc-client/src/index.ts
@@ -1,3 +1,5 @@
+import {ILOidcLocation} from "./location";
+
export { getFetchDefault } from './oidc.js';
export { TokenRenewMode } from './parseTokens.js';
export { getParseQueryStringFromLocation, getPath } from './route-utils';
@@ -5,7 +7,10 @@ export type {
AuthorityConfiguration,
Fetch,
OidcConfiguration,
- StringMap,
+ StringMap
} from './types.js';
-export { type ILOidcLocation, OidcLocation } from './location.js';
+
+export { OidcLocation } from './location.js';
+export type { ILOidcLocation } from './location.js';
+export { TokenAutomaticRenewMode } from './types.js';
export { type OidcUserInfo, OidcClient } from './oidcClient.js';
diff --git a/packages/oidc-client/src/oidc.ts b/packages/oidc-client/src/oidc.ts
index b468a641f..56f4082c5 100644
--- a/packages/oidc-client/src/oidc.ts
+++ b/packages/oidc-client/src/oidc.ts
@@ -5,18 +5,16 @@ import {initSession} from './initSession.js';
import {defaultServiceWorkerUpdateRequireCallback, initWorkerAsync, sleepAsync} from './initWorker.js';
import {defaultLoginAsync, loginCallbackAsync} from './login.js';
import {destroyAsync, logoutAsync} from './logout.js';
-import {isTokensOidcValid, TokenRenewMode, Tokens,} from './parseTokens.js';
+import {TokenRenewMode, Tokens,} from './parseTokens.js';
import {
autoRenewTokens,
- renewTokensAndStartTimerAsync,
- synchroniseTokensStatus,
- syncTokensInfoAsync
+ renewTokensAndStartTimerAsync
} from './renewTokens.js';
-import {fetchFromIssuer, performTokenRequestAsync} from './requests.js';
+import {fetchFromIssuer} from './requests.js';
import {getParseQueryStringFromLocation} from './route-utils.js';
-import defaultSilentLoginAsync, {_silentLoginAsync} from './silentLogin.js';
+import defaultSilentLoginAsync from './silentLogin.js';
import timer from './timer.js';
-import {AuthorityConfiguration, Fetch, OidcConfiguration, StringMap} from './types.js';
+import {AuthorityConfiguration, Fetch, OidcConfiguration, StringMap, TokenAutomaticRenewMode} from './types.js';
import {userInfoAsync} from './user.js';
import {base64urlOfHashOfASCIIEncodingAsync} from "./crypto";
import {
@@ -112,6 +110,7 @@ export class Oidc {
this.configuration = {
...configuration,
silent_login_uri,
+ token_automatic_renew_mode: configuration.token_automatic_renew_mode ?? TokenAutomaticRenewMode.AutomaticBeforeTokenExpiration,
monitor_session: configuration.monitor_session ?? false,
refresh_time_before_tokens_expiration_in_second,
silent_login_timeout: configuration.silent_login_timeout ?? 12000,
diff --git a/packages/oidc-client/src/parseTokens.spec.ts b/packages/oidc-client/src/parseTokens.spec.ts
index 380f05d90..c58669a69 100644
--- a/packages/oidc-client/src/parseTokens.spec.ts
+++ b/packages/oidc-client/src/parseTokens.spec.ts
@@ -8,6 +8,8 @@ import {
setTokens,
TokenRenewMode
} from "./parseTokens";
+import {StringMap, TokenAutomaticRenewMode} from "./types";
+import {sleepAsync} from "./initWorker";
describe('ParseTokens test Suite', () => {
const currentTimeUnixSecond = new Date().getTime() / 1000;
@@ -26,6 +28,10 @@ describe('ParseTokens test Suite', () => {
expiresAt,
issuedAt,
},
+ configuration: { token_automatic_renew_mode: TokenAutomaticRenewMode.AutomaticBeforeTokenExpiration},
+ renewTokensAsync: async (extras: StringMap) => {
+ await sleepAsync({milliseconds:10});
+ }
};
const result = await getValidTokenAsync(oidc, 1, 1);
expect(result.isTokensValid).toEqual(expectIsValidToken);
diff --git a/packages/oidc-client/src/parseTokens.ts b/packages/oidc-client/src/parseTokens.ts
index eec9e2ba1..82d2bfeff 100644
--- a/packages/oidc-client/src/parseTokens.ts
+++ b/packages/oidc-client/src/parseTokens.ts
@@ -1,4 +1,5 @@
import {sleepAsync} from './initWorker.js';
+import {OidcConfiguration, StringMap, TokenAutomaticRenewMode} from "./types";
const b64DecodeUnicode = (str) =>
decodeURIComponent(Array.prototype.map.call(atob(str), (c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join(''));
@@ -174,6 +175,8 @@ export type ValidToken = {
export interface OidcToken{
tokens?: Tokens;
+ configuration: { token_automatic_renew_mode?: TokenAutomaticRenewMode; },
+ renewTokensAsync: (extras: StringMap) => Promise;
}
export const getValidTokenAsync = async (oidc: OidcToken, waitMs = 200, numberWait = 50): Promise => {
@@ -182,7 +185,12 @@ export const getValidTokenAsync = async (oidc: OidcToken, waitMs = 200, numberWa
return null;
}
while (!isTokensValid(oidc.tokens) && numberWaitTemp > 0) {
- await sleepAsync({milliseconds: waitMs});
+ if(oidc.configuration.token_automatic_renew_mode == TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted){
+ await oidc.renewTokensAsync({});
+ break;
+ } else {
+ await sleepAsync({milliseconds: waitMs});
+ }
numberWaitTemp = numberWaitTemp - 1;
}
const isValid = isTokensValid(oidc.tokens);
diff --git a/packages/oidc-client/src/renewTokens.ts b/packages/oidc-client/src/renewTokens.ts
index 72762c61c..980789650 100644
--- a/packages/oidc-client/src/renewTokens.ts
+++ b/packages/oidc-client/src/renewTokens.ts
@@ -3,7 +3,7 @@ import {initWorkerAsync, sleepAsync} from './initWorker.js';
import Oidc from './oidc.js';
import {computeTimeLeft, isTokensOidcValid, setTokens, Tokens} from './parseTokens.js';
import timer from './timer.js';
-import {OidcConfiguration, StringMap} from './types.js';
+import {OidcConfiguration, StringMap, TokenAutomaticRenewMode} from './types.js';
import {_silentLoginAsync} from "./silentLogin";
import {performTokenRequestAsync} from "./requests";
import {eventNames} from "./events";
@@ -86,15 +86,16 @@ export const autoRenewTokens = (oidc:Oidc, expiresAt, extras:StringMap = null) =
};
export const synchroniseTokensStatus ={
- 'SESSION_LOST': 'SESSION_LOST',
- 'NOT_CONNECTED':'NOT_CONNECTED',
- 'TOKENS_VALID':'TOKENS_VALID',
- 'TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID': 'TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID',
- 'LOGOUT_FROM_ANOTHER_TAB': 'LOGOUT_FROM_ANOTHER_TAB',
- 'REQUIRE_SYNC_TOKENS': 'REQUIRE_SYNC_TOKENS'
+ FORCE_REFRESH: 'FORCE_REFRESH',
+ SESSION_LOST: 'SESSION_LOST',
+ NOT_CONNECTED:'NOT_CONNECTED',
+ TOKENS_VALID:'TOKENS_VALID',
+ TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID: 'TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID',
+ LOGOUT_FROM_ANOTHER_TAB: 'LOGOUT_FROM_ANOTHER_TAB',
+ REQUIRE_SYNC_TOKENS: 'REQUIRE_SYNC_TOKENS'
};
-export const syncTokensInfoAsync = (oidc: Oidc) => async (configuration:OidcConfiguration, configurationName: string, currentTokens, forceRefresh = false) => {
+export const syncTokensInfoAsync = (oidc: Oidc) => async (configuration:OidcConfiguration, configurationName: string, currentTokens: Tokens, forceRefresh = false) => {
// Service Worker can be killed by the browser (when it wants,for example after 10 seconds of inactivity, so we retreieve the session if it happen)
// const configuration = this.configuration;
const nullNonce = { nonce: null };
@@ -147,8 +148,6 @@ export const syncTokensInfoAsync = (oidc: Oidc) => async (configuration:OidcConf
}
-
-
const synchroniseTokensAsync = (oidc:Oidc) => async (index = 0, forceRefresh = false, extras:StringMap = null, updateTokens) =>{
while (!navigator.onLine && document.hidden) {
@@ -210,7 +209,6 @@ const synchroniseTokensAsync = (oidc:Oidc) => async (index = 0, forceRefresh = f
if (index > 4) {
if(isDocumentHidden){
- //oidc.publishEvent(eventNames.refreshTokensAsync_error, { message: 'refresh token' });
return { tokens: oidc.tokens, status: 'GIVE_UP' };
} else{
updateTokens(null);
@@ -218,6 +216,7 @@ const synchroniseTokensAsync = (oidc:Oidc) => async (index = 0, forceRefresh = f
return { tokens: null, status: 'SESSION_LOST' };
}
}
+
try {
const { status, tokens, nonce } = await syncTokensInfoAsync(oidc)(configuration, oidc.configurationName, oidc.tokens, forceRefresh);
switch (status) {
@@ -240,9 +239,21 @@ const synchroniseTokensAsync = (oidc:Oidc) => async (index = 0, forceRefresh = f
oidc.publishEvent(eventNames.logout_from_another_tab, { status: 'session syncTokensAsync' });
return { tokens: null, status: 'LOGGED_OUT' };
case synchroniseTokensStatus.REQUIRE_SYNC_TOKENS:
+
+ if(configuration.token_automatic_renew_mode == TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted && synchroniseTokensStatus.FORCE_REFRESH !== status ){
+ oidc.publishEvent(eventNames.tokensInvalidAndWaitingActionsToRefresh, {});
+ return { tokens: oidc.tokens, status: 'GIVE_UP' };
+ }
+
oidc.publishEvent(eventNames.refreshTokensAsync_begin, { tryNumber: index });
return await localsilentLoginAsync();
default: {
+
+ if(configuration.token_automatic_renew_mode == TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted && synchroniseTokensStatus.FORCE_REFRESH !== status ){
+ oidc.publishEvent(eventNames.tokensInvalidAndWaitingActionsToRefresh, {});
+ return { tokens: oidc.tokens, status: 'GIVE_UP' };
+ }
+
oidc.publishEvent(eventNames.refreshTokensAsync_begin, { refreshToken: tokens.refreshToken, status, tryNumber: index });
if (!tokens.refreshToken) {
return await localsilentLoginAsync();
diff --git a/packages/oidc-client/src/types.ts b/packages/oidc-client/src/types.ts
index c823c772e..a816c4a31 100644
--- a/packages/oidc-client/src/types.ts
+++ b/packages/oidc-client/src/types.ts
@@ -6,6 +6,11 @@ export type ServiceWorkerUpdateRequireCallback = (registration:any, stopKeepAliv
export type ServiceWorkerRegister = (serviceWorkerRelativeUrl:string) => Promise;
export type ServiceWorkerActivate = () => boolean;
+export enum TokenAutomaticRenewMode {
+ AutomaticBeforeTokenExpiration = 'AutomaticBeforeTokensExpiration',
+ AutomaticOnlyWhenFetchExecuted = 'AutomaticOnlyWhenFetchExecuted'
+}
+
export type OidcConfiguration = {
client_id: string;
redirect_uri: string;
@@ -18,6 +23,7 @@ export type OidcConfiguration = {
authority_timeout_wellknowurl_in_millisecond?: number;
authority_configuration?: AuthorityConfiguration;
refresh_time_before_tokens_expiration_in_second?: number;
+ token_automatic_renew_mode?: TokenAutomaticRenewMode;
token_request_timeout?: number;
service_worker_relative_url?:string;
service_worker_register?:ServiceWorkerRegister;
diff --git a/packages/oidc-client/src/user.ts b/packages/oidc-client/src/user.ts
index b523bab30..c01033d95 100644
--- a/packages/oidc-client/src/user.ts
+++ b/packages/oidc-client/src/user.ts
@@ -1,42 +1,22 @@
-import { sleepAsync } from './initWorker.js';
-import { isTokensValid } from './parseTokens.js';
import Oidc from "./oidc";
+import {fetchWithTokens} from "./fetch";
export const userInfoAsync = (oidc:Oidc) => async (noCache = false) => {
if (oidc.userInfo != null && !noCache) {
return oidc.userInfo;
}
-
- // We wait the synchronisation before making a request
- while (oidc.tokens && !isTokensValid(oidc.tokens)) {
- await sleepAsync({milliseconds: 200});
- }
-
- if (!oidc.tokens) {
- return null;
- }
- const accessToken = oidc.tokens.accessToken;
- if (!accessToken) {
- return null;
- }
-
const configuration = oidc.configuration;
const oidcServerConfiguration = await oidc.initAsync(configuration.authority, configuration.authority_configuration);
const url = oidcServerConfiguration.userInfoEndpoint;
- const fetchUserInfo = async (accessToken) => {
- const res = await fetch(url, {
- headers: {
- authorization: `Bearer ${accessToken}`,
- },
- });
-
- if (res.status !== 200) {
+ const fetchUserInfo = async () => {
+ const oidcFetch = fetchWithTokens(fetch, oidc);
+ const response = await oidcFetch(url);
+ if (response.status !== 200) {
return null;
}
-
- return res.json();
+ return response.json();
};
- const userInfo = await fetchUserInfo(accessToken);
+ const userInfo = await fetchUserInfo();
oidc.userInfo = userInfo;
return userInfo;
};
diff --git a/packages/oidc-client/src/version.ts b/packages/oidc-client/src/version.ts
index 2ac453ee3..f4679c23b 100644
--- a/packages/oidc-client/src/version.ts
+++ b/packages/oidc-client/src/version.ts
@@ -1 +1 @@
-export default '7.19.6';
+export default '7.20.0';
diff --git a/packages/react-oidc/README.md b/packages/react-oidc/README.md
index 1fee9a95f..17586e3c6 100644
--- a/packages/react-oidc/README.md
+++ b/packages/react-oidc/README.md
@@ -223,6 +223,10 @@ const configuration = {
onLogoutFromAnotherTab: Function, // Optional, can be set to override the default behavior, this function is triggered when a user with the same subject is logged out from another tab when session_monitor is active
onLogoutFromSameTab: Function, // Optional, can be set to override the default behavior, this function is triggered when a user is logged out from the same tab when session_monitor is active
token_renew_mode: String, // Optional, update tokens based on the selected token(s) lifetime: "access_token_or_id_token_invalid" (default), "access_token_invalid", "id_token_invalid"
+ token_automatic_renew_mode: TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted, // Optional, default is TokenAutomaticRenewMode.AutomaticBeforeTokensExpiration
+ // TokenAutomaticRenewMode.AutomaticBeforeTokensExpiration: renew tokens automatically before they expire
+ // TokenAutomaticRenewMode.AutomaticOnlyWhenFetchExecuted: renew tokens automatically only when fetch is executed
+ // It requires you to use fetch given by hook useOidcFetch(fetch) or HOC withOidcFetch(fetch)(Component)
logout_tokens_to_invalidate: Array, // Optional tokens to invalidate during logout, default: ['access_token', 'refresh_token']
location: ILOidcLocation, // Optional, default is window.location, you can inject your own location object respecting the ILOidcLocation interface
demonstrating_proof_of_possession: Boolean, // Optional, default is false, if true, the the Demonstrating Proof of Possession will be activated //https://www.rfc-editor.org/rfc/rfc9449.html#name-protected-resource-access
diff --git a/packages/react-oidc/package.json b/packages/react-oidc/package.json
index 2282036ca..f0cef5649 100644
--- a/packages/react-oidc/package.json
+++ b/packages/react-oidc/package.json
@@ -1,6 +1,6 @@
{
"name": "@axa-fr/react-oidc",
- "version": "7.19.6",
+ "version": "7.20.0",
"private": false,
"type": "module",
"main": "./dist/index.umd.cjs",
diff --git a/packages/react-oidc/src/ReactOidc.tsx b/packages/react-oidc/src/ReactOidc.tsx
index 805e183a1..f80acbb7e 100644
--- a/packages/react-oidc/src/ReactOidc.tsx
+++ b/packages/react-oidc/src/ReactOidc.tsx
@@ -127,11 +127,12 @@ export const useOidcAccessToken = (configurationName = defaultConfigurationName)
return state;
};
-const idTokenInitialState = { idToken: null, idTokenPayload: null };
+const idTokenInitialState = { idToken: null, idTokenPayload: null};
const initIdToken = (configurationName: string) => {
const getOidc = OidcClient.get;
const oidc = getOidc(configurationName);
+
if (oidc.tokens) {
const tokens = oidc.tokens;
return { idToken: tokens.idToken, idTokenPayload: tokens.idTokenPayload };
diff --git a/packages/react-oidc/src/User.ts b/packages/react-oidc/src/User.ts
index c972f25c2..fb25ad4ea 100644
--- a/packages/react-oidc/src/User.ts
+++ b/packages/react-oidc/src/User.ts
@@ -16,8 +16,7 @@ export type OidcUser = {
export const useOidcUser = (configurationName = 'default') => {
const [oidcUser, setOidcUser] = useState>({ user: null, status: OidcUserStatus.Unauthenticated });
const [oidcUserId, setOidcUserId] = useState('');
-
-
+
useEffect(() => {
const oidc = OidcClient.get(configurationName);
let isMounted = true;
diff --git a/packages/react-oidc/src/index.ts b/packages/react-oidc/src/index.ts
index f967e4d8d..116041f13 100644
--- a/packages/react-oidc/src/index.ts
+++ b/packages/react-oidc/src/index.ts
@@ -8,5 +8,6 @@ export type {
Fetch,
OidcConfiguration,
StringMap,
+ ILOidcLocation
} from '@axa-fr/oidc-client';
-export { type OidcUserInfo, TokenRenewMode, OidcClient } from '@axa-fr/oidc-client';
+export { type OidcUserInfo, TokenRenewMode, OidcClient, TokenAutomaticRenewMode, OidcLocation } from '@axa-fr/oidc-client';