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

mpns

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mpns - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

127

lib/mpns.js

@@ -16,8 +16,2 @@ // Copyright Jeff Wilcox

// NOTES:
//
// This library is designed for Windows Phone 7.1 and 8.0 OS. To send push to
// a 7.0 device, the developer must not include the param value (toast) or
// any of the advanced back background tile images (tiles).
// Suggested fallback values if you're storing results in a document/db.

@@ -28,4 +22,5 @@ // See also: http://msdn.microsoft.com/en-us/library/ff941100%28v=VS.92%29.aspx

var url = require('url');
var http = require('http');
var url = require('url')
, http = require('http')
, https = require('https');

@@ -63,4 +58,4 @@ var Toast = function(options) {

if (options) {
copyOfInterest(options, this, propertiesOfInterest,
this.pushType === 'tile');
copyOfInterest(options, this, propertiesOfInterest, this.pushType === 'tile');
copyOfInterest(options, this, sslProperties);
}

@@ -88,64 +83,62 @@ }

var err = undefined;
var protocol = http;
if (options.protocol == 'https:') {
protocol = https;
var req = http.request(options, function(res) {
res.setEncoding('utf8');
res.on('end', function() {
result.statusCode = res.statusCode;
copyOfInterest(me, options, sslProperties);
// Store the important responses from MPNS.
if (res.headers) {
renameFieldsOfInterest(res.headers, result, {
'x-deviceconnectionstatus': 'deviceConnectionStatus',
'x-notificationstatus': 'notificationStatus',
'x-subscriptionstatus' : 'subscriptionStatus'
});
}
//opt out of connection pooling - otherwise error handling gets a lot more complicated
options.agent = false;
}
// Store the fields that were sent to make it easy to log.
copyOfInterest(me, result, propertiesOfInterest,
this.pushType === 'tile');
var req = protocol.request(options);
switch (res.statusCode) {
// The device is in an inactive state.
case 412:
result.minutesToDelay = HTTP_412_MINIMUM_DELAY_MINUTES; // Must be at least an hour.
err = result;
break;
req.on('response', function (message) {
result.statusCode = message.statusCode;
// Store the important responses from MPNS.
if (message.headers) {
renameFieldsOfInterest(message.headers, result, {
'x-deviceconnectionstatus': 'deviceConnectionStatus',
'x-notificationstatus': 'notificationStatus',
'x-subscriptionstatus': 'subscriptionStatus'
});
}
// Invalid subscriptions.
case 400:
case 401:
case 404:
result.shouldDeleteChannel = true;
err = result;
break;
// Store the fields that were sent to make it easy to log.
copyOfInterest(me, result, propertiesOfInterest, this.pushType === 'tile');
// Method Not Allowed (bug in this library)
case 405:
err = result;
break;
switch (message.statusCode) {
// The device is in an inactive state.
case 412:
result.minutesToDelay = HTTP_412_MINIMUM_DELAY_MINUTES; // Must be at least an hour.
err = result;
break;
case 406:
err = result;
err.innerError = 'Per-day throttling limit reached.';
break;
// Invalid subscriptions.
case 400:
case 401:
case 404:
result.shouldDeleteChannel = true;
err = result;
break;
case 503:
err = result;
result.minutesToDelay = ERROR_MINIMUM_DELAY_MINUTES;
err.innerError = 'The Push Notification Service is unable to process the request.';
break;
}
// Method Not Allowed (bug in this library)
case 405:
err = result;
break;
if (callback)
callback(err, err === undefined ? result : undefined);
case 406:
err = result;
err.innerError = 'Per-day throttling limit reached.';
break;
}).on('error', function(e) {
result.minutesToDelay = ERROR_MINIMUM_DELAY_MINUTES; // Just a recommendation.
case 503:
err = result;
err.innerError = e;
result.minutesToDelay = ERROR_MINIMUM_DELAY_MINUTES;
err.innerError = 'The Push Notification Service is unable to process the request.';
break;
}
if (callback)
callback(err);
});
if (callback)
callback(err, err === undefined ? result : undefined);
});

@@ -172,3 +165,3 @@

var key = fieldsOfInterest[i];
if (source[key] || (source[key] === null && allowNull)) {
if (source[key] || (source[key] === null && allowNull === true)) {
destination[key] = source[key];

@@ -313,2 +306,3 @@ }

copyOfInterest(payload, params, typeProperties, type === 'tile');
copyOfInterest(payload, params, sslProperties, false);
}

@@ -340,2 +334,13 @@ else {

//tls.connect ssl params
var sslProperties = [
'pfx',
'key',
'passphrase',
'cert',
'ca',
'ciphers',
'rejectUnauthorized'
];
var toastProperties = [

@@ -342,0 +347,0 @@ 'text1',

{
"name": "mpns",
"description": "A Node.js interface to the Microsoft Push Notification Service (MPNS) for Windows Phone.",
"version": "1.2.4",
"version": "1.2.5",
"author": "Jeff Wilcox <jeffwilcox+github@gmail.com>",

@@ -13,3 +13,3 @@ "contributors": [

"main": "./lib/mpns.js",
"engines": { "node":">= 0.5.0 <= 0.9.0" }
"engines": { "node":">= 0.5.0" }
}

@@ -90,2 +90,33 @@ #mpns

### Using authenticated channels (MTLS)
You may use authenticated channels for the push notifications. Further information can be found here:http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff941099(v=vs.105).aspx
Authenticated channels require a TLS client certificate for client authentication against the MPNS server.
The TLS certificate is registered in your Microsoft Phone Development Dashboard.
The CN of the certificate is used in the APP as Service Name in the HttpNotificationChannel constructor.
To use authentication you must provide the client certificate (including the private key) to the options of the send* functions.
The client certificate is used when the pushURI is a https URI.
The following options from tls.connect() can be specified:
* `pfx` Certificate, Private key and CA certificates to use for SSL. Default null.
* `key` Private key to use for SSL. Default null.
* `passphrase` A string of passphrase for the private key or pfx. Default null.
* `cert` Public x509 certificate to use. Default null.
* `ca` An authority certificate or array of authority certificates to check the remote host against.
* `ciphers` A string describing the ciphers to use or exclude.
* `rejectUnauthorized` If true, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Default true.
```javascript
var options = {
text1: 'Hello!',
text2: 'Great to see you today.'
cert: fs.readFileSync('mycert.pem'),
key: fs.readFileSync('mycertkey.pem')
};
mpns.sendToast(httpspushUri, options, callback);
```
### Results object information

@@ -115,9 +146,10 @@ A results object is passed back through the callback and has important information from MPNS.

Here is a list of features that are only supported in given versions of Windows Phone:
* Only supported in Windows Phone 7.5+ (Mango)
* For Windows Phone 7.0
* Do not use the `param` or other fields as indicated below and it should work OK.
* Only supported in Windows Phone 7.5+ (Mango/WP 7.1 OS)
* Including the `param` field when sending a push
* Including the `id` parameter when sending a tile
* Only supported in Windows Phone 7.8+
* Only supported in Windows Phone 7.8+ (including Windows Phone 8)
* Sending "flip" tiles
## Credits

@@ -153,2 +185,6 @@

1.2.5:
* Adds support for TLS/HTTPS authenticated push channels
1.2.4:

@@ -155,0 +191,0 @@

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