@salesforce/commerce-sdk-react 3.5.0-preview.1 → 4.0.0-nightly-20250826080215
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +21 -3
- package/auth/index.d.ts +126 -57
- package/auth/index.js +160 -107
- package/components/StorefrontPreview/utils.js +3 -2
- package/constant.d.ts +0 -16
- package/constant.js +1 -20
- package/hooks/ShopperBaskets/helpers.d.ts +32 -21
- package/hooks/ShopperBaskets/queryKeyHelpers.js +10 -10
- package/hooks/ShopperContexts/queryKeyHelpers.js +2 -2
- package/hooks/ShopperCustomers/queryKeyHelpers.js +22 -22
- package/hooks/ShopperExperience/queryKeyHelpers.js +4 -4
- package/hooks/ShopperGiftCertificates/queryKeyHelpers.js +2 -2
- package/hooks/ShopperLogin/queryKeyHelpers.js +6 -6
- package/hooks/ShopperOrders/queryKeyHelpers.js +6 -6
- package/hooks/ShopperProducts/queryKeyHelpers.js +8 -8
- package/hooks/ShopperPromotions/queryKeyHelpers.js +4 -4
- package/hooks/{ShopperSeo → ShopperSEO}/query.d.ts +1 -1
- package/hooks/{ShopperSeo → ShopperSEO}/query.js +3 -3
- package/hooks/{ShopperSeo → ShopperSEO}/queryKeyHelpers.d.ts +2 -2
- package/hooks/{ShopperSeo → ShopperSEO}/queryKeyHelpers.js +2 -2
- package/hooks/ShopperSearch/queryKeyHelpers.js +4 -4
- package/hooks/ShopperStores/queryKeyHelpers.js +4 -4
- package/hooks/helpers.d.ts +14 -1
- package/hooks/index.d.ts +1 -1
- package/hooks/index.js +4 -4
- package/hooks/types.d.ts +3 -3
- package/hooks/useDNT.d.ts +0 -4
- package/hooks/useDNT.js +0 -6
- package/hooks/useQuery.js +2 -0
- package/package.json +5 -5
- package/provider.d.ts +14 -2
- package/provider.js +18 -13
- package/utils.d.ts +1 -1
- /package/hooks/{ShopperSeo → ShopperSEO}/index.d.ts +0 -0
- /package/hooks/{ShopperSeo → ShopperSEO}/index.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
##
|
|
1
|
+
## v4.0.0-nightly-20250826080215 (Aug 26, 2025)
|
|
2
|
+
## v4.0.0-dev (Aug 26, 2025)
|
|
3
|
+
## v3.12.0-nightly-20250826080215 (Aug 26, 2025)
|
|
4
|
+
## v4.0.0-dev (Aug 18, 2025)
|
|
5
|
+
- Upgrade to commerce-sdk-isomorphic v4.0.0 [2879](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2879)
|
|
2
6
|
- Add support for environment level base paths on /mobify routes [#2892](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2892)
|
|
3
7
|
- Update USID expiry to match SLAS refresh token expiry[#2854](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2854)
|
|
8
|
+
- [Bugfix] Skip deleting dwsid on shopper login if hybrid auth is enabled for current site. [#3151](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3151)
|
|
9
|
+
- Remove deprecated properties in commerce-sdk-react [#3177](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3177)
|
|
4
10
|
|
|
5
11
|
## v3.4.0 (Jul 22, 2025)
|
|
6
12
|
|
package/README.md
CHANGED
|
@@ -160,9 +160,27 @@ const Example = () => {
|
|
|
160
160
|
const login = useAuthHelper(AuthHelpers.LoginRegisteredUserB2C)
|
|
161
161
|
const logout = useAuthHelper(AuthHelpers.LogOut)
|
|
162
162
|
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
return (
|
|
164
|
+
<div>
|
|
165
|
+
{/* Simple login */}
|
|
166
|
+
<button onClick={() => {
|
|
167
|
+
login.mutate({username: 'kevin', password: 'pa$$word'})
|
|
168
|
+
}}>
|
|
169
|
+
Login
|
|
170
|
+
</button>
|
|
171
|
+
|
|
172
|
+
{/* Login with custom parameters */}
|
|
173
|
+
<button onClick={() => {
|
|
174
|
+
login.mutate({
|
|
175
|
+
username: 'kevin',
|
|
176
|
+
password: 'pa$$word',
|
|
177
|
+
customParameters: {c_customField: 'customValue'}
|
|
178
|
+
})
|
|
179
|
+
}}>
|
|
180
|
+
Login with Custom Parameters
|
|
181
|
+
</button>
|
|
182
|
+
</div>
|
|
183
|
+
)
|
|
166
184
|
}
|
|
167
185
|
```
|
|
168
186
|
|
package/auth/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { helpers, ShopperLoginTypes, ShopperCustomersTypes } from 'commerce-sdk-isomorphic';
|
|
1
|
+
import { helpers, ShopperLoginTypes, ShopperCustomersTypes, FetchOptions } from 'commerce-sdk-isomorphic';
|
|
2
2
|
import { ApiClientConfigParams, Prettify, RemoveStringIndex } from '../hooks/types';
|
|
3
3
|
import { CustomerType } from '../hooks/useCustomerType';
|
|
4
4
|
import { DNT_COOKIE_NAME, DWSID_COOKIE_NAME } from '../constant';
|
|
5
5
|
import { Logger } from '../types';
|
|
6
6
|
type TokenResponse = ShopperLoginTypes.TokenResponse;
|
|
7
|
-
type Helpers = typeof helpers;
|
|
8
7
|
interface AuthConfig extends ApiClientConfigParams {
|
|
9
8
|
redirectURI: string;
|
|
10
9
|
proxy: string;
|
|
11
10
|
privateClientProxyEndpoint?: string;
|
|
12
|
-
fetchOptions?:
|
|
11
|
+
fetchOptions?: FetchOptions;
|
|
13
12
|
fetchedToken?: string;
|
|
14
13
|
enablePWAKitPrivateClient?: boolean;
|
|
15
14
|
clientSecret?: string;
|
|
@@ -19,21 +18,34 @@ interface AuthConfig extends ApiClientConfigParams {
|
|
|
19
18
|
passwordlessLoginCallbackURI?: string;
|
|
20
19
|
refreshTokenRegisteredCookieTTL?: number;
|
|
21
20
|
refreshTokenGuestCookieTTL?: number;
|
|
21
|
+
hybridAuthEnabled?: boolean;
|
|
22
22
|
}
|
|
23
|
-
type AuthorizeIDPParams = Parameters<Helpers['authorizeIDP']>[1];
|
|
24
|
-
type LoginIDPUserParams = Parameters<Helpers['loginIDPUser']>[2];
|
|
25
|
-
type AuthorizePasswordlessParams = Parameters<Helpers['authorizePasswordless']>[2];
|
|
26
|
-
type LoginPasswordlessParams = Parameters<Helpers['getPasswordLessAccessToken']>[2];
|
|
27
|
-
type LoginRegisteredUserB2CCredentials = Parameters<Helpers['loginRegisteredUserB2C']>[1];
|
|
28
23
|
/**
|
|
29
|
-
*
|
|
30
|
-
* loginRegisteredUserB2C so that it takes in a body rather than just credentials
|
|
31
|
-
*
|
|
24
|
+
* Body type for loginRegisteredUserB2C - aligns with register function pattern
|
|
32
25
|
*/
|
|
33
|
-
type
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
type LoginRegisteredUserB2CBody = {
|
|
27
|
+
username: string;
|
|
28
|
+
password: string;
|
|
29
|
+
customParameters?: helpers.CustomRequestBody;
|
|
30
|
+
};
|
|
31
|
+
type LoginIDPUserParams = {
|
|
32
|
+
redirectURI?: string;
|
|
33
|
+
code: string;
|
|
34
|
+
usid?: string;
|
|
35
|
+
};
|
|
36
|
+
type AuthorizeIDPParams = {
|
|
37
|
+
redirectURI: string;
|
|
38
|
+
hint: string;
|
|
39
|
+
usid?: string;
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
};
|
|
42
|
+
type AuthorizePasswordlessParams = {
|
|
43
|
+
callbackURI?: string;
|
|
44
|
+
userid: string;
|
|
45
|
+
mode?: string;
|
|
46
|
+
};
|
|
47
|
+
type GetPasswordLessAccessTokenParams = {
|
|
48
|
+
pwdlessLoginToken: string;
|
|
37
49
|
};
|
|
38
50
|
/**
|
|
39
51
|
* The extended field is not from api response, we manually store the auth type,
|
|
@@ -76,6 +88,7 @@ declare class Auth {
|
|
|
76
88
|
private refreshTokenRegisteredCookieTTL;
|
|
77
89
|
private refreshTokenGuestCookieTTL;
|
|
78
90
|
private refreshTrustedAgentHandler;
|
|
91
|
+
private hybridAuthEnabled;
|
|
79
92
|
constructor(config: AuthConfig);
|
|
80
93
|
get(name: AuthDataKeys): string;
|
|
81
94
|
private set;
|
|
@@ -161,7 +174,20 @@ declare class Auth {
|
|
|
161
174
|
* store the data in storage.
|
|
162
175
|
*/
|
|
163
176
|
private handleTokenResponse;
|
|
164
|
-
refreshAccessToken(): Promise<
|
|
177
|
+
refreshAccessToken(): Promise<{
|
|
178
|
+
access_token: string;
|
|
179
|
+
id_token: string;
|
|
180
|
+
refresh_token: string;
|
|
181
|
+
expires_in: number;
|
|
182
|
+
refresh_token_expires_in: number;
|
|
183
|
+
token_type: "Bearer";
|
|
184
|
+
usid: string;
|
|
185
|
+
customer_id: string;
|
|
186
|
+
enc_user_id: string;
|
|
187
|
+
idp_access_token: string;
|
|
188
|
+
} & {
|
|
189
|
+
[key: string]: any;
|
|
190
|
+
}>;
|
|
165
191
|
/**
|
|
166
192
|
* This method queues the requests and handles the SLAS token response.
|
|
167
193
|
*
|
|
@@ -169,7 +195,20 @@ declare class Auth {
|
|
|
169
195
|
*
|
|
170
196
|
* @Internal
|
|
171
197
|
*/
|
|
172
|
-
queueRequest(fn: () => Promise<TokenResponse>, isGuest: boolean): Promise<
|
|
198
|
+
queueRequest(fn: () => Promise<TokenResponse>, isGuest: boolean): Promise<{
|
|
199
|
+
access_token: string;
|
|
200
|
+
id_token: string;
|
|
201
|
+
refresh_token: string;
|
|
202
|
+
expires_in: number;
|
|
203
|
+
refresh_token_expires_in: number;
|
|
204
|
+
token_type: "Bearer";
|
|
205
|
+
usid: string;
|
|
206
|
+
customer_id: string;
|
|
207
|
+
enc_user_id: string;
|
|
208
|
+
idp_access_token: string;
|
|
209
|
+
} & {
|
|
210
|
+
[key: string]: any;
|
|
211
|
+
}>;
|
|
173
212
|
logWarning: (msg: string) => void;
|
|
174
213
|
/**
|
|
175
214
|
* This method extracts the status and message from a ResponseError that is returned
|
|
@@ -202,7 +241,20 @@ declare class Auth {
|
|
|
202
241
|
* 3. If we have valid TAOB access token - refresh TAOB token flow
|
|
203
242
|
* 4. PKCE flow
|
|
204
243
|
*/
|
|
205
|
-
ready(): Promise<
|
|
244
|
+
ready(): Promise<{
|
|
245
|
+
access_token: string;
|
|
246
|
+
id_token: string;
|
|
247
|
+
refresh_token: string;
|
|
248
|
+
expires_in: number;
|
|
249
|
+
refresh_token_expires_in: number;
|
|
250
|
+
token_type: "Bearer";
|
|
251
|
+
usid: string;
|
|
252
|
+
customer_id: string;
|
|
253
|
+
enc_user_id: string;
|
|
254
|
+
idp_access_token: string;
|
|
255
|
+
} & {
|
|
256
|
+
[key: string]: any;
|
|
257
|
+
}>;
|
|
206
258
|
/**
|
|
207
259
|
* Creates a function that only executes after a session is initialized.
|
|
208
260
|
* @param fn Function that needs to wait until the session is initialized.
|
|
@@ -213,7 +265,20 @@ declare class Auth {
|
|
|
213
265
|
* A wrapper method for commerce-sdk-isomorphic helper: loginGuestUser.
|
|
214
266
|
*
|
|
215
267
|
*/
|
|
216
|
-
loginGuestUser(parameters?: helpers.CustomQueryParameters): Promise<
|
|
268
|
+
loginGuestUser(parameters?: helpers.CustomQueryParameters): Promise<{
|
|
269
|
+
access_token: string;
|
|
270
|
+
id_token: string;
|
|
271
|
+
refresh_token: string;
|
|
272
|
+
expires_in: number;
|
|
273
|
+
refresh_token_expires_in: number;
|
|
274
|
+
token_type: "Bearer";
|
|
275
|
+
usid: string;
|
|
276
|
+
customer_id: string;
|
|
277
|
+
enc_user_id: string;
|
|
278
|
+
idp_access_token: string;
|
|
279
|
+
} & {
|
|
280
|
+
[key: string]: any;
|
|
281
|
+
}>;
|
|
217
282
|
/**
|
|
218
283
|
* This is a wrapper method for ShopperCustomer API registerCustomer endpoint.
|
|
219
284
|
*
|
|
@@ -226,11 +291,11 @@ declare class Auth {
|
|
|
226
291
|
city?: string | undefined;
|
|
227
292
|
companyName?: string | undefined;
|
|
228
293
|
countryCode: string;
|
|
229
|
-
creationDate?:
|
|
294
|
+
creationDate?: string | undefined;
|
|
230
295
|
firstName?: string | undefined;
|
|
231
296
|
fullName?: string | undefined;
|
|
232
297
|
jobTitle?: string | undefined;
|
|
233
|
-
lastModified?:
|
|
298
|
+
lastModified?: string | undefined;
|
|
234
299
|
lastName: string;
|
|
235
300
|
phone?: string | undefined;
|
|
236
301
|
postBox?: string | undefined;
|
|
@@ -245,13 +310,13 @@ declare class Auth {
|
|
|
245
310
|
} & {
|
|
246
311
|
[key: string]: any;
|
|
247
312
|
})[] | undefined;
|
|
248
|
-
authType?:
|
|
249
|
-
birthday?:
|
|
313
|
+
authType?: ("guest" | "registered") | undefined;
|
|
314
|
+
birthday?: string | undefined;
|
|
250
315
|
companyName?: string | undefined;
|
|
251
|
-
creationDate?:
|
|
316
|
+
creationDate?: string | undefined;
|
|
317
|
+
currentPassword?: string | undefined;
|
|
252
318
|
customerId?: string | undefined;
|
|
253
319
|
customerNo?: string | undefined;
|
|
254
|
-
currentPassword?: string | undefined;
|
|
255
320
|
email?: string | undefined;
|
|
256
321
|
enabled?: boolean | undefined;
|
|
257
322
|
fax?: string | undefined;
|
|
@@ -259,29 +324,19 @@ declare class Auth {
|
|
|
259
324
|
gender?: number | undefined;
|
|
260
325
|
hashedLogin?: string | undefined;
|
|
261
326
|
jobTitle?: string | undefined;
|
|
262
|
-
lastLoginTime?:
|
|
263
|
-
lastModified?:
|
|
327
|
+
lastLoginTime?: string | undefined;
|
|
328
|
+
lastModified?: string | undefined;
|
|
264
329
|
lastName?: string | undefined;
|
|
265
|
-
lastVisitTime?:
|
|
330
|
+
lastVisitTime?: string | undefined;
|
|
266
331
|
login?: string | undefined;
|
|
267
332
|
note?: string | undefined;
|
|
268
333
|
paymentInstruments?: ({
|
|
269
334
|
bankRoutingNumber?: string | undefined;
|
|
270
|
-
creationDate?:
|
|
271
|
-
lastModified?:
|
|
335
|
+
creationDate?: string | undefined;
|
|
336
|
+
lastModified?: string | undefined;
|
|
272
337
|
maskedGiftCertificateCode?: string | undefined;
|
|
273
|
-
paymentBankAccount?: ({
|
|
274
|
-
driversLicenseLastDigits?: string | undefined;
|
|
275
|
-
driversLicenseStateCode?: string | undefined;
|
|
276
|
-
holder?: string | undefined;
|
|
277
|
-
maskedDriversLicense?: string | undefined;
|
|
278
|
-
maskedNumber?: string | undefined;
|
|
279
|
-
numberLastDigits?: string | undefined;
|
|
280
|
-
} & {
|
|
281
|
-
[key: string]: any;
|
|
282
|
-
}) | undefined;
|
|
283
338
|
paymentCard?: ({
|
|
284
|
-
cardType
|
|
339
|
+
cardType?: string | undefined;
|
|
285
340
|
creditCardExpired?: boolean | undefined;
|
|
286
341
|
creditCardToken?: string | undefined;
|
|
287
342
|
expirationMonth?: number | undefined;
|
|
@@ -297,6 +352,7 @@ declare class Auth {
|
|
|
297
352
|
}) | undefined;
|
|
298
353
|
paymentInstrumentId?: string | undefined;
|
|
299
354
|
paymentMethodId?: string | undefined;
|
|
355
|
+
default?: boolean | undefined;
|
|
300
356
|
} & {
|
|
301
357
|
[key: string]: any;
|
|
302
358
|
})[] | undefined;
|
|
@@ -304,8 +360,8 @@ declare class Auth {
|
|
|
304
360
|
phoneHome?: string | undefined;
|
|
305
361
|
phoneMobile?: string | undefined;
|
|
306
362
|
preferredLocale?: string | undefined;
|
|
307
|
-
previousLoginTime?:
|
|
308
|
-
previousVisitTime?:
|
|
363
|
+
previousLoginTime?: string | undefined;
|
|
364
|
+
previousVisitTime?: string | undefined;
|
|
309
365
|
salutation?: string | undefined;
|
|
310
366
|
secondName?: string | undefined;
|
|
311
367
|
suffix?: string | undefined;
|
|
@@ -316,14 +372,10 @@ declare class Auth {
|
|
|
316
372
|
/**
|
|
317
373
|
* A wrapper method for commerce-sdk-isomorphic helper: loginRegisteredUserB2C.
|
|
318
374
|
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* 'body' argument into this function.
|
|
322
|
-
*
|
|
323
|
-
* In the next major version release, we should modify this method so that it's input is a body containing credentials,
|
|
324
|
-
* similar to the input for the register function.
|
|
375
|
+
* This method uses a body-based API similar to the register function for consistency.
|
|
376
|
+
* Supports custom parameters through the customParameters field.
|
|
325
377
|
*/
|
|
326
|
-
loginRegisteredUserB2C(
|
|
378
|
+
loginRegisteredUserB2C(body: LoginRegisteredUserB2CBody): Promise<helpers.TokenResponse>;
|
|
327
379
|
/**
|
|
328
380
|
* Trusted agent authorization
|
|
329
381
|
*
|
|
@@ -352,8 +404,8 @@ declare class Auth {
|
|
|
352
404
|
id_token: string;
|
|
353
405
|
refresh_token: string;
|
|
354
406
|
expires_in: number;
|
|
355
|
-
refresh_token_expires_in:
|
|
356
|
-
token_type:
|
|
407
|
+
refresh_token_expires_in: number;
|
|
408
|
+
token_type: "Bearer";
|
|
357
409
|
usid: string;
|
|
358
410
|
customer_id: string;
|
|
359
411
|
enc_user_id: string;
|
|
@@ -372,7 +424,20 @@ declare class Auth {
|
|
|
372
424
|
* A wrapper method for commerce-sdk-isomorphic helper: logout.
|
|
373
425
|
*
|
|
374
426
|
*/
|
|
375
|
-
logout(): Promise<
|
|
427
|
+
logout(): Promise<{
|
|
428
|
+
access_token: string;
|
|
429
|
+
id_token: string;
|
|
430
|
+
refresh_token: string;
|
|
431
|
+
expires_in: number;
|
|
432
|
+
refresh_token_expires_in: number;
|
|
433
|
+
token_type: "Bearer";
|
|
434
|
+
usid: string;
|
|
435
|
+
customer_id: string;
|
|
436
|
+
enc_user_id: string;
|
|
437
|
+
idp_access_token: string;
|
|
438
|
+
} & {
|
|
439
|
+
[key: string]: any;
|
|
440
|
+
}>;
|
|
376
441
|
/**
|
|
377
442
|
* Handle updating customer password and re-log in after the access token is invalidated.
|
|
378
443
|
*
|
|
@@ -385,9 +450,13 @@ declare class Auth {
|
|
|
385
450
|
}): Promise<void>;
|
|
386
451
|
/**
|
|
387
452
|
* A wrapper method for commerce-sdk-isomorphic helper: authorizeIDP.
|
|
453
|
+
* Initiates OAuth2 authorization flow for Identity Provider (IDP) login.
|
|
388
454
|
*
|
|
389
455
|
*/
|
|
390
|
-
authorizeIDP(parameters: AuthorizeIDPParams): Promise<
|
|
456
|
+
authorizeIDP(parameters: AuthorizeIDPParams): Promise<{
|
|
457
|
+
url: string;
|
|
458
|
+
codeVerifier: string;
|
|
459
|
+
}>;
|
|
391
460
|
/**
|
|
392
461
|
* A wrapper method for commerce-sdk-isomorphic helper: loginIDPUser.
|
|
393
462
|
*
|
|
@@ -400,17 +469,17 @@ declare class Auth {
|
|
|
400
469
|
/**
|
|
401
470
|
* A wrapper method for commerce-sdk-isomorphic helper: getPasswordLessAccessToken.
|
|
402
471
|
*/
|
|
403
|
-
getPasswordLessAccessToken(parameters:
|
|
472
|
+
getPasswordLessAccessToken(parameters: GetPasswordLessAccessTokenParams): Promise<helpers.TokenResponse>;
|
|
404
473
|
/**
|
|
405
474
|
* A wrapper method for the SLAS endpoint: getPasswordResetToken.
|
|
406
475
|
*
|
|
407
476
|
*/
|
|
408
|
-
getPasswordResetToken(parameters: ShopperLoginTypes.
|
|
477
|
+
getPasswordResetToken(parameters: ShopperLoginTypes.getPasswordResetTokenBodyType): Promise<void>;
|
|
409
478
|
/**
|
|
410
479
|
* A wrapper method for the SLAS endpoint: resetPassword.
|
|
411
480
|
*
|
|
412
481
|
*/
|
|
413
|
-
resetPassword(parameters: ShopperLoginTypes.
|
|
482
|
+
resetPassword(parameters: ShopperLoginTypes.resetPasswordBodyType): Promise<void>;
|
|
414
483
|
/**
|
|
415
484
|
* Decode SLAS JWT and extract information such as customer id, usid, etc.
|
|
416
485
|
*
|