mirror of
https://github.com/XFox111/SimpleOTP.git
synced 2026-04-23 08:08:40 +03:00
1b989e7b35
* New 2.0 version + DependencyInjection library * Updated docs and repo settings (devcontainers, vscode, github, etc.) * Added tests * Fixed bugs * Minor test project refactoring * Updated projects - Added symbol packages - Updated package versions to pre-release * Updated SECURITY.md * Added GitHub Actions workflows
34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
namespace SimpleOTP.DependencyInjection;
|
|
|
|
/// <summary>
|
|
/// Provides methods for generating and validating One-Time Passwords.
|
|
/// </summary>
|
|
public interface IOtpService
|
|
{
|
|
/// <summary>
|
|
/// Creates an OTP URI for specified user and secret.
|
|
/// </summary>
|
|
/// <param name="username">The username of the user.</param>
|
|
/// <param name="secret">The secret to use.</param>
|
|
/// <param name="counter">(only for HOTP) The counter to use.</param>
|
|
/// <returns>The generated URI.</returns>
|
|
public Uri CreateUri(string username, OtpSecret secret, long counter = 0);
|
|
|
|
/// <summary>
|
|
/// Creates an OTP code for specified user and secret.
|
|
/// </summary>
|
|
/// <param name="secret">The secret to use.</param>
|
|
/// <param name="counter">(only for HOTP) The counter to use.</param>
|
|
public OtpCode GenerateCode(OtpSecret secret, long counter = 0);
|
|
|
|
/// <summary>
|
|
/// Validates an OTP code for specified user and secret.
|
|
/// </summary>
|
|
/// <param name="code">The code to validate.</param>
|
|
/// <param name="secret">The secret to use.</param>
|
|
/// <param name="resyncValue">The resync value. Shows how much the code is ahead or behind the current counter value.</param>
|
|
/// <param name="counter">(only for HOTP) The counter to use.</param>
|
|
/// <returns><c>true</c> if the code is valid; otherwise, <c>false</c>.</returns>
|
|
public bool ValidateCode(OtpCode code, OtpSecret secret, out int resyncValue, long counter = 0);
|
|
}
|