Migrate from webauthn-p256 to 0x p256 module (ox)#193
Merged
jeffsmale90 merged 3 commits intomainfrom Mar 26, 2026
Merged
Conversation
- Replace webauthn-p256 dependency with ox@0.8.1 (compatible with viem 2.31.4) - Update webAuthn.ts to use Signature.fromHex from ox instead of parseSignature - Update signer.ts to use WebAuthnAccount types from viem/account-abstraction - Convert test fixtures from DER-encoded to flat r||s hex format (130 chars) - Update signature parsing to use Ox Signature API with strict length validation - Remove webauthn-p256 from both package.json and root devDependencies Resolves #188 and #192 Co-authored-by: jeffsmale90 <jeffsmale90@users.noreply.github.com>
- Reorder imports: ox before viem - Use descriptive variable names (rValue, sValue, normalizedS) - Use object destructuring for Signature.fromHex - Fix formatting in signer.ts encodeSignature function Co-authored-by: jeffsmale90 <jeffsmale90@users.noreply.github.com>
MoMannn
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📝 Description
This PR implements the migration from the deprecated
webauthn-p256package to 0x'soxpackage for handling P256 WebAuthn signatures, addressing breaking changes introduced in viem 2.43.5+.The changes are not breaking.
🔄 What Changed?
webauthn-p256dependency from both@metamask/smart-accounts-kit/package.jsonand rootpackage.jsonox@0.8.1as a direct dependency (version compatible with viem 2.31.4)packages/smart-accounts-kit/src/webAuthn.ts:parseSignaturefromwebauthn-p256withSignature.fromHexfromox/Signaturepackages/smart-accounts-kit/src/signer.ts:SignReturnTypeimport fromwebauthn-p256WebAuthnAccounttype import fromviem/account-abstractionencodeSignaturecallback type to useAwaited<ReturnType<WebAuthnAccount['signMessage']>>test/webAuthn.test.ts: ReplacedparseSignaturewithSignature.fromHextest/signer.test.ts: Updated WebAuthn signature fixturesoximports now appear beforeviemimports per project standards🚀 Why?
webauthn-p256(see issue Viem dependency specification includes breaking changes #188)toWebAuthnAccountalready uses Ox internally and returns signatures in the flat r||s formatSignature.fromHexprovides stricter validation, requiring exact 130 or 132 character hex strings and rejecting DER-encoded signatures🧪 How to Test?
Testing steps:
yarn build:packagesyarn workspace @metamask/smart-accounts-kit testwebauthn-p256references remain:rg 'webauthn-p256' .Note: While the internal implementation changes, this is not a breaking change for consumers of the SDK because:
encodeDeleGatorSignaturestill accepts the same parameters and returns the same formatWebAuthnAccountalready produces signatures in the format Ox expects📋 Checklist
🔗 Related Issues
Closes #188
Closes #192
📚 Additional Notes
Implementation Details
encodeDeleGatorSignatureremains unchanged and continues to work correctly with Ox-parsed signaturesAwaited<ReturnType<WebAuthnAccount['signMessage']>>ensures type compatibility is maintained automatically if Viem's types evolve furtherVerification
All webauthn-p256 references have been removed from the codebase and yarn.lock. The ox package is now properly installed and integrated.
Slack Thread