@umituz/react-native-auth 4.3.84 → 4.3.85
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-auth",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.85",
|
|
4
4
|
"description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design with dependency injection, configurable validation, and comprehensive error handling.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -26,19 +26,22 @@ export class AuthService {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
private get repositoryInstance(): AuthRepository {
|
|
29
|
-
// Auto-initialize if not already initialized (prevent button failures)
|
|
30
29
|
if (!this.initialized) {
|
|
30
|
+
// Only auto-initialize in development for better DX
|
|
31
31
|
if (__DEV__) {
|
|
32
|
-
console.warn('[AuthService]
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
console.warn('[AuthService] Not initialized - auto-initializing for development. In production, call initialize() explicitly before using auth methods.');
|
|
33
|
+
this.initialize().catch((error) => {
|
|
34
|
+
console.error('[AuthService] Auto-initialization failed:', error);
|
|
35
|
+
throw new Error("AuthService not initialized. Please ensure Firebase Auth is properly configured.");
|
|
36
|
+
});
|
|
37
|
+
// Create repository immediately for synchronous operations
|
|
38
|
+
if (!this.repository) {
|
|
39
|
+
this.repository = new AuthRepository(this.config);
|
|
40
|
+
this.initialized = true;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
// In production, fail fast with clear error
|
|
44
|
+
throw new Error("AuthService not initialized. Please call initializeAuth() during app startup.");
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
return this.repository;
|
|
@@ -148,16 +151,24 @@ export async function initializeAuthService(
|
|
|
148
151
|
|
|
149
152
|
export function getAuthService(): AuthService | null {
|
|
150
153
|
if (!authServiceInstance) {
|
|
151
|
-
|
|
154
|
+
if (__DEV__) {
|
|
155
|
+
console.warn('[AuthService] Auto-creating service instance. Call initializeAuth() explicitly in production.');
|
|
156
|
+
}
|
|
152
157
|
authServiceInstance = new AuthService();
|
|
153
158
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
|
|
160
|
+
// Only attempt auto-initialization in development
|
|
161
|
+
if (!authServiceInstance.isInitialized() && __DEV__) {
|
|
157
162
|
authServiceInstance.initialize().catch(() => {
|
|
158
|
-
// Error
|
|
163
|
+
// Error handled by service
|
|
159
164
|
});
|
|
160
165
|
}
|
|
166
|
+
|
|
167
|
+
// In production, return null if not initialized to fail fast
|
|
168
|
+
if (!authServiceInstance.isInitialized()) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
161
172
|
return authServiceInstance;
|
|
162
173
|
}
|
|
163
174
|
|
|
@@ -13,7 +13,7 @@ export const useSignUpMutation = () => {
|
|
|
13
13
|
mutationFn: async (params: SignUpCredentials): Promise<AuthUser> => {
|
|
14
14
|
const service = getAuthService();
|
|
15
15
|
if (!service) {
|
|
16
|
-
throw new Error("
|
|
16
|
+
throw new Error("Authentication service not available. Please check your internet connection and restart the app.");
|
|
17
17
|
}
|
|
18
18
|
return service.signUp(params);
|
|
19
19
|
},
|
|
@@ -25,7 +25,7 @@ export const useSignInMutation = () => {
|
|
|
25
25
|
mutationFn: async (params: AuthCredentials): Promise<AuthUser> => {
|
|
26
26
|
const service = getAuthService();
|
|
27
27
|
if (!service) {
|
|
28
|
-
throw new Error("
|
|
28
|
+
throw new Error("Authentication service not available. Please check your internet connection and restart the app.");
|
|
29
29
|
}
|
|
30
30
|
return service.signIn(params);
|
|
31
31
|
},
|
|
@@ -37,7 +37,7 @@ export const useSignOutMutation = () => {
|
|
|
37
37
|
mutationFn: async (): Promise<void> => {
|
|
38
38
|
const service = getAuthService();
|
|
39
39
|
if (!service) {
|
|
40
|
-
throw new Error("
|
|
40
|
+
throw new Error("Authentication service not available. Please restart the app.");
|
|
41
41
|
}
|
|
42
42
|
return service.signOut();
|
|
43
43
|
},
|
|
@@ -49,7 +49,7 @@ export const useAnonymousModeMutation = () => {
|
|
|
49
49
|
mutationFn: async (): Promise<void> => {
|
|
50
50
|
const service = getAuthService();
|
|
51
51
|
if (!service) {
|
|
52
|
-
throw new Error("
|
|
52
|
+
throw new Error("Authentication service not available. Please restart the app.");
|
|
53
53
|
}
|
|
54
54
|
return service.setAnonymousMode();
|
|
55
55
|
},
|