UNPKG

passgenerator-js

Version:
99 lines (78 loc) 3.95 kB
<img src="https://docs-assets.developer.apple.com/published/c104c9bff0/841b02dd-b78c-4cad-8da4-700761d34e14.png" width="50" height="50" alt="Apple Wallet Logo" align="left" /> # PassGenerator [![NPM Version][npm-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-downloads-url] Apple Pass Generator for Node.js ## Install ``` $ npm install passgenerator-js ``` ## Get Started Follow the [Apple Wallet Developer Guide][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](http://developer.apple.com/certificationauthority/AppleWWDRCA.cer). ### Pass Signing Certificate To download your pass signing certificate, do the following: 1. Log into your [Apple Developer Console][apple-developer-console]. 2. In Certificates, Identifiers & Profiles, select Identifiers. 3. Under Identifiers, select Pass Type IDs. 4. Click the plus (+) button. 5. Enter the description and pass type identifier, and click Submit. 6. Select the pass type identifier, then click Edit. 7. Click the Create Certificate button, then follow the instructions to create a pass signing certificate. 8. Download your new certificate. Double click to add this certificate to your Keychain. 9. 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 ├── icon@2x.png ├── pass.json ├── en.lproj/ │ ├── logo.png │ └── logo@2x.png └── th.lproj/ ├── logo.png └── logo@2x.png ``` ```js 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) ``` ## License [MIT](LICENSE) [npm-image]: https://img.shields.io/npm/v/passgenerator-js.svg [npm-url]: https://npmjs.org/package/passgenerator-js [npm-downloads-image]: https://img.shields.io/npm/dm/passgenerator-js.svg [npm-downloads-url]: https://npmcharts.com/compare/passgenerator-js?minimal=true [apple-developer-console]: https://developer.apple.com/account [apple-wallet-developer-guide]: https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/PassKit_PG/YourFirst.html