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

penpal

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

penpal - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

lib/connectCallReceiver.d.ts

2

dist/penpal.js

@@ -477,3 +477,3 @@ // Derived from https://github.com/umdjs/umd/blob/master/templates/amdWebGlobal.js

var checkIframeInDocIntervalId = setInterval(function () {
if (!document.contains(iframe)) {
if (!document.body.contains(iframe)) {
clearInterval(checkIframeInDocIntervalId);

@@ -480,0 +480,0 @@ destroy();

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

!function(e,n){var t={};!function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.ERR_IFRAME_ALREADY_ATTACHED_TO_DOM=e.ERR_NOT_IN_IFRAME=e.ERR_CONNECTION_TIMEOUT=e.ERR_CONNECTION_DESTROYED=void 0;e.ERR_CONNECTION_DESTROYED="ConnectionDestroyed";e.ERR_CONNECTION_TIMEOUT="ConnectionTimeout";e.ERR_NOT_IN_IFRAME="NotInIframe";e.ERR_IFRAME_ALREADY_ATTACHED_TO_DOM="IframeAlreadyAttachedToDom";var n={"http:":"80","https:":"443"},t=/^(https?:|file:)?\/\/([^\/:]+)?(:(\d+))?/,o={ERR_CONNECTION_DESTROYED:"ConnectionDestroyed",ERR_CONNECTION_TIMEOUT:"ConnectionTimeout",ERR_NOT_IN_IFRAME:"NotInIframe",ERR_IFRAME_ALREADY_ATTACHED_TO_DOM:"IframeAlreadyAttachedToDom",Promise:function(){try{return window?window.Promise:null}catch(e){return null}}(),debug:!1},r=(l=0,function(){return++l}),a=function(){if(o.debug){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];(e=console).log.apply(e,["[Penpal]"].concat(t))}},i=function(e){var n=[];return e(function(){n.forEach(function(e){e()})}),{then:function(e){n.push(e)}}},c=function(e){var n=e.name,t=e.message,o=e.stack;return{name:n,message:t,stack:o}},d=function(e,n,t,i,c){var d=n.localName,s=n.local,l=n.remote,u=n.remoteOrigin,f=!1;a("".concat(d,": Connecting call sender"));var m=function(e){return function(){for(var n=arguments.length,t=new Array(n),c=0;c<n;c++)t[c]=arguments[c];if(a("".concat(d,": Sending ").concat(e,"() call")),l.closed&&i(),f){var m=new Error("Unable to send ".concat(e,"() call due ")+"to destroyed connection");throw m.code="ConnectionDestroyed",m}return new o.Promise(function(n,o){var i=r();s.addEventListener("message",function t(r){if(r.source===l&&r.origin===u&&"reply"===r.data.penpal&&r.data.id===i){a("".concat(d,": Received ").concat(e,"() reply")),s.removeEventListener("message",t);var c=r.data.returnValue;r.data.returnValueIsError&&(f=c,m=new Error,Object.keys(f).forEach(function(e){return m[e]=f[e]}),c=m),("fulfilled"===r.data.resolution?n:o)(c)}var f,m}),l.postMessage({penpal:"call",id:i,methodName:e,args:t},u)})}};c.then(function(){f=!0}),t.reduce(function(e,n){return e[n]=m(n),e},e)},s=function(e,n,t){var r=e.localName,i=e.local,d=e.remote,s=e.remoteOrigin,l=!1;a("".concat(r,": Connecting call receiver"));var u=function(e){if(e.source===d&&e.origin===s&&"call"===e.data.penpal){var t=e.data,i=t.methodName,u=t.args,f=t.id;if(a("".concat(r,": Received ").concat(i,"() call")),i in n){var m=function(e){return function(n){if(a("".concat(r,": Sending ").concat(i,"() reply")),l)a("".concat(r,": Unable to send ").concat(i,"() reply due to destroyed connection"));else{var t={penpal:"reply",id:f,resolution:e,returnValue:n};"rejected"===e&&n instanceof Error&&(t.returnValue=c(n),t.returnValueIsError=!0);try{d.postMessage(t,s)}catch(e){throw"DataCloneError"===e.name&&d.postMessage({penpal:"reply",id:f,resolution:"rejected",returnValue:c(e),returnValueIsError:!0},s),e}}}};new o.Promise(function(e){return e(n[i].apply(n,u))}).then(m("fulfilled"),m("rejected"))}}};i.addEventListener("message",u),t.then(function(){l=!0,i.removeEventListener("message",u)})};var l;o.connectToChild=function(e){var r,c=e.url,l=e.appendTo,u=e.iframe,f=e.methods,m=void 0===f?{}:f,v=e.timeout;if(u&&u.parentNode){var E=new Error("connectToChild() must not be called with an iframe already attached to DOM");throw E.code="IframeAlreadyAttachedToDom",E}var p=new i(function(e){r=e}),h=window;(u=u||document.createElement("iframe")).src=c;var T=function(e){var o,r,a,i=document.location,c=t.exec(e);c?(o=c[1]?c[1]:i.protocol,r=c[2],a=c[4]):(o=i.protocol,r=i.hostname,a=i.port);if("file:"===o)return"null";var d=a&&a!==n[o]?":".concat(a):"";return"".concat(o,"//").concat(r).concat(d)}(c),g=new o.Promise(function(e,n){var t;void 0!==v&&(t=setTimeout(function(){var e=new Error("Connection to child timed out after ".concat(v,"ms"));e.code="ConnectionTimeout",n(e),r()},v));var o,c,f={},E=function(n){var l=u.contentWindow;if(n.source===l&&n.origin===T&&"handshake"===n.data.penpal){a("Parent: Received handshake, sending reply");var v="null"===n.origin?"*":n.origin;n.source.postMessage({penpal:"handshake-reply",methodNames:Object.keys(m)},v);var E={localName:"Parent",local:h,remote:l,remoteOrigin:v};c&&c();var g=new i(function(e){p.then(e),c=e});s(E,m,g),o&&o.forEach(function(e){delete f[e]}),o=n.data.methodNames,d(f,E,o,r,p),clearTimeout(t),e(f)}};h.addEventListener("message",E),a("Parent: Loading iframe"),(l||document.body).appendChild(u);var g=setInterval(function(){document.contains(u)||(clearInterval(g),r())},6e4);p.then(function(){u.parentNode&&u.parentNode.removeChild(u),h.removeEventListener("message",E),clearInterval(g);var e=new Error("Connection destroyed");e.code="ConnectionDestroyed",n(e)})});return{promise:g,iframe:u,destroy:r}},o.connectToParent=function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=n.parentOrigin,r=void 0===t?"*":t,c=n.methods,l=void 0===c?{}:c,u=n.timeout;if(window===window.top){var f=new Error("connectToParent() must be called within an iframe");throw f.code="NotInIframe",f}var m=new i(function(n){e=n}),v=window,E=v.parent,p=new o.Promise(function(n,t){var o;void 0!==u&&(o=setTimeout(function(){var n=new Error("Connection to parent timed out after ".concat(u,"ms"));n.code="ConnectionTimeout",t(n),e()},u));var i=function t(i){if(("*"===r||r===i.origin)&&i.source===E&&"handshake-reply"===i.data.penpal){a("Child: Received handshake reply"),v.removeEventListener("message",t);var c={localName:"Child",local:v,remote:E,remoteOrigin:i.origin},u={};s(c,l,m),d(u,c,i.data.methodNames,e,m),clearTimeout(o),n(u)}};v.addEventListener("message",i),m.then(function(){v.removeEventListener("message",i);var e=new Error("Connection destroyed");e.code="ConnectionDestroyed",t(e)}),a("Child: Sending handshake"),E.postMessage({penpal:"handshake",methodNames:Object.keys(l)},r)});return{promise:p,destroy:e}};var u=o;e.default=u}(t),"function"==typeof define&&define.amd?define("Penpal",t.default):e.Penpal=t.default}(this);
!function(e,n){var t={};!function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.ERR_IFRAME_ALREADY_ATTACHED_TO_DOM=e.ERR_NOT_IN_IFRAME=e.ERR_CONNECTION_TIMEOUT=e.ERR_CONNECTION_DESTROYED=void 0;e.ERR_CONNECTION_DESTROYED="ConnectionDestroyed";e.ERR_CONNECTION_TIMEOUT="ConnectionTimeout";e.ERR_NOT_IN_IFRAME="NotInIframe";e.ERR_IFRAME_ALREADY_ATTACHED_TO_DOM="IframeAlreadyAttachedToDom";var n={"http:":"80","https:":"443"},t=/^(https?:|file:)?\/\/([^/:]+)?(:(\d+))?/,o={ERR_CONNECTION_DESTROYED:"ConnectionDestroyed",ERR_CONNECTION_TIMEOUT:"ConnectionTimeout",ERR_NOT_IN_IFRAME:"NotInIframe",ERR_IFRAME_ALREADY_ATTACHED_TO_DOM:"IframeAlreadyAttachedToDom",Promise:function(){try{return window?window.Promise:null}catch(e){return null}}(),debug:!1},r=(l=0,function(){return++l}),a=function(){if(o.debug){for(var e,n=arguments.length,t=new Array(n),r=0;r<n;r++)t[r]=arguments[r];(e=console).log.apply(e,["[Penpal]"].concat(t))}},i=function(e){var n=[];return e(function(){n.forEach(function(e){e()})}),{then:function(e){n.push(e)}}},c=function(e){var n=e.name,t=e.message,o=e.stack;return{name:n,message:t,stack:o}},d=function(e,n,t,i,c){var d=n.localName,s=n.local,l=n.remote,u=n.remoteOrigin,f=!1;a("".concat(d,": Connecting call sender"));var m=function(e){return function(){for(var n=arguments.length,t=new Array(n),c=0;c<n;c++)t[c]=arguments[c];if(a("".concat(d,": Sending ").concat(e,"() call")),l.closed&&i(),f){var m=new Error("Unable to send ".concat(e,"() call due ")+"to destroyed connection");throw m.code="ConnectionDestroyed",m}return new o.Promise(function(n,o){var i=r();s.addEventListener("message",function t(r){if(r.source===l&&r.origin===u&&"reply"===r.data.penpal&&r.data.id===i){a("".concat(d,": Received ").concat(e,"() reply")),s.removeEventListener("message",t);var c=r.data.returnValue;r.data.returnValueIsError&&(f=c,m=new Error,Object.keys(f).forEach(function(e){return m[e]=f[e]}),c=m),("fulfilled"===r.data.resolution?n:o)(c)}var f,m}),l.postMessage({penpal:"call",id:i,methodName:e,args:t},u)})}};c.then(function(){f=!0}),t.reduce(function(e,n){return e[n]=m(n),e},e)},s=function(e,n,t){var r=e.localName,i=e.local,d=e.remote,s=e.remoteOrigin,l=!1;a("".concat(r,": Connecting call receiver"));var u=function(e){if(e.source===d&&e.origin===s&&"call"===e.data.penpal){var t=e.data,i=t.methodName,u=t.args,f=t.id;if(a("".concat(r,": Received ").concat(i,"() call")),i in n){var m=function(e){return function(n){if(a("".concat(r,": Sending ").concat(i,"() reply")),l)a("".concat(r,": Unable to send ").concat(i,"() reply due to destroyed connection"));else{var t={penpal:"reply",id:f,resolution:e,returnValue:n};"rejected"===e&&n instanceof Error&&(t.returnValue=c(n),t.returnValueIsError=!0);try{d.postMessage(t,s)}catch(e){throw"DataCloneError"===e.name&&d.postMessage({penpal:"reply",id:f,resolution:"rejected",returnValue:c(e),returnValueIsError:!0},s),e}}}};new o.Promise(function(e){return e(n[i].apply(n,u))}).then(m("fulfilled"),m("rejected"))}}};i.addEventListener("message",u),t.then(function(){l=!0,i.removeEventListener("message",u)})};var l;o.connectToChild=function(e){var r,c=e.url,l=e.appendTo,u=e.iframe,f=e.methods,m=void 0===f?{}:f,v=e.timeout;if(u&&u.parentNode){var E=new Error("connectToChild() must not be called with an iframe already attached to DOM");throw E.code="IframeAlreadyAttachedToDom",E}var p=new i(function(e){r=e}),h=window;(u=u||document.createElement("iframe")).src=c;var T=function(e){var o,r,a,i=document.location,c=t.exec(e);c?(o=c[1]?c[1]:i.protocol,r=c[2],a=c[4]):(o=i.protocol,r=i.hostname,a=i.port);if("file:"===o)return"null";var d=a&&a!==n[o]?":".concat(a):"";return"".concat(o,"//").concat(r).concat(d)}(c),g=new o.Promise(function(e,n){var t;void 0!==v&&(t=setTimeout(function(){var e=new Error("Connection to child timed out after ".concat(v,"ms"));e.code="ConnectionTimeout",n(e),r()},v));var o,c,f={},E=function(n){var l=u.contentWindow;if(n.source===l&&n.origin===T&&"handshake"===n.data.penpal){a("Parent: Received handshake, sending reply");var v="null"===n.origin?"*":n.origin;n.source.postMessage({penpal:"handshake-reply",methodNames:Object.keys(m)},v);var E={localName:"Parent",local:h,remote:l,remoteOrigin:v};c&&c();var g=new i(function(e){p.then(e),c=e});s(E,m,g),o&&o.forEach(function(e){delete f[e]}),o=n.data.methodNames,d(f,E,o,r,p),clearTimeout(t),e(f)}};h.addEventListener("message",E),a("Parent: Loading iframe"),(l||document.body).appendChild(u);var g=setInterval(function(){document.body.contains(u)||(clearInterval(g),r())},6e4);p.then(function(){u.parentNode&&u.parentNode.removeChild(u),h.removeEventListener("message",E),clearInterval(g);var e=new Error("Connection destroyed");e.code="ConnectionDestroyed",n(e)})});return{promise:g,iframe:u,destroy:r}},o.connectToParent=function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=n.parentOrigin,r=void 0===t?"*":t,c=n.methods,l=void 0===c?{}:c,u=n.timeout;if(window===window.top){var f=new Error("connectToParent() must be called within an iframe");throw f.code="NotInIframe",f}var m=new i(function(n){e=n}),v=window,E=v.parent,p=new o.Promise(function(n,t){var o;void 0!==u&&(o=setTimeout(function(){var n=new Error("Connection to parent timed out after ".concat(u,"ms"));n.code="ConnectionTimeout",t(n),e()},u));var i=function t(i){if(("*"===r||r===i.origin)&&i.source===E&&"handshake-reply"===i.data.penpal){a("Child: Received handshake reply"),v.removeEventListener("message",t);var c={localName:"Child",local:v,remote:E,remoteOrigin:i.origin},u={};s(c,l,m),d(u,c,i.data.methodNames,e,m),clearTimeout(o),n(u)}};v.addEventListener("message",i),m.then(function(){v.removeEventListener("message",i);var e=new Error("Connection destroyed");e.code="ConnectionDestroyed",t(e)}),a("Child: Sending handshake"),E.postMessage({penpal:"handshake",methodNames:Object.keys(l)},r)});return{promise:p,destroy:e}};var u=o;e.default=u}(t),"function"==typeof define&&define.amd?define("Penpal",t.default):e.Penpal=t.default}(this);

@@ -463,3 +463,3 @@ "use strict";

var checkIframeInDocIntervalId = setInterval(function () {
if (!document.contains(iframe)) {
if (!document.body.contains(iframe)) {
clearInterval(checkIframeInDocIntervalId);

@@ -466,0 +466,0 @@ destroy();

{
"name": "penpal",
"version": "3.1.2",
"version": "3.1.3",
"description": "A promise-based library for communicating with iframes via postMessage.",

@@ -67,3 +67,6 @@ "author": "Aaron Hardy <aaron@aaronhardy.com>",

"last 1 Edge version"
]
],
"publishConfig": {
"tag": "3.x"
}
}

Sorry, the diff of this file is not supported yet

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