Apple Pass Generator for Node.js
$ npm install passgenerator-js
Follow the Apple Wallet Developer Guide to download and edit a sample pass.
Apple’s World Wide Developer Relations (WWDR) certificate is available from Apple at http://developer.apple.com/certificationauthority/AppleWWDRCA.cer.
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.
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. |
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). |
Directory structure of a sample pass.
.
└── Sample.pass/
├── icon.png
├── icon@2x.png
├── pass.json
├── en.lproj/
│ ├── logo.png
│ └── logo@2x.png
└── th.lproj/
├── logo.png
└── logo@2x.png
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('icon@2x.png', './Sample.pass/icon@2x.png')
pass.add('pass.json', './Sample.pass/pass.json')
pass.add('logo.png', './Sample.pass/en.lproj/logo.png', 'en')
pass.add('logo@2x.png', './Sample.pass/en.lproj/logo@2x.png', 'en')
pass.add('logo.png', './Sample.pass/th.lproj/logo.png', 'th')
pass.add('logo@2x.png', './Sample.pass/th.lproj/logo@2x.png', 'th')
const pkpass = pass.generate()
fs.writeFileSync('Sample.pkpass', pkpass)