@umituz/react-native-auth 2.0.1 → 2.2.0

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.
Files changed (94) hide show
  1. package/package.json +21 -32
  2. package/src/index.ts +8 -0
  3. package/src/presentation/components/AuthBottomSheet.tsx +175 -0
  4. package/src/presentation/stores/authModalStore.ts +72 -0
  5. package/README.md +0 -227
  6. package/lib/__tests__/services/AuthCoreService.test.d.ts +0 -4
  7. package/lib/__tests__/services/AuthCoreService.test.js +0 -198
  8. package/lib/__tests__/services/AuthPackage.test.d.ts +0 -4
  9. package/lib/__tests__/services/AuthPackage.test.js +0 -177
  10. package/lib/__tests__/services/GuestModeService.test.d.ts +0 -4
  11. package/lib/__tests__/services/GuestModeService.test.js +0 -141
  12. package/lib/__tests__/utils/AuthValidation.test.d.ts +0 -4
  13. package/lib/__tests__/utils/AuthValidation.test.js +0 -222
  14. package/lib/application/ports/IAuthProvider.d.ts +0 -42
  15. package/lib/application/ports/IAuthProvider.js +0 -5
  16. package/lib/application/ports/IAuthService.d.ts +0 -48
  17. package/lib/application/ports/IAuthService.js +0 -5
  18. package/lib/domain/entities/AuthUser.d.ts +0 -12
  19. package/lib/domain/entities/AuthUser.js +0 -5
  20. package/lib/domain/errors/AuthError.d.ts +0 -36
  21. package/lib/domain/errors/AuthError.js +0 -76
  22. package/lib/domain/value-objects/AuthConfig.d.ts +0 -16
  23. package/lib/domain/value-objects/AuthConfig.js +0 -14
  24. package/lib/index.d.ts +0 -45
  25. package/lib/index.js +0 -59
  26. package/lib/infrastructure/adapters/StorageProviderAdapter.d.ts +0 -16
  27. package/lib/infrastructure/adapters/StorageProviderAdapter.js +0 -72
  28. package/lib/infrastructure/adapters/UIProviderAdapter.d.ts +0 -18
  29. package/lib/infrastructure/adapters/UIProviderAdapter.js +0 -28
  30. package/lib/infrastructure/providers/FirebaseAuthProvider.d.ts +0 -19
  31. package/lib/infrastructure/providers/FirebaseAuthProvider.js +0 -94
  32. package/lib/infrastructure/services/AuthCoreService.d.ts +0 -22
  33. package/lib/infrastructure/services/AuthCoreService.js +0 -102
  34. package/lib/infrastructure/services/AuthEventService.d.ts +0 -28
  35. package/lib/infrastructure/services/AuthEventService.js +0 -88
  36. package/lib/infrastructure/services/AuthPackage.d.ts +0 -62
  37. package/lib/infrastructure/services/AuthPackage.js +0 -91
  38. package/lib/infrastructure/services/AuthService.d.ts +0 -42
  39. package/lib/infrastructure/services/AuthService.js +0 -123
  40. package/lib/infrastructure/services/GuestModeService.d.ts +0 -23
  41. package/lib/infrastructure/services/GuestModeService.js +0 -69
  42. package/lib/infrastructure/storage/GuestModeStorage.d.ts +0 -16
  43. package/lib/infrastructure/storage/GuestModeStorage.js +0 -73
  44. package/lib/infrastructure/utils/AuthErrorMapper.d.ts +0 -8
  45. package/lib/infrastructure/utils/AuthErrorMapper.js +0 -51
  46. package/lib/infrastructure/utils/AuthEventEmitter.d.ts +0 -12
  47. package/lib/infrastructure/utils/AuthEventEmitter.js +0 -25
  48. package/lib/infrastructure/utils/AuthValidation.d.ts +0 -49
  49. package/lib/infrastructure/utils/AuthValidation.js +0 -133
  50. package/lib/infrastructure/utils/UserMapper.d.ts +0 -15
  51. package/lib/infrastructure/utils/UserMapper.js +0 -16
  52. package/lib/presentation/components/AuthContainer.d.ts +0 -10
  53. package/lib/presentation/components/AuthContainer.js +0 -27
  54. package/lib/presentation/components/AuthDivider.d.ts +0 -6
  55. package/lib/presentation/components/AuthDivider.js +0 -36
  56. package/lib/presentation/components/AuthErrorDisplay.d.ts +0 -10
  57. package/lib/presentation/components/AuthErrorDisplay.js +0 -24
  58. package/lib/presentation/components/AuthFormCard.d.ts +0 -10
  59. package/lib/presentation/components/AuthFormCard.js +0 -19
  60. package/lib/presentation/components/AuthGradientBackground.d.ts +0 -6
  61. package/lib/presentation/components/AuthGradientBackground.js +0 -8
  62. package/lib/presentation/components/AuthHeader.d.ts +0 -11
  63. package/lib/presentation/components/AuthHeader.js +0 -38
  64. package/lib/presentation/components/AuthLegalLinks.d.ts +0 -28
  65. package/lib/presentation/components/AuthLegalLinks.js +0 -54
  66. package/lib/presentation/components/AuthLink.d.ts +0 -13
  67. package/lib/presentation/components/AuthLink.js +0 -27
  68. package/lib/presentation/components/LoginForm.d.ts +0 -10
  69. package/lib/presentation/components/LoginForm.js +0 -27
  70. package/lib/presentation/components/PasswordMatchIndicator.d.ts +0 -9
  71. package/lib/presentation/components/PasswordMatchIndicator.js +0 -30
  72. package/lib/presentation/components/PasswordStrengthIndicator.d.ts +0 -11
  73. package/lib/presentation/components/PasswordStrengthIndicator.js +0 -60
  74. package/lib/presentation/components/RegisterForm.d.ts +0 -14
  75. package/lib/presentation/components/RegisterForm.js +0 -30
  76. package/lib/presentation/hooks/useAuth.d.ts +0 -44
  77. package/lib/presentation/hooks/useAuth.js +0 -38
  78. package/lib/presentation/hooks/useAuthActions.d.ts +0 -15
  79. package/lib/presentation/hooks/useAuthActions.js +0 -162
  80. package/lib/presentation/hooks/useAuthState.d.ts +0 -19
  81. package/lib/presentation/hooks/useAuthState.js +0 -79
  82. package/lib/presentation/hooks/useLoginForm.d.ts +0 -21
  83. package/lib/presentation/hooks/useLoginForm.js +0 -131
  84. package/lib/presentation/hooks/useRegisterForm.d.ts +0 -31
  85. package/lib/presentation/hooks/useRegisterForm.js +0 -136
  86. package/lib/presentation/navigation/AuthNavigator.d.ts +0 -28
  87. package/lib/presentation/navigation/AuthNavigator.js +0 -37
  88. package/lib/presentation/screens/LoginScreen.d.ts +0 -6
  89. package/lib/presentation/screens/LoginScreen.js +0 -15
  90. package/lib/presentation/screens/RegisterScreen.d.ts +0 -12
  91. package/lib/presentation/screens/RegisterScreen.js +0 -15
  92. package/lib/presentation/utils/getAuthErrorMessage.d.ts +0 -8
  93. package/lib/presentation/utils/getAuthErrorMessage.js +0 -69
  94. package/src/domain/errors/AuthError.ts +0 -85
@@ -1,123 +0,0 @@
1
- /**
2
- * Auth Service
3
- * Orchestrates authentication operations using composition
4
- */
5
- import { DEFAULT_AUTH_CONFIG } from "../../domain/value-objects/AuthConfig";
6
- import { AuthCoreService } from "./AuthCoreService";
7
- import { GuestModeService } from "./GuestModeService";
8
- import { authEventService } from "./AuthEventService";
9
- import { getAuthPackage } from "./AuthPackage";
10
- export class AuthService {
11
- constructor(config = {}, storageProvider) {
12
- this.initialized = false;
13
- const authConfig = {
14
- ...DEFAULT_AUTH_CONFIG,
15
- ...config,
16
- password: {
17
- ...DEFAULT_AUTH_CONFIG.password,
18
- ...config.password,
19
- },
20
- };
21
- this.coreService = new AuthCoreService(authConfig);
22
- this.guestModeService = new GuestModeService();
23
- this.storageProvider = storageProvider;
24
- }
25
- async initialize(providerOrAuth) {
26
- if (this.initialized) {
27
- return;
28
- }
29
- // Initialize core service
30
- await this.coreService.initialize(providerOrAuth);
31
- // Initialize guest mode if storage provider is available
32
- if (this.storageProvider) {
33
- await this.guestModeService.load(this.storageProvider);
34
- }
35
- this.initialized = true;
36
- }
37
- isInitialized() {
38
- return this.initialized && this.coreService.isInitialized();
39
- }
40
- async signUp(params) {
41
- const user = await this.coreService.signUp(params);
42
- // Clear guest mode when user signs up
43
- if (this.guestModeService.getIsGuestMode() && this.storageProvider) {
44
- await this.guestModeService.clear(this.storageProvider);
45
- }
46
- authEventService.emitUserAuthenticated(user.uid);
47
- return user;
48
- }
49
- async signIn(params) {
50
- const user = await this.coreService.signIn(params);
51
- // Clear guest mode when user signs in
52
- if (this.guestModeService.getIsGuestMode() && this.storageProvider) {
53
- await this.guestModeService.clear(this.storageProvider);
54
- }
55
- authEventService.emitUserAuthenticated(user.uid);
56
- return user;
57
- }
58
- async signOut() {
59
- await this.coreService.signOut();
60
- // Clear guest mode if signing out explicitly
61
- if (this.guestModeService.getIsGuestMode() && this.storageProvider) {
62
- await this.guestModeService.clear(this.storageProvider);
63
- }
64
- }
65
- async setGuestMode() {
66
- if (!this.storageProvider) {
67
- throw new Error("Storage provider is required for guest mode");
68
- }
69
- // No provider needed for guest mode enablement
70
- await this.guestModeService.enable(this.storageProvider);
71
- }
72
- getCurrentUser() {
73
- if (this.guestModeService.getIsGuestMode()) {
74
- return null;
75
- }
76
- return this.coreService.getCurrentUser();
77
- }
78
- getIsGuestMode() {
79
- return this.guestModeService.getIsGuestMode();
80
- }
81
- onAuthStateChange(callback) {
82
- const wrappedCallback = this.guestModeService.wrapAuthStateCallback(callback);
83
- return this.coreService.onAuthStateChange(wrappedCallback);
84
- }
85
- getConfig() {
86
- return this.coreService.getConfig();
87
- }
88
- getCoreService() {
89
- return this.coreService;
90
- }
91
- getGuestModeService() {
92
- return this.guestModeService;
93
- }
94
- }
95
- // Singleton instance
96
- let authServiceInstance = null;
97
- /**
98
- * Initialize auth service with provider or Firebase Auth instance
99
- */
100
- export async function initializeAuthService(providerOrAuth, config, storageProvider) {
101
- if (!authServiceInstance) {
102
- // Initialize package if not already done
103
- const packageConfig = getAuthPackage()?.getConfig();
104
- authServiceInstance = new AuthService(config, storageProvider);
105
- }
106
- await authServiceInstance.initialize(providerOrAuth);
107
- return authServiceInstance;
108
- }
109
- /**
110
- * Get auth service instance
111
- */
112
- export function getAuthService() {
113
- if (!authServiceInstance || !authServiceInstance.isInitialized()) {
114
- return null;
115
- }
116
- return authServiceInstance;
117
- }
118
- /**
119
- * Reset auth service (useful for testing)
120
- */
121
- export function resetAuthService() {
122
- authServiceInstance = null;
123
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Guest Mode Service
3
- * Handles guest mode functionality
4
- */
5
- import type { IAuthProvider } from "../../application/ports/IAuthProvider";
6
- import type { AuthUser } from "../../domain/entities/AuthUser";
7
- export interface IStorageProvider {
8
- get(key: string): Promise<string | null>;
9
- set(key: string, value: string): Promise<void>;
10
- remove(key: string): Promise<void>;
11
- }
12
- export declare class GuestModeService {
13
- private isGuestMode;
14
- private storageKey;
15
- constructor(storageKey?: string);
16
- load(storageProvider: IStorageProvider): Promise<boolean>;
17
- save(storageProvider: IStorageProvider): Promise<void>;
18
- clear(storageProvider: IStorageProvider): Promise<void>;
19
- enable(storageProvider: IStorageProvider, provider?: IAuthProvider): Promise<void>;
20
- getIsGuestMode(): boolean;
21
- setGuestMode(enabled: boolean): void;
22
- wrapAuthStateCallback(callback: (user: AuthUser | null) => void): (user: AuthUser | null) => void;
23
- }
@@ -1,69 +0,0 @@
1
- /**
2
- * Guest Mode Service
3
- * Handles guest mode functionality
4
- */
5
- import { emitGuestModeEnabled } from "../utils/AuthEventEmitter";
6
- export class GuestModeService {
7
- constructor(storageKey = "@auth_guest_mode") {
8
- this.isGuestMode = false;
9
- this.storageKey = storageKey;
10
- }
11
- async load(storageProvider) {
12
- try {
13
- const value = await storageProvider.get(this.storageKey);
14
- this.isGuestMode = value === "true";
15
- return this.isGuestMode;
16
- }
17
- catch {
18
- return false;
19
- }
20
- }
21
- async save(storageProvider) {
22
- try {
23
- await storageProvider.set(this.storageKey, this.isGuestMode.toString());
24
- }
25
- catch {
26
- // Silently fail storage operations
27
- }
28
- }
29
- async clear(storageProvider) {
30
- try {
31
- await storageProvider.remove(this.storageKey);
32
- }
33
- catch {
34
- // Silently fail storage operations
35
- }
36
- this.isGuestMode = false;
37
- }
38
- async enable(storageProvider, provider) {
39
- // Sign out from provider if logged in
40
- if (provider?.getCurrentUser()) {
41
- try {
42
- await provider.signOut();
43
- }
44
- catch {
45
- // Ignore sign out errors when switching to guest mode
46
- }
47
- }
48
- this.isGuestMode = true;
49
- await this.save(storageProvider);
50
- emitGuestModeEnabled();
51
- }
52
- getIsGuestMode() {
53
- return this.isGuestMode;
54
- }
55
- setGuestMode(enabled) {
56
- this.isGuestMode = enabled;
57
- }
58
- wrapAuthStateCallback(callback) {
59
- return (user) => {
60
- // Don't update if in guest mode
61
- if (!this.isGuestMode) {
62
- callback(user);
63
- }
64
- else {
65
- callback(null);
66
- }
67
- };
68
- }
69
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Guest Mode Storage
3
- * Single Responsibility: Manage guest mode persistence
4
- */
5
- /**
6
- * Load guest mode from storage
7
- */
8
- export declare function loadGuestMode(storageKey?: string): Promise<boolean>;
9
- /**
10
- * Save guest mode to storage
11
- */
12
- export declare function saveGuestMode(isGuest: boolean, storageKey?: string): Promise<void>;
13
- /**
14
- * Clear guest mode from storage
15
- */
16
- export declare function clearGuestMode(storageKey?: string): Promise<void>;
@@ -1,73 +0,0 @@
1
- /**
2
- * Guest Mode Storage
3
- * Single Responsibility: Manage guest mode persistence
4
- */
5
- import { getAuthPackage } from "../services/AuthPackage";
6
- /**
7
- * Load guest mode from storage
8
- */
9
- export async function loadGuestMode(storageKey) {
10
- try {
11
- const packageConfig = getAuthPackage()?.getConfig();
12
- const key = storageKey ?? packageConfig?.storageKeys.guestMode ?? "@auth_guest_mode";
13
- const storageProvider = getAuthPackage()?.getStorageProvider();
14
- if (!storageProvider) {
15
- if (__DEV__) {
16
- console.warn("[GuestModeStorage] No storage provider available");
17
- }
18
- return false;
19
- }
20
- const value = await storageProvider.get(key);
21
- return value === "true";
22
- }
23
- catch {
24
- return false;
25
- }
26
- }
27
- /**
28
- * Save guest mode to storage
29
- */
30
- export async function saveGuestMode(isGuest, storageKey) {
31
- try {
32
- const packageConfig = getAuthPackage()?.getConfig();
33
- const key = storageKey ?? packageConfig?.storageKeys.guestMode ?? "@auth_guest_mode";
34
- const storageProvider = getAuthPackage()?.getStorageProvider();
35
- if (!storageProvider) {
36
- if (__DEV__) {
37
- console.warn("[GuestModeStorage] No storage provider available");
38
- }
39
- return;
40
- }
41
- if (isGuest) {
42
- await storageProvider.set(key, "true");
43
- if (__DEV__) {
44
- console.log("[GuestModeStorage] Guest mode persisted to storage");
45
- }
46
- }
47
- else {
48
- await storageProvider.remove(key);
49
- }
50
- }
51
- catch (error) {
52
- if (__DEV__) {
53
- console.warn("[GuestModeStorage] Failed to persist guest mode:", error);
54
- }
55
- }
56
- }
57
- /**
58
- * Clear guest mode from storage
59
- */
60
- export async function clearGuestMode(storageKey) {
61
- try {
62
- const packageConfig = getAuthPackage()?.getConfig();
63
- const key = storageKey ?? packageConfig?.storageKeys.guestMode ?? "@auth_guest_mode";
64
- const storageProvider = getAuthPackage()?.getStorageProvider();
65
- if (!storageProvider) {
66
- return;
67
- }
68
- await storageProvider.remove(key);
69
- }
70
- catch {
71
- // Ignore storage errors
72
- }
73
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Auth Error Mapper
3
- * Single Responsibility: Map Firebase Auth errors to domain errors
4
- */
5
- /**
6
- * Map Firebase Auth errors to domain errors
7
- */
8
- export declare function mapFirebaseAuthError(error: unknown): Error;
@@ -1,51 +0,0 @@
1
- /**
2
- * Auth Error Mapper
3
- * Single Responsibility: Map Firebase Auth errors to domain errors
4
- */
5
- import { AuthError, AuthConfigurationError, AuthEmailAlreadyInUseError, AuthInvalidEmailError, AuthWeakPasswordError, AuthUserNotFoundError, AuthWrongPasswordError, AuthNetworkError, } from "../../domain/errors/AuthError";
6
- /**
7
- * Map Firebase Auth errors to domain errors
8
- */
9
- export function mapFirebaseAuthError(error) {
10
- if (!error || typeof error !== 'object') {
11
- return new AuthError("Authentication failed", "AUTH_UNKNOWN_ERROR");
12
- }
13
- const errorObj = error;
14
- const code = errorObj.code || "";
15
- const message = errorObj.message || "Authentication failed";
16
- switch (code) {
17
- case "auth/email-already-in-use":
18
- return new AuthEmailAlreadyInUseError();
19
- case "auth/invalid-email":
20
- return new AuthInvalidEmailError();
21
- case "auth/weak-password":
22
- return new AuthWeakPasswordError();
23
- case "auth/user-disabled":
24
- return new AuthError("Your account has been disabled. Please contact support.", "AUTH_USER_DISABLED");
25
- case "auth/user-not-found":
26
- return new AuthUserNotFoundError();
27
- case "auth/wrong-password":
28
- return new AuthWrongPasswordError();
29
- case "auth/invalid-credential":
30
- return new AuthError("Invalid email or password. Please check your credentials.", "AUTH_INVALID_CREDENTIAL");
31
- case "auth/invalid-login-credentials":
32
- return new AuthError("Invalid email or password. Please check your credentials.", "AUTH_INVALID_CREDENTIAL");
33
- case "auth/network-request-failed":
34
- return new AuthNetworkError();
35
- case "auth/too-many-requests":
36
- return new AuthError("Too many failed attempts. Please wait a few minutes and try again.", "AUTH_TOO_MANY_REQUESTS");
37
- case "auth/configuration-not-found":
38
- case "auth/app-not-authorized":
39
- return new AuthConfigurationError("Authentication is not properly configured. Please contact support.");
40
- case "auth/operation-not-allowed":
41
- return new AuthConfigurationError("Email/password authentication is not enabled. Please contact support.");
42
- case "auth/requires-recent-login":
43
- return new AuthError("Please sign in again to complete this action.", "AUTH_REQUIRES_RECENT_LOGIN");
44
- case "auth/expired-action-code":
45
- return new AuthError("This link has expired. Please request a new one.", "AUTH_EXPIRED_ACTION_CODE");
46
- case "auth/invalid-action-code":
47
- return new AuthError("This link is invalid. Please request a new one.", "AUTH_INVALID_ACTION_CODE");
48
- default:
49
- return new AuthError(message, code || "AUTH_UNKNOWN_ERROR");
50
- }
51
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Auth Event Emitter
3
- * Single Responsibility: Emit auth-related events
4
- */
5
- /**
6
- * Emit user authenticated event
7
- */
8
- export declare function emitUserAuthenticated(userId: string): void;
9
- /**
10
- * Emit guest mode enabled event
11
- */
12
- export declare function emitGuestModeEnabled(): void;
@@ -1,25 +0,0 @@
1
- /**
2
- * Auth Event Emitter
3
- * Single Responsibility: Emit auth-related events
4
- */
5
- import { DeviceEventEmitter } from "react-native";
6
- /**
7
- * Emit user authenticated event
8
- */
9
- export function emitUserAuthenticated(userId) {
10
- /* eslint-disable-next-line no-console */
11
- if (__DEV__) {
12
- console.log("[AuthEventEmitter] Emitting user-authenticated event");
13
- }
14
- DeviceEventEmitter.emit("user-authenticated", { userId });
15
- }
16
- /**
17
- * Emit guest mode enabled event
18
- */
19
- export function emitGuestModeEnabled() {
20
- /* eslint-disable-next-line no-console */
21
- if (__DEV__) {
22
- console.log("[AuthEventEmitter] Emitting guest-mode-enabled event");
23
- }
24
- DeviceEventEmitter.emit("guest-mode-enabled");
25
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * Auth Validation Utilities
3
- * Single Responsibility: Email and password validation for authentication
4
- */
5
- import type { PasswordConfig } from "../../domain/value-objects/AuthConfig";
6
- export interface ValidationResult {
7
- isValid: boolean;
8
- error?: string;
9
- }
10
- export interface PasswordStrengthResult extends ValidationResult {
11
- requirements: PasswordRequirements;
12
- }
13
- export interface PasswordRequirements {
14
- hasMinLength: boolean;
15
- hasUppercase: boolean;
16
- hasLowercase: boolean;
17
- hasNumber: boolean;
18
- hasSpecialChar: boolean;
19
- }
20
- export interface ValidationConfig {
21
- emailRegex: RegExp;
22
- uppercaseRegex: RegExp;
23
- lowercaseRegex: RegExp;
24
- numberRegex: RegExp;
25
- specialCharRegex: RegExp;
26
- displayNameMinLength: number;
27
- }
28
- /**
29
- * Validate email format
30
- */
31
- export declare function validateEmail(email: string): ValidationResult;
32
- /**
33
- * Validate password for login - only checks if password is provided
34
- * No strength requirements for login (existing users may have old passwords)
35
- */
36
- export declare function validatePasswordForLogin(password: string): ValidationResult;
37
- /**
38
- * Validate password strength for registration
39
- * Returns detailed requirements for UI feedback
40
- */
41
- export declare function validatePasswordForRegister(password: string, config: PasswordConfig): PasswordStrengthResult;
42
- /**
43
- * Validate password confirmation
44
- */
45
- export declare function validatePasswordConfirmation(password: string, confirmPassword: string): ValidationResult;
46
- /**
47
- * Validate display name
48
- */
49
- export declare function validateDisplayName(displayName: string, minLength?: number): ValidationResult;
@@ -1,133 +0,0 @@
1
- /**
2
- * Auth Validation Utilities
3
- * Single Responsibility: Email and password validation for authentication
4
- */
5
- import { getAuthPackage } from "../services/AuthPackage";
6
- const DEFAULT_VALIDATION_CONFIG = {
7
- emailRegex: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
8
- uppercaseRegex: /[A-Z]/,
9
- lowercaseRegex: /[a-z]/,
10
- numberRegex: /[0-9]/,
11
- specialCharRegex: /[!@#$%^&*(),.?":{}|<>]/,
12
- displayNameMinLength: 2,
13
- };
14
- function getValidationConfig() {
15
- const packageConfig = getAuthPackage()?.getConfig();
16
- return {
17
- emailRegex: packageConfig?.validation.emailRegex || DEFAULT_VALIDATION_CONFIG.emailRegex,
18
- uppercaseRegex: DEFAULT_VALIDATION_CONFIG.uppercaseRegex,
19
- lowercaseRegex: DEFAULT_VALIDATION_CONFIG.lowercaseRegex,
20
- numberRegex: DEFAULT_VALIDATION_CONFIG.numberRegex,
21
- specialCharRegex: DEFAULT_VALIDATION_CONFIG.specialCharRegex,
22
- displayNameMinLength: DEFAULT_VALIDATION_CONFIG.displayNameMinLength,
23
- };
24
- }
25
- /**
26
- * Validate email format
27
- */
28
- export function validateEmail(email) {
29
- if (!email || email.trim() === "") {
30
- return { isValid: false, error: "Email is required" };
31
- }
32
- const config = getValidationConfig();
33
- if (!config.emailRegex.test(email.trim())) {
34
- return { isValid: false, error: "Please enter a valid email address" };
35
- }
36
- return { isValid: true };
37
- }
38
- /**
39
- * Validate password for login - only checks if password is provided
40
- * No strength requirements for login (existing users may have old passwords)
41
- */
42
- export function validatePasswordForLogin(password) {
43
- if (!password || password.length === 0) {
44
- return { isValid: false, error: "Password is required" };
45
- }
46
- return { isValid: true };
47
- }
48
- /**
49
- * Validate password strength for registration
50
- * Returns detailed requirements for UI feedback
51
- */
52
- export function validatePasswordForRegister(password, config) {
53
- const validationConfig = getValidationConfig();
54
- const requirements = {
55
- hasMinLength: password.length >= config.minLength,
56
- hasUppercase: !config.requireUppercase || validationConfig.uppercaseRegex.test(password),
57
- hasLowercase: !config.requireLowercase || validationConfig.lowercaseRegex.test(password),
58
- hasNumber: !config.requireNumber || validationConfig.numberRegex.test(password),
59
- hasSpecialChar: !config.requireSpecialChar || validationConfig.specialCharRegex.test(password),
60
- };
61
- if (!password || password.length === 0) {
62
- return {
63
- isValid: false,
64
- error: "Password is required",
65
- requirements,
66
- };
67
- }
68
- if (!requirements.hasMinLength) {
69
- return {
70
- isValid: false,
71
- error: `Password must be at least ${config.minLength} characters`,
72
- requirements,
73
- };
74
- }
75
- if (config.requireUppercase && !validationConfig.uppercaseRegex.test(password)) {
76
- return {
77
- isValid: false,
78
- error: "Password must contain at least one uppercase letter",
79
- requirements,
80
- };
81
- }
82
- if (config.requireLowercase && !validationConfig.lowercaseRegex.test(password)) {
83
- return {
84
- isValid: false,
85
- error: "Password must contain at least one lowercase letter",
86
- requirements,
87
- };
88
- }
89
- if (config.requireNumber && !validationConfig.numberRegex.test(password)) {
90
- return {
91
- isValid: false,
92
- error: "Password must contain at least one number",
93
- requirements,
94
- };
95
- }
96
- if (config.requireSpecialChar && !validationConfig.specialCharRegex.test(password)) {
97
- return {
98
- isValid: false,
99
- error: "Password must contain at least one special character",
100
- requirements,
101
- };
102
- }
103
- return { isValid: true, requirements };
104
- }
105
- /**
106
- * Validate password confirmation
107
- */
108
- export function validatePasswordConfirmation(password, confirmPassword) {
109
- if (!confirmPassword) {
110
- return { isValid: false, error: "Please confirm your password" };
111
- }
112
- if (password !== confirmPassword) {
113
- return { isValid: false, error: "Passwords do not match" };
114
- }
115
- return { isValid: true };
116
- }
117
- /**
118
- * Validate display name
119
- */
120
- export function validateDisplayName(displayName, minLength) {
121
- if (!displayName || displayName.trim() === "") {
122
- return { isValid: false, error: "Name is required" };
123
- }
124
- const config = getValidationConfig();
125
- const actualMinLength = minLength ?? config.displayNameMinLength;
126
- if (displayName.trim().length < actualMinLength) {
127
- return {
128
- isValid: false,
129
- error: `Name must be at least ${actualMinLength} characters`,
130
- };
131
- }
132
- return { isValid: true };
133
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * User Mapper
3
- * Single Source of Truth for user object transformations
4
- */
5
- import type { AuthUser } from "../../domain/entities/AuthUser";
6
- interface FirebaseUserLike {
7
- uid: string;
8
- email: string | null;
9
- displayName: string | null;
10
- isAnonymous: boolean;
11
- emailVerified: boolean;
12
- photoURL: string | null;
13
- }
14
- export declare function mapToAuthUser(user: FirebaseUserLike | null): AuthUser | null;
15
- export {};
@@ -1,16 +0,0 @@
1
- /**
2
- * User Mapper
3
- * Single Source of Truth for user object transformations
4
- */
5
- export function mapToAuthUser(user) {
6
- if (!user)
7
- return null;
8
- return {
9
- uid: user.uid,
10
- email: user.email,
11
- displayName: user.displayName,
12
- isAnonymous: user.isAnonymous,
13
- emailVerified: user.emailVerified,
14
- photoURL: user.photoURL,
15
- };
16
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Auth Container Component
3
- * Main container for auth screens with gradient and scroll
4
- */
5
- import React from "react";
6
- interface AuthContainerProps {
7
- children: React.ReactNode;
8
- }
9
- export declare const AuthContainer: React.FC<AuthContainerProps>;
10
- export {};
@@ -1,27 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { View, StyleSheet, ScrollView, KeyboardAvoidingView, Platform, } from "react-native";
3
- import { useSafeAreaInsets } from "react-native-safe-area-context";
4
- import { AuthGradientBackground } from "./AuthGradientBackground";
5
- export const AuthContainer = ({ children }) => {
6
- const insets = useSafeAreaInsets();
7
- return (_jsxs(KeyboardAvoidingView, { style: styles.container, behavior: Platform.OS === "ios" ? "padding" : "height", keyboardVerticalOffset: Platform.OS === "ios" ? 0 : 20, children: [_jsx(AuthGradientBackground, {}), _jsx(ScrollView, { contentContainerStyle: [
8
- styles.scrollContent,
9
- { paddingTop: insets.top + 40, paddingBottom: insets.bottom + 40 },
10
- ], keyboardShouldPersistTaps: "handled", showsVerticalScrollIndicator: false, children: _jsx(View, { style: styles.content, children: children }) })] }));
11
- };
12
- const styles = StyleSheet.create({
13
- container: {
14
- flex: 1,
15
- },
16
- scrollContent: {
17
- flexGrow: 1,
18
- paddingHorizontal: 20,
19
- },
20
- content: {
21
- flex: 1,
22
- justifyContent: "center",
23
- maxWidth: 440,
24
- alignSelf: "center",
25
- width: "100%",
26
- },
27
- });
@@ -1,6 +0,0 @@
1
- /**
2
- * Auth Divider Component
3
- * Divider with "OR" text for auth screens
4
- */
5
- import React from "react";
6
- export declare const AuthDivider: React.FC;