@dynamic-labs/sdk-react-core 0.18.100-viem.25 → 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,18 @@
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
+
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)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * support argentX in-browser wallet ([#3601](https://github.com/dynamic-labs/DynamicAuth/issues/3601)) ([b7bd4a8](https://github.com/dynamic-labs/DynamicAuth/commit/b7bd4a80f8c0928e9515151b570cdf88a6731109))
15
+
2
16
  ### [0.18.100-viem.25](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.100-viem.24...v0.18.100-viem.25) (2023-10-12)
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.18.100-viem.25";
5
+ var version = "0.18.100-viem.27";
6
6
  var dependencies = {
7
7
  "react-focus-lock": "2.9.2",
8
8
  "@dynamic-labs/iconic": "0.1.32",
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
- var version = "0.18.100-viem.25";
1
+ var version = "0.18.100-viem.27";
2
2
  var dependencies = {
3
3
  "react-focus-lock": "2.9.2",
4
4
  "@dynamic-labs/iconic": "0.1.32",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "0.18.100-viem.25",
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.25",
19
- "@dynamic-labs/multi-wallet": "0.18.100-viem.25",
20
- "@dynamic-labs/rpc-providers": "0.18.100-viem.25",
21
- "@dynamic-labs/types": "0.18.100-viem.25",
22
- "@dynamic-labs/utils": "0.18.100-viem.25",
23
- "@dynamic-labs/wallet-book": "0.18.100-viem.25",
24
- "@dynamic-labs/wallet-connector-core": "0.18.100-viem.25",
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 wallet = secondaryWallets.find((wallet) => wallet.connector.key === (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.key));
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
- // justification: socialAccount is defined if and only if wallet is also defined
131
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
132
- setPrimaryWalletId(wallet.id);
133
- setShowAuthFlow(false);
134
- setShowDynamicUserProfile(true);
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 wallet = secondaryWallets.find((wallet) => wallet.connector.key === (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.key));
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
- // justification: socialAccount is defined if and only if wallet is also defined
127
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
128
- setPrimaryWalletId(wallet.id);
129
- setShowAuthFlow(false);
130
- setShowDynamicUserProfile(true);
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,