passgenerator-js
v1.0.7
Published
Apple Pass Generator for Node.js
Downloads
994
Maintainers
Readme
PassGenerator
Apple Pass Generator for Node.js
Install
$ npm install passgenerator-js
Get Started
Follow the Apple Wallet Developer Guide to download and edit a sample pass.
Apple's WWDR Certificate
Apple’s World Wide Developer Relations (WWDR) certificate is available from Apple at http://developer.apple.com/certificationauthority/AppleWWDRCA.cer.
Pass Signing Certificate
To download your pass signing certificate, do the following:
- Log into your Apple Developer Console.
- In Certificates, Identifiers & Profiles, select Identifiers.
- Under Identifiers, select Pass Type IDs.
- Click the plus (+) button.
- Enter the description and pass type identifier, and click Submit.
- Select the pass type identifier, then click Edit.
- Click the Create Certificate button, then follow the instructions to create a pass signing certificate.
- Download your new certificate. Double click to add this certificate to your Keychain.
- Right-click on your certificate, then click Export.
Options
Constructor
| Name | Type | Required | Description | |-------------|------------------|----------|-----------------------------------------------| | appleWWDRCA | Buffer | String | Required | Buffer or Path of Apple's WWDR Certificate. | | signCert | Buffer | String | Required | Buffer or Path of Pass Signing Certificate. | | password | String | Optional | The Password of the Pass Signing Certificate. |
Method: add
| Name | Type | Required | Description | |----------|------------------|----------|------------------------------------------------| | filename | String | Required | Filename with extension. | | data | Buffer | String | Required | File path as string or file content as buffer. | | language | String | Optional | Language Code (ISO 639-1). |
Usage
Directory structure of a sample pass.
.
└── Sample.pass/
├── icon.png
├── [email protected]
├── pass.json
├── en.lproj/
│ ├── logo.png
│ └── [email protected]
└── th.lproj/
├── logo.png
└── [email protected]
const fs = require('fs')
const PassGenerator = require('passgenerator-js')
const passGenerator = new PassGenerator({
appleWWDRCA: './AppleWWDRCA.cer',
signCert: './Certificates.p12'
})
const pass = passGenerator.createPass()
pass.add('icon.png', './Sample.pass/icon.png')
pass.add('[email protected]', './Sample.pass/[email protected]')
pass.add('pass.json', './Sample.pass/pass.json')
pass.add('logo.png', './Sample.pass/en.lproj/logo.png', 'en')
pass.add('[email protected]', './Sample.pass/en.lproj/[email protected]', 'en')
pass.add('logo.png', './Sample.pass/th.lproj/logo.png', 'th')
pass.add('[email protected]', './Sample.pass/th.lproj/[email protected]', 'th')
const pkpass = pass.generate()
fs.writeFileSync('Sample.pkpass', pkpass)