import { ReactNode, ReactElement } from 'react'; import { ZyphrClient } from '@zyphr-dev/node-sdk'; import { LoginParams, TokenStorage, SessionState, AuthTransport } from '@zyphr-dev/auth-core'; export { LoginParams, SessionState, SessionStatus, TokenStorage } from '@zyphr-dev/auth-core'; interface ZyphrAuthProviderProps { /** A client-safe ZyphrClient (constructed with your publishable application key). */ client: ZyphrClient; /** Override token storage. Defaults to localStorage (with an in-memory fallback). */ storage?: TokenStorage; /** * Namespace the storage key so multiple providers can share one storage * adapter without colliding (e.g. one session per account). The effective key * becomes `${keyPrefix}zyphr.session`. Default `''`. */ keyPrefix?: string; /** Refresh this many ms before the access token expires. Default 60_000 (from auth-core). */ refreshSkewMs?: number; children: ReactNode; } /** * Provides a reactive Zyphr auth session to the React tree. Constructs a single * {@link SessionManager} (from `@zyphr-dev/auth-core`) driven by the given * ZyphrClient, initializes it (adopting any persisted session), and cleans up on * unmount. Read state with {@link useSession}; act with {@link useAuth}. */ declare function ZyphrAuthProvider({ client, storage, keyPrefix, refreshSkewMs, children, }: ZyphrAuthProviderProps): ReactElement; /** * Reactive session state — re-renders on every session change (login, logout, * refresh). Returns `{ status, accessToken, isAuthenticated }`. */ declare function useSession(): SessionState; interface UseAuthResult { login: (params: LoginParams) => Promise; logout: () => Promise; refresh: () => Promise; } /** Auth actions bound to the provider's session manager. */ declare function useAuth(): UseAuthResult; /** * An {@link AuthTransport} implemented over the client-safe `ZyphrClient` * (publishable application key — no secret). This is what lets the React binding * drive the auth-core session engine against Zyphr's `/auth/*` endpoints. * * `now` is injectable for tests; production uses `Date.now`. */ declare function createZyphrTransport(client: ZyphrClient, now?: () => number): AuthTransport; /** * Web token storage backed by `localStorage`, with a graceful in-memory fallback * when `localStorage` is unavailable (SSR, privacy modes, disabled storage). * * Note on security: `localStorage` is readable by any JS on the page, so it is * vulnerable to XSS token theft. For the strongest posture, proxy auth through * your own backend and keep the refresh token in an httpOnly cookie; use this * adapter for SPAs where that's not feasible, and pass a custom TokenStorage via * `ZyphrAuthProvider` if you have a better store. */ declare function createWebStorage(): TokenStorage; export { type UseAuthResult, ZyphrAuthProvider, type ZyphrAuthProviderProps, createWebStorage, createZyphrTransport, useAuth, useSession };