Skip to content

Commit

Permalink
Allow lcobucci/jwt to v4 or v5 (#8)
Browse files Browse the repository at this point in the history
* Force  lcobucci/jwt to v4

* Allow lcobucci/jwt 5.0

---------

Co-authored-by: Florent Morselli <[email protected]>
  • Loading branch information
ErnadoO and Spomky authored Apr 28, 2023
1 parent afd9498 commit 5ef905d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"doctrine/orm": "^2.6",
"friendsofphp/php-cs-fixer": "^3.0",
"infection/infection": "^0.22",
"lcobucci/jwt": "^4.0",
"lcobucci/jwt": "^4.0|^5.0",
"matthiasnoback/symfony-config-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"nyholm/psr7": "^1.3",
Expand Down Expand Up @@ -85,7 +85,12 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"rector/rector-installer": true,
"infection/extension-installer": true,
"php-http/discovery": true
}
},
"replace": {
"spomky-labs/web-push-lib": "self.version",
Expand Down
6 changes: 5 additions & 1 deletion src/library/VAPID/LcobucciProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public function setLogger(LoggerInterface $logger): self
public function computeHeader(array $claims): Header
{
$this->logger->debug('Computing the JWS');
$signer = Sha256::create();
if (method_exists(Sha256::class, 'create')) {
$signer = Sha256::create();
} else {
$signer = new Sha256();
}
$header = json_encode(['typ' => 'JWT', 'alg' => 'ES256'], self::JSON_OPTIONS);
$payload = json_encode($claims, self::JSON_OPTIONS);
$dataToSign = sprintf(
Expand Down

0 comments on commit 5ef905d

Please sign in to comment.