Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New PublicKeyCredential methods for JSON (de)serialization #1703
New PublicKeyCredential methods for JSON (de)serialization #1703
Changes from 22 commits
59ecbf3
493095f
e87c96d
bec86b5
002d0f5
a476667
161e102
16aab08
d264b61
c1aef27
e11e518
91161a2
1161328
f13cb35
bfa21b0
4a904af
078e432
c0c9454
22a796c
6fa0da7
592271d
408b323
582b2e2
ae3a7d4
b1b5fd1
88bd8fb
12e5071
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about, instead of separate
RegistrationResponseJSON
andAuthenticationResponseJSON
type, we have a singlePublicKeyCredentialJSON
dictionary type with an AuthenticatorResponseJSON member, withtypedef (AuthenticatorAttestationResponseJSON or AuthenticatorAssertionResponseJSON) AuthenticatorResponseJSON
?That would be more akin to how the regular
PublicKeyCredential
is defined.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's frustrating to me that
PublicKeyCredential
has been overloaded to mean two possible data structures, sinceresponse
can be one of two types. I think this is a current developer pain point, that there aren't subclasses ofPublicKeyCredential
coming out of.create()
and.get()
to be uniquely typed. That's why I've been trying to emphasize the idea of "RegistrationResponse
" and "AuthenticationResponse
" here, to get to a 1:1 mapping betweennavigator.credentials
method and return type.To the suggestion that a
PublicKeyCredentialJSON
gets defined as a union type, is it a compromise to make it easier for the client to implement this feature? I personally want to see these additions err on the side of better developer usability, and necessarily see this as hoisting some of this complexity onto the client. The aim is to make it easier for devs to consume WebAuthn, and to achieve this I think we should be more straightforward/explicit with return types.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kreichgauer It's been a few weeks, what do you currently think about my response above to your
PublicKeyCredentialJSON
suggestion?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the slow reply.
No, I think it makes no difference implementation wise, and if it did that would not be a convincing argument as you point out.
I agree with the desire to aid developers as much as we can, and I agree that the structure of the API with create() and get() returning the same interface type but encapsulating two different response dictionary types is…awkward. (It's a side effect of having WebAuthn bolted on top of Credential Management, but our developers/users shouldn't care about that.) However, I'm kind of on the fence whether I find the separate inheritance hierarchy for JSON serialization more or less confusing. I guess it depends on whether you think the hypothetical WebAuthn developer would first look at the PublicKeyCredential interface IDL or not? If they did, comparing the two and realizing that they're different in weird subtle ways (beyond the binary->base64url conversion) I think could be a bit puzzling? If on the other hand, we'd assume the hypothetical developer would only ever see the JSON IDL, I agree what you propose would be simpler to grok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kreichgauer Can we leave comments in IDL definitions? I want to believe a developer who doesn't want to get too deep into things will jump to these JSON methods, but it's probably more realistic that they'd stumble on
PublicKeyCredential
first and then the JSON IDL. If we could leave comments in the JSON IDL explaining why there are split types then perhaps we can have the best of both worlds.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, IDL can contain comments. The syntax is the same as in JavaScript.