diff --git a/packages/passkey/src/client.ts b/packages/passkey/src/client.ts index 10922321cf..2ea1db37ba 100644 --- a/packages/passkey/src/client.ts +++ b/packages/passkey/src/client.ts @@ -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", }, diff --git a/packages/passkey/src/error-codes.ts b/packages/passkey/src/error-codes.ts index bf724ae2d2..12ba1e3887 100644 --- a/packages/passkey/src/error-codes.ts +++ b/packages/passkey/src/error-codes.ts @@ -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", }); diff --git a/packages/passkey/src/index.ts b/packages/passkey/src/index.ts index 1f61327d28..97d4d3605f 100644 --- a/packages/passkey/src/index.ts +++ b/packages/passkey/src/index.ts @@ -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) => {