@umituz/react-native-firebase 3.0.3 → 3.0.5

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.
Files changed (74) hide show
  1. package/package.json +7 -1
  2. package/src/domains/account-deletion/index.ts +15 -10
  3. package/src/domains/account-deletion/infrastructure/services/account-deletion.service.ts +226 -26
  4. package/src/domains/account-deletion/infrastructure/services/reauthentication.service.ts +160 -0
  5. package/src/domains/auth/domain/value-objects/FirebaseAuthConfig.ts +1 -1
  6. package/src/domains/auth/index.ts +156 -6
  7. package/src/domains/auth/infrastructure/config/FirebaseAuthClient.ts +60 -48
  8. package/src/domains/auth/infrastructure/config/initializers/FirebaseAuthInitializer.ts +41 -5
  9. package/src/domains/auth/presentation/hooks/useGoogleOAuth.ts +115 -20
  10. package/src/domains/firestore/domain/constants/QuotaLimits.ts +101 -0
  11. package/src/domains/firestore/domain/entities/QuotaMetrics.ts +26 -0
  12. package/src/domains/firestore/domain/entities/RequestLog.ts +28 -0
  13. package/src/domains/firestore/domain/services/QuotaCalculator.ts +71 -0
  14. package/src/domains/firestore/index.ts +86 -31
  15. package/src/domains/firestore/infrastructure/config/FirestoreClient.ts +82 -45
  16. package/src/domains/firestore/infrastructure/config/initializers/FirebaseFirestoreInitializer.ts +249 -4
  17. package/src/domains/firestore/infrastructure/middleware/QueryDeduplicationMiddleware.ts +312 -0
  18. package/src/domains/firestore/infrastructure/middleware/QuotaTrackingMiddleware.ts +95 -0
  19. package/src/domains/firestore/infrastructure/repositories/BasePaginatedRepository.ts +7 -1
  20. package/src/domains/firestore/infrastructure/repositories/BaseQueryRepository.ts +34 -8
  21. package/src/domains/firestore/infrastructure/repositories/BaseRepository.ts +48 -9
  22. package/src/domains/firestore/infrastructure/services/RequestLoggerService.ts +165 -0
  23. package/src/domains/firestore/presentation/hooks/index.ts +10 -0
  24. package/src/domains/firestore/presentation/hooks/useFirestoreMutation.ts +1 -1
  25. package/src/domains/firestore/presentation/hooks/useFirestoreQuery.ts +1 -1
  26. package/src/domains/firestore/presentation/hooks/useSmartFirestoreSnapshot.ts +361 -0
  27. package/src/domains/firestore/presentation/query-keys/createFirestoreKeys.ts +32 -0
  28. package/src/domains/firestore/presentation/query-keys/index.ts +1 -0
  29. package/src/domains/firestore/utils/deduplication/pending-query-manager.util.ts +119 -0
  30. package/src/domains/firestore/utils/deduplication/query-key-generator.util.ts +34 -0
  31. package/src/domains/firestore/utils/deduplication/timer-manager.util.ts +83 -0
  32. package/src/index.ts +2 -30
  33. package/src/shared/domain/utils/calculation.util.ts +305 -17
  34. package/src/shared/domain/utils/error-handlers/error-messages.ts +0 -11
  35. package/src/shared/domain/utils/index.ts +5 -0
  36. package/src/shared/infrastructure/config/base/ClientStateManager.ts +82 -0
  37. package/src/shared/infrastructure/config/base/ServiceClientSingleton.ts +136 -20
  38. package/src/shared/infrastructure/config/clients/FirebaseClientSingleton.ts +1 -1
  39. package/src/shared/infrastructure/config/initializers/FirebaseAppInitializer.ts +9 -0
  40. package/src/shared/infrastructure/config/services/FirebaseInitializationService.ts +1 -1
  41. package/src/shared/infrastructure/config/state/FirebaseClientState.ts +14 -36
  42. package/src/application/auth/index.ts +0 -10
  43. package/src/application/auth/use-cases/index.ts +0 -6
  44. package/src/domains/account-deletion/domain/index.ts +0 -8
  45. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor.ts +0 -79
  46. package/src/domains/account-deletion/infrastructure/services/AccountDeletionTypes.ts +0 -32
  47. package/src/domains/auth/domain.ts +0 -16
  48. package/src/domains/auth/infrastructure/config/index.ts +0 -2
  49. package/src/domains/auth/infrastructure/config/initializers/index.ts +0 -1
  50. package/src/domains/auth/infrastructure/services/index.ts +0 -16
  51. package/src/domains/auth/infrastructure/services/utils/index.ts +0 -1
  52. package/src/domains/auth/infrastructure/stores/index.ts +0 -1
  53. package/src/domains/auth/infrastructure/utils/index.ts +0 -1
  54. package/src/domains/auth/infrastructure.ts +0 -11
  55. package/src/domains/auth/presentation/hooks/useAppleAuth.ts +0 -82
  56. package/src/domains/auth/presentation.ts +0 -31
  57. package/src/domains/firestore/domain/entities/Collection.ts +0 -122
  58. package/src/domains/firestore/domain/entities/CollectionFactory.ts +0 -55
  59. package/src/domains/firestore/domain/entities/CollectionHelpers.ts +0 -143
  60. package/src/domains/firestore/domain/entities/CollectionUtils.ts +0 -72
  61. package/src/domains/firestore/domain/entities/CollectionValidation.ts +0 -138
  62. package/src/domains/firestore/domain/index.ts +0 -61
  63. package/src/domains/firestore/domain/value-objects/QueryOptions.ts +0 -143
  64. package/src/domains/firestore/domain/value-objects/QueryOptionsFactory.ts +0 -95
  65. package/src/domains/firestore/domain/value-objects/QueryOptionsHelpers.ts +0 -110
  66. package/src/domains/firestore/domain/value-objects/WhereClause.ts +0 -114
  67. package/src/domains/firestore/domain/value-objects/WhereClauseFactory.ts +0 -101
  68. package/src/domains/firestore/domain/value-objects/WhereClauseHelpers.ts +0 -123
  69. package/src/domains/firestore/domain/value-objects/WhereClauseValidation.ts +0 -83
  70. package/src/shared/infrastructure/base/ErrorHandler.ts +0 -81
  71. package/src/shared/infrastructure/base/ServiceBase.ts +0 -62
  72. package/src/shared/infrastructure/base/TypedGuard.ts +0 -131
  73. package/src/shared/infrastructure/base/index.ts +0 -34
  74. package/src/shared/types/firebase.types.ts +0 -274
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Client State Manager
3
+ *
4
+ * Generic state management for Firebase service clients.
5
+ * Provides centralized state tracking for initialization status, errors, and instances.
6
+ *
7
+ * @template TInstance - The service instance type (e.g., FirebaseApp, Firestore, Auth)
8
+ */
9
+
10
+ interface ClientState<TInstance> {
11
+ instance: TInstance | null;
12
+ initializationError: string | null;
13
+ isInitialized: boolean;
14
+ }
15
+
16
+ /**
17
+ * Generic client state manager
18
+ * Handles initialization state, error tracking, and instance management
19
+ */
20
+ export class ClientStateManager<TInstance> {
21
+ private state: ClientState<TInstance>;
22
+
23
+ constructor() {
24
+ this.state = {
25
+ instance: null,
26
+ initializationError: null,
27
+ isInitialized: false,
28
+ };
29
+ }
30
+
31
+ /**
32
+ * Get the current instance
33
+ */
34
+ getInstance(): TInstance | null {
35
+ return this.state.instance;
36
+ }
37
+
38
+ /**
39
+ * Set the instance
40
+ */
41
+ setInstance(instance: TInstance | null): void {
42
+ this.state.instance = instance;
43
+ this.state.isInitialized = instance !== null;
44
+ }
45
+
46
+ /**
47
+ * Check if the service is initialized
48
+ */
49
+ isInitialized(): boolean {
50
+ return this.state.isInitialized;
51
+ }
52
+
53
+ /**
54
+ * Get the initialization error if any
55
+ */
56
+ getInitializationError(): string | null {
57
+ return this.state.initializationError;
58
+ }
59
+
60
+ /**
61
+ * Set the initialization error
62
+ */
63
+ setInitializationError(error: string | null): void {
64
+ this.state.initializationError = error;
65
+ }
66
+
67
+ /**
68
+ * Reset the state
69
+ */
70
+ reset(): void {
71
+ this.state.instance = null;
72
+ this.state.initializationError = null;
73
+ this.state.isInitialized = false;
74
+ }
75
+
76
+ /**
77
+ * Get the current state (read-only)
78
+ */
79
+ getState(): Readonly<ClientState<TInstance>> {
80
+ return this.state;
81
+ }
82
+ }
@@ -1,39 +1,155 @@
1
1
  /**
2
- * Service Client Singleton Base
3
- * Base singleton pattern for service clients
2
+ * Service Client Singleton Base Class
4
3
  *
5
- * Max lines: 150 (enforced for maintainability)
4
+ * Provides a generic singleton pattern for Firebase service clients.
5
+ * Eliminates code duplication across FirebaseClient, FirestoreClient, FirebaseAuthClient.
6
+ *
7
+ * Features:
8
+ * - Generic singleton pattern
9
+ * - Initialization state management
10
+ * - Error handling and tracking
11
+ * - Automatic cleanup
12
+ *
13
+ * @template TInstance - The service instance type (e.g., Firestore, Auth)
14
+ * @template TConfig - The configuration type (optional)
15
+ */
16
+
17
+ interface ServiceClientState<TInstance> {
18
+ instance: TInstance | null;
19
+ initializationError: string | null;
20
+ isInitialized: boolean;
21
+ }
22
+
23
+ interface ServiceClientOptions<TInstance, TConfig = unknown> {
24
+ serviceName: string;
25
+ initializer?: (config?: TConfig) => TInstance | null;
26
+ autoInitializer?: () => TInstance | null;
27
+ }
28
+
29
+ /**
30
+ * Generic service client singleton base class
31
+ * Provides common initialization, state management, and error handling
6
32
  */
33
+ export class ServiceClientSingleton<TInstance, TConfig = unknown> {
34
+ protected state: ServiceClientState<TInstance>;
35
+ private readonly options: ServiceClientOptions<TInstance, TConfig>;
36
+ private initInProgress = false;
37
+
38
+ constructor(options: ServiceClientOptions<TInstance, TConfig>) {
39
+ this.options = options;
40
+ this.state = {
41
+ instance: null,
42
+ initializationError: null,
43
+ isInitialized: false,
44
+ };
45
+ }
46
+
47
+ /**
48
+ * Initialize the service with optional configuration
49
+ */
50
+ initialize(config?: TConfig): TInstance | null {
51
+ if (this.state.isInitialized && this.state.instance) {
52
+ return this.state.instance;
53
+ }
54
+
55
+ if (this.state.initializationError) {
56
+ return null;
57
+ }
58
+
59
+ // Prevent concurrent initialization attempts
60
+ if (this.initInProgress) {
61
+ return null;
62
+ }
7
63
 
8
- export abstract class ServiceClientSingleton<TInstance, TConfig = unknown> {
9
- protected instance: TInstance | null = null;
10
- protected initializationError: Error | null = null;
64
+ this.initInProgress = true;
65
+ try {
66
+ const instance = this.options.initializer ? this.options.initializer(config) : null;
67
+ if (instance) {
68
+ this.state.instance = instance;
69
+ this.state.isInitialized = true;
70
+ }
71
+ return instance;
72
+ } catch (error) {
73
+ const errorMessage = error instanceof Error ? error.message : `Failed to initialize ${this.options.serviceName}`;
74
+ this.state.initializationError = errorMessage;
75
+ return null;
76
+ } finally {
77
+ this.initInProgress = false;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Get the service instance, auto-initializing if needed
83
+ */
84
+ getInstance(autoInit: boolean = false): TInstance | null {
85
+ if (this.state.instance) {
86
+ return this.state.instance;
87
+ }
11
88
 
12
- protected constructor() {}
89
+ if (this.state.initializationError) {
90
+ return null;
91
+ }
13
92
 
14
- abstract initialize(config?: TConfig): Promise<TInstance> | TInstance;
93
+ // Prevent concurrent auto-initialization attempts
94
+ if (this.initInProgress) {
95
+ return null;
96
+ }
15
97
 
16
- getInstance(): TInstance {
17
- if (!this.instance) {
18
- throw new Error('Service not initialized. Call initialize() first.');
98
+ if (autoInit && this.options.autoInitializer) {
99
+ this.initInProgress = true;
100
+ try {
101
+ const instance = this.options.autoInitializer();
102
+ if (instance) {
103
+ this.state.instance = instance;
104
+ this.state.isInitialized = true;
105
+ }
106
+ return instance;
107
+ } catch (error) {
108
+ const errorMessage = error instanceof Error ? error.message : `Failed to initialize ${this.options.serviceName}`;
109
+ this.state.initializationError = errorMessage;
110
+ } finally {
111
+ this.initInProgress = false;
112
+ }
19
113
  }
20
- return this.instance;
114
+
115
+ return null;
21
116
  }
22
117
 
118
+ /**
119
+ * Check if the service is initialized
120
+ */
23
121
  isInitialized(): boolean {
24
- return this.instance !== null;
122
+ return this.state.isInitialized;
25
123
  }
26
124
 
27
- getInitializationError(): Error | null {
28
- return this.initializationError;
125
+ /**
126
+ * Get the initialization error if any
127
+ */
128
+ getInitializationError(): string | null {
129
+ return this.state.initializationError;
29
130
  }
30
131
 
31
- setError(message: string): void {
32
- this.initializationError = new Error(message);
132
+ /**
133
+ * Reset the service state
134
+ */
135
+ reset(): void {
136
+ this.state.instance = null;
137
+ this.state.initializationError = null;
138
+ this.state.isInitialized = false;
139
+ this.initInProgress = false;
33
140
  }
34
141
 
35
- reset(): void {
36
- this.instance = null;
37
- this.initializationError = null;
142
+ /**
143
+ * Get the current instance without initialization
144
+ */
145
+ protected getCurrentInstance(): TInstance | null {
146
+ return this.state.instance;
147
+ }
148
+
149
+ /**
150
+ * Set initialization error
151
+ */
152
+ protected setError(error: string): void {
153
+ this.state.initializationError = error;
38
154
  }
39
155
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  import type { FirebaseConfig } from '../../../domain/value-objects/FirebaseConfig';
7
7
  import type { IFirebaseClient } from '../../../../application/ports/IFirebaseClient';
8
- import type { FirebaseApp } from 'firebase/app';
8
+ import type { FirebaseApp } from '../initializers/FirebaseAppInitializer';
9
9
  import { FirebaseClientState } from '../state/FirebaseClientState';
10
10
  import { FirebaseInitializationOrchestrator } from '../orchestrators/FirebaseInitializationOrchestrator';
11
11
 
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Firebase App Initializer
3
+ *
4
+ * Single Responsibility: Expose Firebase App type
5
+ */
6
+
7
+ import type { FirebaseApp as FirebaseAppType } from 'firebase/app';
8
+
9
+ export type FirebaseApp = FirebaseAppType;
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { FirebaseConfig } from '../../../domain/value-objects/FirebaseConfig';
7
- import type { FirebaseApp } from 'firebase/app';
7
+ import type { FirebaseApp } from '../initializers/FirebaseAppInitializer';
8
8
  import { FirebaseClientSingleton } from '../clients/FirebaseClientSingleton';
9
9
  import { loadFirebaseConfig } from '../FirebaseConfigLoader';
10
10
 
@@ -1,42 +1,20 @@
1
- import type { FirebaseApp } from 'firebase/app';
2
-
3
- export class FirebaseClientState {
4
- private app: FirebaseApp | null = null;
5
- private initializationError: string | null = null;
6
- private isInitializedFlag = false;
7
-
1
+ /**
2
+ * Firebase Client State Manager
3
+ * Manages the state of Firebase initialization
4
+ *
5
+ * Single Responsibility: Only manages initialization state
6
+ * Uses generic ClientStateManager for shared functionality
7
+ */
8
+
9
+ import type { FirebaseApp } from '../initializers/FirebaseAppInitializer';
10
+ import { ClientStateManager } from '../base/ClientStateManager';
11
+
12
+ export class FirebaseClientState extends ClientStateManager<FirebaseApp> {
8
13
  getApp(): FirebaseApp | null {
9
- return this.app;
14
+ return this.getInstance();
10
15
  }
11
16
 
12
17
  setApp(app: FirebaseApp | null): void {
13
- this.app = app;
14
- this.isInitializedFlag = app !== null;
15
- }
16
-
17
- setInstance(app: FirebaseApp | null): void {
18
- this.setApp(app);
19
- }
20
-
21
- getInstance(): FirebaseApp | null {
22
- return this.getApp();
23
- }
24
-
25
- isInitialized(): boolean {
26
- return this.isInitializedFlag;
27
- }
28
-
29
- getInitializationError(): string | null {
30
- return this.initializationError;
31
- }
32
-
33
- setInitializationError(error: string | null): void {
34
- this.initializationError = error;
35
- }
36
-
37
- reset(): void {
38
- this.app = null;
39
- this.initializationError = null;
40
- this.isInitializedFlag = false;
18
+ this.setInstance(app);
41
19
  }
42
20
  }
@@ -1,10 +0,0 @@
1
- /**
2
- * Auth Application Layer
3
- * Domain-Driven Design (DDD) - Application Exports
4
- *
5
- * Application use cases and ports for authentication.
6
- * Coordinates domain services and infrastructure.
7
- */
8
-
9
- // Export types when files are available
10
- // TODO: Implement AuthPort and UseCases
@@ -1,6 +0,0 @@
1
- /**
2
- * Auth Use Cases
3
- * Application layer use cases for authentication
4
- */
5
-
6
- // TODO: Implement SignInUseCase and SignOutUseCase
@@ -1,8 +0,0 @@
1
- /**
2
- * Account Deletion Domain Layer
3
- * Domain-Driven Design (DDD) - Domain Exports
4
- *
5
- * Pure domain logic without infrastructure concerns.
6
- */
7
-
8
- // TODO: Implement UserValidationService
@@ -1,79 +0,0 @@
1
- /**
2
- * Account Deletion Executor
3
- * Handles Firebase account deletion with reauthentication support
4
- *
5
- * Max lines: 150 (enforced for maintainability)
6
- */
7
-
8
- import type { User } from 'firebase/auth';
9
- import type { AccountDeletionOptions } from '../../application/ports/reauthentication.types';
10
- import type { AccountDeletionResult } from './AccountDeletionTypes';
11
-
12
- export class AccountDeletionExecutor {
13
- private deletionInProgress = false;
14
-
15
- async deleteCurrentUser(_options: AccountDeletionOptions): Promise<AccountDeletionResult> {
16
- if (this.deletionInProgress) {
17
- return {
18
- success: false,
19
- error: {
20
- code: 'deletion-in-progress',
21
- message: 'Account deletion is already in progress',
22
- },
23
- };
24
- }
25
-
26
- this.deletionInProgress = true;
27
-
28
- try {
29
- // TODO: Implement actual deletion logic
30
- return {
31
- success: true,
32
- };
33
- } catch (error) {
34
- return {
35
- success: false,
36
- error: {
37
- code: 'deletion-failed',
38
- message: error instanceof Error ? error.message : 'Unknown error',
39
- },
40
- };
41
- } finally {
42
- this.deletionInProgress = false;
43
- }
44
- }
45
-
46
- async deleteUserAccount(user: User | null): Promise<AccountDeletionResult> {
47
- if (!user) {
48
- return {
49
- success: false,
50
- error: {
51
- code: 'no-user',
52
- message: 'No user provided',
53
- },
54
- };
55
- }
56
-
57
- try {
58
- await user.delete();
59
- return {
60
- success: true,
61
- };
62
- } catch (error) {
63
- return {
64
- success: false,
65
- error: {
66
- code: 'deletion-failed',
67
- message: error instanceof Error ? error.message : 'Unknown error',
68
- },
69
- };
70
- }
71
- }
72
-
73
- isDeletionInProgress(): boolean {
74
- return this.deletionInProgress;
75
- }
76
- }
77
-
78
- export const accountDeletionExecutor = new AccountDeletionExecutor();
79
- export const createAccountDeletionExecutor = () => new AccountDeletionExecutor();
@@ -1,32 +0,0 @@
1
- /**
2
- * Account Deletion Types
3
- * Single Responsibility: Define account deletion types
4
- *
5
- * Max lines: 150 (enforced for maintainability)
6
- */
7
-
8
- import type { Result } from '../../../../shared/domain/utils';
9
-
10
- /**
11
- * Account deletion result
12
- */
13
- export interface AccountDeletionResult extends Result<void> {
14
- readonly requiresReauth?: boolean;
15
- }
16
-
17
- /**
18
- * Reauthentication context
19
- */
20
- export interface ReauthenticationContext {
21
- readonly user: import('firebase/auth').User;
22
- readonly options: import('../../application/ports/reauthentication.types').AccountDeletionOptions;
23
- readonly originalUserId?: string;
24
- }
25
-
26
- /**
27
- * Reauthentication result
28
- */
29
- export interface ReauthenticationResult {
30
- readonly success: boolean;
31
- readonly error?: { code?: string; message?: string };
32
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Firebase Auth Domain Layer
3
- * Domain-Driven Design (DDD) - Domain Exports
4
- *
5
- * Pure domain logic without infrastructure concerns.
6
- * Exports domain entities, value objects, and domain services.
7
- */
8
-
9
- // Domain Value Objects
10
- export type { FirebaseAuthConfig } from './domain/value-objects/FirebaseAuthConfig';
11
-
12
- // Domain Entities
13
- export {
14
- isAnonymousUser,
15
- } from './domain/entities/AnonymousUser';
16
- export type { AnonymousUser } from './domain/entities/AnonymousUser';
@@ -1,2 +0,0 @@
1
- export * from './FirebaseAuthClient';
2
- export * from './initializers';
@@ -1 +0,0 @@
1
- export * from './FirebaseAuthInitializer';
@@ -1,16 +0,0 @@
1
- export * from './anonymous-auth.service';
2
- export * from './apple-auth.service';
3
- export * from './apple-auth.types';
4
- export * from './auth-listener.service';
5
- export * from './auth-utils.service';
6
- export * from './email-auth.service';
7
- export * from './google-auth.service';
8
- export * from './google-auth.types';
9
- export * from './google-oauth.service';
10
- export * from './password.service';
11
- export * from './user-document-builder.util';
12
- export * from './user-document.service';
13
- export * from './user-document.types';
14
- export * from './crypto.util';
15
- export * from './firestore-utils.service';
16
- export * from './utils';
@@ -1 +0,0 @@
1
- export * from './auth-result-converter.util';
@@ -1 +0,0 @@
1
- export * from './auth.store';
@@ -1 +0,0 @@
1
- export * from './auth-guard.util';
@@ -1,11 +0,0 @@
1
- /**
2
- * Auth Infrastructure Layer
3
- * Domain-Driven Design (DDD) - Infrastructure Exports
4
- *
5
- * Infrastructure implementations for authentication.
6
- */
7
-
8
- export * from './infrastructure/config';
9
- export * from './infrastructure/services';
10
- export * from './infrastructure/stores';
11
- export * from './infrastructure/utils';
@@ -1,82 +0,0 @@
1
- /**
2
- * useAppleAuth Hook
3
- * Handles Apple Sign-In using Firebase auth
4
- *
5
- * Max lines: 150 (enforced for maintainability)
6
- */
7
-
8
- import { useState, useCallback } from 'react';
9
- import { Platform } from 'react-native';
10
-
11
- export interface UseAppleAuthResult {
12
- signInWithApple: () => Promise<AppleAuthSignInResult>;
13
- appleLoading: boolean;
14
- appleAvailable: boolean;
15
- }
16
-
17
- export interface AppleAuthSignInResult {
18
- success: boolean;
19
- isNewUser?: boolean;
20
- error?: string;
21
- }
22
-
23
- /**
24
- * Check if Apple Sign-In is available
25
- */
26
- function isAppleAuthAvailable(): boolean {
27
- if (Platform.OS !== 'ios') {
28
- return false;
29
- }
30
-
31
- // Check if expo-apple-authentication is available
32
- try {
33
- // eslint-disable-next-line @typescript-eslint/no-require-imports
34
- const AppleAuthentication = require('expo-apple-authentication');
35
- return !!AppleAuthentication;
36
- } catch {
37
- return false;
38
- }
39
- }
40
-
41
- /**
42
- * Hook for Apple authentication
43
- */
44
- export function useAppleAuth(): UseAppleAuthResult {
45
- const [isLoading, setIsLoading] = useState(false);
46
-
47
- const appleAvailable = isAppleAuthAvailable();
48
-
49
- const signInWithApple = useCallback(async (): Promise<AppleAuthSignInResult> => {
50
- if (!appleAvailable) {
51
- return {
52
- success: false,
53
- error: 'Apple Sign-In is not available',
54
- };
55
- }
56
-
57
- setIsLoading(true);
58
-
59
- try {
60
- // TODO: Implement actual Apple Sign-In logic
61
- // This requires expo-apple-authentication
62
- return {
63
- success: true,
64
- isNewUser: false,
65
- };
66
- } catch (error) {
67
- const errorMessage = error instanceof Error ? error.message : 'Apple Sign-In failed';
68
- return {
69
- success: false,
70
- error: errorMessage,
71
- };
72
- } finally {
73
- setIsLoading(false);
74
- }
75
- }, [appleAvailable]);
76
-
77
- return {
78
- signInWithApple,
79
- appleLoading: isLoading,
80
- appleAvailable,
81
- };
82
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Firebase Auth Presentation Layer
3
- * Domain-Driven Design (DDD) - Presentation Exports
4
- *
5
- * React hooks for Firebase authentication.
6
- * Provides clean interface for UI components.
7
- */
8
-
9
- export { useFirebaseAuth } from './presentation/hooks/useFirebaseAuth';
10
- export type { UseFirebaseAuthResult } from './presentation/hooks/useFirebaseAuth';
11
-
12
- export { useAnonymousAuth } from './presentation/hooks/useAnonymousAuth';
13
- export type { UseAnonymousAuthResult } from './presentation/hooks/useAnonymousAuth';
14
-
15
- export { useSocialAuth } from './presentation/hooks/useSocialAuth';
16
- export type {
17
- SocialAuthConfig,
18
- SocialAuthResult,
19
- UseSocialAuthResult,
20
- } from './presentation/hooks/useSocialAuth';
21
-
22
- export { useGoogleOAuth } from './presentation/hooks/useGoogleOAuth';
23
- export type {
24
- UseGoogleOAuthResult,
25
- } from './presentation/hooks/useGoogleOAuth';
26
-
27
- export { useAppleAuth } from './presentation/hooks/useAppleAuth';
28
- export type {
29
- UseAppleAuthResult,
30
- AppleAuthSignInResult,
31
- } from './presentation/hooks/useAppleAuth';