@turnkey/sdk-react 3.0.0 → 3.0.1

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/CHANGELOG.md +13 -0
  2. package/dist/_virtual/_rollupPluginBabelHelpers.mjs +470 -0
  3. package/dist/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -0
  4. package/dist/components/auth/Apple.js +78 -64
  5. package/dist/components/auth/Apple.js.map +1 -1
  6. package/dist/components/auth/Apple.mjs +85 -64
  7. package/dist/components/auth/Apple.mjs.map +1 -1
  8. package/dist/components/auth/Auth.d.ts +3 -0
  9. package/dist/components/auth/Auth.d.ts.map +1 -1
  10. package/dist/components/auth/Auth.js +507 -259
  11. package/dist/components/auth/Auth.js.map +1 -1
  12. package/dist/components/auth/Auth.mjs +725 -229
  13. package/dist/components/auth/Auth.mjs.map +1 -1
  14. package/dist/components/auth/Facebook.js +78 -63
  15. package/dist/components/auth/Facebook.js.map +1 -1
  16. package/dist/components/auth/Facebook.mjs +121 -54
  17. package/dist/components/auth/Facebook.mjs.map +1 -1
  18. package/dist/components/auth/Google.js +63 -47
  19. package/dist/components/auth/Google.js.map +1 -1
  20. package/dist/components/auth/Google.mjs +70 -39
  21. package/dist/components/auth/Google.mjs.map +1 -1
  22. package/dist/components/auth/OtpVerification.js +106 -51
  23. package/dist/components/auth/OtpVerification.js.map +1 -1
  24. package/dist/components/auth/OtpVerification.mjs +151 -41
  25. package/dist/components/auth/OtpVerification.mjs.map +1 -1
  26. package/dist/components/auth/PhoneInput.d.ts.map +1 -1
  27. package/dist/components/auth/PhoneInput.js +138 -69
  28. package/dist/components/auth/PhoneInput.js.map +1 -1
  29. package/dist/components/auth/PhoneInput.mjs +141 -70
  30. package/dist/components/auth/PhoneInput.mjs.map +1 -1
  31. package/dist/components/auth/TurnkeyThemeProvider.js +26 -17
  32. package/dist/components/auth/TurnkeyThemeProvider.js.map +1 -1
  33. package/dist/components/auth/TurnkeyThemeProvider.mjs +33 -18
  34. package/dist/components/auth/TurnkeyThemeProvider.mjs.map +1 -1
  35. package/dist/components/auth/constants.js +26 -26
  36. package/dist/components/auth/constants.js.map +1 -1
  37. package/dist/components/auth/constants.mjs +34 -34
  38. package/dist/components/auth/constants.mjs.map +1 -1
  39. package/dist/components/auth/facebookUtils.js +23 -21
  40. package/dist/components/auth/facebookUtils.js.map +1 -1
  41. package/dist/components/auth/facebookUtils.mjs +65 -23
  42. package/dist/components/auth/facebookUtils.mjs.map +1 -1
  43. package/dist/components/auth/otp.js +84 -71
  44. package/dist/components/auth/otp.js.map +1 -1
  45. package/dist/components/auth/otp.mjs +96 -70
  46. package/dist/components/auth/otp.mjs.map +1 -1
  47. package/dist/components/auth/utils.js +3 -3
  48. package/dist/components/auth/utils.js.map +1 -1
  49. package/dist/components/auth/utils.mjs +3 -3
  50. package/dist/components/auth/utils.mjs.map +1 -1
  51. package/dist/components/export/Export.js +181 -99
  52. package/dist/components/export/Export.js.map +1 -1
  53. package/dist/components/export/Export.mjs +257 -89
  54. package/dist/components/export/Export.mjs.map +1 -1
  55. package/dist/components/import/Import.js +185 -132
  56. package/dist/components/import/Import.js.map +1 -1
  57. package/dist/components/import/Import.mjs +264 -120
  58. package/dist/components/import/Import.mjs.map +1 -1
  59. package/dist/contexts/TurnkeyContext.d.ts.map +1 -1
  60. package/dist/contexts/TurnkeyContext.js +113 -93
  61. package/dist/contexts/TurnkeyContext.js.map +1 -1
  62. package/dist/contexts/TurnkeyContext.mjs +191 -92
  63. package/dist/contexts/TurnkeyContext.mjs.map +1 -1
  64. package/dist/hooks/use-session.js +16 -13
  65. package/dist/hooks/use-session.js.map +1 -1
  66. package/dist/hooks/use-session.mjs +18 -13
  67. package/dist/hooks/use-session.mjs.map +1 -1
  68. package/dist/hooks/use-turnkey.js +5 -5
  69. package/dist/hooks/use-turnkey.js.map +1 -1
  70. package/dist/hooks/use-turnkey.mjs +6 -6
  71. package/dist/hooks/use-turnkey.mjs.map +1 -1
  72. package/package.json +8 -8
@@ -19,269 +19,517 @@ var useTurnkey = require('../../hooks/use-turnkey.js');
19
19
  var constants = require('./constants.js');
20
20
  var sdkServer = require('@turnkey/sdk-server');
21
21
 
22
- const passkeyIcon = (jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "43", height: "48", fill: "none", children: [jsxRuntime.jsx("path", { fill: "var(--icon-color)", "fill-rule": "evenodd", d: "M27.52 37.06a6.8 6.8 0 0 0-2.02-.31H12a6.75 6.75 0 0 0-6.75 6.75V48H.75v-4.5A11.25 11.25 0 0 1 12 32.25h13.5c.68 0 1.355.062 2.016.182zm4.698-23.74a13.5 13.5 0 1 0-8.503 13.484c-.057-.178-.131-.425-.167-.566a13 13 0 0 1-.229-1.134 12 12 0 0 1-.054-.448q-.02-.202-.013-1.064c.007-.82.01-.877.055-1.186.018-.121.046-.29.072-.438a9 9 0 1 1 4.315-6.714 13.83 13.83 0 0 1 .87-.564 14 14 0 0 1 1.08-.556c.102-.045.299-.128.44-.184.14-.056.384-.146.544-.202.16-.055.436-.141.615-.194.18-.05.467-.125.641-.165.092-.02.214-.046.334-.07", "clip-rule": "evenodd" }), jsxRuntime.jsx("path", { fill: "var(--icon-color)", "fill-rule": "evenodd", d: "M33.844 16.554a9.563 9.563 0 0 0-.975.134c-.125.022-.355.075-.51.114s-.418.12-.589.177a11 11 0 0 0-.553.21 12 12 0 0 0-.519.244 8.29 8.29 0 0 0-.961.573c-.114.08-.313.23-.445.334-.13.104-.358.31-.507.454a10 10 0 0 0-.466.495c-.107.127-.269.334-.362.46-.091.128-.232.34-.313.474-.079.133-.195.34-.256.46-.062.122-.15.308-.196.413a10 10 0 0 0-.152.387c-.04.107-.1.304-.14.44a9 9 0 0 0-.119.51c-.028.145-.065.374-.082.51a6 6 0 0 0-.032.773c-.002.327.007.598.021.712a8.924 8.924 0 0 0 .163.905c.03.116.09.322.134.457.046.136.125.35.178.475a8 8 0 0 0 .725 1.329 9.15 9.15 0 0 0 .622.772c.111.121.294.306.408.41.114.101.295.256.4.342.108.085.273.211.37.28.097.068.244.165.325.218l.299.179c.082.047.251.137.374.2.125.062.232.127.24.146.013.025.018 2.403.018 7.032 0 5.905.004 7.018.025 7.125.014.07.047.18.075.24.029.064.08.156.113.203.032.05.522.654 1.086 1.345.564.693 1.07 1.31 1.123 1.371.054.063.14.151.195.195.054.042.162.111.239.151s.204.092.281.115c.121.035.181.04.413.04.206 0 .3-.007.387-.03a2 2 0 0 0 .237-.09 1.8 1.8 0 0 0 .388-.25c.029-.029.547-.657 1.153-1.397a97 97 0 0 0 1.12-1.383.4.4 0 0 0 .019-.137c0-.053-.016-.178-.035-.276a5 5 0 0 0-.273-.876 24 24 0 0 0-.298-.73 32 32 0 0 0-.626-1.365.8.8 0 0 1-.069-.172q.001-.033.041-.043c.021-.003.134-.016.25-.026s.295-.032.395-.046c.102-.016.248-.044.325-.065a.9.9 0 0 0 .237-.102.8.8 0 0 0 .15-.133c.028-.037.073-.116.1-.174.026-.058.054-.16.065-.229a1.895 1.895 0 0 0-.042-.589 2 2 0 0 0-.074-.193c-.023-.053-.355-.542-.736-1.085-.38-.543-.693-1.005-.693-1.025 0-.028.037-.046.234-.105.128-.04.339-.113.469-.162.132-.047.293-.116.36-.15a1 1 0 0 0 .204-.144.8.8 0 0 0 .144-.212c.034-.072.072-.18.085-.238s.024-.2.024-.316c0-.123-.009-.25-.024-.308a1.4 1.4 0 0 0-.072-.202c-.032-.07-.275-.39-.737-.975-.378-.479-.687-.883-.687-.9s.018-.043.04-.055.197-.11.39-.215c.194-.103.431-.237.528-.295.096-.058.22-.15.274-.204a1.1 1.1 0 0 0 .257-.459c.026-.1.031-.247.04-1.283.005-.642.016-1.178.023-1.19s.105-.069.22-.125c.112-.058.284-.15.38-.204a10 10 0 0 0 .985-.668 6.762 6.762 0 0 0 .826-.767c.107-.117.267-.305.358-.418a8 8 0 0 0 .605-.891 8.9 8.9 0 0 0 .373-.756c.045-.105.12-.308.17-.448a8 8 0 0 0 .156-.536c.037-.155.088-.408.113-.563.023-.155.05-.381.061-.505a8 8 0 0 0-.007-1.139 8 8 0 0 0-.07-.527 8 8 0 0 0-.097-.466c-.028-.116-.08-.3-.116-.413a7 7 0 0 0-.83-1.714 10 10 0 0 0-.256-.37 9 9 0 0 0-.23-.29 9 9 0 0 0-.81-.82 9 9 0 0 0-.395-.32 9 9 0 0 0-.835-.556 13 13 0 0 0-.417-.221 11 11 0 0 0-.483-.223 8 8 0 0 0-.98-.343 11 11 0 0 0-.422-.108c-.106-.022-.288-.06-.404-.079a10 10 0 0 0-.51-.073 8 8 0 0 0-.852-.043c-.304-.001-.644.002-.756.011m.207 3.334-.058.006a4.6 4.6 0 0 0-1.283.341 4 4 0 0 0-.334.159 4.354 4.354 0 0 0-.668.452 5.5 5.5 0 0 0-.669.69 5 5 0 0 0-.207.308 4 4 0 0 0-.18.325c-.04.088-.101.234-.135.325a3.856 3.856 0 0 0-.177.66c-.016.087-.034.24-.04.342-.01.159-.008.19.017.215.028.03.25.031 4.175.031 3.663 0 4.15-.003 4.174-.026q.029-.027.028-.12a3 3 0 0 0-.072-.574 3.9 3.9 0 0 0-.297-.87 4 4 0 0 0-.21-.379 6 6 0 0 0-.23-.316 6 6 0 0 0-.346-.37 5 5 0 0 0-.365-.326 7 7 0 0 0-.246-.178 5 5 0 0 0-.264-.16 4.6 4.6 0 0 0-1.585-.52 5.681 5.681 0 0 0-.84-.035z", "clip-rule": "evenodd" })] }));
23
- const passkeyIconError = (jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "43", height: "48", fill: "none", children: [jsxRuntime.jsx("path", { fill: "var(--error-color)", "fill-rule": "evenodd", d: "M27.52 37.06a6.8 6.8 0 0 0-2.02-.31H12a6.75 6.75 0 0 0-6.75 6.75V48H.75v-4.5A11.25 11.25 0 0 1 12 32.25h13.5c.68 0 1.355.062 2.016.182zm4.698-23.74a13.5 13.5 0 1 0-8.503 13.484c-.057-.178-.131-.425-.167-.566a13 13 0 0 1-.229-1.134 12 12 0 0 1-.054-.448q-.02-.202-.013-1.064c.007-.82.01-.877.055-1.186.018-.121.046-.29.072-.438a9 9 0 1 1 4.315-6.714 13.83 13.83 0 0 1 .87-.564 14 14 0 0 1 1.08-.556c.102-.045.299-.128.44-.184.14-.056.384-.146.544-.202.16-.055.436-.141.615-.194.18-.05.467-.125.641-.165.092-.02.214-.046.334-.07", "clip-rule": "evenodd" }), jsxRuntime.jsx("path", { fill: "var(--error-color)", "fill-rule": "evenodd", d: "M33.844 16.554a9.563 9.563 0 0 0-.975.134c-.125.022-.355.075-.51.114s-.418.12-.589.177a11 11 0 0 0-.553.21 12 12 0 0 0-.519.244 8.29 8.29 0 0 0-.961.573c-.114.08-.313.23-.445.334-.13.104-.358.31-.507.454a10 10 0 0 0-.466.495c-.107.127-.269.334-.362.46-.091.128-.232.34-.313.474-.079.133-.195.34-.256.46-.062.122-.15.308-.196.413a10 10 0 0 0-.152.387c-.04.107-.1.304-.14.44a9 9 0 0 0-.119.51c-.028.145-.065.374-.082.51a6 6 0 0 0-.032.773c-.002.327.007.598.021.712a8.924 8.924 0 0 0 .163.905c.03.116.09.322.134.457.046.136.125.35.178.475a8 8 0 0 0 .725 1.329 9.15 9.15 0 0 0 .622.772c.111.121.294.306.408.41.114.101.295.256.4.342.108.085.273.211.37.28.097.068.244.165.325.218l.299.179c.082.047.251.137.374.2.125.062.232.127.24.146.013.025.018 2.403.018 7.032 0 5.905.004 7.018.025 7.125.014.07.047.18.075.24.029.064.08.156.113.203.032.05.522.654 1.086 1.345.564.693 1.07 1.31 1.123 1.371.054.063.14.151.195.195.054.042.162.111.239.151s.204.092.281.115c.121.035.181.04.413.04.206 0 .3-.007.387-.03a2 2 0 0 0 .237-.09 1.8 1.8 0 0 0 .388-.25c.029-.029.547-.657 1.153-1.397a97 97 0 0 0 1.12-1.383.4.4 0 0 0 .019-.137c0-.053-.016-.178-.035-.276a5 5 0 0 0-.273-.876 24 24 0 0 0-.298-.73 32 32 0 0 0-.626-1.365.8.8 0 0 1-.069-.172q.001-.033.041-.043c.021-.003.134-.016.25-.026s.295-.032.395-.046c.102-.016.248-.044.325-.065a.9.9 0 0 0 .237-.102.8.8 0 0 0 .15-.133c.028-.037.073-.116.1-.174.026-.058.054-.16.065-.229a1.895 1.895 0 0 0-.042-.589 2 2 0 0 0-.074-.193c-.023-.053-.355-.542-.736-1.085-.38-.543-.693-1.005-.693-1.025 0-.028.037-.046.234-.105.128-.04.339-.113.469-.162.132-.047.293-.116.36-.15a1 1 0 0 0 .204-.144.8.8 0 0 0 .144-.212c.034-.072.072-.18.085-.238s.024-.2.024-.316c0-.123-.009-.25-.024-.308a1.4 1.4 0 0 0-.072-.202c-.032-.07-.275-.39-.737-.975-.378-.479-.687-.883-.687-.9s.018-.043.04-.055.197-.11.39-.215c.194-.103.431-.237.528-.295.096-.058.22-.15.274-.204a1.1 1.1 0 0 0 .257-.459c.026-.1.031-.247.04-1.283.005-.642.016-1.178.023-1.19s.105-.069.22-.125c.112-.058.284-.15.38-.204a10 10 0 0 0 .985-.668 6.762 6.762 0 0 0 .826-.767c.107-.117.267-.305.358-.418a8 8 0 0 0 .605-.891 8.9 8.9 0 0 0 .373-.756c.045-.105.12-.308.17-.448a8 8 0 0 0 .156-.536c.037-.155.088-.408.113-.563.023-.155.05-.381.061-.505a8 8 0 0 0-.007-1.139 8 8 0 0 0-.07-.527 8 8 0 0 0-.097-.466c-.028-.116-.08-.3-.116-.413a7 7 0 0 0-.83-1.714 10 10 0 0 0-.256-.37 9 9 0 0 0-.23-.29 9 9 0 0 0-.81-.82 9 9 0 0 0-.395-.32 9 9 0 0 0-.835-.556 13 13 0 0 0-.417-.221 11 11 0 0 0-.483-.223 8 8 0 0 0-.98-.343 11 11 0 0 0-.422-.108c-.106-.022-.288-.06-.404-.079a10 10 0 0 0-.51-.073 8 8 0 0 0-.852-.043c-.304-.001-.644.002-.756.011m.207 3.334-.058.006a4.6 4.6 0 0 0-1.283.341 4 4 0 0 0-.334.159 4.354 4.354 0 0 0-.668.452 5.5 5.5 0 0 0-.669.69 5 5 0 0 0-.207.308 4 4 0 0 0-.18.325c-.04.088-.101.234-.135.325a3.856 3.856 0 0 0-.177.66c-.016.087-.034.24-.04.342-.01.159-.008.19.017.215.028.03.25.031 4.175.031 3.663 0 4.15-.003 4.174-.026q.029-.027.028-.12a3 3 0 0 0-.072-.574 3.9 3.9 0 0 0-.297-.87 4 4 0 0 0-.21-.379 6 6 0 0 0-.23-.316 6 6 0 0 0-.346-.37 5 5 0 0 0-.365-.326 7 7 0 0 0-.246-.178 5 5 0 0 0-.264-.16 4.6 4.6 0 0 0-1.585-.52 5.681 5.681 0 0 0-.84-.035z", "clip-rule": "evenodd" })] }));
24
- const Auth = ({ onAuthSuccess, onError, authConfig, configOrder, customSmsMessage, customAccounts, }) => {
25
- const { passkeyClient, authIframeClient } = useTurnkey.useTurnkey();
26
- const [email, setEmail] = React.useState("");
27
- const [phone, setPhone] = React.useState("");
28
- const [otpId, setOtpId] = React.useState(null);
29
- const [step, setStep] = React.useState("auth");
30
- const [oauthLoading, setOauthLoading] = React.useState("");
31
- const [suborgId, setSuborgId] = React.useState("");
32
- const [passkeySignupScreen, setPasskeySignupScreen] = React.useState(false);
33
- const [passkeyCreationScreen, setPasskeyCreationScreen] = React.useState(false);
34
- const [passkeySignupError, setPasskeySignupError] = React.useState("");
35
- const [loading, setLoading] = React.useState(true);
36
- const [passkeyCreated, setPasskeyCreated] = React.useState(false);
37
- const handleResendCode = async () => {
38
- if (step === constants.OtpType.Email) {
39
- await handleOtpLogin(constants.FilterType.Email, email, constants.OtpType.Email);
40
- }
41
- else if (step === constants.OtpType.Sms) {
42
- await handleOtpLogin(constants.FilterType.PhoneNumber, phone, constants.OtpType.Sms);
43
- }
44
- };
45
- React.useEffect(() => {
46
- if (authIframeClient) {
47
- setLoading(false);
48
- }
49
- }, [authIframeClient]);
50
- if (loading) {
51
- return (jsxRuntime.jsx("div", { className: Auth_module.defaultLoader, children: jsxRuntime.jsx(material.CircularProgress, { size: 80, thickness: 1, className: Auth_module.circularProgress }) }));
22
+ const passkeyIcon = jsxRuntime.jsxs("svg", {
23
+ xmlns: "http://www.w3.org/2000/svg",
24
+ width: "43",
25
+ height: "48",
26
+ fill: "none",
27
+ children: [jsxRuntime.jsx("path", {
28
+ fill: "var(--icon-color)",
29
+ "fill-rule": "evenodd",
30
+ d: "M27.52 37.06a6.8 6.8 0 0 0-2.02-.31H12a6.75 6.75 0 0 0-6.75 6.75V48H.75v-4.5A11.25 11.25 0 0 1 12 32.25h13.5c.68 0 1.355.062 2.016.182zm4.698-23.74a13.5 13.5 0 1 0-8.503 13.484c-.057-.178-.131-.425-.167-.566a13 13 0 0 1-.229-1.134 12 12 0 0 1-.054-.448q-.02-.202-.013-1.064c.007-.82.01-.877.055-1.186.018-.121.046-.29.072-.438a9 9 0 1 1 4.315-6.714 13.83 13.83 0 0 1 .87-.564 14 14 0 0 1 1.08-.556c.102-.045.299-.128.44-.184.14-.056.384-.146.544-.202.16-.055.436-.141.615-.194.18-.05.467-.125.641-.165.092-.02.214-.046.334-.07",
31
+ "clip-rule": "evenodd"
32
+ }), jsxRuntime.jsx("path", {
33
+ fill: "var(--icon-color)",
34
+ "fill-rule": "evenodd",
35
+ d: "M33.844 16.554a9.563 9.563 0 0 0-.975.134c-.125.022-.355.075-.51.114s-.418.12-.589.177a11 11 0 0 0-.553.21 12 12 0 0 0-.519.244 8.29 8.29 0 0 0-.961.573c-.114.08-.313.23-.445.334-.13.104-.358.31-.507.454a10 10 0 0 0-.466.495c-.107.127-.269.334-.362.46-.091.128-.232.34-.313.474-.079.133-.195.34-.256.46-.062.122-.15.308-.196.413a10 10 0 0 0-.152.387c-.04.107-.1.304-.14.44a9 9 0 0 0-.119.51c-.028.145-.065.374-.082.51a6 6 0 0 0-.032.773c-.002.327.007.598.021.712a8.924 8.924 0 0 0 .163.905c.03.116.09.322.134.457.046.136.125.35.178.475a8 8 0 0 0 .725 1.329 9.15 9.15 0 0 0 .622.772c.111.121.294.306.408.41.114.101.295.256.4.342.108.085.273.211.37.28.097.068.244.165.325.218l.299.179c.082.047.251.137.374.2.125.062.232.127.24.146.013.025.018 2.403.018 7.032 0 5.905.004 7.018.025 7.125.014.07.047.18.075.24.029.064.08.156.113.203.032.05.522.654 1.086 1.345.564.693 1.07 1.31 1.123 1.371.054.063.14.151.195.195.054.042.162.111.239.151s.204.092.281.115c.121.035.181.04.413.04.206 0 .3-.007.387-.03a2 2 0 0 0 .237-.09 1.8 1.8 0 0 0 .388-.25c.029-.029.547-.657 1.153-1.397a97 97 0 0 0 1.12-1.383.4.4 0 0 0 .019-.137c0-.053-.016-.178-.035-.276a5 5 0 0 0-.273-.876 24 24 0 0 0-.298-.73 32 32 0 0 0-.626-1.365.8.8 0 0 1-.069-.172q.001-.033.041-.043c.021-.003.134-.016.25-.026s.295-.032.395-.046c.102-.016.248-.044.325-.065a.9.9 0 0 0 .237-.102.8.8 0 0 0 .15-.133c.028-.037.073-.116.1-.174.026-.058.054-.16.065-.229a1.895 1.895 0 0 0-.042-.589 2 2 0 0 0-.074-.193c-.023-.053-.355-.542-.736-1.085-.38-.543-.693-1.005-.693-1.025 0-.028.037-.046.234-.105.128-.04.339-.113.469-.162.132-.047.293-.116.36-.15a1 1 0 0 0 .204-.144.8.8 0 0 0 .144-.212c.034-.072.072-.18.085-.238s.024-.2.024-.316c0-.123-.009-.25-.024-.308a1.4 1.4 0 0 0-.072-.202c-.032-.07-.275-.39-.737-.975-.378-.479-.687-.883-.687-.9s.018-.043.04-.055.197-.11.39-.215c.194-.103.431-.237.528-.295.096-.058.22-.15.274-.204a1.1 1.1 0 0 0 .257-.459c.026-.1.031-.247.04-1.283.005-.642.016-1.178.023-1.19s.105-.069.22-.125c.112-.058.284-.15.38-.204a10 10 0 0 0 .985-.668 6.762 6.762 0 0 0 .826-.767c.107-.117.267-.305.358-.418a8 8 0 0 0 .605-.891 8.9 8.9 0 0 0 .373-.756c.045-.105.12-.308.17-.448a8 8 0 0 0 .156-.536c.037-.155.088-.408.113-.563.023-.155.05-.381.061-.505a8 8 0 0 0-.007-1.139 8 8 0 0 0-.07-.527 8 8 0 0 0-.097-.466c-.028-.116-.08-.3-.116-.413a7 7 0 0 0-.83-1.714 10 10 0 0 0-.256-.37 9 9 0 0 0-.23-.29 9 9 0 0 0-.81-.82 9 9 0 0 0-.395-.32 9 9 0 0 0-.835-.556 13 13 0 0 0-.417-.221 11 11 0 0 0-.483-.223 8 8 0 0 0-.98-.343 11 11 0 0 0-.422-.108c-.106-.022-.288-.06-.404-.079a10 10 0 0 0-.51-.073 8 8 0 0 0-.852-.043c-.304-.001-.644.002-.756.011m.207 3.334-.058.006a4.6 4.6 0 0 0-1.283.341 4 4 0 0 0-.334.159 4.354 4.354 0 0 0-.668.452 5.5 5.5 0 0 0-.669.69 5 5 0 0 0-.207.308 4 4 0 0 0-.18.325c-.04.088-.101.234-.135.325a3.856 3.856 0 0 0-.177.66c-.016.087-.034.24-.04.342-.01.159-.008.19.017.215.028.03.25.031 4.175.031 3.663 0 4.15-.003 4.174-.026q.029-.027.028-.12a3 3 0 0 0-.072-.574 3.9 3.9 0 0 0-.297-.87 4 4 0 0 0-.21-.379 6 6 0 0 0-.23-.316 6 6 0 0 0-.346-.37 5 5 0 0 0-.365-.326 7 7 0 0 0-.246-.178 5 5 0 0 0-.264-.16 4.6 4.6 0 0 0-1.585-.52 5.681 5.681 0 0 0-.84-.035z",
36
+ "clip-rule": "evenodd"
37
+ })]
38
+ });
39
+ const passkeyIconError = jsxRuntime.jsxs("svg", {
40
+ xmlns: "http://www.w3.org/2000/svg",
41
+ width: "43",
42
+ height: "48",
43
+ fill: "none",
44
+ children: [jsxRuntime.jsx("path", {
45
+ fill: "var(--error-color)",
46
+ "fill-rule": "evenodd",
47
+ d: "M27.52 37.06a6.8 6.8 0 0 0-2.02-.31H12a6.75 6.75 0 0 0-6.75 6.75V48H.75v-4.5A11.25 11.25 0 0 1 12 32.25h13.5c.68 0 1.355.062 2.016.182zm4.698-23.74a13.5 13.5 0 1 0-8.503 13.484c-.057-.178-.131-.425-.167-.566a13 13 0 0 1-.229-1.134 12 12 0 0 1-.054-.448q-.02-.202-.013-1.064c.007-.82.01-.877.055-1.186.018-.121.046-.29.072-.438a9 9 0 1 1 4.315-6.714 13.83 13.83 0 0 1 .87-.564 14 14 0 0 1 1.08-.556c.102-.045.299-.128.44-.184.14-.056.384-.146.544-.202.16-.055.436-.141.615-.194.18-.05.467-.125.641-.165.092-.02.214-.046.334-.07",
48
+ "clip-rule": "evenodd"
49
+ }), jsxRuntime.jsx("path", {
50
+ fill: "var(--error-color)",
51
+ "fill-rule": "evenodd",
52
+ d: "M33.844 16.554a9.563 9.563 0 0 0-.975.134c-.125.022-.355.075-.51.114s-.418.12-.589.177a11 11 0 0 0-.553.21 12 12 0 0 0-.519.244 8.29 8.29 0 0 0-.961.573c-.114.08-.313.23-.445.334-.13.104-.358.31-.507.454a10 10 0 0 0-.466.495c-.107.127-.269.334-.362.46-.091.128-.232.34-.313.474-.079.133-.195.34-.256.46-.062.122-.15.308-.196.413a10 10 0 0 0-.152.387c-.04.107-.1.304-.14.44a9 9 0 0 0-.119.51c-.028.145-.065.374-.082.51a6 6 0 0 0-.032.773c-.002.327.007.598.021.712a8.924 8.924 0 0 0 .163.905c.03.116.09.322.134.457.046.136.125.35.178.475a8 8 0 0 0 .725 1.329 9.15 9.15 0 0 0 .622.772c.111.121.294.306.408.41.114.101.295.256.4.342.108.085.273.211.37.28.097.068.244.165.325.218l.299.179c.082.047.251.137.374.2.125.062.232.127.24.146.013.025.018 2.403.018 7.032 0 5.905.004 7.018.025 7.125.014.07.047.18.075.24.029.064.08.156.113.203.032.05.522.654 1.086 1.345.564.693 1.07 1.31 1.123 1.371.054.063.14.151.195.195.054.042.162.111.239.151s.204.092.281.115c.121.035.181.04.413.04.206 0 .3-.007.387-.03a2 2 0 0 0 .237-.09 1.8 1.8 0 0 0 .388-.25c.029-.029.547-.657 1.153-1.397a97 97 0 0 0 1.12-1.383.4.4 0 0 0 .019-.137c0-.053-.016-.178-.035-.276a5 5 0 0 0-.273-.876 24 24 0 0 0-.298-.73 32 32 0 0 0-.626-1.365.8.8 0 0 1-.069-.172q.001-.033.041-.043c.021-.003.134-.016.25-.026s.295-.032.395-.046c.102-.016.248-.044.325-.065a.9.9 0 0 0 .237-.102.8.8 0 0 0 .15-.133c.028-.037.073-.116.1-.174.026-.058.054-.16.065-.229a1.895 1.895 0 0 0-.042-.589 2 2 0 0 0-.074-.193c-.023-.053-.355-.542-.736-1.085-.38-.543-.693-1.005-.693-1.025 0-.028.037-.046.234-.105.128-.04.339-.113.469-.162.132-.047.293-.116.36-.15a1 1 0 0 0 .204-.144.8.8 0 0 0 .144-.212c.034-.072.072-.18.085-.238s.024-.2.024-.316c0-.123-.009-.25-.024-.308a1.4 1.4 0 0 0-.072-.202c-.032-.07-.275-.39-.737-.975-.378-.479-.687-.883-.687-.9s.018-.043.04-.055.197-.11.39-.215c.194-.103.431-.237.528-.295.096-.058.22-.15.274-.204a1.1 1.1 0 0 0 .257-.459c.026-.1.031-.247.04-1.283.005-.642.016-1.178.023-1.19s.105-.069.22-.125c.112-.058.284-.15.38-.204a10 10 0 0 0 .985-.668 6.762 6.762 0 0 0 .826-.767c.107-.117.267-.305.358-.418a8 8 0 0 0 .605-.891 8.9 8.9 0 0 0 .373-.756c.045-.105.12-.308.17-.448a8 8 0 0 0 .156-.536c.037-.155.088-.408.113-.563.023-.155.05-.381.061-.505a8 8 0 0 0-.007-1.139 8 8 0 0 0-.07-.527 8 8 0 0 0-.097-.466c-.028-.116-.08-.3-.116-.413a7 7 0 0 0-.83-1.714 10 10 0 0 0-.256-.37 9 9 0 0 0-.23-.29 9 9 0 0 0-.81-.82 9 9 0 0 0-.395-.32 9 9 0 0 0-.835-.556 13 13 0 0 0-.417-.221 11 11 0 0 0-.483-.223 8 8 0 0 0-.98-.343 11 11 0 0 0-.422-.108c-.106-.022-.288-.06-.404-.079a10 10 0 0 0-.51-.073 8 8 0 0 0-.852-.043c-.304-.001-.644.002-.756.011m.207 3.334-.058.006a4.6 4.6 0 0 0-1.283.341 4 4 0 0 0-.334.159 4.354 4.354 0 0 0-.668.452 5.5 5.5 0 0 0-.669.69 5 5 0 0 0-.207.308 4 4 0 0 0-.18.325c-.04.088-.101.234-.135.325a3.856 3.856 0 0 0-.177.66c-.016.087-.034.24-.04.342-.01.159-.008.19.017.215.028.03.25.031 4.175.031 3.663 0 4.15-.003 4.174-.026q.029-.027.028-.12a3 3 0 0 0-.072-.574 3.9 3.9 0 0 0-.297-.87 4 4 0 0 0-.21-.379 6 6 0 0 0-.23-.316 6 6 0 0 0-.346-.37 5 5 0 0 0-.365-.326 7 7 0 0 0-.246-.178 5 5 0 0 0-.264-.16 4.6 4.6 0 0 0-1.585-.52 5.681 5.681 0 0 0-.84-.035z",
53
+ "clip-rule": "evenodd"
54
+ })]
55
+ });
56
+ const Auth = ({
57
+ onAuthSuccess,
58
+ onError,
59
+ authConfig,
60
+ configOrder,
61
+ customSmsMessage,
62
+ customAccounts
63
+ }) => {
64
+ const {
65
+ passkeyClient,
66
+ authIframeClient,
67
+ turnkey: turnkey$1
68
+ } = useTurnkey.useTurnkey();
69
+ const [email, setEmail] = React.useState("");
70
+ const [phone, setPhone] = React.useState("");
71
+ const [otpId, setOtpId] = React.useState(null);
72
+ const [step, setStep] = React.useState("auth");
73
+ const [oauthLoading, setOauthLoading] = React.useState("");
74
+ const [suborgId, setSuborgId] = React.useState("");
75
+ const [passkeySignupScreen, setPasskeySignupScreen] = React.useState(false);
76
+ const [passkeyCreationScreen, setPasskeyCreationScreen] = React.useState(false);
77
+ const [passkeySignupError, setPasskeySignupError] = React.useState("");
78
+ const [loading, setLoading] = React.useState(true);
79
+ const [passkeyCreated, setPasskeyCreated] = React.useState(false);
80
+ const handleResendCode = async () => {
81
+ if (step === constants.OtpType.Email) {
82
+ await handleOtpLogin(constants.FilterType.Email, email, constants.OtpType.Email);
83
+ } else if (step === constants.OtpType.Sms) {
84
+ await handleOtpLogin(constants.FilterType.PhoneNumber, phone, constants.OtpType.Sms);
52
85
  }
53
- const isValidEmail = (email) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
54
- const isValidPhone = (phone) => /^\+1\d{10}$/.test(phone);
55
- const handleGetOrCreateSuborg = async (filterType, filterValue, additionalData = {}) => {
56
- let suborgId;
57
- if (filterType == constants.FilterType.Email ||
58
- filterType == constants.FilterType.PhoneNumber) {
59
- const getVerifiedSuborgsResponse = await sdkServer.server.getVerifiedSuborgs({
60
- filterType,
61
- filterValue,
62
- });
63
- if (!getVerifiedSuborgsResponse ||
64
- !getVerifiedSuborgsResponse.organizationIds) {
65
- onError(constants.authErrors.suborg.fetchFailed);
66
- }
67
- suborgId = getVerifiedSuborgsResponse?.organizationIds[0];
68
- }
69
- else {
70
- const getSuborgsResponse = await sdkServer.server.getSuborgs({
71
- filterType,
72
- filterValue,
73
- });
74
- if (!getSuborgsResponse || !getSuborgsResponse.organizationIds) {
75
- onError(constants.authErrors.suborg.fetchFailed);
76
- }
77
- suborgId = getSuborgsResponse?.organizationIds[0];
78
- }
79
- if (!suborgId) {
80
- const createSuborgData = { ...additionalData };
81
- if (filterType === constants.FilterType.Email)
82
- createSuborgData.email = filterValue;
83
- else if (filterType === constants.FilterType.PhoneNumber)
84
- createSuborgData.phoneNumber = filterValue;
85
- if (customAccounts) {
86
- createSuborgData.customAccounts = customAccounts;
87
- }
88
- const createSuborgResponse = await sdkServer.server.createSuborg(createSuborgData);
89
- if (!createSuborgResponse || !createSuborgResponse.subOrganizationId) {
90
- onError(constants.authErrors.suborg.createFailed);
91
- }
92
- suborgId = createSuborgResponse?.subOrganizationId;
93
- }
94
- return suborgId;
95
- };
96
- const handleAuthSuccess = async (credentialBundle) => {
97
- if (credentialBundle) {
98
- await authIframeClient.injectCredentialBundle(credentialBundle);
99
- await authIframeClient.loginWithAuthBundle(credentialBundle);
100
- await onAuthSuccess();
101
- }
102
- };
103
- const handleSignupWithPasskey = async () => {
104
- setPasskeySignupError("");
105
- const siteInfo = `${new URL(window.location.href).hostname} - ${new Date().toLocaleString(undefined, {
106
- year: "numeric",
107
- month: "long",
108
- day: "numeric",
109
- hour: "2-digit",
110
- minute: "2-digit",
111
- second: "2-digit",
112
- })}`;
113
- setPasskeySignupScreen(false);
114
- setPasskeyCreationScreen(true);
115
- try {
116
- if (!passkeyCreated) {
117
- const { encodedChallenge, attestation } = (await passkeyClient?.createUserPasskey({
118
- publicKey: { user: { name: siteInfo, displayName: siteInfo } },
119
- })) || {};
120
- if (encodedChallenge && attestation) {
121
- const response = await sdkServer.server.createSuborg({
122
- email,
123
- passkey: {
124
- authenticatorName: "First Passkey",
125
- challenge: encodedChallenge,
126
- attestation,
127
- },
128
- ...(customAccounts && { customAccounts }),
129
- });
130
- if (response?.subOrganizationId) {
131
- setPasskeyCreated(true);
132
- }
133
- else {
134
- constants.authErrors.passkey.createFailed;
135
- }
136
- }
137
- else {
138
- constants.authErrors.passkey.createFailed;
139
- }
140
- }
141
- const sessionResponse = await passkeyClient?.createReadWriteSession({
142
- targetPublicKey: authIframeClient?.iframePublicKey,
143
- organizationId: process.env.NEXT_PUBLIC_ORGANIZATION_ID,
144
- });
145
- if (sessionResponse?.credentialBundle) {
146
- await handleAuthSuccess(sessionResponse.credentialBundle);
147
- }
148
- else {
149
- setPasskeySignupError(constants.authErrors.passkey.loginFailed);
150
- }
151
- }
152
- catch {
153
- setPasskeySignupError(constants.authErrors.passkey.timeoutOrNotAllowed);
154
- }
155
- };
156
- const handleLoginWithPasskey = async () => {
157
- try {
158
- const sessionResponse = await passkeyClient?.createReadWriteSession({
159
- targetPublicKey: authIframeClient?.iframePublicKey,
160
- organizationId: process.env.NEXT_PUBLIC_ORGANIZATION_ID,
161
- });
162
- if (sessionResponse?.credentialBundle) {
163
- await handleAuthSuccess(sessionResponse.credentialBundle);
164
- }
165
- else {
166
- constants.authErrors.passkey.loginFailed;
86
+ };
87
+ React.useEffect(() => {
88
+ if (authIframeClient) {
89
+ setLoading(false);
90
+ }
91
+ }, [authIframeClient]);
92
+ if (loading) {
93
+ return jsxRuntime.jsx("div", {
94
+ className: Auth_module.defaultLoader,
95
+ children: jsxRuntime.jsx(material.CircularProgress, {
96
+ size: 80,
97
+ thickness: 1,
98
+ className: Auth_module.circularProgress
99
+ })
100
+ });
101
+ }
102
+ const isValidEmail = email => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
103
+ const isValidPhone = phone => /^\+1\d{10}$/.test(phone);
104
+ const handleGetOrCreateSuborg = async (filterType, filterValue, additionalData = {}) => {
105
+ let suborgId;
106
+ if (filterType == constants.FilterType.Email || filterType == constants.FilterType.PhoneNumber) {
107
+ const getVerifiedSuborgsResponse = await sdkServer.server.getVerifiedSuborgs({
108
+ filterType,
109
+ filterValue
110
+ });
111
+ if (!getVerifiedSuborgsResponse || !getVerifiedSuborgsResponse.organizationIds) {
112
+ onError(constants.authErrors.suborg.fetchFailed);
113
+ }
114
+ suborgId = getVerifiedSuborgsResponse?.organizationIds[0];
115
+ } else {
116
+ const getSuborgsResponse = await sdkServer.server.getSuborgs({
117
+ filterType,
118
+ filterValue
119
+ });
120
+ if (!getSuborgsResponse || !getSuborgsResponse.organizationIds) {
121
+ onError(constants.authErrors.suborg.fetchFailed);
122
+ }
123
+ suborgId = getSuborgsResponse?.organizationIds[0];
124
+ }
125
+ if (!suborgId) {
126
+ const createSuborgData = {
127
+ ...additionalData
128
+ };
129
+ if (filterType === constants.FilterType.Email) createSuborgData.email = filterValue;else if (filterType === constants.FilterType.PhoneNumber) createSuborgData.phoneNumber = filterValue;
130
+ if (customAccounts) {
131
+ createSuborgData.customAccounts = customAccounts;
132
+ }
133
+ const createSuborgResponse = await sdkServer.server.createSuborg(createSuborgData);
134
+ if (!createSuborgResponse || !createSuborgResponse.subOrganizationId) {
135
+ onError(constants.authErrors.suborg.createFailed);
136
+ }
137
+ suborgId = createSuborgResponse?.subOrganizationId;
138
+ }
139
+ return suborgId;
140
+ };
141
+ const handleAuthSuccess = async credentialBundle => {
142
+ if (credentialBundle) {
143
+ await authIframeClient.injectCredentialBundle(credentialBundle);
144
+ await authIframeClient.loginWithAuthBundle(credentialBundle);
145
+ await onAuthSuccess();
146
+ }
147
+ };
148
+ const handleSignupWithPasskey = async () => {
149
+ setPasskeySignupError("");
150
+ const siteInfo = `${new URL(window.location.href).hostname} - ${new Date().toLocaleString(undefined, {
151
+ year: "numeric",
152
+ month: "long",
153
+ day: "numeric",
154
+ hour: "2-digit",
155
+ minute: "2-digit",
156
+ second: "2-digit"
157
+ })}`;
158
+ setPasskeySignupScreen(false);
159
+ setPasskeyCreationScreen(true);
160
+ try {
161
+ if (!passkeyCreated) {
162
+ const {
163
+ encodedChallenge,
164
+ attestation
165
+ } = (await passkeyClient?.createUserPasskey({
166
+ publicKey: {
167
+ user: {
168
+ name: siteInfo,
169
+ displayName: siteInfo
167
170
  }
171
+ }
172
+ })) || {};
173
+ if (encodedChallenge && attestation) {
174
+ const response = await sdkServer.server.createSuborg({
175
+ email,
176
+ passkey: {
177
+ authenticatorName: "First Passkey",
178
+ challenge: encodedChallenge,
179
+ attestation
180
+ },
181
+ ...(customAccounts && {
182
+ customAccounts
183
+ })
184
+ });
185
+ if (response?.subOrganizationId) {
186
+ setPasskeyCreated(true);
187
+ } else {
188
+ constants.authErrors.passkey.createFailed;
189
+ }
190
+ } else {
191
+ constants.authErrors.passkey.createFailed;
168
192
  }
169
- catch (error) {
170
- onError(constants.authErrors.passkey.loginFailed);
171
- }
172
- };
173
- const handleOtpLogin = async (type, value, otpType) => {
174
- const suborgId = await handleGetOrCreateSuborg(type, value);
175
- const initAuthResponse = await sdkServer.server.sendOtp({
176
- suborgID: suborgId,
177
- otpType,
178
- contact: value,
179
- ...(customSmsMessage && { customSmsMessage }),
180
- userIdentifier: authIframeClient?.iframePublicKey,
181
- });
182
- if (initAuthResponse && initAuthResponse.otpId) {
183
- setSuborgId(suborgId);
184
- setOtpId(initAuthResponse?.otpId);
185
- setStep(otpType);
186
- }
187
- else {
188
- onError(constants.authErrors.otp.sendFailed);
189
- }
190
- };
191
- const handleOAuthLogin = async (credential, providerName) => {
192
- setOauthLoading(providerName);
193
- const suborgId = await handleGetOrCreateSuborg(constants.FilterType.OidcToken, credential, {
194
- oauthProviders: [{ providerName, oidcToken: credential }],
195
- });
196
- const oauthResponse = await sdkServer.server.oauth({
197
- suborgID: suborgId,
198
- oidcToken: credential,
199
- targetPublicKey: authIframeClient?.iframePublicKey,
193
+ }
194
+ const sessionResponse = await passkeyClient?.createReadWriteSession({
195
+ targetPublicKey: authIframeClient?.iframePublicKey,
196
+ organizationId: turnkey$1?.config.defaultOrganizationId ?? process.env.NEXT_PUBLIC_ORGANIZATION_ID
197
+ });
198
+ if (sessionResponse?.credentialBundle) {
199
+ await handleAuthSuccess(sessionResponse.credentialBundle);
200
+ } else {
201
+ setPasskeySignupError(constants.authErrors.passkey.loginFailed);
202
+ }
203
+ } catch {
204
+ setPasskeySignupError(constants.authErrors.passkey.timeoutOrNotAllowed);
205
+ }
206
+ };
207
+ const handleLoginWithPasskey = async () => {
208
+ try {
209
+ const sessionResponse = await passkeyClient?.createReadWriteSession({
210
+ targetPublicKey: authIframeClient?.iframePublicKey,
211
+ organizationId: turnkey$1?.config.defaultOrganizationId ?? process.env.NEXT_PUBLIC_ORGANIZATION_ID
212
+ });
213
+ if (sessionResponse?.credentialBundle) {
214
+ await handleAuthSuccess(sessionResponse.credentialBundle);
215
+ } else {
216
+ constants.authErrors.passkey.loginFailed;
217
+ }
218
+ } catch (error) {
219
+ onError(constants.authErrors.passkey.loginFailed);
220
+ }
221
+ };
222
+ const handleOtpLogin = async (type, value, otpType) => {
223
+ const suborgId = await handleGetOrCreateSuborg(type, value);
224
+ const initAuthResponse = await sdkServer.server.sendOtp({
225
+ suborgID: suborgId,
226
+ otpType,
227
+ contact: value,
228
+ ...(customSmsMessage && {
229
+ customSmsMessage
230
+ }),
231
+ userIdentifier: authIframeClient?.iframePublicKey
232
+ });
233
+ if (initAuthResponse && initAuthResponse.otpId) {
234
+ setSuborgId(suborgId);
235
+ setOtpId(initAuthResponse?.otpId);
236
+ setStep(otpType);
237
+ } else {
238
+ onError(constants.authErrors.otp.sendFailed);
239
+ }
240
+ };
241
+ const handleOAuthLogin = async (credential, providerName) => {
242
+ setOauthLoading(providerName);
243
+ const suborgId = await handleGetOrCreateSuborg(constants.FilterType.OidcToken, credential, {
244
+ oauthProviders: [{
245
+ providerName,
246
+ oidcToken: credential
247
+ }]
248
+ });
249
+ const oauthResponse = await sdkServer.server.oauth({
250
+ suborgID: suborgId,
251
+ oidcToken: credential,
252
+ targetPublicKey: authIframeClient?.iframePublicKey,
253
+ sessionLengthSeconds: authConfig.sessionLengthSeconds
254
+ });
255
+ if (oauthResponse && oauthResponse.token) {
256
+ await handleAuthSuccess(oauthResponse.token);
257
+ } else {
258
+ onError(constants.authErrors.oauth.loginFailed);
259
+ }
260
+ };
261
+ const renderBackButton = () => jsxRuntime.jsx(ChevronLeftIcon, {
262
+ onClick: () => {
263
+ setPasskeyCreationScreen(false);
264
+ setPasskeySignupError("");
265
+ setPasskeySignupScreen(false);
266
+ setOtpId(null);
267
+ },
268
+ sx: {
269
+ color: "var(--text-secondary)",
270
+ position: "absolute",
271
+ fontSize: "24px",
272
+ top: 16,
273
+ left: 16,
274
+ zIndex: 10,
275
+ cursor: "pointer",
276
+ borderRadius: "50%",
277
+ padding: "6px",
278
+ transition: "background-color 0.3s ease"
279
+ }
280
+ });
281
+ const renderSocialButtons = () => {
282
+ const {
283
+ googleEnabled,
284
+ appleEnabled,
285
+ facebookEnabled
286
+ } = authConfig;
287
+ const layout = [googleEnabled, appleEnabled, facebookEnabled].filter(Boolean).length >= 2 ? "inline" : "stacked";
288
+ return jsxRuntime.jsxs("div", {
289
+ className: layout === "inline" ? Auth_module.socialButtonContainerInline : Auth_module.socialButtonContainerStacked,
290
+ children: [googleEnabled && jsxRuntime.jsx(Google, {
291
+ layout: layout,
292
+ clientId: authConfig.googleClientId ?? process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
293
+ iframePublicKey: authIframeClient.iframePublicKey,
294
+ onSuccess: response => handleOAuthLogin(response.idToken, "Google")
295
+ }), appleEnabled && jsxRuntime.jsx(Apple, {
296
+ layout: layout,
297
+ clientId: authConfig.appleClientId ?? process.env.NEXT_PUBLIC_APPLE_CLIENT_ID,
298
+ iframePublicKey: authIframeClient.iframePublicKey,
299
+ onSuccess: response => handleOAuthLogin(response.idToken, "Apple")
300
+ }), facebookEnabled && jsxRuntime.jsx(Facebook, {
301
+ layout: layout,
302
+ clientId: authConfig.facebookClientId ?? process.env.NEXT_PUBLIC_FACEBOOK_CLIENT_ID,
303
+ iframePublicKey: authIframeClient.iframePublicKey,
304
+ onSuccess: response => handleOAuthLogin(response.id_token, "Facebook")
305
+ })]
306
+ });
307
+ };
308
+ const renderSection = section => {
309
+ switch (section) {
310
+ case "email":
311
+ return authConfig.emailEnabled && !otpId ? jsxRuntime.jsxs("form", {
312
+ onSubmit: e => {
313
+ e.preventDefault();
314
+ handleOtpLogin(constants.FilterType.Email, email, constants.OtpType.Email);
315
+ },
316
+ children: [jsxRuntime.jsx("div", {
317
+ className: Auth_module.inputGroup,
318
+ children: jsxRuntime.jsx(material.TextField, {
319
+ name: "email-input",
320
+ type: "email",
321
+ placeholder: "Enter your email",
322
+ value: email,
323
+ onChange: e => setEmail(e.target.value),
324
+ fullWidth: true,
325
+ sx: {
326
+ "& .MuiOutlinedInput-root": {
327
+ color: "var(--input-text)",
328
+ "& fieldset": {
329
+ borderColor: "var(--input-border)"
330
+ },
331
+ "&:hover fieldset": {
332
+ borderColor: "var(--input-hover-border)"
333
+ },
334
+ "&.Mui-focused fieldset": {
335
+ borderColor: "var(--input-focus-border)",
336
+ border: "1px solid"
337
+ }
338
+ },
339
+ "& .MuiInputBase-input": {
340
+ padding: "12px"
341
+ },
342
+ backgroundColor: "var(--input-bg)"
343
+ },
344
+ variant: "outlined"
345
+ })
346
+ }), jsxRuntime.jsx("button", {
347
+ className: Auth_module.authButton,
348
+ type: "submit",
349
+ disabled: !isValidEmail(email),
350
+ children: "Continue"
351
+ })]
352
+ }) : null;
353
+ case "phone":
354
+ return authConfig.phoneEnabled && !otpId ? jsxRuntime.jsxs("form", {
355
+ onSubmit: e => {
356
+ e.preventDefault();
357
+ handleOtpLogin(constants.FilterType.PhoneNumber, phone, constants.OtpType.Sms);
358
+ },
359
+ children: [jsxRuntime.jsx("div", {
360
+ className: Auth_module.phoneInput,
361
+ children: jsxRuntime.jsx(PhoneInput.MuiPhone, {
362
+ onChange: value => setPhone(value),
363
+ value: phone
364
+ })
365
+ }), jsxRuntime.jsx("button", {
366
+ className: Auth_module.authButton,
367
+ type: "submit",
368
+ disabled: !isValidPhone(phone),
369
+ children: "Continue"
370
+ })]
371
+ }) : null;
372
+ case "passkey":
373
+ return authConfig.passkeyEnabled && !otpId ? jsxRuntime.jsxs("div", {
374
+ className: Auth_module.passkeyContainer,
375
+ children: [jsxRuntime.jsx("button", {
376
+ className: Auth_module.authButton,
377
+ type: "button",
378
+ onClick: handleLoginWithPasskey,
379
+ children: "Log in with passkey"
380
+ }), jsxRuntime.jsx("div", {
381
+ className: Auth_module.noPasskeyLink,
382
+ onClick: () => setPasskeySignupScreen(true),
383
+ children: "Sign up with passkey"
384
+ })]
385
+ }) : null;
386
+ case "socials":
387
+ return authConfig.googleEnabled || authConfig.appleEnabled || authConfig.facebookEnabled ? renderSocialButtons() : null;
388
+ default:
389
+ return null;
390
+ }
391
+ };
392
+ return jsxRuntime.jsx(jsxRuntime.Fragment, {
393
+ children: passkeySignupScreen ? jsxRuntime.jsxs("div", {
394
+ className: Auth_module.authCard,
395
+ children: [renderBackButton(), jsxRuntime.jsx("div", {
396
+ className: Auth_module.passkeyIconContainer,
397
+ children: passkeyIcon
398
+ }), jsxRuntime.jsx("center", {
399
+ children: jsxRuntime.jsx("h3", {
400
+ className: Auth_module.primaryText,
401
+ children: "Create a passkey"
402
+ })
403
+ }), jsxRuntime.jsx("div", {
404
+ className: Auth_module.rowsContainer,
405
+ children: jsxRuntime.jsx("center", {
406
+ children: jsxRuntime.jsx("span", {
407
+ className: Auth_module.primaryText,
408
+ children: "Passkeys allow for easy biometric access to your wallet and can be synced across devices."
409
+ })
410
+ })
411
+ }), jsxRuntime.jsx("button", {
412
+ className: Auth_module.authButton,
413
+ type: "button",
414
+ onClick: handleSignupWithPasskey,
415
+ children: "Continue"
416
+ })]
417
+ }) : passkeyCreationScreen ? jsxRuntime.jsxs("div", {
418
+ className: Auth_module.authCard,
419
+ children: [renderBackButton(), jsxRuntime.jsx("div", {
420
+ className: Auth_module.passkeyIconContainer,
421
+ children: passkeySignupError ? jsxRuntime.jsx("div", {
422
+ children: passkeyIconError
423
+ }) : jsxRuntime.jsxs("div", {
424
+ className: Auth_module.loadingWrapper,
425
+ children: [jsxRuntime.jsx(material.CircularProgress, {
426
+ size: 80,
427
+ thickness: 1,
428
+ className: Auth_module.circularProgress
429
+ }), passkeyIcon]
430
+ })
431
+ }), jsxRuntime.jsx("center", {
432
+ children: jsxRuntime.jsx("h3", {
433
+ className: Auth_module.primaryText,
434
+ children: passkeySignupError ? "Authentication error" : passkeyCreated ? "Logging in with passkey..." : "Creating passkey..."
435
+ })
436
+ }), jsxRuntime.jsx("div", {
437
+ className: Auth_module.rowsContainer,
438
+ children: jsxRuntime.jsx("span", {
439
+ className: Auth_module.primaryText,
440
+ children: jsxRuntime.jsx("center", {
441
+ children: passkeySignupError ? passkeySignupError : ""
442
+ })
443
+ })
444
+ }), passkeySignupError && jsxRuntime.jsx("button", {
445
+ className: Auth_module.authButton,
446
+ type: "button",
447
+ onClick: handleSignupWithPasskey,
448
+ children: "Retry"
449
+ })]
450
+ }) : jsxRuntime.jsx("div", {
451
+ children: oauthLoading !== "" ? jsxRuntime.jsxs("div", {
452
+ className: Auth_module.authCardLoading,
453
+ children: [jsxRuntime.jsxs("h3", {
454
+ className: Auth_module.verifyingText,
455
+ children: ["Verifying with ", oauthLoading]
456
+ }), jsxRuntime.jsxs("div", {
457
+ className: Auth_module.loadingWrapper,
458
+ children: [jsxRuntime.jsx(material.CircularProgress, {
459
+ size: 80,
460
+ thickness: 1,
461
+ className: Auth_module.circularProgress
462
+ }), oauthLoading === "Google" && jsxRuntime.jsx("img", {
463
+ src: google,
464
+ className: Auth_module.oauthIcon
465
+ }), oauthLoading === "Facebook" && jsxRuntime.jsx("img", {
466
+ src: facebook,
467
+ className: Auth_module.oauthIcon
468
+ }), oauthLoading === "Apple" && jsxRuntime.jsx("img", {
469
+ src: apple,
470
+ className: Auth_module.oauthIcon
471
+ })]
472
+ }), jsxRuntime.jsxs("div", {
473
+ className: Auth_module.poweredBy,
474
+ children: [jsxRuntime.jsx("span", {
475
+ children: "Secured by"
476
+ }), jsxRuntime.jsx("img", {
477
+ src: turnkey
478
+ })]
479
+ })]
480
+ }) : jsxRuntime.jsxs("div", {
481
+ className: Auth_module.authCard,
482
+ children: [otpId && renderBackButton(), jsxRuntime.jsx("h2", {
483
+ className: Auth_module.primaryText,
484
+ children: !otpId && "Log in or sign up"
485
+ }), jsxRuntime.jsxs("div", {
486
+ className: Auth_module.authForm,
487
+ children: [!otpId && configOrder.filter(section => renderSection(section) !== null).map((section, index, visibleSections) => jsxRuntime.jsxs(React.Fragment, {
488
+ children: [renderSection(section), index < visibleSections.length - 1 && jsxRuntime.jsx("div", {
489
+ className: Auth_module.separator,
490
+ children: jsxRuntime.jsx("span", {
491
+ children: "OR"
492
+ })
493
+ })]
494
+ }, section)), otpId && jsxRuntime.jsx(OtpVerification, {
495
+ type: step,
496
+ contact: step === constants.OtpType.Email ? email : phone,
497
+ suborgId: suborgId,
498
+ otpId: otpId,
200
499
  sessionLengthSeconds: authConfig.sessionLengthSeconds,
201
- });
202
- if (oauthResponse && oauthResponse.token) {
203
- await handleAuthSuccess(oauthResponse.token);
204
- }
205
- else {
206
- onError(constants.authErrors.oauth.loginFailed);
207
- }
208
- };
209
- const renderBackButton = () => (jsxRuntime.jsx(ChevronLeftIcon, { onClick: () => {
210
- setPasskeyCreationScreen(false);
211
- setPasskeySignupError("");
212
- setPasskeySignupScreen(false);
213
- setOtpId(null);
214
- }, sx: {
215
- color: "var(--text-secondary)",
216
- position: "absolute",
217
- fontSize: "24px",
218
- top: 16,
219
- left: 16,
220
- zIndex: 10,
221
- cursor: "pointer",
222
- borderRadius: "50%",
223
- padding: "6px",
224
- transition: "background-color 0.3s ease",
225
- } }));
226
- const renderSocialButtons = () => {
227
- const { googleEnabled, appleEnabled, facebookEnabled } = authConfig;
228
- const layout = [googleEnabled, appleEnabled, facebookEnabled].filter(Boolean).length >= 2
229
- ? "inline"
230
- : "stacked";
231
- return (jsxRuntime.jsxs("div", { className: layout === "inline"
232
- ? Auth_module.socialButtonContainerInline
233
- : Auth_module.socialButtonContainerStacked, children: [googleEnabled && (jsxRuntime.jsx(Google, { layout: layout, clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID, iframePublicKey: authIframeClient.iframePublicKey, onSuccess: (response) => handleOAuthLogin(response.idToken, "Google") })), appleEnabled && (jsxRuntime.jsx(Apple, { layout: layout, clientId: process.env.NEXT_PUBLIC_APPLE_CLIENT_ID, iframePublicKey: authIframeClient.iframePublicKey, onSuccess: (response) => handleOAuthLogin(response.idToken, "Apple") })), facebookEnabled && (jsxRuntime.jsx(Facebook, { layout: layout, clientId: process.env.NEXT_PUBLIC_FACEBOOK_CLIENT_ID, iframePublicKey: authIframeClient.iframePublicKey, onSuccess: (response) => handleOAuthLogin(response.id_token, "Facebook") }))] }));
234
- };
235
- const renderSection = (section) => {
236
- switch (section) {
237
- case "email":
238
- return authConfig.emailEnabled && !otpId ? (jsxRuntime.jsxs("form", { onSubmit: (e) => {
239
- e.preventDefault();
240
- handleOtpLogin(constants.FilterType.Email, email, constants.OtpType.Email);
241
- }, children: [jsxRuntime.jsx("div", { className: Auth_module.inputGroup, children: jsxRuntime.jsx(material.TextField, { name: "email-input", type: "email", placeholder: "Enter your email", value: email, onChange: (e) => setEmail(e.target.value), fullWidth: true, sx: {
242
- "& .MuiOutlinedInput-root": {
243
- color: "var(--input-text)",
244
- "& fieldset": {
245
- borderColor: "var(--input-border)",
246
- },
247
- "&:hover fieldset": {
248
- borderColor: "var(--input-hover-border)",
249
- },
250
- "&.Mui-focused fieldset": {
251
- borderColor: "var(--input-focus-border)",
252
- border: "1px solid",
253
- },
254
- },
255
- "& .MuiInputBase-input": {
256
- padding: "12px",
257
- },
258
- backgroundColor: "var(--input-bg)",
259
- }, variant: "outlined" }) }), jsxRuntime.jsx("button", { className: Auth_module.authButton, type: "submit", disabled: !isValidEmail(email), children: "Continue" })] })) : null;
260
- case "phone":
261
- return authConfig.phoneEnabled && !otpId ? (jsxRuntime.jsxs("form", { onSubmit: (e) => {
262
- e.preventDefault();
263
- handleOtpLogin(constants.FilterType.PhoneNumber, phone, constants.OtpType.Sms);
264
- }, children: [jsxRuntime.jsx("div", { className: Auth_module.phoneInput, children: jsxRuntime.jsx(PhoneInput.MuiPhone, { onChange: (value) => setPhone(value), value: phone }) }), jsxRuntime.jsx("button", { className: Auth_module.authButton, type: "submit", disabled: !isValidPhone(phone), children: "Continue" })] })) : null;
265
- case "passkey":
266
- return authConfig.passkeyEnabled && !otpId ? (jsxRuntime.jsxs("div", { className: Auth_module.passkeyContainer, children: [jsxRuntime.jsx("button", { className: Auth_module.authButton, type: "button", onClick: handleLoginWithPasskey, children: "Log in with passkey" }), jsxRuntime.jsx("div", { className: Auth_module.noPasskeyLink, onClick: () => setPasskeySignupScreen(true), children: "Sign up with passkey" })] })) : null;
267
- case "socials":
268
- return authConfig.googleEnabled ||
269
- authConfig.appleEnabled ||
270
- authConfig.facebookEnabled
271
- ? renderSocialButtons()
272
- : null;
273
- default:
274
- return null;
275
- }
276
- };
277
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: passkeySignupScreen ? (jsxRuntime.jsxs("div", { className: Auth_module.authCard, children: [renderBackButton(), jsxRuntime.jsx("div", { className: Auth_module.passkeyIconContainer, children: passkeyIcon }), jsxRuntime.jsx("center", { children: jsxRuntime.jsx("h3", { className: Auth_module.primaryText, children: "Create a passkey" }) }), jsxRuntime.jsx("div", { className: Auth_module.rowsContainer, children: jsxRuntime.jsx("center", { children: jsxRuntime.jsx("span", { className: Auth_module.primaryText, children: "Passkeys allow for easy biometric access to your wallet and can be synced across devices." }) }) }), jsxRuntime.jsx("button", { className: Auth_module.authButton, type: "button", onClick: handleSignupWithPasskey, children: "Continue" })] })) : passkeyCreationScreen ? (jsxRuntime.jsxs("div", { className: Auth_module.authCard, children: [renderBackButton(), jsxRuntime.jsx("div", { className: Auth_module.passkeyIconContainer, children: passkeySignupError ? (jsxRuntime.jsx("div", { children: passkeyIconError })) : (jsxRuntime.jsxs("div", { className: Auth_module.loadingWrapper, children: [jsxRuntime.jsx(material.CircularProgress, { size: 80, thickness: 1, className: Auth_module.circularProgress }), passkeyIcon] })) }), jsxRuntime.jsx("center", { children: jsxRuntime.jsx("h3", { className: Auth_module.primaryText, children: passkeySignupError
278
- ? "Authentication error"
279
- : passkeyCreated
280
- ? "Logging in with passkey..."
281
- : "Creating passkey..." }) }), jsxRuntime.jsx("div", { className: Auth_module.rowsContainer, children: jsxRuntime.jsx("span", { className: Auth_module.primaryText, children: jsxRuntime.jsx("center", { children: passkeySignupError ? passkeySignupError : "" }) }) }), passkeySignupError && (jsxRuntime.jsx("button", { className: Auth_module.authButton, type: "button", onClick: handleSignupWithPasskey, children: "Retry" }))] })) : (jsxRuntime.jsx("div", { children: oauthLoading !== "" ? (jsxRuntime.jsxs("div", { className: Auth_module.authCardLoading, children: [jsxRuntime.jsxs("h3", { className: Auth_module.verifyingText, children: ["Verifying with ", oauthLoading] }), jsxRuntime.jsxs("div", { className: Auth_module.loadingWrapper, children: [jsxRuntime.jsx(material.CircularProgress, { size: 80, thickness: 1, className: Auth_module.circularProgress }), oauthLoading === "Google" && (jsxRuntime.jsx("img", { src: google, className: Auth_module.oauthIcon })), oauthLoading === "Facebook" && (jsxRuntime.jsx("img", { src: facebook, className: Auth_module.oauthIcon })), oauthLoading === "Apple" && (jsxRuntime.jsx("img", { src: apple, className: Auth_module.oauthIcon }))] }), jsxRuntime.jsxs("div", { className: Auth_module.poweredBy, children: [jsxRuntime.jsx("span", { children: "Secured by" }), jsxRuntime.jsx("img", { src: turnkey })] })] })) : (jsxRuntime.jsxs("div", { className: Auth_module.authCard, children: [otpId && renderBackButton(), jsxRuntime.jsx("h2", { className: Auth_module.primaryText, children: !otpId && "Log in or sign up" }), jsxRuntime.jsxs("div", { className: Auth_module.authForm, children: [!otpId &&
282
- configOrder
283
- .filter((section) => renderSection(section) !== null)
284
- .map((section, index, visibleSections) => (jsxRuntime.jsxs(React.Fragment, { children: [renderSection(section), index < visibleSections.length - 1 && (jsxRuntime.jsx("div", { className: Auth_module.separator, children: jsxRuntime.jsx("span", { children: "OR" }) }))] }, section))), otpId && (jsxRuntime.jsx(OtpVerification, { type: step, contact: step === constants.OtpType.Email ? email : phone, suborgId: suborgId, otpId: otpId, sessionLengthSeconds: authConfig.sessionLengthSeconds, authIframeClient: authIframeClient, onValidateSuccess: handleAuthSuccess, onResendCode: handleResendCode })), !otpId && (jsxRuntime.jsx("div", { className: Auth_module.tos, children: jsxRuntime.jsxs("span", { children: ["By continuing, you agree to our", " ", jsxRuntime.jsx("a", { href: "https://www.turnkey.com/legal/terms", target: "_blank", rel: "noopener noreferrer", className: Auth_module.tosBold, children: "Terms of Service" }), " ", "&", " ", jsxRuntime.jsx("a", { href: "https://www.turnkey.com/legal/privacy", target: "_blank", rel: "noopener noreferrer", className: Auth_module.tosBold, children: "Privacy Policy" }), "."] }) }))] }), jsxRuntime.jsxs("div", { onClick: () => (window.location.href = "https://www.turnkey.com/"), className: Auth_module.poweredBy, children: [jsxRuntime.jsx("span", { children: "Secured by" }), jsxRuntime.jsx("img", { src: turnkey })] })] })) })) }));
500
+ authIframeClient: authIframeClient,
501
+ onValidateSuccess: handleAuthSuccess,
502
+ onResendCode: handleResendCode
503
+ }), !otpId && jsxRuntime.jsx("div", {
504
+ className: Auth_module.tos,
505
+ children: jsxRuntime.jsxs("span", {
506
+ children: ["By continuing, you agree to our", " ", jsxRuntime.jsx("a", {
507
+ href: "https://www.turnkey.com/legal/terms",
508
+ target: "_blank",
509
+ rel: "noopener noreferrer",
510
+ className: Auth_module.tosBold,
511
+ children: "Terms of Service"
512
+ }), " ", "&", " ", jsxRuntime.jsx("a", {
513
+ href: "https://www.turnkey.com/legal/privacy",
514
+ target: "_blank",
515
+ rel: "noopener noreferrer",
516
+ className: Auth_module.tosBold,
517
+ children: "Privacy Policy"
518
+ }), "."]
519
+ })
520
+ })]
521
+ }), jsxRuntime.jsxs("div", {
522
+ onClick: () => window.location.href = "https://www.turnkey.com/",
523
+ className: Auth_module.poweredBy,
524
+ children: [jsxRuntime.jsx("span", {
525
+ children: "Secured by"
526
+ }), jsxRuntime.jsx("img", {
527
+ src: turnkey
528
+ })]
529
+ })]
530
+ })
531
+ })
532
+ });
285
533
  };
286
534
 
287
535
  module.exports = Auth;