New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

post-robot

Package Overview
Dependencies
Maintainers
2
Versions
246
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

post-robot - npm Package Compare versions

Comparing version 2.0.25 to 2.0.26

2

bower.json
{
"name": "post-robot",
"main": "index.js",
"version": "2.0.25",
"version": "2.0.26",
"authors": [

@@ -6,0 +6,0 @@ "Daniel Brain <dbrain@paypal.com>"

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("postRobot",[],n):"object"==typeof exports?exports.postRobot=n():e.postRobot=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";function r(){(0,u.registerGlobals)(),i.util.listen(window,"message",a.messageListener),(0,i.initOnReady)()}Object.defineProperty(n,"__esModule",{value:!0}),n.Promise=void 0;var o=t(1);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(8);Object.defineProperty(n,"Promise",{enumerable:!0,get:function(){return i.Promise}});var a=t(6),u=t(17);r(),n["default"]=e.exports},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.util=n.openBridge=n.reset=n.parent=void 0;var r=t(2);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(25);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(26);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(27);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})});var u=t(6);Object.defineProperty(n,"reset",{enumerable:!0,get:function(){return u.resetListeners}});var s=t(18);Object.defineProperty(n,"openBridge",{enumerable:!0,get:function(){return s.openBridge}});var c=t(12);Object.defineProperty(n,"util",{enumerable:!0,get:function(){return c.util}});var d=t(14);n.parent=(0,d.getParentWindow)()},function(e,n,t){"use strict";function r(e){return s.promise.nodeify(new s.promise.Promise(function(n,t){if(!e.name)throw new Error("Expected options.name");if(!e.window)throw new Error("Expected options.window");if(a.CONFIG.MOCK_MODE)e.window=window;else if("string"==typeof e.window){var r=document.getElementById(e.window);if(!r)throw new Error("Expected options.window "+e.window+" to be a valid element id");if("iframe"!==r.tagName.toLowerCase())throw new Error("Expected options.window "+e.window+" to be an iframe");if(e.window=r.contentWindow,!e.window)throw new Error("Expected options.window")}var o=e.name+"_"+s.util.uniqueID();if(u.listeners.response[o]=e,(0,s.isWindowClosed)(e.window))throw new Error("Target window is closed");var i=!1;return e.respond=function(e,r){return e||(i=!0),e?t(e):n(r)},s.promise.run(function(){return(0,s.getParentWindow)(e.window)===window?(0,s.onWindowReady)(e.window):void 0}).then(function(){if((0,u.sendMessage)(e.window,{hash:o,type:a.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,name:e.name,data:e.data,fireAndForget:e.fireAndForget},e.domain||"*")["catch"](t),e.fireAndForget)return n();var r=s.util.intervalTimeout(a.CONFIG.ACK_TIMEOUT,100,function(n){return e.ack||(0,s.isWindowClosed)(e.window)?r.cancel():n?void 0:t(new Error("No ack for postMessage "+e.name+" in "+a.CONFIG.ACK_TIMEOUT+"ms"))});e.timeout&&!function(){var n=s.util.intervalTimeout(e.timeout,100,function(r){return i||(0,s.isWindowClosed)(e.window)?n.cancel():r?void 0:t(new Error("Post message response timed out after "+e.timeout+" ms"))},e.timeout)}()})["catch"](t)}),e.callback)}function o(e,n,t,o,i){return i||(!o&&t instanceof Function?(i=t,o={},t={}):o instanceof Function&&(i=o,o={})),o=o||{},o.window=e,o.name=n,o.data=t,o.callback=i,r(o)}function i(e,n,t,r){var i=(0,s.getParentWindow)();if(!window)throw new Error("Window does not have a parent");return o(i,e,n,t,r)}Object.defineProperty(n,"__esModule",{value:!0}),n.request=r,n.send=o,n.sendToParent=i;var a=t(3),u=t(6),s=t(8)},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(4);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(5);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}Object.defineProperty(n,"__esModule",{value:!0}),n.CONFIG=void 0;var o,i=t(5);n.CONFIG={ALLOW_POSTMESSAGE_POPUP:!1,LOG_LEVEL:"info",ACK_TIMEOUT:500,LOG_TO_PAGE:!1,MOCK_MODE:!1,ALLOWED_POST_MESSAGE_METHODS:(o={},r(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,!0),r(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL_METHOD,!0),r(o,i.CONSTANTS.SEND_STRATEGIES.FOREIGN_BRIDGE,!0),r(o,i.CONSTANTS.SEND_STRATEGIES.LOCAL_BRIDGE,!0),o)}},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=n.CONSTANTS={POST_MESSAGE_TYPE:{REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},POST_MESSAGE_ACK:{SUCCESS:"success",ERROR:"error"},POST_MESSAGE_NAMES:{METHOD:"postrobot_method",READY:"postrobot_ready"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method"},SEND_STRATEGIES:{POST_MESSAGE:"postrobot_post_message",GLOBAL_METHOD:"postrobot_global_method",FOREIGN_BRIDGE:"postrobot_foreign_bridge",LOCAL_BRIDGE:"postrobot_local_bridge"}};n.POST_MESSAGE_NAMES_LIST=Object.keys(t.POST_MESSAGE_NAMES).map(function(e){return t.POST_MESSAGE_NAMES[e]})},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(7);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(21);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(23);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,n,t){"use strict";function r(e){try{e=JSON.parse(e)}catch(n){return}if(e.type&&w.RECEIVE_MESSAGE_TYPES[e.type])return e}function o(e,n){var t={"window.parent":function(e){return window.parent},"window.opener":function(e){return(0,c.getOpener)(window)},"window.parent.opener":function(e){return(0,c.getOpener)(window.parent)},"window.opener.parent":function(e){return(0,c.getOpener)(window).parent}},r=void 0;try{r=t[e](n)}catch(o){throw new Error("Can not get "+e+": "+o.message)}if(!r)throw new Error("Can not get "+e+": not available");return r}function i(e,n){if(!s.CONFIG.MOCK_MODE&&n){var t=(0,l.getRequestListener)(n.name,e);if(n.type!==s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST||!n.name||!t||t.proxy!==!1){var r=(n.type===s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST||n.type===s.CONSTANTS.POST_MESSAGE_TYPE.ACK)&&l.listeners.response[n.hash];if(!r)for(var i=0;i<l.listeners.proxies.length;i++){var a=l.listeners.proxies[i];if(e===a.from)return a.to}if(n.targetHint){var u=o(n.targetHint,n.target);return delete n.targetHint,u}if(n.target&&n.target!==(0,c.getWindowId)(window)){var d=(0,c.getWindowById)(n.target);if(!d)throw new Error("Unable to find window to proxy message to: "+n.target);return d}}}}function a(e){try{e.source}catch(n){return}var t=e.source,a=e.origin,u=e.data,d=r(u);if(d&&-1===p.indexOf(d.id)){p.push(d.id),(0,c.registerWindow)(d.source,t);var l=void 0;try{l=i(t,d)}catch(n){return c.log.debug(n.message)}var S=void 0;if(S=-1!==s.POST_MESSAGE_NAMES_LIST.indexOf(d.name)||d.type===s.CONSTANTS.POST_MESSAGE_TYPE.ACK||l?"debug":"error"===d.ack?"error":"info",c.log.logLevel(S,[l?"#receiveproxy":"#receive",d.type,d.name,d]),l)return(0,c.isWindowClosed)(l)?c.log.debug("Target window is closed: "+d.target+" - can not proxy "+d.type+" "+d.name):(delete d.target,(0,f.sendMessage)(l,d,d.domain||"*",!0));if(d.originalSource!==d.source){if(d.sourceHint)t=o(d.sourceHint,d.originalSource),delete d.sourceHint;else{var E=(0,c.getWindowById)(d.originalSource);if(!E)throw new Error("Can not find original message source: "+d.originalSource);t=E}(0,c.registerWindow)(d.originalSource,t)}if((0,c.isWindowClosed)(t))return c.log.debug("Source window is closed: "+d.originalSource+" - can not send "+d.type+" "+d.name);if(s.CONFIG.MOCK_MODE)return w.RECEIVE_MESSAGE_TYPES[d.type](t,d,a);d.data&&(d.data=(0,c.deserializeMethods)(t,d.data)),w.RECEIVE_MESSAGE_TYPES[d.type](t,d,a)}}function u(e){try{e.source}catch(n){return}e={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent.origin,data:e.data};try{(0,d.emulateIERestrictions)(e.source,window)}catch(n){return}a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.receiveMessage=a,n.messageListener=u;var s=t(3),c=t(8),d=t(17),f=t(21),l=t(23),w=t(24),p=[]},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(9);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(12);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(13);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(14);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})});var u=t(15);Object.keys(u).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return u[e]}})});var s=t(11);Object.keys(s).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return s[e]}})});var c=t(16);Object.keys(c).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return c[e]}})})},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.promise=n.Promise=void 0;var r=t(10),o=t(11),i=n.Promise=r.SyncPromise,a=n.promise={Promise:i,run:function(e){return i.resolve().then(e)},nextTick:function(e){return new i(function(n,t){(0,o.nextTick)(function(){return a.run(e).then(n,t)})})},method:function(e){return function(){var n=this,t=arguments;return i.resolve().then(function(){return e.apply(n,t)})}},nodeify:function(e,n){return n?void e.then(function(e){n(null,e)},function(e){n(e)}):e},deNodeify:function(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return new i(function(n,r){try{return t.length<e.length?e.apply(void 0,t.concat([function(e,t){return e?r(e):n(t)}])):a.run(function(){return e.apply(void 0,t)}).then(n,r)}catch(o){return r(o)}})},map:function(e,n){for(var t=[],r=function(r){t.push(a.run(function(){return n(e[r])}))},o=0;o<e.length;o++)r(o);return i.all(t)}}},function(e,n){"use strict";function t(e,n,t){function r(){if(a){if(s)return t(o);if(u)return n(i)}}var o,i,a=!1,u=!1,s=!1;try{e(function(e){i=e,u=!0,r()},function(e){o=e,s=!0,r()})}catch(c){return t(c)}a=!0,r()}function r(e){c.push(e),s=s||setTimeout(o,1)}function o(){s=null;var e=c;c=[];for(var n=0;n<e.length;n++){var t=e[n];t.hasHandlers||(t.handlers.push({onError:function(e){t.hasHandlers||i(e)}}),t.dispatch())}}function i(e){setTimeout(function(){throw e})}function a(e){try{if(e&&e.then instanceof Function)return!0}catch(n){return!1}return!1}function u(){window.Promise=d}Object.defineProperty(n,"__esModule",{value:!0}),n.patchPromise=u;var s,c=[],d=n.SyncPromise=function(e,n){if(this.parent=n,this.resolved=!1,this.rejected=!1,this.hasHandlers=!1,this.handlers=[],r(this),e){var o=this;t(e,function(e){return o.resolve(e)},function(e){return o.reject(e)})}};d.resolve=function(e){return a(e)?e:(new d).resolve(e)},d.reject=function(e){return(new d).reject(e)},d.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},d.prototype.reject=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not reject promise with another promise");return this.rejected=!0,this.value=e,this.dispatch(),this},d.prototype.dispatch=function(){var e=this;if(this.resolved||this.rejected)for(var n=function(){var n=e.handlers.shift();try{e.resolved?t=n.onSuccess?n.onSuccess(e.value):e.value:n.onError?t=n.onError(e.value):r=e.value}catch(o){r=o}if(t===e)throw new Error("Can not return a promise from the the then handler of the same promise");return n.promise?void(r?n.promise.reject(r):a(t)?t.then(function(e){n.promise.resolve(e)},function(e){n.promise.reject(e)}):n.promise.resolve(t)):"continue"};this.handlers.length;){var t,r;n()}},d.prototype.then=function(e,n){var t=new d(null,this);return this.handlers.push({promise:t,onSuccess:e,onError:n}),this.hasHandlers=!0,this.dispatch(),t},d.prototype["catch"]=function(e){return this.then(null,e)},d.prototype["finally"]=function(e){return this.then(function(n){return e(),n},function(n){throw e(),n})},d.all=function(e){for(var n=new d,t=e.length,r=[],o=0;o<e.length;o++)e[o].then(function(e){r[o]=e,t-=1,0===t&&n.resolve(r)},function(e){n.reject(e)});return n}},function(e,n,t){"use strict";function r(e){a.push(e),window.postMessage(i,"*")}Object.defineProperty(n,"__esModule",{value:!0}),n.nextTick=r;var o=t(12),i="__nextTick__postRobot__"+o.util.uniqueID(),a=[];window.addEventListener("message",function(e){if(e.data===i){var n=a.shift();n.call()}})},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.util=void 0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=t(3),i=n.util={isPopup:function(){return Boolean(window.opener)},isIframe:function(){return Boolean(window.parent&&window!==window.parent)},isFullpage:function(){return Boolean(!i.isIframe()&&!i.isPopup())},getType:function(){return i.isPopup()?o.CONSTANTS.WINDOW_TYPES.POPUP:i.isIframe()?o.CONSTANTS.WINDOW_TYPES.IFRAME:o.CONSTANTS.WINDOW_TYPES.FULLPAGE},once:function(e){if(!e)return e;var n=!1;return function(){return n?void 0:(n=!0,e.apply(this,arguments))}},noop:function(){},safeHasProp:function(e,n){try{return!!e[n]}catch(t){return!1}},safeGetProp:function(e,n){try{return e[n]}catch(t){return}},listen:function(e,n,t){return e.addEventListener?e.addEventListener(n,t):e.attachEvent("on"+n,t),{cancel:function(){e.removeEventListener?e.removeEventListener(n,t):e.detachEvent("on"+n,t)}}},apply:function(e,n,t){return e.apply instanceof Function?e.apply(n,t):e(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9])},find:function(e,n,t){if(!e)return t;for(var r=0;r<e.length;r++)if(n(e[r]))return e[r];return t},map:function(e,n){for(var t=[],r=0;r<e.length;r++)t.push(n(e[r]));return t},some:function(e,n){n=n||Boolean;for(var t=0;t<e.length;t++)if(n(e[t]))return!0;return!1},keys:function(e){var n=[];for(var t in e)e.hasOwnProperty(t)&&n.push(t);return n},values:function(e){var n=[];for(var t in e)e.hasOwnProperty(t)&&n.push(e[t]);return n},getByValue:function(e,n){for(var t in e)if(e.hasOwnProperty(t)&&e[t]===n)return t},uniqueID:function(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})},memoize:function(e){var n={};return function(){var t=JSON.stringify(Array.prototype.slice.call(arguments));return n.hasOwnProperty(t)||(n[t]=e.apply(this,arguments)),n[t]}},extend:function(e,n){if(!n)return e;for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e},each:function(e,n){if(e instanceof Array)for(var t=0;t<e.length;t++)n(e[t],t);else if(e instanceof Object&&!(e instanceof Function))for(var r in e)e.hasOwnProperty(r)&&n(e[r],r)},replaceObject:function(e,n){var t=e instanceof Array?[]:{};return i.each(e,function(e,o){var a=n(e,o);void 0!==a?t[o]=a:"object"===("undefined"==typeof e?"undefined":r(e))&&null!==e?t[o]=i.replaceObject(e,n):t[o]=e}),t},safeInterval:function(e,n){function t(){r=setTimeout(t,n),e.call()}var r=void 0;return r=setTimeout(t,n),{cancel:function(){clearTimeout(r)}}},intervalTimeout:function(e,n,t){var r=i.safeInterval(function(){e-=n,e=0>=e?0:e,0===e&&r.cancel(),t(e)},n);return r},getDomain:function(e){return e.mockDomain||e.location.protocol+"//"+e.location.host}}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.log=void 0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=t(12),i=t(3),a=["debug","info","warn","error"];Function.prototype.bind&&window.console&&"object"===r(console.log)&&["log","info","warn","error"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var u=n.log={clearLogs:function(){if(window.console&&window.console.clear&&window.console.clear(),i.CONFIG.LOG_TO_PAGE){var e=document.getElementById("postRobotLogs");e&&e.parentNode.removeChild(e)}},writeToPage:function(e,n){setTimeout(function(){var t=document.getElementById("postRobotLogs");t||(t=document.createElement("div"),t.id="postRobotLogs",t.style.cssText="width: 800px; font-family: monospace; white-space: pre-wrap;",document.body.appendChild(t));var r=document.createElement("div"),i=(new Date).toString().split(" ")[4],a=o.util.map(n,function(e){if("string"==typeof e)return e;if(!e)return toString.call(e);var n=void 0;try{n=JSON.stringify(e,0,2)}catch(t){n="[object]"}return"\n\n"+n+"\n\n"}).join(" "),u=i+" "+e+" "+a;r.innerHTML=u;var s={log:"#ddd",warn:"orange",error:"red",info:"blue",debug:"#aaa"}[e];r.style.cssText="margin-top: 10px; color: "+s+";",t.childNodes.length?t.insertBefore(r,t.childNodes[0]):t.appendChild(r)})},logLevel:function(e,n){a.indexOf(e)<a.indexOf(i.CONFIG.LOG_LEVEL)||(n=Array.prototype.slice.call(n),n.unshift(window.location.pathname),n.unshift(window.location.host),n.unshift("<"+o.util.getType().toLowerCase()+">"),n.unshift("[post-robot]"),i.CONFIG.LOG_TO_PAGE&&u.writeToPage(e,n),window.console&&(window.console[e]||(e="log"),window.console[e]&&window.console[e].apply(window.console,n)))},debug:function(){u.logLevel("debug",arguments)},info:function(){u.logLevel("info",arguments)},warn:function(){u.logLevel("warn",arguments)},error:function(){u.logLevel("error",arguments)}}},function(e,n,t){"use strict";function r(e,n){var t=void 0;try{t=e[n]}catch(r){}return t}function o(e){for(var n=p,t=Array.isArray(n),r=0,n=t?n:n[Symbol.iterator]();;){var o;if(t){if(r>=n.length)break;o=n[r++]}else{if(r=n.next(),r.done)break;o=r.value}var i=o;if(i.win===e){if(!i.match)return!1;i.match=!1;try{i.match=w.util.getDomain(window)===w.util.getDomain(e)}catch(a){return}return i.match}}var u=!1;try{w.util.getDomain(window)===w.util.getDomain(e)&&(u=!0)}catch(a){}return p.push({win:e,match:u}),u}function i(e){try{return!e||e.closed||"undefined"==typeof e.closed||o(e)&&r(e,"mockclosed")}catch(n){return!0}}function a(e){if(e)try{return e.opener}catch(n){return}}function u(e){e=e||window;var n=a(e);return n?n:e.parent!==e?e.parent:void 0}function s(e){if(e===window)return E;for(var n=S.length-1;n>=0;n--){var t=S[n];try{if(t.win===e)return t.id}catch(r){continue}}}function c(e){if(e===window.name||e===E)return window;if(window.frames&&window.frames[e])return window.frames[e];for(var n=S.length-1;n>=0;n--){var t=S[n];try{if(t.id===e)return t.win}catch(r){continue}}}function d(e,n){for(var t=S,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var a;if(r){if(o>=t.length)break;a=t[o++]}else{if(o=t.next(),o.done)break;a=o.value}var u=a;try{if(u.id===e&&u.win===n)return}catch(s){continue}if(u.id===e&&u.win!==n&&!i(u.win))throw new Error("Can not register a duplicate window with name "+e)}S.push({id:e,win:n})}function f(e,n){if(e===n)return!0;var t=s(e),r=s(n);return!(!t||!r||t!==r)}function l(e,n){try{return e.top===n.top}catch(t){return!1}}Object.defineProperty(n,"__esModule",{value:!0}),n.isSameDomain=o,n.isWindowClosed=i,n.getOpener=a,n.getParentWindow=u,n.getWindowId=s,n.getWindowById=c,n.registerWindow=d,n.isWindowEqual=f,n.isSameTopWindow=l;var w=t(12),p=[],S=[],E=window.name||w.util.getType()+"_"+w.util.uniqueID(),h=window.open;window.open=function(e,n,t,r){n||(n=w.util.uniqueID(),arguments[1]=n);var o=w.util.apply(h,this,arguments);return d(n,o),o}},function(e,n,t){"use strict";function r(e){return e instanceof Object&&e.__type__===s.CONSTANTS.SERIALIZATION_TYPES.METHOD&&e.__id__}function o(e,n,t){var r=c.util.uniqueID();return w[r]={win:e,method:n},{__type__:s.CONSTANTS.SERIALIZATION_TYPES.METHOD,__id__:r,__name__:t}}function i(e,n){return p(),c.util.replaceObject({obj:n},function(n,t){return n instanceof Function?o(e,n,t):void 0}).obj}function a(e,n){function t(){var t=Array.prototype.slice.call(arguments);return f.log.debug("Call foreign method",n.__name__,t),(0,d.send)(e,s.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{id:n.__id__,name:n.__name__,args:t}).then(function(e){return f.log.debug("Got foreign method result",n.__name__,e.result),e.result})}return t.__name__=n.__name__,t}function u(e,n){return c.util.replaceObject({obj:n},function(n,t){return r(n)?a(e,n):void 0}).obj}Object.defineProperty(n,"__esModule",{value:!0}),n.listenForMethods=void 0,n.serializeMethod=o,n.serializeMethods=i,n.deserializeMethod=a,n.deserializeMethods=u;var s=t(3),c=t(12),d=t(1),f=t(13),l=t(9),w={},p=n.listenForMethods=c.util.once(function(){(0,d.on)(s.CONSTANTS.POST_MESSAGE_NAMES.METHOD,function(e,n){if(!w[n.id])throw new Error("Could not find method with id: "+n.id);if(w[n.id].win!==e)throw new Error("Method window does not match");var t=w[n.id].method;return f.log.debug("Call local method",n.name,n.args),l.promise.run(function(){return t.apply(null,n.args)}).then(function(e){return{result:e,id:n.id,name:n.name}})})})},function(e,n,t){"use strict";function r(){(0,u.on)(i.CONSTANTS.POST_MESSAGE_NAMES.READY,function(e,n){d.push(e);for(var t=f,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;a.win===e&&a.resolve(a.win)}});var e=(0,a.getParentWindow)();e&&(0,u.send)(e,i.CONSTANTS.POST_MESSAGE_NAMES.READY,{})["catch"](function(e){s.log.debug(e.stack||e.toString())})}function o(e){var n=arguments.length<=1||void 0===arguments[1]?5e3:arguments[1];return new c.promise.Promise(function(t,r){return-1!==d.indexOf(e)?t(e):(f.push({win:e,resolve:t}),void setTimeout(function(){return r(new Error("Bridge did not load after "+n+"ms"))},n))})}Object.defineProperty(n,"__esModule",{value:!0}),n.initOnReady=r,n.onWindowReady=o;var i=t(3),a=t(14),u=t(1),s=t(13),c=t(9),d=[],f=[]},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(18);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(19);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(20);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,n,t){"use strict";function r(e){if(d)throw new Error("Only one bridge supported!");var n=new u.promise.Promise(function(e){return window.document.body?e(window.document):void window.document.addEventListener("DOMContentLoaded",function(n){return e(window.document)})});return d=n.then(function(n){u.log.debug("Opening bridge:",e);var t=n.createElement("iframe");return t.setAttribute("name",c),t.setAttribute("id",c),t.setAttribute("style","margin: 0; padding: 0; border: 0px none; overflow: hidden;"),t.setAttribute("frameborder","0"),t.setAttribute("border","0"),t.setAttribute("scrolling","no"),t.setAttribute("allowTransparency","true"),t.setAttribute("tabindex","-1"),t.setAttribute("hidden","true"),t.setAttribute("title",""),t.setAttribute("role","presentation"),t.src=e,n.body.appendChild(t),new u.promise.Promise(function(e,n){t.onload=e,t.onerror=n}).then(function(){return(0,u.onWindowReady)(t.contentWindow)})})}function o(e){try{var n=e.frames[c];if(n&&n!==window&&(0,u.isSameDomain)(n)&&n[a.CONSTANTS.WINDOW_PROPS.POSTROBOT])return n}catch(t){}try{if(!e||!e.frames||!e.frames.length)return;for(var r=0;r<e.frames.length;r++)try{var o=e.frames[r];if(o&&o!==window&&(0,u.isSameDomain)(o)&&o[a.CONSTANTS.WINDOW_PROPS.POSTROBOT])return o}catch(t){continue}}catch(t){return}}function i(){return u.promise.Promise.resolve().then(function(){return d||o(window)})}Object.defineProperty(n,"__esModule",{value:!0}),n.openBridge=r,n.getBridgeFor=o,n.getBridge=i;var a=t(3),u=t(8),s="__postrobot_bridge__",c=s+"_"+u.util.uniqueID(),d=void 0},function(e,n,t){"use strict";function r(){if(window[o.CONSTANTS.WINDOW_PROPS.POSTROBOT])throw new Error("Attempting to load postRobot twice on the same window");window[o.CONSTANTS.WINDOW_PROPS.POSTROBOT]={postMessage:function(e){(0,i.receiveMessage)(e)}}}Object.defineProperty(n,"__esModule",{value:!0}),n.registerGlobals=r;var o=t(3),i=t(6)},function(e,n,t){"use strict";function r(e,n){if(!o.CONFIG.ALLOW_POSTMESSAGE_POPUP&&!(0,i.isSameTopWindow)(e,n))throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}Object.defineProperty(n,"__esModule",{value:!0}),n.emulateIERestrictions=r;var o=t(3),i=t(8)},function(e,n,t){"use strict";function r(e,n){var t=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],r=u.util.uniqueID(),o=(0,u.getWindowId)(window),a=u.util.getType(),s=(0,u.getWindowId)(e);return i({},n,t,{id:n.id||r,source:o,originalSource:n.originalSource||o,windowType:a,originalWindowType:n.originalWindowType||a,target:n.target||s})}function o(e,n,t,o){return u.promise.run(function(){n=r(e,n,{data:(0,u.serializeMethods)(e,n.data),domain:t});var i=void 0;if(i=-1!==a.POST_MESSAGE_NAMES_LIST.indexOf(n.name)||n.type===a.CONSTANTS.POST_MESSAGE_TYPE.ACK||o?"debug":"error"===n.ack?"error":"info",u.log.logLevel(i,[o?"#sendproxy":"#send",n.type,n.name,n]),a.CONFIG.MOCK_MODE)return delete n.target,window[a.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:u.util.getDomain(window),source:window,data:JSON.stringify(n)});if(e===window)throw new Error("Attemping to send message to self");if((0,u.isWindowClosed)(e))throw new Error("Window is closed");u.log.debug("Running send message strategies",n);var c=[];return u.promise.map(u.util.keys(s.SEND_MESSAGE_STRATEGIES),function(r){return u.promise.run(function(){if(!a.CONFIG.ALLOWED_POST_MESSAGE_METHODS[r])throw new Error("Strategy disallowed: "+r);return s.SEND_MESSAGE_STRATEGIES[r](e,n,t)}).then(function(){return c.push(r+": success"),!0},function(e){return c.push(r+": "+e.message),!1})}).then(function(e){var t=u.util.some(e),r=n.type+" "+n.name+" "+(t?"success":"error")+":\n - "+c.join("\n - ")+"\n";if(u.log.debug(r),!t)throw new Error(r)})})}Object.defineProperty(n,"__esModule",{value:!0});var i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};n.buildMessage=r,n.sendMessage=o;var a=t(3),u=t(8),s=t(22)},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}Object.defineProperty(n,"__esModule",{value:!0}),n.SEND_MESSAGE_STRATEGIES=void 0;var o,i=t(3),a=t(8),u=t(17);n.SEND_MESSAGE_STRATEGIES=(o={},r(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,function(e,n,t){return(0,u.emulateIERestrictions)(window,e),e.postMessage(JSON.stringify(n,0,2),t)}),r(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL_METHOD,function(e,n,t){if(!(0,a.isSameDomain)(e))throw new Error("Window is not on the same domain");if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use global method to communicate between two different windows, not between frames");var r=a.util.getDomain(window),o=void 0;try{o=a.util.getDomain(e)}catch(u){throw new Error("Can not read target window domain: "+u.message)}if(r!==o)throw new Error("Can not send global message - source "+r+" does not match target "+o);if("*"!==t&&o!==t)throw new Error("Can post post through global method - specified domain "+t+" does not match target domain "+o);if(!a.util.safeHasProp(e,i.CONSTANTS.WINDOW_PROPS.POSTROBOT))throw new Error("post-robot not available on target window at "+o);e[i.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:a.util.getDomain(window),source:window,data:JSON.stringify(n,0,2)})}),r(o,i.CONSTANTS.SEND_STRATEGIES.FOREIGN_BRIDGE,function(e,n,t){if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");var r=(0,u.getBridgeFor)(e);if(!r)throw new Error("No bridge available in window");if(!(0,a.isSameDomain)(r))throw new Error("Bridge is not on the same domain");var o=a.util.getDomain(window),s=void 0;try{s=a.util.getDomain(r)}catch(c){throw new Error("Can not read bridge window domain: "+c.message)}if(o!==s)throw new Error("Can not accept global message through bridge - source "+o+" does not match bridge "+s);if(!a.util.safeHasProp(r,i.CONSTANTS.WINDOW_PROPS.POSTROBOT))throw new Error("post-robot not available on bridge at "+s);n.targetHint="window.parent",window===(0,a.getOpener)(e)&&(n.sourceHint="window.opener"),r[i.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:a.util.getDomain(window),source:window,data:JSON.stringify(n,0,2)})}),r(o,i.CONSTANTS.SEND_STRATEGIES.LOCAL_BRIDGE,function(e,n,t){if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");if(!n.target)throw new Error("Can not post message down through bridge without target");e===(0,a.getOpener)(window)&&(n.targetHint="window.parent.opener");var r=(0,a.getOpener)(e);return r&&window===r&&(n.sourceHint="window.opener"),r&&window===r.parent&&(n.sourceHint="window.opener.parent"),(0,u.getBridge)().then(function(r){if(!r)throw new Error("Bridge not initialized");if(e===r)throw new Error("Message target is bridge");r.postMessage(JSON.stringify(n,0,2),t)})}),o)},function(e,n,t){"use strict";function r(){n.listeners=s={request:[],response:{},proxies:[]}}function o(e,n){for(var t=s.request,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;if(a.name===e){if(!a.win)return a.options;if(n&&(0,u.isWindowEqual)(n,a.win))return a.options}}}function i(e){for(var n=void 0,t=s.request,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;if(a.options===e){n=a;break}}n&&s.request.splice(s.request.indexOf(n),1)}function a(e,n,t,r){var a=o(e,n);if(a){if(!r)throw new Error("Request listener already exists for "+e);i(a)}s.request.push({name:e,win:n,options:t})}Object.defineProperty(n,"__esModule",{value:!0}),n.listeners=void 0,n.resetListeners=r,n.getRequestListener=o,n.removeRequestListener=i,n.addRequestListener=a;var u=t(8),s=n.listeners=void 0;r()},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}Object.defineProperty(n,"__esModule",{value:!0}),n.RECEIVE_MESSAGE_TYPES=void 0;var o,i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},a=t(3),u=t(8),s=t(21),c=t(23);n.RECEIVE_MESSAGE_TYPES=(o={},r(o,a.CONSTANTS.POST_MESSAGE_TYPE.ACK,function(e,n,t){var r=c.listeners.response[n.hash];if(!r)throw new Error("No handler found for post message ack for message: "+n.name+" in "+window.location.href);r.ack=!0}),r(o,a.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,function(e,n,t){function r(t){return n.fireAndForget||(0,u.isWindowClosed)(e)?u.promise.Promise.resolve():(0,s.sendMessage)(e,i({
target:n.originalSource,hash:n.hash,name:n.name},t),"*")}var o=(0,c.getRequestListener)(n.name,e);return r({type:a.CONSTANTS.POST_MESSAGE_TYPE.ACK}).then(function(){return u.promise.run(function(){if(!o)throw new Error("No postmessage request handler for "+n.name+" in "+window.location.href);if(o.domain){var r="string"==typeof o.domain&&t===o.domain||o.domain instanceof RegExp&&t.match(o.domain);if(!r)throw new Error("Message origin "+t+" does not match domain "+o.domain)}return u.promise.deNodeify(o.handler,e,n.data)}).then(function(e){return r({type:a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:a.CONSTANTS.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){return r({type:a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:a.CONSTANTS.POST_MESSAGE_ACK.ERROR,error:e.stack?e.message+"\n"+e.stack:e.toString()})})})["catch"](function(e){return o&&o.handleError?o.handleError(e):void u.log.error(e.stack||e.toString())})}),r(o,a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,function(e,n,t){var r=c.listeners.response[n.hash];if(!r)throw new Error("No response handler found for post message response "+n.name+" in "+window.location.href);return delete c.listeners.response[n.hash],n.ack===a.CONSTANTS.POST_MESSAGE_ACK.ERROR?r.respond(new Error(n.error)):n.ack===a.CONSTANTS.POST_MESSAGE_ACK.SUCCESS?r.respond(null,n.data||n.response):void 0}),o)},function(e,n,t){"use strict";function r(e){if(!e.name)throw new Error("Expected options.name");e.handler=e.handler||u.util.noop,e.errorHandler=e.errorHandler||function(e){throw e},e.once&&!function(){var n=e.handler;e.handler=u.util.once(function(){return(0,s.removeRequestListener)(e),n.apply(this,arguments)})}();var n=e.override||a.CONFIG.MOCK_MODE;return(0,s.addRequestListener)(e.name,e.window,e,n),e.handleError=function(n){e.errorHandler(n)},e.window&&e.errorOnClose&&!function(){var n=u.util.safeInterval(function(){(0,u.isWindowClosed)(e.window)&&(n.cancel(),e.handleError(new Error("Post message target window is closed")))},50)}(),{cancel:function(){(0,s.removeRequestListener)(e)}}}function o(e,n,t,o){return n instanceof Function&&(o=t,t=n,n={}),n.name=e,n.handler=t||n.handler,n.errorHandler=o||n.errorHandler,r(n)}function i(e,n,t,o){n instanceof Function&&(o=t,t=n,n={}),n.name=e,n.handler=t||n.handler,n.errorHandler=o||n.errorHandler,n.once=!0;var i=new u.promise.Promise(function(e,t){n.handler=n.handler||e,n.errorHandler=n.errorHandler||t}),a=r(n);return u.util.extend(i,a),i}Object.defineProperty(n,"__esModule",{value:!0}),n.listen=r,n.on=o,n.once=i;var a=t(3),u=t(8),s=t(6)},function(e,n,t){"use strict";function r(e,n){i.listeners.proxies.push({from:e,to:n}),i.listeners.proxies.push({from:n,to:e})}function o(e,n){for(var t=[],r=0;r<i.listeners.proxies.length;r++){var o=i.listeners.proxies[r];(o.to===e&&o.from===n||o.to===n&&o.from===e)&&t.push(o)}for(var a=0;a<t.length;a++)i.listeners.proxies.splice(i.listeners.proxies.indexOf(t[a]),1)}Object.defineProperty(n,"__esModule",{value:!0}),n.proxy=r,n.unproxy=o;var i=t(6)},function(e,n,t){"use strict";function r(){i.CONFIG.MOCK_MODE=!0}function o(){i.CONFIG.MOCK_MODE=!1}Object.defineProperty(n,"__esModule",{value:!0}),n.CONSTANTS=n.CONFIG=void 0,n.enableMockMode=r,n.disableMockMode=o;var i=t(3);Object.defineProperty(n,"CONFIG",{enumerable:!0,get:function(){return i.CONFIG}}),Object.defineProperty(n,"CONSTANTS",{enumerable:!0,get:function(){return i.CONSTANTS}})}])});
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("postRobot",[],n):"object"==typeof exports?exports.postRobot=n():e.postRobot=n()}(this,function(){return function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){"use strict";function t(){(0,u.registerGlobals)(),i.util.listen(window,"message",a.messageListener),(0,i.initOnReady)()}Object.defineProperty(n,"__esModule",{value:!0}),n.Promise=void 0;var o=r(1);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=r(8);Object.defineProperty(n,"Promise",{enumerable:!0,get:function(){return i.Promise}});var a=r(6),u=r(17);t(),n["default"]=e.exports},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.util=n.openBridge=n.reset=n.parent=void 0;var t=r(2);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return t[e]}})});var o=r(25);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=r(26);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(27);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})});var u=r(6);Object.defineProperty(n,"reset",{enumerable:!0,get:function(){return u.resetListeners}});var s=r(18);Object.defineProperty(n,"openBridge",{enumerable:!0,get:function(){return s.openBridge}});var c=r(12);Object.defineProperty(n,"util",{enumerable:!0,get:function(){return c.util}});var d=r(14);n.parent=(0,d.getParentWindow)()},function(e,n,r){"use strict";function t(e){return s.promise.nodeify(new s.promise.Promise(function(n,r){if(!e.name)throw new Error("Expected options.name");if(!e.window)throw new Error("Expected options.window");if(a.CONFIG.MOCK_MODE)e.window=window;else if("string"==typeof e.window){var t=document.getElementById(e.window);if(!t)throw new Error("Expected options.window "+e.window+" to be a valid element id");if("iframe"!==t.tagName.toLowerCase())throw new Error("Expected options.window "+e.window+" to be an iframe");if(e.window=t.contentWindow,!e.window)throw new Error("Expected options.window")}var o=e.name+"_"+s.util.uniqueID();if(u.listeners.response[o]=e,(0,s.isWindowClosed)(e.window))throw new Error("Target window is closed");var i=!1;return e.respond=function(e,t){return e||(i=!0),e?r(e):n(t)},s.promise.run(function(){return(0,s.getParentWindow)(e.window)===window?(0,s.onWindowReady)(e.window):void 0}).then(function(){if((0,u.sendMessage)(e.window,{hash:o,type:a.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,name:e.name,data:e.data,fireAndForget:e.fireAndForget},e.domain||"*")["catch"](r),e.fireAndForget)return n();var t=s.util.intervalTimeout(a.CONFIG.ACK_TIMEOUT,100,function(n){return e.ack||(0,s.isWindowClosed)(e.window)?t.cancel():n?void 0:r(new Error("No ack for postMessage "+e.name+" in "+a.CONFIG.ACK_TIMEOUT+"ms"))});e.timeout&&!function(){var n=s.util.intervalTimeout(e.timeout,100,function(t){return i||(0,s.isWindowClosed)(e.window)?n.cancel():t?void 0:r(new Error("Post message response timed out after "+e.timeout+" ms"))},e.timeout)}()})["catch"](r)}),e.callback)}function o(e,n,r,o,i){return i||(!o&&r instanceof Function?(i=r,o={},r={}):o instanceof Function&&(i=o,o={})),o=o||{},o.window=e,o.name=n,o.data=r,o.callback=i,t(o)}function i(e,n,r,t){var i=(0,s.getParentWindow)();if(!window)throw new Error("Window does not have a parent");return o(i,e,n,r,t)}Object.defineProperty(n,"__esModule",{value:!0}),n.request=t,n.send=o,n.sendToParent=i;var a=r(3),u=r(6),s=r(8)},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(4);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return t[e]}})});var o=r(5);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,n,r){"use strict";function t(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}Object.defineProperty(n,"__esModule",{value:!0}),n.CONFIG=void 0;var o,i=r(5);n.CONFIG={ALLOW_POSTMESSAGE_POPUP:!1,LOG_LEVEL:"info",ACK_TIMEOUT:500,LOG_TO_PAGE:!1,MOCK_MODE:!1,ALLOWED_POST_MESSAGE_METHODS:(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,!0),t(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL_METHOD,!0),t(o,i.CONSTANTS.SEND_STRATEGIES.FOREIGN_BRIDGE,!0),t(o,i.CONSTANTS.SEND_STRATEGIES.LOCAL_BRIDGE,!0),o)}},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=n.CONSTANTS={POST_MESSAGE_TYPE:{REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},POST_MESSAGE_ACK:{SUCCESS:"success",ERROR:"error"},POST_MESSAGE_NAMES:{METHOD:"postrobot_method",READY:"postrobot_ready"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method"},SEND_STRATEGIES:{POST_MESSAGE:"postrobot_post_message",GLOBAL_METHOD:"postrobot_global_method",FOREIGN_BRIDGE:"postrobot_foreign_bridge",LOCAL_BRIDGE:"postrobot_local_bridge"}};n.POST_MESSAGE_NAMES_LIST=Object.keys(r.POST_MESSAGE_NAMES).map(function(e){return r.POST_MESSAGE_NAMES[e]})},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(7);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return t[e]}})});var o=r(21);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=r(23);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,n,r){"use strict";function t(e){try{e=JSON.parse(e)}catch(n){return}if(e.type&&w.RECEIVE_MESSAGE_TYPES[e.type])return e}function o(e,n){var r={"window.parent":function(e){return window.parent},"window.opener":function(e){return(0,c.getOpener)(window)},"window.parent.opener":function(e){return(0,c.getOpener)(window.parent)},"window.opener.parent":function(e){return(0,c.getOpener)(window).parent}},t=void 0;try{t=r[e](n)}catch(o){throw new Error("Can not get "+e+": "+o.message)}if(!t)throw new Error("Can not get "+e+": not available");return t}function i(e,n){if(!s.CONFIG.MOCK_MODE&&n){var r=(0,l.getRequestListener)(n.name,e);if(n.type!==s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST||!n.name||!r||r.proxy!==!1){var t=(n.type===s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST||n.type===s.CONSTANTS.POST_MESSAGE_TYPE.ACK)&&l.listeners.response[n.hash];if(!t)for(var i=0;i<l.listeners.proxies.length;i++){var a=l.listeners.proxies[i];if(e===a.from)return a.to}if(n.targetHint){var u=o(n.targetHint,n.target);return delete n.targetHint,u}if(n.target&&n.target!==(0,c.getWindowId)(window)){var d=(0,c.getWindowById)(n.target);if(!d)throw new Error("Unable to find window to proxy message to: "+n.target);return d}}}}function a(e){try{e.source}catch(n){return}var r=e.source,a=e.origin,u=e.data,d=t(u);if(d&&-1===p.indexOf(d.id)){p.push(d.id),(0,c.registerWindow)(d.source,r);var l=void 0;try{l=i(r,d)}catch(n){return c.log.debug(n.message)}var S=void 0;if(S=-1!==s.POST_MESSAGE_NAMES_LIST.indexOf(d.name)||d.type===s.CONSTANTS.POST_MESSAGE_TYPE.ACK||l?"debug":"error"===d.ack?"error":"info",c.log.logLevel(S,[l?"#receiveproxy":"#receive",d.type,d.name,d]),l)return(0,c.isWindowClosed)(l)?c.log.debug("Target window is closed: "+d.target+" - can not proxy "+d.type+" "+d.name):(delete d.target,(0,f.sendMessage)(l,d,d.domain||"*",!0));if(d.originalSource!==d.source){if(d.sourceHint)r=o(d.sourceHint,d.originalSource),delete d.sourceHint;else{var E=(0,c.getWindowById)(d.originalSource);if(!E)throw new Error("Can not find original message source: "+d.originalSource);r=E}(0,c.registerWindow)(d.originalSource,r)}if((0,c.isWindowClosed)(r))return c.log.debug("Source window is closed: "+d.originalSource+" - can not send "+d.type+" "+d.name);if(s.CONFIG.MOCK_MODE)return w.RECEIVE_MESSAGE_TYPES[d.type](r,d,a);d.data&&(d.data=(0,c.deserializeMethods)(r,d.data)),w.RECEIVE_MESSAGE_TYPES[d.type](r,d,a)}}function u(e){try{e.source}catch(n){return}e={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent.origin,data:e.data};try{(0,d.emulateIERestrictions)(e.source,window)}catch(n){return}a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.receiveMessage=a,n.messageListener=u;var s=r(3),c=r(8),d=r(17),f=r(21),l=r(23),w=r(24),p=[]},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(9);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return t[e]}})});var o=r(12);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=r(13);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=r(14);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})});var u=r(15);Object.keys(u).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return u[e]}})});var s=r(11);Object.keys(s).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return s[e]}})});var c=r(16);Object.keys(c).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return c[e]}})})},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.promise=n.Promise=void 0;var t=r(10),o=r(11),i=n.Promise=t.SyncPromise,a=n.promise={Promise:i,run:function(e){return i.resolve().then(e)},nextTick:function(e){return new i(function(n,r){(0,o.nextTick)(function(){return a.run(e).then(n,r)})})},method:function(e){return function(){var n=this,r=arguments;return i.resolve().then(function(){return e.apply(n,r)})}},nodeify:function(e,n){return n?void e.then(function(e){n(null,e)},function(e){n(e)}):e},deNodeify:function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),t=1;n>t;t++)r[t-1]=arguments[t];return new i(function(n,t){try{return r.length<e.length?e.apply(void 0,r.concat([function(e,r){return e?t(e):n(r)}])):a.run(function(){return e.apply(void 0,r)}).then(n,t)}catch(o){return t(o)}})},map:function(e,n){for(var r=[],t=function(t){r.push(a.run(function(){return n(e[t])}))},o=0;o<e.length;o++)t(o);return i.all(r)}}},function(e,n){"use strict";function r(e,n,r){function t(){if(a){if(s)return r(o);if(u)return n(i)}}var o,i,a=!1,u=!1,s=!1;try{e(function(e){i=e,u=!0,t()},function(e){o=e,s=!0,t()})}catch(c){return r(c)}a=!0,t()}function t(e){c.push(e),s=s||setTimeout(o,1)}function o(){s=null;var e=c;c=[];for(var n=0;n<e.length;n++){var r=e[n];r.hasHandlers||(r.handlers.push({onError:function(e){r.hasHandlers||i(e)}}),r.dispatch())}}function i(e){setTimeout(function(){throw e})}function a(e){try{if(e&&e.then instanceof Function)return!0}catch(n){return!1}return!1}function u(){window.Promise=d}Object.defineProperty(n,"__esModule",{value:!0}),n.patchPromise=u;var s,c=[],d=n.SyncPromise=function(e,n){if(this.parent=n,this.resolved=!1,this.rejected=!1,this.hasHandlers=!1,this.handlers=[],t(this),e){var o=this;r(e,function(e){return o.resolve(e)},function(e){return o.reject(e)})}};d.resolve=function(e){return a(e)?e:(new d).resolve(e)},d.reject=function(e){return(new d).reject(e)},d.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},d.prototype.reject=function(e){if(this.resolved||this.rejected)return this;if(a(e))throw new Error("Can not reject promise with another promise");return this.rejected=!0,this.value=e,this.dispatch(),this},d.prototype.dispatch=function(){var e=this;if(this.resolved||this.rejected)for(var n=function(){var n=e.handlers.shift();try{e.resolved?r=n.onSuccess?n.onSuccess(e.value):e.value:n.onError?r=n.onError(e.value):t=e.value}catch(o){t=o}if(r===e)throw new Error("Can not return a promise from the the then handler of the same promise");return n.promise?void(t?n.promise.reject(t):a(r)?r.then(function(e){n.promise.resolve(e)},function(e){n.promise.reject(e)}):n.promise.resolve(r)):"continue"};this.handlers.length;){var r,t;n()}},d.prototype.then=function(e,n){var r=new d(null,this);return this.handlers.push({promise:r,onSuccess:e,onError:n}),this.hasHandlers=!0,this.dispatch(),r},d.prototype["catch"]=function(e){return this.then(null,e)},d.prototype["finally"]=function(e){return this.then(function(n){return e(),n},function(n){throw e(),n})},d.all=function(e){for(var n=new d,r=e.length,t=[],o=0;o<e.length;o++)e[o].then(function(e){t[o]=e,r-=1,0===r&&n.resolve(t)},function(e){n.reject(e)});return n}},function(e,n,r){"use strict";function t(e){a.push(e),window.postMessage(i,"*")}Object.defineProperty(n,"__esModule",{value:!0}),n.nextTick=t;var o=r(12),i="__nextTick__postRobot__"+o.util.uniqueID(),a=[];window.addEventListener("message",function(e){if(e.data===i){var n=a.shift();n.call()}})},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.util=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=r(3),i=n.util={isPopup:function(){return Boolean(window.opener)},isIframe:function(){return Boolean(window.parent&&window!==window.parent)},isFullpage:function(){return Boolean(!i.isIframe()&&!i.isPopup())},getType:function(){return i.isPopup()?o.CONSTANTS.WINDOW_TYPES.POPUP:i.isIframe()?o.CONSTANTS.WINDOW_TYPES.IFRAME:o.CONSTANTS.WINDOW_TYPES.FULLPAGE},once:function(e){if(!e)return e;var n=!1;return function(){return n?void 0:(n=!0,e.apply(this,arguments))}},noop:function(){},safeHasProp:function(e,n){try{return!!e[n]}catch(r){return!1}},safeGetProp:function(e,n){try{return e[n]}catch(r){return}},listen:function(e,n,r){return e.addEventListener?e.addEventListener(n,r):e.attachEvent("on"+n,r),{cancel:function(){e.removeEventListener?e.removeEventListener(n,r):e.detachEvent("on"+n,r)}}},apply:function(e,n,r){return e.apply instanceof Function?e.apply(n,r):e(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],r[9])},find:function(e,n,r){if(!e)return r;for(var t=0;t<e.length;t++)if(n(e[t]))return e[t];return r},map:function(e,n){for(var r=[],t=0;t<e.length;t++)r.push(n(e[t]));return r},some:function(e,n){n=n||Boolean;for(var r=0;r<e.length;r++)if(n(e[r]))return!0;return!1},keys:function(e){var n=[];for(var r in e)e.hasOwnProperty(r)&&n.push(r);return n},values:function(e){var n=[];for(var r in e)e.hasOwnProperty(r)&&n.push(e[r]);return n},getByValue:function(e,n){for(var r in e)if(e.hasOwnProperty(r)&&e[r]===n)return r},uniqueID:function(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})},memoize:function(e){var n={};return function(){var r=JSON.stringify(Array.prototype.slice.call(arguments));return n.hasOwnProperty(r)||(n[r]=e.apply(this,arguments)),n[r]}},extend:function(e,n){if(!n)return e;for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r]);return e},each:function(e,n){if(e instanceof Array)for(var r=0;r<e.length;r++)n(e[r],r);else if(e instanceof Object&&!(e instanceof Function))for(var t in e)e.hasOwnProperty(t)&&n(e[t],t)},replaceObject:function(e,n){var r=e instanceof Array?[]:{};return i.each(e,function(e,o){var a=n(e,o);void 0!==a?r[o]=a:"object"===("undefined"==typeof e?"undefined":t(e))&&null!==e?r[o]=i.replaceObject(e,n):r[o]=e}),r},safeInterval:function(e,n){function r(){t=setTimeout(r,n),e.call()}var t=void 0;return t=setTimeout(r,n),{cancel:function(){clearTimeout(t)}}},intervalTimeout:function(e,n,r){var t=i.safeInterval(function(){e-=n,e=0>=e?0:e,0===e&&t.cancel(),r(e)},n);return t},getDomain:function(e){return e.mockDomain||e.location.protocol+"//"+e.location.host}}},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.log=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=r(12),i=r(3),a=["debug","info","warn","error"];Function.prototype.bind&&window.console&&"object"===t(console.log)&&["log","info","warn","error"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var u=n.log={clearLogs:function(){if(window.console&&window.console.clear&&window.console.clear(),i.CONFIG.LOG_TO_PAGE){var e=document.getElementById("postRobotLogs");e&&e.parentNode.removeChild(e)}},writeToPage:function(e,n){setTimeout(function(){var r=document.getElementById("postRobotLogs");r||(r=document.createElement("div"),r.id="postRobotLogs",r.style.cssText="width: 800px; font-family: monospace; white-space: pre-wrap;",document.body.appendChild(r));var t=document.createElement("div"),i=(new Date).toString().split(" ")[4],a=o.util.map(n,function(e){if("string"==typeof e)return e;if(!e)return toString.call(e);var n=void 0;try{n=JSON.stringify(e,0,2)}catch(r){n="[object]"}return"\n\n"+n+"\n\n"}).join(" "),u=i+" "+e+" "+a;t.innerHTML=u;var s={log:"#ddd",warn:"orange",error:"red",info:"blue",debug:"#aaa"}[e];t.style.cssText="margin-top: 10px; color: "+s+";",r.childNodes.length?r.insertBefore(t,r.childNodes[0]):r.appendChild(t)})},logLevel:function(e,n){a.indexOf(e)<a.indexOf(i.CONFIG.LOG_LEVEL)||(n=Array.prototype.slice.call(n),n.unshift(window.location.pathname),n.unshift(window.location.host),n.unshift("<"+o.util.getType().toLowerCase()+">"),n.unshift("[post-robot]"),i.CONFIG.LOG_TO_PAGE&&u.writeToPage(e,n),window.console&&(window.console[e]||(e="log"),window.console[e]&&window.console[e].apply(window.console,n)))},debug:function(){u.logLevel("debug",arguments)},info:function(){u.logLevel("info",arguments)},warn:function(){u.logLevel("warn",arguments)},error:function(){u.logLevel("error",arguments)}}},function(e,n,r){"use strict";function t(e,n){var r=void 0;try{r=e[n]}catch(t){}return r}function o(e){for(var n=S,r=Array.isArray(n),t=0,n=r?n:n[Symbol.iterator]();;){var o;if(r){if(t>=n.length)break;o=n[t++]}else{if(t=n.next(),t.done)break;o=t.value}var i=o;if(i.win===e){if(!i.match)return!1;i.match=!1;try{i.match=p.util.getDomain(window)===p.util.getDomain(e)}catch(a){return}return i.match}}var u=!1;try{p.util.getDomain(window)===p.util.getDomain(e)&&(u=!0)}catch(a){}return S.push({win:e,match:u}),u}function i(e){try{return!e||e.closed||"undefined"==typeof e.closed||o(e)&&t(e,"mockclosed")}catch(n){return!0}}function a(e){if(e)try{return e.opener}catch(n){return}}function u(e){e=e||window;var n=a(e);return n?n:e.parent!==e?e.parent:void 0}function s(e){if(e===window)return h;for(var n=E.length-1;n>=0;n--){var r=E[n];try{if(r.win===e)return r.id}catch(t){continue}}}function c(e){if(e===window.name||e===h)return window;if(window.frames&&window.frames[e])return window.frames[e];for(var n=E.length-1;n>=0;n--){var r=E[n];try{if(r.id===e)return r.win}catch(t){continue}}}function d(e,n){for(var r=E,t=Array.isArray(r),o=0,r=t?r:r[Symbol.iterator]();;){var a;if(t){if(o>=r.length)break;a=r[o++]}else{if(o=r.next(),o.done)break;a=o.value}var u=a;try{if(u.id===e&&u.win===n)return}catch(s){continue}if(u.id===e&&u.win!==n&&!i(u.win))throw new Error("Can not register a duplicate window with name "+e)}E.push({id:e,win:n})}function f(e,n){if(e===n)return!0;var r=s(e),t=s(n);return!(!r||!t||r!==t)}function l(e,n){try{return e.top===n.top}catch(r){return!1}}function w(e){O.push(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.isSameDomain=o,n.isWindowClosed=i,n.getOpener=a,n.getParentWindow=u,n.getWindowId=s,n.getWindowById=c,n.registerWindow=d,n.isWindowEqual=f,n.isSameTopWindow=l,n.onOpenWindow=w;var p=r(12),S=[],E=[],h=window.name||p.util.getType()+"_"+p.util.uniqueID(),O=[],m=window.open;window.open=function(e,n,r,t){n||(n=p.util.uniqueID(),arguments[1]=n);for(var o=p.util.apply(m,this,arguments),i=O,a=Array.isArray(i),u=0,i=a?i:i[Symbol.iterator]();;){var s;if(a){if(u>=i.length)break;s=i[u++]}else{if(u=i.next(),u.done)break;s=u.value}var c=s;c(e,o)}return d(n,o),o}},function(e,n,r){"use strict";function t(e){return e instanceof Object&&e.__type__===s.CONSTANTS.SERIALIZATION_TYPES.METHOD&&e.__id__}function o(e,n,r){var t=c.util.uniqueID();return w[t]={win:e,method:n},{__type__:s.CONSTANTS.SERIALIZATION_TYPES.METHOD,__id__:t,__name__:r}}function i(e,n){return p(),c.util.replaceObject({obj:n},function(n,r){return n instanceof Function?o(e,n,r):void 0}).obj}function a(e,n){function r(){var r=Array.prototype.slice.call(arguments);return f.log.debug("Call foreign method",n.__name__,r),(0,d.send)(e,s.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{id:n.__id__,name:n.__name__,args:r}).then(function(e){return f.log.debug("Got foreign method result",n.__name__,e.result),e.result})}return r.__name__=n.__name__,r}function u(e,n){return c.util.replaceObject({obj:n},function(n,r){return t(n)?a(e,n):void 0}).obj}Object.defineProperty(n,"__esModule",{value:!0}),n.listenForMethods=void 0,n.serializeMethod=o,n.serializeMethods=i,n.deserializeMethod=a,n.deserializeMethods=u;var s=r(3),c=r(12),d=r(1),f=r(13),l=r(9),w={},p=n.listenForMethods=c.util.once(function(){(0,d.on)(s.CONSTANTS.POST_MESSAGE_NAMES.METHOD,function(e,n){if(!w[n.id])throw new Error("Could not find method with id: "+n.id);if(w[n.id].win!==e)throw new Error("Method window does not match");var r=w[n.id].method;return f.log.debug("Call local method",n.name,n.args),l.promise.run(function(){return r.apply(null,n.args)}).then(function(e){return{result:e,id:n.id,name:n.name}})})})},function(e,n,r){"use strict";function t(){(0,u.on)(i.CONSTANTS.POST_MESSAGE_NAMES.READY,function(e,n){d.push(e);for(var r=f,t=Array.isArray(r),o=0,r=t?r:r[Symbol.iterator]();;){var i;if(t){if(o>=r.length)break;i=r[o++]}else{if(o=r.next(),o.done)break;i=o.value}var a=i;a.win===e&&a.resolve(a.win)}});var e=(0,a.getParentWindow)();e&&(0,u.send)(e,i.CONSTANTS.POST_MESSAGE_NAMES.READY,{})["catch"](function(e){s.log.debug(e.stack||e.toString())})}function o(e){var n=arguments.length<=1||void 0===arguments[1]?5e3:arguments[1],r=arguments.length<=2||void 0===arguments[2]?"Window":arguments[2];return new c.promise.Promise(function(t,o){return-1!==d.indexOf(e)?t(e):(f.push({win:e,resolve:t}),void setTimeout(function(){return o(new Error(r+" did not load after "+n+"ms"))},n))})}Object.defineProperty(n,"__esModule",{value:!0}),n.initOnReady=t,n.onWindowReady=o;var i=r(3),a=r(14),u=r(1),s=r(13),c=r(9),d=[],f=[]},function(e,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=r(18);Object.keys(t).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return t[e]}})});var o=r(19);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=r(20);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,n,r){"use strict";function t(e){var n=void 0;return n=0===e.indexOf("http://")||0===e.indexOf("https://")?e:window.location.href,n=n.split("/").slice(0,3).join("/")}function o(){return new d.promise.Promise(function(e){return window.document&&window.document.body?e(window.document):void window.document.addEventListener("DOMContentLoaded",function(n){return e(window.document)})})}function i(e){for(var n=l,r=Array.isArray(n),t=0,n=r?n:n[Symbol.iterator]();;){var o;if(r){if(t>=n.length)break;o=n[t++]}else{if(t=n.next(),t.done)break;o=t.value}var i=o;if(e===i.domain)return i.bridge}}function a(e){for(var n=l,r=Array.isArray(n),t=0,n=r?n:n[Symbol.iterator]();;){var o;if(r){if(t>=n.length)break;o=n[t++]}else{if(t=n.next(),t.done)break;o=t.value}var i=o;if(-1!==i.windows.indexOf(e))return i.bridge}}function u(e){var n=t(e),r=i(n);if(r)return r;var a=f+"_"+d.util.uniqueID(),u=o().then(function(n){d.log.debug("Opening bridge:",e);var r=n.createElement("iframe");return r.setAttribute("name",a),r.setAttribute("id",a),r.setAttribute("style","margin: 0; padding: 0; border: 0px none; overflow: hidden;"),r.setAttribute("frameborder","0"),r.setAttribute("border","0"),r.setAttribute("scrolling","no"),r.setAttribute("allowTransparency","true"),r.setAttribute("tabindex","-1"),r.setAttribute("hidden","true"),r.setAttribute("title",""),r.setAttribute("role","presentation"),r.src=e,n.body.appendChild(r),new d.promise.Promise(function(e,n){r.onload=e,r.onerror=n}).then(function(){return(0,d.onWindowReady)(r.contentWindow,5e3,"Bridge "+e)})});return l.push({id:a,domain:n,bridge:u,windows:w[n]||[]}),delete w[n],u}function s(e){try{if(!e||!e.frames||!e.frames.length)return;for(var n=0;n<e.frames.length;n++)try{var r=e.frames[n];if(r&&r!==window&&(0,d.isSameDomain)(r)&&r[c.CONSTANTS.WINDOW_PROPS.POSTROBOT])return r}catch(t){continue}}catch(t){return}}Object.defineProperty(n,"__esModule",{value:!0}),n.getBridgeByDomain=i,n.getBridgeByWindow=a,n.openBridge=u,n.getRemoteBridge=s;var c=r(3),d=r(8),f="__postrobot_bridge__",l=[],w={};(0,d.onOpenWindow)(function(e,n){for(var r=t(e),o=l,i=Array.isArray(o),a=0,o=i?o:o[Symbol.iterator]();;){var u;if(i){if(a>=o.length)break;u=o[a++]}else{if(a=o.next(),a.done)break;u=a.value}var s=u;if(r===s.domain)return void s.windows.push(n)}w[r]=w[r]||[],w[r].push(n)})},function(e,n,r){"use strict";function t(){if(window[o.CONSTANTS.WINDOW_PROPS.POSTROBOT])throw new Error("Attempting to load postRobot twice on the same window");window[o.CONSTANTS.WINDOW_PROPS.POSTROBOT]={postMessage:function(e){(0,i.receiveMessage)(e)}}}Object.defineProperty(n,"__esModule",{value:!0}),n.registerGlobals=t;var o=r(3),i=r(6)},function(e,n,r){"use strict";function t(e,n){if(!o.CONFIG.ALLOW_POSTMESSAGE_POPUP&&!(0,i.isSameTopWindow)(e,n))throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}Object.defineProperty(n,"__esModule",{value:!0}),n.emulateIERestrictions=t;var o=r(3),i=r(8)},function(e,n,r){"use strict";function t(e,n){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],t=u.util.uniqueID(),o=(0,u.getWindowId)(window),a=u.util.getType(),s=(0,u.getWindowId)(e);return i({},n,r,{id:n.id||t,source:o,originalSource:n.originalSource||o,windowType:a,originalWindowType:n.originalWindowType||a,target:n.target||s})}function o(e,n,r,o){return u.promise.run(function(){n=t(e,n,{data:(0,u.serializeMethods)(e,n.data),domain:r});var i=void 0;if(i=-1!==a.POST_MESSAGE_NAMES_LIST.indexOf(n.name)||n.type===a.CONSTANTS.POST_MESSAGE_TYPE.ACK||o?"debug":"error"===n.ack?"error":"info",u.log.logLevel(i,[o?"#sendproxy":"#send",n.type,n.name,n]),a.CONFIG.MOCK_MODE)return delete n.target,window[a.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:u.util.getDomain(window),source:window,data:JSON.stringify(n)});if(e===window)throw new Error("Attemping to send message to self");if((0,u.isWindowClosed)(e))throw new Error("Window is closed");u.log.debug("Running send message strategies",n);var c=[];return u.promise.map(u.util.keys(s.SEND_MESSAGE_STRATEGIES),function(t){return u.promise.run(function(){if(!a.CONFIG.ALLOWED_POST_MESSAGE_METHODS[t])throw new Error("Strategy disallowed: "+t);return s.SEND_MESSAGE_STRATEGIES[t](e,n,r)}).then(function(){return c.push(t+": success"),!0},function(e){return c.push(t+": "+e.message),!1})}).then(function(e){var r=u.util.some(e),t=n.type+" "+n.name+" "+(r?"success":"error")+":\n - "+c.join("\n - ")+"\n";if(u.log.debug(t),!r)throw new Error(t)})})}Object.defineProperty(n,"__esModule",{value:!0});var i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e};n.buildMessage=t,n.sendMessage=o;var a=r(3),u=r(8),s=r(22)},function(e,n,r){"use strict";function t(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}Object.defineProperty(n,"__esModule",{value:!0}),n.SEND_MESSAGE_STRATEGIES=void 0;var o,i=r(3),a=r(8),u=r(17);n.SEND_MESSAGE_STRATEGIES=(o={},t(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,function(e,n,r){return(0,u.emulateIERestrictions)(window,e),e.postMessage(JSON.stringify(n,0,2),r)}),t(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL_METHOD,function(e,n,r){if(!(0,a.isSameDomain)(e))throw new Error("Window is not on the same domain");if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use global method to communicate between two different windows, not between frames");var t=a.util.getDomain(window),o=void 0;try{o=a.util.getDomain(e)}catch(u){throw new Error("Can not read target window domain: "+u.message)}if(t!==o)throw new Error("Can not send global message - source "+t+" does not match target "+o);if("*"!==r&&o!==r)throw new Error("Can post post through global method - specified domain "+r+" does not match target domain "+o);if(!a.util.safeHasProp(e,i.CONSTANTS.WINDOW_PROPS.POSTROBOT))throw new Error("post-robot not available on target window at "+o);e[i.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:a.util.getDomain(window),source:window,data:JSON.stringify(n,0,2)})}),t(o,i.CONSTANTS.SEND_STRATEGIES.FOREIGN_BRIDGE,function(e,n,r){if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");var t=(0,u.getRemoteBridge)(e);if(!t)throw new Error("No bridge available in window");if(!(0,a.isSameDomain)(t))throw new Error("Bridge is not on the same domain");var o=a.util.getDomain(window),s=void 0;try{s=a.util.getDomain(t)}catch(c){throw new Error("Can not read bridge window domain: "+c.message)}if(o!==s)throw new Error("Can not accept global message through bridge - source "+o+" does not match bridge "+s);if(!a.util.safeHasProp(t,i.CONSTANTS.WINDOW_PROPS.POSTROBOT))throw new Error("post-robot not available on bridge at "+s);n.targetHint="window.parent",window===(0,a.getOpener)(e)&&(n.sourceHint="window.opener"),t[i.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:a.util.getDomain(window),source:window,data:JSON.stringify(n,0,2)})}),t(o,i.CONSTANTS.SEND_STRATEGIES.LOCAL_BRIDGE,function(e,n,r){if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");if(!n.target)throw new Error("Can not post message down through bridge without target");e===(0,a.getOpener)(window)&&(n.targetHint="window.parent.opener");var t=(0,a.getOpener)(e);return t&&window===t&&(n.sourceHint="window.opener"),t&&window===t.parent&&(n.sourceHint="window.opener.parent"),(0,u.getBridgeByWindow)(e).then(function(t){if(!t)throw new Error("Bridge not initialized");if(e===t)throw new Error("Message target is bridge");t.postMessage(JSON.stringify(n,0,2),r)})}),o)},function(e,n,r){"use strict";function t(){n.listeners=s={request:[],response:{},proxies:[]}}function o(e,n){for(var r=s.request,t=Array.isArray(r),o=0,r=t?r:r[Symbol.iterator]();;){var i;if(t){if(o>=r.length)break;i=r[o++]}else{if(o=r.next(),o.done)break;i=o.value}var a=i;if(a.name===e){if(!a.win)return a.options;if(n&&(0,u.isWindowEqual)(n,a.win))return a.options}}}function i(e){for(var n=void 0,r=s.request,t=Array.isArray(r),o=0,r=t?r:r[Symbol.iterator]();;){var i;if(t){if(o>=r.length)break;i=r[o++]}else{if(o=r.next(),o.done)break;i=o.value}var a=i;if(a.options===e){n=a;break}}n&&s.request.splice(s.request.indexOf(n),1)}function a(e,n,r,t){var a=o(e,n);if(a){if(!t)throw new Error("Request listener already exists for "+e);i(a)}s.request.push({name:e,
win:n,options:r})}Object.defineProperty(n,"__esModule",{value:!0}),n.listeners=void 0,n.resetListeners=t,n.getRequestListener=o,n.removeRequestListener=i,n.addRequestListener=a;var u=r(8),s=n.listeners=void 0;t()},function(e,n,r){"use strict";function t(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}Object.defineProperty(n,"__esModule",{value:!0}),n.RECEIVE_MESSAGE_TYPES=void 0;var o,i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},a=r(3),u=r(8),s=r(21),c=r(23);n.RECEIVE_MESSAGE_TYPES=(o={},t(o,a.CONSTANTS.POST_MESSAGE_TYPE.ACK,function(e,n,r){var t=c.listeners.response[n.hash];if(!t)throw new Error("No handler found for post message ack for message: "+n.name+" in "+window.location.href);t.ack=!0}),t(o,a.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,function(e,n,r){function t(r){return n.fireAndForget||(0,u.isWindowClosed)(e)?u.promise.Promise.resolve():(0,s.sendMessage)(e,i({target:n.originalSource,hash:n.hash,name:n.name},r),"*")}var o=(0,c.getRequestListener)(n.name,e);return t({type:a.CONSTANTS.POST_MESSAGE_TYPE.ACK}).then(function(){return u.promise.run(function(){if(!o)throw new Error("No postmessage request handler for "+n.name+" in "+window.location.href);if(o.domain){var t="string"==typeof o.domain&&r===o.domain||o.domain instanceof RegExp&&r.match(o.domain);if(!t)throw new Error("Message origin "+r+" does not match domain "+o.domain)}return u.promise.deNodeify(o.handler,e,n.data)}).then(function(e){return t({type:a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:a.CONSTANTS.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){return t({type:a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:a.CONSTANTS.POST_MESSAGE_ACK.ERROR,error:e.stack?e.message+"\n"+e.stack:e.toString()})})})["catch"](function(e){return o&&o.handleError?o.handleError(e):void u.log.error(e.stack||e.toString())})}),t(o,a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,function(e,n,r){var t=c.listeners.response[n.hash];if(!t)throw new Error("No response handler found for post message response "+n.name+" in "+window.location.href);return delete c.listeners.response[n.hash],n.ack===a.CONSTANTS.POST_MESSAGE_ACK.ERROR?t.respond(new Error(n.error)):n.ack===a.CONSTANTS.POST_MESSAGE_ACK.SUCCESS?t.respond(null,n.data||n.response):void 0}),o)},function(e,n,r){"use strict";function t(e){if(!e.name)throw new Error("Expected options.name");e.handler=e.handler||u.util.noop,e.errorHandler=e.errorHandler||function(e){throw e},e.once&&!function(){var n=e.handler;e.handler=u.util.once(function(){return(0,s.removeRequestListener)(e),n.apply(this,arguments)})}();var n=e.override||a.CONFIG.MOCK_MODE;return(0,s.addRequestListener)(e.name,e.window,e,n),e.handleError=function(n){e.errorHandler(n)},e.window&&e.errorOnClose&&!function(){var n=u.util.safeInterval(function(){(0,u.isWindowClosed)(e.window)&&(n.cancel(),e.handleError(new Error("Post message target window is closed")))},50)}(),{cancel:function(){(0,s.removeRequestListener)(e)}}}function o(e,n,r,o){return n instanceof Function&&(o=r,r=n,n={}),n.name=e,n.handler=r||n.handler,n.errorHandler=o||n.errorHandler,t(n)}function i(e,n,r,o){n instanceof Function&&(o=r,r=n,n={}),n.name=e,n.handler=r||n.handler,n.errorHandler=o||n.errorHandler,n.once=!0;var i=new u.promise.Promise(function(e,r){n.handler=n.handler||e,n.errorHandler=n.errorHandler||r}),a=t(n);return u.util.extend(i,a),i}Object.defineProperty(n,"__esModule",{value:!0}),n.listen=t,n.on=o,n.once=i;var a=r(3),u=r(8),s=r(6)},function(e,n,r){"use strict";function t(e,n){i.listeners.proxies.push({from:e,to:n}),i.listeners.proxies.push({from:n,to:e})}function o(e,n){for(var r=[],t=0;t<i.listeners.proxies.length;t++){var o=i.listeners.proxies[t];(o.to===e&&o.from===n||o.to===n&&o.from===e)&&r.push(o)}for(var a=0;a<r.length;a++)i.listeners.proxies.splice(i.listeners.proxies.indexOf(r[a]),1)}Object.defineProperty(n,"__esModule",{value:!0}),n.proxy=t,n.unproxy=o;var i=r(6)},function(e,n,r){"use strict";function t(){i.CONFIG.MOCK_MODE=!0}function o(){i.CONFIG.MOCK_MODE=!1}Object.defineProperty(n,"__esModule",{value:!0}),n.CONSTANTS=n.CONFIG=void 0,n.enableMockMode=t,n.disableMockMode=o;var i=r(3);Object.defineProperty(n,"CONFIG",{enumerable:!0,get:function(){return i.CONFIG}}),Object.defineProperty(n,"CONSTANTS",{enumerable:!0,get:function(){return i.CONSTANTS}})}])});
{
"name": "post-robot",
"version": "2.0.25",
"version": "2.0.26",
"description": "Simple postMessage based server.",

@@ -5,0 +5,0 @@ "main": "dist/post-robot.min.js",

import { CONSTANTS } from '../conf';
import { util, promise, isSameDomain, log, onWindowReady } from '../lib';
import { util, promise, isSameDomain, log, onWindowReady, onOpenWindow } from '../lib';
const BRIDGE_NAME_PREFIX = '__postrobot_bridge__';
let id = `${BRIDGE_NAME_PREFIX}_${util.uniqueID()}`;
let bridge;
function getDomain(url) {
export function openBridge(url) {
let domain;
if (bridge) {
throw new Error('Only one bridge supported!');
if (url.indexOf('http://') === 0 || url.indexOf('https://') === 0) {
domain = url;
} else {
domain = window.location.href;
}
let documentReady = new promise.Promise(resolve => {
if (window.document.body) {
domain = domain.split('/').slice(0, 3).join('/');
return domain;
}
function documentReady() {
return new promise.Promise(resolve => {
if (window.document && window.document.body) {
return resolve(window.document);

@@ -25,5 +32,52 @@ }

});
}
bridge = documentReady.then(document => {
let bridges = [];
export function getBridgeByDomain(domain) {
for (let bridge of bridges) {
if (domain === bridge.domain) {
return bridge.bridge;
}
}
}
export function getBridgeByWindow(win) {
for (let bridge of bridges) {
if (bridge.windows.indexOf(win) !== -1) {
return bridge.bridge;
}
}
}
let windowBuffer = {};
onOpenWindow((url, win) => {
let domain = getDomain(url);
for (let bridge of bridges) {
if (domain === bridge.domain) {
bridge.windows.push(win);
return;
}
}
windowBuffer[domain] = windowBuffer[domain] || [];
windowBuffer[domain].push(win);
});
export function openBridge(url) {
let domain = getDomain(url);
let existingBridge = getBridgeByDomain(domain);
if (existingBridge) {
return existingBridge;
}
let id = `${BRIDGE_NAME_PREFIX}_${util.uniqueID()}`;
let bridge = documentReady().then(document => {
log.debug('Opening bridge:', url);

@@ -57,23 +111,21 @@

return onWindowReady(iframe.contentWindow);
return onWindowReady(iframe.contentWindow, 5000, `Bridge ${url}`);
});
});
bridges.push({
id,
domain,
bridge,
windows: windowBuffer[domain] || []
});
delete windowBuffer[domain];
return bridge;
}
export function getBridgeFor(win) {
export function getRemoteBridge(win) {
try {
let frame = win.frames[id];
if (frame && frame !== window && isSameDomain(frame) && frame[CONSTANTS.WINDOW_PROPS.POSTROBOT]) {
return frame;
}
} catch (err) {
// pass
}
try {
if (!win || !win.frames || !win.frames.length) {

@@ -98,8 +150,2 @@ return;

}
}
export function getBridge() {
return promise.Promise.resolve().then(() => {
return bridge || getBridgeFor(window);
});
}
import { CONSTANTS } from '../../conf';
import { util, isSameDomain, getOpener, isSameTopWindow } from '../../lib';
import { emulateIERestrictions, getBridge, getBridgeFor } from '../../compat';
import { emulateIERestrictions, getBridgeByWindow, getRemoteBridge } from '../../compat';

@@ -59,3 +59,3 @@ export let SEND_MESSAGE_STRATEGIES = {

let frame = getBridgeFor(win);
let frame = getRemoteBridge(win);

@@ -130,3 +130,3 @@ if (!frame) {

return getBridge().then(bridge => {
return getBridgeByWindow(win).then(bridge => {

@@ -133,0 +133,0 @@ if (!bridge) {

@@ -32,3 +32,3 @@

export function onWindowReady(win, timeout = 5000) {
export function onWindowReady(win, timeout = 5000, name = 'Window') {
return new promise.Promise((resolve, reject) => {

@@ -44,5 +44,5 @@

setTimeout(() => reject(new Error(`Bridge did not load after ${timeout}ms`)), timeout);
setTimeout(() => reject(new Error(`${name} did not load after ${timeout}ms`)), timeout);
}
});
}

@@ -194,2 +194,9 @@

let windowOpenListeners = [];
export function onOpenWindow(method) {
windowOpenListeners.push(method);
}
let openWindow = window.open;

@@ -206,2 +213,6 @@

for (let listener of windowOpenListeners) {
listener(url, win);
}
registerWindow(name, win);

@@ -208,0 +219,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc