diff --git a/src/WalletFramework.Core/ClaimPaths/ClaimPath.cs b/src/WalletFramework.Core/ClaimPaths/ClaimPath.cs index 9f73e679..874a0184 100644 --- a/src/WalletFramework.Core/ClaimPaths/ClaimPath.cs +++ b/src/WalletFramework.Core/ClaimPaths/ClaimPath.cs @@ -1,3 +1,5 @@ +using System.Text; +using LanguageExt; using WalletFramework.Core.ClaimPaths.Errors; using WalletFramework.Core.Functional; using WalletFramework.Core.Path; @@ -31,18 +33,61 @@ from components in array.TraverseAll(ClaimPathComponent.Create) from path in FromComponents(components) select path; } + + public static JArray ToJArray(ClaimPath claimPath) + { + var array = new JArray(); + foreach (var component in claimPath.GetPathComponents()) + { + component.Match( + key => + { + array.Add(new JValue(key)); + return Unit.Default; + }, + index => + { + array.Add(new JValue(index)); + return Unit.Default; + }, + _ => + { + array.Add(JValue.CreateNull()); + return Unit.Default; + } + ); + } + return array; + } } public static class ClaimPathFun { public static JsonPath ToJsonPath(this ClaimPath claimPath) { - var jsonPath = "$." + string.Join('.', claimPath.GetPathComponents().Select(x => + var jsonPath = new StringBuilder(); + jsonPath.Append('$'); + + foreach (var component in claimPath.GetPathComponents()) { - if (x.IsKey) return x.AsKey(); - if (x.IsIndex) return x.AsIndex()?.ToString(); - return null; - }).Where(x => x is not null)); - return JsonPath.ValidJsonPath(jsonPath).UnwrapOrThrow(); + component.Match( + key => + { + jsonPath.Append($".{key}"); + return Unit.Default; + }, + integer => + { + jsonPath.Append($"[{integer}]"); + return Unit.Default; + }, + _ => + { + jsonPath.Append("[*]"); + return Unit.Default; + }); + } + + return JsonPath.ValidJsonPath(jsonPath.ToString()).UnwrapOrThrow(); } } diff --git a/src/WalletFramework.Core/Credentials/CredentialSetId.cs b/src/WalletFramework.Core/Credentials/CredentialSetId.cs index 7ec42bef..b6efc8de 100644 --- a/src/WalletFramework.Core/Credentials/CredentialSetId.cs +++ b/src/WalletFramework.Core/Credentials/CredentialSetId.cs @@ -13,6 +13,8 @@ private CredentialSetId(string value) } public string AsString() => Value; + + public Guid AsGuid() => Guid.Parse(Value); public override string ToString() => Value; diff --git a/src/WalletFramework.MdocVc/ClaimDisplay.cs b/src/WalletFramework.MdocVc/ClaimDisplay.cs deleted file mode 100644 index 2fdc797a..00000000 --- a/src/WalletFramework.MdocVc/ClaimDisplay.cs +++ /dev/null @@ -1,14 +0,0 @@ -using LanguageExt; -using WalletFramework.Core.Localization; - -namespace WalletFramework.MdocVc; - -public record ClaimDisplay( - Option Name, - Option Locale); - -public static class ClaimDisplayJsonKeys -{ - public const string ClaimName = "name"; - public const string Locale = "locale"; -} diff --git a/src/WalletFramework.MdocVc/Display/MdocDisplay.cs b/src/WalletFramework.MdocVc/Display/MdocDisplay.cs deleted file mode 100644 index 16e50d69..00000000 --- a/src/WalletFramework.MdocVc/Display/MdocDisplay.cs +++ /dev/null @@ -1,15 +0,0 @@ -using LanguageExt; -using WalletFramework.Core.Colors; -using WalletFramework.Core.Localization; -using WalletFramework.MdocLib; -using WalletFramework.MdocLib.Elements; - -namespace WalletFramework.MdocVc.Display; - -public record MdocDisplay( - Option Logo, - Option Name, - Option BackgroundColor, - Option TextColor, - Option Locale, - Option>>> ClaimsDisplays); diff --git a/src/WalletFramework.MdocVc/Display/MdocLogo.cs b/src/WalletFramework.MdocVc/Display/MdocLogo.cs deleted file mode 100644 index a2add828..00000000 --- a/src/WalletFramework.MdocVc/Display/MdocLogo.cs +++ /dev/null @@ -1,17 +0,0 @@ -using WalletFramework.Core.Uri; - -namespace WalletFramework.MdocVc.Display; - -public readonly struct MdocLogo -{ - public MdocLogo(Uri value) - { - Value = value; - } - - private Uri Value { get; } - - public override string ToString() => Value.ToStringWithoutTrail(); - - public static implicit operator string(MdocLogo logo) => logo.ToString(); -} diff --git a/src/WalletFramework.MdocVc/Display/MdocName.cs b/src/WalletFramework.MdocVc/Display/MdocName.cs deleted file mode 100644 index 4705f76f..00000000 --- a/src/WalletFramework.MdocVc/Display/MdocName.cs +++ /dev/null @@ -1,22 +0,0 @@ -using LanguageExt; - -namespace WalletFramework.MdocVc.Display; - -public readonly struct MdocName -{ - private string Value { get; } - - private MdocName(string value) => Value = value; - - public override string ToString() => Value; - - public static implicit operator string(MdocName mdocName) => mdocName.Value; - - public static Option OptionMdocName(string name) - { - if (string.IsNullOrWhiteSpace(name)) - return Option.None; - - return new MdocName(name); - } -} diff --git a/src/WalletFramework.MdocVc/Display/Serialization/MdocDisplaySerializationConstants.cs b/src/WalletFramework.MdocVc/Display/Serialization/MdocDisplaySerializationConstants.cs deleted file mode 100644 index c803d3fa..00000000 --- a/src/WalletFramework.MdocVc/Display/Serialization/MdocDisplaySerializationConstants.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace WalletFramework.MdocVc.Display.Serialization; - -public static class MdocDisplaySerializationConstants -{ - public const string LogoJsonKey = "logo"; - - public const string NameJsonKey = "name"; - - public const string BackgroundColorJsonKey = "background_color"; - - public const string TextColorJsonKey = "text_color"; - - public const string LocaleJsonKey = "locale"; - - public const string ClaimsDisplaysJsonKey = "claims_displays"; -} diff --git a/src/WalletFramework.MdocVc/Display/Serialization/MdocDisplaySerializer.cs b/src/WalletFramework.MdocVc/Display/Serialization/MdocDisplaySerializer.cs deleted file mode 100644 index 41c55d48..00000000 --- a/src/WalletFramework.MdocVc/Display/Serialization/MdocDisplaySerializer.cs +++ /dev/null @@ -1,179 +0,0 @@ -using LanguageExt; -using Newtonsoft.Json.Linq; -using WalletFramework.Core.Colors; -using WalletFramework.Core.Functional; -using WalletFramework.Core.Json; -using WalletFramework.Core.Localization; -using WalletFramework.MdocLib; -using WalletFramework.MdocLib.Elements; -using static WalletFramework.MdocVc.Display.Serialization.MdocDisplaySerializationConstants; - -namespace WalletFramework.MdocVc.Display.Serialization; - -public static class MdocDisplaySerializer -{ - public static string Serialize(MdocDisplay display) - { - var json = EncodeToJson(display); - return json.ToString(); - } - - public static Validation Deserialize(string jsonString) - { - var json = JObject.Parse(jsonString); - return DecodeFromJson(json); - } - - private static JObject EncodeToJson(this MdocDisplay display) - { - var result = new JObject(); - display.Logo.IfSome(logo => result.Add(LogoJsonKey, logo.ToString())); - display.Name.IfSome(name => result.Add(NameJsonKey, name.ToString())); - display.BackgroundColor.IfSome(color => result.Add(BackgroundColorJsonKey, color.ToString())); - display.TextColor.IfSome(color => result.Add(TextColorJsonKey, color.ToString())); - display.Locale.IfSome(locale => result.Add(LocaleJsonKey, locale.ToString())); - display.ClaimsDisplays.IfSome(claimsDisplays => - { - var claimsDict = new JObject(); - foreach (var (nameSpace, elementDict) in claimsDisplays) - { - var elements = new JObject(); - foreach (var (elementId, claimDisplays) in elementDict) - { - var displays = new JArray(); - foreach (var claimDisplay in claimDisplays) - { - var claimDisplayJson = new JObject(); - claimDisplay.Name.IfSome( - name => claimDisplayJson.Add(ClaimDisplayJsonKeys.ClaimName, name.ToString()) - ); - claimDisplay.Locale.IfSome( - locale => claimDisplayJson.Add(ClaimDisplayJsonKeys.Locale, locale.ToString()) - ); - displays.Add(claimDisplayJson); - } - elements.Add(elementId.ToString(), displays); - } - claimsDict.Add(nameSpace.ToString(), elements); - } - result.Add(ClaimsDisplaysJsonKey, claimsDict); - }); - return result; - } - - private static MdocDisplay DecodeFromJson(JObject display) - { - var logo = - from jToken in display.GetByKey(LogoJsonKey).ToOption() - let uri = new Uri(jToken.ToString()) - select new MdocLogo(uri); - - var mdocName = - from jToken in display.GetByKey(NameJsonKey).ToOption() - from name in MdocName.OptionMdocName(jToken.ToString()) - select name; - - var backgroundColor = - from jToken in display.GetByKey(BackgroundColorJsonKey).ToOption() - from color in Color.OptionColor(jToken.ToString()) - select color; - - var textColor = - from jToken in display.GetByKey(TextColorJsonKey).ToOption() - from color in Color.OptionColor(jToken.ToString()) - select color; - - var locale = - from jToken in display.GetByKey(LocaleJsonKey).ToOption() - from l in Locale.OptionLocale(jToken.ToString()) - select l; - - var claimsDisplays = - from jToken in display.GetByKey(ClaimsDisplaysJsonKey).ToOption() - from claimsJson in jToken.ToJObject().ToOption() - from displays in DecodeClaimsDisplaysFromJson(claimsJson) - select displays; - - return new MdocDisplay(logo, mdocName, backgroundColor, textColor, locale, claimsDisplays); - } - - private static Option>>> - DecodeClaimsDisplaysFromJson(JObject namespaceDict) - { - var result = new Dictionary>>(); - - var tuples = namespaceDict.Properties().Select(prop => - { - var claimsDict = - from jObject in prop.Value.ToJObject().ToOption() - from claimsDisplays in DecodeClaimsDisplaysDictFromJson(jObject) - select claimsDisplays; - - return ( - NameSpace: NameSpace.ValidNameSpace(prop.Name).ToOption(), - ClaimsDict: claimsDict - ); - }); - - foreach (var (nameSpace, claimsDict) in tuples) - { - nameSpace.OnSome(space => claimsDict.OnSome(dictionary => - { - result.Add(space, dictionary); - return Unit.Default; - })); - } - - return result.Any() - ? result - : Option>>>.None; - } - - private static Option>> - DecodeClaimsDisplaysDictFromJson(JObject json) - { - var result = new Dictionary>(); - - var tuples = json.Properties().Select(prop => - { - var displays = - from jArray in prop.Value.ToJArray().ToOption() - from claimDisplays in jArray.TraverseAny(token => - { - var optionName = - from jToken in token.GetByKey(ClaimDisplayJsonKeys.ClaimName).ToOption() - from name in ClaimName.OptionClaimName(jToken.ToString()) - select name; - - var optionLocale = - from jToken in token.GetByKey(ClaimDisplayJsonKeys.Locale).ToOption() - from locale in Locale.OptionLocale(jToken.ToString()) - select locale; - - return - from name in optionName - from locale in optionLocale - select new ClaimDisplay(name, locale); - }) - select claimDisplays.ToList(); - - return ( - Id: ElementIdentifier.ValidElementIdentifier(prop.Name).ToOption(), - Displays: displays - ); - }); - - foreach (var (elementId, claimDisplays) in tuples) - { - elementId.OnSome(id => claimDisplays.OnSome(displays => - { - result.Add(id, displays); - return Unit.Default; - })); - } - - return result.Any() - ? result - : Option>>.None; - } -} diff --git a/src/WalletFramework.MdocVc/MdocCredential.cs b/src/WalletFramework.MdocVc/MdocCredential.cs index 3e30dfd7..f0080e97 100644 --- a/src/WalletFramework.MdocVc/MdocCredential.cs +++ b/src/WalletFramework.MdocVc/MdocCredential.cs @@ -3,7 +3,6 @@ using WalletFramework.Core.Credentials.Abstractions; using WalletFramework.Core.Cryptography.Models; using WalletFramework.MdocLib; -using WalletFramework.MdocVc.Display; namespace WalletFramework.MdocVc; @@ -11,7 +10,6 @@ public record MdocCredential( Mdoc Mdoc, CredentialId CredentialId, CredentialSetId CredentialSetId, - Option> Displays, KeyId KeyId, CredentialState CredentialState, bool OneTimeUse, diff --git a/src/WalletFramework.MdocVc/MdocCredentialExtensions.cs b/src/WalletFramework.MdocVc/MdocCredentialExtensions.cs index 5f9ebd21..18256fc5 100644 --- a/src/WalletFramework.MdocVc/MdocCredentialExtensions.cs +++ b/src/WalletFramework.MdocVc/MdocCredentialExtensions.cs @@ -3,7 +3,6 @@ using WalletFramework.Core.Credentials; using WalletFramework.Core.Cryptography.Models; using WalletFramework.MdocLib; -using WalletFramework.MdocVc.Display; namespace WalletFramework.MdocVc; @@ -11,7 +10,6 @@ public static class MdocCredentialExtensions { public static MdocCredential ToMdocCredential( this Mdoc mdoc, - Option> displays, KeyId keyId, CredentialSetId credentialSetId, CredentialState credentialState, @@ -19,7 +17,7 @@ public static MdocCredential ToMdocCredential( Option expiresAt, CredentialId credentialId) { - return new MdocCredential(mdoc, credentialId, credentialSetId, displays, keyId, credentialState, oneTimeUse, expiresAt); + return new MdocCredential(mdoc, credentialId, credentialSetId, keyId, credentialState, oneTimeUse, expiresAt); } public static string ToJsonString(this MdocCredential mdocCredential) diff --git a/src/WalletFramework.MdocVc/Persistence/MdocCredentialRecord.cs b/src/WalletFramework.MdocVc/Persistence/MdocCredentialRecord.cs index f41148b3..dc9b0cb6 100644 --- a/src/WalletFramework.MdocVc/Persistence/MdocCredentialRecord.cs +++ b/src/WalletFramework.MdocVc/Persistence/MdocCredentialRecord.cs @@ -10,6 +10,8 @@ namespace WalletFramework.MdocVc.Persistence; public sealed record MdocCredentialRecord : RecordBase { public string DocType { get; init; } + + public string CredentialSetId { get; init; } public string Serialized { get; init; } @@ -25,6 +27,7 @@ public MdocCredentialRecord(MdocCredential mdoc) : base(Guid.Parse(mdoc.Credenti { DocType = mdoc.Mdoc.DocType.AsString(); Serialized = MdocCredentialSerializer.Serialize(mdoc); + CredentialSetId = mdoc.CredentialSetId.AsString(); } public MdocCredential ToDomainModel() diff --git a/src/WalletFramework.MdocVc/Persistence/MdocCredentialRecordConfiguration.cs b/src/WalletFramework.MdocVc/Persistence/MdocCredentialRecordConfiguration.cs index f78b45c1..acc768d5 100644 --- a/src/WalletFramework.MdocVc/Persistence/MdocCredentialRecordConfiguration.cs +++ b/src/WalletFramework.MdocVc/Persistence/MdocCredentialRecordConfiguration.cs @@ -10,6 +10,7 @@ public Unit Configure(ModelBuilder modelBuilder) { var entity = modelBuilder.Entity(); entity.HasIndex(r => r.DocType); + entity.HasIndex(r => r.CredentialSetId); return Unit.Default; } diff --git a/src/WalletFramework.MdocVc/Serialization/MdocCredentialSerializer.cs b/src/WalletFramework.MdocVc/Serialization/MdocCredentialSerializer.cs index 289ed244..dbddc848 100644 --- a/src/WalletFramework.MdocVc/Serialization/MdocCredentialSerializer.cs +++ b/src/WalletFramework.MdocVc/Serialization/MdocCredentialSerializer.cs @@ -4,7 +4,6 @@ using WalletFramework.Core.Credentials; using WalletFramework.Core.Cryptography.Models; using WalletFramework.MdocLib; -using WalletFramework.MdocVc.Display.Serialization; using static WalletFramework.MdocVc.Serialization.MdocCredentialSerializationConstants; namespace WalletFramework.MdocVc.Serialization; @@ -37,12 +36,6 @@ private static JObject EncodeToJObject(this MdocCredential credential) credential.ExpiresAt.IfSome(expires => result.Add(ExpiresAtJsonKey, expires)); - credential.Displays.IfSome(displays => - { - var array = new JArray(displays.Select(MdocDisplaySerializer.Serialize)); - result.Add(DisplaysJsonKey, array); - }); - return result; } @@ -73,17 +66,10 @@ private static MdocCredential DecodeFromJObject(JObject json) from ex in json.GetByKey(ExpiresAtJsonKey).ToOption() select ex.ToObject(); - var displays = - from token in json.GetByKey(DisplaysJsonKey).ToOption() - from array in token.ToJArray().ToOption() - from list in array.TraverseAll(t => MdocDisplaySerializer.Deserialize(t.ToString()).ToOption()) - select list.ToList(); - return new MdocCredential( mdoc, credentialId, credentialSetId, - displays, keyId, credentialState, oneTimeUse, diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/ClaimDisplay.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/ClaimDisplay.cs new file mode 100644 index 00000000..cdb7d598 --- /dev/null +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/ClaimDisplay.cs @@ -0,0 +1,57 @@ +using LanguageExt; +using Newtonsoft.Json.Linq; +using WalletFramework.Core.Functional; +using WalletFramework.Core.Json; +using WalletFramework.Core.Localization; +using static WalletFramework.Core.Localization.Locale; +using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.ClaimDisplayJsonExtensions; + +namespace WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models; + +public record ClaimDisplay +{ + public Option Name { get; } + + public Option Locale { get; } + + private ClaimDisplay(Option name, Option locale) + { + Name = name; + Locale = locale; + } + + private static ClaimDisplay Create(Option name, Option locale) => + new(name, locale); + + public static Validation ValidClaimDisplay(JToken config) + { + var name = + from jToken in config.GetByKey(NameJsonKey) + select jToken.ToObject(); + + var locale = + from jToken in config.GetByKey(LocaleJsonKey) + from validLocale in ValidLocale(jToken) + select validLocale; + + return ValidationFun.Valid(Create) + .Apply(name.ToOption()) + .Apply(locale.ToOption()); + } +} + +public static class ClaimDisplayJsonExtensions +{ + public const string NameJsonKey = "name"; + public const string LocaleJsonKey = "locale"; + + public static JObject EncodeToJson(this ClaimDisplay display) + { + var result = new JObject(); + + display.Locale.IfSome(locale => result.Add(LocaleJsonKey, locale.ToString())); + display.Name.IfSome(name => result.Add(NameJsonKey, name)); + + return result; + } +} diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/ClaimMetadata.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/ClaimMetadata.cs new file mode 100644 index 00000000..2262056b --- /dev/null +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/ClaimMetadata.cs @@ -0,0 +1,80 @@ +using LanguageExt; +using Newtonsoft.Json.Linq; +using WalletFramework.Core.ClaimPaths; +using WalletFramework.Core.Functional; +using WalletFramework.Core.Json; +using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.ClaimMetadataJsonExtensions; + +namespace WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models; + +public record ClaimMetadata +{ + public ClaimPath Path { get; } + + public Option> Display { get; } + + public Option Mandatory { get; } + + private ClaimMetadata(ClaimPath claimPath, Option> claimDisplays, Option mandatory) + { + Path = claimPath; + Display = claimDisplays; + Mandatory = mandatory; + } + + private static ClaimMetadata Create(ClaimPath claimPath, Option> claimDisplays, Option mandatory) => + new(claimPath, claimDisplays, mandatory); + + public static Validation ValidClaimMetadata(JToken config, Func> claimPathValidation) + { + var claimPath = + from jToken in config.GetByKey(PathJsonKey) + from jArray in claimPathValidation(jToken) + select jArray; + + var claimDisplays = + from jToken in config.GetByKey(DisplayJsonKey) + from jArray in jToken.ToJArray() + from claimDisplay in jArray.TraverseAny(ClaimDisplay.ValidClaimDisplay) + select claimDisplay.ToList(); + + var mandatory = + from jToken in config.GetByKey(MandatoryJsonKey) + select jToken.ToObject(); + + var result = ValidationFun.Valid(Create) + .Apply(claimPath) + .Apply(claimDisplays.ToOption()) + .Apply(mandatory.ToOption()); + + return result; + } +} + +public static class ClaimMetadataJsonExtensions +{ + public const string PathJsonKey = "path"; + public const string DisplayJsonKey = "display"; + public const string MandatoryJsonKey = "mandatory"; + + public static JObject EncodeToJson(this ClaimMetadata display) + { + var result = new JObject(); + + result.Add(PathJsonKey, ClaimPath.ToJArray(display.Path)); + + display.Display.IfSome(claimDisplays => + { + var claimsArray = new JArray(); + foreach (var claimDisplay in claimDisplays) + { + claimsArray.Add(claimDisplay.EncodeToJson()); + } + result.Add(DisplayJsonKey, claimsArray); + }); + + display.Mandatory.IfSome(mandatory => { result.Add(MandatoryJsonKey, mandatory); }); + + return result; + } +} diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/CredentialConfiguration.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/CredentialConfiguration.cs index 823873bd..fe84c495 100644 --- a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/CredentialConfiguration.cs +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/CredentialConfiguration.cs @@ -1,5 +1,6 @@ using LanguageExt; using Newtonsoft.Json.Linq; +using WalletFramework.Core.ClaimPaths; using WalletFramework.Core.Functional; using WalletFramework.Core.Json; using static WalletFramework.Core.Functional.ValidationFun; @@ -9,8 +10,8 @@ using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.CryptograhicSigningAlgValue; using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.ProofTypeId; using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.ProofTypeMetadata; -using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.CredentialDisplay; using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.CredentialConfigurationFun; +using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.CredentialMetadata; namespace WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models; @@ -49,7 +50,7 @@ public record CredentialConfiguration /// /// Gets a list of display properties of the supported credential for different languages. /// - public Option> Display { get; } + public Option CredentialMetadata { get; } private CredentialConfiguration( Format format, @@ -57,14 +58,14 @@ private CredentialConfiguration( Option> cryptographicBindingMethodsSupported, Option> credentialSigningAlgValuesSupported, Option> proofTypesSupported, - Option> display) + Option credentialMetadata) { Format = format; Scope = scope; CryptographicBindingMethodsSupported = cryptographicBindingMethodsSupported; CredentialSigningAlgValuesSupported = credentialSigningAlgValuesSupported; ProofTypesSupported = proofTypesSupported; - Display = display; + CredentialMetadata = credentialMetadata; } private static CredentialConfiguration Create( @@ -73,15 +74,15 @@ private static CredentialConfiguration Create( Option> cryptographicBindingMethodsSupported, Option> credentialSigningAlgValuesSupported, Option> proofTypesSupported, - Option> display) => new( + Option credentialMetadata) => new( format, scope, cryptographicBindingMethodsSupported, credentialSigningAlgValuesSupported, proofTypesSupported, - display); + credentialMetadata); - public static Validation ValidCredentialConfiguration(JToken credentialMetadata) + public static Validation ValidCredentialConfiguration(JToken credentialMetadata, Func> claimPathValidation) { var validBindingMethods = new Func>>(bindingMethods => from array in bindingMethods.ToJArray() @@ -96,11 +97,8 @@ from values in array.TraverseAny(ValidCryptograhicSigningAlgValue) var validProofTypes = new Func>>(proofTypes => proofTypes .ToJObject() .OnSuccess(jObject => jObject.ToValidDictionaryAny(ValidProofTypeId, ValidProofTypeMetadata))); - - var optionalCredentialDisplays = new Func>>(credentialDisplays => - from array in credentialDisplays.ToJArray().ToOption() - from displays in array.TraverseAny(OptionalCredentialDisplay) - select displays.ToList()); + + var optionalCredentialMetadata = new Func>(token => OptionalCredentialMetadata(token, claimPathValidation)); return Valid(Create) .Apply(credentialMetadata.GetByKey(FormatJsonKey).OnSuccess(ValidFormat)) @@ -108,7 +106,7 @@ from displays in array.TraverseAny(OptionalCredentialDisplay) .Apply(credentialMetadata.GetByKey(CryptographicBindingMethodsSupportedJsonKey).OnSuccess(validBindingMethods).ToOption()) .Apply(credentialMetadata.GetByKey(CredentialSigningAlgValuesSupportedJsonKey).OnSuccess(validSigningAlgValues).ToOption()) .Apply(credentialMetadata.GetByKey(ProofTypesSupportedJsonKey).OnSuccess(validProofTypes).ToOption()) - .Apply(credentialMetadata.GetByKey(DisplayJsonKey).ToOption().OnSome(optionalCredentialDisplays)); + .Apply(credentialMetadata.GetByKey(CredentialMetadataJsonKey).ToOption().OnSome(optionalCredentialMetadata)); } } @@ -119,7 +117,7 @@ public static class CredentialConfigurationFun public const string CryptographicBindingMethodsSupportedJsonKey = "cryptographic_binding_methods_supported"; public const string CredentialSigningAlgValuesSupportedJsonKey = "credential_signing_alg_values_supported"; public const string ProofTypesSupportedJsonKey = "proof_types_supported"; - public const string DisplayJsonKey = "display"; + public const string CredentialMetadataJsonKey = "credential_metadata"; public static JObject EncodeToJson(this CredentialConfiguration config) { @@ -159,14 +157,9 @@ public static JObject EncodeToJson(this CredentialConfiguration config) result.Add(ProofTypesSupportedJsonKey, proofTypes); }); - config.Display.IfSome(displays => + config.CredentialMetadata.IfSome(metadata => { - var displayArray = new JArray(); - foreach (var display in displays) - { - displayArray.Add(display.EncodeToJson()); - } - result.Add(DisplayJsonKey, displayArray); + result.Add(CredentialMetadataJsonKey, metadata.EncodeToJson()); }); return result; diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/CredentialMetadata.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/CredentialMetadata.cs new file mode 100644 index 00000000..f80738dc --- /dev/null +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/CredentialMetadata.cs @@ -0,0 +1,91 @@ +using LanguageExt; +using Newtonsoft.Json.Linq; +using WalletFramework.Core.ClaimPaths; +using WalletFramework.Core.Functional; +using WalletFramework.Core.Json; +using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.CredentialDisplay; +using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.CredentialMetadataFun; +using static WalletFramework.Core.Functional.ValidationFun; + +namespace WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models; + +/// +/// Represents credential metadata as defined in OpenID4VCI 1.0, containing display information and claims. +/// +public record CredentialMetadata +{ + /// + /// Gets a list of display properties of the supported credential for different languages. + /// + public Option> Display { get; } + + /// + /// Gets the claims token as provided by the issuer metadata. The concrete structure is format-specific. + /// + public Option> Claims { get; } + + private CredentialMetadata(Option> display, Option> claimMetadata) + { + Display = display; + Claims = claimMetadata; + } + + private static CredentialMetadata Create( + Option> display, + Option> claimMetadata) => new( + display, + claimMetadata); + + public static Option OptionalCredentialMetadata(JToken token, Func> claimPathValidation) => token + .ToJObject() + .ToOption() + .OnSome(jObject => + { + var optionalCredentialDisplays = new Func>>(credentialDisplays => + from array in credentialDisplays.ToJArray().ToOption() + from displays in array.TraverseAny(OptionalCredentialDisplay) + select displays.ToList()); + + var optionalClaimsMetadata = new Func>>(claimsMetadata => + from array in claimsMetadata.ToJArray().ToOption() + from claimMetadatas in array.TraverseAny(claimMetadata => ClaimMetadata.ValidClaimMetadata(claimMetadata, claimPathValidation).ToOption()) + select claimMetadatas.ToList()); + + return Valid(Create) + .Apply(jObject.GetByKey(DisplayJsonKey).ToOption().OnSome(optionalCredentialDisplays)) + .Apply(jObject.GetByKey(ClaimsJsonKey).ToOption().OnSome(optionalClaimsMetadata)).ToOption(); + }); +} + +public static class CredentialMetadataFun +{ + public const string DisplayJsonKey = "display"; + public const string ClaimsJsonKey = "claims"; + + public static JObject EncodeToJson(this CredentialMetadata metadata) + { + var result = new JObject(); + + metadata.Display.IfSome(displays => + { + var displayArray = new JArray(); + foreach (var display in displays) + { + displayArray.Add(display.EncodeToJson()); + } + result.Add(DisplayJsonKey, displayArray); + }); + + metadata.Claims.IfSome(claims => + { + var claimsArray = new JArray(); + foreach (var claim in claims) + { + claimsArray.Add(claim.EncodeToJson()); + } + result.Add(ClaimsJsonKey, claimsArray); + }); + + return result; + } +} diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Format.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Format.cs index 1d809cb4..202a8fa0 100644 --- a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Format.cs +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Format.cs @@ -26,7 +26,7 @@ public static Validation ValidFormat(JToken format) => format.ToJValue() ? new Format(str) : new FormatNotSupportedError(str).ToInvalid(); }); - + private static List SupportedFormats => [ Constants.SdJwtVcFormat, diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Mdoc/ClaimsMetadata.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Mdoc/ClaimsMetadata.cs deleted file mode 100644 index e0c31872..00000000 --- a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Mdoc/ClaimsMetadata.cs +++ /dev/null @@ -1,85 +0,0 @@ -using LanguageExt; -using Newtonsoft.Json.Linq; -using WalletFramework.Core.Functional; -using WalletFramework.Core.Json; -using WalletFramework.MdocLib; -using WalletFramework.MdocLib.Elements; -using WalletFramework.MdocVc; -using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.Mdoc.ElementMetadata; - -namespace WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.Mdoc; - -public readonly struct ClaimsMetadata -{ - public Dictionary> Value { get; } - - private ClaimsMetadata(Dictionary> value) => - Value = value; - - public static Validation ValidClaimsMetadata(JObject claims) => claims - .ToValidDictionaryAll(NameSpace.ValidNameSpace, ValidElementMetadatas) - .OnSuccess(dictionary => new ClaimsMetadata(dictionary)); -} - -public static class ClaimsMetadataFun -{ - public static JObject EncodeToJson(this ClaimsMetadata metadata) - { - var result = new JObject(); - - foreach (var (key, elementMetadatas) in metadata.Value) - { - var elementsJson = new JObject(); - foreach (var (elementIdentifier, elementMetadata) in elementMetadatas) - { - elementsJson.Add(elementIdentifier, elementMetadata.EncodeToJson()); - } - - result.Add(key.ToString(), elementsJson); - } - - return result; - } - - public static Option>>> ToClaimsDisplays( - this ClaimsMetadata claimsMetadata) - { - var result = new Dictionary>>(); - - foreach (var nameSpacePair in claimsMetadata.Value) - { - var elementDisplays = new Dictionary>(); - foreach (var elementPair in nameSpacePair.Value) - { - elementPair.Value.Display.Match( - list => - { - var displays = list.Select(elementDisplay => - { - var name = - from elementName in elementDisplay.Name - from claimName in ClaimName.OptionClaimName(elementName) - select claimName; - - return new ClaimDisplay(name, elementDisplay.Locale); - }).ToList(); - elementDisplays.Add(elementPair.Key, displays); - }, - () => {} - ); - } - - if (elementDisplays.Any()) - result.Add(nameSpacePair.Key, elementDisplays); - } - - if (result.Any()) - { - return result; - } - else - { - return Option>>>.None; - } - } -} diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Mdoc/MdocConfiguration.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Mdoc/MdocConfiguration.cs index e71fd586..f6674be7 100644 --- a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Mdoc/MdocConfiguration.cs +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/Mdoc/MdocConfiguration.cs @@ -1,5 +1,7 @@ using LanguageExt; using Newtonsoft.Json.Linq; +using WalletFramework.Core.ClaimPaths; +using WalletFramework.Core.ClaimPaths.Errors; using WalletFramework.Core.Functional; using WalletFramework.Core.Json; using WalletFramework.MdocLib; @@ -22,8 +24,6 @@ public record MdocConfiguration public Option> CryptographicSuitesSupported { get; } public Option> CryptographicCurvesSupported { get; } - - public Option Claims { get; } public Format Format => CredentialConfiguration.Format; @@ -32,15 +32,13 @@ private MdocConfiguration( DocType docType, Option policy, Option> cryptographicSuitesSupported, - Option> cryptographicCurvesSupported, - Option claims) + Option> cryptographicCurvesSupported) { CredentialConfiguration = credentialConfiguration; DocType = docType; Policy = policy; CryptographicSuitesSupported = cryptographicSuitesSupported; CryptographicCurvesSupported = cryptographicCurvesSupported; - Claims = claims; } private static MdocConfiguration Create( @@ -48,13 +46,28 @@ private static MdocConfiguration Create( DocType docType, Option policy, Option> cryptographicSuitesSupported, - Option> cryptographicCurvesSupported, - Option claims) => - new(credentialConfiguration, docType, policy, cryptographicSuitesSupported, cryptographicCurvesSupported, claims); + Option> cryptographicCurvesSupported) => + new(credentialConfiguration, docType, policy, cryptographicSuitesSupported, cryptographicCurvesSupported); public static Validation ValidMdocConfiguration(JObject config) { - var credentialConfiguration = CredentialConfiguration.ValidCredentialConfiguration(config); + var mDocClaimPathValidation = new Func>(token => + { + var mDocClaimPath = + from jArray in token.ToJArray() + from claimPath in ClaimPath.FromJArray(jArray) + let pathComponents = claimPath.GetPathComponents() + from _ in pathComponents.Count > 2 + && pathComponents[0].IsKey + && pathComponents[1].IsKey + ? ValidationFun.Valid(Unit.Default) + : new UnknownComponentError() + select claimPath; + + return mDocClaimPath; + }); + + var credentialConfiguration = CredentialConfiguration.ValidCredentialConfiguration(config, mDocClaimPathValidation); var docType = config.GetByKey(DocTypeJsonKey).OnSuccess(ValidDoctype); var policy = config.GetByKey(PolicyJsonKey).OnSuccess(ValidPolicy).ToOption(); @@ -73,19 +86,12 @@ public static Validation ValidMdocConfiguration(JObject confi .OnSuccess(curves => curves.ToList()) .ToOption(); - var claims = config - .GetByKey(ClaimsJsonKey) - .OnSuccess(token => token.ToJObject()) - .OnSuccess(ClaimsMetadata.ValidClaimsMetadata) - .ToOption(); - return ValidationFun.Valid(Create) .Apply(credentialConfiguration) .Apply(docType) .Apply(policy) .Apply(cryptographicSuitesSupported) - .Apply(cryptographicCurvesSupported) - .Apply(claims); + .Apply(cryptographicCurvesSupported); } } @@ -95,19 +101,18 @@ public static class MdocConfigurationFun public const string PolicyJsonKey = "policy"; public const string CryptographicSuitesSupportedJsonKey = "cryptographic_suites_supported"; public const string CryptographicCurvesSupportedJsonKey = "cryptographic_curves_supported"; - public const string ClaimsJsonKey = "claims"; - public static JObject EncodeToJson(this MdocConfiguration mdocConfig) + public static JObject EncodeToJson(this MdocConfiguration mDocConfig) { - var configJson = mdocConfig.CredentialConfiguration.EncodeToJson(); + var configJson = mDocConfig.CredentialConfiguration.EncodeToJson(); - configJson.Add(DocTypeJsonKey, mdocConfig.DocType.ToString()); + configJson.Add(DocTypeJsonKey, mDocConfig.DocType.ToString()); - mdocConfig.Policy.IfSome(policy => + mDocConfig.Policy.IfSome(policy => configJson.Add(PolicyJsonKey, policy.EncodeToJson()) ); - mdocConfig.CryptographicSuitesSupported.IfSome(suites => + mDocConfig.CryptographicSuitesSupported.IfSome(suites => { var suitesJson = new JArray(); foreach (var suite in suites) @@ -117,7 +122,7 @@ public static JObject EncodeToJson(this MdocConfiguration mdocConfig) configJson.Add(CryptographicSuitesSupportedJsonKey, suitesJson); }); - mdocConfig.CryptographicCurvesSupported.IfSome(curves => + mDocConfig.CryptographicCurvesSupported.IfSome(curves => { var curvesJson = new JArray(); foreach (var curve in curves) @@ -126,10 +131,6 @@ public static JObject EncodeToJson(this MdocConfiguration mdocConfig) } configJson.Add(CryptographicCurvesSupportedJsonKey, curvesJson); }); - - mdocConfig.Claims.IfSome(claims => - configJson.Add(ClaimsJsonKey, claims.EncodeToJson()) - ); return configJson; } diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/SdJwt/SdJwtConfiguration.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/SdJwt/SdJwtConfiguration.cs index 919a1da4..6dd7d8bf 100644 --- a/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/SdJwt/SdJwtConfiguration.cs +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/CredConfiguration/Models/SdJwt/SdJwtConfiguration.cs @@ -1,10 +1,10 @@ using Newtonsoft.Json.Linq; +using WalletFramework.Core.ClaimPaths; using WalletFramework.Core.Functional; using WalletFramework.Core.Json; using WalletFramework.SdJwtVc.Models; using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.CredentialConfiguration; using static WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.SdJwt.SdJwtConfiguration.SdJwtConfigurationJsonKeys; -using ClaimMetadata = WalletFramework.SdJwtVc.Models.Credential.Attributes.ClaimMetadata; namespace WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.SdJwt; @@ -16,16 +16,6 @@ public record SdJwtConfiguration public Vct Vct { get; } - /// - /// Gets or sets the dictionary representing the attributes of the credential in different languages. - /// - public Dictionary? Claims { get; set; } - - /// - /// A list of claim display names, arranged in the order in which they should be displayed by the Wallet. - /// - public List? Order { get; set; } - private SdJwtConfiguration(CredentialConfiguration credentialConfiguration, Vct vct) { CredentialConfiguration = credentialConfiguration; @@ -37,95 +27,29 @@ private static SdJwtConfiguration Create(CredentialConfiguration credentialConfi public static Validation ValidSdJwtCredentialConfiguration(JToken config) { - var credentialConfiguration = ValidCredentialConfiguration(config); - var vct = config.GetByKey(VctJsonName).OnSuccess(Vct.ValidVct); - - var order = config[OrderJsonName]?.ToObject>(); - - var claimToken = config[ClaimsJsonName]; - var claimMetadatas = claimToken switch + var sdJwtClaimPathValidation = new Func>(token => { - //Used to map the ListRepresentation from Vci Draft15 to DictionaryRepresentation of Draft14 and older - JArray => ConvertToDictionaryRepresentation(claimToken.ToObject>()), - JObject => claimToken.ToObject>(), - _ => new Dictionary() - }; - - var result = ValidationFun.Valid(Create) - .Apply(credentialConfiguration) - .Apply(vct) - .OnSuccess(configuration => configuration with - { - Claims = claimMetadatas, - Order = order - }); + var sdJwtClaimPath = + from jArray in token.ToJArray() + from validClaimPath in ClaimPath.FromJArray(jArray) + select validClaimPath; - return result; - } - - private static Dictionary ConvertToDictionaryRepresentation(List? claimsV2) - { - var result = new Dictionary(); - - if (claimsV2 == null) - return result; + return sdJwtClaimPath; + }); - foreach (var claim in claimsV2) - { - if (claim.Path == null || claim.Path.Count == 0) - continue; + var credentialConfiguration = ValidCredentialConfiguration(config, sdJwtClaimPathValidation); + var vct = config.GetByKey(VctJsonName).OnSuccess(Vct.ValidVct); - AddToNestedClaims(result, claim.Path, claim); - } + var result = ValidationFun.Valid(Create) + .Apply(credentialConfiguration) + .Apply(vct); return result; } - - private static void AddToNestedClaims(Dictionary currentLevel, List path, ClaimMetadata sourceClaim) - { - var key = path[0]; - if (!currentLevel.TryGetValue(key, out var claimMetadata)) - { - claimMetadata = new ClaimMetadata(); - currentLevel[key] = claimMetadata; - } - - var isLeafClaim = path.Count == 1; - if (isLeafClaim) - { - claimMetadata.Display = sourceClaim.Display; - claimMetadata.ValueType = sourceClaim.ValueType; - claimMetadata.Mandatory = sourceClaim.Mandatory; - } - else - { - var nextKey = path[1]; - - if (claimMetadata.NestedClaims == null) - claimMetadata.NestedClaims = new Dictionary(); - - if (!claimMetadata.NestedClaims.TryGetValue(nextKey, out var nextToken) || nextToken.Type != JTokenType.Object) - { - var childNode = new ClaimMetadata - { - NestedClaims = new Dictionary() - }; - - claimMetadata.NestedClaims[nextKey] = JObject.FromObject(childNode); - } - - var nextNode = claimMetadata.NestedClaims[nextKey].ToObject()!; - AddToNestedClaims(new Dictionary { [nextKey] = nextNode }, path.Skip(1).ToList(), sourceClaim); - - claimMetadata.NestedClaims[nextKey] = JObject.FromObject(nextNode); - } - } public static class SdJwtConfigurationJsonKeys { public const string VctJsonName = "vct"; - public const string ClaimsJsonName = "claims"; - public const string OrderJsonName = "order"; } } @@ -136,39 +60,7 @@ public static JObject EncodeToJson(this SdJwtConfiguration config) var credentialConfig = config.CredentialConfiguration.EncodeToJson(); credentialConfig.Add(VctJsonName, config.Vct.ToString()); - - if (config.Claims is not null) - { - credentialConfig.Add(ClaimsJsonName, JObject.FromObject(config.Claims)); - } - - if (config.Order is not null) - { - credentialConfig.Add(OrderJsonName, JArray.FromObject(config.Order)); - } return credentialConfig; } - - public static Dictionary ExtractClaimMetadata(this SdJwtConfiguration sdJwtConfiguration) - { - return sdJwtConfiguration - .Claims? - .Where(x => !string.IsNullOrWhiteSpace(x.Key) && x.Value.Display is not null) - .SelectMany(claimMetadata => - { - var claimMetadatas = new Dictionary { { claimMetadata.Key, claimMetadata.Value } }; - - if (claimMetadata.Value.NestedClaims == null || claimMetadata.Value.NestedClaims.Count == 0) - return claimMetadatas; - - foreach (var nested in claimMetadata.Value.NestedClaims!) - { - claimMetadatas.Add(claimMetadata.Key + "." + nested.Key, nested.Value?.ToObject()!); - } - - return claimMetadatas; - }) - .ToDictionary(kvp => kvp.Key, kvp => kvp.Value) ?? new Dictionary(); - } } diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/MdocFun.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/MdocFun.cs index 4263af1f..e69de29b 100644 --- a/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/MdocFun.cs +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/MdocFun.cs @@ -1,40 +0,0 @@ -using LanguageExt; -using WalletFramework.MdocVc.Display; -using WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.Mdoc; - -namespace WalletFramework.Oid4Vc.Oid4Vci.Implementations; - -public static class MdocFun -{ - public static Option> CreateMdocDisplays(MdocConfiguration configuration) - { - var claimsDisplays = - from claimsMetadata in configuration.Claims - from dict in claimsMetadata.ToClaimsDisplays() - select dict; - - var credentialConfigurationDisplay = configuration.CredentialConfiguration.Display; - var result = - from credentialDisplays in credentialConfigurationDisplay - let mdocDisplays = credentialDisplays.Select(credentialDisplay => - { - var logo = - from credentialLogo in credentialDisplay.Logo - select new MdocLogo(credentialLogo.Uri); - - var mdocName = - from credentialName in credentialDisplay.Name - from name in MdocName.OptionMdocName(credentialName.ToString()) - select name; - - var backgroundColor = credentialDisplay.BackgroundColor; - var textColor = credentialDisplay.TextColor; - var locale = credentialDisplay.Locale; - - return new MdocDisplay(logo, mdocName, backgroundColor, textColor, locale, claimsDisplays); - }).ToList() - select mdocDisplays; - - return result; - } -} diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/Oid4VciClientService.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/Oid4VciClientService.cs index 344a93e8..d781975a 100644 --- a/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/Oid4VciClientService.cs +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/Oid4VciClientService.cs @@ -308,7 +308,6 @@ await credential.Value.Match( async sdJwt => { var record = sdJwt.Decoded.ToCredential( - configurationPair.Value.AsT0, response.KeyId, setId, creds.Count > 1); @@ -318,13 +317,10 @@ await credential.Value.Match( }, async mdoc => { - var displays = MdocFun.CreateMdocDisplays(configurationPair.Value.AsT1); - var mdocCredential = new MdocCredential( mdoc.Decoded, CredentialId.CreateCredentialId(), setId, - displays, response.KeyId.UnwrapOrThrow(), CredentialState.Active, creds.Count > 1, @@ -406,6 +402,8 @@ public async Task>> RequestCredentialS //TODO: Make sure that it does not always request all available credConfigurations var credentialSets = new List(); + var records = new List(); + var setId = CredentialSetId.CreateCredentialSetId(); foreach (var configuration in configurations) { var validResponses = await credentialRequestService.RequestCredentials( @@ -418,7 +416,6 @@ public async Task>> RequestCredentialS var result = from responses in validResponses - let setId = CredentialSetId.CreateCredentialSetId() select from response in responses let cNonce = response.CNonce @@ -446,15 +443,19 @@ select credentialsOrTransactionId.Match( Token = dPop.Token with { CNonce = cNonce.ToNullable() } })); }); + + if (configurations.Count == 1) + { + records = []; + setId = CredentialSetId.CreateCredentialSetId(); + } - var records = new List(); foreach (var credential in creds) { await credential.Value.Match( async sdJwt => { var record = sdJwt.Decoded.ToCredential( - configuration.Value.AsT0, response.KeyId, setId, creds.Count > 1); @@ -464,13 +465,10 @@ await credential.Value.Match( }, async mdoc => { - var displays = MdocFun.CreateMdocDisplays(configuration.Value.AsT1); - var mdocCredential = new MdocCredential( mdoc.Decoded, CredentialId.CreateCredentialId(), setId, - displays, response.KeyId.UnwrapOrThrow(), CredentialState.Active, creds.Count > 1, @@ -480,17 +478,29 @@ await credential.Value.Match( records.Add(mdocCredential); }); } - var dataSet = CredentialDataSet.FromCredentials( - records, - session.AuthorizationData.IssuerMetadata.CredentialIssuer.ToString()); - credentialSets.Add(dataSet); + + if (configurations.Count == 1) + { + var dataSet = CredentialDataSet.FromCredentials( + records, + session.AuthorizationData.IssuerMetadata.CredentialIssuer.ToString()); + credentialSets.Add(dataSet); + } }, // ReSharper disable once UnusedParameter.Local transactionId => throw new NotImplementedException()); await result.OnSuccess(async tasks => await Task.WhenAll(tasks)); } - + + if (configurations.Count > 1) + { + var dataSet = CredentialDataSet.FromCredentials( + records, + session.AuthorizationData.IssuerMetadata.CredentialIssuer.ToString()); + credentialSets.Add(dataSet); + } + await credentialDataSetRepository.AddMany(credentialSets); await authFlowSessionRepository.Delete(session.AuthFlowSessionState); @@ -613,7 +623,6 @@ select credentialsOrTransactionId.Match( sdJwt => { var record = sdJwt.Decoded.ToCredential( - configuration.Value.AsT0, response.KeyId, setId, creds.Count > 1); @@ -622,13 +631,10 @@ select credentialsOrTransactionId.Match( }, mdoc => { - var displays = MdocFun.CreateMdocDisplays(configuration.Value.AsT1); - var mdocCredential = new MdocCredential( mdoc.Decoded, CredentialId.CreateCredentialId(), setId, - displays, response.KeyId.UnwrapOrThrow(), CredentialState.Active, creds.Count > 1, diff --git a/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/SdJwtCredentialExtensions.cs b/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/SdJwtCredentialExtensions.cs index 06eb2d44..e6bf16a4 100644 --- a/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/SdJwtCredentialExtensions.cs +++ b/src/WalletFramework.Oid4Vc/Oid4Vci/Implementations/SdJwtCredentialExtensions.cs @@ -1,13 +1,9 @@ -using System.Drawing; using LanguageExt; using Newtonsoft.Json.Linq; using WalletFramework.Core.Credentials; using WalletFramework.Core.Cryptography.Models; -using WalletFramework.Core.Functional; -using WalletFramework.Oid4Vc.Oid4Vci.CredConfiguration.Models.SdJwt; using WalletFramework.SdJwtLib.Models; using WalletFramework.SdJwtVc; -using WalletFramework.SdJwtVc.Models.Credential; namespace WalletFramework.Oid4Vc.Oid4Vci.Implementations; @@ -15,32 +11,10 @@ public static class SdJwtCredentialExtensions { public static SdJwtCredential ToCredential( this SdJwtDoc sdJwtDoc, - SdJwtConfiguration configuration, Option keyId, CredentialSetId credentialSetId, bool isOneTimeUse) { - var displaysOption = - from displays in configuration.CredentialConfiguration.Display - select displays.Select(credentialDisplay => - { - var backgroundColor = credentialDisplay.BackgroundColor.ToNullable() ?? Color.White; - var textColor = credentialDisplay.TextColor.ToNullable() ?? Color.Black; - - return new SdJwtDisplay - { - Logo = new SdJwtDisplay.SdJwtLogo - { - AltText = credentialDisplay.Logo.ToNullable()?.AltText.ToNullable(), - Uri = credentialDisplay.Logo.ToNullable()?.Uri! - }, - Name = credentialDisplay.Name.ToNullable(), - BackgroundColor = backgroundColor, - Locale = credentialDisplay.Locale.ToNullable(), - TextColor = textColor - }; - }).ToList(); - var expiresAt = sdJwtDoc.UnsecuredPayload.SelectToken("exp")?.Value() is { } exp ? Option.Some(DateTimeOffset.FromUnixTimeSeconds(exp).DateTime) : Option.None; @@ -49,7 +23,6 @@ select displays.Select(credentialDisplay => sdJwtDoc, CredentialId.CreateCredentialId(), credentialSetId, - displaysOption, keyId, CredentialState.Active, isOneTimeUse, diff --git a/src/WalletFramework.Oid4Vc/Oid4Vp/Services/ICandidateQueryService.cs b/src/WalletFramework.Oid4Vc/Oid4Vp/Services/ICandidateQueryService.cs index e7373976..fdacf93d 100644 --- a/src/WalletFramework.Oid4Vc/Oid4Vp/Services/ICandidateQueryService.cs +++ b/src/WalletFramework.Oid4Vc/Oid4Vp/Services/ICandidateQueryService.cs @@ -1,6 +1,5 @@ using LanguageExt; using OneOf; -using WalletFramework.Oid4Vc.Oid4Vp.DcApi.Models; using WalletFramework.Oid4Vc.Oid4Vp.Dcql.CredentialQueries; using WalletFramework.Oid4Vc.Oid4Vp.Models; using WalletFramework.Oid4Vc.Oid4Vp.PresentationExchange.Models; diff --git a/src/WalletFramework.SdJwtVc/Models/Credential/Attributes/ClaimDisplay.cs b/src/WalletFramework.SdJwtVc/Models/Credential/Attributes/ClaimDisplay.cs deleted file mode 100644 index 6c1a9d03..00000000 --- a/src/WalletFramework.SdJwtVc/Models/Credential/Attributes/ClaimDisplay.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Newtonsoft.Json; - -namespace WalletFramework.SdJwtVc.Models.Credential.Attributes -{ - /// - /// Represents the visual representations for the credential attribute. - /// - public class ClaimDisplay - { - /// - /// Gets or sets the name for the credential attribute. - /// - [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] - public string? Name { get; set; } - - /// - /// Gets or sets the locale, which represents the specific culture or region. - /// - [JsonProperty("locale", NullValueHandling = NullValueHandling.Ignore)] - public string? Locale { get; set; } - } -} diff --git a/src/WalletFramework.SdJwtVc/Models/Credential/Attributes/ClaimMetadata.cs b/src/WalletFramework.SdJwtVc/Models/Credential/Attributes/ClaimMetadata.cs deleted file mode 100644 index e939d508..00000000 --- a/src/WalletFramework.SdJwtVc/Models/Credential/Attributes/ClaimMetadata.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace WalletFramework.SdJwtVc.Models.Credential.Attributes; - -/// -/// Represents the specifics about a claim. -/// -public class ClaimMetadata { - - [JsonProperty("path", NullValueHandling = NullValueHandling.Ignore)] - public List? Path { get; set; } - - /// - /// Gets or sets the list of display properties associated with a specific credential attribute. - /// - /// - /// The list of display properties. Each display property provides information on how the credential attribute should - /// be displayed. - /// - [JsonProperty("display", NullValueHandling = NullValueHandling.Ignore)] - public List? Display { get; set; } - - /// - /// String value determining type of value of the claim. A non-exhaustive list of valid values defined by this - /// specification are string, number, and image media types such as image/jpeg. - /// - [JsonProperty("value_type", NullValueHandling = NullValueHandling.Ignore)] - public string? ValueType { get; set; } - - /// - /// String value determining type of value of the claim. A non-exhaustive list of valid values defined by this - /// specification are string, number, and image media types such as image/jpeg. - /// - [JsonProperty("mandatory", NullValueHandling = NullValueHandling.Ignore)] - public string? Mandatory { get; set; } - - [JsonProperty("nested_claims", NullValueHandling = NullValueHandling.Ignore)] - [JsonExtensionData] - public Dictionary? NestedClaims { get; set; } -} - diff --git a/src/WalletFramework.SdJwtVc/Models/Credential/CredentialDefinition.cs b/src/WalletFramework.SdJwtVc/Models/Credential/CredentialDefinition.cs deleted file mode 100644 index 6e688244..00000000 --- a/src/WalletFramework.SdJwtVc/Models/Credential/CredentialDefinition.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Newtonsoft.Json; -using WalletFramework.SdJwtVc.Models.Credential.Attributes; - -namespace WalletFramework.SdJwtVc.Models.Credential -{ - /// - /// Represents the detailed description of the credential type. - /// - public class CredentialDefinition - { - /// - /// Gets or sets the verifiable credential type (vct). - /// - [JsonProperty("vct")] - public string Vct { get; set; } = null!; - - /// - /// Gets or sets the dictionary representing the attributes of the credential in different languages. - /// - [JsonProperty("claims")] - public Dictionary? Claims { get; set; } - } -} diff --git a/src/WalletFramework.SdJwtVc/Models/Credential/SdJwtDisplay.cs b/src/WalletFramework.SdJwtVc/Models/Credential/SdJwtDisplay.cs deleted file mode 100644 index 03248476..00000000 --- a/src/WalletFramework.SdJwtVc/Models/Credential/SdJwtDisplay.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Newtonsoft.Json; - -namespace WalletFramework.SdJwtVc.Models.Credential; - -/// -/// Represents the visual representations for the credential. -/// -public record SdJwtDisplay -{ - /// - /// Gets or sets the logo associated with this Credential. - /// - [JsonProperty("logo", NullValueHandling = NullValueHandling.Ignore)] - public SdJwtLogo? Logo { get; set; } - - /// - /// Gets or sets the name of the Credential. - /// - [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] - public string? Name { get; set; } - - /// - /// Gets or sets the background color for the Credential. - /// - [JsonProperty("background_color", NullValueHandling = NullValueHandling.Ignore)] - public string? BackgroundColor { get; set; } - - /// - /// Gets or sets the locale, which represents the specific culture or region. - /// - [JsonProperty("locale", NullValueHandling = NullValueHandling.Ignore)] - public string? Locale { get; set; } - - /// - /// Gets or sets the text color for the Credential. - /// - [JsonProperty("text_color", NullValueHandling = NullValueHandling.Ignore)] - public string? TextColor { get; set; } - - /// - /// Represents the Logo for a Credential. - /// - public class SdJwtLogo - { - /// - /// Gets or sets the alternate text that describes the logo image. This is typically used for accessibility purposes. - /// - [JsonProperty("alt_text")] - public string? AltText { get; set; } - - /// - /// Gets or sets the URL of the logo image. - /// - [JsonProperty("uri")] - public Uri Uri { get; set; } = null!; - } -} diff --git a/src/WalletFramework.SdJwtVc/Models/Credential/SdJwtMetadata.cs b/src/WalletFramework.SdJwtVc/Models/Credential/SdJwtMetadata.cs deleted file mode 100644 index 1f1c0f15..00000000 --- a/src/WalletFramework.SdJwtVc/Models/Credential/SdJwtMetadata.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Newtonsoft.Json; -using WalletFramework.SdJwtVc.Models.Credential.Attributes; - -namespace WalletFramework.SdJwtVc.Models.Credential -{ - /// - /// Represents the metadata of a specific type of credential that a Credential Issuer can issue. - /// - public class SdJwtMetadata - { - /// - /// Gets or sets the verifiable credential type (vct). This is SD-JWT specific. - /// - [JsonProperty("vct")] - public string? Vct { get; set; } - - /// - /// - /// - [JsonProperty("scope")] - public string? Scope { get; set; } - - /// - /// Gets or sets the dictionary representing the attributes of the credential in different languages. - /// - [JsonProperty("claims")] - public Dictionary? Claims { get; set; } - - /// - /// Gets or sets a list of display properties of the supported credential for different languages. - /// - [JsonProperty("display", NullValueHandling = NullValueHandling.Ignore)] - public List? Display { get; set; } - - /// - /// Gets or sets a list of methods that identify how the Credential is bound to the identifier of the End-User who - /// possesses the Credential. - /// - [JsonProperty("cryptographic_binding_methods_supported", NullValueHandling = NullValueHandling.Ignore)] - public List? CryptographicBindingMethodsSupported { get; set; } - - /// - /// Gets or sets a list of identifiers for the signing algorithms that are supported by the issuer and used - /// to sign credentials. - /// - [JsonProperty("credential_signing_alg_values_supported", NullValueHandling = NullValueHandling.Ignore)] - public List? CredentialSigningAlgValuesSupported { get; set; } - - /// - /// A list of claim display names, arranged in the order in which they should be displayed by the Wallet. - /// - [JsonProperty("order", NullValueHandling = NullValueHandling.Ignore)] - public List? Order { get; set; } - - /// - /// Gets or sets the identifier for the format of the credential. - /// - [JsonProperty("format")] - public string Format { get; set; } = null!; - - /// - /// Gets or sets the unique identifier for the respective credential. - /// - [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] - public string? Id { get; set; } - - /// - /// Gets or sets a dictionary which maps a credential type to its supported signing algorithms for key proofs. - /// - [JsonProperty("proof_types_supported", NullValueHandling = NullValueHandling.Ignore)] - public Dictionary? ProofTypesSupported { get; set; } - } - - /// - /// Represents credential type specific signing algorithm information. - /// - public class CredentialProofType - { - /// - /// Gets or sets the available signing algorithms for the associated credential type. - /// - [JsonProperty("proof_signing_alg_values_supported")] - public string[] ProofSigningAlgValuesSupported { get; set; } = null!; - } -} diff --git a/src/WalletFramework.SdJwtVc/Persistence/SdJwtCredentialRecord.cs b/src/WalletFramework.SdJwtVc/Persistence/SdJwtCredentialRecord.cs index b938e35d..89a5f668 100644 --- a/src/WalletFramework.SdJwtVc/Persistence/SdJwtCredentialRecord.cs +++ b/src/WalletFramework.SdJwtVc/Persistence/SdJwtCredentialRecord.cs @@ -3,7 +3,6 @@ using WalletFramework.Core.Credentials; using WalletFramework.Core.Functional; using WalletFramework.SdJwtLib.Models; -using WalletFramework.SdJwtVc.Models.Credential; using WalletFramework.Storage.Records; namespace WalletFramework.SdJwtVc.Persistence; @@ -24,8 +23,6 @@ public record SdJwtCredentialRecord : RecordBase public string Vct { get; init; } - public string? DisplaysJson { get; init; } - public string? ClaimsJson { get; init; } public string? DisclosuresJson { get; init; } @@ -48,9 +45,6 @@ public SdJwtCredentialRecord(SdJwtCredential credential) : base(Guid.Parse(crede ExpiresAt = credential.ExpiresAt.MatchUnsafe( x => x, () => (DateTime?)null); - DisplaysJson = credential.Displays.MatchUnsafe( - JsonConvert.SerializeObject, - () => null); ClaimsJson = JsonConvert.SerializeObject(credential.Claims); DisclosuresJson = JsonConvert.SerializeObject(credential.Disclosures); } @@ -63,13 +57,9 @@ public SdJwtCredential ToDomainModel() var state = Enum.Parse(CredentialState); var expires = ExpiresAt is null ? Option.None : Option.Some(ExpiresAt.Value); - var displaysOption = string.IsNullOrWhiteSpace(DisplaysJson) - ? Option>.None - : JsonConvert.DeserializeObject>(DisplaysJson!); - var disclosures = string.IsNullOrWhiteSpace(DisclosuresJson) ? [] - : JsonConvert.DeserializeObject>(DisclosuresJson!) ?? new List(); + : JsonConvert.DeserializeObject>(DisclosuresJson!) ?? []; var serializedSdJwtWithDisclosures = EncodedIssuerSignedJwt + (disclosures.Count > 0 ? "~" + string.Join("~", disclosures) + "~" : "~"); @@ -80,7 +70,6 @@ public SdJwtCredential ToDomainModel() sdJwtDoc, credentialId, setId, - displaysOption, keyId, state, OneTimeUse, diff --git a/src/WalletFramework.SdJwtVc/Persistence/SdJwtCredentialRecordConfiguration.cs b/src/WalletFramework.SdJwtVc/Persistence/SdJwtCredentialRecordConfiguration.cs index d3572cb0..0c3e786a 100644 --- a/src/WalletFramework.SdJwtVc/Persistence/SdJwtCredentialRecordConfiguration.cs +++ b/src/WalletFramework.SdJwtVc/Persistence/SdJwtCredentialRecordConfiguration.cs @@ -10,6 +10,7 @@ public Unit Configure(ModelBuilder modelBuilder) { var entity = modelBuilder.Entity(); entity.HasIndex(r => r.Vct); + entity.HasIndex(r => r.CredentialSetId); return Unit.Default; } diff --git a/src/WalletFramework.SdJwtVc/SdJwtCredential.cs b/src/WalletFramework.SdJwtVc/SdJwtCredential.cs index ae7fb555..9ae36bba 100644 --- a/src/WalletFramework.SdJwtVc/SdJwtCredential.cs +++ b/src/WalletFramework.SdJwtVc/SdJwtCredential.cs @@ -9,8 +9,6 @@ using WalletFramework.Core.StatusList; using WalletFramework.SdJwtLib.Models; using WalletFramework.SdJwtVc.Models; -using WalletFramework.SdJwtVc.Models.Credential; -using WalletFramework.SdJwtVc.Models.Credential.Attributes; namespace WalletFramework.SdJwtVc; @@ -37,13 +35,6 @@ public record SdJwtCredential : ICredential public Option NotBefore { get; init; } = Option.None; - public Option> DisplayedAttributes { get; } = - Option>.None; - - public Option> Displays { get; init; } = Option>.None; - - public Option> AttributeOrder { get; } = Option>.None; - public Option StatusListEntry { get; init; } = Option.None; public string EncodedIssuerSignedJwt { get; init; } = string.Empty; @@ -59,7 +50,6 @@ public SdJwtCredential( SdJwtDoc sdJwtDoc, CredentialId credentialId, CredentialSetId credentialSetId, - Option> displays, Option keyId, CredentialState credentialState, bool oneTimeUse, @@ -69,7 +59,6 @@ public SdJwtCredential( SdJwtDoc = sdJwtDoc; CredentialId = credentialId; CredentialSetId = credentialSetId; - Displays = displays; var vctValue = sdJwtDoc.UnsecuredPayload.SelectToken("vct")?.Value() ?? throw new ArgumentNullException(nameof(Vct), "vct claim is missing or null"); Vct = Vct.ValidVct(vctValue).UnwrapOrThrow(); diff --git a/test/WalletFramework.Core.Tests/Path/ClaimPathTests.cs b/test/WalletFramework.Core.Tests/Path/ClaimPathTests.cs index c2b98d19..e25f5d8c 100644 --- a/test/WalletFramework.Core.Tests/Path/ClaimPathTests.cs +++ b/test/WalletFramework.Core.Tests/Path/ClaimPathTests.cs @@ -21,10 +21,13 @@ public void Can_Create_ClaimPath() } [Theory] - [InlineData(new[] {"name"}, "$.name")] - [InlineData(new[] {"address"}, "$.address")] - [InlineData(new[] {"address", "street_address"}, "$.address.street_address")] - [InlineData(new[] {"degree", null}, "$.degree")] + [InlineData(new object[] {"name"}, "$.name")] + [InlineData(new object[] {"address"}, "$.address")] + [InlineData(new object[] {"address", "street_address"}, "$.address.street_address")] + [InlineData(new object?[] {"degree", null}, "$.degree[*]")] + [InlineData(new object?[] {"degree", null, "type"}, "$.degree[*].type")] + [InlineData(new object[] {"degree", 1}, "$.degree[1]")] + [InlineData(new object[] {"degree", 1, "type"}, "$.degree[1].type")] public void Can_Convert_ClaimPath_To_JsonPath(object[] path, string expectedResult) { var jArray = new JArray(path); diff --git a/test/WalletFramework.Integration.Tests/WalletFramework.Integration.Tests/Oid4Vp/Dcql/DcqlServiceTests.cs b/test/WalletFramework.Integration.Tests/WalletFramework.Integration.Tests/Oid4Vp/Dcql/DcqlServiceTests.cs index 7ed95392..a9469fd3 100644 --- a/test/WalletFramework.Integration.Tests/WalletFramework.Integration.Tests/Oid4Vp/Dcql/DcqlServiceTests.cs +++ b/test/WalletFramework.Integration.Tests/WalletFramework.Integration.Tests/Oid4Vp/Dcql/DcqlServiceTests.cs @@ -17,8 +17,6 @@ using WalletFramework.Oid4Vc.Tests.Samples; using WalletFramework.SdJwtVc; using WalletFramework.SdJwtLib.Roles.Implementation; -using WalletFramework.SdJwtVc.Models.Credential; -using WalletFramework.SdJwtVc.Models.Credential.Attributes; using WalletFramework.SdJwtVc.Persistence; using WalletFramework.Storage; @@ -243,7 +241,6 @@ private static SdJwtCredential CreateCredential(JObject payload, CredentialSetId issuedSdJwt, CredentialId.CreateCredentialId(), credentialSetId, - Option>.None, keyId, CredentialState.Active, false, diff --git a/test/WalletFramework.Integration.Tests/WalletFramework.Integration.Tests/Oid4Vp/PresentationExchange/Services/PexServiceTests.cs b/test/WalletFramework.Integration.Tests/WalletFramework.Integration.Tests/Oid4Vp/PresentationExchange/Services/PexServiceTests.cs index 9d7e717f..5027b076 100644 --- a/test/WalletFramework.Integration.Tests/WalletFramework.Integration.Tests/Oid4Vp/PresentationExchange/Services/PexServiceTests.cs +++ b/test/WalletFramework.Integration.Tests/WalletFramework.Integration.Tests/Oid4Vp/PresentationExchange/Services/PexServiceTests.cs @@ -18,7 +18,6 @@ using WalletFramework.Oid4Vc.Tests.Samples; using WalletFramework.SdJwtLib.Roles.Implementation; using WalletFramework.SdJwtVc; -using WalletFramework.SdJwtVc.Models.Credential; using WalletFramework.SdJwtVc.Persistence; using WalletFramework.Storage; @@ -341,7 +340,6 @@ private static SdJwtCredential CreateCredential(JObject payload, CredentialSetId issuedSdJwt, CredentialId.CreateCredentialId(), credentialSetId, - Option>.None, keyId, CredentialState.Active, false, diff --git a/test/WalletFramework.MdocVc.Tests/MdocCredentialTests.cs b/test/WalletFramework.MdocVc.Tests/MdocCredentialTests.cs index aff70020..dd9d1763 100644 --- a/test/WalletFramework.MdocVc.Tests/MdocCredentialTests.cs +++ b/test/WalletFramework.MdocVc.Tests/MdocCredentialTests.cs @@ -7,7 +7,6 @@ using FluentAssertions; using Newtonsoft.Json.Linq; using LanguageExt; -using WalletFramework.MdocVc.Display; using WalletFramework.MdocVc.Persistence; using Xunit; @@ -27,7 +26,6 @@ public void Can_Serialize_MdocCredential() mdoc, credentialId, credentialSetId, - Option>.None, keyId, CredentialState.Active, false, @@ -90,7 +88,6 @@ public void Can_Map_To_Record() mdoc, credentialId, credentialSetId, - Option>.None, keyId, CredentialState.Active, false, @@ -122,7 +119,6 @@ public void Can_Map_From_Record() mdoc, credentialId, credentialSetId, - Option>.None, keyId, CredentialState.Active, false, diff --git a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/AuthFlow/Samples/AuthFlowSamples.cs b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/AuthFlow/Samples/AuthFlowSamples.cs new file mode 100644 index 00000000..e69de29b diff --git a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/Mdoc/MdocConfigurationTests.cs b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/Mdoc/MdocConfigurationTests.cs index 51e09c4e..84a4e4ba 100644 --- a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/Mdoc/MdocConfigurationTests.cs +++ b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/Mdoc/MdocConfigurationTests.cs @@ -39,20 +39,6 @@ public void Can_Parse() sut.CryptographicCurvesSupported.Match( list => list.Should().Contain(MdocConfigurationSample.CryptoCurve), () => Assert.Fail("CryptographicCurvesSupported must be some")); - - sut.Claims.Match( - claims => - { - var dict = claims.Value[MdocConfigurationSample.NameSpace]; - dict[MdocConfigurationSample.GivenName].Display.Match( - list => - { - list.Should().Contain(MdocConfigurationSample.EnglishDisplay); - list.Should().Contain(MdocConfigurationSample.JapaneseDisplay); - }, - () => Assert.Fail("Display must be some")); - }, - () => Assert.Fail("Claims must be some")); }, _ => Assert.Fail("Must be valid") ); diff --git a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/Mdoc/Samples/MdocConfigurationSample.cs b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/Mdoc/Samples/MdocConfigurationSample.cs index d3b19d82..f20f7487 100644 --- a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/Mdoc/Samples/MdocConfigurationSample.cs +++ b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/Mdoc/Samples/MdocConfigurationSample.cs @@ -51,29 +51,7 @@ public static class MdocConfigurationSample ["batch_size"] = BatchSize }, ["cryptographic_suites_supported"] = new JArray { CryptoSuite.ToString() }, - ["cryptographic_curves_supported"] = new JArray { CryptoCurve.ToString() }, - ["claims"] = new JObject - { - [NameSpace] = new JObject - { - [GivenName] = new JObject - { - ["display"] = new JArray - { - new JObject - { - ["name"] = EnglishName.ToString(), - ["locale"] = LocaleSample.English.ToString() - }, - new JObject - { - ["name"] = JapaneseName.ToString(), - ["locale"] = LocaleSample.Japanese.ToString() - } - } - } - } - } + ["cryptographic_curves_supported"] = new JArray { CryptoCurve.ToString() } }; public static NameSpace NameSpace => diff --git a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/SdJwt/Samples/SdJwtConfigurationSample.cs b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/SdJwt/Samples/SdJwtConfigurationSample.cs index da5f29fa..ef16c9ce 100644 --- a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/SdJwt/Samples/SdJwtConfigurationSample.cs +++ b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/CredConfiguration/SdJwt/Samples/SdJwtConfigurationSample.cs @@ -19,285 +19,194 @@ public static class SdJwtConfigurationSample .OptionalScope("VerifiedEMailSdJwtVc") .ToNullable() ?? throw new InvalidOperationException(); - public static JObject ValidDraft15 => new() + public static JObject ValidSample => new() { ["format"] = Format.ToString(), ["scope"] = Scope.ToString(), ["cryptographic_binding_methods_supported"] = new JArray { "jwk" }, ["credential_signing_alg_values_supported"] = new JArray { "ES256" }, - ["display"] = new JArray + ["proof_types_supported"] = new JObject { - new JObject { - ["name"] = "Verified e-mail adress", - ["logo"] = new JObject + "jwt", new JObject { - ["uri"] = "https://test-issuer.com/credential-logo.png" - }, - ["background_color"] = "#12107c", - ["text_color"] = "#FFFFFF", - ["locale"] = "en-US" + ["proof_signing_alg_values_supported"] = new JArray { "ES256" } + } } }, - ["vct"] = Vct.ToString(), - ["claims"] = new JArray() + ["credential_metadata"] = new JObject { - new JObject - { - ["path"] = new JArray(){"given_name"}, - ["display"] = new JArray - { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "Vorname" - }, - new JObject - { - ["locale"] = "en-US", - ["name"] = "Given name" - } - } - }, - new JObject + ["display"] = new JArray { - ["path"] = new JArray(){"family_name"}, - ["display"] = new JArray + new JObject { - new JObject + ["name"] = "Verified e-mail adress", + ["logo"] = new JObject { - ["locale"] = "de-DE", - ["name"] = "Nachname" + ["uri"] = "https://test-issuer.com/credential-logo.png" }, - new JObject - { - ["locale"] = "en-US", - ["name"] = "Surname" - } - } - }, - new JObject - { - ["path"] = new JArray(){"email"}, - ["display"] = new JArray - { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "E-Mail Adresse" - }, - new JObject - { - ["locale"] = "en-US", - ["name"] = "e-Mail address" - } + ["background_color"] = "#12107c", + ["text_color"] = "#FFFFFF", + ["locale"] = "en-US" } }, - new JObject + ["claims"] = new JArray() { - ["path"] = new JArray(){"address" }, - ["display"] = new JArray + new JObject { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "Adresse" - }, - new JObject - { - ["locale"] = "en-US", - ["name"] = "Address" - } - } - }, - new JObject - { - ["path"] = new JArray(){"address", "street"}, - ["display"] = new JArray - { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "Straße" - }, - new JObject - { - ["locale"] = "en-US", - ["name"] = "Street" - } - } - }, - new JObject - { - ["path"] = new JArray(){"address", "zip"}, - ["display"] = new JArray - { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "Postleitzahl" - }, - new JObject + ["path"] = new JArray(){"given_name"}, + ["display"] = new JArray { - ["locale"] = "en-US", - ["name"] = "Zip Code" + new JObject + { + ["locale"] = "de-DE", + ["name"] = "Vorname" + }, + new JObject + { + ["locale"] = "en-US", + ["name"] = "Given name" + } } - } - }, - new JObject - { - ["path"] = new JArray(){"address", "zip", "building"}, - ["display"] = new JArray + }, + new JObject { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "Gebäude" - }, - new JObject + ["path"] = new JArray(){"family_name"}, + ["display"] = new JArray { - ["locale"] = "en-US", - ["name"] = "Building" + new JObject + { + ["locale"] = "de-DE", + ["name"] = "Nachname" + }, + new JObject + { + ["locale"] = "en-US", + ["name"] = "Surname" + } } - } - } - } - }; - public static JObject ValidDraft14AndLower => new() - { - ["format"] = Format.ToString(), - ["scope"] = Scope.ToString(), - ["cryptographic_binding_methods_supported"] = new JArray { "jwk" }, - ["credential_signing_alg_values_supported"] = new JArray { "ES256" }, - ["display"] = new JArray - { - new JObject - { - ["name"] = "Verified e-mail adress", - ["logo"] = new JObject - { - ["uri"] = "https://test-issuer.com/credential-logo.png" }, - ["background_color"] = "#12107c", - ["text_color"] = "#FFFFFF", - ["locale"] = "en-US" - } - }, - ["vct"] = Vct.ToString(), - ["claims"] = new JObject - { - ["given_name"] = new JObject - { - ["display"] = new JArray + new JObject { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "Vorname" - }, - new JObject + ["path"] = new JArray(){"email"}, + ["display"] = new JArray { - ["locale"] = "en-US", - ["name"] = "Given name" + new JObject + { + ["locale"] = "de-DE", + ["name"] = "E-Mail Adresse" + }, + new JObject + { + ["locale"] = "en-US", + ["name"] = "e-Mail address" + } } - } - }, - ["family_name"] = new JObject - { - ["display"] = new JArray + }, + new JObject { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "Nachname" - }, - new JObject + ["path"] = new JArray(){"address" }, + ["display"] = new JArray { - ["locale"] = "en-US", - ["name"] = "Surname" + new JObject + { + ["locale"] = "de-DE", + ["name"] = "Adresse" + }, + new JObject + { + ["locale"] = "en-US", + ["name"] = "Address" + } } - } - }, - ["email"] = new JObject - { - ["display"] = new JArray + }, + new JObject { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "E-Mail Adresse" - }, - new JObject + ["path"] = new JArray(){"address", "street"}, + ["display"] = new JArray { - ["locale"] = "en-US", - ["name"] = "e-Mail address" + new JObject + { + ["locale"] = "de-DE", + ["name"] = "Straße" + }, + new JObject + { + ["locale"] = "en-US", + ["name"] = "Street" + } } - } - }, - ["address"] = new JObject - { - ["display"] = new JArray + }, + new JObject { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "Adresse" - }, - new JObject + ["path"] = new JArray(){"address", "zip"}, + ["display"] = new JArray { - ["locale"] = "en-US", - ["name"] = "Address" + new JObject + { + ["locale"] = "de-DE", + ["name"] = "Postleitzahl" + }, + new JObject + { + ["locale"] = "en-US", + ["name"] = "Zip Code" + } } }, - ["street"] = new JObject + new JObject { + ["path"] = new JArray(){"address", "zip", "building"}, ["display"] = new JArray { new JObject { ["locale"] = "de-DE", - ["name"] = "Straße" + ["name"] = "Gebäude" }, new JObject { ["locale"] = "en-US", - ["name"] = "Street" + ["name"] = "Building" } } }, - ["zip"] = new JObject + new JObject { + ["path"] = new JArray(){"degrees"}, ["display"] = new JArray { new JObject { ["locale"] = "de-DE", - ["name"] = "Postleitzahl" + ["name"] = "Abschlüsse" }, new JObject { ["locale"] = "en-US", - ["name"] = "Zip Code" + ["name"] = "Degrees" } - }, - ["building"] = new JObject + } + }, + new JObject + { + ["path"] = new JArray(){"degrees", JValue.CreateNull(), "type"}, + ["display"] = new JArray { - ["display"] = new JArray + new JObject { - new JObject - { - ["locale"] = "de-DE", - ["name"] = "Gebäude" - }, - new JObject - { - ["locale"] = "en-US", - ["name"] = "Building" - } + ["locale"] = "de-DE", + ["name"] = "Typ" + }, + new JObject + { + ["locale"] = "en-US", + ["name"] = "Type" } } } } - } + }, + ["vct"] = Vct.ToString() }; } diff --git a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/Issuer/IssuerMetadataTests.cs b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/Issuer/IssuerMetadataTests.cs index f06f068f..8a730f81 100644 --- a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/Issuer/IssuerMetadataTests.cs +++ b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/Issuer/IssuerMetadataTests.cs @@ -11,10 +11,10 @@ namespace WalletFramework.Oid4Vc.Tests.Oid4Vci.Issuer; public class IssuerMetadataTests { [Fact] - public void Can_Decode_Draft14_From_Json() + public void Can_Decode_From_Json() { // Arrange - var sample = IssuerMetadataSample.EncodedAsJsonDraft14AndLower; + var sample = IssuerMetadataSample.EncodedAsJson; // Act ValidIssuerMetadata(sample).Match( @@ -44,18 +44,18 @@ public void Can_Decode_Draft14_From_Json() [Fact] public void Can_Encode_To_Json() { - var issuerMetadata = IssuerMetadataSample.DecodedDraft14AndLower; + var issuerMetadata = IssuerMetadataSample.Decoded; var sut = issuerMetadata.EncodeToJson(); - sut.Should().BeEquivalentTo(IssuerMetadataSample.EncodedAsJsonDraft14AndLower); + sut.Should().BeEquivalentTo(IssuerMetadataSample.EncodedAsJson); } [Fact] - public void Can_Decode_And_Encode_From_Json_Draft14() + public void Can_Decode_And_Encode_From_Json() { // Arrange - var sample = IssuerMetadataSample.EncodedAsJsonDraft14AndLower; + var sample = IssuerMetadataSample.EncodedAsJson; // Act ValidIssuerMetadata(sample).Match( @@ -67,22 +67,4 @@ public void Can_Decode_And_Encode_From_Json_Draft14() }, _ => Assert.Fail("IssuerMetadata must be valid")); } - - [Fact] - public void Can_Decode_And_Encode_ClaimMetadata_From_Json_Draft15() - { - // Arrange - var sampleDraft15 = IssuerMetadataSample.EncodedAsJsonDraft15; - - // Act - ValidIssuerMetadata(sampleDraft15).Match( - // Assert - issuerMetadata => - { - ValidIssuerMetadata(issuerMetadata.EncodeToJson()).UnwrapOrThrow().CredentialConfigurationsSupported[IssuerMetadataSample.SdJwtConfigurationId].AsT0.Claims - .Should() - .BeEquivalentTo(issuerMetadata.CredentialConfigurationsSupported[IssuerMetadataSample.SdJwtConfigurationId].AsT0.Claims); - }, - _ => Assert.Fail("IssuerMetadata must be valid")); - } } diff --git a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/Issuer/Samples/IssuerMetadataSample.cs b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/Issuer/Samples/IssuerMetadataSample.cs index fbcc23d1..eb58d087 100644 --- a/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/Issuer/Samples/IssuerMetadataSample.cs +++ b/test/WalletFramework.Oid4Vc.Tests/Oid4Vci/Issuer/Samples/IssuerMetadataSample.cs @@ -22,7 +22,7 @@ public static class IssuerMetadataSample .ValidCredentialConfigurationId(SdJwtConfigurationSample.Scope.ToString()) .UnwrapOrThrow(new InvalidOperationException()); - public static JObject EncodedAsJsonDraft14AndLower => new() + public static JObject EncodedAsJson => new() { ["credential_issuer"] = CredentialIssuer.ToStringWithoutTrail(), ["credential_endpoint"] = CredentialEndpoint.ToStringWithoutTrail(), @@ -50,7 +50,7 @@ public static class IssuerMetadataSample ["authorization_servers"] = new JArray { "https://test-issuer.com/authorizationserver" }, ["credential_configurations_supported"] = new JObject { - [SdJwtConfigurationId] = SdJwtConfigurationSample.ValidDraft14AndLower, + [SdJwtConfigurationId] = SdJwtConfigurationSample.ValidSample, [MdocConfigurationId] = MdocConfigurationSample.Valid }, ["batch_credential_issuance"] = new JObject @@ -59,43 +59,6 @@ public static class IssuerMetadataSample } }; - public static JObject EncodedAsJsonDraft15 => new() - { - ["credential_issuer"] = CredentialIssuer.ToStringWithoutTrail(), - ["credential_endpoint"] = CredentialEndpoint.ToStringWithoutTrail(), - ["display"] = new JArray - { - new JObject - { - ["name"] = "Test Company GmbH", - ["logo"] = new JObject - { - { "uri", "https://test-issuer.com/logo.png" } - }, - ["locale"] = "en-US" - }, - new JObject - { - ["name"] = "Test Company GmbH", - ["logo"] = new JObject - { - { "uri", "https://test-issuer.com/logo.png" } - }, - ["locale"] = "de-DE" - } - }, - ["authorization_servers"] = new JArray { "https://test-issuer.com/authorizationserver" }, - ["credential_configurations_supported"] = new JObject - { - [SdJwtConfigurationId] = SdJwtConfigurationSample.ValidDraft15, - [MdocConfigurationId] = MdocConfigurationSample.Valid - }, - ["batch_credential_issuance"] = new JObject - { - ["batch_size"] = 5 - } - }; - - public static IssuerMetadata DecodedDraft14AndLower => - IssuerMetadata.ValidIssuerMetadata(EncodedAsJsonDraft14AndLower).UnwrapOrThrow(new InvalidOperationException()); + public static IssuerMetadata Decoded => + IssuerMetadata.ValidIssuerMetadata(EncodedAsJson).UnwrapOrThrow(new InvalidOperationException()); } diff --git a/test/WalletFramework.Oid4Vc.Tests/Oid4Vp/Dcql/DcqlFindingCandidatesTests.cs b/test/WalletFramework.Oid4Vc.Tests/Oid4Vp/Dcql/DcqlFindingCandidatesTests.cs index 244185bb..767c110e 100644 --- a/test/WalletFramework.Oid4Vc.Tests/Oid4Vp/Dcql/DcqlFindingCandidatesTests.cs +++ b/test/WalletFramework.Oid4Vc.Tests/Oid4Vp/Dcql/DcqlFindingCandidatesTests.cs @@ -5,7 +5,6 @@ using WalletFramework.Core.Functional; using WalletFramework.MdocLib; using WalletFramework.MdocVc; -using WalletFramework.MdocVc.Display; using WalletFramework.Oid4Vc.Oid4Vp.Models; using WalletFramework.Oid4Vc.Tests.Oid4Vp.Dcql.Samples; using WalletFramework.Oid4Vc.Tests.Samples; @@ -312,7 +311,7 @@ private MdocCredential GetMdocCredentialSample() var credentialState = CredentialState.Active; var oneTimeUse = false; - var mdocCredential = new MdocCredential(mdoc, credentialId, credentialSetId, Option>.None, keyId, credentialState, oneTimeUse, Option.None); + var mdocCredential = new MdocCredential(mdoc, credentialId, credentialSetId, keyId, credentialState, oneTimeUse, Option.None); return mdocCredential; } diff --git a/test/WalletFramework.Oid4Vc.Tests/Samples/SdJwtSamples.cs b/test/WalletFramework.Oid4Vc.Tests/Samples/SdJwtSamples.cs index 6941cb40..96c8c0b8 100644 --- a/test/WalletFramework.Oid4Vc.Tests/Samples/SdJwtSamples.cs +++ b/test/WalletFramework.Oid4Vc.Tests/Samples/SdJwtSamples.cs @@ -3,7 +3,6 @@ using WalletFramework.Core.Cryptography.Models; using WalletFramework.SdJwtLib.Models; using WalletFramework.SdJwtVc; -using WalletFramework.SdJwtVc.Models.Credential; namespace WalletFramework.Oid4Vc.Tests.Samples; @@ -17,7 +16,6 @@ public static SdJwtCredential GetIdCardCredential() sdJwtDoc, CredentialId.CreateCredentialId(), CredentialSetId.CreateCredentialSetId(), - Option>.None, KeyId.CreateKeyId(), CredentialState.Active, false, @@ -34,7 +32,6 @@ public static SdJwtCredential GetIdCard2Credential() sdJwtDoc, CredentialId.CreateCredentialId(), CredentialSetId.CreateCredentialSetId(), - Option>.None, KeyId.CreateKeyId(), CredentialState.Active, false, @@ -51,7 +48,6 @@ public static SdJwtCredential GetIdCard3Credential() sdJwtDoc, CredentialId.CreateCredentialId(), CredentialSetId.CreateCredentialSetId(), - Option>.None, KeyId.CreateKeyId(), CredentialState.Active, false, diff --git a/test/WalletFramework.SdJwtVc.Tests/SdJwtRecordTests.cs b/test/WalletFramework.SdJwtVc.Tests/SdJwtRecordTests.cs new file mode 100644 index 00000000..e69de29b diff --git a/test/WalletFramework.SdJwtVc.Tests/SdJwtVcHolderServiceTests.cs b/test/WalletFramework.SdJwtVc.Tests/SdJwtVcHolderServiceTests.cs index 7c42f5e8..552c11e7 100644 --- a/test/WalletFramework.SdJwtVc.Tests/SdJwtVcHolderServiceTests.cs +++ b/test/WalletFramework.SdJwtVc.Tests/SdJwtVcHolderServiceTests.cs @@ -5,8 +5,6 @@ using WalletFramework.SdJwtLib.Models; using WalletFramework.SdJwtLib.Roles; using WalletFramework.SdJwtLib.Roles.Implementation; -using WalletFramework.SdJwtVc.Models.Credential; -using WalletFramework.SdJwtVc.Models.Credential.Attributes; using WalletFramework.SdJwtVc.Services.SdJwtVcHolderService; namespace WalletFramework.SdJwtVc.Tests; @@ -38,7 +36,6 @@ public async Task Can_Create_Presentation_For_Example_4A() sdJwtDoc, credentialId, credentialSetId, - Option>.None, keyId, CredentialState.Active, false, diff --git a/test/WalletFramework.Storage.Tests/MdocCredentialRecordCrudTests.cs b/test/WalletFramework.Storage.Tests/MdocCredentialRecordCrudTests.cs index 61707c16..3c7cc96d 100644 --- a/test/WalletFramework.Storage.Tests/MdocCredentialRecordCrudTests.cs +++ b/test/WalletFramework.Storage.Tests/MdocCredentialRecordCrudTests.cs @@ -7,7 +7,6 @@ using WalletFramework.Core.Functional; using WalletFramework.MdocLib; using WalletFramework.MdocVc; -using WalletFramework.MdocVc.Display; using WalletFramework.MdocVc.Persistence; using WalletFramework.Storage.Database; using WalletFramework.TestSamples; @@ -36,7 +35,6 @@ public async Task Can_Store_And_Retrieve_MdocCredentialRecord() var mdoc = Mdoc.ValidMdoc(encodedMdoc).UnwrapOrThrow(); var mdocCredential = mdoc.ToMdocCredential( - Option>.None, KeyId.CreateKeyId(), CredentialSetId.CreateCredentialSetId(), CredentialState.Active, @@ -79,7 +77,6 @@ public async Task Can_Update_MdocCredentialRecord() var keyId = KeyId.CreateKeyId(); var initial = mdoc.ToMdocCredential( - Option>.None, keyId, credentialSetId, CredentialState.Active, @@ -91,7 +88,6 @@ public async Task Can_Update_MdocCredentialRecord() // Act var updated = mdoc.ToMdocCredential( - Option>.None, keyId, credentialSetId, CredentialState.Revoked, @@ -133,7 +129,6 @@ public async Task Can_Delete_MdocCredentialRecord() var keyId = KeyId.CreateKeyId(); var mdocCredential = mdoc.ToMdocCredential( - Option>.None, keyId, credentialSetId, CredentialState.Active, @@ -169,7 +164,6 @@ public async Task Can_Delete_MdocCredentialRecord_By_Domain() var keyId = KeyId.CreateKeyId(); var mdocCredential = mdoc.ToMdocCredential( - Option>.None, keyId, credentialSetId, CredentialState.Active, @@ -205,8 +199,8 @@ public async Task Can_ListAll_MdocCredentialRecords() var csid = CredentialSetId.CreateCredentialSetId(); var kid = KeyId.CreateKeyId(); - var cred1 = mdoc.ToMdocCredential(Option>.None, kid, csid, CredentialState.Active, false, Option.None, id1); - var cred2 = mdoc.ToMdocCredential(Option>.None, kid, csid, CredentialState.Active, false, Option.None, id2); + var cred1 = mdoc.ToMdocCredential(kid, csid, CredentialState.Active, false, Option.None, id1); + var cred2 = mdoc.ToMdocCredential(kid, csid, CredentialState.Active, false, Option.None, id2); await repository.Add(cred1); await repository.Add(cred2); @@ -241,8 +235,8 @@ public async Task Can_Find_MdocCredentialRecords_By_DocType() var csid = CredentialSetId.CreateCredentialSetId(); var kid = KeyId.CreateKeyId(); - var cred1 = mdoc.ToMdocCredential(Option>.None, kid, csid, CredentialState.Active, false, Option.None, CredentialId.CreateCredentialId()); - var cred2 = mdoc.ToMdocCredential(Option>.None, kid, csid, CredentialState.Active, false, Option.None, CredentialId.CreateCredentialId()); + var cred1 = mdoc.ToMdocCredential(kid, csid, CredentialState.Active, false, Option.None, CredentialId.CreateCredentialId()); + var cred2 = mdoc.ToMdocCredential(kid, csid, CredentialState.Active, false, Option.None, CredentialId.CreateCredentialId()); await repository.Add(cred1); await repository.Add(cred2); @@ -277,7 +271,7 @@ public async Task Can_Find_MdocCredentialRecords_By_NonExistent_DocType_Returns_ var csid = CredentialSetId.CreateCredentialSetId(); var kid = KeyId.CreateKeyId(); - var cred1 = mdoc.ToMdocCredential(Option>.None, kid, csid, CredentialState.Active, false, Option.None, CredentialId.CreateCredentialId()); + var cred1 = mdoc.ToMdocCredential(kid, csid, CredentialState.Active, false, Option.None, CredentialId.CreateCredentialId()); await repository.Add(cred1); diff --git a/test/WalletFramework.Storage.Tests/SdJwtCredentialRecordCrudTests.cs b/test/WalletFramework.Storage.Tests/SdJwtCredentialRecordCrudTests.cs index 97f850a1..554d6c72 100644 --- a/test/WalletFramework.Storage.Tests/SdJwtCredentialRecordCrudTests.cs +++ b/test/WalletFramework.Storage.Tests/SdJwtCredentialRecordCrudTests.cs @@ -6,7 +6,6 @@ using WalletFramework.SdJwtLib.Models; using WalletFramework.SdJwtVc; using WalletFramework.Storage.Database; -using WalletFramework.SdJwtVc.Models.Credential; using WalletFramework.SdJwtVc.Persistence; namespace WalletFramework.Storage.Tests; @@ -40,7 +39,6 @@ public async Task Can_Store_And_Retrieve_SdJwtCredentialRecord() sdJwtDoc, credentialId, credentialSetId, - Option>.None, keyId, CredentialState.Active, false, @@ -84,7 +82,6 @@ public async Task Can_Delete_SdJwtCredentialRecord_By_Domain() sdJwtDoc, credentialId, credentialSetId, - Option>.None, keyId, CredentialState.Active, false,