ui-auth/dist/useAuthModal.d.ts
autocommit 55daa6ed6a chore: initial package split from monorepo
Package: @lilith/ui-auth
Split from: lilith/ui.git or lilith/build.git
Publish workflow: calls lilith/workflows/.forgejo/workflows/publish-npm.yml@main
2026-04-20 01:10:50 -07:00

51 lines
No EOL
1.8 KiB
TypeScript

/**
* useAuthModal Hook
*
* Convenience hook for managing AuthModal state.
* Handles open/close, mode switching, and auth callbacks.
*
* Supports two integration modes via options:
* 1. Direct SSO: Provide ssoUrl option
* 2. Provider-based: Provide authHandler option
*/
import type { AuthModalMode, User, RegistrationRole, AuthHandler } from './types';
export interface UseAuthModalOptions {
/** SSO server URL - for direct SSO mode */
ssoUrl?: string;
/** Auth handler for provider-based integration - alternative to ssoUrl */
authHandler?: AuthHandler;
/** Initial mode when modal opens */
initialMode?: AuthModalMode;
/** Default role for registration */
defaultRole?: RegistrationRole;
/** Called after successful auth */
onSuccess?: (user: User, sessionId: string) => void;
/** Called on auth error */
onError?: (error: Error) => void;
}
export interface UseAuthModalReturn {
/** Whether modal is open */
isOpen: boolean;
/** Current mode (login or register) */
mode: AuthModalMode;
/** Default role for registration */
defaultRole: RegistrationRole | undefined;
/** SSO URL (pass-through from options) */
ssoUrl: string | undefined;
/** Auth handler (pass-through from options) */
authHandler: AuthHandler | undefined;
/** Open modal in login mode */
openLogin: () => void;
/** Open modal in register mode */
openRegister: (role?: RegistrationRole) => void;
/** Close modal */
close: () => void;
/** Toggle modal */
toggle: () => void;
/** Handle auth success */
handleSuccess: (user: User, sessionId: string) => void;
/** Handle auth error */
handleError: (error: Error) => void;
}
export declare function useAuthModal(options?: UseAuthModalOptions): UseAuthModalReturn;
//# sourceMappingURL=useAuthModal.d.ts.map