Skip to content

Commit c2f384d

Browse files
authored
Rename extensions to clientExtensionResults (#485)
* Rename `extensions` to `clientExtensionResults` * Update WebAuthn.ts
1 parent 31a4f94 commit c2f384d

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

Src/Fido2.BlazorWebAssembly/wwwroot/js/WebAuthn.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function createCreds(options: PublicKeyCredentialCreationOptions) {
2929
id: base64StringToUrl(newCreds.id),
3030
rawId: toBase64Url(newCreds.rawId),
3131
type: newCreds.type,
32-
extensions: newCreds.getClientExtensionResults(),
32+
clientExtensionResults: newCreds.getClientExtensionResults(),
3333
response: {
3434
attestationObject: toBase64Url(response.attestationObject),
3535
clientDataJSON: toBase64Url(response.clientDataJSON),
@@ -55,6 +55,7 @@ export async function verify(options: PublicKeyCredentialRequestOptions) {
5555
id: creds.id,
5656
rawId: toBase64Url(creds.rawId),
5757
type: creds.type,
58+
clientExtensionResults: creds.getClientExtensionResults(),
5859
response: {
5960
authenticatorData: toBase64Url(response.authenticatorData),
6061
clientDataJSON: toBase64Url(response.clientDataJSON),

Src/Fido2.Models/AuthenticatorAttestationRawResponse.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ public sealed class AuthenticatorAttestationRawResponse
2121
public AttestationResponse Response { get; set; }
2222

2323
[JsonPropertyName("extensions")]
24-
public AuthenticationExtensionsClientOutputs Extensions { get; set; }
24+
[Obsolete("Use ClientExtensionResults instead")]
25+
public AuthenticationExtensionsClientOutputs Extensions
26+
{
27+
get => ClientExtensionResults;
28+
set => ClientExtensionResults = value;
29+
}
30+
31+
[JsonPropertyName("clientExtensionResults")]
32+
public AuthenticationExtensionsClientOutputs ClientExtensionResults { get; set; }
2533

2634
public sealed class AttestationResponse
2735
{

Src/Fido2/AuthenticatorAttestationResponse.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ public async Task<RegisteredPublicKeyCredential> VerifyAsync(
123123
// TODO?: Implement sort of like this: ClientExtensions.Keys.Any(x => options.extensions.contains(x);
124124
byte[]? devicePublicKeyResult = null;
125125

126-
if (Raw.Extensions?.DevicePubKey is not null)
126+
if (Raw.ClientExtensionResults?.DevicePubKey is not null)
127127
{
128-
devicePublicKeyResult = await DevicePublicKeyRegistrationAsync(config, metadataService, Raw.Extensions, AttestationObject.AuthData, clientDataHash, cancellationToken).ConfigureAwait(false);
128+
devicePublicKeyResult = await DevicePublicKeyRegistrationAsync(config, metadataService, Raw.ClientExtensionResults, AttestationObject.AuthData, clientDataHash, cancellationToken).ConfigureAwait(false);
129129
}
130130

131131
// 19. Determine the attestation statement format by performing a USASCII case-sensitive match on fmt

Test/AuthenticatorResponse.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public void TestAuthenticatorAttestationRawResponse()
253253
AttestationObject = new CborMap().Encode(),
254254
ClientDataJson = clientDataJson
255255
},
256-
Extensions = new AuthenticationExtensionsClientOutputs
256+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
257257
{
258258
AppID = true,
259259
Extensions = new string[] { "foo", "bar" },
@@ -281,13 +281,13 @@ public void TestAuthenticatorAttestationRawResponse()
281281
Assert.Equal(new byte[] { 0xf1, 0xd0 }, rawResponse.RawId);
282282
Assert.Equal(new byte[] { 0xa0 }, rawResponse.Response.AttestationObject);
283283
Assert.Equal(clientDataJson, rawResponse.Response.ClientDataJson);
284-
Assert.True(rawResponse.Extensions.AppID);
285-
Assert.Equal(new string[] { "foo", "bar" }, rawResponse.Extensions.Extensions);
286-
Assert.Equal("test", rawResponse.Extensions.Example);
287-
Assert.Equal((ulong)4, rawResponse.Extensions.UserVerificationMethod[0][0]);
288-
Assert.True(rawResponse.Extensions.PRF.Enabled);
289-
Assert.Equal(rawResponse.Extensions.PRF.Results.First, new byte[] { 0xf1, 0xd0 });
290-
Assert.Equal(new byte[] { 0xf1, 0xd0 }, rawResponse.Extensions.PRF.Results.Second);
284+
Assert.True(rawResponse.ClientExtensionResults.AppID);
285+
Assert.Equal(new string[] { "foo", "bar" }, rawResponse.ClientExtensionResults.Extensions);
286+
Assert.Equal("test", rawResponse.ClientExtensionResults.Example);
287+
Assert.Equal((ulong)4, rawResponse.ClientExtensionResults.UserVerificationMethod[0][0]);
288+
Assert.True(rawResponse.ClientExtensionResults.PRF.Enabled);
289+
Assert.Equal(rawResponse.ClientExtensionResults.PRF.Results.First, new byte[] { 0xf1, 0xd0 });
290+
Assert.Equal(new byte[] { 0xf1, 0xd0 }, rawResponse.ClientExtensionResults.PRF.Results.Second);
291291
}
292292

293293
[Fact]

Test/Fido2Tests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public async Task<MakeNewCredentialResult> MakeAttestationResponseAsync()
165165
ClientDataJson = _clientDataJson,
166166
Transports = new[] { AuthenticatorTransport.Internal }
167167
},
168-
Extensions = new AuthenticationExtensionsClientOutputs()
168+
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
169169
{
170170
AppID = true,
171171
Extensions = new string[] { "foo", "bar" },

0 commit comments

Comments
 (0)