@umituz/react-native-auth 3.2.8 → 3.2.9

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": "3.2.8",
3
+ "version": "3.2.9",
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",
@@ -17,7 +17,7 @@
17
17
  * ```
18
18
  */
19
19
 
20
- import { create, type StoreApi, type UseBoundStore } from "zustand";
20
+ import { createStore } from "@umituz/react-native-storage";
21
21
 
22
22
  export type AuthModalMode = "login" | "register";
23
23
 
@@ -38,47 +38,46 @@ interface AuthModalActions {
38
38
  clearPendingCallback: () => void;
39
39
  }
40
40
 
41
- type AuthModalStore = AuthModalState & AuthModalActions;
42
-
43
- type SetModalState = (partial: Partial<AuthModalState> | ((state: AuthModalState) => Partial<AuthModalState>)) => void;
44
- type GetModalState = () => AuthModalStore;
45
-
46
- export const useAuthModalStore: UseBoundStore<StoreApi<AuthModalStore>> = create<AuthModalStore>((
47
- set: SetModalState,
48
- get: GetModalState,
49
- ) => ({
41
+ const initialAuthModalState: AuthModalState = {
50
42
  isVisible: false,
51
43
  mode: "login",
52
44
  pendingCallback: null,
45
+ };
53
46
 
54
- showAuthModal: (
55
- callback?: () => void | Promise<void>,
56
- mode: AuthModalMode = "login",
57
- ) => {
58
- set({
59
- isVisible: true,
60
- mode,
61
- pendingCallback: callback || null,
62
- });
63
- },
47
+ export const useAuthModalStore = createStore<AuthModalState, AuthModalActions>({
48
+ name: "auth-modal-store",
49
+ initialState: initialAuthModalState,
50
+ persist: false,
51
+ actions: (set, get) => ({
52
+ showAuthModal: (
53
+ callback?: () => void | Promise<void>,
54
+ mode: AuthModalMode = "login",
55
+ ) => {
56
+ set({
57
+ isVisible: true,
58
+ mode,
59
+ pendingCallback: callback || null,
60
+ });
61
+ },
64
62
 
65
- hideAuthModal: () => {
66
- set({ isVisible: false });
67
- },
63
+ hideAuthModal: () => {
64
+ set({ isVisible: false });
65
+ },
68
66
 
69
- setMode: (mode: AuthModalMode) => {
70
- set({ mode });
71
- },
67
+ setMode: (mode: AuthModalMode) => {
68
+ set({ mode });
69
+ },
72
70
 
73
- executePendingCallback: () => {
74
- const { pendingCallback } = get();
75
- if (pendingCallback) {
76
- void pendingCallback();
77
- set({ pendingCallback: null });
78
- }
79
- },
71
+ executePendingCallback: () => {
72
+ const state = get();
73
+ if (state.pendingCallback) {
74
+ void state.pendingCallback();
75
+ set({ pendingCallback: null });
76
+ }
77
+ },
80
78
 
81
- clearPendingCallback: () => {
82
- set({ pendingCallback: null });
83
- },
84
- }));
79
+ clearPendingCallback: () => {
80
+ set({ pendingCallback: null });
81
+ },
82
+ }),
83
+ });
@@ -7,20 +7,10 @@
7
7
  */
8
8
 
9
9
  import { createStore } from "@umituz/react-native-storage";
10
- import type { User } from "firebase/auth";
11
10
  import type { AuthUser } from "../../domain/entities/AuthUser";
12
11
  import { mapToAuthUser } from "../../infrastructure/utils/UserMapper";
13
12
  import type { AuthState, AuthActions, UserType } from "../../types/auth-store.types";
14
13
  import { initialAuthState } from "../../types/auth-store.types";
15
-
16
- // Type for the combined store
17
- type AuthStore = AuthState & AuthActions;
18
-
19
- // Type for set function
20
- type SetState = (partial: Partial<AuthState>) => void;
21
-
22
- // Type for get function
23
- type GetState = () => AuthStore;
24
14
  import {
25
15
  selectUser,
26
16
  selectLoading,
@@ -73,12 +63,12 @@ export const useAuthStore = createStore<AuthState, AuthActions>({
73
63
  initialState: initialAuthState,
74
64
  persist: true,
75
65
  version: 1,
76
- partialize: (state: AuthState) => ({
66
+ partialize: (state) => ({
77
67
  isGuest: state.isGuest,
78
68
  initialized: state.initialized,
79
69
  }),
80
- actions: (set: SetState, get: GetState) => ({
81
- setFirebaseUser: (firebaseUser: User | null) => {
70
+ actions: (set, get) => ({
71
+ setFirebaseUser: (firebaseUser) => {
82
72
  const { isGuest } = get();
83
73
 
84
74
  let user: AuthUser | null = null;
@@ -98,9 +88,9 @@ export const useAuthStore = createStore<AuthState, AuthActions>({
98
88
  });
99
89
  },
100
90
 
101
- setLoading: (loading: boolean) => set({ loading }),
91
+ setLoading: (loading) => set({ loading }),
102
92
 
103
- setIsGuest: (isGuest: boolean) => {
93
+ setIsGuest: (isGuest) => {
104
94
  const { firebaseUser } = get();
105
95
 
106
96
  let user: AuthUser | null = null;
@@ -115,9 +105,9 @@ export const useAuthStore = createStore<AuthState, AuthActions>({
115
105
  set({ isGuest, user });
116
106
  },
117
107
 
118
- setError: (error: string | null) => set({ error }),
108
+ setError: (error) => set({ error }),
119
109
 
120
- setInitialized: (initialized: boolean) => set({ initialized }),
110
+ setInitialized: (initialized) => set({ initialized }),
121
111
 
122
112
  reset: () => set(initialAuthState),
123
113
  }),