@umituz/react-native-firebase 2.6.3 → 2.6.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.
- package/package.json +1 -1
- package/src/application/auth/index.ts +2 -34
- package/src/application/auth/use-cases/index.ts +1 -21
- package/src/domains/account-deletion/domain/index.ts +1 -8
- package/src/domains/account-deletion/index.ts +0 -42
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor.ts +79 -0
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionTypes.ts +0 -1
- package/src/domains/account-deletion/infrastructure/services/account-deletion.service.ts +2 -14
- package/src/domains/auth/index.ts +3 -12
- package/src/domains/auth/infrastructure/config/FirebaseAuthClient.ts +48 -60
- package/src/domains/auth/infrastructure/config/index.ts +2 -0
- package/src/domains/auth/infrastructure/config/initializers/index.ts +1 -0
- package/src/domains/auth/infrastructure/services/index.ts +16 -0
- package/src/domains/auth/infrastructure/services/utils/index.ts +1 -0
- package/src/domains/auth/infrastructure/stores/index.ts +1 -0
- package/src/domains/auth/infrastructure/utils/index.ts +1 -0
- package/src/domains/auth/infrastructure.ts +11 -0
- package/src/domains/auth/presentation/hooks/useGoogleOAuth.ts +18 -59
- package/src/domains/firestore/domain/entities/Collection.ts +0 -2
- package/src/domains/firestore/domain/index.ts +6 -2
- package/src/domains/firestore/domain/value-objects/WhereClause.ts +0 -14
- package/src/domains/firestore/index.ts +0 -1
- package/src/domains/firestore/infrastructure/config/FirestoreClient.ts +42 -60
- package/src/domains/firestore/presentation/hooks/useFirestoreMutation.ts +1 -1
- package/src/domains/firestore/presentation/hooks/useFirestoreQuery.ts +1 -1
- package/src/shared/infrastructure/base/ErrorHandler.ts +81 -0
- package/src/shared/infrastructure/base/ServiceBase.ts +62 -0
- package/src/shared/infrastructure/config/base/ServiceClientSingleton.ts +39 -0
- package/src/application/auth/ports/AuthPort.ts.bak +0 -164
- package/src/application/auth/ports/AuthPort_part_aa +0 -150
- package/src/application/auth/ports/AuthPort_part_ab +0 -14
- package/src/application/auth/use-cases/SignInUseCase.ts.bak +0 -253
- package/src/application/auth/use-cases/SignInUseCaseHelpers.ts +0 -0
- package/src/application/auth/use-cases/SignInUseCaseMain.ts +0 -0
- package/src/application/auth/use-cases/SignInUseCase_part_aa +0 -150
- package/src/application/auth/use-cases/SignInUseCase_part_ab +0 -103
- package/src/application/auth/use-cases/SignOutUseCase.ts.bak +0 -288
- package/src/application/auth/use-cases/SignOutUseCaseCleanup.ts +0 -0
- package/src/application/auth/use-cases/SignOutUseCaseMain.ts +0 -0
- package/src/application/auth/use-cases/SignOutUseCase_part_aa +0 -150
- package/src/application/auth/use-cases/SignOutUseCase_part_ab +0 -138
- package/src/domains/account-deletion/domain/services/UserValidationHelpers.ts.bak +0 -181
- package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_aa +0 -150
- package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_ab +0 -31
- package/src/domains/account-deletion/domain/services/UserValidationService.ts.bak +0 -286
- package/src/domains/account-deletion/domain/services/UserValidationService_part_aa +0 -150
- package/src/domains/account-deletion/domain/services/UserValidationService_part_ab +0 -136
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor.ts.bak +0 -230
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_aa +0 -150
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_ab +0 -80
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler.ts.bak +0 -174
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_aa +0 -150
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_ab +0 -24
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository.ts.bak +0 -266
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_aa +0 -150
- package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_ab +0 -116
- package/src/domains/account-deletion/infrastructure/services/reauthentication.service.ts.bak +0 -160
- package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_aa +0 -150
- package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_ab +0 -10
- package/src/domains/auth/infrastructure.ts.bak +0 -156
- package/src/domains/auth/infrastructure_part_aa +0 -150
- package/src/domains/auth/infrastructure_part_ab +0 -6
- package/src/domains/auth/presentation/hooks/GoogleOAuthHelpers.ts +0 -0
- package/src/domains/auth/presentation/hooks/GoogleOAuthHookService.ts.bak +0 -247
- package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_aa +0 -150
- package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_ab +0 -97
- package/src/domains/auth/presentation/hooks/GoogleOAuthService.ts +0 -0
- package/src/domains/firestore/domain/entities/Collection.ts.bak +0 -288
- package/src/domains/firestore/domain/entities/Collection_part_aa +0 -150
- package/src/domains/firestore/domain/entities/Collection_part_ab +0 -138
- package/src/domains/firestore/domain/entities/Document.ts.bak +0 -233
- package/src/domains/firestore/domain/entities/DocumentHelpers.ts +0 -0
- package/src/domains/firestore/domain/entities/DocumentMain.ts +0 -0
- package/src/domains/firestore/domain/entities/Document_part_aa +0 -150
- package/src/domains/firestore/domain/entities/Document_part_ab +0 -83
- package/src/domains/firestore/domain/services/QueryService.ts.bak +0 -182
- package/src/domains/firestore/domain/services/QueryServiceAnalysis.ts.bak +0 -169
- package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_aa +0 -150
- package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_ab +0 -19
- package/src/domains/firestore/domain/services/QueryServiceHelpers.ts.bak +0 -151
- package/src/domains/firestore/domain/services/QueryServiceHelpers_part_aa +0 -150
- package/src/domains/firestore/domain/services/QueryServiceHelpers_part_ab +0 -1
- package/src/domains/firestore/domain/services/QueryService_part_aa +0 -150
- package/src/domains/firestore/domain/services/QueryService_part_ab +0 -32
- package/src/domains/firestore/domain/value-objects/QueryOptions.ts.bak +0 -191
- package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization.ts.bak +0 -207
- package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_ab +0 -57
- package/src/domains/firestore/domain/value-objects/QueryOptionsValidation.ts.bak +0 -182
- package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_ab +0 -32
- package/src/domains/firestore/domain/value-objects/QueryOptions_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/QueryOptions_part_ab +0 -41
- package/src/domains/firestore/domain/value-objects/WhereClause.ts.bak +0 -299
- package/src/domains/firestore/domain/value-objects/WhereClauseFactory.ts.bak +0 -207
- package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_ab +0 -57
- package/src/domains/firestore/domain/value-objects/WhereClause_part_aa +0 -150
- package/src/domains/firestore/domain/value-objects/WhereClause_part_ab +0 -149
- package/src/shared/infrastructure/base/ErrorHandler.ts.bak +0 -189
- package/src/shared/infrastructure/base/ErrorHandler_part_aa +0 -150
- package/src/shared/infrastructure/base/ErrorHandler_part_ab +0 -39
- package/src/shared/infrastructure/base/ServiceBase.ts.bak +0 -220
- package/src/shared/infrastructure/base/ServiceBase_part_aa +0 -150
- package/src/shared/infrastructure/base/ServiceBase_part_ab +0 -70
- package/src/shared/infrastructure/config/base/ServiceClientSingleton.ts.bak +0 -155
- package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_aa +0 -150
- package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_ab +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-firebase",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5",
|
|
4
4
|
"description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -6,37 +6,5 @@
|
|
|
6
6
|
* Coordinates domain services and infrastructure.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
EmailCredentials,
|
|
12
|
-
SignInResult,
|
|
13
|
-
SignUpResult,
|
|
14
|
-
AuthPortOptions,
|
|
15
|
-
AuthPortConfig,
|
|
16
|
-
IAuthPortFactory,
|
|
17
|
-
} from './ports/AuthPort';
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
type IAuthPort,
|
|
21
|
-
createAuthPortConfig,
|
|
22
|
-
AuthPortFactory,
|
|
23
|
-
authPortFactory,
|
|
24
|
-
createAuthPort,
|
|
25
|
-
} from './ports/AuthPort';
|
|
26
|
-
|
|
27
|
-
// Use Cases
|
|
28
|
-
export type {
|
|
29
|
-
SignInUseCaseResult,
|
|
30
|
-
SignInOptions,
|
|
31
|
-
SignOutUseCaseResult,
|
|
32
|
-
SignOutOptions,
|
|
33
|
-
} from './use-cases';
|
|
34
|
-
|
|
35
|
-
export {
|
|
36
|
-
SignInUseCase,
|
|
37
|
-
createSignInUseCase,
|
|
38
|
-
createDefaultSignInUseCase,
|
|
39
|
-
SignOutUseCase,
|
|
40
|
-
createSignOutUseCase,
|
|
41
|
-
createDefaultSignOutUseCase,
|
|
42
|
-
} from './use-cases';
|
|
9
|
+
// Export types when files are available
|
|
10
|
+
// TODO: Implement AuthPort and UseCases
|
|
@@ -3,24 +3,4 @@
|
|
|
3
3
|
* Application layer use cases for authentication
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
SignInUseCaseResult,
|
|
8
|
-
SignInOptions,
|
|
9
|
-
} from './SignInUseCase';
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
SignInUseCase,
|
|
13
|
-
createSignInUseCase,
|
|
14
|
-
createDefaultSignInUseCase,
|
|
15
|
-
} from './SignInUseCase';
|
|
16
|
-
|
|
17
|
-
export type {
|
|
18
|
-
SignOutUseCaseResult,
|
|
19
|
-
SignOutOptions,
|
|
20
|
-
} from './SignOutUseCase';
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
SignOutUseCase,
|
|
24
|
-
createSignOutUseCase,
|
|
25
|
-
createDefaultSignOutUseCase,
|
|
26
|
-
} from './SignOutUseCase';
|
|
6
|
+
// TODO: Implement SignInUseCase and SignOutUseCase
|
|
@@ -3,13 +3,6 @@
|
|
|
3
3
|
* Domain-Driven Design (DDD) - Domain Exports
|
|
4
4
|
*
|
|
5
5
|
* Pure domain logic without infrastructure concerns.
|
|
6
|
-
* Exports domain services for account deletion operations.
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
|
-
//
|
|
10
|
-
export {
|
|
11
|
-
UserValidationService,
|
|
12
|
-
createUserValidationService,
|
|
13
|
-
userValidationService,
|
|
14
|
-
} from './services/UserValidationService';
|
|
15
|
-
export type { UserValidationResult } from './services/UserValidationService';
|
|
8
|
+
// TODO: Implement UserValidationService
|
|
@@ -5,21 +5,6 @@
|
|
|
5
5
|
* Domain-Driven Design (DDD) Architecture
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
// =============================================================================
|
|
9
|
-
// DOMAIN LAYER - Business Logic
|
|
10
|
-
// =============================================================================
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
UserValidationService,
|
|
14
|
-
createUserValidationService,
|
|
15
|
-
userValidationService,
|
|
16
|
-
} from './domain';
|
|
17
|
-
export type { UserValidationResult } from './domain';
|
|
18
|
-
|
|
19
|
-
// =============================================================================
|
|
20
|
-
// APPLICATION LAYER - Use Cases & Ports
|
|
21
|
-
// =============================================================================
|
|
22
|
-
|
|
23
8
|
export type {
|
|
24
9
|
AccountDeletionOptions,
|
|
25
10
|
ReauthenticationResult,
|
|
@@ -27,11 +12,6 @@ export type {
|
|
|
27
12
|
ReauthCredentialResult,
|
|
28
13
|
} from './application/ports/reauthentication.types';
|
|
29
14
|
|
|
30
|
-
// =============================================================================
|
|
31
|
-
// INFRASTRUCTURE LAYER - Implementation
|
|
32
|
-
// =============================================================================
|
|
33
|
-
|
|
34
|
-
// Main Service (Refactored)
|
|
35
15
|
export {
|
|
36
16
|
deleteCurrentUser,
|
|
37
17
|
deleteUserAccount,
|
|
@@ -41,25 +21,3 @@ export {
|
|
|
41
21
|
export type {
|
|
42
22
|
AccountDeletionResult,
|
|
43
23
|
} from './infrastructure/services/account-deletion.service';
|
|
44
|
-
|
|
45
|
-
// Deletion Components
|
|
46
|
-
export {
|
|
47
|
-
AccountDeletionRepository,
|
|
48
|
-
createAccountDeletionRepository,
|
|
49
|
-
accountDeletionRepository,
|
|
50
|
-
} from './infrastructure/services/AccountDeletionRepository';
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
AccountDeletionExecutor,
|
|
54
|
-
createAccountDeletionExecutor,
|
|
55
|
-
accountDeletionExecutor,
|
|
56
|
-
} from './infrastructure/services/AccountDeletionExecutor';
|
|
57
|
-
|
|
58
|
-
// Reauthentication Service
|
|
59
|
-
export {
|
|
60
|
-
getUserAuthProvider,
|
|
61
|
-
reauthenticateWithPassword,
|
|
62
|
-
reauthenticateWithGoogle,
|
|
63
|
-
reauthenticateWithApple,
|
|
64
|
-
getAppleReauthCredential,
|
|
65
|
-
} from './infrastructure/services/reauthentication.service';
|
|
@@ -0,0 +1,79 @@
|
|
|
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();
|
|
@@ -21,7 +21,6 @@ export interface ReauthenticationContext {
|
|
|
21
21
|
readonly user: import('firebase/auth').User;
|
|
22
22
|
readonly options: import('../../application/ports/reauthentication.types').AccountDeletionOptions;
|
|
23
23
|
readonly originalUserId?: string;
|
|
24
|
-
readonly repository: AccountDeletionRepository;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
/**
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Account Deletion Service
|
|
2
|
+
* Account Deletion Service
|
|
3
3
|
* Handles Firebase account deletion with reauthentication support
|
|
4
4
|
*
|
|
5
|
-
* This file now delegates to the new DDD architecture:
|
|
6
|
-
* - AccountDeletionExecutor for deletion logic
|
|
7
|
-
* - UserValidationService for validation
|
|
8
|
-
* - AccountDeletionRepository for persistence
|
|
9
|
-
*
|
|
10
5
|
* Max lines: 150 (enforced for maintainability)
|
|
11
6
|
*/
|
|
12
7
|
|
|
13
8
|
import type { User } from "firebase/auth";
|
|
14
9
|
import type { AccountDeletionOptions } from "../../application/ports/reauthentication.types";
|
|
15
10
|
import { accountDeletionExecutor } from "./AccountDeletionExecutor";
|
|
16
|
-
import type { AccountDeletionResult } from "./
|
|
11
|
+
import type { AccountDeletionResult } from "./AccountDeletionTypes";
|
|
17
12
|
|
|
18
|
-
/**
|
|
19
|
-
* Delete current user account
|
|
20
|
-
* Handles reauthentication automatically if enabled
|
|
21
|
-
*
|
|
22
|
-
* @param options - Deletion options including reauthentication settings
|
|
23
|
-
* @returns Result of deletion operation
|
|
24
|
-
*/
|
|
25
13
|
export async function deleteCurrentUser(
|
|
26
14
|
options: AccountDeletionOptions = { autoReauthenticate: true }
|
|
27
15
|
): Promise<AccountDeletionResult> {
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Firebase Auth Module
|
|
3
3
|
* Domain-Driven Design (DDD) Architecture
|
|
4
|
-
*
|
|
5
|
-
* Exports organized by DDD layers for better maintainability.
|
|
6
|
-
* Main re-exports everything for backward compatibility.
|
|
7
4
|
*/
|
|
8
5
|
|
|
9
|
-
//
|
|
10
|
-
// DOMAIN LAYER - Business Logic
|
|
11
|
-
// =============================================================================
|
|
6
|
+
// Domain Layer
|
|
12
7
|
export * from './domain';
|
|
13
8
|
|
|
14
|
-
//
|
|
15
|
-
// INFRASTRUCTURE LAYER - Implementation
|
|
16
|
-
// =============================================================================
|
|
9
|
+
// Infrastructure Layer
|
|
17
10
|
export * from './infrastructure';
|
|
18
11
|
|
|
19
|
-
//
|
|
20
|
-
// PRESENTATION LAYER - React Hooks
|
|
21
|
-
// =============================================================================
|
|
12
|
+
// Presentation Layer
|
|
22
13
|
export * from './presentation';
|
|
23
14
|
|
|
24
15
|
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { Auth } from 'firebase/auth';
|
|
8
|
+
import { getAuth as getFirebaseAuthFromFirebase } from 'firebase/auth';
|
|
8
9
|
import { getFirebaseApp } from '../../../../shared/infrastructure/config/services/FirebaseInitializationService';
|
|
9
|
-
import { FirebaseAuthInitializer } from './initializers/FirebaseAuthInitializer';
|
|
10
10
|
import type { FirebaseAuthConfig } from '../../domain/value-objects/FirebaseAuthConfig';
|
|
11
11
|
import { ServiceClientSingleton } from '../../../../shared/infrastructure/config/base/ServiceClientSingleton';
|
|
12
12
|
|
|
@@ -15,76 +15,64 @@ import { ServiceClientSingleton } from '../../../../shared/infrastructure/config
|
|
|
15
15
|
*/
|
|
16
16
|
class FirebaseAuthClientSingleton extends ServiceClientSingleton<Auth, FirebaseAuthConfig> {
|
|
17
17
|
private constructor() {
|
|
18
|
-
super(
|
|
19
|
-
serviceName: 'FirebaseAuth',
|
|
20
|
-
initializer: (config?: FirebaseAuthConfig) => {
|
|
21
|
-
const app = getFirebaseApp();
|
|
22
|
-
if (!app) {
|
|
23
|
-
this.setError('Firebase App is not initialized');
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
const auth = FirebaseAuthInitializer.initialize(app, config);
|
|
27
|
-
if (!auth) {
|
|
28
|
-
this.setError('Auth initialization returned null');
|
|
29
|
-
}
|
|
30
|
-
return auth;
|
|
31
|
-
},
|
|
32
|
-
});
|
|
18
|
+
super();
|
|
33
19
|
}
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
initialize(): Auth {
|
|
22
|
+
try {
|
|
23
|
+
const app = getFirebaseApp();
|
|
24
|
+
if (!app) {
|
|
25
|
+
this.setError('Firebase App is not initialized');
|
|
26
|
+
throw new Error('Firebase App is not initialized');
|
|
27
|
+
}
|
|
41
28
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
const auth = getFirebaseAuthFromFirebase(app);
|
|
30
|
+
this.instance = auth;
|
|
31
|
+
return auth;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
const errorMessage = error instanceof Error ? error.message : 'Auth initialization failed';
|
|
34
|
+
this.setError(errorMessage);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
47
37
|
}
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
getAuth(): Auth | null {
|
|
53
|
-
// Attempt initialization if not already initialized
|
|
54
|
-
if (!this.isInitialized() && !this.getInitializationError()) {
|
|
55
|
-
try {
|
|
56
|
-
const app = getFirebaseApp();
|
|
57
|
-
if (app) {
|
|
58
|
-
this.initialize();
|
|
59
|
-
}
|
|
60
|
-
} catch (error) {
|
|
61
|
-
// Silently handle auto-initialization errors
|
|
62
|
-
// The error will be stored in state for later retrieval
|
|
63
|
-
const errorMessage = error instanceof Error ? error.message : 'Auto-initialization failed';
|
|
64
|
-
this.setError(errorMessage);
|
|
65
|
-
}
|
|
39
|
+
getAuth(): Auth {
|
|
40
|
+
if (!this.isInitialized()) {
|
|
41
|
+
return this.initialize();
|
|
66
42
|
}
|
|
67
|
-
|
|
68
|
-
return this.getInstance(true);
|
|
43
|
+
return this.getInstance();
|
|
69
44
|
}
|
|
70
|
-
}
|
|
71
45
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
console.warn('[Firebase] Could not create FirebaseAuth client singleton.');
|
|
46
|
+
private static instance: FirebaseAuthClientSingleton | null = null;
|
|
47
|
+
|
|
48
|
+
static getInstance(): FirebaseAuthClientSingleton {
|
|
49
|
+
if (!this.instance) {
|
|
50
|
+
this.instance = new FirebaseAuthClientSingleton();
|
|
78
51
|
}
|
|
79
|
-
return
|
|
52
|
+
return this.instance;
|
|
80
53
|
}
|
|
81
54
|
}
|
|
82
55
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
export const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
56
|
+
const firebaseAuthClientSingleton = FirebaseAuthClientSingleton.getInstance();
|
|
57
|
+
|
|
58
|
+
export const initializeFirebaseAuth = (): Auth => {
|
|
59
|
+
return firebaseAuthClientSingleton.initialize();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const getFirebaseAuth = (): Auth => {
|
|
63
|
+
return firebaseAuthClientSingleton.getAuth();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const isFirebaseAuthInitialized = (): boolean => {
|
|
67
|
+
return firebaseAuthClientSingleton.isInitialized();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const getFirebaseAuthInitializationError = (): Error | null => {
|
|
71
|
+
return firebaseAuthClientSingleton.getInitializationError();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const resetFirebaseAuthClient = (): void => {
|
|
75
|
+
firebaseAuthClientSingleton.reset();
|
|
76
|
+
};
|
|
89
77
|
|
|
90
78
|
export type { Auth } from 'firebase/auth';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FirebaseAuthInitializer';
|
|
@@ -0,0 +1,16 @@
|
|
|
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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth-result-converter.util';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth.store';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth-guard.util';
|
|
@@ -0,0 +1,11 @@
|
|
|
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';
|
|
@@ -2,20 +2,13 @@
|
|
|
2
2
|
* useGoogleOAuth Hook
|
|
3
3
|
* Handles Google OAuth flow using expo-auth-session and Firebase auth
|
|
4
4
|
*
|
|
5
|
-
* This hook delegates business logic to GoogleOAuthHookService.
|
|
6
|
-
* Focuses only on React state management and side effects.
|
|
7
|
-
*
|
|
8
5
|
* Max lines: 150 (enforced for maintainability)
|
|
9
6
|
*/
|
|
10
7
|
|
|
11
|
-
import { useState, useCallback
|
|
8
|
+
import { useState, useCallback } from 'react';
|
|
12
9
|
import { getFirebaseAuth } from '../../infrastructure/config/FirebaseAuthClient';
|
|
13
10
|
import type { GoogleOAuthConfig } from '../../infrastructure/services/google-oauth.service';
|
|
14
|
-
import {
|
|
15
|
-
GoogleOAuthHookService,
|
|
16
|
-
createGoogleOAuthHookService,
|
|
17
|
-
isExpoAuthSessionAvailable,
|
|
18
|
-
} from './GoogleOAuthHookService';
|
|
11
|
+
import { GoogleOAuthService } from '../../infrastructure/services/google-oauth.service';
|
|
19
12
|
|
|
20
13
|
export interface UseGoogleOAuthResult {
|
|
21
14
|
signInWithGoogle: () => Promise<SocialAuthResult>;
|
|
@@ -33,68 +26,41 @@ interface SocialAuthResult {
|
|
|
33
26
|
|
|
34
27
|
/**
|
|
35
28
|
* Hook for Google OAuth authentication
|
|
36
|
-
* Requires expo-auth-session and expo-web-browser to be installed
|
|
37
29
|
*/
|
|
38
30
|
export function useGoogleOAuth(config?: GoogleOAuthConfig): UseGoogleOAuthResult {
|
|
39
31
|
const [isLoading, setIsLoading] = useState(false);
|
|
40
32
|
const [googleError, setGoogleError] = useState<string | null>(null);
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
const service = useMemo(() => createGoogleOAuthHookService(config), [config]);
|
|
44
|
-
|
|
45
|
-
// Update service when config changes
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
service.updateConfig(config);
|
|
48
|
-
}, [service, config]);
|
|
49
|
-
|
|
50
|
-
// Memoize service checks
|
|
51
|
-
const googleAvailable = useMemo(() => service.isAvailable(), [service]);
|
|
52
|
-
const googleConfigured = useMemo(() => service.isConfigured(), [service]);
|
|
53
|
-
|
|
54
|
-
// Get auth request tuple from service
|
|
55
|
-
const [, response] = service.getAuthRequest();
|
|
56
|
-
|
|
57
|
-
// Handle OAuth response
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (!googleAvailable || !response) return;
|
|
60
|
-
|
|
61
|
-
const handleResponse = async () => {
|
|
62
|
-
setIsLoading(true);
|
|
63
|
-
setGoogleError(null);
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
const auth = getFirebaseAuth();
|
|
67
|
-
await service.handleResponse(response, auth);
|
|
68
|
-
} catch (error) {
|
|
69
|
-
setGoogleError(service.getErrorMessage(error));
|
|
70
|
-
} finally {
|
|
71
|
-
setIsLoading(false);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
34
|
+
const service = new GoogleOAuthService();
|
|
74
35
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
console.error('[useGoogleOAuth] Unexpected error in handleResponse:', err);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}, [response, googleAvailable, service]);
|
|
36
|
+
const googleAvailable = service.isAvailable();
|
|
37
|
+
const googleConfigured = service.isConfigured(config);
|
|
81
38
|
|
|
82
|
-
// Sign in with Google
|
|
83
39
|
const signInWithGoogle = useCallback(async (): Promise<SocialAuthResult> => {
|
|
84
40
|
setIsLoading(true);
|
|
85
41
|
setGoogleError(null);
|
|
86
42
|
|
|
87
43
|
try {
|
|
88
44
|
const auth = getFirebaseAuth();
|
|
89
|
-
|
|
45
|
+
const result = await service.signInWithOAuth(auth, config);
|
|
46
|
+
|
|
47
|
+
if (!result.success) {
|
|
48
|
+
setGoogleError(result.error || 'Google sign-in failed');
|
|
49
|
+
return { success: false, error: result.error };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
success: true,
|
|
54
|
+
isNewUser: result.isNewUser,
|
|
55
|
+
};
|
|
90
56
|
} catch (error) {
|
|
91
|
-
const errorMessage =
|
|
57
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
92
58
|
setGoogleError(errorMessage);
|
|
93
59
|
return { success: false, error: errorMessage };
|
|
94
60
|
} finally {
|
|
95
61
|
setIsLoading(false);
|
|
96
62
|
}
|
|
97
|
-
}, [service]);
|
|
63
|
+
}, [service, config]);
|
|
98
64
|
|
|
99
65
|
return {
|
|
100
66
|
signInWithGoogle,
|
|
@@ -104,10 +70,3 @@ export function useGoogleOAuth(config?: GoogleOAuthConfig): UseGoogleOAuthResult
|
|
|
104
70
|
googleError,
|
|
105
71
|
};
|
|
106
72
|
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Check if expo-auth-session is available
|
|
110
|
-
* Useful for conditional rendering
|
|
111
|
-
*/
|
|
112
|
-
export { isExpoAuthSessionAvailable };
|
|
113
|
-
|
|
@@ -14,7 +14,8 @@ export {
|
|
|
14
14
|
} from './errors/FirebaseFirestoreError';
|
|
15
15
|
|
|
16
16
|
// Domain Entities
|
|
17
|
-
export { Collection
|
|
17
|
+
export { Collection } from './entities/Collection';
|
|
18
|
+
export { fromReference, fromQuery, createCollection } from './entities/CollectionFactory';
|
|
18
19
|
export type { CollectionMetadata } from './entities/Collection';
|
|
19
20
|
|
|
20
21
|
// Collection Entity Helpers
|
|
@@ -52,6 +53,9 @@ export {
|
|
|
52
53
|
|
|
53
54
|
// Domain Value Objects
|
|
54
55
|
export { QueryOptions, createQueryOptions } from './value-objects/QueryOptions';
|
|
55
|
-
export { WhereClause, equals, where, create as createWhereClause } from './value-objects/WhereClause';
|
|
56
56
|
export type { SortOptions, DateRangeOptions, PaginationOptions } from './value-objects/QueryOptions';
|
|
57
|
+
|
|
58
|
+
// Where Clause
|
|
59
|
+
export { WhereClause } from './value-objects/WhereClause';
|
|
60
|
+
export { equals, where, fromObject as createWhereClause } from './value-objects/WhereClauseFactory';
|
|
57
61
|
export type { WhereOperator } from './value-objects/WhereClause';
|
|
@@ -113,17 +113,3 @@ export class WhereClause {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
// Re-export factory functions for backward compatibility
|
|
117
|
-
export const create = Factory.where;
|
|
118
|
-
export const equals = Factory.equals;
|
|
119
|
-
export const notEquals = Factory.notEquals;
|
|
120
|
-
export const lessThan = Factory.lessThan;
|
|
121
|
-
export const lessThanOrEqual = Factory.lessThanOrEqual;
|
|
122
|
-
export const greaterThan = Factory.greaterThan;
|
|
123
|
-
export const greaterThanOrEqual = Factory.greaterThanOrEqual;
|
|
124
|
-
export const arrayContains = Factory.arrayContains;
|
|
125
|
-
export const inOp = Factory.inOp;
|
|
126
|
-
export const notIn = Factory.notIn;
|
|
127
|
-
export const arrayContainsAny = Factory.arrayContainsAny;
|
|
128
|
-
export const where = Factory.where;
|
|
129
|
-
export const fromObject = Factory.fromObject;
|