@dypai-ai/client-sdk - v1.12.0
    Preparing search index...

    Interface UseAuthReturn

    Return type of the useAuth hook.

    interface UseAuthReturn {
        authEvent: string | null;
        createOrganization: (
            name: string,
            slug?: string,
        ) => Promise<{ data: any; error: DypaiError | null }>;
        disableTwoFactor: () => Promise<{ error: DypaiError | null }>;
        enableTwoFactor: () => Promise<
            {
                data: { backupCodes: string[]; totpURI: string }
                | null;
                error: DypaiError | null;
            },
        >;
        inviteMember: (
            orgId: string,
            email: string,
            role?: string,
        ) => Promise<{ error: DypaiError | null }>;
        isAuthenticated: boolean;
        isLoading: boolean;
        isPasswordRecovery: boolean;
        lastError: { code: string; message: string } | null;
        listOrganizations: () => Promise<
            { data: any[]
            | null; error: DypaiError | null },
        >;
        resetPassword: (
            email: string,
            options?: { redirectTo?: string },
        ) => Promise<{ error: DypaiError | null }>;
        setPassword: (password: string) => Promise<{ error: DypaiError | null }>;
        signIn: (
            email: string,
            password: string,
        ) => Promise<{ error: DypaiError | null }>;
        signInWithMagicLink: (
            email: string,
        ) => Promise<{ error: DypaiError | null }>;
        signInWithOAuth: (provider: "google" | "github" | "apple") => Promise<void>;
        signInWithOtp: (email: string) => Promise<{ error: DypaiError | null }>;
        signOut: () => Promise<void>;
        signUp: (
            email: string,
            password: string,
            data?: Record<string, any>,
        ) => Promise<{ confirmationRequired?: boolean; error: DypaiError | null }>;
        user: User | null;
        verifyTwoFactor: (code: string) => Promise<{ error: DypaiError | null }>;
    }
    Index

    Properties

    authEvent: string | null

    Current auth event (SIGNED_IN, PASSWORD_RECOVERY, etc.)

    createOrganization: (
        name: string,
        slug?: string,
    ) => Promise<{ data: any; error: DypaiError | null }>

    Create an organization

    disableTwoFactor: () => Promise<{ error: DypaiError | null }>

    Disable 2FA

    enableTwoFactor: () => Promise<
        {
            data: { backupCodes: string[]; totpURI: string }
            | null;
            error: DypaiError | null;
        },
    >

    Enable 2FA (returns TOTP URI for authenticator app)

    inviteMember: (
        orgId: string,
        email: string,
        role?: string,
    ) => Promise<{ error: DypaiError | null }>

    Invite member to organization

    isAuthenticated: boolean

    Whether user is authenticated

    isLoading: boolean

    Whether auth state is still loading

    isPasswordRecovery: boolean

    Whether the current browser state is a password recovery/invite flow

    lastError: { code: string; message: string } | null

    Last auth error (expired link, etc.)

    listOrganizations: () => Promise<
        { data: any[]
        | null; error: DypaiError | null },
    >

    List user's organizations

    resetPassword: (
        email: string,
        options?: { redirectTo?: string },
    ) => Promise<{ error: DypaiError | null }>

    Send password recovery email

    setPassword: (password: string) => Promise<{ error: DypaiError | null }>

    Set new password (after recovery/invite link)

    signIn: (
        email: string,
        password: string,
    ) => Promise<{ error: DypaiError | null }>

    Sign in with email and password

    signInWithMagicLink: (email: string) => Promise<{ error: DypaiError | null }>

    Sign in with magic link (passwordless)

    signInWithOAuth: (provider: "google" | "github" | "apple") => Promise<void>

    Sign in with OAuth provider

    signInWithOtp: (email: string) => Promise<{ error: DypaiError | null }>

    Sign in with OTP (magic link)

    signOut: () => Promise<void>

    Sign out

    signUp: (
        email: string,
        password: string,
        data?: Record<string, any>,
    ) => Promise<{ confirmationRequired?: boolean; error: DypaiError | null }>

    Sign up with email and password

    user: User | null

    Current authenticated user (null if not logged in)

    verifyTwoFactor: (code: string) => Promise<{ error: DypaiError | null }>

    Verify 2FA code