@shopgate/pwa-common 6.22.0 → 6.22.1-rc.1

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.
@@ -6,7 +6,8 @@ import{logger}from'@shopgate/pwa-core/helpers';import{historyPush,historyReset}f
6
6
  */export default function handleLink(payload){var allowExternalLinks=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return function(dispatch){var link=payload.link;if(!link){return;}// cast to string
7
7
  link=String(link);var pathname;if(link.startsWith('http')){// Link is common URL schema.
8
8
  if(allowExternalLinks){dispatch(historyPush({pathname:link}));return;}try{var _URL=new URL(link);pathname=_URL.pathname;}catch(linkParseError){logger.error("Could not parse link ".concat(link),linkParseError);}}else{// Remove the deeplink protocol from the link.
9
- pathname=link.replace(/^(.*:)(\/\/)?/,'/');}if(!pathname||pathname===INDEX_PATH||pathname.startsWith(INDEX_PATH_DEEPLINK)){/**
9
+ pathname=link.replace(/^(.*:)(\/\/)?/,'/');if(!pathname.startsWith('/')){// Take care that pathname starts with a slash. Otherwise routing can break
10
+ pathname="/".concat(pathname);}}if(!pathname||pathname===INDEX_PATH||pathname.startsWith(INDEX_PATH_DEEPLINK)){/**
10
11
  * Special treatment for the index page. To avoid multiple index pages within the history,
11
12
  * the parsed link helper will only emit the openLink events for the link to inform the
12
13
  * streams, but not open a real page. Additionally the history is reset.
@@ -1,4 +1,4 @@
1
- import{PipelineRequest,EINVALIDCALL,ELEGACYSGCONNECT,EINCOMPLETELOGIN}from'@shopgate/pwa-core';import{requestLogin,successLogin,errorLogin,errorLegacyConnectRegister}from"../../action-creators/user";import{SHOPGATE_USER_LOGIN_USER}from"../../constants/Pipelines";import{DEFAULT_LOGIN_STRATEGY}from"../../constants/user";import{mutable}from"../../helpers/redux";/**
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{PipelineRequest,EINVALIDCALL,ELEGACYSGCONNECT,EINCOMPLETELOGIN}from'@shopgate/pwa-core';import{requestLogin,successLogin,errorLogin,errorLegacyConnectRegister}from"../../action-creators/user";import{SHOPGATE_USER_LOGIN_USER}from"../../constants/Pipelines";import{DEFAULT_LOGIN_STRATEGY}from"../../constants/user";import{mutable}from"../../helpers/redux";import appConfig from"../../helpers/config";/**
2
2
  * Login the current user.
3
3
  * @param {Object} parameters The login credentials.
4
4
  * @param {string} parameters.login The username to login.
@@ -6,11 +6,11 @@ import{PipelineRequest,EINVALIDCALL,ELEGACYSGCONNECT,EINCOMPLETELOGIN}from'@shop
6
6
  * @param {string} redirect The location to redirect to when logged in.
7
7
  * @param {string} strategy basic or facebook, amazon, etc
8
8
  * @return {Function} A redux thunk.
9
- */function login(parameters,redirect){var strategy=arguments.length>2&&arguments[2]!==undefined?arguments[2]:DEFAULT_LOGIN_STRATEGY;return function(dispatch){dispatch(requestLogin(parameters.login,parameters.password,strategy));var request=new PipelineRequest(SHOPGATE_USER_LOGIN_USER).setTrusted().setErrorBlacklist([EINVALIDCALL,ELEGACYSGCONNECT,EINCOMPLETELOGIN]).setInput({strategy:strategy,parameters:parameters}).dispatch();request.then(function(result){var success=result.success,messages=result.messages;if(success){dispatch(successLogin(redirect,strategy));}else{dispatch(errorLogin(messages));}})["catch"](function(error){var code=error.code;if(code===EINVALIDCALL){/**
9
+ */function login(parameters,redirect){var strategy=arguments.length>2&&arguments[2]!==undefined?arguments[2]:DEFAULT_LOGIN_STRATEGY;return/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _ref2,recaptchaEnabled,googleCloudSiteKey,recaptchaToken,request;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_ref2=(appConfig===null||appConfig===void 0?void 0:appConfig.recaptcha)||{},recaptchaEnabled=_ref2.enabled,googleCloudSiteKey=_ref2.googleCloudSiteKey;dispatch(requestLogin(parameters.login,parameters.password,strategy));if(!(recaptchaEnabled&&googleCloudSiteKey)){_context.next=13;break;}_context.prev=3;_context.next=6;return new Promise(function(resolve){return window.grecaptcha.enterprise.ready(resolve);});case 6:_context.next=8;return window.grecaptcha.enterprise.execute(googleCloudSiteKey,{action:'login'});case 8:recaptchaToken=_context.sent;_context.next=13;break;case 11:_context.prev=11;_context.t0=_context["catch"](3);case 13:request=new PipelineRequest(SHOPGATE_USER_LOGIN_USER).setTrusted().setErrorBlacklist([EINVALIDCALL,ELEGACYSGCONNECT,EINCOMPLETELOGIN]).setInput({strategy:strategy,parameters:_extends({},parameters,recaptchaToken?{recaptchaToken:recaptchaToken}:null)}).dispatch();request.then(function(result){var success=result.success,messages=result.messages;if(success){dispatch(successLogin(redirect,strategy));}else{dispatch(errorLogin(messages));}})["catch"](function(error){var code=error.code;if(code===EINVALIDCALL){/**
10
10
  * This code is thrown when the login request failed, because the user was already logged
11
11
  * in. In that situation the success action can also dispatch to trigger the necessary
12
12
  * processes which has to happen after a successful login.
13
13
  */dispatch(successLogin(redirect,strategy));}else if(code===ELEGACYSGCONNECT){/**
14
14
  * The app is connected to the shop system via the legacy shopgate connect. Login via
15
15
  * the shop system credentials failed and further steps are necessary to login the user.
16
- */dispatch(errorLegacyConnectRegister());dispatch(errorLogin([],ELEGACYSGCONNECT));}else{dispatch(errorLogin([],code));}});return request;};}/** @mixes {MutableFunction} */export default mutable(login);
16
+ */dispatch(errorLegacyConnectRegister());dispatch(errorLogin([],ELEGACYSGCONNECT));}else{dispatch(errorLogin([],code));}});return _context.abrupt("return",request);case 16:case"end":return _context.stop();}}},_callee,null,[[3,11]]);}));return function(_x){return _ref.apply(this,arguments);};}();}/** @mixes {MutableFunction} */export default mutable(login);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common",
3
- "version": "6.22.0",
3
+ "version": "6.22.1-rc.1",
4
4
  "description": "Common library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@sentry/browser": "^4.6.3",
19
- "@shopgate/pwa-benchmark": "6.22.0",
19
+ "@shopgate/pwa-benchmark": "6.22.1-rc.1",
20
20
  "@virtuous/conductor": "~2.4.0",
21
21
  "@virtuous/react-conductor": "~2.4.0",
22
22
  "@virtuous/redux-persister": "1.1.0-beta.7",
@@ -44,7 +44,7 @@
44
44
  "url-search-params": "^0.10.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@shopgate/pwa-core": "6.22.0",
47
+ "@shopgate/pwa-core": "6.22.1-rc.1",
48
48
  "lodash": "^4.17.4",
49
49
  "prop-types": "~15.7.2",
50
50
  "react": "~16.12.0",
package/streams/app.js CHANGED
@@ -1,4 +1,4 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{getCurrentRoute}from"../selectors/router";import{APP_WILL_INIT,APP_DID_START,APP_WILL_START,PWA_DID_APPEAR,PWA_DID_DISAPPEAR}from"../constants/ActionTypes";import{main$}from"./main";export var appWillInit$=main$.filter(function(_ref){var action=_ref.action;return action.type===APP_WILL_INIT;});/**
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{getCurrentRoute}from"../selectors/router";import{APP_WILL_INIT,APP_DID_START,APP_WILL_START,PWA_DID_APPEAR,PWA_DID_DISAPPEAR,OPEN_PUSH_NOTIFICATION,OPEN_UNIVERSAL_LINK,OPEN_DEEP_LINK}from"../constants/ActionTypes";import{main$}from"./main";export var appWillInit$=main$.filter(function(_ref){var action=_ref.action;return action.type===APP_WILL_INIT;});/**
2
2
  * Gets triggered before the app starts.
3
3
  * @type {Observable}
4
4
  */export var appWillStart$=main$.filter(function(_ref2){var action=_ref2.action;return action.type===APP_WILL_START;});/**
@@ -8,4 +8,10 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
8
8
  * Emits when the PWA appeared again after navigating back from a legacy page.
9
9
  */export var pwaDidAppear$=main$.filter(function(_ref4){var action=_ref4.action;return action.type===PWA_DID_APPEAR;}).map(function(params){return _extends({},params,{action:_extends({},params.action,{route:getCurrentRoute(params.getState())})});});/**
10
10
  * Emits when the PWA disappears
11
- */export var pwaDidDisappear$=main$.filter(function(_ref5){var action=_ref5.action;return action.type===PWA_DID_DISAPPEAR;}).map(function(params){return _extends({},params,{action:_extends({},params.action,{route:getCurrentRoute(params.getState())})});});
11
+ */export var pwaDidDisappear$=main$.filter(function(_ref5){var action=_ref5.action;return action.type===PWA_DID_DISAPPEAR;}).map(function(params){return _extends({},params,{action:_extends({},params.action,{route:getCurrentRoute(params.getState())})});});/**
12
+ * Emits when a push message was opened.
13
+ */export var pushNotificationOpened$=main$.filter(function(_ref6){var action=_ref6.action;return action.type===OPEN_PUSH_NOTIFICATION;});/**
14
+ * Emits when a universal link was opened.
15
+ */export var universalLinkOpened$=main$.filter(function(_ref7){var action=_ref7.action;return action.type===OPEN_UNIVERSAL_LINK;});/**
16
+ * Emits when a deeplink was opened.
17
+ */export var deeplinkOpened$=main$.filter(function(_ref8){var action=_ref8.action;return action.type===OPEN_DEEP_LINK;});