@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/provider.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import React, { ReactElement } from 'react';
|
|
|
2
2
|
import Auth from './auth';
|
|
3
3
|
import { ApiClientConfigParams, ApiClients } from './hooks/types';
|
|
4
4
|
import { Logger } from './types';
|
|
5
|
-
import {
|
|
5
|
+
import { FetchOptions } from 'commerce-sdk-isomorphic';
|
|
6
6
|
export interface CommerceApiProviderProps extends ApiClientConfigParams {
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
proxy: string;
|
|
9
9
|
locale: string;
|
|
10
10
|
currency: string;
|
|
11
11
|
redirectURI: string;
|
|
12
|
-
fetchOptions?:
|
|
12
|
+
fetchOptions?: FetchOptions;
|
|
13
13
|
headers?: Record<string, string>;
|
|
14
14
|
fetchedToken?: string;
|
|
15
15
|
enablePWAKitPrivateClient?: boolean;
|
|
@@ -23,6 +23,7 @@ export interface CommerceApiProviderProps extends ApiClientConfigParams {
|
|
|
23
23
|
refreshTokenGuestCookieTTL?: number;
|
|
24
24
|
apiClients?: ApiClients;
|
|
25
25
|
disableAuthInit?: boolean;
|
|
26
|
+
hybridAuthEnabled?: boolean;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* @internal
|
|
@@ -76,6 +77,17 @@ export declare const AuthContext: React.Context<Auth>;
|
|
|
76
77
|
* directly to the provider. However, be careful when doing this as you will have
|
|
77
78
|
* to make sure the secret is not unexpectedly exposed to the client.
|
|
78
79
|
*
|
|
80
|
+
*
|
|
81
|
+
* `hybridAuthEnabled` is an optional flag that indicates the current Site has Hybrid Auth enabled.
|
|
82
|
+
* This drives the behavior of the `clearECOMSession` method. If `hybridAuthEnabled` is true,
|
|
83
|
+
* the `clearECOMSession` method will not be called. This makes sure the session-bridged dwsid, received from `/oauth2/token` call
|
|
84
|
+
* on shopper login is NOT cleared and can be used to maintain the server affinity.
|
|
85
|
+
*
|
|
86
|
+
* `hybridAuthEnabled` flag can also be used to drive other Hybrid Auth specific behaviors in the future.
|
|
87
|
+
*
|
|
88
|
+
* Note: `hybridAuthEnabled` should NOT be set to true for hybrid storefronts using Plugin SLAS as we need the dwsid to be deleted
|
|
89
|
+
* to force session-bridging on SFRA as in this case, the `oauth2/token` call does not return a dwsid.
|
|
90
|
+
*
|
|
79
91
|
* @returns Provider to wrap your app with
|
|
80
92
|
*/
|
|
81
93
|
declare const CommerceApiProvider: (props: CommerceApiProviderProps) => ReactElement;
|
package/provider.js
CHANGED
|
@@ -79,6 +79,17 @@ const AuthContext = exports.AuthContext = /*#__PURE__*/_react.default.createCont
|
|
|
79
79
|
* Non-PWA Kit users can enable private client mode by passing in a client secret
|
|
80
80
|
* directly to the provider. However, be careful when doing this as you will have
|
|
81
81
|
* to make sure the secret is not unexpectedly exposed to the client.
|
|
82
|
+
*
|
|
83
|
+
*
|
|
84
|
+
* `hybridAuthEnabled` is an optional flag that indicates the current Site has Hybrid Auth enabled.
|
|
85
|
+
* This drives the behavior of the `clearECOMSession` method. If `hybridAuthEnabled` is true,
|
|
86
|
+
* the `clearECOMSession` method will not be called. This makes sure the session-bridged dwsid, received from `/oauth2/token` call
|
|
87
|
+
* on shopper login is NOT cleared and can be used to maintain the server affinity.
|
|
88
|
+
*
|
|
89
|
+
* `hybridAuthEnabled` flag can also be used to drive other Hybrid Auth specific behaviors in the future.
|
|
90
|
+
*
|
|
91
|
+
* Note: `hybridAuthEnabled` should NOT be set to true for hybrid storefronts using Plugin SLAS as we need the dwsid to be deleted
|
|
92
|
+
* to force session-bridging on SFRA as in this case, the `oauth2/token` call does not return a dwsid.
|
|
82
93
|
*
|
|
83
94
|
* @returns Provider to wrap your app with
|
|
84
95
|
*/
|
|
@@ -106,7 +117,8 @@ const CommerceApiProvider = props => {
|
|
|
106
117
|
refreshTokenRegisteredCookieTTL,
|
|
107
118
|
refreshTokenGuestCookieTTL,
|
|
108
119
|
apiClients,
|
|
109
|
-
disableAuthInit = false
|
|
120
|
+
disableAuthInit = false,
|
|
121
|
+
hybridAuthEnabled = false
|
|
110
122
|
} = props;
|
|
111
123
|
|
|
112
124
|
// Set the logger based on provided configuration, or default to the console object if no logger is provided
|
|
@@ -119,6 +131,7 @@ const CommerceApiProvider = props => {
|
|
|
119
131
|
siteId,
|
|
120
132
|
proxy,
|
|
121
133
|
redirectURI,
|
|
134
|
+
headers,
|
|
122
135
|
fetchOptions,
|
|
123
136
|
fetchedToken,
|
|
124
137
|
enablePWAKitPrivateClient,
|
|
@@ -129,9 +142,10 @@ const CommerceApiProvider = props => {
|
|
|
129
142
|
defaultDnt,
|
|
130
143
|
passwordlessLoginCallbackURI,
|
|
131
144
|
refreshTokenRegisteredCookieTTL,
|
|
132
|
-
refreshTokenGuestCookieTTL
|
|
145
|
+
refreshTokenGuestCookieTTL,
|
|
146
|
+
hybridAuthEnabled
|
|
133
147
|
});
|
|
134
|
-
}, [clientId, organizationId, shortCode, siteId, proxy, redirectURI, fetchOptions, fetchedToken, enablePWAKitPrivateClient, privateClientProxyEndpoint, clientSecret, silenceWarnings, configLogger, defaultDnt, passwordlessLoginCallbackURI, refreshTokenRegisteredCookieTTL, refreshTokenGuestCookieTTL, apiClients]);
|
|
148
|
+
}, [clientId, organizationId, shortCode, siteId, proxy, redirectURI, headers, fetchOptions, fetchedToken, enablePWAKitPrivateClient, privateClientProxyEndpoint, clientSecret, silenceWarnings, configLogger, defaultDnt, passwordlessLoginCallbackURI, refreshTokenRegisteredCookieTTL, refreshTokenGuestCookieTTL, apiClients, hybridAuthEnabled]);
|
|
135
149
|
const dwsid = auth.get(_constant.DWSID_COOKIE_NAME);
|
|
136
150
|
const serverAffinityHeader = {};
|
|
137
151
|
if (dwsid) {
|
|
@@ -178,14 +192,6 @@ const CommerceApiProvider = props => {
|
|
|
178
192
|
throwOnBadResponse: true,
|
|
179
193
|
fetchOptions
|
|
180
194
|
};
|
|
181
|
-
|
|
182
|
-
// Special proxy endpoint for injecting SLAS private client secret.
|
|
183
|
-
// This is only used by the ShopperLogin API as that is the only one that interacts with SLAS.
|
|
184
|
-
// We prioritize config.privateClientProxyEndpoint since that allows us to use the new envBasePath feature
|
|
185
|
-
// The preexisting hard coded privateClientEndpoint is kept here for now to prevent a breaking change.
|
|
186
|
-
// TODO: We should remove this in the next major release so we do not have a hard coded proxy path inside commerce-sdk-react
|
|
187
|
-
const baseUrl = config.proxy.split(_constant.MOBIFY_PATH)[0];
|
|
188
|
-
const privateClientEndpoint = `${baseUrl}${_constant.SLAS_PRIVATE_PROXY_PATH}`;
|
|
189
195
|
return {
|
|
190
196
|
shopperBaskets: new _commerceSdkIsomorphic.ShopperBaskets(config),
|
|
191
197
|
shopperContexts: new _commerceSdkIsomorphic.ShopperContexts(config),
|
|
@@ -193,13 +199,13 @@ const CommerceApiProvider = props => {
|
|
|
193
199
|
shopperExperience: new _commerceSdkIsomorphic.ShopperExperience(config),
|
|
194
200
|
shopperGiftCertificates: new _commerceSdkIsomorphic.ShopperGiftCertificates(config),
|
|
195
201
|
shopperLogin: new _commerceSdkIsomorphic.ShopperLogin(_objectSpread(_objectSpread({}, config), {}, {
|
|
196
|
-
proxy: enablePWAKitPrivateClient ? privateClientProxyEndpoint
|
|
202
|
+
proxy: enablePWAKitPrivateClient ? privateClientProxyEndpoint : config.proxy
|
|
197
203
|
})),
|
|
198
204
|
shopperOrders: new _commerceSdkIsomorphic.ShopperOrders(config),
|
|
199
205
|
shopperProducts: new _commerceSdkIsomorphic.ShopperProducts(config),
|
|
200
206
|
shopperPromotions: new _commerceSdkIsomorphic.ShopperPromotions(config),
|
|
201
207
|
shopperSearch: new _commerceSdkIsomorphic.ShopperSearch(config),
|
|
202
|
-
shopperSeo: new _commerceSdkIsomorphic.
|
|
208
|
+
shopperSeo: new _commerceSdkIsomorphic.ShopperSEO(config),
|
|
203
209
|
shopperStores: new _commerceSdkIsomorphic.ShopperStores(config)
|
|
204
210
|
};
|
|
205
211
|
}, [clientId, organizationId, shortCode, siteId, proxy, fetchOptions, locale, currency, headers === null || headers === void 0 ? void 0 : headers['correlation-id'], apiClients]);
|
package/utils.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const isOriginTrusted: (origin: string | undefined) => boolean;
|
|
|
25
25
|
* @returns `undefined` if running on the server, `"none"` if running as an iframe on a trusted site
|
|
26
26
|
* (i.e. Storefront Preview), otherwise `"Lax"`
|
|
27
27
|
*/
|
|
28
|
-
export declare const getCookieSameSiteAttribute: () => "
|
|
28
|
+
export declare const getCookieSameSiteAttribute: () => "none" | "Lax" | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Gets the default cookie attributes. Sets the secure flag unless running on localhost in Safari.
|
|
31
31
|
* Sets the sameSite attribute to `"none"` when running in a trusted iframe.
|
|
File without changes
|
|
File without changes
|