@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
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import { ElementType, HTMLAttributes } from 'react';
|
|
2
2
|
import { EnrollMfaMethodComponentProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The props for the EnrollMfaImage component.
|
|
5
|
+
*/
|
|
3
6
|
export interface EnrollMfaImageProps extends EnrollMfaMethodComponentProps, HTMLAttributes<HTMLElement> {
|
|
4
7
|
as?: ElementType;
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* A description for the MfaVerification component.
|
|
11
|
+
*
|
|
12
|
+
* @param {EnrollMfaImageProps} props - The props for the component.
|
|
13
|
+
* @param {ElementType} [props.as] - The element type to render the description as.
|
|
14
|
+
* @param {MfaMethod} [props.method] - The MFA method to render the description for.
|
|
15
|
+
* @param {MfaVerificationState["step"]} [props.step] - The step of the verification flow.
|
|
16
|
+
* @returns {JSX.Element} The rendered component.
|
|
17
|
+
*
|
|
18
|
+
* @group Components
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <EnrollMfa>
|
|
23
|
+
* <EnrollMfaImage />
|
|
24
|
+
* <EnrollMfaTitle />
|
|
25
|
+
* <EnrollMfaDescription />
|
|
26
|
+
* <EnrollMfaFlow />
|
|
27
|
+
* </EnrollMfa>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
6
30
|
export declare const EnrollMfaImage: ({ as: Component, children, className, method: methodFromProps, step: stepFromProps, ...props }: EnrollMfaImageProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
2
|
import { MfaMethod } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The props for the EnrollMfaItem component.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link EnrollMfaItem}
|
|
7
|
+
*/
|
|
3
8
|
interface EnrollMfaItemProps {
|
|
9
|
+
/** The MFA method this item represents */
|
|
4
10
|
method: MfaMethod;
|
|
11
|
+
/** An icon to display */
|
|
5
12
|
icon?: ReactNode;
|
|
13
|
+
/** A label for the MFA method */
|
|
6
14
|
label: string;
|
|
15
|
+
/** Whether this method's enrollment is pending */
|
|
7
16
|
isPending?: boolean;
|
|
17
|
+
/** A function to call when the user clicks to set up this method */
|
|
8
18
|
onSetUp: MouseEventHandler<HTMLButtonElement>;
|
|
9
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* A component for displaying an MFA method in the enrollment list.
|
|
22
|
+
*
|
|
23
|
+
* @param {EnrollMfaItemProps} props - The props for the EnrollMfaItem component.
|
|
24
|
+
* @returns {JSX.Element} The EnrollMfaItem component.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link EnrollMfaItems}
|
|
27
|
+
* @see {@link EnrollMfa}
|
|
28
|
+
*
|
|
29
|
+
* @group Components
|
|
30
|
+
*/
|
|
10
31
|
declare const EnrollMfaItem: ({ method, icon, label, isPending, onSetUp }: EnrollMfaItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
32
|
export { EnrollMfaItem, type EnrollMfaItemProps };
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { EnrollMfaItemProps } from './EnrollMfaItem';
|
|
3
3
|
import { MfaMethod } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* The props for the EnrollMfaItems component.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link EnrollMfaItems}
|
|
8
|
+
*/
|
|
4
9
|
interface EnrollMfaItemsProps extends Omit<HTMLAttributes<HTMLUListElement>, "children"> {
|
|
10
|
+
/** A render function for the MFA method item. */
|
|
5
11
|
children?: (props: EnrollMfaItemProps) => ReactNode;
|
|
12
|
+
/** A function to call when a method is selected for setup. */
|
|
6
13
|
onSetUp?: (method: MfaMethod) => void | Promise<void>;
|
|
7
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* A list of MFA methods available for enrollment.
|
|
17
|
+
*
|
|
18
|
+
* @param {EnrollMfaItemsProps} props - The props for the EnrollMfaItems component.
|
|
19
|
+
* @returns {JSX.Element} The EnrollMfaItems component.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link EnrollMfa}
|
|
22
|
+
*
|
|
23
|
+
* @group Components
|
|
24
|
+
*/
|
|
8
25
|
declare const EnrollMfaItems: ({ children, className, onSetUp, ...props }: EnrollMfaItemsProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
26
|
export { EnrollMfaItems, type EnrollMfaItemsProps };
|
|
@@ -1,14 +1,49 @@
|
|
|
1
1
|
import { Dispatch, ReactNode } from 'react';
|
|
2
2
|
import { EnrollMfaAction, EnrollMfaState, MfaMethod } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The value of the EnrollMfa context.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link useEnrollMfaContext}
|
|
7
|
+
*/
|
|
3
8
|
export interface EnrollMfaContextValue {
|
|
9
|
+
/** The current state of the enrollment flow. */
|
|
4
10
|
state: EnrollMfaState;
|
|
11
|
+
/** The dispatch function to update the state. */
|
|
5
12
|
dispatch: Dispatch<EnrollMfaAction>;
|
|
13
|
+
/** The function to call when enrollment is successful. */
|
|
6
14
|
onEnrollSuccess?: () => void;
|
|
7
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Hook to access the EnrollMfa context.
|
|
18
|
+
*
|
|
19
|
+
* @returns The EnrollMfa context value.
|
|
20
|
+
* @throws If used outside of EnrollMfaProvider.
|
|
21
|
+
*
|
|
22
|
+
* @group Hooks
|
|
23
|
+
*
|
|
24
|
+
* @see {@link EnrollMfa}
|
|
25
|
+
*/
|
|
8
26
|
export declare const useEnrollMfaContext: () => EnrollMfaContextValue;
|
|
27
|
+
/**
|
|
28
|
+
* Props for the EnrollMfaProvider component.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link EnrollMfaProvider}
|
|
31
|
+
*/
|
|
9
32
|
export interface EnrollMfaProviderProps {
|
|
10
33
|
children: ReactNode;
|
|
34
|
+
/** The available MFA methods for enrollment. Defaults to ["totp"]. */
|
|
11
35
|
methods?: MfaMethod[];
|
|
36
|
+
/** The function to call when enrollment is successful. */
|
|
12
37
|
onEnrollSuccess?: () => void;
|
|
13
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Provider for EnrollMfa context.
|
|
41
|
+
*
|
|
42
|
+
* @param {EnrollMfaProviderProps} props - The props for the provider.
|
|
43
|
+
* @param {ReactNode} props.children - The children to render.
|
|
44
|
+
* @param {MfaMethod[]} [props.methods] - The available MFA methods for enrollment.
|
|
45
|
+
* @returns {JSX.Element} The provider component.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link EnrollMfa}
|
|
48
|
+
*/
|
|
14
49
|
export declare const EnrollMfaProvider: ({ children, onEnrollSuccess, methods, }: EnrollMfaProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { ElementType, HTMLAttributes } from 'react';
|
|
2
2
|
import { EnrollMfaMethodComponentProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The props for the EnrollMfaTitle component.
|
|
5
|
+
*/
|
|
3
6
|
export interface EnrollMfaTitleProps extends EnrollMfaMethodComponentProps, HTMLAttributes<HTMLElement> {
|
|
7
|
+
/** The element type to render the title as. */
|
|
4
8
|
as?: ElementType;
|
|
5
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* A title for the EnrollMfa component.
|
|
12
|
+
*
|
|
13
|
+
* @param {EnrollMfaTitleProps} props - The props for the component.
|
|
14
|
+
* @returns {JSX.Element} The rendered component.
|
|
15
|
+
*
|
|
16
|
+
* @group Components
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <EnrollMfa>
|
|
21
|
+
* <EnrollMfaTitle />
|
|
22
|
+
* <EnrollMfaDescription />
|
|
23
|
+
* <EnrollMfaFlow />
|
|
24
|
+
* </EnrollMfa>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
6
27
|
export declare const EnrollMfaTitle: ({ as: Component, children, className, method: methodFromProps, step: stepFromProps, ...props }: EnrollMfaTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,11 +10,76 @@ import { EnrollMfaItems, EnrollMfaItemsProps } from './EnrollMfaItems';
|
|
|
10
10
|
import { useEnrollMfaContext, EnrollMfaContextValue } from './EnrollMfaProvider';
|
|
11
11
|
import { EnrollMfaTitle, EnrollMfaTitleProps } from './EnrollMfaTitle';
|
|
12
12
|
import { EnrollMfaAction, EnrollMfaState, EnrollMfaStep, MfaMethod } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* Props for the EnrollMfa component.
|
|
15
|
+
*/
|
|
13
16
|
interface EnrollMfaProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
17
|
+
/**
|
|
18
|
+
* The children of the component. Leave empty to use the default enrollment UI.
|
|
19
|
+
*
|
|
20
|
+
* If a function is provided, it will be called with the current state of the enrollment flow.
|
|
21
|
+
* The function should return a `ReactNode`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <EnrollMfa>
|
|
26
|
+
* {(state) => (
|
|
27
|
+
* <>
|
|
28
|
+
* <EnrollMfaTitle />
|
|
29
|
+
* <EnrollMfaDescription />
|
|
30
|
+
* <EnrollMfaFlow />
|
|
31
|
+
* </>
|
|
32
|
+
* )}
|
|
33
|
+
* </EnrollMfa>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
14
36
|
children?: ReactNode | ((state: EnrollMfaState) => ReactNode);
|
|
37
|
+
/** A function to call when the enrollment is successful. */
|
|
15
38
|
onEnrollSuccess?: () => void;
|
|
39
|
+
/** Whether to reset the enrollment state when the enrollment is successful. Defaults to `true`. */
|
|
16
40
|
resetOnSuccess?: boolean;
|
|
17
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* A component for displaying an error banner in the EnrollMfa component.
|
|
44
|
+
*
|
|
45
|
+
* @param {HTMLAttributes<HTMLDivElement>} props - The props for the EnrollMfaError component.
|
|
46
|
+
* @returns {JSX.Element} The EnrollMfaError component.
|
|
47
|
+
*
|
|
48
|
+
* @group Components
|
|
49
|
+
*/
|
|
18
50
|
declare const EnrollMfaError: ({ role, ...props }: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element | null;
|
|
51
|
+
/**
|
|
52
|
+
* A component for MFA enrollment. Guides users through setting up
|
|
53
|
+
* two-factor authentication.
|
|
54
|
+
*
|
|
55
|
+
* @param {EnrollMfaProps} props - The props for the component.
|
|
56
|
+
* @returns {JSX.Element} The rendered component.
|
|
57
|
+
*
|
|
58
|
+
* @group Components
|
|
59
|
+
*
|
|
60
|
+
* @document ./README.md
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```tsx
|
|
64
|
+
* // Default usage
|
|
65
|
+
* <EnrollMfa onEnrollSuccess={() => console.log("Enrolled!")} />
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* // With custom UI
|
|
71
|
+
* <EnrollMfa onEnrollSuccess={onEnrollSuccess}>
|
|
72
|
+
* {(state) => (
|
|
73
|
+
* <>
|
|
74
|
+
* <h1>{state.step === "list" ? "Multi-factor authentication" : "Add new method"}</h1>
|
|
75
|
+
* <EnrollMfaTitle />
|
|
76
|
+
* <EnrollMfaDescription />
|
|
77
|
+
* {state.step === "list" && <EnrollMfaError />}
|
|
78
|
+
* <EnrollMfaFlow />
|
|
79
|
+
* </>
|
|
80
|
+
* )}
|
|
81
|
+
* </EnrollMfa>
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
19
84
|
declare const EnrollMfa: ({ onEnrollSuccess, ...props }: EnrollMfaProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
85
|
export { EnrollMfa, EnrollMfaDescription, EnrollMfaError, EnrollMfaFlow, EnrollMfaFlowBackButton, EnrollMfaFooter, EnrollMfaImage, EnrollMfaItem, EnrollMfaItems, EnrollMfaTitle, useEnrollMfaContext, useEnrollMfaFlow, type EnrollMfaProps, type EnrollMfaContextValue, type EnrollMfaDescriptionProps, type EnrollMfaFlowBackButtonProps, type EnrollMfaFlowContextValue, type EnrollMfaFlowProps, type EnrollMfaImageProps, type EnrollMfaItemProps, type EnrollMfaItemsProps, type EnrollMfaTitleProps, type EnrollMfaAction, type EnrollMfaState, type EnrollMfaStep, type MfaMethod, };
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import { EnrollMfaMethodConfig, EnrollMfaMethodContentProps, EnrollMfaMethodComponentProps } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Content component for SMS enrollment.
|
|
4
|
+
* Handles the setup (phone number entry) and verification (OTP) steps.
|
|
5
|
+
*
|
|
6
|
+
* @param {EnrollMfaMethodContentProps} props - The props for the component.
|
|
7
|
+
* @returns {JSX.Element} The rendered component.
|
|
8
|
+
*/
|
|
2
9
|
export declare const SmsContent: ({ autoFocus, step, onSubmit, children, }: EnrollMfaMethodContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
/**
|
|
11
|
+
* Title component for SMS enrollment.
|
|
12
|
+
*
|
|
13
|
+
* @param {EnrollMfaMethodComponentProps} props - The props for the component.
|
|
14
|
+
* @returns {JSX.Element} The rendered component.
|
|
15
|
+
*/
|
|
3
16
|
export declare const SmsTitle: ({ step }: EnrollMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
17
|
+
/**
|
|
18
|
+
* Description component for SMS enrollment.
|
|
19
|
+
*
|
|
20
|
+
* @param {EnrollMfaMethodComponentProps} props - The props for the component.
|
|
21
|
+
* @returns {JSX.Element | null} The rendered component.
|
|
22
|
+
*/
|
|
4
23
|
export declare const SmsDescription: ({ step }: EnrollMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
24
|
+
/**
|
|
25
|
+
* Image component for SMS enrollment.
|
|
26
|
+
*
|
|
27
|
+
* @param {EnrollMfaMethodComponentProps} props - The props for the component.
|
|
28
|
+
* @returns {JSX.Element | null} The rendered component.
|
|
29
|
+
*/
|
|
5
30
|
export declare const SmsImage: ({ step }: EnrollMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
31
|
export declare const smsMethodConfig: EnrollMfaMethodConfig;
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import { EnrollMfaMethodConfig, EnrollMfaMethodContentProps, EnrollMfaMethodComponentProps } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Content component for TOTP enrollment.
|
|
4
|
+
* Handles the setup (QR code) and verification steps.
|
|
5
|
+
*
|
|
6
|
+
* @param {EnrollMfaMethodContentProps} props - The props for the component.
|
|
7
|
+
* @returns {JSX.Element} The rendered component.
|
|
8
|
+
*/
|
|
2
9
|
export declare const TotpContent: ({ autoFocus, step, onSubmit, children, }: EnrollMfaMethodContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
/**
|
|
11
|
+
* Title component for TOTP enrollment.
|
|
12
|
+
*
|
|
13
|
+
* @param {EnrollMfaMethodComponentProps} props - The props for the component.
|
|
14
|
+
* @returns {JSX.Element} The rendered component.
|
|
15
|
+
*/
|
|
3
16
|
export declare const TotpTitle: ({ step }: EnrollMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Description component for TOTP enrollment.
|
|
19
|
+
*
|
|
20
|
+
* @param {EnrollMfaMethodComponentProps} props - The props for the component.
|
|
21
|
+
* @returns {JSX.Element} The rendered component.
|
|
22
|
+
*/
|
|
4
23
|
export declare const TotpDescription: ({ step }: EnrollMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
24
|
+
/**
|
|
25
|
+
* Image component for TOTP enrollment.
|
|
26
|
+
*
|
|
27
|
+
* @param {EnrollMfaMethodComponentProps} _props - The props for the component.
|
|
28
|
+
* @returns {JSX.Element | null} The rendered component.
|
|
29
|
+
*/
|
|
5
30
|
export declare const TotpImage: ({ step }: EnrollMfaMethodComponentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
31
|
export declare const totpMethodConfig: EnrollMfaMethodConfig;
|
|
@@ -1,28 +1,61 @@
|
|
|
1
1
|
import { InitiateMfaEnrollmentResult, InitiateMfaOptions } from '@coinbase/cdp-core';
|
|
2
2
|
import { APIError } from '@coinbase/cdp-hooks';
|
|
3
3
|
import { FC, FormEvent, ReactNode } from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* The MFA methods available for enrollment.
|
|
6
|
+
*/
|
|
4
7
|
export type MfaMethod = InitiateMfaOptions["mfaMethod"];
|
|
8
|
+
/**
|
|
9
|
+
* The steps in the MFA enrollment flow.
|
|
10
|
+
*/
|
|
5
11
|
export type EnrollMfaStep = "list" | "setup" | "setup-verification";
|
|
12
|
+
/**
|
|
13
|
+
* The method-specific steps (excludes prompt which is handled by parent).
|
|
14
|
+
*/
|
|
6
15
|
export type EnrollMfaMethodStep = Exclude<EnrollMfaStep, "list">;
|
|
16
|
+
/**
|
|
17
|
+
* Props for method-specific components (title, description, image).
|
|
18
|
+
*/
|
|
7
19
|
export interface EnrollMfaMethodComponentProps {
|
|
20
|
+
/** The MFA method to render for. */
|
|
8
21
|
method?: MfaMethod;
|
|
22
|
+
/** If set, will render for this step regardless of context value. */
|
|
9
23
|
step?: EnrollMfaStep;
|
|
10
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The state of the EnrollMfa component.
|
|
27
|
+
*/
|
|
11
28
|
export interface EnrollMfaState {
|
|
29
|
+
/** The currently selected MFA method. */
|
|
12
30
|
method: MfaMethod;
|
|
31
|
+
/** The available MFA methods for enrollment. */
|
|
13
32
|
methods: MfaMethod[];
|
|
33
|
+
/** The current step of the enrollment flow. */
|
|
14
34
|
step: EnrollMfaStep;
|
|
35
|
+
/** The direction of the flow. */
|
|
15
36
|
flowDirection: "left" | "right";
|
|
37
|
+
/** The MFA code entered by the user (for verification step). */
|
|
16
38
|
mfaCode: string;
|
|
39
|
+
/** The otpauth:// URL for QR code generation (from initiate). */
|
|
17
40
|
authUrl: string | null;
|
|
41
|
+
/** The base32-encoded secret for manual entry (from initiate). */
|
|
18
42
|
secret: string | null;
|
|
43
|
+
/** The phone number for SMS MFA enrollment (E.164 format). */
|
|
19
44
|
phoneNumber: string;
|
|
45
|
+
/** The timestamp when enrollment was initiated. */
|
|
20
46
|
initiatedAt: number | null;
|
|
47
|
+
/** Whether the enrollment session has expired. */
|
|
21
48
|
isExpired: boolean;
|
|
49
|
+
/** Error message or APIError object. */
|
|
22
50
|
error: string | APIError | null;
|
|
51
|
+
/** Whether a request is pending. */
|
|
23
52
|
isPending: boolean;
|
|
53
|
+
/** Whether the enrollment was successful. */
|
|
24
54
|
isSuccess: boolean;
|
|
25
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The actions that can be performed on the EnrollMfa state.
|
|
58
|
+
*/
|
|
26
59
|
export type EnrollMfaAction = {
|
|
27
60
|
type: "SET_STEP";
|
|
28
61
|
payload: {
|
|
@@ -76,6 +109,11 @@ export type EnrollMfaAction = {
|
|
|
76
109
|
} | {
|
|
77
110
|
type: "RESET_STATE";
|
|
78
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* Shared props for an MFA method content component.
|
|
114
|
+
* Note: Methods only handle "setup" and "setup-verification" steps.
|
|
115
|
+
* The "list" step is handled by the parent EnrollMfaFlow.
|
|
116
|
+
*/
|
|
79
117
|
export interface EnrollMfaMethodContentProps {
|
|
80
118
|
step: EnrollMfaMethodStep;
|
|
81
119
|
autoFocus?: boolean;
|
|
@@ -85,11 +123,21 @@ export interface EnrollMfaMethodContentProps {
|
|
|
85
123
|
Content: ReactNode;
|
|
86
124
|
}) => ReactNode;
|
|
87
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* The configuration for an MFA enrollment method.
|
|
128
|
+
* Each method has its own title, description, image, and content components.
|
|
129
|
+
*/
|
|
88
130
|
export interface EnrollMfaMethodConfig {
|
|
131
|
+
/** The main content component for this method. */
|
|
89
132
|
content: FC<EnrollMfaMethodContentProps>;
|
|
133
|
+
/** The description component for this method. */
|
|
90
134
|
description: FC<EnrollMfaMethodComponentProps>;
|
|
135
|
+
/** Build the InitiateMfaOptions from current state. Defaults to `{ mfaMethod: method }`. */
|
|
91
136
|
getInitiateOptions: (state: EnrollMfaState) => InitiateMfaOptions;
|
|
137
|
+
/** The image component for this method. */
|
|
92
138
|
image: FC<EnrollMfaMethodComponentProps>;
|
|
139
|
+
/** Whether this method needs user input before calling the initiate API. */
|
|
93
140
|
requiresInput?: boolean;
|
|
141
|
+
/** The title component for this method. */
|
|
94
142
|
title: FC<EnrollMfaMethodComponentProps>;
|
|
95
143
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { EnrollMfaAction, EnrollMfaState, MfaMethod } from './types';
|
|
2
2
|
export declare const STEPS: readonly ["list", "setup", "setup-verification"];
|
|
3
|
+
/**
|
|
4
|
+
* A hook for managing the state of the EnrollMfa component.
|
|
5
|
+
*
|
|
6
|
+
* @param methods - The available MFA methods for enrollment.
|
|
7
|
+
* @returns The state and dispatch function for the EnrollMfa component.
|
|
8
|
+
*/
|
|
3
9
|
export declare const useEnrollMfaReducer: (methods?: MfaMethod[]) => [EnrollMfaState, import('react').ActionDispatch<[action: EnrollMfaAction]>];
|
|
@@ -2,19 +2,130 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { EnrollMfaProps } from '../EnrollMfa';
|
|
3
3
|
import { ButtonProps } from '../ui/Button';
|
|
4
4
|
import { ModalContentProps } from '../ui/Modal';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the enroll MFA modal trigger button
|
|
7
|
+
*
|
|
8
|
+
* @see {@link EnrollMfaModalTrigger}
|
|
9
|
+
*/
|
|
5
10
|
interface EnrollMfaModalTriggerProps extends Partial<Pick<ButtonProps, "className" | "fullWidth" | "size" | "style" | "variant">> {
|
|
11
|
+
/** If provided, will render the children instead of the default trigger button. */
|
|
6
12
|
children?: ReactNode;
|
|
13
|
+
/** The label to display on the trigger button. */
|
|
7
14
|
label?: ReactNode;
|
|
8
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Props for the EnrollMfaModal component.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link EnrollMfaModal}
|
|
20
|
+
*/
|
|
9
21
|
interface EnrollMfaModalProps extends Pick<EnrollMfaProps, "onEnrollSuccess" | "resetOnSuccess"> {
|
|
22
|
+
/** If provided, will render the children instead of the default trigger button. */
|
|
10
23
|
children?: ReactNode;
|
|
24
|
+
/** Whether the modal is open. Note: if you set this, you must also set `setIsOpen`. */
|
|
11
25
|
open?: boolean;
|
|
26
|
+
/** A function to set the modal's open state. Note: if you set this, you must also set `open`. */
|
|
12
27
|
setIsOpen?: (value: boolean) => void;
|
|
13
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Props for the EnrollMfaModalContent component.
|
|
31
|
+
*
|
|
32
|
+
* @see {@link EnrollMfaModalContent}
|
|
33
|
+
*/
|
|
14
34
|
interface EnrollMfaModalContentProps extends Omit<ModalContentProps, "children"> {
|
|
35
|
+
/** The children of the component. Leave empty to use the default verification UI. */
|
|
15
36
|
children?: EnrollMfaProps["children"];
|
|
16
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* A trigger button that opens the enroll MFA modal.
|
|
40
|
+
*
|
|
41
|
+
* @param {EnrollMfaModalTriggerProps} props - The props for the EnrollMfaModalTrigger component.
|
|
42
|
+
* @param {ReactNode} [props.children] - The children to render inside the trigger button.
|
|
43
|
+
* @param {ReactNode} [props.label] - The label to display on the trigger button.
|
|
44
|
+
* @returns {JSX.Element} The EnrollMfaModalTrigger component.
|
|
45
|
+
*
|
|
46
|
+
* @group Components
|
|
47
|
+
*/
|
|
17
48
|
declare const EnrollMfaModalTrigger: ({ children, className, label, ...props }: EnrollMfaModalTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* The enroll MFA modal content.
|
|
51
|
+
*
|
|
52
|
+
* @param {EnrollMfaModalContentProps} props - The props for the EnrollMfaModalContent component.
|
|
53
|
+
* @returns {JSX.Element} The EnrollMfaModalContent component.
|
|
54
|
+
*
|
|
55
|
+
* @group Components
|
|
56
|
+
*/
|
|
18
57
|
declare const EnrollMfaModalContent: ({ children, ...props }: EnrollMfaModalContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
/**
|
|
59
|
+
* A enroll MFA modal component that wraps the {@link EnrollMfa} component.
|
|
60
|
+
*
|
|
61
|
+
* @param {EnrollMfaModalProps} props - The props for the EnrollMfaModal component.
|
|
62
|
+
* @returns {JSX.Element} The EnrollMfaModal component.
|
|
63
|
+
*
|
|
64
|
+
* @see {@link EnrollMfaModalTrigger} for the trigger button.
|
|
65
|
+
* @see {@link EnrollMfaModalContent} for the modal content.
|
|
66
|
+
*
|
|
67
|
+
* @group Components
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx lines
|
|
71
|
+
* // Render the EnrollMfaModal component with a custom success handler
|
|
72
|
+
* function App() {
|
|
73
|
+
* const handleSuccess = (mfaCode: string) => {
|
|
74
|
+
* console.log(`Successfully verified`, mfaCode);
|
|
75
|
+
* };
|
|
76
|
+
*
|
|
77
|
+
* return (
|
|
78
|
+
* <CDPReactProvider config={config}>
|
|
79
|
+
* <EnrollMfaModal onSuccess={handleSuccess} />
|
|
80
|
+
* </CDPReactProvider>
|
|
81
|
+
* );
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx lines
|
|
87
|
+
* // Render the EnrollMfaModal component with a custom trigger button
|
|
88
|
+
* function App() {
|
|
89
|
+
* return (
|
|
90
|
+
* <CDPReactProvider config={config}>
|
|
91
|
+
* <EnrollMfaModal>
|
|
92
|
+
* <button type="button">Verify</button>
|
|
93
|
+
* </EnrollMfaModal>
|
|
94
|
+
* </CDPReactProvider>
|
|
95
|
+
* );
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```tsx lines
|
|
101
|
+
* // Render the EnrollMfaModal component with a custom trigger button label
|
|
102
|
+
* function App() {
|
|
103
|
+
* return (
|
|
104
|
+
* <CDPReactProvider config={config}>
|
|
105
|
+
* <EnrollMfaModal>
|
|
106
|
+
* <EnrollMfaModalTrigger variant="secondary" label="Verify" />
|
|
107
|
+
* </EnrollMfaModal>
|
|
108
|
+
* </CDPReactProvider>
|
|
109
|
+
* );
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```tsx lines
|
|
115
|
+
* // Render the EnrollMfaModal with controlled open state
|
|
116
|
+
* function App() {
|
|
117
|
+
* const [isOpen, setIsOpen] = useState(false);
|
|
118
|
+
*
|
|
119
|
+
* return (
|
|
120
|
+
* <CDPReactProvider config={config}>
|
|
121
|
+
* <EnrollMfaModal open={isOpen} setIsOpen={setIsOpen}>
|
|
122
|
+
* <EnrollMfaModalTrigger />
|
|
123
|
+
* <EnrollMfaModalContent />
|
|
124
|
+
* </EnrollMfaModal>
|
|
125
|
+
* </CDPReactProvider>
|
|
126
|
+
* );
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
19
130
|
declare const EnrollMfaModal: ({ children, open, setIsOpen, onEnrollSuccess, resetOnSuccess, }: EnrollMfaModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
131
|
export { EnrollMfaModal, EnrollMfaModalContent, EnrollMfaModalTrigger, type EnrollMfaModalProps, type EnrollMfaModalContentProps, type EnrollMfaModalTriggerProps, };
|