@turnkey/sdk-react 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/dist/components/auth/Apple.d.ts.map +1 -1
- package/dist/components/auth/Apple.js +21 -8
- package/dist/components/auth/Apple.js.map +1 -1
- package/dist/components/auth/Apple.mjs +27 -11
- package/dist/components/auth/Apple.mjs.map +1 -1
- package/dist/components/auth/Auth.d.ts +7 -1
- package/dist/components/auth/Auth.d.ts.map +1 -1
- package/dist/components/auth/Auth.js +72 -77
- package/dist/components/auth/Auth.js.map +1 -1
- package/dist/components/auth/Auth.mjs +198 -238
- package/dist/components/auth/Auth.mjs.map +1 -1
- package/dist/components/auth/Facebook.d.ts.map +1 -1
- package/dist/components/auth/Facebook.js +19 -8
- package/dist/components/auth/Facebook.js.map +1 -1
- package/dist/components/auth/Facebook.mjs +35 -21
- package/dist/components/auth/Facebook.mjs.map +1 -1
- package/dist/components/auth/Google.d.ts.map +1 -1
- package/dist/components/auth/Google.js +20 -9
- package/dist/components/auth/Google.js.map +1 -1
- package/dist/components/auth/Google.mjs +28 -14
- package/dist/components/auth/Google.mjs.map +1 -1
- package/dist/components/auth/OtpVerification.d.ts +1 -2
- package/dist/components/auth/OtpVerification.d.ts.map +1 -1
- package/dist/components/auth/OtpVerification.js +11 -5
- package/dist/components/auth/OtpVerification.js.map +1 -1
- package/dist/components/auth/OtpVerification.mjs +24 -17
- package/dist/components/auth/OtpVerification.mjs.map +1 -1
- package/dist/contexts/TurnkeyContext.d.ts.map +1 -1
- package/dist/contexts/TurnkeyContext.js +24 -16
- package/dist/contexts/TurnkeyContext.js.map +1 -1
- package/dist/contexts/TurnkeyContext.mjs +30 -33
- package/dist/contexts/TurnkeyContext.mjs.map +1 -1
- package/dist/hooks/use-session.d.ts.map +1 -1
- package/dist/hooks/use-session.js +24 -12
- package/dist/hooks/use-session.js.map +1 -1
- package/dist/hooks/use-session.mjs +28 -14
- package/dist/hooks/use-session.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
4
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
7
|
var Auth_module = require('./Auth.module.css.js');
|
|
6
8
|
var React = require('react');
|
|
@@ -20,6 +22,11 @@ var constants = require('./constants.js');
|
|
|
20
22
|
var sdkServer = require('@turnkey/sdk-server');
|
|
21
23
|
var parsePhoneNumberFromString = require('libphonenumber-js');
|
|
22
24
|
|
|
25
|
+
exports.SessionType = void 0;
|
|
26
|
+
(function (SessionType) {
|
|
27
|
+
SessionType["READ_ONLY"] = "SESSION_TYPE_READ_ONLY";
|
|
28
|
+
SessionType["READ_WRITE"] = "SESSION_TYPE_READ_WRITE";
|
|
29
|
+
})(exports.SessionType || (exports.SessionType = {}));
|
|
23
30
|
const passkeyIcon = jsxRuntime.jsxs("svg", {
|
|
24
31
|
xmlns: "http://www.w3.org/2000/svg",
|
|
25
32
|
width: "43",
|
|
@@ -27,14 +34,14 @@ const passkeyIcon = jsxRuntime.jsxs("svg", {
|
|
|
27
34
|
fill: "none",
|
|
28
35
|
children: [jsxRuntime.jsx("path", {
|
|
29
36
|
fill: "var(--icon-color)",
|
|
30
|
-
|
|
37
|
+
fillRule: "evenodd",
|
|
31
38
|
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",
|
|
32
|
-
|
|
39
|
+
clipRule: "evenodd"
|
|
33
40
|
}), jsxRuntime.jsx("path", {
|
|
34
41
|
fill: "var(--icon-color)",
|
|
35
|
-
|
|
42
|
+
fillRule: "evenodd",
|
|
36
43
|
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",
|
|
37
|
-
|
|
44
|
+
clipRule: "evenodd"
|
|
38
45
|
})]
|
|
39
46
|
});
|
|
40
47
|
const passkeyIconError = jsxRuntime.jsxs("svg", {
|
|
@@ -44,14 +51,14 @@ const passkeyIconError = jsxRuntime.jsxs("svg", {
|
|
|
44
51
|
fill: "none",
|
|
45
52
|
children: [jsxRuntime.jsx("path", {
|
|
46
53
|
fill: "var(--error-color)",
|
|
47
|
-
|
|
54
|
+
fillRule: "evenodd",
|
|
48
55
|
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",
|
|
49
|
-
|
|
56
|
+
clipRule: "evenodd"
|
|
50
57
|
}), jsxRuntime.jsx("path", {
|
|
51
58
|
fill: "var(--error-color)",
|
|
52
|
-
|
|
59
|
+
fillRule: "evenodd",
|
|
53
60
|
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",
|
|
54
|
-
|
|
61
|
+
clipRule: "evenodd"
|
|
55
62
|
})]
|
|
56
63
|
});
|
|
57
64
|
const Auth = ({
|
|
@@ -59,27 +66,28 @@ const Auth = ({
|
|
|
59
66
|
onError,
|
|
60
67
|
authConfig,
|
|
61
68
|
configOrder,
|
|
69
|
+
emailCustomization,
|
|
70
|
+
sendFromEmailAddress,
|
|
62
71
|
customSmsMessage,
|
|
63
72
|
customAccounts
|
|
64
73
|
}) => {
|
|
65
74
|
const {
|
|
66
|
-
passkeyClient,
|
|
67
75
|
authIframeClient,
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
passkeyClient,
|
|
77
|
+
walletClient
|
|
70
78
|
} = useTurnkey.useTurnkey();
|
|
71
79
|
const [email, setEmail] = React.useState("");
|
|
72
80
|
const [phone, setPhone] = React.useState("");
|
|
73
81
|
const [otpId, setOtpId] = React.useState(null);
|
|
74
82
|
const [step, setStep] = React.useState("auth");
|
|
83
|
+
const [loading, setLoading] = React.useState();
|
|
75
84
|
const [oauthLoading, setOauthLoading] = React.useState("");
|
|
76
85
|
const [suborgId, setSuborgId] = React.useState("");
|
|
77
86
|
const [passkeySignupScreen, setPasskeySignupScreen] = React.useState(false);
|
|
78
87
|
const [passkeyCreationScreen, setPasskeyCreationScreen] = React.useState(false);
|
|
79
88
|
const [passkeySignupError, setPasskeySignupError] = React.useState("");
|
|
80
|
-
const [
|
|
89
|
+
const [componentReady, setComponentReady] = React.useState(false);
|
|
81
90
|
const [passkeyCreated, setPasskeyCreated] = React.useState(false);
|
|
82
|
-
const [walletLoading, setWalletLoading] = React.useState(false);
|
|
83
91
|
const handleResendCode = async () => {
|
|
84
92
|
if (step === constants.OtpType.Email) {
|
|
85
93
|
await handleOtpLogin(constants.FilterType.Email, email, constants.OtpType.Email);
|
|
@@ -89,10 +97,10 @@ const Auth = ({
|
|
|
89
97
|
};
|
|
90
98
|
React.useEffect(() => {
|
|
91
99
|
if (authIframeClient) {
|
|
92
|
-
|
|
100
|
+
setComponentReady(true);
|
|
93
101
|
}
|
|
94
102
|
}, [authIframeClient]);
|
|
95
|
-
if (
|
|
103
|
+
if (!componentReady) {
|
|
96
104
|
return jsxRuntime.jsx("div", {
|
|
97
105
|
className: Auth_module.defaultLoader,
|
|
98
106
|
children: jsxRuntime.jsx(material.CircularProgress, {
|
|
@@ -107,13 +115,6 @@ const Auth = ({
|
|
|
107
115
|
const phoneNumber = parsePhoneNumberFromString(phone);
|
|
108
116
|
return phoneNumber?.isValid() ?? false;
|
|
109
117
|
};
|
|
110
|
-
const handleAuthSuccess = async (credentialBundle, expirationSeconds) => {
|
|
111
|
-
if (credentialBundle) {
|
|
112
|
-
await authIframeClient.injectCredentialBundle(credentialBundle);
|
|
113
|
-
await authIframeClient.loginWithAuthBundle(credentialBundle, expirationSeconds);
|
|
114
|
-
await onAuthSuccess();
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
118
|
const handleSignupWithPasskey = async () => {
|
|
118
119
|
setPasskeySignupError("");
|
|
119
120
|
const siteInfo = `${new URL(window.location.href).hostname} - ${new Date().toLocaleString(undefined, {
|
|
@@ -160,41 +161,27 @@ const Auth = ({
|
|
|
160
161
|
constants.authErrors.passkey.createFailed;
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
expirationSeconds: authConfig.sessionLengthSeconds.toString()
|
|
167
|
-
}),
|
|
168
|
-
organizationId: turnkey$1?.config.defaultOrganizationId ?? process.env.NEXT_PUBLIC_ORGANIZATION_ID
|
|
169
|
-
});
|
|
170
|
-
if (sessionResponse?.credentialBundle) {
|
|
171
|
-
await handleAuthSuccess(sessionResponse.credentialBundle, authConfig.sessionLengthSeconds?.toString());
|
|
172
|
-
} else {
|
|
173
|
-
setPasskeySignupError(constants.authErrors.passkey.loginFailed);
|
|
174
|
-
}
|
|
175
|
-
} catch {
|
|
164
|
+
await passkeyClient?.loginWithPasskey(exports.SessionType.READ_WRITE, authIframeClient, authIframeClient?.iframePublicKey, authConfig.sessionLengthSeconds?.toString());
|
|
165
|
+
await onAuthSuccess();
|
|
166
|
+
} catch (error) {
|
|
176
167
|
setPasskeySignupError(constants.authErrors.passkey.timeoutOrNotAllowed);
|
|
168
|
+
console.error("Error during passkey signup: ", error);
|
|
177
169
|
}
|
|
178
170
|
};
|
|
179
171
|
const handleLoginWithPasskey = async () => {
|
|
180
172
|
try {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
expirationSeconds: authConfig.sessionLengthSeconds.toString()
|
|
185
|
-
}),
|
|
186
|
-
organizationId: turnkey$1?.config.defaultOrganizationId ?? process.env.NEXT_PUBLIC_ORGANIZATION_ID
|
|
187
|
-
});
|
|
188
|
-
if (sessionResponse?.credentialBundle) {
|
|
189
|
-
await handleAuthSuccess(sessionResponse.credentialBundle, authConfig.sessionLengthSeconds?.toString());
|
|
190
|
-
} else {
|
|
191
|
-
constants.authErrors.passkey.loginFailed;
|
|
192
|
-
}
|
|
173
|
+
setLoading("passkey");
|
|
174
|
+
await passkeyClient?.loginWithPasskey(exports.SessionType.READ_WRITE, authIframeClient, authIframeClient?.iframePublicKey, authConfig.sessionLengthSeconds?.toString());
|
|
175
|
+
await onAuthSuccess();
|
|
193
176
|
} catch (error) {
|
|
194
177
|
onError(constants.authErrors.passkey.loginFailed);
|
|
178
|
+
console.error("Error during passkey login: ", error);
|
|
179
|
+
} finally {
|
|
180
|
+
setLoading(undefined);
|
|
195
181
|
}
|
|
196
182
|
};
|
|
197
183
|
const handleOtpLogin = async (type, value, otpType) => {
|
|
184
|
+
setLoading(otpType);
|
|
198
185
|
const createSuborgData = {};
|
|
199
186
|
if (type === constants.FilterType.Email) createSuborgData.email = value;else if (type === constants.FilterType.PhoneNumber) createSuborgData.phoneNumber = value;
|
|
200
187
|
if (customAccounts) {
|
|
@@ -215,6 +202,12 @@ const Auth = ({
|
|
|
215
202
|
suborgID: suborgId,
|
|
216
203
|
otpType,
|
|
217
204
|
contact: value,
|
|
205
|
+
...(emailCustomization && {
|
|
206
|
+
emailCustomization
|
|
207
|
+
}),
|
|
208
|
+
...(sendFromEmailAddress && {
|
|
209
|
+
sendFromEmailAddress
|
|
210
|
+
}),
|
|
218
211
|
...(customSmsMessage && {
|
|
219
212
|
customSmsMessage
|
|
220
213
|
}),
|
|
@@ -227,6 +220,7 @@ const Auth = ({
|
|
|
227
220
|
} else {
|
|
228
221
|
onError(constants.authErrors.otp.sendFailed);
|
|
229
222
|
}
|
|
223
|
+
setLoading(undefined);
|
|
230
224
|
};
|
|
231
225
|
const handleOAuthLogin = async (credential, providerName) => {
|
|
232
226
|
setOauthLoading(providerName);
|
|
@@ -250,20 +244,21 @@ const Auth = ({
|
|
|
250
244
|
return;
|
|
251
245
|
}
|
|
252
246
|
const suborgId = suborgIds[0];
|
|
253
|
-
const
|
|
247
|
+
const oauthSession = await sdkServer.server.oauth({
|
|
254
248
|
suborgID: suborgId,
|
|
255
249
|
oidcToken: credential,
|
|
256
250
|
targetPublicKey: authIframeClient?.iframePublicKey,
|
|
257
251
|
sessionLengthSeconds: authConfig.sessionLengthSeconds
|
|
258
252
|
});
|
|
259
|
-
if (
|
|
260
|
-
await
|
|
253
|
+
if (oauthSession && oauthSession.token) {
|
|
254
|
+
await authIframeClient.loginWithSession(oauthSession);
|
|
255
|
+
await onAuthSuccess();
|
|
261
256
|
} else {
|
|
262
257
|
onError(constants.authErrors.oauth.loginFailed);
|
|
263
258
|
}
|
|
264
259
|
};
|
|
265
260
|
const handleLoginWithWallet = async () => {
|
|
266
|
-
|
|
261
|
+
setLoading("wallet");
|
|
267
262
|
try {
|
|
268
263
|
if (!walletClient) {
|
|
269
264
|
throw new Error("Wallet client not initialized");
|
|
@@ -290,25 +285,13 @@ const Auth = ({
|
|
|
290
285
|
onError(constants.authErrors.wallet.loginFailed);
|
|
291
286
|
return;
|
|
292
287
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
targetPublicKey: authIframeClient?.iframePublicKey,
|
|
296
|
-
...(suborgId && {
|
|
297
|
-
organizationId: suborgId
|
|
298
|
-
}),
|
|
299
|
-
...(authConfig.sessionLengthSeconds !== undefined && {
|
|
300
|
-
expirationSeconds: authConfig.sessionLengthSeconds.toString()
|
|
301
|
-
})
|
|
302
|
-
});
|
|
303
|
-
if (sessionResponse?.credentialBundle) {
|
|
304
|
-
await handleAuthSuccess(sessionResponse.credentialBundle, authConfig.sessionLengthSeconds?.toString());
|
|
305
|
-
} else {
|
|
306
|
-
throw new Error(constants.authErrors.wallet.loginFailed);
|
|
307
|
-
}
|
|
288
|
+
await walletClient.loginWithWallet(exports.SessionType.READ_WRITE, authIframeClient, authIframeClient?.iframePublicKey, authConfig.sessionLengthSeconds?.toString());
|
|
289
|
+
await onAuthSuccess();
|
|
308
290
|
} catch (error) {
|
|
309
291
|
onError(error.message || constants.authErrors.wallet.loginFailed);
|
|
292
|
+
console.error("Error during wallet login: ", error);
|
|
310
293
|
} finally {
|
|
311
|
-
|
|
294
|
+
setLoading(undefined);
|
|
312
295
|
}
|
|
313
296
|
};
|
|
314
297
|
const renderBackButton = () => jsxRuntime.jsx(ChevronLeftIcon, {
|
|
@@ -399,8 +382,12 @@ const Auth = ({
|
|
|
399
382
|
}), jsxRuntime.jsx("button", {
|
|
400
383
|
className: Auth_module.authButton,
|
|
401
384
|
type: "submit",
|
|
402
|
-
disabled: !isValidEmail(email),
|
|
403
|
-
children:
|
|
385
|
+
disabled: !isValidEmail(email) || loading === constants.OtpType.Email,
|
|
386
|
+
children: loading === constants.OtpType.Email ? jsxRuntime.jsx(material.CircularProgress, {
|
|
387
|
+
size: 24,
|
|
388
|
+
thickness: 4,
|
|
389
|
+
className: Auth_module.buttonProgress || ""
|
|
390
|
+
}) : "Continue"
|
|
404
391
|
})]
|
|
405
392
|
}) : null;
|
|
406
393
|
case "phone":
|
|
@@ -418,8 +405,12 @@ const Auth = ({
|
|
|
418
405
|
}), jsxRuntime.jsx("button", {
|
|
419
406
|
className: Auth_module.authButton,
|
|
420
407
|
type: "submit",
|
|
421
|
-
disabled: !isValidPhone(phone),
|
|
422
|
-
children:
|
|
408
|
+
disabled: !isValidPhone(phone) || loading === constants.OtpType.Sms,
|
|
409
|
+
children: loading === constants.OtpType.Sms ? jsxRuntime.jsx(material.CircularProgress, {
|
|
410
|
+
size: 24,
|
|
411
|
+
thickness: 4,
|
|
412
|
+
className: Auth_module.buttonProgress || ""
|
|
413
|
+
}) : "Continue"
|
|
423
414
|
})]
|
|
424
415
|
}) : null;
|
|
425
416
|
case "passkey":
|
|
@@ -429,7 +420,12 @@ const Auth = ({
|
|
|
429
420
|
className: Auth_module.authButton,
|
|
430
421
|
type: "button",
|
|
431
422
|
onClick: handleLoginWithPasskey,
|
|
432
|
-
|
|
423
|
+
disabled: loading === "passkey",
|
|
424
|
+
children: loading === "passkey" ? jsxRuntime.jsx(material.CircularProgress, {
|
|
425
|
+
size: 24,
|
|
426
|
+
thickness: 4,
|
|
427
|
+
className: Auth_module.buttonProgress || ""
|
|
428
|
+
}) : "Log in with passkey"
|
|
433
429
|
}), jsxRuntime.jsx("div", {
|
|
434
430
|
className: Auth_module.noPasskeyLink,
|
|
435
431
|
onClick: () => setPasskeySignupScreen(true),
|
|
@@ -443,8 +439,8 @@ const Auth = ({
|
|
|
443
439
|
className: Auth_module.authButton,
|
|
444
440
|
type: "button",
|
|
445
441
|
onClick: handleLoginWithWallet,
|
|
446
|
-
disabled:
|
|
447
|
-
children:
|
|
442
|
+
disabled: loading === "wallet",
|
|
443
|
+
children: loading === "wallet" ? jsxRuntime.jsx(material.CircularProgress, {
|
|
448
444
|
size: 24,
|
|
449
445
|
thickness: 4,
|
|
450
446
|
className: Auth_module.buttonProgress || ""
|
|
@@ -565,8 +561,7 @@ const Auth = ({
|
|
|
565
561
|
suborgId: suborgId,
|
|
566
562
|
otpId: otpId,
|
|
567
563
|
sessionLengthSeconds: authConfig.sessionLengthSeconds,
|
|
568
|
-
|
|
569
|
-
onValidateSuccess: handleAuthSuccess,
|
|
564
|
+
onValidateSuccess: onAuthSuccess,
|
|
570
565
|
onResendCode: handleResendCode
|
|
571
566
|
}), !otpId && jsxRuntime.jsx("div", {
|
|
572
567
|
className: Auth_module.tos,
|
|
@@ -600,5 +595,5 @@ const Auth = ({
|
|
|
600
595
|
});
|
|
601
596
|
};
|
|
602
597
|
|
|
603
|
-
|
|
598
|
+
exports.default = Auth;
|
|
604
599
|
//# sourceMappingURL=Auth.js.map
|