@umituz/react-native-firebase 2.6.1 → 2.6.2

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 (87) hide show
  1. package/package.json +1 -1
  2. package/src/application/auth/ports/AuthPort_part_aa +150 -0
  3. package/src/application/auth/ports/AuthPort_part_ab +14 -0
  4. package/src/application/auth/use-cases/SignInUseCaseHelpers.ts +0 -0
  5. package/src/application/auth/use-cases/SignInUseCaseMain.ts +0 -0
  6. package/src/application/auth/use-cases/SignInUseCase_part_aa +150 -0
  7. package/src/application/auth/use-cases/SignInUseCase_part_ab +103 -0
  8. package/src/application/auth/use-cases/SignOutUseCaseCleanup.ts +0 -0
  9. package/src/application/auth/use-cases/SignOutUseCaseMain.ts +0 -0
  10. package/src/application/auth/use-cases/SignOutUseCase_part_aa +150 -0
  11. package/src/application/auth/use-cases/SignOutUseCase_part_ab +138 -0
  12. package/src/domains/account-deletion/domain/services/UserValidationHelpers.ts.bak +181 -0
  13. package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_aa +150 -0
  14. package/src/domains/account-deletion/domain/services/UserValidationHelpers_part_ab +31 -0
  15. package/src/domains/account-deletion/domain/services/{UserValidationService.ts → UserValidationService.ts.bak} +1 -10
  16. package/src/domains/account-deletion/domain/services/UserValidationService_part_aa +150 -0
  17. package/src/domains/account-deletion/domain/services/UserValidationService_part_ab +136 -0
  18. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_aa +150 -0
  19. package/src/domains/account-deletion/infrastructure/services/AccountDeletionExecutor_part_ab +80 -0
  20. package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_aa +150 -0
  21. package/src/domains/account-deletion/infrastructure/services/AccountDeletionReauthHandler_part_ab +24 -0
  22. package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_aa +150 -0
  23. package/src/domains/account-deletion/infrastructure/services/AccountDeletionRepository_part_ab +116 -0
  24. package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_aa +150 -0
  25. package/src/domains/account-deletion/infrastructure/services/reauthentication.service_part_ab +10 -0
  26. package/src/domains/auth/infrastructure_part_aa +150 -0
  27. package/src/domains/auth/infrastructure_part_ab +6 -0
  28. package/src/domains/auth/presentation/hooks/GoogleOAuthHelpers.ts +0 -0
  29. package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_aa +150 -0
  30. package/src/domains/auth/presentation/hooks/GoogleOAuthHookService_part_ab +97 -0
  31. package/src/domains/auth/presentation/hooks/GoogleOAuthService.ts +0 -0
  32. package/src/domains/firestore/domain/entities/Collection.ts +31 -191
  33. package/src/domains/firestore/domain/entities/Collection.ts.bak +288 -0
  34. package/src/domains/firestore/domain/entities/CollectionFactory.ts +55 -0
  35. package/src/domains/firestore/domain/entities/CollectionHelpers.ts +143 -0
  36. package/src/domains/firestore/domain/entities/CollectionUtils.ts +72 -0
  37. package/src/domains/firestore/domain/entities/CollectionValidation.ts +138 -0
  38. package/src/domains/firestore/domain/entities/Collection_part_aa +150 -0
  39. package/src/domains/firestore/domain/entities/Collection_part_ab +138 -0
  40. package/src/domains/firestore/domain/entities/DocumentHelpers.ts +0 -0
  41. package/src/domains/firestore/domain/entities/DocumentMain.ts +0 -0
  42. package/src/domains/firestore/domain/entities/Document_part_aa +150 -0
  43. package/src/domains/firestore/domain/entities/Document_part_ab +83 -0
  44. package/src/domains/firestore/domain/index.ts +44 -9
  45. package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_aa +150 -0
  46. package/src/domains/firestore/domain/services/QueryServiceAnalysis_part_ab +19 -0
  47. package/src/domains/firestore/domain/services/QueryServiceHelpers_part_aa +150 -0
  48. package/src/domains/firestore/domain/services/QueryServiceHelpers_part_ab +1 -0
  49. package/src/domains/firestore/domain/services/QueryService_part_aa +150 -0
  50. package/src/domains/firestore/domain/services/QueryService_part_ab +32 -0
  51. package/src/domains/firestore/domain/value-objects/QueryOptions.ts.bak +6 -135
  52. package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_aa +150 -0
  53. package/src/domains/firestore/domain/value-objects/QueryOptionsSerialization_part_ab +57 -0
  54. package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_aa +150 -0
  55. package/src/domains/firestore/domain/value-objects/QueryOptionsValidation_part_ab +32 -0
  56. package/src/domains/firestore/domain/value-objects/{QueryOptions.ts → QueryOptions_part_aa} +0 -41
  57. package/src/domains/firestore/domain/value-objects/QueryOptions_part_ab +41 -0
  58. package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_aa +150 -0
  59. package/src/domains/firestore/domain/value-objects/WhereClauseFactory_part_ab +57 -0
  60. package/src/domains/firestore/domain/value-objects/WhereClause_part_aa +150 -0
  61. package/src/domains/firestore/domain/value-objects/WhereClause_part_ab +149 -0
  62. package/src/shared/infrastructure/base/ErrorHandler_part_aa +150 -0
  63. package/src/shared/infrastructure/base/ErrorHandler_part_ab +39 -0
  64. package/src/shared/infrastructure/base/ServiceBase_part_aa +150 -0
  65. package/src/shared/infrastructure/base/ServiceBase_part_ab +70 -0
  66. package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_aa +150 -0
  67. package/src/shared/infrastructure/config/base/ServiceClientSingleton_part_ab +5 -0
  68. /package/src/application/auth/ports/{AuthPort.ts → AuthPort.ts.bak} +0 -0
  69. /package/src/application/auth/use-cases/{SignInUseCase.ts → SignInUseCase.ts.bak} +0 -0
  70. /package/src/application/auth/use-cases/{SignOutUseCase.ts → SignOutUseCase.ts.bak} +0 -0
  71. /package/src/domains/account-deletion/infrastructure/services/{AccountDeletionExecutor.ts → AccountDeletionExecutor.ts.bak} +0 -0
  72. /package/src/domains/account-deletion/infrastructure/services/{AccountDeletionReauthHandler.ts → AccountDeletionReauthHandler.ts.bak} +0 -0
  73. /package/src/domains/account-deletion/infrastructure/services/{AccountDeletionRepository.ts → AccountDeletionRepository.ts.bak} +0 -0
  74. /package/src/domains/account-deletion/infrastructure/services/{reauthentication.service.ts → reauthentication.service.ts.bak} +0 -0
  75. /package/src/domains/auth/{infrastructure.ts → infrastructure.ts.bak} +0 -0
  76. /package/src/domains/auth/presentation/hooks/{GoogleOAuthHookService.ts → GoogleOAuthHookService.ts.bak} +0 -0
  77. /package/src/domains/firestore/domain/entities/{Document.ts → Document.ts.bak} +0 -0
  78. /package/src/domains/firestore/domain/services/{QueryService.ts → QueryService.ts.bak} +0 -0
  79. /package/src/domains/firestore/domain/services/{QueryServiceAnalysis.ts → QueryServiceAnalysis.ts.bak} +0 -0
  80. /package/src/domains/firestore/domain/services/{QueryServiceHelpers.ts → QueryServiceHelpers.ts.bak} +0 -0
  81. /package/src/domains/firestore/domain/value-objects/{QueryOptionsSerialization.ts → QueryOptionsSerialization.ts.bak} +0 -0
  82. /package/src/domains/firestore/domain/value-objects/{QueryOptionsValidation.ts → QueryOptionsValidation.ts.bak} +0 -0
  83. /package/src/domains/firestore/domain/value-objects/{WhereClause.ts → WhereClause.ts.bak} +0 -0
  84. /package/src/domains/firestore/domain/value-objects/{WhereClauseFactory.ts → WhereClauseFactory.ts.bak} +0 -0
  85. /package/src/shared/infrastructure/base/{ErrorHandler.ts → ErrorHandler.ts.bak} +0 -0
  86. /package/src/shared/infrastructure/base/{ServiceBase.ts → ServiceBase.ts.bak} +0 -0
  87. /package/src/shared/infrastructure/config/base/{ServiceClientSingleton.ts → ServiceClientSingleton.ts.bak} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-firebase",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
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",
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Auth Port
3
+ * Single Responsibility: Define authentication contract
4
+ *
5
+ * Port interface for authentication operations.
6
+ * Defines the contract that infrastructure must implement.
7
+ *
8
+ * Max lines: 150 (enforced for maintainability)
9
+ */
10
+
11
+ import type { User, Auth } from 'firebase/auth';
12
+ import type { Result } from '../../../shared/domain/utils';
13
+
14
+ /**
15
+ * Email credentials
16
+ */
17
+ export interface EmailCredentials {
18
+ readonly email: string;
19
+ readonly password: string;
20
+ }
21
+
22
+ /**
23
+ * Sign in result
24
+ */
25
+ export interface SignInResult {
26
+ readonly user: User;
27
+ readonly isNewUser: boolean;
28
+ }
29
+
30
+ /**
31
+ * Sign up result
32
+ */
33
+ export interface SignUpResult {
34
+ readonly user: User;
35
+ readonly userId: string;
36
+ }
37
+
38
+ /**
39
+ * Auth port interface
40
+ * Defines contract for authentication operations
41
+ */
42
+ export interface IAuthPort {
43
+ /**
44
+ * Sign in with email and password
45
+ */
46
+ signInWithEmail(credentials: EmailCredentials): Promise<Result<SignInResult>>;
47
+
48
+ /**
49
+ * Sign up with email and password
50
+ */
51
+ signUpWithEmail(credentials: EmailCredentials): Promise<Result<SignUpResult>>;
52
+
53
+ /**
54
+ * Sign out current user
55
+ */
56
+ signOut(): Promise<Result<void>>;
57
+
58
+ /**
59
+ * Get current authenticated user
60
+ */
61
+ getCurrentUser(): User | null;
62
+
63
+ /**
64
+ * Get current user ID
65
+ */
66
+ getCurrentUserId(): string | null;
67
+
68
+ /**
69
+ * Check if user is authenticated
70
+ */
71
+ isAuthenticated(): boolean;
72
+
73
+ /**
74
+ * Check if user is anonymous
75
+ */
76
+ isAnonymous(): boolean;
77
+
78
+ /**
79
+ * Delete user account
80
+ */
81
+ deleteAccount(): Promise<Result<void>>;
82
+
83
+ /**
84
+ * Update user password
85
+ */
86
+ updatePassword(newPassword: string): Promise<Result<void>>;
87
+
88
+ /**
89
+ * Send password reset email
90
+ */
91
+ sendPasswordResetEmail(email: string): Promise<Result<void>>;
92
+
93
+ /**
94
+ * Get auth instance
95
+ */
96
+ getAuth(): Auth | null;
97
+ }
98
+
99
+ /**
100
+ * Auth port options
101
+ */
102
+ export interface AuthPortOptions {
103
+ /** Auto-initialize auth on first access */
104
+ autoInitialize?: boolean;
105
+ /** Enable detailed logging */
106
+ enableLogging?: boolean;
107
+ }
108
+
109
+ /**
110
+ * Auth port configuration
111
+ */
112
+ export interface AuthPortConfig {
113
+ readonly port: IAuthPort;
114
+ readonly options: AuthPortOptions;
115
+ }
116
+
117
+ /**
118
+ * Create auth port configuration
119
+ */
120
+ export function createAuthPortConfig(
121
+ port: IAuthPort,
122
+ options: AuthPortOptions = {}
123
+ ): AuthPortConfig {
124
+ return {
125
+ port,
126
+ options: {
127
+ autoInitialize: true,
128
+ enableLogging: __DEV__,
129
+ ...options,
130
+ },
131
+ };
132
+ }
133
+
134
+ /**
135
+ * Auth port factory
136
+ * Creates auth port instances
137
+ */
138
+ export interface IAuthPortFactory {
139
+ createPort(options?: AuthPortOptions): IAuthPort;
140
+ }
141
+
142
+ /**
143
+ * Default auth port factory
144
+ * Implements factory pattern for auth ports
145
+ */
146
+ export class AuthPortFactory implements IAuthPortFactory {
147
+ createPort(options?: AuthPortOptions): IAuthPort {
148
+ // Import and create actual implementation
149
+ const { FirebaseAuthPort } = require('../implementations/FirebaseAuthPort');
150
+ return new FirebaseAuthPort(options);
@@ -0,0 +1,14 @@
1
+ }
2
+ }
3
+
4
+ /**
5
+ * Default auth port factory instance
6
+ */
7
+ export const authPortFactory = new AuthPortFactory();
8
+
9
+ /**
10
+ * Create auth port with default factory
11
+ */
12
+ export function createAuthPort(options?: AuthPortOptions): IAuthPort {
13
+ return authPortFactory.createPort(options);
14
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Sign In Use Case
3
+ * Single Responsibility: Handle user sign in operations
4
+ *
5
+ * Application use case for user authentication.
6
+ * Coordinates domain services and infrastructure.
7
+ *
8
+ * Max lines: 150 (enforced for maintainability)
9
+ */
10
+
11
+ import type { User } from 'firebase/auth';
12
+ import type { Result } from '../../../shared/domain/utils';
13
+ import type { IAuthPort, EmailCredentials, SignInResult } from '../ports/AuthPort';
14
+
15
+ /**
16
+ * Sign in use case result
17
+ */
18
+ export interface SignInUseCaseResult extends Result<SignInResult> {
19
+ readonly requiresVerification?: boolean;
20
+ }
21
+
22
+ /**
23
+ * Sign in use case options
24
+ */
25
+ export interface SignInOptions {
26
+ /** Email credentials */
27
+ readonly email: string;
28
+ /** Password */
29
+ readonly password: string;
30
+ /** Remember user */
31
+ readonly rememberMe?: boolean;
32
+ }
33
+
34
+ /**
35
+ * Sign in use case
36
+ * Handles user sign in with validation and error handling
37
+ */
38
+ export class SignInUseCase {
39
+ private readonly authPort: IAuthPort;
40
+
41
+ constructor(authPort: IAuthPort) {
42
+ this.authPort = authPort;
43
+ }
44
+
45
+ /**
46
+ * Execute sign in use case
47
+ * Validates credentials and signs in user
48
+ */
49
+ async execute(options: SignInOptions): Promise<SignInUseCaseResult> {
50
+ // Validate credentials
51
+ const validation = this.validateCredentials(options);
52
+ if (!validation.valid) {
53
+ return {
54
+ success: false,
55
+ error: {
56
+ code: 'auth/invalid-credentials',
57
+ message: validation.error,
58
+ },
59
+ };
60
+ }
61
+
62
+ // Create credentials object
63
+ const credentials: EmailCredentials = {
64
+ email: options.email,
65
+ password: options.password,
66
+ };
67
+
68
+ // Sign in with credentials
69
+ const result = await this.authPort.signInWithEmail(credentials);
70
+
71
+ if (!result.success) {
72
+ return {
73
+ success: false,
74
+ error: result.error,
75
+ requiresVerification: this.requiresVerification(result.error?.code),
76
+ };
77
+ }
78
+
79
+ return {
80
+ success: true,
81
+ data: result.data,
82
+ };
83
+ }
84
+
85
+ /**
86
+ * Validate email and password
87
+ */
88
+ private validateCredentials(options: SignInOptions): { valid: boolean; error?: string } {
89
+ const { email, password } = options;
90
+
91
+ // Validate email
92
+ if (!email || typeof email !== 'string' || email.trim() === '') {
93
+ return { valid: false, error: 'Email is required' };
94
+ }
95
+
96
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
97
+ if (!emailRegex.test(email)) {
98
+ return { valid: false, error: 'Invalid email format' };
99
+ }
100
+
101
+ // Validate password
102
+ if (!password || typeof password !== 'string' || password.trim() === '') {
103
+ return { valid: false, error: 'Password is required' };
104
+ }
105
+
106
+ if (password.length < 6) {
107
+ return { valid: false, error: 'Password must be at least 6 characters' };
108
+ }
109
+
110
+ return { valid: true };
111
+ }
112
+
113
+ /**
114
+ * Check if error requires email verification
115
+ */
116
+ private requiresVerification(errorCode?: string): boolean {
117
+ return errorCode === 'auth/unverified-email' || errorCode === 'auth/email-not-verified';
118
+ }
119
+
120
+ /**
121
+ * Check if user is already signed in
122
+ */
123
+ isSignedIn(): boolean {
124
+ return this.authPort.isAuthenticated();
125
+ }
126
+
127
+ /**
128
+ * Get current user
129
+ */
130
+ getCurrentUser(): User | null {
131
+ return this.authPort.getCurrentUser();
132
+ }
133
+
134
+ /**
135
+ * Sign out current user
136
+ */
137
+ async signOut(): Promise<Result<void>> {
138
+ return this.authPort.signOut();
139
+ }
140
+
141
+ /**
142
+ * Check if credentials match current user
143
+ */
144
+ async credentialsMatchCurrentUser(email: string): Promise<boolean> {
145
+ const currentUser = this.getCurrentUser();
146
+ if (!currentUser || !currentUser.email) {
147
+ return false;
148
+ }
149
+
150
+ return currentUser.email.toLowerCase() === email.toLowerCase();
@@ -0,0 +1,103 @@
1
+ }
2
+
3
+ /**
4
+ * Validate email format
5
+ */
6
+ isValidEmail(email: string): boolean {
7
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
8
+ return emailRegex.test(email);
9
+ }
10
+
11
+ /**
12
+ * Validate password strength
13
+ */
14
+ isStrongPassword(password: string): boolean {
15
+ // Basic password strength check
16
+ return password.length >= 8;
17
+ }
18
+
19
+ /**
20
+ * Get password strength indicator
21
+ */
22
+ getPasswordStrength(password: string): 'weak' | 'medium' | 'strong' {
23
+ if (password.length < 6) {
24
+ return 'weak';
25
+ }
26
+
27
+ if (password.length < 8) {
28
+ return 'medium';
29
+ }
30
+
31
+ // Check for variety
32
+ const hasLower = /[a-z]/.test(password);
33
+ const hasUpper = /[A-Z]/.test(password);
34
+ const hasNumber = /[0-9]/.test(password);
35
+ const hasSpecial = /[^a-zA-Z0-9]/.test(password);
36
+
37
+ const varietyScore = [hasLower, hasUpper, hasNumber, hasSpecial].filter(Boolean).length;
38
+
39
+ if (varietyScore >= 3) {
40
+ return 'strong';
41
+ }
42
+
43
+ return 'medium';
44
+ }
45
+
46
+ /**
47
+ * Check if account is locked
48
+ */
49
+ isAccountLocked(errorCode?: string): boolean {
50
+ return errorCode === 'auth/too-many-requests' || errorCode === 'auth/user-disabled';
51
+ }
52
+
53
+ /**
54
+ * Get user-friendly error message
55
+ */
56
+ getErrorMessage(errorCode: string): string {
57
+ const errorMessages: Record<string, string> = {
58
+ 'auth/invalid-credentials': 'Invalid email or password',
59
+ 'auth/user-not-found': 'No account found with this email',
60
+ 'auth/wrong-password': 'Incorrect password',
61
+ 'auth/unverified-email': 'Please verify your email first',
62
+ 'auth/user-disabled': 'This account has been disabled',
63
+ 'auth/too-many-requests': 'Too many attempts. Please try again later',
64
+ 'auth/invalid-email': 'Invalid email address',
65
+ };
66
+
67
+ return errorMessages[errorCode] || 'Sign in failed. Please try again.';
68
+ }
69
+
70
+ /**
71
+ * Create sign in options from email and password
72
+ */
73
+ createOptions(email: string, password: string, rememberMe: boolean = false): SignInOptions {
74
+ return {
75
+ email,
76
+ password,
77
+ rememberMe,
78
+ };
79
+ }
80
+
81
+ /**
82
+ * Quick sign in helper
83
+ */
84
+ async quickSignIn(email: string, password: string): Promise<SignInUseCaseResult> {
85
+ return this.execute(this.createOptions(email, password));
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Factory function to create sign in use case
91
+ */
92
+ export function createSignInUseCase(authPort: IAuthPort): SignInUseCase {
93
+ return new SignInUseCase(authPort);
94
+ }
95
+
96
+ /**
97
+ * Factory function to create sign in use case with default auth port
98
+ */
99
+ export async function createDefaultSignInUseCase(): Promise<SignInUseCase> {
100
+ const { createAuthPort } = await import('../ports/AuthPort');
101
+ const authPort = createAuthPort();
102
+ return createSignInUseCase(authPort);
103
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Sign Out Use Case
3
+ * Single Responsibility: Handle user sign out operations
4
+ *
5
+ * Application use case for user sign out.
6
+ * Ensures proper cleanup and state management.
7
+ *
8
+ * Max lines: 150 (enforced for maintainability)
9
+ */
10
+
11
+ import type { User } from 'firebase/auth';
12
+ import type { Result } from '../../../shared/domain/utils';
13
+ import type { IAuthPort } from '../ports/AuthPort';
14
+
15
+ /**
16
+ * Sign out use case result
17
+ */
18
+ export interface SignOutUseCaseResult extends Result<void> {
19
+ readonly wasSignedIn: boolean;
20
+ }
21
+
22
+ /**
23
+ * Sign out use case options
24
+ */
25
+ export interface SignOutOptions {
26
+ /** Clear local data */
27
+ readonly clearLocalData?: boolean;
28
+ /** Navigate to sign in screen */
29
+ readonly navigateToSignIn?: boolean;
30
+ /** Show confirmation dialog */
31
+ readonly showConfirmation?: boolean;
32
+ }
33
+
34
+ /**
35
+ * Sign out use case
36
+ * Handles user sign out with proper cleanup
37
+ */
38
+ export class SignOutUseCase {
39
+ private readonly authPort: IAuthPort;
40
+
41
+ constructor(authPort: IAuthPort) {
42
+ this.authPort = authPort;
43
+ }
44
+
45
+ /**
46
+ * Execute sign out use case
47
+ * Signs out user and performs cleanup
48
+ */
49
+ async execute(options: SignOutOptions = {}): Promise<SignOutUseCaseResult> {
50
+ const wasSignedIn = this.authPort.isAuthenticated();
51
+
52
+ // Check if user is signed in
53
+ if (!wasSignedIn) {
54
+ return {
55
+ success: true,
56
+ wasSignedIn: false,
57
+ };
58
+ }
59
+
60
+ // Sign out from auth
61
+ const result = await this.authPort.signOut();
62
+
63
+ if (!result.success) {
64
+ return {
65
+ success: false,
66
+ error: result.error,
67
+ wasSignedIn,
68
+ };
69
+ }
70
+
71
+ // Perform cleanup
72
+ await this.performCleanup(options);
73
+
74
+ return {
75
+ success: true,
76
+ wasSignedIn,
77
+ };
78
+ }
79
+
80
+ /**
81
+ * Perform cleanup after sign out
82
+ */
83
+ private async performCleanup(options: SignOutOptions): Promise<void> {
84
+ // Clear local data if requested
85
+ if (options.clearLocalData) {
86
+ await this.clearLocalData();
87
+ }
88
+
89
+ // Additional cleanup can be added here
90
+ // For example: clear cache, reset state, etc.
91
+ }
92
+
93
+ /**
94
+ * Clear local data
95
+ * Override in subclass for custom cleanup
96
+ */
97
+ protected async clearLocalData(): Promise<void> {
98
+ // Default implementation does nothing
99
+ // Subclass can override for custom cleanup
100
+ if (__DEV__) {
101
+ console.log('[SignOutUseCase] Clearing local data');
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Check if user is signed in
107
+ */
108
+ isSignedIn(): boolean {
109
+ return this.authPort.isAuthenticated();
110
+ }
111
+
112
+ /**
113
+ * Get current user
114
+ */
115
+ getCurrentUser(): User | null {
116
+ return this.authPort.getCurrentUser();
117
+ }
118
+
119
+ /**
120
+ * Get current user ID
121
+ */
122
+ getCurrentUserId(): string | null {
123
+ return this.authPort.getCurrentUserId();
124
+ }
125
+
126
+ /**
127
+ * Check if user is anonymous
128
+ */
129
+ isAnonymous(): boolean {
130
+ return this.authPort.isAnonymous();
131
+ }
132
+
133
+ /**
134
+ * Confirm sign out
135
+ * Useful for showing confirmation dialog
136
+ */
137
+ async confirmSignOut(): Promise<boolean> {
138
+ // Default implementation always returns true
139
+ // Override in subclass to show confirmation dialog
140
+ return true;
141
+ }
142
+
143
+ /**
144
+ * Validate can sign out
145
+ * Check if sign out is allowed
146
+ */
147
+ async canSignOut(): Promise<Result<void>> {
148
+ if (!this.isSignedIn()) {
149
+ return {
150
+ success: false,