diff --git a/API-reference.md b/API-reference.md index 82530f5..85aadd4 100644 --- a/API-reference.md +++ b/API-reference.md @@ -31,5 +31,9 @@ ## EugeneFox.SimpleOTP.DependencyInjection package -> [!NOTE] -This section is still in development. +- **SimpleOTP.DependencyInjection** + - [IOtpService](./simpleotp.dependencyinjection.iotpservice) + - [OtpOptions](./simpleotp.dependencyinjection.otpoptions) + - [OtpServiceConfig](./simpleotp.dependencyinjection.otpserviceconfig) + - [OtpServiceExtensions](./simpleotp.dependencyinjection.otpserviceextensions) + - [ToleranceSpanConfig](./simpleotp.dependencyinjection.tolerancespanconfig) diff --git a/simpleotp.dependencyinjection.iotpservice.md b/simpleotp.dependencyinjection.iotpservice.md new file mode 100644 index 0000000..2dd09b2 --- /dev/null +++ b/simpleotp.dependencyinjection.iotpservice.md @@ -0,0 +1,84 @@ +# IOtpService + +Namespace: SimpleOTP.DependencyInjection + +Provides methods for generating and validating One-Time Passwords. + +```csharp +public interface IOtpService +``` + +Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) + +## Methods + +### **CreateUri(String, OtpSecret, Int64)** + +Creates an OTP URI for specified user and secret. + +```csharp +Uri CreateUri(string username, OtpSecret secret, long counter) +``` + +#### Parameters + +`username` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+The username of the user. + +`secret` OtpSecret
+The secret to use. + +`counter` [Int64](https://docs.microsoft.com/en-us/dotnet/api/system.int64)
+(only for HOTP) The counter to use. + +#### Returns + +Uri
+The generated URI. + +### **GenerateCode(OtpSecret, Int64)** + +Creates an OTP code for specified user and secret. + +```csharp +OtpCode GenerateCode(OtpSecret secret, long counter) +``` + +#### Parameters + +`secret` OtpSecret
+The secret to use. + +`counter` [Int64](https://docs.microsoft.com/en-us/dotnet/api/system.int64)
+(only for HOTP) The counter to use. + +#### Returns + +OtpCode
+ +### **ValidateCode(OtpCode, OtpSecret, Int32&, Int64)** + +Validates an OTP code for specified user and secret. + +```csharp +bool ValidateCode(OtpCode code, OtpSecret secret, Int32& resyncValue, long counter) +``` + +#### Parameters + +`code` OtpCode
+The code to validate. + +`secret` OtpSecret
+The secret to use. + +`resyncValue` [Int32&](https://docs.microsoft.com/en-us/dotnet/api/system.int32&)
+The resync value. Shows how much the code is ahead or behind the current counter value. + +`counter` [Int64](https://docs.microsoft.com/en-us/dotnet/api/system.int64)
+(only for HOTP) The counter to use. + +#### Returns + +[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`true` if the code is valid; otherwise, `false`. diff --git a/simpleotp.dependencyinjection.otpoptions.md b/simpleotp.dependencyinjection.otpoptions.md new file mode 100644 index 0000000..d60b3bb --- /dev/null +++ b/simpleotp.dependencyinjection.otpoptions.md @@ -0,0 +1,140 @@ +# OtpOptions + +Namespace: SimpleOTP.DependencyInjection + +Provides options for the One-Time Password service. + +```csharp +public class OtpOptions +``` + +Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [OtpOptions](simpleotp.dependencyinjection.otpoptions)
+Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [RequiredMemberAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.requiredmemberattribute) + +## Properties + +### **Issuer** + +The name of the issuer. + +```csharp +public string Issuer { get; set; } +``` + +#### Property Value + +[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+ +### **IssuerDomain** + +The issuer domain. + +```csharp +public string IssuerDomain { get; set; } +``` + +#### Property Value + +[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+ +**Remarks:** + +IMPORTANT: Using this property will imply adherence to the Apple specification. + +### **Algorithm** + +The algorithm to use. + +```csharp +public OtpAlgorithm Algorithm { get; set; } +``` + +#### Property Value + +OtpAlgorithm
+ +### **Digits** + +The number of digits in the OTP code. + +```csharp +public int Digits { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **Period** + +The number of seconds between each OTP code. + +```csharp +public int Period { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **Type** + +The type of One-Time Password to generate. + +```csharp +public OtpType Type { get; set; } +``` + +#### Property Value + +OtpType
+ +### **UriFormat** + +The format of OTP URIs. + +```csharp +public OtpUriFormat UriFormat { get; set; } +``` + +#### Property Value + +OtpUriFormat
+ +### **ToleranceSpan** + +The tolerance span for the OTP codes validation. + +```csharp +public ToleranceSpan ToleranceSpan { get; set; } +``` + +#### Property Value + +ToleranceSpan
+ +### **CustomProperties** + +Custom properties to place in OTP URIs. + +```csharp +public NameValueCollection CustomProperties { get; } +``` + +#### Property Value + +NameValueCollection
+ +## Constructors + +### **OtpOptions()** + +#### Caution + +Constructors of types with required members are not supported in this version of your compiler. + +--- + +```csharp +public OtpOptions() +``` diff --git a/simpleotp.dependencyinjection.otpserviceconfig.md b/simpleotp.dependencyinjection.otpserviceconfig.md new file mode 100644 index 0000000..fa6dacd --- /dev/null +++ b/simpleotp.dependencyinjection.otpserviceconfig.md @@ -0,0 +1,146 @@ +# OtpServiceConfig + +Namespace: SimpleOTP.DependencyInjection + +Configuration for the One-Time Password service. + +```csharp +public class OtpServiceConfig +``` + +Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [OtpServiceConfig](simpleotp.dependencyinjection.otpserviceconfig)
+Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Properties + +### **Issuer** + +The name of the issuer. + +```csharp +public string Issuer { get; set; } +``` + +#### Property Value + +[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+ +### **IssuerDomain** + +The issuer domain. + +```csharp +public string IssuerDomain { get; set; } +``` + +#### Property Value + +[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+ +**Remarks:** + +IMPORTANT: Using this property will imply adherence to the Apple specification. + +### **Algorithm** + +The algorithm to use. + +```csharp +public OtpAlgorithm Algorithm { get; set; } +``` + +#### Property Value + +OtpAlgorithm
+ +### **Digits** + +The number of digits in the OTP code. + +```csharp +public int Digits { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **Period** + +The number of seconds between each OTP code. + +```csharp +public int Period { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **Type** + +The type of One-Time Password to generate. + +```csharp +public OtpType Type { get; set; } +``` + +#### Property Value + +OtpType
+ +### **UriFormat** + +The format of OTP URIs. + +```csharp +public OtpUriFormat UriFormat { get; set; } +``` + +#### Property Value + +OtpUriFormat
+ +### **MinimalUri** + +Whether to use minimal URI formatting (only required, or altered properties are included), or full URI formatting. + +```csharp +public bool MinimalUri { get; set; } +``` + +#### Property Value + +[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **ToleranceSpan** + +The tolerance span for the OTP codes validation. + +```csharp +public ToleranceSpanConfig ToleranceSpan { get; set; } +``` + +#### Property Value + +[ToleranceSpanConfig](simpleotp.dependencyinjection.tolerancespanconfig)
+ +### **CustomProperties** + +Custom properties to place in OTP URIs. + +```csharp +public Dictionary CustomProperties { get; } +``` + +#### Property Value + +[Dictionary<String, String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2)
+ +## Constructors + +### **OtpServiceConfig()** + +```csharp +public OtpServiceConfig() +``` diff --git a/simpleotp.dependencyinjection.otpserviceextensions.md b/simpleotp.dependencyinjection.otpserviceextensions.md new file mode 100644 index 0000000..2129feb --- /dev/null +++ b/simpleotp.dependencyinjection.otpserviceextensions.md @@ -0,0 +1,104 @@ +# OtpServiceExtensions + +Namespace: SimpleOTP.DependencyInjection + +Extension methods for the One-Time Password service. + +```csharp +public static class OtpServiceExtensions +``` + +Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [OtpServiceExtensions](simpleotp.dependencyinjection.otpserviceextensions)
+Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [ExtensionAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) + +## Methods + +### **AddAuthenticator(IServiceCollection, String)** + +Adds the One-Time Password service to the service collection. + +```csharp +public static IServiceCollection AddAuthenticator(IServiceCollection services, string issuerName) +``` + +#### Parameters + +`services` IServiceCollection
+The service collection. + +`issuerName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+The issuer/application/service name. + +#### Returns + +IServiceCollection
+A reference to this instance after the operation has completed. + +### **AddAuthenticator(IServiceCollection, String, Action<OtpOptions>)** + +Adds the One-Time Password service to the service collection. + +```csharp +public static IServiceCollection AddAuthenticator(IServiceCollection services, string issuerName, Action configure) +``` + +#### Parameters + +`services` IServiceCollection
+The service collection. + +`issuerName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+The issuer/application/service name. + +`configure` [Action<OtpOptions>](https://docs.microsoft.com/en-us/dotnet/api/system.action-1)
+The configuration for the One-Time Password service. + +#### Returns + +IServiceCollection
+A reference to this instance after the operation has completed. + +### **AddAuthenticator(IServiceCollection, IConfiguration)** + +Adds the One-Time Password service to the service collection. + +```csharp +public static IServiceCollection AddAuthenticator(IServiceCollection services, IConfiguration configuration) +``` + +#### Parameters + +`services` IServiceCollection
+The service collection. + +`configuration` IConfiguration
+The configuration for the One-Time Password service. + +#### Returns + +IServiceCollection
+A reference to this instance after the operation has completed. + +### **AddAuthenticator(IServiceCollection, IConfiguration, Action<OtpOptions>)** + +Adds the One-Time Password service to the service collection. + +```csharp +public static IServiceCollection AddAuthenticator(IServiceCollection services, IConfiguration configuration, Action configure) +``` + +#### Parameters + +`services` IServiceCollection
+The service collection. + +`configuration` IConfiguration
+The configuration for the One-Time Password service. + +`configure` [Action<OtpOptions>](https://docs.microsoft.com/en-us/dotnet/api/system.action-1)
+The configuration for the One-Time Password service. + +#### Returns + +IServiceCollection
+A reference to this instance after the operation has completed. diff --git a/simpleotp.dependencyinjection.tolerancespanconfig.md b/simpleotp.dependencyinjection.tolerancespanconfig.md new file mode 100644 index 0000000..3602844 --- /dev/null +++ b/simpleotp.dependencyinjection.tolerancespanconfig.md @@ -0,0 +1,45 @@ +# ToleranceSpanConfig + +Namespace: SimpleOTP.DependencyInjection + +Configuration for the tolerance span. + +```csharp +public class ToleranceSpanConfig +``` + +Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ToleranceSpanConfig](simpleotp.dependencyinjection.tolerancespanconfig) + +## Properties + +### **Behind** + +The number of periods/counter values behind the current value. + +```csharp +public int Behind { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **Ahead** + +The number of periods/counter values ahead of the current value. + +```csharp +public int Ahead { get; set; } +``` + +#### Property Value + +[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+ +## Constructors + +### **ToleranceSpanConfig()** + +```csharp +public ToleranceSpanConfig() +```