| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace OTPHP; |
| 6 |
|
| 7 |
interface TOTPInterface extends OTPInterface |
| 8 |
{ |
| 9 |
public const DEFAULT_PERIOD = 30; |
| 10 |
|
| 11 |
public const DEFAULT_EPOCH = 0; |
| 12 |
|
| 13 |
/** |
| 14 |
* Create a new TOTP object. |
| 15 |
* |
| 16 |
* If the secret is null, a random 64 bytes secret will be generated. |
| 17 |
* |
| 18 |
* @param null|non-empty-string $secret |
| 19 |
* @param positive-int $period |
| 20 |
* @param non-empty-string $digest |
| 21 |
* @param positive-int $digits |
| 22 |
* |
| 23 |
* @deprecated Deprecated since v11.1, use ::createFromSecret or ::generate instead |
| 24 |
*/ |
| 25 |
public static function create( |
| 26 |
null|string $secret = null, |
| 27 |
int $period = self::DEFAULT_PERIOD, |
| 28 |
string $digest = self::DEFAULT_DIGEST, |
| 29 |
int $digits = self::DEFAULT_DIGITS |
| 30 |
): self; |
| 31 |
|
| 32 |
/** |
| 33 |
* @deprecated Deprecated since v11.4, use {@see self::withPeriod()} instead |
| 34 |
*/ |
| 35 |
public function setPeriod(int $period): void; |
| 36 |
|
| 37 |
public function withPeriod(int $period): self; |
| 38 |
|
| 39 |
/** |
| 40 |
* @deprecated Deprecated since v11.4, use {@see self::withEpoch()} instead |
| 41 |
*/ |
| 42 |
public function setEpoch(int $epoch): void; |
| 43 |
|
| 44 |
public function withEpoch(int $epoch): self; |
| 45 |
|
| 46 |
/** |
| 47 |
* Return the TOTP at the current time. |
| 48 |
* |
| 49 |
* @return non-empty-string |
| 50 |
*/ |
| 51 |
public function now(): string; |
| 52 |
|
| 53 |
/** |
| 54 |
* Get the period of time for OTP generation (a non-null positive integer, in second). |
| 55 |
*/ |
| 56 |
public function getPeriod(): int; |
| 57 |
|
| 58 |
public function expiresIn(): int; |
| 59 |
|
| 60 |
public function getEpoch(): int; |
| 61 |
} |