@umituz/react-native-auth 4.3.82 → 4.3.84

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": "4.3.82",
3
+ "version": "4.3.84",
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",
@@ -26,7 +26,21 @@ export class AuthService {
26
26
  }
27
27
 
28
28
  private get repositoryInstance(): AuthRepository {
29
- if (!this.initialized) throw new Error("AuthService not initialized");
29
+ // Auto-initialize if not already initialized (prevent button failures)
30
+ if (!this.initialized) {
31
+ if (__DEV__) {
32
+ console.warn('[AuthService] Auto-initializing to prevent auth failures. Call initialize() explicitly in production.');
33
+ }
34
+ // Don't await - fire and forget to prevent blocking UI
35
+ this.initialize().catch((error) => {
36
+ console.error('[AuthService] Auto-initialization failed:', error);
37
+ });
38
+ // For synchronous operations, create repository immediately
39
+ if (!this.repository) {
40
+ this.repository = new AuthRepository(this.config);
41
+ this.initialized = true;
42
+ }
43
+ }
30
44
  return this.repository;
31
45
  }
32
46
 
@@ -133,7 +147,18 @@ export async function initializeAuthService(
133
147
  }
134
148
 
135
149
  export function getAuthService(): AuthService | null {
136
- return (authServiceInstance && authServiceInstance.isInitialized()) ? authServiceInstance : null;
150
+ if (!authServiceInstance) {
151
+ // Auto-create instance if it doesn't exist
152
+ authServiceInstance = new AuthService();
153
+ }
154
+ // Trigger auto-initialization if needed
155
+ if (!authServiceInstance.isInitialized()) {
156
+ // Non-blocking initialization attempt
157
+ authServiceInstance.initialize().catch(() => {
158
+ // Error will be handled by the service itself
159
+ });
160
+ }
161
+ return authServiceInstance;
137
162
  }
138
163
 
139
164
  export function resetAuthService(): void {
@@ -1,10 +1,19 @@
1
- import type { PasswordConfig } from "@domain/value-objects/AuthConfig";
1
+ import type { PasswordConfig } from "../../domain/value-objects/AuthConfig";
2
2
  import { isEmptyEmail, isEmptyPassword, isEmptyName } from "./validation/validationHelpers";
3
- import type {
4
- ValidationResult,
5
- PasswordStrengthResult,
6
- PasswordRequirements,
7
- } from "@shared/validation/types";
3
+
4
+ // Define validation types locally
5
+ export interface ValidationResult {
6
+ isValid: boolean;
7
+ error?: string;
8
+ }
9
+
10
+ export interface PasswordRequirements {
11
+ hasMinLength: boolean;
12
+ }
13
+
14
+ export interface PasswordStrengthResult extends ValidationResult {
15
+ requirements: PasswordRequirements;
16
+ }
8
17
 
9
18
  // Export validation types
10
19
  export type {
@@ -9,7 +9,7 @@ import {
9
9
  validatePasswordConfirmation,
10
10
  } from "../AuthValidation";
11
11
  import type { PasswordConfig } from "../../../domain/value-objects/AuthConfig";
12
- import type { PasswordRequirements } from "@shared/validation/types";
12
+ import type { PasswordRequirements } from "../AuthValidation";
13
13
 
14
14
  interface PasswordValidationInput {
15
15
  password: string;
@@ -3,7 +3,7 @@ import { View, StyleSheet } from "react-native";
3
3
  import { useAppDesignTokens } from "@umituz/react-native-design-system/theme";
4
4
  import { AtomicText } from "@umituz/react-native-design-system/atoms";
5
5
  import type { ColorVariant } from "@umituz/react-native-design-system/typography";
6
- import type { PasswordRequirements } from "@shared/validation/types";
6
+ import type { PasswordRequirements } from "../../infrastructure/utils/AuthValidation";
7
7
 
8
8
  export interface PasswordStrengthTranslations {
9
9
  minLength: string;
@@ -11,7 +11,7 @@ import { FormPasswordInput } from '../form/FormPasswordInput';
11
11
  import { PasswordStrengthIndicator } from '../PasswordStrengthIndicator';
12
12
  import { PasswordMatchIndicator } from '../PasswordMatchIndicator';
13
13
  import type { RegisterFormTranslations } from './types';
14
- import type { PasswordRequirements } from '@shared/validation/types';
14
+ import type { PasswordRequirements } from '../../../infrastructure/utils/AuthValidation';
15
15
 
16
16
  export interface RegisterFormFieldsProps {
17
17
  displayName: string;
@@ -12,7 +12,9 @@ export const useSignUpMutation = () => {
12
12
  return useMutation({
13
13
  mutationFn: async (params: SignUpCredentials): Promise<AuthUser> => {
14
14
  const service = getAuthService();
15
- if (!service) throw new Error("Auth Service not initialized");
15
+ if (!service) {
16
+ throw new Error("Unable to initialize authentication service. Please restart the app.");
17
+ }
16
18
  return service.signUp(params);
17
19
  },
18
20
  });
@@ -22,7 +24,9 @@ export const useSignInMutation = () => {
22
24
  return useMutation({
23
25
  mutationFn: async (params: AuthCredentials): Promise<AuthUser> => {
24
26
  const service = getAuthService();
25
- if (!service) throw new Error("Auth Service not initialized");
27
+ if (!service) {
28
+ throw new Error("Unable to initialize authentication service. Please restart the app.");
29
+ }
26
30
  return service.signIn(params);
27
31
  },
28
32
  });
@@ -32,7 +36,9 @@ export const useSignOutMutation = () => {
32
36
  return useMutation({
33
37
  mutationFn: async (): Promise<void> => {
34
38
  const service = getAuthService();
35
- if (!service) throw new Error("Auth Service not initialized");
39
+ if (!service) {
40
+ throw new Error("Unable to initialize authentication service. Please restart the app.");
41
+ }
36
42
  return service.signOut();
37
43
  },
38
44
  });
@@ -42,7 +48,9 @@ export const useAnonymousModeMutation = () => {
42
48
  return useMutation({
43
49
  mutationFn: async (): Promise<void> => {
44
50
  const service = getAuthService();
45
- if (!service) throw new Error("Auth Service not initialized");
51
+ if (!service) {
52
+ throw new Error("Unable to initialize authentication service. Please restart the app.");
53
+ }
46
54
  return service.setAnonymousMode();
47
55
  },
48
56
  });
@@ -5,9 +5,9 @@
5
5
  */
6
6
 
7
7
  import { useMemo } from "react";
8
- import type { PasswordRequirements } from "@shared/validation/types";
9
- import type { PasswordConfig } from "@domain/value-objects/AuthConfig";
10
- import { calculatePasswordValidation } from "@infrastructure/utils/calculators/passwordStrengthCalculator";
8
+ import type { PasswordRequirements } from "../../../infrastructure/utils/calculators/passwordStrengthCalculator";
9
+ import type { PasswordConfig } from "../../../domain/value-objects/AuthConfig";
10
+ import { calculatePasswordValidation } from "../../../infrastructure/utils/calculators/passwordStrengthCalculator";
11
11
 
12
12
  interface UsePasswordValidationResult {
13
13
  passwordRequirements: PasswordRequirements;