Cannot read properties of undefined (reading 'signerKeyPassphrase')
Gangadhar9848 opened this issue · 5 comments
##macOS Venture 13.5.2
nodejs: v18.18.0
Description
Wrote a simple program to see the Apple pass generated but got this error ": Cannot read properties of undefined (reading 'signerKeyPassphrase')" even though that attribute has been given as a string under certificates
Expected behavior
Should be able to read all certificate params required to generate apple pass
-->
Steps to reproduce
// Specify the file path
const filePath = './model/Generic.pass/pass.json';
const iconpath = './model/Generic.pass/icon.png';
const thumbnailpath = './model/Generic.pass/thumbnail.png';
// Create a new PKPass instance
const pass = new PKPass({
"thumbnail.png" : fs.readFileSync(thumbnailpath),
"pass.json": fs.readFileSync(filePath),
"icon.png": fs.readFileSync(iconpath),
certificates: {
wwdr: fs.readFileSync("./certs/wwdr.pem"),
signerCert: fs.readFileSync("./certs/signerCert.pem"),
signerKey: fs.readFileSync("./certs/signerKey.pem"),
signerKeyPassphrase: "test"
}
});
Error: Error: TypeError: Cannot read properties of undefined (reading 'signerKeyPassphrase')
at getStringCertificates (/Users/gangadhar_bhimavarap/Desktop/VS/Apple-pass/node_modules/passkit-generator/lib/Signature.js:96:43)
at Object.create (/Users/gangadhar_bhimavarap/Desktop/VS/Apple-pass/node_modules/passkit-generator/lib/Signature.js:30:63)
at [pass.close] (/Users/gangadhar_bhimavarap/Desktop/VS/Apple-pass/node_modules/passkit-generator/lib/PKPass.js:461:43)
at PKPass.getAsBuffer (/Users/gangadhar_bhimavarap/Desktop/VS/Apple-pass/node_modules/passkit-generator/lib/PKPass.js:476:34)
at createPass (/Users/gangadhar_bhimavarap/Desktop/VS/Apple-pass/index.js:33:25)
at Object.<anonymous> (/Users/gangadhar_bhimavarap/Desktop/VS/Apple-pass/index.js:48:1)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
Were you able to verify it by using (and changing) the examples?
Yes
If yes, which changes did you apply?
yes the way certificates can be read
Other details
- I'm available to open a Pull Request to resolve the problem (after the triage)
Hi @Gangadhar9848, thanks for using passkit-generator!
I've edited your post because the code you provided was hidden.
You are using the API in the wrong way. You should not have a property certificates
, which only belongs to PKPass.from
.
Please look again at the API Documentation in wiki and the examples.
Feel free to come back to ask if you need any further help.
Let me know.
ah yes, I overlooked it. Thanks @alexandercerutti. Fixed it, pass has been generated but unable to open. need to check
If you need, you can use the guide in the wiki to help you debugging 💪
Thank You for this @alexandercerutti , I am able to create my first ever wallet pass:). i am new this so have a question. can this pass be opened in any apple device? i mean cant we assign to the user meant to be? may be i am missing to read that property somwhere
Apple Wallet passes can be opened on iPhones and Macs, but they depend on the loaded assets.
For example, to open a pass on an iPhone that uses a x3 resolutions assets, you will need (mandatory) an icon@x3.png file. I think that opening them on the Mac requires just the basic icon file, but I'm not sure.
They are zip files and do not own opening-protection mechanisms.
But, if you want, you can prevent sharing them.