@@ -34,11 +34,11 @@ public sealed class Credential
34
34
private readonly byte [ ] id ;
35
35
private readonly byte [ ] ? userHandle ;
36
36
37
- private Credential ( byte [ ] id , bool isResidentCredential , string rpId , string privateKey , byte [ ] ? userHandle , int signCount )
37
+ private Credential ( byte [ ] id , bool isResidentCredential , string ? rpId , string privateKey , byte [ ] ? userHandle , int signCount )
38
38
{
39
39
this . id = id ?? throw new ArgumentNullException ( nameof ( id ) ) ;
40
40
this . IsResidentCredential = isResidentCredential ;
41
- this . RpId = rpId ?? throw new ArgumentNullException ( nameof ( rpId ) ) ;
41
+ this . RpId = rpId ;
42
42
this . PrivateKey = privateKey ?? throw new ArgumentNullException ( nameof ( privateKey ) ) ;
43
43
this . userHandle = userHandle ;
44
44
this . SignCount = signCount ;
@@ -52,7 +52,7 @@ private Credential(byte[] id, bool isResidentCredential, string rpId, string pri
52
52
/// <param name="privateKey">The private Key for the credentials.</param>
53
53
/// <param name="signCount">The signature counter for the credentials.</param>
54
54
/// <returns>The created instance of the Credential class.</returns>
55
- /// <exception cref="ArgumentNullException">If <paramref name="id"/>, <paramref name="rpId"/>, or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
55
+ /// <exception cref="ArgumentNullException">If <paramref name="id"/> or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
56
56
public static Credential CreateNonResidentCredential ( byte [ ] id , string rpId , string privateKey , int signCount )
57
57
{
58
58
return new Credential ( id , false , rpId , privateKey , null , signCount ) ;
@@ -67,7 +67,7 @@ public static Credential CreateNonResidentCredential(byte[] id, string rpId, str
67
67
/// <param name="userHandle">The user handle associated to the credential.</param>
68
68
/// <param name="signCount">The signature counter for the credentials.</param>
69
69
/// <returns>The created instance of the Credential class.</returns>
70
- /// <exception cref="ArgumentNullException">If <paramref name="id"/>, <paramref name="rpId"/>, or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
70
+ /// <exception cref="ArgumentNullException">If <paramref name="id"/> or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
71
71
public static Credential CreateResidentCredential ( byte [ ] id , string rpId , string privateKey , byte [ ] userHandle , int signCount )
72
72
{
73
73
return new Credential ( id , true , rpId , privateKey , userHandle , signCount ) ;
@@ -86,7 +86,7 @@ public static Credential CreateResidentCredential(byte[] id, string rpId, string
86
86
/// <summary>
87
87
/// Gets the ID of the relying party of this credential.
88
88
/// </summary>
89
- public string RpId { get ; }
89
+ public string ? RpId { get ; }
90
90
91
91
/// <summary>
92
92
/// Gets the private key of the credential.
@@ -130,7 +130,10 @@ public Dictionary<string, object> ToDictionary()
130
130
131
131
toReturn [ "credentialId" ] = Base64UrlEncoder . Encode ( this . id ) ;
132
132
toReturn [ "isResidentCredential" ] = this . IsResidentCredential ;
133
- toReturn [ "rpId" ] = this . RpId ;
133
+ if ( this . RpId is not null )
134
+ {
135
+ toReturn [ "rpId" ] = this . RpId ;
136
+ }
134
137
toReturn [ "privateKey" ] = this . PrivateKey ;
135
138
toReturn [ "signCount" ] = this . SignCount ;
136
139
if ( this . userHandle is not null )
0 commit comments