@truworth/twc-auth 3.0.7 → 3.0.9

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 (381) hide show
  1. package/build/assets/animation/redirect-home.json +1101 -0
  2. package/build/assets/cross_icon copy.svg +5 -0
  3. package/build/assets/cross_icon.svg +5 -0
  4. package/build/assets/email_icon.svg +6 -0
  5. package/build/assets/gender-diversity.svg +22 -0
  6. package/build/assets/loading-spinner.json +1 -0
  7. package/build/assets/logo.svg +55 -0
  8. package/build/assets/okay_icon.svg +3 -0
  9. package/build/src/api/auth.js +36 -0
  10. package/build/src/api/axiosClient/index.js +5 -0
  11. package/build/src/api/axiosClient/index.native.js +5 -0
  12. package/build/src/components/AdvancedTransitionWrapper/index.js +374 -0
  13. package/build/src/components/AdvancedTransitionWrapper/index.native.js +10 -0
  14. package/build/src/components/AdvancedTransitionWrapper/types.js +1 -0
  15. package/build/src/components/ConfirmationModal/index.js +11 -0
  16. package/build/src/components/ConfirmationModal/index.native.js +15 -0
  17. package/build/src/components/ConfirmationModal/types.js +1 -0
  18. package/build/src/components/IonIcon/index.js +11 -0
  19. package/build/src/components/IonIcon/index.native.js +9 -0
  20. package/build/src/components/IonIcon/types.js +1 -0
  21. package/build/src/components/LoadingAnimation/index.js +50 -0
  22. package/build/src/components/OTPStatusLabel/index.js +10 -0
  23. package/build/src/components/OTPStatusLabel/index.native.js +21 -0
  24. package/build/src/components/OTPStatusLabel/types.js +1 -0
  25. package/build/src/components/PasswordCriteria/hooks/usePasswordCriteria.js +71 -0
  26. package/build/src/components/PasswordCriteria/index.js +47 -0
  27. package/build/src/components/PasswordCriteria/index.native.js +22 -0
  28. package/build/src/components/PasswordCriteria/types.js +1 -0
  29. package/build/src/components/ScreenLayout/index.js +12 -0
  30. package/build/src/components/ScreenLayout/index.native.js +18 -0
  31. package/build/src/components/ScreenLayout/types.js +1 -0
  32. package/build/src/components/SupportDetails/index.js +9 -0
  33. package/build/src/components/SupportDetails/index.native.js +6 -0
  34. package/build/src/components/VerifyEmailOTP/index.js +20 -0
  35. package/build/src/components/VerifyEmailOTP/index.native.js +22 -0
  36. package/build/src/components/VerifyEmailOTP/types.js +1 -0
  37. package/build/src/components/VerifyMobileOTP/index.js +25 -0
  38. package/build/src/components/VerifyMobileOTP/index.native.js +38 -0
  39. package/build/src/components/VerifyMobileOTP/types.js +1 -0
  40. package/build/src/constants/base-url/index.js +5 -0
  41. package/build/src/constants/base-url/index.native.js +1 -0
  42. package/build/src/constants/cdn-url/index.js +2 -0
  43. package/build/src/constants/cdn-url/index.native.js +5 -0
  44. package/build/src/constants/defaultPolicy.js +9 -0
  45. package/build/src/constants/password-requirements.js +7 -0
  46. package/build/src/constants/social-login-options.js +16 -0
  47. package/build/src/contexts/AuthContext.js +192 -0
  48. package/build/src/contexts/type.js +1 -0
  49. package/build/src/enums/index.js +3 -0
  50. package/build/src/enums/loginMethod.enum.js +8 -0
  51. package/build/src/enums/registrationMethod.enum.js +7 -0
  52. package/build/src/enums/socialLogins.enum.js +6 -0
  53. package/build/src/helpers/network.js +93 -0
  54. package/build/src/helpers/show-message/index.js +19 -0
  55. package/build/src/helpers/show-message/index.native.js +14 -0
  56. package/build/src/helpers/show-message/types.js +1 -0
  57. package/build/src/helpers/types.js +1 -0
  58. package/build/src/helpers/validation.js +12 -0
  59. package/build/src/hooks/internal/useAuthPackageContext.js +9 -0
  60. package/build/src/hooks/internal/useTimer.js +40 -0
  61. package/build/src/hooks/useAuthContext.js +10 -0
  62. package/build/src/hooks/useNavigator.js +83 -0
  63. package/build/src/hooks/useRequest.js +34 -0
  64. package/build/src/index.js +23 -0
  65. package/build/src/navigator/index.js +10 -0
  66. package/build/src/navigator/index.native.js +27 -0
  67. package/build/src/screens/CountryCode/components/CountryCodeDropdown/index.js +37 -0
  68. package/build/src/screens/CountryCode/components/CountryCodeDropdown/index.native.js +6 -0
  69. package/build/src/screens/CountryCode/components/CountryCodeDropdown/types.js +1 -0
  70. package/build/src/screens/CountryCode/hooks/internal/useCountryCode.js +38 -0
  71. package/build/src/screens/CountryCode/index.js +10 -0
  72. package/build/src/screens/CountryCode/index.native.js +37 -0
  73. package/build/src/screens/CountryCode/type.js +1 -0
  74. package/build/src/screens/CreatePassword/hooks/internal/useCreatePassword.js +46 -0
  75. package/build/src/screens/CreatePassword/index.js +19 -0
  76. package/build/src/screens/CreatePassword/index.native.js +32 -0
  77. package/build/src/screens/CreatePassword/type.js +1 -0
  78. package/build/src/screens/EnterEmail/hooks/internal/useEnterEmail.js +77 -0
  79. package/build/src/screens/EnterEmail/index.js +58 -0
  80. package/build/src/screens/EnterEmail/index.native.js +31 -0
  81. package/build/src/screens/EnterEmail/types.js +1 -0
  82. package/build/src/screens/EnterMobile/components/ExistingAccountsSheet/hooks/internal/useExistingAccountsSheet.js +36 -0
  83. package/build/src/screens/EnterMobile/components/ExistingAccountsSheet/index.js +33 -0
  84. package/build/src/screens/EnterMobile/components/ExistingAccountsSheet/index.native.js +73 -0
  85. package/build/src/screens/EnterMobile/components/ExistingAccountsSheet/types.js +1 -0
  86. package/build/src/screens/EnterMobile/hooks/internal/useEnterMobile.js +70 -0
  87. package/build/src/screens/EnterMobile/index.js +82 -0
  88. package/build/src/screens/EnterMobile/index.native.js +56 -0
  89. package/build/src/screens/EnterMobile/types.js +1 -0
  90. package/build/src/screens/EnterPassword/hooks/internal/useEnterPassword.js +79 -0
  91. package/build/src/screens/EnterPassword/index.js +68 -0
  92. package/build/src/screens/EnterPassword/index.native.js +41 -0
  93. package/build/src/screens/EnterPassword/types.js +1 -0
  94. package/build/src/screens/Login/components/LoginWebComponent/index.js +63 -0
  95. package/build/src/screens/Login/components/LoginWebComponent/index.native.js +6 -0
  96. package/build/src/screens/Login/index.js +10 -0
  97. package/build/src/screens/Login/index.native.js +6 -0
  98. package/build/src/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.js +85 -0
  99. package/build/src/screens/LoginWithEmailOTP/index.js +8 -0
  100. package/build/src/screens/LoginWithEmailOTP/index.native.js +10 -0
  101. package/build/src/screens/LoginWithMobileOTP/hooks/internal/useLoginWithMobileOTP.js +72 -0
  102. package/build/src/screens/LoginWithMobileOTP/index.js +8 -0
  103. package/build/src/screens/LoginWithMobileOTP/index.native.js +10 -0
  104. package/build/src/screens/PartnerSSO/PartnerLogin/components/PartnerLoginWebComponent/index.js +71 -0
  105. package/build/src/screens/PartnerSSO/PartnerLogin/components/PartnerLoginWebComponent/index.native.js +6 -0
  106. package/build/src/screens/PartnerSSO/PartnerLogin/hooks/internal/usePartnerLogin.js +52 -0
  107. package/build/src/screens/PartnerSSO/PartnerLogin/index.js +2 -0
  108. package/build/src/screens/PartnerSSO/PartnerLogin/types.js +1 -0
  109. package/build/src/screens/PartnerSSO/PartnerRegistration/components/PartnerRegistrationWebComponent/index.js +207 -0
  110. package/build/src/screens/PartnerSSO/PartnerRegistration/components/PartnerRegistrationWebComponent/index.native.js +6 -0
  111. package/build/src/screens/PartnerSSO/PartnerRegistration/hooks/internal/usePartnerRegistration.js +90 -0
  112. package/build/src/screens/PartnerSSO/PartnerRegistration/index.js +2 -0
  113. package/build/src/screens/PartnerSSO/PartnerRegistration/types.js +1 -0
  114. package/build/src/screens/PartnerSSO/index.js +2 -0
  115. package/build/src/screens/Profile/components/EditMobileNumber/index.js +31 -0
  116. package/build/src/screens/Profile/components/EditMobileNumber/index.native.js +8 -0
  117. package/build/src/screens/Profile/components/EditPassword/index.js +29 -0
  118. package/build/src/screens/Profile/components/EditPassword/index.native.js +8 -0
  119. package/build/src/screens/Profile/components/EditProfile/index.js +89 -0
  120. package/build/src/screens/Profile/components/EditProfile/index.native.js +8 -0
  121. package/build/src/screens/Profile/components/OtpVerificationModal/index.js +61 -0
  122. package/build/src/screens/Profile/components/OtpVerificationModal/index.native.js +7 -0
  123. package/build/src/screens/Profile/components/ProfileWebComponent/index.js +80 -0
  124. package/build/src/screens/Profile/components/ProfileWebComponent/index.native.js +9 -0
  125. package/build/src/screens/Profile/hooks/internal/useProfile.js +185 -0
  126. package/build/src/screens/Profile/index.js +6 -0
  127. package/build/src/screens/Profile/index.native.js +6 -0
  128. package/build/src/screens/Profile/types.js +1 -0
  129. package/build/src/screens/ResetPassword/hooks/internal/useResetPassword.js +57 -0
  130. package/build/src/screens/ResetPassword/index.js +46 -0
  131. package/build/src/screens/ResetPassword/index.native.js +26 -0
  132. package/build/src/screens/ResetPassword/types.js +1 -0
  133. package/build/src/screens/SSOLogin/AuthWebView/index.js +9 -0
  134. package/build/src/screens/SSOLogin/AuthWebView/index.native.js +42 -0
  135. package/build/src/screens/SSOLogin/AuthWebView/types.js +1 -0
  136. package/build/src/screens/SSOLogin/AuthenticationMethods/hooks/internal/useSSOAuthenticationMethods.js +39 -0
  137. package/build/src/screens/SSOLogin/AuthenticationMethods/index.js +50 -0
  138. package/build/src/screens/SSOLogin/AuthenticationMethods/index.native.js +59 -0
  139. package/build/src/screens/SSOLogin/AuthenticationMethods/types.js +1 -0
  140. package/build/src/screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index.js +62 -0
  141. package/build/src/screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index.native.js +6 -0
  142. package/build/src/screens/SSOLogin/SSOCallback/hooks/internal/useSSOCallback.js +58 -0
  143. package/build/src/screens/SSOLogin/SSOCallback/index.js +9 -0
  144. package/build/src/screens/SSOLogin/SSOCallback/index.native.js +35 -0
  145. package/build/src/screens/SSOLogin/SSOCallback/types.js +1 -0
  146. package/build/src/screens/SSOLogin/SearchOrganization/hooks/internal/useSSOSearchOrganization.js +71 -0
  147. package/build/src/screens/SSOLogin/SearchOrganization/index.js +46 -0
  148. package/build/src/screens/SSOLogin/SearchOrganization/index.native.js +37 -0
  149. package/build/src/screens/SSOLogin/SearchOrganization/types.js +1 -0
  150. package/build/src/screens/SignUp/components/SignUpForm/index.js +215 -0
  151. package/build/src/screens/SignUp/components/SignUpForm/index.native.js +6 -0
  152. package/build/src/screens/SignUp/components/SignUpForm/type.js +1 -0
  153. package/build/src/screens/SignUp/components/SignUpWebComponent/index.js +62 -0
  154. package/build/src/screens/SignUp/components/SignUpWebComponent/index.native.js +6 -0
  155. package/build/src/screens/SignUp/components/SignUpWebComponent/types.js +1 -0
  156. package/build/src/screens/SignUp/hooks/internal/useSignUp.js +134 -0
  157. package/build/src/screens/SignUp/index.js +6 -0
  158. package/build/src/screens/SignUp/index.native.js +188 -0
  159. package/build/src/screens/SignUp/types.js +1 -0
  160. package/build/src/screens/UserConsent/hooks/internal/useConsent.js +64 -0
  161. package/build/src/screens/UserConsent/index.js +84 -0
  162. package/build/src/screens/UserConsent/index.native.js +47 -0
  163. package/build/src/screens/UserConsent/types.js +1 -0
  164. package/build/src/screens/VerifyEmail/hooks/internal/useVerifyEmail.js +69 -0
  165. package/build/src/screens/VerifyEmail/index.js +8 -0
  166. package/build/src/screens/VerifyEmail/index.native.js +14 -0
  167. package/build/src/screens/VerifyEmail/types.js +1 -0
  168. package/build/src/screens/VerifyLinkPrimaryAccountEmailOTP/hooks/internal/useVerifyLinkPrimaryAccountEmailOTP.js +73 -0
  169. package/build/src/screens/VerifyLinkPrimaryAccountEmailOTP/index.js +8 -0
  170. package/build/src/screens/VerifyLinkPrimaryAccountEmailOTP/index.native.js +14 -0
  171. package/build/src/screens/VerifyLinkPrimaryAccountEmailOTP/types.js +1 -0
  172. package/build/src/screens/VerifyLinkPrimaryAccountMobileOTP/hooks/internal/useVerifyLinkPrimaryAccountMobileOTP.js +83 -0
  173. package/build/src/screens/VerifyLinkPrimaryAccountMobileOTP/index.js +8 -0
  174. package/build/src/screens/VerifyLinkPrimaryAccountMobileOTP/index.native.js +10 -0
  175. package/build/src/screens/VerifyLinkPrimaryAccountMobileOTP/types.js +1 -0
  176. package/build/src/screens/VerifyMobile/hooks/internal/useVerifyMobile.js +74 -0
  177. package/build/src/screens/VerifyMobile/index.js +8 -0
  178. package/build/src/screens/VerifyMobile/index.native.js +9 -0
  179. package/build/src/screens/VerifyMobile/types.js +1 -0
  180. package/build/src/screens/VerifyResetPasswordOTP/hooks/internal/useVerifyResetPasswordOTP.js +74 -0
  181. package/build/src/screens/VerifyResetPasswordOTP/index.js +8 -0
  182. package/build/src/screens/VerifyResetPasswordOTP/index.native.js +14 -0
  183. package/build/src/screens/Welcome/SocialAuth/commonSocialAuth.js +127 -0
  184. package/build/src/screens/Welcome/SocialAuth/hooks/useSocialAuth.native.js +187 -0
  185. package/build/src/screens/Welcome/SocialAuth/hooks/useSocialAuth.web.js +13 -0
  186. package/build/src/screens/Welcome/SocialAuth/hooks/web/useFacebookAuth.web.js +115 -0
  187. package/build/src/screens/Welcome/SocialAuth/hooks/web/useGoogleAuth.web.js +72 -0
  188. package/build/src/screens/Welcome/components/SocialLoginModal/index.js +9 -0
  189. package/build/src/screens/Welcome/components/SocialLoginModal/index.native.js +21 -0
  190. package/build/src/screens/Welcome/components/SocialLoginModal/types.js +1 -0
  191. package/build/src/screens/Welcome/hooks/internal/useWelcome.js +26 -0
  192. package/build/src/screens/Welcome/index.js +28 -0
  193. package/build/src/screens/Welcome/index.native.js +78 -0
  194. package/build/src/types/types.js +2 -0
  195. package/build/types/api/auth.d.ts +11 -0
  196. package/build/types/api/axiosClient/index.d.ts +1 -0
  197. package/build/types/api/axiosClient/index.native.d.ts +1 -0
  198. package/build/types/components/AdvancedTransitionWrapper/index.d.ts +3 -0
  199. package/build/types/components/AdvancedTransitionWrapper/index.native.d.ts +5 -0
  200. package/build/types/components/AdvancedTransitionWrapper/types.d.ts +25 -0
  201. package/build/types/components/ConfirmationModal/index.d.ts +3 -0
  202. package/build/types/components/ConfirmationModal/index.native.d.ts +3 -0
  203. package/build/types/components/ConfirmationModal/types.d.ts +16 -0
  204. package/build/types/components/IonIcon/index.d.ts +3 -0
  205. package/build/types/components/IonIcon/index.native.d.ts +4 -0
  206. package/build/types/components/IonIcon/types.d.ts +6 -0
  207. package/build/types/components/LoadingAnimation/index.d.ts +6 -0
  208. package/build/types/components/OTPStatusLabel/index.d.ts +2 -0
  209. package/build/types/components/OTPStatusLabel/index.native.d.ts +3 -0
  210. package/build/types/components/OTPStatusLabel/types.d.ts +6 -0
  211. package/build/types/components/PasswordCriteria/hooks/usePasswordCriteria.d.ts +8 -0
  212. package/build/types/components/PasswordCriteria/index.d.ts +3 -0
  213. package/build/types/components/PasswordCriteria/index.native.d.ts +3 -0
  214. package/build/types/components/PasswordCriteria/types.d.ts +15 -0
  215. package/build/types/components/ScreenLayout/index.d.ts +3 -0
  216. package/build/types/components/ScreenLayout/index.native.d.ts +3 -0
  217. package/build/types/components/ScreenLayout/types.d.ts +13 -0
  218. package/build/types/components/SupportDetails/index.d.ts +2 -0
  219. package/build/types/components/SupportDetails/index.native.d.ts +2 -0
  220. package/build/types/components/VerifyEmailOTP/index.d.ts +3 -0
  221. package/build/types/components/VerifyEmailOTP/index.native.d.ts +3 -0
  222. package/build/types/components/VerifyEmailOTP/types.d.ts +9 -0
  223. package/build/types/components/VerifyMobileOTP/index.d.ts +3 -0
  224. package/build/types/components/VerifyMobileOTP/index.native.d.ts +3 -0
  225. package/build/types/components/VerifyMobileOTP/types.d.ts +9 -0
  226. package/build/types/constants/base-url/index.d.ts +1 -0
  227. package/build/types/constants/base-url/index.native.d.ts +1 -0
  228. package/build/types/constants/cdn-url/index.d.ts +2 -0
  229. package/build/types/constants/cdn-url/index.native.d.ts +3 -0
  230. package/build/types/constants/defaultPolicy.d.ts +9 -0
  231. package/build/types/constants/password-requirements.d.ts +4 -0
  232. package/build/types/constants/social-login-options.d.ts +3 -0
  233. package/build/types/contexts/AuthContext.d.ts +40 -0
  234. package/build/types/contexts/type.d.ts +94 -0
  235. package/build/types/enums/index.d.ts +3 -0
  236. package/build/types/enums/loginMethod.enum.d.ts +7 -0
  237. package/build/types/enums/registrationMethod.enum.d.ts +6 -0
  238. package/build/types/enums/socialLogins.enum.d.ts +5 -0
  239. package/build/types/helpers/network.d.ts +5 -0
  240. package/build/types/helpers/show-message/index.d.ts +3 -0
  241. package/build/types/helpers/show-message/index.native.d.ts +3 -0
  242. package/build/types/helpers/show-message/types.d.ts +6 -0
  243. package/build/types/helpers/types.d.ts +19 -0
  244. package/build/types/helpers/validation.d.ts +2 -0
  245. package/build/types/hooks/internal/useAuthPackageContext.d.ts +1 -0
  246. package/build/types/hooks/internal/useTimer.d.ts +3 -0
  247. package/build/types/hooks/useAuthContext.d.ts +2 -0
  248. package/build/types/hooks/useNavigator.d.ts +66 -0
  249. package/build/types/hooks/useRequest.d.ts +5 -0
  250. package/build/types/index.d.ts +15 -0
  251. package/build/types/navigator/index.d.ts +2 -0
  252. package/build/types/navigator/index.native.d.ts +82 -0
  253. package/build/types/screens/CountryCode/components/CountryCodeDropdown/index.d.ts +3 -0
  254. package/build/types/screens/CountryCode/components/CountryCodeDropdown/index.native.d.ts +2 -0
  255. package/build/types/screens/CountryCode/components/CountryCodeDropdown/types.d.ts +17 -0
  256. package/build/types/screens/CountryCode/hooks/internal/useCountryCode.d.ts +12 -0
  257. package/build/types/screens/CountryCode/index.d.ts +2 -0
  258. package/build/types/screens/CountryCode/index.native.d.ts +2 -0
  259. package/build/types/screens/CountryCode/type.d.ts +11 -0
  260. package/build/types/screens/CreatePassword/hooks/internal/useCreatePassword.d.ts +37 -0
  261. package/build/types/screens/CreatePassword/index.d.ts +3 -0
  262. package/build/types/screens/CreatePassword/index.native.d.ts +4 -0
  263. package/build/types/screens/CreatePassword/type.d.ts +43 -0
  264. package/build/types/screens/EnterEmail/hooks/internal/useEnterEmail.d.ts +19 -0
  265. package/build/types/screens/EnterEmail/index.d.ts +3 -0
  266. package/build/types/screens/EnterEmail/index.native.d.ts +4 -0
  267. package/build/types/screens/EnterEmail/types.d.ts +13 -0
  268. package/build/types/screens/EnterMobile/components/ExistingAccountsSheet/hooks/internal/useExistingAccountsSheet.d.ts +13 -0
  269. package/build/types/screens/EnterMobile/components/ExistingAccountsSheet/index.d.ts +3 -0
  270. package/build/types/screens/EnterMobile/components/ExistingAccountsSheet/index.native.d.ts +3 -0
  271. package/build/types/screens/EnterMobile/components/ExistingAccountsSheet/types.d.ts +28 -0
  272. package/build/types/screens/EnterMobile/hooks/internal/useEnterMobile.d.ts +15 -0
  273. package/build/types/screens/EnterMobile/index.d.ts +4 -0
  274. package/build/types/screens/EnterMobile/index.native.d.ts +4 -0
  275. package/build/types/screens/EnterMobile/types.d.ts +44 -0
  276. package/build/types/screens/EnterPassword/hooks/internal/useEnterPassword.d.ts +25 -0
  277. package/build/types/screens/EnterPassword/index.d.ts +3 -0
  278. package/build/types/screens/EnterPassword/index.native.d.ts +4 -0
  279. package/build/types/screens/EnterPassword/types.d.ts +24 -0
  280. package/build/types/screens/Login/components/LoginWebComponent/index.d.ts +2 -0
  281. package/build/types/screens/Login/components/LoginWebComponent/index.native.d.ts +2 -0
  282. package/build/types/screens/Login/index.d.ts +2 -0
  283. package/build/types/screens/Login/index.native.d.ts +2 -0
  284. package/build/types/screens/LoginWithEmailOTP/hooks/internal/useLoginWithEmailOTP.d.ts +17 -0
  285. package/build/types/screens/LoginWithEmailOTP/index.d.ts +7 -0
  286. package/build/types/screens/LoginWithEmailOTP/index.native.d.ts +4 -0
  287. package/build/types/screens/LoginWithMobileOTP/hooks/internal/useLoginWithMobileOTP.d.ts +11 -0
  288. package/build/types/screens/LoginWithMobileOTP/index.d.ts +5 -0
  289. package/build/types/screens/LoginWithMobileOTP/index.native.d.ts +4 -0
  290. package/build/types/screens/PartnerSSO/PartnerLogin/components/PartnerLoginWebComponent/index.d.ts +25 -0
  291. package/build/types/screens/PartnerSSO/PartnerLogin/components/PartnerLoginWebComponent/index.native.d.ts +2 -0
  292. package/build/types/screens/PartnerSSO/PartnerLogin/hooks/internal/usePartnerLogin.d.ts +8 -0
  293. package/build/types/screens/PartnerSSO/PartnerLogin/index.d.ts +2 -0
  294. package/build/types/screens/PartnerSSO/PartnerLogin/types.d.ts +35 -0
  295. package/build/types/screens/PartnerSSO/PartnerRegistration/components/PartnerRegistrationWebComponent/index.d.ts +24 -0
  296. package/build/types/screens/PartnerSSO/PartnerRegistration/components/PartnerRegistrationWebComponent/index.native.d.ts +2 -0
  297. package/build/types/screens/PartnerSSO/PartnerRegistration/hooks/internal/usePartnerRegistration.d.ts +8 -0
  298. package/build/types/screens/PartnerSSO/PartnerRegistration/index.d.ts +2 -0
  299. package/build/types/screens/PartnerSSO/PartnerRegistration/types.d.ts +63 -0
  300. package/build/types/screens/PartnerSSO/index.d.ts +2 -0
  301. package/build/types/screens/Profile/components/EditMobileNumber/index.d.ts +6 -0
  302. package/build/types/screens/Profile/components/EditMobileNumber/index.native.d.ts +3 -0
  303. package/build/types/screens/Profile/components/EditPassword/index.d.ts +6 -0
  304. package/build/types/screens/Profile/components/EditPassword/index.native.d.ts +3 -0
  305. package/build/types/screens/Profile/components/EditProfile/index.d.ts +6 -0
  306. package/build/types/screens/Profile/components/EditProfile/index.native.d.ts +3 -0
  307. package/build/types/screens/Profile/components/OtpVerificationModal/index.d.ts +4 -0
  308. package/build/types/screens/Profile/components/OtpVerificationModal/index.native.d.ts +3 -0
  309. package/build/types/screens/Profile/components/ProfileWebComponent/index.d.ts +4 -0
  310. package/build/types/screens/Profile/components/ProfileWebComponent/index.native.d.ts +3 -0
  311. package/build/types/screens/Profile/hooks/internal/useProfile.d.ts +26 -0
  312. package/build/types/screens/Profile/index.d.ts +7 -0
  313. package/build/types/screens/Profile/index.native.d.ts +7 -0
  314. package/build/types/screens/Profile/types.d.ts +53 -0
  315. package/build/types/screens/ResetPassword/hooks/internal/useResetPassword.d.ts +29 -0
  316. package/build/types/screens/ResetPassword/index.d.ts +3 -0
  317. package/build/types/screens/ResetPassword/index.native.d.ts +4 -0
  318. package/build/types/screens/ResetPassword/types.d.ts +11 -0
  319. package/build/types/screens/SSOLogin/AuthWebView/index.d.ts +2 -0
  320. package/build/types/screens/SSOLogin/AuthWebView/index.native.d.ts +4 -0
  321. package/build/types/screens/SSOLogin/AuthWebView/types.d.ts +8 -0
  322. package/build/types/screens/SSOLogin/AuthenticationMethods/hooks/internal/useSSOAuthenticationMethods.d.ts +9 -0
  323. package/build/types/screens/SSOLogin/AuthenticationMethods/index.d.ts +3 -0
  324. package/build/types/screens/SSOLogin/AuthenticationMethods/index.native.d.ts +4 -0
  325. package/build/types/screens/SSOLogin/AuthenticationMethods/types.d.ts +14 -0
  326. package/build/types/screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index.d.ts +6 -0
  327. package/build/types/screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index.native.d.ts +2 -0
  328. package/build/types/screens/SSOLogin/SSOCallback/hooks/internal/useSSOCallback.d.ts +15 -0
  329. package/build/types/screens/SSOLogin/SSOCallback/index.d.ts +2 -0
  330. package/build/types/screens/SSOLogin/SSOCallback/index.native.d.ts +4 -0
  331. package/build/types/screens/SSOLogin/SSOCallback/types.d.ts +14 -0
  332. package/build/types/screens/SSOLogin/SearchOrganization/hooks/internal/useSSOSearchOrganization.d.ts +18 -0
  333. package/build/types/screens/SSOLogin/SearchOrganization/index.d.ts +3 -0
  334. package/build/types/screens/SSOLogin/SearchOrganization/index.native.d.ts +4 -0
  335. package/build/types/screens/SSOLogin/SearchOrganization/types.d.ts +13 -0
  336. package/build/types/screens/SignUp/components/SignUpForm/index.d.ts +3 -0
  337. package/build/types/screens/SignUp/components/SignUpForm/index.native.d.ts +2 -0
  338. package/build/types/screens/SignUp/components/SignUpForm/type.d.ts +6 -0
  339. package/build/types/screens/SignUp/components/SignUpWebComponent/index.d.ts +2 -0
  340. package/build/types/screens/SignUp/components/SignUpWebComponent/index.native.d.ts +2 -0
  341. package/build/types/screens/SignUp/components/SignUpWebComponent/types.d.ts +9 -0
  342. package/build/types/screens/SignUp/hooks/internal/useSignUp.d.ts +48 -0
  343. package/build/types/screens/SignUp/index.d.ts +2 -0
  344. package/build/types/screens/SignUp/index.native.d.ts +4 -0
  345. package/build/types/screens/SignUp/types.d.ts +40 -0
  346. package/build/types/screens/UserConsent/hooks/internal/useConsent.d.ts +10 -0
  347. package/build/types/screens/UserConsent/index.d.ts +3 -0
  348. package/build/types/screens/UserConsent/index.native.d.ts +4 -0
  349. package/build/types/screens/UserConsent/types.d.ts +33 -0
  350. package/build/types/screens/VerifyEmail/hooks/internal/useVerifyEmail.d.ts +19 -0
  351. package/build/types/screens/VerifyEmail/index.d.ts +3 -0
  352. package/build/types/screens/VerifyEmail/index.native.d.ts +4 -0
  353. package/build/types/screens/VerifyEmail/types.d.ts +8 -0
  354. package/build/types/screens/VerifyLinkPrimaryAccountEmailOTP/hooks/internal/useVerifyLinkPrimaryAccountEmailOTP.d.ts +15 -0
  355. package/build/types/screens/VerifyLinkPrimaryAccountEmailOTP/index.d.ts +3 -0
  356. package/build/types/screens/VerifyLinkPrimaryAccountEmailOTP/index.native.d.ts +4 -0
  357. package/build/types/screens/VerifyLinkPrimaryAccountEmailOTP/types.d.ts +14 -0
  358. package/build/types/screens/VerifyLinkPrimaryAccountMobileOTP/hooks/internal/useVerifyLinkPrimaryAccountMobileOTP.d.ts +17 -0
  359. package/build/types/screens/VerifyLinkPrimaryAccountMobileOTP/index.d.ts +3 -0
  360. package/build/types/screens/VerifyLinkPrimaryAccountMobileOTP/index.native.d.ts +4 -0
  361. package/build/types/screens/VerifyLinkPrimaryAccountMobileOTP/types.d.ts +5 -0
  362. package/build/types/screens/VerifyMobile/hooks/internal/useVerifyMobile.d.ts +14 -0
  363. package/build/types/screens/VerifyMobile/index.d.ts +3 -0
  364. package/build/types/screens/VerifyMobile/index.native.d.ts +4 -0
  365. package/build/types/screens/VerifyMobile/types.d.ts +5 -0
  366. package/build/types/screens/VerifyResetPasswordOTP/hooks/internal/useVerifyResetPasswordOTP.d.ts +19 -0
  367. package/build/types/screens/VerifyResetPasswordOTP/index.d.ts +7 -0
  368. package/build/types/screens/VerifyResetPasswordOTP/index.native.d.ts +4 -0
  369. package/build/types/screens/Welcome/SocialAuth/commonSocialAuth.d.ts +50 -0
  370. package/build/types/screens/Welcome/SocialAuth/hooks/useSocialAuth.native.d.ts +7 -0
  371. package/build/types/screens/Welcome/SocialAuth/hooks/useSocialAuth.web.d.ts +7 -0
  372. package/build/types/screens/Welcome/SocialAuth/hooks/web/useFacebookAuth.web.d.ts +5 -0
  373. package/build/types/screens/Welcome/SocialAuth/hooks/web/useGoogleAuth.web.d.ts +4 -0
  374. package/build/types/screens/Welcome/components/SocialLoginModal/index.d.ts +3 -0
  375. package/build/types/screens/Welcome/components/SocialLoginModal/index.native.d.ts +3 -0
  376. package/build/types/screens/Welcome/components/SocialLoginModal/types.d.ts +8 -0
  377. package/build/types/screens/Welcome/hooks/internal/useWelcome.d.ts +22 -0
  378. package/build/types/screens/Welcome/index.d.ts +4 -0
  379. package/build/types/screens/Welcome/index.native.d.ts +4 -0
  380. package/build/types/types/types.d.ts +115 -0
  381. package/package.json +3 -1
@@ -0,0 +1,192 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useEffect, useState, useMemo, useCallback } from 'react';
3
+ import { MEMBER_IMAGES_URL } from '../constants/cdn-url';
4
+ import { createHttpClient } from '../helpers/network';
5
+ /**
6
+ * Public Auth Authentication Context
7
+ *
8
+ * Exposed to consumers of the Auth package.
9
+ * Provides access to user profile, client info, logout, and helper utilities.
10
+ */
11
+ const AuthContext = React.createContext(null);
12
+ /**
13
+ * Package Auth Authentication Context
14
+ *
15
+ * Not meant for public use. Contains lower-level auth state such as
16
+ * token, login/logout functions, and refresh session.
17
+ */
18
+ const AuthPackageContext = React.createContext(null);
19
+ /**
20
+ * AuthProvider
21
+ *
22
+ * Provides authentication state and actions to children.
23
+ * Wraps both AuthContext (public) and AuthPackageContext (internal).
24
+ *
25
+ * @param children - React children to be rendered inside the provider
26
+ * @param router - Router adapter for navigation in web apps only
27
+ * @param basePath - Base path for web routes where the auth module is mounted (default: '')
28
+ * @param LogoComponent - Optional component for branding/logo in auth flows
29
+ * @param session - Initial session containing token & sessionTimeout (if available)
30
+ * @param supportEmail - Optional support email for auth flows
31
+ * @param appConfig - Optional app config for auth flows
32
+ * @param onLogin - Optional callback after successful login
33
+ * @param onLogout - Optional callback after successful logout
34
+ * @param onLaunchAuthSession - Optional callback after successfully launching the auth session. For example, it can be used to set the Firebase notification token or request Android permissions.
35
+ * @param onRefreshSession - Optional handler for refreshing user session
36
+ * @param openChatSupport - Optional callback to open chat support
37
+ * @param socialLoginConfig - Optional social login configuration
38
+ */
39
+ const AuthProvider = ({ children, router, basePath = '', LogoComponent, session, appConfig, onLogin, onLogout, onLaunchAuthSession, onRefreshSession, openChatSupport, socialLoginConfig }) => {
40
+ const [isLoadingProfile, setIsLoadingProfile] = useState(false);
41
+ const [profile, setProfile] = useState(null);
42
+ const [client, setClient] = useState(null);
43
+ const [registrationMethod, setRegistrationMethod] = useState(null);
44
+ const [token, setToken] = useState(session?.token || '');
45
+ const [otpValue, setOtpValue] = useState('');
46
+ const { request } = useMemo(() => createHttpClient({
47
+ token,
48
+ onRefreshSession: onRefreshSession
49
+ ? (t) => onRefreshSession({ token: t })
50
+ : undefined,
51
+ onLogout: async () => {
52
+ onLogout?.();
53
+ clearSession();
54
+ },
55
+ }), [token, onRefreshSession, onLogout]);
56
+ /**
57
+ * Sync local token state with session prop
58
+ */
59
+ useEffect(() => {
60
+ if (session?.token) {
61
+ setToken(session?.token);
62
+ }
63
+ }, [session?.token]);
64
+ /**
65
+ * fetch user profile if not already loaded.
66
+ */
67
+ useEffect(() => {
68
+ if (token && !profile) {
69
+ getUserProfile();
70
+ }
71
+ }, [token, profile]);
72
+ /**
73
+ * Logout user and clear authentication state.
74
+ * Falls back to default /auth/logout request
75
+ *
76
+ * @returns Promise<any> Resolves when logout is completed
77
+ */
78
+ const logout = useCallback(() => {
79
+ return new Promise((resolve, reject) => {
80
+ request({
81
+ url: '/auth/logout',
82
+ method: 'POST',
83
+ }).then((res) => {
84
+ clearSession();
85
+ onLogout?.();
86
+ resolve(res);
87
+ }).catch((err) => {
88
+ reject(err);
89
+ });
90
+ });
91
+ }, [request, onLogout]);
92
+ /**
93
+ * Fetch and update user profile and client data.
94
+ *
95
+ * @param token - Optional token for API request
96
+ * @returns Promise<any> Resolves with profile/config response
97
+ */
98
+ const getUserProfile = useCallback(() => {
99
+ if (isLoadingProfile)
100
+ return Promise.resolve(); // Prevent concurrent calls
101
+ setIsLoadingProfile(true);
102
+ return new Promise((resolve, reject) => {
103
+ request({
104
+ url: '/auth/config',
105
+ method: 'GET',
106
+ }).then((res) => {
107
+ const data = res?.data;
108
+ if (!data?.profile) {
109
+ console.warn('No profile data received from /auth/config');
110
+ return resolve(data);
111
+ }
112
+ const formatted = formatUserData(data);
113
+ setProfile(formatted.profile);
114
+ setClient(formatted.client);
115
+ resolve(data);
116
+ }).catch((err) => {
117
+ reject(err);
118
+ });
119
+ }).finally(() => {
120
+ setIsLoadingProfile(false);
121
+ });
122
+ }, [request, isLoadingProfile]);
123
+ const clearSession = useCallback(() => {
124
+ setToken('');
125
+ setClient(null);
126
+ setRegistrationMethod(null);
127
+ setProfile(null);
128
+ }, []);
129
+ /**
130
+ * Helper to normalize and format user profile data
131
+ * similar to legacy implementation.
132
+ *
133
+ * @param data - AuthConfigResponse from API
134
+ * @returns Object containing client and profile data
135
+ */
136
+ const formatUserData = useCallback((data) => {
137
+ const clientData = {
138
+ name: data.profile.clientName,
139
+ clientId: data.profile.clientId,
140
+ image: data.profile.clientImage,
141
+ partner: data.profile.partner,
142
+ directClient: data.profile.directClient
143
+ };
144
+ const profileData = {
145
+ ...data.profile,
146
+ firstName: data.profile.firstName,
147
+ lastName: data.profile.lastName,
148
+ image: data.profile?.image ? `${MEMBER_IMAGES_URL}${data.profile.image}` : '',
149
+ };
150
+ return { client: clientData, profile: profileData };
151
+ }, []);
152
+ const handleOtpReceived = (otp) => {
153
+ setOtpValue(otp);
154
+ };
155
+ const AuthContextValues = {
156
+ token,
157
+ profile,
158
+ client,
159
+ isLoadingProfile,
160
+ logout,
161
+ onLaunchAuthSession,
162
+ getUserProfile,
163
+ onOtpReceived: handleOtpReceived,
164
+ };
165
+ const appConfigValue = {
166
+ appName: appConfig?.appName ?? 'The Wellness Corner',
167
+ supportEmail: appConfig?.supportEmail ?? 'support@thewellnesscorner.com',
168
+ privacyPolicyUrl: appConfig?.privacyPolicyUrl ?? 'https://thewellnesscorner.com/privacy-policy',
169
+ termsAndConditionsUrl: appConfig?.termsAndConditionsUrl ?? 'https://thewellnesscorner.com/privacy-policy'
170
+ };
171
+ const AuthPackageContextValues = {
172
+ token,
173
+ router,
174
+ basePath,
175
+ LogoComponent,
176
+ appConfig: appConfigValue,
177
+ registrationMethod,
178
+ socialLoginConfig,
179
+ onLaunchAuthSession,
180
+ onLogin,
181
+ logout,
182
+ refreshSession: onRefreshSession,
183
+ onTokenChange: (token) => setToken(token),
184
+ onRegistrationMethodChange: (method) => setRegistrationMethod(method),
185
+ otpValue,
186
+ openChatSupport
187
+ };
188
+ return (_jsx(AuthContext.Provider, { value: AuthContextValues, children: _jsx(AuthPackageContext.Provider, { value: AuthPackageContextValues, children: children }) }));
189
+ };
190
+ export { AuthProvider };
191
+ export default AuthContext;
192
+ export { AuthPackageContext };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './registrationMethod.enum';
2
+ export * from './loginMethod.enum';
3
+ export * from './socialLogins.enum';
@@ -0,0 +1,8 @@
1
+ export var LoginMethodCode;
2
+ (function (LoginMethodCode) {
3
+ LoginMethodCode[LoginMethodCode["Email"] = 1] = "Email";
4
+ LoginMethodCode[LoginMethodCode["Facebook"] = 2] = "Facebook";
5
+ LoginMethodCode[LoginMethodCode["Google"] = 3] = "Google";
6
+ LoginMethodCode[LoginMethodCode["Apple"] = 4] = "Apple";
7
+ LoginMethodCode[LoginMethodCode["SSO"] = 5] = "SSO";
8
+ })(LoginMethodCode || (LoginMethodCode = {}));
@@ -0,0 +1,7 @@
1
+ export var RegistrationMethod;
2
+ (function (RegistrationMethod) {
3
+ RegistrationMethod["EMAIL"] = "email";
4
+ RegistrationMethod["SSO"] = "sso";
5
+ RegistrationMethod["MOBILE"] = "mobile";
6
+ RegistrationMethod["SOCIAL"] = "social";
7
+ })(RegistrationMethod || (RegistrationMethod = {}));
@@ -0,0 +1,6 @@
1
+ export var SocialLoginsEnum;
2
+ (function (SocialLoginsEnum) {
3
+ SocialLoginsEnum["Google"] = "google";
4
+ SocialLoginsEnum["Facebook"] = "facebook";
5
+ SocialLoginsEnum["Apple"] = "apple";
6
+ })(SocialLoginsEnum || (SocialLoginsEnum = {}));
@@ -0,0 +1,93 @@
1
+ import { axiosClient } from '../api/axiosClient';
2
+ import { showMessage } from './show-message';
3
+ import {} from 'axios';
4
+ export const createHttpClient = ({ token, onRefreshSession, onLogout }) => {
5
+ let currentToken = token;
6
+ const request = ({ url, method, data, ...axiosOptions }) => {
7
+ const upper = method?.toUpperCase();
8
+ const payload = {
9
+ method: upper,
10
+ url,
11
+ data,
12
+ headers: {
13
+ ...(axiosOptions.headers ?? {}),
14
+ ...(currentToken ? { 'x-access-token': currentToken } : {}),
15
+ },
16
+ ...axiosOptions,
17
+ };
18
+ return new Promise((resolve, reject) => {
19
+ axiosClient(payload)
20
+ .then((res) => resolve(res))
21
+ .catch(async (err) => {
22
+ console.log(err?.response?.data);
23
+ // TokenExpiredError → refresh & retry
24
+ if (isAxios401(err, 'TokenExpiredError') && token) {
25
+ try {
26
+ const newToken = await refreshToken();
27
+ if (newToken) {
28
+ currentToken = newToken;
29
+ await onRefreshSession?.(newToken);
30
+ const retryResponse = await axiosClient({
31
+ ...payload,
32
+ headers: {
33
+ ...(payload.headers ?? {}),
34
+ 'x-access-token': newToken,
35
+ },
36
+ });
37
+ resolve(retryResponse);
38
+ }
39
+ }
40
+ catch (refreshErr) {
41
+ if (isAxios401(refreshErr, 'InvalidSessionError')) {
42
+ await handleInvalidSession();
43
+ resolve(null);
44
+ return;
45
+ }
46
+ reject(refreshErr);
47
+ }
48
+ }
49
+ // InvalidSessionError → logout
50
+ if (isAxios401(err, 'InvalidSessionError')) {
51
+ await handleInvalidSession();
52
+ resolve(null);
53
+ return;
54
+ }
55
+ reject(err);
56
+ });
57
+ });
58
+ };
59
+ let refreshPromise = null;
60
+ const refreshToken = async () => {
61
+ if (refreshPromise)
62
+ return refreshPromise;
63
+ if (!currentToken)
64
+ return undefined;
65
+ const tokenRequest = {
66
+ method: 'GET',
67
+ url: '/auth/refresh-token',
68
+ headers: {
69
+ 'x-access-token': currentToken,
70
+ },
71
+ };
72
+ refreshPromise = axiosClient(tokenRequest)
73
+ .then(res => res.data?.token)
74
+ .finally(() => { refreshPromise = null; });
75
+ return refreshPromise;
76
+ };
77
+ const handleInvalidSession = async () => {
78
+ try {
79
+ await onLogout?.();
80
+ showMessage({ message: 'Your session has expired. Please login again.' });
81
+ }
82
+ catch (err) {
83
+ console.log('Error logging out:', err);
84
+ }
85
+ };
86
+ return { request };
87
+ };
88
+ const isAxios401 = (err, name) => {
89
+ const e = err;
90
+ const status = e?.response?.status;
91
+ const n = e?.response?.data?.errors?.[0]?.name;
92
+ return status === 401 && (!name || n === name);
93
+ };
@@ -0,0 +1,19 @@
1
+ import { showNotification } from "@truworth/twc-web-design";
2
+ const showMessage = ({ message, type }) => {
3
+ if (message == null)
4
+ return;
5
+ const text = typeof message === 'string'
6
+ ? message
7
+ : message instanceof Error
8
+ ? message.message
9
+ : (typeof message === 'object' && 'message' in message)
10
+ ? String(message.message)
11
+ : String(message);
12
+ showNotification({
13
+ type: type ?? 'error',
14
+ title: text,
15
+ showIcon: false,
16
+ duration: 3000,
17
+ });
18
+ };
19
+ export { showMessage };
@@ -0,0 +1,14 @@
1
+ import { Snackbar } from "@truworth/twc-rn-common";
2
+ const showMessage = ({ message, leftIcon = 'warning' }) => {
3
+ if (message == null)
4
+ return;
5
+ const text = typeof message === 'string'
6
+ ? message
7
+ : message instanceof Error
8
+ ? message.message
9
+ : (typeof message === 'object' && 'message' in message)
10
+ ? String(message.message)
11
+ : String(message);
12
+ Snackbar.show({ text, leftIcon });
13
+ };
14
+ export { showMessage };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ export const validatePhoneNo = (text) => {
2
+ // Normalize common formatting then enforce E.164 constraints
3
+ const normalized = text.replace(/[\s()-]/g, '');
4
+ if (!/^\+?\d+$/.test(normalized))
5
+ return false; // digits (optional leading +)
6
+ return /^\+?[1-9]\d{6,14}$/.test(normalized); // 7–15 digits, no leading zero country code
7
+ };
8
+ export const validateEmojiRegex = (text) => {
9
+ const regexpEmoji = /[\u{1f300}-\u{1f5ff}\u{1f900}-\u{1f9ff}\u{1f600}-\u{1f64f}\u{1f680}-\u{1f6ff}\u{2600}-\u{26ff}\u{2700}-\u{27bf}\u{1f1e6}-\u{1f1ff}\u{1f191}-\u{1f251}\u{1f004}\u{1f0cf}\u{1f170}-\u{1f171}\u{1f17e}-\u{1f17f}\u{1f18e}\u{3030}\u{2b50}\u{2b55}\u{2934}-\u{2935}\u{2b05}-\u{2b07}\u{2b1b}-\u{2b1c}\u{3297}\u{3299}\u{303d}\u{00a9}\u{00ae}\u{2122}\u{23f3}\u{24c2}\u{23e9}-\u{23ef}\u{25b6}\u{23f8}-\u{23fa}]/ug;
10
+ text = text.replace(regexpEmoji, '');
11
+ return text;
12
+ };
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { AuthPackageContext } from "../../contexts/AuthContext";
3
+ export const useAuthPackageContext = () => {
4
+ const context = React.useContext(AuthPackageContext);
5
+ if (!context) {
6
+ throw new Error('useAuthPackageContext must be used within a LoginProvider');
7
+ }
8
+ return context;
9
+ };
@@ -0,0 +1,40 @@
1
+ import { useEffect, useState, useRef } from 'react';
2
+ const useTimer = (duration) => {
3
+ const [timer, setTimer] = useState(duration);
4
+ useEffect(() => {
5
+ // Reset timer whenever duration changes
6
+ setTimer(duration);
7
+ // Strongly type the interval ID
8
+ const id = setInterval(() => {
9
+ setTimer(prev => {
10
+ if (prev <= 1) {
11
+ clearInterval(id);
12
+ return 0; // Clamp at zero
13
+ }
14
+ return prev - 1;
15
+ });
16
+ }, 1000);
17
+ return () => clearInterval(id);
18
+ }, [duration]);
19
+ return timer;
20
+ };
21
+ const useInterval = (callback, delay) => {
22
+ const savedCallback = useRef();
23
+ // Remember the latest function.
24
+ useEffect(() => {
25
+ savedCallback.current = callback;
26
+ }, [callback]);
27
+ // Set up the interval.
28
+ useEffect(() => {
29
+ function tick() {
30
+ savedCallback.current?.();
31
+ }
32
+ if (delay !== null) {
33
+ const id = setInterval(tick, delay);
34
+ return () => {
35
+ clearInterval(id);
36
+ };
37
+ }
38
+ }, [delay]);
39
+ };
40
+ export { useTimer, useInterval };
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import AuthContext from "../contexts/AuthContext";
3
+ const useAuthContext = () => {
4
+ const context = React.useContext(AuthContext);
5
+ if (!context) {
6
+ throw new Error('useAuthContext must be used within a AuthProvider');
7
+ }
8
+ return context;
9
+ };
10
+ export { useAuthContext };
@@ -0,0 +1,83 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import { AuthPackageContext } from '../contexts/AuthContext';
3
+ /**
4
+ * useNavigator Hook
5
+ *
6
+ * Provides framework-agnostic navigation capabilities.
7
+ * Uses the RouterAdapter provided by the host app through AuthProvider.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * const navigator = useNavigator();
12
+ *
13
+ * // Relative navigation (uses basePath)
14
+ * navigator.push('/registration');
15
+ *
16
+ * // Absolute navigation (ignores basePath)
17
+ * navigator.pushAbsolute('/dashboard');
18
+ *
19
+ * // With query params
20
+ * navigator.push('/registration', { query: { email: 'test@example.com' } });
21
+ *
22
+ * // Access query params
23
+ * const { email } = navigator.query;
24
+ * ```
25
+ */
26
+ const useNavigator = () => {
27
+ const context = useContext(AuthPackageContext);
28
+ if (!context?.router) {
29
+ throw new Error('useNavigator: router not found in context. ' +
30
+ 'Make sure to wrap your component with AuthProvider and pass a router adapter.');
31
+ }
32
+ const { router, basePath = '' } = context;
33
+ const navigator = useMemo(() => ({
34
+ /**
35
+ * Navigate to a path relative to basePath
36
+ */
37
+ push: (path, options) => {
38
+ const fullPath = path.startsWith('/') ? `${basePath}${path}` : `${basePath}/${path}`;
39
+ router.push(fullPath, options);
40
+ },
41
+ /**
42
+ * Replace current path with a path relative to basePath
43
+ */
44
+ replace: (path, options) => {
45
+ const fullPath = path.startsWith('/') ? `${basePath}${path}` : `${basePath}/${path}`;
46
+ router.replace(fullPath, options);
47
+ },
48
+ /**
49
+ * Navigate to an absolute path (ignores basePath)
50
+ */
51
+ pushAbsolute: (path, options) => {
52
+ router.push(path, options);
53
+ },
54
+ /**
55
+ * Replace with an absolute path (ignores basePath)
56
+ */
57
+ replaceAbsolute: (path, options) => {
58
+ router.replace(path, options);
59
+ },
60
+ /**
61
+ * Go back to the previous page
62
+ */
63
+ back: () => router.back(),
64
+ /**
65
+ * Get current query parameters
66
+ */
67
+ get query() {
68
+ return router.getQuery();
69
+ },
70
+ /**
71
+ * Get current pathname
72
+ */
73
+ get pathname() {
74
+ return router.getPathname();
75
+ },
76
+ /**
77
+ * The base path where the auth module is mounted
78
+ */
79
+ basePath,
80
+ }), [router, basePath]);
81
+ return navigator;
82
+ };
83
+ export { useNavigator };
@@ -0,0 +1,34 @@
1
+ import { useMemo } from 'react';
2
+ import { showMessage } from '../helpers/show-message';
3
+ import { useAuthPackageContext } from './internal/useAuthPackageContext';
4
+ import { createHttpClient } from '../helpers/network';
5
+ const useRequest = () => {
6
+ const { token, logout, refreshSession } = useAuthPackageContext();
7
+ const { request } = useMemo(() => createHttpClient({
8
+ token,
9
+ onRefreshSession: async (token) => refreshSession?.({ token }),
10
+ onLogout: async () => logout(),
11
+ }), [token]);
12
+ const makeRequest = async ({ url, method, body, onSuccess, onFailure, ...axiosOptions }) => {
13
+ try {
14
+ const response = await request({
15
+ url,
16
+ method,
17
+ data: body,
18
+ ...axiosOptions,
19
+ });
20
+ onSuccess?.(response.data, response.headers);
21
+ return response.data;
22
+ }
23
+ catch (err) {
24
+ if (onFailure) {
25
+ onFailure(err);
26
+ }
27
+ if (err?.response?.status >= 500) {
28
+ showMessage({ message: "Something went wrong" });
29
+ }
30
+ }
31
+ };
32
+ return { makeRequest };
33
+ };
34
+ export { useRequest };
@@ -0,0 +1,23 @@
1
+ // export contexts
2
+ export * from './contexts/AuthContext';
3
+ export { default as AuthContext } from './contexts/AuthContext';
4
+ export * from './contexts/type';
5
+ // export hooks
6
+ export * from './hooks/useAuthContext';
7
+ export * from './hooks/useRequest';
8
+ export * from './hooks/useNavigator';
9
+ // export axiosClient
10
+ export * from './api/axiosClient';
11
+ // export navigator/router
12
+ export * from './navigator';
13
+ // export components
14
+ export * from './screens/Login/components/LoginWebComponent/index';
15
+ export * from './screens/SignUp/components/SignUpWebComponent/index';
16
+ export * from './screens/SSOLogin/SSOCallback/components/SSOCallbackComponent/index';
17
+ // export partner SSO components
18
+ export * from './screens/PartnerSSO/PartnerLogin/components/PartnerLoginWebComponent';
19
+ export * from './screens/PartnerSSO/PartnerRegistration/components/PartnerRegistrationWebComponent';
20
+ // export profile components
21
+ export * from './screens/Profile';
22
+ // export constants
23
+ export { strongPasswordRequirements } from './constants/password-requirements';
@@ -0,0 +1,10 @@
1
+ 'use client';
2
+ const AuthNavigator = () => {
3
+ if (process.env.NODE_ENV !== 'production') {
4
+ if (typeof window !== 'undefined') {
5
+ console.warn("[@truworth/twc-auth] We use only AuthNavigator for app navigation");
6
+ }
7
+ }
8
+ return null;
9
+ };
10
+ export { AuthNavigator };
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createNativeStackNavigator } from '@react-navigation/native-stack';
3
+ import Welcome from '../screens/Welcome';
4
+ import EnterEmail from '../screens/EnterEmail/index.native';
5
+ import EnterPassword from '../screens/EnterPassword/index.native';
6
+ import SignUp from '../screens/SignUp/index.native';
7
+ import CountryCode from '../screens/CountryCode/index.native';
8
+ import CreatePassword from '../screens/CreatePassword/index.native';
9
+ import UserConsent from '../screens/UserConsent/index.native';
10
+ import VerifyMobile from '../screens/VerifyMobile/index.native';
11
+ import VerifyEmail from '../screens/VerifyEmail/index.native';
12
+ import LoginWithEmailOTP from '../screens/LoginWithEmailOTP/index.native';
13
+ import VerifyResetPasswordOTP from '../screens/VerifyResetPasswordOTP/index.native';
14
+ import ResetPassword from '../screens/ResetPassword/index.native';
15
+ import SSOSearchOrganization from '../screens/SSOLogin/SearchOrganization/index.native';
16
+ import SSOAuthenticationMethods from '../screens/SSOLogin/AuthenticationMethods/index.native';
17
+ import SSOAuthWebView from '../screens/SSOLogin/AuthWebView/index.native';
18
+ import SSOCallback from '../screens/SSOLogin/SSOCallback/index.native';
19
+ import LoginWithMobileOTP from '../screens/LoginWithMobileOTP/index.native';
20
+ import EnterMobile from '../screens/EnterMobile/index.native';
21
+ import VerifyLinkPrimaryAccountEmailOTP from '../screens/VerifyLinkPrimaryAccountEmailOTP/index.native';
22
+ import VerifyLinkPrimaryAccountMobileOTP from '../screens/VerifyLinkPrimaryAccountMobileOTP/index.native';
23
+ const { Navigator, Screen } = createNativeStackNavigator();
24
+ const AuthNavigator = () => {
25
+ return (_jsxs(Navigator, { screenOptions: { headerShown: false }, children: [_jsx(Screen, { name: "Welcome", component: Welcome }), _jsx(Screen, { name: "EnterEmail", component: EnterEmail }), _jsx(Screen, { name: "EnterPassword", component: EnterPassword }), _jsx(Screen, { name: "SignUp", component: SignUp }), _jsx(Screen, { name: "CountryCode", component: CountryCode }), _jsx(Screen, { name: "CreatePassword", component: CreatePassword }), _jsx(Screen, { name: "UserConsent", component: UserConsent }), _jsx(Screen, { name: "VerifyMobile", component: VerifyMobile }), _jsx(Screen, { name: "VerifyEmail", component: VerifyEmail }), _jsx(Screen, { name: "LoginWithEmailOTP", component: LoginWithEmailOTP }), _jsx(Screen, { name: "VerifyResetPasswordOTP", component: VerifyResetPasswordOTP }), _jsx(Screen, { name: "ResetPassword", component: ResetPassword }), _jsx(Screen, { name: "LoginWithMobileOTP", component: LoginWithMobileOTP }), _jsx(Screen, { name: "EnterMobile", component: EnterMobile }), _jsx(Screen, { name: "VerifyLinkPrimaryAccountEmailOTP", component: VerifyLinkPrimaryAccountEmailOTP }), _jsx(Screen, { name: "VerifyLinkPrimaryAccountMobileOTP", component: VerifyLinkPrimaryAccountMobileOTP }), _jsx(Screen, { name: "SSOSearchOrganization", component: SSOSearchOrganization }), _jsx(Screen, { name: "SSOAuthenticationMethods", component: SSOAuthenticationMethods }), _jsx(Screen, { name: "SSOAuthWebView", component: SSOAuthWebView }), _jsx(Screen, { name: "SSOCallback", component: SSOCallback })] }));
26
+ };
27
+ export { AuthNavigator };
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useMemo } from "react";
3
+ import { Typography, SelectField, Flex } from '@truworth/twc-web-design';
4
+ import { useCountryCode } from '../../hooks/internal/useCountryCode';
5
+ export const CountryCodeDropdown = React.memo(({ selectedCountry, handleSelect }) => {
6
+ const { countryCodes: countries } = useCountryCode();
7
+ const isValidCountryCode = (code) => /^[a-z]{2}$/i.test(code); // only 2-letter codes
8
+ const allCountries = useMemo(() => {
9
+ const seen = new Set();
10
+ const uniqueCountries = countries.filter((item) => {
11
+ const rawCode = typeof item.countryCode === 'string' ? item.countryCode : '';
12
+ const code = rawCode.toLowerCase();
13
+ if (!isValidCountryCode(code))
14
+ return false; // filter invalid ones
15
+ if (seen.has(code))
16
+ return false;
17
+ seen.add(code);
18
+ return true;
19
+ });
20
+ return uniqueCountries.map((item) => {
21
+ const code = item.countryCode.toLowerCase();
22
+ const flagUrl = `https://cdn.thewellnesscorner.com/country-flags/${code}.png`;
23
+ return {
24
+ leftIcon: (_jsx(_Fragment, { children: isValidCountryCode(code) && (_jsx("img", { src: flagUrl, width: 20, height: 20, className: "h-5 w-5 shrink-0", alt: `${item.name} flag`, loading: "lazy" })) })),
25
+ label: (_jsxs(Typography, { type: "body", size: "small", children: [item.name, " (+", item.phoneCode, ")"] })),
26
+ value: code,
27
+ selectedField: (_jsxs(Flex, { align: "center", className: "gap-2 pl-2 pr-2 cursor-pointer", children: [isValidCountryCode(code) && (_jsx("img", { src: flagUrl, width: 20, height: 20, className: "h-5 w-5 shrink-0", alt: `${item.name} flag`, loading: "lazy" })), _jsx(Typography, { type: "body", size: "medium", className: "countryCode cursor-pointer", children: `+${item.phoneCode}` })] })),
28
+ };
29
+ });
30
+ }, [countries]);
31
+ return (_jsx(SelectField, { selectedValues: selectedCountry.countryCode, options: allCountries, className: "border-0 w-100 h-1", onSelect: (value) => {
32
+ const currSelectedCountry = countries.find((country) => country.countryCode.toLowerCase() === value);
33
+ if (currSelectedCountry) {
34
+ handleSelect(currSelectedCountry);
35
+ }
36
+ }, fullWidth: true, selectContentClassName: "h-32 pl-2 min-h-[30vh]", maxHeight: "400px", contentOffset: 10 }));
37
+ });