diff --git a/CHANGELOG.md b/CHANGELOG.md index a4450bf79..346a8668e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog -## 7.22.6 +## 7.22.7 + +- [9f4cbf4](https://github.com/AxaFrance/oidc-client/commit/9f4cbf414e1b41f448b2a36d759a035786d26668) - fix(oidc): 2 readmes with the same name (release) (#1377), 2024-06-07 by *meesvandongen* +- [0bfabd4](https://github.com/AxaFrance/oidc-client/commit/0bfabd41d67cad57415905b7ce729ee4fe85c8b4) - fix(oidc): session lost to quickly (alpha) (#1381), 2024-06-07 by *Guillaume Chervet* + + +## v7.22.6 - [bcba15b](https://github.com/AxaFrance/oidc-client/commit/bcba15b412063d139c0902de117b0516150c13a2) - fix(react-oidc): compatibility with react 19 (release) (#1372), 2024-05-22 by *Guillaume Chervet* - [c49a857](https://github.com/AxaFrance/oidc-client/commit/c49a8572702c485c9a089b0f9aa11eb4bc6e7f1d) - refactor(test): add missing logout test case, 2024-05-22 by *Guillaume Chervet* @@ -313,8 +319,3 @@ - [f8be6ab](https://github.com/AxaFrance/oidc-client/commit/f8be6ab1096143c1a2eb35408669aef6df72d2d9) - doc(redame): fix service worker command to work with oidc-client standalone (#1200), 2023-11-29 by *Felix Roos* -## v7.12.8 - -- [53fd1f1](https://github.com/AxaFrance/oidc-client/commit/53fd1f1c093430f7e60eb43bc4a9a4fccebefe73) - build(npm): bump jsdom from 22.1.0 to 23.0.0 (#1220), 2023-11-29 by *dependabot[bot]* - - diff --git a/packages/oidc-client-service-worker/package.json b/packages/oidc-client-service-worker/package.json index 99fd66e4d..9c82d11bd 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.6", + "version": "7.22.7", "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 f217ff774..fbdee0f56 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.6'; +export default '7.22.7'; diff --git a/packages/oidc-client/package.json b/packages/oidc-client/package.json index 845cdf319..937dbf858 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.6", + "version": "7.22.7", "private": false, "type": "module", "main": "./dist/index.umd.cjs", diff --git a/packages/oidc-client/src/timer.ts b/packages/oidc-client/src/timer.ts index cd088f52b..1e540e40a 100644 --- a/packages/oidc-client/src/timer.ts +++ b/packages/oidc-client/src/timer.ts @@ -1,163 +1,14 @@ const timer = (function () { - const workerPort = (function () { - let worker; - let blobURL; - - const workerCode = function () { - const innerIdsByOuterIds = {}; - - const methods = { - setTimeout: function (port, id, timeout) { - innerIdsByOuterIds[id] = setTimeout(function () { - port.postMessage(id); - innerIdsByOuterIds[id] = null; - }, timeout); - }, - - setInterval: function (port, id, timeout) { - innerIdsByOuterIds[id] = setInterval(function () { - port.postMessage(id); - }, timeout); - }, - - clearTimeout: function (port, id) { - clearTimeout(innerIdsByOuterIds[id]); - innerIdsByOuterIds[id] = null; - }, - - clearInterval: function (port, id) { - clearInterval(innerIdsByOuterIds[id]); - innerIdsByOuterIds[id] = null; - }, - }; - - function onMessage(port, event) { - const method = event.data[0]; - const id = event.data[1]; - const option = event.data[2]; - - if (methods[method]) { - methods[method](port, id, option); - } - } - - // For Dedicated Worker - this.onmessage = function (event) { - onMessage(self, event); - }; - - // For Shared Worker - this.onconnect = function (event) { - const port = event.ports[0]; - - port.onmessage = function (event) { - onMessage(port, event); - }; - }; - }.toString(); - - try { - const blob = new Blob(['(', workerCode, ')()'], { type: 'application/javascript' }); - blobURL = URL.createObjectURL(blob); - } catch (error) { - return null; - } - const isInsideBrowser = (typeof process === 'undefined'); - try { - if (SharedWorker) { - worker = new SharedWorker(blobURL); - return worker.port; - } - } catch (error) { - if (isInsideBrowser) { - console.warn('SharedWorker not available'); - } - } - try { - if (Worker) { - worker = new Worker(blobURL); - return worker; - } - } catch (error) { - if (isInsideBrowser) { - console.warn('Worker not available'); - } - } - - return null; - }()); - - if (!workerPort) { - // In NextJS with SSR (Server Side Rendering) during rending in Node JS, the window object is undefined, - // the global object is used instead as it is the closest approximation of a browsers window object. - const bindContext = (typeof window === 'undefined') ? global : window; - - return { - setTimeout: setTimeout.bind(bindContext), - clearTimeout: clearTimeout.bind(bindContext), - setInterval: setInterval.bind(bindContext), - clearInterval: clearInterval.bind(bindContext), - }; - } - - const getId = (function () { - let currentId = 0; - - return function () { - currentId++; - return currentId; - }; - }()); - - const timeoutCallbacksById = {}; - const intervalCallbacksById = {}; - - workerPort.onmessage = function (event) { - const id = event.data; - - const timeoutCallback = timeoutCallbacksById[id]; - if (timeoutCallback) { - timeoutCallback(); - timeoutCallbacksById[id] = null; - return; - } - - const intervalCallback = intervalCallbacksById[id]; - if (intervalCallback) { - intervalCallback(); - } - }; - - function setTimeoutWorker(callback, timeout) { - const id = getId(); - workerPort.postMessage(['setTimeout', id, timeout]); - timeoutCallbacksById[id] = callback; - return id; - } - - function clearTimeoutWorker(id) { - workerPort.postMessage(['clearTimeout', id]); - timeoutCallbacksById[id] = null; - } - - function setIntervalWorker(callback, timeout) { - const id = getId(); - workerPort.postMessage(['setInterval', id, timeout]); - intervalCallbacksById[id] = callback; - return id; - } - - function clearIntervalWorker(id) { - workerPort.postMessage(['clearInterval', id]); - intervalCallbacksById[id] = null; - } - + // In NextJS with SSR (Server Side Rendering) during rending in Node JS, the window object is undefined, + // the global object is used instead as it is the closest approximation of a browsers window object. + const bindContext = (typeof window === 'undefined') ? global : window; return { - setTimeout: setTimeoutWorker, - clearTimeout: clearTimeoutWorker, - setInterval: setIntervalWorker, - clearInterval: clearIntervalWorker, + setTimeout: setTimeout.bind(bindContext), + clearTimeout: clearTimeout.bind(bindContext), + setInterval: setInterval.bind(bindContext), + clearInterval: clearInterval.bind(bindContext), }; + }()); export default timer; diff --git a/packages/oidc-client/src/version.ts b/packages/oidc-client/src/version.ts index f217ff774..fbdee0f56 100644 --- a/packages/oidc-client/src/version.ts +++ b/packages/oidc-client/src/version.ts @@ -1 +1 @@ -export default '7.22.6'; +export default '7.22.7'; diff --git a/packages/react-oidc/package.json b/packages/react-oidc/package.json index 963a95428..599cf218e 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.6", + "version": "7.22.7", "private": false, "type": "module", "main": "./dist/index.umd.cjs",