@dynamic-labs/sdk-react-core 2.1.0-alpha.11 → 2.1.0-alpha.13

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 (34) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +12 -12
  5. package/src/lib/components/CopyButton/CopyButton.cjs +3 -3
  6. package/src/lib/components/CopyButton/CopyButton.d.ts +1 -1
  7. package/src/lib/components/CopyButton/CopyButton.js +3 -3
  8. package/src/lib/components/LoadingQrCode/LoadingQrCode.cjs +11 -0
  9. package/src/lib/components/LoadingQrCode/LoadingQrCode.d.ts +8 -0
  10. package/src/lib/components/LoadingQrCode/LoadingQrCode.js +7 -0
  11. package/src/lib/components/LoadingQrCode/index.d.ts +1 -0
  12. package/src/lib/components/QrCodeWrapper/QrCodeContainer/QrCodeContainer.cjs +2 -1
  13. package/src/lib/components/QrCodeWrapper/QrCodeContainer/QrCodeContainer.js +2 -1
  14. package/src/lib/components/QrCodeWrapper/QrCodeWrapper.cjs +5 -1
  15. package/src/lib/components/QrCodeWrapper/QrCodeWrapper.js +5 -1
  16. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -1
  17. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -1
  18. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +3 -1
  19. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +3 -1
  20. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +2 -2
  21. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +2 -1
  22. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +2 -2
  23. package/src/lib/views/FarcasterQrCodeView/FarcasterQrCodeView.cjs +45 -0
  24. package/src/lib/views/FarcasterQrCodeView/FarcasterQrCodeView.d.ts +6 -0
  25. package/src/lib/views/FarcasterQrCodeView/FarcasterQrCodeView.js +41 -0
  26. package/src/lib/views/FarcasterQrCodeView/index.d.ts +1 -0
  27. package/src/lib/views/LoginView/LoginView.cjs +9 -1
  28. package/src/lib/views/LoginView/LoginView.js +9 -1
  29. package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +1 -0
  30. package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +1 -0
  31. package/src/lib/views/LoginView/utils/showFarcasterQrCodeView/index.d.ts +1 -0
  32. package/src/lib/views/LoginView/utils/showFarcasterQrCodeView/showFarcasterQrCodeView.cjs +14 -0
  33. package/src/lib/views/LoginView/utils/showFarcasterQrCodeView/showFarcasterQrCodeView.d.ts +2 -0
  34. package/src/lib/views/LoginView/utils/showFarcasterQrCodeView/showFarcasterQrCodeView.js +10 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,18 @@
1
1
 
2
+ ## [2.1.0-alpha.13](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.12...v2.1.0-alpha.13) (2024-05-03)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * ensure Farcaster QR uses useSocialAuth hook ([#5550](https://github.com/dynamic-labs/DynamicAuth/issues/5550)) ([57fcd97](https://github.com/dynamic-labs/DynamicAuth/commit/57fcd97c44e3f52065dcf856acf7bca7b24fabc7))
8
+
9
+ ## [2.1.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.11...v2.1.0-alpha.12) (2024-05-02)
10
+
11
+
12
+ ### Features
13
+
14
+ * display Farcaster QR code when it is the only login option ([#5514](https://github.com/dynamic-labs/DynamicAuth/issues/5514)) ([7b166d9](https://github.com/dynamic-labs/DynamicAuth/commit/7b166d9a30c581746f0e2edb71c44fc015dc128e))
15
+
2
16
  ## [2.1.0-alpha.11](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.10...v2.1.0-alpha.11) (2024-05-02)
3
17
 
4
18
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "2.1.0-alpha.11";
6
+ var version = "2.1.0-alpha.13";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.433",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "2.1.0-alpha.11";
2
+ var version = "2.1.0-alpha.13";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.433",
5
5
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "2.1.0-alpha.11",
3
+ "version": "2.1.0-alpha.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -17,17 +17,17 @@
17
17
  "react-i18next": "13.5.0",
18
18
  "yup": "0.32.11",
19
19
  "react-international-phone": "4.2.5",
20
- "@dynamic-labs/iconic": "2.1.0-alpha.11",
21
- "@dynamic-labs/logger": "2.1.0-alpha.11",
22
- "@dynamic-labs/multi-wallet": "2.1.0-alpha.11",
23
- "@dynamic-labs/rpc-provider-ethereum": "2.1.0-alpha.11",
24
- "@dynamic-labs/rpc-provider-solana": "2.1.0-alpha.11",
25
- "@dynamic-labs/rpc-providers": "2.1.0-alpha.11",
26
- "@dynamic-labs/types": "2.1.0-alpha.11",
27
- "@dynamic-labs/utils": "2.1.0-alpha.11",
28
- "@dynamic-labs/viem-utils": "2.1.0-alpha.11",
29
- "@dynamic-labs/wallet-book": "2.1.0-alpha.11",
30
- "@dynamic-labs/wallet-connector-core": "2.1.0-alpha.11",
20
+ "@dynamic-labs/iconic": "2.1.0-alpha.13",
21
+ "@dynamic-labs/logger": "2.1.0-alpha.13",
22
+ "@dynamic-labs/multi-wallet": "2.1.0-alpha.13",
23
+ "@dynamic-labs/rpc-provider-ethereum": "2.1.0-alpha.13",
24
+ "@dynamic-labs/rpc-provider-solana": "2.1.0-alpha.13",
25
+ "@dynamic-labs/rpc-providers": "2.1.0-alpha.13",
26
+ "@dynamic-labs/types": "2.1.0-alpha.13",
27
+ "@dynamic-labs/utils": "2.1.0-alpha.13",
28
+ "@dynamic-labs/viem-utils": "2.1.0-alpha.13",
29
+ "@dynamic-labs/wallet-book": "2.1.0-alpha.13",
30
+ "@dynamic-labs/wallet-connector-core": "2.1.0-alpha.13",
31
31
  "eventemitter3": "5.0.1"
32
32
  },
33
33
  "devDependencies": {
@@ -10,7 +10,7 @@ var TextButton = require('../TextButton/TextButton.cjs');
10
10
  var TypographyButton = require('../TypographyButton/TypographyButton.cjs');
11
11
  var Tooltip = require('../Tooltip/Tooltip.cjs');
12
12
 
13
- const CopyButton = ({ children, className = '', textToCopy, onClick, variant = 'text', copykey, buttonPadding = 'small', buttonVariant = 'primary', buttonClassName = '', startSlot, }) => {
13
+ const CopyButton = ({ children, className = '', textToCopy, onClick, variant = 'text', copykey, buttonPadding = 'small', buttonVariant = 'primary', buttonClassName = '', startSlot, disabled, }) => {
14
14
  const [copied, setCopied] = React.useState(false);
15
15
  const copyToClipboard = () => {
16
16
  navigator.clipboard.writeText(textToCopy);
@@ -19,9 +19,9 @@ const CopyButton = ({ children, className = '', textToCopy, onClick, variant = '
19
19
  };
20
20
  const CopyButtonTooltip = () => (jsxRuntime.jsx(Tooltip.Tooltip, { className: 'copy-button__tooltip', content: copied ? 'Copied' : 'Copy', children: children }));
21
21
  if (variant === 'text') {
22
- return (jsxRuntime.jsx(TextButton.TextButton, { className: classNames.classNames('copy-button__container', className), onClick: () => copyToClipboard(), onMouseLeave: () => setCopied(false), copykey: copykey, children: jsxRuntime.jsx(CopyButtonTooltip, {}) }));
22
+ return (jsxRuntime.jsx(TextButton.TextButton, { className: classNames.classNames('copy-button__container', className), onClick: () => copyToClipboard(), onMouseLeave: () => setCopied(false), copykey: copykey, disabled: disabled, children: jsxRuntime.jsx(CopyButtonTooltip, {}) }));
23
23
  }
24
- return (jsxRuntime.jsx(TypographyButton.TypographyButton, { expanded: true, buttonPadding: buttonPadding, buttonVariant: buttonVariant, buttonClassName: buttonClassName, onClick: () => copyToClipboard(), copykey: copykey, startSlot: startSlot, children: jsxRuntime.jsx(CopyButtonTooltip, {}) }));
24
+ return (jsxRuntime.jsx(TypographyButton.TypographyButton, { expanded: true, buttonPadding: buttonPadding, buttonVariant: buttonVariant, buttonClassName: buttonClassName, onClick: () => copyToClipboard(), copykey: copykey, startSlot: startSlot, disabled: disabled, children: jsxRuntime.jsx(CopyButtonTooltip, {}) }));
25
25
  };
26
26
 
27
27
  exports.CopyButton = CopyButton;
@@ -8,5 +8,5 @@ type Props = ComponentPropsWithoutRef<'button'> & {
8
8
  textToCopy: string;
9
9
  variant?: 'text' | 'button';
10
10
  } & CopyKey & Pick<ButtonProps, 'buttonPadding' | 'buttonVariant' | 'buttonClassName' | 'startSlot'>;
11
- export declare const CopyButton: ({ children, className, textToCopy, onClick, variant, copykey, buttonPadding, buttonVariant, buttonClassName, startSlot, }: Props) => JSX.Element;
11
+ export declare const CopyButton: ({ children, className, textToCopy, onClick, variant, copykey, buttonPadding, buttonVariant, buttonClassName, startSlot, disabled, }: Props) => JSX.Element;
12
12
  export {};
@@ -6,7 +6,7 @@ import { TextButton } from '../TextButton/TextButton.js';
6
6
  import { TypographyButton } from '../TypographyButton/TypographyButton.js';
7
7
  import { Tooltip } from '../Tooltip/Tooltip.js';
8
8
 
9
- const CopyButton = ({ children, className = '', textToCopy, onClick, variant = 'text', copykey, buttonPadding = 'small', buttonVariant = 'primary', buttonClassName = '', startSlot, }) => {
9
+ const CopyButton = ({ children, className = '', textToCopy, onClick, variant = 'text', copykey, buttonPadding = 'small', buttonVariant = 'primary', buttonClassName = '', startSlot, disabled, }) => {
10
10
  const [copied, setCopied] = useState(false);
11
11
  const copyToClipboard = () => {
12
12
  navigator.clipboard.writeText(textToCopy);
@@ -15,9 +15,9 @@ const CopyButton = ({ children, className = '', textToCopy, onClick, variant = '
15
15
  };
16
16
  const CopyButtonTooltip = () => (jsx(Tooltip, { className: 'copy-button__tooltip', content: copied ? 'Copied' : 'Copy', children: children }));
17
17
  if (variant === 'text') {
18
- return (jsx(TextButton, { className: classNames('copy-button__container', className), onClick: () => copyToClipboard(), onMouseLeave: () => setCopied(false), copykey: copykey, children: jsx(CopyButtonTooltip, {}) }));
18
+ return (jsx(TextButton, { className: classNames('copy-button__container', className), onClick: () => copyToClipboard(), onMouseLeave: () => setCopied(false), copykey: copykey, disabled: disabled, children: jsx(CopyButtonTooltip, {}) }));
19
19
  }
20
- return (jsx(TypographyButton, { expanded: true, buttonPadding: buttonPadding, buttonVariant: buttonVariant, buttonClassName: buttonClassName, onClick: () => copyToClipboard(), copykey: copykey, startSlot: startSlot, children: jsx(CopyButtonTooltip, {}) }));
20
+ return (jsx(TypographyButton, { expanded: true, buttonPadding: buttonPadding, buttonVariant: buttonVariant, buttonClassName: buttonClassName, onClick: () => copyToClipboard(), copykey: copykey, startSlot: startSlot, disabled: disabled, children: jsx(CopyButtonTooltip, {}) }));
21
21
  };
22
22
 
23
23
  export { CopyButton };
@@ -0,0 +1,11 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var IconWithSpinner = require('../IconWithSpinner/IconWithSpinner.cjs');
8
+
9
+ const LoadingQrCode = ({ Icon, logoSize }) => (jsxRuntime.jsx("div", { className: 'qrcode__container qrcode', "data-testid": 'loading-qrcode', children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: Icon, iconSize: logoSize, isSpinning: true, className: 'qrcode__icon' }) }));
10
+
11
+ exports.LoadingQrCode = LoadingQrCode;
@@ -0,0 +1,8 @@
1
+ import { FC, ReactElement } from 'react';
2
+ type LoadingQrCodeProps = {
3
+ Icon: ReactElement;
4
+ accentColor?: string;
5
+ logoSize?: number;
6
+ };
7
+ export declare const LoadingQrCode: FC<LoadingQrCodeProps>;
8
+ export {};
@@ -0,0 +1,7 @@
1
+ 'use client'
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { IconWithSpinner } from '../IconWithSpinner/IconWithSpinner.js';
4
+
5
+ const LoadingQrCode = ({ Icon, logoSize }) => (jsx("div", { className: 'qrcode__container qrcode', "data-testid": 'loading-qrcode', children: jsx(IconWithSpinner, { Icon: Icon, iconSize: logoSize, isSpinning: true, className: 'qrcode__icon' }) }));
6
+
7
+ export { LoadingQrCode };
@@ -0,0 +1 @@
1
+ export { LoadingQrCode } from './LoadingQrCode';
@@ -77,6 +77,7 @@ require('../../IsBrowser/IsBrowser.cjs');
77
77
  require('../../Popper/Popper/Popper.cjs');
78
78
  require('../../Popper/PopperContext/PopperContext.cjs');
79
79
  var QRCode = require('../../QRCode/QRCode.cjs');
80
+ var LoadingQrCode = require('../../LoadingQrCode/LoadingQrCode.cjs');
80
81
  require('../../../views/WalletList/WalletList.cjs');
81
82
  require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
82
83
  require('@hcaptcha/react-hcaptcha');
@@ -101,7 +102,7 @@ const QrCodeContainer = ({ accentColor, walletConnector, qrcodeValue, Icon: Main
101
102
  };
102
103
  return (jsxRuntime.jsxs("div", { className: classNames.classNames('qrcode-container__container', {
103
104
  'qrcode-container__container--message': showQrCodeMessage,
104
- }), children: [jsxRuntime.jsxs("div", { className: 'qrcode-container__top', children: [qrcodeValue && (jsxRuntime.jsx(QRCode.QRCode, { Icon: MainIcon, accentColor: accentColor, value: qrcodeValue, logoSize: 50, walletKey: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key, showQrCodeImage: showQrCodeImage })), jsxRuntime.jsx(MockedQrCode.MockedQrCode, {}), jsxRuntime.jsxs("div", { className: 'button-container', children: [showCopyToClipboardButton && qrcodeValue && (jsxRuntime.jsx(CopyButton.CopyButton, { variant: 'button', textToCopy: qrcodeValue, buttonClassName: 'qr-code-button', copykey: 'dyn_qr_code.copy_button', startSlot:
105
+ }), children: [jsxRuntime.jsxs("div", { className: 'qrcode-container__top', children: [qrcodeValue.length ? (jsxRuntime.jsx(QRCode.QRCode, { Icon: MainIcon, accentColor: accentColor, value: qrcodeValue, logoSize: 50, walletKey: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key, showQrCodeImage: showQrCodeImage })) : (jsxRuntime.jsx(LoadingQrCode.LoadingQrCode, { Icon: MainIcon, logoSize: 50 })), jsxRuntime.jsx(MockedQrCode.MockedQrCode, {}), jsxRuntime.jsxs("div", { className: 'button-container', children: [showCopyToClipboardButton && (jsxRuntime.jsx(CopyButton.CopyButton, { variant: 'button', textToCopy: qrcodeValue, disabled: !qrcodeValue.length, buttonClassName: 'qr-code-button', copykey: 'dyn_qr_code.copy_button', startSlot:
105
106
  // eslint-disable-next-line react/jsx-wrap-multilines
106
107
  jsxRuntime.jsx(Icon.Icon, { size: 'mini', color: 'text-tertiary', children: jsxRuntime.jsx(link.ReactComponent, {}) }), children: t('dyn_qr_code.copy_button') })), renderAppOrExtensionButton()] })] }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', weight: 'regular', className: 'qrcode-container__content', copykey: 'dyn_qr_code.scan_title', children: t('dyn_qr_code.scan_title', {
107
108
  app: walletConnector ? 'wallet' : 'app',
@@ -73,6 +73,7 @@ import '../../IsBrowser/IsBrowser.js';
73
73
  import '../../Popper/Popper/Popper.js';
74
74
  import '../../Popper/PopperContext/PopperContext.js';
75
75
  import { QRCode } from '../../QRCode/QRCode.js';
76
+ import { LoadingQrCode } from '../../LoadingQrCode/LoadingQrCode.js';
76
77
  import '../../../views/WalletList/WalletList.js';
77
78
  import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
78
79
  import '@hcaptcha/react-hcaptcha';
@@ -97,7 +98,7 @@ const QrCodeContainer = ({ accentColor, walletConnector, qrcodeValue, Icon: Main
97
98
  };
98
99
  return (jsxs("div", { className: classNames('qrcode-container__container', {
99
100
  'qrcode-container__container--message': showQrCodeMessage,
100
- }), children: [jsxs("div", { className: 'qrcode-container__top', children: [qrcodeValue && (jsx(QRCode, { Icon: MainIcon, accentColor: accentColor, value: qrcodeValue, logoSize: 50, walletKey: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key, showQrCodeImage: showQrCodeImage })), jsx(MockedQrCode, {}), jsxs("div", { className: 'button-container', children: [showCopyToClipboardButton && qrcodeValue && (jsx(CopyButton, { variant: 'button', textToCopy: qrcodeValue, buttonClassName: 'qr-code-button', copykey: 'dyn_qr_code.copy_button', startSlot:
101
+ }), children: [jsxs("div", { className: 'qrcode-container__top', children: [qrcodeValue.length ? (jsx(QRCode, { Icon: MainIcon, accentColor: accentColor, value: qrcodeValue, logoSize: 50, walletKey: walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key, showQrCodeImage: showQrCodeImage })) : (jsx(LoadingQrCode, { Icon: MainIcon, logoSize: 50 })), jsx(MockedQrCode, {}), jsxs("div", { className: 'button-container', children: [showCopyToClipboardButton && (jsx(CopyButton, { variant: 'button', textToCopy: qrcodeValue, disabled: !qrcodeValue.length, buttonClassName: 'qr-code-button', copykey: 'dyn_qr_code.copy_button', startSlot:
101
102
  // eslint-disable-next-line react/jsx-wrap-multilines
102
103
  jsx(Icon, { size: 'mini', color: 'text-tertiary', children: jsx(SvgLink, {}) }), children: t('dyn_qr_code.copy_button') })), renderAppOrExtensionButton()] })] }), jsx(Typography, { variant: 'body_normal', color: 'secondary', weight: 'regular', className: 'qrcode-container__content', copykey: 'dyn_qr_code.scan_title', children: t('dyn_qr_code.scan_title', {
103
104
  app: walletConnector ? 'wallet' : 'app',
@@ -81,7 +81,11 @@ require('../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSign
81
81
  const QrCodeWrapper = ({ uri, desktopUri, icon, accentColor, showCopyToClipboardButton, walletConnector, }) => {
82
82
  const [showQrCodeMessage, setShowQrCodeMessage] = React.useState(false);
83
83
  const [showQrCodeImage, setShowQrCodeImage] = React.useState(false);
84
- useTimeout.useTimeout(() => setShowQrCodeMessage(true), 5000);
84
+ /**
85
+ * Show the QR code message after 5 seconds
86
+ * disabled if url is empty
87
+ */
88
+ useTimeout.useTimeout(() => setShowQrCodeMessage(true), uri.length ? 5000 : null);
85
89
  return (jsxRuntime.jsxs("div", { "data-testid": 'qr-code-wrapper', children: [jsxRuntime.jsx(AnimatePresence.AnimatePresence, { animationComponent: jsxRuntime.jsx(VerticalDrawerTransition.VerticalDrawerTransition, { style: { width: '100%' } }), children: showQrCodeMessage && !showQrCodeImage && (jsxRuntime.jsxs("div", { className: 'qr-code-wrapper__scan-issue-message', children: [jsxRuntime.jsx(Typography.Typography, { color: 'primary', variant: 'body_small', children: "If you're having issues scanning, click\u00A0" }), jsxRuntime.jsx("button", { "data-testid": 'qr-code-wrapper__scan-issue-button', className: 'qr-code-wrapper__scan-issue-button', onClick: () => setShowQrCodeImage(true), children: "here" })] })) }), jsxRuntime.jsx(QrCodeContainer.QrCodeContainer, { showQrCodeMessage: showQrCodeMessage, desktopUri: desktopUri, accentColor: accentColor, walletConnector: walletConnector, qrcodeValue: uri, Icon: icon, showCopyToClipboardButton: showCopyToClipboardButton, showQrCodeImage: showQrCodeImage })] }));
86
90
  };
87
91
 
@@ -77,7 +77,11 @@ import '../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignI
77
77
  const QrCodeWrapper = ({ uri, desktopUri, icon, accentColor, showCopyToClipboardButton, walletConnector, }) => {
78
78
  const [showQrCodeMessage, setShowQrCodeMessage] = useState(false);
79
79
  const [showQrCodeImage, setShowQrCodeImage] = useState(false);
80
- useTimeout(() => setShowQrCodeMessage(true), 5000);
80
+ /**
81
+ * Show the QR code message after 5 seconds
82
+ * disabled if url is empty
83
+ */
84
+ useTimeout(() => setShowQrCodeMessage(true), uri.length ? 5000 : null);
81
85
  return (jsxs("div", { "data-testid": 'qr-code-wrapper', children: [jsx(AnimatePresence, { animationComponent: jsx(VerticalDrawerTransition, { style: { width: '100%' } }), children: showQrCodeMessage && !showQrCodeImage && (jsxs("div", { className: 'qr-code-wrapper__scan-issue-message', children: [jsx(Typography, { color: 'primary', variant: 'body_small', children: "If you're having issues scanning, click\u00A0" }), jsx("button", { "data-testid": 'qr-code-wrapper__scan-issue-button', className: 'qr-code-wrapper__scan-issue-button', onClick: () => setShowQrCodeImage(true), children: "here" })] })) }), jsx(QrCodeContainer, { showQrCodeMessage: showQrCodeMessage, desktopUri: desktopUri, accentColor: accentColor, walletConnector: walletConnector, qrcodeValue: uri, Icon: icon, showCopyToClipboardButton: showCopyToClipboardButton, showQrCodeImage: showQrCodeImage })] }));
82
86
  };
83
87
 
@@ -81,8 +81,8 @@ require('qrcode');
81
81
  require('../../../../views/WalletList/WalletList.cjs');
82
82
  require('../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
83
83
  require('@hcaptcha/react-hcaptcha');
84
- require('../../../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.cjs');
85
84
  require('@dynamic-labs/types');
85
+ require('../../../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.cjs');
86
86
 
87
87
  const UserProfileSocialAccount = ({ provider, }) => {
88
88
  var _a;
@@ -77,8 +77,8 @@ import 'qrcode';
77
77
  import '../../../../views/WalletList/WalletList.js';
78
78
  import '../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
79
79
  import '@hcaptcha/react-hcaptcha';
80
- import '../../../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js';
81
80
  import '@dynamic-labs/types';
81
+ import '../../../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js';
82
82
 
83
83
  const UserProfileSocialAccount = ({ provider, }) => {
84
84
  var _a;
@@ -12,7 +12,7 @@ require('../../../shared/logger.cjs');
12
12
  require('@dynamic-labs/iconic');
13
13
  require('@dynamic-labs/wallet-connector-core');
14
14
  require('react/jsx-runtime');
15
- require('../../../context/ViewContext/ViewContext.cjs');
15
+ var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
16
16
  require('@dynamic-labs/wallet-book');
17
17
  var localStorage$1 = require('../../constants/localStorage.cjs');
18
18
  require('../../constants/colors.cjs');
@@ -87,9 +87,11 @@ const useSocialAccounts = ({ sessionTimeout } = {
87
87
  }) => {
88
88
  var _a;
89
89
  const { environmentId, user, projectSettings, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
90
+ const { setView } = ViewContext.useViewContext();
90
91
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
91
92
  const { handleError, setError, setIsProcessing, checkValidProvider, error, isProcessing, connectSocialAccount, } = useSocialAuth.useSocialAuth({
92
93
  authMode: 'link',
94
+ onFarcasterUrl: (url) => setView('farcaster-connect-view', { url }),
93
95
  sessionTimeout,
94
96
  });
95
97
  const userJwt = (_a = getMinAuthToken.getMinAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
@@ -8,7 +8,7 @@ import '../../../shared/logger.js';
8
8
  import '@dynamic-labs/iconic';
9
9
  import '@dynamic-labs/wallet-connector-core';
10
10
  import 'react/jsx-runtime';
11
- import '../../../context/ViewContext/ViewContext.js';
11
+ import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
12
12
  import '@dynamic-labs/wallet-book';
13
13
  import { PRIMARY_WALLET_ID } from '../../constants/localStorage.js';
14
14
  import '../../constants/colors.js';
@@ -83,9 +83,11 @@ const useSocialAccounts = ({ sessionTimeout } = {
83
83
  }) => {
84
84
  var _a;
85
85
  const { environmentId, user, projectSettings, onboardingOnlyJwt } = useInternalDynamicContext();
86
+ const { setView } = useViewContext();
86
87
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
87
88
  const { handleError, setError, setIsProcessing, checkValidProvider, error, isProcessing, connectSocialAccount, } = useSocialAuth({
88
89
  authMode: 'link',
90
+ onFarcasterUrl: (url) => setView('farcaster-connect-view', { url }),
89
91
  sessionTimeout,
90
92
  });
91
93
  const userJwt = (_a = getMinAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
@@ -105,7 +105,7 @@ const socialProviders = [
105
105
  const providersRequiringPkce = ['twitter', 'github'];
106
106
  const providersWithoutWindowOpenerRefence = ['twitter'];
107
107
  // Hook to handle common social auth logic (for social linking and social sign in)
108
- const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
108
+ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcasterUrl, }) => {
109
109
  var _a;
110
110
  const { environmentId, onboardingOnlyJwt, setOnboardingOnlyJwt, setCallback, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext.useInternalDynamicContext();
111
111
  const { handleVerifiedUserWithJWT } = useHandleVerifiedUser.useHandleVerifiedUser();
@@ -414,7 +414,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
414
414
  }
415
415
  else {
416
416
  setShowAuthFlow(true);
417
- setView('farcaster-connect-view', { url: data.url });
417
+ onFarcasterUrl === null || onFarcasterUrl === void 0 ? void 0 : onFarcasterUrl(data.url);
418
418
  }
419
419
  const status = yield farcaster.watchStatus({
420
420
  channelToken: data.channelToken,
@@ -7,8 +7,9 @@ type UseSocialAuthProps = {
7
7
  authMode: SocialAuthMode;
8
8
  onSettled?: () => void;
9
9
  onError?: () => void;
10
+ onFarcasterUrl?: (url: string) => void;
10
11
  };
11
- export declare const useSocialAuth: ({ sessionTimeout, authMode, onSettled, onError, }: UseSocialAuthProps) => {
12
+ export declare const useSocialAuth: ({ sessionTimeout, authMode, onSettled, onError, onFarcasterUrl, }: UseSocialAuthProps) => {
12
13
  readonly checkValidProvider: (provider: ProviderEnum) => boolean;
13
14
  readonly connectSocialAccount: ({ provider, validator, captchaToken, }: {
14
15
  provider: ProviderEnum;
@@ -101,7 +101,7 @@ const socialProviders = [
101
101
  const providersRequiringPkce = ['twitter', 'github'];
102
102
  const providersWithoutWindowOpenerRefence = ['twitter'];
103
103
  // Hook to handle common social auth logic (for social linking and social sign in)
104
- const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
104
+ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcasterUrl, }) => {
105
105
  var _a;
106
106
  const { environmentId, onboardingOnlyJwt, setOnboardingOnlyJwt, setCallback, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext();
107
107
  const { handleVerifiedUserWithJWT } = useHandleVerifiedUser();
@@ -410,7 +410,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
410
410
  }
411
411
  else {
412
412
  setShowAuthFlow(true);
413
- setView('farcaster-connect-view', { url: data.url });
413
+ onFarcasterUrl === null || onFarcasterUrl === void 0 ? void 0 : onFarcasterUrl(data.url);
414
414
  }
415
415
  const status = yield watchStatus({
416
416
  channelToken: data.channelToken,
@@ -0,0 +1,45 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var React = require('react');
8
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
9
+ var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
10
+ var FarcasterConnectView = require('../FarcasterConnectView/FarcasterConnectView.cjs');
11
+ var useSocialAuth = require('../../utils/hooks/useSocialAuth/useSocialAuth.cjs');
12
+ require('../../shared/logger.cjs');
13
+ require('@dynamic-labs/iconic');
14
+ require('@dynamic-labs/wallet-connector-core');
15
+ require('../../context/ViewContext/ViewContext.cjs');
16
+ require('@dynamic-labs/wallet-book');
17
+ require('../../utils/constants/colors.cjs');
18
+ require('../../utils/constants/values.cjs');
19
+ require('../../shared/utils/classes/storage/localStorage.cjs');
20
+ var useEffectOnce = require('../../shared/utils/hooks/useEffectOnce/useEffectOnce.cjs');
21
+ require('@dynamic-labs/utils');
22
+ require('../../shared/consts/index.cjs');
23
+
24
+ /**
25
+ * This view is used to display the QR code for the farcaster connection.
26
+ * It is only used in the login view when Farcaster is the only available login method.
27
+ */
28
+ const FarcasterQrCodeView = () => {
29
+ const { setError } = ErrorContext.useErrorContext();
30
+ const [url, setUrl] = React.useState(undefined);
31
+ const { connectSocialAccount } = useSocialAuth.useSocialAuth({
32
+ authMode: 'signin',
33
+ onError: () => setError('Something went wrong'),
34
+ onFarcasterUrl: (url) => setUrl(url),
35
+ sessionTimeout: 10000,
36
+ });
37
+ useEffectOnce.useEffectOnce(() => {
38
+ connectSocialAccount({
39
+ provider: sdkApiCore.ProviderEnum.Farcaster,
40
+ });
41
+ });
42
+ return jsxRuntime.jsx(FarcasterConnectView.FarcasterConnectView, { url: url !== null && url !== void 0 ? url : '' });
43
+ };
44
+
45
+ exports.FarcasterQrCodeView = FarcasterQrCodeView;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * This view is used to display the QR code for the farcaster connection.
4
+ * It is only used in the login view when Farcaster is the only available login method.
5
+ */
6
+ export declare const FarcasterQrCodeView: () => JSX.Element;
@@ -0,0 +1,41 @@
1
+ 'use client'
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+ import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
5
+ import { useErrorContext } from '../../context/ErrorContext/ErrorContext.js';
6
+ import { FarcasterConnectView } from '../FarcasterConnectView/FarcasterConnectView.js';
7
+ import { useSocialAuth } from '../../utils/hooks/useSocialAuth/useSocialAuth.js';
8
+ import '../../shared/logger.js';
9
+ import '@dynamic-labs/iconic';
10
+ import '@dynamic-labs/wallet-connector-core';
11
+ import '../../context/ViewContext/ViewContext.js';
12
+ import '@dynamic-labs/wallet-book';
13
+ import '../../utils/constants/colors.js';
14
+ import '../../utils/constants/values.js';
15
+ import '../../shared/utils/classes/storage/localStorage.js';
16
+ import { useEffectOnce } from '../../shared/utils/hooks/useEffectOnce/useEffectOnce.js';
17
+ import '@dynamic-labs/utils';
18
+ import '../../shared/consts/index.js';
19
+
20
+ /**
21
+ * This view is used to display the QR code for the farcaster connection.
22
+ * It is only used in the login view when Farcaster is the only available login method.
23
+ */
24
+ const FarcasterQrCodeView = () => {
25
+ const { setError } = useErrorContext();
26
+ const [url, setUrl] = useState(undefined);
27
+ const { connectSocialAccount } = useSocialAuth({
28
+ authMode: 'signin',
29
+ onError: () => setError('Something went wrong'),
30
+ onFarcasterUrl: (url) => setUrl(url),
31
+ sessionTimeout: 10000,
32
+ });
33
+ useEffectOnce(() => {
34
+ connectSocialAccount({
35
+ provider: ProviderEnum.Farcaster,
36
+ });
37
+ });
38
+ return jsx(FarcasterConnectView, { url: url !== null && url !== void 0 ? url : '' });
39
+ };
40
+
41
+ export { FarcasterQrCodeView };
@@ -0,0 +1 @@
1
+ export { FarcasterQrCodeView } from './FarcasterQrCodeView';
@@ -14,14 +14,18 @@ var DefaultFooter = require('../../layout/DynamicAuthLayout/DefaultFooter/Defaul
14
14
  var classNames = require('../../utils/functions/classNames/classNames.cjs');
15
15
  var useAuthLayoutChecks = require('../../utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs');
16
16
  var WalletList = require('../WalletList/WalletList.cjs');
17
+ var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
18
+ var FarcasterQrCodeView = require('../FarcasterQrCodeView/FarcasterQrCodeView.cjs');
17
19
  var LoginViewSection = require('./LoginViewSection/LoginViewSection.cjs');
18
20
  var useLoginView = require('./useLoginView/useLoginView.cjs');
21
+ var showFarcasterQrCodeView = require('./utils/showFarcasterQrCodeView/showFarcasterQrCodeView.cjs');
19
22
 
20
23
  const LoginView = () => {
21
24
  var _a;
22
25
  const { error } = ErrorContext.useErrorContext();
23
26
  const { view, setView } = ViewContext.useViewContext();
24
27
  const { isWalletOnly, loginViewSections } = useLoginView.useLoginView();
28
+ const { enabledSocialProviders } = SocialRedirectContext.useSocialRedirectContext();
25
29
  const [showWalletList, setShowWalletList] = React.useState(isWalletOnly);
26
30
  React.useEffect(() => {
27
31
  // toolkit log in with email was set to false
@@ -43,11 +47,15 @@ const LoginView = () => {
43
47
  const { showDefaultFooter } = useAuthLayoutChecks.useAuthLayoutChecks();
44
48
  const numOfWallets = ((_a = loginViewSections.find((section) => section.type === sdkApiCore.SdkViewSectionType.Wallet)) === null || _a === void 0 ? void 0 : _a.numOfItemsToDisplay) || 0;
45
49
  const renderViewSections = React.useMemo(() => loginViewSections.map((viewSection, index) => (jsxRuntime.jsx("div", { className: classNames.classNames('login-view__scroll__section', `login-view__scroll__section--${viewSection.type}`), children: jsxRuntime.jsx(LoginViewSection.LoginViewSection, { gotToWalletList: () => setShowWalletList(true), index: index, viewSection: viewSection, walletCount: numOfWallets }) }, `${viewSection.type}__${index}`))), [loginViewSections, numOfWallets]);
50
+ const errorElement = error && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { className: 'login-view__error-container', withIcon: false, children: error }));
51
+ if (showFarcasterQrCodeView.showFarcasterQrCodeView(loginViewSections, enabledSocialProviders)) {
52
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [errorElement, jsxRuntime.jsx(FarcasterQrCodeView.FarcasterQrCodeView, {})] }));
53
+ }
46
54
  if (showWalletList) {
47
55
  return jsxRuntime.jsx(WalletList.WalletList, {});
48
56
  }
49
57
  const shouldShowFooter = utils.isMobile() && showDefaultFooter;
50
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [error && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { className: 'login-view__error-container', withIcon: false, children: error })), jsxRuntime.jsx("div", { className: classNames.classNames('login-view__container', {
58
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [errorElement, jsxRuntime.jsx("div", { className: classNames.classNames('login-view__container', {
51
59
  'login-view__container--error': Boolean(error),
52
60
  }), children: jsxRuntime.jsx("div", { className: 'login-view__scroll', "data-testid": 'login-view-scroll', children: renderViewSections }) }), shouldShowFooter && jsxRuntime.jsx(DefaultFooter.DefaultFooter, { hideBorder: true })] }));
53
61
  };
@@ -10,14 +10,18 @@ import { DefaultFooter } from '../../layout/DynamicAuthLayout/DefaultFooter/Defa
10
10
  import { classNames } from '../../utils/functions/classNames/classNames.js';
11
11
  import { useAuthLayoutChecks } from '../../utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js';
12
12
  import { WalletList } from '../WalletList/WalletList.js';
13
+ import { useSocialRedirectContext } from '../../context/SocialRedirectContext/SocialRedirectContext.js';
14
+ import { FarcasterQrCodeView } from '../FarcasterQrCodeView/FarcasterQrCodeView.js';
13
15
  import { LoginViewSection } from './LoginViewSection/LoginViewSection.js';
14
16
  import { useLoginView } from './useLoginView/useLoginView.js';
17
+ import { showFarcasterQrCodeView } from './utils/showFarcasterQrCodeView/showFarcasterQrCodeView.js';
15
18
 
16
19
  const LoginView = () => {
17
20
  var _a;
18
21
  const { error } = useErrorContext();
19
22
  const { view, setView } = useViewContext();
20
23
  const { isWalletOnly, loginViewSections } = useLoginView();
24
+ const { enabledSocialProviders } = useSocialRedirectContext();
21
25
  const [showWalletList, setShowWalletList] = useState(isWalletOnly);
22
26
  useEffect(() => {
23
27
  // toolkit log in with email was set to false
@@ -39,11 +43,15 @@ const LoginView = () => {
39
43
  const { showDefaultFooter } = useAuthLayoutChecks();
40
44
  const numOfWallets = ((_a = loginViewSections.find((section) => section.type === SdkViewSectionType.Wallet)) === null || _a === void 0 ? void 0 : _a.numOfItemsToDisplay) || 0;
41
45
  const renderViewSections = useMemo(() => loginViewSections.map((viewSection, index) => (jsx("div", { className: classNames('login-view__scroll__section', `login-view__scroll__section--${viewSection.type}`), children: jsx(LoginViewSection, { gotToWalletList: () => setShowWalletList(true), index: index, viewSection: viewSection, walletCount: numOfWallets }) }, `${viewSection.type}__${index}`))), [loginViewSections, numOfWallets]);
46
+ const errorElement = error && (jsx(ErrorContainer, { className: 'login-view__error-container', withIcon: false, children: error }));
47
+ if (showFarcasterQrCodeView(loginViewSections, enabledSocialProviders)) {
48
+ return (jsxs(Fragment, { children: [errorElement, jsx(FarcasterQrCodeView, {})] }));
49
+ }
42
50
  if (showWalletList) {
43
51
  return jsx(WalletList, {});
44
52
  }
45
53
  const shouldShowFooter = isMobile() && showDefaultFooter;
46
- return (jsxs(Fragment, { children: [error && (jsx(ErrorContainer, { className: 'login-view__error-container', withIcon: false, children: error })), jsx("div", { className: classNames('login-view__container', {
54
+ return (jsxs(Fragment, { children: [errorElement, jsx("div", { className: classNames('login-view__container', {
47
55
  'login-view__container--error': Boolean(error),
48
56
  }), children: jsx("div", { className: 'login-view__scroll', "data-testid": 'login-view-scroll', children: renderViewSections }) }), shouldShowFooter && jsx(DefaultFooter, { hideBorder: true })] }));
49
57
  };
@@ -87,6 +87,7 @@ const DynamicSocialSignIn = ({ defaultProvider, numOfItemsToDisplay, collapsedLa
87
87
  onError: () => {
88
88
  goToInitialView();
89
89
  },
90
+ onFarcasterUrl: (url) => setView('farcaster-connect-view', { url }),
90
91
  onSettled: () => {
91
92
  setSocialProvider(undefined);
92
93
  },
@@ -83,6 +83,7 @@ const DynamicSocialSignIn = ({ defaultProvider, numOfItemsToDisplay, collapsedLa
83
83
  onError: () => {
84
84
  goToInitialView();
85
85
  },
86
+ onFarcasterUrl: (url) => setView('farcaster-connect-view', { url }),
86
87
  onSettled: () => {
87
88
  setSocialProvider(undefined);
88
89
  },
@@ -0,0 +1 @@
1
+ export { showFarcasterQrCodeView } from './showFarcasterQrCodeView';
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
7
+ var utils = require('@dynamic-labs/utils');
8
+
9
+ const showFarcasterQrCodeView = (loginViewSections, enabledSocialProviders) => loginViewSections.length === 1 &&
10
+ enabledSocialProviders.length === 1 &&
11
+ enabledSocialProviders.includes(sdkApiCore.SocialSignInProviderEnum.Farcaster) &&
12
+ !utils.isMobile();
13
+
14
+ exports.showFarcasterQrCodeView = showFarcasterQrCodeView;
@@ -0,0 +1,2 @@
1
+ import { SdkViewSection, SocialSignInProviderEnum } from '@dynamic-labs/sdk-api-core';
2
+ export declare const showFarcasterQrCodeView: (loginViewSections: SdkViewSection[], enabledSocialProviders: SocialSignInProviderEnum[]) => boolean;
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ import { SocialSignInProviderEnum } from '@dynamic-labs/sdk-api-core';
3
+ import { isMobile } from '@dynamic-labs/utils';
4
+
5
+ const showFarcasterQrCodeView = (loginViewSections, enabledSocialProviders) => loginViewSections.length === 1 &&
6
+ enabledSocialProviders.length === 1 &&
7
+ enabledSocialProviders.includes(SocialSignInProviderEnum.Farcaster) &&
8
+ !isMobile();
9
+
10
+ export { showFarcasterQrCodeView };