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