diff --git a/Src/Fido2.Models/AssertionOptions.cs b/Src/Fido2.Models/AssertionOptions.cs index 4ac4fb9c..95c50be8 100644 --- a/Src/Fido2.Models/AssertionOptions.cs +++ b/Src/Fido2.Models/AssertionOptions.cs @@ -11,6 +11,8 @@ namespace Fido2NetLib; /// public class AssertionOptions { +#nullable disable + /// /// This member represents a challenge that the selected authenticator signs, along with other data, when producing an authentication assertion. /// See the §13.1 Cryptographic Challenges security consideration. diff --git a/Src/Fido2.Models/AuthenticatorAssertionRawResponse.cs b/Src/Fido2.Models/AuthenticatorAssertionRawResponse.cs index c78b14bc..92d814c1 100644 --- a/Src/Fido2.Models/AuthenticatorAssertionRawResponse.cs +++ b/Src/Fido2.Models/AuthenticatorAssertionRawResponse.cs @@ -38,6 +38,8 @@ public AuthenticationExtensionsClientOutputs Extensions [JsonPropertyName("clientExtensionResults"), Required] public AuthenticationExtensionsClientOutputs ClientExtensionResults { get; set; } +#nullable enable + public sealed class AssertionResponse { [JsonConverter(typeof(Base64UrlConverter))] @@ -52,8 +54,6 @@ public sealed class AssertionResponse [JsonPropertyName("clientDataJSON")] public required byte[] ClientDataJson { get; init; } -#nullable enable - [JsonPropertyName("userHandle")] [JsonConverter(typeof(Base64UrlConverter))] public byte[]? UserHandle { get; init; } diff --git a/Src/Fido2.Models/AuthenticatorAttestationRawResponse.cs b/Src/Fido2.Models/AuthenticatorAttestationRawResponse.cs index cd2b1f46..06cddf99 100644 --- a/Src/Fido2.Models/AuthenticatorAttestationRawResponse.cs +++ b/Src/Fido2.Models/AuthenticatorAttestationRawResponse.cs @@ -1,4 +1,6 @@ -using System.ComponentModel.DataAnnotations; +#nullable disable + +using System.ComponentModel.DataAnnotations; using System.Text.Json.Serialization; using Fido2NetLib.Objects; diff --git a/Src/Fido2.Models/Converters/Base64UrlConverter.cs b/Src/Fido2.Models/Converters/Base64UrlConverter.cs index e67bab25..33237edf 100644 --- a/Src/Fido2.Models/Converters/Base64UrlConverter.cs +++ b/Src/Fido2.Models/Converters/Base64UrlConverter.cs @@ -1,6 +1,4 @@ -#nullable enable - -using System.Buffers; +using System.Buffers; using System.Buffers.Text; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/Src/Fido2.Models/Converters/EnumNameMapper.cs b/Src/Fido2.Models/Converters/EnumNameMapper.cs index d69568bc..b04c3d1a 100644 --- a/Src/Fido2.Models/Converters/EnumNameMapper.cs +++ b/Src/Fido2.Models/Converters/EnumNameMapper.cs @@ -47,9 +47,9 @@ private static FrozenDictionary GetIdToNameMap() { var description = field.GetCustomAttribute(false); - var value = (TEnum)field.GetValue(null); + var value = (TEnum)field.GetValue(null)!; - items.Add(new(value, description is not null ? description.Value : value.ToString())); + items.Add(new(value, description is not null ? description.Value! : value.ToString())); } return items.ToFrozenDictionary(); diff --git a/Src/Fido2.Models/Converters/FidoEnumConverter.cs b/Src/Fido2.Models/Converters/FidoEnumConverter.cs index d9e6f523..0c5e59f5 100644 --- a/Src/Fido2.Models/Converters/FidoEnumConverter.cs +++ b/Src/Fido2.Models/Converters/FidoEnumConverter.cs @@ -12,7 +12,7 @@ public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerial switch (reader.TokenType) { case JsonTokenType.String: - string text = reader.GetString(); + string text = reader.GetString()!; if (EnumNameMapper.TryGetValue(text, out T value)) return value; else diff --git a/Src/Fido2.Models/CredentialCreateOptions.cs b/Src/Fido2.Models/CredentialCreateOptions.cs index 0d1d2315..c076c453 100644 --- a/Src/Fido2.Models/CredentialCreateOptions.cs +++ b/Src/Fido2.Models/CredentialCreateOptions.cs @@ -9,7 +9,6 @@ namespace Fido2NetLib; public sealed class CredentialCreateOptions { /// - /// /// This member contains data about the Relying Party responsible for the request. /// Its value’s name member is required. /// Its value’s id member specifies the relying party identifier with which the credential should be associated.If omitted, its value will be the CredentialsContainer object’s relevant settings object's origin's effective domain. @@ -58,12 +57,16 @@ public sealed class CredentialCreateOptions [JsonPropertyName("attestationFormats")] public IReadOnlyList AttestationFormats { get; set; } = []; +#nullable disable + /// /// This member is intended for use by Relying Parties that wish to select the appropriate authenticators to participate in the create() operation. /// [JsonPropertyName("authenticatorSelection")] public AuthenticatorSelection AuthenticatorSelection { get; set; } +#nullable enable + private IReadOnlyList _hints = Array.Empty(); /// @@ -113,7 +116,7 @@ public IReadOnlyList Hints /// [JsonPropertyName("extensions")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public AuthenticationExtensionsClientInputs Extensions { get; set; } + public AuthenticationExtensionsClientInputs? Extensions { get; set; } public static CredentialCreateOptions Create( Fido2Configuration config, @@ -122,7 +125,7 @@ public static CredentialCreateOptions Create( AuthenticatorSelection authenticatorSelection, AttestationConveyancePreference attestationConveyancePreference, IReadOnlyList excludeCredentials, - AuthenticationExtensionsClientInputs extensions, + AuthenticationExtensionsClientInputs? extensions, IReadOnlyList pubKeyCredParams) { @@ -147,12 +150,10 @@ public string ToJson() public static CredentialCreateOptions FromJson(string json) { - return JsonSerializer.Deserialize(json, FidoModelSerializerContext.Default.CredentialCreateOptions); + return JsonSerializer.Deserialize(json, FidoModelSerializerContext.Default.CredentialCreateOptions)!; } } -#nullable enable - /// /// Constructs a PubKeyCredParam instance /// diff --git a/Src/Fido2.Models/Fido2.Models.csproj b/Src/Fido2.Models/Fido2.Models.csproj index 34d32d3c..0c53ce3d 100644 --- a/Src/Fido2.Models/Fido2.Models.csproj +++ b/Src/Fido2.Models/Fido2.Models.csproj @@ -5,6 +5,7 @@ Fido2NetLib true true + enable $(NoWarn);CS1591 true diff --git a/Src/Fido2.Models/Fido2Configuration.cs b/Src/Fido2.Models/Fido2Configuration.cs index 15c8a02a..686052e5 100644 --- a/Src/Fido2.Models/Fido2Configuration.cs +++ b/Src/Fido2.Models/Fido2Configuration.cs @@ -1,4 +1,6 @@ -using System.Runtime.Serialization; +#nullable disable + +using System.Runtime.Serialization; namespace Fido2NetLib; diff --git a/Src/Fido2.Models/Metadata/BiometricStatusReport.cs b/Src/Fido2.Models/Metadata/BiometricStatusReport.cs index 7c12043a..728bdd15 100644 --- a/Src/Fido2.Models/Metadata/BiometricStatusReport.cs +++ b/Src/Fido2.Models/Metadata/BiometricStatusReport.cs @@ -31,19 +31,19 @@ public class BiometricStatusReport /// If no date is given, the status is assumed to be effective while present. /// [JsonPropertyName("effectiveDate")] - public string EffectiveDate { get; set; } + public string? EffectiveDate { get; set; } /// /// Gets or sets the externally visible aspects of the Biometric Certification evaluation. /// [JsonPropertyName("certificationDescriptor")] - public string CertificationDescriptor { get; set; } + public string? CertificationDescriptor { get; set; } /// /// Gets or sets the unique identifier for the issued Biometric Certification. /// [JsonPropertyName("certificateNumber")] - public string CertificateNumber { get; set; } + public string? CertificateNumber { get; set; } /// /// Gets or sets the version of the Biometric Certification Policy the implementation is Certified to. @@ -52,7 +52,7 @@ public class BiometricStatusReport /// For example: "1.0.0". /// [JsonPropertyName("certificationPolicyVersion")] - public string CertificationPolicyVersion { get; set; } + public string? CertificationPolicyVersion { get; set; } /// /// Gets or sets the version of the Biometric Requirements the implementation is certified to. @@ -61,5 +61,5 @@ public class BiometricStatusReport /// For example: "1.0.0". /// [JsonPropertyName("certificationRequirementsVersion")] - public string CertificationRequirementsVersion { get; set; } + public string? CertificationRequirementsVersion { get; set; } } diff --git a/Src/Fido2.Models/Metadata/DisplayPNGCharacteristicsDescriptor.cs b/Src/Fido2.Models/Metadata/DisplayPNGCharacteristicsDescriptor.cs index b0e6327a..a3d0d45a 100644 --- a/Src/Fido2.Models/Metadata/DisplayPNGCharacteristicsDescriptor.cs +++ b/Src/Fido2.Models/Metadata/DisplayPNGCharacteristicsDescriptor.cs @@ -52,6 +52,8 @@ public sealed class DisplayPNGCharacteristicsDescriptor [JsonPropertyName("interlace")] public required byte Interlace { get; set; } +#nullable disable + /// /// Gets or sets the palette (1 to 256 palette entries). /// diff --git a/Src/Fido2.Models/Metadata/MetadataBLOBPayload.cs b/Src/Fido2.Models/Metadata/MetadataBLOBPayload.cs index e90dc230..e4a59309 100644 --- a/Src/Fido2.Models/Metadata/MetadataBLOBPayload.cs +++ b/Src/Fido2.Models/Metadata/MetadataBLOBPayload.cs @@ -1,5 +1,4 @@ -using System.ComponentModel.DataAnnotations; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Fido2NetLib; @@ -18,7 +17,7 @@ public sealed class MetadataBLOBPayload /// This value MAY contain URL(s) pointing to further information, such as a full Terms and Conditions statement. /// [JsonPropertyName("legalHeader")] - public string LegalHeader { get; set; } + public string? LegalHeader { get; set; } /// /// Gets or sets the serial number of this UAF Metadata BLOB Payload. @@ -26,20 +25,22 @@ public sealed class MetadataBLOBPayload /// /// Serial numbers MUST be consecutive and strictly monotonic, i.e. the successor BLOB will have a no value exactly incremented by one. /// - [JsonPropertyName("no"), Required] - public int Number { get; set; } + [JsonPropertyName("no")] + public required int Number { get; set; } /// /// Gets or sets a formatted date (ISO-8601) when the next update will be provided at latest. /// - [JsonPropertyName("nextUpdate"), Required] - public string NextUpdate { get; set; } + [JsonPropertyName("nextUpdate")] + public required string NextUpdate { get; set; } /// /// Gets or sets a list of zero or more entries of . /// - [JsonPropertyName("entries"), Required] - public MetadataBLOBPayloadEntry[] Entries { get; set; } + [JsonPropertyName("entries")] + public required MetadataBLOBPayloadEntry[] Entries { get; set; } + +#nullable disable /// /// The "alg" property from the original JWT header. Used to validate MetadataStatements. diff --git a/Src/Fido2.Models/Metadata/MetadataBLOBPayloadEntry.cs b/Src/Fido2.Models/Metadata/MetadataBLOBPayloadEntry.cs index 64131d7b..7320964b 100644 --- a/Src/Fido2.Models/Metadata/MetadataBLOBPayloadEntry.cs +++ b/Src/Fido2.Models/Metadata/MetadataBLOBPayloadEntry.cs @@ -1,4 +1,6 @@ -using System.ComponentModel.DataAnnotations; +#nullable disable + +using System.ComponentModel.DataAnnotations; using System.Text.Json.Serialization; namespace Fido2NetLib; diff --git a/Src/Fido2.Models/Metadata/MetadataStatement.cs b/Src/Fido2.Models/Metadata/MetadataStatement.cs index 38af1679..2435afd1 100644 --- a/Src/Fido2.Models/Metadata/MetadataStatement.cs +++ b/Src/Fido2.Models/Metadata/MetadataStatement.cs @@ -1,4 +1,6 @@ -using System.ComponentModel.DataAnnotations; +#nullable disable + +using System.ComponentModel.DataAnnotations; using System.Text.Json.Serialization; namespace Fido2NetLib; diff --git a/Src/Fido2.Models/Metadata/RgbPaletteEntry.cs b/Src/Fido2.Models/Metadata/RgbPaletteEntry.cs index 3a3fc92e..3766dc4d 100644 --- a/Src/Fido2.Models/Metadata/RgbPaletteEntry.cs +++ b/Src/Fido2.Models/Metadata/RgbPaletteEntry.cs @@ -43,7 +43,7 @@ public bool Equals(RgbPaletteEntry other) && B == other.B; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { return obj is RgbPaletteEntry other && Equals(other); } diff --git a/Src/Fido2.Models/Metadata/StatusReport.cs b/Src/Fido2.Models/Metadata/StatusReport.cs index 01abf6ac..46db43b9 100644 --- a/Src/Fido2.Models/Metadata/StatusReport.cs +++ b/Src/Fido2.Models/Metadata/StatusReport.cs @@ -1,4 +1,6 @@ -using System.ComponentModel.DataAnnotations; +#nullable disable + +using System.ComponentModel.DataAnnotations; using System.Text.Json.Serialization; namespace Fido2NetLib; diff --git a/Src/Fido2.Models/Metadata/UafVersion.cs b/Src/Fido2.Models/Metadata/UafVersion.cs index eba3ca59..33f04537 100644 --- a/Src/Fido2.Models/Metadata/UafVersion.cs +++ b/Src/Fido2.Models/Metadata/UafVersion.cs @@ -35,7 +35,7 @@ public bool Equals(UafVersion other) && Minor == other.Minor; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { return obj is UafVersion other && Equals(other); } diff --git a/Src/Fido2.Models/Metadata/VerificationMethodDescriptor.cs b/Src/Fido2.Models/Metadata/VerificationMethodDescriptor.cs index 98569196..69949e77 100644 --- a/Src/Fido2.Models/Metadata/VerificationMethodDescriptor.cs +++ b/Src/Fido2.Models/Metadata/VerificationMethodDescriptor.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +#nullable disable + +using System.Text.Json.Serialization; namespace Fido2NetLib; diff --git a/Src/Fido2.Models/Objects/AuthenticationExtensionsClientInputs.cs b/Src/Fido2.Models/Objects/AuthenticationExtensionsClientInputs.cs index 308eefac..e0bbace1 100644 --- a/Src/Fido2.Models/Objects/AuthenticationExtensionsClientInputs.cs +++ b/Src/Fido2.Models/Objects/AuthenticationExtensionsClientInputs.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +#nullable disable + +using System.Text.Json.Serialization; namespace Fido2NetLib.Objects; @@ -40,6 +42,7 @@ public sealed class AuthenticationExtensionsClientInputs public bool? UserVerificationMethod { private get; set; } #nullable enable + /// /// This client registration extension facilitates reporting certain credential properties known by the client to the requesting WebAuthn Relying Party upon creation of a public key credential source as a result of a registration ceremony. /// diff --git a/Src/Fido2.Models/Objects/AuthenticationExtensionsClientOutputs.cs b/Src/Fido2.Models/Objects/AuthenticationExtensionsClientOutputs.cs index 0d516287..03d748ef 100644 --- a/Src/Fido2.Models/Objects/AuthenticationExtensionsClientOutputs.cs +++ b/Src/Fido2.Models/Objects/AuthenticationExtensionsClientOutputs.cs @@ -11,8 +11,6 @@ public class AuthenticationExtensionsClientOutputs [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public bool? Example { get; set; } -#nullable enable - /// /// This extension allows WebAuthn Relying Parties that have previously registered a credential using the legacy FIDO JavaScript APIs to request an assertion. /// https://www.w3.org/TR/webauthn/#sctn-appid-extension diff --git a/Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobInputs.cs b/Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobInputs.cs index fc18c36f..2378edf8 100644 --- a/Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobInputs.cs +++ b/Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobInputs.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Fido2NetLib.Objects; diff --git a/Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobOutputs.cs b/Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobOutputs.cs index b751ffe3..295fe327 100644 --- a/Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobOutputs.cs +++ b/Src/Fido2.Models/Objects/AuthenticationExtensionsLargeBlobOutputs.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Fido2NetLib.Objects; diff --git a/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFInputs.cs b/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFInputs.cs index a32a4145..2dd2e89a 100644 --- a/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFInputs.cs +++ b/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFInputs.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +#nullable disable + +using System.Text.Json.Serialization; namespace Fido2NetLib.Objects; diff --git a/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFOutputs.cs b/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFOutputs.cs index 2f3f647d..e0e09cfb 100644 --- a/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFOutputs.cs +++ b/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFOutputs.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +#nullable disable + +using System.Text.Json.Serialization; namespace Fido2NetLib.Objects; diff --git a/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFValues.cs b/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFValues.cs index 9b6e25ac..0d1750ea 100644 --- a/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFValues.cs +++ b/Src/Fido2.Models/Objects/AuthenticationExtensionsPRFValues.cs @@ -1,6 +1,4 @@ -#nullable enable - -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Fido2NetLib.Objects; diff --git a/Src/Fido2.Models/Objects/CredentialPropertiesOutput.cs b/Src/Fido2.Models/Objects/CredentialPropertiesOutput.cs index a5f32577..d4134b74 100644 --- a/Src/Fido2.Models/Objects/CredentialPropertiesOutput.cs +++ b/Src/Fido2.Models/Objects/CredentialPropertiesOutput.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace Fido2NetLib.Objects; diff --git a/Src/Fido2.Models/Objects/PublicKeyCredentialUserEntity.cs b/Src/Fido2.Models/Objects/PublicKeyCredentialUserEntity.cs index 47d067d0..e0171a43 100644 --- a/Src/Fido2.Models/Objects/PublicKeyCredentialUserEntity.cs +++ b/Src/Fido2.Models/Objects/PublicKeyCredentialUserEntity.cs @@ -1,4 +1,6 @@ -using System.ComponentModel.DataAnnotations; +#nullable disable + +using System.ComponentModel.DataAnnotations; namespace Fido2NetLib.Objects; diff --git a/Src/Fido2.Models/Objects/RegisteredPublicKeyCredential.cs b/Src/Fido2.Models/Objects/RegisteredPublicKeyCredential.cs index cd8aee9c..61d7e3c0 100644 --- a/Src/Fido2.Models/Objects/RegisteredPublicKeyCredential.cs +++ b/Src/Fido2.Models/Objects/RegisteredPublicKeyCredential.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +#nullable disable + +using System.Text.Json.Serialization; namespace Fido2NetLib.Objects; diff --git a/Src/Fido2.Models/Objects/VerifyAssertionResult.cs b/Src/Fido2.Models/Objects/VerifyAssertionResult.cs index 812507c7..4ec96d30 100644 --- a/Src/Fido2.Models/Objects/VerifyAssertionResult.cs +++ b/Src/Fido2.Models/Objects/VerifyAssertionResult.cs @@ -1,4 +1,6 @@ -namespace Fido2NetLib.Objects; +#nullable disable + +namespace Fido2NetLib.Objects; /// /// Result of the MakeAssertion verification diff --git a/Src/Fido2/Metadata/ConformanceMetadataRepository.cs b/Src/Fido2/Metadata/ConformanceMetadataRepository.cs index 5c477fa2..82ad224b 100644 --- a/Src/Fido2/Metadata/ConformanceMetadataRepository.cs +++ b/Src/Fido2/Metadata/ConformanceMetadataRepository.cs @@ -78,7 +78,8 @@ public async Task GetBLOBAsync(CancellationToken cancellati var combinedBlob = new MetadataBLOBPayload { Number = -1, - NextUpdate = "2099-08-07" + NextUpdate = "2099-08-07", + Entries = [] }; var entries = new List();