@umituz/react-native-auth 3.6.22 → 3.6.24

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.22",
3
+ "version": "3.6.24",
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",
package/src/index.ts CHANGED
@@ -214,6 +214,12 @@ export type { AuthListenerOptions } from './types/auth-store.types';
214
214
  // UTILITIES
215
215
  export { getAuthErrorLocalizationKey } from './presentation/utils/getAuthErrorMessage';
216
216
 
217
+ // App Service Helper (for configureAppServices)
218
+ export {
219
+ createAuthService,
220
+ type IAuthService as IAppAuthService,
221
+ } from './infrastructure/services/app-service-helpers';
222
+
217
223
  // Init Module Factory
218
224
  export {
219
225
  createAuthInitModule,
@@ -0,0 +1,30 @@
1
+ /**
2
+ * App Service Helpers
3
+ * Creates ready-to-use auth service for configureAppServices
4
+ */
5
+
6
+ import { useAuthStore, selectIsAuthenticated, selectUserId } from "../../presentation/stores/authStore";
7
+ import { useAuthModalStore } from "../../presentation/stores/authModalStore";
8
+
9
+ export interface IAuthService {
10
+ getUserId: () => string | null;
11
+ isAuthenticated: () => boolean;
12
+ requireAuth: () => string;
13
+ }
14
+
15
+ /**
16
+ * Creates an auth service implementation for configureAppServices
17
+ */
18
+ export function createAuthService(): IAuthService {
19
+ return {
20
+ getUserId: () => selectUserId(useAuthStore.getState()),
21
+ isAuthenticated: () => selectIsAuthenticated(useAuthStore.getState()),
22
+ requireAuth: () => {
23
+ if (!selectIsAuthenticated(useAuthStore.getState())) {
24
+ useAuthModalStore.getState().showAuthModal();
25
+ throw new Error("Auth required");
26
+ }
27
+ return selectUserId(useAuthStore.getState()) ?? "";
28
+ },
29
+ };
30
+ }
@@ -35,7 +35,7 @@ export interface AuthInitModuleConfig {
35
35
  /**
36
36
  * Function to collect device extras for user document
37
37
  */
38
- collectExtras?: () => Promise<Record<string, unknown>>;
38
+ collectExtras?: InitializeAuthOptions['collectExtras'];
39
39
 
40
40
  /**
41
41
  * Storage provider for auth persistence