iOS Apple passbook library
$ npm install passbookster
To create a pass, you first create a pass template which holds information that remains static for each subsequent pass created from the template. Then you can create a Pass by providing the rest of the fields and images.
A Pass can act as a stream, or as a plain-callback async operation. Performance-wise you should use the stream interface, when its possible to pipe the pass to another stream. (eg store to filesystem or Amazon S3)
openssl must be installed, and inside the
$PATH. It is used internally to calculate the pass signature, since node crypto API does not support PKCS 7. (TODO).
var passbook = require'passbookster'var template = passbookcreateTemplate'coupon'passTypeIdentifier: 'PASS_TYPE_ID'teamIdentifier: 'TEAM_ID'organizationName: 'Paw Planet'certs:wwdr: '/path/to/wwdr.pem'pass: '/path/to/pass_cert.pem' // pem with certificate and private keypassword: 'this_is_the_pass_phrase' // pass phrase for the pass_cert.pem filevar pass = templatecreatePassserialNumber: 'E5982H-I2'backgroundColor: 'rgb(206, 140, 53)'description: '20% off premium dog food'icon: fscreateReadStream'/path/to/icon.png'passpipefscreateWriteStream'pass.pkpass'
var template = passbookcreateTemplatestyle fields options
The style of the pass.
Must be one of: 'boardingPass', 'coupon', 'eventTicker', 'storeCard', 'generic'
Any field that should be included in all passes created from this template. Usually you want these to be passTypeIdentifier, teamIdentifier and organizationName, but it's completely ok to pass any pass field. These will be merely copied to each pass you create.
Object containing extra information about this pass. Only certificates for now.
Object with keys
pass and values the paths to the apple WWDR certificate and the pass certificate.
An object containing paths to apple wwdr and the pass certificate.
Pass to apple wwdr certificate
Pass to pass certificate
Rest of the fields you want this pass to have. Fields provided to the template will be included.
Optional callback function. If a callback is provided, then the pass will not act as a stream, and will call this function as
cb(err, res) when its done. Result is a buffer of the .pkpass created.
Images should be passed either in the template or pass fields. Type must be stream, buffer or path string. Valid image keys are: 'icon', 'logo', 'strip', 'thumbnail', 'background', 'footer' and a '2x' version of each of those, in case you also have high resolution images for retina displays.
templatecreatePassicon: '/path/to/image.png'icon2x: '/path/to/high/resolution/image.png'logo: fscreateReadStream'/path/to/logo.png'logo2x: streamFromS3footer: footerBuffer
export WWDR_CERT=/path/to/wwdr.certexport PASS_CERT=/path/to/pass.certnpm test
- More and proper tests
- Add PKCS7 signing to node crypto