Repository: go-webauthn/webauthn (go)

Issue:
UserEntity.DisplayName should not have omitempty
### Version

0.9.1

### Description

> Its value’s [name](https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name), [displayName](https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname) and [id](https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-id) members are REQUIRED.

but when a user is registering for the first time the RP might not require the user to enter their name and the displayName might be empty, which would then get omitted and cause an error in JavaScript when calling `navigator.credentials.create`.

### Reproduction

1. Create a user with an empty displayName
2. Pass user to `wa.BeginRegistration`.
3. Encode the result as JSON
4. Pass to `navigator.credentials.create`

### Expectations

Expectation is that the resulting JSON would contain `displayName: ''` but instead `displayName` is undefined.

### Documentation

https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-user

Pull request description:
fix(protocol): display name omitted incorrectly
This fixes an issue where the displayName value for a user entity was omitted in error. See https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialcreationoptions-user and https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialuserentity (and the same links for level 2).

Fixes #183

Patch:
diff --git a/protocol/entities.go b/protocol/entities.go
index 814e608..1d2f6e8 100644
--- a/protocol/entities.go
+++ b/protocol/entities.go
@@ -45,7 +45,7 @@ type UserEntity struct {
 	// A human-palatable name for the user account, intended only for display.
 	// For example, "Alex P. Müller" or "田中 倫". The Relying Party SHOULD let
 	// the user choose this, and SHOULD NOT restrict the choice more than necessary.
-	DisplayName string `json:"displayName,omitempty"`
+	DisplayName string `json:"displayName"`
 
 	// ID is the user handle of the user account entity. To ensure secure operation,
 	// authentication and authorization decisions MUST be made on the basis of this id


Test patch:
diff --git a/webauthn/registration_test.go b/webauthn/registration_test.go
index ed689ab..a2c597d 100644
--- a/webauthn/registration_test.go
+++ b/webauthn/registration_test.go
@@ -35,8 +35,8 @@ func TestEntityEncoding(t *testing.T) {
 		b64            bool
 		have, expected string
 	}{
-		{"ShouldEncodeBase64", true, "abc", "{\"name\":\"\",\"id\":\"YWJj\"}"},
-		{"ShouldEncodeString", false, "abc", "{\"name\":\"\",\"id\":\"abc\"}"},
+		{"ShouldEncodeBase64", true, "abc", `{"name":"","displayName":"","id":"YWJj"}`},
+		{"ShouldEncodeString", false, "abc", `{"name":"","displayName":"","id":"abc"}`},
 	}
 
 	for _, tc := range testCases {