Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistency OTPInterface param name and HOPT en TOTP param names #235

Open
DaanBaars opened this issue Jan 16, 2025 · 1 comment
Open
Labels

Comments

@DaanBaars
Copy link

Version(s) affected

14.3

Description

When using named arguments window: as from the interface

Interface: \OTPHP\OTPInterface
public function verify(string $otp, null|int $input = null, null|int $window = null): bool;

HOTP
public function verify(string $otp, null|int $counter = null, null|int $window = null): bool

TOTP
public function verify(string $otp, null|int $timestamp = null, null|int $leeway = null): bool

The interface and HOTP both use window the TOTP uses name leeway

This results in error "Unknown named parameter 'Window'"

How to reproduce

$totp = TOTP::create( '{SECRET}', 60, 'sha256', 12 ); $totp->verify('verify_code',window:'window');

Possible Solution

align argument names

Additional Context

No response

@Spomky
Copy link
Member

Spomky commented Jan 27, 2025

Hello @DaanBaars,

Thank you for your report and for providing the code snippet reproducing the issue.

We’re aware that the HOTP methods (interface and implementation) use the parameter name “window,” whereas the TOTP method uses “leeway.” This difference is intentional, as the TOTP specification refers to the permissible time drift (leeway) rather than a counter-based window.

Please use the following syntax instead:

$totp = TOTP::create( '{SECRET}',  60, 'sha256',  12 );

$totp->verify('verify_code',leeway:'window'); //or
$totp->verify('verify_code',null, 'window');

@Spomky Spomky added the wontfix label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants