Skip to content

Commit

Permalink
Rename extensions to clientExtensionResults (#485)
Browse files Browse the repository at this point in the history
* Rename `extensions` to `clientExtensionResults`

* Update WebAuthn.ts
  • Loading branch information
joegoldman2 committed Jan 5, 2024
1 parent 31a4f94 commit c2f384d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Src/Fido2.BlazorWebAssembly/wwwroot/js/WebAuthn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function createCreds(options: PublicKeyCredentialCreationOptions) {
id: base64StringToUrl(newCreds.id),
rawId: toBase64Url(newCreds.rawId),
type: newCreds.type,
extensions: newCreds.getClientExtensionResults(),
clientExtensionResults: newCreds.getClientExtensionResults(),
response: {
attestationObject: toBase64Url(response.attestationObject),
clientDataJSON: toBase64Url(response.clientDataJSON),
Expand All @@ -55,6 +55,7 @@ export async function verify(options: PublicKeyCredentialRequestOptions) {
id: creds.id,
rawId: toBase64Url(creds.rawId),
type: creds.type,
clientExtensionResults: creds.getClientExtensionResults(),
response: {
authenticatorData: toBase64Url(response.authenticatorData),
clientDataJSON: toBase64Url(response.clientDataJSON),
Expand Down
10 changes: 9 additions & 1 deletion Src/Fido2.Models/AuthenticatorAttestationRawResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ public sealed class AuthenticatorAttestationRawResponse
public AttestationResponse Response { get; set; }

[JsonPropertyName("extensions")]
public AuthenticationExtensionsClientOutputs Extensions { get; set; }
[Obsolete("Use ClientExtensionResults instead")]
public AuthenticationExtensionsClientOutputs Extensions
{
get => ClientExtensionResults;
set => ClientExtensionResults = value;
}

[JsonPropertyName("clientExtensionResults")]
public AuthenticationExtensionsClientOutputs ClientExtensionResults { get; set; }

public sealed class AttestationResponse
{
Expand Down
4 changes: 2 additions & 2 deletions Src/Fido2/AuthenticatorAttestationResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public static AuthenticatorAttestationResponse Parse(AuthenticatorAttestationRaw
// TODO?: Implement sort of like this: ClientExtensions.Keys.Any(x => options.extensions.contains(x);
byte[]? devicePublicKeyResult = null;

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

// 19. Determine the attestation statement format by performing a USASCII case-sensitive match on fmt
Expand Down
16 changes: 8 additions & 8 deletions Test/AuthenticatorResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public void TestAuthenticatorAttestationRawResponse()
AttestationObject = new CborMap().Encode(),
ClientDataJson = clientDataJson
},
Extensions = new AuthenticationExtensionsClientOutputs
ClientExtensionResults = new AuthenticationExtensionsClientOutputs
{
AppID = true,
Extensions = new string[] { "foo", "bar" },
Expand Down Expand Up @@ -281,13 +281,13 @@ public void TestAuthenticatorAttestationRawResponse()
Assert.Equal(new byte[] { 0xf1, 0xd0 }, rawResponse.RawId);
Assert.Equal(new byte[] { 0xa0 }, rawResponse.Response.AttestationObject);
Assert.Equal(clientDataJson, rawResponse.Response.ClientDataJson);
Assert.True(rawResponse.Extensions.AppID);
Assert.Equal(new string[] { "foo", "bar" }, rawResponse.Extensions.Extensions);
Assert.Equal("test", rawResponse.Extensions.Example);
Assert.Equal((ulong)4, rawResponse.Extensions.UserVerificationMethod[0][0]);
Assert.True(rawResponse.Extensions.PRF.Enabled);
Assert.Equal(rawResponse.Extensions.PRF.Results.First, new byte[] { 0xf1, 0xd0 });
Assert.Equal(new byte[] { 0xf1, 0xd0 }, rawResponse.Extensions.PRF.Results.Second);
Assert.True(rawResponse.ClientExtensionResults.AppID);
Assert.Equal(new string[] { "foo", "bar" }, rawResponse.ClientExtensionResults.Extensions);
Assert.Equal("test", rawResponse.ClientExtensionResults.Example);
Assert.Equal((ulong)4, rawResponse.ClientExtensionResults.UserVerificationMethod[0][0]);
Assert.True(rawResponse.ClientExtensionResults.PRF.Enabled);
Assert.Equal(rawResponse.ClientExtensionResults.PRF.Results.First, new byte[] { 0xf1, 0xd0 });
Assert.Equal(new byte[] { 0xf1, 0xd0 }, rawResponse.ClientExtensionResults.PRF.Results.Second);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Test/Fido2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public async Task<MakeNewCredentialResult> MakeAttestationResponseAsync()
ClientDataJson = _clientDataJson,
Transports = new[] { AuthenticatorTransport.Internal }
},
Extensions = new AuthenticationExtensionsClientOutputs()
ClientExtensionResults = new AuthenticationExtensionsClientOutputs()
{
AppID = true,
Extensions = new string[] { "foo", "bar" },
Expand Down

0 comments on commit c2f384d

Please sign in to comment.