@umituz/react-native-auth 4.3.13 → 4.3.15
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 +1 -1
- package/src/application/services/ValidationService.ts +0 -28
- package/src/domain/value-objects/AuthConfig.ts +2 -2
- package/src/infrastructure/adapters/StorageProviderAdapter.ts +4 -3
- package/src/infrastructure/services/AuthEventService.ts +3 -10
- package/src/infrastructure/utils/AuthValidation.ts +2 -2
- package/src/infrastructure/utils/UserMapper.ts +1 -1
- package/src/infrastructure/utils/authConversionDetector.ts +1 -1
- package/src/infrastructure/utils/authStateHandler.ts +1 -1
- package/src/infrastructure/utils/listener/anonymousSignInHandler.ts +3 -3
- package/src/infrastructure/utils/listener/cleanupHandlers.ts +1 -1
- package/src/infrastructure/utils/listener/listenerLifecycle.util.ts +0 -7
- package/src/infrastructure/utils/listener/listenerState.util.ts +1 -22
- package/src/init/index.ts +1 -6
- package/src/presentation/components/AccountActions.tsx +1 -1
- package/src/presentation/components/AuthHeader.tsx +1 -1
- package/src/presentation/components/AuthLegalLinks.tsx +1 -1
- package/src/presentation/components/EditProfileActions.tsx +1 -1
- package/src/presentation/components/EditProfileAvatar.tsx +1 -1
- package/src/presentation/components/EditProfileForm.tsx +1 -1
- package/src/presentation/components/LoginForm.tsx +1 -1
- package/src/presentation/components/PasswordMatchIndicator.tsx +1 -1
- package/src/presentation/components/PasswordStrengthIndicator.tsx +1 -1
- package/src/presentation/components/ProfileBenefitsList.tsx +3 -3
- package/src/presentation/components/RegisterForm.tsx +1 -1
- package/src/presentation/components/SocialLoginButtons.tsx +1 -1
- package/src/presentation/components/form/FormEmailInput.tsx +1 -1
- package/src/presentation/components/form/FormPasswordInput.tsx +1 -1
- package/src/presentation/components/form/FormTextInput.tsx +1 -1
- package/src/presentation/components/form/index.ts +0 -3
- package/src/presentation/hooks/useAuthRequired.ts +1 -1
- package/src/presentation/hooks/useGoogleAuth.ts +0 -2
- package/src/presentation/hooks/useLoginForm.ts +1 -1
- package/src/presentation/hooks/useSocialLogin.ts +0 -1
- package/src/presentation/navigation/AuthNavigator.tsx +27 -25
- package/src/presentation/providers/AuthProvider.tsx +1 -1
- package/src/presentation/screens/EditProfileScreen.tsx +2 -2
- package/src/presentation/screens/PasswordPromptScreen.tsx +0 -1
- package/src/presentation/stores/authModalStore.ts +1 -1
- package/src/presentation/stores/authStore.ts +1 -47
- package/src/presentation/utils/authTransition.util.ts +2 -14
- package/src/presentation/utils/commonStyles.ts +0 -45
- package/src/presentation/utils/form/formErrorUtils.ts +0 -55
- package/src/presentation/utils/form/formValidation.util.ts +0 -12
- package/src/presentation/utils/form/useFormField.hook.ts +1 -51
- package/src/presentation/utils/form/usePasswordValidation.hook.ts +2 -16
- package/src/presentation/utils/passwordPromptCallback.ts +0 -2
- package/src/presentation/utils/socialAuthHandler.util.ts +1 -55
- package/src/infrastructure/utils/AuthErrorMapper.ts +0 -93
- package/src/infrastructure/utils/error/errorCodeMapping.constants.ts +0 -23
- package/src/infrastructure/utils/error/errorExtraction.ts +0 -80
- package/src/infrastructure/utils/error/mappings/actionCodeErrorMappings.ts +0 -26
- package/src/infrastructure/utils/error/mappings/authErrorMappings.ts +0 -69
- package/src/infrastructure/utils/error/mappings/configErrorMappings.ts +0 -31
- package/src/infrastructure/utils/error/mappings/errorMapping.types.ts +0 -12
- package/src/infrastructure/utils/error/mappings/networkErrorMappings.ts +0 -22
- package/src/presentation/utils/authOperation.util.ts +0 -67
- package/src/presentation/utils/form/formFieldState.util.ts +0 -82
- package/src/presentation/utils/form/validation/formValidation.hook.ts +0 -30
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication Error Mappings
|
|
3
|
-
* Email, password, and credential related errors
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
AuthError,
|
|
8
|
-
AuthEmailAlreadyInUseError,
|
|
9
|
-
AuthInvalidEmailError,
|
|
10
|
-
AuthWeakPasswordError,
|
|
11
|
-
AuthUserNotFoundError,
|
|
12
|
-
AuthWrongPasswordError,
|
|
13
|
-
} from "../../../../domain/errors/AuthError";
|
|
14
|
-
import type { ErrorMapping } from "./errorMapping.types";
|
|
15
|
-
|
|
16
|
-
export const AUTH_ERROR_MAPPINGS: Record<string, ErrorMapping> = {
|
|
17
|
-
"auth/email-already-in-use": {
|
|
18
|
-
type: "class",
|
|
19
|
-
create: AuthEmailAlreadyInUseError,
|
|
20
|
-
},
|
|
21
|
-
"auth/invalid-email": {
|
|
22
|
-
type: "class",
|
|
23
|
-
create: AuthInvalidEmailError,
|
|
24
|
-
},
|
|
25
|
-
"auth/weak-password": {
|
|
26
|
-
type: "class",
|
|
27
|
-
create: AuthWeakPasswordError,
|
|
28
|
-
},
|
|
29
|
-
"auth/user-disabled": {
|
|
30
|
-
type: "factory",
|
|
31
|
-
create: () =>
|
|
32
|
-
new AuthError(
|
|
33
|
-
"Your account has been disabled. Please contact support.",
|
|
34
|
-
"AUTH_USER_DISABLED"
|
|
35
|
-
),
|
|
36
|
-
},
|
|
37
|
-
"auth/user-not-found": {
|
|
38
|
-
type: "class",
|
|
39
|
-
create: AuthUserNotFoundError,
|
|
40
|
-
},
|
|
41
|
-
"auth/wrong-password": {
|
|
42
|
-
type: "class",
|
|
43
|
-
create: AuthWrongPasswordError,
|
|
44
|
-
},
|
|
45
|
-
"auth/invalid-credential": {
|
|
46
|
-
type: "factory",
|
|
47
|
-
create: () =>
|
|
48
|
-
new AuthError(
|
|
49
|
-
"Invalid email or password. Please check your credentials.",
|
|
50
|
-
"AUTH_INVALID_CREDENTIAL"
|
|
51
|
-
),
|
|
52
|
-
},
|
|
53
|
-
"auth/invalid-login-credentials": {
|
|
54
|
-
type: "factory",
|
|
55
|
-
create: () =>
|
|
56
|
-
new AuthError(
|
|
57
|
-
"Invalid email or password. Please check your credentials.",
|
|
58
|
-
"AUTH_INVALID_CREDENTIAL"
|
|
59
|
-
),
|
|
60
|
-
},
|
|
61
|
-
"auth/requires-recent-login": {
|
|
62
|
-
type: "factory",
|
|
63
|
-
create: () =>
|
|
64
|
-
new AuthError(
|
|
65
|
-
"Please sign in again to complete this action.",
|
|
66
|
-
"AUTH_REQUIRES_RECENT_LOGIN"
|
|
67
|
-
),
|
|
68
|
-
},
|
|
69
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration Error Mappings
|
|
3
|
-
* Firebase configuration and setup errors
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { AuthConfigurationError } from "../../../../domain/errors/AuthError";
|
|
7
|
-
import type { ErrorMapping } from "./errorMapping.types";
|
|
8
|
-
|
|
9
|
-
export const CONFIG_ERROR_MAPPINGS: Record<string, ErrorMapping> = {
|
|
10
|
-
"auth/configuration-not-found": {
|
|
11
|
-
type: "factory",
|
|
12
|
-
create: () =>
|
|
13
|
-
new AuthConfigurationError(
|
|
14
|
-
"Authentication is not properly configured. Please contact support."
|
|
15
|
-
),
|
|
16
|
-
},
|
|
17
|
-
"auth/app-not-authorized": {
|
|
18
|
-
type: "factory",
|
|
19
|
-
create: () =>
|
|
20
|
-
new AuthConfigurationError(
|
|
21
|
-
"Authentication is not properly configured. Please contact support."
|
|
22
|
-
),
|
|
23
|
-
},
|
|
24
|
-
"auth/operation-not-allowed": {
|
|
25
|
-
type: "factory",
|
|
26
|
-
create: () =>
|
|
27
|
-
new AuthConfigurationError(
|
|
28
|
-
"Email/password authentication is not enabled. Please contact support."
|
|
29
|
-
),
|
|
30
|
-
},
|
|
31
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Mapping Types
|
|
3
|
-
* Shared types for error code mappings
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export type ErrorConstructor = new (message?: string) => Error;
|
|
7
|
-
export type ErrorFactory = () => Error;
|
|
8
|
-
|
|
9
|
-
export interface ErrorMapping {
|
|
10
|
-
type: "class" | "factory";
|
|
11
|
-
create: ErrorConstructor | ErrorFactory;
|
|
12
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Network Error Mappings
|
|
3
|
-
* Network and rate limit errors
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { AuthError, AuthNetworkError } from "../../../../domain/errors/AuthError";
|
|
7
|
-
import type { ErrorMapping } from "./errorMapping.types";
|
|
8
|
-
|
|
9
|
-
export const NETWORK_ERROR_MAPPINGS: Record<string, ErrorMapping> = {
|
|
10
|
-
"auth/network-request-failed": {
|
|
11
|
-
type: "class",
|
|
12
|
-
create: AuthNetworkError,
|
|
13
|
-
},
|
|
14
|
-
"auth/too-many-requests": {
|
|
15
|
-
type: "factory",
|
|
16
|
-
create: () =>
|
|
17
|
-
new AuthError(
|
|
18
|
-
"Too many failed attempts. Please wait a few minutes and try again.",
|
|
19
|
-
"AUTH_TOO_MANY_REQUESTS"
|
|
20
|
-
),
|
|
21
|
-
},
|
|
22
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth Operation Utilities
|
|
3
|
-
* Shared error handling for authentication operations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useCallback } from "react";
|
|
7
|
-
|
|
8
|
-
export interface AuthOperationOptions {
|
|
9
|
-
setLoading: (loading: boolean) => void;
|
|
10
|
-
setError: (error: string | null) => void;
|
|
11
|
-
onSuccess?: () => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Create an auth operation wrapper with consistent error handling
|
|
16
|
-
*/
|
|
17
|
-
export function createAuthOperation<T>(
|
|
18
|
-
mutation: (params: T) => Promise<unknown>,
|
|
19
|
-
options: AuthOperationOptions
|
|
20
|
-
) {
|
|
21
|
-
const { setLoading, setError, onSuccess } = options;
|
|
22
|
-
|
|
23
|
-
return useCallback(
|
|
24
|
-
async (params: T) => {
|
|
25
|
-
try {
|
|
26
|
-
setLoading(true);
|
|
27
|
-
setError(null);
|
|
28
|
-
await mutation(params);
|
|
29
|
-
onSuccess?.();
|
|
30
|
-
} catch (err: unknown) {
|
|
31
|
-
const errorMessage = err instanceof Error ? err.message : "Operation failed";
|
|
32
|
-
setError(errorMessage);
|
|
33
|
-
throw err;
|
|
34
|
-
} finally {
|
|
35
|
-
setLoading(false);
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
[setLoading, setError, onSuccess, mutation]
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Create auth operation that doesn't throw on failure
|
|
44
|
-
*/
|
|
45
|
-
export function createSilentAuthOperation<T>(
|
|
46
|
-
mutation: (params: T) => Promise<unknown>,
|
|
47
|
-
options: AuthOperationOptions
|
|
48
|
-
) {
|
|
49
|
-
const { setLoading, setError, onSuccess } = options;
|
|
50
|
-
|
|
51
|
-
return useCallback(
|
|
52
|
-
async (params?: T) => {
|
|
53
|
-
try {
|
|
54
|
-
setLoading(true);
|
|
55
|
-
setError(null);
|
|
56
|
-
await mutation(params as T);
|
|
57
|
-
onSuccess?.();
|
|
58
|
-
} catch {
|
|
59
|
-
// Silently fail
|
|
60
|
-
onSuccess?.();
|
|
61
|
-
} finally {
|
|
62
|
-
setLoading(false);
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
[setLoading, setError, onSuccess, mutation]
|
|
66
|
-
);
|
|
67
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Form Field State Management Utilities
|
|
3
|
-
* Shared utilities for form field state management across all auth forms
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useCallback, useState } from "react";
|
|
7
|
-
|
|
8
|
-
export type FieldState = Record<string, string>;
|
|
9
|
-
|
|
10
|
-
export interface UseFieldStateResult<T extends FieldState> {
|
|
11
|
-
fields: T;
|
|
12
|
-
updateField: <K extends keyof T>(field: K, value: T[K]) => void;
|
|
13
|
-
setFields: (fields: T | ((prev: T) => T)) => void;
|
|
14
|
-
resetFields: (initial: T) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Hook for managing form field state with automatic error clearing
|
|
19
|
-
* @param initialFields - Initial field values
|
|
20
|
-
* @param clearErrors - Function to clear errors when fields change
|
|
21
|
-
* @returns Field state and handlers
|
|
22
|
-
*/
|
|
23
|
-
export function useFieldState<T extends FieldState>(
|
|
24
|
-
initialFields: T,
|
|
25
|
-
clearErrors?: (fields?: (keyof T)[]) => void
|
|
26
|
-
): UseFieldStateResult<T> {
|
|
27
|
-
const [fields, setFields] = useState<T>(initialFields);
|
|
28
|
-
|
|
29
|
-
const updateField = useCallback(
|
|
30
|
-
<K extends keyof T>(field: K, value: T[K]) => {
|
|
31
|
-
setFields((prev) => ({ ...prev, [field]: value }));
|
|
32
|
-
clearErrors?.([field as string]);
|
|
33
|
-
},
|
|
34
|
-
[clearErrors]
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const resetFields = useCallback((initial: T) => {
|
|
38
|
-
setFields(initial);
|
|
39
|
-
}, []);
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
fields,
|
|
43
|
-
updateField,
|
|
44
|
-
setFields,
|
|
45
|
-
resetFields,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Create a field change handler that updates field value and clears errors
|
|
51
|
-
* @param setter - State setter for the field
|
|
52
|
-
* @param clearErrors - Function to clear errors
|
|
53
|
-
* @param fieldsToClear - Fields to clear when this field changes
|
|
54
|
-
* @returns Field change handler
|
|
55
|
-
*/
|
|
56
|
-
export function createFieldChangeHandler(
|
|
57
|
-
setter: (value: string) => void,
|
|
58
|
-
clearErrors?: () => void
|
|
59
|
-
): (value: string) => void {
|
|
60
|
-
return (value: string) => {
|
|
61
|
-
setter(value);
|
|
62
|
-
clearErrors?.();
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Create multiple field change handlers
|
|
68
|
-
* @param setters - Object mapping field names to their setters
|
|
69
|
-
* @param clearErrors - Function to clear errors
|
|
70
|
-
* @returns Object mapping field names to change handlers
|
|
71
|
-
*/
|
|
72
|
-
export function createFieldChangeHandlers<T extends Record<string, (value: string) => void>>(
|
|
73
|
-
setters: T,
|
|
74
|
-
clearErrors?: () => void
|
|
75
|
-
): T {
|
|
76
|
-
return Object.fromEntries(
|
|
77
|
-
Object.entries(setters).map(([key, setter]) => [
|
|
78
|
-
key,
|
|
79
|
-
createFieldChangeHandler(setter, clearErrors),
|
|
80
|
-
])
|
|
81
|
-
) as T;
|
|
82
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Form Validation Hook
|
|
3
|
-
* React hook for form validation
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useCallback } from "react";
|
|
7
|
-
import type { PasswordConfig } from "../../../../domain/value-objects/AuthConfig";
|
|
8
|
-
import type { LoginFormValues, RegisterFormValues, ProfileFormValues } from "./formValidation.types";
|
|
9
|
-
import { validateLoginForm, validateRegisterForm, validateProfileForm } from "./formValidators";
|
|
10
|
-
import { errorsToFieldErrors } from "./formValidation.utils";
|
|
11
|
-
|
|
12
|
-
export function useFormValidation(getErrorMessage: (key: string) => string) {
|
|
13
|
-
const validateLogin = useCallback(
|
|
14
|
-
(values: LoginFormValues) => validateLoginForm(values, getErrorMessage),
|
|
15
|
-
[getErrorMessage]
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const validateRegister = useCallback(
|
|
19
|
-
(values: RegisterFormValues, passwordConfig: PasswordConfig) =>
|
|
20
|
-
validateRegisterForm(values, getErrorMessage, passwordConfig),
|
|
21
|
-
[getErrorMessage]
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const validateProfile = useCallback(
|
|
25
|
-
(values: ProfileFormValues) => validateProfileForm(values, getErrorMessage),
|
|
26
|
-
[getErrorMessage]
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
return { validateLogin, validateRegister, validateProfile, errorsToFieldErrors };
|
|
30
|
-
}
|