MasterKale / SimpleWebAuthn

WebAuthn, Simplified. A collection of TypeScript-first libraries for simpler WebAuthn integration. Supports modern browsers, Node, Deno, and more.
https://simplewebauthn.dev
MIT License
1.62k stars 137 forks source link

Fixed generateAuthenticationOptions #524

Closed H3RSKO closed 9 months ago

H3RSKO commented 9 months ago

As discussed here and here, even though we are storing credentialID as a base64Url, the generateAuthenticationOptions function requires it to be a buffer, and then converts it back to a base64Url.

This PR adds the ability to generateAuthenticationOptions to check if it is a string (i.e base64Url) and if it is will return it as is, if it is not a string (i.e it is a buffer) it will go through the existing conversion of buffer to base64Url. This allows users who are storing credentialID as a base64Url (which is recommended), to pass it in directly to generateAuthenticationOptions without having to convert it to a buffer first.

MasterKale commented 9 months ago

Thank you for the contribution @H3RSKO, but I'm closing this because I'll be solving this problem more comprehensively as part of addressing #528 (which was inspired by your PR.)