From: Cyperghost Date: Tue, 5 Nov 2024 08:54:54 +0000 (+0100) Subject: Revert "Update composer package `minishlink/web-push` to `^v9.0.1`" X-Git-Tag: 6.1.1_dev_1~28^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a3e52ecf7029e45ad8f926f9c62c92d691d4dd74;p=GitHub%2FWoltLab%2FWCF.git Revert "Update composer package `minishlink/web-push` to `^v9.0.1`" This reverts commit 1f958bcb2df425a892161a018134e6c74caf0770. --- diff --git a/wcfsetup/install/files/lib/system/api/composer.json b/wcfsetup/install/files/lib/system/api/composer.json index cf8cc8a17f..b5304b6a3c 100644 --- a/wcfsetup/install/files/lib/system/api/composer.json +++ b/wcfsetup/install/files/lib/system/api/composer.json @@ -19,7 +19,7 @@ "laminas/laminas-diactoros": "^3.3.1", "laminas/laminas-httphandlerrunner": "^2.10.0", "laminas/laminas-progressbar": "^2.13", - "minishlink/web-push": "^v9.0.1", + "minishlink/web-push": "^v9.0.0-rc2", "nikic/fast-route": "2.0.0-beta1", "paragonie/constant_time_encoding": "^3.0", "pelago/emogrifier": "^7.2.0", @@ -33,7 +33,7 @@ "sebastian/diff": "^5.1.1", "symfony/polyfill-php82": "^1.30.0", "symfony/polyfill-php83": "^1.30", - "web-token/jwt-library": "3.3.50 as dev-3.3.x", + "web-token/jwt-library": "^3.3.50", "willdurand/negotiation": "^3.1" }, "replace": { diff --git a/wcfsetup/install/files/lib/system/api/composer.lock b/wcfsetup/install/files/lib/system/api/composer.lock index 272511bc9e..f30ffc5941 100644 --- a/wcfsetup/install/files/lib/system/api/composer.lock +++ b/wcfsetup/install/files/lib/system/api/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7fb0b03afd912128e100c108aa1b7fd1", + "content-hash": "70268093034722fc94f786ec6395a6bf", "packages": [ { "name": "brick/math", @@ -2463,6 +2463,12 @@ "url": "https://github.com/WoltLab/jwt-library.git", "reference": "18b89d806835d351ebebab3eeb8103a45cfd10b5" }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WoltLab/jwt-library/zipball/18b89d806835d351ebebab3eeb8103a45cfd10b5", + "reference": "18b89d806835d351ebebab3eeb8103a45cfd10b5", + "shasum": "" + }, "require": { "brick/math": "^0.9|^0.10|^0.11|^0.12", "ext-json": "*", @@ -2663,6 +2669,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "minishlink/web-push": 5, "nikic/fast-route": 10 }, "prefer-stable": false, diff --git a/wcfsetup/install/files/lib/system/api/composer/installed.json b/wcfsetup/install/files/lib/system/api/composer/installed.json index acaffda29a..351d1eb825 100644 --- a/wcfsetup/install/files/lib/system/api/composer/installed.json +++ b/wcfsetup/install/files/lib/system/api/composer/installed.json @@ -2566,6 +2566,12 @@ "url": "https://github.com/WoltLab/jwt-library.git", "reference": "18b89d806835d351ebebab3eeb8103a45cfd10b5" }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WoltLab/jwt-library/zipball/18b89d806835d351ebebab3eeb8103a45cfd10b5", + "reference": "18b89d806835d351ebebab3eeb8103a45cfd10b5", + "shasum": "" + }, "require": { "brick/math": "^0.9|^0.10|^0.11|^0.12", "ext-json": "*", @@ -2634,6 +2640,19 @@ "RFC7520", "Symfony" ], + "support": { + "source": "https://github.com/WoltLab/jwt-library/tree/3.3.50" + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/Spomky" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/FlorentMorselli" + } + ], "install-path": "../web-token/jwt-library" }, { @@ -2757,6 +2776,6 @@ "install-path": "../willdurand/negotiation" } ], - "dev": true, + "dev": false, "dev-package-names": [] } diff --git a/wcfsetup/install/files/lib/system/api/composer/installed.php b/wcfsetup/install/files/lib/system/api/composer/installed.php index c8b938cf34..0e4c28ec32 100644 --- a/wcfsetup/install/files/lib/system/api/composer/installed.php +++ b/wcfsetup/install/files/lib/system/api/composer/installed.php @@ -1,19 +1,19 @@ array( 'name' => '__root__', - 'pretty_version' => '6.1.x-dev', - 'version' => '6.1.9999999.9999999-dev', - 'reference' => 'fe4913df9ac21beb9718c8dc312246df476fc7ff', + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => '37708311277ea8a294ac6ee74bfe8f055446016b', 'type' => 'project', 'install_path' => __DIR__ . '/../', 'aliases' => array(), - 'dev' => true, + 'dev' => false, ), 'versions' => array( '__root__' => array( - 'pretty_version' => '6.1.x-dev', - 'version' => '6.1.9999999.9999999-dev', - 'reference' => 'fe4913df9ac21beb9718c8dc312246df476fc7ff', + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => '37708311277ea8a294ac6ee74bfe8f055446016b', 'type' => 'project', 'install_path' => __DIR__ . '/../', 'aliases' => array(), diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/ClaimCheckerManager.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/ClaimCheckerManager.php index 64f0c405b4..5b7230d3e7 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/ClaimCheckerManager.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/ClaimCheckerManager.php @@ -22,7 +22,7 @@ class ClaimCheckerManager /** * @param ClaimChecker[] $checkers */ - public function __construct(iterable $checkers) + public function __construct(array $checkers) { foreach ($checkers as $checker) { $this->add($checker); diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/HeaderCheckerManager.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/HeaderCheckerManager.php index 1b05be6e86..124bfe920e 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/HeaderCheckerManager.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/HeaderCheckerManager.php @@ -28,7 +28,7 @@ class HeaderCheckerManager * @param HeaderChecker[] $checkers * @param TokenTypeSupport[] $tokenTypes */ - public function __construct(iterable $checkers, iterable $tokenTypes) + public function __construct(array $checkers, array $tokenTypes) { foreach ($checkers as $checker) { $this->add($checker); diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/NoneKeyGeneratorCommand.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/NoneKeyGeneratorCommand.php index ec1e1b59df..86dd6cf91b 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/NoneKeyGeneratorCommand.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/NoneKeyGeneratorCommand.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Jose\Component\Console; use Jose\Component\KeyManagement\JWKFactory; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/PublicKeyCommand.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/PublicKeyCommand.php index fd721b7231..81bd93fb96 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/PublicKeyCommand.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/PublicKeyCommand.php @@ -7,7 +7,6 @@ namespace Jose\Component\Console; use InvalidArgumentException; use Jose\Component\Core\JWK; use Jose\Component\Core\Util\JsonConverter; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/X5ULoaderCommand.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/X5ULoaderCommand.php index 5c7ae16709..2592c5ba20 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/X5ULoaderCommand.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/X5ULoaderCommand.php @@ -6,7 +6,6 @@ namespace Jose\Component\Console; use InvalidArgumentException; use Jose\Component\KeyManagement\X5UFactory; -use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManager.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManager.php index c528c9b463..147921b5e7 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManager.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManager.php @@ -17,7 +17,7 @@ class AlgorithmManager /** * @param Algorithm[] $algorithms */ - public function __construct(iterable $algorithms) + public function __construct(array $algorithms) { foreach ($algorithms as $algorithm) { $this->add($algorithm); diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManagerFactory.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManagerFactory.php index 4303e512c1..3854e668fc 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManagerFactory.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManagerFactory.php @@ -17,7 +17,7 @@ class AlgorithmManagerFactory /** * @param Algorithm[] $algorithms */ - public function __construct(iterable $algorithms = []) + public function __construct(array $algorithms = []) { foreach ($algorithms as $algorithm) { $this->add($algorithm->name(), $algorithm); diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethod.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethod.php index 16b316b47a..85d2bf38a2 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethod.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethod.php @@ -4,9 +4,6 @@ declare(strict_types=1); namespace Jose\Component\Encryption\Compression; -/** - * @deprecated This class is deprecated and will be removed in v4.0. Compression is not recommended for JWE. - */ interface CompressionMethod { /** diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManager.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManager.php index 3708e3a41c..8a51e6a6bf 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManager.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManager.php @@ -7,9 +7,6 @@ namespace Jose\Component\Encryption\Compression; use InvalidArgumentException; use function array_key_exists; -/** - * @deprecated This class is deprecated and will be removed in v4.0. Compression is not recommended for JWE. - */ class CompressionMethodManager { /** @@ -17,10 +14,7 @@ class CompressionMethodManager */ private array $compressionMethods = []; - /** - * @param CompressionMethod[] $methods - */ - public function __construct(iterable $methods = []) + public function __construct(array $methods = []) { foreach ($methods as $method) { $this->add($method); diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManagerFactory.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManagerFactory.php index 592ae7bbbb..806424ef9a 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManagerFactory.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManagerFactory.php @@ -6,9 +6,6 @@ namespace Jose\Component\Encryption\Compression; use InvalidArgumentException; -/** - * @deprecated This class is deprecated and will be removed in v4.0. Compression is not recommended for JWE. - */ class CompressionMethodManagerFactory { /** diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/Deflate.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/Deflate.php index 5c3deaa4e0..3f87968510 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/Deflate.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/Deflate.php @@ -8,9 +8,6 @@ use InvalidArgumentException; use Throwable; use function is_string; -/** - * @deprecated This class is deprecated and will be removed in v4.0. Compression is not recommended for JWE. - */ final class Deflate implements CompressionMethod { private int $compressionLevel = -1; diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilder.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilder.php index 0d34218077..73827c9c57 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilder.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilder.php @@ -51,16 +51,9 @@ class JWEBuilder public function __construct( AlgorithmManager $algorithmManager, - null|AlgorithmManager $contentEncryptionAlgorithmManager = null, - private readonly null|CompressionMethodManager $compressionManager = null + null|AlgorithmManager $contentEncryptionAlgorithmManager, + private readonly CompressionMethodManager $compressionManager ) { - if ($compressionManager !== null) { - trigger_deprecation( - 'web-token/jwt-library', - '3.3.0', - 'The parameter "$compressionManager" is deprecated and will be removed in 4.0.0. Compression is not recommended for JWE. Please set "null" instead.' - ); - } if ($contentEncryptionAlgorithmManager !== null) { trigger_deprecation( 'web-token/jwt-library', @@ -120,9 +113,8 @@ class JWEBuilder /** * Returns the compression method manager. - * @deprecated This method is deprecated and will be removed in v4.0. Compression is not recommended for JWE. */ - public function getCompressionMethodManager(): null|CompressionMethodManager + public function getCompressionMethodManager(): CompressionMethodManager { return $this->compressionManager; } @@ -527,7 +519,7 @@ class JWEBuilder private function getCompressionMethod(array $completeHeader): ?CompressionMethod { - if ($this->compressionManager === null || ! array_key_exists('zip', $completeHeader)) { + if (! array_key_exists('zip', $completeHeader)) { return null; } diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilderFactory.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilderFactory.php index 038050898e..37f5d9b106 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilderFactory.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilderFactory.php @@ -11,43 +11,31 @@ class JWEBuilderFactory { public function __construct( private readonly AlgorithmManagerFactory $algorithmManagerFactory, - private readonly null|CompressionMethodManagerFactory $compressionMethodManagerFactory = null + private readonly CompressionMethodManagerFactory $compressionMethodManagerFactory ) { - if ($compressionMethodManagerFactory !== null) { - trigger_deprecation( - 'web-token/jwt-library', - '3.3.0', - 'The parameter "$compressionMethodManagerFactory" is deprecated and will be removed in 4.0.0. Compression is not recommended for JWE. Please set "null" instead.' - ); - } } /** * Creates a JWE Builder object using the given key encryption algorithms, content encryption algorithms and * compression methods. * - * @param array $encryptionAlgorithms - * @param null|array $contentEncryptionAlgorithm - * @param null|string[] $compressionMethods + * @param string[] $keyEncryptionAlgorithms + * @param string[] $contentEncryptionAlgorithm + * @param string[] $compressionMethods */ public function create( - array $encryptionAlgorithms, - null|array $contentEncryptionAlgorithm = null, - null|array $compressionMethods = null + array $keyEncryptionAlgorithms, + array $contentEncryptionAlgorithm, + array $compressionMethods ): JWEBuilder { - if ($contentEncryptionAlgorithm !== null) { - trigger_deprecation( - 'web-token/jwt-library', - '3.3.0', - 'The parameter "$contentEncryptionAlgorithm" is deprecated and will be removed in 4.0.0. Please set "null" instead.' - ); - $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithm); - } - $encryptionAlgorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms); - $compressionMethodManager = $compressionMethods === null ? null : $this->compressionMethodManagerFactory?->create( - $compressionMethods - ); + $keyEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($keyEncryptionAlgorithms); + $contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithm); + $compressionMethodManager = $this->compressionMethodManagerFactory->create($compressionMethods); - return new JWEBuilder($encryptionAlgorithmManager, null, $compressionMethodManager); + return new JWEBuilder( + $keyEncryptionAlgorithmManager, + $contentEncryptionAlgorithmManager, + $compressionMethodManager + ); } } diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypter.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypter.php index fdbe8d91b1..e688112efe 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypter.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypter.php @@ -31,15 +31,8 @@ class JWEDecrypter public function __construct( AlgorithmManager $algorithmManager, null|AlgorithmManager $contentEncryptionAlgorithmManager, - private readonly null|CompressionMethodManager $compressionMethodManager = null + private readonly CompressionMethodManager $compressionMethodManager ) { - if ($compressionMethodManager !== null) { - trigger_deprecation( - 'web-token/jwt-library', - '3.3.0', - 'The parameter "$compressionMethodManager" is deprecated and will be removed in 4.0.0. Compression is not recommended for JWE. Please set "null" instead.' - ); - } if ($contentEncryptionAlgorithmManager !== null) { trigger_deprecation( 'web-token/jwt-library', @@ -82,9 +75,8 @@ class JWEDecrypter /** * Returns the compression method manager. - * @deprecated This method is deprecated and will be removed in v4.0. Compression is not recommended for JWE. */ - public function getCompressionMethodManager(): null|CompressionMethodManager + public function getCompressionMethodManager(): CompressionMethodManager { return $this->compressionMethodManager; } @@ -278,13 +270,12 @@ class JWEDecrypter private function decompressIfNeeded(string $payload, array $completeHeaders): string { - if ($this->compressionMethodManager === null || ! array_key_exists('zip', $completeHeaders)) { - return $payload; + if (array_key_exists('zip', $completeHeaders)) { + $compression_method = $this->compressionMethodManager->get($completeHeaders['zip']); + $payload = $compression_method->uncompress($payload); } - $compression_method = $this->compressionMethodManager->get($completeHeaders['zip']); - - return $compression_method->uncompress($payload); + return $payload; } private function checkCompleteHeader(array $completeHeaders): void diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypterFactory.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypterFactory.php index 0df9b7daed..a61ef3bae8 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypterFactory.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypterFactory.php @@ -11,38 +11,27 @@ class JWEDecrypterFactory { public function __construct( private readonly AlgorithmManagerFactory $algorithmManagerFactory, - private readonly null|CompressionMethodManagerFactory $compressionMethodManagerFactory = null + private readonly CompressionMethodManagerFactory $compressionMethodManagerFactory ) { - if ($compressionMethodManagerFactory !== null) { - trigger_deprecation( - 'web-token/jwt-library', - '3.3.0', - 'The parameter "$compressionMethodManagerFactory" is deprecated and will be removed in 4.0.0. Compression is not recommended for JWE. Please set "null" instead.' - ); - } } /** * Creates a JWE Decrypter object using the given key encryption algorithms, content encryption algorithms and * compression methods. * - * @param string[] $encryptionAlgorithms - * @param null|string[] $contentEncryptionAlgorithms - * @param null|string[] $compressionMethods + * @param string[] $keyEncryptionAlgorithms + * @param string[] $contentEncryptionAlgorithms + * @param string[] $compressionMethods */ public function create( - array $encryptionAlgorithms, - null|array $contentEncryptionAlgorithms = null, - null|array $compressionMethods = null + array $keyEncryptionAlgorithms, + array $contentEncryptionAlgorithms, + array $compressionMethods ): JWEDecrypter { - if ($contentEncryptionAlgorithms !== null) { - $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); - } - - $algorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms); - $compressionMethodManager = $compressionMethods === null ? null : $this->compressionMethodManagerFactory?->create( - $compressionMethods + $algorithmManager = $this->algorithmManagerFactory->create( + array_merge($keyEncryptionAlgorithms, $contentEncryptionAlgorithms) ); + $compressionMethodManager = $this->compressionMethodManagerFactory->create($compressionMethods); return new JWEDecrypter($algorithmManager, null, $compressionMethodManager); } diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWELoaderFactory.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWELoaderFactory.php index 98159109a3..818e2d4863 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWELoaderFactory.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWELoaderFactory.php @@ -22,16 +22,17 @@ class JWELoaderFactory */ public function create( array $serializers, - array $encryptionAlgorithms, - null|array $contentEncryptionAlgorithms = null, - null|array $compressionMethods = null, + array $keyEncryptionAlgorithms, + array $contentEncryptionAlgorithms, + array $compressionMethods, array $headerCheckers = [] ): JWELoader { - if ($contentEncryptionAlgorithms !== null) { - $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); - } $serializerManager = $this->jweSerializerManagerFactory->create($serializers); - $jweDecrypter = $this->jweDecrypterFactory->create($encryptionAlgorithms, null, $compressionMethods); + $jweDecrypter = $this->jweDecrypterFactory->create( + $keyEncryptionAlgorithms, + $contentEncryptionAlgorithms, + $compressionMethods + ); if ($this->headerCheckerManagerFactory !== null) { $headerCheckerManager = $this->headerCheckerManagerFactory->create($headerCheckers); } else { diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Serializer/JWESerializerManager.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Serializer/JWESerializerManager.php index 5082c79883..14641bbaa6 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Serializer/JWESerializerManager.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Serializer/JWESerializerManager.php @@ -17,7 +17,7 @@ class JWESerializerManager /** * @param JWESerializer[] $serializers */ - public function __construct(iterable $serializers) + public function __construct(array $serializers) { foreach ($serializers as $serializer) { $this->add($serializer); diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/KeyManagement/KeyConverter/KeyConverter.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/KeyManagement/KeyConverter/KeyConverter.php index 010c7ab88e..82442bb7d4 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/KeyManagement/KeyConverter/KeyConverter.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/KeyManagement/KeyConverter/KeyConverter.php @@ -4,17 +4,14 @@ declare(strict_types=1); namespace Jose\Component\KeyManagement\KeyConverter; -use Brick\Math\BigInteger; use InvalidArgumentException; use OpenSSLCertificate; use ParagonIE\ConstantTime\Base64UrlSafe; use ParagonIE\Sodium\Core\Ed25519; use RuntimeException; use SpomkyLabs\Pki\CryptoEncoding\PEM; -use SpomkyLabs\Pki\CryptoTypes\AlgorithmIdentifier\AlgorithmIdentifier; use SpomkyLabs\Pki\CryptoTypes\Asymmetric\PrivateKey; use SpomkyLabs\Pki\CryptoTypes\Asymmetric\PublicKey; -use SpomkyLabs\Pki\CryptoTypes\Asymmetric\RSA\RSASSAPSSPrivateKey; use Throwable; use function array_key_exists; use function assert; @@ -232,79 +229,29 @@ final class KeyConverter private static function tryToLoadOtherKeyTypes(string $input): array { $pem = PEM::fromString($input); - return match ($pem->type()) { - PEM::TYPE_PUBLIC_KEY => self::loadPublicKey($pem), - PEM::TYPE_PRIVATE_KEY => self::loadPrivateKey($pem), - default => throw new InvalidArgumentException('Unsupported key type'), - }; - } - - /** - * @return array - */ - private static function loadPrivateKey(PEM $pem): array - { try { $key = PrivateKey::fromPEM($pem); - switch ($key->algorithmIdentifier()->oid()) { - case AlgorithmIdentifier::OID_RSASSA_PSS_ENCRYPTION: - assert($key instanceof RSASSAPSSPrivateKey); - return [ - 'kty' => 'RSA', - 'n' => self::convertDecimalToBas64Url($key->modulus()), - 'e' => self::convertDecimalToBas64Url($key->publicExponent()), - 'd' => self::convertDecimalToBas64Url($key->privateExponent()), - 'dp' => self::convertDecimalToBas64Url($key->exponent1()), - 'dq' => self::convertDecimalToBas64Url($key->exponent2()), - 'p' => self::convertDecimalToBas64Url($key->prime1()), - 'q' => self::convertDecimalToBas64Url($key->prime2()), - 'qi' => self::convertDecimalToBas64Url($key->coefficient()), - ]; - case AlgorithmIdentifier::OID_ED25519: - case AlgorithmIdentifier::OID_ED448: - case AlgorithmIdentifier::OID_X25519: - case AlgorithmIdentifier::OID_X448: - $curve = self::getCurve($key->algorithmIdentifier()->oid()); - $values = [ - 'kty' => 'OKP', - 'crv' => $curve, - 'd' => Base64UrlSafe::encodeUnpadded($key->privateKeyData()), - ]; - return self::populatePoints($key, $values); - default: - throw new InvalidArgumentException('Unsupported key type'); - } - } catch (Throwable $e) { - throw new InvalidArgumentException('Unable to load the key.', 0, $e); + $curve = self::getCurve($key->algorithmIdentifier()->oid()); + $values = [ + 'kty' => 'OKP', + 'crv' => $curve, + 'd' => Base64UrlSafe::encodeUnpadded($key->privateKeyData()), + ]; + return self::populatePoints($key, $values); + } catch (Throwable) { } - } - - /** - * @return array - */ - private static function loadPublicKey(PEM $pem): array - { - $key = PublicKey::fromPEM($pem); - switch ($key->algorithmIdentifier()->oid()) { - case AlgorithmIdentifier::OID_ED25519: - case AlgorithmIdentifier::OID_ED448: - case AlgorithmIdentifier::OID_X25519: - case AlgorithmIdentifier::OID_X448: - $curve = self::getCurve($key->algorithmIdentifier()->oid()); - self::checkType($curve); - return [ - 'kty' => 'OKP', - 'crv' => $curve, - 'x' => Base64UrlSafe::encodeUnpadded((string) $key->subjectPublicKey()), - ]; - default: - throw new InvalidArgumentException('Unsupported key type'); + 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) { } - } - - private static function convertDecimalToBas64Url(string $decimal): string - { - return Base64UrlSafe::encodeUnpadded(BigInteger::fromBase($decimal, 10)->toBytes()); + throw new InvalidArgumentException('Unsupported key type'); } /** diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenBuilderFactory.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenBuilderFactory.php index f3f9259ff2..81269e829a 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenBuilderFactory.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenBuilderFactory.php @@ -24,24 +24,25 @@ class NestedTokenBuilderFactory * compression methods. * * @param array $jwe_serializers - * @param array $encryptionAlgorithms - * @param null|array $contentEncryptionAlgorithms - * @param null|array $compressionMethods + * @param array $keyEncryptionAlgorithms + * @param array $contentEncryptionAlgorithms + * @param array $compressionMethods * @param array $jws_serializers * @param array $signatureAlgorithms */ public function create( array $jwe_serializers, - array $encryptionAlgorithms, - null|array $contentEncryptionAlgorithms, - null|array $compressionMethods, + array $keyEncryptionAlgorithms, + array $contentEncryptionAlgorithms, + array $compressionMethods, array $jws_serializers, array $signatureAlgorithms ): NestedTokenBuilder { - if ($contentEncryptionAlgorithms !== null) { - $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithms); - } - $jweBuilder = $this->jweBuilderFactory->create($encryptionAlgorithms, null, $compressionMethods); + $jweBuilder = $this->jweBuilderFactory->create( + $keyEncryptionAlgorithms, + $contentEncryptionAlgorithms, + $compressionMethods + ); $jweSerializerManager = $this->jweSerializerManagerFactory->create($jwe_serializers); $jwsBuilder = $this->jwsBuilderFactory->create($signatureAlgorithms); $jwsSerializerManager = $this->jwsSerializerManagerFactory->create($jws_serializers); diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenLoaderFactory.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenLoaderFactory.php index 632ff5e87e..eb2d7bd598 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenLoaderFactory.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenLoaderFactory.php @@ -22,7 +22,7 @@ class NestedTokenLoaderFactory * @param array $jweSerializers * @param array $keyEncryptionAlgorithms * @param array $contentEncryptionAlgorithms - * @param null|array $compressionMethods + * @param array $compressionMethods * @param array $jweHeaderCheckers * @param array $jwsSerializers * @param array $signatureAlgorithms @@ -31,8 +31,8 @@ class NestedTokenLoaderFactory public function create( array $jweSerializers, array $keyEncryptionAlgorithms, - null|array $contentEncryptionAlgorithms, - null|array $compressionMethods, + array $contentEncryptionAlgorithms, + array $compressionMethods, array $jweHeaderCheckers, array $jwsSerializers, array $signatureAlgorithms, diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Signature/Serializer/JWSSerializerManager.php b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Signature/Serializer/JWSSerializerManager.php index ebdfc70dfa..fdf5b481c8 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Signature/Serializer/JWSSerializerManager.php +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/Signature/Serializer/JWSSerializerManager.php @@ -17,7 +17,7 @@ class JWSSerializerManager /** * @param JWSSerializer[] $serializers */ - public function __construct(iterable $serializers) + public function __construct(array $serializers) { foreach ($serializers as $serializer) { $this->add($serializer); diff --git a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/composer.json b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/composer.json index 7245271788..bf35f837be 100644 --- a/wcfsetup/install/files/lib/system/api/web-token/jwt-library/composer.json +++ b/wcfsetup/install/files/lib/system/api/web-token/jwt-library/composer.json @@ -42,12 +42,12 @@ "ext-json": "*", "ext-mbstring": "*", "brick/math": "^0.9|^0.10|^0.11|^0.12", - "paragonie/constant_time_encoding": "^3.0", + "paragonie/constant_time_encoding": "^2.6", "paragonie/sodium_compat": "^1.20", "psr/clock": "^1.0", "psr/http-factory": "^1.0", "psr/http-client": "^1.0", - "spomky-labs/pki-framework": "^1.2.1", + "spomky-labs/pki-framework": "^1.0", "symfony/console": "^5.4|^6.0|^7.0", "symfony/http-client": "^5.4|^6.0|^7.0", "symfony/polyfill-mbstring": "^1.12"