github webhooks
This commit is contained in:
@@ -189,8 +189,8 @@ use Lcobucci\JWT\Signer\Key\InMemory;
|
||||
use Lcobucci\JWT\Signer\Rsa\Sha256;
|
||||
use Lcobucci\JWT\Token\Builder;
|
||||
|
||||
if (!function_exists('generate_github_token')) {
|
||||
function generate_github_token(GithubApp $source)
|
||||
if (!function_exists('generate_github_installation_token')) {
|
||||
function generate_github_installation_token(GithubApp $source)
|
||||
{
|
||||
$signingKey = InMemory::plainText($source->privateKey->private_key);
|
||||
$algorithm = new Sha256();
|
||||
@@ -213,6 +213,23 @@ if (!function_exists('generate_github_token')) {
|
||||
return $token->json()['token'];
|
||||
}
|
||||
}
|
||||
if (!function_exists('generate_github_jwt_token')) {
|
||||
function generate_github_jwt_token(GithubApp $source)
|
||||
{
|
||||
$signingKey = InMemory::plainText($source->privateKey->private_key);
|
||||
$algorithm = new Sha256();
|
||||
$tokenBuilder = (new Builder(new JoseEncoder(), ChainedFormatter::default()));
|
||||
$now = new DateTimeImmutable();
|
||||
$now = $now->setTime($now->format('H'), $now->format('i'));
|
||||
$issuedToken = $tokenBuilder
|
||||
->issuedBy($source->app_id)
|
||||
->issuedAt($now->modify('-1 minute'))
|
||||
->expiresAt($now->modify('+10 minutes'))
|
||||
->getToken($algorithm, $signingKey)
|
||||
->toString();
|
||||
return $issuedToken;
|
||||
}
|
||||
}
|
||||
if (!function_exists('getParameters')) {
|
||||
function getParameters()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user