mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 04:29:40 +02:00
Created createManaAuthStore in @manacore/shared-auth-stores that replaces ~350 lines of duplicated auth.svelte.ts per app with a ~10 line factory call. The factory handles: SSO, passkeys, 2FA, magic links, token management, password reset, sign up/in/out — everything the old stores did. Each app only provides devBackendPort and optional onAuthenticated callback. Before: 21 apps × ~350 lines = 6,800 lines of duplicated auth code After: 21 apps × ~10 lines = 182 lines total (97% reduction) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
/**
|
|
* @manacore/shared-auth-stores
|
|
*
|
|
* Svelte 5 auth store factories for the ManaCore monorepo.
|
|
*
|
|
* Provides two approaches:
|
|
* 1. createAuthStore - Generic factory that works with any auth service adapter
|
|
* 2. createSupabaseAuthStore - Direct Supabase integration for simpler setups
|
|
*
|
|
* @example Generic auth store with custom adapter
|
|
* ```ts
|
|
* import { createAuthStore } from '@manacore/shared-auth-stores';
|
|
* import { authService } from '$lib/auth';
|
|
* import type { AppUser } from '$lib/types';
|
|
*
|
|
* export const authStore = createAuthStore<AppUser>(authService);
|
|
* ```
|
|
*
|
|
* @example Supabase auth store
|
|
* ```ts
|
|
* import { createSupabaseAuthStore } from '@manacore/shared-auth-stores';
|
|
* import { createBrowserClient } from '@supabase/ssr';
|
|
*
|
|
* const getClient = () => createBrowserClient(url, key);
|
|
* export const authStore = createSupabaseAuthStore(getClient);
|
|
* ```
|
|
*/
|
|
|
|
// Factory functions
|
|
export { createManaAuthStore } from './createManaAuthStore.svelte';
|
|
export type { ManaAuthStoreConfig, ManaAuthStore } from './createManaAuthStore.svelte';
|
|
export { createAuthStore } from './createAuthStore.svelte';
|
|
export { createSupabaseAuthStore } from './createSupabaseAuthStore.svelte';
|
|
export type {
|
|
CreateSupabaseAuthStoreOptions,
|
|
SupabaseUser,
|
|
} from './createSupabaseAuthStore.svelte';
|
|
|
|
// Types
|
|
export type {
|
|
BaseUser,
|
|
AuthResult,
|
|
AuthServiceAdapter,
|
|
AuthStoreState,
|
|
AuthStoreActions,
|
|
AuthStore,
|
|
} from './types';
|