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

Closed
opened 2026-04-15 21:31:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5831
Author: @DevDuki
Created: 11/7/2025
Status: Merged
Merged: 3/11/2026
Merged by: @himself65

Base: canaryHead: refactor/user-error-codes-in-passkey-client-actions


📝 Commits (4)

  • ac8a8f4 chore(refactor)(passkey): use error codes in passkey client actions
  • def0eb2 chore(refactor)(passkey): return data in try block instead of error at the end of the action
  • 0b2d2f0 chore(refactor)(passkey): export PASSKEY_ERROR_CODES
  • dbb77bd fix(passkey): preserve original error message for unknown errors

📊 Changes

3 files changed (+11 additions, -4 deletions)

View changed files

📝 packages/passkey/src/client.ts (+5 -4)
📝 packages/passkey/src/error-codes.ts (+4 -0)
📝 packages/passkey/src/index.ts (+2 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5831 **Author:** [@DevDuki](https://github.com/DevDuki) **Created:** 11/7/2025 **Status:** ✅ Merged **Merged:** 3/11/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `refactor/user-error-codes-in-passkey-client-actions` --- ### 📝 Commits (4) - [`ac8a8f4`](https://github.com/better-auth/better-auth/commit/ac8a8f4b93a54e993d233be3da604e73e46fbc4a) chore(refactor)(passkey): use error codes in passkey client actions - [`def0eb2`](https://github.com/better-auth/better-auth/commit/def0eb2d81dc91785642a04cf7494ab27c3e21ff) chore(refactor)(passkey): return data in try block instead of error at the end of the action - [`0b2d2f0`](https://github.com/better-auth/better-auth/commit/0b2d2f04ad3fc20b9ed021dbe965885a6daacd8b) chore(refactor)(passkey): export PASSKEY_ERROR_CODES - [`dbb77bd`](https://github.com/better-auth/better-auth/commit/dbb77bd3608250b3335a7c995a1a23faa5212d65) fix(passkey): preserve original error message for unknown errors ### 📊 Changes **3 files changed** (+11 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/passkey/src/client.ts` (+5 -4) 📝 `packages/passkey/src/error-codes.ts` (+4 -0) 📝 `packages/passkey/src/index.ts` (+2 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 21:31:21 -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#23159