mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-19 23:53:17 -05:00
chore(passkey): use error codes in passkey client actions (#5831)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
committed by
Alex Yang
co-authored by
Alex Yang
parent
974449f113
commit
d5a6b024f4
@@ -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",
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
});
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user