@umituz/react-native-auth 1.6.3 → 1.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-auth",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design supports Firebase Auth and can be adapted for Supabase or other providers.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -141,12 +141,20 @@ export class AuthService implements IAuthService {
|
|
|
141
141
|
* Initialize auth service with Firebase Auth instance
|
|
142
142
|
* Must be called before using any auth methods
|
|
143
143
|
*/
|
|
144
|
-
initialize(auth: Auth): void {
|
|
144
|
+
async initialize(auth: Auth): Promise<void> {
|
|
145
145
|
if (!auth) {
|
|
146
146
|
throw new AuthInitializationError("Auth instance is required");
|
|
147
147
|
}
|
|
148
148
|
this.auth = auth;
|
|
149
|
-
|
|
149
|
+
|
|
150
|
+
// Restore guest mode from storage
|
|
151
|
+
try {
|
|
152
|
+
const guestModeValue = await storageRepository.getString(GUEST_MODE_KEY, "false");
|
|
153
|
+
this.isGuestMode = guestModeValue === "true";
|
|
154
|
+
} catch (error) {
|
|
155
|
+
// If storage fails, default to false
|
|
156
|
+
this.isGuestMode = false;
|
|
157
|
+
}
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
/**
|
|
@@ -300,6 +308,10 @@ export class AuthService implements IAuthService {
|
|
|
300
308
|
* Set guest mode (no authentication)
|
|
301
309
|
*/
|
|
302
310
|
async setGuestMode(): Promise<void> {
|
|
311
|
+
/* eslint-disable-next-line no-console */
|
|
312
|
+
if (__DEV__) {
|
|
313
|
+
console.log("[AuthService] setGuestMode called");
|
|
314
|
+
}
|
|
303
315
|
const auth = this.getAuth();
|
|
304
316
|
|
|
305
317
|
// Sign out from Firebase if logged in
|
|
@@ -312,15 +324,31 @@ export class AuthService implements IAuthService {
|
|
|
312
324
|
}
|
|
313
325
|
|
|
314
326
|
this.isGuestMode = true;
|
|
327
|
+
/* eslint-disable-next-line no-console */
|
|
328
|
+
if (__DEV__) {
|
|
329
|
+
console.log("[AuthService] isGuestMode set to true");
|
|
330
|
+
}
|
|
315
331
|
|
|
316
332
|
// Persist guest mode to storage
|
|
317
333
|
try {
|
|
318
334
|
await storageRepository.setString(GUEST_MODE_KEY, "true");
|
|
335
|
+
/* eslint-disable-next-line no-console */
|
|
336
|
+
if (__DEV__) {
|
|
337
|
+
console.log("[AuthService] Guest mode persisted to storage");
|
|
338
|
+
}
|
|
319
339
|
} catch (error) {
|
|
320
340
|
// Ignore storage errors - guest mode will still work in memory
|
|
341
|
+
/* eslint-disable-next-line no-console */
|
|
342
|
+
if (__DEV__) {
|
|
343
|
+
console.warn("[AuthService] Failed to persist guest mode to storage:", error);
|
|
344
|
+
}
|
|
321
345
|
}
|
|
322
346
|
|
|
323
347
|
// Emit event for AppNavigator to handle navigation
|
|
348
|
+
/* eslint-disable-next-line no-console */
|
|
349
|
+
if (__DEV__) {
|
|
350
|
+
console.log("[AuthService] Emitting guest-mode-enabled event");
|
|
351
|
+
}
|
|
324
352
|
DeviceEventEmitter.emit("guest-mode-enabled");
|
|
325
353
|
}
|
|
326
354
|
|
|
@@ -81,9 +81,21 @@ export const LoginForm: React.FC<LoginFormProps> = ({
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
const handleContinueAsGuest = async () => {
|
|
84
|
+
/* eslint-disable-next-line no-console */
|
|
85
|
+
if (__DEV__) {
|
|
86
|
+
console.log("[LoginForm] Continue as Guest button pressed");
|
|
87
|
+
}
|
|
84
88
|
try {
|
|
85
89
|
await continueAsGuest();
|
|
90
|
+
/* eslint-disable-next-line no-console */
|
|
91
|
+
if (__DEV__) {
|
|
92
|
+
console.log("[LoginForm] continueAsGuest completed");
|
|
93
|
+
}
|
|
86
94
|
} catch (err) {
|
|
95
|
+
/* eslint-disable-next-line no-console */
|
|
96
|
+
if (__DEV__) {
|
|
97
|
+
console.error("[LoginForm] Error in continueAsGuest:", err);
|
|
98
|
+
}
|
|
87
99
|
// Error handling is done in the hook
|
|
88
100
|
}
|
|
89
101
|
};
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { useEffect, useRef, useCallback, useState } from "react";
|
|
10
10
|
import type { User } from "firebase/auth";
|
|
11
|
+
import { DeviceEventEmitter } from "react-native";
|
|
11
12
|
import { getAuthService } from "../../infrastructure/services/AuthService";
|
|
12
13
|
import { useFirebaseAuth } from "@umituz/react-native-firebase-auth";
|
|
13
14
|
|
|
@@ -109,6 +110,24 @@ export function useAuth(): UseAuthResult {
|
|
|
109
110
|
}
|
|
110
111
|
}, []);
|
|
111
112
|
|
|
113
|
+
// Listen for guest-mode-enabled event to update state
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
const subscription = DeviceEventEmitter.addListener(
|
|
116
|
+
"guest-mode-enabled",
|
|
117
|
+
() => {
|
|
118
|
+
/* eslint-disable-next-line no-console */
|
|
119
|
+
if (__DEV__) {
|
|
120
|
+
console.log("[useAuth] Guest mode enabled event received");
|
|
121
|
+
}
|
|
122
|
+
setIsGuest(true);
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
return () => {
|
|
127
|
+
subscription.remove();
|
|
128
|
+
};
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
112
131
|
const signUp = useCallback(async (
|
|
113
132
|
email: string,
|
|
114
133
|
password: string,
|