Created
June 14, 2022 12:17
-
-
Save luisivan/acd1661ef410b13632aeed5b320ee3e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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