@alore/auth-react-ui 1.2.0-alpha.23 → 1.2.0-alpha.25
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/dist/cjs/auth/ForgotPassword.js +28 -5
- package/dist/cjs/auth/ForgotPassword.js.map +1 -1
- package/dist/cjs/auth/Login.js +206 -57
- package/dist/cjs/auth/Login.js.map +1 -1
- package/dist/cjs/auth/Register.js +216 -63
- package/dist/cjs/auth/Register.js.map +1 -1
- package/dist/cjs/components/Auth.js +47 -11
- package/dist/cjs/components/Auth.js.map +1 -1
- package/dist/cjs/components/AuthProvider.d.ts +20 -0
- package/dist/cjs/components/BackButton.js +1 -1
- package/dist/cjs/components/BackButton.js.map +1 -1
- package/dist/cjs/components/CheckboxForm.js +2 -2
- package/dist/cjs/components/CheckboxForm.js.map +1 -1
- package/dist/cjs/components/InputForm.d.ts +2 -1
- package/dist/cjs/components/InputForm.js +2 -2
- package/dist/cjs/components/InputForm.js.map +1 -1
- package/dist/cjs/components/InputOTP.js +1 -1
- package/dist/cjs/components/InputOTP.js.map +1 -1
- package/dist/cjs/components/LinkButton.d.ts +14 -0
- package/dist/cjs/components/LinkButton.js +29 -0
- package/dist/cjs/components/LinkButton.js.map +1 -0
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +3 -1
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/dictionaries/en.json +5 -1
- package/dist/cjs/dictionaries/pt.json +12 -8
- package/dist/cjs/get-dictionary.d.ts +12 -0
- package/dist/cjs/hooks/useAuthService.d.ts +60 -0
- package/dist/cjs/hooks/useAuthServiceInstance.d.ts +20 -0
- package/dist/cjs/hooks/useDictionary.d.ts +4 -0
- package/dist/cjs/machine/index.d.ts +40 -0
- package/dist/cjs/machine/index.js +101 -0
- package/dist/cjs/machine/index.js.map +1 -1
- package/dist/cjs/machine/types.d.ts +22 -1
- package/dist/cjs/styles/themes.js +2 -2
- package/dist/cjs/styles/themes.js.map +1 -1
- package/dist/mjs/auth/ForgotPassword.js +29 -6
- package/dist/mjs/auth/ForgotPassword.js.map +1 -1
- package/dist/mjs/auth/Login.js +213 -59
- package/dist/mjs/auth/Login.js.map +1 -1
- package/dist/mjs/auth/Register.js +188 -34
- package/dist/mjs/auth/Register.js.map +1 -1
- package/dist/mjs/components/Auth.js +44 -11
- package/dist/mjs/components/Auth.js.map +1 -1
- package/dist/mjs/components/AuthProvider.d.ts +20 -0
- package/dist/mjs/components/BackButton.js +1 -1
- package/dist/mjs/components/BackButton.js.map +1 -1
- package/dist/mjs/components/CheckboxForm.js +2 -2
- package/dist/mjs/components/CheckboxForm.js.map +1 -1
- package/dist/mjs/components/InputForm.d.ts +2 -1
- package/dist/mjs/components/InputForm.js +2 -2
- package/dist/mjs/components/InputForm.js.map +1 -1
- package/dist/mjs/components/InputOTP.js +1 -1
- package/dist/mjs/components/InputOTP.js.map +1 -1
- package/dist/mjs/components/LinkButton.d.ts +14 -0
- package/dist/mjs/components/LinkButton.js +10 -0
- package/dist/mjs/components/LinkButton.js.map +1 -0
- package/dist/mjs/components/index.d.ts +1 -0
- package/dist/mjs/components/index.js +1 -0
- package/dist/mjs/components/index.js.map +1 -1
- package/dist/mjs/dictionaries/en.json +5 -1
- package/dist/mjs/dictionaries/pt.json +12 -8
- package/dist/mjs/get-dictionary.d.ts +12 -0
- package/dist/mjs/hooks/useAuthService.d.ts +60 -0
- package/dist/mjs/hooks/useAuthServiceInstance.d.ts +20 -0
- package/dist/mjs/hooks/useDictionary.d.ts +4 -0
- package/dist/mjs/machine/index.d.ts +40 -0
- package/dist/mjs/machine/index.js +95 -0
- package/dist/mjs/machine/index.js.map +1 -1
- package/dist/mjs/machine/types.d.ts +22 -1
- package/dist/mjs/styles/themes.js +3 -2
- package/dist/mjs/styles/themes.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/auth/Login.js
CHANGED
|
@@ -55,22 +55,64 @@ const passkeyExtensions_1 = require("../utils/passkeyExtensions");
|
|
|
55
55
|
const InputForm = react_2.default.lazy(() => Promise.resolve().then(() => __importStar(require('../components/InputForm'))));
|
|
56
56
|
const InputOTP = react_2.default.lazy(() => Promise.resolve().then(() => __importStar(require('../components/InputOTP'))));
|
|
57
57
|
const BackButton = react_2.default.lazy(() => Promise.resolve().then(() => __importStar(require('../components/BackButton'))));
|
|
58
|
+
const LinkButton = react_2.default.lazy(() => Promise.resolve().then(() => __importStar(require('../components/LinkButton'))));
|
|
58
59
|
const envelopIcon = () => react_2.default.createElement(solid_1.EnvelopeIcon, { className: "size-4 text-gray-500" });
|
|
59
60
|
const lockClosedIcon = () => react_2.default.createElement(solid_1.LockClosedIcon, { className: "size-4 text-gray-500" });
|
|
60
61
|
const HARDWARE = 1;
|
|
61
62
|
const SOFTWARE = 2;
|
|
62
63
|
const ABORT_CONDITIONAL_UI = 'abort-conditional-ui';
|
|
64
|
+
// Google's button is rendered by GSI and cannot be restyled, so the Microsoft
|
|
65
|
+
// one copies its typography exactly — same stack, size, weight and tracking —
|
|
66
|
+
// rather than inheriting the host app's font and reading as a different
|
|
67
|
+
// control. Measured off the rendered GSI button.
|
|
68
|
+
const GOOGLE_BUTTON_TYPOGRAPHY = {
|
|
69
|
+
fontFamily: '"Google Sans", arial, sans-serif',
|
|
70
|
+
fontSize: '14px',
|
|
71
|
+
fontWeight: 400,
|
|
72
|
+
letterSpacing: '0.25px',
|
|
73
|
+
};
|
|
63
74
|
const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshareWorker, cryptoUtils, customStyles, title, titleClassName, loginTitle, loginTitleClassName, emailInputLabel, inputClassName, contentAlignment = 'center', customClassName, titleSpacing = 'gap-y-2 sm:gap-y-7', logoContainerClassName, }) => {
|
|
64
75
|
const { hashUserInfo, generateSecureHash } = cryptoUtils;
|
|
65
76
|
const dictionary = (0, useDictionary_1.default)(locale);
|
|
66
77
|
const loginDictionary = dictionary === null || dictionary === void 0 ? void 0 : dictionary.auth.login;
|
|
67
78
|
const [secureCode2FA, setSecure2FACode] = (0, react_2.useState)('');
|
|
68
79
|
const [secureCodeEmail, setSecureCodeEmail] = (0, react_2.useState)('');
|
|
80
|
+
const [socialEmailCode, setSocialEmailCode] = (0, react_2.useState)('');
|
|
81
|
+
// Google's button is rendered by GSI, which ignores a percentage width — it
|
|
82
|
+
// only accepts a pixel number, and falls back to its own default otherwise
|
|
83
|
+
// (the "Provided button width is invalid: 100%" warning). Measuring the row
|
|
84
|
+
// is the only way the two providers can be the same width.
|
|
85
|
+
const [socialButtonWidth, setSocialButtonWidth] = (0, react_2.useState)(0);
|
|
86
|
+
// Callback ref, not useEffect+useRef: the row is inside a memoized subtree
|
|
87
|
+
// that remounts (e.g. when an error block appears), and an effect keyed on
|
|
88
|
+
// anything else keeps observing the old, detached node — leaving GSI rendered
|
|
89
|
+
// at a stale width. A zero measurement is ignored rather than clamped up to
|
|
90
|
+
// the 200px floor, which is what produced a short Google button next to a
|
|
91
|
+
// full-width Microsoft one.
|
|
92
|
+
const socialRowObserver = (0, react_2.useRef)();
|
|
93
|
+
const socialRowRef = (0, react_2.useCallback)((node) => {
|
|
94
|
+
var _a;
|
|
95
|
+
(_a = socialRowObserver.current) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
96
|
+
if (!node)
|
|
97
|
+
return;
|
|
98
|
+
const measure = () => {
|
|
99
|
+
const width = Math.round(node.clientWidth);
|
|
100
|
+
if (width > 0)
|
|
101
|
+
setSocialButtonWidth(Math.max(200, Math.min(400, width)));
|
|
102
|
+
};
|
|
103
|
+
measure();
|
|
104
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
105
|
+
socialRowObserver.current = new ResizeObserver(measure);
|
|
106
|
+
socialRowObserver.current.observe(node);
|
|
107
|
+
}
|
|
108
|
+
}, []);
|
|
69
109
|
const [authState, sendAuth] = (0, react_1.useActor)(authServiceInstance);
|
|
70
|
-
const { salt, error: errorObj, active2fa, registerUser, googleOtpCode, googleUser, RCRPublicKey, authProviderConfigs, credentialEmail, } = authState.context;
|
|
110
|
+
const { salt, error: errorObj, active2fa, registerUser, googleOtpCode, googleUser, RCRPublicKey, authProviderConfigs, credentialEmail, socialChallenge, } = authState.context;
|
|
71
111
|
// Single UI-facing error message derived from the error object
|
|
72
112
|
const displayError = (errorObj === null || errorObj === void 0 ? void 0 : errorObj.message) || '';
|
|
73
113
|
const hasDisplayError = !!displayError;
|
|
114
|
+
// Failures whose copy already tells the user what happened and what to do.
|
|
115
|
+
const isExplainedError = ['SOCIAL_EMAIL_MISSING', 'EMAIL_NOT_ALLOWED'].includes(displayError);
|
|
74
116
|
const { enablePasskeys, requireEmailVerification, enablePasswords, socialProviders, enableWalletCreation, } = authProviderConfigs || {};
|
|
75
117
|
const [currentDevice, setCurrentDevice] = (0, react_2.useState)('');
|
|
76
118
|
const [loading, setLoading] = (0, react_2.useState)(false);
|
|
@@ -86,29 +128,21 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
86
128
|
const onlyPasskeyLogin = (0, react_2.useMemo)(() => {
|
|
87
129
|
return enablePasskeys && !enablePasswords;
|
|
88
130
|
}, [enablePasskeys, enablePasswords]);
|
|
89
|
-
const googleLogin = (0, google_1.useGoogleLogin)({
|
|
90
|
-
onSuccess: (tokenResponse) => {
|
|
91
|
-
resetEmail();
|
|
92
|
-
sendAuth({
|
|
93
|
-
type: 'GOOGLE_LOGIN',
|
|
94
|
-
payload: {
|
|
95
|
-
accessToken: tokenResponse.access_token,
|
|
96
|
-
providerName: 'google',
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
131
|
const microsoftLogin = () => {
|
|
102
132
|
instance
|
|
133
|
+
// The OIDC scopes, not Graph's user.read: `email` is what puts an email
|
|
134
|
+
// claim in the id_token, and the backend has nothing to send a code to
|
|
135
|
+
// without it. Nothing here calls Graph, so user.read only bought a
|
|
136
|
+
// consent prompt.
|
|
103
137
|
.loginPopup({
|
|
104
|
-
scopes: ['
|
|
138
|
+
scopes: ['openid', 'profile', 'email'],
|
|
105
139
|
})
|
|
106
140
|
.then((response) => {
|
|
107
|
-
|
|
141
|
+
resetEmail();
|
|
108
142
|
sendAuth({
|
|
109
|
-
type: '
|
|
143
|
+
type: 'SOCIAL_LOGIN',
|
|
110
144
|
payload: {
|
|
111
|
-
|
|
145
|
+
idToken: response.idToken,
|
|
112
146
|
providerName: 'microsoft',
|
|
113
147
|
},
|
|
114
148
|
});
|
|
@@ -117,8 +151,31 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
117
151
|
console.error('Login failed:', error);
|
|
118
152
|
});
|
|
119
153
|
};
|
|
120
|
-
const handleGoogleLogin = () => googleLogin();
|
|
121
154
|
const handleMicrosoftLogin = () => microsoftLogin();
|
|
155
|
+
// Answering the emailed-code challenge: the SAME id_token goes back with the
|
|
156
|
+
// session and the code. The backend re-verifies it and requires the session's
|
|
157
|
+
// address and identity to match it, so nothing else can be substituted here.
|
|
158
|
+
const onSubmitSocialEmailCode = () => {
|
|
159
|
+
if (!socialChallenge)
|
|
160
|
+
return;
|
|
161
|
+
sendAuth({
|
|
162
|
+
type: 'SOCIAL_LOGIN',
|
|
163
|
+
payload: Object.assign(Object.assign({ idToken: socialChallenge.idToken, providerName: socialChallenge.providerName }, (socialChallenge.device ? { device: socialChallenge.device } : {})), { sessionId: socialChallenge.sessionId, emailCode: socialEmailCode }),
|
|
164
|
+
});
|
|
165
|
+
setSocialEmailCode('');
|
|
166
|
+
};
|
|
167
|
+
const handleGoogleCredential = (credentialResponse) => {
|
|
168
|
+
if (!credentialResponse.credential)
|
|
169
|
+
return;
|
|
170
|
+
resetEmail();
|
|
171
|
+
sendAuth({
|
|
172
|
+
type: 'SOCIAL_LOGIN',
|
|
173
|
+
payload: {
|
|
174
|
+
idToken: credentialResponse.credential,
|
|
175
|
+
providerName: 'google',
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
};
|
|
122
179
|
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
123
180
|
const hasPasskeySupportWithPRFOrLargeBlob = () => {
|
|
124
181
|
if (window.PublicKeyCredential &&
|
|
@@ -271,6 +328,7 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
271
328
|
authState.matches('active.login.verifyingEmail2fa') ||
|
|
272
329
|
authState.matches('active.login.resendingEmailCode') ||
|
|
273
330
|
authState.matches('active.login.googleLogin') ||
|
|
331
|
+
authState.matches('active.login.socialLogin') ||
|
|
274
332
|
authState.matches('active.login.verifyingGoogleLogin') ||
|
|
275
333
|
authState.matches('active.login.verifyingRegisterPublicKeyCredential') ||
|
|
276
334
|
authState.matches('active.login.retrievingCredentialRCR') ||
|
|
@@ -294,6 +352,25 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
294
352
|
window.removeEventListener('keydown', handleMethodSelectionEnter);
|
|
295
353
|
};
|
|
296
354
|
}, [authState.value, isLoading, selectLoginMethod]);
|
|
355
|
+
const canGoBack = (0, react_2.useMemo)(() => authState.matches('active.login.loginMethodSelection') ||
|
|
356
|
+
authState.matches('active.login.inputPassword') ||
|
|
357
|
+
authState.matches('active.login.email2fa') ||
|
|
358
|
+
authState.matches('active.login.hardware2fa') ||
|
|
359
|
+
authState.matches('active.login.software2fa'), [authState.value]);
|
|
360
|
+
(0, react_2.useEffect)(() => {
|
|
361
|
+
if (typeof window === 'undefined')
|
|
362
|
+
return undefined;
|
|
363
|
+
const handleEscape = (event) => {
|
|
364
|
+
if (event.key === 'Escape' && canGoBack && !isLoading) {
|
|
365
|
+
event.preventDefault();
|
|
366
|
+
sendAuth('BACK');
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
window.addEventListener('keydown', handleEscape);
|
|
370
|
+
return () => {
|
|
371
|
+
window.removeEventListener('keydown', handleEscape);
|
|
372
|
+
};
|
|
373
|
+
}, [canGoBack, isLoading, sendAuth]);
|
|
297
374
|
(0, react_2.useEffect)(() => {
|
|
298
375
|
if (typeof window !== 'undefined') {
|
|
299
376
|
hasPasskeySupportWithPRFOrLargeBlob();
|
|
@@ -363,6 +440,11 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
363
440
|
onSubmitSecureCodeEmail();
|
|
364
441
|
}
|
|
365
442
|
}, [secureCodeEmail]);
|
|
443
|
+
(0, react_2.useEffect)(() => {
|
|
444
|
+
if (socialEmailCode.length === 6) {
|
|
445
|
+
onSubmitSocialEmailCode();
|
|
446
|
+
}
|
|
447
|
+
}, [socialEmailCode]);
|
|
366
448
|
(0, react_2.useEffect)(() => {
|
|
367
449
|
if (sendEmailCooldown <= 0) {
|
|
368
450
|
clearInterval(intervalRef.current);
|
|
@@ -562,7 +644,7 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
562
644
|
return errorMessage;
|
|
563
645
|
}, [displayError]);
|
|
564
646
|
const getAuthError = () => {
|
|
565
|
-
var _a, _b, _c, _d;
|
|
647
|
+
var _a, _b, _c, _d, _e, _f;
|
|
566
648
|
let authErrorTitle = loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.somethingWrong;
|
|
567
649
|
let authErrorDescription = loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.defaultError;
|
|
568
650
|
const lower = (_a = displayError.toLowerCase) === null || _a === void 0 ? void 0 : _a.call(displayError);
|
|
@@ -573,6 +655,13 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
573
655
|
authErrorTitle = (_d = dictionary === null || dictionary === void 0 ? void 0 : dictionary.auth) === null || _d === void 0 ? void 0 : _d.emailDomainNotAllowed;
|
|
574
656
|
return { authErrorTitle, authErrorDescription };
|
|
575
657
|
}
|
|
658
|
+
// Nothing the user can do on this screen fixes it — the provider sent no
|
|
659
|
+
// address — so it gets its own copy instead of the generic failure.
|
|
660
|
+
if (displayError === 'SOCIAL_EMAIL_MISSING' || serverMessage === 'social_email_missing') {
|
|
661
|
+
authErrorTitle = (_e = dictionary === null || dictionary === void 0 ? void 0 : dictionary.auth) === null || _e === void 0 ? void 0 : _e.socialEmailMissing;
|
|
662
|
+
authErrorDescription = (_f = dictionary === null || dictionary === void 0 ? void 0 : dictionary.auth) === null || _f === void 0 ? void 0 : _f.socialEmailMissingDescription;
|
|
663
|
+
return { authErrorTitle, authErrorDescription };
|
|
664
|
+
}
|
|
576
665
|
if (displayError === 'INVALID_CREDENTIALS' || serverMessage === 'INVALID_CREDENTIALS') {
|
|
577
666
|
authErrorTitle = loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.invalidEmailPassword;
|
|
578
667
|
authErrorDescription = loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.invalidEmailPasswordDescription;
|
|
@@ -617,18 +706,23 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
617
706
|
const IdleStep = (0, react_2.useMemo)(() => {
|
|
618
707
|
const { authErrorTitle, authErrorDescription } = getAuthError();
|
|
619
708
|
return (react_2.default.createElement("div", { "data-testid": "login-email-step" },
|
|
620
|
-
hasDisplayError ? (
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
709
|
+
hasDisplayError ? (
|
|
710
|
+
// Compact on purpose: this block sits ABOVE the form it interrupts,
|
|
711
|
+
// so every pixel it takes pushes the sign-in controls further down —
|
|
712
|
+
// on a short window that is what drove the card past its container.
|
|
713
|
+
react_2.default.createElement("div", { className: "flex flex-col items-center justify-center gap-3 pb-7 pt-2" },
|
|
714
|
+
react_2.default.createElement("img", { src: utils_1.authErrorImage, alt: "", width: 48 }),
|
|
715
|
+
(displayError === null || displayError === void 0 ? void 0 : displayError.includes('beta')) ? (react_2.default.createElement("span", { className: "font-poppins text-alr-red text-center text-base font-bold" }, displayError)) : (react_2.default.createElement(react_2.default.Fragment, null,
|
|
716
|
+
react_2.default.createElement("span", { className: "font-poppins text-alr-red text-center text-base font-bold" }, authErrorTitle),
|
|
717
|
+
react_2.default.createElement("span", { className: "text-alr-grey text-center text-sm font-medium leading-snug" }, authErrorDescription),
|
|
718
|
+
(errorObj === null || errorObj === void 0 ? void 0 : errorObj.code) && !isExplainedError && (react_2.default.createElement("span", { className: "mt-1 text-center text-xs text-gray-500" }, `${loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.errorCode} ${errorObj.code}`)))))) : (react_2.default.createElement("h1", { className: loginTitleClassName ||
|
|
719
|
+
`font-inter text-xl font-bold text-gray-700 ${getTextAlignment}` }, loginTitle || (forgeId ? loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.forgeLogin : loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.loginAccount))),
|
|
626
720
|
react_2.default.createElement("div", { className: "mt-4 flex flex-col gap-y-5" },
|
|
627
721
|
!onlyPasskeyLogin && requireEmailVerification && (react_2.default.createElement("form", { className: "flex flex-col gap-y-5", onSubmit: handleSubmitEmail((data) => onSubmitEmail(data)) },
|
|
628
|
-
react_2.default.createElement(InputForm, {
|
|
722
|
+
react_2.default.createElement(InputForm, { inputClassName: inputClassName, control: emailControl, errors: emailErrors, name: "email", type: "text", placeholder: emailInputLabel || (loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.enterEmail), "data-testid": "login-email-input", icon: envelopIcon, autoComplete: authAbortController && isConditionalMediationAvailable
|
|
629
723
|
? 'username webauthn'
|
|
630
724
|
: undefined, autoFocus: true }),
|
|
631
|
-
react_2.default.createElement("
|
|
725
|
+
react_2.default.createElement(LinkButton, { "data-testid": "forgot-password-link", onClick: () => sendAuth('FORGOT_PASSWORD'), className: "text-xs" }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.forgotPassword),
|
|
632
726
|
react_2.default.createElement(flowbite_react_1.Button, { type: "submit", "data-testid": "login-button", disabled: (0, helpers_1.verifyEmptyValues)(getValuesEmail('email')) },
|
|
633
727
|
isLoading && react_2.default.createElement(flowbite_react_1.Spinner, { className: "mr-3 !h-5 w-full !fill-gray-300" }),
|
|
634
728
|
onlyPasskeyLogin ? loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.passkeyLogin : loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.login))),
|
|
@@ -638,12 +732,35 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
638
732
|
react_2.default.createElement("span", { className: "font-semibold text-white" }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.passkeyLogin)))),
|
|
639
733
|
react_2.default.createElement("div", { className: "h-[0.5px] w-full bg-gray-300" }),
|
|
640
734
|
(socialProviders === null || socialProviders === void 0 ? void 0 : socialProviders.length) && (react_2.default.createElement(react_2.default.Fragment, null,
|
|
641
|
-
react_2.default.createElement("div", { className: "flex w-full flex-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
735
|
+
react_2.default.createElement("div", { ref: socialRowRef, className: "flex w-full flex-col gap-3" }, socialProviders.map((provider) => {
|
|
736
|
+
if (provider.providerName === 'google') {
|
|
737
|
+
return (
|
|
738
|
+
// Google's own button, because the credential it returns IS
|
|
739
|
+
// the id_token. The custom button below cannot produce one:
|
|
740
|
+
// useGoogleLogin yields an access_token, whose audience the
|
|
741
|
+
// backend has no way to verify. Styling is limited to what
|
|
742
|
+
// Google exposes here.
|
|
743
|
+
react_2.default.createElement("div", { key: provider.id, className: "w-full", "data-testid": "login-social-google-button" },
|
|
744
|
+
react_2.default.createElement(google_1.GoogleLogin
|
|
745
|
+
// GSI renders the button once and ignores a later width
|
|
746
|
+
// change, so the measurement has to remount it — otherwise it
|
|
747
|
+
// keeps its 209px default and sits narrower than Microsoft's.
|
|
748
|
+
, {
|
|
749
|
+
// GSI renders the button once and ignores a later width
|
|
750
|
+
// change, so the measurement has to remount it — otherwise it
|
|
751
|
+
// keeps its 209px default and sits narrower than Microsoft's.
|
|
752
|
+
key: socialButtonWidth, onSuccess: handleGoogleCredential, onError: () => console.error('Google sign-in failed'), shape: "rectangular", size: "large", width: socialButtonWidth || undefined, text: "continue_with", locale: locale })));
|
|
753
|
+
}
|
|
754
|
+
if (provider.providerName === 'microsoft') {
|
|
755
|
+
return (react_2.default.createElement("button", { key: provider.id, type: "button", "data-testid": "login-social-microsoft-button", onClick: handleMicrosoftLogin, className: "flex h-10 w-full items-center rounded border border-[#dadce0] bg-white px-3 text-sm font-normal text-[#3c4043] transition-colors hover:border-[#d2e3fc] hover:bg-[rgba(66,133,244,0.08)] focus:bg-[rgba(66,133,244,0.1)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[--primary-color] active:bg-[rgba(66,133,244,0.1)]", style: GOOGLE_BUTTON_TYPOGRAPHY },
|
|
756
|
+
react_2.default.createElement("img", { src: utils_1.microsoftLogo, alt: "", width: 18, height: 18 }),
|
|
757
|
+
react_2.default.createElement("span", { className: "flex-1 text-center" }, dictionary === null || dictionary === void 0 ? void 0 : dictionary.auth.continueMicrosoft)));
|
|
758
|
+
}
|
|
759
|
+
// A provider this build has no button for. Rendering the
|
|
760
|
+
// Microsoft one for it, as this used to, signs the user into
|
|
761
|
+
// the wrong provider.
|
|
762
|
+
return null;
|
|
763
|
+
})),
|
|
647
764
|
react_2.default.createElement("div", { className: "h-[0.5px] w-full bg-gray-300" }))),
|
|
648
765
|
forgeId && (react_2.default.createElement(flowbite_react_1.Button, { color: "light", onClick: () => sendAuth('LOGIN_WITH_WEB3CONNECTOR'), outline: true },
|
|
649
766
|
react_2.default.createElement("div", { className: "flex flex-row items-center justify-center gap-2" },
|
|
@@ -651,9 +768,9 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
651
768
|
react_2.default.createElement("img", { src: utils_1.metamaskLogo, alt: "metamask logo", width: 20, className: "absolute right-3" }),
|
|
652
769
|
react_2.default.createElement("img", { src: utils_1.walletConnectLogo, alt: "walletconnect logo", width: 20 })), loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
653
770
|
loginDictionary.metamaskWalletConnect))),
|
|
654
|
-
react_2.default.createElement("
|
|
655
|
-
loginDictionary.dontHaveAccount,
|
|
656
|
-
react_2.default.createElement(
|
|
771
|
+
react_2.default.createElement("div", { className: "flex flex-col items-center gap-0.5 text-center text-sm font-medium" },
|
|
772
|
+
react_2.default.createElement("span", null, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.dontHaveAccount),
|
|
773
|
+
react_2.default.createElement(LinkButton, { "data-testid": "sign-up-button", className: "text-sm", onClick: () => {
|
|
657
774
|
sendAuth(['RESET', { type: 'INITIALIZE', forgeId }, 'SIGN_UP']);
|
|
658
775
|
} }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.signUp)))));
|
|
659
776
|
}, [
|
|
@@ -672,25 +789,30 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
672
789
|
isConditionalMediationAvailable,
|
|
673
790
|
sendAuth,
|
|
674
791
|
socialProviders,
|
|
792
|
+
// Without this the memo keeps the subtree from the first render, when the
|
|
793
|
+
// row had not been measured yet, and Google's button stays at its default
|
|
794
|
+
// width while Microsoft's fills the card.
|
|
795
|
+
socialButtonWidth,
|
|
675
796
|
dictionary,
|
|
676
797
|
handleSubmitEmail,
|
|
677
798
|
onSubmitEmail,
|
|
678
799
|
handlePasskeyButton,
|
|
679
|
-
|
|
800
|
+
handleGoogleCredential,
|
|
680
801
|
handleMicrosoftLogin,
|
|
681
802
|
onlyPasskeyLogin,
|
|
682
803
|
requireEmailVerification,
|
|
683
804
|
errorObj,
|
|
684
805
|
hasDisplayError,
|
|
806
|
+
getTextAlignment,
|
|
685
807
|
]);
|
|
686
808
|
const SelectLoginMethod = (0, react_2.useMemo)(() => {
|
|
687
809
|
const { authErrorTitle, authErrorDescription } = getAuthError();
|
|
688
810
|
return (react_2.default.createElement("div", null,
|
|
689
811
|
react_2.default.createElement(BackButton, { disabled: isLoading, onClick: () => sendAuth('BACK') }, dictionary === null || dictionary === void 0 ? void 0 : dictionary.back),
|
|
690
|
-
hasDisplayError ? (react_2.default.createElement("div", { className: `my-
|
|
691
|
-
react_2.default.createElement("span", { className: `font-poppins text-alr-red text-
|
|
692
|
-
react_2.default.createElement("span", { className: `text-alr-grey font-medium ${getTextAlignment}` }, authErrorDescription),
|
|
693
|
-
(errorObj === null || errorObj === void 0 ? void 0 : errorObj.code) && (react_2.default.createElement("span", { className: `text-xs text-gray-500 ${getTextAlignment}` }, `${loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.errorCode} ${errorObj.code}`)))) : undefined,
|
|
812
|
+
hasDisplayError ? (react_2.default.createElement("div", { className: `my-3 flex flex-col gap-1.5 ${getAlignmentClasses}` },
|
|
813
|
+
react_2.default.createElement("span", { className: `font-poppins text-alr-red text-base font-bold ${getTextAlignment}` }, authErrorTitle),
|
|
814
|
+
react_2.default.createElement("span", { className: `text-alr-grey text-sm font-medium leading-snug ${getTextAlignment}` }, authErrorDescription),
|
|
815
|
+
(errorObj === null || errorObj === void 0 ? void 0 : errorObj.code) && !isExplainedError && (react_2.default.createElement("span", { className: `text-xs text-gray-500 ${getTextAlignment}` }, `${loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.errorCode} ${errorObj.code}`)))) : undefined,
|
|
694
816
|
react_2.default.createElement("div", { className: `mt-4 flex w-full flex-col ${getAlignmentClasses}`, "data-testid": "login-method-selection-step" },
|
|
695
817
|
isLoading && react_2.default.createElement(flowbite_react_1.Spinner, { className: "mr-3 !h-5 w-full !fill-gray-300" }),
|
|
696
818
|
react_2.default.createElement("span", { className: `font-poppins text-alr-grey mb-6 text-2xl font-bold md:text-[1.75rem] ${getTextAlignment}` }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.selectMethodTitle),
|
|
@@ -735,14 +857,14 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
735
857
|
react_2.default.createElement("span", { className: "text-alr-grey text-center font-medium" }, authErrorDescription),
|
|
736
858
|
(errorObj === null || errorObj === void 0 ? void 0 : errorObj.code) && (react_2.default.createElement("span", { className: "text-center text-xs text-gray-500" }, `${loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.errorCode} ${errorObj.code}`))))),
|
|
737
859
|
react_2.default.createElement("form", { onSubmit: handleSubmitPassword((data) => onSubmitLogin(data)), className: "flex flex-col gap-y-5", "data-testid": "login-password-step" },
|
|
738
|
-
react_2.default.createElement(InputForm, { inputClassName: inputClassName, control: passwordControl, errors: passwordErrors, name: "password", placeholder: loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.enterPassword, icon: lockClosedIcon, type: "password", label: dictionary === null || dictionary === void 0 ? void 0 : dictionary.password, "data-testid": "login-password" }),
|
|
739
|
-
react_2.default.createElement("
|
|
860
|
+
react_2.default.createElement(InputForm, { inputClassName: inputClassName, control: passwordControl, errors: passwordErrors, name: "password", placeholder: loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.enterPassword, icon: lockClosedIcon, type: "password", label: dictionary === null || dictionary === void 0 ? void 0 : dictionary.password, passwordToggleLabel: dictionary === null || dictionary === void 0 ? void 0 : dictionary.auth.togglePasswordVisibility, "data-testid": "login-password" }),
|
|
861
|
+
react_2.default.createElement(LinkButton, { "data-testid": "forgot-password-link", onClick: () => sendAuth('FORGOT_PASSWORD'), className: "text-xs" }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.forgotPassword),
|
|
740
862
|
react_2.default.createElement(flowbite_react_1.Button, { type: "submit", "data-testid": "login-submit", disabled: isLoginSubmitDisabled },
|
|
741
863
|
isLoading && react_2.default.createElement(flowbite_react_1.Spinner, { className: "mr-3 !h-5 w-full !fill-gray-300" }), loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
742
864
|
loginDictionary.login),
|
|
743
|
-
react_2.default.createElement("
|
|
744
|
-
loginDictionary.dontHaveAccount,
|
|
745
|
-
react_2.default.createElement(
|
|
865
|
+
react_2.default.createElement("div", { className: "flex flex-col items-center gap-0.5 text-center text-sm font-medium" },
|
|
866
|
+
react_2.default.createElement("span", null, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.dontHaveAccount),
|
|
867
|
+
react_2.default.createElement(LinkButton, { "data-testid": "sign-up-button", className: "text-sm", onClick: () => {
|
|
746
868
|
sendAuth(['RESET', { type: 'INITIALIZE', forgeId }, 'SIGN_UP']);
|
|
747
869
|
} }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.signUp)))));
|
|
748
870
|
}, [
|
|
@@ -764,6 +886,7 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
764
886
|
onSubmitLogin,
|
|
765
887
|
forgeId,
|
|
766
888
|
isLoginSubmitDisabled,
|
|
889
|
+
getTextAlignment,
|
|
767
890
|
]);
|
|
768
891
|
const VerifyEmail = (0, react_2.useMemo)(() => (react_2.default.createElement("div", { "data-testid": "login-verify-email-step" },
|
|
769
892
|
react_2.default.createElement(BackButton, { className: "mb-4", disabled: isLoading, onClick: () => sendAuth('BACK') }, dictionary === null || dictionary === void 0 ? void 0 : dictionary.back),
|
|
@@ -778,9 +901,7 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
778
901
|
react_2.default.createElement(flowbite_react_1.Button, { "data-testid": "secure-code-submit", onClick: () => onClickSecureCodeSubmit(), className: "group relative mb-6 flex w-full items-center justify-center rounded-lg border border-transparent bg-[--primary-color] p-0.5 text-center font-medium text-white duration-300 hover:bg-[--primary-hover] focus:z-10 focus:outline-none focus:ring-2 focus:ring-red-300 enabled:hover:bg-red-700 disabled:hover:bg-red-900 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900 dark:enabled:hover:bg-red-700 dark:disabled:hover:bg-red-600", disabled: secureCode2FA.length !== 6 || isLoading },
|
|
779
902
|
isLoading && react_2.default.createElement(flowbite_react_1.Spinner, { className: "mr-3 !h-5 w-full !fill-gray-300" }), loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
780
903
|
loginDictionary.confirmCode),
|
|
781
|
-
react_2.default.createElement("
|
|
782
|
-
? 'pointer-events-none opacity-50'
|
|
783
|
-
: 'cursor-pointer opacity-100 hover:text-[--primary-hover]') }, `${loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.resendCode}${sendEmailCooldown ? ` (${sendEmailCooldown}s)` : ''}`)))), [
|
|
904
|
+
react_2.default.createElement(LinkButton, { "data-testid": "resend-code-button", onClick: () => resendSecureCode(), disabled: sendEmailCooldown > 0, className: (0, tailwind_merge_1.twMerge)(`text-base`, sendEmailCooldown > 0 ? 'opacity-50' : 'opacity-100') }, `${loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.resendCode}${sendEmailCooldown ? ` (${sendEmailCooldown}s)` : ''}`)))), [
|
|
784
905
|
secureCode2FA,
|
|
785
906
|
sendEmailCooldown,
|
|
786
907
|
isLoading,
|
|
@@ -795,6 +916,30 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
795
916
|
onClickSecureCodeSubmit,
|
|
796
917
|
resendSecureCode,
|
|
797
918
|
]);
|
|
919
|
+
// Shown when the provider's word on the address is not enough — Microsoft's
|
|
920
|
+
// never is — and the backend has emailed a code to the address the token
|
|
921
|
+
// claimed. No trust-this-device box: there is no password step behind this
|
|
922
|
+
// one to skip next time.
|
|
923
|
+
const VerifySocialEmail = (0, react_2.useMemo)(() => (react_2.default.createElement("div", { "data-testid": "login-social-verify-email-step" },
|
|
924
|
+
react_2.default.createElement(BackButton, { className: "mb-4", disabled: isLoading, onClick: () => sendAuth('BACK') }, dictionary === null || dictionary === void 0 ? void 0 : dictionary.back),
|
|
925
|
+
react_2.default.createElement("div", { className: `flex w-full flex-col ${getAlignmentClasses}` },
|
|
926
|
+
react_2.default.createElement("span", { className: `font-poppins text-alr-grey mb-4 mt-2 text-[1.75rem] font-bold ${getTextAlignment}` }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.verifyEmail),
|
|
927
|
+
react_2.default.createElement("span", { className: `mb-6 font-medium text-gray-600 ${getTextAlignment}` }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.verifyEmailDescription),
|
|
928
|
+
react_2.default.createElement("div", { className: "mb-6 flex" },
|
|
929
|
+
react_2.default.createElement(InputOTP, { className: "child:gap-x-3 md:child:gap-x-5 [&>div>input]:!h-9 [&>div>input]:!w-9", value: socialEmailCode, onChange: (value) => setSocialEmailCode(value), inputLength: 6, "data-testid": "social-email-code", errorMessage: displayError, disabled: isLoading })),
|
|
930
|
+
react_2.default.createElement(flowbite_react_1.Button, { "data-testid": "social-email-code-submit", onClick: () => onSubmitSocialEmailCode(), className: "group relative mb-6 flex w-full items-center justify-center rounded-lg border border-transparent bg-[--primary-color] p-0.5 text-center font-medium text-white duration-300 hover:bg-[--primary-hover] focus:z-10 focus:outline-none focus:ring-2 focus:ring-red-300 enabled:hover:bg-red-700 disabled:hover:bg-red-900 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900 dark:enabled:hover:bg-red-700 dark:disabled:hover:bg-red-600", disabled: socialEmailCode.length !== 6 || isLoading },
|
|
931
|
+
isLoading && react_2.default.createElement(flowbite_react_1.Spinner, { className: "mr-3 !h-5 w-full !fill-gray-300" }), loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
932
|
+
loginDictionary.confirmCode)))), [
|
|
933
|
+
socialEmailCode,
|
|
934
|
+
isLoading,
|
|
935
|
+
displayError,
|
|
936
|
+
getAlignmentClasses,
|
|
937
|
+
getTextAlignment,
|
|
938
|
+
dictionary,
|
|
939
|
+
loginDictionary,
|
|
940
|
+
sendAuth,
|
|
941
|
+
onSubmitSocialEmailCode,
|
|
942
|
+
]);
|
|
798
943
|
const VerifyHw2FAStep = (0, react_2.useMemo)(() => (react_2.default.createElement("div", null,
|
|
799
944
|
react_2.default.createElement(BackButton, { onClick: () => sendAuth('BACK') }),
|
|
800
945
|
(displayError === null || displayError === void 0 ? void 0 : displayError.includes('Failed authenticating with hardware key')) ? (react_2.default.createElement("div", { className: `mt-6 flex w-full flex-col gap-6 ${getAlignmentClasses}` },
|
|
@@ -803,16 +948,16 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
803
948
|
react_2.default.createElement(flowbite_react_1.Button, { className: "bg-alr-red hover:bg-alr-dark-red group relative flex w-full items-center justify-center rounded-lg border border-transparent p-0.5 text-center font-medium text-white duration-300 focus:z-10 focus:outline-none focus:ring-2 focus:ring-red-300 enabled:hover:bg-red-700 disabled:hover:bg-red-900 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900 dark:enabled:hover:bg-red-700 dark:disabled:hover:bg-red-600", onClick: () => startHwAuth(0) }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.tryAgain),
|
|
804
949
|
(activeHw2fa === null || activeHw2fa === void 0 ? void 0 : activeHw2fa.length) > 1 && (react_2.default.createElement(react_2.default.Fragment, null,
|
|
805
950
|
react_2.default.createElement("span", null, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.tryHardware),
|
|
806
|
-
react_2.default.createElement(
|
|
951
|
+
react_2.default.createElement(LinkButton, { "data-testid": "use-another-hardware-button", className: "flex items-center gap-x-1 text-base font-semibold", onClick: () => startHwAuth(1) }, loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
807
952
|
loginDictionary.useAnotherHardware,
|
|
808
953
|
react_2.default.createElement(solid_1.ArrowRightIcon, { className: "size-5" })))),
|
|
809
|
-
activeSw2fa && (react_2.default.createElement(
|
|
954
|
+
activeSw2fa && (react_2.default.createElement(LinkButton, { "data-testid": "use-software-2fa-button", className: "flex items-center gap-x-1 text-base font-semibold", onClick: () => sendAuth('USE_SOFTWARE_2FA') }, loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
810
955
|
loginDictionary.useSw2fa,
|
|
811
956
|
react_2.default.createElement(solid_1.ArrowRightIcon, { className: "size-5" }))))) : (react_2.default.createElement("div", { className: `flex w-full flex-col ${getAlignmentClasses}` },
|
|
812
957
|
react_2.default.createElement("span", { className: `font-poppins text-alr-grey mb-10 mt-12 text-[1.3rem] font-bold ${getTextAlignment}` }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.touchHardware),
|
|
813
958
|
react_2.default.createElement("span", { className: `text-alr-grey mb-10 w-60 text-sm font-normal ${getTextAlignment}` }, loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.touchHardwareDescription),
|
|
814
959
|
react_2.default.createElement("img", { alt: "usb indicator", src: utils_1.fingerprint }),
|
|
815
|
-
activeSw2fa && (react_2.default.createElement(
|
|
960
|
+
activeSw2fa && (react_2.default.createElement(LinkButton, { "data-testid": "use-software-2fa-button", className: "mt-9 flex items-center gap-x-1 text-base font-semibold", onClick: () => sendAuth('USE_SOFTWARE_2FA') }, loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
816
961
|
loginDictionary.useSw2fa,
|
|
817
962
|
react_2.default.createElement(solid_1.ArrowRightIcon, { className: "size-5" }))))))), [
|
|
818
963
|
isLoading,
|
|
@@ -835,7 +980,7 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
835
980
|
react_2.default.createElement(flowbite_react_1.Button, { "data-testid": "secure-code-2FA-submit", onClick: () => onSubmitSecureCode2FA(), className: "bg-alr-red hover:bg-alr-dark-red group relative mb-6 flex w-full items-center justify-center rounded-lg border border-transparent p-0.5 text-center font-medium text-white duration-300 focus:z-10 focus:outline-none focus:ring-2 focus:ring-red-300 enabled:hover:bg-red-700 disabled:hover:bg-red-900 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900 dark:enabled:hover:bg-red-700 dark:disabled:hover:bg-red-600", disabled: secureCode2FA.length !== 6 },
|
|
836
981
|
isLoading && react_2.default.createElement(flowbite_react_1.Spinner, { className: "mr-3 !h-5 w-full !fill-gray-300" }), loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
837
982
|
loginDictionary.confirmCode),
|
|
838
|
-
(active2fa === null || active2fa === void 0 ? void 0 : active2fa.find((item) => item.twoFaTypeId === HARDWARE)) && (react_2.default.createElement(
|
|
983
|
+
(active2fa === null || active2fa === void 0 ? void 0 : active2fa.find((item) => item.twoFaTypeId === HARDWARE)) && (react_2.default.createElement(LinkButton, { "data-testid": "use-hardware-2fa-button", className: "mt-9 flex items-center gap-x-1 text-base font-semibold", onClick: () => sendAuth('USE_HARDWARE_2FA') }, loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
839
984
|
loginDictionary.useHw2fa,
|
|
840
985
|
react_2.default.createElement(solid_1.ArrowRightIcon, { className: "size-5" })))))), [
|
|
841
986
|
secureCode2FA,
|
|
@@ -860,9 +1005,7 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
860
1005
|
react_2.default.createElement(flowbite_react_1.Button, { "data-testid": "secure-code-email-submit", onClick: () => onSubmitSecureCodeEmail(), className: "bg-alr-red hover:bg-alr-dark-red group relative mb-6 flex w-full items-center justify-center rounded-lg border border-transparent p-0.5 text-center font-medium text-white duration-300 focus:z-10 focus:outline-none focus:ring-2 focus:ring-red-300 enabled:hover:bg-red-700 disabled:hover:bg-red-900 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900 dark:enabled:hover:bg-red-700 dark:disabled:hover:bg-red-600", disabled: secureCodeEmail.length !== 6 },
|
|
861
1006
|
isLoading && react_2.default.createElement(flowbite_react_1.Spinner, { className: "mr-3 !h-5 w-full !fill-gray-300" }), loginDictionary === null || loginDictionary === void 0 ? void 0 :
|
|
862
1007
|
loginDictionary.confirmCode),
|
|
863
|
-
react_2.default.createElement("
|
|
864
|
-
? 'pointer-events-none opacity-50'
|
|
865
|
-
: 'hover:text-alr-red cursor-pointer opacity-100') }, `${loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.resendCode}${sendEmailCooldown ? ` (${sendEmailCooldown}s)` : ''}`)))), [
|
|
1008
|
+
react_2.default.createElement(LinkButton, { "data-testid": "resend-code-button", onClick: () => resendSecureCode(), disabled: sendEmailCooldown > 0, className: (0, tailwind_merge_1.twMerge)(`text-base`, sendEmailCooldown > 0 ? 'opacity-50' : 'opacity-100') }, `${loginDictionary === null || loginDictionary === void 0 ? void 0 : loginDictionary.resendCode}${sendEmailCooldown ? ` (${sendEmailCooldown}s)` : ''}`)))), [
|
|
866
1009
|
secureCodeEmail,
|
|
867
1010
|
sendEmailCooldown,
|
|
868
1011
|
isLoading,
|
|
@@ -897,7 +1040,10 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
897
1040
|
}, [customStyles]);
|
|
898
1041
|
if (authState.matches('active.login.successfulLogin'))
|
|
899
1042
|
return null;
|
|
900
|
-
return (react_2.default.createElement("div", {
|
|
1043
|
+
return (react_2.default.createElement("div", {
|
|
1044
|
+
// min-h-full, not min-h-screen: this renders inside the consuming app's
|
|
1045
|
+
// own card, and a viewport-height floor stretches that card to the window.
|
|
1046
|
+
className: `flex size-full min-h-full flex-col items-center justify-center ${titleSpacing}`, "data-testid": "login-page" },
|
|
901
1047
|
forgeId ? (react_2.default.createElement("div", { className: "flex flex-col" },
|
|
902
1048
|
react_2.default.createElement("span", { className: "font-poppins text-alr-grey text-center text-2xl font-black" }, "Tardezinha com Thiaguinho"),
|
|
903
1049
|
react_2.default.createElement("div", { className: "flex w-full flex-row items-center justify-center gap-2" },
|
|
@@ -928,6 +1074,9 @@ const Login = ({ locale = 'pt', authServiceInstance, forgeId, logoImage, keyshar
|
|
|
928
1074
|
authState.matches('active.login.resendingEmailCode') ||
|
|
929
1075
|
authState.matches('active.login.verifyingEmail2fa')) &&
|
|
930
1076
|
VerifyEmail,
|
|
1077
|
+
(authState.matches('active.login.socialEmailCode') ||
|
|
1078
|
+
(authState.matches('active.login.socialLogin') && !!socialChallenge)) &&
|
|
1079
|
+
VerifySocialEmail,
|
|
931
1080
|
(authState.matches('active.login.hardware2fa') ||
|
|
932
1081
|
authState.matches('active.login.verifyingHwAuth')) &&
|
|
933
1082
|
VerifyHw2FAStep,
|