@joelbarron/react-web-dev-kit 0.1.7 → 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 -45
- package/dist/auth/client.d.ts.map +0 -1
- package/dist/auth/client.js +0 -367
- 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 -190
- 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 -460
- package/dist/auth/fuse/fuseAdapter.d.ts +0 -41
- package/dist/auth/fuse/fuseAdapter.d.ts.map +0 -1
- package/dist/auth/fuse/fuseAdapter.js +0 -271
- 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 -226
- 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 -12
- package/dist/forms/JBDatePickerField.d.ts.map +0 -1
- package/dist/forms/JBDatePickerField.js +0 -16
- 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 -16
- 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 -333
- 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 -47
- 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 -28
- 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 -196
- 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
package/dist/auth/query.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
package/dist/auth/query.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/auth/query.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/auth/routes.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,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
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"providerAuth.d.ts","sourceRoot":"","sources":["../../../src/auth/social/providerAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE9D,KAAK,0BAA0B,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,aAAa,GAAG,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC;IAClE,YAAY,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC;IAC/B,eAAe,CAAC,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AAQ,0BAA0B,KACjC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,mBAAmB,GAAG,SAAS,GAAG,aAAa,GAAG,aAAa,GAAG,UAAU,CAAC,CAc7H,CAAC"}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
const scriptLoaders = new Map();
|
|
2
|
-
const loadScript = (src) => {
|
|
3
|
-
const existing = scriptLoaders.get(src);
|
|
4
|
-
if (existing) {
|
|
5
|
-
return existing;
|
|
6
|
-
}
|
|
7
|
-
const loader = new Promise((resolve, reject) => {
|
|
8
|
-
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
9
|
-
reject(new Error('Social auth is only available in browser environments.'));
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const script = document.createElement('script');
|
|
13
|
-
script.src = src;
|
|
14
|
-
script.async = true;
|
|
15
|
-
script.defer = true;
|
|
16
|
-
script.onload = () => resolve();
|
|
17
|
-
script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
|
|
18
|
-
document.head.appendChild(script);
|
|
19
|
-
});
|
|
20
|
-
scriptLoaders.set(src, loader);
|
|
21
|
-
return loader;
|
|
22
|
-
};
|
|
23
|
-
const ensureGoogleSdk = async () => {
|
|
24
|
-
await loadScript('https://accounts.google.com/gsi/client');
|
|
25
|
-
if (!window.google?.accounts?.id?.initialize) {
|
|
26
|
-
throw new Error('Google SDK is not available.');
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const ensureAppleSdk = async () => {
|
|
30
|
-
await loadScript('https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js');
|
|
31
|
-
if (!window.AppleID?.auth) {
|
|
32
|
-
throw new Error('Apple SDK is not available.');
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const ensureFacebookSdk = async (clientId) => {
|
|
36
|
-
await loadScript('https://connect.facebook.net/en_US/sdk.js');
|
|
37
|
-
if (!window.FB?.init) {
|
|
38
|
-
throw new Error('Facebook SDK is not available.');
|
|
39
|
-
}
|
|
40
|
-
window.FB.init({
|
|
41
|
-
appId: clientId,
|
|
42
|
-
cookie: true,
|
|
43
|
-
xfbml: false,
|
|
44
|
-
version: 'v20.0'
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
const isLikelyMobileBrowser = () => {
|
|
48
|
-
if (typeof navigator === 'undefined' || typeof window === 'undefined') {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
const userAgent = navigator.userAgent || '';
|
|
52
|
-
const hasTouch = (navigator.maxTouchPoints ?? 0) > 0;
|
|
53
|
-
const hasCoarsePointer = typeof window.matchMedia === 'function'
|
|
54
|
-
? window.matchMedia('(pointer: coarse)').matches
|
|
55
|
-
: false;
|
|
56
|
-
const smallViewport = typeof window.innerWidth === 'number' ? window.innerWidth <= 1024 : false;
|
|
57
|
-
const isMobileUserAgent = /Android|iPhone|iPad|iPod|IEMobile|Opera Mini|Mobile/i.test(userAgent);
|
|
58
|
-
const isIpadOsDesktopMode = /Macintosh/i.test(userAgent) && hasTouch;
|
|
59
|
-
return isMobileUserAgent || isIpadOsDesktopMode || ((hasTouch || hasCoarsePointer) && smallViewport);
|
|
60
|
-
};
|
|
61
|
-
const logSocialDebug = (enabled, message, payload) => {
|
|
62
|
-
if (!enabled) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (typeof payload === 'undefined') {
|
|
66
|
-
console.info(`[jb-auth][social] ${message}`);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
console.info(`[jb-auth][social] ${message}`, payload);
|
|
70
|
-
};
|
|
71
|
-
const authenticateWithGoogle = async (config) => {
|
|
72
|
-
logSocialDebug(config.debug, 'google provider auth start', {
|
|
73
|
-
clientId: config.clientId
|
|
74
|
-
});
|
|
75
|
-
await ensureGoogleSdk();
|
|
76
|
-
const response = await new Promise((resolve, reject) => {
|
|
77
|
-
let settled = false;
|
|
78
|
-
const timeoutId = window.setTimeout(() => {
|
|
79
|
-
if (settled) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
settled = true;
|
|
83
|
-
reject(new Error('Google authentication timeout.'));
|
|
84
|
-
}, 30000);
|
|
85
|
-
window.google.accounts.id.initialize({
|
|
86
|
-
client_id: config.clientId,
|
|
87
|
-
callback: (credentialResponse) => {
|
|
88
|
-
if (settled) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
settled = true;
|
|
92
|
-
window.clearTimeout(timeoutId);
|
|
93
|
-
resolve(credentialResponse);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
window.google.accounts.id.cancel();
|
|
97
|
-
window.google.accounts.id.prompt((notification) => {
|
|
98
|
-
if (settled) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const isNotDisplayed = notification?.isNotDisplayed?.() ?? false;
|
|
102
|
-
const isSkipped = notification?.isSkippedMoment?.() ?? false;
|
|
103
|
-
const isDismissed = notification?.isDismissedMoment?.() ?? false;
|
|
104
|
-
if (!isNotDisplayed && !isSkipped && !isDismissed) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
settled = true;
|
|
108
|
-
window.clearTimeout(timeoutId);
|
|
109
|
-
const reason = notification?.getNotDisplayedReason?.() ||
|
|
110
|
-
notification?.getSkippedReason?.() ||
|
|
111
|
-
notification?.getDismissedReason?.() ||
|
|
112
|
-
'Google sign-in cancelled';
|
|
113
|
-
reject(new Error(`Google authentication was not completed: ${reason}`));
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
if (!response.credential) {
|
|
117
|
-
throw new Error('Google authentication failed.');
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
provider: 'google',
|
|
121
|
-
idToken: response.credential,
|
|
122
|
-
clientId: config.clientId
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
const authenticateWithApple = async (config) => {
|
|
126
|
-
logSocialDebug(config.debug, 'apple provider auth start', {
|
|
127
|
-
clientId: config.clientId,
|
|
128
|
-
redirectUri: config.redirectUri,
|
|
129
|
-
usePopup: config.usePopup,
|
|
130
|
-
responseMode: config.responseMode,
|
|
131
|
-
responseType: config.responseType
|
|
132
|
-
});
|
|
133
|
-
await ensureAppleSdk();
|
|
134
|
-
const usePopup = config.usePopup ?? true;
|
|
135
|
-
const resolvedScope = config.scope ?? config.scopes?.join(' ') ?? 'name email';
|
|
136
|
-
const resolvedRedirectUri = config.redirectUri || window.location.origin;
|
|
137
|
-
const resolvedResponseMode = config.responseMode ?? (usePopup ? 'web_message' : 'form_post');
|
|
138
|
-
const resolvedResponseType = config.responseType ?? (usePopup ? 'code id_token' : 'code');
|
|
139
|
-
window.AppleID.auth.init({
|
|
140
|
-
clientId: config.clientId,
|
|
141
|
-
scope: resolvedScope,
|
|
142
|
-
redirectURI: resolvedRedirectUri,
|
|
143
|
-
usePopup,
|
|
144
|
-
responseMode: resolvedResponseMode,
|
|
145
|
-
responseType: resolvedResponseType,
|
|
146
|
-
state: config.state,
|
|
147
|
-
nonce: config.nonce
|
|
148
|
-
});
|
|
149
|
-
const response = await window.AppleID.auth.signIn();
|
|
150
|
-
const authorizationCode = response.authorization?.code ??
|
|
151
|
-
response.authorization?.grant_code ??
|
|
152
|
-
response.authorization?.grantCode ??
|
|
153
|
-
response.authorization?.authorizationCode;
|
|
154
|
-
const idToken = response.authorization?.id_token ?? response.authorization?.idToken;
|
|
155
|
-
if (!authorizationCode && !idToken) {
|
|
156
|
-
throw new Error('Apple authentication failed.');
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
provider: 'apple',
|
|
160
|
-
authorizationCode,
|
|
161
|
-
idToken,
|
|
162
|
-
redirectUri: resolvedRedirectUri,
|
|
163
|
-
clientId: config.clientId
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
const authenticateWithFacebook = async (config) => {
|
|
167
|
-
const mobileBrowser = isLikelyMobileBrowser();
|
|
168
|
-
const shouldUsePopup = config.usePopup ?? !mobileBrowser;
|
|
169
|
-
const resolvedDisplay = shouldUsePopup
|
|
170
|
-
? 'popup'
|
|
171
|
-
: mobileBrowser
|
|
172
|
-
? 'touch'
|
|
173
|
-
: 'page';
|
|
174
|
-
logSocialDebug(config.debug, 'facebook provider auth start', {
|
|
175
|
-
clientId: config.clientId,
|
|
176
|
-
display: resolvedDisplay,
|
|
177
|
-
usePopup: shouldUsePopup
|
|
178
|
-
});
|
|
179
|
-
await ensureFacebookSdk(config.clientId);
|
|
180
|
-
const response = await new Promise((resolve) => {
|
|
181
|
-
window.FB.login(resolve, {
|
|
182
|
-
scope: config.scope ?? 'email,public_profile',
|
|
183
|
-
display: resolvedDisplay
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
const accessToken = response.authResponse?.accessToken;
|
|
187
|
-
if (!accessToken) {
|
|
188
|
-
throw new Error('Facebook authentication failed.');
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
provider: 'facebook',
|
|
192
|
-
accessToken,
|
|
193
|
-
clientId: config.clientId
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
export const authenticateWithSocialProvider = async (provider, config) => {
|
|
197
|
-
if (!config.clientId?.trim()) {
|
|
198
|
-
throw new Error(`Missing social clientId for provider "${provider}".`);
|
|
199
|
-
}
|
|
200
|
-
if (provider === 'google') {
|
|
201
|
-
return authenticateWithGoogle(config);
|
|
202
|
-
}
|
|
203
|
-
if (provider === 'facebook') {
|
|
204
|
-
return authenticateWithFacebook(config);
|
|
205
|
-
}
|
|
206
|
-
return authenticateWithApple(config);
|
|
207
|
-
};
|
package/dist/auth/storage.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/auth/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,MAAM,KAAG,YAiBxE,CAAC"}
|
package/dist/auth/storage.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const createLocalStorageTokenStorage = (tokenStorageKey) => {
|
|
2
|
-
const hasWindow = typeof window !== 'undefined' && !!window.localStorage;
|
|
3
|
-
return {
|
|
4
|
-
getAccessToken: () => {
|
|
5
|
-
if (!hasWindow)
|
|
6
|
-
return null;
|
|
7
|
-
return window.localStorage.getItem(tokenStorageKey);
|
|
8
|
-
},
|
|
9
|
-
setAccessToken: (token) => {
|
|
10
|
-
if (!hasWindow)
|
|
11
|
-
return;
|
|
12
|
-
window.localStorage.setItem(tokenStorageKey, token);
|
|
13
|
-
},
|
|
14
|
-
removeAccessToken: () => {
|
|
15
|
-
if (!hasWindow)
|
|
16
|
-
return;
|
|
17
|
-
window.localStorage.removeItem(tokenStorageKey);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
};
|