diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 85dcd2fe6..09a8bd259 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -268,19 +268,19 @@ jobs: git commit -m "[skip ci] Generate changelog to version ${{ steps.tag.outputs.new_version }}" git push --set-upstream origin "HEAD:main" --follow-tags -f - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@master - if: github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.head.repo.fork - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - with: - args: > - -Dsonar.organization=axaguildev - -Dsonar.projectKey=AxaGuilDEv_react-oidc - -Dsonar.exclusions=**/*.spec.js,**/*.stories.js,Scripts/**,**/*.scss,**/__snapshots__/**,**/*[Tt]ests.cs,**/node_modules/**,**/ClientApp/build/**,**/ClientApp/.storybook/**,**/ClientApp/storybook-static/**,**/obj/**,**/__mocks__/**,**/ClientApp/src/serviceWorker.ts - -Dsonar.javascript.lcov.reportPaths=**/coverage/lcov.info - + # - name: SonarCloud Scan + # uses: sonarsource/sonarcloud-github-action@master + # if: github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.head.repo.fork + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # with: + # args: > + # -Dsonar.organization=axaguildev + # -Dsonar.projectKey=AxaGuilDEv_react-oidc + # -Dsonar.exclusions=**/*.spec.js,**/*.stories.js,Scripts/**,**/*.scss,**/__snapshots__/**,**/*[Tt]ests.cs,**/node_modules/**,**/ClientApp/build/**,**/ClientApp/.storybook/**,**/ClientApp/storybook-static/**,**/obj/**,**/__mocks__/**,**/ClientApp/src/serviceWorker.ts + # -Dsonar.javascript.lcov.reportPaths=**/coverage/lcov.info + # - name: Create a GitHub release uses: ncipollo/release-action@v1 if: github.ref == 'refs/heads/main' && steps.which_tag.outputs.tag == 'release' diff --git a/CHANGELOG.md b/CHANGELOG.md index 9309f979f..edc28b3d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## 7.22.24 +## 7.22.25 + +- [3a0d48e](https://github.com/AxaFrance/oidc-client/commit/3a0d48ea0d3609d31de0f45d6aebfb1a23b25e73) - fix(oidc): number timer increase (#1457) (release), 2024-09-26 by _Guillaume Chervet_ + +## v7.22.24 - [b34eabf](https://github.com/AxaFrance/oidc-client/commit/b34eabf39ce108f8de93a49f1a4d9ec6e46d642c) - refactor(all): update dependencies (#1446) (release), 2024-09-02 by _Guillaume Chervet_ - [35081e1](https://github.com/AxaFrance/oidc-client/commit/35081e16b947ebd490b83a1f6d6b9dc101363736) - Merge branch 'main' of https://github.com/AxaFrance/oidc-client into HEAD, 2024-08-25 by _Guillaume Chervet_ @@ -270,8 +274,3 @@ ## v7.13.14 - [3a1883c](https://github.com/AxaFrance/oidc-client/commit/3a1883c343c55637aa1ce5d118cc2841c76d8752) - build(npm): bump react-router-dom from 6.20.1 to 6.21.1 (#1252), 2024-01-02 by _dependabot[bot]_ - -## v7.13.13 - -- [1faaab4](https://github.com/AxaFrance/oidc-client/commit/1faaab4ecb86144ed6f3c1ed68b938804854bd36) - build(npm): bump next from 14.0.3 to 14.0.4 (#1255), 2024-01-02 by _dependabot[bot]_ -- [d009de8](https://github.com/AxaFrance/oidc-client/commit/d009de8091ac256d1384466df9b3fe7de75a5629) - chore(ci): Update npm-publish.yml, 2023-12-28 by _Guillaume Chervet_ diff --git a/packages/oidc-client-service-worker/package.json b/packages/oidc-client-service-worker/package.json index 6c3860203..229daa012 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.22.24", + "version": "7.22.25", "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 168242672..151a0fac4 100644 --- a/packages/oidc-client-service-worker/src/version.ts +++ b/packages/oidc-client-service-worker/src/version.ts @@ -1 +1 @@ -export default '7.22.24'; +export default '7.22.25'; diff --git a/packages/oidc-client/package.json b/packages/oidc-client/package.json index 10d015692..431e82dcc 100644 --- a/packages/oidc-client/package.json +++ b/packages/oidc-client/package.json @@ -1,6 +1,6 @@ { "name": "@axa-fr/oidc-client", - "version": "7.22.24", + "version": "7.22.25", "private": false, "type": "module", "main": "./dist/index.umd.cjs", diff --git a/packages/oidc-client/src/renewTokens.ts b/packages/oidc-client/src/renewTokens.ts index 254abbb6f..d6de921d0 100644 --- a/packages/oidc-client/src/renewTokens.ts +++ b/packages/oidc-client/src/renewTokens.ts @@ -32,31 +32,6 @@ async function syncTokens(oidc: Oidc, forceRefresh: boolean, extras: StringMap) return tokens; } -const loadLatestTokensAsync = async ( - oidc: Oidc, - configuration: OidcConfiguration, -): Promise => { - const serviceWorker = await initWorkerAsync(configuration, oidc.configurationName); - if (serviceWorker) { - const oidcServerConfiguration = await oidc.initAsync( - configuration.authority, - configuration.authority_configuration, - ); - const { tokens } = await serviceWorker.initAsync( - oidcServerConfiguration, - 'tryKeepExistingSessionAsync', - configuration, - ); - return tokens; - } else { - const session = initSession(oidc.configurationName, configuration.storage ?? sessionStorage); - let { tokens } = await session.initAsync(); - // @ts-ignore - tokens = setTokens(tokens, oidc.tokens, configuration.token_renew_mode); - return tokens; - } -}; - export async function renewTokensAndStartTimerAsync( oidc, forceRefresh = false, @@ -71,15 +46,23 @@ export async function renewTokensAndStartTimerAsync( if (configuration?.storage === window?.sessionStorage && !serviceWorker) { tokens = await syncTokens(oidc, forceRefresh, extras); } else { - tokens = await navigator.locks.request(lockResourcesName, { ifAvailable: true }, async lock => { - if (!lock) { - oidc.publishEvent(Oidc.eventNames.syncTokensAsync_lock_not_available, { - lock: 'lock not available', - }); - return await loadLatestTokensAsync(oidc, configuration); - } - return await syncTokens(oidc, forceRefresh, extras); - }); + let status: any = 'retry'; + while (status === 'retry') { + status = await navigator.locks.request( + lockResourcesName, + { ifAvailable: true }, + async lock => { + if (!lock) { + oidc.publishEvent(Oidc.eventNames.syncTokensAsync_lock_not_available, { + lock: 'lock not available', + }); + return 'retry'; + } + return await syncTokens(oidc, forceRefresh, extras); + }, + ); + } + tokens = status; } if (!tokens) { diff --git a/packages/oidc-client/src/version.ts b/packages/oidc-client/src/version.ts index 168242672..151a0fac4 100644 --- a/packages/oidc-client/src/version.ts +++ b/packages/oidc-client/src/version.ts @@ -1 +1 @@ -export default '7.22.24'; +export default '7.22.25'; diff --git a/packages/react-oidc/package.json b/packages/react-oidc/package.json index 50b8cbe25..95e939a91 100644 --- a/packages/react-oidc/package.json +++ b/packages/react-oidc/package.json @@ -1,6 +1,6 @@ { "name": "@axa-fr/react-oidc", - "version": "7.22.24", + "version": "7.22.25", "private": false, "type": "module", "main": "./dist/index.umd.cjs",