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.8 to 2.0.0

CHANGELOG.md

60

lib/mpns.js

@@ -21,5 +21,5 @@ // Copyright Jeff Wilcox

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

@@ -40,6 +40,6 @@ var Toast = function(options) {

return new PushMessage('tile', '1', 'token', options);
}
};
var RawNotification = function(payload, options) {
if (options == undefined) {
if (options === undefined) {
options = payload;

@@ -91,3 +91,3 @@ } else {

var result = { };
var err = undefined;
var err;
var protocol = http;

@@ -239,3 +239,3 @@ if (options.protocol == 'https:') {

function startTag(tag, attributes, endInstead) {
var tag = '<' + (endInstead ? '/' : '') + 'wp:' + tag;
tag = '<' + (endInstead ? '/' : '') + 'wp:' + tag;
if(!endInstead && attributes && attributes.length){

@@ -295,12 +295,7 @@ attributes.forEach(function(pair){

attributes.push(['Id', options.id]);
};;
}
return attributes;
}
function send(type, typeProperties, objectType, args) {
var pushUri = Array.prototype.shift.apply(args);
if (typeof pushUri !== 'string')
throw new Error('The pushUri parameter must be the push notification channel URI string.');
function create(type, typeProperties, objectType, args) {
var params = {};

@@ -323,8 +318,19 @@ if (typeof args[0] === 'object') {

if (type == 'toast' && typeof params.text1 !== 'string')
if (type == 'toast' && typeof params.text1 !== 'string') {
throw new Error('The text1 toast parameter must be set and a string.');
}
if (type == 'tile' && Object.keys(params).length == 0)
if (type == 'tile' && Object.keys(params).length === 0) {
throw new Error('At least 1 tile parameter must be set.');
}
return new objectType(params);
}
function send(type, typeProperties, objectType, args) {
var pushUri = Array.prototype.shift.apply(args);
if (typeof pushUri !== 'string')
throw new Error('The pushUri parameter must be the push notification channel URI string.');
var callback = args[args.length - 1];

@@ -335,3 +341,3 @@

var instance = new objectType(params);
var instance = create(type, typeProperties, objectType, args);
instance.send(pushUri, callback);

@@ -400,10 +406,20 @@ }

// These object constructors are effectively deprecated. Consider using
// sendToast, sendTile or sendRaw methods going forward.
liveTile: LiveTile,
toast: Toast,
rawNotification: RawNotification,
createTile: function () {
return create('tile', properties.tile, LiveTile, arguments);
},
createFlipTile: function() {
return create('tile', properties.flipTile, FlipTile, arguments);
},
createToast: function () {
return create('toast', properties.toast, Toast, arguments);
},
createRaw: function () {
return create('raw', ['payload'], RawNotification, arguments);
},
// Used for testing
Properties: properties
};
{
"name": "mpns",
"description": "A Node.js interface to the Microsoft Push Notification Service (MPNS) for Windows Phone.",
"version": "1.2.8",
"version": "2.0.0",
"author": "Jeff Wilcox <jeffwilcox+github@gmail.com>",

@@ -14,3 +14,5 @@ "contributors": [

"engines": { "node":">= 0.5.0" },
"test": "make test",
"scripts": {
"test": "mocha -u tdd --reporter spec test/*.js"
},
"devDependencies": {

@@ -17,0 +19,0 @@ "should": "*",

@@ -190,69 +190,6 @@ #mpns

1.2.8:
The changelog has moved over time.
* Adds a fix for Node 0.10.10+ to properly consume response data via stream resume
* 1.2.8 and newer: The GitHub releases feature provides this information at https://github.com/jeffwilcox/mpns/releases
* 0-1.2.8: Available in the [CHANGELOG.md](https://github.com/jeffwilcox/mpns/blob/master/CHANGELOG.md) markdown file
1.2.7:
* Mild refactoring
1.2.6:
* Adds support for an HTTP proxy via `options.proxy` (thanks @tjunnone)
1.2.5:
* Adds support for TLS/HTTPS authenticated push channels
1.2.4:
* Fixes a small typo in smallBackgroundImage (thanks @rs)
* Adds error handling when URLs cannot be resolved
1.2.3:
* Uses `url.parse` to support hostnames with ports
1.2.2:
* Allows clearing a property value for tiles
1.2.1:
* Renames `sendRawNotification` to `sendRaw`
* Renames `error` parameter to `innerError`
* Fixes issue #8 that `sendRaw` wasn't working
1.2.0:
* Adds support for `sendFlipTile` method to support the new kinds of tiles added in 7.8+ devices
* Adds support for secondary tiles via the `id` parameter
1.1.1:
* Adds parameter validation that will throw, for robustness.
1.1.0:
* Adds `sendText` and `sendTile` methods more consistent with the WNS module, removing the need to create a new object, only to then call send on it with a push URI.
1.0.4:
* Adds support for Node.js through 0.9.0
1.0.3:
* Addresses issues when using numbers to set the tile data
* Cleans up string encoding functions.
1.0.2:
* Fixes some small formatting issues.
1.0.1:
* Adds raw notification type support.
1.0.0:
* Initial implementation offering basic live tile and toast (no raw) support.

@@ -16,94 +16,142 @@ // Copyright Jeff Wilcox

var assert = require('assert')
, mpns = require('../lib/mpns');
var assert = require('assert'),
mpns = require('../lib/mpns');
suite('mpns', function () {
test('HttpProperties', function () {
assert.notEqual(mpns.Properties.http, null);
assert.deepEqual(mpns.Properties.http, ['proxy']);
});
test('HttpProperties', function () {
assert.notEqual(mpns.Properties.http, null);
assert.deepEqual(mpns.Properties.http, ['proxy']);
});
test('SslProperties', function () {
assert.notEqual(mpns.Properties.ssl, null);
assert.deepEqual(mpns.Properties.ssl,
[
'pfx',
'key',
'passphrase',
'cert',
'ca',
'ciphers',
'rejectUnauthorized'
]);
});
test('SslProperties', function () {
assert.notEqual(mpns.Properties.ssl, null);
assert.deepEqual(mpns.Properties.ssl,
[
'pfx',
'key',
'passphrase',
'cert',
'ca',
'ciphers',
'rejectUnauthorized'
]);
});
test('ToastProperties', function () {
assert.notEqual(mpns.Properties.toast, null);
assert.deepEqual(mpns.Properties.toast,
[
'text1',
'text2',
'param'
]);
});
test('ToastProperties', function () {
assert.notEqual(mpns.Properties.toast, null);
assert.deepEqual(mpns.Properties.toast,
[
'text1',
'text2',
'param'
]);
});
test('TileProperties', function () {
assert.notEqual(mpns.Properties.tile, null);
assert.deepEqual(mpns.Properties.tile,
[
'backgroundImage',
'count',
'title',
'backBackgroundImage',
'backTitle',
'backContent',
'id'
]);
});
test('TileProperties', function () {
assert.notEqual(mpns.Properties.tile, null);
assert.deepEqual(mpns.Properties.tile,
[
'backgroundImage',
'count',
'title',
'backBackgroundImage',
'backTitle',
'backContent',
'id'
]);
});
test('FlipTileProperties', function () {
assert.notEqual(mpns.Properties.flipTile, null);
assert.deepEqual(mpns.Properties.flipTile.sort(),
[
'backgroundImage',
'count',
'title',
'backBackgroundImage',
'backTitle',
'backContent',
'id',
'smallBackgroundImage',
'wideBackgroundImage',
'wideBackContent',
'wideBackBackgroundImage'
].sort());
});
test('FlipTileProperties', function () {
assert.notEqual(mpns.Properties.flipTile, null);
assert.deepEqual(mpns.Properties.flipTile.sort(),
[
'backgroundImage',
'count',
'title',
'backBackgroundImage',
'backTitle',
'backContent',
'id',
'smallBackgroundImage',
'wideBackgroundImage',
'wideBackContent',
'wideBackBackgroundImage'
].sort());
});
test('OfInterestProperties', function () {
assert.notEqual(mpns.Properties.ofInterest, null);
assert.deepEqual(mpns.Properties.ofInterest.sort(),
[
'payload',
'pushType',
'tileTemplate',
test('OfInterestProperties', function () {
assert.notEqual(mpns.Properties.ofInterest, null);
assert.deepEqual(mpns.Properties.ofInterest.sort(),
[
'payload',
'pushType',
'tileTemplate',
'backgroundImage',
'count',
'title',
'backBackgroundImage',
'backTitle',
'backContent',
'id',
'smallBackgroundImage',
'wideBackgroundImage',
'wideBackContent',
'wideBackBackgroundImage',
'backgroundImage',
'count',
'title',
'backBackgroundImage',
'backTitle',
'backContent',
'id',
'smallBackgroundImage',
'wideBackgroundImage',
'wideBackContent',
'wideBackBackgroundImage',
'text1',
'text2',
'param'
].sort());
});
'text1',
'text2',
'param'
].sort());
});
});
test('CreateToastWithObject', function () {
var toast = mpns.createToast({
text1: 'Bold text:',
text2: 'normal text',
param: 'NewPage.xaml?item=5'
});
assert.deepEqual(toast.pushType, 'toast');
assert.deepEqual(toast.notificationClass, '2');
assert.deepEqual(toast.targetName, 'toast');
assert.deepEqual(toast.param, 'NewPage.xaml?item=5');
assert.deepEqual(toast.text1, 'Bold text:');
assert.deepEqual(toast.text2, 'normal text');
});
test('CreateToastWithPrimitives', function () {
var toast = mpns.createToast('Bold text:', 'normal text', 'NewPage.xaml?item=5');
assert.deepEqual(toast.pushType, 'toast');
assert.deepEqual(toast.notificationClass, '2');
assert.deepEqual(toast.targetName, 'toast');
assert.deepEqual(toast.param, 'NewPage.xaml?item=5');
assert.deepEqual(toast.text1, 'Bold text:');
assert.deepEqual(toast.text2, 'normal text');
});
test('CreateTileWithObject', function () {
var tile = mpns.createTile({
count: 1,
title: 'hello',
backTitle: 'backtitle',
backContent: 'backcontent'
});
assert.deepEqual(tile.count, 1);
assert.deepEqual(tile.title, 'hello');
assert.deepEqual(tile.backTitle, 'backtitle');
assert.deepEqual(tile.backContent, 'backcontent');
});
test('CreateTileWithPrimitives', function () {
var tile = mpns.createTile('', 1, 'hello', '', 'backtitle', 'backcontent');
assert.deepEqual(tile.count, 1);
assert.deepEqual(tile.title, 'hello');
assert.deepEqual(tile.backTitle, 'backtitle');
assert.deepEqual(tile.backContent, 'backcontent');
});
});
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