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.5 to 0.2.6

8

dist/windowPostMessageProxy-noexports.d.ts

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

/*! window-post-message-proxy v0.2.5 | (c) 2016 Microsoft Corporation MIT */
/*! window-post-message-proxy v0.2.6 | (c) 2016 Microsoft Corporation MIT */
declare global {
interface Window {
msCrypto: Crypto;
}
}
interface ITrackingProperties {

@@ -88,1 +93,2 @@ id: string;

}
{};

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

/*! window-post-message-proxy v0.2.5 | (c) 2016 Microsoft Corporation MIT */
/*! window-post-message-proxy v0.2.6 | (c) 2016 Microsoft Corporation MIT */
declare global {
interface Window {
msCrypto: Crypto;
}
}
export interface ITrackingProperties {

@@ -88,1 +93,2 @@ id: string;

}
export {};

8

dist/windowPostMessageProxy.js

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

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

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

WindowPostMessageProxy.createRandomString = function () {
return (Math.random() + 1).toString(36).substring(7);
// window.msCrypto for IE
var cryptoObj = window.crypto || window.msCrypto;
var randomValueArray = new Uint32Array(1);
cryptoObj.getRandomValues(randomValueArray);
return randomValueArray[0].toString(36).substring(1);
};

@@ -125,0 +129,0 @@ /**

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

/*! 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}])});
/*! window-post-message-proxy v0.2.6 | (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(){var e=window.crypto||window.msCrypto,r=new Uint32Array(1);return e.getRandomValues(r),r[0].toString(36).substring(1)},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.5",
"version": "0.2.6",
"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",

@@ -5,0 +5,0 @@ "main": "dist/windowPostMessageProxy.js",

@@ -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