ouisys-engine 4.6.2 → 4.6.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}require("core-js/modules/es.symbol.js"),require("core-js/modules/es.symbol.description.js"),require("core-js/modules/es.symbol.iterator.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.symbol.async-iterator.js"),require("core-js/modules/es.symbol.to-string-tag.js"),require("core-js/modules/es.json.to-string-tag.js"),require("core-js/modules/es.math.to-string-tag.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.object.set-prototype-of.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.weak-map.js"),require("core-js/modules/es.object.get-own-property-descriptor.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=identify_user,exports.pin_header_enrichment=exports.he_pin_one_click_header_enrichment=exports.he_pin_mo_redir_header_enrichment=exports.he_mo_redir_one_click_header_enrichment=void 0,require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.promise.js");var _=require(".."),RDS=_interopRequireWildcard(require("../../../common-types/RemoteDataState")),_tryGetIPRangeName=_interopRequireDefault(require("../../../ips/tryGetIPRangeName")),_utilities=require("../../../utilities"),_utils=require("../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!==_typeof(obj)&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!=key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _regeneratorRuntime(){"use strict";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key]}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return generator._invoke=function(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult()}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg)}else"return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return{value:record.arg,done:context.done}}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg)}}}(innerFn,self,context),generator}function tryCatch(fn,obj,arg){try{return{type:"normal",arg:fn.call(obj,arg)}}catch(err){return{type:"throw",arg:err}}}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){define(prototype,method,function(arg){return this._invoke(method,arg)})})}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==_typeof(value)&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then(function(value){invoke("next",value,resolve,reject)},function(err){invoke("throw",err,resolve,reject)}):PromiseImpl.resolve(value).then(function(unwrapped){result.value=unwrapped,resolve(result)},function(error){return invoke("throw",error,resolve,reject)})}reject(record.arg)}var previousPromise;this._invoke=function(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl(function(resolve,reject){invoke(method,arg,resolve,reject)})}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(delegate,context){var method=delegate.iterator[context.method];if(void 0===method){if(context.delegate=null,"throw"===context.method){if(delegate.iterator.return&&(context.method="return",context.arg=void 0,maybeInvokeDelegate(delegate,context),"throw"===context.method))return ContinueSentinel;context.method="throw",context.arg=new TypeError("The iterator does not provide a 'throw' method")}return ContinueSentinel}var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=void 0),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel)}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry)}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0)}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i<iterable.length;)if(hasOwn.call(iterable,i))return next.value=iterable[i],next.done=!1,next;return next.value=void 0,next.done=!0,next};return next.next=next}}return{next:doneResult}}function doneResult(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return exports};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";try{define({},"")}catch(err){define=function(obj,key,value){return obj[key]=value}}exports.wrap=wrap;var ContinueSentinel={},IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,function(){return this});var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);return GeneratorFunction.prototype=GeneratorFunctionPrototype,define(Gp,"constructor",GeneratorFunctionPrototype),define(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,toStringTagSymbol,"GeneratorFunction"),exports.isGeneratorFunction=function(genFun){var ctor="function"==typeof genFun&&genFun.constructor;return!!ctor&&(ctor===GeneratorFunction||"GeneratorFunction"===(ctor.displayName||ctor.name))},exports.mark=function(genFun){return Object.setPrototypeOf?Object.setPrototypeOf(genFun,GeneratorFunctionPrototype):(genFun.__proto__=GeneratorFunctionPrototype,define(genFun,toStringTagSymbol,"GeneratorFunction")),genFun.prototype=Object.create(Gp),genFun},exports.awrap=function(arg){return{__await:arg}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,asyncIteratorSymbol,function(){return this}),exports.AsyncIterator=AsyncIterator,exports.async=function(innerFn,outerFn,self,tryLocsList,PromiseImpl){void 0===PromiseImpl&&(PromiseImpl=Promise);var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList),PromiseImpl);return exports.isGeneratorFunction(outerFn)?iter:iter.next().then(function(result){return result.done?result.value:iter.next()})},defineIteratorMethods(Gp),define(Gp,toStringTagSymbol,"Generator"),define(Gp,iteratorSymbol,function(){return this}),define(Gp,"toString",function(){return"[object Generator]"}),exports.keys=function(object){var keys=[];for(var key in object)keys.push(key);return keys.reverse(),function next(){for(;keys.length;){var key=keys.pop();if(key in object)return next.value=key,next.done=!1,next}return next.done=!0,next}},exports.values=values,Context.prototype={constructor:Context,reset:function reset(skipTempReset){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(resetTryEntry),!skipTempReset)for(var name in this)"t"===name.charAt(0)&&hasOwn.call(this,name)&&!isNaN(+name.slice(1))&&(this[name]=void 0)},stop:function stop(){this.done=!0;var rootRecord=this.tryEntries[0].completion;if("throw"===rootRecord.type)throw rootRecord.arg;return this.rval},dispatchException:function dispatchException(exception){function handle(loc,caught){return record.type="throw",record.arg=exception,context.next=loc,caught&&(context.method="next",context.arg=void 0),!!caught}if(this.done)throw exception;for(var context=this,i=this.tryEntries.length-1;0<=i;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc)}else if(!hasCatch){if(!hasFinally)throw new Error("try statement without catch or finally");if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc)}else if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0)}}},abrupt:function abrupt(type,arg){for(var entry,i=this.tryEntries.length-1;0<=i;--i)if(entry=this.tryEntries[i],entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev<entry.finallyLoc){var finallyEntry=entry;break}finallyEntry&&("break"===type||"continue"===type)&&finallyEntry.tryLoc<=arg&&arg<=finallyEntry.finallyLoc&&(finallyEntry=null);var record=finallyEntry?finallyEntry.completion:{};return record.type=type,record.arg=arg,finallyEntry?(this.method="next",this.next=finallyEntry.finallyLoc,ContinueSentinel):this.complete(record)},complete:function complete(record,afterLoc){if("throw"===record.type)throw record.arg;return"break"===record.type||"continue"===record.type?this.next=record.arg:"return"===record.type?(this.rval=this.arg=record.arg,this.method="return",this.next="end"):"normal"===record.type&&afterLoc&&(this.next=afterLoc),ContinueSentinel},finish:function finish(finallyLoc){for(var entry,i=this.tryEntries.length-1;0<=i;--i)if(entry=this.tryEntries[i],entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel},catch:function _catch(tryLoc){for(var entry,i=this.tryEntries.length-1;0<=i;--i)if(entry=this.tryEntries[i],entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry)}return thrown}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=void 0),ContinueSentinel}},exports}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg),value=info.value}catch(error){return void reject(error)}info.done?resolve(value):Promise.resolve(value).then(_next,_throw)}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}var gen=fn.apply(self,args);_next(void 0)})}}function identify_user(){return function(dispatch){try{var _getConfig=(0,_utils.getConfig)(),strategy=_getConfig.strategy,strategyConfigs=_getConfig.strategyConfigs,defaultFlow=strategyConfigs.default;switch(strategy){case"pin-header-enrichment":return dispatch(pin_header_enrichment(defaultFlow));case"he-pin-mo-redir-header-enrichment":return dispatch(he_pin_mo_redir_header_enrichment(defaultFlow));case"he-pin-one-click-header-enrichment":return dispatch(he_pin_one_click_header_enrichment(defaultFlow));case"he-mo-redir-one-click-header-enrichment":return dispatch(he_mo_redir_one_click_header_enrichment(defaultFlow));}}catch(err){dispatch({type:"HE_IDENTIFY",payload:{type:"HE_IDENTIFY",result:RDS.Failure(err)}})}}}var pin_header_enrichment=function(defaultFlow){return function(){var _ref=_asyncToGenerator(_regeneratorRuntime().mark(function _callee(dispatch){var _ipRangeName$toLowerC,_window,_window$pac_analytics,_window$pac_analytics2,_window$pac_analytics3,ipRangeName,isIPInRnge,heResult,flowObj,msisdn;return _regeneratorRuntime().wrap(function _callee$(_context){for(;1;)switch(_context.prev=_context.next){case 0:return _context.prev=0,_context.next=3,(0,_tryGetIPRangeName.default)(window.pac_analytics.visitor);case 3:if(ipRangeName=_context.sent,isIPInRnge=null!==ipRangeName||(null===ipRangeName||void 0===ipRangeName||null===(_ipRangeName$toLowerC=ipRangeName.toLowerCase())||void 0===_ipRangeName$toLowerC?void 0:_ipRangeName$toLowerC.includes("".concat(null===(_window=window)||void 0===_window||null===(_window$pac_analytics=_window.pac_analytics)||void 0===_window$pac_analytics||null===(_window$pac_analytics2=_window$pac_analytics.visitor)||void 0===_window$pac_analytics2||null===(_window$pac_analytics3=_window$pac_analytics2.country)||void 0===_window$pac_analytics3?void 0:_window$pac_analytics3.toLowerCase()))),isIPInRnge&&(0,_utils.searchToObject)().msisdn){_context.next=8;break}return _.tracker.sendOptInFlowEvent("Pin"),_context.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}}));case 8:return _context.next=10,(0,_utils.identifyUser)();case 10:if(heResult=_context.sent,flowObj=defaultFlow,void 0===heResult.msisdn||""===heResult.msisdn){_context.next=17;break}return msisdn=heResult.msisdn,_.tracker.customEvent("Flow","advance-auto","msisdn-detected",{msisdn:msisdn}),_.tracker.sendOptInFlowEvent("Hybrid Pin"),_context.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,isHeaderEnrichmentSuccess:!0}}}));case 17:return _.tracker.sendOptInFlowEvent("Pin"),_context.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig}}}));case 21:_context.prev=21,_context.t0=_context["catch"](0),console.warn(_context.t0),_.tracker.customEvent("Flow","recede-auto","msisdn-detection-failure",{errorType:null===_context.t0||void 0===_context.t0?void 0:_context.t0.message}),_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}});case 27:case"end":return _context.stop();}},_callee,null,[[0,21]])}));return function(_x){return _ref.apply(this,arguments)}}()};exports.pin_header_enrichment=pin_header_enrichment;var he_pin_one_click_header_enrichment=function he_pin_one_click_header_enrichment(defaultFlow){return function(){var _ref2=_asyncToGenerator(_regeneratorRuntime().mark(function _callee2(dispatch){var _window2,_window2$pac_analytic,_window2$pac_analytic2,_window2$pac_analytic3,_window2$pac_analytic4,search,switchState,ipRangeName,_window3,_window3$pac_analytic,_window3$pac_analytic2,mapIpRangeToAgency,flowObj,heResult,msisdn,subscription_url,redirect_url,operator;return _regeneratorRuntime().wrap(function _callee2$(_context2){for(;1;)switch(_context2.prev=_context2.next){case 0:if(search=(0,_utils.searchToObject)(),switchState=function switchState(_ref3){var flowObj=_ref3.flowObj,msisdn=_ref3.msisdn,operator=_ref3.operator,subscription_url=_ref3.subscription_url,redirect_url=_ref3.redirect_url,isHeaderEnrichmentSuccess=void 0!==msisdn&&""!==msisdn;switch(flowObj.flow){case"oneClick":return _.tracker.sendOptInFlowEvent("3G click"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"ONE_CLICK",result:{nextAction:"getRedirectUrlAction",config:flowObj.flowConfig,operator:flowObj.operator,subscription_url:subscription_url||null,redirect_url:redirect_url||null}}});case"pin":return!0===isHeaderEnrichmentSuccess?_.tracker.sendOptInFlowEvent("Hybrid Pin"):_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,operator:operator,isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess}}});default:return _.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}});}},_context2.t0=null===search||void 0===search?void 0:search.operator,_context2.t0){_context2.next=7;break}return _context2.next=6,(0,_tryGetIPRangeName.default)(window.pac_analytics.visitor);case 6:_context2.t0=_context2.sent;case 7:if(ipRangeName=_context2.t0,null!==(_window2=window)&&void 0!==_window2&&null!==(_window2$pac_analytic=_window2.pac_analytics)&&void 0!==_window2$pac_analytic&&null!==(_window2$pac_analytic2=_window2$pac_analytic.visitor)&&void 0!==_window2$pac_analytic2&&null!==(_window2$pac_analytic3=_window2$pac_analytic2.ip_range_name)&&void 0!==_window2$pac_analytic3&&null!==(_window2$pac_analytic4=_window2$pac_analytic3.toLowerCase())&&void 0!==_window2$pac_analytic4&&_window2$pac_analytic4.includes("cz")){_context2.next=11;break}return _.tracker.sendOptInFlowEvent("Pin"),_context2.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}}));case 11:if(_context2.prev=11,mapIpRangeToAgency={om_ooredoo:"o2_ooredoo"},flowObj=(0,_utils.determineFlowByOperator)((0,_utilities.hasNumber)(null===(_window3=window)||void 0===_window3||null===(_window3$pac_analytic=_window3.pac_analytics)||void 0===_window3$pac_analytic||null===(_window3$pac_analytic2=_window3$pac_analytic.visitor)||void 0===_window3$pac_analytic2?void 0:_window3$pac_analytic2.country)?mapIpRangeToAgency[ipRangeName]:ipRangeName),"oneClick"!==flowObj.flow){_context2.next=23;break}return _context2.next=17,(0,_utils.identifyUser)({operator:ipRangeName});case 17:heResult=_context2.sent,msisdn=heResult.msisdn,subscription_url=heResult.subscription_url,redirect_url=heResult.redirect_url,operator=heResult.operator?heResult.operator.toUpperCase():ipRangeName.toUpperCase(),msisdn&&""!==msisdn?(_.tracker.customEvent("Flow","advance-auto","msisdn-detected",{msisdn:msisdn}),switchState({flowObj:flowObj,msisdn:msisdn,operator:operator,subscription_url:subscription_url,redirect_url:redirect_url})):switchState({flowObj:flowObj,redirect_url:redirect_url,subscription_url:subscription_url,operator:operator}),_context2.next=25;break;case 23:return _.tracker.sendOptInFlowEvent("Pin"),_context2.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}}));case 25:_context2.next=33;break;case 27:_context2.prev=27,_context2.t1=_context2["catch"](11),console.warn(_context2.t1),_.tracker.customEvent("Flow","recede-auto","msisdn-detection-failure",{errorType:null===_context2.t1||void 0===_context2.t1?void 0:_context2.t1.message}),_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}});case 33:case"end":return _context2.stop();}},_callee2,null,[[11,27]])}));return function(_x2){return _ref2.apply(this,arguments)}}()};exports.he_pin_one_click_header_enrichment=he_pin_one_click_header_enrichment;var he_mo_redir_one_click_header_enrichment=function he_mo_redir_one_click_header_enrichment(defaultFlow){return function(){var _ref4=_asyncToGenerator(_regeneratorRuntime().mark(function _callee3(dispatch){var switchState,searchObj,ipRangeName,flowObj,heResult,msisdn,subscription_url,redirect_url,operator;return _regeneratorRuntime().wrap(function _callee3$(_context3){for(;1;)switch(_context3.prev=_context3.next){case 0:if(switchState=function switchState(_ref5){var flowObj=_ref5.flowObj,msisdn=_ref5.msisdn,operator=_ref5.operator,subscription_url=_ref5.subscription_url,redirect_url=_ref5.redirect_url,isHeaderEnrichmentSuccess=void 0!==msisdn&&""!==msisdn;switch(flowObj.flow){case"oneClick":return _.tracker.sendOptInFlowEvent("3G click"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"ONE_CLICK",result:{nextAction:"getRedirectUrlAction",config:flowObj.flowConfig,operator:flowObj.operator,subscription_url:subscription_url||null,redirect_url:redirect_url||null}}});case"moRedir":return _.tracker.sendOptInFlowEvent("Redirect"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,operator:operator,isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess}}});default:return _.tracker.sendOptInFlowEvent("Redirect"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}});}},searchObj=(0,_utils.searchToObject)(),_context3.t1=null===searchObj||void 0===searchObj?void 0:searchObj.operator,_context3.t1){_context3.next=7;break}return _context3.next=6,(0,_tryGetIPRangeName.default)(window.pac_analytics.visitor);case 6:_context3.t1=_context3.sent;case 7:if(_context3.t0=_context3.t1,_context3.t0){_context3.next=10;break}_context3.t0=null;case 10:if(ipRangeName=_context3.t0,null!==ipRangeName){_context3.next=14;break}return _.tracker.sendOptInFlowEvent("Redirect"),_context3.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}}));case 14:if(_context3.prev=14,flowObj=(0,_utils.determineFlowByOperator)(ipRangeName.toUpperCase()),"oneClick"!==flowObj.flow){_context3.next=25;break}return _context3.next=19,(0,_utils.identifyUser)({operator:ipRangeName});case 19:heResult=_context3.sent,msisdn=heResult.msisdn,subscription_url=heResult.subscription_url,redirect_url=heResult.redirect_url,operator=heResult.operator?heResult.operator.toUpperCase():ipRangeName.toUpperCase(),msisdn&&""!==msisdn?(_.tracker.customEvent("Flow","advance-auto","msisdn-detected",{msisdn:msisdn}),switchState({flowObj:flowObj,msisdn:msisdn,operator:operator,subscription_url:subscription_url,redirect_url:redirect_url})):switchState({flowObj:flowObj,redirect_url:redirect_url,subscription_url:subscription_url,operator:operator}),_context3.next=27;break;case 25:return _.tracker.sendOptInFlowEvent("Redirect"),_context3.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}}));case 27:_context3.next=35;break;case 29:_context3.prev=29,_context3.t2=_context3["catch"](14),console.warn(_context3.t2),_.tracker.customEvent("Flow","recede-auto","msisdn-detection-failure",{errorType:null===_context3.t2||void 0===_context3.t2?void 0:_context3.t2.message}),_.tracker.sendOptInFlowEvent("Redirect"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}});case 35:case"end":return _context3.stop();}},_callee3,null,[[14,29]])}));return function(_x3){return _ref4.apply(this,arguments)}}()};exports.he_mo_redir_one_click_header_enrichment=he_mo_redir_one_click_header_enrichment;var he_pin_mo_redir_header_enrichment=function he_pin_mo_redir_header_enrichment(defaultFlow){return function(){var _ref6=_asyncToGenerator(_regeneratorRuntime().mark(function _callee4(dispatch){var switchState,heResult,msisdn,operator,flowObj,_flowObj,_flowObj2,_flowObj3;return _regeneratorRuntime().wrap(function _callee4$(_context4){for(;1;)switch(_context4.prev=_context4.next){case 0:return switchState=function switchState(flowObj,msisdn,operator){var isHeaderEnrichmentSuccess=void 0!==msisdn&&""!==msisdn;switch(flowObj.flow){case"moRedir":return _.tracker.sendOptInFlowEvent("Redirect"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,operator:operator,isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess}}});case"pin":return!0===isHeaderEnrichmentSuccess?_.tracker.sendOptInFlowEvent("Hybrid Pin"):_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,operator:operator,isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess}}});default:return _.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}});}},_context4.prev=1,_context4.next=4,(0,_utils.identifyUser)();case 4:if(heResult=_context4.sent,void 0===heResult.msisdn||""===heResult.msisdn){_context4.next=20;break}if(msisdn=heResult.msisdn,operator=heResult.operator,_.tracker.customEvent("Flow","advance-auto","msisdn-detected",{msisdn:msisdn}),!operator||""===operator){_context4.next=14;break}flowObj=(0,_utils.determineFlowByOperator)(operator),switchState(flowObj,msisdn,operator),_context4.next=18;break;case 14:return _context4.next=16,(0,_utils.determineFlowByOperatorFromIp)();case 16:_flowObj=_context4.sent,switchState(_flowObj,msisdn);case 18:_context4.next=24;break;case 20:return _context4.next=22,(0,_utils.determineFlowByOperatorFromIp)();case 22:_flowObj2=_context4.sent,switchState(_flowObj2);case 24:_context4.next=42;break;case 26:return _context4.prev=26,_context4.t0=_context4["catch"](1),console.warn(_context4.t0),_.tracker.customEvent("Flow","recede-auto","msisdn-detection-failure",{errorType:null===_context4.t0||void 0===_context4.t0?void 0:_context4.t0.message}),_context4.prev=30,_context4.next=33,(0,_utils.determineFlowByOperatorFromIp)();case 33:_flowObj3=_context4.sent,switchState(_flowObj3),_context4.next=42;break;case 37:_context4.prev=37,_context4.t1=_context4["catch"](30),console.warn(_context4.t1),_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}});case 42:case"end":return _context4.stop();}},_callee4,null,[[1,26],[30,37]])}));return function(_x4){return _ref6.apply(this,arguments)}}()};exports.he_pin_mo_redir_header_enrichment=he_pin_mo_redir_header_enrichment;
|
|
1
|
+
"use strict";function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}require("core-js/modules/es.symbol.js"),require("core-js/modules/es.symbol.description.js"),require("core-js/modules/es.symbol.iterator.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.symbol.async-iterator.js"),require("core-js/modules/es.symbol.to-string-tag.js"),require("core-js/modules/es.json.to-string-tag.js"),require("core-js/modules/es.math.to-string-tag.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.object.set-prototype-of.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.weak-map.js"),require("core-js/modules/es.object.get-own-property-descriptor.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=identify_user,exports.pin_header_enrichment=exports.he_pin_one_click_header_enrichment=exports.he_pin_mo_redir_header_enrichment=exports.he_mo_redir_one_click_header_enrichment=void 0,require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.promise.js");var _=require(".."),RDS=_interopRequireWildcard(require("../../../common-types/RemoteDataState")),_tryGetIPRangeName=_interopRequireDefault(require("../../../ips/tryGetIPRangeName")),_utils=require("../utils");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!==_typeof(obj)&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!=key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _regeneratorRuntime(){"use strict";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key]}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return generator._invoke=function(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult()}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg)}else"return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return{value:record.arg,done:context.done}}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg)}}}(innerFn,self,context),generator}function tryCatch(fn,obj,arg){try{return{type:"normal",arg:fn.call(obj,arg)}}catch(err){return{type:"throw",arg:err}}}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){define(prototype,method,function(arg){return this._invoke(method,arg)})})}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==_typeof(value)&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then(function(value){invoke("next",value,resolve,reject)},function(err){invoke("throw",err,resolve,reject)}):PromiseImpl.resolve(value).then(function(unwrapped){result.value=unwrapped,resolve(result)},function(error){return invoke("throw",error,resolve,reject)})}reject(record.arg)}var previousPromise;this._invoke=function(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl(function(resolve,reject){invoke(method,arg,resolve,reject)})}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(delegate,context){var method=delegate.iterator[context.method];if(void 0===method){if(context.delegate=null,"throw"===context.method){if(delegate.iterator.return&&(context.method="return",context.arg=void 0,maybeInvokeDelegate(delegate,context),"throw"===context.method))return ContinueSentinel;context.method="throw",context.arg=new TypeError("The iterator does not provide a 'throw' method")}return ContinueSentinel}var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=void 0),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel)}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry)}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0)}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i<iterable.length;)if(hasOwn.call(iterable,i))return next.value=iterable[i],next.done=!1,next;return next.value=void 0,next.done=!0,next};return next.next=next}}return{next:doneResult}}function doneResult(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return exports};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";try{define({},"")}catch(err){define=function(obj,key,value){return obj[key]=value}}exports.wrap=wrap;var ContinueSentinel={},IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,function(){return this});var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);return GeneratorFunction.prototype=GeneratorFunctionPrototype,define(Gp,"constructor",GeneratorFunctionPrototype),define(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,toStringTagSymbol,"GeneratorFunction"),exports.isGeneratorFunction=function(genFun){var ctor="function"==typeof genFun&&genFun.constructor;return!!ctor&&(ctor===GeneratorFunction||"GeneratorFunction"===(ctor.displayName||ctor.name))},exports.mark=function(genFun){return Object.setPrototypeOf?Object.setPrototypeOf(genFun,GeneratorFunctionPrototype):(genFun.__proto__=GeneratorFunctionPrototype,define(genFun,toStringTagSymbol,"GeneratorFunction")),genFun.prototype=Object.create(Gp),genFun},exports.awrap=function(arg){return{__await:arg}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,asyncIteratorSymbol,function(){return this}),exports.AsyncIterator=AsyncIterator,exports.async=function(innerFn,outerFn,self,tryLocsList,PromiseImpl){void 0===PromiseImpl&&(PromiseImpl=Promise);var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList),PromiseImpl);return exports.isGeneratorFunction(outerFn)?iter:iter.next().then(function(result){return result.done?result.value:iter.next()})},defineIteratorMethods(Gp),define(Gp,toStringTagSymbol,"Generator"),define(Gp,iteratorSymbol,function(){return this}),define(Gp,"toString",function(){return"[object Generator]"}),exports.keys=function(object){var keys=[];for(var key in object)keys.push(key);return keys.reverse(),function next(){for(;keys.length;){var key=keys.pop();if(key in object)return next.value=key,next.done=!1,next}return next.done=!0,next}},exports.values=values,Context.prototype={constructor:Context,reset:function reset(skipTempReset){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(resetTryEntry),!skipTempReset)for(var name in this)"t"===name.charAt(0)&&hasOwn.call(this,name)&&!isNaN(+name.slice(1))&&(this[name]=void 0)},stop:function stop(){this.done=!0;var rootRecord=this.tryEntries[0].completion;if("throw"===rootRecord.type)throw rootRecord.arg;return this.rval},dispatchException:function dispatchException(exception){function handle(loc,caught){return record.type="throw",record.arg=exception,context.next=loc,caught&&(context.method="next",context.arg=void 0),!!caught}if(this.done)throw exception;for(var context=this,i=this.tryEntries.length-1;0<=i;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc)}else if(!hasCatch){if(!hasFinally)throw new Error("try statement without catch or finally");if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc)}else if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0)}}},abrupt:function abrupt(type,arg){for(var entry,i=this.tryEntries.length-1;0<=i;--i)if(entry=this.tryEntries[i],entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev<entry.finallyLoc){var finallyEntry=entry;break}finallyEntry&&("break"===type||"continue"===type)&&finallyEntry.tryLoc<=arg&&arg<=finallyEntry.finallyLoc&&(finallyEntry=null);var record=finallyEntry?finallyEntry.completion:{};return record.type=type,record.arg=arg,finallyEntry?(this.method="next",this.next=finallyEntry.finallyLoc,ContinueSentinel):this.complete(record)},complete:function complete(record,afterLoc){if("throw"===record.type)throw record.arg;return"break"===record.type||"continue"===record.type?this.next=record.arg:"return"===record.type?(this.rval=this.arg=record.arg,this.method="return",this.next="end"):"normal"===record.type&&afterLoc&&(this.next=afterLoc),ContinueSentinel},finish:function finish(finallyLoc){for(var entry,i=this.tryEntries.length-1;0<=i;--i)if(entry=this.tryEntries[i],entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel},catch:function _catch(tryLoc){for(var entry,i=this.tryEntries.length-1;0<=i;--i)if(entry=this.tryEntries[i],entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry)}return thrown}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=void 0),ContinueSentinel}},exports}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg),value=info.value}catch(error){return void reject(error)}info.done?resolve(value):Promise.resolve(value).then(_next,_throw)}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}var gen=fn.apply(self,args);_next(void 0)})}}function identify_user(){return function(dispatch){try{var _getConfig=(0,_utils.getConfig)(),strategy=_getConfig.strategy,strategyConfigs=_getConfig.strategyConfigs,defaultFlow=strategyConfigs.default;switch(strategy){case"pin-header-enrichment":return dispatch(pin_header_enrichment(defaultFlow));case"he-pin-mo-redir-header-enrichment":return dispatch(he_pin_mo_redir_header_enrichment(defaultFlow));case"he-pin-one-click-header-enrichment":return dispatch(he_pin_one_click_header_enrichment(defaultFlow));case"he-mo-redir-one-click-header-enrichment":return dispatch(he_mo_redir_one_click_header_enrichment(defaultFlow));}}catch(err){dispatch({type:"HE_IDENTIFY",payload:{type:"HE_IDENTIFY",result:RDS.Failure(err)}})}}}var pin_header_enrichment=function(defaultFlow){return function(){var _ref=_asyncToGenerator(_regeneratorRuntime().mark(function _callee(dispatch){var _ipRangeName$toLowerC,_window,_window$pac_analytics,_window$pac_analytics2,_window$pac_analytics3,ipRangeName,isIPInRnge,heResult,flowObj,msisdn;return _regeneratorRuntime().wrap(function _callee$(_context){for(;1;)switch(_context.prev=_context.next){case 0:return _context.prev=0,_context.next=3,(0,_tryGetIPRangeName.default)(window.pac_analytics.visitor);case 3:if(ipRangeName=_context.sent,isIPInRnge=null!==ipRangeName||(null===ipRangeName||void 0===ipRangeName||null===(_ipRangeName$toLowerC=ipRangeName.toLowerCase())||void 0===_ipRangeName$toLowerC?void 0:_ipRangeName$toLowerC.includes("".concat(null===(_window=window)||void 0===_window||null===(_window$pac_analytics=_window.pac_analytics)||void 0===_window$pac_analytics||null===(_window$pac_analytics2=_window$pac_analytics.visitor)||void 0===_window$pac_analytics2||null===(_window$pac_analytics3=_window$pac_analytics2.country)||void 0===_window$pac_analytics3?void 0:_window$pac_analytics3.toLowerCase()))),isIPInRnge&&(0,_utils.searchToObject)().msisdn){_context.next=8;break}return _.tracker.sendOptInFlowEvent("Pin"),_context.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}}));case 8:return _context.next=10,(0,_utils.identifyUser)();case 10:if(heResult=_context.sent,flowObj=defaultFlow,void 0===heResult.msisdn||""===heResult.msisdn){_context.next=17;break}return msisdn=heResult.msisdn,_.tracker.customEvent("Flow","advance-auto","msisdn-detected",{msisdn:msisdn}),_.tracker.sendOptInFlowEvent("Hybrid Pin"),_context.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,isHeaderEnrichmentSuccess:!0}}}));case 17:return _.tracker.sendOptInFlowEvent("Pin"),_context.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig}}}));case 21:_context.prev=21,_context.t0=_context["catch"](0),console.warn(_context.t0),_.tracker.customEvent("Flow","recede-auto","msisdn-detection-failure",{errorType:null===_context.t0||void 0===_context.t0?void 0:_context.t0.message}),_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}});case 27:case"end":return _context.stop();}},_callee,null,[[0,21]])}));return function(_x){return _ref.apply(this,arguments)}}()};exports.pin_header_enrichment=pin_header_enrichment;var he_pin_one_click_header_enrichment=function he_pin_one_click_header_enrichment(defaultFlow){return function(){var _ref2=_asyncToGenerator(_regeneratorRuntime().mark(function _callee2(dispatch){var search,switchState,operatorResult,flowObj,heResult,msisdn,subscription_url,redirect_url,operator;return _regeneratorRuntime().wrap(function _callee2$(_context2){for(;1;)switch(_context2.prev=_context2.next){case 0:if(search=(0,_utils.searchToObject)(),switchState=function switchState(_ref3){var flowObj=_ref3.flowObj,msisdn=_ref3.msisdn,operator=_ref3.operator,subscription_url=_ref3.subscription_url,redirect_url=_ref3.redirect_url,isHeaderEnrichmentSuccess=void 0!==msisdn&&""!==msisdn;switch(flowObj.flow){case"oneClick":return _.tracker.sendOptInFlowEvent("3G click"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"ONE_CLICK",result:{nextAction:"getRedirectUrlAction",config:flowObj.flowConfig,operator:flowObj.operator,subscription_url:subscription_url||null,redirect_url:redirect_url||null}}});case"pin":return!0===isHeaderEnrichmentSuccess?_.tracker.sendOptInFlowEvent("Hybrid Pin"):_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,operator:operator,isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess}}});default:return _.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}});}},_context2.t0=null===search||void 0===search?void 0:search.operator,_context2.t0){_context2.next=7;break}return _context2.next=6,(0,_tryGetIPRangeName.default)(window.pac_analytics.visitor);case 6:_context2.t0=_context2.sent;case 7:if(operatorResult=_context2.t0,_context2.prev=8,flowObj=(0,_utils.determineFlowByOperator)(operatorResult),"oneClick"!==flowObj.flow){_context2.next=19;break}return _context2.next=13,(0,_utils.identifyUser)({operator:operatorResult});case 13:heResult=_context2.sent,msisdn=heResult.msisdn,subscription_url=heResult.subscription_url,redirect_url=heResult.redirect_url,operator=heResult.operator?heResult.operator.toUpperCase():operatorResult.toUpperCase(),msisdn&&""!==msisdn?(_.tracker.customEvent("Flow","advance-auto","msisdn-detected",{msisdn:msisdn}),switchState({flowObj:flowObj,msisdn:msisdn,operator:operator,subscription_url:subscription_url,redirect_url:redirect_url})):switchState({flowObj:flowObj,redirect_url:redirect_url,subscription_url:subscription_url,operator:operator}),_context2.next=21;break;case 19:return _.tracker.sendOptInFlowEvent("Pin"),_context2.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}}));case 21:_context2.next=29;break;case 23:_context2.prev=23,_context2.t1=_context2["catch"](8),console.warn(_context2.t1),_.tracker.customEvent("Flow","recede-auto","msisdn-detection-failure",{errorType:null===_context2.t1||void 0===_context2.t1?void 0:_context2.t1.message}),_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}});case 29:case"end":return _context2.stop();}},_callee2,null,[[8,23]])}));return function(_x2){return _ref2.apply(this,arguments)}}()};exports.he_pin_one_click_header_enrichment=he_pin_one_click_header_enrichment;var he_mo_redir_one_click_header_enrichment=function he_mo_redir_one_click_header_enrichment(defaultFlow){return function(){var _ref4=_asyncToGenerator(_regeneratorRuntime().mark(function _callee3(dispatch){var switchState,searchObj,ipRangeName,flowObj,heResult,msisdn,subscription_url,redirect_url,operator;return _regeneratorRuntime().wrap(function _callee3$(_context3){for(;1;)switch(_context3.prev=_context3.next){case 0:if(switchState=function switchState(_ref5){var flowObj=_ref5.flowObj,msisdn=_ref5.msisdn,operator=_ref5.operator,subscription_url=_ref5.subscription_url,redirect_url=_ref5.redirect_url,isHeaderEnrichmentSuccess=void 0!==msisdn&&""!==msisdn;switch(flowObj.flow){case"oneClick":return _.tracker.sendOptInFlowEvent("3G click"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"ONE_CLICK",result:{nextAction:"getRedirectUrlAction",config:flowObj.flowConfig,operator:flowObj.operator,subscription_url:subscription_url||null,redirect_url:redirect_url||null}}});case"moRedir":return _.tracker.sendOptInFlowEvent("Redirect"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,operator:operator,isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess}}});default:return _.tracker.sendOptInFlowEvent("Redirect"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}});}},searchObj=(0,_utils.searchToObject)(),_context3.t1=null===searchObj||void 0===searchObj?void 0:searchObj.operator,_context3.t1){_context3.next=7;break}return _context3.next=6,(0,_tryGetIPRangeName.default)(window.pac_analytics.visitor);case 6:_context3.t1=_context3.sent;case 7:if(_context3.t0=_context3.t1,_context3.t0){_context3.next=10;break}_context3.t0=null;case 10:if(ipRangeName=_context3.t0,null!==ipRangeName){_context3.next=14;break}return _.tracker.sendOptInFlowEvent("Redirect"),_context3.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}}));case 14:if(_context3.prev=14,flowObj=(0,_utils.determineFlowByOperator)(ipRangeName.toUpperCase()),"oneClick"!==flowObj.flow){_context3.next=25;break}return _context3.next=19,(0,_utils.identifyUser)({operator:ipRangeName});case 19:heResult=_context3.sent,msisdn=heResult.msisdn,subscription_url=heResult.subscription_url,redirect_url=heResult.redirect_url,operator=heResult.operator?heResult.operator.toUpperCase():ipRangeName.toUpperCase(),msisdn&&""!==msisdn?(_.tracker.customEvent("Flow","advance-auto","msisdn-detected",{msisdn:msisdn}),switchState({flowObj:flowObj,msisdn:msisdn,operator:operator,subscription_url:subscription_url,redirect_url:redirect_url})):switchState({flowObj:flowObj,redirect_url:redirect_url,subscription_url:subscription_url,operator:operator}),_context3.next=27;break;case 25:return _.tracker.sendOptInFlowEvent("Redirect"),_context3.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}}));case 27:_context3.next=35;break;case 29:_context3.prev=29,_context3.t2=_context3["catch"](14),console.warn(_context3.t2),_.tracker.customEvent("Flow","recede-auto","msisdn-detection-failure",{errorType:null===_context3.t2||void 0===_context3.t2?void 0:_context3.t2.message}),_.tracker.sendOptInFlowEvent("Redirect"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}});case 35:case"end":return _context3.stop();}},_callee3,null,[[14,29]])}));return function(_x3){return _ref4.apply(this,arguments)}}()};exports.he_mo_redir_one_click_header_enrichment=he_mo_redir_one_click_header_enrichment;var he_pin_mo_redir_header_enrichment=function he_pin_mo_redir_header_enrichment(defaultFlow){return function(){var _ref6=_asyncToGenerator(_regeneratorRuntime().mark(function _callee4(dispatch){var switchState,heResult,msisdn,operator,flowObj,_flowObj,_flowObj2,_flowObj3;return _regeneratorRuntime().wrap(function _callee4$(_context4){for(;1;)switch(_context4.prev=_context4.next){case 0:return switchState=function switchState(flowObj,msisdn,operator){var isHeaderEnrichmentSuccess=void 0!==msisdn&&""!==msisdn;switch(flowObj.flow){case"moRedir":return _.tracker.sendOptInFlowEvent("Redirect"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"MO_REDIR",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,operator:operator,isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess}}});case"pin":return!0===isHeaderEnrichmentSuccess?_.tracker.sendOptInFlowEvent("Hybrid Pin"):_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:flowObj.flowConfig,msisdn:msisdn,rockman_id:flowObj.rockman_id,operator:operator,isHeaderEnrichmentSuccess:isHeaderEnrichmentSuccess}}});default:return _.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig,rockman_id:defaultFlow.rockman_id}}});}},_context4.prev=1,_context4.next=4,(0,_utils.identifyUser)();case 4:if(heResult=_context4.sent,void 0===heResult.msisdn||""===heResult.msisdn){_context4.next=20;break}if(msisdn=heResult.msisdn,operator=heResult.operator,_.tracker.customEvent("Flow","advance-auto","msisdn-detected",{msisdn:msisdn}),!operator||""===operator){_context4.next=14;break}flowObj=(0,_utils.determineFlowByOperator)(operator),switchState(flowObj,msisdn,operator),_context4.next=18;break;case 14:return _context4.next=16,(0,_utils.determineFlowByOperatorFromIp)();case 16:_flowObj=_context4.sent,switchState(_flowObj,msisdn);case 18:_context4.next=24;break;case 20:return _context4.next=22,(0,_utils.determineFlowByOperatorFromIp)();case 22:_flowObj2=_context4.sent,switchState(_flowObj2);case 24:_context4.next=42;break;case 26:return _context4.prev=26,_context4.t0=_context4["catch"](1),console.warn(_context4.t0),_.tracker.customEvent("Flow","recede-auto","msisdn-detection-failure",{errorType:null===_context4.t0||void 0===_context4.t0?void 0:_context4.t0.message}),_context4.prev=30,_context4.next=33,(0,_utils.determineFlowByOperatorFromIp)();case 33:_flowObj3=_context4.sent,switchState(_flowObj3),_context4.next=42;break;case 37:_context4.prev=37,_context4.t1=_context4["catch"](30),console.warn(_context4.t1),_.tracker.sendOptInFlowEvent("Pin"),dispatch({type:"IDENTIFY_FLOW_BY_HE",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:defaultFlow.flowConfig}}});case 42:case"end":return _context4.stop();}},_callee4,null,[[1,26],[30,37]])}));return function(_x4){return _ref6.apply(this,arguments)}}()};exports.he_pin_mo_redir_header_enrichment=he_pin_mo_redir_header_enrichment;
|