import { BaseError, type TErrorMetadata } from '@pawells/typescript-common'; /** * Error metadata type for {@link AuthError}. */ type TAuthErrorMetadata = TErrorMetadata & { readonly code: string; }; /** * Domain error class for all authentication failures raised by `@pawells/react-auth`. * * Extends `BaseError` to provide a machine-readable `code` (via the inherited `Code` * getter) and an optional `cause` chain (via the inherited `Cause` getter), replacing * ad hoc string-literal codes passed directly to `BaseError` at each throw site. * * @example * ```typescript * throw new AuthError('UserManager not initialized', { * code: AuthError.Code.USERMANAGER_NOT_INITIALIZED * }); * ``` */ export declare class AuthError extends BaseError { /** * Enumeration of `@pawells/react-auth` error codes for classification and debugging. * * - `AUTH_ERROR` — Generic auth-state failure surfaced via `applyError` * - `USERMANAGER_NOT_INITIALIZED` — An action was invoked before the `UserManager` was ready * - `OUTSIDE_PROVIDER` — `useAuth` was called outside of an `AuthProvider` * - `APOLLO_AUTH_LINK_ERROR` — The Apollo Link auth integration failed to attach a token */ static readonly Code: Readonly<{ readonly AUTH_ERROR: "AUTH_ERROR"; readonly USERMANAGER_NOT_INITIALIZED: "USERMANAGER_NOT_INITIALIZED"; readonly OUTSIDE_PROVIDER: "OUTSIDE_PROVIDER"; readonly APOLLO_AUTH_LINK_ERROR: "APOLLO_AUTH_LINK_ERROR"; }>; /** * Creates a new AuthError instance with a code, message, and optional cause chain. * * @param message - Human-readable error message describing the auth failure * @param options - Optional configuration object * @param options.code - One of {@link AuthError.Code}; defaults to `AUTH_ERROR` * @param options.cause - Original error to chain for root cause analysis * * @example * ```typescript * try { * // attempt operation * } catch (originalError) { * throw new AuthError('Silent renewal failed', { * code: AuthError.Code.AUTH_ERROR, * cause: originalError instanceof Error ? originalError : undefined * }); * } * ``` */ constructor(message: string, options?: { code?: (typeof AuthError.Code)[keyof typeof AuthError.Code]; cause?: Error; }); } export {}; //# sourceMappingURL=auth.error.d.ts.map