Skip to content

Commit 97a5d5c

Browse files
committed
RpId is not optional
1 parent 99a6e5b commit 97a5d5c

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

dotnet/src/webdriver/VirtualAuth/Credential.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public sealed class Credential
3434
private readonly byte[] id;
3535
private readonly byte[]? userHandle;
3636

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)
3838
{
3939
this.id = id ?? throw new ArgumentNullException(nameof(id));
4040
this.IsResidentCredential = isResidentCredential;
41-
this.RpId = rpId;
41+
this.RpId = rpId ?? throw new ArgumentNullException(nameof(rpId));
4242
this.PrivateKey = privateKey ?? throw new ArgumentNullException(nameof(privateKey));
4343
this.userHandle = userHandle;
4444
this.SignCount = signCount;
@@ -52,7 +52,7 @@ private Credential(byte[] id, bool isResidentCredential, string? rpId, string pr
5252
/// <param name="privateKey">The private Key for the credentials.</param>
5353
/// <param name="signCount">The signature counter for the credentials.</param>
5454
/// <returns>The created instance of the Credential class.</returns>
55-
/// <exception cref="ArgumentNullException">If <paramref name="id"/> or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
55+
/// <exception cref="ArgumentNullException">If <paramref name="id"/>, <paramref name="rpId"/>, or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
5656
public static Credential CreateNonResidentCredential(byte[] id, string rpId, string privateKey, int signCount)
5757
{
5858
return new Credential(id, false, rpId, privateKey, null, signCount);
@@ -67,7 +67,7 @@ public static Credential CreateNonResidentCredential(byte[] id, string rpId, str
6767
/// <param name="userHandle">The user handle associated to the credential.</param>
6868
/// <param name="signCount">The signature counter for the credentials.</param>
6969
/// <returns>The created instance of the Credential class.</returns>
70-
/// <exception cref="ArgumentNullException">If <paramref name="id"/> or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
70+
/// <exception cref="ArgumentNullException">If <paramref name="id"/>, <paramref name="rpId"/>, or <paramref name="privateKey"/> are <see langword="null"/>.</exception>
7171
public static Credential CreateResidentCredential(byte[] id, string rpId, string privateKey, byte[] userHandle, int signCount)
7272
{
7373
return new Credential(id, true, rpId, privateKey, userHandle, signCount);
@@ -86,7 +86,7 @@ public static Credential CreateResidentCredential(byte[] id, string rpId, string
8686
/// <summary>
8787
/// Gets the ID of the relying party of this credential.
8888
/// </summary>
89-
public string? RpId { get; }
89+
public string RpId { get; }
9090

9191
/// <summary>
9292
/// Gets the private key of the credential.
@@ -130,11 +130,7 @@ public Dictionary<string, object> ToDictionary()
130130

131131
toReturn["credentialId"] = Base64UrlEncoder.Encode(this.id);
132132
toReturn["isResidentCredential"] = this.IsResidentCredential;
133-
if (this.RpId is not null)
134-
{
135-
toReturn["rpId"] = this.RpId;
136-
}
137-
133+
toReturn["rpId"] = this.RpId;
138134
toReturn["privateKey"] = this.PrivateKey;
139135
toReturn["signCount"] = this.SignCount;
140136
if (this.userHandle is not null)

0 commit comments

Comments
 (0)