Revert "Update composer package `minishlink/web-push` to `^v9.0.1`"
authorCyperghost <olaf_schmitz_1@t-online.de>
Tue, 5 Nov 2024 08:54:54 +0000 (09:54 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Tue, 5 Nov 2024 08:54:54 +0000 (09:54 +0100)
This reverts commit 1f958bcb2df425a892161a018134e6c74caf0770.

26 files changed:
wcfsetup/install/files/lib/system/api/composer.json
wcfsetup/install/files/lib/system/api/composer.lock
wcfsetup/install/files/lib/system/api/composer/installed.json
wcfsetup/install/files/lib/system/api/composer/installed.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/ClaimCheckerManager.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Checker/HeaderCheckerManager.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/NoneKeyGeneratorCommand.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/PublicKeyCommand.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Console/X5ULoaderCommand.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManager.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Core/AlgorithmManagerFactory.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethod.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManager.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/CompressionMethodManagerFactory.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Compression/Deflate.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilder.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEBuilderFactory.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypter.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWEDecrypterFactory.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/JWELoaderFactory.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Encryption/Serializer/JWESerializerManager.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/KeyManagement/KeyConverter/KeyConverter.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenBuilderFactory.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/NestedToken/NestedTokenLoaderFactory.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/Signature/Serializer/JWSSerializerManager.php
wcfsetup/install/files/lib/system/api/web-token/jwt-library/composer.json

index cf8cc8a17fe875fe0eba2c91fcfbfefe0fdcc1ee..b5304b6a3c17d397d69920d2d9d208b1688edf02 100644 (file)
@@ -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": {
index 272511bc9e2c2c7cb4ca6d3639ef652089586af1..f30ffc59417dab18dc0e866990453020d1174786 100644 (file)
@@ -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",
                 "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": "*",
     "aliases": [],
     "minimum-stability": "stable",
     "stability-flags": {
+        "minishlink/web-push": 5,
         "nikic/fast-route": 10
     },
     "prefer-stable": false,
index acaffda29a0ef72095f5a81e9dea6663104fed8d..351d1eb825bbc98a9ca03b0456fc17c32bb60fcf 100644 (file)
                 "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": "*",
                 "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"
         },
         {
             "install-path": "../willdurand/negotiation"
         }
     ],
-    "dev": true,
+    "dev": false,
     "dev-package-names": []
 }
index c8b938cf34d0aeb0032cca17fdc1aa324937fb88..0e4c28ec32a185a835027449e93f9692bccac303 100644 (file)
@@ -1,19 +1,19 @@
 <?php return array(
     'root' => 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(),
index 64f0c405b467bee140d71a6bbdcda1b23ef6a4f1..5b7230d3e7a26f52c02d50be58f23b188ef58de0 100644 (file)
@@ -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);
index 1b05be6e869ede2360a6f4da61d8f0c76c8467c4..124bfe920e0c8f9e566979212f72b7d8088b0a77 100644 (file)
@@ -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);
index ec1e1b59df5e6a5b32f09cb13c0e0b01d31af846..86dd6cf91b07fd68ff41ef092093f48c96e8b8ee 100644 (file)
@@ -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;
 
index fd721b723104338e129f200e8ebb8dfc178516dc..81bd93fb96e038ada8312f8d4c54f12902999b2e 100644 (file)
@@ -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;
index 5c7ae16709185563c4cb1c1495e9a5e53664c259..2592c5ba20715f14993153486d0aefdf4d491012 100644 (file)
@@ -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;
index c528c9b4630a15b36c6da3bcf00d60fc301824e5..147921b5e77fcc5f0f6aaa58d59f84d9e88c27d7 100644 (file)
@@ -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);
index 4303e512c123cda34c1077e8f1c74feb981d95df..3854e668fcfcc11664689839a02bc6cd38c53b3b 100644 (file)
@@ -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);
index 16b316b47a6bc7d6865ac89de7e21fafcd425a94..85d2bf38a2cc20e0fee61bb00920c2c19baa6b78 100644 (file)
@@ -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
 {
     /**
index 3708e3a41c407982031ee8f5058c8138fa7c5fd9..8a51e6a6bfb5f3af881b1587ed0fab9f1a72942d 100644 (file)
@@ -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);
index 592ae7bbbb793d92e9caf50f4c0df91e7927952b..806424ef9aabbe1109d290523c6733c6928fdf9f 100644 (file)
@@ -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
 {
     /**
index 5c3deaa4e0a912a681d3dd6d81ace7ee10cba3de..3f87968510c2dd3fa38ca53423dca3eeea36ebe3 100644 (file)
@@ -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;
index 0d34218077bb456c89323bdfec84f50cb8fd3a0a..73827c9c5750c13e04ec4c26e97b220900d202d9 100644 (file)
@@ -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;
         }
 
index 038050898ef286cbc20f16e8314de999184610e0..37f5d9b1066062dbed6d96b2a4fcfb901898837d 100644 (file)
@@ -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<string> $encryptionAlgorithms
-     * @param null|array<string> $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
+        );
     }
 }
index fdbe8d91b190696a21cfd5c0f2f6b75831d1ebb2..e688112efe6a5bb68855d7306ee550e6c377b255 100644 (file)
@@ -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
index 0df9b7daed86a4d9f1f9679b5e2f49d02b667671..a61ef3bae836c217dff5af8cd1a70dedcc3751ad 100644 (file)
@@ -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);
     }
index 98159109a3ab706e9d219fde1c38ad036d8a8693..818e2d486314df320a5144445b0524dab46f1577 100644 (file)
@@ -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 {
index 5082c798833e50e4fa388b8b7c775b4e7c0776d3..14641bbaa672b73ddd48d1024473cbc000cf8d82 100644 (file)
@@ -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);
index 010c7ab88e9c07ccbe4ea75494beadf941e8851f..82442bb7d49c2bcfaf0772ccb3901ba43f56ab17 100644 (file)
@@ -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<string, mixed>
-     */
-    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<string, mixed>
-     */
-    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');
     }
 
     /**
index f3f9259ff2ee8fb3796d5205397bb1c4ebeba284..81269e829aec99033b97dbc9d543cb270e2853b3 100644 (file)
@@ -24,24 +24,25 @@ class NestedTokenBuilderFactory
      * compression methods.
      *
      * @param array<string> $jwe_serializers
-     * @param array<string> $encryptionAlgorithms
-     * @param null|array<string> $contentEncryptionAlgorithms
-     * @param null|array<string> $compressionMethods
+     * @param array<string> $keyEncryptionAlgorithms
+     * @param array<string> $contentEncryptionAlgorithms
+     * @param array<string> $compressionMethods
      * @param array<string> $jws_serializers
      * @param array<string> $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);
index 632ff5e87e169f4afb192962b208051b60dda7be..eb2d7bd598ae68e1b857b41907d7b3adc5f543cb 100644 (file)
@@ -22,7 +22,7 @@ class NestedTokenLoaderFactory
      * @param array<string> $jweSerializers
      * @param array<string> $keyEncryptionAlgorithms
      * @param array<string> $contentEncryptionAlgorithms
-     * @param null|array<string> $compressionMethods
+     * @param array<string> $compressionMethods
      * @param array<string> $jweHeaderCheckers
      * @param array<string> $jwsSerializers
      * @param array<string> $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,
index ebdfc70dfaf30ba412254eaa44b6328d40dc4071..fdf5b481c80fbe5e5af2190fe2a6adf823df6124 100644 (file)
@@ -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);
index 72452717888b1fe00c62a3d1e9781c2ebb9d2986..bf35f837be0cde862cdfc6b77c6f486bdfbee65f 100644 (file)
         "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"