@dynamic-labs/sdk-react-core 0.18.11 → 0.18.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,17 @@
1
1
 
2
+ ### [0.18.12](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.11...v0.18.12) (2023-08-30)
3
+
4
+
5
+ ### Features
6
+
7
+ * add deepLinkPreference prop ([#3174](https://github.com/dynamic-labs/DynamicAuth/issues/3174)) ([#3176](https://github.com/dynamic-labs/DynamicAuth/issues/3176)) ([8a6e389](https://github.com/dynamic-labs/DynamicAuth/commit/8a6e389e84bd74e80dc9df37ba6df5d46e6ba831))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * end connector session when unlinking from bridge ([#3120](https://github.com/dynamic-labs/DynamicAuth/issues/3120)) ([#3178](https://github.com/dynamic-labs/DynamicAuth/issues/3178)) ([0a69e21](https://github.com/dynamic-labs/DynamicAuth/commit/0a69e218dc9a9a0709bb74b901ed0ca08c7f463c))
13
+ * **bridge:** update address when switching networks ([#3171](https://github.com/dynamic-labs/DynamicAuth/issues/3171)) ([#3180](https://github.com/dynamic-labs/DynamicAuth/issues/3180)) ([8ab5ce4](https://github.com/dynamic-labs/DynamicAuth/commit/8ab5ce4add675ae326c052fc1510d54d56d0d665))
14
+
2
15
  ### [0.18.11](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.10...v0.18.11) (2023-08-29)
3
16
 
4
17
 
package/package.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "0.18.11";
5
+ var version = "0.18.12";
6
6
  var dependencies = {
7
7
  "react-focus-lock": "2.9.2",
8
8
  "@dynamic-labs/iconic": "0.1.27",
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
- var version = "0.18.11";
1
+ var version = "0.18.12";
2
2
  var dependencies = {
3
3
  "react-focus-lock": "2.9.2",
4
4
  "@dynamic-labs/iconic": "0.1.27",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "0.18.11",
3
+ "version": "0.18.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -16,13 +16,13 @@
16
16
  "formik": "2.2.9",
17
17
  "qrcode": "1.5.1",
18
18
  "ethers": "5.7.2",
19
- "@dynamic-labs/logger": "0.18.11",
20
- "@dynamic-labs/multi-wallet": "0.18.11",
21
- "@dynamic-labs/rpc-providers": "0.18.11",
22
- "@dynamic-labs/types": "0.18.11",
23
- "@dynamic-labs/utils": "0.18.11",
24
- "@dynamic-labs/wallet-book": "0.18.11",
25
- "@dynamic-labs/wallet-connector-core": "0.18.11",
19
+ "@dynamic-labs/logger": "0.18.12",
20
+ "@dynamic-labs/multi-wallet": "0.18.12",
21
+ "@dynamic-labs/rpc-providers": "0.18.12",
22
+ "@dynamic-labs/types": "0.18.12",
23
+ "@dynamic-labs/utils": "0.18.12",
24
+ "@dynamic-labs/wallet-book": "0.18.12",
25
+ "@dynamic-labs/wallet-connector-core": "0.18.12",
26
26
  "eventemitter3": "5.0.1"
27
27
  },
28
28
  "devDependencies": {
@@ -101,7 +101,7 @@ const EMPTY_INITIAL_USER = undefined;
101
101
  const DynamicContext = React.createContext(undefined);
102
102
  const DynamicContextProvider = ({ children, theme, settings, }) => {
103
103
  var _a, _b, _c, _d, _e, _f, _g, _h;
104
- const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, } = settings;
104
+ const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, deepLinkPreference = 'native', walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, } = settings;
105
105
  // The following event related methods are temporary and should be removed after QNTM-180 is done
106
106
  // ============ START REMOVE AFTER QNTM-180 ============
107
107
  const internalEventsRef = React.useRef(internalEvents.getInternalEvents());
@@ -174,6 +174,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
174
174
  const { wallets } = useWallets.useWallets({
175
175
  appLogoUrl,
176
176
  appName,
177
+ deepLinkPreference,
177
178
  flowNetwork,
178
179
  networkConfigurations: serverNetworkConfigurations,
179
180
  projectSettings,
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { LogLevel } from '@dynamic-labs/logger';
3
3
  import { EvmNetwork, SocialProviderFilter } from '@dynamic-labs/types';
4
- import { WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
4
+ import { DeepLinkVariant, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
5
5
  import { AccessDeniedCustomButton, AuthModeType, ChainToWalletMap, DynamicEventsCallbacks, WalletOption } from '../../shared';
6
6
  import { SocialNetworkIconType } from '../../utils/functions/getSocialNetworkIcon';
7
7
  import { ThemeData, ThemeSetting } from '../ThemeContext';
@@ -19,6 +19,15 @@ export interface DynamicContextProps {
19
19
  appName?: string;
20
20
  cssOverrides?: string | JSX.Element;
21
21
  debugError?: boolean;
22
+ /**
23
+ * Used to control the type of deep link used when connecting
24
+ * a mobile wallet. Defaults to 'native'. This is useful for
25
+ * example if your app is running in a webview of a native
26
+ * mobile app, and you want to be able to link out to any
27
+ * wallet without having to modify your iOS build config.
28
+ * In this case, you can set this to 'universal'.
29
+ */
30
+ deepLinkPreference?: DeepLinkVariant;
22
31
  defaultNumberOfWalletsToShow?: number;
23
32
  displaySiweStatement?: boolean;
24
33
  enableVisitTrackingOnConnectOnly?: boolean;
@@ -97,7 +97,7 @@ const EMPTY_INITIAL_USER = undefined;
97
97
  const DynamicContext = createContext(undefined);
98
98
  const DynamicContextProvider = ({ children, theme, settings, }) => {
99
99
  var _a, _b, _c, _d, _e, _f, _g, _h;
100
- const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, } = settings;
100
+ const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, deepLinkPreference = 'native', walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, } = settings;
101
101
  // The following event related methods are temporary and should be removed after QNTM-180 is done
102
102
  // ============ START REMOVE AFTER QNTM-180 ============
103
103
  const internalEventsRef = useRef(getInternalEvents());
@@ -170,6 +170,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
170
170
  const { wallets } = useWallets({
171
171
  appLogoUrl,
172
172
  appName,
173
+ deepLinkPreference,
173
174
  flowNetwork,
174
175
  networkConfigurations: serverNetworkConfigurations,
175
176
  projectSettings,
@@ -47,12 +47,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
47
47
  const walletNetwork = yield walletConnector.getNetwork();
48
48
  const walletChain = walletConnector.connectedChain;
49
49
  const walletObject = {
50
- address:
51
- // We use `storedConnectedWalletInfo.lastWalletAddress` as a workaround to Braavos issue
52
- // Braavos during initialization returns an empty string as a wallet address
53
- walletAddress ||
54
- storedConnectedWalletInfo.lastWalletAddress ||
55
- '',
50
+ address: walletAddress || '',
56
51
  chain: walletChain || '',
57
52
  connected: true,
58
53
  connector: walletConnector,
@@ -89,11 +84,10 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
89
84
  }, [connectedWallets]);
90
85
  const connectedWallet = connectedWallets[0] || null;
91
86
  // Keeps connected wallet data inside localStorage
92
- const applyConnectedWalletToStore = ({ walletId, walletAddress, walletConnectorKey, walletChain, provider, }) => {
87
+ const applyConnectedWalletToStore = ({ walletId, walletConnectorKey, walletChain, provider, }) => {
93
88
  const nextConnectedWalletsInfo = [...connectedWalletsInfo];
94
89
  nextConnectedWalletsInfo.push({
95
90
  id: walletId,
96
- lastWalletAddress: walletAddress,
97
91
  provider,
98
92
  walletChain,
99
93
  walletConnectorKey,
@@ -183,14 +177,16 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
183
177
  }
184
178
  return Promise.resolve(publicWalletAddress);
185
179
  });
186
- const unlinkConnectedWallet = (walletId) => {
180
+ const unlinkConnectedWallet = (walletId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
181
+ const connectedWalletToUnlink = connectedWallets.find((wallet) => wallet.id === walletId);
182
+ yield (connectedWalletToUnlink === null || connectedWalletToUnlink === void 0 ? void 0 : connectedWalletToUnlink.connector.endSession());
187
183
  const filteredWallets = connectedWalletsInfo.filter((wallet) => wallet.id !== walletId);
188
184
  if (walletId === primaryWalletId) {
189
185
  clearPrimaryWalletId();
190
186
  }
191
187
  setConnectedWalletsInfo(filteredWallets);
192
188
  onUnlink === null || onUnlink === void 0 ? void 0 : onUnlink(walletId, filteredWallets);
193
- };
189
+ });
194
190
  const getConnectedWalletById = React.useCallback((walletId) => connectedWallets.find((wallet) => wallet.id === walletId), [connectedWallets]);
195
191
  return {
196
192
  connectWallet,
@@ -6,7 +6,6 @@ export type ConnectedWalletConnectorType = {
6
6
  walletChain?: Chain;
7
7
  walletConnectorKey: string;
8
8
  provider: string;
9
- lastWalletAddress?: string;
10
9
  };
11
10
  type Props = {
12
11
  authMode: AuthModeType;
@@ -28,6 +27,6 @@ export declare const useConnectWallet: ({ authMode, clearPrimaryWalletId, enable
28
27
  getConnectedWalletById: (walletId: string) => Wallet | undefined;
29
28
  refreshConnectedWallet: (walletId: string, walletConnector: WalletConnector) => Promise<void>;
30
29
  removeConnectedWalletsInfo: () => void;
31
- unlinkConnectedWallet: (walletId: string) => void;
30
+ unlinkConnectedWallet: (walletId: string) => Promise<void>;
32
31
  };
33
32
  export {};
@@ -43,12 +43,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
43
43
  const walletNetwork = yield walletConnector.getNetwork();
44
44
  const walletChain = walletConnector.connectedChain;
45
45
  const walletObject = {
46
- address:
47
- // We use `storedConnectedWalletInfo.lastWalletAddress` as a workaround to Braavos issue
48
- // Braavos during initialization returns an empty string as a wallet address
49
- walletAddress ||
50
- storedConnectedWalletInfo.lastWalletAddress ||
51
- '',
46
+ address: walletAddress || '',
52
47
  chain: walletChain || '',
53
48
  connected: true,
54
49
  connector: walletConnector,
@@ -85,11 +80,10 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
85
80
  }, [connectedWallets]);
86
81
  const connectedWallet = connectedWallets[0] || null;
87
82
  // Keeps connected wallet data inside localStorage
88
- const applyConnectedWalletToStore = ({ walletId, walletAddress, walletConnectorKey, walletChain, provider, }) => {
83
+ const applyConnectedWalletToStore = ({ walletId, walletConnectorKey, walletChain, provider, }) => {
89
84
  const nextConnectedWalletsInfo = [...connectedWalletsInfo];
90
85
  nextConnectedWalletsInfo.push({
91
86
  id: walletId,
92
- lastWalletAddress: walletAddress,
93
87
  provider,
94
88
  walletChain,
95
89
  walletConnectorKey,
@@ -179,14 +173,16 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
179
173
  }
180
174
  return Promise.resolve(publicWalletAddress);
181
175
  });
182
- const unlinkConnectedWallet = (walletId) => {
176
+ const unlinkConnectedWallet = (walletId) => __awaiter(void 0, void 0, void 0, function* () {
177
+ const connectedWalletToUnlink = connectedWallets.find((wallet) => wallet.id === walletId);
178
+ yield (connectedWalletToUnlink === null || connectedWalletToUnlink === void 0 ? void 0 : connectedWalletToUnlink.connector.endSession());
183
179
  const filteredWallets = connectedWalletsInfo.filter((wallet) => wallet.id !== walletId);
184
180
  if (walletId === primaryWalletId) {
185
181
  clearPrimaryWalletId();
186
182
  }
187
183
  setConnectedWalletsInfo(filteredWallets);
188
184
  onUnlink === null || onUnlink === void 0 ? void 0 : onUnlink(walletId, filteredWallets);
189
- };
185
+ });
190
186
  const getConnectedWalletById = useCallback((walletId) => connectedWallets.find((wallet) => wallet.id === walletId), [connectedWallets]);
191
187
  return {
192
188
  connectWallet,
@@ -6,7 +6,7 @@ var React = require('react');
6
6
  var data = require('../../../views/WalletList/data.cjs');
7
7
  var verifyMagicIsSetup = require('./utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
8
8
 
9
- const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }) => {
9
+ const useWallets = ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }) => {
10
10
  const wallets = React.useMemo(() => {
11
11
  if (!projectSettings || !Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length)
12
12
  return [];
@@ -14,6 +14,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, network
14
14
  appLogoUrl,
15
15
  appName,
16
16
  customerApiProviders: projectSettings.providers || [],
17
+ deepLinkPreference,
17
18
  flowNetwork,
18
19
  networkConfigurations,
19
20
  skipMemo: true,
@@ -26,6 +27,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, network
26
27
  appLogoUrl,
27
28
  appName,
28
29
  customerApiProviders: projectSettings.providers || [],
30
+ deepLinkPreference,
29
31
  flowNetwork,
30
32
  networkConfigurations,
31
33
  skipMemo: true,
@@ -1,10 +1,11 @@
1
1
  import { ProjectSettings } from '@dynamic-labs/sdk-api';
2
2
  import { NetworkConfigurationMap, WalletUiUtils } from '@dynamic-labs/types';
3
- import { WalletConnector, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
3
+ import { DeepLinkVariant, WalletConnector, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
4
4
  import { WalletBookSchema } from '@dynamic-labs/wallet-book';
5
5
  type Props = {
6
6
  appLogoUrl?: string;
7
7
  appName?: string;
8
+ deepLinkPreference?: DeepLinkVariant;
8
9
  flowNetwork?: 'mainnet' | 'testnet';
9
10
  networkConfigurations: NetworkConfigurationMap | undefined;
10
11
  projectSettings: ProjectSettings | undefined;
@@ -13,7 +14,7 @@ type Props = {
13
14
  walletConnectorsProp?: WalletConnectorsMethod[];
14
15
  walletUiUtils: WalletUiUtils<WalletConnector>;
15
16
  };
16
- export declare const useWallets: ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }: Props) => {
17
+ export declare const useWallets: ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }: Props) => {
17
18
  wallets: import("../../../shared").WalletOption[];
18
19
  };
19
20
  export {};
@@ -2,7 +2,7 @@ import { useMemo, useEffect } from 'react';
2
2
  import { getInstalledWallets, getNotInstalledWallets } from '../../../views/WalletList/data.js';
3
3
  import { verifyMagicIsSetup } from './utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
4
4
 
5
- const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }) => {
5
+ const useWallets = ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }) => {
6
6
  const wallets = useMemo(() => {
7
7
  if (!projectSettings || !Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length)
8
8
  return [];
@@ -10,6 +10,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, network
10
10
  appLogoUrl,
11
11
  appName,
12
12
  customerApiProviders: projectSettings.providers || [],
13
+ deepLinkPreference,
13
14
  flowNetwork,
14
15
  networkConfigurations,
15
16
  skipMemo: true,
@@ -22,6 +23,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, network
22
23
  appLogoUrl,
23
24
  appName,
24
25
  customerApiProviders: projectSettings.providers || [],
26
+ deepLinkPreference,
25
27
  flowNetwork,
26
28
  networkConfigurations,
27
29
  skipMemo: true,