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

Change error name to reflect the type #191

Closed felixmosh closed 2 years ago

felixmosh commented 2 years ago

fixes #190

MasterKale commented 2 years ago

Hmm, I don't like the idea of calling an error "WebAuthnError" and then allowing for its name to be overridden so error.name would never be "WebAuthnError". The better way to do this is probably to throw basic Error's instead and set the name to the original WebAuthn error so that RPs like you can continue to rely on error.name for detection. Then just drop "WebAuthnError" completely so what the functionality really becomes is an overriding of the description of the error.

MasterKale commented 2 years ago

I experimented with some potential solutions tonight and after hitting a bunch of dead ends I do think your proposed solution is the only way forward. I'm going to request a fix, and once that's done this should be good to merge.

felixmosh commented 2 years ago

I've updated tests, thank you

MasterKale commented 2 years ago

@felixmosh Thank you for your contribution! This is a great improvement to the error detection logic 🚀