@truworth/twc-auth 1.2.8 → 1.2.10

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.
@@ -1,18 +1,14 @@
1
- import { useEffect, useMemo, useState } from 'react';
1
+ import { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import { showMessage } from '../helpers/show-message';
3
3
  import { useAuthPackageContext } from './internal/useAuthPackageContext';
4
4
  import { createHttpClient } from '../helpers/network';
5
5
  const useRequest = () => {
6
- const { token: sessionToken, logout, refreshSession } = useAuthPackageContext();
7
- const [token, setToken] = useState(sessionToken);
8
- useEffect(() => {
9
- setToken(sessionToken);
10
- }, [sessionToken]);
6
+ const { token, logout, refreshSession } = useAuthPackageContext();
11
7
  const { request } = useMemo(() => createHttpClient({
12
8
  token,
13
9
  onRefreshSession: async (token) => refreshSession?.({ token }),
14
10
  onLogout: async () => logout(),
15
- }), [token, logout, refreshSession]);
11
+ }), [token]);
16
12
  const makeRequest = async ({ url, method, body, onSuccess, onFailure, ...axiosOptions }) => {
17
13
  if (!token) {
18
14
  return;
@@ -23,7 +23,7 @@ const useCreatePassword = () => {
23
23
  setConfirmPassword('');
24
24
  onResult();
25
25
  };
26
- const disabled = !Object.keys(criteria).every(c => criteria[c]) || (password !== confirmPassword);
26
+ const isContinueDisabled = !Object.keys(criteria).every(c => criteria[c]) || (password !== confirmPassword);
27
27
  return {
28
28
  password, setPassword,
29
29
  confirmPassword, setConfirmPassword,
@@ -33,7 +33,7 @@ const useCreatePassword = () => {
33
33
  criteria, setCriteria,
34
34
  handlePassword, handleConfirmPassword,
35
35
  handleSkip,
36
- disabled
36
+ isContinueDisabled
37
37
  };
38
38
  };
39
39
  export { useCreatePassword };
@@ -12,12 +12,12 @@ const CreatePassword = ({ userDetails, handleBack, onContinue }) => {
12
12
  }
13
13
  });
14
14
  const { password, confirmPassword } = form.watch();
15
- const { criteria, setCriteria, maxLength, setMaxLength, handleSkip, } = useCreatePassword();
15
+ const { criteria, setCriteria, maxLength, setMaxLength, handleSkip, isContinueDisabled } = useCreatePassword();
16
16
  return (_jsx(ScreenLayout, { title: _jsxs(Flex, { justify: "between", align: "center", children: [_jsx(Typography, { type: "heading", size: "h5", children: "Create your Password" }), countryCode == '91' &&
17
17
  _jsx(Button, { label: "Skip Now", variant: "link", onClick: () => handleSkip({ onResult: onContinue }) })] }), subTitle: "Use a password that's easy to remember and fulfills all the requirements listed below.", buttonProps: {
18
18
  label: 'Continue',
19
19
  onClick: () => onContinue(password, confirmPassword),
20
- disabled: !password || !confirmPassword || (password !== confirmPassword)
20
+ disabled: isContinueDisabled
21
21
  }, onPressBack: handleBack, children: _jsxs(Form, { form: form, className: 'w-full', children: [_jsx(Form.Item, { name: "password", label: "Enter Password", normalize: (value) => value.replace(/\s/g, ''), rules: [
22
22
  {
23
23
  required: true,
@@ -8,14 +8,14 @@ import { PasswordCriteria } from '../../components/PasswordCriteria/index.native
8
8
  const { primary } = Colors;
9
9
  const CreatePassword = ({ navigation, route }) => {
10
10
  const { countryCode, email } = route.params;
11
- const { password, confirmPassword, passwordVisible, setPasswordVisible, confirmPasswordVisible, setConfirmPasswordVisible, maxLength, setMaxLength, criteria, setCriteria, handlePassword, handleConfirmPassword, handleSkip, disabled } = useCreatePassword();
11
+ const { password, confirmPassword, passwordVisible, setPasswordVisible, confirmPasswordVisible, setConfirmPasswordVisible, maxLength, setMaxLength, criteria, setCriteria, handlePassword, handleConfirmPassword, handleSkip, isContinueDisabled } = useCreatePassword();
12
12
  const onContinue = () => {
13
13
  navigation.navigate('UserConsent', { ...route.params, password });
14
14
  };
15
15
  return (_jsx(Layout, { style: { flex: 1, backgroundColor: primary.white }, children: _jsxs(ScreenLayout, { title: "Create your Password", subTitle: "Use a password that\u2019s easy to remember and fulfills all the requirement listed below.", buttonProps: {
16
16
  label: 'Continue',
17
17
  onPress: onContinue,
18
- disabled: disabled,
18
+ disabled: isContinueDisabled,
19
19
  }, accessoryRight: countryCode == '91'
20
20
  ? _jsx(TouchableOpacity, { activeOpacity: 0.8, onPress: () => {
21
21
  Keyboard.dismiss();
@@ -35,7 +35,11 @@ const EnterEmail = ({ onContinue, onPressSignInWithSSO }) => {
35
35
  });
36
36
  },
37
37
  disabled: !isEmailValid,
38
- }, children: [_jsx(Form, { className: "w-full", form: form, children: _jsx(Form.Item, { name: "email", label: "Email", children: _jsx(TextInput, { type: "email", value: email, size: "medium", placeholder: "example@domain", ...form.register('email', {
38
+ }, children: [_jsx(Form, { className: "w-full", form: form, onSubmit: () => {
39
+ handleEmailExists({
40
+ onValidate: ({ emailExist }) => onContinue({ email, emailExist })
41
+ });
42
+ }, children: _jsx(Form.Item, { name: "email", label: "Email", children: _jsx(TextInput, { type: "email", value: email, size: "medium", placeholder: "example@domain", ...form.register('email', {
39
43
  onChange: (e) => {
40
44
  handleEmailChange(e.target.value);
41
45
  }
@@ -29,7 +29,18 @@ const EnterPassword = ({ email, onPressBack, onVerifiedResetPasswordOTP }) => {
29
29
  });
30
30
  },
31
31
  disabled: !password || !email || loading,
32
- }, onPressBack: onPressBack, children: [_jsx(Form, { className: "w-full", form: form, children: _jsx(Form.Item, { name: "password", label: "Password", children: _jsx(PasswordInput, { placeholder: "Enter your password", value: password, showStrengthIndicator: false, className: `border rounded-md px-3 py-2 border-gray-300`, ...form.register('password', {
32
+ }, onPressBack: onPressBack, children: [_jsx(Form, { className: "w-full", form: form, onSubmit: () => {
33
+ if (email)
34
+ handleSubmit({
35
+ email,
36
+ source: 'web',
37
+ verifyEmailOTP: ({ mfaEnabled, sessionToken }) => {
38
+ setMfaSessionToken(sessionToken);
39
+ setMfaEnabled(mfaEnabled);
40
+ setShowLoginWithEmailOTPModal(true);
41
+ }
42
+ });
43
+ }, children: _jsx(Form.Item, { name: "password", label: "Password", children: _jsx(PasswordInput, { placeholder: "Enter your password", value: password, showStrengthIndicator: false, className: `border rounded-md px-3 py-2 border-gray-300`, ...form.register('password', {
33
44
  onChange: (e) => {
34
45
  handlePasswordChange(e.target.value);
35
46
  }
@@ -39,6 +39,7 @@ const useResetPassword = ({ sessionToken }) => {
39
39
  showMessage({ message: err?.response?.data?.errors?.[0]?.message || 'An unexpected error occurred' });
40
40
  }).finally(() => setLoading(false));
41
41
  };
42
+ const isContinueDisabled = !Object.keys(criteria).every(c => criteria[c]) || (password !== confirmPassword);
42
43
  return {
43
44
  loading,
44
45
  password, setPassword,
@@ -50,6 +51,7 @@ const useResetPassword = ({ sessionToken }) => {
50
51
  handlePassword,
51
52
  handleContinue,
52
53
  handleConfirmPassword,
54
+ isContinueDisabled
53
55
  };
54
56
  };
55
57
  export { useResetPassword };
@@ -11,12 +11,12 @@ const ResetPassword = ({ email, sessionToken, onPressBack, onContinue }) => {
11
11
  }
12
12
  });
13
13
  const { password, confirmPassword } = form.watch();
14
- const { loading, criteria, setCriteria, maxLength, setMaxLength, handlePassword, handleConfirmPassword, handleContinue, } = useResetPassword({ sessionToken });
14
+ const { loading, criteria, setCriteria, maxLength, setMaxLength, handlePassword, handleConfirmPassword, handleContinue, isContinueDisabled } = useResetPassword({ sessionToken });
15
15
  return (_jsx(ScreenLayout, { title: "Reset your Password", subTitle: "Use a password that\u2019s easy to remember and fulfills all the requirements listed below.", buttonProps: {
16
16
  loading,
17
17
  label: 'Continue',
18
18
  onClick: () => handleContinue({ onResult: onContinue }),
19
- disabled: !password || !confirmPassword || (password !== confirmPassword)
19
+ disabled: isContinueDisabled
20
20
  }, onPressBack: onPressBack, children: _jsx(Flex, { direction: "column", children: _jsxs(Form, { form: form, className: "w-full", children: [_jsx(Form.Item, { label: "Enter Password", normalize: (value) => value.replace(/\s/g, ''), rules: [
21
21
  {
22
22
  required: true,
@@ -7,7 +7,7 @@ import { PasswordCriteria } from '../../components/PasswordCriteria/index.native
7
7
  const { primary } = Colors;
8
8
  const ResetPassword = ({ navigation, route }) => {
9
9
  const { sessionToken, email } = route.params || {};
10
- const { loading, password, confirmPassword, passwordVisible, setPasswordVisible, confirmPasswordVisible, setConfirmPasswordVisible, maxLength, setMaxLength, criteria, setCriteria, handlePassword, handleContinue, handleConfirmPassword, } = useResetPassword({ sessionToken });
10
+ const { loading, password, confirmPassword, passwordVisible, setPasswordVisible, confirmPasswordVisible, setConfirmPasswordVisible, maxLength, setMaxLength, criteria, setCriteria, handlePassword, handleContinue, handleConfirmPassword, isContinueDisabled } = useResetPassword({ sessionToken });
11
11
  return (_jsx(Layout, { style: { flex: 1, backgroundColor: primary.white }, children: _jsxs(ScreenLayout, { title: "Reset your Password", subTitle: "Use a password that\u2019s easy to remember and fulfills all the requirements listed below.", buttonProps: {
12
12
  loading,
13
13
  label: 'Continue',
@@ -16,7 +16,7 @@ const ResetPassword = ({ navigation, route }) => {
16
16
  onResult: () => navigation.navigate('EnterEmail')
17
17
  });
18
18
  },
19
- disabled: !Object.keys(criteria).every(c => criteria[c]) || (password !== confirmPassword),
19
+ disabled: isContinueDisabled
20
20
  }, children: [_jsx(TextInputField, { placeholder: "Enter password...", onChangeValue: handlePassword, secureTextEntry: !passwordVisible, value: password, rightIcon2: passwordVisible
21
21
  ? 'eye-outline'
22
22
  : 'eye-off-outline', onPressRightIcon2: () => setPasswordVisible(!passwordVisible), autoFocus: true, maxLength: maxLength }), _jsx(PasswordCriteria, { email: email, criteria: criteria, onCriteriaChange: setCriteria, onMaxLengthChange: setMaxLength, password: password }), _jsx(TextInputField, { placeholder: "Confirm password...", onChangeValue: handleConfirmPassword, secureTextEntry: !confirmPasswordVisible, value: confirmPassword, rightIcon2: confirmPasswordVisible
@@ -27,8 +27,8 @@ const SignUpFormComponent = ({ userDetails, onContinue }) => {
27
27
  const form = useForm({
28
28
  liveValidation: true,
29
29
  defaultValues: {
30
- firstName: userDetails.firstName ?? "",
31
- lastName: userDetails.lastName ?? "",
30
+ firstName: userDetails.firstName ?? getQueryParam(router.query.firstName),
31
+ lastName: userDetails.lastName ?? getQueryParam(router.query.lastName),
32
32
  dateOfBirth: userDetails.selectedDOB,
33
33
  email: userDetails.email ?? "",
34
34
  phone: userDetails.phone ?? "",
@@ -21,6 +21,6 @@ declare const useCreatePassword: () => {
21
21
  handleSkip: ({ onResult }: {
22
22
  onResult: () => void;
23
23
  }) => void;
24
- disabled: boolean;
24
+ isContinueDisabled: boolean;
25
25
  };
26
26
  export { useCreatePassword };
@@ -24,5 +24,6 @@ declare const useResetPassword: ({ sessionToken }: {
24
24
  onResult: () => void;
25
25
  }) => void;
26
26
  handleConfirmPassword: (text: string) => void;
27
+ isContinueDisabled: boolean;
27
28
  };
28
29
  export { useResetPassword };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "description": "Truworth Auth Package for React Native and Web",
7
- "version": "1.2.8",
7
+ "version": "1.2.10",
8
8
  "main": "build/src/index.js",
9
9
  "types": "build/types/index.d.ts",
10
10
  "files": [
@@ -26,7 +26,7 @@
26
26
  "@react-native-google-signin/google-signin": "12.2.1",
27
27
  "@react-navigation/native": "6.1.17",
28
28
  "@react-navigation/native-stack": "6.10.0",
29
- "@truworth/twc-rn-common": "1.0.15",
29
+ "@truworth/twc-rn-common": "1.1.2",
30
30
  "@truworth/twc-web-design": "1.11.0",
31
31
  "@twotalltotems/react-native-otp-input": "1.3.11",
32
32
  "@types/crypto-js": "^4.2.2",
@@ -46,7 +46,7 @@
46
46
  "lottie-react": "^2.4.1",
47
47
  "lottie-react-native": "6.7.2",
48
48
  "moment": "^2.30.1",
49
- "next": "^15.0.4",
49
+ "next": "15.5.9",
50
50
  "react": "18.3.1",
51
51
  "react-dom": "^18.2.0",
52
52
  "react-google-login": "^5.2.2",
@@ -63,7 +63,6 @@
63
63
  "react-native-rsa-native": "2.0.5",
64
64
  "react-native-safe-area-context": "4.14.0",
65
65
  "react-native-svg": "15.8.0",
66
- "react-native-svg-uri": "^1.2.3",
67
66
  "react-native-vector-icons": "9.2.0",
68
67
  "react-redux": "^9.2.0",
69
68
  "sweetalert2": "^11.23.0",