@joelbarron/react-web-dev-kit 0.1.9 → 0.1.10
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/auth/client.d.ts +46 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +379 -0
- package/dist/auth/constants/countryCallingCodes.d.ts +9 -0
- package/dist/auth/constants/countryCallingCodes.d.ts.map +1 -0
- package/dist/auth/constants/countryCallingCodes.js +209 -0
- package/dist/auth/constants/gender.d.ts +9 -0
- package/dist/auth/constants/gender.d.ts.map +1 -0
- package/dist/auth/constants/gender.js +12 -0
- package/dist/auth/constants/index.d.ts +3 -0
- package/dist/auth/constants/index.d.ts.map +1 -0
- package/dist/auth/constants/index.js +2 -0
- package/dist/auth/forms/account/AuthAccountConfirmationForm.d.ts +18 -0
- package/dist/auth/forms/account/AuthAccountConfirmationForm.d.ts.map +1 -0
- package/dist/auth/forms/account/AuthAccountConfirmationForm.js +167 -0
- package/dist/auth/forms/account/index.d.ts +2 -0
- package/dist/auth/forms/account/index.d.ts.map +1 -0
- package/dist/auth/forms/account/index.js +1 -0
- package/dist/auth/forms/errorParser.d.ts +7 -0
- package/dist/auth/forms/errorParser.d.ts.map +1 -0
- package/dist/auth/forms/errorParser.js +65 -0
- package/dist/auth/forms/index.d.ts +6 -0
- package/dist/auth/forms/index.d.ts.map +1 -0
- package/dist/auth/forms/index.js +5 -0
- package/dist/auth/forms/password/AuthForgotPasswordForm.d.ts +16 -0
- package/dist/auth/forms/password/AuthForgotPasswordForm.d.ts.map +1 -0
- package/dist/auth/forms/password/AuthForgotPasswordForm.js +109 -0
- package/dist/auth/forms/password/AuthPasswordResetConfirmForm.d.ts +17 -0
- package/dist/auth/forms/password/AuthPasswordResetConfirmForm.d.ts.map +1 -0
- package/dist/auth/forms/password/AuthPasswordResetConfirmForm.js +163 -0
- package/dist/auth/forms/password/AuthResetPasswordForm.d.ts +12 -0
- package/dist/auth/forms/password/AuthResetPasswordForm.d.ts.map +1 -0
- package/dist/auth/forms/password/AuthResetPasswordForm.js +22 -0
- package/dist/auth/forms/password/index.d.ts +4 -0
- package/dist/auth/forms/password/index.d.ts.map +1 -0
- package/dist/auth/forms/password/index.js +3 -0
- package/dist/auth/forms/password/passwordValidation.d.ts +3 -0
- package/dist/auth/forms/password/passwordValidation.d.ts.map +1 -0
- package/dist/auth/forms/password/passwordValidation.js +45 -0
- package/dist/auth/forms/sign-in/AuthOtpSignInForm.d.ts +24 -0
- package/dist/auth/forms/sign-in/AuthOtpSignInForm.d.ts.map +1 -0
- package/dist/auth/forms/sign-in/AuthOtpSignInForm.js +227 -0
- package/dist/auth/forms/sign-in/AuthPasswordSignInForm.d.ts +22 -0
- package/dist/auth/forms/sign-in/AuthPasswordSignInForm.d.ts.map +1 -0
- package/dist/auth/forms/sign-in/AuthPasswordSignInForm.js +148 -0
- package/dist/auth/forms/sign-in/index.d.ts +3 -0
- package/dist/auth/forms/sign-in/index.d.ts.map +1 -0
- package/dist/auth/forms/sign-in/index.js +2 -0
- package/dist/auth/forms/sign-up/AuthSignUpForm.d.ts +37 -0
- package/dist/auth/forms/sign-up/AuthSignUpForm.d.ts.map +1 -0
- package/dist/auth/forms/sign-up/AuthSignUpForm.js +193 -0
- package/dist/auth/forms/sign-up/index.d.ts +2 -0
- package/dist/auth/forms/sign-up/index.d.ts.map +1 -0
- package/dist/auth/forms/sign-up/index.js +1 -0
- package/dist/auth/fuse/createFuseAuthViews.d.ts +25 -0
- package/dist/auth/fuse/createFuseAuthViews.d.ts.map +1 -0
- package/dist/auth/fuse/createFuseAuthViews.js +510 -0
- package/dist/auth/fuse/fuseAdapter.d.ts +42 -0
- package/dist/auth/fuse/fuseAdapter.d.ts.map +1 -0
- package/dist/auth/fuse/fuseAdapter.js +291 -0
- package/dist/auth/fuse/fuseIntegration.d.ts +74 -0
- package/dist/auth/fuse/fuseIntegration.d.ts.map +1 -0
- package/dist/auth/fuse/fuseIntegration.js +121 -0
- package/dist/auth/fuse/index.d.ts +4 -0
- package/dist/auth/fuse/index.d.ts.map +1 -0
- package/dist/auth/fuse/index.js +3 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/provider.d.ts +35 -0
- package/dist/auth/provider.d.ts.map +1 -0
- package/dist/auth/provider.js +133 -0
- package/dist/auth/query.d.ts +23 -0
- package/dist/auth/query.d.ts.map +1 -0
- package/dist/auth/query.js +103 -0
- package/dist/auth/routes.d.ts +37 -0
- package/dist/auth/routes.d.ts.map +1 -0
- package/dist/auth/routes.js +75 -0
- package/dist/auth/social/providerAuth.d.ts +101 -0
- package/dist/auth/social/providerAuth.d.ts.map +1 -0
- package/dist/auth/social/providerAuth.js +207 -0
- package/dist/auth/storage.d.ts +3 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +20 -0
- package/dist/auth/types.d.ts +238 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/auth/ui/AuthPageTitle.d.ts +7 -0
- package/dist/auth/ui/AuthPageTitle.d.ts.map +1 -0
- package/dist/auth/ui/AuthPageTitle.js +7 -0
- package/dist/auth/ui/AuthPagesMessageSection.d.ts +3 -0
- package/dist/auth/ui/AuthPagesMessageSection.d.ts.map +1 -0
- package/dist/auth/ui/AuthPagesMessageSection.js +39 -0
- package/dist/auth/ui/AuthPrimaryButton.d.ts +9 -0
- package/dist/auth/ui/AuthPrimaryButton.d.ts.map +1 -0
- package/dist/auth/ui/AuthPrimaryButton.js +19 -0
- package/dist/auth/ui/AuthRoleSelectionDialog.d.ts +14 -0
- package/dist/auth/ui/AuthRoleSelectionDialog.d.ts.map +1 -0
- package/dist/auth/ui/AuthRoleSelectionDialog.js +39 -0
- package/dist/auth/ui/AuthRoutePageWrapper.d.ts +12 -0
- package/dist/auth/ui/AuthRoutePageWrapper.d.ts.map +1 -0
- package/dist/auth/ui/AuthRoutePageWrapper.js +61 -0
- package/dist/auth/ui/AuthSecondaryButton.d.ts +7 -0
- package/dist/auth/ui/AuthSecondaryButton.d.ts.map +1 -0
- package/dist/auth/ui/AuthSecondaryButton.js +18 -0
- package/dist/auth/ui/AuthSocialProviderButton.d.ts +11 -0
- package/dist/auth/ui/AuthSocialProviderButton.d.ts.map +1 -0
- package/dist/auth/ui/AuthSocialProviderButton.js +33 -0
- package/dist/auth/ui/index.d.ts +9 -0
- package/dist/auth/ui/index.d.ts.map +1 -0
- package/dist/auth/ui/index.js +8 -0
- package/dist/auth/ui/types.d.ts +15 -0
- package/dist/auth/ui/types.d.ts.map +1 -0
- package/dist/auth/ui/types.js +1 -0
- package/dist/config/createConfig.d.ts +14 -0
- package/dist/config/createConfig.d.ts.map +1 -0
- package/dist/config/createConfig.js +179 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +39 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/config/merge.d.ts +2 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/merge.js +18 -0
- package/dist/config/types.d.ts +53 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +1 -0
- package/dist/core/buttons/JBButton.d.ts +8 -0
- package/dist/core/buttons/JBButton.d.ts.map +1 -0
- package/dist/core/buttons/JBButton.js +55 -0
- package/dist/core/buttons/index.d.ts +2 -0
- package/dist/core/buttons/index.d.ts.map +1 -0
- package/dist/core/buttons/index.js +1 -0
- package/dist/core/dialogs/JBConfirmDialog.d.ts +15 -0
- package/dist/core/dialogs/JBConfirmDialog.d.ts.map +1 -0
- package/dist/core/dialogs/JBConfirmDialog.js +6 -0
- package/dist/core/dialogs/index.d.ts +2 -0
- package/dist/core/dialogs/index.d.ts.map +1 -0
- package/dist/core/dialogs/index.js +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/layout/JBContentContainer.d.ts +31 -0
- package/dist/core/layout/JBContentContainer.d.ts.map +1 -0
- package/dist/core/layout/JBContentContainer.js +50 -0
- package/dist/core/layout/JBFormHeader.d.ts +3 -0
- package/dist/core/layout/JBFormHeader.d.ts.map +1 -0
- package/dist/core/layout/JBFormHeader.js +131 -0
- package/dist/core/layout/index.d.ts +3 -0
- package/dist/core/layout/index.d.ts.map +1 -0
- package/dist/core/layout/index.js +2 -0
- package/dist/core/skeletons/JBFormContentSkeleton.d.ts +5 -0
- package/dist/core/skeletons/JBFormContentSkeleton.d.ts.map +1 -0
- package/dist/core/skeletons/JBFormContentSkeleton.js +12 -0
- package/dist/core/skeletons/JBFormHeaderSkeleton.d.ts +6 -0
- package/dist/core/skeletons/JBFormHeaderSkeleton.d.ts.map +1 -0
- package/dist/core/skeletons/JBFormHeaderSkeleton.js +19 -0
- package/dist/core/skeletons/index.d.ts +3 -0
- package/dist/core/skeletons/index.d.ts.map +1 -0
- package/dist/core/skeletons/index.js +2 -0
- package/dist/forms/JBAutocompleteField.d.ts +12 -0
- package/dist/forms/JBAutocompleteField.d.ts.map +1 -0
- package/dist/forms/JBAutocompleteField.js +20 -0
- package/dist/forms/JBCheckboxField.d.ts +12 -0
- package/dist/forms/JBCheckboxField.d.ts.map +1 -0
- package/dist/forms/JBCheckboxField.js +36 -0
- package/dist/forms/JBDatePickerField.d.ts +13 -0
- package/dist/forms/JBDatePickerField.d.ts.map +1 -0
- package/dist/forms/JBDatePickerField.js +67 -0
- package/dist/forms/JBRadioGroupField.d.ts +10 -0
- package/dist/forms/JBRadioGroupField.d.ts.map +1 -0
- package/dist/forms/JBRadioGroupField.js +8 -0
- package/dist/forms/JBSelectField.d.ts +9 -0
- package/dist/forms/JBSelectField.d.ts.map +1 -0
- package/dist/forms/JBSelectField.js +8 -0
- package/dist/forms/JBSwitchField.d.ts +11 -0
- package/dist/forms/JBSwitchField.d.ts.map +1 -0
- package/dist/forms/JBSwitchField.js +10 -0
- package/dist/forms/JBTextField.d.ts +6 -0
- package/dist/forms/JBTextField.d.ts.map +1 -0
- package/dist/forms/JBTextField.js +8 -0
- package/dist/forms/JBTimePickerField.d.ts +12 -0
- package/dist/forms/JBTimePickerField.d.ts.map +1 -0
- package/dist/forms/JBTimePickerField.js +35 -0
- package/dist/forms/index.d.ts +13 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +12 -0
- package/dist/forms/rules.d.ts +16 -0
- package/dist/forms/rules.d.ts.map +1 -0
- package/dist/forms/rules.js +21 -0
- package/dist/forms/types.d.ts +12 -0
- package/dist/forms/types.d.ts.map +1 -0
- package/dist/forms/types.js +1 -0
- package/dist/forms/utils.d.ts +5 -0
- package/dist/forms/utils.d.ts.map +1 -0
- package/dist/forms/utils.js +7 -0
- package/dist/forms/zod.d.ts +4 -0
- package/dist/forms/zod.d.ts.map +1 -0
- package/dist/forms/zod.js +9 -0
- package/dist/grid/JBGrid.d.ts +3 -0
- package/dist/grid/JBGrid.d.ts.map +1 -0
- package/dist/grid/JBGrid.js +338 -0
- package/dist/grid/JBGridHeader.d.ts +3 -0
- package/dist/grid/JBGridHeader.d.ts.map +1 -0
- package/dist/grid/JBGridHeader.js +93 -0
- package/dist/grid/JBGridLoading.d.ts +9 -0
- package/dist/grid/JBGridLoading.d.ts.map +1 -0
- package/dist/grid/JBGridLoading.js +14 -0
- package/dist/grid/JBGridProviders.d.ts +13 -0
- package/dist/grid/JBGridProviders.d.ts.map +1 -0
- package/dist/grid/JBGridProviders.js +54 -0
- package/dist/grid/JBGridSkeleton.d.ts +7 -0
- package/dist/grid/JBGridSkeleton.d.ts.map +1 -0
- package/dist/grid/JBGridSkeleton.js +6 -0
- package/dist/grid/defaults.d.ts +4 -0
- package/dist/grid/defaults.d.ts.map +1 -0
- package/dist/grid/defaults.js +29 -0
- package/dist/grid/index.d.ts +8 -0
- package/dist/grid/index.d.ts.map +1 -0
- package/dist/grid/index.js +7 -0
- package/dist/grid/types.d.ts +197 -0
- package/dist/grid/types.d.ts.map +1 -0
- package/dist/grid/types.js +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/useJBDebouncedValue.d.ts +2 -0
- package/dist/hooks/useJBDebouncedValue.d.ts.map +1 -0
- package/dist/hooks/useJBDebouncedValue.js +11 -0
- package/dist/hooks/useJBEntityFormController.d.ts +54 -0
- package/dist/hooks/useJBEntityFormController.d.ts.map +1 -0
- package/dist/hooks/useJBEntityFormController.js +156 -0
- package/dist/hooks/useJBRedirect.d.ts +10 -0
- package/dist/hooks/useJBRedirect.d.ts.map +1 -0
- package/dist/hooks/useJBRedirect.js +11 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/query/createQueryClient.d.ts +8 -0
- package/dist/query/createQueryClient.d.ts.map +1 -0
- package/dist/query/createQueryClient.js +25 -0
- package/dist/query/http.d.ts +3 -0
- package/dist/query/http.d.ts.map +1 -0
- package/dist/query/http.js +12 -0
- package/dist/query/index.d.ts +4 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +3 -0
- package/dist/query/types.d.ts +7 -0
- package/dist/query/types.d.ts.map +1 -0
- package/dist/query/types.js +1 -0
- package/dist/utils/errors.d.ts +10 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +55 -0
- package/dist/utils/format.d.ts +4 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +28 -0
- package/dist/utils/geo.d.ts +9 -0
- package/dist/utils/geo.d.ts.map +1 -0
- package/dist/utils/geo.js +186 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/query.d.ts +2 -0
- package/dist/utils/query.d.ts.map +1 -0
- package/dist/utils/query.js +4 -0
- package/dist/utils/regex.d.ts +7 -0
- package/dist/utils/regex.d.ts.map +1 -0
- package/dist/utils/regex.js +6 -0
- package/package.json +3 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
const JBAuthContext = createContext(undefined);
|
|
4
|
+
const isTokenValid = (token) => {
|
|
5
|
+
if (!token)
|
|
6
|
+
return false;
|
|
7
|
+
try {
|
|
8
|
+
const payload = JSON.parse(atob(token.split('.')[1]));
|
|
9
|
+
const now = Date.now() / 1000;
|
|
10
|
+
return payload.exp > now;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export function JBAuthProvider(props) {
|
|
17
|
+
const { authClient, children, onAuthStateChanged } = props;
|
|
18
|
+
const [authStatus, setAuthStatus] = useState('configuring');
|
|
19
|
+
const [user, setUser] = useState(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
onAuthStateChanged?.({
|
|
22
|
+
authStatus,
|
|
23
|
+
isAuthenticated: authStatus === 'authenticated',
|
|
24
|
+
user
|
|
25
|
+
});
|
|
26
|
+
}, [authStatus, onAuthStateChanged, user]);
|
|
27
|
+
const setAuthenticatedSession = useCallback((authResponse) => {
|
|
28
|
+
setUser(authResponse.user ?? null);
|
|
29
|
+
setAuthStatus('authenticated');
|
|
30
|
+
return authResponse.user ?? null;
|
|
31
|
+
}, []);
|
|
32
|
+
const signIn = useCallback(async (payload) => {
|
|
33
|
+
const response = await authClient.loginBasic(payload);
|
|
34
|
+
return setAuthenticatedSession(response);
|
|
35
|
+
}, [authClient, setAuthenticatedSession]);
|
|
36
|
+
const signInOtp = useCallback(async (payload) => {
|
|
37
|
+
const response = await authClient.verifyOtp(payload);
|
|
38
|
+
return setAuthenticatedSession(response);
|
|
39
|
+
}, [authClient, setAuthenticatedSession]);
|
|
40
|
+
const signUp = useCallback(async (payload) => {
|
|
41
|
+
const response = await authClient.register(payload);
|
|
42
|
+
return response;
|
|
43
|
+
}, [authClient]);
|
|
44
|
+
const confirmAccountEmail = useCallback(async (payload) => authClient.confirmAccountEmail(payload), [authClient]);
|
|
45
|
+
const resendAccountConfirmation = useCallback(async (payload) => authClient.resendAccountConfirmation(payload), [authClient]);
|
|
46
|
+
const signOut = useCallback(() => {
|
|
47
|
+
authClient.logout();
|
|
48
|
+
setUser(null);
|
|
49
|
+
setAuthStatus('unauthenticated');
|
|
50
|
+
}, [authClient]);
|
|
51
|
+
const refreshToken = useCallback(async () => {
|
|
52
|
+
const response = await authClient.refreshToken();
|
|
53
|
+
return response.accessToken || null;
|
|
54
|
+
}, [authClient]);
|
|
55
|
+
const requestOtp = useCallback(async (payload) => authClient.requestOtp(payload), [authClient]);
|
|
56
|
+
const requestPasswordReset = useCallback(async (payload) => authClient.requestPasswordReset(payload), [authClient]);
|
|
57
|
+
const confirmPasswordReset = useCallback(async (payload) => authClient.confirmPasswordReset(payload), [authClient]);
|
|
58
|
+
const changePassword = useCallback(async (payload) => authClient.changePassword(payload), [authClient]);
|
|
59
|
+
const getProfiles = useCallback(async () => authClient.getProfiles(), [authClient]);
|
|
60
|
+
const switchProfile = useCallback(async (payload) => {
|
|
61
|
+
const response = await authClient.switchProfile(payload);
|
|
62
|
+
return setAuthenticatedSession(response);
|
|
63
|
+
}, [authClient, setAuthenticatedSession]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
let isMounted = true;
|
|
66
|
+
const bootstrapAuth = async () => {
|
|
67
|
+
const accessToken = authClient.getAccessToken();
|
|
68
|
+
if (!isTokenValid(accessToken)) {
|
|
69
|
+
setAuthStatus('unauthenticated');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const response = await authClient.getMe();
|
|
74
|
+
if (!isMounted)
|
|
75
|
+
return;
|
|
76
|
+
setAuthenticatedSession(response);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
if (!isMounted)
|
|
80
|
+
return;
|
|
81
|
+
authClient.logout();
|
|
82
|
+
setUser(null);
|
|
83
|
+
setAuthStatus('unauthenticated');
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
bootstrapAuth();
|
|
87
|
+
return () => {
|
|
88
|
+
isMounted = false;
|
|
89
|
+
};
|
|
90
|
+
}, [authClient, setAuthenticatedSession]);
|
|
91
|
+
const contextValue = useMemo(() => ({
|
|
92
|
+
authStatus,
|
|
93
|
+
isAuthenticated: authStatus === 'authenticated',
|
|
94
|
+
user,
|
|
95
|
+
signIn,
|
|
96
|
+
signUp,
|
|
97
|
+
confirmAccountEmail,
|
|
98
|
+
resendAccountConfirmation,
|
|
99
|
+
signInOtp,
|
|
100
|
+
requestOtp,
|
|
101
|
+
requestPasswordReset,
|
|
102
|
+
confirmPasswordReset,
|
|
103
|
+
changePassword,
|
|
104
|
+
getProfiles,
|
|
105
|
+
switchProfile,
|
|
106
|
+
signOut,
|
|
107
|
+
refreshToken
|
|
108
|
+
}), [
|
|
109
|
+
authStatus,
|
|
110
|
+
user,
|
|
111
|
+
signIn,
|
|
112
|
+
signUp,
|
|
113
|
+
confirmAccountEmail,
|
|
114
|
+
resendAccountConfirmation,
|
|
115
|
+
signInOtp,
|
|
116
|
+
requestOtp,
|
|
117
|
+
requestPasswordReset,
|
|
118
|
+
confirmPasswordReset,
|
|
119
|
+
changePassword,
|
|
120
|
+
getProfiles,
|
|
121
|
+
switchProfile,
|
|
122
|
+
signOut,
|
|
123
|
+
refreshToken
|
|
124
|
+
]);
|
|
125
|
+
return _jsx(JBAuthContext.Provider, { value: contextValue, children: children });
|
|
126
|
+
}
|
|
127
|
+
export function useJBAuth() {
|
|
128
|
+
const context = useContext(JBAuthContext);
|
|
129
|
+
if (!context) {
|
|
130
|
+
throw new Error('useJBAuth must be used within JBAuthProvider');
|
|
131
|
+
}
|
|
132
|
+
return context;
|
|
133
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AuthClient } from './client';
|
|
2
|
+
import { AccountUpdatePayload, DeleteAccountPayload, JbDrfWebAuthResponse, LinkSocialPayload, LoginBasicPayload, LoginSocialPayload, SwitchProfilePayload, UnlinkSocialPayload } from './types';
|
|
3
|
+
export declare const authQueryKeys: {
|
|
4
|
+
all: readonly ["auth"];
|
|
5
|
+
me: () => readonly ["auth", "me"];
|
|
6
|
+
social: () => readonly ["auth", "social"];
|
|
7
|
+
account: () => readonly ["auth", "account"];
|
|
8
|
+
};
|
|
9
|
+
export declare const createAuthQueryHooks: (authClient: Pick<AuthClient, "getMe" | "loginBasic" | "loginSocial" | "linkSocial" | "unlinkSocial" | "updateAccount" | "deleteAccount" | "switchProfile" | "logout">) => {
|
|
10
|
+
useMeQuery: (enabled?: boolean) => import("@tanstack/react-query").UseQueryResult<JbDrfWebAuthResponse, Error>;
|
|
11
|
+
useLoginMutation: () => import("@tanstack/react-query").UseMutationResult<JbDrfWebAuthResponse, Error, LoginBasicPayload, unknown>;
|
|
12
|
+
useSocialLoginMutation: () => import("@tanstack/react-query").UseMutationResult<JbDrfWebAuthResponse, Error, LoginSocialPayload, unknown>;
|
|
13
|
+
useLinkSocialMutation: () => import("@tanstack/react-query").UseMutationResult<Record<string, unknown>, Error, LinkSocialPayload, unknown>;
|
|
14
|
+
useUnlinkSocialMutation: () => import("@tanstack/react-query").UseMutationResult<Record<string, unknown>, Error, UnlinkSocialPayload, unknown>;
|
|
15
|
+
useAccountUpdateMutation: () => import("@tanstack/react-query").UseMutationResult<Record<string, unknown>, Error, {
|
|
16
|
+
payload: AccountUpdatePayload;
|
|
17
|
+
method?: "PATCH" | "PUT";
|
|
18
|
+
}, unknown>;
|
|
19
|
+
useDeleteAccountMutation: () => import("@tanstack/react-query").UseMutationResult<unknown, Error, DeleteAccountPayload, unknown>;
|
|
20
|
+
useSwitchProfileMutation: () => import("@tanstack/react-query").UseMutationResult<JbDrfWebAuthResponse, Error, SwitchProfilePayload, unknown>;
|
|
21
|
+
useLogoutMutation: () => import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/auth/query.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,aAAa;;;;;CAKzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,YAAY,IAAI,CACd,UAAU,EACR,OAAO,GACP,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,cAAc,GACd,eAAe,GACf,eAAe,GACf,eAAe,GACf,QAAQ,CACX;;;;;;;iBA8DgD,oBAAoB;iBAAW,OAAO,GAAG,KAAK;;;;;CA6ChG,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
export const authQueryKeys = {
|
|
3
|
+
all: ['auth'],
|
|
4
|
+
me: () => [...authQueryKeys.all, 'me'],
|
|
5
|
+
social: () => [...authQueryKeys.all, 'social'],
|
|
6
|
+
account: () => [...authQueryKeys.all, 'account']
|
|
7
|
+
};
|
|
8
|
+
export const createAuthQueryHooks = (authClient) => {
|
|
9
|
+
const useMeQuery = (enabled = true) => useQuery({
|
|
10
|
+
queryKey: authQueryKeys.me(),
|
|
11
|
+
queryFn: () => authClient.getMe(),
|
|
12
|
+
enabled
|
|
13
|
+
});
|
|
14
|
+
const useLoginMutation = () => {
|
|
15
|
+
const queryClient = useQueryClient();
|
|
16
|
+
return useMutation({
|
|
17
|
+
mutationFn: (payload) => authClient.loginBasic(payload),
|
|
18
|
+
onSuccess: async () => {
|
|
19
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.me() });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const useSwitchProfileMutation = () => {
|
|
24
|
+
const queryClient = useQueryClient();
|
|
25
|
+
return useMutation({
|
|
26
|
+
mutationFn: (payload) => authClient.switchProfile(payload),
|
|
27
|
+
onSuccess: async () => {
|
|
28
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.me() });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const useSocialLoginMutation = () => {
|
|
33
|
+
const queryClient = useQueryClient();
|
|
34
|
+
return useMutation({
|
|
35
|
+
mutationFn: (payload) => authClient.loginSocial(payload),
|
|
36
|
+
onSuccess: async () => {
|
|
37
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.me() });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const useLinkSocialMutation = () => {
|
|
42
|
+
const queryClient = useQueryClient();
|
|
43
|
+
return useMutation({
|
|
44
|
+
mutationFn: (payload) => authClient.linkSocial(payload),
|
|
45
|
+
onSuccess: async () => {
|
|
46
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.social() });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const useUnlinkSocialMutation = () => {
|
|
51
|
+
const queryClient = useQueryClient();
|
|
52
|
+
return useMutation({
|
|
53
|
+
mutationFn: (payload) => authClient.unlinkSocial(payload),
|
|
54
|
+
onSuccess: async () => {
|
|
55
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.social() });
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const useAccountUpdateMutation = () => {
|
|
60
|
+
const queryClient = useQueryClient();
|
|
61
|
+
return useMutation({
|
|
62
|
+
mutationFn: ({ payload, method }) => authClient.updateAccount(payload, method),
|
|
63
|
+
onSuccess: async () => {
|
|
64
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.me() });
|
|
65
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.account() });
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const useDeleteAccountMutation = () => {
|
|
70
|
+
const queryClient = useQueryClient();
|
|
71
|
+
return useMutation({
|
|
72
|
+
mutationFn: (payload) => authClient.deleteAccount(payload),
|
|
73
|
+
onSuccess: async () => {
|
|
74
|
+
queryClient.setQueryData(authQueryKeys.me(), null);
|
|
75
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.me() });
|
|
76
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.account() });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const useLogoutMutation = () => {
|
|
81
|
+
const queryClient = useQueryClient();
|
|
82
|
+
return useMutation({
|
|
83
|
+
mutationFn: async () => {
|
|
84
|
+
authClient.logout();
|
|
85
|
+
},
|
|
86
|
+
onSuccess: async () => {
|
|
87
|
+
queryClient.setQueryData(authQueryKeys.me(), null);
|
|
88
|
+
await queryClient.invalidateQueries({ queryKey: authQueryKeys.me() });
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
useMeQuery,
|
|
94
|
+
useLoginMutation,
|
|
95
|
+
useSocialLoginMutation,
|
|
96
|
+
useLinkSocialMutation,
|
|
97
|
+
useUnlinkSocialMutation,
|
|
98
|
+
useAccountUpdateMutation,
|
|
99
|
+
useDeleteAccountMutation,
|
|
100
|
+
useSwitchProfileMutation,
|
|
101
|
+
useLogoutMutation
|
|
102
|
+
};
|
|
103
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ComponentType, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { JBAppConfig, JBAuthProfileRoleOption } from '../config';
|
|
3
|
+
import { AuthLinkComponent, AuthMessageSectionProps, AuthPageLayoutVariant } from './ui';
|
|
4
|
+
type AuthRouteKey = 'signIn' | 'signUp' | 'forgotPassword' | 'resetPassword' | 'signOut' | 'accountConfirmation';
|
|
5
|
+
export type AuthPageWrapperProps = {
|
|
6
|
+
routeKey: AuthRouteKey;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
layoutVariant?: AuthPageLayoutVariant;
|
|
9
|
+
messageSectionProps?: AuthMessageSectionProps;
|
|
10
|
+
};
|
|
11
|
+
export type AuthRouteItem<TMeta extends Record<string, unknown> = Record<string, unknown>> = {
|
|
12
|
+
path: string;
|
|
13
|
+
element: ReactElement;
|
|
14
|
+
} & TMeta;
|
|
15
|
+
export type CreateAuthRoutesOptions<TMeta extends Record<string, unknown> = Record<string, unknown>> = {
|
|
16
|
+
basePath?: string;
|
|
17
|
+
pages?: Partial<Record<AuthRouteKey, ComponentType>>;
|
|
18
|
+
autoFuseViews?: boolean;
|
|
19
|
+
linkComponent?: AuthLinkComponent;
|
|
20
|
+
jbWebConfig?: JBAppConfig;
|
|
21
|
+
signUpRoleOptions?: JBAuthProfileRoleOption[];
|
|
22
|
+
defaultSignUpRole?: string;
|
|
23
|
+
onSignUpSuccess?: (values: {
|
|
24
|
+
email: string;
|
|
25
|
+
detail?: string;
|
|
26
|
+
response: Record<string, unknown>;
|
|
27
|
+
}) => void;
|
|
28
|
+
pageComponent?: ComponentType<AuthPageWrapperProps>;
|
|
29
|
+
layoutVariant?: AuthPageLayoutVariant;
|
|
30
|
+
messageSectionProps?: AuthMessageSectionProps;
|
|
31
|
+
wrapperPropsByRoute?: Partial<Record<AuthRouteKey, Pick<AuthPageWrapperProps, 'layoutVariant' | 'messageSectionProps'>>>;
|
|
32
|
+
routeMeta?: Partial<Record<AuthRouteKey, TMeta>>;
|
|
33
|
+
paths?: Partial<Record<AuthRouteKey, string>>;
|
|
34
|
+
};
|
|
35
|
+
export declare function createAuthRoutes<TMeta extends Record<string, unknown> = Record<string, unknown>>(options: CreateAuthRoutesOptions<TMeta>): Array<AuthRouteItem<TMeta>>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/auth/routes.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,WAAW,EACX,uBAAuB,EAKxB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,MAAM,CAAC;AAEzF,KAAK,YAAY,GACb,QAAQ,GACR,QAAQ,GACR,gBAAgB,GAChB,eAAe,GACf,SAAS,GACT,qBAAqB,CAAC;AAE1B,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IAC3F,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB,GAAG,KAAK,CAAC;AAEV,MAAM,MAAM,uBAAuB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACrG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;IACrD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,iBAAiB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAC9C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE;QACzB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,KAAK,IAAI,CAAC;IACX,aAAa,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IACpD,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;IAC9C,mBAAmB,CAAC,EAAE,OAAO,CAC3B,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,oBAAoB,EAAE,eAAe,GAAG,qBAAqB,CAAC,CAAC,CAC1F,CAAC;IACF,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;CAC/C,CAAC;AAyCF,wBAAgB,gBAAgB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9F,OAAO,EAAE,uBAAuB,CAAC,KAAK,CAAC,GACtC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAsE7B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getAuthDefaultProfileRole, getAuthShowDebugSocial, getAuthSignupProfileRoles, getAuthSocialConfig } from '../config';
|
|
3
|
+
import { createFuseAuthViews } from './fuse';
|
|
4
|
+
const defaultPaths = {
|
|
5
|
+
signIn: 'sign-in',
|
|
6
|
+
signUp: 'sign-up',
|
|
7
|
+
forgotPassword: 'forgot-password',
|
|
8
|
+
resetPassword: 'reset-password',
|
|
9
|
+
signOut: 'sign-out',
|
|
10
|
+
accountConfirmation: 'verify-email'
|
|
11
|
+
};
|
|
12
|
+
const normalizePath = (basePath, routePath) => {
|
|
13
|
+
const cleanBasePath = (basePath ?? '').replace(/^\/+|\/+$/g, '');
|
|
14
|
+
const cleanRoutePath = routePath.replace(/^\/+|\/+$/g, '');
|
|
15
|
+
if (!cleanBasePath) {
|
|
16
|
+
return cleanRoutePath;
|
|
17
|
+
}
|
|
18
|
+
return `${cleanBasePath}/${cleanRoutePath}`;
|
|
19
|
+
};
|
|
20
|
+
const renderRouteElement = (Page, routeKey, Wrapper, wrapperProps) => {
|
|
21
|
+
if (!Wrapper) {
|
|
22
|
+
return _jsx(Page, {});
|
|
23
|
+
}
|
|
24
|
+
return (_jsx(Wrapper, { routeKey: routeKey, ...(wrapperProps ?? {}), children: _jsx(Page, {}) }));
|
|
25
|
+
};
|
|
26
|
+
export function createAuthRoutes(options) {
|
|
27
|
+
const { basePath, pages, autoFuseViews, linkComponent, jbWebConfig, signUpRoleOptions, defaultSignUpRole, onSignUpSuccess, pageComponent, layoutVariant, messageSectionProps, wrapperPropsByRoute, routeMeta, paths } = options;
|
|
28
|
+
const resolvedSignUpRoleOptions = signUpRoleOptions ?? (jbWebConfig ? getAuthSignupProfileRoles(jbWebConfig) : undefined);
|
|
29
|
+
const resolvedDefaultSignUpRole = defaultSignUpRole ?? (jbWebConfig ? getAuthDefaultProfileRole(jbWebConfig) : undefined);
|
|
30
|
+
const resolvedSocialConfig = jbWebConfig ? getAuthSocialConfig(jbWebConfig) : undefined;
|
|
31
|
+
const resolvedShowDebugSocial = jbWebConfig ? getAuthShowDebugSocial(jbWebConfig) : false;
|
|
32
|
+
const resolvedPaths = { ...defaultPaths, ...(paths ?? {}) };
|
|
33
|
+
const accountConfirmationRoutePath = normalizePath(basePath, resolvedPaths.accountConfirmation);
|
|
34
|
+
const accountConfirmationPath = `/${accountConfirmationRoutePath}`;
|
|
35
|
+
const autoGeneratedPages = autoFuseViews && linkComponent
|
|
36
|
+
? (() => {
|
|
37
|
+
const views = createFuseAuthViews({
|
|
38
|
+
LinkComponent: linkComponent,
|
|
39
|
+
accountConfirmationPath,
|
|
40
|
+
signUpRoleOptions: resolvedSignUpRoleOptions,
|
|
41
|
+
defaultSignUpRole: resolvedDefaultSignUpRole,
|
|
42
|
+
socialConfig: resolvedSocialConfig,
|
|
43
|
+
showDebugSocial: resolvedShowDebugSocial,
|
|
44
|
+
onSignUpSuccess
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
signIn: views.SignInPageView,
|
|
48
|
+
signUp: views.SignUpPageView,
|
|
49
|
+
forgotPassword: views.ForgotPasswordPageView,
|
|
50
|
+
resetPassword: views.ResetPasswordPageView,
|
|
51
|
+
signOut: views.SignOutPageView,
|
|
52
|
+
accountConfirmation: views.AccountConfirmationPageView
|
|
53
|
+
};
|
|
54
|
+
})()
|
|
55
|
+
: undefined;
|
|
56
|
+
const resolvedPages = pages ?? autoGeneratedPages;
|
|
57
|
+
if (!resolvedPages) {
|
|
58
|
+
throw new Error('createAuthRoutes requires "pages" or "autoFuseViews + linkComponent".');
|
|
59
|
+
}
|
|
60
|
+
return Object.keys(resolvedPaths)
|
|
61
|
+
.filter((routeKey) => !!resolvedPages[routeKey])
|
|
62
|
+
.map((routeKey) => {
|
|
63
|
+
const page = resolvedPages[routeKey];
|
|
64
|
+
const wrapperProps = {
|
|
65
|
+
layoutVariant,
|
|
66
|
+
messageSectionProps,
|
|
67
|
+
...(wrapperPropsByRoute?.[routeKey] ?? {})
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
path: normalizePath(basePath, resolvedPaths[routeKey]),
|
|
71
|
+
element: renderRouteElement(page, routeKey, pageComponent, wrapperProps),
|
|
72
|
+
...(routeMeta?.[routeKey] ?? {})
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { LoginSocialPayload, SocialProvider } from '../types';
|
|
2
|
+
type SocialProviderClientConfig = {
|
|
3
|
+
clientId: string;
|
|
4
|
+
redirectUri?: string;
|
|
5
|
+
scope?: string;
|
|
6
|
+
scopes?: string[];
|
|
7
|
+
usePopup?: boolean;
|
|
8
|
+
responseMode?: 'web_message' | 'form_post' | 'query' | 'fragment';
|
|
9
|
+
responseType?: 'code' | 'id_token' | 'code id_token';
|
|
10
|
+
state?: string;
|
|
11
|
+
nonce?: string;
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type GoogleCodeResponse = {
|
|
15
|
+
code?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
};
|
|
18
|
+
type GoogleCredentialResponse = {
|
|
19
|
+
credential?: string;
|
|
20
|
+
};
|
|
21
|
+
type GooglePromptMomentNotification = {
|
|
22
|
+
isNotDisplayed?: () => boolean;
|
|
23
|
+
isSkippedMoment?: () => boolean;
|
|
24
|
+
isDismissedMoment?: () => boolean;
|
|
25
|
+
getNotDisplayedReason?: () => string;
|
|
26
|
+
getSkippedReason?: () => string;
|
|
27
|
+
getDismissedReason?: () => string;
|
|
28
|
+
};
|
|
29
|
+
type AppleSignInResponse = {
|
|
30
|
+
authorization?: {
|
|
31
|
+
code?: string;
|
|
32
|
+
grant_code?: string;
|
|
33
|
+
grantCode?: string;
|
|
34
|
+
authorizationCode?: string;
|
|
35
|
+
id_token?: string;
|
|
36
|
+
idToken?: string;
|
|
37
|
+
scope?: string | string[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
type FacebookLoginResponse = {
|
|
41
|
+
authResponse?: {
|
|
42
|
+
accessToken?: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
declare global {
|
|
46
|
+
interface Window {
|
|
47
|
+
google?: {
|
|
48
|
+
accounts?: {
|
|
49
|
+
id?: {
|
|
50
|
+
initialize: (options: {
|
|
51
|
+
client_id: string;
|
|
52
|
+
callback: (response: GoogleCredentialResponse) => void;
|
|
53
|
+
}) => void;
|
|
54
|
+
prompt: (listener?: (notification: GooglePromptMomentNotification) => void) => void;
|
|
55
|
+
cancel: () => void;
|
|
56
|
+
};
|
|
57
|
+
oauth2?: {
|
|
58
|
+
initCodeClient: (options: {
|
|
59
|
+
client_id: string;
|
|
60
|
+
scope: string;
|
|
61
|
+
redirect_uri?: string;
|
|
62
|
+
ux_mode: 'popup';
|
|
63
|
+
callback: (response: GoogleCodeResponse) => void;
|
|
64
|
+
}) => {
|
|
65
|
+
requestCode: () => void;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
AppleID?: {
|
|
71
|
+
auth: {
|
|
72
|
+
init: (options: {
|
|
73
|
+
clientId: string;
|
|
74
|
+
scope: string;
|
|
75
|
+
redirectURI: string;
|
|
76
|
+
usePopup: boolean;
|
|
77
|
+
responseMode?: 'web_message' | 'form_post' | 'query' | 'fragment';
|
|
78
|
+
responseType?: 'code' | 'id_token' | 'code id_token';
|
|
79
|
+
state?: string;
|
|
80
|
+
nonce?: string;
|
|
81
|
+
}) => void;
|
|
82
|
+
signIn: () => Promise<AppleSignInResponse>;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
FB?: {
|
|
86
|
+
init: (options: {
|
|
87
|
+
appId: string;
|
|
88
|
+
cookie: boolean;
|
|
89
|
+
xfbml: boolean;
|
|
90
|
+
version: string;
|
|
91
|
+
}) => void;
|
|
92
|
+
login: (callback: (response: FacebookLoginResponse) => void, options?: {
|
|
93
|
+
scope?: string;
|
|
94
|
+
display?: 'popup' | 'touch' | 'page';
|
|
95
|
+
}) => void;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export declare const authenticateWithSocialProvider: (provider: SocialProvider, config: SocialProviderClientConfig) => Promise<Pick<LoginSocialPayload, "provider" | "authorizationCode" | "idToken" | "accessToken" | "redirectUri" | "clientId">>;
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=providerAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providerAuth.d.ts","sourceRoot":"","sources":["../../../src/auth/social/providerAuth.ts"],"names":[],"mappings":"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"}
|