Unverified Commit e5b4eed8 authored by Spomky's avatar Spomky
Browse files

Bugs fixed

Showing with 11 additions and 17 deletions
+11 -17
# Upgrade from `v10.x` to `v11.x` # Upgrade from `v10.x` to `v11.x`
Congratulation, you have nothing to do!
\ No newline at end of file
...@@ -18,10 +18,8 @@ Support for the version 9 will end when PHP 7.1 will not be maintained (1 Dec 20 ...@@ -18,10 +18,8 @@ Support for the version 9 will end when PHP 7.1 will not be maintained (1 Dec 20
# Prerequisites # Prerequisites
This library needs at least `PHP 7.1` for v9.0 and `PHP 7.2` for v10.0. This library needs at least `PHP 8.0`.
It has been successfully tested using `PHP 7.1`, `PHP 7.2`, `PHP 7.3`. It has been successfully tested using `PHP 8.0` and `PHP 8.1`.
Nightly branch (`PHP 8.0`) fails as dependencies are not yet compatible.
# Installation # Installation
...@@ -31,13 +29,6 @@ The preferred way to install this library is to rely on Composer: ...@@ -31,13 +29,6 @@ The preferred way to install this library is to rely on Composer:
composer require spomky-labs/otphp composer require spomky-labs/otphp
``` ```
By default, documentation and test environment are excluded.
If you want to test the library or get the documentation, please add `--prefer-source` option:
```sh
composer require spomky-labs/otphp --prefer-source
```
# TOTP or HOTP? # TOTP or HOTP?
This library supports both `TOTP` and `HOTP`. This library supports both `TOTP` and `HOTP`.
...@@ -107,3 +98,4 @@ $otp->verify($input); // Returns true if the input is verified, otherwise false. ...@@ -107,3 +98,4 @@ $otp->verify($input); // Returns true if the input is verified, otherwise false.
* [From `v8.3` to `v9.x`](UPGRADE_v8-v9.md) * [From `v8.3` to `v9.x`](UPGRADE_v8-v9.md)
* [From `v9.x` to `v10.x`](UPGRADE_v9-v10.md) * [From `v9.x` to `v10.x`](UPGRADE_v9-v10.md)
* [From `v10.x` to `v11.x`](UPGRADE_v10-v11.md)
...@@ -41,7 +41,7 @@ final class HOTP extends OTP implements HOTPInterface ...@@ -41,7 +41,7 @@ final class HOTP extends OTP implements HOTPInterface
/** /**
* If the counter is not provided, the OTP is verified at the actual counter. * If the counter is not provided, the OTP is verified at the actual counter.
*/ */
public function verify(string $otp, null|int $counter = null, null|int|float $window = null): bool public function verify(string $otp, null|int $counter = null, null|int $window = null): bool
{ {
Assertion::greaterOrEqualThan($counter, 0, 'The counter must be at least 0.'); Assertion::greaterOrEqualThan($counter, 0, 'The counter must be at least 0.');
...@@ -81,12 +81,12 @@ final class HOTP extends OTP implements HOTPInterface ...@@ -81,12 +81,12 @@ final class HOTP extends OTP implements HOTPInterface
$this->setCounter($counter); $this->setCounter($counter);
} }
private function getWindow(null|int|float $window): int|float private function getWindow(null|int $window): int
{ {
return abs($window ?? 0); return abs($window ?? 0);
} }
private function verifyOtpWithWindow(string $otp, int $counter, null|int|float $window): bool private function verifyOtpWithWindow(string $otp, int $counter, null|int $window): bool
{ {
$window = $this->getWindow($window); $window = $this->getWindow($window);
......
...@@ -15,7 +15,7 @@ interface OTPInterface ...@@ -15,7 +15,7 @@ interface OTPInterface
* Verify that the OTP is valid with the specified input. If no input is provided, the input is set to a default * Verify that the OTP is valid with the specified input. If no input is provided, the input is set to a default
* value or false is returned. * value or false is returned.
*/ */
public function verify(string $otp, null|int $input = null, null|int|float $window = null): bool; public function verify(string $otp, null|int $input = null, null|int $window = null): bool;
/** /**
* @return string The secret of the OTP * @return string The secret of the OTP
......
...@@ -55,7 +55,7 @@ final class TOTP extends OTP implements TOTPInterface ...@@ -55,7 +55,7 @@ final class TOTP extends OTP implements TOTPInterface
/** /**
* If no timestamp is provided, the OTP is verified at the actual timestamp. * If no timestamp is provided, the OTP is verified at the actual timestamp.
*/ */
public function verify(string $otp, null|int $timestamp = null, null|int|float $window = null): bool public function verify(string $otp, null|int $timestamp = null, null|int $window = null): bool
{ {
$timestamp = $this->getTimestamp($timestamp); $timestamp = $this->getTimestamp($timestamp);
...@@ -126,7 +126,7 @@ final class TOTP extends OTP implements TOTPInterface ...@@ -126,7 +126,7 @@ final class TOTP extends OTP implements TOTPInterface
$this->setParameter('epoch', $epoch); $this->setParameter('epoch', $epoch);
} }
private function verifyOtpWithWindow(string $otp, int $timestamp, int|float $window): bool private function verifyOtpWithWindow(string $otp, int $timestamp, int $window): bool
{ {
$window = abs($window); $window = abs($window);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment