@bymax-one/nest-auth 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,304 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var shared = require('@bymax-one/nest-auth/shared');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var React__default = /*#__PURE__*/_interopDefault(React);
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
12
+ var AuthContext = React.createContext(null);
13
+
14
+ // src/react/AuthProvider.tsx
15
+ var DEFAULT_REVALIDATE_INTERVAL_MS = 3e5;
16
+ var DEFAULT_TENANT_ID = "default";
17
+ var INITIAL_STATE = {
18
+ user: null,
19
+ status: "loading",
20
+ lastValidation: null
21
+ };
22
+ function authReducer(state, action) {
23
+ switch (action.type) {
24
+ case "SET_USER":
25
+ return {
26
+ user: action.payload.user,
27
+ status: "authenticated",
28
+ lastValidation: action.payload.timestamp
29
+ };
30
+ case "SET_LOADING":
31
+ return {
32
+ ...state,
33
+ status: "loading"
34
+ };
35
+ case "CLEAR_SESSION":
36
+ return {
37
+ user: null,
38
+ status: "unauthenticated",
39
+ lastValidation: null
40
+ };
41
+ case "SET_ERROR":
42
+ return {
43
+ user: null,
44
+ status: "unauthenticated",
45
+ lastValidation: state.lastValidation
46
+ };
47
+ }
48
+ }
49
+ __name(authReducer, "authReducer");
50
+ function isSessionExpiredError(error) {
51
+ return error instanceof shared.AuthClientError && error.status === 401;
52
+ }
53
+ __name(isSessionExpiredError, "isSessionExpiredError");
54
+ function AuthProvider({ children, client, onSessionExpired, revalidateInterval = DEFAULT_REVALIDATE_INTERVAL_MS }) {
55
+ const [state, dispatch] = React.useReducer(authReducer, INITIAL_STATE);
56
+ const onSessionExpiredRef = React.useRef(onSessionExpired);
57
+ const clientRef = React.useRef(client);
58
+ const statusRef = React.useRef(INITIAL_STATE.status);
59
+ React.useEffect(() => {
60
+ onSessionExpiredRef.current = onSessionExpired;
61
+ }, [
62
+ onSessionExpired
63
+ ]);
64
+ React.useEffect(() => {
65
+ clientRef.current = client;
66
+ }, [
67
+ client
68
+ ]);
69
+ const syncedDispatch = React.useCallback((action) => {
70
+ dispatch(action);
71
+ switch (action.type) {
72
+ case "SET_USER":
73
+ statusRef.current = "authenticated";
74
+ return;
75
+ // Stryker disable next-line ConditionalExpression: reducer case label; the SET_LOADING and tick paths are exercised elsewhere and this case's presence does not change the dispatched-state outcome under test
76
+ case "SET_LOADING":
77
+ statusRef.current = "loading";
78
+ return;
79
+ case "CLEAR_SESSION":
80
+ case "SET_ERROR":
81
+ statusRef.current = "unauthenticated";
82
+ return;
83
+ }
84
+ }, []);
85
+ const revalidate = React.useCallback(
86
+ async (isInitial) => {
87
+ try {
88
+ const user = await clientRef.current.getMe();
89
+ syncedDispatch({
90
+ type: "SET_USER",
91
+ payload: {
92
+ user,
93
+ timestamp: /* @__PURE__ */ new Date()
94
+ }
95
+ });
96
+ } catch (error) {
97
+ const wasAuthenticated = statusRef.current === "authenticated";
98
+ if (isSessionExpiredError(error)) {
99
+ if (!isInitial && wasAuthenticated) {
100
+ try {
101
+ onSessionExpiredRef.current?.();
102
+ } catch (callbackError) {
103
+ console.warn("[nest-auth] onSessionExpired callback threw:", callbackError);
104
+ }
105
+ }
106
+ syncedDispatch({
107
+ type: "CLEAR_SESSION"
108
+ });
109
+ return;
110
+ }
111
+ syncedDispatch({
112
+ type: "SET_ERROR"
113
+ });
114
+ }
115
+ },
116
+ // Stryker disable next-line ArrayDeclaration: deps hold only the stable `syncedDispatch`, so emptying the array does not change effect/memo behavior
117
+ [
118
+ syncedDispatch
119
+ ]
120
+ );
121
+ React.useEffect(() => {
122
+ void revalidate(true);
123
+ }, [
124
+ revalidate
125
+ ]);
126
+ React.useEffect(() => {
127
+ if (revalidateInterval <= 0) {
128
+ return void 0;
129
+ }
130
+ const handle = setInterval(() => {
131
+ void revalidate(false);
132
+ }, revalidateInterval);
133
+ return () => {
134
+ clearInterval(handle);
135
+ };
136
+ }, [
137
+ revalidate,
138
+ revalidateInterval
139
+ ]);
140
+ const login = React.useCallback(
141
+ async (email, password, options) => {
142
+ const tenantId = options?.tenantId ?? DEFAULT_TENANT_ID;
143
+ syncedDispatch({
144
+ type: "SET_LOADING"
145
+ });
146
+ try {
147
+ const result = await clientRef.current.login({
148
+ email,
149
+ password,
150
+ tenantId
151
+ });
152
+ if ("mfaRequired" in result) {
153
+ syncedDispatch({
154
+ type: "CLEAR_SESSION"
155
+ });
156
+ return result;
157
+ }
158
+ syncedDispatch({
159
+ type: "SET_USER",
160
+ payload: {
161
+ user: result.user,
162
+ timestamp: /* @__PURE__ */ new Date()
163
+ }
164
+ });
165
+ return result;
166
+ } catch (error) {
167
+ syncedDispatch({
168
+ type: "SET_ERROR"
169
+ });
170
+ throw error;
171
+ }
172
+ },
173
+ // Stryker disable next-line ArrayDeclaration: deps hold only the stable `syncedDispatch`, so emptying the array does not change memoization
174
+ [
175
+ syncedDispatch
176
+ ]
177
+ );
178
+ const register = React.useCallback(
179
+ async (data) => {
180
+ syncedDispatch({
181
+ type: "SET_LOADING"
182
+ });
183
+ try {
184
+ const result = await clientRef.current.register(data);
185
+ syncedDispatch({
186
+ type: "SET_USER",
187
+ payload: {
188
+ user: result.user,
189
+ timestamp: /* @__PURE__ */ new Date()
190
+ }
191
+ });
192
+ return result;
193
+ } catch (error) {
194
+ syncedDispatch({
195
+ type: "SET_ERROR"
196
+ });
197
+ throw error;
198
+ }
199
+ },
200
+ // Stryker disable next-line ArrayDeclaration: deps hold only the stable `syncedDispatch`, so emptying the array does not change memoization
201
+ [
202
+ syncedDispatch
203
+ ]
204
+ );
205
+ const logout = React.useCallback(async () => {
206
+ try {
207
+ await clientRef.current.logout();
208
+ } finally {
209
+ syncedDispatch({
210
+ type: "CLEAR_SESSION"
211
+ });
212
+ }
213
+ }, [
214
+ syncedDispatch
215
+ ]);
216
+ const refresh = React.useCallback(async () => {
217
+ await revalidate(false);
218
+ }, [
219
+ revalidate
220
+ ]);
221
+ const forgotPassword = React.useCallback(
222
+ async (email, tenantId) => {
223
+ await clientRef.current.forgotPassword(email, tenantId ?? DEFAULT_TENANT_ID);
224
+ },
225
+ // Stryker disable next-line ArrayDeclaration: empty deps array with only stable references in scope; a constant-string array re-runs identically
226
+ []
227
+ );
228
+ const resetPassword = React.useCallback(
229
+ async (input) => {
230
+ await clientRef.current.resetPassword(input);
231
+ },
232
+ // Stryker disable next-line ArrayDeclaration: empty deps array with only stable references in scope; a constant-string array re-runs identically
233
+ []
234
+ );
235
+ const value = React.useMemo(() => ({
236
+ user: state.user,
237
+ status: state.status,
238
+ isLoading: state.status === "loading",
239
+ lastValidation: state.lastValidation,
240
+ login,
241
+ register,
242
+ logout,
243
+ refresh,
244
+ forgotPassword,
245
+ resetPassword
246
+ }), [
247
+ state.user,
248
+ state.status,
249
+ state.lastValidation,
250
+ login,
251
+ register,
252
+ logout,
253
+ refresh,
254
+ forgotPassword,
255
+ resetPassword
256
+ ]);
257
+ return /* @__PURE__ */ React__default.default.createElement(AuthContext.Provider, {
258
+ value
259
+ }, children);
260
+ }
261
+ __name(AuthProvider, "AuthProvider");
262
+ function useSession() {
263
+ const ctx = React.useContext(AuthContext);
264
+ if (ctx === null) {
265
+ throw new Error("useSession must be called within an <AuthProvider> \u2014 wrap the consuming tree in a provider built from createAuthClient().");
266
+ }
267
+ return {
268
+ user: ctx.user,
269
+ status: ctx.status,
270
+ isLoading: ctx.isLoading,
271
+ refresh: ctx.refresh,
272
+ lastValidation: ctx.lastValidation
273
+ };
274
+ }
275
+ __name(useSession, "useSession");
276
+ function useAuth() {
277
+ const ctx = React.useContext(AuthContext);
278
+ if (ctx === null) {
279
+ throw new Error("useAuth must be called within an <AuthProvider> \u2014 wrap the consuming tree in a provider built from createAuthClient().");
280
+ }
281
+ return {
282
+ login: ctx.login,
283
+ register: ctx.register,
284
+ logout: ctx.logout,
285
+ forgotPassword: ctx.forgotPassword,
286
+ resetPassword: ctx.resetPassword
287
+ };
288
+ }
289
+ __name(useAuth, "useAuth");
290
+
291
+ // src/react/useAuthStatus.ts
292
+ function useAuthStatus() {
293
+ const { status, isLoading } = useSession();
294
+ return {
295
+ isAuthenticated: status === "authenticated",
296
+ isLoading
297
+ };
298
+ }
299
+ __name(useAuthStatus, "useAuthStatus");
300
+
301
+ exports.AuthProvider = AuthProvider;
302
+ exports.useAuth = useAuth;
303
+ exports.useAuthStatus = useAuthStatus;
304
+ exports.useSession = useSession;
@@ -0,0 +1,342 @@
1
+ import { ReactNode } from 'react';
2
+ import { AuthClient, RegisterInput, ResetPasswordInput } from '@bymax-one/nest-auth/client';
3
+ import { AuthUserClient, LoginResult, AuthResult } from '@bymax-one/nest-auth/shared';
4
+
5
+ /**
6
+ * React provider for @bymax-one/nest-auth.
7
+ *
8
+ * Owns the session state machine (`loading` → `authenticated` /
9
+ * `unauthenticated`), bridges the typed {@link AuthClient} into
10
+ * {@link AuthContext}, and schedules a best-effort revalidation loop
11
+ * so long-lived UIs surface role/status changes without requiring the
12
+ * user to refresh manually.
13
+ *
14
+ * The provider is deliberately thin: it does not parse tokens, touch
15
+ * storage, or decide how the server delivers credentials. Every
16
+ * transport detail lives in the `client` subpath; this file only
17
+ * coordinates state and React plumbing.
18
+ */
19
+
20
+ /**
21
+ * Props accepted by {@link AuthProvider}.
22
+ */
23
+ interface AuthProviderProps {
24
+ /** Rendered inside the provider once state is initialized. */
25
+ children: ReactNode;
26
+ /**
27
+ * Authentication client built via `createAuthClient`. The provider
28
+ * never constructs one itself so test harnesses and SSR shells can
29
+ * inject a mock or a pre-configured instance.
30
+ */
31
+ client: AuthClient;
32
+ /**
33
+ * Fired when the provider detects that the session has expired —
34
+ * i.e. a prior `authenticated` state transitions to
35
+ * `unauthenticated` because `getMe()` or `refresh()` failed with a
36
+ * 401. Typical wiring: redirect to the sign-in page.
37
+ *
38
+ * Not called on the initial mount when no session exists to begin
39
+ * with (that is "not signed in", not "session expired"), nor on
40
+ * explicit {@link AuthContextValue.logout} calls.
41
+ */
42
+ onSessionExpired?: () => void;
43
+ /**
44
+ * Interval (in milliseconds) between automatic revalidations.
45
+ * Default: {@link DEFAULT_REVALIDATE_INTERVAL_MS} (5 minutes).
46
+ *
47
+ * Set to `0` to disable the loop entirely — useful for short-lived
48
+ * flows (sign-up wizards, kiosk screens) where the overhead of a
49
+ * background poll is not worth the freshness guarantee.
50
+ */
51
+ revalidateInterval?: number;
52
+ }
53
+ /**
54
+ * Top-level React provider that wires the auth state machine into the
55
+ * {@link AuthContext}.
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * const client = createAuthClient({ baseUrl: '/api' })
60
+ *
61
+ * export function App() {
62
+ * return (
63
+ * <AuthProvider client={client} onSessionExpired={() => router.push('/sign-in')}>
64
+ * <Routes />
65
+ * </AuthProvider>
66
+ * )
67
+ * }
68
+ * ```
69
+ */
70
+ declare function AuthProvider({ children, client, onSessionExpired, revalidateInterval }: AuthProviderProps): ReactNode;
71
+
72
+ /**
73
+ * Lifecycle state of the authenticated session.
74
+ *
75
+ * - `'loading'` — initial mount or in-flight revalidation; user is unknown.
76
+ * - `'authenticated'` — a valid session exists and `user` is populated.
77
+ * - `'unauthenticated'` — no session; `user` is `null`.
78
+ */
79
+ type AuthStatus = 'authenticated' | 'unauthenticated' | 'loading';
80
+ /**
81
+ * Shape of the value published by {@link AuthContext}.
82
+ *
83
+ * Hooks ({@link useSession}, {@link useAuth}, {@link useAuthStatus}) read
84
+ * from this surface. Method signatures mirror the typed client so callers
85
+ * pass the same arguments they would to `createAuthClient` directly.
86
+ */
87
+ interface AuthContextValue {
88
+ /** Authenticated user, or `null` when there is no session. */
89
+ user: AuthUserClient | null;
90
+ /** Current lifecycle status of the session — see {@link AuthStatus}. */
91
+ status: AuthStatus;
92
+ /**
93
+ * Convenience flag that mirrors `status === 'loading'`. Kept as a
94
+ * discrete field so consumers can destructure it without widening
95
+ * their dependency on the full status union.
96
+ */
97
+ isLoading: boolean;
98
+ /**
99
+ * Submit credentials to the server and update context state with the
100
+ * resulting user on success.
101
+ *
102
+ * @param email User's primary email address.
103
+ * @param password Plaintext password — the server hashes on receipt.
104
+ * @param options Optional metadata. `tenantId` defaults to `'default'`
105
+ * when omitted so single-tenant apps can skip it.
106
+ *
107
+ * @returns The discriminated {@link LoginResult} — branch on
108
+ * `'mfaRequired' in result` to handle the MFA challenge case.
109
+ */
110
+ login: (email: string, password: string, options?: {
111
+ tenantId?: string;
112
+ }) => Promise<LoginResult>;
113
+ /**
114
+ * Register a new account and, on success, commit the returned user
115
+ * to the context as the active session.
116
+ *
117
+ * @param data Payload matching `AuthClient.register` — `email`,
118
+ * `password`, `name`, `tenantId` — forwarded to the server DTO
119
+ * unchanged.
120
+ *
121
+ * @returns The {@link AuthResult} returned by the server. In cookie
122
+ * mode `accessToken` is the empty string; in bearer mode callers
123
+ * must keep the token in memory only (never in storage).
124
+ *
125
+ * @throws {AuthClientError} When the server rejects the payload
126
+ * (e.g. `auth.email_already_registered`, validation failures).
127
+ * The context state lands in `unauthenticated` before the error
128
+ * is re-thrown so the caller's catch branch can update its own
129
+ * form-error UI.
130
+ */
131
+ register: (data: RegisterInput) => Promise<AuthResult>;
132
+ /**
133
+ * Revoke the current session server-side and clear the local
134
+ * context state.
135
+ *
136
+ * @throws The underlying error raised by `AuthClient.logout` when
137
+ * the network call fails. Local context state is STILL cleared
138
+ * before the error propagates — consumers can treat a rejection
139
+ * as "you are signed out locally, but the server revocation
140
+ * request did not complete" and decide whether to retry.
141
+ * Callers that do not care about the server-side outcome should
142
+ * wrap the call in a try/catch and ignore the error.
143
+ */
144
+ logout: () => Promise<void>;
145
+ /**
146
+ * Force a session revalidation by calling `client.getMe()`.
147
+ * Intended for explicit refresh flows (e.g. after an action that
148
+ * may have changed the user's role server-side). Not required for
149
+ * routine session maintenance — the provider handles that
150
+ * automatically via the configured interval.
151
+ */
152
+ refresh: () => Promise<void>;
153
+ /**
154
+ * Initiate a password reset. The server returns 200 regardless of
155
+ * whether the email is registered (anti-enumeration) — treat a
156
+ * resolved Promise as "request accepted", not "email known".
157
+ */
158
+ forgotPassword: (email: string, tenantId?: string) => Promise<void>;
159
+ /**
160
+ * Submit a new password. Accepts the same discriminated-union shape
161
+ * as `AuthClient.resetPassword` so callers can construct the input
162
+ * with a single field — `token`, `otp`, or `verifiedToken`.
163
+ */
164
+ resetPassword: (input: ResetPasswordInput) => Promise<void>;
165
+ /**
166
+ * Timestamp of the most recent successful `getMe()` call, or `null`
167
+ * when the provider has not yet completed its initial mount.
168
+ * Consumers can surface this to show a "last checked" indicator in
169
+ * long-lived sessions (dashboards, admin tools).
170
+ */
171
+ lastValidation: Date | null;
172
+ }
173
+
174
+ /**
175
+ * Read-only view of the auth session for the consuming component tree.
176
+ *
177
+ * Companion to {@link useAuth} — this hook exposes the state part of
178
+ * {@link AuthContextValue} (user, status, loading, last revalidation
179
+ * timestamp, and the explicit `refresh` trigger) while {@link useAuth}
180
+ * exposes the action part (login, register, logout, password reset).
181
+ *
182
+ * Splitting the two surfaces means read-heavy components (navbars,
183
+ * profile badges, route guards) can depend on just the subset they
184
+ * actually need and do not get re-rendered by unrelated action churn.
185
+ */
186
+
187
+ /**
188
+ * Shape returned by {@link useSession}.
189
+ *
190
+ * A deliberate subset of {@link AuthContextValue}: the method surface
191
+ * stays with {@link useAuth} so consumers of session state do not
192
+ * accidentally couple themselves to the login/logout imperative API.
193
+ *
194
+ * @remarks
195
+ * The returned object identity is not stable across renders. Treat
196
+ * the individual fields (`user`, `status`, `lastValidation`) as the
197
+ * correct memoization keys — never the container object itself, or
198
+ * downstream `useMemo` / `useEffect` dependency arrays will fire on
199
+ * every render regardless of whether the session actually changed.
200
+ */
201
+ interface UseSessionResult {
202
+ /** Authenticated user, or `null` when there is no session. */
203
+ user: AuthUserClient | null;
204
+ /** Current lifecycle status of the session — see {@link AuthStatus}. */
205
+ status: AuthStatus;
206
+ /**
207
+ * Convenience boolean mirroring `status === 'loading'`. Exposed as
208
+ * a discrete field so destructuring is ergonomic in components that
209
+ * only branch on "are we still deciding?".
210
+ */
211
+ isLoading: boolean;
212
+ /**
213
+ * Force a revalidation by calling `AuthClient.getMe()` through the
214
+ * provider. Useful after an action that may have changed the user's
215
+ * role server-side (e.g. tenant switch). Routine freshness is
216
+ * already handled by the provider's interval — reach for this only
217
+ * when you need a synchronous round-trip.
218
+ */
219
+ refresh: () => Promise<void>;
220
+ /**
221
+ * Timestamp of the most recent successful `getMe()` round-trip, or
222
+ * `null` when the provider has not yet completed its initial probe.
223
+ */
224
+ lastValidation: Date | null;
225
+ }
226
+ /**
227
+ * Read the current session state from the {@link AuthContext}.
228
+ *
229
+ * @throws When called outside of an {@link AuthProvider} subtree.
230
+ * The descriptive message points the developer to wrap their app
231
+ * rather than leaving them with a `null`-based runtime failure
232
+ * deeper in the call stack.
233
+ *
234
+ * @example
235
+ * ```tsx
236
+ * function Navbar(): ReactNode {
237
+ * const { user, isLoading } = useSession()
238
+ * if (isLoading) return <Spinner />
239
+ * return user ? <UserMenu user={user} /> : <SignInButton />
240
+ * }
241
+ * ```
242
+ */
243
+ declare function useSession(): UseSessionResult;
244
+
245
+ /**
246
+ * Imperative action surface of the auth session.
247
+ *
248
+ * Companion to {@link useSession} — this hook returns the mutating
249
+ * methods that consumers call from event handlers (login, register,
250
+ * logout, password-reset flows). State reading lives in
251
+ * {@link useSession}, so forms can take `useAuth()` without
252
+ * subscribing to `user` / `status` churn unless they really need it.
253
+ */
254
+
255
+ /**
256
+ * Shape returned by {@link useAuth}. Narrows {@link AuthContextValue}
257
+ * to its method members — state-only consumers should use
258
+ * {@link useSession} instead so they do not re-render when an unrelated
259
+ * action runs.
260
+ */
261
+ type UseAuthResult = Pick<AuthContextValue, 'login' | 'register' | 'logout' | 'forgotPassword' | 'resetPassword'>;
262
+ /**
263
+ * Read the session-mutating methods from the {@link AuthContext}.
264
+ *
265
+ * @throws When called outside of an {@link AuthProvider} subtree. A
266
+ * typed error makes the misuse immediately actionable instead of
267
+ * surfacing as an undefined-method runtime failure inside a
268
+ * component handler.
269
+ *
270
+ * @example
271
+ * ```tsx
272
+ * function LoginForm(): ReactNode {
273
+ * const { login } = useAuth()
274
+ * return (
275
+ * <form
276
+ * onSubmit={async (event) => {
277
+ * event.preventDefault()
278
+ * await login(email, password)
279
+ * }}
280
+ * >
281
+ * ...
282
+ * </form>
283
+ * )
284
+ * }
285
+ * ```
286
+ */
287
+ declare function useAuth(): UseAuthResult;
288
+
289
+ /**
290
+ * Binary-flag convenience view of the auth session.
291
+ *
292
+ * Most route guards and conditional renders only need two pieces of
293
+ * information: "are we still figuring it out?" and "is the user
294
+ * signed in?". This hook collapses {@link useSession}'s status union
295
+ * into those two booleans so consumers can skip the string-compare
296
+ * boilerplate and so a future rename of the status union stays
297
+ * contained inside {@link useSession}.
298
+ */
299
+ /**
300
+ * Shape returned by {@link useAuthStatus}.
301
+ *
302
+ * The two booleans are mutually independent — it is legal (and
303
+ * expected during the initial probe) to have both `isAuthenticated`
304
+ * and `isLoading` be `false`, representing "not signed in, no probe
305
+ * in flight".
306
+ */
307
+ interface UseAuthStatusResult {
308
+ /**
309
+ * `true` only when the session status is `'authenticated'`. Safe
310
+ * to use as the gate for protected-route guards and "signed-in only"
311
+ * UI — a `loading` or `unauthenticated` status correctly evaluates
312
+ * to `false`.
313
+ */
314
+ isAuthenticated: boolean;
315
+ /**
316
+ * `true` only when the session status is `'loading'`. Use it to
317
+ * show a skeleton or spinner while the provider completes its
318
+ * initial probe or an explicit `refresh()` — the `authenticated`
319
+ * and `unauthenticated` states both evaluate to `false`.
320
+ */
321
+ isLoading: boolean;
322
+ }
323
+ /**
324
+ * Derive the two binary session flags from {@link useSession}.
325
+ *
326
+ * @throws When called outside of an {@link AuthProvider} subtree.
327
+ * The error propagates from {@link useSession}, so the same
328
+ * descriptive message applies.
329
+ *
330
+ * @example
331
+ * ```tsx
332
+ * function ProtectedRoute({ children }: { children: ReactNode }): ReactNode {
333
+ * const { isAuthenticated, isLoading } = useAuthStatus()
334
+ * if (isLoading) return <Spinner />
335
+ * if (!isAuthenticated) return <Navigate to="/sign-in" />
336
+ * return <>{children}</>
337
+ * }
338
+ * ```
339
+ */
340
+ declare function useAuthStatus(): UseAuthStatusResult;
341
+
342
+ export { type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthStatus, type UseAuthResult, type UseAuthStatusResult, type UseSessionResult, useAuth, useAuthStatus, useSession };