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.2.1 to 0.2.2

2

dist/httpPostMessage-noexports.d.ts

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

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

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

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

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

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

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

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

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

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

/*! http-post-message v0.2.1 | (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}])});
/*! http-post-message v0.2.2 | (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)&&!(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.2.1",
"version": "0.2.2",
"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'.",

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

"scripts": {
"test": "gulp test --chrome",
"build": "gulp build",
"test": "gulp test",
"postinstall": "typings install",
"prepublish": "gulp build"

@@ -56,2 +58,4 @@ },

"typedoc": "^0.4.4",
"typescript": "^1.8.10",
"typings": "^1.3.2",
"webpack-stream": "^3.2.0",

@@ -58,0 +62,0 @@ "yargs": "^4.7.0"

# 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)
[![Travis branch](https://img.shields.io/travis/Microsoft/http-post-message.svg)](https://travis-ci.org/Microsoft/http-post-message)
[![npm](https://img.shields.io/npm/v/http-post-message.svg)](https://www.npmjs.com/package/http-post-message)
[![Total Downloads](https://img.shields.io/npm/dt/http-post-message.svg)](https://www.npmjs.com/package/http-post-message)
[![Monthly Downloads](https://img.shields.io/npm/dm/http-post-message.svg)](https://www.npmjs.com/package/http-post-message)
[![GitHub tag](https://img.shields.io/github/tag/microsoft/http-post-message.svg)](https://github.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'.
## Documentation:
### [https://microsoft.github.io/http-post-message](https://microsoft.github.io/http-post-message)
## Installation
```bash
npm install -g http-post-message
npm install --save http-post-message
```

@@ -16,3 +23,3 @@

In the case below we created a mock postMessage proxy, but in normal usage you would likely use the accompanying library [window-post-message-proxy](https://pbix.visualstudio.com/DefaultCollection/PaaS/_git/window-post-message-proxy).
In the case below we created a mock postMessage proxy, but in normal usage you would likely use the accompanying library [window-post-message-proxy](https://pbix.visualstudio.com/DefaultCollection/PaaS/_git/window-post-message-proxy) and configure it to handle http messages as shown in the section [below](#promiseresolution)

@@ -41,1 +48,37 @@ ```typescript

### <a name="promiseresolution"></a> Determining promise resolution state
The promise returned by the request will be fulfulled or rejected depending on how the instance of WindowPostMessageProxy provided to the constructor was configured.
Since we intend to use HTTP semantics, this library comes with static methods that can be provided to the WPMP class during construction as seen below:
```javascript
import * as wpmp from 'window-post-message-proxy';
import * as hpm from 'http-post-message';
const windowPostMessageProxy = new wpmp.WindowPostMessageProxy({
processTrackingProperties: {
addTrackingProperties: hpm.HttpPostMessage.addTrackingProperties,
getTrackingProperties: hpm.HttpPostMessage.getTrackingProperties,
},
isErrorMessage: hpm.HttpPostMessage.isErrorMessage
});
const httpPostMessage = new hpm.HttpPostMessage(windowPostMessageProxy);
```
### Default Headers and Default Window
You may specify default headers and default target window to be sent with every request by supplying them during construction.
Providing the default target window in the constructor means you do not have to specify it in each individual request, but it can be over written to allow a single instance of HPM to communicate with multiple windows.
```javascript
import * as hpm from 'http-post-message';
...
const httpPostMessage = new hpm.HttpPostMessage(wpmp, {
'x-sdk-type': sdkType,
'x-sdk-version': sdkVersion
}, defaultTargetWindow);
});
```

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