1 <?php 2 3 /* 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. 10 */ 11 12 namespace OTPHP; 13 14 interface OTPInterface 15 { 16 /** 17 * @param int $timestamp 18 * 19 * @return string Return the OTP at the specified timestamp 20 */ 21 public function at(int $timestamp): string; 22 23 /** 24 * Verify that the OTP is valid with the specified input. 25 * If no input is provided, the input is set to a default value or false is returned. 26 * 27 * @param string $otp 28 * @param int|null $input 29 * @param int|null $window 30 * 31 * @return bool 32 */ 33 public function verify(string $otp, $input = null, $window = null): bool; 34 35 /** 36 * @return string The secret of the OTP 37 */ 38 public function getSecret(): string; 39 40 /** 41 * @param string $label The label of the OTP 42 */ 43 public function setLabel(string $label); 44 45 /** 46 * @return string|null The label of the OTP 47 */ 48 public function getLabel(); 49 50 /** 51 * @return string|null The issuer 52 */ 53 public function getIssuer(); 54 55 /** 56 * @param string $issuer 57 * 58 * @throws \InvalidArgumentException 59 */ 60 public function setIssuer(string $issuer); 61 62 /** 63 * @return bool If true, the issuer will be added as a parameter in the provisioning URI 64 */ 65 public function isIssuerIncludedAsParameter(): bool; 66 67 /** 68 * @param bool $issuer_included_as_parameter 69 * 70 * @return $this 71 */ 72 public function setIssuerIncludedAsParameter(bool $issuer_included_as_parameter); 73 74 /** 75 * @return int Number of digits in the OTP 76 */ 77 public function getDigits(): int; 78 79 /** 80 * @return string Digest algorithm used to calculate the OTP. Possible values are 'md5', 'sha1', 'sha256' and 'sha512' 81 */ 82 public function getDigest(): string; 83 84 /** 85 * @param string $parameter 86 * 87 * @return null|mixed 88 */ 89 public function getParameter(string $parameter); 90 91 /** 92 * @param string $parameter 93 * 94 * @return bool 95 */ 96 public function hasParameter(string $parameter): bool; 97 98 /** 99 * @return array 100 */ 101 public function getParameters(): array; 102 103 /** 104 * @param string $parameter 105 * @param mixed $value 106 * 107 * @return $this 108 */ 109 public function setParameter(string $parameter, $value); 110 111 /** 112 * @return string Get the provisioning URI 113 */ 114 public function getProvisioningUri(): string; 115 116 /** 117 * @param string $uri The Uri of the QRCode generator with all parameters. By default the Googgle Chart API is used. This Uri MUST contain a placeholder that will be replaced by the method. 118 * @param string $placeholder The placeholder to be replaced in the QR Code generator URI. Default value is {PROVISIONING_URI}. 119 * 120 * @return string Get the provisioning URI 121 */ 122 public function getQrCodeUri(string $uri = 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl={PROVISIONING_URI}', string $placeholder = '{PROVISIONING_URI}'): string; 123 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body