TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

Change return type of CredentialsContainer.create for WebAuthn

Open asmsuechan opened this issue 1 year ago • 5 comments

Hi developers,

The return value for CredentialsContainer.create is one of FederatedCredential, PasswordCredential, and PublicKeyCredential according to https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer/create#return_value

The return types are subclass of Credential. So I changed using PublicKeyCredential from Credential. Note that FederatedCredential and PasswordCredential haven't been implemented yet, therefore, I didn't use them. I'll also try to create them after I learn the manners of this repo.

Thank you for reading my PR.

asmsuechan avatar Jun 19 '24 14:06 asmsuechan

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

github-actions[bot] avatar Jun 19 '24 14:06 github-actions[bot]

@microsoft-github-policy-service agree

asmsuechan avatar Jun 19 '24 14:06 asmsuechan

This can be a problem when other types of credentials come, maybe there should be additional overload based on the value of credential?

saschanaz avatar Jun 19 '24 17:06 saschanaz

@saschanaz Thank you for your comment! Yes, what you say is true. Promise<PublicKeyCredential | FederatedCredential | PasswordCredential | null> is the correct interface. However, FederatedCredential and PasswordCredential are not yet implemented. So I added only PublicKeyCredential because it's better than the current implementation Promise<Credential | null>.

If it's unacceptable, I'll add the other interfaces above in this PR. I would love to know the manners of this repo first.

asmsuechan avatar Jun 20 '24 11:06 asmsuechan

Oops, FederatedCredential and PasswordCredential are supported only by Chrome.

check whether it's supported by two or more browser engines

According to the sentence, they don't meet the qualification.

  • https://github.com/mdn/browser-compat-data/blob/main/api/FederatedCredential.json
  • https://github.com/mdn/browser-compat-data/blob/main/api/PasswordCredential.json

So, Promise<Credential | PublicKeyCredential | null> is better for now?

asmsuechan avatar Jun 20 '24 12:06 asmsuechan