diff --git a/packages/commerce-sdk-react/CHANGELOG.md b/packages/commerce-sdk-react/CHANGELOG.md index 5947e7efea..36c8cdc83d 100644 --- a/packages/commerce-sdk-react/CHANGELOG.md +++ b/packages/commerce-sdk-react/CHANGELOG.md @@ -1,3 +1,6 @@ +## v3.0.1 (Sep 03, 2024) +- Fixed an issue where the `expires` attribute in cookies, ensuring it uses seconds instead of days. [#1994](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1994) + ## v3.0.0 (Aug 07, 2024) - Add `meta.displayName` to queries. It can be used to identify queries in performance metrics or logs. [#1895](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1895) - Upgrade to commerce-sdk-isomorphic v3.0.0 [#1914](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1914) diff --git a/packages/commerce-sdk-react/package-lock.json b/packages/commerce-sdk-react/package-lock.json index 1f0924d343..c715bf776e 100644 --- a/packages/commerce-sdk-react/package-lock.json +++ b/packages/commerce-sdk-react/package-lock.json @@ -1,12 +1,12 @@ { "name": "@salesforce/commerce-sdk-react", - "version": "3.0.0", + "version": "3.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@salesforce/commerce-sdk-react", - "version": "3.0.0", + "version": "3.0.1", "license": "See license in LICENSE", "dependencies": { "commerce-sdk-isomorphic": "^3.0.0", diff --git a/packages/commerce-sdk-react/package.json b/packages/commerce-sdk-react/package.json index 588262c697..6be1775473 100644 --- a/packages/commerce-sdk-react/package.json +++ b/packages/commerce-sdk-react/package.json @@ -1,6 +1,6 @@ { "name": "@salesforce/commerce-sdk-react", - "version": "3.0.0", + "version": "3.0.1", "description": "A library that provides react hooks for fetching data from Commerce Cloud", "homepage": "https://github.com/SalesforceCommerceCloud/pwa-kit/tree/develop/packages/ecom-react-hooks#readme", "bugs": { diff --git a/packages/commerce-sdk-react/src/auth/index.ts b/packages/commerce-sdk-react/src/auth/index.ts index aadb2330a9..5a1b1916a0 100644 --- a/packages/commerce-sdk-react/src/auth/index.ts +++ b/packages/commerce-sdk-react/src/auth/index.ts @@ -361,6 +361,21 @@ class Auth { store.delete(key) } + /** + * Converts a duration in seconds to a Date object. + * This function takes a number representing seconds and returns a Date object + * for the current time plus the given duration. + * + * @param {number} seconds - The number of seconds to add to the current time. + * @returns {Date} A Date object for the expiration time. + */ + private convertSecondsToDate(seconds: number): Date { + if (typeof seconds !== 'number') { + throw new Error('The refresh_token_expires_in seconds parameter must be a number.') + } + return new Date(Date.now() + seconds * 1000) + } + /** * This method stores the TokenResponse object retrived from SLAS, and * store the data in storage. @@ -377,9 +392,12 @@ class Auth { this.set('customer_type', isGuest ? 'guest' : 'registered') const refreshTokenKey = isGuest ? 'refresh_token_guest' : 'refresh_token_registered' + const expiresDate = res.refresh_token_expires_in + ? this.convertSecondsToDate(res.refresh_token_expires_in) + : undefined this.set(refreshTokenKey, res.refresh_token, { - expires: res.refresh_token_expires_in + expires: expiresDate }) } diff --git a/packages/template-retail-react-app/CHANGELOG.md b/packages/template-retail-react-app/CHANGELOG.md index 9a2dbd9ab5..459c5a1bdf 100644 --- a/packages/template-retail-react-app/CHANGELOG.md +++ b/packages/template-retail-react-app/CHANGELOG.md @@ -1,3 +1,6 @@ +## v4.0.1 (Sept 4, 2024) +- Updated @salesforce/commerce-sdk-react to 3.0.1 to fix an issue with the expires attribute of cookies, ensuring it uses seconds instead of days [#1994](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/1994) + ## v4.0.0 (Aug 7, 2024) ### New Features diff --git a/packages/template-retail-react-app/package-lock.json b/packages/template-retail-react-app/package-lock.json index 3000943264..85fac77849 100644 --- a/packages/template-retail-react-app/package-lock.json +++ b/packages/template-retail-react-app/package-lock.json @@ -1,12 +1,12 @@ { "name": "@salesforce/retail-react-app", - "version": "4.0.0", + "version": "4.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@salesforce/retail-react-app", - "version": "4.0.0", + "version": "4.0.1", "license": "See license in LICENSE", "dependencies": { "@chakra-ui/icons": "^2.0.19", diff --git a/packages/template-retail-react-app/package.json b/packages/template-retail-react-app/package.json index 626ec62d38..156afd1aba 100644 --- a/packages/template-retail-react-app/package.json +++ b/packages/template-retail-react-app/package.json @@ -1,6 +1,6 @@ { "name": "@salesforce/retail-react-app", - "version": "4.0.0", + "version": "4.0.1", "license": "See license in LICENSE", "author": "cc-pwa-kit@salesforce.com", "ccExtensibility": { @@ -45,7 +45,7 @@ "@lhci/cli": "^0.11.0", "@loadable/component": "^5.15.3", "@peculiar/webcrypto": "^1.4.2", - "@salesforce/commerce-sdk-react": "3.0.0", + "@salesforce/commerce-sdk-react": "3.0.1", "@salesforce/pwa-kit-dev": "3.7.0", "@salesforce/pwa-kit-react-sdk": "3.7.0", "@salesforce/pwa-kit-runtime": "3.7.0", diff --git a/packages/test-commerce-sdk-react/package.json b/packages/test-commerce-sdk-react/package.json index 3d878c1892..26179d757e 100644 --- a/packages/test-commerce-sdk-react/package.json +++ b/packages/test-commerce-sdk-react/package.json @@ -18,7 +18,7 @@ }, "devDependencies": { "@loadable/component": "^5.15.3", - "@salesforce/commerce-sdk-react": "3.0.0", + "@salesforce/commerce-sdk-react": "3.0.1", "@salesforce/pwa-kit-dev": "3.7.0", "@salesforce/pwa-kit-react-sdk": "3.7.0", "@salesforce/pwa-kit-runtime": "3.7.0",