@umituz/react-native-auth 3.6.18 → 3.6.19

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.6.18",
3
+ "version": "3.6.19",
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",
@@ -20,6 +20,7 @@ import {
20
20
  selectUserType,
21
21
  selectIsAnonymous,
22
22
  selectIsAuthReady,
23
+ selectIsRegisteredUser,
23
24
  type UserType,
24
25
  } from "../stores/authStore";
25
26
  import {
@@ -45,6 +46,8 @@ export interface UseAuthResult {
45
46
  isAnonymous: boolean;
46
47
  /** Whether user is authenticated (not anonymous) */
47
48
  isAuthenticated: boolean;
49
+ /** Whether user is a registered user (authenticated AND not anonymous) */
50
+ isRegisteredUser: boolean;
48
51
  /** Current error message */
49
52
  error: string | null;
50
53
  /** Sign up function */
@@ -75,6 +78,7 @@ export function useAuth(): UseAuthResult {
75
78
  const userType = useAuthStore(selectUserType);
76
79
  const isAnonymous = useAuthStore(selectIsAnonymous);
77
80
  const isAuthReady = useAuthStore(selectIsAuthReady);
81
+ const isRegisteredUser = useAuthStore(selectIsRegisteredUser);
78
82
 
79
83
  // Actions from store - using typed selectors
80
84
  const setLoading = useAuthStore(selectSetLoading);
@@ -152,6 +156,7 @@ export function useAuth(): UseAuthResult {
152
156
  isAuthReady,
153
157
  isAnonymous,
154
158
  isAuthenticated,
159
+ isRegisteredUser,
155
160
  error,
156
161
  signUp,
157
162
  signIn,
@@ -110,3 +110,12 @@ export const selectUserType = (state: AuthStore): UserType => {
110
110
  export const selectIsAuthReady = (state: AuthStore): boolean => {
111
111
  return state.initialized && !state.loading;
112
112
  };
113
+
114
+ /**
115
+ * Check if user is a registered user (authenticated AND not anonymous)
116
+ * Use this for feature gating - only registered users can access premium features
117
+ */
118
+ export const selectIsRegisteredUser = (state: AuthStore): boolean => {
119
+ if (!state.initialized) return false;
120
+ return !!state.user && !state.isAnonymous && !state.user.isAnonymous;
121
+ };
@@ -27,6 +27,7 @@ import {
27
27
  selectIsAnonymous,
28
28
  selectUserType,
29
29
  selectIsAuthReady,
30
+ selectIsRegisteredUser,
30
31
  } from "./auth.selectors";
31
32
 
32
33
  // Re-export types for convenience
@@ -47,6 +48,7 @@ export {
47
48
  selectIsAnonymous,
48
49
  selectUserType,
49
50
  selectIsAuthReady,
51
+ selectIsRegisteredUser,
50
52
  };
51
53
 
52
54
  // Re-export listener functions
@@ -172,3 +174,11 @@ export function getIsAuthenticated(): boolean {
172
174
  export function getIsAnonymous(): boolean {
173
175
  return selectIsAnonymous(useAuthStore.getState());
174
176
  }
177
+
178
+ /**
179
+ * Check if registered user without hook
180
+ * Returns true only if user is authenticated AND not anonymous
181
+ */
182
+ export function getIsRegisteredUser(): boolean {
183
+ return selectIsRegisteredUser(useAuthStore.getState());
184
+ }