@dynamic-labs/sdk-react-core 0.18.100-viem.26 → 0.18.100-viem.27
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,11 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.18.100-viem.27](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.100-viem.26...v0.18.100-viem.27) (2023-10-19)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* fix: don't show user profile when reconnecting a primary social wallet ([#3619](https://github.com/dynamic-labs/DynamicAuth/issues/3619)) ([88a9667](https://github.com/dynamic-labs/DynamicAuth/commit/88a9667c7d51a9792bfbffc13c1dca4eedb6f5eb)), closes [#3614](https://github.com/dynamic-labs/DynamicAuth/issues/3614)
|
|
8
|
+
|
|
2
9
|
### [0.18.100-viem.26](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.100-viem.25...v0.18.100-viem.26) (2023-10-14)
|
|
3
10
|
|
|
4
11
|
|
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": "0.18.100-viem.
|
|
3
|
+
"version": "0.18.100-viem.27",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"formik": "2.2.9",
|
|
17
17
|
"qrcode": "1.5.1",
|
|
18
|
-
"@dynamic-labs/logger": "0.18.100-viem.
|
|
19
|
-
"@dynamic-labs/multi-wallet": "0.18.100-viem.
|
|
20
|
-
"@dynamic-labs/rpc-providers": "0.18.100-viem.
|
|
21
|
-
"@dynamic-labs/types": "0.18.100-viem.
|
|
22
|
-
"@dynamic-labs/utils": "0.18.100-viem.
|
|
23
|
-
"@dynamic-labs/wallet-book": "0.18.100-viem.
|
|
24
|
-
"@dynamic-labs/wallet-connector-core": "0.18.100-viem.
|
|
18
|
+
"@dynamic-labs/logger": "0.18.100-viem.27",
|
|
19
|
+
"@dynamic-labs/multi-wallet": "0.18.100-viem.27",
|
|
20
|
+
"@dynamic-labs/rpc-providers": "0.18.100-viem.27",
|
|
21
|
+
"@dynamic-labs/types": "0.18.100-viem.27",
|
|
22
|
+
"@dynamic-labs/utils": "0.18.100-viem.27",
|
|
23
|
+
"@dynamic-labs/wallet-book": "0.18.100-viem.27",
|
|
24
|
+
"@dynamic-labs/wallet-connector-core": "0.18.100-viem.27",
|
|
25
25
|
"eventemitter3": "5.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -46,7 +46,7 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
|
46
46
|
const SocialRedirectContext = React.createContext(undefined);
|
|
47
47
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
48
48
|
var _a, _b;
|
|
49
|
-
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, connectWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
49
|
+
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, connectWallet, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
50
50
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
51
51
|
const { setView } = ViewContext.useViewContext();
|
|
52
52
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
@@ -65,7 +65,10 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
65
65
|
.find(walletConnectorCore.isSocialWalletConnector);
|
|
66
66
|
const [redirectStatus, setRedirectStatus] = React.useState('idle');
|
|
67
67
|
const [socialProvider, setSocialProvider] = React.useState();
|
|
68
|
-
const
|
|
68
|
+
const userWallets = primaryWallet
|
|
69
|
+
? [primaryWallet, ...secondaryWallets]
|
|
70
|
+
: secondaryWallets;
|
|
71
|
+
const wallet = userWallets.find((wallet) => wallet.connector.key === (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.key));
|
|
69
72
|
const socialAccount = React.useMemo(() => (wallet ? getReferencedAccount.getReferencedAccount(authToken, wallet.id) : undefined), [authToken, wallet]);
|
|
70
73
|
const handleError = React.useCallback((message) => {
|
|
71
74
|
logger.logger.error(message);
|
|
@@ -126,12 +129,32 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
126
129
|
if (!socialAccount) {
|
|
127
130
|
throw new Error('Social account not found');
|
|
128
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* consider google: a user may have multiple google accounts.
|
|
134
|
+
* we need to make sure they connected with the same google account
|
|
135
|
+
* that they originally used to authenticate
|
|
136
|
+
*
|
|
137
|
+
* there are two known scenarios that we enter this branch:
|
|
138
|
+
* 1. the user is reconnected a social wallet:
|
|
139
|
+
* a. the user signed in with social
|
|
140
|
+
* b. the user then linked another wallet (for ex: metamask)
|
|
141
|
+
* c. the user signed out
|
|
142
|
+
* d. the user signed in with metamask
|
|
143
|
+
* e. the user selects their social wallet as their primary wallet
|
|
144
|
+
* f. we need to reconnect the social wallet and put the user in the social oauth redirect flow
|
|
145
|
+
*
|
|
146
|
+
* 2. for an unknown reason, the magic search params get put back into the url and this component rerenders,
|
|
147
|
+
* causing us to think the user is reconnecting.
|
|
148
|
+
* see: https://dynamiclabsgroup.slack.com/archives/C0473MNEP0T/p1697503460754999
|
|
149
|
+
*/
|
|
129
150
|
if (socialAccount.oauthAccountId === session.oauthId) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
151
|
+
if ((wallet === null || wallet === void 0 ? void 0 : wallet.id) !== (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id)) {
|
|
152
|
+
// justification: socialAccount is defined if and only if wallet is also defined
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
154
|
+
setPrimaryWalletId(wallet.id);
|
|
155
|
+
setShowAuthFlow(false);
|
|
156
|
+
setShowDynamicUserProfile(true);
|
|
157
|
+
}
|
|
135
158
|
}
|
|
136
159
|
else {
|
|
137
160
|
yield socialWalletConnector.endSession();
|
|
@@ -182,6 +205,8 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
182
205
|
walletUiUtils,
|
|
183
206
|
wallet,
|
|
184
207
|
handleError,
|
|
208
|
+
connectWallet,
|
|
209
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id,
|
|
185
210
|
]);
|
|
186
211
|
return (jsxRuntime.jsx(SocialRedirectContext.Provider, { value: {
|
|
187
212
|
enabledSocialProviders,
|
|
@@ -42,7 +42,7 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
|
42
42
|
const SocialRedirectContext = createContext(undefined);
|
|
43
43
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
44
44
|
var _a, _b;
|
|
45
|
-
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, connectWallet, } = useInternalDynamicContext();
|
|
45
|
+
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, connectWallet, primaryWallet, } = useInternalDynamicContext();
|
|
46
46
|
const { setErrorMessage } = useErrorContext();
|
|
47
47
|
const { setView } = useViewContext();
|
|
48
48
|
const verifyWallet = useVerifyWallet({
|
|
@@ -61,7 +61,10 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
61
61
|
.find(isSocialWalletConnector);
|
|
62
62
|
const [redirectStatus, setRedirectStatus] = useState('idle');
|
|
63
63
|
const [socialProvider, setSocialProvider] = useState();
|
|
64
|
-
const
|
|
64
|
+
const userWallets = primaryWallet
|
|
65
|
+
? [primaryWallet, ...secondaryWallets]
|
|
66
|
+
: secondaryWallets;
|
|
67
|
+
const wallet = userWallets.find((wallet) => wallet.connector.key === (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.key));
|
|
65
68
|
const socialAccount = useMemo(() => (wallet ? getReferencedAccount(authToken, wallet.id) : undefined), [authToken, wallet]);
|
|
66
69
|
const handleError = useCallback((message) => {
|
|
67
70
|
logger.error(message);
|
|
@@ -122,12 +125,32 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
122
125
|
if (!socialAccount) {
|
|
123
126
|
throw new Error('Social account not found');
|
|
124
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* consider google: a user may have multiple google accounts.
|
|
130
|
+
* we need to make sure they connected with the same google account
|
|
131
|
+
* that they originally used to authenticate
|
|
132
|
+
*
|
|
133
|
+
* there are two known scenarios that we enter this branch:
|
|
134
|
+
* 1. the user is reconnected a social wallet:
|
|
135
|
+
* a. the user signed in with social
|
|
136
|
+
* b. the user then linked another wallet (for ex: metamask)
|
|
137
|
+
* c. the user signed out
|
|
138
|
+
* d. the user signed in with metamask
|
|
139
|
+
* e. the user selects their social wallet as their primary wallet
|
|
140
|
+
* f. we need to reconnect the social wallet and put the user in the social oauth redirect flow
|
|
141
|
+
*
|
|
142
|
+
* 2. for an unknown reason, the magic search params get put back into the url and this component rerenders,
|
|
143
|
+
* causing us to think the user is reconnecting.
|
|
144
|
+
* see: https://dynamiclabsgroup.slack.com/archives/C0473MNEP0T/p1697503460754999
|
|
145
|
+
*/
|
|
125
146
|
if (socialAccount.oauthAccountId === session.oauthId) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
147
|
+
if ((wallet === null || wallet === void 0 ? void 0 : wallet.id) !== (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id)) {
|
|
148
|
+
// justification: socialAccount is defined if and only if wallet is also defined
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
150
|
+
setPrimaryWalletId(wallet.id);
|
|
151
|
+
setShowAuthFlow(false);
|
|
152
|
+
setShowDynamicUserProfile(true);
|
|
153
|
+
}
|
|
131
154
|
}
|
|
132
155
|
else {
|
|
133
156
|
yield socialWalletConnector.endSession();
|
|
@@ -178,6 +201,8 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
178
201
|
walletUiUtils,
|
|
179
202
|
wallet,
|
|
180
203
|
handleError,
|
|
204
|
+
connectWallet,
|
|
205
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id,
|
|
181
206
|
]);
|
|
182
207
|
return (jsx(SocialRedirectContext.Provider, { value: {
|
|
183
208
|
enabledSocialProviders,
|