Skip to content

Commit

Permalink
Update spomky-labs/pki-framework version and improve error handling
Browse files Browse the repository at this point in the history
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.~
  • Loading branch information
Spomky committed Apr 9, 2024
1 parent 3005ee6 commit c66f1b7
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 33 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"brick/math": "^0.12",
"psr/clock": "^1.0",
"psr/event-dispatcher": "^1.0",
"spomky-labs/pki-framework": "^1.1",
"spomky-labs/pki-framework": "^1.2.1",
"symfony/config": "^7.0",
"symfony/console": "^7.0",
"symfony/dependency-injection": "^7.0",
Expand Down
35 changes: 35 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,41 @@ parameters:
count: 1
path: src/Library/KeyManagement/KeyConverter/ECKey.php

-
message: "#^Access to an undefined property Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:\\$requestFactory\\.$#"
count: 1
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Call to an undefined method Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:sendPsrRequest\\(\\)\\.$#"
count: 1
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Call to function assert\\(\\) with true will always evaluate to true\\.$#"
count: 1
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Class Psr\\\\Http\\\\Client\\\\ClientInterface not found\\.$#"
count: 3
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Instanceof between Symfony\\\\Contracts\\\\HttpClient\\\\HttpClientInterface and Symfony\\\\Contracts\\\\HttpClient\\\\HttpClientInterface will always evaluate to true\\.$#"
count: 3
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:getContent\\(\\) should return string but returns mixed\\.$#"
count: 1
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Result of && is always false\\.$#"
count: 1
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Parameter \\#2 \\$recipient of method Jose\\\\Component\\\\NestedToken\\\\NestedTokenLoader\\:\\:checkContentTypeHeader\\(\\) expects int, int\\|null given\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public function getNodeDefinition(NodeDefinition $node): void
{
$node->children()
->arrayNode('jku_factory')
->canBeEnabled()
->children()
->scalarNode('client')
->info('HTTP Client used to retrieve key sets.')
->isRequired()
->end()
->end()
->canBeEnabled()
->children()
->scalarNode('client')
->info('HTTP Client used to retrieve key sets.')
->isRequired()
->end()
->end();
->end()
->end()
->end();
}

#[Override]
Expand Down
Empty file removed src/Deprecated/Core/composer.json
Empty file.
22 changes: 0 additions & 22 deletions src/Library/KeyManagement/KeyConverter/KeyConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,6 @@ private static function loadPrivateKey(PEM $pem): array
{
try {
$key = PrivateKey::fromPEM($pem);
$curve = self::getCurve($key->algorithmIdentifier()->oid());
$values = [
'kty' => 'OKP',
'crv' => $curve,
'd' => Base64UrlSafe::encodeUnpadded($key->privateKeyData()),
];
return self::populatePoints($key, $values);
} catch (Throwable) {
// no break
switch ($key->algorithmIdentifier()->oid()) {
case AlgorithmIdentifier::OID_RSASSA_PSS_ENCRYPTION:
assert($key instanceof RSASSAPSSPrivateKey);
Expand Down Expand Up @@ -317,19 +308,6 @@ private static function loadPrivateKey(PEM $pem): array
} catch (Throwable $e) {
throw new InvalidArgumentException('Unable to load the key.', 0, $e);
}
try {
$key = PublicKey::fromPEM($pem);
$curve = self::getCurve($key->algorithmIdentifier()->oid());
self::checkType($curve);
return [
'kty' => 'OKP',
'crv' => $curve,
'x' => Base64UrlSafe::encodeUnpadded((string) $key->subjectPublicKey()),
];
} catch (Throwable) {
// no break
}
throw new InvalidArgumentException('Unsupported key type');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Library/KeyManagement/UrlKeySetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use Psr\Cache\CacheItemPoolInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use RuntimeException;
use Symfony\Component\Cache\Adapter\NullAdapter;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use function assert;

/**
* @see \Jose\Tests\Component\KeyManagement\UrlKeySetFactoryTest
Expand Down
2 changes: 1 addition & 1 deletion src/Library/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"ext-mbstring": "*",
"brick/math": "^0.12",
"psr/clock": "^1.0",
"spomky-labs/pki-framework": "^1.1"
"spomky-labs/pki-framework": "^1.2.1"
},
"conflict": {
"spomky-labs/jose": "*"
Expand Down

0 comments on commit c66f1b7

Please sign in to comment.