@umituz/react-native-auth 1.0.3 → 1.1.1

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.0.3",
3
+ "version": "1.1.1",
4
4
  "description": "Firebase Authentication wrapper for React Native apps - Secure, type-safe, and production-ready",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -9,6 +9,7 @@ export interface SignUpParams {
9
9
  email: string;
10
10
  password: string;
11
11
  displayName?: string;
12
+ username?: string;
12
13
  }
13
14
 
14
15
  export interface SignInParams {
@@ -15,11 +15,15 @@ export interface AuthConfig {
15
15
  /** Require special characters in password */
16
16
  requireSpecialChars?: boolean;
17
17
  /** Callback for user profile creation after signup */
18
- onUserCreated?: (user: any) => Promise<void> | void;
18
+ onUserCreated?: (user: any, context?: { username?: string; displayName?: string }) => Promise<void> | void;
19
19
  /** Callback for user profile update */
20
20
  onUserUpdated?: (user: any) => Promise<void> | void;
21
+ /** Callback after successful sign in */
22
+ onSignIn?: (user: any) => Promise<void> | void;
21
23
  /** Callback for sign out cleanup */
22
24
  onSignOut?: () => Promise<void> | void;
25
+ /** Callback when guest mode is enabled */
26
+ onGuestModeEnabled?: () => Promise<void> | void;
23
27
  }
24
28
 
25
29
  export const DEFAULT_AUTH_CONFIG: Required<Omit<AuthConfig, 'onUserCreated' | 'onUserUpdated' | 'onSignOut'>> = {
@@ -14,6 +14,7 @@ import {
14
14
  } from "firebase/auth";
15
15
  import type { IAuthService, SignUpParams, SignInParams } from "../../application/ports/IAuthService";
16
16
  import {
17
+ AuthError,
17
18
  AuthInitializationError,
18
19
  AuthConfigurationError,
19
20
  AuthValidationError,
@@ -201,7 +202,10 @@ export class AuthService implements IAuthService {
201
202
  // Call user created callback if provided
202
203
  if (this.config.onUserCreated) {
203
204
  try {
204
- await this.config.onUserCreated(userCredential.user);
205
+ await this.config.onUserCreated(userCredential.user, {
206
+ username: params.username,
207
+ displayName: params.displayName,
208
+ });
205
209
  } catch (callbackError) {
206
210
  // Don't fail signup if callback fails
207
211
  }
@@ -240,6 +244,16 @@ export class AuthService implements IAuthService {
240
244
  );
241
245
 
242
246
  this.isGuestMode = false;
247
+
248
+ // Call sign in callback if provided
249
+ if (this.config.onSignIn) {
250
+ try {
251
+ await this.config.onSignIn(userCredential.user);
252
+ } catch (callbackError) {
253
+ // Don't fail signin if callback fails
254
+ }
255
+ }
256
+
243
257
  return userCredential.user;
244
258
  } catch (error: any) {
245
259
  throw mapFirebaseAuthError(error);
@@ -290,6 +304,15 @@ export class AuthService implements IAuthService {
290
304
  }
291
305
 
292
306
  this.isGuestMode = true;
307
+
308
+ // Call guest mode enabled callback if provided
309
+ if (this.config.onGuestModeEnabled) {
310
+ try {
311
+ await this.config.onGuestModeEnabled();
312
+ } catch (callbackError) {
313
+ // Don't fail guest mode if callback fails
314
+ }
315
+ }
293
316
  }
294
317
 
295
318
  /**