A javascript library for parsing & validating APNS (Apple Push Notification Service) PKCS#12 certificates.
The purpose of the library is to handle changes to / addition of APNS certificates during runtime of services handling multiple certificates at once.
And throws understandable messages given erroneous certificates.
It can be used both client and server side.
constfs=require('fs');constpath=require('path');constApnsCertificate=require('../../build/src').ApnsCertificate;constP12_BASE64=fs.readFileSync('cert.p12').toString('base64');constpassphrase='passphrase if any';constcertificate=newApnsCertificate(P12_BASE64,passphrase);console.log(JSON.stringify(certificate,undefined,4));This will output
{
"key": "-----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY-----",
"cert": "-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----",
"topic": "dk.discountrobot.push",
"environment": {
"sandbox": true,
"production": false
},
"expires": "2018-08-05T20:34:44.000Z"
}Which can be used with the https module or more preferably the node-apn library
For client side use, the node-forge dependency must resolved during transpilation.
See the examples for more information