@joelbarron/react-web-dev-kit 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -160
- package/package.json +9 -2
- package/dist/auth/client.d.ts +0 -46
- package/dist/auth/client.d.ts.map +0 -1
- package/dist/auth/client.js +0 -379
- package/dist/auth/constants/countryCallingCodes.d.ts +0 -9
- package/dist/auth/constants/countryCallingCodes.d.ts.map +0 -1
- package/dist/auth/constants/countryCallingCodes.js +0 -209
- package/dist/auth/constants/gender.d.ts +0 -9
- package/dist/auth/constants/gender.d.ts.map +0 -1
- package/dist/auth/constants/gender.js +0 -12
- package/dist/auth/constants/index.d.ts +0 -3
- package/dist/auth/constants/index.d.ts.map +0 -1
- package/dist/auth/constants/index.js +0 -2
- package/dist/auth/forms/account/AuthAccountConfirmationForm.d.ts +0 -18
- package/dist/auth/forms/account/AuthAccountConfirmationForm.d.ts.map +0 -1
- package/dist/auth/forms/account/AuthAccountConfirmationForm.js +0 -167
- package/dist/auth/forms/account/index.d.ts +0 -2
- package/dist/auth/forms/account/index.d.ts.map +0 -1
- package/dist/auth/forms/account/index.js +0 -1
- package/dist/auth/forms/errorParser.d.ts +0 -7
- package/dist/auth/forms/errorParser.d.ts.map +0 -1
- package/dist/auth/forms/errorParser.js +0 -65
- package/dist/auth/forms/index.d.ts +0 -6
- package/dist/auth/forms/index.d.ts.map +0 -1
- package/dist/auth/forms/index.js +0 -5
- package/dist/auth/forms/password/AuthForgotPasswordForm.d.ts +0 -16
- package/dist/auth/forms/password/AuthForgotPasswordForm.d.ts.map +0 -1
- package/dist/auth/forms/password/AuthForgotPasswordForm.js +0 -109
- package/dist/auth/forms/password/AuthPasswordResetConfirmForm.d.ts +0 -17
- package/dist/auth/forms/password/AuthPasswordResetConfirmForm.d.ts.map +0 -1
- package/dist/auth/forms/password/AuthPasswordResetConfirmForm.js +0 -163
- package/dist/auth/forms/password/AuthResetPasswordForm.d.ts +0 -12
- package/dist/auth/forms/password/AuthResetPasswordForm.d.ts.map +0 -1
- package/dist/auth/forms/password/AuthResetPasswordForm.js +0 -22
- package/dist/auth/forms/password/index.d.ts +0 -4
- package/dist/auth/forms/password/index.d.ts.map +0 -1
- package/dist/auth/forms/password/index.js +0 -3
- package/dist/auth/forms/password/passwordValidation.d.ts +0 -3
- package/dist/auth/forms/password/passwordValidation.d.ts.map +0 -1
- package/dist/auth/forms/password/passwordValidation.js +0 -45
- package/dist/auth/forms/sign-in/AuthOtpSignInForm.d.ts +0 -24
- package/dist/auth/forms/sign-in/AuthOtpSignInForm.d.ts.map +0 -1
- package/dist/auth/forms/sign-in/AuthOtpSignInForm.js +0 -227
- package/dist/auth/forms/sign-in/AuthPasswordSignInForm.d.ts +0 -22
- package/dist/auth/forms/sign-in/AuthPasswordSignInForm.d.ts.map +0 -1
- package/dist/auth/forms/sign-in/AuthPasswordSignInForm.js +0 -148
- package/dist/auth/forms/sign-in/index.d.ts +0 -3
- package/dist/auth/forms/sign-in/index.d.ts.map +0 -1
- package/dist/auth/forms/sign-in/index.js +0 -2
- package/dist/auth/forms/sign-up/AuthSignUpForm.d.ts +0 -37
- package/dist/auth/forms/sign-up/AuthSignUpForm.d.ts.map +0 -1
- package/dist/auth/forms/sign-up/AuthSignUpForm.js +0 -193
- package/dist/auth/forms/sign-up/index.d.ts +0 -2
- package/dist/auth/forms/sign-up/index.d.ts.map +0 -1
- package/dist/auth/forms/sign-up/index.js +0 -1
- package/dist/auth/fuse/createFuseAuthViews.d.ts +0 -25
- package/dist/auth/fuse/createFuseAuthViews.d.ts.map +0 -1
- package/dist/auth/fuse/createFuseAuthViews.js +0 -510
- package/dist/auth/fuse/fuseAdapter.d.ts +0 -42
- package/dist/auth/fuse/fuseAdapter.d.ts.map +0 -1
- package/dist/auth/fuse/fuseAdapter.js +0 -291
- package/dist/auth/fuse/fuseIntegration.d.ts +0 -61
- package/dist/auth/fuse/fuseIntegration.d.ts.map +0 -1
- package/dist/auth/fuse/fuseIntegration.js +0 -103
- package/dist/auth/fuse/index.d.ts +0 -4
- package/dist/auth/fuse/index.d.ts.map +0 -1
- package/dist/auth/fuse/index.js +0 -3
- package/dist/auth/index.d.ts +0 -11
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js +0 -10
- package/dist/auth/provider.d.ts +0 -35
- package/dist/auth/provider.d.ts.map +0 -1
- package/dist/auth/provider.js +0 -133
- package/dist/auth/query.d.ts +0 -23
- package/dist/auth/query.d.ts.map +0 -1
- package/dist/auth/query.js +0 -103
- package/dist/auth/routes.d.ts +0 -37
- package/dist/auth/routes.d.ts.map +0 -1
- package/dist/auth/routes.js +0 -75
- package/dist/auth/social/providerAuth.d.ts +0 -101
- package/dist/auth/social/providerAuth.d.ts.map +0 -1
- package/dist/auth/social/providerAuth.js +0 -207
- package/dist/auth/storage.d.ts +0 -3
- package/dist/auth/storage.d.ts.map +0 -1
- package/dist/auth/storage.js +0 -20
- package/dist/auth/types.d.ts +0 -238
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js +0 -1
- package/dist/auth/ui/AuthPageTitle.d.ts +0 -7
- package/dist/auth/ui/AuthPageTitle.d.ts.map +0 -1
- package/dist/auth/ui/AuthPageTitle.js +0 -7
- package/dist/auth/ui/AuthPagesMessageSection.d.ts +0 -3
- package/dist/auth/ui/AuthPagesMessageSection.d.ts.map +0 -1
- package/dist/auth/ui/AuthPagesMessageSection.js +0 -39
- package/dist/auth/ui/AuthPrimaryButton.d.ts +0 -9
- package/dist/auth/ui/AuthPrimaryButton.d.ts.map +0 -1
- package/dist/auth/ui/AuthPrimaryButton.js +0 -19
- package/dist/auth/ui/AuthRoleSelectionDialog.d.ts +0 -14
- package/dist/auth/ui/AuthRoleSelectionDialog.d.ts.map +0 -1
- package/dist/auth/ui/AuthRoleSelectionDialog.js +0 -39
- package/dist/auth/ui/AuthRoutePageWrapper.d.ts +0 -12
- package/dist/auth/ui/AuthRoutePageWrapper.d.ts.map +0 -1
- package/dist/auth/ui/AuthRoutePageWrapper.js +0 -61
- package/dist/auth/ui/AuthSecondaryButton.d.ts +0 -7
- package/dist/auth/ui/AuthSecondaryButton.d.ts.map +0 -1
- package/dist/auth/ui/AuthSecondaryButton.js +0 -18
- package/dist/auth/ui/AuthSocialProviderButton.d.ts +0 -11
- package/dist/auth/ui/AuthSocialProviderButton.d.ts.map +0 -1
- package/dist/auth/ui/AuthSocialProviderButton.js +0 -33
- package/dist/auth/ui/index.d.ts +0 -9
- package/dist/auth/ui/index.d.ts.map +0 -1
- package/dist/auth/ui/index.js +0 -8
- package/dist/auth/ui/types.d.ts +0 -15
- package/dist/auth/ui/types.d.ts.map +0 -1
- package/dist/auth/ui/types.js +0 -1
- package/dist/config/createConfig.d.ts +0 -14
- package/dist/config/createConfig.d.ts.map +0 -1
- package/dist/config/createConfig.js +0 -179
- package/dist/config/defaults.d.ts +0 -3
- package/dist/config/defaults.d.ts.map +0 -1
- package/dist/config/defaults.js +0 -39
- package/dist/config/index.d.ts +0 -5
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -4
- package/dist/config/merge.d.ts +0 -2
- package/dist/config/merge.d.ts.map +0 -1
- package/dist/config/merge.js +0 -18
- package/dist/config/types.d.ts +0 -53
- package/dist/config/types.d.ts.map +0 -1
- package/dist/config/types.js +0 -1
- package/dist/core/buttons/JBButton.d.ts +0 -8
- package/dist/core/buttons/JBButton.d.ts.map +0 -1
- package/dist/core/buttons/JBButton.js +0 -55
- package/dist/core/buttons/index.d.ts +0 -2
- package/dist/core/buttons/index.d.ts.map +0 -1
- package/dist/core/buttons/index.js +0 -1
- package/dist/core/dialogs/JBConfirmDialog.d.ts +0 -15
- package/dist/core/dialogs/JBConfirmDialog.d.ts.map +0 -1
- package/dist/core/dialogs/JBConfirmDialog.js +0 -6
- package/dist/core/dialogs/index.d.ts +0 -2
- package/dist/core/dialogs/index.d.ts.map +0 -1
- package/dist/core/dialogs/index.js +0 -1
- package/dist/core/index.d.ts +0 -5
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -4
- package/dist/core/layout/JBContentContainer.d.ts +0 -31
- package/dist/core/layout/JBContentContainer.d.ts.map +0 -1
- package/dist/core/layout/JBContentContainer.js +0 -50
- package/dist/core/layout/JBFormHeader.d.ts +0 -3
- package/dist/core/layout/JBFormHeader.d.ts.map +0 -1
- package/dist/core/layout/JBFormHeader.js +0 -131
- package/dist/core/layout/index.d.ts +0 -3
- package/dist/core/layout/index.d.ts.map +0 -1
- package/dist/core/layout/index.js +0 -2
- package/dist/core/skeletons/JBFormContentSkeleton.d.ts +0 -5
- package/dist/core/skeletons/JBFormContentSkeleton.d.ts.map +0 -1
- package/dist/core/skeletons/JBFormContentSkeleton.js +0 -12
- package/dist/core/skeletons/JBFormHeaderSkeleton.d.ts +0 -6
- package/dist/core/skeletons/JBFormHeaderSkeleton.d.ts.map +0 -1
- package/dist/core/skeletons/JBFormHeaderSkeleton.js +0 -19
- package/dist/core/skeletons/index.d.ts +0 -3
- package/dist/core/skeletons/index.d.ts.map +0 -1
- package/dist/core/skeletons/index.js +0 -2
- package/dist/forms/JBAutocompleteField.d.ts +0 -12
- package/dist/forms/JBAutocompleteField.d.ts.map +0 -1
- package/dist/forms/JBAutocompleteField.js +0 -20
- package/dist/forms/JBCheckboxField.d.ts +0 -12
- package/dist/forms/JBCheckboxField.d.ts.map +0 -1
- package/dist/forms/JBCheckboxField.js +0 -36
- package/dist/forms/JBDatePickerField.d.ts +0 -13
- package/dist/forms/JBDatePickerField.d.ts.map +0 -1
- package/dist/forms/JBDatePickerField.js +0 -49
- package/dist/forms/JBRadioGroupField.d.ts +0 -10
- package/dist/forms/JBRadioGroupField.d.ts.map +0 -1
- package/dist/forms/JBRadioGroupField.js +0 -8
- package/dist/forms/JBSelectField.d.ts +0 -9
- package/dist/forms/JBSelectField.d.ts.map +0 -1
- package/dist/forms/JBSelectField.js +0 -8
- package/dist/forms/JBSwitchField.d.ts +0 -11
- package/dist/forms/JBSwitchField.d.ts.map +0 -1
- package/dist/forms/JBSwitchField.js +0 -10
- package/dist/forms/JBTextField.d.ts +0 -6
- package/dist/forms/JBTextField.d.ts.map +0 -1
- package/dist/forms/JBTextField.js +0 -8
- package/dist/forms/JBTimePickerField.d.ts +0 -12
- package/dist/forms/JBTimePickerField.d.ts.map +0 -1
- package/dist/forms/JBTimePickerField.js +0 -17
- package/dist/forms/index.d.ts +0 -13
- package/dist/forms/index.d.ts.map +0 -1
- package/dist/forms/index.js +0 -12
- package/dist/forms/rules.d.ts +0 -16
- package/dist/forms/rules.d.ts.map +0 -1
- package/dist/forms/rules.js +0 -21
- package/dist/forms/types.d.ts +0 -12
- package/dist/forms/types.d.ts.map +0 -1
- package/dist/forms/types.js +0 -1
- package/dist/forms/utils.d.ts +0 -5
- package/dist/forms/utils.d.ts.map +0 -1
- package/dist/forms/utils.js +0 -7
- package/dist/forms/zod.d.ts +0 -4
- package/dist/forms/zod.d.ts.map +0 -1
- package/dist/forms/zod.js +0 -9
- package/dist/grid/JBGrid.d.ts +0 -3
- package/dist/grid/JBGrid.d.ts.map +0 -1
- package/dist/grid/JBGrid.js +0 -338
- package/dist/grid/JBGridHeader.d.ts +0 -3
- package/dist/grid/JBGridHeader.d.ts.map +0 -1
- package/dist/grid/JBGridHeader.js +0 -93
- package/dist/grid/JBGridLoading.d.ts +0 -9
- package/dist/grid/JBGridLoading.d.ts.map +0 -1
- package/dist/grid/JBGridLoading.js +0 -14
- package/dist/grid/JBGridProviders.d.ts +0 -13
- package/dist/grid/JBGridProviders.d.ts.map +0 -1
- package/dist/grid/JBGridProviders.js +0 -54
- package/dist/grid/JBGridSkeleton.d.ts +0 -7
- package/dist/grid/JBGridSkeleton.d.ts.map +0 -1
- package/dist/grid/JBGridSkeleton.js +0 -6
- package/dist/grid/defaults.d.ts +0 -4
- package/dist/grid/defaults.d.ts.map +0 -1
- package/dist/grid/defaults.js +0 -29
- package/dist/grid/index.d.ts +0 -8
- package/dist/grid/index.d.ts.map +0 -1
- package/dist/grid/index.js +0 -7
- package/dist/grid/types.d.ts +0 -197
- package/dist/grid/types.d.ts.map +0 -1
- package/dist/grid/types.js +0 -1
- package/dist/hooks/index.d.ts +0 -4
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -3
- package/dist/hooks/useJBDebouncedValue.d.ts +0 -2
- package/dist/hooks/useJBDebouncedValue.d.ts.map +0 -1
- package/dist/hooks/useJBDebouncedValue.js +0 -11
- package/dist/hooks/useJBEntityFormController.d.ts +0 -54
- package/dist/hooks/useJBEntityFormController.d.ts.map +0 -1
- package/dist/hooks/useJBEntityFormController.js +0 -156
- package/dist/hooks/useJBRedirect.d.ts +0 -10
- package/dist/hooks/useJBRedirect.d.ts.map +0 -1
- package/dist/hooks/useJBRedirect.js +0 -11
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/query/createQueryClient.d.ts +0 -8
- package/dist/query/createQueryClient.d.ts.map +0 -1
- package/dist/query/createQueryClient.js +0 -25
- package/dist/query/http.d.ts +0 -3
- package/dist/query/http.d.ts.map +0 -1
- package/dist/query/http.js +0 -12
- package/dist/query/index.d.ts +0 -4
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/index.js +0 -3
- package/dist/query/types.d.ts +0 -7
- package/dist/query/types.d.ts.map +0 -1
- package/dist/query/types.js +0 -1
- package/dist/utils/errors.d.ts +0 -10
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -55
- package/dist/utils/format.d.ts +0 -4
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js +0 -28
- package/dist/utils/geo.d.ts +0 -9
- package/dist/utils/geo.d.ts.map +0 -1
- package/dist/utils/geo.js +0 -186
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -5
- package/dist/utils/query.d.ts +0 -2
- package/dist/utils/query.d.ts.map +0 -1
- package/dist/utils/query.js +0 -4
- package/dist/utils/regex.d.ts +0 -7
- package/dist/utils/regex.d.ts.map +0 -1
- package/dist/utils/regex.js +0 -6
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import ArrowBackOutlinedIcon from '@mui/icons-material/ArrowBackOutlined';
|
|
3
|
-
import EmailOutlinedIcon from '@mui/icons-material/EmailOutlined';
|
|
4
|
-
import PersonAddAlt1OutlinedIcon from '@mui/icons-material/PersonAddAlt1Outlined';
|
|
5
|
-
import Alert from "@mui/material/Alert";
|
|
6
|
-
import Box from "@mui/material/Box";
|
|
7
|
-
import Typography from "@mui/material/Typography";
|
|
8
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
9
|
-
import { useNavigate, useSearchParams } from "react-router";
|
|
10
|
-
import { AuthAccountConfirmationForm, AuthForgotPasswordForm, AuthOtpSignInForm, AuthPasswordResetConfirmForm, AuthPasswordSignInForm, AuthSignUpForm, } from "../forms";
|
|
11
|
-
import { parseAuthError } from "../forms/errorParser";
|
|
12
|
-
import { authenticateWithSocialProvider } from "../social/providerAuth";
|
|
13
|
-
import { AuthPageTitle, AuthRoleSelectionDialog, AuthSecondaryButton, AuthSocialProviderButton, } from "../ui";
|
|
14
|
-
import { useFuseJwtAuth } from "./fuseAdapter";
|
|
15
|
-
const IS_DEV = typeof window !== "undefined" && window.location.hostname === "localhost";
|
|
16
|
-
const DEV_LOGIN_DEFAULT_VALUES = IS_DEV
|
|
17
|
-
? {
|
|
18
|
-
login: "admin",
|
|
19
|
-
password: "Test123_",
|
|
20
|
-
remember: true,
|
|
21
|
-
}
|
|
22
|
-
: undefined;
|
|
23
|
-
const DEV_SIGN_UP_DEFAULT_VALUES = IS_DEV
|
|
24
|
-
? {
|
|
25
|
-
firstName: "Joel",
|
|
26
|
-
lastName1: "Barron",
|
|
27
|
-
lastName2: "Hernandez",
|
|
28
|
-
email: "joel.test+1@example.com",
|
|
29
|
-
birthday: "1995-12-16",
|
|
30
|
-
gender: "MALE",
|
|
31
|
-
password: "Test123_",
|
|
32
|
-
passwordConfirm: "Test123_",
|
|
33
|
-
acceptTermsConditions: true,
|
|
34
|
-
}
|
|
35
|
-
: undefined;
|
|
36
|
-
const DEV_OTP_DEFAULT_VALUES = IS_DEV
|
|
37
|
-
? {
|
|
38
|
-
countryCode: "+52",
|
|
39
|
-
phone: "5512345678",
|
|
40
|
-
code: "",
|
|
41
|
-
}
|
|
42
|
-
: undefined;
|
|
43
|
-
const SOCIAL_PROVIDER_ORDER = ["google", "facebook", "apple"];
|
|
44
|
-
const parseBooleanLike = (value) => {
|
|
45
|
-
if (typeof value === "boolean") {
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
if (typeof value === "string") {
|
|
49
|
-
const normalized = value.trim().toLowerCase();
|
|
50
|
-
if (normalized === "true") {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
if (normalized === "false") {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (typeof value === "number") {
|
|
58
|
-
if (value === 1) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
if (value === 0) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return undefined;
|
|
66
|
-
};
|
|
67
|
-
const shouldSelectRoleForSocialLogin = (precheckResponse, hasRoleOptions) => {
|
|
68
|
-
if (!hasRoleOptions) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
const userExists = parseBooleanLike(precheckResponse.userExists) ??
|
|
72
|
-
parseBooleanLike(precheckResponse.user_exists);
|
|
73
|
-
if (typeof userExists === "boolean") {
|
|
74
|
-
return !userExists;
|
|
75
|
-
}
|
|
76
|
-
const wouldCreateUser = parseBooleanLike(precheckResponse.wouldCreateUser) ??
|
|
77
|
-
parseBooleanLike(precheckResponse.would_create_user);
|
|
78
|
-
if (typeof wouldCreateUser === "boolean") {
|
|
79
|
-
return wouldCreateUser;
|
|
80
|
-
}
|
|
81
|
-
const socialAccountExists = parseBooleanLike(precheckResponse.socialAccountExists) ??
|
|
82
|
-
parseBooleanLike(precheckResponse.social_account_exists);
|
|
83
|
-
if (socialAccountExists === true) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
const linkedExistingUser = parseBooleanLike(precheckResponse.linkedExistingUser) ??
|
|
87
|
-
parseBooleanLike(precheckResponse.linked_existing_user);
|
|
88
|
-
if (linkedExistingUser === true) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
return hasRoleOptions;
|
|
92
|
-
};
|
|
93
|
-
function getEnabledSocialProviders(socialConfig, showDebugSocial) {
|
|
94
|
-
if (!socialConfig) {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
return SOCIAL_PROVIDER_ORDER.flatMap((provider) => {
|
|
98
|
-
const providerConfig = socialConfig[provider];
|
|
99
|
-
if (!providerConfig?.enabled || !providerConfig.clientId?.trim()) {
|
|
100
|
-
return [];
|
|
101
|
-
}
|
|
102
|
-
return [
|
|
103
|
-
{
|
|
104
|
-
provider,
|
|
105
|
-
clientId: providerConfig.clientId.trim(),
|
|
106
|
-
redirectUri: providerConfig.redirectUri?.trim() || undefined,
|
|
107
|
-
scope: providerConfig.scope?.trim() || undefined,
|
|
108
|
-
scopes: providerConfig.scopes,
|
|
109
|
-
usePopup: providerConfig.usePopup,
|
|
110
|
-
responseMode: providerConfig.responseMode,
|
|
111
|
-
responseType: providerConfig.responseType,
|
|
112
|
-
state: providerConfig.state,
|
|
113
|
-
nonce: providerConfig.nonce,
|
|
114
|
-
debug: showDebugSocial
|
|
115
|
-
}
|
|
116
|
-
];
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
function FuseSignInController(props) {
|
|
120
|
-
const { LinkComponent, mode = "password", disabled = false, onBackToPassword, requestRoleSelection } = props;
|
|
121
|
-
const { signIn, requestOtp, signInOtp } = useFuseJwtAuth();
|
|
122
|
-
if (mode === "otp") {
|
|
123
|
-
return (_jsx(AuthOtpSignInForm, { defaultValues: DEV_OTP_DEFAULT_VALUES, requestRoleSelection: requestRoleSelection, onBackToPassword: onBackToPassword, onRequestOtp: ({ phone }) => requestOtp({
|
|
124
|
-
channel: "sms",
|
|
125
|
-
phone,
|
|
126
|
-
}), onVerifyOtp: ({ phone, code, role }) => signInOtp({
|
|
127
|
-
channel: "sms",
|
|
128
|
-
phone,
|
|
129
|
-
code,
|
|
130
|
-
role,
|
|
131
|
-
}) }));
|
|
132
|
-
}
|
|
133
|
-
return (_jsx(AuthPasswordSignInForm, { defaultValues: DEV_LOGIN_DEFAULT_VALUES, disabled: disabled, LinkComponent: LinkComponent, onSubmit: (values) => signIn({
|
|
134
|
-
login: values.login,
|
|
135
|
-
password: values.password,
|
|
136
|
-
}) }));
|
|
137
|
-
}
|
|
138
|
-
function FuseSignUpController(props) {
|
|
139
|
-
const { onSuccess, requestRoleSelection, requiresRoleSelection = false, disabled = false } = props;
|
|
140
|
-
const { signUp } = useFuseJwtAuth();
|
|
141
|
-
return (_jsx(AuthSignUpForm, { defaultValues: DEV_SIGN_UP_DEFAULT_VALUES, disabled: disabled, onSubmit: async (values) => {
|
|
142
|
-
const selectedRole = requestRoleSelection
|
|
143
|
-
? await requestRoleSelection()
|
|
144
|
-
: values.role;
|
|
145
|
-
if (requiresRoleSelection && !selectedRole) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const response = await signUp({
|
|
149
|
-
...values,
|
|
150
|
-
role: selectedRole ?? values.role,
|
|
151
|
-
});
|
|
152
|
-
onSuccess?.({
|
|
153
|
-
email: values.email,
|
|
154
|
-
detail: response.detail ?? undefined,
|
|
155
|
-
response
|
|
156
|
-
});
|
|
157
|
-
} }));
|
|
158
|
-
}
|
|
159
|
-
function FuseOtpSignUpForm(props) {
|
|
160
|
-
const { onBackToPassword, requestRoleSelection } = props;
|
|
161
|
-
const { requestOtp, signInOtp } = useFuseJwtAuth();
|
|
162
|
-
return (_jsx(AuthOtpSignInForm, { defaultValues: DEV_OTP_DEFAULT_VALUES, requestRoleSelection: requestRoleSelection, onBackToPassword: onBackToPassword, onRequestOtp: ({ phone }) => requestOtp({
|
|
163
|
-
channel: "sms",
|
|
164
|
-
phone,
|
|
165
|
-
}), onVerifyOtp: ({ phone, code, role }) => signInOtp({
|
|
166
|
-
channel: "sms",
|
|
167
|
-
phone,
|
|
168
|
-
code,
|
|
169
|
-
role,
|
|
170
|
-
}) }));
|
|
171
|
-
}
|
|
172
|
-
function FuseAuthAlternativesSection(props) {
|
|
173
|
-
const { onSmsClick, socialProviders = [], onSocialClick, socialLoadingProvider, socialError } = props;
|
|
174
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: { mt: 4, display: "flex", alignItems: "center" }, children: [_jsx(Box, { sx: { mt: "1px", flex: 1, borderTop: 1, borderColor: "divider" } }), _jsx(Typography, { sx: { mx: 1 }, color: "text.secondary", children: "O accede con" }), _jsx(Box, { sx: { mt: "1px", flex: 1, borderTop: 1, borderColor: "divider" } })] }), _jsxs(Box, { sx: {
|
|
175
|
-
mt: 4,
|
|
176
|
-
display: "grid",
|
|
177
|
-
gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
|
|
178
|
-
gap: 1.5
|
|
179
|
-
}, children: [socialProviders.map((socialProvider) => (_jsx(AuthSocialProviderButton, { provider: socialProvider.provider, loading: socialLoadingProvider === socialProvider.provider, disabled: Boolean(socialLoadingProvider && socialLoadingProvider !== socialProvider.provider), onClick: () => onSocialClick?.(socialProvider.provider) }, socialProvider.provider))), _jsx(AuthSocialProviderButton, { "aria-label": "SMS", provider: "sms", disabled: Boolean(socialLoadingProvider), onClick: onSmsClick, children: "SMS" })] }), socialError ? (_jsx(Alert, { severity: "error", sx: { mt: 2 }, children: socialError })) : null] }));
|
|
180
|
-
}
|
|
181
|
-
function FuseSignUpCtaSection(props) {
|
|
182
|
-
const { LinkComponent, signUpPath = "/sign-up", disabled = false } = props;
|
|
183
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: { mt: 6, display: "flex", alignItems: "center" }, children: [_jsx(Box, { sx: { mt: "1px", flex: 1, borderTop: 1, borderColor: "divider" } }), _jsx(Typography, { sx: { mx: 1 }, color: "text.secondary", children: "\u00BFNo tienes una cuenta?" }), _jsx(Box, { sx: { mt: "1px", flex: 1, borderTop: 1, borderColor: "divider" } })] }), _jsx(Box, { sx: { mt: 2, display: "flex", alignItems: "center", gap: 2 }, children: _jsx(AuthSecondaryButton, { component: LinkComponent, to: signUpPath, sx: { flex: 1 }, disabled: disabled, startIcon: _jsx(PersonAddAlt1OutlinedIcon, { fontSize: "small" }), onClick: (event) => {
|
|
184
|
-
if (disabled) {
|
|
185
|
-
event.preventDefault();
|
|
186
|
-
}
|
|
187
|
-
}, "aria-label": "Crear cuenta", children: "Crear cuenta" }) })] }));
|
|
188
|
-
}
|
|
189
|
-
function FuseSignInCtaSection(props) {
|
|
190
|
-
const { LinkComponent, signInPath = "/sign-in", disabled = false } = props;
|
|
191
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: { mt: 6, display: "flex", alignItems: "center" }, children: [_jsx(Box, { sx: { mt: "1px", flex: 1, borderTop: 1, borderColor: "divider" } }), _jsx(Typography, { sx: { mx: 1 }, color: "text.secondary", children: "\u00BFYa tienes una cuenta?" }), _jsx(Box, { sx: { mt: "1px", flex: 1, borderTop: 1, borderColor: "divider" } })] }), _jsx(Box, { sx: { mt: 2, display: "flex", alignItems: "center", gap: 2 }, children: _jsx(AuthSecondaryButton, { component: LinkComponent, to: signInPath, sx: { flex: 1 }, disabled: disabled, startIcon: _jsx(EmailOutlinedIcon, { fontSize: "small" }), onClick: (event) => {
|
|
192
|
-
if (disabled) {
|
|
193
|
-
event.preventDefault();
|
|
194
|
-
}
|
|
195
|
-
}, "aria-label": "Iniciar sesi\u00F3n", children: "Iniciar sesi\u00F3n" }) })] }));
|
|
196
|
-
}
|
|
197
|
-
function FuseForgotPasswordPageForm(props) {
|
|
198
|
-
const { LinkComponent } = props;
|
|
199
|
-
const { requestPasswordReset } = useFuseJwtAuth();
|
|
200
|
-
return (_jsxs(_Fragment, { children: [_jsx(AuthForgotPasswordForm, { onSubmit: (values) => requestPasswordReset({ email: values.email }) }), _jsx(AuthSecondaryButton, { sx: { mt: 2 }, component: LinkComponent, to: "/sign-in", startIcon: _jsx(ArrowBackOutlinedIcon, { fontSize: "small" }), "aria-label": "Regresar a iniciar sesi\u00F3n", children: "Regresar a iniciar sesi\u00F3n" })] }));
|
|
201
|
-
}
|
|
202
|
-
function FuseResetPasswordPageForm(props) {
|
|
203
|
-
const { initialUid = "", initialToken = "" } = props;
|
|
204
|
-
const { confirmPasswordReset } = useFuseJwtAuth();
|
|
205
|
-
const navigate = useNavigate();
|
|
206
|
-
return (_jsx(AuthPasswordResetConfirmForm, { defaultValues: {
|
|
207
|
-
uid: initialUid,
|
|
208
|
-
token: initialToken,
|
|
209
|
-
}, onGoToSignIn: () => navigate('/sign-in'), onSubmit: (values) => confirmPasswordReset(values) }));
|
|
210
|
-
}
|
|
211
|
-
function FuseAccountConfirmationPageForm(props) {
|
|
212
|
-
const { initialUid = "", initialToken = "" } = props;
|
|
213
|
-
const [searchParams] = useSearchParams();
|
|
214
|
-
const navigate = useNavigate();
|
|
215
|
-
const initialEmail = useMemo(() => searchParams.get("email") || "", [searchParams]);
|
|
216
|
-
const { confirmAccountEmail, resendAccountConfirmation } = useFuseJwtAuth();
|
|
217
|
-
return (_jsx(AuthAccountConfirmationForm, { defaultValues: {
|
|
218
|
-
uid: initialUid,
|
|
219
|
-
token: initialToken,
|
|
220
|
-
}, defaultEmail: initialEmail, onGoToSignIn: () => navigate('/sign-in'), onSubmit: (values) => confirmAccountEmail(values), onResend: (values) => resendAccountConfirmation(values) }));
|
|
221
|
-
}
|
|
222
|
-
function useRoleSelectionDialog(options, defaultRole) {
|
|
223
|
-
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
224
|
-
const [selectedRole, setSelectedRole] = useState(defaultRole ?? options[0]?.value ?? "");
|
|
225
|
-
const roleSelectionResolverRef = useRef(null);
|
|
226
|
-
const requestRoleSelection = useCallback(() => {
|
|
227
|
-
if (!options.length) {
|
|
228
|
-
return Promise.resolve(undefined);
|
|
229
|
-
}
|
|
230
|
-
if (options.length === 1) {
|
|
231
|
-
return Promise.resolve(options[0].value);
|
|
232
|
-
}
|
|
233
|
-
return new Promise((resolve) => {
|
|
234
|
-
roleSelectionResolverRef.current = resolve;
|
|
235
|
-
setIsDialogOpen(true);
|
|
236
|
-
});
|
|
237
|
-
}, [options]);
|
|
238
|
-
const closeRoleDialog = useCallback((role) => {
|
|
239
|
-
const resolver = roleSelectionResolverRef.current;
|
|
240
|
-
roleSelectionResolverRef.current = null;
|
|
241
|
-
setIsDialogOpen(false);
|
|
242
|
-
resolver?.(role);
|
|
243
|
-
}, []);
|
|
244
|
-
const dialog = (_jsx(AuthRoleSelectionDialog, { open: isDialogOpen, options: options, initialRole: selectedRole, onCancel: () => closeRoleDialog(undefined), onConfirm: (role) => {
|
|
245
|
-
setSelectedRole(role);
|
|
246
|
-
closeRoleDialog(role);
|
|
247
|
-
} }));
|
|
248
|
-
return { requestRoleSelection, dialog, hasRoleOptions: options.length > 0 };
|
|
249
|
-
}
|
|
250
|
-
export function createFuseAuthViews(options) {
|
|
251
|
-
const { LinkComponent, accountConfirmationPath = "/verify-email", signUpRoleOptions, defaultSignUpRole, socialConfig, showDebugSocial = false, onSignUpSuccess, } = options;
|
|
252
|
-
function SignInPageView() {
|
|
253
|
-
const [mode, setMode] = useState("password");
|
|
254
|
-
const { signInMagicLink, signInSocial, signInSocialPrecheck } = useFuseJwtAuth();
|
|
255
|
-
const [searchParams, setSearchParams] = useSearchParams();
|
|
256
|
-
const [socialLoadingProvider, setSocialLoadingProvider] = useState(null);
|
|
257
|
-
const [socialError, setSocialError] = useState(null);
|
|
258
|
-
const [magicLinkState, setMagicLinkState] = useState("idle");
|
|
259
|
-
const [magicLinkError, setMagicLinkError] = useState(null);
|
|
260
|
-
const attemptedMagicLinkRef = useRef("");
|
|
261
|
-
const signupRoleOptions = (signUpRoleOptions ?? [])
|
|
262
|
-
.filter((roleOption) => roleOption.allowSignup === true)
|
|
263
|
-
.map((roleOption) => ({
|
|
264
|
-
value: roleOption.value,
|
|
265
|
-
label: roleOption.label,
|
|
266
|
-
}));
|
|
267
|
-
const { requestRoleSelection, dialog, hasRoleOptions } = useRoleSelectionDialog(signupRoleOptions, defaultSignUpRole);
|
|
268
|
-
const enabledSocialProviders = useMemo(() => getEnabledSocialProviders(socialConfig, showDebugSocial), [socialConfig, showDebugSocial]);
|
|
269
|
-
const magicLinkToken = useMemo(() => (searchParams.get("mlt") || "").trim(), [searchParams]);
|
|
270
|
-
const isAuthFlowBusy = socialLoadingProvider !== null;
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
if (!magicLinkToken) {
|
|
273
|
-
setMagicLinkState("idle");
|
|
274
|
-
setMagicLinkError(null);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
if (attemptedMagicLinkRef.current === magicLinkToken) {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
attemptedMagicLinkRef.current = magicLinkToken;
|
|
281
|
-
setMagicLinkState("loading");
|
|
282
|
-
setMagicLinkError(null);
|
|
283
|
-
let active = true;
|
|
284
|
-
signInMagicLink({ token: magicLinkToken })
|
|
285
|
-
.then(() => {
|
|
286
|
-
if (!active) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
const nextParams = new URLSearchParams(searchParams);
|
|
290
|
-
nextParams.delete("mlt");
|
|
291
|
-
setSearchParams(nextParams, { replace: true });
|
|
292
|
-
})
|
|
293
|
-
.catch((error) => {
|
|
294
|
-
if (!active) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
const parsed = parseAuthError(error);
|
|
298
|
-
setMagicLinkError(parsed.rootMessage || "La liga de acceso es inválida o expiró.");
|
|
299
|
-
setMagicLinkState("error");
|
|
300
|
-
});
|
|
301
|
-
return () => {
|
|
302
|
-
active = false;
|
|
303
|
-
};
|
|
304
|
-
}, [magicLinkToken, searchParams, setSearchParams, signInMagicLink]);
|
|
305
|
-
const onSocialClick = useCallback(async (provider) => {
|
|
306
|
-
const providerConfig = enabledSocialProviders.find((item) => item.provider === provider);
|
|
307
|
-
if (!providerConfig) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
try {
|
|
311
|
-
setSocialError(null);
|
|
312
|
-
setSocialLoadingProvider(provider);
|
|
313
|
-
if (showDebugSocial) {
|
|
314
|
-
console.info("[jb-auth][social] start provider auth", { provider, providerConfig });
|
|
315
|
-
}
|
|
316
|
-
const tokenPayload = await authenticateWithSocialProvider(provider, providerConfig);
|
|
317
|
-
if (showDebugSocial) {
|
|
318
|
-
console.info("[jb-auth][social] provider token payload ready", { provider, tokenPayload });
|
|
319
|
-
}
|
|
320
|
-
const baseSocialPayload = {
|
|
321
|
-
...tokenPayload,
|
|
322
|
-
provider,
|
|
323
|
-
client: "web",
|
|
324
|
-
termsAndConditionsAccepted: true,
|
|
325
|
-
};
|
|
326
|
-
if (showDebugSocial) {
|
|
327
|
-
console.info("[jb-auth][social] sending social precheck", { provider, client: "web" });
|
|
328
|
-
}
|
|
329
|
-
const socialPrecheckResponse = await signInSocialPrecheck(baseSocialPayload);
|
|
330
|
-
const shouldSelectRole = shouldSelectRoleForSocialLogin(socialPrecheckResponse, hasRoleOptions);
|
|
331
|
-
const selectedRole = shouldSelectRole ? await requestRoleSelection() : undefined;
|
|
332
|
-
if (shouldSelectRole && !selectedRole) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
if (showDebugSocial) {
|
|
336
|
-
console.info("[jb-auth][social] sending loginSocial request", {
|
|
337
|
-
provider,
|
|
338
|
-
role: selectedRole,
|
|
339
|
-
client: "web"
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
await signInSocial({
|
|
343
|
-
...baseSocialPayload,
|
|
344
|
-
role: selectedRole,
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
catch (error) {
|
|
348
|
-
if (showDebugSocial) {
|
|
349
|
-
console.error("[jb-auth][social] flow failed", { provider, error });
|
|
350
|
-
}
|
|
351
|
-
const parsed = parseAuthError(error);
|
|
352
|
-
setSocialError(parsed.rootMessage || "No se pudo acceder con el proveedor social.");
|
|
353
|
-
}
|
|
354
|
-
finally {
|
|
355
|
-
setSocialLoadingProvider(null);
|
|
356
|
-
}
|
|
357
|
-
}, [enabledSocialProviders, hasRoleOptions, requestRoleSelection, showDebugSocial, signInSocial, signInSocialPrecheck]);
|
|
358
|
-
if (magicLinkToken && magicLinkState === "loading") {
|
|
359
|
-
return (_jsxs(Box, { sx: {
|
|
360
|
-
mx: { xs: "auto", sm: 0 },
|
|
361
|
-
width: { xs: "100%", sm: 320 },
|
|
362
|
-
maxWidth: 320,
|
|
363
|
-
display: "flex",
|
|
364
|
-
flexDirection: "column",
|
|
365
|
-
gap: 2,
|
|
366
|
-
alignItems: "center"
|
|
367
|
-
}, children: [_jsx(AuthPageTitle, { title: "Accediendo..." }), _jsx(Typography, { sx: { fontSize: 16, textAlign: "center" }, color: "text.secondary", children: "Validando liga de acceso segura." })] }));
|
|
368
|
-
}
|
|
369
|
-
return (_jsxs(Box, { sx: {
|
|
370
|
-
mx: { xs: "auto", sm: 0 },
|
|
371
|
-
width: { xs: "100%", sm: 320 },
|
|
372
|
-
maxWidth: 320,
|
|
373
|
-
display: "flex",
|
|
374
|
-
flexDirection: "column",
|
|
375
|
-
gap: 4,
|
|
376
|
-
}, children: [_jsx(AuthPageTitle, { title: "Iniciar sesi\u00F3n" }), magicLinkError ? _jsx(Alert, { severity: "error", children: magicLinkError }) : null, _jsxs(Box, { sx: { width: "100%" }, children: [_jsx(FuseSignInController, { LinkComponent: LinkComponent, mode: mode, disabled: isAuthFlowBusy, requestRoleSelection: requestRoleSelection, onBackToPassword: () => setMode("password") }), mode === "password" && (_jsxs(_Fragment, { children: [_jsx(FuseSignUpCtaSection, { LinkComponent: LinkComponent, disabled: isAuthFlowBusy }), _jsx(FuseAuthAlternativesSection, { onSmsClick: () => setMode("otp"), socialProviders: enabledSocialProviders, onSocialClick: onSocialClick, socialLoadingProvider: socialLoadingProvider, socialError: socialError })] }))] }), dialog] }));
|
|
377
|
-
}
|
|
378
|
-
function SignUpPageView() {
|
|
379
|
-
const [mode, setMode] = useState("password");
|
|
380
|
-
const { signInSocial, signInSocialPrecheck } = useFuseJwtAuth();
|
|
381
|
-
const [socialLoadingProvider, setSocialLoadingProvider] = useState(null);
|
|
382
|
-
const [socialError, setSocialError] = useState(null);
|
|
383
|
-
const navigate = useNavigate();
|
|
384
|
-
const signupRoleOptions = (signUpRoleOptions ?? [])
|
|
385
|
-
.filter((roleOption) => roleOption.allowSignup === true)
|
|
386
|
-
.map((roleOption) => ({
|
|
387
|
-
value: roleOption.value,
|
|
388
|
-
label: roleOption.label,
|
|
389
|
-
}));
|
|
390
|
-
const { requestRoleSelection, dialog, hasRoleOptions } = useRoleSelectionDialog(signupRoleOptions, defaultSignUpRole);
|
|
391
|
-
const enabledSocialProviders = useMemo(() => getEnabledSocialProviders(socialConfig, showDebugSocial), [socialConfig, showDebugSocial]);
|
|
392
|
-
const isAuthFlowBusy = socialLoadingProvider !== null;
|
|
393
|
-
const onSocialClick = useCallback(async (provider) => {
|
|
394
|
-
const providerConfig = enabledSocialProviders.find((item) => item.provider === provider);
|
|
395
|
-
if (!providerConfig) {
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
try {
|
|
399
|
-
setSocialError(null);
|
|
400
|
-
setSocialLoadingProvider(provider);
|
|
401
|
-
if (showDebugSocial) {
|
|
402
|
-
console.info("[jb-auth][social] start provider auth", { provider, providerConfig });
|
|
403
|
-
}
|
|
404
|
-
const tokenPayload = await authenticateWithSocialProvider(provider, providerConfig);
|
|
405
|
-
if (showDebugSocial) {
|
|
406
|
-
console.info("[jb-auth][social] provider token payload ready", { provider, tokenPayload });
|
|
407
|
-
}
|
|
408
|
-
const baseSocialPayload = {
|
|
409
|
-
...tokenPayload,
|
|
410
|
-
provider,
|
|
411
|
-
client: "web",
|
|
412
|
-
termsAndConditionsAccepted: true,
|
|
413
|
-
};
|
|
414
|
-
if (showDebugSocial) {
|
|
415
|
-
console.info("[jb-auth][social] sending social precheck", { provider, client: "web" });
|
|
416
|
-
}
|
|
417
|
-
const socialPrecheckResponse = await signInSocialPrecheck(baseSocialPayload);
|
|
418
|
-
const shouldSelectRole = shouldSelectRoleForSocialLogin(socialPrecheckResponse, hasRoleOptions);
|
|
419
|
-
const selectedRole = shouldSelectRole ? await requestRoleSelection() : undefined;
|
|
420
|
-
if (shouldSelectRole && !selectedRole) {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
if (showDebugSocial) {
|
|
424
|
-
console.info("[jb-auth][social] sending loginSocial request", {
|
|
425
|
-
provider,
|
|
426
|
-
role: selectedRole,
|
|
427
|
-
client: "web"
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
await signInSocial({
|
|
431
|
-
...baseSocialPayload,
|
|
432
|
-
role: selectedRole,
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
catch (error) {
|
|
436
|
-
if (showDebugSocial) {
|
|
437
|
-
console.error("[jb-auth][social] flow failed", { provider, error });
|
|
438
|
-
}
|
|
439
|
-
const parsed = parseAuthError(error);
|
|
440
|
-
setSocialError(parsed.rootMessage || "No se pudo acceder con el proveedor social.");
|
|
441
|
-
}
|
|
442
|
-
finally {
|
|
443
|
-
setSocialLoadingProvider(null);
|
|
444
|
-
}
|
|
445
|
-
}, [enabledSocialProviders, hasRoleOptions, requestRoleSelection, showDebugSocial, signInSocial, signInSocialPrecheck]);
|
|
446
|
-
return (_jsxs(Box, { sx: {
|
|
447
|
-
mx: { xs: "auto", sm: 0 },
|
|
448
|
-
width: { xs: "100%", sm: 320 },
|
|
449
|
-
maxWidth: 320,
|
|
450
|
-
display: "flex",
|
|
451
|
-
flexDirection: "column",
|
|
452
|
-
gap: 4,
|
|
453
|
-
}, children: [_jsx(AuthPageTitle, { title: "Crear cuenta" }), _jsx(Box, { sx: { width: "100%" }, children: mode === "password" ? (_jsxs(_Fragment, { children: [_jsx(FuseSignUpController, { disabled: isAuthFlowBusy, requiresRoleSelection: hasRoleOptions, requestRoleSelection: requestRoleSelection, onSuccess: (payload) => {
|
|
454
|
-
const { email } = payload;
|
|
455
|
-
onSignUpSuccess?.(payload);
|
|
456
|
-
navigate(`${accountConfirmationPath}?email=${encodeURIComponent(email)}`);
|
|
457
|
-
} }), _jsx(FuseSignInCtaSection, { LinkComponent: LinkComponent, disabled: isAuthFlowBusy }), _jsx(FuseAuthAlternativesSection, { onSmsClick: () => setMode("otp"), socialProviders: enabledSocialProviders, onSocialClick: onSocialClick, socialLoadingProvider: socialLoadingProvider, socialError: socialError })] })) : (_jsx(FuseOtpSignUpForm, { requestRoleSelection: requestRoleSelection, onBackToPassword: () => setMode("password") })) }), dialog] }));
|
|
458
|
-
}
|
|
459
|
-
function ForgotPasswordPageView() {
|
|
460
|
-
return (_jsxs(Box, { sx: {
|
|
461
|
-
mx: { xs: "auto", sm: 0 },
|
|
462
|
-
width: { xs: "100%", sm: 320 },
|
|
463
|
-
maxWidth: 320,
|
|
464
|
-
display: "flex",
|
|
465
|
-
flexDirection: "column",
|
|
466
|
-
gap: 4,
|
|
467
|
-
}, children: [_jsxs(Box, { sx: { width: "100%" }, children: [_jsx(AuthPageTitle, { title: "Olvid\u00E9 mi contrase\u00F1a" }), _jsx(Typography, { sx: { mt: 1.5, fontSize: 16, textAlign: "center" }, color: "text.secondary", children: "Ingresa tu correo y te enviaremos un enlace para restablecer tu contrase\u00F1a." })] }), _jsx(FuseForgotPasswordPageForm, { LinkComponent: LinkComponent })] }));
|
|
468
|
-
}
|
|
469
|
-
function ResetPasswordPageView() {
|
|
470
|
-
const [searchParams] = useSearchParams();
|
|
471
|
-
const initialUid = useMemo(() => searchParams.get("uid") || "", [searchParams]);
|
|
472
|
-
const initialToken = useMemo(() => searchParams.get("token") || "", [searchParams]);
|
|
473
|
-
return (_jsxs(Box, { sx: {
|
|
474
|
-
mx: { xs: "auto", sm: 0 },
|
|
475
|
-
width: { xs: "100%", sm: 320 },
|
|
476
|
-
maxWidth: 320,
|
|
477
|
-
display: "flex",
|
|
478
|
-
flexDirection: "column",
|
|
479
|
-
gap: 4,
|
|
480
|
-
}, children: [_jsxs(Box, { sx: { width: "100%" }, children: [_jsx(AuthPageTitle, { title: "Restablecer contrase\u00F1a" }), _jsx(Typography, { sx: { mt: 1.5, fontSize: 16 }, color: "text.secondary", children: "Define una nueva contrase\u00F1a para volver a acceder a tu cuenta." })] }), _jsx(FuseResetPasswordPageForm, { initialUid: initialUid, initialToken: initialToken })] }));
|
|
481
|
-
}
|
|
482
|
-
function SignOutPageView() {
|
|
483
|
-
return (_jsxs(Box, { sx: {
|
|
484
|
-
mx: { xs: "auto", sm: 0 },
|
|
485
|
-
width: { xs: "100%", sm: 320 },
|
|
486
|
-
maxWidth: 320,
|
|
487
|
-
}, children: [_jsx(AuthPageTitle, { title: "Has cerrado sesi\u00F3n" }), _jsxs(Typography, { sx: { mt: 2, textAlign: "center", fontSize: 16, fontWeight: 500 }, color: "text.secondary", children: ["Ir a ", _jsx(LinkComponent, { to: "/sign-in", children: "iniciar sesi\u00F3n" })] })] }));
|
|
488
|
-
}
|
|
489
|
-
function AccountConfirmationPageView() {
|
|
490
|
-
const [searchParams] = useSearchParams();
|
|
491
|
-
const initialUid = useMemo(() => searchParams.get("uid") || "", [searchParams]);
|
|
492
|
-
const initialToken = useMemo(() => searchParams.get("token") || "", [searchParams]);
|
|
493
|
-
return (_jsxs(Box, { sx: {
|
|
494
|
-
mx: { xs: "auto", sm: 0 },
|
|
495
|
-
width: { xs: "100%", sm: 320 },
|
|
496
|
-
maxWidth: 320,
|
|
497
|
-
display: "flex",
|
|
498
|
-
flexDirection: "column",
|
|
499
|
-
gap: 4,
|
|
500
|
-
}, children: [_jsxs(Box, { sx: { width: "100%" }, children: [_jsx(AuthPageTitle, { title: "Verificar cuenta" }), _jsx(Typography, { sx: { mt: 1.5, fontSize: 16 }, color: "text.secondary", children: "Estamos validando tu enlace de confirmaci\u00F3n." })] }), _jsx(FuseAccountConfirmationPageForm, { initialUid: initialUid, initialToken: initialToken })] }));
|
|
501
|
-
}
|
|
502
|
-
return {
|
|
503
|
-
SignInPageView,
|
|
504
|
-
SignUpPageView,
|
|
505
|
-
ForgotPasswordPageView,
|
|
506
|
-
ResetPasswordPageView,
|
|
507
|
-
SignOutPageView,
|
|
508
|
-
AccountConfirmationPageView,
|
|
509
|
-
};
|
|
510
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { AuthClient } from '../client';
|
|
3
|
-
import { AccountConfirmationPayload, AccountConfirmationResendPayload, LoginSocialPrecheckResponse, LoginSocialPayload, MagicLinkConsumePayload, PasswordChangePayload, PasswordResetConfirmPayload, PasswordResetRequestPayload, RegisterPayload, RequestOtpPayload, VerifyOtpPayload } from '../types';
|
|
4
|
-
type JsonRecord = Record<string, unknown>;
|
|
5
|
-
type FuseAuthState<TUser = JsonRecord> = {
|
|
6
|
-
authStatus: 'configuring' | 'authenticated' | 'unauthenticated';
|
|
7
|
-
isAuthenticated: boolean;
|
|
8
|
-
user: TUser | null;
|
|
9
|
-
};
|
|
10
|
-
export type FuseJwtAuthContextType<TUser = JsonRecord> = FuseAuthState<TUser> & {
|
|
11
|
-
signIn: (credentials: {
|
|
12
|
-
login: string;
|
|
13
|
-
password: string;
|
|
14
|
-
username?: string;
|
|
15
|
-
}) => Promise<JsonRecord>;
|
|
16
|
-
signInSocial: (payload: LoginSocialPayload) => Promise<JsonRecord>;
|
|
17
|
-
signInSocialPrecheck: (payload: LoginSocialPayload) => Promise<LoginSocialPrecheckResponse>;
|
|
18
|
-
requestOtp: (payload: RequestOtpPayload) => Promise<Record<string, unknown>>;
|
|
19
|
-
signInOtp: (payload: VerifyOtpPayload) => Promise<JsonRecord>;
|
|
20
|
-
signInMagicLink: (payload: MagicLinkConsumePayload) => Promise<JsonRecord>;
|
|
21
|
-
signUp: (payload: RegisterPayload) => Promise<JsonRecord>;
|
|
22
|
-
confirmAccountEmail: (payload: AccountConfirmationPayload) => Promise<Record<string, unknown>>;
|
|
23
|
-
resendAccountConfirmation: (payload: AccountConfirmationResendPayload) => Promise<Record<string, unknown>>;
|
|
24
|
-
requestPasswordReset: (payload: PasswordResetRequestPayload) => Promise<Record<string, unknown>>;
|
|
25
|
-
confirmPasswordReset: (payload: PasswordResetConfirmPayload) => Promise<Record<string, unknown>>;
|
|
26
|
-
changePassword: (payload: PasswordChangePayload) => Promise<Record<string, unknown>>;
|
|
27
|
-
switchProfile: (profileId: number) => Promise<JsonRecord>;
|
|
28
|
-
getProfiles: () => Promise<Record<string, unknown>[]>;
|
|
29
|
-
signOut: () => void;
|
|
30
|
-
refreshToken: () => Promise<string | null>;
|
|
31
|
-
};
|
|
32
|
-
type FuseAuthProviderComponentProps = {
|
|
33
|
-
children?: ReactNode;
|
|
34
|
-
onAuthStateChanged?: (state: FuseAuthState) => void;
|
|
35
|
-
ref?: React.Ref<{
|
|
36
|
-
signOut: () => void;
|
|
37
|
-
}>;
|
|
38
|
-
};
|
|
39
|
-
export declare const createFuseJwtAuthProvider: (authClient: AuthClient) => (props: FuseAuthProviderComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
|
-
export declare const useFuseJwtAuth: () => FuseJwtAuthContextType<JsonRecord>;
|
|
41
|
-
export {};
|
|
42
|
-
//# sourceMappingURL=fuseAdapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fuseAdapter.d.ts","sourceRoot":"","sources":["../../../src/auth/fuse/fuseAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAOV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,2BAA2B,EAC3B,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,KAAK,aAAa,CAAC,KAAK,GAAG,UAAU,IAAI;IACvC,UAAU,EAAE,aAAa,GAAG,eAAe,GAAG,iBAAiB,CAAC;IAChE,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,KAAK,GAAG,UAAU,IAAI,aAAa,CAAC,KAAK,CAAC,GAAG;IAC9E,MAAM,EAAE,CAAC,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACrG,YAAY,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACnE,oBAAoB,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC5F,UAAU,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7E,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9D,eAAe,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3E,MAAM,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1D,mBAAmB,EAAE,CAAC,OAAO,EAAE,0BAA0B,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/F,yBAAyB,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3G,oBAAoB,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjG,oBAAoB,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjG,cAAc,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACrF,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1D,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACtD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACpD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC;QACd,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC,CAAC;CACJ,CAAC;AAsEF,eAAO,MAAM,yBAAyB,GAAI,YAAY,UAAU,aAC1B,8BAA8B,4CAkSnE,CAAC;AAEF,eAAO,MAAM,cAAc,0CAM1B,CAAC"}
|