@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.
- package/build/src/components/PasswordCriteria/hooks/usePasswordCriteria.js +1 -8
- package/build/src/components/PasswordCriteria/index.native.js +3 -3
- package/build/src/components/{EmailOTPVerify → VerifyEmailOTP}/index.js +2 -2
- package/build/src/components/{EmailOTPVerify → VerifyEmailOTP}/index.native.js +3 -10
- package/build/src/components/{VerifyOTP → VerifyMobileOTP}/index.js +2 -2
- package/build/src/components/{VerifyOTP → VerifyMobileOTP}/index.native.js +2 -2
- package/build/src/constants/defaultPolicy.js +9 -0
- package/build/src/helpers/Network.js +1 -1
- package/build/src/helpers/show-message/index.js +2 -2
- package/build/src/helpers/show-message/index.native.js +1 -1
- package/build/src/hooks/useRequest.js +1 -1
- package/build/src/navigator/index.native.js +4 -1
- package/build/src/screens/CreatePassword/hooks/internal/useCreatePassword.js +2 -15
- package/build/src/screens/EnterEmail/hooks/internal/useEnterEmail.js +2 -2
- package/build/src/screens/EnterPassword/index.js +16 -9
- package/build/src/screens/EnterPassword/index.native.js +28 -16
- package/build/src/screens/Login/components/LoginWebComponent/index.js +19 -3
- package/build/src/screens/Login/components/LoginWebComponent/types.js +1 -0
- package/build/src/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.js +72 -0
- package/build/src/screens/LoginWithEmailOTP/index.js +8 -0
- package/build/src/screens/LoginWithEmailOTP/index.native.js +10 -0
- package/build/src/screens/ResetPassword/hooks/internal/useResetPassword.js +55 -0
- package/build/src/screens/ResetPassword/index.js +46 -0
- package/build/src/screens/ResetPassword/index.native.js +26 -0
- package/build/src/screens/ResetPassword/types.js +1 -0
- package/build/src/screens/SignUp/components/SignUpForm/index.js +1 -1
- package/build/src/screens/SignUp/hooks/internal/useSignUp.js +3 -3
- package/build/src/screens/UserConsent/hooks/internal/useConsent.js +1 -1
- package/build/src/screens/VerifyEmail/hooks/internal/useVerifyEmail.js +3 -3
- package/build/src/screens/VerifyEmail/index.js +2 -2
- package/build/src/screens/VerifyEmail/index.native.js +2 -2
- package/build/src/screens/VerifyMobile/hooks/internal/useVerifyMobile.js +5 -5
- package/build/src/screens/VerifyMobile/index.js +2 -2
- package/build/src/screens/VerifyMobile/index.native.js +2 -2
- package/build/src/screens/VerifyResetPasswordOTP/hooks/internal/useVerifyResetPasswordOTP.js +74 -0
- package/build/src/screens/VerifyResetPasswordOTP/index.js +8 -0
- package/build/src/screens/VerifyResetPasswordOTP/index.native.js +14 -0
- package/build/src/types/types.js +1 -0
- package/build/types/components/PasswordCriteria/hooks/usePasswordCriteria.d.ts +2 -7
- package/build/types/components/VerifyEmailOTP/index.d.ts +3 -0
- package/build/types/components/VerifyEmailOTP/index.native.d.ts +3 -0
- package/build/types/components/{EmailOTPVerify/type.d.ts → VerifyEmailOTP/types.d.ts} +2 -2
- package/build/types/components/VerifyMobileOTP/index.d.ts +3 -0
- package/build/types/components/VerifyMobileOTP/index.native.d.ts +3 -0
- package/build/types/constants/defaultPolicy.d.ts +9 -0
- package/build/types/helpers/show-message/index.d.ts +2 -2
- package/build/types/helpers/show-message/index.native.d.ts +2 -2
- package/build/types/helpers/show-message/types.d.ts +6 -2
- package/build/types/navigator/index.native.d.ts +10 -0
- package/build/types/screens/EnterPassword/index.d.ts +1 -1
- package/build/types/screens/EnterPassword/index.native.d.ts +1 -1
- package/build/types/screens/EnterPassword/types.d.ts +13 -1
- package/build/types/screens/Login/components/LoginWebComponent/types.d.ts +6 -0
- package/build/types/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.d.ts +14 -0
- package/build/types/screens/LoginWithEmailOTP/index.d.ts +4 -0
- package/build/types/screens/LoginWithEmailOTP/index.native.d.ts +4 -0
- package/build/types/screens/ResetPassword/hooks/internal/useResetPassword.d.ts +28 -0
- package/build/types/screens/ResetPassword/index.d.ts +3 -0
- package/build/types/screens/ResetPassword/index.native.d.ts +4 -0
- package/build/types/screens/ResetPassword/types.d.ts +11 -0
- package/build/types/screens/VerifyResetPasswordOTP/hooks/internal/useVerifyResetPasswordOTP.d.ts +19 -0
- package/build/types/screens/VerifyResetPasswordOTP/index.d.ts +7 -0
- package/build/types/screens/VerifyResetPasswordOTP/index.native.d.ts +4 -0
- package/build/types/types/types.d.ts +9 -1
- package/package.json +2 -2
- package/build/types/components/EmailOTPVerify/index.d.ts +0 -3
- package/build/types/components/EmailOTPVerify/index.native.d.ts +0 -3
- package/build/types/components/VerifyOTP/index.d.ts +0 -3
- package/build/types/components/VerifyOTP/index.native.d.ts +0 -3
- /package/build/src/components/{VerifyOTP → VerifyEmailOTP}/types.js +0 -0
- /package/build/src/components/{EmailOTPVerify/type.js → VerifyMobileOTP/types.js} +0 -0
- /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.'
|
|
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 {
|
|
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(
|
|
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 {
|
|
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(
|
|
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
|
|
39
|
-
showMessage(
|
|
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
|
|
61
|
-
showMessage(
|
|
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 {
|
|
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(
|
|
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 {
|
|
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(
|
|
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;
|
package/build/src/types/types.js
CHANGED
|
@@ -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 };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { OTPStatus } from "../OTPStatusLabel/types";
|
|
2
|
-
type
|
|
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 {
|
|
9
|
+
export type { VerifyEmailOTPProps };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const showMessage:
|
|
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 {
|
|
2
|
-
declare const showMessage:
|
|
1
|
+
import type { MessageHandlerProps } from "./types";
|
|
2
|
+
declare const showMessage: ({ message, leftIcon }: MessageHandlerProps) => void;
|
|
3
3
|
export { showMessage };
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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,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,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,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 };
|
package/build/types/screens/VerifyResetPasswordOTP/hooks/internal/useVerifyResetPasswordOTP.d.ts
ADDED
|
@@ -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,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.
|
|
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.
|
|
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",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|