Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node-safari-push-notifications [![Build Status](https://travis-ci.org/MySiteApp/node-safari-push-notifications.svg?branch=master)](https://travis-ci.org/MySiteApp/node-safari-push-notifications) [![Coverage Status](https://coveralls.io/repos/github/MySiteApp/node-safari-push-notifications/badge.svg?branch=master)](https://coveralls.io/github/MySiteApp/node-safari-push-notifications?branch=master)
==============================

[![NPM](https://nodei.co/npm/safari-push-notifications.png)](https://nodei.co/npm/safari-push-notifications/)
[![NPM](https://nodei.co/npm/safari-push-package.png)](https://nodei.co/npm/safari-push-package/)

Helper methods for generating resources required by [Apple's Safari Push Notifications](http://apple.co/1rAeIvg).
This library was written while trying to implement node.js server that answers Safari, but it seems that OpenSSL's PKCS7 functions weren't available.
Expand All @@ -14,18 +14,18 @@ This library was written while trying to implement node.js server that answers S

Stable version:

$ npm install safari-push-notifications
$ npm install safari-push-package

From git:

$ npm install git://github.com/MySiteApp/node-safari-push-notifications.git
$ npm install https://github.com/raymondflores/node-safari-push-notifications.git

# Example
Certificate and Private Key should be in PEM format (pKey without password for now...)

```javascript
var fs = require('fs'),
pushLib = require('safari-push-notifications');
pushLib = require('safari-push-package');

var cert = fs.readFileSync('cert.pem'),
key = fs.readFileSync('key.pem'),
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "safari-push-notifications",
"name": "safari-push-package",
"version": "0.3.1",
"description": "Helper methods for generating resources required by Apple's Safari Push Notifications (http://apple.co/1P39vbY)",
"main": "src/index.js",
Expand All @@ -9,20 +9,20 @@
},
"repository": {
"type": "git",
"url": "git://github.com/MySiteApp/node-safari-push-notifications"
"url": "https://github.com/raymondflores/node-safari-push-notifications"
},
"keywords": [
"safari",
"push",
"notifications",
"apple"
],
"author": "Kobi Meirson <[email protected]>",
"author": "Kobi Meirson <[email protected]>, Raymond Flores <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/MySiteApp/node-safari-push-notifications/issues"
"url": "https://github.com/raymondflores/node-safari-push-notifications/issues"
},
"homepage": "https://github.com/MySiteApp/node-safari-push-notifications",
"homepage": "https://github.com/raymondflores/node-safari-push-notifications",
"dependencies": {
"jszip": "^3.1.3",
"bindings": "^1.2.1",
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ var generatePackage = function(websiteJSON, iconsDir, certData, pKeyData, interm

// website.json
var websiteContent = new Buffer(JSON.stringify(websiteJSON));
manifest['website.json'] = utils.sha1(websiteContent);
manifest['website.json'] = utils.sha512(websiteContent);
zip.file('website.json', websiteContent);

// icon.iconset
var icons = zip.folder('icon.iconset'),
addIconFile = function(name, content) {
content = typeof content === 'string' ? fs.readFileSync(content) : content;
manifest['icon.iconset/' + name] = utils.sha1(content);
manifest['icon.iconset/' + name] = utils.sha512(content);
icons.file(name, content);
};
if (typeof iconsDir === 'object') {
Expand Down
9 changes: 6 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ module.exports = {
}
return number + ""; // always return a string
},
sha1: function (content) {
var shasum = crypto.createHash('sha1');
sha512: function (content) {
var shasum = crypto.createHash('sha512');
shasum.update(content);
return shasum.digest('hex');
return {
"hashType": "sha512",
"hashValue": shasum.digest('hex')
};
}
};
4 changes: 2 additions & 2 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ describe('test zeroFill', function() {
});
});

describe('test sha1', function() {
describe('test sha512', function() {
test('it works', function() {
expect(pushUtils.sha1('itworks')).toBe('fe077c8079ace921b8f9bd00d7e50e049acfda94');
expect(pushUtils.sha512('itworks')).toEqual({"hashType": "sha512", "hashValue": "ff3470c61d4e3f66e69bf472fd48ff67b42be150625aa0d825f0fa86dd7cb6c01e54f0c810b9208371ae3295cf892ae051e93455a041dcdafcf2cffb5d2a245a"});
});
});