@dynamic-labs/sdk-react-core 1.4.4 → 1.4.5
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 +8 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/context/DynamicContext/DynamicContext.cjs +5 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +5 -1
- package/src/lib/context/DynamicContext/hooks/useParentDynamicContextGuard/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.cjs +15 -0
- package/src/lib/context/DynamicContext/hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.js +11 -0
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +4 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
|
|
2
|
+
### [1.4.5](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.4...v1.4.5) (2024-04-05)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* use in-app browser deeplink for metamask ([#5176](https://github.com/dynamic-labs/DynamicAuth/issues/5176)) ([#5203](https://github.com/dynamic-labs/DynamicAuth/issues/5203)) ([63951d8](https://github.com/dynamic-labs/DynamicAuth/commit/63951d8896ea073e595e4a1e92bfe22731b012f4))
|
|
8
|
+
* clear user wallets immediately on logout ([#5238](https://github.com/dynamic-labs/DynamicAuth/issues/5238)) ([13b55a7](https://github.com/dynamic-labs/DynamicAuth/commit/13b55a7070f6f159504bf05b503848cc2c5ed445)), closes [#5211](https://github.com/dynamic-labs/DynamicAuth/issues/5211)
|
|
9
|
+
|
|
2
10
|
### [1.4.4](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.3...v1.4.4) (2024-04-01)
|
|
3
11
|
|
|
4
12
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
"react-focus-lock": "2.9.2",
|
|
17
17
|
"react-i18next": "^13.2.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
|
-
"@dynamic-labs/ethereum": "1.4.
|
|
20
|
-
"@dynamic-labs/iconic": "1.4.
|
|
21
|
-
"@dynamic-labs/logger": "1.4.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "1.4.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "1.4.
|
|
24
|
-
"@dynamic-labs/types": "1.4.
|
|
25
|
-
"@dynamic-labs/utils": "1.4.
|
|
26
|
-
"@dynamic-labs/viem-utils": "1.4.
|
|
27
|
-
"@dynamic-labs/wallet-book": "1.4.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "1.4.
|
|
19
|
+
"@dynamic-labs/ethereum": "1.4.5",
|
|
20
|
+
"@dynamic-labs/iconic": "1.4.5",
|
|
21
|
+
"@dynamic-labs/logger": "1.4.5",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "1.4.5",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "1.4.5",
|
|
24
|
+
"@dynamic-labs/types": "1.4.5",
|
|
25
|
+
"@dynamic-labs/utils": "1.4.5",
|
|
26
|
+
"@dynamic-labs/viem-utils": "1.4.5",
|
|
27
|
+
"@dynamic-labs/wallet-book": "1.4.5",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "1.4.5",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -120,6 +120,7 @@ var useMultiWallet = require('./hooks/useMultiWallet/useMultiWallet.cjs');
|
|
|
120
120
|
var useSetShowLinkNewWalletModal = require('./hooks/useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.cjs');
|
|
121
121
|
var useCustomerCallbacks = require('./useCustomerCallbacks/useCustomerCallbacks.cjs');
|
|
122
122
|
var validators = require('./validators/validators.cjs');
|
|
123
|
+
var useParentDynamicContextGuard = require('./hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.cjs');
|
|
123
124
|
|
|
124
125
|
const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = '2762a57b-faa4-41ce-9f16-abff9300e2c9';
|
|
125
126
|
const EMPTY_INITIAL_USER = undefined;
|
|
@@ -707,7 +708,10 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale
|
|
|
707
708
|
}), children: [networkValidationMode === 'always' && jsxRuntime.jsx(UseNetworkValidation.UseNetworkValidation, {}), jsxRuntime.jsx(CaptchaContext.CaptchaContextProvider, { children: jsxRuntime.jsx(AccountExistsContext.AccountExistsContextProvider, { children: jsxRuntime.jsx(WalletContext.WalletContextProvider, { canSync: didConnectedStateLoad, children: jsxRuntime.jsx(PasskeyContext.PasskeyContextProvider, { children: jsxRuntime.jsx(EmailVerificationContext.EmailVerificationContextProvider, { children: jsxRuntime.jsx(DynamicWidgetContext.DynamicWidgetContextProvider, { children: jsxRuntime.jsx(DynamicBridgeWidgetContext.DynamicBridgeWidgetContextProvider, { children: jsxRuntime.jsx(FundingContext.FundingContextProvider, { children: jsxRuntime.jsx(AccessDeniedContext.AccessDeniedContextProvider, { children: jsxRuntime.jsx(SendBalanceContext.SendBalanceContextProvider, { children: jsxRuntime.jsx(WalletGroupContext.WalletGroupContextProvider, { children: jsxRuntime.jsx(UserFieldEditorContext.UserFieldEditorContextProvider, { children: jsxRuntime.jsx(ConnectWithEmailOtpProvider.ConnectWithEmailOtpProvider, { children: jsxRuntime.jsx(PhantomRedirectContext.PhantomRedirectContextProvider, { children: jsxRuntime.jsxs(SocialRedirectContext.SocialRedirectContextProvider, { children: [jsxRuntime.jsx(app.DynamicAuthFlow, {}), jsxRuntime.jsx(Toolkit.Toolkit, {}), jsxRuntime.jsx(FundingWidget.FundingWidget, {}), jsxRuntime.jsx(SyncPasskeyFlow.SyncPasskeyFlow, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) }) }) }) })] }) }) }) }) }) }));
|
|
708
709
|
};
|
|
709
710
|
/** The context provider you need to have access too all of Dynamic's hooks */
|
|
710
|
-
const DynamicContextProvider = (props) =>
|
|
711
|
+
const DynamicContextProvider = (props) => {
|
|
712
|
+
useParentDynamicContextGuard.useParentDynamicContextGuard();
|
|
713
|
+
return (jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(UserWalletsContext.UserWalletsProvider, { children: jsxRuntime.jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }));
|
|
714
|
+
};
|
|
711
715
|
|
|
712
716
|
exports.DynamicContext = DynamicContext;
|
|
713
717
|
exports.DynamicContextProvider = DynamicContextProvider;
|
|
@@ -116,6 +116,7 @@ import { useMultiWallet } from './hooks/useMultiWallet/useMultiWallet.js';
|
|
|
116
116
|
import { useSetShowLinkNewWalletModal } from './hooks/useSetShowLinkNewWalletModal/useSetShowLinkNewWalletModal.js';
|
|
117
117
|
import { useCustomerCallbacks } from './useCustomerCallbacks/useCustomerCallbacks.js';
|
|
118
118
|
import { validateAuthUser } from './validators/validators.js';
|
|
119
|
+
import { useParentDynamicContextGuard } from './hooks/useParentDynamicContextGuard/useParentDynamicContextGuard.js';
|
|
119
120
|
|
|
120
121
|
const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = '2762a57b-faa4-41ce-9f16-abff9300e2c9';
|
|
121
122
|
const EMPTY_INITIAL_USER = undefined;
|
|
@@ -703,6 +704,9 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
703
704
|
}), children: [networkValidationMode === 'always' && jsx(UseNetworkValidation, {}), jsx(CaptchaContextProvider, { children: jsx(AccountExistsContextProvider, { children: jsx(WalletContextProvider, { canSync: didConnectedStateLoad, children: jsx(PasskeyContextProvider, { children: jsx(EmailVerificationContextProvider, { children: jsx(DynamicWidgetContextProvider, { children: jsx(DynamicBridgeWidgetContextProvider, { children: jsx(FundingContextProvider, { children: jsx(AccessDeniedContextProvider, { children: jsx(SendBalanceContextProvider, { children: jsx(WalletGroupContextProvider, { children: jsx(UserFieldEditorContextProvider, { children: jsx(ConnectWithEmailOtpProvider, { children: jsx(PhantomRedirectContextProvider, { children: jsxs(SocialRedirectContextProvider, { children: [jsx(DynamicAuthFlow, {}), jsx(Toolkit, {}), jsx(FundingWidget, {}), jsx(SyncPasskeyFlow, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) }) }) }) })] }) }) }) }) }) }));
|
|
704
705
|
};
|
|
705
706
|
/** The context provider you need to have access too all of Dynamic's hooks */
|
|
706
|
-
const DynamicContextProvider = (props) =>
|
|
707
|
+
const DynamicContextProvider = (props) => {
|
|
708
|
+
useParentDynamicContextGuard();
|
|
709
|
+
return (jsx(ErrorContextProvider, { children: jsx(UserWalletsProvider, { children: jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }));
|
|
710
|
+
};
|
|
707
711
|
|
|
708
712
|
export { DynamicContext, DynamicContextProvider, InnerDynamicContextProvider, PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useParentDynamicContextGuard } from './useParentDynamicContextGuard';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var DynamicContext = require('../../DynamicContext.cjs');
|
|
7
|
+
|
|
8
|
+
const useParentDynamicContextGuard = () => {
|
|
9
|
+
const context = React.useContext(DynamicContext.DynamicContext);
|
|
10
|
+
if (context) {
|
|
11
|
+
throw new Error('DynamicContextProvider should not be nested. Please wrap your application in a single DynamicContextProvider.');
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.useParentDynamicContextGuard = useParentDynamicContextGuard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useParentDynamicContextGuard: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { DynamicContext } from '../../DynamicContext.js';
|
|
3
|
+
|
|
4
|
+
const useParentDynamicContextGuard = () => {
|
|
5
|
+
const context = useContext(DynamicContext);
|
|
6
|
+
if (context) {
|
|
7
|
+
throw new Error('DynamicContextProvider should not be nested. Please wrap your application in a single DynamicContextProvider.');
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { useParentDynamicContextGuard };
|
|
@@ -72,7 +72,10 @@ const useWalletConnectors = ({ authMode, authToken, connectedWallets, walletConn
|
|
|
72
72
|
const { setUserWallets } = UserWalletsContext.useInternalUserWallets();
|
|
73
73
|
// Keep userWallets in sync whenever linkedWallets changes
|
|
74
74
|
React.useEffect(() => {
|
|
75
|
-
|
|
75
|
+
// we don't want to set the user wallets until their connected states have been computed
|
|
76
|
+
// but that doesn't matter if the wallets list is empty, and if we return early when
|
|
77
|
+
// the wallets list is empty, we'll never set the user wallets correctly after logout
|
|
78
|
+
if (!didConnectedStateLoad.current && wallets.length)
|
|
76
79
|
return;
|
|
77
80
|
setUserWallets((userWallets) => updateUserWalletsFromLinkedWallets.updateUserWalletsFromLinkedWallets(userWallets, wallets));
|
|
78
81
|
}, [didConnectedStateLoad, setUserWallets, wallets]);
|
|
@@ -68,7 +68,10 @@ const useWalletConnectors = ({ authMode, authToken, connectedWallets, walletConn
|
|
|
68
68
|
const { setUserWallets } = useInternalUserWallets();
|
|
69
69
|
// Keep userWallets in sync whenever linkedWallets changes
|
|
70
70
|
useEffect(() => {
|
|
71
|
-
|
|
71
|
+
// we don't want to set the user wallets until their connected states have been computed
|
|
72
|
+
// but that doesn't matter if the wallets list is empty, and if we return early when
|
|
73
|
+
// the wallets list is empty, we'll never set the user wallets correctly after logout
|
|
74
|
+
if (!didConnectedStateLoad.current && wallets.length)
|
|
72
75
|
return;
|
|
73
76
|
setUserWallets((userWallets) => updateUserWalletsFromLinkedWallets(userWallets, wallets));
|
|
74
77
|
}, [didConnectedStateLoad, setUserWallets, wallets]);
|