Skip to content

Instantly share code, notes, and snippets.

@luisivan
Created June 14, 2022 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luisivan/acd1661ef410b13632aeed5b320ee3e5 to your computer and use it in GitHub Desktop.
Save luisivan/acd1661ef410b13632aeed5b320ee3e5 to your computer and use it in GitHub Desktop.
import passkit from "passkit-generator";
import fs from 'fs'
try {
/** Each, but last, can be either a string or a Buffer. See API Documentation for more */
const wwdr = fs.readFileSync('./cert/AppleWWDRCAG4.pem')
const signerCert = fs.readFileSync('./cert/passes.pem')
const signerKey = fs.readFileSync('./cert/passes.key')
const pass = await passkit.PKPass.from({
/**
* Note: .pass extension is enforced when reading a
* model from FS, even if not specified here below
*/
model: "./passport.pass",
certificates: {
wwdr,
signerCert,
signerKey,
},
}, {
// keys to be added or overridden
serialNumber: "001",
id: "not yet :)",
holder: "luisc.eth",
});
// pass.setBarcodes("36478105430"); // Random value
// Generate the stream .pkpass file stream
const out = fs.createWriteStream('passport.pkpass')
pass.getAsStream().pipe(out)
} catch (err) {
console.log(err)
}⏎
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment