From b9812ba06ac16899df2a25f0abf25962ae3273f2 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 30 May 2023 08:36:17 +0000 Subject: update composer libs --- vendor/spomky-labs/otphp/src/OTP.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'vendor/spomky-labs/otphp/src/OTP.php') diff --git a/vendor/spomky-labs/otphp/src/OTP.php b/vendor/spomky-labs/otphp/src/OTP.php index 2cba067b3..4765d49eb 100644 --- a/vendor/spomky-labs/otphp/src/OTP.php +++ b/vendor/spomky-labs/otphp/src/OTP.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace OTPHP; +use function assert; use function chr; use function count; use Exception; @@ -49,6 +50,10 @@ abstract class OTP implements OTPInterface /** * The OTP at the specified input. + * + * @param 0|positive-int $input + * + * @return non-empty-string */ protected function generateOTP(int $input): string { @@ -65,7 +70,7 @@ abstract class OTP implements OTPInterface } /** - * @param array $options + * @param array $options */ protected function filterOptions(array &$options): void { @@ -83,7 +88,10 @@ abstract class OTP implements OTPInterface } /** - * @param array $options + * @param non-empty-string $type + * @param array $options + * + * @return non-empty-string */ protected function generateURI(string $type, array $options): string { @@ -102,20 +110,33 @@ abstract class OTP implements OTPInterface ); } + /** + * @param non-empty-string $safe + * @param non-empty-string $user + */ protected function compareOTP(string $safe, string $user): bool { return hash_equals($safe, $user); } + /** + * @return non-empty-string + */ private function getDecodedSecret(): string { try { - return Base32::decodeUpper($this->getSecret()); + $decoded = Base32::decodeUpper($this->getSecret()); } catch (Exception) { throw new RuntimeException('Unable to decode the secret. Is it correctly base32 encoded?'); } + assert($decoded !== ''); + + return $decoded; } + /** + * @param 0|positive-int $int + */ private function intToByteString(int $int): string { $result = []; -- cgit v1.2.3