replace usage of Node's Buffer with browser-friendly code#72
Conversation
jeffsmale90
left a comment
There was a problem hiding this comment.
Thanks @gabspeck for this, and sorry for taking so long to get to it. We've been heads down on some other things. If I'm not mistaken, this is our first external contribution to the Delegation Toolkit 🎉
This all looks good - can you please just add a test for the "Authenticator flags not found in authenticator data"?
Thanks for the review, test added |
jeffsmale90
left a comment
There was a problem hiding this comment.
Thanks @gabspeck! We will get this out in an update shortly.
📝 Description
This PR makes the
delegation-toolkitpackage compatible with environments where Node.js'sBufferglobal is not available.🔄 What Changed?
List the specific changes made:
packages/delegation-toolkit/src/webAuthn.ts:parseAuthenticatorFlagschanged to use Viem'shexToBytesin combination withUint8Array🚀 Why?
Explain the motivation behind these changes:
toMetaMaskSmartAccountand ran into an error becauseBufferis not defined on the browser.🧪 How to Test?
Describe how to test these changes:
toMetamaskSmartAccount, using the hybrid implementationList any breaking changes:
📋 Checklist
Check off completed items:
🔗 Related Issues
Link to related issues:
Closes #
Related to #
📚 Additional Notes
Any additional information, concerns, or context:
Note
Switches parseAuthenticatorFlags to viem hexToBytes/Uint8Array with a bounds check, and adds a unit test for missing flags.
Bufferusage inparseAuthenticatorFlagswithhexToBytes+Uint8Array; add error when flags byte is missing.webAuthn.test.ts: Add test asserting an error when authenticator flags are not found at the expected offset.Written by Cursor Bugbot for commit 688f14c. This will update automatically on new commits. Configure here.