UNPKG

@ouim/simple-logto

Version:

A simpler way to use @logto/react with prebuilt UI components and hooks for fast authentication setup

94 lines (93 loc) 2.5 kB
import { type ClassValue } from 'clsx'; import type { LogtoUser, NavigationOptions } from './types'; /** * Transform Logto user object to a simpler format */ export declare const transformUser: (logtoUser: any) => LogtoUser | null; /** * Set a custom navigation function (used by AuthProvider) */ export declare const setCustomNavigate: (navigateFn: ((url: string, options?: NavigationOptions) => void) | null) => void; /** * Navigate to a URL, handling both client-side routing and direct navigation * Attempts to use client-side routing first (History API), then falls back to window.location */ export declare const navigateTo: (url: string, options?: NavigationOptions) => void; /** * Get initials from name for avatar fallback */ export declare const getInitials: (name?: string) => string; /** * Cookie management utilities */ export declare const cookieUtils: { /** * Set a cookie with the given name, value, and options */ setCookie: (name: string, value: string, options?: { expires?: Date | number; maxAge?: number; domain?: string; path?: string; secure?: boolean; sameSite?: "strict" | "lax" | "none"; httpOnly?: boolean; }) => void; /** * Get a cookie value by name */ getCookie: (name: string) => string | null; /** * Remove a cookie by name */ removeCookie: (name: string, options?: { domain?: string; path?: string; }) => void; }; /** * Specialized functions for JWT token management */ export declare const jwtCookieUtils: { /** * Save JWT token to cookie */ saveToken: (token: string) => void; /** * Get JWT token from cookie */ getToken: () => string | null; /** * Remove JWT token from cookie */ removeToken: () => void; }; /** * Client-side guest utilities */ export declare const guestUtils: { /** * Generate a fingerprint-based guest ID */ generateGuestId(): Promise<string>; /** * Get guest ID from cookie */ getGuestId(): string | null; /** * Set guest ID cookie */ setGuestId(guestId?: string): Promise<string>; /** * Ensure guest ID exists, create if not */ ensureGuestId(): Promise<string>; /** * Clear guest ID cookie */ clearGuestId(): void; }; /** * Utility function to combine class names (for components) */ export declare function cn(...inputs: ClassValue[]): string;