Skip to content

Commit 93f75b0

Browse files
committed
refactor: 代码格式化
1 parent 54cf24f commit 93f75b0

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/components/BootstrapBlazor.Authenticator/Extensions/OTPExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ namespace BootstrapBlazor.Components;
66

77
internal static class OTPExtensions
88
{
9-
public static OtpNet.OtpHashMode ToMode(this OTPHashMode mode) => mode switch
9+
public static OtpNet.OtpHashMode ToMode(this OtpHashMode mode) => mode switch
1010
{
11-
OTPHashMode.Sha256 => OtpNet.OtpHashMode.Sha256,
12-
OTPHashMode.Sha512 => OtpNet.OtpHashMode.Sha512,
11+
OtpHashMode.Sha256 => OtpNet.OtpHashMode.Sha256,
12+
OtpHashMode.Sha512 => OtpNet.OtpHashMode.Sha512,
1313
_ => OtpNet.OtpHashMode.Sha1
1414
};
1515

16-
public static OtpNet.OtpType ToType(this OTPType type) => type switch
16+
public static OtpNet.OtpType ToType(this OtpType type) => type switch
1717
{
18-
OTPType.HOTP => OtpNet.OtpType.Hotp,
18+
OtpType.Hotp => OtpNet.OtpType.Hotp,
1919
_ => OtpNet.OtpType.Totp
2020
};
2121
}

src/components/BootstrapBlazor.Authenticator/Extensions/ServiceCollectionExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static class ServiceCollectionExtension
2121
public static IServiceCollection AddBootstrapBlazorAuthenticator(this IServiceCollection services, Action<
2222
AuthenticatorOptions>? configOptions = null)
2323
{
24-
services.TryAddSingleton<ITOTPService, DefaultTOTPServices>();
24+
services.TryAddSingleton<ITotpService, DefaultTotpServices>();
2525
services.AddOptionsMonitor<AuthenticatorOptions>();
2626
services.Configure<AuthenticatorOptions>(options =>
2727
{

src/components/BootstrapBlazor.Authenticator/Services/DefaultTOTPServices.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace BootstrapBlazor.Components;
99

10-
class DefaultTOTPServices(IOptionsMonitor<AuthenticatorOptions> optionsMonitor) : ITOTPService
10+
class DefaultTotpServices(IOptionsMonitor<AuthenticatorOptions> optionsMonitor) : ITotpService
1111
{
12-
public TOTPInstanceBase? TOTPInstance { get; private set; }
12+
public TotpInstanceBase? Instance { get; private set; }
1313

1414
public string GenerateOtpUri(AuthenticatorOptions? options = null)
1515
{
@@ -23,15 +23,15 @@ public string GenerateOtpUri(AuthenticatorOptions? options = null)
2323
public string Compute(string secretKey, DateTime? timestamp = null)
2424
{
2525
var instance = new Totp(Base32Encoding.ToBytes(secretKey));
26-
TOTPInstance = new DefaultTOTPInstance(instance);
26+
Instance = new DefaultTOTPInstance(instance);
2727
return timestamp == null ? instance.ComputeTotp() : instance.ComputeTotp(timestamp.Value);
2828
}
2929

3030
public int GetRemainingSeconds(DateTime? timestamp = null)
3131
{
32-
if (TOTPInstance != null)
32+
if (Instance != null)
3333
{
34-
return timestamp == null ? TOTPInstance.GetRemainingSeconds() : TOTPInstance.GetRemainingSeconds(timestamp.Value);
34+
return timestamp == null ? Instance.GetRemainingSeconds() : Instance.GetRemainingSeconds(timestamp.Value);
3535
}
3636
var instance = new Totp(Base32Encoding.ToBytes("OMM2LVLFX6QJHMYI"));
3737
return timestamp == null ? instance.RemainingSeconds() : instance.RemainingSeconds(timestamp.Value);
@@ -50,16 +50,16 @@ public byte[] GetSecretKeyBytes(string input)
5050

5151
public bool Verify(string code, DateTime? timestamp = null)
5252
{
53-
if (TOTPInstance != null)
53+
if (Instance != null)
5454
{
55-
return timestamp == null ? TOTPInstance.Verify(code) : TOTPInstance.Verify(code, timestamp.Value);
55+
return timestamp == null ? Instance.Verify(code) : Instance.Verify(code, timestamp.Value);
5656
}
5757
var instance = new Totp(Base32Encoding.ToBytes("OMM2LVLFX6QJHMYI"));
5858
return timestamp == null ? instance.VerifyTotp(code, out _) : instance.VerifyTotp(timestamp.Value, code, out _);
5959
}
6060
}
6161

62-
class DefaultTOTPInstance(Totp instance) : TOTPInstanceBase
62+
class DefaultTOTPInstance(Totp instance) : TotpInstanceBase
6363
{
6464
public override int GetRemainingSeconds(DateTime? timestamp = null)
6565
{

0 commit comments

Comments
 (0)