@dynamic-labs/sdk-react-core 0.17.0-RC.20 → 0.17.0-RC.22

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 (30) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +7 -7
  5. package/src/lib/Main.cjs +2 -1
  6. package/src/lib/Main.js +2 -1
  7. package/src/lib/components/WalletOrSocialMagicIcon/WalletOrSocialMagicIcon.cjs +32 -6
  8. package/src/lib/components/WalletOrSocialMagicIcon/WalletOrSocialMagicIcon.d.ts +3 -1
  9. package/src/lib/components/WalletOrSocialMagicIcon/WalletOrSocialMagicIcon.js +32 -6
  10. package/src/lib/context/AccessDeniedContext/AccessDeniedContext.cjs +7 -1
  11. package/src/lib/context/AccessDeniedContext/AccessDeniedContext.d.ts +3 -0
  12. package/src/lib/context/AccessDeniedContext/AccessDeniedContext.js +7 -1
  13. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -1
  14. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -1
  15. package/src/lib/styles/index.shadow.cjs +1 -1
  16. package/src/lib/styles/index.shadow.js +1 -1
  17. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +8 -4
  18. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +8 -4
  19. package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +1 -1
  20. package/src/lib/views/CollectUserDataView/CollectUserDataView.js +1 -1
  21. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -1
  22. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -1
  23. package/src/lib/views/NoAccess/NoAccess.cjs +7 -5
  24. package/src/lib/views/NoAccess/NoAccess.js +7 -5
  25. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +4 -1
  26. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +4 -1
  27. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +4 -4
  28. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +4 -4
  29. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.cjs +20 -4
  30. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.js +21 -5
package/CHANGELOG.md CHANGED
@@ -1,4 +1,18 @@
1
1
 
2
+ ## [0.17.0-RC.22](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.21...v0.17.0-RC.22) (2023-06-02)
3
+
4
+
5
+ ### Features
6
+
7
+ * social copy update ([#2215](https://github.com/dynamic-labs/DynamicAuth/issues/2215)) ([1fe7316](https://github.com/dynamic-labs/DynamicAuth/commit/1fe7316a94284db7227d5ab09026354269559752))
8
+
9
+ ## [0.17.0-RC.21](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.20...v0.17.0-RC.21) (2023-06-02)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * social icon is missing on some views ([#2211](https://github.com/dynamic-labs/DynamicAuth/issues/2211)) ([bddd255](https://github.com/dynamic-labs/DynamicAuth/commit/bddd255f0aa61aed4b767145c51624ac1eb9b963))
15
+
2
16
  ## [0.17.0-RC.20](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.19...v0.17.0-RC.20) (2023-06-01)
3
17
 
4
18
 
package/package.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "0.17.0-RC.20";
5
+ var version = "0.17.0-RC.22";
6
6
  var dependencies = {
7
7
  "react-focus-lock": "2.9.2",
8
8
  "@dynamic-labs/iconic": "0.1.19",
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
- var version = "0.17.0-RC.20";
1
+ var version = "0.17.0-RC.22";
2
2
  var dependencies = {
3
3
  "react-focus-lock": "2.9.2",
4
4
  "@dynamic-labs/iconic": "0.1.19",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "0.17.0-RC.20",
3
+ "version": "0.17.0-RC.22",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -17,12 +17,12 @@
17
17
  "formik": "2.2.9",
18
18
  "qrcode": "1.5.1",
19
19
  "ethers": "5.7.2",
20
- "@dynamic-labs/logger": "0.17.0-RC.20",
21
- "@dynamic-labs/multi-wallet": "0.17.0-RC.20",
22
- "@dynamic-labs/rpc-providers": "0.17.0-RC.20",
23
- "@dynamic-labs/types": "0.17.0-RC.20",
24
- "@dynamic-labs/utils": "0.17.0-RC.20",
25
- "@dynamic-labs/wallet-connector-core": "0.17.0-RC.20"
20
+ "@dynamic-labs/logger": "0.17.0-RC.22",
21
+ "@dynamic-labs/multi-wallet": "0.17.0-RC.22",
22
+ "@dynamic-labs/rpc-providers": "0.17.0-RC.22",
23
+ "@dynamic-labs/types": "0.17.0-RC.22",
24
+ "@dynamic-labs/utils": "0.17.0-RC.22",
25
+ "@dynamic-labs/wallet-connector-core": "0.17.0-RC.22"
26
26
  },
27
27
  "devDependencies": {
28
28
  "semver": "7.3.8"
package/src/lib/Main.cjs CHANGED
@@ -50,11 +50,12 @@ require('./main.global.cjs');
50
50
  const Main = () => {
51
51
  const { selectedWalletConnector, appName, connectedWallets, isProjectSettingsLoading, projectSettings, privacyPolicyUrl, setShowAuthFlow, showAuthFlow, termsOfServiceUrl, newToWeb3WalletChainMap, wallets, clearStatesOnBackClick, user, loginWithEmail, } = useInternalDynamicContext.useInternalDynamicContext();
52
52
  const { view, setView } = ViewContext.useViewContext();
53
- const { setDeniedAddress } = AccessDeniedContext.useAccessDeniedContext();
53
+ const { setDeniedAddress, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
54
54
  usePreventPageScroll.usePreventPageScroll(showAuthFlow);
55
55
  const handleClose = () => {
56
56
  setShowAuthFlow(false);
57
57
  setDeniedAddress('');
58
+ setDeniedOauthProvider(undefined);
58
59
  clearStatesOnBackClick();
59
60
  };
60
61
  const handleOnPortalUnmount = React.useCallback(
package/src/lib/Main.js CHANGED
@@ -46,11 +46,12 @@ import './main.global.js';
46
46
  const Main = () => {
47
47
  const { selectedWalletConnector, appName, connectedWallets, isProjectSettingsLoading, projectSettings, privacyPolicyUrl, setShowAuthFlow, showAuthFlow, termsOfServiceUrl, newToWeb3WalletChainMap, wallets, clearStatesOnBackClick, user, loginWithEmail, } = useInternalDynamicContext();
48
48
  const { view, setView } = useViewContext();
49
- const { setDeniedAddress } = useAccessDeniedContext();
49
+ const { setDeniedAddress, setDeniedOauthProvider } = useAccessDeniedContext();
50
50
  usePreventPageScroll(showAuthFlow);
51
51
  const handleClose = () => {
52
52
  setShowAuthFlow(false);
53
53
  setDeniedAddress('');
54
+ setDeniedOauthProvider(undefined);
54
55
  clearStatesOnBackClick();
55
56
  };
56
57
  const handleOnPortalUnmount = useCallback(
@@ -19,18 +19,44 @@ var getReferencedAccount = require('../../utils/functions/getReferencedAccount/g
19
19
  var getSocialIcon = require('../../utils/functions/getSocialIcon/getSocialIcon.cjs');
20
20
  var IconWithStatus = require('../IconWithStatus/IconWithStatus.cjs');
21
21
  var useInternalDynamicContext = require('../../context/DynamicContext/useInternalDynamicContext.cjs');
22
+ var WalletIconWithStatus = require('../../widgets/DynamicWidget/components/WalletIconWithStatus/WalletIconWithStatus.cjs');
23
+ var AccessDeniedContext = require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
22
24
 
23
- const WalletOrSocialMagicIcon = ({ jwt, iconSize = 64, showInnerMagicIcon, }) => {
24
- const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
25
+ const WalletOrSocialMagicIcon = ({ jwt, iconSize = 64, showStatus, wallet, }) => {
26
+ const { primaryWallet, selectedWalletConnector } = useInternalDynamicContext.useInternalDynamicContext();
27
+ const { deniedOauthProvider, deniedAddress } = AccessDeniedContext.useAccessDeniedContext();
28
+ // when access is denied we don't have jwt set, so we're getting this value out of useAccessDeniedContext
29
+ if (deniedOauthProvider) {
30
+ const MagicSocialWalletIcon = getSocialIcon.getSocialIcon(deniedOauthProvider);
31
+ return (jsxRuntime.jsx(MagicSocialWalletIcon, { style: {
32
+ height: pixelToRem.pixelToRem(iconSize),
33
+ width: pixelToRem.pixelToRem(iconSize),
34
+ } }));
35
+ }
36
+ // it means that user tried to login with actual wallet and no magic social and failed to go through the access list
37
+ if (deniedAddress) {
38
+ return (jsxRuntime.jsx(walletBook.WalletIcon, { walletName: selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name, style: { height: pixelToRem.pixelToRem(iconSize), width: pixelToRem.pixelToRem(iconSize) } }));
39
+ }
25
40
  if (!primaryWallet) {
26
41
  return null;
27
42
  }
28
- if (walletConnectorCore.isSocialWalletConnector(primaryWallet.connector)) {
29
- const socialAccountDataForWallet = getReferencedAccount.getReferencedAccount(jwt, primaryWallet.id);
43
+ const walletForIcon = wallet ? wallet : primaryWallet;
44
+ if (walletConnectorCore.isSocialWalletConnector(walletForIcon.connector)) {
45
+ const socialAccountDataForWallet = getReferencedAccount.getReferencedAccount(jwt, walletForIcon.id);
30
46
  const MagicSocialWalletIcon = getSocialIcon.getSocialIcon(socialAccountDataForWallet === null || socialAccountDataForWallet === void 0 ? void 0 : socialAccountDataForWallet.oauthProvider);
31
- return showInnerMagicIcon ? (jsxRuntime.jsx(IconWithStatus.IconWithStatus, { iconSize: iconSize, Icon: MagicSocialWalletIcon, primaryWalletName: primaryWallet.connector.name })) : (jsxRuntime.jsx(MagicSocialWalletIcon, { style: { height: pixelToRem.pixelToRem(iconSize), width: pixelToRem.pixelToRem(iconSize) } }));
47
+ // to show social icon with status dot
48
+ if (showStatus) {
49
+ return (jsxRuntime.jsx(IconWithStatus.IconWithStatus, { iconSize: iconSize, Icon: MagicSocialWalletIcon, variant: walletForIcon.connected ? 'green' : 'red' }));
50
+ }
51
+ // to show social icon
52
+ return (jsxRuntime.jsx(MagicSocialWalletIcon, { style: { height: pixelToRem.pixelToRem(iconSize), width: pixelToRem.pixelToRem(iconSize) } }));
53
+ }
54
+ // to show wallet icon with status dot
55
+ if (showStatus) {
56
+ return (jsxRuntime.jsx(WalletIconWithStatus.WalletIconWithStatus, { iconSize: iconSize, walletName: walletForIcon.connector.name, connected: walletForIcon.connected, variant: 'secondary' }));
32
57
  }
33
- return (jsxRuntime.jsx(walletBook.WalletIcon, { walletName: primaryWallet.connector.name, style: { height: pixelToRem.pixelToRem(iconSize), width: pixelToRem.pixelToRem(iconSize) } }));
58
+ // to show wallet icon without status dot
59
+ return (jsxRuntime.jsx(walletBook.WalletIcon, { walletName: walletForIcon.connector.name, style: { height: pixelToRem.pixelToRem(iconSize), width: pixelToRem.pixelToRem(iconSize) } }));
34
60
  };
35
61
 
36
62
  exports.WalletOrSocialMagicIcon = WalletOrSocialMagicIcon;
@@ -1,8 +1,10 @@
1
1
  import { FC } from 'react';
2
+ import { Wallet } from '../../shared';
2
3
  type Props = {
3
4
  iconSize?: number;
4
5
  jwt: string | undefined;
5
- showInnerMagicIcon?: boolean;
6
+ wallet?: Wallet | null;
7
+ showStatus?: boolean;
6
8
  };
7
9
  export declare const WalletOrSocialMagicIcon: FC<Props>;
8
10
  export {};
@@ -15,18 +15,44 @@ import { getReferencedAccount } from '../../utils/functions/getReferencedAccount
15
15
  import { getSocialIcon } from '../../utils/functions/getSocialIcon/getSocialIcon.js';
16
16
  import { IconWithStatus } from '../IconWithStatus/IconWithStatus.js';
17
17
  import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
18
+ import { WalletIconWithStatus } from '../../widgets/DynamicWidget/components/WalletIconWithStatus/WalletIconWithStatus.js';
19
+ import { useAccessDeniedContext } from '../../context/AccessDeniedContext/AccessDeniedContext.js';
18
20
 
19
- const WalletOrSocialMagicIcon = ({ jwt, iconSize = 64, showInnerMagicIcon, }) => {
20
- const { primaryWallet } = useInternalDynamicContext();
21
+ const WalletOrSocialMagicIcon = ({ jwt, iconSize = 64, showStatus, wallet, }) => {
22
+ const { primaryWallet, selectedWalletConnector } = useInternalDynamicContext();
23
+ const { deniedOauthProvider, deniedAddress } = useAccessDeniedContext();
24
+ // when access is denied we don't have jwt set, so we're getting this value out of useAccessDeniedContext
25
+ if (deniedOauthProvider) {
26
+ const MagicSocialWalletIcon = getSocialIcon(deniedOauthProvider);
27
+ return (jsx(MagicSocialWalletIcon, { style: {
28
+ height: pixelToRem(iconSize),
29
+ width: pixelToRem(iconSize),
30
+ } }));
31
+ }
32
+ // it means that user tried to login with actual wallet and no magic social and failed to go through the access list
33
+ if (deniedAddress) {
34
+ return (jsx(WalletIcon, { walletName: selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name, style: { height: pixelToRem(iconSize), width: pixelToRem(iconSize) } }));
35
+ }
21
36
  if (!primaryWallet) {
22
37
  return null;
23
38
  }
24
- if (isSocialWalletConnector(primaryWallet.connector)) {
25
- const socialAccountDataForWallet = getReferencedAccount(jwt, primaryWallet.id);
39
+ const walletForIcon = wallet ? wallet : primaryWallet;
40
+ if (isSocialWalletConnector(walletForIcon.connector)) {
41
+ const socialAccountDataForWallet = getReferencedAccount(jwt, walletForIcon.id);
26
42
  const MagicSocialWalletIcon = getSocialIcon(socialAccountDataForWallet === null || socialAccountDataForWallet === void 0 ? void 0 : socialAccountDataForWallet.oauthProvider);
27
- return showInnerMagicIcon ? (jsx(IconWithStatus, { iconSize: iconSize, Icon: MagicSocialWalletIcon, primaryWalletName: primaryWallet.connector.name })) : (jsx(MagicSocialWalletIcon, { style: { height: pixelToRem(iconSize), width: pixelToRem(iconSize) } }));
43
+ // to show social icon with status dot
44
+ if (showStatus) {
45
+ return (jsx(IconWithStatus, { iconSize: iconSize, Icon: MagicSocialWalletIcon, variant: walletForIcon.connected ? 'green' : 'red' }));
46
+ }
47
+ // to show social icon
48
+ return (jsx(MagicSocialWalletIcon, { style: { height: pixelToRem(iconSize), width: pixelToRem(iconSize) } }));
49
+ }
50
+ // to show wallet icon with status dot
51
+ if (showStatus) {
52
+ return (jsx(WalletIconWithStatus, { iconSize: iconSize, walletName: walletForIcon.connector.name, connected: walletForIcon.connected, variant: 'secondary' }));
28
53
  }
29
- return (jsx(WalletIcon, { walletName: primaryWallet.connector.name, style: { height: pixelToRem(iconSize), width: pixelToRem(iconSize) } }));
54
+ // to show wallet icon without status dot
55
+ return (jsx(WalletIcon, { walletName: walletForIcon.connector.name, style: { height: pixelToRem(iconSize), width: pixelToRem(iconSize) } }));
30
56
  };
31
57
 
32
58
  export { WalletOrSocialMagicIcon };
@@ -8,7 +8,13 @@ var React = require('react');
8
8
  const AccessDeniedContext = React.createContext(undefined);
9
9
  const AccessDeniedContextProvider = ({ children, }) => {
10
10
  const [deniedAddress, setDeniedAddress] = React.useState('');
11
- const value = React.useMemo(() => ({ deniedAddress, setDeniedAddress }), [deniedAddress]);
11
+ const [deniedOauthProvider, setDeniedOauthProvider] = React.useState(undefined);
12
+ const value = React.useMemo(() => ({
13
+ deniedAddress,
14
+ deniedOauthProvider,
15
+ setDeniedAddress,
16
+ setDeniedOauthProvider,
17
+ }), [deniedAddress, deniedOauthProvider]);
12
18
  return (jsxRuntime.jsx(AccessDeniedContext.Provider, Object.assign({ value: value }, { children: children })));
13
19
  };
14
20
  const useAccessDeniedContext = () => {
@@ -1,7 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
+ import { ProviderEnum } from '@dynamic-labs/sdk-api';
2
3
  export type AccessDeniedContextType = {
3
4
  deniedAddress: string;
4
5
  setDeniedAddress(address: string): void;
6
+ setDeniedOauthProvider(deniedOauthProvider: ProviderEnum | undefined): void;
7
+ deniedOauthProvider: ProviderEnum | undefined;
5
8
  };
6
9
  export declare const AccessDeniedContext: import("react").Context<AccessDeniedContextType | undefined>;
7
10
  export declare const AccessDeniedContextProvider: ({ children, }: {
@@ -4,7 +4,13 @@ import { createContext, useState, useMemo, useContext } from 'react';
4
4
  const AccessDeniedContext = createContext(undefined);
5
5
  const AccessDeniedContextProvider = ({ children, }) => {
6
6
  const [deniedAddress, setDeniedAddress] = useState('');
7
- const value = useMemo(() => ({ deniedAddress, setDeniedAddress }), [deniedAddress]);
7
+ const [deniedOauthProvider, setDeniedOauthProvider] = useState(undefined);
8
+ const value = useMemo(() => ({
9
+ deniedAddress,
10
+ deniedOauthProvider,
11
+ setDeniedAddress,
12
+ setDeniedOauthProvider,
13
+ }), [deniedAddress, deniedOauthProvider]);
8
14
  return (jsx(AccessDeniedContext.Provider, Object.assign({ value: value }, { children: children })));
9
15
  };
10
16
  const useAccessDeniedContext = () => {
@@ -61,7 +61,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
61
61
  const [redirectStatus, setRedirectStatus] = React.useState('idle');
62
62
  const [socialProvider, setSocialProvider] = React.useState();
63
63
  const wallet = secondaryWallets.find((wallet) => wallet.connector.key === (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.key));
64
- const socialAccount = React.useMemo(() => (wallet ? getReferencedAccount.getReferencedAccount(authToken, '123') : undefined), [authToken, wallet]);
64
+ const socialAccount = React.useMemo(() => (wallet ? getReferencedAccount.getReferencedAccount(authToken, wallet.id) : undefined), [authToken, wallet]);
65
65
  const handleError = React.useCallback((message) => {
66
66
  logger.logger.error(message);
67
67
  if (isAuthenticated) {
@@ -57,7 +57,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
57
57
  const [redirectStatus, setRedirectStatus] = useState('idle');
58
58
  const [socialProvider, setSocialProvider] = useState();
59
59
  const wallet = secondaryWallets.find((wallet) => wallet.connector.key === (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.key));
60
- const socialAccount = useMemo(() => (wallet ? getReferencedAccount(authToken, '123') : undefined), [authToken, wallet]);
60
+ const socialAccount = useMemo(() => (wallet ? getReferencedAccount(authToken, wallet.id) : undefined), [authToken, wallet]);
61
61
  const handleError = useCallback((message) => {
62
62
  logger.error(message);
63
63
  if (isAuthenticated) {