2.0.0 • Published 9 years ago

spn-auth-token v2.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

spn-auth-token

Build Status Dependency Status devDependency Status

Encoding and decoding authentication token of Safari Push Notifications.

Install

npm install spn-auth-token

Usage

var spnAuthToken = require('spn-auth-token');

spnAuthToken.crypt({id: 'my-id'}, 'salt')
.then(function (token) {
  console.log(token); // eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIifQ.e9wZgUdux3Bp-QVGjhEBpuS65hU4zcr1uzCMJyPwsg0
});

spnAuthToken.decrypt('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIifQ.e9wZgUdux3Bp-QVGjhEBpuS65hU4zcr1uzCMJyPwsg0', 'salt')
.then(function (payload) {
  console.log(payload); // {id: 'my-id'}
});

spnAuthToken.encode(payload, secret)

Generate an authentication token from a payload.

spnAuthToken.decode(token, secret)

Decode an authentication token.

License

MIT