Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
Línea 2... Línea -...
2
 
-
 
3
/*
2
 
4
 * The MIT License (MIT)
-
 
5
 *
-
 
6
 * Copyright (c) 2014-2018 Spomky-Labs
-
 
7
 *
-
 
8
 * This software may be modified and distributed under the terms
-
 
9
 * of the MIT license.  See the LICENSE file for details.
-
 
Línea 10... Línea 3...
10
 */
3
declare(strict_types=1);
Línea 11... Línea 4...
11
 
4
 
12
namespace OTPHP;
5
namespace OTPHP;
-
 
6
 
-
 
7
interface OTPInterface
-
 
8
{
-
 
9
    public const DEFAULT_DIGITS = 6;
13
 
10
 
14
interface OTPInterface
11
    public const DEFAULT_DIGEST = 'sha1';
15
{
12
 
-
 
13
    /**
-
 
14
     * Create a OTP object from an existing secret.
-
 
15
     *
-
 
16
     * @param non-empty-string $secret
-
 
17
     */
16
    /**
18
    public static function createFromSecret(string $secret): self;
-
 
19
 
-
 
20
    /**
-
 
21
     * Create a new OTP object. A random 64 bytes secret will be generated.
-
 
22
     */
-
 
23
    public static function generate(): self;
-
 
24
 
-
 
25
    /**
-
 
26
     * @param non-empty-string $secret
-
 
27
     */
-
 
28
    public function setSecret(string $secret): void;
-
 
29
 
-
 
30
    public function setDigits(int $digits): void;
17
     * @param int $timestamp
31
 
18
     *
32
    /**
Línea 19... Línea 33...
19
     * @return string Return the OTP at the specified timestamp
33
     * @param non-empty-string $digest
20
     */
34
     */
21
    public function at(int $timestamp): string;
-
 
22
 
35
    public function setDigest(string $digest): void;
23
    /**
-
 
24
     * Verify that the OTP is valid with the specified input.
36
 
25
     * If no input is provided, the input is set to a default value or false is returned.
-
 
26
     *
37
    /**
27
     * @param string   $otp
38
     * Generate the OTP at the specified input.
28
     * @param int|null $input
39
     *
29
     * @param int|null $window
40
     * @param 0|positive-int $input
Línea 30... Línea 41...
30
     *
41
     *
-
 
42
     * @return non-empty-string Return the OTP at the specified timestamp
-
 
43
     */
-
 
44
    public function at(int $input): string;
-
 
45
 
-
 
46
    /**
-
 
47
     * Verify that the OTP is valid with the specified input. If no input is provided, the input is set to a default
-
 
48
     * value or false is returned.
-
 
49
     *
-
 
50
     * @param non-empty-string $otp
-
 
51
     * @param null|0|positive-int $input
31
     * @return bool
52
     * @param null|0|positive-int $window
32
     */
53
     */
33
    public function verify(string $otp, $input = null, $window = null): bool;
54
    public function verify(string $otp, null|int $input = null, null|int $window = null): bool;
Línea 34... Línea 55...
34
 
55
 
35
    /**
56
    /**
36
     * @return string The secret of the OTP
57
     * @return non-empty-string The secret of the OTP
37
     */
58
     */
Línea 38... Línea 59...
38
    public function getSecret(): string;
59
    public function getSecret(): string;
39
 
60
 
40
    /**
61
    /**
41
     * @param string $label The label of the OTP
62
     * @param non-empty-string $label The label of the OTP
Línea 42... Línea 63...
42
     */
63
     */
43
    public function setLabel(string $label);
64
    public function setLabel(string $label): void;
44
 
65
 
45
    /**
66
    /**
Línea 46... Línea 67...
46
     * @return string|null The label of the OTP
67
     * @return non-empty-string|null The label of the OTP
47
     */
68
     */
48
    public function getLabel();
-
 
49
 
-
 
50
    /**
69
    public function getLabel(): null|string;
51
     * @return string|null The issuer
70
 
Línea 52... Línea 71...
52
     */
71
    /**
53
    public function getIssuer();
72
     * @return non-empty-string|null The issuer
54
 
73
     */
55
    /**
74
    public function getIssuer(): ?string;
Línea 56... Línea -...
56
     * @param string $issuer
-
 
57
     *
-
 
58
     * @throws \InvalidArgumentException
-
 
59
     */
-
 
60
    public function setIssuer(string $issuer);
-
 
61
 
75
 
Línea 62... Línea 76...
62
    /**
76
    /**
63
     * @return bool If true, the issuer will be added as a parameter in the provisioning URI
77
     * @param non-empty-string $issuer
64
     */
78
     */
65
    public function isIssuerIncludedAsParameter(): bool;
79
    public function setIssuer(string $issuer): void;
Línea 66... Línea 80...
66
 
80
 
67
    /**
81
    /**
68
     * @param bool $issuer_included_as_parameter
82
     * @return bool If true, the issuer will be added as a parameter in the provisioning URI
69
     *
83
     */
Línea 70... Línea 84...
70
     * @return $this
84
    public function isIssuerIncludedAsParameter(): bool;
71
     */
85
 
72
    public function setIssuerIncludedAsParameter(bool $issuer_included_as_parameter);
-
 
73
 
-
 
74
    /**
86
    public function setIssuerIncludedAsParameter(bool $issuer_included_as_parameter): void;
75
     * @return int Number of digits in the OTP
87
 
Línea 76... Línea 88...
76
     */
88
    /**
77
    public function getDigits(): int;
89
     * @return positive-int Number of digits in the OTP
78
 
-
 
79
    /**
-
 
80
     * @return string Digest algorithm used to calculate the OTP. Possible values are 'md5', 'sha1', 'sha256' and 'sha512'
90
     */
81
     */
91
    public function getDigits(): int;
Línea 82... Línea 92...
82
    public function getDigest(): string;
92
 
83
 
93
    /**
84
    /**
94
     * @return non-empty-string Digest algorithm used to calculate the OTP. Possible values are 'md5', 'sha1', 'sha256' and 'sha512'
85
     * @param string $parameter
95
     */
Línea 86... Línea 96...
86
     *
96
    public function getDigest(): string;
87
     * @return null|mixed
97
 
88
     */
-
 
89
    public function getParameter(string $parameter);
-
 
90
 
-
 
91
    /**
98
    /**
92
     * @param string $parameter
99
     * @param non-empty-string $parameter
Línea 93... Línea 100...
93
     *
100
     */
94
     * @return bool
101
    public function getParameter(string $parameter): mixed;
-
 
102
 
-
 
103
    /**
95
     */
104
     * @param non-empty-string $parameter
96
    public function hasParameter(string $parameter): bool;
105
     */
Línea 97... Línea 106...
97
 
106
    public function hasParameter(string $parameter): bool;
98
    /**
-
 
99
     * @return array
107
 
100
     */
108
    /**
-
 
109
     * @return array<non-empty-string, mixed>
101
    public function getParameters(): array;
110
     */
102
 
111
    public function getParameters(): array;
103
    /**
112
 
104
     * @param string $parameter
113
    /**