Skip to content

Commit 92f4e2b

Browse files
authored
Upgrade web-token dependency to version ^2.0 (#248)
* upgrade web-token dependencies to ^2.0 upgrade web-token/jwt-signature and web-token/jwt-key-mgmt to version ^2.0 * add missing algorithms * fix deprecations * Bump minimum required PHP-Version to PHP 7.2 * Remove PHP 7.1 from Travis matrix build * Update README.md to newer PHP version requirements
1 parent 0e75af4 commit 92f4e2b

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ matrix:
1616
- php: nightly
1717
fast_finish: true
1818
include:
19-
- php: 7.1
2019
- php: 7.2
2120
- php: 7.3
2221
- php: 7.4

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ As it is standardized, you don't have to worry about what server type it relies
1010

1111
## Requirements
1212

13-
* PHP 7.1+
14-
* gmp
15-
* mbstring
16-
* curl
17-
* openssl
18-
19-
PHP 7.2+ is recommended for better performance.
13+
PHP 7.2+ and the following extensions:
14+
* gmp
15+
* mbstring
16+
* curl
17+
* openssl
2018

2119
There is no support and maintenance for older PHP versions, however you are free to use the following compatible versions:
2220
- PHP 5.6 or HHVM: `v1.x`
2321
- PHP 7.0: `v2.x`
22+
- PHP 7.1: `v3.x-v5.x`
2423

2524
## Installation
2625
Use [composer](https://getcomposer.org/) to download and install the library and its dependencies.

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
"test:syntax": "./vendor/bin/php-cs-fixer fix ./src --dry-run --stop-on-violation --using-cache=no"
1919
},
2020
"require": {
21-
"php": "^7.1",
21+
"php": "^7.2",
2222
"ext-json": "*",
2323
"ext-gmp": "*",
2424
"lib-openssl": "*",
2525
"guzzlehttp/guzzle": "^6.2",
26-
"web-token/jwt-signature": "^1.0",
27-
"web-token/jwt-key-mgmt": "^1.0"
26+
"web-token/jwt-signature": "^2.0",
27+
"web-token/jwt-key-mgmt": "^2.0",
28+
"web-token/jwt-signature-algorithm-ecdsa": "^2.0",
29+
"web-token/jwt-util-ecc": "^2.0"
2830
},
2931
"require-dev": {
3032
"phpunit/phpunit": "^7.0",

src/Encryption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ private static function createLocalKeyObjectUsingOpenSSL(): array
285285
}
286286

287287
return [
288-
PublicKey::create(Point::create(
288+
new PublicKey(Point::create(
289289
gmp_init(bin2hex($details['ec']['x']), 16),
290290
gmp_init(bin2hex($details['ec']['y']), 16)
291291
)),

src/VAPID.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use Base64Url\Base64Url;
1717
use Jose\Component\Core\AlgorithmManager;
18-
use Jose\Component\Core\Converter\StandardConverter;
1918
use Jose\Component\Core\JWK;
2019
use Jose\Component\Core\Util\Ecc\NistCurve;
2120
use Jose\Component\Core\Util\Ecc\Point;
@@ -56,7 +55,7 @@ public static function validate(array $vapid): array
5655
if ($jwk->get('kty') !== 'EC' || !$jwk->has('d') || !$jwk->has('x') || !$jwk->has('y')) {
5756
throw new \ErrorException('Invalid PEM data.');
5857
}
59-
$publicKey = PublicKey::create(Point::create(
58+
$publicKey = new PublicKey(Point::create(
6059
gmp_init(bin2hex(Base64Url::decode($jwk->get('x'))), 16),
6160
gmp_init(bin2hex(Base64Url::decode($jwk->get('y'))), 16)
6261
));
@@ -132,17 +131,16 @@ public static function getVapidHeaders(string $audience, string $subject, string
132131
}
133132

134133
list($x, $y) = Utils::unserializePublicKey($publicKey);
135-
$jwk = JWK::create([
134+
$jwk = new JWK([
136135
'kty' => 'EC',
137136
'crv' => 'P-256',
138137
'x' => Base64Url::encode($x),
139138
'y' => Base64Url::encode($y),
140139
'd' => Base64Url::encode($privateKey),
141140
]);
142141

143-
$jsonConverter = new StandardConverter();
144-
$jwsCompactSerializer = new CompactSerializer($jsonConverter);
145-
$jwsBuilder = new JWSBuilder($jsonConverter, AlgorithmManager::create([new ES256()]));
142+
$jwsCompactSerializer = new CompactSerializer();
143+
$jwsBuilder = new JWSBuilder(new AlgorithmManager([new ES256()]));
146144
$jws = $jwsBuilder
147145
->create()
148146
->withPayload($jwtPayload)

0 commit comments

Comments
 (0)