[PR #5831] chore(passkey): use error codes in passkey client actions #14505

Closed
opened 2026-04-13 09:30:37 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5831

State: closed
Merged: Yes


Just noticed that no error codes were used here, which makes handling i18n of these errors inconsistent compared to other actions. Ofc one could use the WebAuthnErrorCodes but it just feels like a style break and edge cases are still not covered this way.

Also the registerPasskey action had a missing final return because in the try block data is only returned by this if statement:

if (!verified.data) {
  return verified;
}

Which led to an awkward | undefined return type when calling the function in the client. To get rid of the undefined you'd need to do something like this:
const { error } = (await authClient.passkey.addPasskey({ name: passkeyName })) ?? {};

I also noticed that the PASSKEY_ERROR_CODES were not exported. So I also added them.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5831 **State:** closed **Merged:** Yes --- Just noticed that no error codes were used here, which makes handling i18n of these errors inconsistent compared to other actions. Ofc one could use the `WebAuthnErrorCodes` but it just feels like a style break and edge cases are still not covered this way. Also the `registerPasskey` action had a missing final return because in the `try` block data is only returned by this if statement: ``` if (!verified.data) { return verified; } ``` Which led to an awkward `| undefined` return type when calling the function in the client. To get rid of the undefined you'd need to do something like this: `const { error } = (await authClient.passkey.addPasskey({ name: passkeyName })) ?? {};` I also noticed that the `PASSKEY_ERROR_CODES` were not exported. So I also added them.
GiteaMirror added the pull-request label 2026-04-13 09:30:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14505