@salesforce/commerce-sdk-react 3.5.0-preview.0 → 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.
Files changed (36) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/README.md +21 -3
  3. package/auth/index.d.ts +127 -57
  4. package/auth/index.js +163 -108
  5. package/components/StorefrontPreview/utils.js +3 -2
  6. package/constant.d.ts +0 -16
  7. package/constant.js +1 -19
  8. package/hooks/ShopperBaskets/helpers.d.ts +32 -21
  9. package/hooks/ShopperBaskets/queryKeyHelpers.js +10 -10
  10. package/hooks/ShopperContexts/queryKeyHelpers.js +2 -2
  11. package/hooks/ShopperCustomers/queryKeyHelpers.js +22 -22
  12. package/hooks/ShopperExperience/queryKeyHelpers.js +4 -4
  13. package/hooks/ShopperGiftCertificates/queryKeyHelpers.js +2 -2
  14. package/hooks/ShopperLogin/queryKeyHelpers.js +6 -6
  15. package/hooks/ShopperOrders/queryKeyHelpers.js +6 -6
  16. package/hooks/ShopperProducts/queryKeyHelpers.js +8 -8
  17. package/hooks/ShopperPromotions/queryKeyHelpers.js +4 -4
  18. package/hooks/{ShopperSeo → ShopperSEO}/query.d.ts +1 -1
  19. package/hooks/{ShopperSeo → ShopperSEO}/query.js +3 -3
  20. package/hooks/{ShopperSeo → ShopperSEO}/queryKeyHelpers.d.ts +2 -2
  21. package/hooks/{ShopperSeo → ShopperSEO}/queryKeyHelpers.js +2 -2
  22. package/hooks/ShopperSearch/queryKeyHelpers.js +4 -4
  23. package/hooks/ShopperStores/queryKeyHelpers.js +4 -4
  24. package/hooks/helpers.d.ts +14 -1
  25. package/hooks/index.d.ts +1 -1
  26. package/hooks/index.js +4 -4
  27. package/hooks/types.d.ts +3 -3
  28. package/hooks/useDNT.d.ts +0 -4
  29. package/hooks/useDNT.js +0 -6
  30. package/hooks/useQuery.js +2 -0
  31. package/package.json +5 -5
  32. package/provider.d.ts +14 -2
  33. package/provider.js +19 -12
  34. package/utils.d.ts +1 -1
  35. /package/hooks/{ShopperSeo → ShopperSEO}/index.d.ts +0 -0
  36. /package/hooks/{ShopperSeo → ShopperSEO}/index.js +0 -0
package/auth/index.js CHANGED
@@ -9,7 +9,8 @@ var _jwtDecode = require("jwt-decode");
9
9
  var _storage = require("./storage");
10
10
  var _utils = require("../utils");
11
11
  var _constant = require("../constant");
12
- const _excluded = ["customer", "password"];
12
+ const _excluded = ["customer", "password"],
13
+ _excluded2 = ["redirectURI", "hint"];
13
14
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
14
15
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
15
16
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
@@ -25,9 +26,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
25
26
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
26
27
  */
27
28
  /**
28
- * This is a temporary type until we can make a breaking change and modify the signature for
29
- * loginRegisteredUserB2C so that it takes in a body rather than just credentials
30
- *
29
+ * Body type for loginRegisteredUserB2C - aligns with register function pattern
31
30
  */
32
31
 
33
32
  /**
@@ -148,13 +147,10 @@ const DEFAULT_SLAS_REFRESH_TOKEN_GUEST_TTL = exports.DEFAULT_SLAS_REFRESH_TOKEN_
148
147
  class Auth {
149
148
  constructor(config) {
150
149
  // Special proxy endpoint for injecting SLAS private client secret.
151
- // Note: we want to prioritize config.privateClientProxyEndpoint instead of this since that allows us to use the new envBasePath feature
152
- // This is kept here for now to prevent a breaking change.
153
- // We should remove this in the next major release so we do not have a hard coded proxy path inside commerce-sdk-react
154
- const baseUrl = config.proxy.split(_constant.MOBIFY_PATH)[0];
155
- const privateClientEndpoint = `${baseUrl}${_constant.SLAS_PRIVATE_PROXY_PATH}`;
150
+ // We prioritize config.privateClientProxyEndpoint since that allows us to use the new envBasePath feature
156
151
  this.client = new _commerceSdkIsomorphic.ShopperLogin({
157
- proxy: config.enablePWAKitPrivateClient ? config.privateClientProxyEndpoint ? config.privateClientProxyEndpoint : privateClientEndpoint : config.proxy,
152
+ proxy: config.enablePWAKitPrivateClient ? config.privateClientProxyEndpoint : config.proxy,
153
+ headers: config.headers || {},
158
154
  parameters: {
159
155
  clientId: config.clientId,
160
156
  organizationId: config.organizationId,
@@ -171,6 +167,7 @@ class Auth {
171
167
  });
172
168
  this.shopperCustomersClient = new _commerceSdkIsomorphic.ShopperCustomers({
173
169
  proxy: config.proxy,
170
+ headers: config.headers || {},
174
171
  parameters: {
175
172
  clientId: config.clientId,
176
173
  organizationId: config.organizationId,
@@ -227,10 +224,8 @@ class Auth {
227
224
  this.silenceWarnings = config.silenceWarnings || false;
228
225
  this.isPrivate = !!this.clientSecret;
229
226
  const passwordlessLoginCallbackURI = config.passwordlessLoginCallbackURI;
230
- this.passwordlessLoginCallbackURI = passwordlessLoginCallbackURI ? (0, _utils.isAbsoluteUrl)(passwordlessLoginCallbackURI) ? passwordlessLoginCallbackURI :
231
- // This fallback does not take into account the envBasePath feature
232
- // To set an env base path, config.passwordlessLoginCallbackURI must be an absolute url
233
- `${baseUrl}${passwordlessLoginCallbackURI}` : '';
227
+ this.passwordlessLoginCallbackURI = passwordlessLoginCallbackURI || '';
228
+ this.hybridAuthEnabled = config.hybridAuthEnabled || false;
234
229
  }
235
230
  get(name) {
236
231
  const {
@@ -363,7 +358,7 @@ class Auth {
363
358
  token_type: this.get('token_type'),
364
359
  usid: this.get('usid'),
365
360
  customer_type: this.get('customer_type'),
366
- refresh_token_expires_in: this.get('refresh_token_expires_in')
361
+ refresh_token_expires_in: Number(this.get('refresh_token_expires_in'))
367
362
  };
368
363
  }
369
364
 
@@ -478,6 +473,14 @@ class Auth {
478
473
  * registered shopper refresh-token and restores session and basket on SFRA.
479
474
  */
480
475
  clearECOMSession() {
476
+ /**
477
+ * If `hybridAuthEnabled` is true, dwsid cookie must not be cleared.
478
+ * This makes sure the session-bridged dwsid, received from `/oauth2/token` call on shopper login
479
+ * is NOT cleared and can be used to maintain the server affinity.
480
+ */
481
+ if (this.hybridAuthEnabled) {
482
+ return;
483
+ }
481
484
  const {
482
485
  key,
483
486
  storageType
@@ -564,11 +567,15 @@ class Auth {
564
567
  const refreshToken = refreshTokenRegistered || refreshTokenGuest;
565
568
  if (refreshToken) {
566
569
  try {
567
- return yield _this2.queueRequest(() => _commerceSdkIsomorphic.helpers.refreshAccessToken(_this2.client, {
568
- refreshToken,
569
- dnt: dntPref
570
- }, {
571
- clientSecret: _this2.clientSecret
570
+ return yield _this2.queueRequest(() => _commerceSdkIsomorphic.helpers.refreshAccessToken({
571
+ slasClient: _this2.client,
572
+ parameters: {
573
+ refreshToken,
574
+ dnt: dntPref
575
+ },
576
+ credentials: {
577
+ clientSecret: _this2.clientSecret
578
+ }
572
579
  }), !!refreshTokenGuest);
573
580
  } catch (error) {
574
581
  // If the refresh token is invalid, we need to re-login the user
@@ -771,20 +778,27 @@ class Auth {
771
778
  includeDefaults: true
772
779
  });
773
780
  const isGuest = true;
774
- const guestPrivateArgs = [_this6.client, _objectSpread({
775
- dnt: dntPref
776
- }, usid && {
777
- usid
778
- }), {
779
- clientSecret: _this6.clientSecret
780
- }];
781
- const guestPublicArgs = [_this6.client, _objectSpread(_objectSpread({
782
- redirectURI: _this6.redirectURI,
783
- dnt: dntPref
784
- }, usid && {
785
- usid
786
- }), parameters)];
787
- const callback = _this6.clientSecret ? () => _commerceSdkIsomorphic.helpers.loginGuestUserPrivate(...guestPrivateArgs) : () => _commerceSdkIsomorphic.helpers.loginGuestUser(...guestPublicArgs);
781
+ const guestPrivateArgs = {
782
+ slasClient: _this6.client,
783
+ parameters: _objectSpread({
784
+ dnt: dntPref
785
+ }, usid && {
786
+ usid
787
+ }),
788
+ credentials: {
789
+ clientSecret: _this6.clientSecret
790
+ }
791
+ };
792
+ const guestPublicArgs = {
793
+ slasClient: _this6.client,
794
+ parameters: _objectSpread(_objectSpread({
795
+ redirectURI: _this6.redirectURI,
796
+ dnt: dntPref
797
+ }, usid && {
798
+ usid
799
+ }), parameters)
800
+ };
801
+ const callback = _this6.clientSecret ? () => _commerceSdkIsomorphic.helpers.loginGuestUserPrivate(_objectSpread({}, guestPrivateArgs)) : () => _commerceSdkIsomorphic.helpers.loginGuestUser(_objectSpread({}, guestPublicArgs));
788
802
  try {
789
803
  return yield _this6.queueRequest(callback, isGuest);
790
804
  } catch (error) {
@@ -838,9 +852,7 @@ class Auth {
838
852
  yield _this7.loginRegisteredUserB2C({
839
853
  username: login,
840
854
  password,
841
- options: {
842
- body: customParameters
843
- }
855
+ customParameters
844
856
  });
845
857
  return res;
846
858
  })();
@@ -849,14 +861,10 @@ class Auth {
849
861
  /**
850
862
  * A wrapper method for commerce-sdk-isomorphic helper: loginRegisteredUserB2C.
851
863
  *
852
- * Note: This uses the type LoginRegisteredUserCredentialsWithCustomParams rather than LoginRegisteredUserB2CCredentials
853
- * as a workaround to allow custom parameters through because the login.mutateAsync hook will only pass through a single
854
- * 'body' argument into this function.
855
- *
856
- * In the next major version release, we should modify this method so that it's input is a body containing credentials,
857
- * similar to the input for the register function.
864
+ * This method uses a body-based API similar to the register function for consistency.
865
+ * Supports custom parameters through the customParameters field.
858
866
  */
859
- loginRegisteredUserB2C(credentials) {
867
+ loginRegisteredUserB2C(body) {
860
868
  var _this8 = this;
861
869
  return _asyncToGenerator(function* () {
862
870
  if (_this8.clientSecret && (0, _utils.onClient)() && _this8.clientSecret !== _constant.SLAS_SECRET_PLACEHOLDER) {
@@ -868,16 +876,29 @@ class Auth {
868
876
  includeDefaults: true
869
877
  });
870
878
  const isGuest = false;
871
- const token = yield _commerceSdkIsomorphic.helpers.loginRegisteredUserB2C(_this8.client, {
872
- username: credentials.username,
873
- password: credentials.password,
874
- clientSecret: _this8.clientSecret
875
- }, _objectSpread({
876
- redirectURI,
877
- dnt: dntPref
878
- }, usid && {
879
- usid
880
- }), credentials.options);
879
+
880
+ // Extract fields from body parameter (aligned with register function pattern)
881
+ const {
882
+ username,
883
+ password,
884
+ customParameters
885
+ } = body;
886
+ const loginParams = {
887
+ slasClient: _this8.client,
888
+ credentials: {
889
+ username,
890
+ password,
891
+ clientSecret: _this8.clientSecret
892
+ },
893
+ parameters: _objectSpread({
894
+ redirectURI,
895
+ dnt: dntPref
896
+ }, usid && {
897
+ usid
898
+ }),
899
+ body: customParameters
900
+ };
901
+ const token = yield _commerceSdkIsomorphic.helpers.loginRegisteredUserB2C(loginParams);
881
902
  _this8.handleTokenResponse(token, isGuest);
882
903
  if ((0, _utils.onClient)()) {
883
904
  void _this8.clearECOMSession();
@@ -981,9 +1002,12 @@ class Auth {
981
1002
  return _asyncToGenerator(function* () {
982
1003
  if (_this12.get('customer_type') === 'registered') {
983
1004
  // Not awaiting on purpose because there isn't much we can do if this fails.
984
- void _commerceSdkIsomorphic.helpers.logout(_this12.client, {
985
- accessToken: _this12.get('access_token'),
986
- refreshToken: _this12.get('refresh_token_registered')
1005
+ void _commerceSdkIsomorphic.helpers.logout({
1006
+ slasClient: _this12.client,
1007
+ parameters: {
1008
+ accessToken: _this12.get('access_token'),
1009
+ refreshToken: _this12.get('refresh_token_registered')
1010
+ }
987
1011
  });
988
1012
  }
989
1013
  _this12.clearStorage();
@@ -1037,29 +1061,47 @@ class Auth {
1037
1061
 
1038
1062
  /**
1039
1063
  * A wrapper method for commerce-sdk-isomorphic helper: authorizeIDP.
1064
+ * Initiates OAuth2 authorization flow for Identity Provider (IDP) login.
1040
1065
  *
1041
1066
  */
1042
1067
  authorizeIDP(parameters) {
1043
1068
  var _this14 = this;
1044
1069
  return _asyncToGenerator(function* () {
1045
- const redirectURI = parameters.redirectURI || _this14.redirectURI;
1070
+ const slasClient = _this14.client;
1046
1071
  const usid = _this14.get('usid');
1047
- const customParameters = (0, _utils.extractCustomParameters)(parameters);
1072
+ const dntPref = _this14.getDnt({
1073
+ includeDefaults: true
1074
+ });
1075
+
1076
+ // Extract known parameters and get custom ones
1048
1077
  const {
1049
- url,
1050
- codeVerifier
1051
- } = yield _commerceSdkIsomorphic.helpers.authorizeIDP(_this14.client, _objectSpread(_objectSpread({
1052
- redirectURI,
1053
- hint: parameters.hint
1054
- }, usid && {
1078
+ redirectURI,
1079
+ hint
1080
+ } = parameters,
1081
+ customParams = _objectWithoutProperties(parameters, _excluded2);
1082
+ const finalRedirectURI = redirectURI || _this14.redirectURI;
1083
+ const authorizeParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customParams), usid && {
1055
1084
  usid
1056
- }), customParameters), _this14.isPrivate);
1085
+ }), dntPref && {
1086
+ dnt: dntPref
1087
+ }), {}, {
1088
+ redirectURI: finalRedirectURI,
1089
+ hint: hint || ''
1090
+ });
1091
+ const result = yield _commerceSdkIsomorphic.helpers.authorizeIDP({
1092
+ slasClient,
1093
+ parameters: authorizeParams,
1094
+ privateClient: _this14.isPrivate
1095
+ });
1096
+
1097
+ // Store code verifier for later use in loginIDPUser
1098
+ _this14.set('code_verifier', result.codeVerifier);
1057
1099
  if ((0, _utils.onClient)()) {
1058
- window.location.assign(url);
1100
+ window.location.assign(result.url);
1059
1101
  } else {
1060
1102
  console.warn('Something went wrong, this client side method is invoked on the server.');
1061
1103
  }
1062
- _this14.set('code_verifier', codeVerifier);
1104
+ return result;
1063
1105
  })();
1064
1106
  }
1065
1107
 
@@ -1071,22 +1113,25 @@ class Auth {
1071
1113
  var _this15 = this;
1072
1114
  return _asyncToGenerator(function* () {
1073
1115
  const codeVerifier = _this15.get('code_verifier');
1074
- const code = parameters.code;
1075
- const usid = parameters.usid || _this15.get('usid');
1076
1116
  const redirectURI = parameters.redirectURI || _this15.redirectURI;
1117
+ const usid = parameters.usid || _this15.get('usid');
1077
1118
  const dntPref = _this15.getDnt({
1078
1119
  includeDefaults: true
1079
1120
  });
1080
- const token = yield _commerceSdkIsomorphic.helpers.loginIDPUser(_this15.client, {
1081
- codeVerifier,
1082
- clientSecret: _this15.clientSecret
1083
- }, _objectSpread({
1084
- redirectURI,
1085
- code,
1086
- dnt: dntPref
1087
- }, usid && {
1088
- usid
1089
- }));
1121
+ const token = yield _commerceSdkIsomorphic.helpers.loginIDPUser({
1122
+ slasClient: _this15.client,
1123
+ credentials: {
1124
+ codeVerifier,
1125
+ clientSecret: _this15.clientSecret
1126
+ },
1127
+ parameters: _objectSpread({
1128
+ redirectURI,
1129
+ code: parameters.code,
1130
+ dnt: dntPref
1131
+ }, usid && {
1132
+ usid
1133
+ })
1134
+ });
1090
1135
  const isGuest = false;
1091
1136
  _this15.handleTokenResponse(token, isGuest);
1092
1137
  // Delete the code verifier once the user has logged in
@@ -1104,20 +1149,23 @@ class Auth {
1104
1149
  authorizePasswordless(parameters) {
1105
1150
  var _this16 = this;
1106
1151
  return _asyncToGenerator(function* () {
1107
- const userid = parameters.userid;
1108
- const callbackURI = parameters.callbackURI || _this16.passwordlessLoginCallbackURI;
1109
1152
  const usid = _this16.get('usid');
1110
- const mode = callbackURI ? 'callback' : 'sms';
1111
- const res = yield _commerceSdkIsomorphic.helpers.authorizePasswordless(_this16.client, {
1112
- clientSecret: _this16.clientSecret
1113
- }, _objectSpread(_objectSpread(_objectSpread({}, callbackURI && {
1114
- callbackURI: callbackURI
1115
- }), usid && {
1116
- usid
1117
- }), {}, {
1118
- userid,
1119
- mode
1120
- }));
1153
+ const callbackURI = parameters.callbackURI || _this16.passwordlessLoginCallbackURI;
1154
+ const finalMode = callbackURI ? 'callback' : parameters.mode || 'sms';
1155
+ const res = yield _commerceSdkIsomorphic.helpers.authorizePasswordless({
1156
+ slasClient: _this16.client,
1157
+ credentials: {
1158
+ clientSecret: _this16.clientSecret
1159
+ },
1160
+ parameters: _objectSpread(_objectSpread(_objectSpread({}, callbackURI && {
1161
+ callbackURI: callbackURI
1162
+ }), usid && {
1163
+ usid
1164
+ }), {}, {
1165
+ userid: parameters.userid,
1166
+ mode: finalMode
1167
+ })
1168
+ });
1121
1169
  if (res && res.status !== 200) {
1122
1170
  const errorData = yield res.json();
1123
1171
  throw new Error(`${res.status} ${String(errorData.message)}`);
@@ -1132,15 +1180,19 @@ class Auth {
1132
1180
  getPasswordLessAccessToken(parameters) {
1133
1181
  var _this17 = this;
1134
1182
  return _asyncToGenerator(function* () {
1135
- const pwdlessLoginToken = parameters.pwdlessLoginToken;
1183
+ const pwdlessLoginToken = parameters.pwdlessLoginToken || '';
1136
1184
  const dntPref = _this17.getDnt({
1137
1185
  includeDefaults: true
1138
1186
  });
1139
- const token = yield _commerceSdkIsomorphic.helpers.getPasswordLessAccessToken(_this17.client, {
1140
- clientSecret: _this17.clientSecret
1141
- }, {
1142
- pwdlessLoginToken,
1143
- dnt: dntPref !== undefined ? String(dntPref) : undefined
1187
+ const token = yield _commerceSdkIsomorphic.helpers.getPasswordLessAccessToken({
1188
+ slasClient: _this17.client,
1189
+ credentials: {
1190
+ clientSecret: _this17.clientSecret
1191
+ },
1192
+ parameters: {
1193
+ pwdlessLoginToken,
1194
+ dnt: dntPref !== undefined ? String(dntPref) : undefined
1195
+ }
1144
1196
  });
1145
1197
  const isGuest = false;
1146
1198
  _this17.handleTokenResponse(token, isGuest);
@@ -1159,18 +1211,20 @@ class Auth {
1159
1211
  var _this18 = this;
1160
1212
  return _asyncToGenerator(function* () {
1161
1213
  const slasClient = _this18.client;
1162
- const callbackURI = parameters.callback_uri;
1163
1214
  const options = {
1164
1215
  headers: {
1165
1216
  Authorization: ''
1166
1217
  },
1167
1218
  body: {
1168
1219
  user_id: parameters.user_id,
1169
- mode: 'callback',
1170
- channel_id: slasClient.clientConfig.parameters.siteId,
1171
- client_id: slasClient.clientConfig.parameters.clientId,
1172
- callback_uri: callbackURI,
1173
- hint: 'cross_device'
1220
+ mode: parameters.mode || 'callback',
1221
+ channel_id: parameters.channel_id || slasClient.clientConfig.parameters.siteId,
1222
+ client_id: parameters.client_id || slasClient.clientConfig.parameters.clientId,
1223
+ callback_uri: parameters.callback_uri,
1224
+ hint: parameters.hint || 'cross_device',
1225
+ locale: parameters.locale,
1226
+ code_challenge: parameters.code_challenge,
1227
+ idp_name: parameters.idp_name
1174
1228
  }
1175
1229
  };
1176
1230
 
@@ -1197,10 +1251,11 @@ class Auth {
1197
1251
  },
1198
1252
  body: {
1199
1253
  pwd_action_token: parameters.pwd_action_token,
1200
- channel_id: slasClient.clientConfig.parameters.siteId,
1201
- client_id: slasClient.clientConfig.parameters.clientId,
1254
+ channel_id: parameters.channel_id || slasClient.clientConfig.parameters.siteId,
1255
+ client_id: parameters.client_id || slasClient.clientConfig.parameters.clientId,
1202
1256
  new_password: parameters.new_password,
1203
- user_id: parameters.user_id
1257
+ code_verifier: parameters.code_verifier,
1258
+ hint: parameters.hint
1204
1259
  }
1205
1260
  };
1206
1261
 
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.proxyRequests = exports.getClientScript = exports.detectStorefrontPreview = exports.CustomPropTypes = void 0;
7
7
  var _utils = require("../../utils");
8
- var _constant = require("../../constant");
9
8
  /*
10
9
  * Copyright (c) 2023, Salesforce, Inc.
11
10
  * All rights reserved.
@@ -13,6 +12,8 @@ var _constant = require("../../constant");
13
12
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
14
13
  */
15
14
 
15
+ const LOCAL_BUNDLE_PATH = `/mobify/bundle/development`;
16
+
16
17
  /** Detects whether the storefront is running in an iframe as part of Storefront Preview.
17
18
  * @private
18
19
  */
@@ -31,7 +32,7 @@ const getClientScript = () => {
31
32
  const parentOrigin = (0, _utils.getParentOrigin)() ?? 'https://runtime.commercecloud.com';
32
33
  return parentOrigin === _utils.DEVELOPMENT_ORIGIN
33
34
  // TODO: This will need to be updated to support base paths with storefront preview
34
- ? `${parentOrigin}${_constant.LOCAL_BUNDLE_PATH}/static/storefront-preview.js` : `${parentOrigin}/cc/b2c/preview/preview.client.js`;
35
+ ? `${parentOrigin}${LOCAL_BUNDLE_PATH}/static/storefront-preview.js` : `${parentOrigin}/cc/b2c/preview/preview.client.js`;
35
36
  };
36
37
 
37
38
  // Custom Prop Types.
package/constant.d.ts CHANGED
@@ -2,22 +2,6 @@
2
2
  * This list contains domains that can host code in iframe
3
3
  */
4
4
  export declare const IFRAME_HOST_ALLOW_LIST: readonly string[];
5
- /**
6
- * @deprecated
7
- */
8
- export declare const MOBIFY_PATH = "/mobify";
9
- /**
10
- * @deprecated
11
- */
12
- export declare const PROXY_PATH: string;
13
- /**
14
- * @deprecated
15
- */
16
- export declare const LOCAL_BUNDLE_PATH: string;
17
- /**
18
- * @deprecated
19
- */
20
- export declare const SLAS_PRIVATE_PROXY_PATH: string;
21
5
  export declare const SLAS_SECRET_WARNING_MSG = "You are potentially exposing SLAS secret on browser. Make sure to keep it safe and secure!";
22
6
  export declare const SLAS_SECRET_PLACEHOLDER = "_PLACEHOLDER_PROXY-PWA_KIT_SLAS_CLIENT_SECRET";
23
7
  export declare const SLAS_SECRET_OVERRIDE_MSG = "You have enabled PWA Kit Private Client mode which gets the SLAS secret from your environment variable. The SLAS secret you have set in the Auth provider will be ignored.";
package/constant.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SLAS_SECRET_WARNING_MSG = exports.SLAS_SECRET_PLACEHOLDER = exports.SLAS_SECRET_OVERRIDE_MSG = exports.SLAS_REFRESH_TOKEN_COOKIE_TTL_OVERRIDE_MSG = exports.SLAS_PRIVATE_PROXY_PATH = exports.SERVER_AFFINITY_HEADER_KEY = exports.PROXY_PATH = exports.MOBIFY_PATH = exports.LOCAL_BUNDLE_PATH = exports.IFRAME_HOST_ALLOW_LIST = exports.EXCLUDE_COOKIE_SUFFIX = exports.DWSID_COOKIE_NAME = exports.DNT_COOKIE_NAME = exports.CLIENT_KEYS = void 0;
6
+ exports.SLAS_SECRET_WARNING_MSG = exports.SLAS_SECRET_PLACEHOLDER = exports.SLAS_SECRET_OVERRIDE_MSG = exports.SLAS_REFRESH_TOKEN_COOKIE_TTL_OVERRIDE_MSG = exports.SERVER_AFFINITY_HEADER_KEY = exports.IFRAME_HOST_ALLOW_LIST = exports.EXCLUDE_COOKIE_SUFFIX = exports.DWSID_COOKIE_NAME = exports.DNT_COOKIE_NAME = exports.CLIENT_KEYS = void 0;
7
7
  /*
8
8
  * Copyright (c) 2023, Salesforce, Inc.
9
9
  * All rights reserved.
@@ -15,24 +15,6 @@ exports.SLAS_SECRET_WARNING_MSG = exports.SLAS_SECRET_PLACEHOLDER = exports.SLAS
15
15
  * This list contains domains that can host code in iframe
16
16
  */
17
17
  const IFRAME_HOST_ALLOW_LIST = exports.IFRAME_HOST_ALLOW_LIST = Object.freeze(['https://runtime.commercecloud.com', 'https://runtime-admin-staging.mobify-storefront.com', 'https://runtime-admin-preview.mobify-storefront.com']);
18
-
19
- /* The following constants will need to adapt to work with the new envBasePath feature */
20
- /**
21
- * @deprecated
22
- */
23
- const MOBIFY_PATH = exports.MOBIFY_PATH = '/mobify';
24
- /**
25
- * @deprecated
26
- */
27
- const PROXY_PATH = exports.PROXY_PATH = `${MOBIFY_PATH}/proxy`;
28
- /**
29
- * @deprecated
30
- */
31
- const LOCAL_BUNDLE_PATH = exports.LOCAL_BUNDLE_PATH = `${MOBIFY_PATH}/bundle/development`;
32
- /**
33
- * @deprecated
34
- */
35
- const SLAS_PRIVATE_PROXY_PATH = exports.SLAS_PRIVATE_PROXY_PATH = `${MOBIFY_PATH}/slas/private`;
36
18
  const SLAS_SECRET_WARNING_MSG = exports.SLAS_SECRET_WARNING_MSG = 'You are potentially exposing SLAS secret on browser. Make sure to keep it safe and secure!';
37
19
  const SLAS_SECRET_PLACEHOLDER = exports.SLAS_SECRET_PLACEHOLDER = '_PLACEHOLDER_PROXY-PWA_KIT_SLAS_CLIENT_SECRET';
38
20
  const SLAS_SECRET_OVERRIDE_MSG = exports.SLAS_SECRET_OVERRIDE_MSG = 'You have enabled PWA Kit Private Client mode which gets the SLAS secret from your environment variable. The SLAS secret you have set in the Auth provider will be ignored.';
@@ -61,21 +61,20 @@ export declare function useShopperBasketsMutationHelper(): {
61
61
  amount?: number | undefined;
62
62
  percentage?: number | undefined;
63
63
  priceBookId?: string | undefined;
64
- type: string;
64
+ type: "percentage" | "fixed_price" | "amount" | "free" | "price_book_price" | "bonus" | "total_fixed_price" | "bonus_choice" | "percentage_off_options";
65
65
  } & {
66
66
  [key: string]: any;
67
67
  }) | undefined;
68
68
  couponCode?: string | undefined;
69
69
  createdBy?: string | undefined;
70
- creationDate?: any;
70
+ creationDate?: string | undefined;
71
71
  custom?: boolean | undefined;
72
72
  itemText?: string | undefined;
73
- lastModified?: any;
73
+ lastModified?: string | undefined;
74
74
  manual?: boolean | undefined;
75
75
  price?: number | undefined;
76
76
  priceAdjustmentId?: string | undefined;
77
77
  promotionId?: string | undefined;
78
- promotionLink?: string | undefined;
79
78
  reasonCode?: string | undefined;
80
79
  } & {
81
80
  [key: string]: any;
@@ -83,29 +82,33 @@ export declare function useShopperBasketsMutationHelper(): {
83
82
  priceAfterItemDiscount?: number | undefined;
84
83
  priceAfterOrderDiscount?: number | undefined;
85
84
  productId?: string | undefined;
86
- productListItem?: {
85
+ productListItem?: ({
87
86
  id: string;
88
87
  priority?: number | undefined;
89
- productDetailsLink?: {
88
+ productDetailsLink?: ({
90
89
  productDescription?: string | undefined;
91
90
  productId: string;
92
91
  productName?: string | undefined;
93
92
  title?: string | undefined;
94
- } | undefined;
93
+ } & {
94
+ [key: string]: any;
95
+ }) | undefined;
95
96
  productList?: ({
96
97
  description?: string | undefined;
97
98
  name?: string | undefined;
98
99
  public?: boolean | undefined;
99
100
  title?: string | undefined;
100
- type?: string | undefined;
101
+ type?: ("wish_list" | "gift_registry" | "shopping_list" | "custom_1" | "custom_2" | "custom_3") | undefined;
101
102
  } & {
102
103
  [key: string]: any;
103
104
  }) | undefined;
104
105
  public?: boolean | undefined;
105
106
  purchasedQuantity?: number | undefined;
106
107
  quantity?: number | undefined;
107
- type?: string | undefined;
108
- } | undefined;
108
+ type?: ("product" | "gift_certificate") | undefined;
109
+ } & {
110
+ [key: string]: any;
111
+ }) | undefined;
109
112
  productName?: string | undefined;
110
113
  quantity?: number | undefined;
111
114
  shipmentId?: string | undefined;
@@ -123,21 +126,20 @@ export declare function useShopperBasketsMutationHelper(): {
123
126
  amount?: number | undefined;
124
127
  percentage?: number | undefined;
125
128
  priceBookId?: string | undefined;
126
- type: string;
129
+ type: "percentage" | "fixed_price" | "amount" | "free" | "price_book_price" | "bonus" | "total_fixed_price" | "bonus_choice" | "percentage_off_options";
127
130
  } & {
128
131
  [key: string]: any;
129
132
  }) | undefined;
130
133
  couponCode?: string | undefined;
131
134
  createdBy?: string | undefined;
132
- creationDate?: any;
135
+ creationDate?: string | undefined;
133
136
  custom?: boolean | undefined;
134
137
  itemText?: string | undefined;
135
- lastModified?: any;
138
+ lastModified?: string | undefined;
136
139
  manual?: boolean | undefined;
137
140
  price?: number | undefined;
138
141
  priceAdjustmentId?: string | undefined;
139
142
  promotionId?: string | undefined;
140
- promotionLink?: string | undefined;
141
143
  reasonCode?: string | undefined;
142
144
  } & {
143
145
  [key: string]: any;
@@ -145,30 +147,35 @@ export declare function useShopperBasketsMutationHelper(): {
145
147
  priceAfterItemDiscount?: number | undefined;
146
148
  priceAfterOrderDiscount?: number | undefined;
147
149
  productId?: string | undefined;
148
- productListItem?: {
150
+ productListItem?: ({
149
151
  id: string;
150
152
  priority?: number | undefined;
151
- productDetailsLink?: {
153
+ productDetailsLink?: ({
152
154
  productDescription?: string | undefined;
153
155
  productId: string;
154
156
  productName?: string | undefined;
155
157
  title?: string | undefined;
156
- } | undefined;
158
+ } & {
159
+ [key: string]: any;
160
+ }) | undefined;
157
161
  productList?: ({
158
162
  description?: string | undefined;
159
163
  name?: string | undefined;
160
164
  public?: boolean | undefined;
161
165
  title?: string | undefined;
162
- type?: string | undefined;
166
+ type?: ("wish_list" | "gift_registry" | "shopping_list" | "custom_1" | "custom_2" | "custom_3") | undefined;
163
167
  } & {
164
168
  [key: string]: any;
165
169
  }) | undefined;
166
170
  public?: boolean | undefined;
167
171
  purchasedQuantity?: number | undefined;
168
172
  quantity?: number | undefined;
169
- type?: string | undefined;
170
- } | undefined;
173
+ type?: ("product" | "gift_certificate") | undefined;
174
+ } & {
175
+ [key: string]: any;
176
+ }) | undefined;
171
177
  productName?: string | undefined;
178
+ qualifyingProductItemId?: string | undefined;
172
179
  quantity?: number | undefined;
173
180
  shipmentId?: string | undefined;
174
181
  shippingItemId?: string | undefined;
@@ -178,7 +185,11 @@ export declare function useShopperBasketsMutationHelper(): {
178
185
  taxRate?: number | undefined;
179
186
  } & {
180
187
  [key: string]: any;
181
- })[]) => Promise<Basket>;
188
+ })[] & {
189
+ [x: `c_${string}`]: string | number | boolean | string[] | number[] | {
190
+ [key: string]: unknown;
191
+ };
192
+ }) => Promise<Basket>;
182
193
  };
183
194
  export {};
184
195
  //# sourceMappingURL=helpers.d.ts.map