Comparing version 0.2.0 to 0.3.0
0.3.0 / 2013-01-16 | ||
================== | ||
* test: [agent] add common agent tests that run for both mock and live | ||
* test: [travis] only test node 0.8.x | ||
* test: [live-agent] change tests to only run if key/cert is available | ||
* Merge branch 'feature/msgid' | ||
* test: [agent] nextId and agent integration | ||
* agent: [nextId] add nextId method and message.id getter | ||
* Merge branch 'feature/mockagent' | ||
* test: [mockagent] normalize reconnect process against live | ||
* test: [mock-agent] add tests for mock agent | ||
* agent: [mock] add mock agent | ||
* agent: [util] normalize prep of gateway options | ||
* agent: rename live agent from agent.js to live.js | ||
* agent: add base class and live agent extends base class | ||
* deps: update with tea-inherits | ||
* agent: [old] remove single class agent | ||
0.2.0 / 2013-01-15 | ||
@@ -3,0 +22,0 @@ ================== |
@@ -11,11 +11,17 @@ /*! | ||
exports.version = '0.2.0'; | ||
exports.version = '0.3.0'; | ||
/*! | ||
* Agent | ||
* Agent (Live) | ||
*/ | ||
exports.Agent = require('./apnagent/agent'); | ||
exports.Agent = require('./apnagent/agent/live'); | ||
/*! | ||
* Agent (Mock) | ||
*/ | ||
exports.MockAgent = require('./apnagent/agent/mock'); | ||
/*! | ||
* Errors | ||
@@ -22,0 +28,0 @@ */ |
@@ -17,3 +17,4 @@ /*! | ||
var util = require('./util'); | ||
var errors = require('./errors') | ||
, util = require('./util'); | ||
@@ -42,3 +43,8 @@ /*! | ||
this.encoding = enc || 'utf8'; | ||
this.meta = { codec: codec }; | ||
this.meta = { | ||
codec: codec | ||
, identifier: this._agent | ||
? this._agent.nextId() | ||
: 0 | ||
}; | ||
this.settings = {}; | ||
@@ -49,2 +55,8 @@ this.payload = {}; | ||
Object.defineProperty(Message.prototype, 'id', { | ||
get: function () { | ||
return this.meta.identifier; | ||
} | ||
}); | ||
/** | ||
@@ -161,22 +173,2 @@ * .set (key, value) | ||
* | ||
* Set the message ID when being used with the enhanced | ||
* codec. If you are composing a message using the | ||
* service API, this will be automatically set. | ||
* | ||
* See APNS documentation for more information. | ||
* | ||
* @param {Buffer|Hex|String} message id | ||
* @returns {this} for chaining | ||
* @api public | ||
*/ | ||
Message.prototype.id = function (id) { | ||
//TODO: implement this | ||
}; | ||
/** | ||
* .id (id) | ||
* | ||
* > NOTE: not currently implemented | ||
* | ||
* Set the message expiration date when being used | ||
@@ -249,4 +241,6 @@ * with the enhanced codec. If you are composing a | ||
Message.prototype.serialize = function () { | ||
var payload = {} | ||
, enc = this.encoding; | ||
var enc = this.encoding | ||
, payload = {} | ||
, SE = errors.SerializationError | ||
, ssf = arguments.callee; | ||
@@ -283,3 +277,3 @@ // copy over extra variables | ||
if (!body) { | ||
throw new Error('Message too long.'); | ||
throw new SE('Message too long.', null, ssf); | ||
} | ||
@@ -293,10 +287,14 @@ | ||
} else if (len > 256) { | ||
throw new Error('Message too long.'); | ||
throw new SE('Message too long.', null, ssf); | ||
} | ||
if (!this.meta.device) { | ||
throw new Error('Device must be specified'); | ||
throw new SE('Device must be specified', null, ssf); | ||
} | ||
return { deviceToken: this.meta.device, payload: payload }; | ||
return { | ||
deviceToken: this.meta.device | ||
, identifier: this.id | ||
, payload: payload | ||
}; | ||
}; | ||
@@ -303,0 +301,0 @@ |
@@ -7,2 +7,16 @@ /*! | ||
/*! | ||
* Module Dependencies | ||
*/ | ||
var fs = require('fs'); | ||
/*! | ||
* APN Service Constants | ||
*/ | ||
var APNS_PORT = 2195 | ||
, APNS_PROD = 'gateway.push.apple.com' | ||
, APNS_SANDBOX = 'gateway.sandbox.push.apple.com'; | ||
/** | ||
@@ -23,1 +37,47 @@ * Trim a string to a specific length. It is | ||
}; | ||
exports.gatewayOptions = function (agent) { | ||
var opts = {}; | ||
function copy (key) { | ||
if (agent.get(key)) opts[key] = agent.get(key); | ||
} | ||
function read (file) { | ||
if (!fs.existsSync(file)) return null; | ||
return fs.readFileSync(file); | ||
} | ||
// get the tls host based on sandbox | ||
opts.host = agent.enabled('sandbox') | ||
? APNS_SANDBOX | ||
: APNS_PROD; | ||
// use default port | ||
opts.port = APNS_PORT; | ||
// get our tls certificates | ||
if (agent.get('pfx') || agent.get('pfx file')) { | ||
opts.pfx = agent.get('pfx file') | ||
? read(agent.get('pfx file')) | ||
: agent.get('pfx'); | ||
} else { | ||
opts.key = agent.get('key file') | ||
? read(agent.get('key file')) | ||
: agent.get('key'); | ||
opts.cert = agent.get('cert file') | ||
? read(agent.get('cert file')) | ||
: agent.get('cert'); | ||
} | ||
// apply ca certificate | ||
if (agent.get('ca')) { | ||
copy('ca'); | ||
opts.ca = [ opts.ca ]; | ||
} | ||
// include passphrase | ||
copy('passphrase'); | ||
return opts; | ||
} |
{ | ||
"name": "apnagent" | ||
, "version": "0.2.0" | ||
, "version": "0.3.0" | ||
, "description": "Node adapter for Apple Push Notification (APN) Service." | ||
@@ -25,3 +25,3 @@ , "author": "Jake Luer <jake@alogicalpardox.com> (http://alogicalparadox.com)" | ||
, "engines": { | ||
"node": "*" | ||
"node": ">= 0.8.0" | ||
} | ||
@@ -37,4 +37,5 @@ , "main": "./index" | ||
, "lotus": "0.2.x" | ||
, "tea-error": "0.1.x" | ||
, "tea-extend": "0.2.x" | ||
, "tea-error": "0.1.x" | ||
, "tea-inherits": "0.1.x" | ||
, "sherlock": "*" | ||
@@ -41,0 +42,0 @@ } |
@@ -1,2 +0,2 @@ | ||
# APN Agent | ||
# APN Agent [![Build Status](https://travis-ci.org/logicalparadox/apnagent.png?branch=master)](https://travis-ci.org/logicalparadox/apnagent) | ||
@@ -8,4 +8,4 @@ > Node adapater for Apple Push Notification (APN) Service. | ||
- chainable message builder | ||
- feature complete mock agent for local-only testing/development | ||
- support for both simple and enhanced apple message protocol | ||
- easy sandbox mode | ||
- continuous connection and auto-reconnect on timeout | ||
@@ -15,3 +15,2 @@ | ||
- feature complete mock agent for local-only testing/development | ||
- apn feedback service integration | ||
@@ -18,0 +17,0 @@ - documenation website |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30576
15
1008
8
50
2
+ Addedtea-inherits@0.1.x
+ Addedtea-inherits@0.1.0(transitive)