This file contains hidden or 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
| const jwt = require('jsonwebtoken'); | |
| const http2 = require('http2'); | |
| const fs = require('fs'); | |
| /* | |
| Read p8 file. Assumes p8 file to be in same directory | |
| */ | |
| const key = fs.readFileSync(__dirname + "/{your p8 filename}.p8", 'utf8') | |
| //"iat" should not be older than 1 hr from current time or will get rejected |
This file contains hidden or 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
| <?php | |
| function base64url_encode($binary_data) { return strtr(rtrim(base64_encode($binary_data), '='), '+/', '-_'); } | |
| function apns_jwt_token($team_id, $key_id, $private_key_pem_str) | |
| { | |
| if (! function_exists('openssl_get_md_methods') || ! in_array('sha256', openssl_get_md_methods())) throw new Exception('Requires openssl with sha256 support'); | |
| $private_key = openssl_pkey_get_private($private_key_pem_str); | |
| if (! $private_key) throw new Exception('Cannot decode private key'); |