@dynamic-labs/sdk-react-core 2.2.0 → 2.2.1

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,12 @@
1
1
 
2
+ ### [2.2.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0...v2.2.1) (2024-06-17)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * improve handling of bitcoin connected accounts ([#6049](https://github.com/dynamic-labs/DynamicAuth/issues/6049)) ([08cb8ba](https://github.com/dynamic-labs/DynamicAuth/commit/08cb8bae2b1521367234cbe2bb55a8c3766df3c1))
8
+ * improve wagmi hooks with embedded wallets ([#6044](https://github.com/dynamic-labs/DynamicAuth/issues/6044)) ([#6052](https://github.com/dynamic-labs/DynamicAuth/issues/6052)) ([28654e8](https://github.com/dynamic-labs/DynamicAuth/commit/28654e8a45b25c4fc3bb3abfa89b453808a55053))
9
+
2
10
  ## [2.2.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.5...v2.2.0) (2024-06-16)
3
11
 
4
12
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "2.2.0";
6
+ var version = "2.2.1";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.460",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "2.2.0";
2
+ var version = "2.2.1";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.460",
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.2.0",
3
+ "version": "2.2.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -17,18 +17,18 @@
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.2.0",
21
- "@dynamic-labs/logger": "2.2.0",
22
- "@dynamic-labs/multi-wallet": "2.2.0",
23
- "@dynamic-labs/rpc-provider-ethereum": "2.2.0",
24
- "@dynamic-labs/rpc-provider-solana": "2.2.0",
25
- "@dynamic-labs/rpc-providers": "2.2.0",
26
- "@dynamic-labs/store": "2.2.0",
27
- "@dynamic-labs/types": "2.2.0",
28
- "@dynamic-labs/utils": "2.2.0",
29
- "@dynamic-labs/viem-utils": "2.2.0",
30
- "@dynamic-labs/wallet-book": "2.2.0",
31
- "@dynamic-labs/wallet-connector-core": "2.2.0",
20
+ "@dynamic-labs/iconic": "2.2.1",
21
+ "@dynamic-labs/logger": "2.2.1",
22
+ "@dynamic-labs/multi-wallet": "2.2.1",
23
+ "@dynamic-labs/rpc-provider-ethereum": "2.2.1",
24
+ "@dynamic-labs/rpc-provider-solana": "2.2.1",
25
+ "@dynamic-labs/rpc-providers": "2.2.1",
26
+ "@dynamic-labs/store": "2.2.1",
27
+ "@dynamic-labs/types": "2.2.1",
28
+ "@dynamic-labs/utils": "2.2.1",
29
+ "@dynamic-labs/viem-utils": "2.2.1",
30
+ "@dynamic-labs/wallet-book": "2.2.1",
31
+ "@dynamic-labs/wallet-connector-core": "2.2.1",
32
32
  "eventemitter3": "5.0.1"
33
33
  },
34
34
  "devDependencies": {
@@ -272,7 +272,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
272
272
  const { selectedWalletConnector, setSelectedWalletConnectorKey } = useSelectedWalletConnector.useSelectedWalletConnector({ walletConnectorOptions });
273
273
  //selected wallet to perform an action (become primary, unlink, etc)
274
274
  const [selectedWalletWithAction, setSelectedWalletWithAction] = React.useState(null);
275
- useSetWalletConnectorVerifiedCredentials.useSetWalletConnectorVerifiedCredentials(user, walletConnectorOptions);
275
+ useSetWalletConnectorVerifiedCredentials.useSetWalletConnectorVerifiedCredentials(user !== null && user !== void 0 ? user : unauthenticatedUser, walletConnectorOptions);
276
276
  useSetWalletConnectorFetchers.useSetWalletConnectorFetchers(walletConnectorOptions, environmentId);
277
277
  const { didConnectedStateLoad, primaryWallet, showQrcodeModal, secondaryWallets, setPrimaryWallet, setShowQrcodeModal, wallets: linkedOrConnectedWallets, } = useWalletConnectors.useWalletConnectors({
278
278
  authMode,
@@ -268,7 +268,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
268
268
  const { selectedWalletConnector, setSelectedWalletConnectorKey } = useSelectedWalletConnector({ walletConnectorOptions });
269
269
  //selected wallet to perform an action (become primary, unlink, etc)
270
270
  const [selectedWalletWithAction, setSelectedWalletWithAction] = useState(null);
271
- useSetWalletConnectorVerifiedCredentials(user, walletConnectorOptions);
271
+ useSetWalletConnectorVerifiedCredentials(user !== null && user !== void 0 ? user : unauthenticatedUser, walletConnectorOptions);
272
272
  useSetWalletConnectorFetchers(walletConnectorOptions, environmentId);
273
273
  const { didConnectedStateLoad, primaryWallet, showQrcodeModal, secondaryWallets, setPrimaryWallet, setShowQrcodeModal, wallets: linkedOrConnectedWallets, } = useWalletConnectors({
274
274
  authMode,
@@ -1,2 +0,0 @@
1
- import { UserProfile } from '@dynamic-labs/types';
2
- export declare const isUserLinkingWallet: (user: UserProfile | undefined, view: string, isMockedSDK: boolean) => boolean;
@@ -1 +0,0 @@
1
- export * from './isPhoneNumberProviderEnabled';
@@ -5,11 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
7
  var React = require('react');
8
- var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
9
8
  var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
10
9
  require('@dynamic-labs/sdk-api-core');
11
10
  require('../../../shared/logger.cjs');
12
11
  require('@dynamic-labs/iconic');
12
+ require('@dynamic-labs/wallet-connector-core');
13
13
  require('react/jsx-runtime');
14
14
  require('../../../context/ViewContext/ViewContext.cjs');
15
15
  require('@dynamic-labs/wallet-book');
@@ -53,11 +53,6 @@ const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWall
53
53
  const numberOfLinkedWallets = verifiedCredentials.filter((account) => account.walletName === ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.key) || '')).length;
54
54
  // If there's only 1, it's the one being removed and we can kill the session
55
55
  if (numberOfLinkedWallets === 1) {
56
- if (wallet && walletConnectorCore.isBitcoinConnector(wallet.connector)) {
57
- // to avoid the infinite wallet popup issue experienced with the ME wallet
58
- // we only want to clear the cached connected accounts when we unlink, but not on logout
59
- yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.clearConnectedAccounts());
60
- }
61
56
  yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.endSession());
62
57
  }
63
58
  removedWalletsIds.current.push(walletId);
@@ -1,11 +1,11 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { useCallback } from 'react';
4
- import { isBitcoinConnector } from '@dynamic-labs/wallet-connector-core';
5
4
  import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
6
5
  import '@dynamic-labs/sdk-api-core';
7
6
  import '../../../shared/logger.js';
8
7
  import '@dynamic-labs/iconic';
8
+ import '@dynamic-labs/wallet-connector-core';
9
9
  import 'react/jsx-runtime';
10
10
  import '../../../context/ViewContext/ViewContext.js';
11
11
  import '@dynamic-labs/wallet-book';
@@ -49,11 +49,6 @@ const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWall
49
49
  const numberOfLinkedWallets = verifiedCredentials.filter((account) => account.walletName === ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.key) || '')).length;
50
50
  // If there's only 1, it's the one being removed and we can kill the session
51
51
  if (numberOfLinkedWallets === 1) {
52
- if (wallet && isBitcoinConnector(wallet.connector)) {
53
- // to avoid the infinite wallet popup issue experienced with the ME wallet
54
- // we only want to clear the cached connected accounts when we unlink, but not on logout
55
- yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.clearConnectedAccounts());
56
- }
57
52
  yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.endSession());
58
53
  }
59
54
  removedWalletsIds.current.push(walletId);
@@ -83,7 +83,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
83
83
 
84
84
  const sleepToShowSuccessMessage = () => utils.sleep(1500);
85
85
  const useUserAuth = ({ authMethod, }) => {
86
- const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, environmentId, } = useInternalDynamicContext.useInternalDynamicContext();
86
+ const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, environmentId, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
87
87
  const { view, setView, goToInitialView } = ViewContext.useViewContext();
88
88
  const { setLoading } = LoadingContext.useLoadingContext();
89
89
  const { setErrorMessage, setError } = ErrorContext.useErrorContext();
@@ -110,6 +110,9 @@ const useUserAuth = ({ authMethod, }) => {
110
110
  verifiedUser = verifyResponse;
111
111
  }
112
112
  onVerifySuccess === null || onVerifySuccess === void 0 ? void 0 : onVerifySuccess(verifiedUser);
113
+ walletConnectorOptions.forEach((walletOption) => {
114
+ walletOption.walletConnector.setVerifiedCredentials(verifiedUser.verifiedCredentials);
115
+ });
113
116
  if ((_b = verifiedUser.scope) === null || _b === void 0 ? void 0 : _b.includes('requiresAdditionalAuth')) {
114
117
  const devices = yield mfa.getUserMfaDevices({ environmentId });
115
118
  if (devices.length === 0) {
@@ -79,7 +79,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
79
79
 
80
80
  const sleepToShowSuccessMessage = () => sleep(1500);
81
81
  const useUserAuth = ({ authMethod, }) => {
82
- const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, environmentId, } = useInternalDynamicContext();
82
+ const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, environmentId, walletConnectorOptions, } = useInternalDynamicContext();
83
83
  const { view, setView, goToInitialView } = useViewContext();
84
84
  const { setLoading } = useLoadingContext();
85
85
  const { setErrorMessage, setError } = useErrorContext();
@@ -106,6 +106,9 @@ const useUserAuth = ({ authMethod, }) => {
106
106
  verifiedUser = verifyResponse;
107
107
  }
108
108
  onVerifySuccess === null || onVerifySuccess === void 0 ? void 0 : onVerifySuccess(verifiedUser);
109
+ walletConnectorOptions.forEach((walletOption) => {
110
+ walletOption.walletConnector.setVerifiedCredentials(verifiedUser.verifiedCredentials);
111
+ });
109
112
  if ((_b = verifiedUser.scope) === null || _b === void 0 ? void 0 : _b.includes('requiresAdditionalAuth')) {
110
113
  const devices = yield getUserMfaDevices({ environmentId });
111
114
  if (devices.length === 0) {
@@ -102,7 +102,7 @@ require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
102
102
  const SECONDS_TO_RETRY = 15;
103
103
  const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
104
104
  var _a, _b, _c, _d;
105
- const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, } = useInternalDynamicContext.useInternalDynamicContext();
105
+ const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
106
106
  const { setView, goToInitialView } = ViewContext.useViewContext();
107
107
  const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
108
108
  const { loading, setLoading } = LoadingContext.useLoadingContext();
@@ -177,14 +177,16 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
177
177
  if (!embeddedWalletVerifiedCredential) {
178
178
  throw new Error('Could not find an embedded wallet');
179
179
  }
180
+ const walletOption = walletConnectorOptions === null || walletConnectorOptions === void 0 ? void 0 : walletConnectorOptions.find((option) => option.key === embeddedWalletVerifiedCredential.walletName);
181
+ if (!(walletOption === null || walletOption === void 0 ? void 0 : walletOption.walletConnector)) {
182
+ throw new Error('Could not find connector for embedded wallet');
183
+ }
180
184
  const wallet = {
181
185
  address: embeddedWalletVerifiedCredential.address,
182
186
  authenticated: false,
183
187
  chain: embeddedWalletVerifiedCredential.chain,
184
188
  connected: true,
185
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
186
- // @ts-ignore
187
- connector: undefined,
189
+ connector: walletOption.walletConnector,
188
190
  id: embeddedWalletVerifiedCredential.id,
189
191
  key: (_k = embeddedWalletVerifiedCredential.walletName) !== null && _k !== void 0 ? _k : '',
190
192
  };
@@ -210,6 +212,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
210
212
  setShowAuthFlow,
211
213
  setView,
212
214
  user,
215
+ walletConnectorOptions,
213
216
  ]);
214
217
  const handleEmailVerification = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
215
218
  setError(undefined);
@@ -98,7 +98,7 @@ import '../../context/IpConfigurationContext/IpConfigurationContext.js';
98
98
  const SECONDS_TO_RETRY = 15;
99
99
  const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
100
100
  var _a, _b, _c, _d;
101
- const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, } = useInternalDynamicContext();
101
+ const { environmentId, handleLogOut, setPrimaryWalletId, setShowAuthFlow, projectSettings, user, unauthenticatedUser, walletConnectorOptions, } = useInternalDynamicContext();
102
102
  const { setView, goToInitialView } = useViewContext();
103
103
  const { error, setError, setErrorMessage } = useErrorContext();
104
104
  const { loading, setLoading } = useLoadingContext();
@@ -173,14 +173,16 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
173
173
  if (!embeddedWalletVerifiedCredential) {
174
174
  throw new Error('Could not find an embedded wallet');
175
175
  }
176
+ const walletOption = walletConnectorOptions === null || walletConnectorOptions === void 0 ? void 0 : walletConnectorOptions.find((option) => option.key === embeddedWalletVerifiedCredential.walletName);
177
+ if (!(walletOption === null || walletOption === void 0 ? void 0 : walletOption.walletConnector)) {
178
+ throw new Error('Could not find connector for embedded wallet');
179
+ }
176
180
  const wallet = {
177
181
  address: embeddedWalletVerifiedCredential.address,
178
182
  authenticated: false,
179
183
  chain: embeddedWalletVerifiedCredential.chain,
180
184
  connected: true,
181
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
182
- // @ts-ignore
183
- connector: undefined,
185
+ connector: walletOption.walletConnector,
184
186
  id: embeddedWalletVerifiedCredential.id,
185
187
  key: (_k = embeddedWalletVerifiedCredential.walletName) !== null && _k !== void 0 ? _k : '',
186
188
  };
@@ -206,6 +208,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
206
208
  setShowAuthFlow,
207
209
  setView,
208
210
  user,
211
+ walletConnectorOptions,
209
212
  ]);
210
213
  const handleEmailVerification = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
211
214
  setError(undefined);