Skip to content

Commit c66f1b7

Browse files
committed
Update spomky-labs/pki-framework version and improve error handling
This commit updates the 'spomky-labs/pki-framework' dependency to version 1.2.1 in both 'src/Library/composer.json' and 'composer.json' files. It also adds an exception dump in 'src/Library/KeyManagement/KeyConverter/KeyConverter.php' file for better error debugging.~
1 parent 3005ee6 commit c66f1b7

File tree

7 files changed

+46
-33
lines changed

7 files changed

+46
-33
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"brick/math": "^0.12",
5454
"psr/clock": "^1.0",
5555
"psr/event-dispatcher": "^1.0",
56-
"spomky-labs/pki-framework": "^1.1",
56+
"spomky-labs/pki-framework": "^1.2.1",
5757
"symfony/config": "^7.0",
5858
"symfony/console": "^7.0",
5959
"symfony/dependency-injection": "^7.0",

phpstan-baseline.neon

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,41 @@ parameters:
18401840
count: 1
18411841
path: src/Library/KeyManagement/KeyConverter/ECKey.php
18421842

1843+
-
1844+
message: "#^Access to an undefined property Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:\\$requestFactory\\.$#"
1845+
count: 1
1846+
path: src/Library/KeyManagement/UrlKeySetFactory.php
1847+
1848+
-
1849+
message: "#^Call to an undefined method Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:sendPsrRequest\\(\\)\\.$#"
1850+
count: 1
1851+
path: src/Library/KeyManagement/UrlKeySetFactory.php
1852+
1853+
-
1854+
message: "#^Call to function assert\\(\\) with true will always evaluate to true\\.$#"
1855+
count: 1
1856+
path: src/Library/KeyManagement/UrlKeySetFactory.php
1857+
1858+
-
1859+
message: "#^Class Psr\\\\Http\\\\Client\\\\ClientInterface not found\\.$#"
1860+
count: 3
1861+
path: src/Library/KeyManagement/UrlKeySetFactory.php
1862+
1863+
-
1864+
message: "#^Instanceof between Symfony\\\\Contracts\\\\HttpClient\\\\HttpClientInterface and Symfony\\\\Contracts\\\\HttpClient\\\\HttpClientInterface will always evaluate to true\\.$#"
1865+
count: 3
1866+
path: src/Library/KeyManagement/UrlKeySetFactory.php
1867+
1868+
-
1869+
message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:getContent\\(\\) should return string but returns mixed\\.$#"
1870+
count: 1
1871+
path: src/Library/KeyManagement/UrlKeySetFactory.php
1872+
1873+
-
1874+
message: "#^Result of && is always false\\.$#"
1875+
count: 1
1876+
path: src/Library/KeyManagement/UrlKeySetFactory.php
1877+
18431878
-
18441879
message: "#^Parameter \\#2 \\$recipient of method Jose\\\\Component\\\\NestedToken\\\\NestedTokenLoader\\:\\:checkContentTypeHeader\\(\\) expects int, int\\|null given\\.$#"
18451880
count: 1

src/Bundle/DependencyInjection/Source/KeyManagement/JKUSource.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public function getNodeDefinition(NodeDefinition $node): void
3535
{
3636
$node->children()
3737
->arrayNode('jku_factory')
38-
->canBeEnabled()
39-
->children()
40-
->scalarNode('client')
41-
->info('HTTP Client used to retrieve key sets.')
42-
->isRequired()
43-
->end()
44-
->end()
38+
->canBeEnabled()
39+
->children()
40+
->scalarNode('client')
41+
->info('HTTP Client used to retrieve key sets.')
42+
->isRequired()
4543
->end()
46-
->end();
44+
->end()
45+
->end()
46+
->end();
4747
}
4848

4949
#[Override]

src/Deprecated/Core/composer.json

Whitespace-only changes.

src/Library/KeyManagement/KeyConverter/KeyConverter.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,6 @@ private static function loadPrivateKey(PEM $pem): array
277277
{
278278
try {
279279
$key = PrivateKey::fromPEM($pem);
280-
$curve = self::getCurve($key->algorithmIdentifier()->oid());
281-
$values = [
282-
'kty' => 'OKP',
283-
'crv' => $curve,
284-
'd' => Base64UrlSafe::encodeUnpadded($key->privateKeyData()),
285-
];
286-
return self::populatePoints($key, $values);
287-
} catch (Throwable) {
288-
// no break
289280
switch ($key->algorithmIdentifier()->oid()) {
290281
case AlgorithmIdentifier::OID_RSASSA_PSS_ENCRYPTION:
291282
assert($key instanceof RSASSAPSSPrivateKey);
@@ -317,19 +308,6 @@ private static function loadPrivateKey(PEM $pem): array
317308
} catch (Throwable $e) {
318309
throw new InvalidArgumentException('Unable to load the key.', 0, $e);
319310
}
320-
try {
321-
$key = PublicKey::fromPEM($pem);
322-
$curve = self::getCurve($key->algorithmIdentifier()->oid());
323-
self::checkType($curve);
324-
return [
325-
'kty' => 'OKP',
326-
'crv' => $curve,
327-
'x' => Base64UrlSafe::encodeUnpadded((string) $key->subjectPublicKey()),
328-
];
329-
} catch (Throwable) {
330-
// no break
331-
}
332-
throw new InvalidArgumentException('Unsupported key type');
333311
}
334312

335313
/**

src/Library/KeyManagement/UrlKeySetFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
use Psr\Cache\CacheItemPoolInterface;
88
use Psr\Http\Client\ClientInterface;
9-
use Psr\Http\Message\RequestFactoryInterface;
109
use RuntimeException;
1110
use Symfony\Component\Cache\Adapter\NullAdapter;
1211
use Symfony\Contracts\HttpClient\HttpClientInterface;
12+
use function assert;
1313

1414
/**
1515
* @see \Jose\Tests\Component\KeyManagement\UrlKeySetFactoryTest

src/Library/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"ext-mbstring": "*",
4444
"brick/math": "^0.12",
4545
"psr/clock": "^1.0",
46-
"spomky-labs/pki-framework": "^1.1"
46+
"spomky-labs/pki-framework": "^1.2.1"
4747
},
4848
"conflict": {
4949
"spomky-labs/jose": "*"

0 commit comments

Comments
 (0)