Skip to content

Commit

Permalink
[WebAuthn] Enhance code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Skrzeczkowski authored and terry2000s committed Nov 7, 2024
1 parent 39faa31 commit 98c18ee
Show file tree
Hide file tree
Showing 17 changed files with 403 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

using static Interop;
using static Tizen.Security.WebAuthn.ErrorFactory;

namespace Tizen.Security.WebAuthn
{
Expand Down Expand Up @@ -47,12 +46,20 @@ internal AuthenticationExtension(WauthnAuthenticationExt ext)
}

/// <summary>
/// Extension identifier.
/// Gets the extension identifier.
/// </summary>
/// <value>
/// The binary data of the extension indentifier.
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] ExtensionId { get; init; }
/// <summary>
/// Extension value.
/// Gets the extension value.
/// </summary>
/// <value>
/// The binary data of the extension value.
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] ExtensionValue { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,36 @@ public AuthenticationSelectionCriteria(
}

/// <summary>
/// Authenticator attachment modality.
/// Gets the authenticator attachment modality.
/// </summary>
/// <value>
/// The attachment modality - the usage of platform or roaming authenticators.
/// </value>
/// <since_tizen> 12 </since_tizen>
public AuthenticatorAttachment Attachment { get; init; }
/// <summary>
/// The extent to which the Relying Party desires to create a client-side discoverable credential.
/// Gets the Relying Party's requirement regarding client-side discoverable credentials.
/// </summary>
/// <value>
/// The extent to which the Relying Party desires to create a client-side discoverable credential.
/// </value>
/// <since_tizen> 12 </since_tizen>
public ResidentKeyRequirement ResidentKey { get; init; }
/// <summary>
/// Whether residentKey is required.
/// Gets a value indicating whether a ResidentKey is required.
/// </summary>
/// <value>
/// A boolean value indicating whether a ResidentKey is required.
/// </value>
/// <since_tizen> 12 </since_tizen>
public bool RequireResidentKey { get; init; }
/// <summary>
/// The Relying Party's requirements regarding user verification.
/// Gets the user verification requirements.
/// </summary>
/// <value>
/// The Relying Party's requirements regarding user verification.
/// </value>
/// <since_tizen> 12 </since_tizen>
public UserVerificationRequirement UserVerification { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static class Authenticator
/// <since_tizen> 12 </since_tizen>
/// <feature>http://tizen.org/feature/security.webauthn</feature>
/// <returns>An enum with the collection of all supported authenticator types.</returns>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
/// <exception cref="NotSupportedException">Thrown when the required feature is not supported.</exception>
public static AuthenticatorTransport SupportedAuthenticators()
{
int ret = Libwebauthn.SupportedAuthenticators(out uint supported);
Expand Down Expand Up @@ -72,11 +72,11 @@ public static AuthenticatorTransport SupportedAuthenticators()
/// <param name="clientData">UTF-8 encoded JSON serialization of the client data.</param>
/// <param name="options">Specifies the desired attributes of the to-be-created public key credential.</param>
/// <param name="callbacks">The callback functions to be invoked.</param>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
/// <exception cref="UnauthorizedAccessException">Required privilege is missing.</exception>
/// <exception cref="ArgumentException">Input parameter is invalid.</exception>
/// <exception cref="InvalidOperationException">Operation invalid in current state.</exception>
/// <exception cref="OperationCanceledException">Canceled by a cancel request.</exception>
/// <exception cref="NotSupportedException">Thrown when the required feature is not supported.</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when a required privilege is missing.</exception>
/// <exception cref="ArgumentException">Thrown when an input parameter is invalid.</exception>
/// <exception cref="InvalidOperationException">Thrown when the operation is invalid in current state.</exception>
/// <exception cref="OperationCanceledException">Thrown when the call is canceled by a cancel request.</exception>
public static void MakeCredential(ClientData clientData, PubkeyCredCreationOptions options, MakeCredentialCallbacks callbacks)
{
CheckPreconditions();
Expand Down Expand Up @@ -136,11 +136,11 @@ public static void MakeCredential(ClientData clientData, PubkeyCredCreationOptio
/// <param name="clientData">UTF-8 encoded JSON serialization of the client data.</param>
/// <param name="options">Specifies the desired attributes of the public key credential to discover.</param>
/// <param name="callbacks">The callback functions to be invoked.</param>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
/// <exception cref="UnauthorizedAccessException">Required privilege is missing.</exception>
/// <exception cref="ArgumentException">Input parameter is invalid.</exception>
/// <exception cref="InvalidOperationException">Operation invalid in current state.</exception>
/// <exception cref="OperationCanceledException">Canceled by a cancel request.</exception>
/// <exception cref="NotSupportedException">Thrown when the required feature is not supported.</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when a required privilege is missing.</exception>
/// <exception cref="ArgumentException">Thrown when an input parameter is invalid.</exception>
/// <exception cref="InvalidOperationException">Thrown when the operation is invalid in current state.</exception>
/// <exception cref="OperationCanceledException">Thrown when the call is canceled by a cancel request.</exception>
public static void GetAssertion(ClientData clientData, PubkeyCredRequestOptions options, GetAssertionCallbacks callbacks)
{
CheckPreconditions();
Expand Down Expand Up @@ -180,8 +180,8 @@ public static void GetAssertion(ClientData clientData, PubkeyCredRequestOptions
/// </summary>
/// <since_tizen> 12 </since_tizen>
/// <feature>http://tizen.org/feature/security.webauthn</feature>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
/// <exception cref="InvalidOperationException">Not allowed in the current context.</exception>
/// <exception cref="NotSupportedException">Thrown when the required feature is not supported.</exception>
/// <exception cref="InvalidOperationException">Thrown when the operation is invalid in current state.</exception>
public static void Cancel()
{
int ret = Libwebauthn.Cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace Tizen.Security.WebAuthn
{
/// <summary>
/// The response of GetAssertion().
/// The authenticator's response of <see cref="Authenticator.GetAssertion"/>.
/// </summary>
/// <remarks>
/// Refer to the following W3C specification for more information.
Expand All @@ -38,28 +38,48 @@ internal AuthenticatorAssertionResponse(WauthnAuthenticatorAssertionResponse wau
}

/// <summary>
/// JSON-compatible serialization of client data.
/// Gets the serialized client data json.
/// </summary>
/// <value>
/// A JSON-compatible serialization of client data.
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] ClientDataJson { get; init; }
/// <summary>
/// The authenticator data contained within attestation_object.
/// For more information, refer to https://www.w3.org/TR/webauthn-3/#sctn-authenticator-data
/// Gets the authenticator data contained within the Attestation Object.
/// </summary>
/// <value>
/// Authenticator data contained within the Attestation Object.
/// For more information, refer to https://www.w3.org/TR/webauthn-3/#sctn-authenticator-data
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] AuthenticatorData { get; init; }
/// <summary>
/// The raw signature returned from the authenticator.
/// For more information, refer to https://www.w3.org/TR/webauthn-3/#sctn-op-get-assertion
/// Gets the signature returned from the authenticator.
/// </summary>
/// <value>
/// The signature returned from the authenticator.
/// For more information, refer to https://www.w3.org/TR/webauthn-3/#sctn-op-get-assertion
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] Signature { get; init; }
/// <summary>
/// Gets the user handle returned from the authenticator.
/// </summary>
/// <value>
/// The user handle returned from the authenticator,
/// or null if the authenticator did not return a user handle.
/// </summary>
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] UserHandle { get; init; }
/// <summary>
/// This OPTIONAL attribute contains an attestation object,
/// if the authenticator supports attestation in assertions.
/// Gets the attestation object.
/// </summary>
/// <value>
/// An OPTIONAL property that contains an attestation object,
/// if the authenticator supports attestation in assertions.
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] AttestationObject { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace Tizen.Security.WebAuthn
{
/// <summary>
/// The response of MakeCredential().
/// The response of <see cref="Authenticator.MakeCredential"/>.
/// </summary>
/// <remarks>
/// Refer to the following W3C specification for more information.
Expand All @@ -39,30 +39,55 @@ internal AuthenticatorAttestationResponse(WauthnAuthenticatorAttestationResponse
}

/// <summary>
/// JSON-compatible serialization of client data.
/// Gets the serialized client data json.
/// </summary>
/// <value>
/// A JSON-compatible serialization of client data.
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] ClientDataJson { get; init; }
/// <summary>
/// The CBOR encoded Attestation Object to be returned to the RP.
/// Gets the Attestation Object to be returned to the Relying Party.
/// </summary>
/// <value>
/// A CBOR-encoded Attestation Object.
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] AttestationObject { get; init; }
/// <summary>
/// To represent multiple transports, <see cref="AuthenticatorTransport"/> can be ORed multiple times.
/// Gets an enum containing a list of transports.
/// </summary>
/// <value>
/// A list of transports. To represent multiple transports,
/// <see cref="AuthenticatorTransport"/> can be ORed multiple times.
/// </value>
/// <since_tizen> 12 </since_tizen>
public AuthenticatorTransport Transports { get; init; }
/// <summary>
/// The authenticator data contained within attestation_object.
/// For more information, refer to https://www.w3.org/TR/webauthn-3/#sctn-authenticator-data
/// Gets the authenticator data contained within the Attestation Object.
/// </summary>
/// <value>
/// Authenticator data contained within the Attestation Object.
/// For more information, refer to https://www.w3.org/TR/webauthn-3/#sctn-authenticator-data
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] AuthenticatorData { get; init; }
/// <summary>
/// Gets the DER SubjectPublicKeyInfo of the new credential.
/// </summary>
/// <value>
/// DER SubjectPublicKeyInfo of the new credential, or null if this is not available.
/// For more information, refer to https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.7
/// </summary>
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] SubjectPubkeyInfo { get; init; }
/// <summary>
/// The COSEAlgorithmIdentifier of the new credential.
/// Gets the COSE algorithm identifier of the new credential.
/// </summary>
/// <value>
/// The COSE algorithm identifier of the new credential.
/// </value>
/// <since_tizen> 12 </since_tizen>
public CoseAlgorithm PubkeyAlg { get; init; }

}
Expand Down
16 changes: 11 additions & 5 deletions src/Tizen.Security.WebAuthn/Tizen.Security.WebAuthn/ClientData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License
*/

using static Tizen.Security.WebAuthn.ErrorFactory;

namespace Tizen.Security.WebAuthn
{
/// <summary>
Expand All @@ -33,20 +31,28 @@ public class ClientData
/// </summary>
/// <since_tizen> 12 </since_tizen>
/// <param name="jsonData">UTF-8 encoded JSON serialization of the client data.</param>
/// <param name="hashAlgo">Hash algorithm used to hash the JsonData property.</param>
/// <param name="hashAlgo">Hash algorithm used to hash the jsonData parameter.</param>
public ClientData(byte[] jsonData, HashAlgorithm hashAlgo)
{
JsonData = jsonData;
HashAlgo = hashAlgo;
}

/// <summary>
/// UTF-8 encoded JSON serialization of the client data.
/// Gets the serialized client data json.
/// </summary>
/// <value>
/// A UTF-8 encoded JSON serialization of the client data.
/// </value>
/// <since_tizen> 12 </since_tizen>
public byte[] JsonData { get; init; }
/// <summary>
/// Hash algorithm used to hash the JsonData property.
/// Gets the hash algorithm.
/// </summary>
/// <value>
/// The hash algorithm used to hash the JsonData property.
/// </value>
/// <since_tizen> 12 </since_tizen>
public HashAlgorithm HashAlgo{ get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,36 @@ public GetAssertionCallbacks(
}

/// <summary>
/// Callback function for displaying QR code.
/// Gets the callback function for displaying the QR code.
/// </summary>
/// <value>
/// The callback function for displaying the QR code.
/// </value>
/// <since_tizen> 12 </since_tizen>
public Action<string, object> QrcodeCallback { get; init; }
/// <summary>
/// Callback function for getting the final response.
/// Gets the callback function for getting the final response.
/// </summary>
/// <value>
/// The callback function for getting the final response of the operation from the authenticator.
/// </value>
/// <since_tizen> 12 </since_tizen>
public Action<PubkeyCredAssertion, WauthnError, object> ResponseCallback { get; init; }
/// <summary>
/// Callback function for getting the updated linked device data.
/// Gets the callback function for getting the updated linked device data.
/// </summary>
/// <value>
/// The callback function for getting the updated linked device data from the authenticator.
/// </value>
/// <since_tizen> 12 </since_tizen>
public Action<HybridLinkedData, WauthnError, object> LinkedDataCallback { get; init; }
/// <summary>
/// User data to be passed to <see cref="QrcodeCallback"/>, <see cref="ResponseCallback"/> and <see cref="LinkedDataCallback"/>.
/// Gets the user data to be passed to callbacks.
/// </summary>
/// <value>
/// The user data to be passed to <see cref="QrcodeCallback"/>, <see cref="ResponseCallback"/> and <see cref="LinkedDataCallback"/>.
/// </value>
/// <since_tizen> 12 </since_tizen>
public object UserData { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,35 @@ internal HybridLinkedData(WauthnHybridLinkedData linkedData)
}

/// <summary>
/// CBOR:"1".
/// Gets the contact id (CBOR:"1").
/// </summary>
public byte[] ContactId { get; init; }
/// <summary>
/// CBOR:"3".
/// Gets the link id (CBOR:"3").
/// </summary>
public byte[] LinkId { get; init; }
/// <summary>
/// CBOR:"3".
/// Gets the link secret (CBOR:"3").
/// </summary>
public byte[] LinkSecret { get; init; }
/// <summary>
/// CBOR:"4".
/// Gets the authenticator public key (CBOR:"4").
/// </summary>
public byte[] AuthenticatorPubkey { get; init; }
/// <summary>
/// CBOR:"5".
/// Gets the authenticator name (CBOR:"5").
/// </summary>
public byte[] AuthenticatorName { get; init; }
/// <summary>
/// CBOR:"6".
/// Gets the signature (CBOR:"6").
/// </summary>
public byte[] Signature { get; init; }
/// <summary>
/// Domain String of tunnel server.
/// Gets the Domain String of tunnel server.
/// </summary>
public byte[] TunnelServerDomain { get; init; }
/// <summary>
/// Identity Key created during QR initiated transaction.
/// Gets the identity Key created during QR initiated transaction.
/// </summary>
public byte[] IdentityKey { get; init; }
}
Expand Down
Loading

0 comments on commit 98c18ee

Please sign in to comment.