@coinbase/cdp-react 0.0.97 → 0.0.99

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.
Files changed (198) hide show
  1. package/dist/components/AuthButton/index.d.ts +102 -0
  2. package/dist/components/CDPReactProvider/index.d.ts +114 -0
  3. package/dist/components/CopyAddress/index.d.ts +29 -0
  4. package/dist/components/CopyEvmKeyButton/index.d.ts +77 -0
  5. package/dist/components/CopySolanaKeyButton/index.d.ts +73 -0
  6. package/dist/components/EnrollMfa/EnrollMfaDescription.d.ts +21 -0
  7. package/dist/components/EnrollMfa/EnrollMfaFlow.d.ts +27 -0
  8. package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.d.ts +19 -0
  9. package/dist/components/EnrollMfa/EnrollMfaFlowProvider.d.ts +52 -0
  10. package/dist/components/EnrollMfa/EnrollMfaFooter.d.ts +18 -0
  11. package/dist/components/EnrollMfa/EnrollMfaImage.d.ts +24 -0
  12. package/dist/components/EnrollMfa/EnrollMfaItem.d.ts +21 -0
  13. package/dist/components/EnrollMfa/EnrollMfaItems.d.ts +17 -0
  14. package/dist/components/EnrollMfa/EnrollMfaProvider.d.ts +35 -0
  15. package/dist/components/EnrollMfa/EnrollMfaTitle.d.ts +21 -0
  16. package/dist/components/EnrollMfa/index.d.ts +65 -0
  17. package/dist/components/EnrollMfa/methods/sms.d.ts +25 -0
  18. package/dist/components/EnrollMfa/methods/totp.d.ts +25 -0
  19. package/dist/components/EnrollMfa/types.d.ts +48 -0
  20. package/dist/components/EnrollMfa/useEnrollMfaReducer.d.ts +6 -0
  21. package/dist/components/EnrollMfaModal/index.d.ts +111 -0
  22. package/dist/components/ExportWallet/index.d.ts +163 -0
  23. package/dist/components/ExportWalletModal/index.d.ts +173 -0
  24. package/dist/components/Fund/FundForm.d.ts +18 -0
  25. package/dist/components/Fund/FundProvider.d.ts +17 -0
  26. package/dist/components/Fund/FundTitle.d.ts +12 -0
  27. package/dist/components/Fund/components/FundAmountInput.d.ts +13 -0
  28. package/dist/components/Fund/components/FundErrorScreen.d.ts +7 -0
  29. package/dist/components/Fund/components/FundPaymentMethods.d.ts +7 -0
  30. package/dist/components/Fund/components/FundPresetAmountInputs.d.ts +7 -0
  31. package/dist/components/Fund/components/FundTransactionStatus.d.ts +6 -0
  32. package/dist/components/Fund/hooks/useBuyUrl.d.ts +23 -0
  33. package/dist/components/Fund/hooks/useEmitLifecycleStatus.d.ts +12 -0
  34. package/dist/components/Fund/hooks/useExchangeRate.d.ts +17 -0
  35. package/dist/components/Fund/hooks/usePaymentMethods.d.ts +16 -0
  36. package/dist/components/Fund/hooks/usePopupMonitor.d.ts +9 -0
  37. package/dist/components/Fund/hooks/useSetupOnrampEventListeners.d.ts +6 -0
  38. package/dist/components/Fund/index.d.ts +87 -0
  39. package/dist/components/Fund/types.d.ts +137 -0
  40. package/dist/components/Fund/useFundReducer.d.ts +15 -0
  41. package/dist/components/Fund/utils/buildPaymentMethods.d.ts +15 -0
  42. package/dist/components/Fund/utils/setupOnrampEventListeners.d.ts +10 -0
  43. package/dist/components/Fund/utils/subscribeToWindowMessage.d.ts +27 -0
  44. package/dist/components/FundModal/index.d.ts +106 -0
  45. package/dist/components/LinkAuth/LinkAuthFlow.d.ts +25 -0
  46. package/dist/components/LinkAuth/LinkAuthFlowBackButton.d.ts +19 -0
  47. package/dist/components/LinkAuth/LinkAuthFlowProvider.d.ts +60 -0
  48. package/dist/components/LinkAuth/LinkAuthItem.d.ts +23 -0
  49. package/dist/components/LinkAuth/LinkAuthItems.d.ts +17 -0
  50. package/dist/components/LinkAuth/LinkAuthProvider.d.ts +31 -0
  51. package/dist/components/LinkAuth/LinkAuthTitle.d.ts +17 -0
  52. package/dist/components/LinkAuth/index.d.ts +170 -0
  53. package/dist/components/LinkAuth/types.d.ts +31 -0
  54. package/dist/components/LinkAuth/utils.d.ts +12 -0
  55. package/dist/components/LinkAuthModal/index.d.ts +112 -0
  56. package/dist/components/OAuthStatusModal/index.d.ts +24 -0
  57. package/dist/components/SendEvmTransactionButton/index.d.ts +27 -0
  58. package/dist/components/SendSolanaTransactionButton/index.d.ts +27 -0
  59. package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +26 -0
  60. package/dist/components/SignIn/SignInBackButton.d.ts +40 -0
  61. package/dist/components/SignIn/SignInCredentials.d.ts +13 -0
  62. package/dist/components/SignIn/SignInDescription.d.ts +35 -0
  63. package/dist/components/SignIn/SignInFooter.d.ts +27 -0
  64. package/dist/components/SignIn/SignInForm.d.ts +39 -0
  65. package/dist/components/SignIn/SignInImage.d.ts +38 -0
  66. package/dist/components/SignIn/SignInProvider.d.ts +54 -0
  67. package/dist/components/SignIn/SignInTitle.d.ts +35 -0
  68. package/dist/components/SignIn/flows/SignInWithEmail.d.ts +26 -0
  69. package/dist/components/SignIn/flows/SignInWithOAuth.d.ts +19 -0
  70. package/dist/components/SignIn/flows/SignInWithSms.d.ts +26 -0
  71. package/dist/components/SignIn/hooks/useEmailForm.d.ts +7 -0
  72. package/dist/components/SignIn/hooks/useOTPForm.d.ts +8 -0
  73. package/dist/components/SignIn/hooks/usePhoneNumberForm.d.ts +7 -0
  74. package/dist/components/SignIn/hooks/useSignInWithOAuth.d.ts +8 -0
  75. package/dist/components/SignIn/index.d.ts +124 -0
  76. package/dist/components/SignIn/types.d.ts +37 -0
  77. package/dist/components/SignIn/useSignInReducer.d.ts +9 -0
  78. package/dist/components/SignInModal/index.d.ts +123 -0
  79. package/dist/components/SignOutButton/index.d.ts +39 -0
  80. package/dist/components/ThemeProvider/index.d.ts +70 -0
  81. package/dist/components/VerifyMfa/VerifyMfaDescription.d.ts +24 -0
  82. package/dist/components/VerifyMfa/VerifyMfaFlow.d.ts +30 -0
  83. package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.d.ts +19 -0
  84. package/dist/components/VerifyMfa/VerifyMfaFlowProvider.d.ts +51 -0
  85. package/dist/components/VerifyMfa/VerifyMfaFooter.d.ts +18 -0
  86. package/dist/components/VerifyMfa/VerifyMfaImage.d.ts +23 -0
  87. package/dist/components/VerifyMfa/VerifyMfaItem.d.ts +20 -0
  88. package/dist/components/VerifyMfa/VerifyMfaItems.d.ts +18 -0
  89. package/dist/components/VerifyMfa/VerifyMfaProvider.d.ts +40 -0
  90. package/dist/components/VerifyMfa/VerifyMfaTitle.d.ts +24 -0
  91. package/dist/components/VerifyMfa/index.d.ts +55 -0
  92. package/dist/components/VerifyMfa/methods/sms.d.ts +29 -0
  93. package/dist/components/VerifyMfa/methods/totp.d.ts +29 -0
  94. package/dist/components/VerifyMfa/types.d.ts +33 -0
  95. package/dist/components/VerifyMfa/useVerifyMfaReducer.d.ts +7 -0
  96. package/dist/components/VerifyMfaInline/index.d.ts +212 -0
  97. package/dist/components/VerifyMfaModal/index.d.ts +114 -0
  98. package/dist/components/forms/AmountInput/index.d.ts +16 -0
  99. package/dist/components/forms/AmountInput/types.d.ts +9 -0
  100. package/dist/components/forms/AmountInput/useAmountInput.d.ts +14 -0
  101. package/dist/components/forms/AmountInput/useInputScale.d.ts +12 -0
  102. package/dist/components/forms/AmountInput/useNumberParseAndFormat.d.ts +20 -0
  103. package/dist/components/forms/CountrySelect/index.d.ts +9 -0
  104. package/dist/components/forms/EmailForm/index.d.ts +17 -0
  105. package/dist/components/forms/ExchangeAmountInput/index.d.ts +19 -0
  106. package/dist/components/forms/ExchangeAmountInput/types.d.ts +12 -0
  107. package/dist/components/forms/ExchangeAmountInput/useExchangeAmountInput.d.ts +17 -0
  108. package/dist/components/forms/Field/index.d.ts +15 -0
  109. package/dist/components/forms/Input/index.d.ts +15 -0
  110. package/dist/components/forms/Label/index.d.ts +8 -0
  111. package/dist/components/forms/OTP/index.d.ts +6 -0
  112. package/dist/components/forms/OTPForm/index.d.ts +20 -0
  113. package/dist/components/forms/PhoneNumberForm/index.d.ts +27 -0
  114. package/dist/components/forms/PhoneNumberInput/index.d.ts +16 -0
  115. package/dist/components/forms/PhoneNumberInput/maskOverride.d.ts +6 -0
  116. package/dist/components/forms/PhoneNumberInput/usePhoneNumberFormatter.d.ts +7 -0
  117. package/dist/components/forms/Select/index.d.ts +30 -0
  118. package/dist/components/ui/Badge/index.d.ts +19 -0
  119. package/dist/components/ui/Banner/index.d.ts +25 -0
  120. package/dist/components/ui/Button/index.d.ts +50 -0
  121. package/dist/components/ui/ButtonBase/index.d.ts +20 -0
  122. package/dist/components/ui/CoinbaseFooter/index.d.ts +16 -0
  123. package/dist/components/ui/CopyTextField/index.d.ts +35 -0
  124. package/dist/components/ui/Error/index.d.ts +14 -0
  125. package/dist/components/ui/IframeButton/index.d.ts +17 -0
  126. package/dist/components/ui/LoadingSkeleton/index.d.ts +22 -0
  127. package/dist/components/ui/LoadingSpinner/index.d.ts +11 -0
  128. package/dist/components/ui/Modal/index.d.ts +82 -0
  129. package/dist/components/ui/QRCode/QRCodeSvg.d.ts +35 -0
  130. package/dist/components/ui/QRCode/index.d.ts +7 -0
  131. package/dist/components/ui/QRCode/useCorners.d.ts +9 -0
  132. package/dist/components/ui/QRCode/useDotsPath.d.ts +18 -0
  133. package/dist/components/ui/QRCode/useLogo.d.ts +18 -0
  134. package/dist/components/ui/QRCode/useMatrix.d.ts +7 -0
  135. package/dist/components/ui/ServerError/index.d.ts +6 -0
  136. package/dist/components/ui/SuccessMessage/index.d.ts +14 -0
  137. package/dist/components/ui/SwitchFadeTransition/index.d.ts +15 -0
  138. package/dist/components/ui/SwitchSlideTransition/index.d.ts +16 -0
  139. package/dist/components/ui/SwitchTransition/index.d.ts +42 -0
  140. package/dist/components/ui/ToggleListItem/index.d.ts +31 -0
  141. package/dist/components/ui/VisuallyHidden/index.d.ts +18 -0
  142. package/dist/data/countries.d.ts +15 -0
  143. package/dist/data/countryNames.d.ts +4 -0
  144. package/dist/hooks/useKeyExportPostMessage.d.ts +25 -0
  145. package/dist/hooks/usePhoneNumberState.d.ts +47 -0
  146. package/dist/hooks/usePhoneNumberValidators.d.ts +8 -0
  147. package/dist/hooks/useTimeout.d.ts +18 -0
  148. package/dist/hooks/useTimer.d.ts +6 -0
  149. package/dist/hooks/useTransitionMap.d.ts +22 -0
  150. package/dist/hooks/useVerifyMfaModal.d.ts +78 -0
  151. package/dist/icons/IconAppleLogo.d.ts +22 -0
  152. package/dist/icons/IconArrowLeft.d.ts +22 -0
  153. package/dist/icons/IconArrowsUpDown.d.ts +22 -0
  154. package/dist/icons/IconCheck.d.ts +22 -0
  155. package/dist/icons/IconCheckCircle.d.ts +21 -0
  156. package/dist/icons/IconChevronDown.d.ts +22 -0
  157. package/dist/icons/IconCoinbaseMark.d.ts +22 -0
  158. package/dist/icons/IconCoinbaseWordmark.d.ts +22 -0
  159. package/dist/icons/IconCopy.d.ts +22 -0
  160. package/dist/icons/IconCreditCard.d.ts +22 -0
  161. package/dist/icons/IconCurrencies.d.ts +22 -0
  162. package/dist/icons/IconEnvelope.d.ts +22 -0
  163. package/dist/icons/IconExclamationCircle.d.ts +22 -0
  164. package/dist/icons/IconExclamationTriangle.d.ts +22 -0
  165. package/dist/icons/IconGoogleColorLogo.d.ts +22 -0
  166. package/dist/icons/IconGoogleLogo.d.ts +22 -0
  167. package/dist/icons/IconLock.d.ts +22 -0
  168. package/dist/icons/IconMinus.d.ts +21 -0
  169. package/dist/icons/IconPhone.d.ts +22 -0
  170. package/dist/icons/IconPinCode.d.ts +22 -0
  171. package/dist/icons/IconPlus.d.ts +21 -0
  172. package/dist/icons/IconShield.d.ts +22 -0
  173. package/dist/icons/IconSmartPhone.d.ts +22 -0
  174. package/dist/icons/IconTelegramLogo.d.ts +22 -0
  175. package/dist/icons/IconXLogo.d.ts +22 -0
  176. package/dist/icons/IconXMark.d.ts +22 -0
  177. package/dist/icons/SvgIcon.d.ts +6 -0
  178. package/dist/theme/cssVariables.d.ts +10 -0
  179. package/dist/theme/theme.d.ts +246 -0
  180. package/dist/theme/tokens.d.ts +54 -0
  181. package/dist/theme/utils.d.ts +63 -0
  182. package/dist/types/secureIframe.d.ts +3 -0
  183. package/dist/utils/capitalize.d.ts +8 -0
  184. package/dist/utils/childrenHasComponent.d.ts +10 -0
  185. package/dist/utils/clamp.d.ts +10 -0
  186. package/dist/utils/formatFiat.d.ts +11 -0
  187. package/dist/utils/formatPhoneNumber.d.ts +8 -0
  188. package/dist/utils/getMessageFromUnknownError.d.ts +9 -0
  189. package/dist/utils/isApiError.d.ts +21 -0
  190. package/dist/utils/isEmailInvalid.d.ts +15 -0
  191. package/dist/utils/openPopup.d.ts +15 -0
  192. package/dist/utils/parseValuesFromPhoneNumber.d.ts +16 -0
  193. package/dist/utils/sendIframeMessage.d.ts +8 -0
  194. package/dist/utils/toOAuthProviderType.d.ts +8 -0
  195. package/dist/utils/transition.d.ts +41 -0
  196. package/dist/version.d.ts +5 -1
  197. package/dist/version.js +1 -1
  198. 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,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;
@@ -2,20 +2,132 @@ import { ReactNode } from 'react';
2
2
  import { AuthMethod } from '../CDPReactProvider';
3
3
  import { ButtonProps } from '../ui/Button';
4
4
  import { ModalContentProps } from '../ui/Modal';
5
+ /**
6
+ * Props for the link auth modal trigger button
7
+ *
8
+ * @see {@link LinkAuthModalTrigger}
9
+ */
5
10
  interface LinkAuthModalTriggerProps 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 link auth modal content.
18
+ *
19
+ * @see {@link LinkAuthModalContent}
20
+ */
9
21
  interface LinkAuthModalContentProps extends ModalContentProps {
22
+ /** A function to call when an auth method is successfully linked. */
10
23
  onLinkSuccess?: (method: string) => void;
11
24
  }
25
+ /**
26
+ * Props for the LinkAuthModal component.
27
+ *
28
+ * @see {@link LinkAuthModal}
29
+ */
12
30
  interface LinkAuthModalProps {
31
+ /** If provided, will render the children instead of the default trigger button. */
13
32
  children?: ReactNode;
33
+ /** Whether the modal is open. Note: if you set this, you must also set `setIsOpen`. */
14
34
  open?: boolean;
35
+ /** A function to set the modal's open state. Note: if you set this, you must also set `open`. */
15
36
  setIsOpen?: (value: boolean) => void;
37
+ /** A function to call when an auth method is successfully linked. */
16
38
  onLinkSuccess?: (method: AuthMethod | null) => void;
17
39
  }
40
+ /**
41
+ * A trigger button that opens the link auth modal.
42
+ *
43
+ * @param {LinkAuthModalTriggerProps} props - The props for the LinkAuthModalTrigger component.
44
+ * @param {ReactNode} [props.children] - The children to render inside the trigger button.
45
+ * @param {ReactNode} [props.label] - The label to display on the trigger button.
46
+ * @returns {JSX.Element} The LinkAuthModalTrigger component.
47
+ *
48
+ * @group Components
49
+ */
18
50
  declare const LinkAuthModalTrigger: ({ children, className, label, ...props }: LinkAuthModalTriggerProps) => import("react/jsx-runtime").JSX.Element;
51
+ /**
52
+ * The link auth modal content.
53
+ *
54
+ * @param {LinkAuthModalContentProps} props - The props for the LinkAuthModalContent component.
55
+ * @returns {JSX.Element} The LinkAuthModalContent component.
56
+ *
57
+ * @group Components
58
+ */
19
59
  declare const LinkAuthModalContent: (props: LinkAuthModalContentProps) => import("react/jsx-runtime").JSX.Element;
60
+ /**
61
+ * A link auth modal component that wraps the {@link LinkAuth} component.
62
+ *
63
+ * @param {LinkAuthModalProps} props - The props for the LinkAuthModal component.
64
+ * @returns {JSX.Element} The LinkAuthModal component.
65
+ *
66
+ * @see {@link LinkAuthModalTrigger} for the trigger button.
67
+ * @see {@link LinkAuthModalContent} for the modal content.
68
+ *
69
+ * @group Components
70
+ *
71
+ * @example
72
+ * ```tsx lines
73
+ * // Render the LinkAuthModal component with a custom success handler
74
+ * function App() {
75
+ * const handleLinkSuccess = (method: string) => {
76
+ * console.log(`Successfully linked ${method}`);
77
+ * };
78
+ *
79
+ * return (
80
+ * <CDPReactProvider config={config}>
81
+ * <LinkAuthModal onLinkSuccess={handleLinkSuccess} />
82
+ * </CDPReactProvider>
83
+ * );
84
+ * }
85
+ * ```
86
+ *
87
+ * @example
88
+ * ```tsx lines
89
+ * // Render the LinkAuthModal component with a custom trigger button
90
+ * function App() {
91
+ * return (
92
+ * <CDPReactProvider config={config}>
93
+ * <LinkAuthModal>
94
+ * <button type="button">Manage linked accounts</button>
95
+ * </LinkAuthModal>
96
+ * </CDPReactProvider>
97
+ * );
98
+ * }
99
+ * ```
100
+ *
101
+ * @example
102
+ * ```tsx lines
103
+ * // Render the LinkAuthModal component with a custom trigger button label
104
+ * function App() {
105
+ * return (
106
+ * <CDPReactProvider config={config}>
107
+ * <LinkAuthModal>
108
+ * <LinkAuthModalTrigger variant="secondary" label="Link more accounts" />
109
+ * </LinkAuthModal>
110
+ * </CDPReactProvider>
111
+ * );
112
+ * }
113
+ * ```
114
+ *
115
+ * @example
116
+ * ```tsx lines
117
+ * // Render the LinkAuthModal with controlled open state
118
+ * function App() {
119
+ * const [isOpen, setIsOpen] = useState(false);
120
+ *
121
+ * return (
122
+ * <CDPReactProvider config={config}>
123
+ * <LinkAuthModal open={isOpen} setIsOpen={setIsOpen}>
124
+ * <LinkAuthModalTrigger />
125
+ * <LinkAuthModalContent />
126
+ * </LinkAuthModal>
127
+ * </CDPReactProvider>
128
+ * );
129
+ * }
130
+ * ```
131
+ */
20
132
  declare const LinkAuthModal: ({ children, open, setIsOpen, onLinkSuccess }: LinkAuthModalProps) => import("react/jsx-runtime").JSX.Element;
21
133
  export { LinkAuthModal, LinkAuthModalContent, LinkAuthModalTrigger, type LinkAuthModalProps, type LinkAuthModalContentProps, type LinkAuthModalTriggerProps, };
@@ -4,10 +4,34 @@ type OAuthStatusModalContentProps = {
4
4
  isAccountLink?: boolean;
5
5
  handleClose: () => void;
6
6
  };
7
+ /**
8
+ * The useOauthStatusModal hook provides a function to persist state for the oauth status modal for use on redirect.
9
+ *
10
+ * The returned function sets two values in session storage:
11
+ * 1. The app provider name (set in app config): this is used to identify which app intiiated the flow, in case of multiple CDPReactProvider instances.
12
+ * 2. Whether this is an account link flow: this is used to determine whether the user is signing in or linking an account.
13
+ *
14
+ * @returns {{persistOAuthState: (isAccountLink?: boolean) => void}} An object with a function to prepare the oauth status modal for use.
15
+ *
16
+ * @see {@link OAuthStatusModal}
17
+ *
18
+ * @group Hooks
19
+ */
7
20
  export declare const useOauthStatusModal: () => {
8
21
  persistOAuthState: (isAccountLink?: boolean) => void;
9
22
  cleanupOAuthState: () => void;
10
23
  };
24
+ /**
25
+ * The OAuthStatusModal component is a modal that displays the status of an OAuth flow.
26
+ *
27
+ * @returns {JSX.Element} The OAuthStatusModal component.
28
+ */
11
29
  export declare const OAuthStatusModal: () => import("react/jsx-runtime").JSX.Element;
30
+ /**
31
+ * The OAuthStatusModalContent component is a component that displays the status of an OAuth flow.
32
+ *
33
+ * @param {OAuthStatusModalContentProps} props - The props for the OAuthStatusModalContent component.
34
+ * @returns {JSX.Element} The OAuthStatusModalContent component.
35
+ */
12
36
  export declare const OAuthStatusModalContent: ({ isAccountLink, handleClose, }: OAuthStatusModalContentProps) => import("react/jsx-runtime").JSX.Element;
13
37
  export default OAuthStatusModal;
@@ -1,5 +1,17 @@
1
1
  import { APIError, SendEvmTransactionOptions } from '@coinbase/cdp-hooks';
2
2
  import { ButtonProps } from '../ui/Button';
3
+ /**
4
+ * The props for the SendEvmTransactionButton component.
5
+ *
6
+ * @augments {Omit<ButtonProps, "onError">}
7
+ * @property {SendEvmTransactionOptions["evmAccount"]} account - The account to send the transaction from.
8
+ * @property {SendEvmTransactionOptions["network"]} network - The network to send the transaction on.
9
+ * @property {(error: APIError | Error) => void} [onError] - A function to call when the transaction errors.
10
+ * @property {(hash: string) => void} [onSuccess] - A function to call when the transaction is successful.
11
+ * @property {SendEvmTransactionOptions["transaction"]} transaction - The transaction to send.
12
+ *
13
+ * @see {@link SendEvmTransactionButton}
14
+ */
3
15
  export interface SendEvmTransactionButtonProps extends Omit<ButtonProps, "onError"> {
4
16
  account: SendEvmTransactionOptions["evmAccount"];
5
17
  network: SendEvmTransactionOptions["network"];
@@ -7,4 +19,19 @@ export interface SendEvmTransactionButtonProps extends Omit<ButtonProps, "onErro
7
19
  onSuccess?: (hash: string) => void;
8
20
  transaction: SendEvmTransactionOptions["transaction"];
9
21
  }
22
+ /**
23
+ * A button that signs and sends a transaction.
24
+ *
25
+ * @param {SendEvmTransactionButtonProps} props - The props for the SendEvmTransactionButton component.
26
+ * @param {SendEvmTransactionOptions["evmAccount"]} props.account - The account to send the transaction from.
27
+ * @param {SendEvmTransactionOptions["network"]} props.network - The network to send the transaction on.
28
+ * @param {(error: APIError | Error) => void} [props.onError] - A function to call when the transaction errors.
29
+ * @param {(hash: string) => void} [props.onSuccess] - A function to call when the transaction is successful.
30
+ * @param {ReactNode} [props.pendingLabel] - The label to display when the transaction is pending.
31
+ * @param {SendEvmTransactionOptions["transaction"]} props.transaction - The transaction to send.
32
+ * @param {ButtonVariant} [props.variant] - The variant of the button.
33
+ * @returns {JSX.Element} The rendered component.
34
+ *
35
+ * @group Components
36
+ */
10
37
  export declare const SendEvmTransactionButton: ({ account, children, className, network, onClick, onError, onSuccess, pendingLabel, transaction, ...props }: SendEvmTransactionButtonProps) => import("react/jsx-runtime").JSX.Element;