diff --git a/README.md b/README.md index d663734..028d41c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ See more documentation at [project's wiki](https://github.com/xfox111/SimpleOTP/ ```csharp string sample_config_uri = "otpauth://totp/FoxDev%20Studio:eugene@xfox111.net?secret=ESQVTYRM2CWZC3NX24GRRWIAUUWVHWQH&issuer=FoxDev%20Studio"; OTPConfiguration config = OTPConfiguration.GetConfiguration(sample_config_uri); -// OTPModel { Id = af2358b0-3f69-4dd7-9537-32c07d6663aa, Type = TOTP, IssuerLabel = FoxDev Studio, AccountName = eugene@xfox111.net, Secret = ESQVTYRM2CWZC3NX24GRRWIAUUWVHWQH, Issuer = FoxDev Studio, Algorithm = SHA1, Digits = 6, Counter = 0, Period = 00:00:30 } +// OTPConfiguration { Id = af2358b0-3f69-4dd7-9537-32c07d6663aa, Type = TOTP, IssuerLabel = FoxDev Studio, AccountName = eugene@xfox111.net, Secret = ESQVTYRM2CWZC3NX24GRRWIAUUWVHWQH, Issuer = FoxDev Studio, Algorithm = SHA1, Digits = 6, Counter = 0, Period = 00:00:30 } + OTPCode code = OTPService.GenerateCode(ref config); // OTPasswordModel { Code = 350386, Expiring = 23-May-21 06:08:30 PM } @@ -53,7 +54,7 @@ string qrCode = config.GetQrImage(300); // data:image/png;base64,... OTPFactory factory = new (config); factory.CodeUpdated += (newCode) => Console.WriteLine(newCode); -// OTPasswordModel { Code = 350386, Expiring = 23-May-21 06:08:30 PM } +// OTPCode { Code = 350386, Expiring = 23-May-21 06:08:30 PM } factory.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(factory.TimeLeft)) diff --git a/SimpleOTP/Models/OTPCode.cs b/SimpleOTP/Models/OTPCode.cs index 9900f3f..dbf0ed6 100644 --- a/SimpleOTP/Models/OTPCode.cs +++ b/SimpleOTP/Models/OTPCode.cs @@ -33,7 +33,7 @@ namespace SimpleOTP.Models /// /// Initializes a new instance of the class.
- /// Use this contructor only for HOTP key. Otherwise, fill out all properties. + /// Use this constructor only for HOTP key. Otherwise, fill out all properties. ///
/// OTP code. public OTPCode(int code) => @@ -48,4 +48,4 @@ namespace SimpleOTP.Models public string GetCode(string formatter = "000000") => Code.ToString(formatter); } -} \ No newline at end of file +} diff --git a/SimpleOTP/Models/OTPConfiguration.cs b/SimpleOTP/Models/OTPConfiguration.cs index 6fdff7c..d8214ff 100644 --- a/SimpleOTP/Models/OTPConfiguration.cs +++ b/SimpleOTP/Models/OTPConfiguration.cs @@ -26,7 +26,7 @@ namespace SimpleOTP.Models public Guid Id { get; set; } = Guid.NewGuid(); /// - /// Gets or sets oTP algorithm type. + /// Gets or sets OTP algorithm type. /// public OTPType Type { get; set; } = OTPType.TOTP; @@ -217,7 +217,7 @@ namespace SimpleOTP.Models HttpResponseMessage response = client.GetAsync($"https://chart.googleapis.com/chart?cht=qr&chs={qrCodeSize}x{qrCodeSize}&chl={HttpUtility.UrlEncode(GetUri().AbsoluteUri)}").Result; if (!response.IsSuccessStatusCode) - throw new HttpRequestException("Response status code indicates that request has failed", null, response.StatusCode); + throw new HttpRequestException($"Response status code indicates that request has failed (Response code: {response.StatusCode})"); byte[] imageBytes = await response.Content.ReadAsByteArrayAsync(); string imageString = @$"data:image/png;base64,{Convert.ToBase64String(imageBytes)}"; @@ -225,4 +225,4 @@ namespace SimpleOTP.Models return imageString; } } -} \ No newline at end of file +} diff --git a/SimpleOTP/SimpleOTP.csproj b/SimpleOTP/SimpleOTP.csproj index af2e7a1..ea53c4d 100644 --- a/SimpleOTP/SimpleOTP.csproj +++ b/SimpleOTP/SimpleOTP.csproj @@ -1,7 +1,8 @@ - net5.0 + net5.0;netstandard2.1;netcoreapp3.1 + 9 true true true @@ -11,7 +12,7 @@ SimpleOTP SimpleOTP - 1.1.0 + 1.2.0 .NET library for TOTP/HOTP implementation on server (ASP.NET) or client (Xamarin) side Eugene Fox FoxDev Studio @@ -21,7 +22,8 @@ https://github.com/XFox111/SimpleOTP en-US otp;totp;dotnet;hotp;authenticator;2fa;mfa;security;oath - - Updated OTP validation methods signatures: `ValidateCode()` is now deprecated and will be removed in future releases + - Expanded support to .NET Standard 2.1 and .NET Core 3.1 +- Fixed some documentation typos (https://github.com/XFox111/SimpleOTP/issues/14)