Coder Social home page Coder Social logo

Return more nuanced errors about webauthn HOT 3 OPEN

MasterKale avatar MasterKale commented on July 28, 2024
Return more nuanced errors

from webauthn.

Comments (3)

stephenmcgruer avatar stephenmcgruer commented on July 28, 2024 1

Fortunately, TimeoutError already exists, and OptOutError seems like a suitable match for UserCancelledError. The others are trickier to find existing matches for, though.

As a note, we added OptOutError very recently for a specific use-case we had in Secure Payment Confirmation that didn't seem to be covered by existing DOMException types. That is, the WHATWG is open to adding new DOMException names, so please don't feel constricted by that!

from webauthn.

MasterKale avatar MasterKale commented on July 28, 2024

I've created an Explainer here to help communicate more of the intent behind the proposed new error codes:

https://github.com/w3c/webauthn/wiki/Explainer:-New-Error-Codes-(2024-Edition)

from webauthn.

emlun avatar emlun commented on July 28, 2024

Without judgement of the proposed errors, some spec formalia: currently, most WebAuthn errors are instances of DOMException with different names. The DOMException names table section of the WebIDL spec states that:

When creating or throwing a DOMException, specifications must use one of these names. If a specification author believes none of these names are a good fit for their case, they must file an issue to discuss adding a new name to the shared namespace [...]

So if we're going to continue using DOMException for all of these errors (I currently don't know any arguments for nor against it), we may need to pick from the already existing names, or generalize the error names enough that they can be upstreamed and useful in other contexts.

Fortunately, TimeoutError already exists, and OptOutError seems like a suitable match for UserCancelledError. The others are trickier to find existing matches for, though.

As summarized in #2047 (thanks!), the errors we already use are AbortError, ConstraintError, InvalidStateError, NotAllowedError, NotSupportedError, SecurityError and UnknownError (hm, turns out TypeError is not a DOMException but a simple exception). Adding TimeoutError and OptOutError to that, and removing deprecated names, the remaining ones are:

  • DataCloneError: The object can not be cloned.
  • DataError: Provided data is inadequate.
  • EncodingError: The encoding operation (either encoded or decoding) failed.
  • HierarchyRequestError: The operation would yield an incorrect node tree.
  • InUseAttributeError: The attribute is in use by another element.
  • InvalidCharacterError: The string contains invalid characters.
  • InvalidModificationError: The object can not be modified in this way.
  • InvalidNodeTypeError: The supplied node is incorrect or has an incorrect ancestor for this operation.
  • NamespaceError: The operation is not allowed by Namespaces in XML.
  • NetworkError: A network error occurred.
  • NoModificationAllowedError: The object can not be modified.
  • NotFoundError: The object can not be found here.
  • NotReadableError: The I/O read operation failed.
  • OperationError: The operation failed for an operation-specific reason.
  • QuotaExceededError: The quota has been exceeded.
  • ReadOnlyError: The mutating operation was attempted in a "readonly" transaction.
  • SyntaxError: The string did not match the expected pattern.
  • TransactionInactiveError: A request was placed against a transaction which is currently not active, or which is finished.
  • VersionError: An attempt was made to open a database using a lower version than the existing version.
  • WrongDocumentError: The object is in the wrong document.

I don't think any of these are good matches for HybridPrerequisitesError, UserHybridCancelError or UserVerificationError. The only somewhat-applicable one would be OperationError, but only because it's so unspecific it could apply to anything.

So maybe we need to use DOMException derived interfaces for these errors? Maybe a WebAuthenticationError with an enum-like DOMString cause attribute, for example.

from webauthn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.