@umituz/react-native-auth 3.6.23 → 3.6.25

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,11 +1,11 @@
1
1
  {
2
2
  "name": "@umituz/react-native-auth",
3
- "version": "3.6.23",
3
+ "version": "3.6.25",
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",
7
7
  "scripts": {
8
- "typecheck": "tsc --noEmit",
8
+ "typecheck": "tsc --noEmit --skipLibCheck",
9
9
  "lint": "eslint src --ext .ts,.tsx --max-warnings 0",
10
10
  "lint:fix": "eslint src --ext .ts,.tsx --fix",
11
11
  "version:patch": "npm version patch -m 'chore: release v%s'",
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
+ }
@@ -5,7 +5,6 @@
5
5
 
6
6
  import { initializeAuth } from '../infrastructure/services/initializeAuth';
7
7
  import type { InitializeAuthOptions } from '../infrastructure/services/initializeAuth';
8
- import { SubscriptionManager } from '@umituz/react-native-subscription';
9
8
 
10
9
  declare const __DEV__: boolean;
11
10
 
@@ -43,10 +42,10 @@ export interface AuthInitModuleConfig {
43
42
  storageProvider?: InitializeAuthOptions['storageProvider'];
44
43
 
45
44
  /**
46
- * Whether to restore purchases after user conversion
47
- * @default true
45
+ * Callback to restore purchases after user conversion
46
+ * If provided, will be called after anonymous user converts to authenticated
48
47
  */
49
- restorePurchasesOnConversion?: boolean;
48
+ onRestorePurchases?: () => Promise<void>;
50
49
 
51
50
  /**
52
51
  * Custom callback when user converts from anonymous to authenticated
@@ -96,7 +95,7 @@ export function createAuthInitModule(
96
95
  autoAnonymousSignIn = true,
97
96
  collectExtras,
98
97
  storageProvider,
99
- restorePurchasesOnConversion = true,
98
+ onRestorePurchases,
100
99
  onUserConverted,
101
100
  critical = true,
102
101
  dependsOn = ['firebase'],
@@ -121,12 +120,12 @@ export function createAuthInitModule(
121
120
  });
122
121
  }
123
122
 
124
- // Restore purchases after conversion
125
- if (restorePurchasesOnConversion) {
123
+ // Restore purchases after conversion (if callback provided)
124
+ if (onRestorePurchases) {
126
125
  try {
127
- const result = await SubscriptionManager.restore();
126
+ await onRestorePurchases();
128
127
  if (typeof __DEV__ !== 'undefined' && __DEV__) {
129
- console.log('[createAuthInitModule] Restore purchases result:', result);
128
+ console.log('[createAuthInitModule] Purchases restored');
130
129
  }
131
130
  } catch (error) {
132
131
  if (typeof __DEV__ !== 'undefined' && __DEV__) {