local-lite 0.1.3 → 0.2.1

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.
package/README.md CHANGED
@@ -93,7 +93,15 @@ For an application-level upgrade checklist or AI-assisted code review, see the
93
93
  ## AI Skills
94
94
 
95
95
  The package ships [Agent Skills](./skills) that AI coding assistants can load:
96
- `local-lite-setup`, `local-lite-custom-adapter` and `local-lite-upgrade`.
96
+ * `local-lite-setup`: Multi-platform setup (Expo, Web, Node) and client initialization.
97
+ * `local-lite-auth`: Zero-backend SQLite authentication, PBKDF2 crypto, lockout, reset tokens, and OAuth.
98
+ * `local-lite-backups`: Cloud backups (OneDrive, Google Drive), AES-256-GCM database encryption, and restore.
99
+ * `local-lite-schema`: Declarative cascading deletions (`onDelete`), append-only migrations, and FTS5 search.
100
+ * `local-lite-storage`: Blob and file management, ExpoFileDriver, and cloud storage bucket sync.
101
+ * `local-lite-react`: Reactive hooks (`useLiveQuery`, `useSyncStatus`, `useLocalAuth`, `useKV`), and 0ms optimistic writes.
102
+ * `local-lite-offline-actions`: Queued mutation outbox, encrypted secret preferences, and background scheduler.
103
+ * `local-lite-custom-adapter`: Implementing custom REST, GraphQL, or WebSocket remote database adapters.
104
+ * `local-lite-upgrade`: Migration checklist and breaking change reviews across version upgrades.
97
105
 
98
106
  ```bash
99
107
  npx local-lite install-skills # Copilot: .github/skills
@@ -1,10 +1,9 @@
1
+ import { type AuthUser } from './identity.js';
1
2
  export declare const APPLE_AUTHORIZATION_ENDPOINT = "https://appleid.apple.com/auth/authorize";
2
3
  export declare const APPLE_TOKEN_ENDPOINT = "https://appleid.apple.com/auth/token";
3
4
  export declare const DEFAULT_APPLE_AUTH_SCOPES: string[];
4
- export interface AppleUser {
5
- id: string;
6
- email: string;
7
- name: string;
5
+ export interface AppleUser extends AuthUser {
6
+ provider: 'apple';
8
7
  givenName?: string;
9
8
  familyName?: string;
10
9
  identityToken?: string;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AppleAuthClient = exports.DEFAULT_APPLE_AUTH_SCOPES = exports.APPLE_TOKEN_ENDPOINT = exports.APPLE_AUTHORIZATION_ENDPOINT = void 0;
4
4
  exports.createInMemoryAppleTokenStore = createInMemoryAppleTokenStore;
5
5
  exports.createAppleAuthTokenStore = createAppleAuthTokenStore;
6
+ const identity_js_1 = require("./identity.js");
6
7
  exports.APPLE_AUTHORIZATION_ENDPOINT = 'https://appleid.apple.com/auth/authorize';
7
8
  exports.APPLE_TOKEN_ENDPOINT = 'https://appleid.apple.com/auth/token';
8
9
  exports.DEFAULT_APPLE_AUTH_SCOPES = ['name', 'email'];
@@ -200,14 +201,24 @@ class AppleAuthClient {
200
201
  expiresAt: claims.exp ? claims.exp * 1000 : undefined,
201
202
  };
202
203
  await this.tokenStore.setTokens(tokens);
204
+ const canonicalId = (0, identity_js_1.resolveUnifiedUserId)({ id, email, emailVerified: Boolean(claims.email_verified ?? true) }, 'apple');
203
205
  const user = {
204
- id,
206
+ id: canonicalId,
207
+ userId: canonicalId,
205
208
  email,
209
+ emailVerified: Boolean(claims.email_verified ?? true),
206
210
  name,
211
+ displayName: name,
212
+ avatarUrl: null,
213
+ picture: null,
214
+ provider: 'apple',
215
+ providerAccountId: id,
207
216
  givenName,
208
217
  familyName,
209
218
  identityToken: authorization.id_token,
210
219
  authorizationCode: authorization.code,
220
+ rawProfile: claims,
221
+ createdAt: Date.now(),
211
222
  };
212
223
  await this.tokenStore.setUser(user);
213
224
  this.notify(user);
@@ -226,14 +237,26 @@ class AppleAuthClient {
226
237
  const resolvedGivenName = givenName || priorUser?.givenName;
227
238
  const resolvedFamilyName = familyName || priorUser?.familyName;
228
239
  const resolvedName = name !== email.split('@')[0] ? name : priorUser?.name || name;
240
+ const rawId = String(cred.user || claims.sub || 'apple_user');
241
+ const finalEmail = cred.email || priorUser?.email || email;
242
+ const canonicalId = (0, identity_js_1.resolveUnifiedUserId)({ id: rawId, email: finalEmail, emailVerified: true }, 'apple');
229
243
  const user = {
230
- id,
231
- email: cred.email || priorUser?.email || email,
244
+ id: canonicalId,
245
+ userId: canonicalId,
246
+ email: finalEmail,
247
+ emailVerified: true,
232
248
  name: resolvedName,
249
+ displayName: resolvedName,
250
+ avatarUrl: null,
251
+ picture: null,
252
+ provider: 'apple',
253
+ providerAccountId: rawId,
233
254
  givenName: resolvedGivenName,
234
255
  familyName: resolvedFamilyName,
235
256
  identityToken: cred.identityToken || undefined,
236
257
  authorizationCode: cred.authorizationCode || undefined,
258
+ rawProfile: claims,
259
+ createdAt: Date.now(),
237
260
  };
238
261
  if (cred.identityToken) {
239
262
  await this.tokenStore.setTokens({
@@ -1,13 +1,11 @@
1
+ import { type AuthUser } from './identity.js';
1
2
  export declare const GITHUB_AUTHORIZATION_ENDPOINT = "https://github.com/login/oauth/authorize";
2
3
  export declare const GITHUB_TOKEN_ENDPOINT = "https://github.com/login/oauth/access_token";
3
4
  export declare const GITHUB_API_ENDPOINT = "https://api.github.com";
4
5
  export declare const DEFAULT_GITHUB_AUTH_SCOPES: string[];
5
- export interface GitHubUser {
6
- id: string;
6
+ export interface GitHubUser extends AuthUser {
7
+ provider: 'github';
7
8
  login: string;
8
- name: string;
9
- email: string;
10
- avatarUrl?: string;
11
9
  bio?: string;
12
10
  company?: string;
13
11
  location?: string;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GitHubAuthClient = exports.DEFAULT_GITHUB_AUTH_SCOPES = exports.GITHUB_API_ENDPOINT = exports.GITHUB_TOKEN_ENDPOINT = exports.GITHUB_AUTHORIZATION_ENDPOINT = void 0;
4
4
  exports.createInMemoryGitHubTokenStore = createInMemoryGitHubTokenStore;
5
5
  exports.createGitHubAuthTokenStore = createGitHubAuthTokenStore;
6
+ const identity_js_1 = require("./identity.js");
6
7
  exports.GITHUB_AUTHORIZATION_ENDPOINT = 'https://github.com/login/oauth/authorize';
7
8
  exports.GITHUB_TOKEN_ENDPOINT = 'https://github.com/login/oauth/access_token';
8
9
  exports.GITHUB_API_ENDPOINT = 'https://api.github.com';
@@ -273,15 +274,28 @@ class GitHubAuthClient {
273
274
  // Fallback to username generated placeholder if emails restricted
274
275
  }
275
276
  }
277
+ const rawId = String(raw.id ?? raw.sub ?? 'github_user');
278
+ const normalizedEmail = email ? email.trim().toLowerCase() : `${raw.login}@users.noreply.github.com`;
279
+ const id = (0, identity_js_1.resolveUnifiedUserId)({ id: rawId, email: normalizedEmail, emailVerified: true }, 'github');
280
+ const name = raw.name || raw.login || 'GitHub User';
281
+ const avatarUrl = raw.avatar_url || null;
276
282
  return {
277
- id: String(raw.id),
283
+ id,
284
+ userId: id,
278
285
  login: raw.login,
279
- name: raw.name || raw.login,
280
- email: email || `${raw.login}@users.noreply.github.com`,
281
- avatarUrl: raw.avatar_url,
286
+ name,
287
+ displayName: name,
288
+ email: normalizedEmail,
289
+ emailVerified: true,
290
+ provider: 'github',
291
+ providerAccountId: rawId,
292
+ avatarUrl,
293
+ picture: avatarUrl,
282
294
  bio: raw.bio,
283
295
  company: raw.company,
284
296
  location: raw.location,
297
+ rawProfile: raw,
298
+ createdAt: Date.now(),
285
299
  };
286
300
  }
287
301
  }
@@ -1,16 +1,13 @@
1
+ import { type AuthUser } from './identity.js';
1
2
  import { GoogleDriveBackupStorage, GoogleDriveBackupClient, type GoogleDriveBackupClientOptions } from '../backups/cloud-storage.js';
2
3
  export declare const GOOGLE_AUTHORIZATION_ENDPOINT = "https://accounts.google.com/o/oauth2/v2/auth";
3
4
  export declare const GOOGLE_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token";
4
5
  export declare const GOOGLE_USERINFO_ENDPOINT = "https://www.googleapis.com/oauth2/v3/userinfo";
5
6
  export declare const DEFAULT_GOOGLE_AUTH_SCOPES: string[];
6
- export interface GoogleUser {
7
- id: string;
8
- email: string;
9
- emailVerified: boolean;
10
- name: string;
7
+ export interface GoogleUser extends AuthUser {
8
+ provider: 'google';
11
9
  givenName?: string;
12
10
  familyName?: string;
13
- picture?: string;
14
11
  locale?: string;
15
12
  }
16
13
  export interface GoogleAuthTokens {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GoogleAuthClient = exports.DEFAULT_GOOGLE_AUTH_SCOPES = exports.GOOGLE_USERINFO_ENDPOINT = exports.GOOGLE_TOKEN_ENDPOINT = exports.GOOGLE_AUTHORIZATION_ENDPOINT = void 0;
4
4
  exports.createInMemoryGoogleTokenStore = createInMemoryGoogleTokenStore;
5
5
  exports.createGoogleAuthTokenStore = createGoogleAuthTokenStore;
6
+ const identity_js_1 = require("./identity.js");
6
7
  const sha2_js_1 = require("@noble/hashes/sha2.js");
7
8
  const utils_js_1 = require("@noble/hashes/utils.js");
8
9
  const cloud_storage_js_1 = require("../backups/cloud-storage.js");
@@ -309,15 +310,28 @@ class GoogleAuthClient {
309
310
  throw new Error(`Failed to fetch Google user profile (${res.status}).`);
310
311
  }
311
312
  const raw = (await res.json());
313
+ const email = raw.email ? String(raw.email).trim().toLowerCase() : '';
314
+ const emailVerified = Boolean(raw.email_verified ?? true);
315
+ const sub = String(raw.sub || raw.id || 'google_user');
316
+ const id = (0, identity_js_1.resolveUnifiedUserId)({ id: sub, email, emailVerified }, 'google');
317
+ const name = raw.name || raw.email || 'Google User';
318
+ const avatarUrl = raw.picture || null;
312
319
  return {
313
- id: raw.sub,
314
- email: raw.email,
315
- emailVerified: Boolean(raw.email_verified),
316
- name: raw.name || raw.email || 'Google User',
320
+ id,
321
+ userId: id,
322
+ email,
323
+ emailVerified,
324
+ name,
325
+ displayName: name,
326
+ avatarUrl,
327
+ picture: avatarUrl,
328
+ provider: 'google',
329
+ providerAccountId: sub,
317
330
  givenName: raw.given_name,
318
331
  familyName: raw.family_name,
319
- picture: raw.picture,
320
332
  locale: raw.locale,
333
+ rawProfile: raw,
334
+ createdAt: Date.now(),
321
335
  };
322
336
  }
323
337
  createDriveBackupStorage() {
@@ -0,0 +1,42 @@
1
+ export declare const DEFAULT_UNIFIED_EMAIL_NAMESPACE = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
2
+ export type SupportedAuthProvider = 'google' | 'github' | 'microsoft' | 'apple' | 'local';
3
+ /**
4
+ * Standardized first-class user identity across all auth providers in local-lite.
5
+ * Every provider client natively resolves and returns this canonical model.
6
+ */
7
+ export interface AuthUser {
8
+ /** Canonical deterministic UUID across all providers with the same verified email */
9
+ id: string;
10
+ /** Alias for id to ensure compatibility with session records and sync workers */
11
+ userId: string;
12
+ email: string;
13
+ emailVerified: boolean;
14
+ name: string;
15
+ displayName: string;
16
+ avatarUrl?: string | null;
17
+ picture?: string | null;
18
+ provider: SupportedAuthProvider;
19
+ providerAccountId: string;
20
+ rawProfile?: Record<string, any>;
21
+ createdAt?: number;
22
+ }
23
+ export type UnifiedAuthUser = AuthUser;
24
+ export interface IdentityResolverOptions {
25
+ namespace?: string;
26
+ requireVerifiedEmail?: boolean;
27
+ }
28
+ /**
29
+ * Resolves a canonical UUID for an incoming profile.
30
+ * If email is verified, hashes the normalized email against the UUIDv5 namespace.
31
+ * Falls back to provider-scoped deterministic ID if unverified or email is missing.
32
+ */
33
+ export declare function resolveUnifiedUserId(profile: {
34
+ id: string | number;
35
+ email?: string | null;
36
+ emailVerified?: boolean;
37
+ }, provider: SupportedAuthProvider, options?: IdentityResolverOptions): string;
38
+ /**
39
+ * Standardizes raw user records from Google, GitHub, Microsoft, Apple, or local auth
40
+ * into a single unified user object with a canonical `id` / `userId`.
41
+ */
42
+ export declare function createUnifiedAuthUser(rawUser: Record<string, any>, provider: SupportedAuthProvider, options?: IdentityResolverOptions): AuthUser;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_UNIFIED_EMAIL_NAMESPACE = void 0;
4
+ exports.resolveUnifiedUserId = resolveUnifiedUserId;
5
+ exports.createUnifiedAuthUser = createUnifiedAuthUser;
6
+ const uuid_1 = require("uuid");
7
+ exports.DEFAULT_UNIFIED_EMAIL_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
8
+ /**
9
+ * Resolves a canonical UUID for an incoming profile.
10
+ * If email is verified, hashes the normalized email against the UUIDv5 namespace.
11
+ * Falls back to provider-scoped deterministic ID if unverified or email is missing.
12
+ */
13
+ function resolveUnifiedUserId(profile, provider, options) {
14
+ const ns = options?.namespace || exports.DEFAULT_UNIFIED_EMAIL_NAMESPACE;
15
+ const requireVerified = options?.requireVerifiedEmail ?? true;
16
+ const isVerified = !requireVerified || profile.emailVerified === true;
17
+ if (isVerified && profile.email && profile.email.trim().length > 0) {
18
+ return (0, uuid_1.v5)(profile.email.trim().toLowerCase(), ns);
19
+ }
20
+ return (0, uuid_1.v5)(`${provider}:${profile.id}`, ns);
21
+ }
22
+ /**
23
+ * Standardizes raw user records from Google, GitHub, Microsoft, Apple, or local auth
24
+ * into a single unified user object with a canonical `id` / `userId`.
25
+ */
26
+ function createUnifiedAuthUser(rawUser, provider, options) {
27
+ const emailRaw = typeof rawUser.email === 'string' ? rawUser.email : undefined;
28
+ const email = emailRaw ? emailRaw.trim().toLowerCase() : '';
29
+ const emailVerified = rawUser.emailVerified === true ||
30
+ rawUser.email_verified === true ||
31
+ provider === 'microsoft' ||
32
+ provider === 'github';
33
+ const providerAccountId = String(rawUser.providerAccountId ?? rawUser.id ?? rawUser.sub ?? rawUser.userId ?? '');
34
+ const id = resolveUnifiedUserId({ id: providerAccountId, email, emailVerified }, provider, options);
35
+ const name = typeof rawUser.name === 'string' && rawUser.name.trim()
36
+ ? rawUser.name.trim()
37
+ : typeof rawUser.displayName === 'string' && rawUser.displayName.trim()
38
+ ? rawUser.displayName.trim()
39
+ : typeof rawUser.login === 'string'
40
+ ? rawUser.login
41
+ : email.split('@')[0] || 'User';
42
+ const avatarUrl = typeof rawUser.picture === 'string'
43
+ ? rawUser.picture
44
+ : typeof rawUser.avatarUrl === 'string'
45
+ ? rawUser.avatarUrl
46
+ : typeof rawUser.avatar_url === 'string'
47
+ ? rawUser.avatar_url
48
+ : null;
49
+ return {
50
+ id,
51
+ userId: id,
52
+ email,
53
+ emailVerified,
54
+ name,
55
+ displayName: name,
56
+ avatarUrl,
57
+ picture: avatarUrl,
58
+ provider,
59
+ providerAccountId,
60
+ rawProfile: rawUser,
61
+ createdAt: typeof rawUser.createdAt === 'number' ? rawUser.createdAt : Date.now(),
62
+ };
63
+ }
@@ -4,3 +4,5 @@ export * from './github.js';
4
4
  export * from './apple.js';
5
5
  export * from './session.js';
6
6
  export * from './local.js';
7
+ export * from './identity.js';
8
+ export * from './unified.js';
@@ -20,3 +20,5 @@ __exportStar(require("./github.js"), exports);
20
20
  __exportStar(require("./apple.js"), exports);
21
21
  __exportStar(require("./session.js"), exports);
22
22
  __exportStar(require("./local.js"), exports);
23
+ __exportStar(require("./identity.js"), exports);
24
+ __exportStar(require("./unified.js"), exports);
@@ -1,13 +1,11 @@
1
+ import { type AuthUser } from './identity.js';
1
2
  import { OneDriveBackupStorage, OneDriveBackupClient, type OneDriveBackupClientOptions } from '../backups/onedrive.js';
2
3
  export declare const MICROSOFT_GRAPH_ENDPOINT = "https://graph.microsoft.com/v1.0";
3
4
  export declare const DEFAULT_MICROSOFT_AUTH_SCOPES: string[];
4
- export interface MicrosoftUser {
5
- id: string;
6
- email: string;
7
- name: string;
5
+ export interface MicrosoftUser extends AuthUser {
6
+ provider: 'microsoft';
8
7
  givenName?: string;
9
8
  familyName?: string;
10
- picture?: string;
11
9
  userPrincipalName?: string;
12
10
  }
13
11
  export interface MicrosoftAuthTokens {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MicrosoftAuthClient = exports.DEFAULT_MICROSOFT_AUTH_SCOPES = exports.MICROSOFT_GRAPH_ENDPOINT = void 0;
4
4
  exports.createInMemoryMicrosoftTokenStore = createInMemoryMicrosoftTokenStore;
5
5
  exports.createMicrosoftAuthTokenStore = createMicrosoftAuthTokenStore;
6
+ const identity_js_1 = require("./identity.js");
6
7
  const sha2_js_1 = require("@noble/hashes/sha2.js");
7
8
  const utils_js_1 = require("@noble/hashes/utils.js");
8
9
  const onedrive_js_1 = require("../backups/onedrive.js");
@@ -299,14 +300,26 @@ class MicrosoftAuthClient {
299
300
  throw new Error(`Failed to fetch Microsoft user profile (${res.status}).`);
300
301
  }
301
302
  const raw = (await res.json());
302
- const email = raw.mail || raw.userPrincipalName || `${raw.id}@microsoft.account`;
303
+ const email = (raw.mail || raw.userPrincipalName || '').trim().toLowerCase();
304
+ const sub = String(raw.id || raw.sub || 'microsoft_user');
305
+ const id = (0, identity_js_1.resolveUnifiedUserId)({ id: sub, email, emailVerified: true }, 'microsoft');
306
+ const name = raw.displayName || email || 'Microsoft User';
303
307
  return {
304
- id: raw.id,
308
+ id,
309
+ userId: id,
305
310
  email,
306
- name: raw.displayName || raw.givenName || email,
311
+ emailVerified: true,
312
+ name,
313
+ displayName: name,
314
+ avatarUrl: null,
315
+ picture: null,
316
+ provider: 'microsoft',
317
+ providerAccountId: sub,
307
318
  givenName: raw.givenName,
308
319
  familyName: raw.surname,
309
320
  userPrincipalName: raw.userPrincipalName,
321
+ rawProfile: raw,
322
+ createdAt: Date.now(),
310
323
  };
311
324
  }
312
325
  createOneDriveBackupStorage() {
@@ -75,6 +75,10 @@ export declare class SessionManager {
75
75
  * Retrieves the authenticated user profile object, or null if signed out.
76
76
  */
77
77
  getUser<TUser = any>(): Promise<TUser | null>;
78
+ /**
79
+ * Retrieves a session record by its canonical userId.
80
+ */
81
+ getSessionByUserId<TUser = any>(userId: string): Promise<SessionRecord<TUser> | null>;
78
82
  /**
79
83
  * Updates last active timestamp.
80
84
  */
@@ -84,7 +84,16 @@ class SessionManager {
84
84
  * Creates or updates a user session, persisting it to local SQLite so it remains available offline.
85
85
  */
86
86
  async createSession(options) {
87
- const id = options.id || `sess_${(0, uuid_js_1.generateUUID)()}`;
87
+ let id = options.id;
88
+ if (!id) {
89
+ const existing = await this.db.execute(`SELECT id FROM ${this.sqlTableName} WHERE user_id = ? LIMIT 1;`, [options.userId]);
90
+ if (existing && existing.length > 0) {
91
+ id = String(existing[0].id);
92
+ }
93
+ else {
94
+ id = `sess_${(0, uuid_js_1.generateUUID)()}`;
95
+ }
96
+ }
88
97
  const now = Date.now();
89
98
  const offlineDuration = options.offlineDurationMs !== undefined
90
99
  ? options.offlineDurationMs
@@ -179,6 +188,15 @@ class SessionManager {
179
188
  const session = await this.getActiveSession();
180
189
  return session ? session.user : null;
181
190
  }
191
+ /**
192
+ * Retrieves a session record by its canonical userId.
193
+ */
194
+ async getSessionByUserId(userId) {
195
+ const rows = await this.db.execute(`SELECT * FROM ${this.sqlTableName} WHERE user_id = ? LIMIT 1;`, [userId]);
196
+ if (!rows || rows.length === 0)
197
+ return null;
198
+ return mapSessionRow(rows[0]);
199
+ }
182
200
  /**
183
201
  * Updates last active timestamp.
184
202
  */
@@ -0,0 +1,73 @@
1
+ import { GoogleAuthClient } from './google.js';
2
+ import { GitHubAuthClient } from './github.js';
3
+ import { MicrosoftAuthClient } from './microsoft.js';
4
+ import { AppleAuthClient } from './apple.js';
5
+ import { LocalAuthEngine } from './local.js';
6
+ import { SessionManager, SessionRecord } from './session.js';
7
+ import { SupportedAuthProvider, UnifiedAuthUser } from './identity.js';
8
+ export interface UnifiedAuthConfig {
9
+ google?: GoogleAuthClient;
10
+ github?: GitHubAuthClient;
11
+ microsoft?: MicrosoftAuthClient;
12
+ apple?: AppleAuthClient;
13
+ local?: LocalAuthEngine;
14
+ sessionManager?: SessionManager;
15
+ /**
16
+ * Whether to unify user identity across providers by verified email.
17
+ * Default: true
18
+ */
19
+ unifyByEmail?: boolean;
20
+ /**
21
+ * Custom UUIDv5 namespace for deriving email-based user IDs.
22
+ * Default: DEFAULT_UNIFIED_EMAIL_NAMESPACE ('6ba7b810-9dad-11d1-80b4-00c04fd430c8')
23
+ */
24
+ emailNamespace?: string;
25
+ }
26
+ export type AuthStateChangeListener = (user: UnifiedAuthUser | null) => void;
27
+ /**
28
+ * High-level orchestrator that unifies multiple OAuth providers (Google, GitHub,
29
+ * Microsoft, Apple) and local auth into a single consistent user identity model.
30
+ */
31
+ export declare class UnifiedAuthManager {
32
+ private google?;
33
+ private github?;
34
+ private microsoft?;
35
+ private apple?;
36
+ private local?;
37
+ private sessionManager?;
38
+ private unifyByEmail;
39
+ private emailNamespace?;
40
+ private listeners;
41
+ private unsubscribers;
42
+ constructor(config: UnifiedAuthConfig);
43
+ private bindProviderListeners;
44
+ private notify;
45
+ /**
46
+ * Subscribes to global unified authentication state changes.
47
+ */
48
+ onAuthStateChange(listener: AuthStateChangeListener): () => void;
49
+ /**
50
+ * Authenticates using the specified provider and automatically establishes a unified session.
51
+ */
52
+ signIn(provider: SupportedAuthProvider, credentials?: any): Promise<UnifiedAuthUser | null>;
53
+ /**
54
+ * Retrieves the currently authenticated unified user.
55
+ */
56
+ getUser(): Promise<UnifiedAuthUser | null>;
57
+ /**
58
+ * Retrieves the active SQLite session record.
59
+ */
60
+ getSession(): Promise<SessionRecord<UnifiedAuthUser> | null>;
61
+ /**
62
+ * Checks whether there is an active session or signed-in provider.
63
+ */
64
+ isAuthenticated(): Promise<boolean>;
65
+ /**
66
+ * Signs out of the active session and all configured providers.
67
+ */
68
+ signOut(): Promise<void>;
69
+ /**
70
+ * Cleans up all event listeners.
71
+ */
72
+ destroy(): void;
73
+ }