Skip to content

Commit

Permalink
Bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Feb 2, 2022
1 parent b668f63 commit e5b4eed
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
2 changes: 2 additions & 0 deletions doc/UPGRADE_v10-v11.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Upgrade from `v10.x` to `v11.x`

Congratulation, you have nothing to do!
14 changes: 3 additions & 11 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ Support for the version 9 will end when PHP 7.1 will not be maintained (1 Dec 20

# Prerequisites

This library needs at least `PHP 7.1` for v9.0 and `PHP 7.2` for v10.0.
It has been successfully tested using `PHP 7.1`, `PHP 7.2`, `PHP 7.3`.

Nightly branch (`PHP 8.0`) fails as dependencies are not yet compatible.
This library needs at least `PHP 8.0`.
It has been successfully tested using `PHP 8.0` and `PHP 8.1`.

# Installation

Expand All @@ -31,13 +29,6 @@ The preferred way to install this library is to rely on Composer:
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?

This library supports both `TOTP` and `HOTP`.
Expand Down Expand Up @@ -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 `v9.x` to `v10.x`](UPGRADE_v9-v10.md)
* [From `v10.x` to `v11.x`](UPGRADE_v10-v11.md)
6 changes: 3 additions & 3 deletions src/HOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getProvisioningUri(): string
/**
* 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.');

Expand Down Expand Up @@ -81,12 +81,12 @@ private function updateCounter(int $counter): void
$this->setCounter($counter);
}

private function getWindow(null|int|float $window): int|float
private function getWindow(null|int $window): int
{
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);

Expand Down
2 changes: 1 addition & 1 deletion src/OTPInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function at(int $timestamp): string;
* 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.
*/
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
Expand Down
4 changes: 2 additions & 2 deletions src/TOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function now(): string
/**
* 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);

Expand Down Expand Up @@ -126,7 +126,7 @@ private function setEpoch(int $epoch): void
$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);

Expand Down

0 comments on commit e5b4eed

Please sign in to comment.