@shopgate/pwa-common 7.30.0-alpha.7 → 7.30.0-alpha.9
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/App.js +48 -6
- package/action-creators/app/index.js +75 -12
- package/action-creators/app/spec.js +96 -1
- package/action-creators/client/index.js +27 -5
- package/action-creators/client/spec.js +44 -1
- package/action-creators/error/index.js +15 -3
- package/action-creators/index.js +9 -1
- package/action-creators/menu/index.js +23 -4
- package/action-creators/menu/spec.js +37 -1
- package/action-creators/modal/index.js +15 -3
- package/action-creators/modal/spec.js +26 -1
- package/action-creators/page/index.js +24 -4
- package/action-creators/page/spec.js +38 -1
- package/action-creators/router/index.js +48 -7
- package/action-creators/url/index.js +24 -4
- package/action-creators/url/spec.js +45 -1
- package/action-creators/user/index.js +90 -13
- package/action-creators/user/spec.js +186 -2
- package/actions/app/handleDeepLink.js +11 -2
- package/actions/app/handleLink.js +62 -6
- package/actions/app/handlePushNotification.js +32 -4
- package/actions/app/handleUniversalLink.js +11 -2
- package/actions/app/registerLinkEvents.js +24 -3
- package/actions/client/fetchClientInformation.js +26 -2
- package/actions/menu/fetchMenu.js +23 -2
- package/actions/modal/closeModal.js +18 -2
- package/actions/modal/promiseMap.js +3 -1
- package/actions/modal/showModal.js +54 -8
- package/actions/page/fetchPageConfig.js +69 -2
- package/actions/page/getPageConfig.js +6 -2
- package/actions/page/index.js +1 -1
- package/actions/router/historyPop.js +12 -2
- package/actions/router/historyPopToRoute.js +27 -2
- package/actions/router/historyPush.js +12 -2
- package/actions/router/historyRedirect.js +21 -2
- package/actions/router/historyReplace.js +20 -3
- package/actions/router/historyReset.js +11 -2
- package/actions/router/historyResetTo.js +12 -2
- package/actions/router/index.js +17 -1
- package/actions/router/routeDidPop.js +11 -2
- package/actions/router/routeDidPush.js +13 -2
- package/actions/router/routeDidReplace.js +11 -2
- package/actions/router/routeDidReset.js +11 -2
- package/actions/router/routeDidUpdate.js +10 -2
- package/actions/router/routeWillPop.js +11 -2
- package/actions/router/routeWillPush.js +13 -2
- package/actions/router/routeWillReplace.js +11 -2
- package/actions/router/routeWillReset.js +11 -2
- package/actions/router/windowOpenOverride.js +10 -2
- package/actions/user/fetchRegisterUrl.js +36 -2
- package/actions/user/fetchUser.js +29 -3
- package/actions/user/getUser.js +6 -2
- package/actions/user/index.js +1 -1
- package/actions/user/login.js +76 -9
- package/actions/user/logout.js +30 -2
- package/collections/AuthRoutes.js +73 -14
- package/collections/Configuration.js +54 -7
- package/collections/EmbeddedMedia.js +84 -11
- package/collections/PersistedReducers.js +41 -6
- package/collections/Redirects.js +103 -17
- package/collections/index.js +5 -1
- package/collections/media-providers/MediaProvider.js +151 -26
- package/collections/media-providers/Vimeo.js +113 -19
- package/collections/media-providers/YouTube.js +74 -14
- package/collections/media-providers/index.js +3 -1
- package/collections/media-providers/style.js +52 -2
- package/components/Backdrop/index.js +95 -6
- package/components/Backdrop/spec.js +23 -1
- package/components/Backdrop/style.js +11 -2
- package/components/Button/index.js +47 -5
- package/components/Button/spec.js +36 -1
- package/components/Button/style.js +6 -1
- package/components/Checkbox/index.js +126 -32
- package/components/Checkbox/spec.js +94 -3
- package/components/Consume/helpers/buildParams.js +13 -2
- package/components/Consume/index.js +14 -2
- package/components/CountdownTimer/index.js +115 -17
- package/components/CountdownTimer/spec.js +126 -12
- package/components/Drawer/index.js +131 -16
- package/components/Drawer/spec.js +76 -1
- package/components/Drawer/style.js +37 -1
- package/components/Dropdown/index.js +65 -6
- package/components/Dropdown/style.js +4 -1
- package/components/Dropdown/transitions.js +34 -1
- package/components/Ellipsis/index.js +16 -2
- package/components/Ellipsis/spec.js +13 -1
- package/components/EmbeddedMedia/index.js +56 -6
- package/components/EmbeddedMedia/spec.js +52 -3
- package/components/ErrorBoundary/connector.js +9 -2
- package/components/ErrorBoundary/index.js +43 -7
- package/components/Grid/components/Item/index.js +40 -4
- package/components/Grid/components/Item/spec.js +23 -1
- package/components/Grid/components/Item/style.js +17 -3
- package/components/Grid/index.js +36 -4
- package/components/Grid/spec.js +23 -1
- package/components/Grid/style.js +11 -2
- package/components/HtmlSanitizer/connector.js +24 -3
- package/components/HtmlSanitizer/index.js +104 -12
- package/components/HtmlSanitizer/spec.js +214 -7
- package/components/I18n/components/FormatDate/index.js +26 -2
- package/components/I18n/components/FormatDate/spec.js +46 -1
- package/components/I18n/components/FormatNumber/index.js +34 -2
- package/components/I18n/components/FormatNumber/spec.js +41 -2
- package/components/I18n/components/FormatPrice/index.js +32 -2
- package/components/I18n/components/FormatPrice/spec.js +46 -1
- package/components/I18n/components/FormatTime/index.js +26 -2
- package/components/I18n/components/FormatTime/spec.js +43 -2
- package/components/I18n/components/I18nProvider/index.js +52 -9
- package/components/I18n/components/I18nProvider/spec.js +39 -1
- package/components/I18n/components/Placeholder/index.js +8 -2
- package/components/I18n/components/Placeholder/spec.js +30 -1
- package/components/I18n/components/Translate/index.js +68 -7
- package/components/I18n/components/Translate/spec.js +30 -1
- package/components/I18n/index.js +16 -1
- package/components/Icon/index.js +25 -2
- package/components/Icon/style.js +6 -1
- package/components/Image/Image.js +176 -19
- package/components/Image/ImageInner.js +48 -2
- package/components/Image/index.js +1 -1
- package/components/Image/style.js +29 -2
- package/components/InfiniteContainer/index.js +381 -49
- package/components/InfiniteContainer/spec.js +199 -10
- package/components/Input/components/DateInput.js +262 -6
- package/components/Input/components/MultiLineInput.js +98 -12
- package/components/Input/components/SimpleInput.js +207 -31
- package/components/Input/index.js +32 -3
- package/components/Input/spec.js +122 -1
- package/components/KeyboardConsumer/index.js +48 -7
- package/components/Link/connector.js +7 -1
- package/components/Link/index.js +96 -11
- package/components/Link/spec.js +56 -1
- package/components/Link/style.js +10 -1
- package/components/List/components/Item/index.js +35 -3
- package/components/List/components/Item/style.js +16 -1
- package/components/List/index.js +20 -2
- package/components/List/spec.js +31 -1
- package/components/Loading/index.js +6 -2
- package/components/Modal/index.js +38 -3
- package/components/Modal/style.js +36 -1
- package/components/ModalContainer/connector.js +17 -3
- package/components/ModalContainer/index.js +36 -3
- package/components/ModalContainer/spec.js +105 -5
- package/components/Picker/components/Button/index.js +34 -2
- package/components/Picker/components/Button/style.js +19 -1
- package/components/Picker/components/List/index.js +33 -2
- package/components/Picker/components/List/style.js +17 -1
- package/components/Picker/components/Modal/index.js +60 -7
- package/components/Picker/components/Modal/style.js +78 -1
- package/components/Picker/index.js +167 -21
- package/components/Picker/spec.js +83 -2
- package/components/Portal/index.js +130 -19
- package/components/ProductCharacteristics/connector.js +33 -4
- package/components/ProductCharacteristics/context.js +2 -1
- package/components/ProductCharacteristics/helpers/index.js +135 -21
- package/components/ProductCharacteristics/index.js +266 -31
- package/components/RangeSlider/components/Handle/index.js +25 -2
- package/components/RangeSlider/components/Handle/style.js +14 -1
- package/components/RangeSlider/helper.js +43 -8
- package/components/RangeSlider/index.js +228 -38
- package/components/RangeSlider/style.js +14 -1
- package/components/Route/RouteNotFound.js +46 -3
- package/components/Route/index.js +78 -10
- package/components/Router/connector.js +9 -2
- package/components/Router/index.js +237 -31
- package/components/ScannerContainer/connector.js +9 -2
- package/components/ScannerContainer/index.js +42 -6
- package/components/Select/components/Item/index.js +20 -4
- package/components/Select/components/Item/style.js +4 -1
- package/components/Select/index.js +149 -28
- package/components/Select/spec.js +86 -2
- package/components/Select/style.js +17 -1
- package/components/SelectBox/components/Item/index.js +47 -5
- package/components/SelectBox/components/Item/style.js +7 -1
- package/components/SelectBox/index.js +173 -17
- package/components/SelectBox/spec.js +59 -3
- package/components/SelectBox/style.js +18 -1
- package/components/Slider/index.js +6 -2
- package/components/SurroundPortals/index.js +26 -2
- package/components/Swiper/components/SwiperItem/index.js +28 -4
- package/components/Swiper/components/SwiperItem/spec.js +21 -1
- package/components/Swiper/components/SwiperItem/styles.js +5 -1
- package/components/Swiper/index.js +210 -18
- package/components/Swiper/styles.js +75 -7
- package/components/Toaster/index.js +10 -2
- package/components/Transition/index.js +89 -13
- package/components/Widgets/components/Widget/index.js +52 -4
- package/components/Widgets/components/Widget/spec.js +68 -3
- package/components/Widgets/components/Widget/style.js +21 -3
- package/components/Widgets/components/WidgetGrid/index.js +52 -7
- package/components/Widgets/components/WidgetGrid/spec.js +46 -2
- package/components/Widgets/components/WidgetGrid/style.js +8 -1
- package/components/Widgets/helpers/shouldShowWidget.js +44 -7
- package/components/Widgets/index.js +127 -15
- package/components/Widgets/spec.js +228 -6
- package/components/index.js +9 -1
- package/constants/ActionTypes.js +97 -19
- package/constants/Configuration.js +12 -2
- package/constants/Device.js +29 -2
- package/constants/DisplayOptions.js +8 -1
- package/constants/MenuIDs.js +2 -1
- package/constants/ModalTypes.js +1 -1
- package/constants/PageIDs.js +1 -1
- package/constants/Pipelines.js +7 -1
- package/constants/Portals.js +136 -3
- package/constants/Registration.js +3 -1
- package/constants/RoutePaths.js +13 -2
- package/constants/Tracking.js +3 -1
- package/constants/client.js +6 -1
- package/constants/ui.js +2 -1
- package/constants/user.js +6 -2
- package/context/index.js +33 -3
- package/helpers/config/index.js +139 -21
- package/helpers/config/mock.js +200 -8
- package/helpers/config/theme.js +50 -4
- package/helpers/data/index.js +204 -29
- package/helpers/data/spec.js +187 -7
- package/helpers/date/index.js +58 -6
- package/helpers/date/spec.js +92 -1
- package/helpers/dom/index.js +48 -11
- package/helpers/environment/index.js +14 -2
- package/helpers/html/decodeHTML.js +7 -1
- package/helpers/html/handleDOM.js +172 -21
- package/helpers/html/parseHTML.js +67 -12
- package/helpers/i18n/getDateFormatter.js +23 -4
- package/helpers/i18n/getNumberFormatter.js +32 -4
- package/helpers/i18n/getPriceFormatter.js +38 -4
- package/helpers/i18n/getTimeFormatter.js +23 -4
- package/helpers/i18n/getTranslator.js +62 -8
- package/helpers/i18n/index.js +5 -1
- package/helpers/i18n/mergeTranslations.js +36 -9
- package/helpers/i18n/messageCache.js +3 -1
- package/helpers/legacy/index.js +47 -9
- package/helpers/modal/withShowModal.js +13 -2
- package/helpers/portals/portalCollection.js +28 -6
- package/helpers/portals/routePortals.js +12 -1
- package/helpers/redux/compareObjects.js +7 -2
- package/helpers/redux/generateResultHash.js +36 -3
- package/helpers/redux/generateSortedHash.js +7 -2
- package/helpers/redux/hasExpired.js +10 -2
- package/helpers/redux/index.js +7 -1
- package/helpers/redux/mutable.js +143 -24
- package/helpers/redux/shouldFetchData.js +46 -10
- package/helpers/redux/shouldFetchFilters.js +17 -4
- package/helpers/router/index.js +49 -5
- package/helpers/style/index.js +43 -4
- package/helpers/style/spec.js +108 -2
- package/helpers/tracking/index.js +52 -9
- package/helpers/validation/index.js +39 -12
- package/helpers/validation/spec.js +10 -1
- package/package.json +3 -4
- package/providers/index.js +4 -1
- package/providers/loading/context.js +2 -1
- package/providers/loading/index.js +137 -22
- package/providers/toast/context.js +2 -1
- package/providers/toast/index.js +105 -11
- package/reducers/client/connectivity.js +22 -2
- package/reducers/client/index.js +7 -1
- package/reducers/client/info.js +27 -2
- package/reducers/index.js +23 -4
- package/reducers/menu/index.js +5 -1
- package/reducers/menu/menusById.js +41 -2
- package/reducers/modal/index.js +14 -2
- package/reducers/page/index.js +68 -5
- package/reducers/router/index.js +48 -2
- package/reducers/url/index.js +42 -3
- package/reducers/user/data.js +27 -2
- package/reducers/user/index.js +7 -1
- package/reducers/user/login.js +65 -2
- package/selectors/client.js +138 -21
- package/selectors/history.js +49 -11
- package/selectors/menu.js +34 -6
- package/selectors/modal.js +15 -4
- package/selectors/page.js +25 -4
- package/selectors/router.js +154 -30
- package/selectors/url.js +25 -4
- package/selectors/user.js +90 -13
- package/store/index.js +60 -6
- package/store/middelwares/logger.js +7 -1
- package/store/middelwares/streams.js +19 -2
- package/streams/app.js +60 -8
- package/streams/client.js +8 -2
- package/streams/error.js +14 -3
- package/streams/index.js +6 -1
- package/streams/interval.js +6 -2
- package/streams/main.js +27 -2
- package/streams/router.js +45 -8
- package/streams/user.js +89 -15
- package/streams/view.js +97 -25
- package/styles/reset/form.js +57 -5
- package/styles/reset/index.js +6 -1
- package/styles/reset/media.js +22 -1
- package/styles/reset/root.js +33 -1
- package/styles/reset/table.js +10 -1
- package/styles/reset/typography.js +26 -1
- package/subscriptions/app.js +148 -17
- package/subscriptions/error.js +292 -13
- package/subscriptions/helpers/buildRegisterUrl.js +25 -6
- package/subscriptions/helpers/clearUpInAppBrowser.js +14 -3
- package/subscriptions/helpers/handleLinks.js +267 -25
- package/subscriptions/helpers/pipeline.js +12 -1
- package/subscriptions/history.js +34 -6
- package/subscriptions/index.js +25 -4
- package/subscriptions/menu.js +22 -5
- package/subscriptions/mock.js +39 -7
- package/subscriptions/router.js +336 -23
- package/subscriptions/user.js +93 -3
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import{ACTION_REPLACE}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_REPLACE } from '@virtuous/conductor';
|
|
2
|
+
import * as actions from "../../action-creators/router";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {Route} prev The previous route.
|
|
3
6
|
* @param {Route} next The next route.
|
|
4
7
|
* @returns {Function}
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export function routeWillReplace(prev, next) {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
dispatch(actions.routeWillLeave(prev, ACTION_REPLACE));
|
|
12
|
+
dispatch(actions.routeWillEnter(next, ACTION_REPLACE));
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import{ACTION_RESET}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_RESET } from '@virtuous/conductor';
|
|
2
|
+
import * as actions from "../../action-creators/router";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {Route} prev The previous route.
|
|
3
6
|
* @param {Route} next The next route.
|
|
4
7
|
* @returns {Function}
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export function routeWillReset(prev, next) {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
dispatch(actions.routeWillLeave(prev, ACTION_RESET));
|
|
12
|
+
dispatch(actions.routeWillEnter(next, ACTION_RESET));
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import{WINDOW_OPEN_OVERRIDE}from"../../constants/ActionTypes"
|
|
1
|
+
import { WINDOW_OPEN_OVERRIDE } from "../../constants/ActionTypes";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Indicates a call to window.open e.g. invoked by an external SDK.
|
|
3
5
|
*
|
|
4
6
|
* @param {Object} params Action params
|
|
5
7
|
* @param {string} params.pathname The pathname window.open was called with
|
|
6
8
|
* @returns {Object}
|
|
7
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
export const windowOpenOverride = ({
|
|
11
|
+
pathname
|
|
12
|
+
}) => ({
|
|
13
|
+
type: WINDOW_OPEN_OVERRIDE,
|
|
14
|
+
pathname
|
|
15
|
+
});
|
|
@@ -1,4 +1,38 @@
|
|
|
1
|
-
import{PipelineRequest}from'@shopgate/pwa-core';
|
|
1
|
+
import { PipelineRequest } from '@shopgate/pwa-core';
|
|
2
|
+
import { requestUrl, receiveUrl, errorUrl } from "../../action-creators/url";
|
|
3
|
+
import { SHOPGATE_USER_GET_REGISTRATION_URL } from "../../constants/Pipelines";
|
|
4
|
+
import { URL_TYPE_REGISTER } from "../../constants/Registration";
|
|
5
|
+
import { shouldFetchData, mutable } from "../../helpers/redux";
|
|
6
|
+
import { getEntryByType } from "../../selectors/url";
|
|
7
|
+
import { getRegisterUrl } from "../../selectors/user";
|
|
8
|
+
|
|
9
|
+
/**
|
|
2
10
|
* Get the url for the registration.
|
|
3
11
|
* @return {Function} A redux thunk.
|
|
4
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
function fetchRegisterUrl() {
|
|
14
|
+
return (dispatch, getState) => new Promise((resolve, reject) => {
|
|
15
|
+
const state = getState();
|
|
16
|
+
const entry = getEntryByType(state, {
|
|
17
|
+
type: URL_TYPE_REGISTER
|
|
18
|
+
});
|
|
19
|
+
if (!shouldFetchData(entry, 'url')) {
|
|
20
|
+
resolve(getRegisterUrl(state));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
dispatch(requestUrl(URL_TYPE_REGISTER));
|
|
24
|
+
new PipelineRequest(SHOPGATE_USER_GET_REGISTRATION_URL).setTrusted().dispatch().then(({
|
|
25
|
+
url,
|
|
26
|
+
expires
|
|
27
|
+
}) => {
|
|
28
|
+
dispatch(receiveUrl(URL_TYPE_REGISTER, url, expires));
|
|
29
|
+
resolve(url);
|
|
30
|
+
}).catch(() => {
|
|
31
|
+
dispatch(errorUrl(URL_TYPE_REGISTER));
|
|
32
|
+
reject();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @mixes {MutableFunction} */
|
|
38
|
+
export default mutable(fetchRegisterUrl);
|
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
import{PipelineRequest,EACCESS}from'@shopgate/pwa-core';
|
|
1
|
+
import { PipelineRequest, EACCESS } from '@shopgate/pwa-core';
|
|
2
|
+
import { requestUser, receiveUser, errorUser, toggleLoggedIn } from "../../action-creators/user";
|
|
3
|
+
import { SHOPGATE_USER_GET_USER } from "../../constants/Pipelines";
|
|
4
|
+
import { mutable } from "../../helpers/redux";
|
|
5
|
+
import { isUserLoggedIn } from "../../selectors/user";
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* Get the current user
|
|
3
9
|
* @return {Function} A redux thunk.
|
|
4
|
-
*/
|
|
5
|
-
|
|
10
|
+
*/
|
|
11
|
+
function fetchUser() {
|
|
12
|
+
return (dispatch, getState) => {
|
|
13
|
+
dispatch(requestUser());
|
|
14
|
+
const request = new PipelineRequest(SHOPGATE_USER_GET_USER).setTrusted().setErrorBlacklist([EACCESS]).dispatch();
|
|
15
|
+
request.then(user => {
|
|
16
|
+
dispatch(receiveUser(user));
|
|
17
|
+
|
|
18
|
+
// If the user's login state was incorrectly set false then set to true.
|
|
19
|
+
if (!isUserLoggedIn(getState())) {
|
|
20
|
+
dispatch(toggleLoggedIn(true));
|
|
21
|
+
}
|
|
22
|
+
}).catch(error => {
|
|
23
|
+
dispatch(toggleLoggedIn(false));
|
|
24
|
+
dispatch(errorUser(error));
|
|
25
|
+
});
|
|
26
|
+
return request;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** @mixes {MutableFunction} */
|
|
31
|
+
export default mutable(fetchUser);
|
package/actions/user/getUser.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import fetchUser from"./fetchUser"
|
|
1
|
+
import fetchUser from "./fetchUser";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Get the current user
|
|
3
5
|
* @return {Function} A redux thunk.
|
|
4
6
|
* @deprecated Will be removed in the near future. Use fetchUser instead.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const getUser = fetchUser;
|
|
9
|
+
export default getUser;
|
package/actions/user/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as fetchUser}from"./fetchUser";
|
|
1
|
+
export { default as fetchUser } from "./fetchUser";
|
package/actions/user/login.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PipelineRequest, EINVALIDCALL, ELEGACYSGCONNECT, EINCOMPLETELOGIN } from '@shopgate/pwa-core';
|
|
2
|
+
import { requestLogin, successLogin, errorLogin, errorLegacyConnectRegister } from "../../action-creators/user";
|
|
3
|
+
import { SHOPGATE_USER_LOGIN_USER } from "../../constants/Pipelines";
|
|
4
|
+
import { DEFAULT_LOGIN_STRATEGY } from "../../constants/user";
|
|
5
|
+
import { mutable } from "../../helpers/redux";
|
|
6
|
+
import appConfig from "../../helpers/config";
|
|
7
|
+
|
|
8
|
+
/**
|
|
2
9
|
* Login the current user.
|
|
3
10
|
* @param {Object} parameters The login credentials.
|
|
4
11
|
* @param {string} parameters.login The username to login.
|
|
@@ -6,11 +13,71 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){
|
|
|
6
13
|
* @param {string} redirect The location to redirect to when logged in.
|
|
7
14
|
* @param {string} strategy basic or facebook, amazon, etc
|
|
8
15
|
* @return {Function} A redux thunk.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
*/
|
|
17
|
+
function login(parameters, redirect, strategy = DEFAULT_LOGIN_STRATEGY) {
|
|
18
|
+
return async dispatch => {
|
|
19
|
+
const {
|
|
20
|
+
enabled: recaptchaEnabled,
|
|
21
|
+
googleCloudSiteKey
|
|
22
|
+
} = appConfig?.recaptcha || {};
|
|
23
|
+
dispatch(requestLogin(parameters.login, parameters.password, strategy));
|
|
24
|
+
let recaptchaToken;
|
|
25
|
+
if (recaptchaEnabled && googleCloudSiteKey) {
|
|
26
|
+
try {
|
|
27
|
+
// Add a reCAPTCHA token to the login request when feature is configured
|
|
28
|
+
await new Promise(resolve => window.grecaptcha.enterprise.ready(resolve));
|
|
29
|
+
recaptchaToken = await window.grecaptcha.enterprise.execute(googleCloudSiteKey, {
|
|
30
|
+
action: 'login'
|
|
31
|
+
});
|
|
32
|
+
} catch (e) {
|
|
33
|
+
// noting to do here - just for protection
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const request = new PipelineRequest(SHOPGATE_USER_LOGIN_USER).setTrusted().setErrorBlacklist([EINVALIDCALL, ELEGACYSGCONNECT, EINCOMPLETELOGIN]).setInput({
|
|
37
|
+
strategy,
|
|
38
|
+
parameters: {
|
|
39
|
+
...parameters,
|
|
40
|
+
...(recaptchaToken ? {
|
|
41
|
+
recaptchaToken
|
|
42
|
+
} : null)
|
|
43
|
+
}
|
|
44
|
+
}).dispatch();
|
|
45
|
+
request.then(result => {
|
|
46
|
+
const {
|
|
47
|
+
success,
|
|
48
|
+
messages,
|
|
49
|
+
sessionLifetimeInSeconds
|
|
50
|
+
} = result;
|
|
51
|
+
if (success) {
|
|
52
|
+
dispatch(successLogin(redirect, strategy, sessionLifetimeInSeconds));
|
|
53
|
+
} else {
|
|
54
|
+
dispatch(errorLogin(messages));
|
|
55
|
+
}
|
|
56
|
+
}).catch(error => {
|
|
57
|
+
const {
|
|
58
|
+
code
|
|
59
|
+
} = error;
|
|
60
|
+
if (code === EINVALIDCALL) {
|
|
61
|
+
/**
|
|
62
|
+
* This code is thrown when the login request failed, because the user was already logged
|
|
63
|
+
* in. In that situation the success action can also dispatch to trigger the necessary
|
|
64
|
+
* processes which has to happen after a successful login.
|
|
65
|
+
*/
|
|
66
|
+
dispatch(successLogin(redirect, strategy));
|
|
67
|
+
} else if (code === ELEGACYSGCONNECT) {
|
|
68
|
+
/**
|
|
69
|
+
* The app is connected to the shop system via the legacy shopgate connect. Login via
|
|
70
|
+
* the shop system credentials failed and further steps are necessary to login the user.
|
|
71
|
+
*/
|
|
72
|
+
dispatch(errorLegacyConnectRegister());
|
|
73
|
+
dispatch(errorLogin([], ELEGACYSGCONNECT));
|
|
74
|
+
} else {
|
|
75
|
+
dispatch(errorLogin([], code));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return request;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** @mixes {MutableFunction} */
|
|
83
|
+
export default mutable(login);
|
package/actions/user/logout.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
|
-
import{PipelineRequest}from'@shopgate/pwa-core';
|
|
1
|
+
import { PipelineRequest } from '@shopgate/pwa-core';
|
|
2
|
+
import { requestLogout, successLogout, errorLogout } from "../../action-creators/user";
|
|
3
|
+
import { SHOPGATE_USER_LOGOUT_USER } from "../../constants/Pipelines";
|
|
4
|
+
import { mutable } from "../../helpers/redux";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* Logout the current user.
|
|
3
8
|
* @param {boolean} [notify=true] If set to TRUE users are notified when the logout was successful.
|
|
4
9
|
* @param {boolean} [autoLogout=false] Whether the logout happened because session expired
|
|
5
10
|
* @return {Function} A redux thunk.
|
|
6
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
function logout(notify = true, autoLogout = false) {
|
|
13
|
+
return dispatch => {
|
|
14
|
+
dispatch(requestLogout());
|
|
15
|
+
const request = new PipelineRequest(SHOPGATE_USER_LOGOUT_USER).setTrusted().dispatch();
|
|
16
|
+
request.then(result => {
|
|
17
|
+
const {
|
|
18
|
+
success,
|
|
19
|
+
messages
|
|
20
|
+
} = result;
|
|
21
|
+
if (success) {
|
|
22
|
+
dispatch(successLogout(notify, autoLogout));
|
|
23
|
+
} else {
|
|
24
|
+
dispatch(errorLogout(messages, autoLogout));
|
|
25
|
+
}
|
|
26
|
+
}).catch(() => {
|
|
27
|
+
dispatch(errorLogout(undefined, autoLogout));
|
|
28
|
+
});
|
|
29
|
+
return request;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** @mixes {MutableFunction} */
|
|
34
|
+
export default mutable(logout);
|
|
@@ -1,34 +1,93 @@
|
|
|
1
|
-
|
|
1
|
+
import pathMatch from 'path-match';
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Class to maintain the routes that should be protected by authentication.
|
|
3
|
-
*/
|
|
5
|
+
*/
|
|
6
|
+
class AuthRoutes {
|
|
7
|
+
/**
|
|
4
8
|
* Constructor
|
|
5
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
constructor() {
|
|
11
|
+
this.routes = new Map();
|
|
12
|
+
this.matcher = pathMatch({
|
|
13
|
+
sensitive: false,
|
|
14
|
+
strict: false,
|
|
15
|
+
end: true
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
6
20
|
* Finds a particular protected route.
|
|
7
21
|
* @param {string} pattern The pattern to find.
|
|
8
22
|
* @return {string|null}
|
|
9
|
-
*/
|
|
23
|
+
*/
|
|
24
|
+
get(pattern) {
|
|
25
|
+
return this.routes.get(pattern) || null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
10
29
|
* Returns all protected routes.
|
|
11
30
|
* @return {Map}
|
|
12
|
-
*/
|
|
31
|
+
*/
|
|
32
|
+
getAll() {
|
|
33
|
+
return this.routes;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
13
37
|
* Sets a new route as protected.
|
|
14
38
|
* @param {string} civilian The route to protect.
|
|
15
39
|
* @param {string} bouncer The protector route.
|
|
16
|
-
*/
|
|
40
|
+
*/
|
|
41
|
+
set(civilian, bouncer) {
|
|
42
|
+
if (!civilian || !bouncer) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.routes.set(civilian, bouncer);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
17
49
|
* Check if the given pathname is a protector route.
|
|
18
50
|
* @param {string} location The location to check.
|
|
19
51
|
* @return {boolean}
|
|
20
|
-
*/
|
|
52
|
+
*/
|
|
53
|
+
isProtector(location) {
|
|
54
|
+
return Array.from(this.routes.values()).includes(location);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
21
58
|
* Returns the protector for a passed location.
|
|
22
59
|
* @param {string} location The location to check.
|
|
23
60
|
* @return {string|null}
|
|
24
|
-
*/
|
|
61
|
+
*/
|
|
62
|
+
getProtector(location) {
|
|
63
|
+
/**
|
|
25
64
|
* Try to make a direct match with the location.
|
|
26
65
|
* If we get lucky then we don't have to iterate over the protected patterns.
|
|
27
|
-
*/
|
|
66
|
+
*/
|
|
67
|
+
let protector = this.get(location);
|
|
68
|
+
|
|
69
|
+
/**
|
|
28
70
|
* If we didn't find a direct match then we need to match
|
|
29
71
|
* the given location against the protected patters.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
72
|
+
*/
|
|
73
|
+
if (!protector) {
|
|
74
|
+
// Get the protected patterns as an array.
|
|
75
|
+
const patterns = Array.from(this.routes.keys());
|
|
76
|
+
const [locationWithoutParams] = location.split('?');
|
|
77
|
+
|
|
78
|
+
// Loop over the patterns until a match is found.
|
|
79
|
+
patterns.some(pattern => {
|
|
80
|
+
// Check for a match.
|
|
81
|
+
const match = this.matcher(pattern)(locationWithoutParams);
|
|
82
|
+
|
|
83
|
+
// Match found, set the protector.
|
|
84
|
+
if (match) {
|
|
85
|
+
protector = this.routes.get(pattern);
|
|
86
|
+
}
|
|
87
|
+
return match;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return protector;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export default new AuthRoutes();
|
|
@@ -1,21 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
import logGroup from '@shopgate/pwa-core/helpers/logGroup';
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Class to maintain different configurations
|
|
3
|
-
*/
|
|
5
|
+
*/
|
|
6
|
+
class Configuration {
|
|
7
|
+
/**
|
|
4
8
|
* Constructor
|
|
5
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
constructor() {
|
|
11
|
+
this.store = new Map();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
6
15
|
* Get a config value
|
|
7
16
|
* @param {*} key config key
|
|
8
17
|
* @param {*} defaultValue defaultValue
|
|
9
18
|
* @returns {*|undefined}
|
|
10
|
-
*/
|
|
19
|
+
*/
|
|
20
|
+
get(key, defaultValue) {
|
|
21
|
+
return this.store.get(key) || defaultValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
11
25
|
* Sets a configuration.
|
|
12
26
|
* @param {*} key key
|
|
13
27
|
* @param {*} value value
|
|
14
28
|
* @returns {Configuration}
|
|
15
|
-
*/
|
|
29
|
+
*/
|
|
30
|
+
set(key, value) {
|
|
31
|
+
this.store.set(key, value);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
16
36
|
* Update config with given callback function
|
|
17
37
|
* @param {*} key key
|
|
18
38
|
* @param {Function} updater function to update value
|
|
19
39
|
* @returns {Configuration}
|
|
20
|
-
*/
|
|
21
|
-
|
|
40
|
+
*/
|
|
41
|
+
update(key, updater) {
|
|
42
|
+
if (!this.store.has(key)) {
|
|
43
|
+
logGroup('CONFIGURATION%c not found', {
|
|
44
|
+
key
|
|
45
|
+
}, '#e0061e');
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
if (typeof updater !== 'function') {
|
|
49
|
+
logGroup('CONFIGURATION%c updater is not function', {
|
|
50
|
+
key
|
|
51
|
+
}, '#e0061e');
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
const prevValue = this.store.get(key);
|
|
55
|
+
const newValue = updater(this.store.get(key));
|
|
56
|
+
|
|
57
|
+
// eslint-disable-next-line extra-rules/no-single-line-objects
|
|
58
|
+
logGroup('CONFIGURATION%c changed', {
|
|
59
|
+
key,
|
|
60
|
+
prevValue,
|
|
61
|
+
newValue
|
|
62
|
+
}, '#069215');
|
|
63
|
+
return this.set(key, newValue);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** @type {Configuration} */
|
|
68
|
+
export default new Configuration();
|
|
@@ -1,21 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable extra-rules/potential-point-free */
|
|
2
|
+
/**
|
|
2
3
|
* Class to maintain embedded media within DOM containers.
|
|
3
|
-
*/
|
|
4
|
+
*/
|
|
5
|
+
class EmbeddedMedia {
|
|
6
|
+
/**
|
|
4
7
|
* Constructor
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
this.providers = new Set();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
6
14
|
* Add a provider for embedded media.
|
|
7
15
|
* @param {Object} provider A provider instance.
|
|
8
|
-
*/
|
|
16
|
+
*/
|
|
17
|
+
addProvider(provider) {
|
|
18
|
+
this.providers.add(provider);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
9
22
|
* Remove a provider for embedded media.
|
|
10
23
|
* @param {Object} provider A provider instance.
|
|
11
|
-
*/
|
|
24
|
+
*/
|
|
25
|
+
removeProvider(provider) {
|
|
26
|
+
this.providers.delete(provider);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
12
30
|
* Add a DOM container with embedded media.
|
|
13
31
|
* @param {ParentNode} container A DOM container.
|
|
14
|
-
*/
|
|
32
|
+
*/
|
|
33
|
+
add(container) {
|
|
34
|
+
this.providers.forEach(provider => {
|
|
35
|
+
provider.add(container);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
15
40
|
* Remove a DOM container. Should be called whenever a component which hosts a DOM container with
|
|
16
41
|
* embedded media is unmounted.
|
|
17
42
|
* @param {ParentNode} container A DOM container.
|
|
18
|
-
*/
|
|
43
|
+
*/
|
|
44
|
+
remove(container) {
|
|
45
|
+
this.providers.forEach(provider => {
|
|
46
|
+
provider.remove(container);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
19
51
|
* Searches for embedded media and replaces it with a placeholder element when required cookie
|
|
20
52
|
* consent is not accepted.
|
|
21
53
|
* Should be invoked before container content is added to the DOM to fulfill all regulations.
|
|
@@ -25,15 +57,56 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
25
57
|
* are accepted.
|
|
26
58
|
* @param {boolean} [cookieConsentSettings.statisticsCookiesAccepted] Whether statistics cookies
|
|
27
59
|
* are accepted.
|
|
28
|
-
*/
|
|
60
|
+
*/
|
|
61
|
+
handleCookieConsent(container, cookieConsentSettings = {}) {
|
|
62
|
+
const cookieConsent = {
|
|
63
|
+
comfortCookiesAccepted: false,
|
|
64
|
+
statisticsCookiesAccepted: false,
|
|
65
|
+
...cookieConsentSettings
|
|
66
|
+
};
|
|
67
|
+
this.providers.forEach(provider => {
|
|
68
|
+
if (provider.handleCookieConsent) {
|
|
69
|
+
provider.handleCookieConsent(container, cookieConsent);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
29
75
|
* Applies optimizations to embedded media iframes within the given container.
|
|
30
76
|
* Common enhancements include adding responsive wrappers and appropriate
|
|
31
77
|
* sandbox attributes to improve security and layout behavior.
|
|
32
78
|
*
|
|
33
79
|
* @param {Document} document - The DOM document containing iframes to optimize.
|
|
34
|
-
*/
|
|
80
|
+
*/
|
|
81
|
+
applyIframeOptimizations(document) {
|
|
82
|
+
this.providers.forEach(provider => {
|
|
83
|
+
provider.applyIframeOptimizations(document);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
35
88
|
* Stops all playing media within the DOM containers.
|
|
36
|
-
*/
|
|
89
|
+
*/
|
|
90
|
+
stop() {
|
|
91
|
+
this.providers.forEach(provider => {
|
|
92
|
+
provider.stop();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
37
97
|
* Check if we have media providers with not-ready SDK
|
|
38
98
|
* @returns {boolean}
|
|
39
|
-
*/
|
|
99
|
+
*/
|
|
100
|
+
getHasPendingProviders() {
|
|
101
|
+
let hasPendingProviders = false;
|
|
102
|
+
this.providers.forEach(provider => {
|
|
103
|
+
if (provider.isPending) {
|
|
104
|
+
hasPendingProviders = true;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return hasPendingProviders;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export default new EmbeddedMedia();
|
|
111
|
+
|
|
112
|
+
/* eslint-enable extra-rules/potential-point-free */
|
|
@@ -1,16 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
2
|
* Class to maintain the persisted redux reducers.
|
|
3
|
-
*/
|
|
3
|
+
*/
|
|
4
|
+
class PersistedReducers {
|
|
5
|
+
/**
|
|
4
6
|
* Constructor.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
constructor() {
|
|
9
|
+
this.reducers = [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
6
13
|
* Returns all reducers.
|
|
7
14
|
* @return {Array}
|
|
8
|
-
*/
|
|
15
|
+
*/
|
|
16
|
+
getAll() {
|
|
17
|
+
return this.reducers;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
9
21
|
* Sets a new reducers to be persisted.
|
|
10
22
|
* @param {string|Array} reducer The name of the reducer to persist.
|
|
11
23
|
* @return {PersistedReducers}
|
|
12
|
-
*/
|
|
24
|
+
*/
|
|
25
|
+
set(reducer) {
|
|
26
|
+
if (Array.isArray(reducer)) {
|
|
27
|
+
reducer.forEach(red => {
|
|
28
|
+
if (!this.reducers.includes(red)) {
|
|
29
|
+
this.reducers.push(red);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
if (this.reducers.includes(reducer)) {
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
this.reducers.push(reducer);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
13
42
|
* Removes a reducer from the list of persisted reducers.
|
|
14
43
|
* @param {string} reducer The name of the reducer to remove.
|
|
15
44
|
* @return {PersistedReducers}
|
|
16
|
-
*/
|
|
45
|
+
*/
|
|
46
|
+
remove(reducer) {
|
|
47
|
+
this.reducers = this.reducers.filter(red => red !== reducer);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export default new PersistedReducers();
|