Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

window-post-message-proxy

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

window-post-message-proxy - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

2

dist/windowPostMessageProxy-noexports.d.ts

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

/*! window-post-message-proxy v0.2.4 | (c) 2016 Microsoft Corporation MIT */
/*! window-post-message-proxy v0.2.5 | (c) 2016 Microsoft Corporation MIT */
interface ITrackingProperties {

@@ -3,0 +3,0 @@ id: string;

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

/*! window-post-message-proxy v0.2.4 | (c) 2016 Microsoft Corporation MIT */
/*! window-post-message-proxy v0.2.5 | (c) 2016 Microsoft Corporation MIT */
export interface ITrackingProperties {

@@ -3,0 +3,0 @@ id: string;

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

/*! window-post-message-proxy v0.2.4 | (c) 2016 Microsoft Corporation MIT */
/*! window-post-message-proxy v0.2.5 | (c) 2016 Microsoft Corporation MIT */
(function webpackUniversalModuleDefinition(root, factory) {

@@ -56,3 +56,3 @@ if(typeof exports === 'object' && typeof module === 'object')

/* 0 */
/***/ function(module, exports) {
/***/ (function(module, exports) {

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

/***/ }
/***/ })
/******/ ])

@@ -295,0 +295,0 @@ });

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

/*! window-post-message-proxy v0.2.4 | (c) 2016 Microsoft Corporation MIT */
/*! window-post-message-proxy v0.2.5 | (c) 2016 Microsoft Corporation MIT */
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["window-post-message-proxy"]=r():e["window-post-message-proxy"]=r()}(this,function(){return function(e){function r(n){if(s[n])return s[n].exports;var t=s[n]={exports:{},id:n,loaded:!1};return e[n].call(t.exports,t,t.exports,r),t.loaded=!0,t.exports}var s={};return r.m=e,r.c=s,r.p="",r(0)}([function(e,r){"use strict";var s=function(){function e(r){var s=this;void 0===r&&(r={processTrackingProperties:{addTrackingProperties:e.defaultAddTrackingProperties,getTrackingProperties:e.defaultGetTrackingProperties},isErrorMessage:e.defaultIsErrorMessage,receiveWindow:window,name:e.createRandomString()}),this.pendingRequestPromises={},this.addTrackingProperties=r.processTrackingProperties&&r.processTrackingProperties.addTrackingProperties||e.defaultAddTrackingProperties,this.getTrackingProperties=r.processTrackingProperties&&r.processTrackingProperties.getTrackingProperties||e.defaultGetTrackingProperties,this.isErrorMessage=r.isErrorMessage||e.defaultIsErrorMessage,this.receiveWindow=r.receiveWindow||window,this.name=r.name||e.createRandomString(),this.logMessages=r.logMessages||!1,this.eventSourceOverrideWindow=r.eventSourceOverrideWindow,this.suppressWarnings=r.suppressWarnings||!1,this.logMessages&&console.log("new WindowPostMessageProxy created with name: "+this.name+" receiving on window: "+this.receiveWindow.document.title),this.handlers=[],this.windowMessageHandler=function(e){return s.onMessageReceived(e)},this.start()}return e.defaultAddTrackingProperties=function(r,s){return r[e.messagePropertyName]=s,r},e.defaultGetTrackingProperties=function(r){return r[e.messagePropertyName]},e.defaultIsErrorMessage=function(e){return!!e.error},e.createDeferred=function(){var e={resolve:null,reject:null,promise:null},r=new Promise(function(r,s){e.resolve=r,e.reject=s});return e.promise=r,e},e.createRandomString=function(){return(Math.random()+1).toString(36).substring(7)},e.prototype.addHandler=function(e){this.handlers.push(e)},e.prototype.removeHandler=function(e){var r=this.handlers.indexOf(e);if(r===-1)throw new Error("You attempted to remove a handler but no matching handler was found.");this.handlers.splice(r,1)},e.prototype.start=function(){this.receiveWindow.addEventListener("message",this.windowMessageHandler)},e.prototype.stop=function(){this.receiveWindow.removeEventListener("message",this.windowMessageHandler)},e.prototype.postMessage=function(r,s){var n={id:e.createRandomString()};this.addTrackingProperties(s,n),this.logMessages&&(console.log(this.name+" Posting message:"),console.log(JSON.stringify(s,null," "))),r.postMessage(s,"*");var t=e.createDeferred();return this.pendingRequestPromises[n.id]=t,t.promise},e.prototype.sendResponse=function(e,r,s){this.addTrackingProperties(r,s),this.logMessages&&(console.log(this.name+" Sending response:"),console.log(JSON.stringify(r,null," "))),e.postMessage(r,"*")},e.prototype.onMessageReceived=function(e){var r=this;this.logMessages&&(console.log(this.name+" Received message:"),console.log("type: "+e.type),console.log(JSON.stringify(e.data,null," ")));var s=this.eventSourceOverrideWindow||e.source,n=e.data;if("object"!=typeof n)return void(this.suppressWarnings||console.warn("Proxy("+this.name+"): Received message that was not an object. Discarding message"));var t;try{t=this.getTrackingProperties(n)}catch(o){this.suppressWarnings||console.warn("Proxy("+this.name+"): Error occurred when attempting to get tracking properties from incoming message:",JSON.stringify(n,null," "),"Error: ",o)}var i;if(t&&(i=this.pendingRequestPromises[t.id]),i){var a=!0;try{a=this.isErrorMessage(n)}catch(o){console.warn("Proxy("+this.name+") Error occurred when trying to determine if message is consider an error response. Message: ",JSON.stringify(n,null,""),"Error: ",o)}a?i.reject(n):i.resolve(n),delete this.pendingRequestPromises[t.id]}else{var d=this.handlers.some(function(e){var o=!1;try{o=e.test(n)}catch(i){r.suppressWarnings||console.warn("Proxy("+r.name+"): Error occurred when handler was testing incoming message:",JSON.stringify(n,null," "),"Error: ",i)}if(o){var a=void 0;try{a=Promise.resolve(e.handle(n))}catch(i){r.suppressWarnings||console.warn("Proxy("+r.name+"): Error occurred when handler was processing incoming message:",JSON.stringify(n,null," "),"Error: ",i),a=Promise.resolve()}return a.then(function(e){if(!e){var o="Handler for message: "+JSON.stringify(n,null," ")+" did not return a response message. The default response message will be returned instead.";r.suppressWarnings||console.warn("Proxy("+r.name+"): "+o),e={warning:o}}r.sendResponse(s,e,t)}),!0}});d||this.suppressWarnings||console.warn("Proxy("+this.name+") did not handle message. Handlers: "+this.handlers.length+" Message: "+JSON.stringify(n,null,"")+".")}},e.messagePropertyName="windowPostMessageProxy",e}();r.WindowPostMessageProxy=s}])});
{
"name": "window-post-message-proxy",
"version": "0.2.4",
"version": "0.2.5",
"description": "A library used in place of the native window.postMessage which when used on both the sending and receiving windows allow for a nicer asynchronouse promise messaging between the windows",

@@ -46,3 +46,3 @@ "main": "dist/windowPostMessageProxy.js",

"jasmine-core": "^2.4.1",
"jquery": "^2.2.3",
"jquery": "^3.3.1",
"karma": "^0.13.22",

@@ -49,0 +49,0 @@ "karma-chrome-launcher": "^1.0.1",

@@ -0,0 +0,0 @@ # window-post-message-proxy

Sorry, the diff of this file is not supported yet

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