@umituz/react-native-auth 4.3.83 → 4.3.84
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.84",
|
|
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,7 +26,21 @@ export class AuthService {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
private get repositoryInstance(): AuthRepository {
|
|
29
|
-
if
|
|
29
|
+
// Auto-initialize if not already initialized (prevent button failures)
|
|
30
|
+
if (!this.initialized) {
|
|
31
|
+
if (__DEV__) {
|
|
32
|
+
console.warn('[AuthService] Auto-initializing to prevent auth failures. Call initialize() explicitly in production.');
|
|
33
|
+
}
|
|
34
|
+
// Don't await - fire and forget to prevent blocking UI
|
|
35
|
+
this.initialize().catch((error) => {
|
|
36
|
+
console.error('[AuthService] Auto-initialization failed:', error);
|
|
37
|
+
});
|
|
38
|
+
// For synchronous operations, create repository immediately
|
|
39
|
+
if (!this.repository) {
|
|
40
|
+
this.repository = new AuthRepository(this.config);
|
|
41
|
+
this.initialized = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
30
44
|
return this.repository;
|
|
31
45
|
}
|
|
32
46
|
|
|
@@ -133,7 +147,18 @@ export async function initializeAuthService(
|
|
|
133
147
|
}
|
|
134
148
|
|
|
135
149
|
export function getAuthService(): AuthService | null {
|
|
136
|
-
|
|
150
|
+
if (!authServiceInstance) {
|
|
151
|
+
// Auto-create instance if it doesn't exist
|
|
152
|
+
authServiceInstance = new AuthService();
|
|
153
|
+
}
|
|
154
|
+
// Trigger auto-initialization if needed
|
|
155
|
+
if (!authServiceInstance.isInitialized()) {
|
|
156
|
+
// Non-blocking initialization attempt
|
|
157
|
+
authServiceInstance.initialize().catch(() => {
|
|
158
|
+
// Error will be handled by the service itself
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return authServiceInstance;
|
|
137
162
|
}
|
|
138
163
|
|
|
139
164
|
export function resetAuthService(): void {
|
|
@@ -12,7 +12,9 @@ export const useSignUpMutation = () => {
|
|
|
12
12
|
return useMutation({
|
|
13
13
|
mutationFn: async (params: SignUpCredentials): Promise<AuthUser> => {
|
|
14
14
|
const service = getAuthService();
|
|
15
|
-
if (!service)
|
|
15
|
+
if (!service) {
|
|
16
|
+
throw new Error("Unable to initialize authentication service. Please restart the app.");
|
|
17
|
+
}
|
|
16
18
|
return service.signUp(params);
|
|
17
19
|
},
|
|
18
20
|
});
|
|
@@ -22,7 +24,9 @@ export const useSignInMutation = () => {
|
|
|
22
24
|
return useMutation({
|
|
23
25
|
mutationFn: async (params: AuthCredentials): Promise<AuthUser> => {
|
|
24
26
|
const service = getAuthService();
|
|
25
|
-
if (!service)
|
|
27
|
+
if (!service) {
|
|
28
|
+
throw new Error("Unable to initialize authentication service. Please restart the app.");
|
|
29
|
+
}
|
|
26
30
|
return service.signIn(params);
|
|
27
31
|
},
|
|
28
32
|
});
|
|
@@ -32,7 +36,9 @@ export const useSignOutMutation = () => {
|
|
|
32
36
|
return useMutation({
|
|
33
37
|
mutationFn: async (): Promise<void> => {
|
|
34
38
|
const service = getAuthService();
|
|
35
|
-
if (!service)
|
|
39
|
+
if (!service) {
|
|
40
|
+
throw new Error("Unable to initialize authentication service. Please restart the app.");
|
|
41
|
+
}
|
|
36
42
|
return service.signOut();
|
|
37
43
|
},
|
|
38
44
|
});
|
|
@@ -42,7 +48,9 @@ export const useAnonymousModeMutation = () => {
|
|
|
42
48
|
return useMutation({
|
|
43
49
|
mutationFn: async (): Promise<void> => {
|
|
44
50
|
const service = getAuthService();
|
|
45
|
-
if (!service)
|
|
51
|
+
if (!service) {
|
|
52
|
+
throw new Error("Unable to initialize authentication service. Please restart the app.");
|
|
53
|
+
}
|
|
46
54
|
return service.setAnonymousMode();
|
|
47
55
|
},
|
|
48
56
|
});
|