123456789101112131415161718192021222324252627282930313233 |
- const APNKey = require('./APNKey');
- const oids = require('./oids');
- function APNCertificate(cert) {
- if (!cert.publicKey || !cert.validity || !cert.subject) {
- throw new Error('certificate object is invalid');
- }
- this._cert = cert;
- }
- APNCertificate.prototype.key = function () {
- return new APNKey(this._cert.publicKey);
- };
- APNCertificate.prototype.validity = function () {
- return this._cert.validity;
- };
- APNCertificate.prototype.environment = function () {
- const environment = { sandbox: false, production: false };
- if (this._cert.getExtension({ id: oids.applePushServiceClientDevelopment })) {
- environment.sandbox = true;
- }
- if (this._cert.getExtension({ id: oids.applePushServiceClientProduction })) {
- environment.production = true;
- }
- return environment;
- };
- module.exports = APNCertificate;
|