@coinbase/cdp-react 0.0.98 → 0.0.100
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/components/AuthButton/index.d.ts +102 -0
- package/dist/components/CDPReactProvider/index.d.ts +114 -0
- package/dist/components/CopyAddress/index.d.ts +29 -0
- package/dist/components/CopyEvmKeyButton/index.d.ts +77 -0
- package/dist/components/CopySolanaKeyButton/index.d.ts +73 -0
- package/dist/components/EnrollMfa/EnrollMfaDescription.d.ts +21 -0
- package/dist/components/EnrollMfa/EnrollMfaFlow.d.ts +27 -0
- package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.d.ts +19 -0
- package/dist/components/EnrollMfa/EnrollMfaFlowProvider.d.ts +52 -0
- package/dist/components/EnrollMfa/EnrollMfaFooter.d.ts +18 -0
- package/dist/components/EnrollMfa/EnrollMfaImage.d.ts +24 -0
- package/dist/components/EnrollMfa/EnrollMfaItem.d.ts +21 -0
- package/dist/components/EnrollMfa/EnrollMfaItems.d.ts +17 -0
- package/dist/components/EnrollMfa/EnrollMfaProvider.d.ts +35 -0
- package/dist/components/EnrollMfa/EnrollMfaTitle.d.ts +21 -0
- package/dist/components/EnrollMfa/index.d.ts +65 -0
- package/dist/components/EnrollMfa/methods/sms.d.ts +25 -0
- package/dist/components/EnrollMfa/methods/totp.d.ts +25 -0
- package/dist/components/EnrollMfa/types.d.ts +48 -0
- package/dist/components/EnrollMfa/useEnrollMfaReducer.d.ts +6 -0
- package/dist/components/EnrollMfaModal/index.d.ts +111 -0
- package/dist/components/ExportWallet/index.d.ts +163 -0
- package/dist/components/ExportWalletModal/index.d.ts +173 -0
- package/dist/components/Fund/FundForm.d.ts +18 -0
- package/dist/components/Fund/FundProvider.d.ts +17 -0
- package/dist/components/Fund/FundTitle.d.ts +12 -0
- package/dist/components/Fund/components/FundAmountInput.d.ts +13 -0
- package/dist/components/Fund/components/FundErrorScreen.d.ts +7 -0
- package/dist/components/Fund/components/FundPaymentMethods.d.ts +7 -0
- package/dist/components/Fund/components/FundPresetAmountInputs.d.ts +7 -0
- package/dist/components/Fund/components/FundTransactionStatus.d.ts +6 -0
- package/dist/components/Fund/hooks/useBuyUrl.d.ts +23 -0
- package/dist/components/Fund/hooks/useEmitLifecycleStatus.d.ts +12 -0
- package/dist/components/Fund/hooks/useExchangeRate.d.ts +17 -0
- package/dist/components/Fund/hooks/usePaymentMethods.d.ts +16 -0
- package/dist/components/Fund/hooks/usePopupMonitor.d.ts +9 -0
- package/dist/components/Fund/hooks/useSetupOnrampEventListeners.d.ts +6 -0
- package/dist/components/Fund/index.d.ts +87 -0
- package/dist/components/Fund/types.d.ts +137 -0
- package/dist/components/Fund/useFundReducer.d.ts +15 -0
- package/dist/components/Fund/utils/buildPaymentMethods.d.ts +15 -0
- package/dist/components/Fund/utils/setupOnrampEventListeners.d.ts +10 -0
- package/dist/components/Fund/utils/subscribeToWindowMessage.d.ts +27 -0
- package/dist/components/FundModal/index.d.ts +106 -0
- package/dist/components/LinkAuth/LinkAuthFlow.d.ts +25 -0
- package/dist/components/LinkAuth/LinkAuthFlowBackButton.d.ts +19 -0
- package/dist/components/LinkAuth/LinkAuthFlowProvider.d.ts +60 -0
- package/dist/components/LinkAuth/LinkAuthItem.d.ts +23 -0
- package/dist/components/LinkAuth/LinkAuthItems.d.ts +17 -0
- package/dist/components/LinkAuth/LinkAuthItems.js +30 -30
- package/dist/components/LinkAuth/LinkAuthProvider.d.ts +31 -0
- package/dist/components/LinkAuth/LinkAuthTitle.d.ts +17 -0
- package/dist/components/LinkAuth/index.d.ts +170 -0
- package/dist/components/LinkAuth/types.d.ts +31 -0
- package/dist/components/LinkAuth/utils.d.ts +12 -0
- package/dist/components/LinkAuthModal/index.d.ts +112 -0
- package/dist/components/OAuthStatusModal/index.d.ts +24 -0
- package/dist/components/SendEvmTransactionButton/index.d.ts +27 -0
- package/dist/components/SendSolanaTransactionButton/index.d.ts +27 -0
- package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +26 -0
- package/dist/components/SignIn/SignInBackButton.d.ts +40 -0
- package/dist/components/SignIn/SignInCredentials.d.ts +13 -0
- package/dist/components/SignIn/SignInDescription.d.ts +35 -0
- package/dist/components/SignIn/SignInFooter.d.ts +27 -0
- package/dist/components/SignIn/SignInForm.d.ts +39 -0
- package/dist/components/SignIn/SignInImage.d.ts +38 -0
- package/dist/components/SignIn/SignInProvider.d.ts +54 -0
- package/dist/components/SignIn/SignInTitle.d.ts +35 -0
- package/dist/components/SignIn/flows/SignInWithEmail.d.ts +26 -0
- package/dist/components/SignIn/flows/SignInWithOAuth.d.ts +19 -0
- package/dist/components/SignIn/flows/SignInWithSms.d.ts +26 -0
- package/dist/components/SignIn/hooks/useEmailForm.d.ts +7 -0
- package/dist/components/SignIn/hooks/useOTPForm.d.ts +8 -0
- package/dist/components/SignIn/hooks/usePhoneNumberForm.d.ts +7 -0
- package/dist/components/SignIn/hooks/useSignInWithOAuth.d.ts +8 -0
- package/dist/components/SignIn/index.d.ts +124 -0
- package/dist/components/SignIn/types.d.ts +37 -0
- package/dist/components/SignIn/useSignInReducer.d.ts +9 -0
- package/dist/components/SignInModal/index.d.ts +123 -0
- package/dist/components/SignOutButton/index.d.ts +39 -0
- package/dist/components/ThemeProvider/index.d.ts +70 -0
- package/dist/components/VerifyMfa/VerifyMfaDescription.d.ts +24 -0
- package/dist/components/VerifyMfa/VerifyMfaFlow.d.ts +30 -0
- package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.d.ts +19 -0
- package/dist/components/VerifyMfa/VerifyMfaFlowProvider.d.ts +51 -0
- package/dist/components/VerifyMfa/VerifyMfaFooter.d.ts +18 -0
- package/dist/components/VerifyMfa/VerifyMfaImage.d.ts +23 -0
- package/dist/components/VerifyMfa/VerifyMfaItem.d.ts +20 -0
- package/dist/components/VerifyMfa/VerifyMfaItems.d.ts +18 -0
- package/dist/components/VerifyMfa/VerifyMfaProvider.d.ts +40 -0
- package/dist/components/VerifyMfa/VerifyMfaTitle.d.ts +24 -0
- package/dist/components/VerifyMfa/index.d.ts +55 -0
- package/dist/components/VerifyMfa/methods/sms.d.ts +29 -0
- package/dist/components/VerifyMfa/methods/totp.d.ts +29 -0
- package/dist/components/VerifyMfa/types.d.ts +33 -0
- package/dist/components/VerifyMfa/useVerifyMfaReducer.d.ts +7 -0
- package/dist/components/VerifyMfaInline/index.d.ts +212 -0
- package/dist/components/VerifyMfaModal/index.d.ts +114 -0
- package/dist/components/forms/AmountInput/index.d.ts +16 -0
- package/dist/components/forms/AmountInput/types.d.ts +9 -0
- package/dist/components/forms/AmountInput/useAmountInput.d.ts +14 -0
- package/dist/components/forms/AmountInput/useInputScale.d.ts +12 -0
- package/dist/components/forms/AmountInput/useNumberParseAndFormat.d.ts +20 -0
- package/dist/components/forms/CountrySelect/index.d.ts +9 -0
- package/dist/components/forms/EmailForm/index.d.ts +17 -0
- package/dist/components/forms/ExchangeAmountInput/index.d.ts +19 -0
- package/dist/components/forms/ExchangeAmountInput/types.d.ts +12 -0
- package/dist/components/forms/ExchangeAmountInput/useExchangeAmountInput.d.ts +17 -0
- package/dist/components/forms/Field/index.d.ts +15 -0
- package/dist/components/forms/Input/index.d.ts +15 -0
- package/dist/components/forms/Label/index.d.ts +8 -0
- package/dist/components/forms/OTP/index.d.ts +6 -0
- package/dist/components/forms/OTPForm/index.d.ts +20 -0
- package/dist/components/forms/PhoneNumberForm/index.d.ts +27 -0
- package/dist/components/forms/PhoneNumberInput/index.d.ts +16 -0
- package/dist/components/forms/PhoneNumberInput/maskOverride.d.ts +6 -0
- package/dist/components/forms/PhoneNumberInput/usePhoneNumberFormatter.d.ts +7 -0
- package/dist/components/forms/Select/index.d.ts +30 -0
- package/dist/components/ui/Badge/index.d.ts +19 -0
- package/dist/components/ui/Banner/index.d.ts +25 -0
- package/dist/components/ui/Button/index.d.ts +50 -0
- package/dist/components/ui/ButtonBase/index.d.ts +20 -0
- package/dist/components/ui/CoinbaseFooter/index.d.ts +16 -0
- package/dist/components/ui/CopyTextField/index.d.ts +35 -0
- package/dist/components/ui/Error/index.d.ts +14 -0
- package/dist/components/ui/IframeButton/index.d.ts +17 -0
- package/dist/components/ui/LoadingSkeleton/index.d.ts +22 -0
- package/dist/components/ui/LoadingSpinner/index.d.ts +11 -0
- package/dist/components/ui/Modal/index.d.ts +82 -0
- package/dist/components/ui/QRCode/QRCodeSvg.d.ts +35 -0
- package/dist/components/ui/QRCode/index.d.ts +7 -0
- package/dist/components/ui/QRCode/useCorners.d.ts +9 -0
- package/dist/components/ui/QRCode/useDotsPath.d.ts +18 -0
- package/dist/components/ui/QRCode/useLogo.d.ts +18 -0
- package/dist/components/ui/QRCode/useMatrix.d.ts +7 -0
- package/dist/components/ui/ServerError/index.d.ts +6 -0
- package/dist/components/ui/SuccessMessage/index.d.ts +14 -0
- package/dist/components/ui/SwitchFadeTransition/index.d.ts +15 -0
- package/dist/components/ui/SwitchSlideTransition/index.d.ts +16 -0
- package/dist/components/ui/SwitchTransition/index.d.ts +42 -0
- package/dist/components/ui/ToggleListItem/index.d.ts +31 -0
- package/dist/components/ui/VisuallyHidden/index.d.ts +18 -0
- package/dist/data/countries.d.ts +15 -0
- package/dist/data/countryNames.d.ts +4 -0
- package/dist/hooks/useKeyExportPostMessage.d.ts +25 -0
- package/dist/hooks/usePhoneNumberState.d.ts +47 -0
- package/dist/hooks/usePhoneNumberValidators.d.ts +8 -0
- package/dist/hooks/useTimeout.d.ts +18 -0
- package/dist/hooks/useTimer.d.ts +6 -0
- package/dist/hooks/useTransitionMap.d.ts +22 -0
- package/dist/hooks/useVerifyMfaModal.d.ts +78 -0
- package/dist/icons/IconAppleLogo.d.ts +22 -0
- package/dist/icons/IconArrowLeft.d.ts +22 -0
- package/dist/icons/IconArrowsUpDown.d.ts +22 -0
- package/dist/icons/IconCheck.d.ts +22 -0
- package/dist/icons/IconCheckCircle.d.ts +21 -0
- package/dist/icons/IconChevronDown.d.ts +22 -0
- package/dist/icons/IconCoinbaseMark.d.ts +22 -0
- package/dist/icons/IconCoinbaseWordmark.d.ts +22 -0
- package/dist/icons/IconCopy.d.ts +22 -0
- package/dist/icons/IconCreditCard.d.ts +22 -0
- package/dist/icons/IconCurrencies.d.ts +22 -0
- package/dist/icons/IconEnvelope.d.ts +22 -0
- package/dist/icons/IconExclamationCircle.d.ts +22 -0
- package/dist/icons/IconExclamationTriangle.d.ts +22 -0
- package/dist/icons/IconGoogleColorLogo.d.ts +22 -0
- package/dist/icons/IconGoogleLogo.d.ts +22 -0
- package/dist/icons/IconLock.d.ts +22 -0
- package/dist/icons/IconMinus.d.ts +21 -0
- package/dist/icons/IconPhone.d.ts +22 -0
- package/dist/icons/IconPinCode.d.ts +22 -0
- package/dist/icons/IconPlus.d.ts +21 -0
- package/dist/icons/IconShield.d.ts +22 -0
- package/dist/icons/IconSmartPhone.d.ts +22 -0
- package/dist/icons/IconTelegramLogo.d.ts +22 -0
- package/dist/icons/IconXLogo.d.ts +22 -0
- package/dist/icons/IconXMark.d.ts +22 -0
- package/dist/icons/SvgIcon.d.ts +6 -0
- package/dist/theme/cssVariables.d.ts +10 -0
- package/dist/theme/theme.d.ts +246 -0
- package/dist/theme/tokens.d.ts +54 -0
- package/dist/theme/utils.d.ts +63 -0
- package/dist/types/secureIframe.d.ts +3 -0
- package/dist/utils/capitalize.d.ts +8 -0
- package/dist/utils/childrenHasComponent.d.ts +10 -0
- package/dist/utils/clamp.d.ts +10 -0
- package/dist/utils/formatFiat.d.ts +11 -0
- package/dist/utils/formatPhoneNumber.d.ts +8 -0
- package/dist/utils/getMessageFromUnknownError.d.ts +9 -0
- package/dist/utils/isApiError.d.ts +21 -0
- package/dist/utils/isEmailInvalid.d.ts +15 -0
- package/dist/utils/openPopup.d.ts +15 -0
- package/dist/utils/parseValuesFromPhoneNumber.d.ts +16 -0
- package/dist/utils/sendIframeMessage.d.ts +8 -0
- package/dist/utils/toOAuthProviderType.d.ts +8 -0
- package/dist/utils/transition.d.ts +41 -0
- package/dist/version.d.ts +5 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
|
@@ -3,31 +3,91 @@ import { AuthMethod } from '../CDPReactProvider';
|
|
|
3
3
|
import { SwitchSlideTransitionRef } from '../ui/SwitchSlideTransition';
|
|
4
4
|
import { SignInContentRef } from './LinkAuthFlow';
|
|
5
5
|
import { LinkAuthFlowView } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* The value of the link auth flow context.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link useLinkAuthFlow}
|
|
10
|
+
*/
|
|
6
11
|
export interface LinkAuthFlowContextValue {
|
|
12
|
+
/** A function to call when the back button is clicked. */
|
|
7
13
|
back: () => void;
|
|
14
|
+
/** The direction of the flow transition. */
|
|
8
15
|
direction?: "left" | "right";
|
|
16
|
+
/** A function to call when the user links an auth method. */
|
|
9
17
|
link: (method: AuthMethod) => void;
|
|
18
|
+
/** A function to call when an auth method is successfully linked. */
|
|
10
19
|
linkSuccess: () => void;
|
|
11
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* The value of the link auth flow context for the internal use of the component.
|
|
23
|
+
*
|
|
24
|
+
* @see {@link useLinkAuthFlowInternal}
|
|
25
|
+
*/
|
|
12
26
|
export interface LinkAuthFlowContextValueInternal extends LinkAuthFlowContextValue {
|
|
27
|
+
/** A ref to the flow transition. */
|
|
13
28
|
transitionRef: RefObject<SwitchSlideTransitionRef<LinkAuthFlowView> | null> | null;
|
|
29
|
+
/** A ref that provides the ability to go back to the previous step of the sign in flow. */
|
|
14
30
|
signInRef: RefObject<SignInContentRef | null> | null;
|
|
15
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Props for the LinkAuthFlowProvider component.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link LinkAuthFlowProvider}
|
|
36
|
+
*/
|
|
16
37
|
interface LinkAuthFlowProviderProps {
|
|
38
|
+
/** The children of the component. */
|
|
17
39
|
children?: ReactNode;
|
|
40
|
+
/** The direction of the flow transition. */
|
|
18
41
|
direction?: LinkAuthFlowContextValue["direction"];
|
|
42
|
+
/** A function to call when the back button is clicked. */
|
|
19
43
|
onBack: LinkAuthFlowContextValue["back"];
|
|
44
|
+
/** A function to call when the user links an auth method. */
|
|
20
45
|
onLink: LinkAuthFlowContextValue["link"];
|
|
46
|
+
/** A function to call when an auth method is successfully linked. */
|
|
21
47
|
onLinkSuccess: LinkAuthFlowContextValue["linkSuccess"];
|
|
48
|
+
/** A ref to the flow transition. */
|
|
22
49
|
transitionRef: LinkAuthFlowContextValueInternal["transitionRef"];
|
|
50
|
+
/** A ref that provides the ability to go back to the previous step of the sign in flow. */
|
|
23
51
|
signInRef: LinkAuthFlowContextValueInternal["signInRef"];
|
|
24
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* A hook to get the link auth flow context value.
|
|
55
|
+
*
|
|
56
|
+
* @returns {LinkAuthFlowContextValueInternal} The link auth flow context value.
|
|
57
|
+
*
|
|
58
|
+
* @group Hooks
|
|
59
|
+
*/
|
|
25
60
|
export declare const useLinkAuthFlowInternal: () => LinkAuthFlowContextValueInternal;
|
|
61
|
+
/**
|
|
62
|
+
* A hook to get the link auth flow context value.
|
|
63
|
+
*
|
|
64
|
+
* @returns {LinkAuthFlowContextValue} The link auth flow context value.
|
|
65
|
+
*
|
|
66
|
+
* @see {@link LinkAuthFlow}
|
|
67
|
+
* @see {@link LinkAuth}
|
|
68
|
+
*
|
|
69
|
+
* @group Hooks
|
|
70
|
+
*/
|
|
26
71
|
export declare const useLinkAuthFlow: () => {
|
|
72
|
+
/** A function to call when the back button is clicked. */
|
|
27
73
|
back: () => void;
|
|
74
|
+
/** The direction of the flow transition. */
|
|
28
75
|
direction?: "left" | "right";
|
|
76
|
+
/** A function to call when the user links an auth method. */
|
|
29
77
|
link: (method: AuthMethod) => void;
|
|
78
|
+
/** A function to call when an auth method is successfully linked. */
|
|
30
79
|
linkSuccess: () => void;
|
|
31
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* A provider for the link auth flow.
|
|
83
|
+
*
|
|
84
|
+
* @param {LinkAuthFlowProviderProps} props - The props for the LinkAuthFlowProvider component.
|
|
85
|
+
* @returns {JSX.Element} The LinkAuthFlowProvider component.
|
|
86
|
+
*
|
|
87
|
+
* @see {@link LinkAuthFlow}
|
|
88
|
+
* @see {@link LinkAuth}
|
|
89
|
+
*
|
|
90
|
+
* @group Components
|
|
91
|
+
*/
|
|
32
92
|
export declare const LinkAuthFlowProvider: ({ direction, children, onBack, onLink, onLinkSuccess, signInRef, transitionRef, }: LinkAuthFlowProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
93
|
export {};
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
2
|
import { LinkAuthMethod } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The props for the LinkAuthItem component.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link LinkAuthItem}
|
|
7
|
+
*/
|
|
3
8
|
interface LinkAuthItemProps {
|
|
9
|
+
/** A user-readable label for the auth method */
|
|
4
10
|
authMethod: LinkAuthMethod["method"];
|
|
11
|
+
/** Whether the auth method is linked to the current user's account */
|
|
5
12
|
isLinked: boolean;
|
|
13
|
+
/** Whether the auth method linking is pending */
|
|
6
14
|
isPending?: boolean;
|
|
15
|
+
/** An icon to display */
|
|
7
16
|
icon?: ReactNode;
|
|
17
|
+
/** A label for the auth method */
|
|
8
18
|
label: string;
|
|
19
|
+
/** The user alias for the auth method (i.e. email address, phone number, etc.) */
|
|
9
20
|
userAlias?: string;
|
|
21
|
+
/** A function to call when the auth method is linked. */
|
|
10
22
|
onLink: MouseEventHandler<HTMLButtonElement>;
|
|
11
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* A component for displaying an auth method in the link auth list.
|
|
26
|
+
*
|
|
27
|
+
* @param {LinkAuthItemProps} props - The props for the LinkAuthItem component.
|
|
28
|
+
* @returns {JSX.Element} The LinkAuthItem component.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link LinkAuthItems}
|
|
31
|
+
* @see {@link LinkAuth}
|
|
32
|
+
*
|
|
33
|
+
* @group Components
|
|
34
|
+
*/
|
|
12
35
|
declare const LinkAuthItem: ({ authMethod: _authMethod, userAlias, icon, isLinked, isPending, label, onLink, }: LinkAuthItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
36
|
export { LinkAuthItem, type LinkAuthItemProps };
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { AuthMethod } from '../CDPReactProvider';
|
|
3
3
|
import { LinkAuthItemProps } from './LinkAuthItem';
|
|
4
|
+
/**
|
|
5
|
+
* The props for the LinkAuthItems component.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link LinkAuthItems}
|
|
8
|
+
*/
|
|
4
9
|
interface LinkAuthItemsProps extends Omit<HTMLAttributes<HTMLUListElement>, "children"> {
|
|
10
|
+
/** A render function for the auth method item. */
|
|
5
11
|
children?: (props: LinkAuthItemProps) => ReactNode;
|
|
12
|
+
/** A function to call when the link button is clicked. */
|
|
6
13
|
onLink?: (method: AuthMethod) => void | Promise<void>;
|
|
7
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* A list of auth methods for linking to the current user's account.
|
|
17
|
+
*
|
|
18
|
+
* @param {LinkAuthItemsProps} props - The props for the LinkAuthItems component.
|
|
19
|
+
* @returns {JSX.Element} The LinkAuthItems component.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link LinkAuth}
|
|
22
|
+
*
|
|
23
|
+
* @group Components
|
|
24
|
+
*/
|
|
8
25
|
declare const LinkAuthItems: ({ children, className, onLink, ...props }: LinkAuthItemsProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
26
|
export { LinkAuthItems, type LinkAuthItemsProps };
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import { useMemo as
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { c as b } from "../../chunks/lite.1fxw3LjI.js";
|
|
3
|
+
import { useMemo as g } from "react";
|
|
4
4
|
import "../../chunks/CDPReactProvider.0yuqyXCv.js";
|
|
5
|
-
import { IconAppleLogo as
|
|
6
|
-
import { IconEnvelope as
|
|
7
|
-
import { IconGoogleColorLogo as
|
|
8
|
-
import { IconPhone as
|
|
9
|
-
import { IconTelegramLogo as
|
|
10
|
-
import { IconXLogo as
|
|
11
|
-
import { LinkAuthItem as
|
|
12
|
-
import { useLinkAuthContext as
|
|
13
|
-
import '../../assets/LinkAuthItems.css';const
|
|
14
|
-
list:
|
|
15
|
-
},
|
|
16
|
-
email: { Icon: /* @__PURE__ */
|
|
17
|
-
sms: { Icon: /* @__PURE__ */
|
|
18
|
-
"oauth:google": { Icon: /* @__PURE__ */
|
|
19
|
-
"oauth:apple": { Icon: /* @__PURE__ */
|
|
20
|
-
"oauth:x": { Icon: /* @__PURE__ */
|
|
21
|
-
"oauth:telegram": { Icon: /* @__PURE__ */
|
|
22
|
-
}, O = ({ children:
|
|
23
|
-
const { state:
|
|
24
|
-
const { Icon:
|
|
5
|
+
import { IconAppleLogo as d } from "../../icons/IconAppleLogo.js";
|
|
6
|
+
import { IconEnvelope as f } from "../../icons/IconEnvelope.js";
|
|
7
|
+
import { IconGoogleColorLogo as L } from "../../icons/IconGoogleColorLogo.js";
|
|
8
|
+
import { IconPhone as _ } from "../../icons/IconPhone.js";
|
|
9
|
+
import { IconTelegramLogo as A } from "../../icons/IconTelegramLogo.js";
|
|
10
|
+
import { IconXLogo as P } from "../../icons/IconXLogo.js";
|
|
11
|
+
import { LinkAuthItem as T } from "./LinkAuthItem.js";
|
|
12
|
+
import { useLinkAuthContext as k } from "./LinkAuthProvider.js";
|
|
13
|
+
import '../../assets/LinkAuthItems.css';const x = "LinkAuthItems-module__list___5AimM", M = {
|
|
14
|
+
list: x
|
|
15
|
+
}, m = {
|
|
16
|
+
email: { Icon: /* @__PURE__ */ e(f, { "aria-label": "Email" }), label: "Email" },
|
|
17
|
+
sms: { Icon: /* @__PURE__ */ e(_, { "aria-label": "Phone" }), label: "Phone" },
|
|
18
|
+
"oauth:google": { Icon: /* @__PURE__ */ e(L, { "aria-label": "Google" }), label: "Google" },
|
|
19
|
+
"oauth:apple": { Icon: /* @__PURE__ */ e(d, { "aria-label": "Apple" }), label: "Apple" },
|
|
20
|
+
"oauth:x": { Icon: /* @__PURE__ */ e(P, { "aria-label": "X" }), label: "X" },
|
|
21
|
+
"oauth:telegram": { Icon: /* @__PURE__ */ e(A, { "aria-label": "Telegram" }), label: "Telegram" }
|
|
22
|
+
}, O = ({ children: s, className: c = "", onLink: t, ...p }) => {
|
|
23
|
+
const { state: h, dispatch: a } = k(), { authMethods: i, isPending: r, methodToLink: n } = h, I = g(() => i.filter((o) => m[o.method]).map((o) => {
|
|
24
|
+
const { Icon: l, label: u } = m[o.method];
|
|
25
25
|
return {
|
|
26
26
|
...o,
|
|
27
|
-
icon:
|
|
28
|
-
label:
|
|
27
|
+
icon: l,
|
|
28
|
+
label: u,
|
|
29
29
|
onLink: async () => {
|
|
30
30
|
a({ type: "LINK_AUTH_METHOD", payload: { method: o.method } }), await t?.(o.method);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
}), [i, a, t]);
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
-
...
|
|
34
|
+
return /* @__PURE__ */ e("ul", { className: b(M.list, c), ...p, children: I.map(({ method: o, ...l }) => /* @__PURE__ */ e("li", { children: s?.({
|
|
35
|
+
...l,
|
|
36
36
|
authMethod: o,
|
|
37
37
|
isPending: r && n === o
|
|
38
|
-
}) || /* @__PURE__ */
|
|
39
|
-
|
|
38
|
+
}) || /* @__PURE__ */ e(
|
|
39
|
+
T,
|
|
40
40
|
{
|
|
41
|
-
...
|
|
41
|
+
...l,
|
|
42
42
|
authMethod: o,
|
|
43
43
|
isPending: r && n === o
|
|
44
44
|
}
|
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
import { Dispatch, ReactNode } from 'react';
|
|
2
2
|
import { LinkAuthAction, LinkAuthState } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The value of the link auth context.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link useLinkAuthContext}
|
|
7
|
+
*/
|
|
3
8
|
interface LinkAuthContextValue {
|
|
9
|
+
/** The current state of the link auth component. */
|
|
4
10
|
state: LinkAuthState;
|
|
11
|
+
/** The dispatch function for the link auth component. */
|
|
5
12
|
dispatch: Dispatch<LinkAuthAction>;
|
|
6
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Props for the LinkAuthProvider component.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link LinkAuthProvider}
|
|
18
|
+
*/
|
|
7
19
|
interface LinkAuthProviderProps {
|
|
20
|
+
/** The children to render. */
|
|
8
21
|
children: ReactNode;
|
|
9
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* A provider for the account linking context.
|
|
25
|
+
*
|
|
26
|
+
* @param {LinkAuthProviderProps} props - The props for the LinkAuthProvider component.
|
|
27
|
+
* @param {ReactNode} props.children - The children to render.
|
|
28
|
+
* @returns {JSX.Element} The LinkAuthProvider component.
|
|
29
|
+
*
|
|
30
|
+
* @group Components
|
|
31
|
+
*/
|
|
10
32
|
declare const LinkAuthProvider: ({ children }: LinkAuthProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
/**
|
|
34
|
+
* A hook to access the link auth context.
|
|
35
|
+
*
|
|
36
|
+
* @returns {LinkAuthContextValue} The link auth context.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link LinkAuth}
|
|
39
|
+
*
|
|
40
|
+
* @group Hooks
|
|
41
|
+
*/
|
|
11
42
|
declare const useLinkAuthContext: () => LinkAuthContextValue;
|
|
12
43
|
export { LinkAuthProvider, useLinkAuthContext, type LinkAuthProviderProps, type LinkAuthContextValue, };
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the LinkAuthTitle component.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link LinkAuthTitle}
|
|
6
|
+
*/
|
|
2
7
|
export interface LinkAuthTitleProps extends HTMLAttributes<HTMLElement> {
|
|
8
|
+
/** The element type to render the title as. */
|
|
3
9
|
as?: ElementType;
|
|
10
|
+
/** The children of the component. */
|
|
4
11
|
children?: ReactNode;
|
|
5
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* A title for the LinkAuth component.
|
|
15
|
+
*
|
|
16
|
+
* @param {LinkAuthTitleProps} props - The props for the component.
|
|
17
|
+
* @returns {JSX.Element} The LinkAuthTitle component.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link LinkAuth}
|
|
20
|
+
*
|
|
21
|
+
* @group Components
|
|
22
|
+
*/
|
|
6
23
|
export declare const LinkAuthTitle: ({ as: Component, children, className, ...props }: LinkAuthTitleProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -8,10 +8,180 @@ import { LinkAuthItems, LinkAuthItemsProps } from './LinkAuthItems';
|
|
|
8
8
|
import { useLinkAuthContext, LinkAuthContextValue } from './LinkAuthProvider';
|
|
9
9
|
import { LinkAuthTitle, LinkAuthTitleProps } from './LinkAuthTitle';
|
|
10
10
|
import { LinkAuthState, LinkAuthMethod, LinkAuthAction } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Props for the LinkAuth component
|
|
13
|
+
*
|
|
14
|
+
* @see {@link LinkAuth}
|
|
15
|
+
*/
|
|
11
16
|
interface LinkAuthProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
17
|
+
/**
|
|
18
|
+
* The children of the component. Leave empty to use the default UI.
|
|
19
|
+
*
|
|
20
|
+
* If a function is provided, it will be called with the current state of the link auth flow.
|
|
21
|
+
* The function should return a `ReactNode`.
|
|
22
|
+
*/
|
|
12
23
|
children?: ReactNode | ((state: LinkAuthState) => ReactNode);
|
|
24
|
+
/** A function to call when an auth method is successfully linked. */
|
|
13
25
|
onLinkSuccess?: (method: AuthMethod | null) => void;
|
|
14
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A component for displaying an error banner in the LinkAuth component.
|
|
29
|
+
*
|
|
30
|
+
* @param {HTMLAttributes<HTMLDivElement>} props - The props for the LinkAuthError component.
|
|
31
|
+
* @returns {JSX.Element} The LinkAuthError component.
|
|
32
|
+
*
|
|
33
|
+
* @group Components
|
|
34
|
+
*/
|
|
15
35
|
declare const LinkAuthError: ({ role, ...props }: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element | null;
|
|
36
|
+
/**
|
|
37
|
+
* A component for managing linked authentication methods for the current user.
|
|
38
|
+
*
|
|
39
|
+
* This component displays a list of available authentication methods (email, phone, OAuth providers)
|
|
40
|
+
* and allows users to link or unlink them from their account.
|
|
41
|
+
*
|
|
42
|
+
* @param {LinkAuthProps} props - The props for the component.
|
|
43
|
+
* @param {(method: string) => void} [props.onLinkSuccess] - A function to call when an auth method is successfully linked.
|
|
44
|
+
* @returns {JSX.Element} The LinkAuth component.
|
|
45
|
+
*
|
|
46
|
+
* @group Components
|
|
47
|
+
*
|
|
48
|
+
* @document ./README.md
|
|
49
|
+
*
|
|
50
|
+
* @see {@link LinkAuthError}
|
|
51
|
+
* @see {@link LinkAuthFlow}
|
|
52
|
+
* @see {@link LinkAuthFlowBackButton}
|
|
53
|
+
* @see {@link LinkAuthItem}
|
|
54
|
+
* @see {@link LinkAuthItems}
|
|
55
|
+
* @see {@link LinkAuthTitle}
|
|
56
|
+
* @see {@link useLinkAuthContext}
|
|
57
|
+
* @see {@link useLinkAuthFlow}
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx lines
|
|
61
|
+
* // Render the LinkAuth component with a custom success handler
|
|
62
|
+
*
|
|
63
|
+
* function App() {
|
|
64
|
+
* return (
|
|
65
|
+
* <CDPReactProvider config={config}>
|
|
66
|
+
* <LinkAuth onLinkSuccess={method => console.log(`Linked ${method}`)} />
|
|
67
|
+
* </CDPReactProvider>
|
|
68
|
+
* );
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx lines
|
|
74
|
+
* // Recreate the default UI
|
|
75
|
+
*
|
|
76
|
+
* function App() {
|
|
77
|
+
* return (
|
|
78
|
+
* <CDPReactProvider config={config}>
|
|
79
|
+
* <LinkAuth>
|
|
80
|
+
* <div className="header">
|
|
81
|
+
* <LinkAuthTitle />
|
|
82
|
+
* <LinkAuthFlowBackButton />
|
|
83
|
+
* </div>
|
|
84
|
+
* <div className="error">
|
|
85
|
+
* <LinkAuthError />
|
|
86
|
+
* </div>
|
|
87
|
+
* <LinkAuthFlow />
|
|
88
|
+
* </LinkAuth>
|
|
89
|
+
* </CDPReactProvider>
|
|
90
|
+
* );
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx lines
|
|
96
|
+
* // Add a message based on the LinkAuth state
|
|
97
|
+
*
|
|
98
|
+
* function App() {
|
|
99
|
+
* return (
|
|
100
|
+
* <CDPReactProvider config={config}>
|
|
101
|
+
* <LinkAuth>
|
|
102
|
+
* {state => (
|
|
103
|
+
* <>
|
|
104
|
+
* <div className="header">
|
|
105
|
+
* <LinkAuthTitle />
|
|
106
|
+
* <LinkAuthFlowBackButton />
|
|
107
|
+
* </div>
|
|
108
|
+
* {state.methodToLink && (
|
|
109
|
+
* <p className="message">
|
|
110
|
+
* Linking {state.methodToLink}...
|
|
111
|
+
* </p>
|
|
112
|
+
* )}
|
|
113
|
+
* <div className="error">
|
|
114
|
+
* <LinkAuthError />
|
|
115
|
+
* </div>
|
|
116
|
+
* <LinkAuthFlow />
|
|
117
|
+
* </>
|
|
118
|
+
* )}
|
|
119
|
+
* </LinkAuth>
|
|
120
|
+
* </CDPReactProvider>
|
|
121
|
+
* );
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```tsx lines
|
|
127
|
+
* // Customize LinkAuthItems to show a modal for non-OAuth methods instead of transitioning in place.
|
|
128
|
+
*
|
|
129
|
+
* function CustomLinkAuthItems() {
|
|
130
|
+
* const { link, back } = useLinkAuthFlow();
|
|
131
|
+
* const { authMethods } = useAppConfig();
|
|
132
|
+
* const [openModal, setOpenModal] = useState<AuthMethod | null>(null);
|
|
133
|
+
*
|
|
134
|
+
* const modalMethods = useMemo(
|
|
135
|
+
* () => authMethods.filter(method => !method.startsWith("oauth:")),
|
|
136
|
+
* [authMethods],
|
|
137
|
+
* );
|
|
138
|
+
*
|
|
139
|
+
* const handleClose = useCallback(() => {
|
|
140
|
+
* setOpenModal(null);
|
|
141
|
+
* back();
|
|
142
|
+
* }, [back, setOpenModal]);
|
|
143
|
+
*
|
|
144
|
+
* const handleLink = useCallback(
|
|
145
|
+
* (method: AuthMethod) => {
|
|
146
|
+
* link(method);
|
|
147
|
+
* if (!method.startsWith("oauth:")) {
|
|
148
|
+
* setOpenModal(method);
|
|
149
|
+
* }
|
|
150
|
+
* },
|
|
151
|
+
* [link, setOpenModal],
|
|
152
|
+
* );
|
|
153
|
+
*
|
|
154
|
+
* return (
|
|
155
|
+
* <>
|
|
156
|
+
* <LinkAuthItems onLink={handleLink} />
|
|
157
|
+
* {modalMethods.map(method => {
|
|
158
|
+
* return (
|
|
159
|
+
* <SignInModal
|
|
160
|
+
* key={method}
|
|
161
|
+
* open={openModal === method}
|
|
162
|
+
* authMethods={[method]}
|
|
163
|
+
* setIsOpen={isOpen => (isOpen ? setOpenModal(method) : handleClose())}
|
|
164
|
+
* onSuccess={() => setOpenModal(null)}
|
|
165
|
+
* >
|
|
166
|
+
* <SignInModalTrigger>null</SignInModalTrigger>
|
|
167
|
+
* </SignInModal>
|
|
168
|
+
* );
|
|
169
|
+
* })}
|
|
170
|
+
* </>
|
|
171
|
+
* );
|
|
172
|
+
* };
|
|
173
|
+
*
|
|
174
|
+
* function App() {
|
|
175
|
+
* return (
|
|
176
|
+
* <CDPReactProvider config={config}>
|
|
177
|
+
* <LinkAuth>
|
|
178
|
+
* <h2>Link a profile</h2>
|
|
179
|
+
* <CustomLinkAuthItems />
|
|
180
|
+
* </LinkAuth>
|
|
181
|
+
* </CDPReactProvider>
|
|
182
|
+
* );
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
16
186
|
declare const LinkAuth: (props: LinkAuthProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
187
|
export { LinkAuthError, LinkAuthFlow, LinkAuthFlowBackButton, LinkAuthItem, LinkAuthItems, LinkAuthTitle, LinkAuth, useLinkAuthContext, useLinkAuthFlow, type LinkAuthAction, type LinkAuthContextValue, type LinkAuthFlowBackButtonProps, type LinkAuthFlowContextValue, type LinkAuthFlowProps, type LinkAuthItemProps, type LinkAuthItemsProps, type LinkAuthMethod, type LinkAuthProps, type LinkAuthState, type LinkAuthTitleProps, };
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import { AuthMethod } from '../CDPReactProvider';
|
|
2
|
+
/**
|
|
3
|
+
* Representation of auth method
|
|
4
|
+
*
|
|
5
|
+
* @see {@link LinkAuthState}
|
|
6
|
+
* @see {@link LinkAuth}
|
|
7
|
+
*/
|
|
2
8
|
export type LinkAuthMethod = {
|
|
9
|
+
/** Whether the user has this auth method linked to their account */
|
|
3
10
|
isLinked: boolean;
|
|
11
|
+
/** The auth method */
|
|
4
12
|
method: AuthMethod;
|
|
13
|
+
/** The user's identifier for this auth method (i.e. email address, phone number, etc.) */
|
|
5
14
|
userAlias: string;
|
|
6
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* The state of the account linking component
|
|
18
|
+
*
|
|
19
|
+
* @see {@link LinkAuthAction}
|
|
20
|
+
* @see {@link LinkAuth}
|
|
21
|
+
*/
|
|
7
22
|
export interface LinkAuthState {
|
|
23
|
+
/** The auth methods with data about the user and whether they are linked */
|
|
8
24
|
authMethods: LinkAuthMethod[];
|
|
25
|
+
/** Error message if fetching linked accounts failed */
|
|
9
26
|
error: string | null;
|
|
27
|
+
/** Whether the account linking is pending */
|
|
10
28
|
isPending: boolean;
|
|
29
|
+
/** The auth method to link */
|
|
11
30
|
methodToLink: AuthMethod | null;
|
|
12
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The actions that can be performed on the LinkAuth state.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link LinkAuthState}
|
|
36
|
+
* @see {@link LinkAuth}
|
|
37
|
+
*/
|
|
13
38
|
export type LinkAuthAction = {
|
|
14
39
|
type: "LINK_AUTH_METHOD";
|
|
15
40
|
payload: {
|
|
@@ -28,5 +53,11 @@ export type LinkAuthAction = {
|
|
|
28
53
|
} | {
|
|
29
54
|
type: "RESET_STATE";
|
|
30
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* The views of the link auth flow.
|
|
58
|
+
*/
|
|
31
59
|
export declare const LINK_AUTH_FLOW_VIEWS: readonly ["list", "email", "sms"];
|
|
60
|
+
/**
|
|
61
|
+
* The view of the link auth flow.
|
|
62
|
+
*/
|
|
32
63
|
export type LinkAuthFlowView = (typeof LINK_AUTH_FLOW_VIEWS)[number];
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { AuthMethod } from '../CDPReactProvider';
|
|
2
2
|
import { LinkAuthFlowView } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Typeguard function to checks if a string is a valid view for the link auth flow.
|
|
5
|
+
*
|
|
6
|
+
* @param view - The string to check.
|
|
7
|
+
* @returns {boolean} Whether the view is a valid view.
|
|
8
|
+
*/
|
|
3
9
|
export declare const isView: (view: string) => view is LinkAuthFlowView;
|
|
10
|
+
/**
|
|
11
|
+
* Converts a method to a view for the link auth flow.
|
|
12
|
+
*
|
|
13
|
+
* @param method - The method to convert to a view.
|
|
14
|
+
* @returns {LinkAuthFlowView} The view for the method. If the method is not a valid view, returns "list".
|
|
15
|
+
*/
|
|
4
16
|
export declare const methodToView: (method: AuthMethod | null) => LinkAuthFlowView;
|