1.1.1 • Published 10 years ago
passbooker v1.1.1
node-passbooker
Generates Apple Passboks.
Warning: Not yet production ready! The API is still subject to change without notice and it's using blocking I/O internally.
Dependencies
- openssl
General
Pass types:
- Boarding passes
boardingPass
- Coupon
coupon
- Event ticket
eventTicket
- Store card
storeCard
- Generic
generic
Usage
$ npm install passbooker
Preparation
- Get your Passbook certificate from the Apple Developer portal, import it into your key chain and export it as a passwordless PKCS #12 archive (e.g. Certificates.p12).
- Get the Worldwide Developer Relations Certificate,import it into your key chain and export it as a PEM (e.g. WWDR.pem).
- Use the node-passbooker CLI to extract the certificate and private key needed to sign your Passbooks.
- Put pass.pem, pass-key.pem and WWDR.pem in a dir your node app can access and set the keysPath to your template.
$ ./node_modules/passbooker/bin/node-passbooker -c './path/to/Certificates.p12' -o './keys/'
-->
keys
+--- pass.pem
+--- pass-key.pem
+--- WWDR.pem
Example
var path = require('path');
var fs = require('fs');
var Passbooker = require('passbooker');
var templateOptions = {
// Mandatory
passTypeIdentifier:'pass.acmecorp.genericFoo',
teamIdentifier: 'XXXXXXXXXX',
organizationName: 'ACME Corp',
imagePath: path.join( __dirname, 'samples', 'images' ),
keysPath: path.join( __dirname, 'samples', 'keys' ),
// Nice to have
logoText: 'ACME Corp',
description: 'Foo bar'
};
var template = new Passbooker.Template( 'generic', templateOptions );
template
.setPrimaryField( 'headline', 'ACME Generic card' )
var pass = new Passbooker.Pass( template, {
serialNumber: 'foo:bar:1'
});
pass
.setSecondaryField( 'acme_id', 'ID', 'xxxx' )
.setSecondaryField( 'acme_pin', 'PIN', 'xxxx' )
.setBackField( 'acme_id', 'ID', 'xxxx' );
pass.getPackage(function( err, passPackage ) {
if ( !!err ) {
return console.log( err );
}
fs.writeFileSync( './samples/fooBar.pkpass', passPackage );
});
Apples Passbook Programming Guide
Links:
Directory structure of a sample pass
[Pass package]
+--- icon.png
+--- icon@2x.png
+--- thumbnail.png
+--- thumbnail@2x.png
+--- pass.json
\--- de.lproj
+--- logo.png
+--- logo@2x.png
+--- pass.strings
\--- en.lproj
+--- logo.png
+--- logo@2x.png
+--- pass.strings