@truworth/twc-auth 1.2.2 → 1.2.3

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 (72) hide show
  1. package/build/src/components/PasswordCriteria/hooks/usePasswordCriteria.js +1 -8
  2. package/build/src/components/PasswordCriteria/index.native.js +3 -3
  3. package/build/src/components/{EmailOTPVerify → VerifyEmailOTP}/index.js +2 -2
  4. package/build/src/components/{EmailOTPVerify → VerifyEmailOTP}/index.native.js +3 -10
  5. package/build/src/components/{VerifyOTP → VerifyMobileOTP}/index.js +2 -2
  6. package/build/src/components/{VerifyOTP → VerifyMobileOTP}/index.native.js +2 -2
  7. package/build/src/constants/defaultPolicy.js +9 -0
  8. package/build/src/helpers/Network.js +1 -1
  9. package/build/src/helpers/show-message/index.js +2 -2
  10. package/build/src/helpers/show-message/index.native.js +1 -1
  11. package/build/src/hooks/useRequest.js +1 -1
  12. package/build/src/navigator/index.native.js +4 -1
  13. package/build/src/screens/CreatePassword/hooks/internal/useCreatePassword.js +2 -15
  14. package/build/src/screens/EnterEmail/hooks/internal/useEnterEmail.js +2 -2
  15. package/build/src/screens/EnterPassword/index.js +16 -9
  16. package/build/src/screens/EnterPassword/index.native.js +28 -16
  17. package/build/src/screens/Login/components/LoginWebComponent/index.js +19 -3
  18. package/build/src/screens/Login/components/LoginWebComponent/types.js +1 -0
  19. package/build/src/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.js +72 -0
  20. package/build/src/screens/LoginWithEmailOTP/index.js +8 -0
  21. package/build/src/screens/LoginWithEmailOTP/index.native.js +10 -0
  22. package/build/src/screens/ResetPassword/hooks/internal/useResetPassword.js +55 -0
  23. package/build/src/screens/ResetPassword/index.js +46 -0
  24. package/build/src/screens/ResetPassword/index.native.js +26 -0
  25. package/build/src/screens/ResetPassword/types.js +1 -0
  26. package/build/src/screens/SignUp/components/SignUpForm/index.js +1 -1
  27. package/build/src/screens/SignUp/hooks/internal/useSignUp.js +3 -3
  28. package/build/src/screens/UserConsent/hooks/internal/useConsent.js +1 -1
  29. package/build/src/screens/VerifyEmail/hooks/internal/useVerifyEmail.js +3 -3
  30. package/build/src/screens/VerifyEmail/index.js +2 -2
  31. package/build/src/screens/VerifyEmail/index.native.js +2 -2
  32. package/build/src/screens/VerifyMobile/hooks/internal/useVerifyMobile.js +5 -5
  33. package/build/src/screens/VerifyMobile/index.js +2 -2
  34. package/build/src/screens/VerifyMobile/index.native.js +2 -2
  35. package/build/src/screens/VerifyResetPasswordOTP/hooks/internal/useVerifyResetPasswordOTP.js +74 -0
  36. package/build/src/screens/VerifyResetPasswordOTP/index.js +8 -0
  37. package/build/src/screens/VerifyResetPasswordOTP/index.native.js +14 -0
  38. package/build/src/types/types.js +1 -0
  39. package/build/types/components/PasswordCriteria/hooks/usePasswordCriteria.d.ts +2 -7
  40. package/build/types/components/VerifyEmailOTP/index.d.ts +3 -0
  41. package/build/types/components/VerifyEmailOTP/index.native.d.ts +3 -0
  42. package/build/types/components/{EmailOTPVerify/type.d.ts → VerifyEmailOTP/types.d.ts} +2 -2
  43. package/build/types/components/VerifyMobileOTP/index.d.ts +3 -0
  44. package/build/types/components/VerifyMobileOTP/index.native.d.ts +3 -0
  45. package/build/types/constants/defaultPolicy.d.ts +9 -0
  46. package/build/types/helpers/show-message/index.d.ts +2 -2
  47. package/build/types/helpers/show-message/index.native.d.ts +2 -2
  48. package/build/types/helpers/show-message/types.d.ts +6 -2
  49. package/build/types/navigator/index.native.d.ts +10 -0
  50. package/build/types/screens/EnterPassword/index.d.ts +1 -1
  51. package/build/types/screens/EnterPassword/index.native.d.ts +1 -1
  52. package/build/types/screens/EnterPassword/types.d.ts +13 -1
  53. package/build/types/screens/Login/components/LoginWebComponent/types.d.ts +6 -0
  54. package/build/types/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.d.ts +14 -0
  55. package/build/types/screens/LoginWithEmailOTP/index.d.ts +4 -0
  56. package/build/types/screens/LoginWithEmailOTP/index.native.d.ts +4 -0
  57. package/build/types/screens/ResetPassword/hooks/internal/useResetPassword.d.ts +28 -0
  58. package/build/types/screens/ResetPassword/index.d.ts +3 -0
  59. package/build/types/screens/ResetPassword/index.native.d.ts +4 -0
  60. package/build/types/screens/ResetPassword/types.d.ts +11 -0
  61. package/build/types/screens/VerifyResetPasswordOTP/hooks/internal/useVerifyResetPasswordOTP.d.ts +19 -0
  62. package/build/types/screens/VerifyResetPasswordOTP/index.d.ts +7 -0
  63. package/build/types/screens/VerifyResetPasswordOTP/index.native.d.ts +4 -0
  64. package/build/types/types/types.d.ts +9 -1
  65. package/package.json +2 -2
  66. package/build/types/components/EmailOTPVerify/index.d.ts +0 -3
  67. package/build/types/components/EmailOTPVerify/index.native.d.ts +0 -3
  68. package/build/types/components/VerifyOTP/index.d.ts +0 -3
  69. package/build/types/components/VerifyOTP/index.native.d.ts +0 -3
  70. /package/build/src/components/{VerifyOTP → VerifyEmailOTP}/types.js +0 -0
  71. /package/build/src/components/{EmailOTPVerify/type.js → VerifyMobileOTP/types.js} +0 -0
  72. /package/build/types/components/{VerifyOTP → VerifyMobileOTP}/types.d.ts +0 -0
@@ -169,6 +169,6 @@ const ExistingAccountsModal = ({ visible, hide, existingAccounts, countryCode, p
169
169
  })] }));
170
170
  };
171
171
  const RecaptchaComponent = React.memo(({ onChange }) => {
172
- return (_jsx(Row, { gutter: 10, children: _jsx(Col, { span: 24, children: _jsx(ReCAPTCHA, { className: "g-recaptcha", sitekey: process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY || '', onChange: (token) => onChange(token ?? ''), onExpired: () => onChange(''), onErrored: () => onChange(''), size: "normal" }) }) }));
172
+ return (_jsx(Row, { gutter: 10, children: _jsx(Col, { span: 24, children: _jsx(ReCAPTCHA, { className: "g-recaptcha mt-4", sitekey: process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY || '', onChange: (token) => onChange(token ?? ''), onExpired: () => onChange(''), onErrored: () => onChange(''), size: "normal" }) }) }));
173
173
  });
174
174
  export { SignUpFormComponent };
@@ -84,16 +84,16 @@ const useSignUp = () => {
84
84
  setLoading(false);
85
85
  const status = err?.response?.status;
86
86
  if (!status) {
87
- return showMessage('Network error. Please try again.', err?.response?.data?.message);
87
+ return showMessage({ message: 'Network error. Please try again.' });
88
88
  }
89
89
  if (status === 404) {
90
90
  return onResult();
91
91
  }
92
92
  if (status === 400) {
93
- return showMessage(err?.response?.data?.errors?.[0]?.message ?? 'Something went wrong');
93
+ return showMessage({ message: err?.response?.data?.errors?.[0]?.message ?? 'Something went wrong' });
94
94
  }
95
95
  if (typeof status === 'number' && status >= 500) {
96
- return showMessage('Something went wrong');
96
+ return showMessage({ message: 'Something went wrong' });
97
97
  }
98
98
  };
99
99
  const getLoginTypeText = (loginType) => {
@@ -39,7 +39,7 @@ const useConsent = () => {
39
39
  .then((res) => onResult(res.data))
40
40
  .catch((err) => {
41
41
  console.log(err);
42
- showMessage(err?.response?.data?.errors?.[0]);
42
+ showMessage({ message: err?.response?.data?.errors?.[0]?.message });
43
43
  })
44
44
  .finally(() => setLoading(false));
45
45
  };
@@ -28,7 +28,7 @@ const useVerifyEmail = ({ sessionToken }) => {
28
28
  setSessionToken(res.data.sessionToken);
29
29
  }).catch((err) => {
30
30
  console.log(err);
31
- showMessage(err?.response?.data?.errors?.[0]?.message);
31
+ showMessage({ message: err?.response?.data?.errors?.[0]?.message });
32
32
  }).finally(() => setStatus(''));
33
33
  }, [sessionTokenState]);
34
34
  const validateOTP = useCallback(({ otp, onVerifiedOTP }) => {
@@ -52,11 +52,11 @@ const useVerifyEmail = ({ sessionToken }) => {
52
52
  setTimeout(() => {
53
53
  setStatus('');
54
54
  }, 5000);
55
- showMessage(err?.response?.data?.errors?.[0]?.message);
55
+ showMessage({ message: err?.response?.data?.errors?.[0]?.message });
56
56
  return;
57
57
  }
58
58
  setStatus('');
59
- showMessage(err?.response?.data?.errors?.[0]?.message);
59
+ showMessage({ message: err?.response?.data?.errors?.[0]?.message });
60
60
  });
61
61
  }, [sessionTokenState]);
62
62
  return {
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useVerifyEmail } from "./hooks/internal/useVerifyEmail";
3
- import { EmailOTPVerify } from "../../components/EmailOTPVerify";
3
+ import { VerifyEmailOTP } from "../../components/VerifyEmailOTP";
4
4
  const VerifyEmail = ({ email, sessionToken, onVerifiedOTP }) => {
5
5
  const { status, resendOTPCounter, validateOTP, resendOTP, } = useVerifyEmail({ sessionToken });
6
- return (_jsx(EmailOTPVerify, { email: email, status: status, resendOTPCounter: resendOTPCounter, validateOTP: (otp) => validateOTP?.({ otp, onVerifiedOTP }), resendOTP: resendOTP }));
6
+ return (_jsx(VerifyEmailOTP, { email: email, status: status, resendOTPCounter: resendOTPCounter, validateOTP: (otp) => validateOTP?.({ otp, onVerifiedOTP }), resendOTP: resendOTP }));
7
7
  };
8
8
  export default VerifyEmail;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { EmailOTPVerify } from "../../components/EmailOTPVerify";
2
+ import { VerifyEmailOTP } from "../../components/VerifyEmailOTP";
3
3
  import { useVerifyEmail } from "./hooks/internal/useVerifyEmail";
4
4
  const VerifyEmail = ({ navigation, route }) => {
5
5
  const { phone, sessionToken, email } = route.params || {};
6
6
  const { status, resendOTPCounter, validateOTP, resendOTP, } = useVerifyEmail({ sessionToken });
7
- return (_jsx(EmailOTPVerify, { email: email, status: status, resendOTPCounter: resendOTPCounter, validateOTP: (otp) => validateOTP?.({
7
+ return (_jsx(VerifyEmailOTP, { email: email, status: status, resendOTPCounter: resendOTPCounter, validateOTP: (otp) => validateOTP?.({
8
8
  otp,
9
9
  onVerifiedOTP: ({ sessionToken }) => {
10
10
  navigation.navigate('VerifyMobile', { phone, sessionToken });
@@ -35,8 +35,8 @@ const useVerifyMobile = ({ sessionToken }) => {
35
35
  setTimer(initialTimer);
36
36
  }).catch((err) => {
37
37
  console.log(err);
38
- const msg = err?.response?.data?.errors?.[0]?.message ?? 'Unable to send OTP. Please try again.';
39
- showMessage(msg);
38
+ const message = err?.response?.data?.errors?.[0]?.message ?? 'Unable to send OTP. Please try again.';
39
+ showMessage({ message });
40
40
  setStatus('timer');
41
41
  });
42
42
  }, [sessionTokenState]);
@@ -54,11 +54,11 @@ const useVerifyMobile = ({ sessionToken }) => {
54
54
  if (err?.response?.status === 400) {
55
55
  setStatus('invalid');
56
56
  setTimeout(() => setStatus('timer'), 5000);
57
- showMessage(err?.response?.data?.errors?.[0]?.message ?? 'Invalid OTP. Please try again.');
57
+ showMessage({ message: err?.response?.data?.errors?.[0]?.message ?? 'Invalid OTP. Please try again.' });
58
58
  }
59
59
  else {
60
- const msg = err?.response?.data?.errors?.[0]?.message ?? 'Verification failed. Please try again.';
61
- showMessage(msg);
60
+ const message = err?.response?.data?.errors?.[0]?.message ?? 'Verification failed. Please try again.';
61
+ showMessage({ message });
62
62
  setStatus('timer');
63
63
  }
64
64
  });
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { OTPVerify } from "../../components/VerifyOTP";
2
+ import { VerifyMobileOTP } from "../../components/VerifyMobileOTP";
3
3
  import { useVerifyMobile } from "./hooks/internal/useVerifyMobile";
4
4
  const VerifyMobile = ({ sessionToken, phone }) => {
5
5
  const { timer, status, validateOTP, resendOTP, } = useVerifyMobile({ sessionToken });
6
- return (_jsx(OTPVerify, { timer: timer, phone: phone, status: status, validateOTP: validateOTP, resendOTP: resendOTP }));
6
+ return (_jsx(VerifyMobileOTP, { timer: timer, phone: phone, status: status, validateOTP: validateOTP, resendOTP: resendOTP }));
7
7
  };
8
8
  export default VerifyMobile;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { OTPVerify } from '../../components/VerifyOTP';
2
+ import { VerifyMobileOTP } from '../../components/VerifyMobileOTP';
3
3
  import { useVerifyMobile } from './hooks/internal/useVerifyMobile';
4
4
  const VerifyMobile = ({ route }) => {
5
5
  const { sessionToken, phone } = route.params || {};
6
6
  const { timer, status, validateOTP, resendOTP, } = useVerifyMobile({ sessionToken });
7
- return (_jsx(OTPVerify, { timer: timer, phone: phone, status: status, validateOTP: validateOTP, resendOTP: resendOTP }));
7
+ return (_jsx(VerifyMobileOTP, { timer: timer, phone: phone, status: status, validateOTP: validateOTP, resendOTP: resendOTP }));
8
8
  };
9
9
  export default VerifyMobile;
@@ -0,0 +1,74 @@
1
+ import { useCallback, useEffect, useState, useRef } from "react";
2
+ import { showMessage } from "../../../../helpers/show-message";
3
+ import { axiosClient } from "../../../../api/axiosClient";
4
+ /**
5
+ * @internal
6
+ * Hook for managing VerifyResetPasswordOTP screen state and auth context integration.
7
+ * This hook is not exposed to package consumers.
8
+ */
9
+ const useVerifyResetPasswordOTP = ({ email }) => {
10
+ const [resendOTPCounter, setResendOTPCounter] = useState(0);
11
+ const [status, setStatus] = useState("idle");
12
+ const resetStatusTimeoutRef = useRef();
13
+ const sessionTokenRef = useRef('');
14
+ const scheduleStatusReset = (delay) => {
15
+ if (resetStatusTimeoutRef.current) {
16
+ clearTimeout(resetStatusTimeoutRef.current);
17
+ }
18
+ resetStatusTimeoutRef.current = setTimeout(() => setStatus('idle'), delay);
19
+ };
20
+ const sendOtp = useCallback(() => {
21
+ setStatus('loading');
22
+ axiosClient({
23
+ url: '/auth/reset-password/send-otp',
24
+ method: 'POST',
25
+ data: { email },
26
+ }).then((res) => {
27
+ setResendOTPCounter(prevCounter => prevCounter + 1);
28
+ sessionTokenRef.current = res.data.sessionToken;
29
+ }).catch((error) => {
30
+ console.error('Failed to send OTP:', error);
31
+ const message = error?.response?.data?.errors?.[0]?.message || "Failed to send OTP. Please try again.";
32
+ showMessage({ message });
33
+ }).finally(() => setStatus("idle"));
34
+ }, [email]);
35
+ const verifyOtp = useCallback(({ otp, onVerifiedOTP }) => {
36
+ setStatus('loading');
37
+ axiosClient({
38
+ url: "/auth/reset-password/verify-otp",
39
+ method: "POST",
40
+ data: { sessionToken: sessionTokenRef.current, otp },
41
+ }).then((res) => {
42
+ setStatus('valid');
43
+ onVerifiedOTP({ sessionToken: res.data.sessionToken });
44
+ scheduleStatusReset(0);
45
+ }).catch((error) => {
46
+ const message = error?.response?.data?.errors?.[0]?.message ||
47
+ (error?.response?.status === 400
48
+ ? "Invalid OTP. Please try again."
49
+ : "Verification failed. Please try again.");
50
+ showMessage({ message });
51
+ setStatus(error?.response?.status === 400 ? "invalid" : "idle");
52
+ if (error?.response?.status === 400) {
53
+ scheduleStatusReset(5000);
54
+ }
55
+ });
56
+ }, []);
57
+ useEffect(() => () => {
58
+ if (resetStatusTimeoutRef.current) {
59
+ clearTimeout(resetStatusTimeoutRef.current);
60
+ }
61
+ }, []);
62
+ useEffect(() => {
63
+ if (email) {
64
+ sendOtp();
65
+ }
66
+ }, [email, sendOtp]);
67
+ return {
68
+ status,
69
+ resendOTPCounter,
70
+ sendOtp,
71
+ verifyOtp,
72
+ };
73
+ };
74
+ export { useVerifyResetPasswordOTP };
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useVerifyResetPasswordOTP } from "./hooks/internal/useVerifyResetPasswordOTP";
3
+ import { VerifyEmailOTP } from "../../components/VerifyEmailOTP";
4
+ const VerifyResetPasswordOTP = ({ email, onVerifiedOTP }) => {
5
+ const { status, resendOTPCounter, sendOtp, verifyOtp, } = useVerifyResetPasswordOTP({ email });
6
+ return (_jsx(VerifyEmailOTP, { email: email, validateOTP: (otp) => verifyOtp({ otp, onVerifiedOTP }), resendOTP: sendOtp, status: status, resendOTPCounter: resendOTPCounter }));
7
+ };
8
+ export default VerifyResetPasswordOTP;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useVerifyResetPasswordOTP } from './hooks/internal/useVerifyResetPasswordOTP';
3
+ import { VerifyEmailOTP } from '../../components/VerifyEmailOTP';
4
+ const VerifyResetPasswordOTP = ({ navigation, route }) => {
5
+ const { email } = route.params;
6
+ const { status, resendOTPCounter, sendOtp, verifyOtp, } = useVerifyResetPasswordOTP({ email });
7
+ return (_jsx(VerifyEmailOTP, { email: email, validateOTP: (otp) => {
8
+ verifyOtp({
9
+ otp,
10
+ onVerifiedOTP: ({ sessionToken }) => navigation.navigate('ResetPassword', { sessionToken, email })
11
+ });
12
+ }, resendOTP: sendOtp, status: status, resendOTPCounter: resendOTPCounter }));
13
+ };
14
+ export default VerifyResetPasswordOTP;
@@ -1 +1,2 @@
1
+ ;
1
2
  export {};
@@ -1,13 +1,8 @@
1
1
  import type { UsePasswordCriteriaProps } from "../types";
2
+ import type { PasswordPolicy } from "../../../types/types";
2
3
  declare const usePasswordCriteria: ({ email, password, onCriteriaChange, onMaxLengthChange }: UsePasswordCriteriaProps) => {
3
4
  loading: boolean;
4
- passwordPolicy: {
5
- minLength: number;
6
- numbers: boolean;
7
- uppercase: boolean;
8
- lowercase: boolean;
9
- specialCharacters: boolean;
10
- };
5
+ passwordPolicy: PasswordPolicy;
11
6
  renderLabel: (criteria: string) => string;
12
7
  };
13
8
  export { usePasswordCriteria };
@@ -0,0 +1,3 @@
1
+ import type { VerifyEmailOTPProps } from "./types";
2
+ declare const VerifyEmailOTP: ({ validateOTP, resendOTP, resendOTPCounter, email, status }: VerifyEmailOTPProps) => import("react/jsx-runtime").JSX.Element;
3
+ export { VerifyEmailOTP };
@@ -0,0 +1,3 @@
1
+ import type { VerifyEmailOTPProps } from "./types";
2
+ declare const VerifyEmailOTP: ({ email, status, validateOTP, resendOTP, resendOTPCounter }: VerifyEmailOTPProps) => import("react/jsx-runtime").JSX.Element;
3
+ export { VerifyEmailOTP };
@@ -1,9 +1,9 @@
1
1
  import type { OTPStatus } from "../OTPStatusLabel/types";
2
- type EmailOTPVerifyProps = {
2
+ type VerifyEmailOTPProps = {
3
3
  validateOTP: (otp: string) => void | Promise<void>;
4
4
  resendOTP: () => void | Promise<void>;
5
5
  resendOTPCounter: number;
6
6
  email?: string;
7
7
  status: OTPStatus | string;
8
8
  };
9
- export type { EmailOTPVerifyProps };
9
+ export type { VerifyEmailOTPProps };
@@ -0,0 +1,3 @@
1
+ import type { OTPVerifyProps } from "./types";
2
+ declare const VerifyMobileOTP: ({ validateOTP, timer, resendOTP, phone, status, resendTextClassName }: OTPVerifyProps) => import("react/jsx-runtime").JSX.Element;
3
+ export { VerifyMobileOTP };
@@ -0,0 +1,3 @@
1
+ import type { OTPVerifyProps } from './types';
2
+ declare const VerifyMobileOTP: ({ validateOTP, timer, status, resendOTP, phone }: OTPVerifyProps) => import("react/jsx-runtime").JSX.Element;
3
+ export { VerifyMobileOTP };
@@ -0,0 +1,9 @@
1
+ declare const defaultPolicy: {
2
+ minLength: number;
3
+ maxLength: number;
4
+ numbers: boolean;
5
+ uppercase: boolean;
6
+ lowercase: boolean;
7
+ specialCharacters: boolean;
8
+ };
9
+ export { defaultPolicy };
@@ -1,3 +1,3 @@
1
- import type { MessageHandler } from "./types";
2
- declare const showMessage: MessageHandler;
1
+ import type { MessageHandlerProps } from "./types";
2
+ declare const showMessage: ({ message, type }: MessageHandlerProps) => void;
3
3
  export { showMessage };
@@ -1,3 +1,3 @@
1
- import type { MessageHandler } from "./types";
2
- declare const showMessage: MessageHandler;
1
+ import type { MessageHandlerProps } from "./types";
2
+ declare const showMessage: ({ message, leftIcon }: MessageHandlerProps) => void;
3
3
  export { showMessage };
@@ -1,2 +1,6 @@
1
- type MessageHandler = (message: string | Error | object, leftIcon?: string) => void;
2
- export type { MessageHandler };
1
+ interface MessageHandlerProps {
2
+ message: string | Error | object;
3
+ type?: 'error' | 'info' | 'message' | 'success' | 'warning';
4
+ leftIcon?: string;
5
+ }
6
+ export type { MessageHandlerProps };
@@ -32,5 +32,15 @@ export type AuthStackParamList = {
32
32
  sessionToken: string;
33
33
  phone: string;
34
34
  };
35
+ LoginWithEmailOTP: {
36
+ email: string;
37
+ };
38
+ ResetPassword: {
39
+ sessionToken: string;
40
+ email: string;
41
+ };
42
+ VerifyResetPasswordOTP: {
43
+ email: string;
44
+ };
35
45
  };
36
46
  export type AuthScreensProps<T extends keyof AuthStackParamList> = NativeStackScreenProps<AuthStackParamList, T>;
@@ -1,3 +1,3 @@
1
1
  import type { EnterPasswordProps } from './types';
2
- declare const EnterPassword: ({ email, onPressBack }: EnterPasswordProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const EnterPassword: ({ email, onPressBack, onSignInWithEmailOTP, onVerifiedResetPasswordOTP }: EnterPasswordProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default EnterPassword;
@@ -1,4 +1,4 @@
1
1
  import type { AuthScreensProps } from '../../navigator/index.native';
2
2
  type ScreenProps = AuthScreensProps<'EnterPassword'>;
3
- declare const EnterPassword: ({ route }: ScreenProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const EnterPassword: ({ navigation, route }: ScreenProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export default EnterPassword;
@@ -1,5 +1,17 @@
1
1
  interface EnterPasswordProps {
2
2
  email: string;
3
3
  onPressBack: () => void;
4
+ onVerifiedResetPasswordOTP: ({ sessionToken }: {
5
+ sessionToken: string;
6
+ }) => void;
7
+ onSignInWithEmailOTP: () => void;
4
8
  }
5
- export type { EnterPasswordProps };
9
+ interface VerifyResetPasswordOTPModalProps {
10
+ show: boolean;
11
+ hide: () => void;
12
+ email: string;
13
+ onVerifiedOTP: ({ sessionToken }: {
14
+ sessionToken: string;
15
+ }) => void;
16
+ }
17
+ export type { EnterPasswordProps, VerifyResetPasswordOTPModalProps };
@@ -0,0 +1,6 @@
1
+ interface LoginWithEmailOTPModalProps {
2
+ show: boolean;
3
+ hide: () => void;
4
+ email: string;
5
+ }
6
+ export type { LoginWithEmailOTPModalProps };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @internal
3
+ * Hook for handling Email OTP Login flow.
4
+ */
5
+ declare const useLoginWithEmailOTP: ({ email, source }: {
6
+ email: string;
7
+ source: string;
8
+ }) => {
9
+ sendOtp: () => void;
10
+ verifyOtp: (otp: string) => Promise<void>;
11
+ resendOTPCounter: number;
12
+ status: "loading" | "idle" | "valid" | "invalid";
13
+ };
14
+ export { useLoginWithEmailOTP };
@@ -0,0 +1,4 @@
1
+ declare const LoginWithEmailOTP: ({ email }: {
2
+ email: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default LoginWithEmailOTP;
@@ -0,0 +1,4 @@
1
+ import type { AuthScreensProps } from './../../navigator/index.native';
2
+ type ScreenProps = AuthScreensProps<'LoginWithEmailOTP'>;
3
+ declare const LoginWithEmailOTP: ({ route }: ScreenProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default LoginWithEmailOTP;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @internal
3
+ * Hook for managing ResetPassword screen state and auth context integration.
4
+ * This hook is not exposed to package consumers.
5
+ */
6
+ declare const useResetPassword: ({ sessionToken }: {
7
+ sessionToken: string;
8
+ }) => {
9
+ loading: boolean;
10
+ password: string;
11
+ setPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
12
+ confirmPassword: string;
13
+ setConfirmPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
14
+ passwordVisible: boolean;
15
+ setPasswordVisible: import("react").Dispatch<import("react").SetStateAction<boolean>>;
16
+ confirmPasswordVisible: boolean;
17
+ setConfirmPasswordVisible: import("react").Dispatch<import("react").SetStateAction<boolean>>;
18
+ maxLength: number;
19
+ setMaxLength: import("react").Dispatch<import("react").SetStateAction<number>>;
20
+ criteria: Record<string, boolean>;
21
+ setCriteria: import("react").Dispatch<import("react").SetStateAction<Record<string, boolean>>>;
22
+ handlePassword: (text: string) => void;
23
+ handleContinue: ({ onResult }: {
24
+ onResult: () => void;
25
+ }) => void;
26
+ handleConfirmPassword: (text: string) => void;
27
+ };
28
+ export { useResetPassword };
@@ -0,0 +1,3 @@
1
+ import type { ResetPasswordProps } from "./types";
2
+ declare const ResetPassword: ({ email, sessionToken, onPressBack, onContinue }: ResetPasswordProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default ResetPassword;
@@ -0,0 +1,4 @@
1
+ import type { AuthScreensProps } from '../../navigator/index.native';
2
+ type ScreenProps = AuthScreensProps<'ResetPassword'>;
3
+ declare const ResetPassword: ({ navigation, route }: ScreenProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default ResetPassword;
@@ -0,0 +1,11 @@
1
+ interface ResetPasswordProps {
2
+ email: string;
3
+ sessionToken: string;
4
+ onPressBack?: () => void;
5
+ onContinue: () => void;
6
+ }
7
+ interface ResetPasswordFormData {
8
+ password: string;
9
+ confirmPassword: string;
10
+ }
11
+ export type { ResetPasswordProps, ResetPasswordFormData };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @internal
3
+ * Hook for managing VerifyResetPasswordOTP screen state and auth context integration.
4
+ * This hook is not exposed to package consumers.
5
+ */
6
+ declare const useVerifyResetPasswordOTP: ({ email }: {
7
+ email: string;
8
+ }) => {
9
+ status: "loading" | "idle" | "valid" | "invalid";
10
+ resendOTPCounter: number;
11
+ sendOtp: () => void;
12
+ verifyOtp: ({ otp, onVerifiedOTP }: {
13
+ otp: string;
14
+ onVerifiedOTP: (data: {
15
+ sessionToken: string;
16
+ }) => void;
17
+ }) => void;
18
+ };
19
+ export { useVerifyResetPasswordOTP };
@@ -0,0 +1,7 @@
1
+ declare const VerifyResetPasswordOTP: ({ email, onVerifiedOTP }: {
2
+ email: string;
3
+ onVerifiedOTP: ({ sessionToken }: {
4
+ sessionToken: string;
5
+ }) => void;
6
+ }) => import("react/jsx-runtime").JSX.Element;
7
+ export default VerifyResetPasswordOTP;
@@ -0,0 +1,4 @@
1
+ import type { AuthScreensProps } from '../../navigator/index.native';
2
+ type ScreenProps = AuthScreensProps<'VerifyResetPasswordOTP'>;
3
+ declare const VerifyResetPasswordOTP: ({ navigation, route }: ScreenProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default VerifyResetPasswordOTP;
@@ -86,5 +86,13 @@ interface PersonalDetails {
86
86
  password?: string;
87
87
  confirmPassword?: string;
88
88
  }
89
+ interface PasswordPolicy {
90
+ minLength: number;
91
+ maxLength?: number;
92
+ numbers: boolean;
93
+ uppercase: boolean;
94
+ lowercase: boolean;
95
+ specialCharacters: boolean;
96
+ }
89
97
  export type UseRequestOptions = BaseRequestOptions;
90
- export type { RegistrationParams, MemberProfile, ClientProfile, Partner, Profile, Country, RegistrationMethod, PersonalDetails };
98
+ export type { RegistrationParams, MemberProfile, ClientProfile, Partner, Profile, Country, RegistrationMethod, PersonalDetails, PasswordPolicy };
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.2",
7
+ "version": "1.2.3",
8
8
  "main": "build/src/index.js",
9
9
  "types": "build/types/index.d.ts",
10
10
  "files": [
@@ -27,7 +27,7 @@
27
27
  "@react-navigation/native-stack": "^6.10.0",
28
28
  "@truworth/twc-rn-common": "^1.0.15",
29
29
  "@truworth/twc-web-common": "^1.0.11",
30
- "@truworth/twc-web-design": "^1.9.0",
30
+ "@truworth/twc-web-design": "^1.10.0",
31
31
  "@twotalltotems/react-native-otp-input": "1.3.11",
32
32
  "@types/crypto-js": "^4.2.2",
33
33
  "@types/fbemitter": "^2.0.35",
@@ -1,3 +0,0 @@
1
- import type { EmailOTPVerifyProps } from "./type";
2
- declare const EmailOTPVerify: ({ validateOTP, resendOTP, resendOTPCounter, email, status }: EmailOTPVerifyProps) => import("react/jsx-runtime").JSX.Element;
3
- export { EmailOTPVerify };
@@ -1,3 +0,0 @@
1
- import type { EmailOTPVerifyProps } from "./type";
2
- declare const EmailOTPVerify: ({ status, validateOTP, resendOTP, resendOTPCounter, email }: EmailOTPVerifyProps) => import("react/jsx-runtime").JSX.Element;
3
- export { EmailOTPVerify };
@@ -1,3 +0,0 @@
1
- import type { OTPVerifyProps } from "./types";
2
- declare const OTPVerify: ({ validateOTP, timer, resendOTP, phone, status, resendTextClassName }: OTPVerifyProps) => import("react/jsx-runtime").JSX.Element;
3
- export { OTPVerify };
@@ -1,3 +0,0 @@
1
- import type { OTPVerifyProps } from './types';
2
- declare const OTPVerify: ({ validateOTP, timer, status, resendOTP, phone }: OTPVerifyProps) => import("react/jsx-runtime").JSX.Element;
3
- export { OTPVerify };