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

http-post-message

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-post-message - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

22

dist/httpPostMessage-noexports.d.ts

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

/*! http-post-message v0.1.2 | (c) 2016 Microsoft Corporation MIT */
/*! http-post-message v0.2.0 | (c) 2016 Microsoft Corporation MIT */
interface IHttpPostMessageRequest {

@@ -15,3 +15,3 @@ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";

interface IPostMessage {
postMessage(window: Window, message: any): Promise<any>;
postMessage<T>(window: Window, message: any): Promise<T>;
}

@@ -23,11 +23,11 @@ declare class HttpPostMessage {

defaultHeaders: any;
targetWindow: Window;
windowPostMessageProxy: any;
constructor(targetWindow: Window, windowPostMessageProxy: IPostMessage, defaultHeaders?: any);
get<T>(url: string, headers?: any): Promise<IHttpPostMessageResponse<T>>;
post<T>(url: string, body: any, headers?: any): Promise<IHttpPostMessageResponse<T>>;
put<T>(url: string, body: any, headers?: any): Promise<IHttpPostMessageResponse<T>>;
patch<T>(url: string, body: any, headers?: any): Promise<IHttpPostMessageResponse<T>>;
delete<T>(url: string, body?: any, headers?: any): Promise<IHttpPostMessageResponse<T>>;
send<T>(request: IHttpPostMessageRequest): Promise<IHttpPostMessageResponse<T>>;
defaultTargetWindow: Window;
windowPostMessageProxy: IPostMessage;
constructor(windowPostMessageProxy: IPostMessage, defaultHeaders?: any, defaultTargetWindow?: Window);
get<T>(url: string, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
post<T>(url: string, body: any, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
put<T>(url: string, body: any, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
patch<T>(url: string, body: any, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
delete<T>(url: string, body?: any, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
send<T>(request: IHttpPostMessageRequest, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
/**

@@ -34,0 +34,0 @@ * Object.assign() polyfill

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

/*! http-post-message v0.1.2 | (c) 2016 Microsoft Corporation MIT */
/*! http-post-message v0.2.0 | (c) 2016 Microsoft Corporation MIT */
export interface IHttpPostMessageRequest {

@@ -15,3 +15,3 @@ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";

export interface IPostMessage {
postMessage(window: Window, message: any): Promise<any>;
postMessage<T>(window: Window, message: any): Promise<T>;
}

@@ -23,11 +23,11 @@ export declare class HttpPostMessage {

defaultHeaders: any;
targetWindow: Window;
windowPostMessageProxy: any;
constructor(targetWindow: Window, windowPostMessageProxy: IPostMessage, defaultHeaders?: any);
get<T>(url: string, headers?: any): Promise<IHttpPostMessageResponse<T>>;
post<T>(url: string, body: any, headers?: any): Promise<IHttpPostMessageResponse<T>>;
put<T>(url: string, body: any, headers?: any): Promise<IHttpPostMessageResponse<T>>;
patch<T>(url: string, body: any, headers?: any): Promise<IHttpPostMessageResponse<T>>;
delete<T>(url: string, body?: any, headers?: any): Promise<IHttpPostMessageResponse<T>>;
send<T>(request: IHttpPostMessageRequest): Promise<IHttpPostMessageResponse<T>>;
defaultTargetWindow: Window;
windowPostMessageProxy: IPostMessage;
constructor(windowPostMessageProxy: IPostMessage, defaultHeaders?: any, defaultTargetWindow?: Window);
get<T>(url: string, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
post<T>(url: string, body: any, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
put<T>(url: string, body: any, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
patch<T>(url: string, body: any, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
delete<T>(url: string, body?: any, headers?: any, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
send<T>(request: IHttpPostMessageRequest, targetWindow?: Window): Promise<IHttpPostMessageResponse<T>>;
/**

@@ -34,0 +34,0 @@ * Object.assign() polyfill

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

/*! http-post-message v0.1.2 | (c) 2016 Microsoft Corporation MIT */
/*! http-post-message v0.2.0 | (c) 2016 Microsoft Corporation MIT */
(function webpackUniversalModuleDefinition(root, factory) {

@@ -60,10 +60,12 @@ if(typeof exports === 'object' && typeof module === 'object')

var HttpPostMessage = (function () {
function HttpPostMessage(targetWindow, windowPostMessageProxy, defaultHeaders) {
function HttpPostMessage(windowPostMessageProxy, defaultHeaders, defaultTargetWindow) {
if (defaultHeaders === void 0) { defaultHeaders = {}; }
this.defaultHeaders = defaultHeaders;
this.targetWindow = targetWindow;
this.defaultTargetWindow = defaultTargetWindow;
this.windowPostMessageProxy = windowPostMessageProxy;
}
// TODO: I the responsibility of knowing how to configure windowPostMessageProxy should
// live in this class, but then we have to have hard dependency for things like ITrackingProperties
// TODO: See if it's possible to share tracking properties interface?
// The responsibility of knowing how to configure windowPostMessageProxy for http should
// live in this http class, but the configuration would need ITrackingProperties
// interface which lives in WindowPostMessageProxy. Use <any> type as workaround
HttpPostMessage.addTrackingProperties = function (message, trackingProperties) {

@@ -82,6 +84,10 @@ message.headers = message.headers || {};

HttpPostMessage.isErrorMessage = function (message) {
if (typeof (message && message.statusCode) !== 'number') {
return false;
}
return !(200 <= message.statusCode && message.statusCode < 300);
};
HttpPostMessage.prototype.get = function (url, headers) {
HttpPostMessage.prototype.get = function (url, headers, targetWindow) {
if (headers === void 0) { headers = {}; }
if (targetWindow === void 0) { targetWindow = this.defaultTargetWindow; }
return this.send({

@@ -91,6 +97,7 @@ method: "GET",

headers: headers
});
}, targetWindow);
};
HttpPostMessage.prototype.post = function (url, body, headers) {
HttpPostMessage.prototype.post = function (url, body, headers, targetWindow) {
if (headers === void 0) { headers = {}; }
if (targetWindow === void 0) { targetWindow = this.defaultTargetWindow; }
return this.send({

@@ -101,6 +108,7 @@ method: "POST",

body: body
});
}, targetWindow);
};
HttpPostMessage.prototype.put = function (url, body, headers) {
HttpPostMessage.prototype.put = function (url, body, headers, targetWindow) {
if (headers === void 0) { headers = {}; }
if (targetWindow === void 0) { targetWindow = this.defaultTargetWindow; }
return this.send({

@@ -111,6 +119,7 @@ method: "PUT",

body: body
});
}, targetWindow);
};
HttpPostMessage.prototype.patch = function (url, body, headers) {
HttpPostMessage.prototype.patch = function (url, body, headers, targetWindow) {
if (headers === void 0) { headers = {}; }
if (targetWindow === void 0) { targetWindow = this.defaultTargetWindow; }
return this.send({

@@ -121,7 +130,8 @@ method: "PATCH",

body: body
});
}, targetWindow);
};
HttpPostMessage.prototype.delete = function (url, body, headers) {
HttpPostMessage.prototype.delete = function (url, body, headers, targetWindow) {
if (body === void 0) { body = null; }
if (headers === void 0) { headers = {}; }
if (targetWindow === void 0) { targetWindow = this.defaultTargetWindow; }
return this.send({

@@ -132,7 +142,11 @@ method: "DELETE",

body: body
});
}, targetWindow);
};
HttpPostMessage.prototype.send = function (request) {
this.assign(request.headers, this.defaultHeaders);
return this.windowPostMessageProxy.postMessage(this.targetWindow, request);
HttpPostMessage.prototype.send = function (request, targetWindow) {
if (targetWindow === void 0) { targetWindow = this.defaultTargetWindow; }
request.headers = this.assign({}, this.defaultHeaders, request.headers);
if (!targetWindow) {
throw new Error("target window is not provided. You must either provide the target window explicitly as argument to request, or specify default target window when constructing instance of this class.");
}
return this.windowPostMessageProxy.postMessage(targetWindow, request);
};

@@ -139,0 +153,0 @@ /**

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

/*! http-post-message v0.1.2 | (c) 2016 Microsoft Corporation MIT */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["http-post-message"]=t():e["http-post-message"]=t()}(this,function(){return function(e){function t(r){if(o[r])return o[r].exports;var n=o[r]={exports:{},id:r,loaded:!1};return e[r].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t){"use strict";var o=function(){function e(e,t,o){void 0===o&&(o={}),this.defaultHeaders=o,this.targetWindow=e,this.windowPostMessageProxy=t}return e.addTrackingProperties=function(e,t){return e.headers=e.headers||{},t&&t.id&&(e.headers.id=t.id),e},e.getTrackingProperties=function(e){return{id:e.headers&&e.headers.id}},e.isErrorMessage=function(e){return!(200<=e.statusCode&&e.statusCode<300)},e.prototype.get=function(e,t){return void 0===t&&(t={}),this.send({method:"GET",url:e,headers:t})},e.prototype.post=function(e,t,o){return void 0===o&&(o={}),this.send({method:"POST",url:e,headers:o,body:t})},e.prototype.put=function(e,t,o){return void 0===o&&(o={}),this.send({method:"PUT",url:e,headers:o,body:t})},e.prototype.patch=function(e,t,o){return void 0===o&&(o={}),this.send({method:"PATCH",url:e,headers:o,body:t})},e.prototype["delete"]=function(e,t,o){return void 0===t&&(t=null),void 0===o&&(o={}),this.send({method:"DELETE",url:e,headers:o,body:t})},e.prototype.send=function(e){return this.assign(e.headers,this.defaultHeaders),this.windowPostMessageProxy.postMessage(this.targetWindow,e)},e.prototype.assign=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");var r=Object(e);return t.forEach(function(e){if(void 0!==e&&null!==e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])}),r},e}();t.HttpPostMessage=o}])});
/*! http-post-message v0.2.0 | (c) 2016 Microsoft Corporation MIT */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["http-post-message"]=e():t["http-post-message"]=e()}(this,function(){return function(t){function e(r){if(o[r])return o[r].exports;var n=o[r]={exports:{},id:r,loaded:!1};return t[r].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e){"use strict";var o=function(){function t(t,e,o){void 0===e&&(e={}),this.defaultHeaders=e,this.defaultTargetWindow=o,this.windowPostMessageProxy=t}return t.addTrackingProperties=function(t,e){return t.headers=t.headers||{},e&&e.id&&(t.headers.id=e.id),t},t.getTrackingProperties=function(t){return{id:t.headers&&t.headers.id}},t.isErrorMessage=function(t){return"number"!=typeof(t&&t.statusCode)?!1:!(200<=t.statusCode&&t.statusCode<300)},t.prototype.get=function(t,e,o){return void 0===e&&(e={}),void 0===o&&(o=this.defaultTargetWindow),this.send({method:"GET",url:t,headers:e},o)},t.prototype.post=function(t,e,o,r){return void 0===o&&(o={}),void 0===r&&(r=this.defaultTargetWindow),this.send({method:"POST",url:t,headers:o,body:e},r)},t.prototype.put=function(t,e,o,r){return void 0===o&&(o={}),void 0===r&&(r=this.defaultTargetWindow),this.send({method:"PUT",url:t,headers:o,body:e},r)},t.prototype.patch=function(t,e,o,r){return void 0===o&&(o={}),void 0===r&&(r=this.defaultTargetWindow),this.send({method:"PATCH",url:t,headers:o,body:e},r)},t.prototype["delete"]=function(t,e,o,r){return void 0===e&&(e=null),void 0===o&&(o={}),void 0===r&&(r=this.defaultTargetWindow),this.send({method:"DELETE",url:t,headers:o,body:e},r)},t.prototype.send=function(t,e){if(void 0===e&&(e=this.defaultTargetWindow),t.headers=this.assign({},this.defaultHeaders,t.headers),!e)throw new Error("target window is not provided. You must either provide the target window explicitly as argument to request, or specify default target window when constructing instance of this class.");return this.windowPostMessageProxy.postMessage(e,t)},t.prototype.assign=function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");var r=Object(t);return e.forEach(function(t){if(void 0!==t&&null!==t)for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])}),r},t}();e.HttpPostMessage=o}])});
{
"name": "http-post-message",
"version": "0.1.2",
"version": "0.2.0",
"description": "A generic messaging component to send HTTP style message payloads over the window.postMessage API. Requires an implementation of window postMessage proxy such as 'window-post-message-proxy'.",

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

# htt-post-message
[![Build Status](https://travis-ci.com/Microsoft/http-post-message.svg?token=nXyWFYxRu6tVxUMJAuJr&branch=master)](https://travis-ci.com/Microsoft/http-post-message)
A generic messaging component to send HTTP style message payloads over the window.postMessage API. Requires an implementation of window postMessage proxy such as 'window-post-message-proxy'.

@@ -3,0 +5,0 @@

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