Skip to content

Commit a56693f

Browse files
authored
commerce-sdk-react v4 - Remove deprecated properties + fix private client proxy endpoint prop name (#3177)
* Clean up useDNT deprecations * Breaking: remove /mobify path constants from commerce-sdk-react * Fix private client prop name * Update changelogs * Update CHANGELOG.md * update more places that called updateDNT
1 parent b69fb2f commit a56693f

File tree

18 files changed

+30
-86
lines changed

18 files changed

+30
-86
lines changed

packages/commerce-sdk-react/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## v3.5.0-dev (Jul 22, 2025)
22
- Add support for environment level base paths on /mobify routes [#2892](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2892)
33
- Update USID expiry to match SLAS refresh token expiry[#2854](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2854)
4-
54
- [Bugfix] Skip deleting dwsid on shopper login if hybrid auth is enabled for current site. [#3151](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3151)
5+
- Remove deprecated properties in commerce-sdk-react [#3177](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3177)
66

77
## v3.4.0 (Jul 22, 2025)
88

packages/commerce-sdk-react/src/auth/index.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import {
2525
extractCustomParameters
2626
} from '../utils'
2727
import {
28-
MOBIFY_PATH,
29-
SLAS_PRIVATE_PROXY_PATH,
3028
SLAS_SECRET_WARNING_MSG,
3129
SLAS_SECRET_PLACEHOLDER,
3230
SLAS_SECRET_OVERRIDE_MSG,
@@ -250,16 +248,9 @@ class Auth {
250248
constructor(config: AuthConfig) {
251249
// Special proxy endpoint for injecting SLAS private client secret.
252250
// We prioritize config.privateClientProxyEndpoint since that allows us to use the new envBasePath feature
253-
// The preexisting hard coded privateClientEndpoint is kept here for now to prevent a breaking change.
254-
// TODO: We should remove this in the next major release so we do not have a hard coded proxy path inside commerce-sdk-react
255-
const baseUrl = config.proxy.split(MOBIFY_PATH)[0]
256-
const privateClientEndpoint = `${baseUrl}${SLAS_PRIVATE_PROXY_PATH}`
257-
258251
this.client = new ShopperLogin({
259252
proxy: config.enablePWAKitPrivateClient
260253
? config.privateClientProxyEndpoint
261-
? config.privateClientProxyEndpoint
262-
: privateClientEndpoint
263254
: config.proxy,
264255
parameters: {
265256
clientId: config.clientId,
@@ -345,13 +336,7 @@ class Auth {
345336
this.isPrivate = !!this.clientSecret
346337

347338
const passwordlessLoginCallbackURI = config.passwordlessLoginCallbackURI
348-
this.passwordlessLoginCallbackURI = passwordlessLoginCallbackURI
349-
? isAbsoluteUrl(passwordlessLoginCallbackURI)
350-
? passwordlessLoginCallbackURI
351-
: // This fallback does not take into account the envBasePath feature
352-
// To set an env base path, config.passwordlessLoginCallbackURI must be an absolute url
353-
`${baseUrl}${passwordlessLoginCallbackURI}`
354-
: ''
339+
this.passwordlessLoginCallbackURI = passwordlessLoginCallbackURI || ''
355340

356341
this.hybridAuthEnabled = config.hybridAuthEnabled || false
357342
}

packages/commerce-sdk-react/src/components/StorefrontPreview/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
import {ApiClients} from '../../hooks/types'
99
import {DEVELOPMENT_ORIGIN, getParentOrigin, isOriginTrusted} from '../../utils'
10-
import {LOCAL_BUNDLE_PATH} from '../../constant'
10+
11+
const LOCAL_BUNDLE_PATH = `/mobify/bundle/development`
1112

1213
/** Detects whether the storefront is running in an iframe as part of Storefront Preview.
1314
* @private

packages/commerce-sdk-react/src/constant.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,6 @@ export const IFRAME_HOST_ALLOW_LIST = Object.freeze([
1414
'https://runtime-admin-preview.mobify-storefront.com'
1515
])
1616

17-
/* Deprecating the following path constants since, outside of storefront preview,
18-
* the paths they are used for can be passed in via the provider. */
19-
/**
20-
* @deprecated
21-
*/
22-
export const MOBIFY_PATH = '/mobify'
23-
/**
24-
* @deprecated
25-
*/
26-
export const PROXY_PATH = `${MOBIFY_PATH}/proxy`
27-
/**
28-
* @deprecated
29-
*/
30-
export const LOCAL_BUNDLE_PATH = `${MOBIFY_PATH}/bundle/development`
31-
/**
32-
* @deprecated
33-
*/
34-
export const SLAS_PRIVATE_PROXY_PATH = `${MOBIFY_PATH}/slas/private`
35-
3617
export const SLAS_SECRET_WARNING_MSG =
3718
'You are potentially exposing SLAS secret on browser. Make sure to keep it safe and secure!'
3819

packages/commerce-sdk-react/src/hooks/useDNT.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ describe('useDNT tests', () => {
3737
})
3838
})
3939

40-
it('updateDNT should create dw_dnt cookie', async () => {
41-
const {updateDNT} = useDNT()
42-
await updateDNT(true)
40+
it('updateDnt should create dw_dnt cookie', async () => {
41+
const {updateDnt} = useDNT()
42+
await updateDnt(true)
4343
expect(mockSetDnt).toHaveBeenCalledWith(true)
4444
})
4545

packages/commerce-sdk-react/src/hooks/useDNT.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import useAuthContext from './useAuthContext'
88

99
interface useDntReturn {
1010
selectedDnt: boolean | undefined
11-
dntStatus: boolean | undefined
1211
effectiveDnt: boolean | undefined
13-
updateDNT: (preference: boolean | null) => Promise<void>
1412
updateDnt: (preference: boolean | null) => Promise<void>
1513
}
1614

@@ -26,8 +24,6 @@ interface useDntReturn {
2624
* If defaultDnt is undefined as well, then SDK default is used.
2725
* @property {function} updateDnt - takes a DNT choice and creates the dw_dnt
2826
* cookie and reauthorizes with SLAS
29-
* @property {function} updateDNT - @deprecated Deprecated since version 3.1.0. Use updateDnt instead.
30-
* @property {boolean} dntStatus - @deprecated Deprecated since version 3.1.0. Use selectedDnt instead.
3127
*
3228
*
3329
*/
@@ -40,14 +36,10 @@ const useDNT = (): useDntReturn => {
4036
const updateDnt = async (preference: boolean | null) => {
4137
await auth.setDnt(preference)
4238
}
43-
const updateDNT = updateDnt
44-
const dntStatus = selectedDnt
4539

4640
return {
4741
selectedDnt,
4842
effectiveDnt,
49-
dntStatus,
50-
updateDNT,
5143
updateDnt
5244
}
5345
}

packages/commerce-sdk-react/src/provider.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ describe('provider', () => {
6565
)
6666
}
6767
const config = {
68-
enablePWAKitPrivateClient: true
68+
enablePWAKitPrivateClient: true,
69+
privateClientProxyEndpoint: 'http://localhost:3000/mobify/slas/private'
6970
}
7071
renderWithProviders(<Component />, config)
7172
const element = screen.getByTestId('proxy-value')

packages/commerce-sdk-react/src/provider.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ import React, {ReactElement, useEffect, useMemo} from 'react'
88
import Auth from './auth'
99
import {ApiClientConfigParams, ApiClients, SDKClientTransformer} from './hooks/types'
1010
import {Logger} from './types'
11-
import {
12-
DWSID_COOKIE_NAME,
13-
MOBIFY_PATH,
14-
SERVER_AFFINITY_HEADER_KEY,
15-
SLAS_PRIVATE_PROXY_PATH
16-
} from './constant'
11+
import {DWSID_COOKIE_NAME, SERVER_AFFINITY_HEADER_KEY} from './constant'
1712
import {
1813
ShopperBaskets,
1914
ShopperContexts,
@@ -257,14 +252,6 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => {
257252
fetchOptions
258253
}
259254

260-
// Special proxy endpoint for injecting SLAS private client secret.
261-
// This is only used by the ShopperLogin API as that is the only one that interacts with SLAS.
262-
// We prioritize config.privateClientProxyEndpoint since that allows us to use the new envBasePath feature
263-
// The preexisting hard coded privateClientEndpoint is kept here for now to prevent a breaking change.
264-
// TODO: We should remove this in the next major release so we do not have a hard coded proxy path inside commerce-sdk-react
265-
const baseUrl = config.proxy.split(MOBIFY_PATH)[0]
266-
const privateClientEndpoint = `${baseUrl}${SLAS_PRIVATE_PROXY_PATH}`
267-
268255
return {
269256
shopperBaskets: new ShopperBaskets(config),
270257
shopperContexts: new ShopperContexts(config),
@@ -273,11 +260,7 @@ const CommerceApiProvider = (props: CommerceApiProviderProps): ReactElement => {
273260
shopperGiftCertificates: new ShopperGiftCertificates(config),
274261
shopperLogin: new ShopperLogin({
275262
...config,
276-
proxy: enablePWAKitPrivateClient
277-
? privateClientProxyEndpoint
278-
? privateClientProxyEndpoint
279-
: privateClientEndpoint
280-
: config.proxy
263+
proxy: enablePWAKitPrivateClient ? privateClientProxyEndpoint : config.proxy
281264
}),
282265
shopperOrders: new ShopperOrders(config),
283266
shopperProducts: new ShopperProducts(config),

packages/commerce-sdk-react/src/test-utils.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ import {
1616
import nock from 'nock'
1717
import CommerceApiProvider, {CommerceApiProviderProps} from './provider'
1818
import userEvent from '@testing-library/user-event'
19-
import {PROXY_PATH} from './constant'
2019

2120
// Note: this host does NOT exist
2221
// it is intentional b/c we can catch those unintercepted requests
2322
// from log easily. You should always make sure all requests are nocked.
2423
export const DEFAULT_TEST_HOST = 'http://localhost:8888'
2524

2625
export const DEFAULT_TEST_CONFIG = {
27-
proxy: `${DEFAULT_TEST_HOST}${PROXY_PATH}/api`,
26+
proxy: `${DEFAULT_TEST_HOST}/mobify/proxy/api`,
2827
redirectURI: `${DEFAULT_TEST_HOST}/callback`,
2928
clientId: '12345678-1234-1234-1234-123412341234',
3029
organizationId: 'f_ecom_zzrmy_orgf_001',

packages/pwa-kit-create-app/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## v3.12.0-dev (Jul 22, 2025)
22
- This feature introduces an AI-powered shopping assistant that integrates Salesforce Embedded Messaging Service with PWA Kit applications. The shopper agent provides real-time chat support, search assistance, and personalized shopping guidance directly within the e-commerce experience. [#2658](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2658)
33
- Add support for environment level base paths on /mobify routes [#2892](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2892)
4+
- Fix private client endpoint prop name in app config templates [#3177](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3177)
45
- Add `--initGit` to automate git repo creation for the generated project [#2817](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2817)
56

67

0 commit comments

Comments
 (0)