chore(passkey): use error codes in passkey client actions (#5831)

Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
Duki
2026-03-13 23:46:35 -07:00
committed by Alex Yang
co-authored by Alex Yang
parent 974449f113
commit d5a6b024f4
3 changed files with 11 additions and 4 deletions
+5 -4
View File
@@ -77,7 +77,7 @@ export const getPasskeyActions = (
data: null,
error: {
code: "AUTH_CANCELLED",
message: "auth cancelled",
message: PASSKEY_ERROR_CODES.AUTH_CANCELLED,
status: 400,
statusText: "BAD_REQUEST",
},
@@ -158,7 +158,7 @@ export const getPasskeyActions = (
data: null,
error: {
code: e.code,
message: "previously registered",
message: PASSKEY_ERROR_CODES.PREVIOUSLY_REGISTERED,
status: 400,
statusText: "BAD_REQUEST",
},
@@ -169,7 +169,7 @@ export const getPasskeyActions = (
data: null,
error: {
code: e.code,
message: "registration cancelled",
message: PASSKEY_ERROR_CODES.REGISTRATION_CANCELLED,
status: 400,
statusText: "BAD_REQUEST",
},
@@ -189,7 +189,8 @@ export const getPasskeyActions = (
data: null,
error: {
code: "UNKNOWN_ERROR",
message: e instanceof Error ? e.message : "unknown error",
message:
e instanceof Error ? e.message : PASSKEY_ERROR_CODES.UNKNOWN_ERROR,
status: 500,
statusText: "INTERNAL_SERVER_ERROR",
},
+4
View File
@@ -9,4 +9,8 @@ export const PASSKEY_ERROR_CODES = defineErrorCodes({
AUTHENTICATION_FAILED: "Authentication failed",
UNABLE_TO_CREATE_SESSION: "Unable to create session",
FAILED_TO_UPDATE_PASSKEY: "Failed to update passkey",
PREVIOUSLY_REGISTERED: "Previously registered",
REGISTRATION_CANCELLED: "Registration cancelled",
AUTH_CANCELLED: "Auth cancelled",
UNKNOWN_ERROR: "Unknown error",
});
+2
View File
@@ -21,6 +21,8 @@ declare module "@better-auth/core" {
}
}
export { PASSKEY_ERROR_CODES } from "./error-codes";
const MAX_AGE_IN_SECONDS = 60 * 5; // 5 minutes
export const passkey = (options?: PasskeyOptions | undefined) => {