UNPKG

passbooker

Version:
120 lines (84 loc) 3.17 kB
# 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 1. Get your Passbook certificate from the [Apple Developer portal](https://developer.apple.com/account/ios/certificate/certificateList.action), import it into your key chain and export it as a passwordless PKCS #12 archive (e.g. **Certificates.p12**). 2. Get the [Worldwide Developer Relations Certificate](http://www.apple.com/certificateauthority/),import it into your key chain and export it as a PEM (e.g. **WWDR.pem**). 3. Use the node-passbooker CLI to extract the certificate and private key needed to sign your Passbooks. 4. 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 ```javascript 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:** * [About Pass Files](https://developer.apple.com/library/ios/documentation/userexperience/Reference/PassKit_Bundle/Chapters/Introduction.html#//apple_ref/doc/uid/TP40012026-CH0-SW1) * [pass.json - Top-Level Keys (used in Template options)](https://developer.apple.com/library/ios/documentation/userexperience/Reference/PassKit_Bundle/Chapters/TopLevel.html#//apple_ref/doc/uid/TP40012026-CH2-SW1) * [Pass Design and Creation](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/PassKit_PG/Chapters/Creating.html) ### 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 ```