@classic-homes/auth 0.1.43 → 0.1.44

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.
@@ -1,4 +1,8 @@
1
- import { A as AuthState, U as User } from '../types-DGN45Uih.js';
1
+ import { f as AuthState, U as User, A as AuthConfig } from '../types-Ct5g1Nbj.js';
2
+ export { i as initAuth, a as isInitialized } from '../types-Ct5g1Nbj.js';
3
+ import { a as authService } from '../user-utils-BtLu_jhF.js';
4
+ export { R as RoleDeniedError, f as formatUserRoles, c as getAvatarFallback, g as getDisplayName, e as getGreeting, d as getUserEmail, b as getUserInitials, i as isRoleDeniedError } from '../user-utils-BtLu_jhF.js';
5
+ import { RequestEvent, Handle } from '@sveltejs/kit';
2
6
 
3
7
  /**
4
8
  * Auth Store
@@ -53,6 +57,14 @@ declare class AuthStore {
53
57
  logoutWithSSO(): Promise<{
54
58
  ssoLogoutUrl?: string;
55
59
  }>;
60
+ /**
61
+ * Handle session expiration (e.g., token refresh failure).
62
+ * Clears auth state and calls the onSessionExpired callback if configured.
63
+ *
64
+ * Use this instead of logout() when the session expires unexpectedly,
65
+ * to trigger different handling (e.g., redirect with error message).
66
+ */
67
+ handleSessionExpired(): void;
56
68
  /**
57
69
  * Check if user has a specific permission.
58
70
  */
@@ -81,6 +93,22 @@ declare class AuthStore {
81
93
  * Re-hydrate state from storage (useful after config changes).
82
94
  */
83
95
  rehydrate(): void;
96
+ /**
97
+ * Reset the store to initial state and clear all storage.
98
+ * Primarily intended for testing scenarios where auth needs to be fully reset.
99
+ *
100
+ * Unlike logout(), this also clears all subscribers and doesn't
101
+ * dispatch events or call config callbacks.
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * // In test setup/teardown
106
+ * beforeEach(() => {
107
+ * authStore.reset();
108
+ * });
109
+ * ```
110
+ */
111
+ reset(): void;
84
112
  }
85
113
  /** Singleton auth store instance */
86
114
  declare const authStore: AuthStore;
@@ -96,6 +124,7 @@ declare const authActions: {
96
124
  logoutWithSSO: () => Promise<{
97
125
  ssoLogoutUrl?: string;
98
126
  }>;
127
+ handleSessionExpired: () => void;
99
128
  hasPermission: (permission: string) => boolean;
100
129
  hasRole: (role: string) => boolean;
101
130
  hasAnyRole: (roles: string[]) => boolean;
@@ -103,6 +132,7 @@ declare const authActions: {
103
132
  hasAnyPermission: (permissions: string[]) => boolean;
104
133
  hasAllPermissions: (permissions: string[]) => boolean;
105
134
  rehydrate: () => void;
135
+ reset: () => void;
106
136
  };
107
137
  /**
108
138
  * Derived stores for common auth values.
@@ -197,19 +227,55 @@ declare function requirePermission(permissions: string | string[], requireAll?:
197
227
  /**
198
228
  * Utility to protect a load function.
199
229
  *
230
+ * **Important:** This returns a plain object with `{ redirect: string }` when auth fails,
231
+ * NOT a SvelteKit redirect exception. You must handle the redirect in your load function
232
+ * or use `checkAuth()` directly with SvelteKit's `redirect()` function.
233
+ *
234
+ * @returns A wrapped load function that returns either:
235
+ * - Your load function's result (when authenticated)
236
+ * - `{ redirect: string }` object (when not authenticated)
237
+ *
200
238
  * @example
201
239
  * ```typescript
240
+ * // Option 1: Handle redirect in +page.svelte
202
241
  * // In +page.ts
203
242
  * import { protectedLoad } from '@classic-homes/auth/svelte';
204
243
  *
205
244
  * export const load = protectedLoad(
206
245
  * { roles: ['admin'] },
207
246
  * async ({ fetch }) => {
208
- * // This only runs if auth check passes
209
247
  * const data = await fetch('/api/admin/data');
210
248
  * return { data };
211
249
  * }
212
250
  * );
251
+ *
252
+ * // In +page.svelte - check for redirect property
253
+ * <script>
254
+ * export let data;
255
+ * import { goto } from '$app/navigation';
256
+ * import { onMount } from 'svelte';
257
+ *
258
+ * onMount(() => {
259
+ * if ('redirect' in data) goto(data.redirect);
260
+ * });
261
+ * </script>
262
+ * ```
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * // Option 2 (Recommended): Use checkAuth with SvelteKit's redirect
267
+ * // In +page.ts
268
+ * import { checkAuth } from '@classic-homes/auth/svelte';
269
+ * import { redirect } from '@sveltejs/kit';
270
+ *
271
+ * export async function load({ fetch }) {
272
+ * const result = checkAuth({ roles: ['admin'] });
273
+ * if (!result.allowed) {
274
+ * throw redirect(302, result.redirectTo ?? '/login');
275
+ * }
276
+ * const data = await fetch('/api/admin/data');
277
+ * return { data };
278
+ * }
213
279
  * ```
214
280
  */
215
281
  declare function protectedLoad<T>(options: AuthGuardOptions, loadFn: (event: {
@@ -220,4 +286,371 @@ declare function protectedLoad<T>(options: AuthGuardOptions, loadFn: (event: {
220
286
  redirect: string;
221
287
  }>;
222
288
 
223
- export { type AuthGuardOptions, type AuthGuardResult, AuthState, User, authActions, authStore, checkAuth, createAuthGuard, currentUser, isAuthenticated, protectedLoad, requireAuth, requirePermission, requireRole };
289
+ /**
290
+ * Auth Client Factory
291
+ *
292
+ * Simplified initialization API that bundles configuration and rehydration.
293
+ * Use this for a one-liner auth setup in your app.
294
+ */
295
+
296
+ /**
297
+ * Options for createAuthClient, extending AuthConfig with client-specific options.
298
+ */
299
+ interface CreateAuthClientOptions extends AuthConfig {
300
+ /**
301
+ * Automatically rehydrate auth state from storage on creation.
302
+ * Set to false if you want to control when rehydration happens.
303
+ * @default true
304
+ */
305
+ autoRehydrate?: boolean;
306
+ }
307
+ /**
308
+ * Return type for createAuthClient.
309
+ */
310
+ interface AuthClient {
311
+ /** The auth store (Svelte store contract) */
312
+ authStore: typeof authStore;
313
+ /** Actions for modifying auth state */
314
+ authActions: typeof authActions;
315
+ /** Service for API calls */
316
+ authService: typeof authService;
317
+ /** Derived store for isAuthenticated */
318
+ isAuthenticated: typeof isAuthenticated;
319
+ /** Derived store for currentUser */
320
+ currentUser: typeof currentUser;
321
+ }
322
+ /**
323
+ * Create and initialize the auth client.
324
+ *
325
+ * This is a convenience function that:
326
+ * 1. Initializes the auth configuration (if not already done)
327
+ * 2. Rehydrates auth state from storage (unless disabled)
328
+ * 3. Returns all auth utilities in one object
329
+ *
330
+ * @param options - Configuration options
331
+ * @returns Auth client with stores and services
332
+ *
333
+ * @example
334
+ * ```typescript
335
+ * // In your app's auth setup file (e.g., lib/auth.ts)
336
+ * import { createAuthClient } from '@classic-homes/auth/svelte';
337
+ * import { PUBLIC_API_URL } from '$env/static/public';
338
+ *
339
+ * export const {
340
+ * authStore,
341
+ * authActions,
342
+ * authService,
343
+ * isAuthenticated,
344
+ * currentUser,
345
+ * } = createAuthClient({
346
+ * baseUrl: PUBLIC_API_URL,
347
+ * storageKey: 'my_app_auth',
348
+ * sso: { enabled: true, provider: 'authentik' },
349
+ * onSessionExpired: (currentPath) => {
350
+ * window.location.href = `/login?redirect=${encodeURIComponent(currentPath)}`;
351
+ * },
352
+ * });
353
+ * ```
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * // In a Svelte component
358
+ * <script>
359
+ * import { isAuthenticated, currentUser } from '$lib/auth';
360
+ * </script>
361
+ *
362
+ * {#if $isAuthenticated}
363
+ * <p>Welcome, {$currentUser?.firstName}</p>
364
+ * {/if}
365
+ * ```
366
+ */
367
+ declare function createAuthClient(options: CreateAuthClientOptions): AuthClient;
368
+
369
+ /**
370
+ * Navigation Filtering Utilities
371
+ *
372
+ * Filter navigation items based on user roles and permissions.
373
+ * Works with any navigation structure that includes roles/permissions arrays.
374
+ */
375
+
376
+ /**
377
+ * Interface for items that can be filtered by role/permission.
378
+ * Navigation items should include these optional arrays to restrict access.
379
+ */
380
+ interface RoleRestrictedItem {
381
+ /** Optional item identifier */
382
+ id?: string;
383
+ /**
384
+ * Roles that can see this item.
385
+ * By default, user needs ANY of these roles (use requireAllRoles for ALL).
386
+ * If empty/undefined, item is visible to all authenticated users.
387
+ */
388
+ roles?: string[];
389
+ /**
390
+ * Permissions that can see this item.
391
+ * By default, user needs ANY of these permissions (use requireAllPermissions for ALL).
392
+ * If empty/undefined, item is visible without permission check.
393
+ */
394
+ permissions?: string[];
395
+ /** Allow additional properties */
396
+ [key: string]: unknown;
397
+ }
398
+ /**
399
+ * Options for filtering behavior.
400
+ */
401
+ interface NavFilterOptions {
402
+ /**
403
+ * If true, user needs ALL specified roles to see item (default: false = any role)
404
+ */
405
+ requireAllRoles?: boolean;
406
+ /**
407
+ * If true, user needs ALL specified permissions to see item (default: false = any permission)
408
+ */
409
+ requireAllPermissions?: boolean;
410
+ /**
411
+ * If true, items without roles/permissions are hidden for unauthenticated users.
412
+ * If false (default), items without restrictions are visible to everyone.
413
+ */
414
+ hideUnrestrictedForGuests?: boolean;
415
+ }
416
+ /**
417
+ * Filter navigation items based on user roles and permissions.
418
+ *
419
+ * @param items - Array of navigation items
420
+ * @param user - Current user (null for unauthenticated)
421
+ * @param options - Filter options
422
+ * @returns Filtered array of items the user can access
423
+ *
424
+ * @example
425
+ * ```typescript
426
+ * const navItems = [
427
+ * { id: 'dashboard', label: 'Dashboard' },
428
+ * { id: 'users', label: 'Users', roles: ['admin', 'manager'] },
429
+ * { id: 'settings', label: 'Settings', permissions: ['settings:read'] },
430
+ * ];
431
+ *
432
+ * const filtered = filterByAccess(navItems, user);
433
+ * // Returns items the user can see based on their roles/permissions
434
+ * ```
435
+ */
436
+ declare function filterByAccess<T extends RoleRestrictedItem>(items: T[], user: User | null, options?: NavFilterOptions): T[];
437
+ /**
438
+ * Filter navigation sections (groups with nested items).
439
+ * Removes empty sections after filtering items.
440
+ *
441
+ * @param sections - Array of navigation sections with items
442
+ * @param user - Current user (null for unauthenticated)
443
+ * @param options - Filter options
444
+ * @returns Filtered sections with non-empty items
445
+ *
446
+ * @example
447
+ * ```typescript
448
+ * const sections = [
449
+ * {
450
+ * title: 'Main',
451
+ * items: [
452
+ * { id: 'dashboard', label: 'Dashboard' },
453
+ * { id: 'analytics', label: 'Analytics', roles: ['admin'] },
454
+ * ],
455
+ * },
456
+ * {
457
+ * title: 'Admin',
458
+ * items: [
459
+ * { id: 'users', label: 'Users', roles: ['admin'] },
460
+ * ],
461
+ * },
462
+ * ];
463
+ *
464
+ * const filtered = filterNavSections(sections, user);
465
+ * // Admin section removed entirely if user isn't admin
466
+ * ```
467
+ */
468
+ declare function filterNavSections<TItem extends RoleRestrictedItem, TSection extends {
469
+ items: TItem[];
470
+ }>(sections: TSection[], user: User | null, options?: NavFilterOptions): TSection[];
471
+ /**
472
+ * Check if a user can access a specific item.
473
+ * Useful for conditional rendering of individual items.
474
+ *
475
+ * @param item - The item to check access for
476
+ * @param user - Current user (null for unauthenticated)
477
+ * @param options - Filter options
478
+ * @returns true if user can access the item
479
+ *
480
+ * @example
481
+ * ```typescript
482
+ * const adminItem = { id: 'admin', roles: ['admin'] };
483
+ *
484
+ * if (canAccess(adminItem, user)) {
485
+ * // Show admin link
486
+ * }
487
+ * ```
488
+ */
489
+ declare function canAccess(item: RoleRestrictedItem, user: User | null, options?: NavFilterOptions): boolean;
490
+ /**
491
+ * Create a pre-configured filter function with fixed options.
492
+ * Useful when you want consistent filtering behavior across the app.
493
+ *
494
+ * @param defaultOptions - Default filter options
495
+ * @returns A filter function with the options pre-applied
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * // In a config file
500
+ * export const filterNav = createNavFilter({ requireAllRoles: false });
501
+ *
502
+ * // In components
503
+ * const filtered = filterNav(items, user);
504
+ * ```
505
+ */
506
+ declare function createNavFilter(defaultOptions?: NavFilterOptions): <T extends RoleRestrictedItem>(items: T[], user: User | null, options?: NavFilterOptions) => T[];
507
+
508
+ /**
509
+ * SvelteKit Auth Hook
510
+ *
511
+ * Server-side authentication middleware for SvelteKit.
512
+ * Use this in hooks.server.ts to protect routes at the server level.
513
+ */
514
+
515
+ /**
516
+ * Options for the auth hook.
517
+ */
518
+ interface AuthHookOptions {
519
+ /**
520
+ * Path to redirect unauthenticated users.
521
+ * @default '/login'
522
+ */
523
+ loginPath?: string;
524
+ /**
525
+ * Routes that always require authentication.
526
+ * Matched against pathname using regex.
527
+ * If not specified and publicRoutes is set, all non-public routes require auth.
528
+ *
529
+ * @example [/^\/dashboard/, /^\/api\/protected/]
530
+ */
531
+ protectedRoutes?: RegExp[];
532
+ /**
533
+ * Routes that don't require authentication.
534
+ * Matched against pathname using regex.
535
+ *
536
+ * @example [/^\/auth\//, /^\/public\//]
537
+ * @default [/^\/auth\//, /^\/api\/auth\//]
538
+ */
539
+ publicRoutes?: RegExp[];
540
+ /**
541
+ * Cookie name where the auth token is stored.
542
+ * The hook checks for this cookie to determine if user is authenticated.
543
+ *
544
+ * @default 'classic_auth'
545
+ */
546
+ cookieName?: string;
547
+ /**
548
+ * Alternative: header name to check for auth token.
549
+ * Useful for API routes that use Authorization header.
550
+ */
551
+ headerName?: string;
552
+ /**
553
+ * Query parameter to use for redirect URL.
554
+ * @default 'redirect'
555
+ */
556
+ redirectParam?: string;
557
+ /**
558
+ * Custom function to determine if a request is authenticated.
559
+ * Use this for advanced auth checks (e.g., validating token with API).
560
+ *
561
+ * @param event - The SvelteKit request event
562
+ * @returns true if authenticated, false otherwise
563
+ */
564
+ isAuthenticated?: (event: RequestEvent) => boolean | Promise<boolean>;
565
+ /**
566
+ * Custom function to handle unauthenticated requests.
567
+ * By default, redirects to loginPath with redirect parameter.
568
+ *
569
+ * @param event - The SvelteKit request event
570
+ * @returns Response to send (typically a redirect)
571
+ */
572
+ onUnauthenticated?: (event: RequestEvent) => Response | Promise<Response>;
573
+ /**
574
+ * Callback when authentication check is performed.
575
+ * Useful for logging or analytics.
576
+ */
577
+ onAuthCheck?: (event: RequestEvent, isAuthenticated: boolean) => void;
578
+ }
579
+ /**
580
+ * Create a SvelteKit handle function for authentication.
581
+ *
582
+ * @param options - Configuration options
583
+ * @returns SvelteKit Handle function
584
+ *
585
+ * @example
586
+ * ```typescript
587
+ * // src/hooks.server.ts
588
+ * import { createAuthHook } from '@classic-homes/auth/svelte';
589
+ * import { sequence } from '@sveltejs/kit/hooks';
590
+ *
591
+ * const authHook = createAuthHook({
592
+ * loginPath: '/auth/login',
593
+ * publicRoutes: [/^\/auth\//, /^\/api\/health/],
594
+ * cookieName: 'my_app_auth',
595
+ * });
596
+ *
597
+ * export const handle = sequence(authHook);
598
+ * ```
599
+ *
600
+ * @example
601
+ * ```typescript
602
+ * // With custom authentication check
603
+ * const authHook = createAuthHook({
604
+ * isAuthenticated: async (event) => {
605
+ * const token = event.cookies.get('auth_token');
606
+ * if (!token) return false;
607
+ *
608
+ * // Validate token with your API
609
+ * const response = await fetch('/api/auth/validate', {
610
+ * headers: { Authorization: `Bearer ${token}` },
611
+ * });
612
+ * return response.ok;
613
+ * },
614
+ * });
615
+ * ```
616
+ */
617
+ declare function createAuthHook(options?: AuthHookOptions): Handle;
618
+ /**
619
+ * Helper to check if a pathname matches any pattern in a list.
620
+ *
621
+ * @param pathname - The pathname to check
622
+ * @param patterns - Array of regex patterns
623
+ * @returns true if pathname matches any pattern
624
+ */
625
+ declare function matchesRoute(pathname: string, patterns: RegExp[]): boolean;
626
+ /**
627
+ * Create common route patterns for convenience.
628
+ */
629
+ declare const routePatterns: {
630
+ /** Match all /auth/* routes */
631
+ auth: RegExp;
632
+ /** Match all /api/* routes */
633
+ api: RegExp;
634
+ /** Match all /api/auth/* routes */
635
+ apiAuth: RegExp;
636
+ /** Match all /public/* routes */
637
+ public: RegExp;
638
+ /** Match all /admin/* routes */
639
+ admin: RegExp;
640
+ /** Match exact root path */
641
+ root: RegExp;
642
+ /** Match health check endpoints */
643
+ health: RegExp;
644
+ /**
645
+ * Create a pattern for a specific path prefix.
646
+ * @param prefix - Path prefix (e.g., '/dashboard')
647
+ */
648
+ prefix: (prefix: string) => RegExp;
649
+ /**
650
+ * Create a pattern for exact path match.
651
+ * @param path - Exact path (e.g., '/about')
652
+ */
653
+ exact: (path: string) => RegExp;
654
+ };
655
+
656
+ export { type AuthClient, type AuthGuardOptions, type AuthGuardResult, type AuthHookOptions, AuthState, type CreateAuthClientOptions, type NavFilterOptions, type RoleRestrictedItem, User, authActions, authStore, canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, currentUser, filterByAccess, filterNavSections, isAuthenticated, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns };
@@ -1,4 +1,5 @@
1
- export { checkAuth, createAuthGuard, protectedLoad, requireAuth, requirePermission, requireRole } from '../chunk-IAPPE4US.js';
2
- export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-7M4DUK45.js';
3
- import '../chunk-BDIQSTES.js';
4
- import '../chunk-DCGC6CNV.js';
1
+ export { canAccess, checkAuth, createAuthClient, createAuthGuard, createAuthHook, createNavFilter, filterByAccess, filterNavSections, matchesRoute, protectedLoad, requireAuth, requirePermission, requireRole, routePatterns } from '../chunk-YTMFXVJR.js';
2
+ export { RoleDeniedError, formatUserRoles, getAvatarFallback, getDisplayName, getGreeting, getUserEmail, getUserInitials, isRoleDeniedError } from '../chunk-XSQYERC6.js';
3
+ export { authActions, authStore, currentUser, isAuthenticated } from '../chunk-DSNTNK6T.js';
4
+ import '../chunk-ES4UOD62.js';
5
+ export { initAuth, isInitialized } from '../chunk-DCGC6CNV.js';
@@ -1,5 +1,4 @@
1
- import { U as User, a as LoginResponse, b as LogoutResponse, c as RegisterResponse, M as MFASetupResponse, f as MFAStatus, S as Session, D as Device, d as ApiKey, i as LinkedAccount, j as SecurityEvent, h as UserPreferences, A as AuthState } from '../types-DGN45Uih.js';
2
- import { e as StorageAdapter, A as AuthConfig } from '../config-C-iBNu07.js';
1
+ import { U as User, h as LoginResponse, j as LogoutResponse, k as RegisterResponse, M as MFASetupResponse, o as MFAStatus, l as Session, D as Device, m as ApiKey, s as LinkedAccount, t as SecurityEvent, q as UserPreferences, e as StorageAdapter, f as AuthState, A as AuthConfig } from '../types-Ct5g1Nbj.js';
3
2
 
4
3
  /**
5
4
  * User Fixtures
@@ -1,3 +1,103 @@
1
+ /**
2
+ * Auth Configuration
3
+ *
4
+ * Manages global configuration for the auth package.
5
+ * Must be initialized via initAuth() before using auth services.
6
+ */
7
+ interface SSOConfig {
8
+ /** Whether SSO is enabled */
9
+ enabled: boolean;
10
+ /** SSO provider name (e.g., 'authentik', 'okta') */
11
+ provider: string;
12
+ /** Override the default authorize URL (defaults to /auth/sso/authorize) */
13
+ authorizeUrl?: string;
14
+ }
15
+ interface StorageAdapter {
16
+ getItem(key: string): string | null;
17
+ setItem(key: string, value: string): void;
18
+ removeItem(key: string): void;
19
+ }
20
+ interface AuthConfig {
21
+ /** Base URL for the API (e.g., 'https://api.example.com/v1') */
22
+ baseUrl: string;
23
+ /** Custom fetch implementation (useful for SSR or testing) */
24
+ fetch?: typeof fetch;
25
+ /** Storage adapter for token persistence (defaults to localStorage in browser) */
26
+ storage?: StorageAdapter;
27
+ /** Storage key prefix for auth data */
28
+ storageKey?: string;
29
+ /** Callback when auth errors occur (e.g., for logging or analytics) */
30
+ onAuthError?: (error: Error) => void;
31
+ /** Callback when tokens are refreshed */
32
+ onTokenRefresh?: (tokens: {
33
+ accessToken: string;
34
+ refreshToken: string;
35
+ }) => void;
36
+ /** Callback when user is logged out (e.g., for redirect) */
37
+ onLogout?: () => void;
38
+ /**
39
+ * Callback when the session expires (e.g., token refresh fails).
40
+ * Receives the current path for redirect handling.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * initAuth({
45
+ * baseUrl: 'https://api.example.com',
46
+ * onSessionExpired: (currentPath) => {
47
+ * goto(`/auth/login?redirect=${encodeURIComponent(currentPath)}&error=session_expired`);
48
+ * },
49
+ * });
50
+ * ```
51
+ */
52
+ onSessionExpired?: (currentPath: string) => void;
53
+ /** SSO configuration */
54
+ sso?: SSOConfig;
55
+ }
56
+ /**
57
+ * Initialize the auth package with configuration.
58
+ * Must be called before using any auth services.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * import { initAuth } from '@classic-homes/auth';
63
+ *
64
+ * initAuth({
65
+ * baseUrl: import.meta.env.PUBLIC_API_URL,
66
+ * sso: {
67
+ * enabled: true,
68
+ * provider: 'authentik',
69
+ * },
70
+ * });
71
+ * ```
72
+ */
73
+ declare function initAuth(options: AuthConfig): void;
74
+ /**
75
+ * Get the current auth configuration.
76
+ * Throws if initAuth() has not been called.
77
+ */
78
+ declare function getConfig(): AuthConfig;
79
+ /**
80
+ * Check if auth has been initialized.
81
+ */
82
+ declare function isInitialized(): boolean;
83
+ /**
84
+ * Reset the auth configuration (useful for testing).
85
+ */
86
+ declare function resetConfig(): void;
87
+ /**
88
+ * Get the default storage adapter.
89
+ * Returns localStorage in browser, or a no-op adapter in SSR.
90
+ */
91
+ declare function getDefaultStorage(): StorageAdapter;
92
+ /**
93
+ * Get the storage adapter from config or use default.
94
+ */
95
+ declare function getStorage(): StorageAdapter;
96
+ /**
97
+ * Get the fetch implementation from config or use global fetch.
98
+ */
99
+ declare function getFetch(): typeof fetch;
100
+
1
101
  /**
2
102
  * Auth Types
3
103
  *
@@ -202,4 +302,4 @@ interface ResetPasswordData {
202
302
  newPassword: string;
203
303
  }
204
304
 
205
- export type { AuthState as A, CreateApiKeyRequest as C, Device as D, LoginCredentials as L, MFASetupResponse as M, Pagination as P, RegisterData as R, Session as S, User as U, LoginResponse as a, LogoutResponse as b, RegisterResponse as c, ApiKey as d, CreateApiKeyResponse as e, MFAStatus as f, MFAChallengeData as g, UserPreferences as h, LinkedAccount as i, SecurityEvent as j, ProfileUpdateData as k, ChangePasswordData as l, ResetPasswordData as m };
305
+ export { type AuthConfig as A, type CreateApiKeyRequest as C, type Device as D, type LoginCredentials as L, type MFASetupResponse as M, type Pagination as P, type RegisterData as R, type SSOConfig as S, type User as U, isInitialized as a, getDefaultStorage as b, getStorage as c, getFetch as d, type StorageAdapter as e, type AuthState as f, getConfig as g, type LoginResponse as h, initAuth as i, type LogoutResponse as j, type RegisterResponse as k, type Session as l, type ApiKey as m, type CreateApiKeyResponse as n, type MFAStatus as o, type MFAChallengeData as p, type UserPreferences as q, resetConfig as r, type LinkedAccount as s, type SecurityEvent as t, type ProfileUpdateData as u, type ChangePasswordData as v, type ResetPasswordData as w };