Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace OTPHP;
6
 
7
interface TOTPInterface extends OTPInterface
8
{
1441 ariadna 9
    public const DEFAULT_PERIOD = 30;
10
 
11
    public const DEFAULT_EPOCH = 0;
12
 
1 efrain 13
    /**
1441 ariadna 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
1 efrain 24
     */
1441 ariadna 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
    public function setPeriod(int $period): void;
33
 
34
    public function setEpoch(int $epoch): void;
35
 
36
    /**
37
     * Return the TOTP at the current time.
38
     *
39
     * @return non-empty-string
40
     */
1 efrain 41
    public function now(): string;
42
 
43
    /**
1441 ariadna 44
     * Get the period of time for OTP generation (a non-null positive integer, in second).
1 efrain 45
     */
46
    public function getPeriod(): int;
1441 ariadna 47
 
48
    public function expiresIn(): int;
49
 
50
    public function getEpoch(): int;
1 efrain 51
}