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.1.0 to 0.1.1

1

dist/windowPostMessageProxy-noexports.d.ts

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

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

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

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

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

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

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

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

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

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

/*! window-post-message-proxy v0.1.1 | (c) 2016 Microsoft Corporation MIT */
!function(e,s){"object"==typeof exports&&"object"==typeof module?module.exports=s():"function"==typeof define&&define.amd?define([],s):"object"==typeof exports?exports["window-post-message-proxy"]=s():e["window-post-message-proxy"]=s()}(this,function(){return function(e){function s(t){if(r[t])return r[t].exports;var n=r[t]={exports:{},id:t,loaded:!1};return e[t].call(n.exports,n,n.exports,s),n.loaded=!0,n.exports}var r={};return s.m=e,s.c=r,s.p="",s(0)}([function(e,s){"use strict";var r=function(){function e(s){var r=this;void 0===s&&(s={processTrackingProperties:{addTrackingProperties:e.defaultAddTrackingProperties,getTrackingProperties:e.defaultGetTrackingProperties},isErrorMessage:e.defaultIsErrorMessage,receiveWindow:window,name:e.createRandomString()}),this.pendingRequestPromises={},this.addTrackingProperties=s.processTrackingProperties&&s.processTrackingProperties.addTrackingProperties||e.defaultAddTrackingProperties,this.getTrackingProperties=s.processTrackingProperties&&s.processTrackingProperties.getTrackingProperties||e.defaultGetTrackingProperties,this.isErrorMessage=s.isErrorMessage||e.defaultIsErrorMessage,this.receiveWindow=s.receiveWindow||window,this.name=s.name||e.createRandomString(),this.logMessages=s.logMessages||!1,this.eventSourceOverrideWindow=s.eventSourceOverrideWindow,this.suppressMessageNotHandledWarning=s.suppressMessageNotHandledWarning||!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 r.onMessageReceived(e)},this.start()}return e.defaultAddTrackingProperties=function(s,r){return s[e.messagePropertyName]=r,s},e.defaultGetTrackingProperties=function(s){return s[e.messagePropertyName]},e.defaultIsErrorMessage=function(e){return!!e.error},e.prototype.addHandler=function(e){this.handlers.push(e)},e.prototype.removeHandler=function(e){var s=this.handlers.indexOf(e);if(-1==s)throw new Error("You attempted to remove a handler but no matching handler was found.");this.handlers.splice(s,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(s,r){var t={id:e.createRandomString()};this.addTrackingProperties(r,t),this.logMessages&&(console.log(this.name+" Posting message:"),console.log(JSON.stringify(r,null," "))),s.postMessage(r,"*");var n=e.createDeferred();return this.pendingRequestPromises[t.id]=n,n.promise},e.prototype.sendResponse=function(e,s,r){this.addTrackingProperties(s,r),this.logMessages&&(console.log(this.name+" Sending response:"),console.log(JSON.stringify(s,null," "))),e.postMessage(s,"*")},e.prototype.onMessageReceived=function(e){var s=this;this.logMessages&&(console.log(this.name+" Received message:"),console.log("type: "+e.type),console.log(JSON.stringify(e.data,null," ")));var r,t=this.eventSourceOverrideWindow||e.source,n=e.data,o=this.getTrackingProperties(n);if(o&&(r=this.pendingRequestPromises[o.id]),r)this.isErrorMessage(n)?r.reject(n):r.resolve(n),delete this.pendingRequestPromises[o.id];else{var i=this.handlers.some(function(e){return e.test(n)?(Promise.resolve(e.handle(n)).then(function(e){s.sendResponse(t,e,o)}),!0):void 0});i||this.suppressMessageNotHandledWarning||console.warn("Proxy("+this.name+") did not handle message. Handlers: "+this.handlers.length+" Message: "+JSON.stringify(n,null,"")+".")}},e.createDeferred=function(){var e={resolve:null,reject:null,promise:null},s=new Promise(function(s,r){e.resolve=s,e.reject=r});return e.promise=s,e},e.createRandomString=function(){return(Math.random()+1).toString(36).substring(7)},e.messagePropertyName="windowPostMessageProxy",e}();s.WindowPostMessageProxy=r}])});
var gulp = require('gulp-help')(require('gulp'));
var rename = require('gulp-rename'),
var del = require('del'),
header = require('gulp-header'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),

@@ -13,7 +15,12 @@ uglify = require('gulp-uglify'),

var package = require('./package.json');
var banner = "/*! <%= package.name %> v<%= package.version %> | (c) 2016 Microsoft Corporation <%= package.license %> */\n";
gulp.task('build', 'Build for release', function (done) {
return runSequence(
'clean:dist',
'compile:ts',
'min',
'generatecustomdts',
'header',
done

@@ -25,2 +32,3 @@ );

return runSequence(
'clean:tmp',
'compile:spec',

@@ -38,2 +46,8 @@ 'test:spec',

gulp.task('header', 'Add header to distributed files', function () {
return gulp.src(['!./dist/*.map', './dist/*'])
.pipe(header(banner, { package : package }))
.pipe(gulp.dest('./dist'));
});
gulp.task('min', 'Minify build files', function () {

@@ -48,2 +62,14 @@ return gulp.src(['./dist/*.js'])

gulp.task('clean:dist', 'Clean dist directory', function () {
return del([
'./dist/**/*'
]);
});
gulp.task('clean:tmp', 'Clean tmp directory', function () {
return del([
'./tmp/**/*'
]);
});
gulp.task('compile:spec', 'Compile typescript for tests', function () {

@@ -50,0 +76,0 @@ return gulp.src(['./test/windowPostMessageProxy.spec.ts'])

4

package.json
{
"name": "window-post-message-proxy",
"version": "0.1.0",
"version": "0.1.1",
"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",

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

"devDependencies": {
"del": "^2.2.1",
"gulp": "^3.9.1",
"gulp-header": "^1.8.7",
"gulp-help": "^1.6.1",

@@ -32,0 +34,0 @@ "gulp-rename": "^1.2.2",

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