@dynamic-labs/sdk-react-core 0.17.18 → 0.17.20
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 +16 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/index.cjs +2 -0
- package/src/index.js +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +24 -11
- package/src/lib/context/DynamicContext/DynamicContext.js +25 -12
- package/src/lib/shared/utils/functions/storage/getLSKeys.cjs +12 -0
- package/src/lib/shared/utils/functions/storage/getLSKeys.d.ts +1 -0
- package/src/lib/shared/utils/functions/storage/getLSKeys.js +8 -0
- package/src/lib/shared/utils/functions/storage/index.d.ts +1 -0
- package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.cjs +16 -3
- package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.js +16 -3
- package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs +1 -1
- package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js +1 -1
- package/src/lib/utils/hooks/useValidateSession/index.d.ts +1 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +79 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.d.ts +12 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +75 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +5 -5
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.17.20](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.19...v0.17.20) (2023-07-03)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* persist chain to WalletConnect session when changed in wallet ([#2556](https://github.com/dynamic-labs/DynamicAuth/issues/2556)) ([#2562](https://github.com/dynamic-labs/DynamicAuth/issues/2562)) ([0415e6d](https://github.com/dynamic-labs/DynamicAuth/commit/0415e6d055e860ab63ebf0d249ca9cdd71dfdb83))
|
|
8
|
+
|
|
9
|
+
### [0.17.19](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.18...v0.17.19) (2023-07-02)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* log out if there's any session sync issue ([#2548](https://github.com/dynamic-labs/DynamicAuth/issues/2548)) ([3f92bab](https://github.com/dynamic-labs/DynamicAuth/commit/3f92bab1b6b317f4a024a68d4d220921bad3437c))
|
|
15
|
+
* WC2 sign-message on non-selected chain ([#2551](https://github.com/dynamic-labs/DynamicAuth/issues/2551)) ([c455e53](https://github.com/dynamic-labs/DynamicAuth/commit/c455e530c964b2865ffd29529546faddf2a57096)), closes [#2544](https://github.com/dynamic-labs/DynamicAuth/issues/2544) [#2552](https://github.com/dynamic-labs/DynamicAuth/issues/2552) [#2525](https://github.com/dynamic-labs/DynamicAuth/issues/2525) [#2500](https://github.com/dynamic-labs/DynamicAuth/issues/2500) [#2546](https://github.com/dynamic-labs/DynamicAuth/issues/2546)
|
|
16
|
+
* **wcv2:** don't force required chain to eth in case is not enabled ([#2538](https://github.com/dynamic-labs/DynamicAuth/issues/2538)) ([933dc20](https://github.com/dynamic-labs/DynamicAuth/commit/933dc20b300f0740a438810b9e65d693aae61689))
|
|
17
|
+
|
|
2
18
|
### [0.17.18](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.17...v0.17.18) (2023-06-29)
|
|
3
19
|
|
|
4
20
|
### [0.17.17](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.16...v0.17.17) (2023-06-29)
|
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.17.
|
|
3
|
+
"version": "0.17.20",
|
|
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.17.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "0.17.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "0.17.
|
|
22
|
-
"@dynamic-labs/types": "0.17.
|
|
23
|
-
"@dynamic-labs/utils": "0.17.
|
|
24
|
-
"@dynamic-labs/wallet-book": "0.17.
|
|
25
|
-
"@dynamic-labs/wallet-connector-core": "0.17.
|
|
19
|
+
"@dynamic-labs/logger": "0.17.20",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "0.17.20",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "0.17.20",
|
|
22
|
+
"@dynamic-labs/types": "0.17.20",
|
|
23
|
+
"@dynamic-labs/utils": "0.17.20",
|
|
24
|
+
"@dynamic-labs/wallet-book": "0.17.20",
|
|
25
|
+
"@dynamic-labs/wallet-connector-core": "0.17.20"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"semver": "7.3.8"
|
package/src/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var getFromLS = require('./lib/shared/utils/functions/storage/getFromLS.cjs');
|
|
|
21
21
|
var getDynamicLSKey = require('./lib/shared/utils/functions/storage/getDynamicLSKey.cjs');
|
|
22
22
|
var removeFromLS = require('./lib/shared/utils/functions/storage/removeFromLS.cjs');
|
|
23
23
|
var setToLS = require('./lib/shared/utils/functions/storage/setToLS.cjs');
|
|
24
|
+
var getLSKeys = require('./lib/shared/utils/functions/storage/getLSKeys.cjs');
|
|
24
25
|
var validateType = require('./lib/shared/utils/functions/validateType/validateType.cjs');
|
|
25
26
|
var getChainIcon = require('./lib/shared/utils/functions/chain/getChainIcon.cjs');
|
|
26
27
|
var getChainDisplayName = require('./lib/shared/utils/functions/chain/getChainDisplayName.cjs');
|
|
@@ -143,6 +144,7 @@ exports.getFromLS = getFromLS.getFromLS;
|
|
|
143
144
|
exports.getDynamicLSKey = getDynamicLSKey.getDynamicLSKey;
|
|
144
145
|
exports.removeFromLS = removeFromLS.removeFromLS;
|
|
145
146
|
exports.setToLS = setToLS.setToLS;
|
|
147
|
+
exports.getLSKeys = getLSKeys.getLSKeys;
|
|
146
148
|
exports.validateType = validateType.validateType;
|
|
147
149
|
exports.getChainIcon = getChainIcon.getChainIcon;
|
|
148
150
|
exports.getChainDisplayName = getChainDisplayName.getChainDisplayName;
|
package/src/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export { getFromLS } from './lib/shared/utils/functions/storage/getFromLS.js';
|
|
|
17
17
|
export { getDynamicLSKey } from './lib/shared/utils/functions/storage/getDynamicLSKey.js';
|
|
18
18
|
export { removeFromLS } from './lib/shared/utils/functions/storage/removeFromLS.js';
|
|
19
19
|
export { setToLS } from './lib/shared/utils/functions/storage/setToLS.js';
|
|
20
|
+
export { getLSKeys } from './lib/shared/utils/functions/storage/getLSKeys.js';
|
|
20
21
|
export { validateType } from './lib/shared/utils/functions/validateType/validateType.js';
|
|
21
22
|
export { getChainIcon } from './lib/shared/utils/functions/chain/getChainIcon.js';
|
|
22
23
|
export { getChainDisplayName } from './lib/shared/utils/functions/chain/getChainDisplayName.js';
|
|
@@ -76,6 +76,7 @@ var FundingWidget = require('../../widgets/FundingWidget/FundingWidget.cjs');
|
|
|
76
76
|
var DynamicBridgeWidgetContext = require('../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs');
|
|
77
77
|
require('../../widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetViews/DynamicBridgeWidgetViews.cjs');
|
|
78
78
|
var SendBalanceContext = require('../SendBalanceContext/SendBalanceContext.cjs');
|
|
79
|
+
var useValidateSession = require('../../utils/hooks/useValidateSession/useValidateSession.cjs');
|
|
79
80
|
var helpers = require('./helpers.cjs');
|
|
80
81
|
var validators = require('./validators.cjs');
|
|
81
82
|
var useCustomerCallbacks = require('./useCustomerCallbacks/useCustomerCallbacks.cjs');
|
|
@@ -88,17 +89,12 @@ var useSetShowAuthFlowWithInit = require('./hooks/useSetShowAuthFlowWithInit/use
|
|
|
88
89
|
const EMPTY_INITIAL_USER = undefined;
|
|
89
90
|
const DynamicContext = React.createContext(undefined);
|
|
90
91
|
const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, appLogoUrl = 'https://demo.dynamic.xyz/assets/dynamic-logo.svg', appName = 'Dynamic Example', cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displayTermsOfService = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', multiWallet: deprecatedMultiWallet, notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectV1Bridge, walletConnectors: walletConnectorsProp, }, children, theme, }) => {
|
|
91
|
-
var _a, _b, _c, _d, _e;
|
|
92
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
92
93
|
logger.logger.setLogLevel(logLevel);
|
|
93
94
|
walletConnectorCore.logger.setLogLevel(logLevel);
|
|
94
95
|
ApiEndpoint.setBaseUrl((_a = process.env.DYNAMIC_API_BASE_URL) !== null && _a !== void 0 ? _a : apiBaseUrl);
|
|
95
96
|
LSSuffix.setSuffix(localStorageSuffix);
|
|
96
97
|
const isAuthenticated = Boolean(getAuthToken.getAuthToken());
|
|
97
|
-
// HOTFIX - NEED TO BE REVISITED
|
|
98
|
-
// if there's user but not auth_token, remove user
|
|
99
|
-
if (!isAuthenticated) {
|
|
100
|
-
removeFromLS.removeFromLS(localStorage$1.AUTH_USER);
|
|
101
|
-
}
|
|
102
98
|
const [onboardingOnlyJwt, setOnboardingOnlyJwt] = React.useState(undefined);
|
|
103
99
|
const [showAuthFlow, setShowAuthFlow] = React.useState(false);
|
|
104
100
|
// Allows clients to control widget flow without need to click on AccountControl
|
|
@@ -170,8 +166,10 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
170
166
|
setShowAuthFlow,
|
|
171
167
|
wallets,
|
|
172
168
|
});
|
|
169
|
+
// until user completes onboarding, jwt is only stored in onboardingOnlyJwt
|
|
170
|
+
const authToken = (_d = getAuthToken.getAuthToken()) !== null && _d !== void 0 ? _d : onboardingOnlyJwt;
|
|
173
171
|
const { getNameService, removeConnectedNameService } = useNameService.useNameService({
|
|
174
|
-
authToken
|
|
172
|
+
authToken,
|
|
175
173
|
currentWallet: primaryWallet !== null && primaryWallet !== void 0 ? primaryWallet : connectedWallet,
|
|
176
174
|
});
|
|
177
175
|
const walletForUserFacingContext = authMode === 'connect-and-sign' || user ? primaryWallet : connectedWallet;
|
|
@@ -182,7 +180,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
182
180
|
clearOphanedWalletConnectSessions,
|
|
183
181
|
]);
|
|
184
182
|
const handleLogOut = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
185
|
-
var
|
|
183
|
+
var _h, _j;
|
|
186
184
|
clearAllWalletConnectSessions();
|
|
187
185
|
localStorage.removeItem(localStorage$1.WALLET_PICKER_SEARCH_KEY);
|
|
188
186
|
const jwt = getAuthToken.getAuthToken();
|
|
@@ -193,7 +191,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
193
191
|
for (const connector of walletConnectors) {
|
|
194
192
|
yield connector.endSession();
|
|
195
193
|
}
|
|
196
|
-
(
|
|
194
|
+
(_h = connectedWallet === null || connectedWallet === void 0 ? void 0 : connectedWallet.connector) === null || _h === void 0 ? void 0 : _h.endSession();
|
|
197
195
|
setShowAuthFlow(false);
|
|
198
196
|
setMultiWalletWidgetState('idle');
|
|
199
197
|
removeAuthTokenAndUser();
|
|
@@ -203,7 +201,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
203
201
|
removeConnectedInfo();
|
|
204
202
|
clearPrimaryWalletId();
|
|
205
203
|
removeConnectedNameService();
|
|
206
|
-
(
|
|
204
|
+
(_j = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLogout) === null || _j === void 0 ? void 0 : _j.call(eventsCallbacks, user);
|
|
207
205
|
}), [
|
|
208
206
|
clearAllWalletConnectSessions,
|
|
209
207
|
user,
|
|
@@ -219,6 +217,21 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
219
217
|
environmentId,
|
|
220
218
|
walletConnectors,
|
|
221
219
|
]);
|
|
220
|
+
let wcVersion;
|
|
221
|
+
if (projectSettings) {
|
|
222
|
+
wcVersion =
|
|
223
|
+
((_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _e === void 0 ? void 0 : _e.walletConnect) === null || _f === void 0 ? void 0 : _f.v2Enabled) && !walletConnectV1Bridge
|
|
224
|
+
? 2
|
|
225
|
+
: 1;
|
|
226
|
+
}
|
|
227
|
+
useValidateSession.useValidateSession({
|
|
228
|
+
authToken,
|
|
229
|
+
handleLogOut,
|
|
230
|
+
user,
|
|
231
|
+
walletConnectV1Bridge,
|
|
232
|
+
walletConnectors,
|
|
233
|
+
wcVersion,
|
|
234
|
+
});
|
|
222
235
|
useSyncPrimaryWallet.useSyncPrimaryWallet({
|
|
223
236
|
canSync: didConnectedStateLoad,
|
|
224
237
|
computeConnectedStateForWallets,
|
|
@@ -519,7 +532,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
519
532
|
setShowDynamicUserProfile(true);
|
|
520
533
|
}
|
|
521
534
|
}, [multiWallet, multiWalletWidgetState, showDynamicUserProfile, user]);
|
|
522
|
-
return (jsxRuntime.jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsxRuntime.jsx(ThemeContext.ThemeContextProvider, Object.assign({ customerTheme: parseTheme.parseTheme(theme, ((
|
|
535
|
+
return (jsxRuntime.jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsxRuntime.jsx(ThemeContext.ThemeContextProvider, Object.assign({ customerTheme: parseTheme.parseTheme(theme, ((_g = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _g === void 0 ? void 0 : _g.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design }, { children: jsxRuntime.jsx(LoadingContext.LoadingContextProvider, { children: jsxRuntime.jsx(ViewContext.ViewContextProvider, Object.assign({ initialView: loginWithEmail ? 'login-with-email-or-wallet' : 'wallet-list' }, { children: jsxRuntime.jsx(QrCodeContext.QrCodeContextProvider, { children: jsxRuntime.jsx(EmailVerificationContext.EmailVerificationContextProvider, { children: jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(DynamicWidgetContext.DynamicWidgetContextProvider, { children: jsxRuntime.jsx(DynamicBridgeWidgetContext.DynamicBridgeWidgetContextProvider, { children: jsxRuntime.jsx(CaptchaContext.CaptchaContextProvider, { children: jsxRuntime.jsx(FundingContext.FundingContextProvider, { children: jsxRuntime.jsx(AccessDeniedContext.AccessDeniedContextProvider, { children: jsxRuntime.jsxs(SendBalanceContext.SendBalanceContextProvider, { children: [jsxRuntime.jsx(app.DynamicAuthFlow, {}), jsxRuntime.jsx(Toolkit.Toolkit, {}), jsxRuntime.jsx(FundingWidget.FundingWidget, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) })) }) })) })));
|
|
523
536
|
};
|
|
524
537
|
|
|
525
538
|
exports.DynamicContext = DynamicContext;
|
|
@@ -3,7 +3,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
3
3
|
import { createContext, useState, useCallback, useEffect, useMemo } from 'react';
|
|
4
4
|
import { logger as logger$1 } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { ICONIC_SPRITE_URL } from '@dynamic-labs/iconic';
|
|
6
|
-
import {
|
|
6
|
+
import { AUTH_TOKEN, AUTH_USER, AUTH_MODE, WALLET_PICKER_SEARCH_KEY } from '../../utils/constants/localStorage.js';
|
|
7
7
|
import '../../utils/constants/colors.js';
|
|
8
8
|
import { DEFAULT_NUMBER_OF_WALLETS_TO_SHOW } from '../../utils/constants/values.js';
|
|
9
9
|
import { decodeJwt } from '../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
@@ -72,6 +72,7 @@ import { FundingWidget } from '../../widgets/FundingWidget/FundingWidget.js';
|
|
|
72
72
|
import { DynamicBridgeWidgetContextProvider } from '../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
|
|
73
73
|
import '../../widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetViews/DynamicBridgeWidgetViews.js';
|
|
74
74
|
import { SendBalanceContextProvider } from '../SendBalanceContext/SendBalanceContext.js';
|
|
75
|
+
import { useValidateSession } from '../../utils/hooks/useValidateSession/useValidateSession.js';
|
|
75
76
|
import { initExpirationTime } from './helpers.js';
|
|
76
77
|
import { validateAuthUser } from './validators.js';
|
|
77
78
|
import { useCustomerCallbacks } from './useCustomerCallbacks/useCustomerCallbacks.js';
|
|
@@ -84,17 +85,12 @@ import { useSetShowAuthFlowWithInit } from './hooks/useSetShowAuthFlowWithInit/u
|
|
|
84
85
|
const EMPTY_INITIAL_USER = undefined;
|
|
85
86
|
const DynamicContext = createContext(undefined);
|
|
86
87
|
const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, appLogoUrl = 'https://demo.dynamic.xyz/assets/dynamic-logo.svg', appName = 'Dynamic Example', cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displayTermsOfService = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', multiWallet: deprecatedMultiWallet, notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectV1Bridge, walletConnectors: walletConnectorsProp, }, children, theme, }) => {
|
|
87
|
-
var _a, _b, _c, _d, _e;
|
|
88
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
88
89
|
logger.setLogLevel(logLevel);
|
|
89
90
|
logger$1.setLogLevel(logLevel);
|
|
90
91
|
ApiEndpoint.setBaseUrl((_a = process.env.DYNAMIC_API_BASE_URL) !== null && _a !== void 0 ? _a : apiBaseUrl);
|
|
91
92
|
LSSuffix.setSuffix(localStorageSuffix);
|
|
92
93
|
const isAuthenticated = Boolean(getAuthToken());
|
|
93
|
-
// HOTFIX - NEED TO BE REVISITED
|
|
94
|
-
// if there's user but not auth_token, remove user
|
|
95
|
-
if (!isAuthenticated) {
|
|
96
|
-
removeFromLS(AUTH_USER);
|
|
97
|
-
}
|
|
98
94
|
const [onboardingOnlyJwt, setOnboardingOnlyJwt] = useState(undefined);
|
|
99
95
|
const [showAuthFlow, setShowAuthFlow] = useState(false);
|
|
100
96
|
// Allows clients to control widget flow without need to click on AccountControl
|
|
@@ -166,8 +162,10 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
166
162
|
setShowAuthFlow,
|
|
167
163
|
wallets,
|
|
168
164
|
});
|
|
165
|
+
// until user completes onboarding, jwt is only stored in onboardingOnlyJwt
|
|
166
|
+
const authToken = (_d = getAuthToken()) !== null && _d !== void 0 ? _d : onboardingOnlyJwt;
|
|
169
167
|
const { getNameService, removeConnectedNameService } = useNameService({
|
|
170
|
-
authToken
|
|
168
|
+
authToken,
|
|
171
169
|
currentWallet: primaryWallet !== null && primaryWallet !== void 0 ? primaryWallet : connectedWallet,
|
|
172
170
|
});
|
|
173
171
|
const walletForUserFacingContext = authMode === 'connect-and-sign' || user ? primaryWallet : connectedWallet;
|
|
@@ -178,7 +176,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
178
176
|
clearOphanedWalletConnectSessions,
|
|
179
177
|
]);
|
|
180
178
|
const handleLogOut = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
181
|
-
var
|
|
179
|
+
var _h, _j;
|
|
182
180
|
clearAllWalletConnectSessions();
|
|
183
181
|
localStorage.removeItem(WALLET_PICKER_SEARCH_KEY);
|
|
184
182
|
const jwt = getAuthToken();
|
|
@@ -189,7 +187,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
189
187
|
for (const connector of walletConnectors) {
|
|
190
188
|
yield connector.endSession();
|
|
191
189
|
}
|
|
192
|
-
(
|
|
190
|
+
(_h = connectedWallet === null || connectedWallet === void 0 ? void 0 : connectedWallet.connector) === null || _h === void 0 ? void 0 : _h.endSession();
|
|
193
191
|
setShowAuthFlow(false);
|
|
194
192
|
setMultiWalletWidgetState('idle');
|
|
195
193
|
removeAuthTokenAndUser();
|
|
@@ -199,7 +197,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
199
197
|
removeConnectedInfo();
|
|
200
198
|
clearPrimaryWalletId();
|
|
201
199
|
removeConnectedNameService();
|
|
202
|
-
(
|
|
200
|
+
(_j = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLogout) === null || _j === void 0 ? void 0 : _j.call(eventsCallbacks, user);
|
|
203
201
|
}), [
|
|
204
202
|
clearAllWalletConnectSessions,
|
|
205
203
|
user,
|
|
@@ -215,6 +213,21 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
215
213
|
environmentId,
|
|
216
214
|
walletConnectors,
|
|
217
215
|
]);
|
|
216
|
+
let wcVersion;
|
|
217
|
+
if (projectSettings) {
|
|
218
|
+
wcVersion =
|
|
219
|
+
((_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _e === void 0 ? void 0 : _e.walletConnect) === null || _f === void 0 ? void 0 : _f.v2Enabled) && !walletConnectV1Bridge
|
|
220
|
+
? 2
|
|
221
|
+
: 1;
|
|
222
|
+
}
|
|
223
|
+
useValidateSession({
|
|
224
|
+
authToken,
|
|
225
|
+
handleLogOut,
|
|
226
|
+
user,
|
|
227
|
+
walletConnectV1Bridge,
|
|
228
|
+
walletConnectors,
|
|
229
|
+
wcVersion,
|
|
230
|
+
});
|
|
218
231
|
useSyncPrimaryWallet({
|
|
219
232
|
canSync: didConnectedStateLoad,
|
|
220
233
|
computeConnectedStateForWallets,
|
|
@@ -515,7 +528,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
515
528
|
setShowDynamicUserProfile(true);
|
|
516
529
|
}
|
|
517
530
|
}, [multiWallet, multiWalletWidgetState, showDynamicUserProfile, user]);
|
|
518
|
-
return (jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsx(ThemeContextProvider, Object.assign({ customerTheme: parseTheme(theme, ((
|
|
531
|
+
return (jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsx(ThemeContextProvider, Object.assign({ customerTheme: parseTheme(theme, ((_g = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _g === void 0 ? void 0 : _g.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design }, { children: jsx(LoadingContextProvider, { children: jsx(ViewContextProvider, Object.assign({ initialView: loginWithEmail ? 'login-with-email-or-wallet' : 'wallet-list' }, { children: jsx(QrCodeContextProvider, { children: jsx(EmailVerificationContextProvider, { children: jsx(ErrorContextProvider, { children: jsx(DynamicWidgetContextProvider, { children: jsx(DynamicBridgeWidgetContextProvider, { children: jsx(CaptchaContextProvider, { children: jsx(FundingContextProvider, { children: jsx(AccessDeniedContextProvider, { children: jsxs(SendBalanceContextProvider, { children: [jsx(DynamicAuthFlow, {}), jsx(Toolkit, {}), jsx(FundingWidget, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) })) }) })) })));
|
|
519
532
|
};
|
|
520
533
|
|
|
521
534
|
export { DynamicContext, DynamicContextProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getLSKeys: () => string[];
|
|
@@ -4,6 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
|
+
require('@dynamic-labs/sdk-api');
|
|
8
|
+
require('../../../shared/logger.cjs');
|
|
9
|
+
require('../../../config/LSSuffix.cjs');
|
|
10
|
+
var getLSKeys = require('../../../shared/utils/functions/storage/getLSKeys.cjs');
|
|
11
|
+
require('@dynamic-labs/iconic');
|
|
12
|
+
require('react/jsx-runtime');
|
|
13
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
14
|
+
require('@dynamic-labs/utils');
|
|
15
|
+
require('../../constants/colors.cjs');
|
|
16
|
+
require('ethers');
|
|
17
|
+
require('../../../shared/consts/index.cjs');
|
|
7
18
|
|
|
8
19
|
const useClearWalletConnectSessions = ({ connectors }) => {
|
|
9
20
|
const clearOphanedWalletConnectSessions = React.useCallback(() => {
|
|
@@ -12,7 +23,7 @@ const useClearWalletConnectSessions = ({ connectors }) => {
|
|
|
12
23
|
if (connectors.length === 0)
|
|
13
24
|
return;
|
|
14
25
|
const names = new Set(connectors.map((connector) => walletConnectorCore.normalizeWalletName(connector.name)));
|
|
15
|
-
for (const key of
|
|
26
|
+
for (const key of getLSKeys.getLSKeys()) {
|
|
16
27
|
if (key.startsWith('walletconnect') &&
|
|
17
28
|
!names.has(key.replace('walletconnect-', ''))) {
|
|
18
29
|
localStorage.removeItem(key);
|
|
@@ -22,8 +33,10 @@ const useClearWalletConnectSessions = ({ connectors }) => {
|
|
|
22
33
|
const clearAllWalletConnectSessions = () => {
|
|
23
34
|
if (typeof window === 'undefined')
|
|
24
35
|
return;
|
|
25
|
-
for (const key of
|
|
26
|
-
if (key.startsWith('walletconnect')
|
|
36
|
+
for (const key of getLSKeys.getLSKeys()) {
|
|
37
|
+
if (key.startsWith('walletconnect') ||
|
|
38
|
+
key.startsWith('walletlink') ||
|
|
39
|
+
key.startsWith('wc@2')) {
|
|
27
40
|
localStorage.removeItem(key);
|
|
28
41
|
}
|
|
29
42
|
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { normalizeWalletName } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import '@dynamic-labs/sdk-api';
|
|
4
|
+
import '../../../shared/logger.js';
|
|
5
|
+
import '../../../config/LSSuffix.js';
|
|
6
|
+
import { getLSKeys } from '../../../shared/utils/functions/storage/getLSKeys.js';
|
|
7
|
+
import '@dynamic-labs/iconic';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
10
|
+
import '@dynamic-labs/utils';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import 'ethers';
|
|
13
|
+
import '../../../shared/consts/index.js';
|
|
3
14
|
|
|
4
15
|
const useClearWalletConnectSessions = ({ connectors }) => {
|
|
5
16
|
const clearOphanedWalletConnectSessions = useCallback(() => {
|
|
@@ -8,7 +19,7 @@ const useClearWalletConnectSessions = ({ connectors }) => {
|
|
|
8
19
|
if (connectors.length === 0)
|
|
9
20
|
return;
|
|
10
21
|
const names = new Set(connectors.map((connector) => normalizeWalletName(connector.name)));
|
|
11
|
-
for (const key of
|
|
22
|
+
for (const key of getLSKeys()) {
|
|
12
23
|
if (key.startsWith('walletconnect') &&
|
|
13
24
|
!names.has(key.replace('walletconnect-', ''))) {
|
|
14
25
|
localStorage.removeItem(key);
|
|
@@ -18,8 +29,10 @@ const useClearWalletConnectSessions = ({ connectors }) => {
|
|
|
18
29
|
const clearAllWalletConnectSessions = () => {
|
|
19
30
|
if (typeof window === 'undefined')
|
|
20
31
|
return;
|
|
21
|
-
for (const key of
|
|
22
|
-
if (key.startsWith('walletconnect')
|
|
32
|
+
for (const key of getLSKeys()) {
|
|
33
|
+
if (key.startsWith('walletconnect') ||
|
|
34
|
+
key.startsWith('walletlink') ||
|
|
35
|
+
key.startsWith('wc@2')) {
|
|
23
36
|
localStorage.removeItem(key);
|
|
24
37
|
}
|
|
25
38
|
}
|
package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs
CHANGED
|
@@ -30,9 +30,9 @@ const useCreateUserProfileByJWTCallback = () => {
|
|
|
30
30
|
goToInitialView();
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
+
index.storeAuthToken(jwt);
|
|
33
34
|
const userProfile = createUserProfile.createUserProfile(decodedJWT);
|
|
34
35
|
setUser(userProfile);
|
|
35
|
-
index.storeAuthToken(jwt);
|
|
36
36
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
37
|
}, []);
|
|
38
38
|
return { createUserProfileByJWT };
|
package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js
CHANGED
|
@@ -26,9 +26,9 @@ const useCreateUserProfileByJWTCallback = () => {
|
|
|
26
26
|
goToInitialView();
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
+
storeAuthToken(jwt);
|
|
29
30
|
const userProfile = createUserProfile(decodedJWT);
|
|
30
31
|
setUser(userProfile);
|
|
31
|
-
storeAuthToken(jwt);
|
|
32
32
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
33
|
}, []);
|
|
34
34
|
return { createUserProfileByJWT };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useValidateSession } from './useValidateSession';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
require('@dynamic-labs/sdk-api');
|
|
8
|
+
var logger = require('../../../shared/logger.cjs');
|
|
9
|
+
require('../../../config/LSSuffix.cjs');
|
|
10
|
+
var getLSKeys = require('../../../shared/utils/functions/storage/getLSKeys.cjs');
|
|
11
|
+
require('@dynamic-labs/iconic');
|
|
12
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
13
|
+
require('react/jsx-runtime');
|
|
14
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
require('@dynamic-labs/utils');
|
|
16
|
+
require('../../constants/colors.cjs');
|
|
17
|
+
require('ethers');
|
|
18
|
+
require('../../../shared/consts/index.cjs');
|
|
19
|
+
|
|
20
|
+
const useValidateSession = ({ handleLogOut, user, authToken, walletConnectV1Bridge, walletConnectors, wcVersion, }) => {
|
|
21
|
+
const [hasLoggedOut, setHasLoggedOut] = React.useState(false);
|
|
22
|
+
if (hasLoggedOut) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const logout = (reason, params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
setHasLoggedOut(true);
|
|
27
|
+
logger.logger.debug(`Logging out - Reason: ${reason}`, Object.assign({}, params));
|
|
28
|
+
yield handleLogOut();
|
|
29
|
+
});
|
|
30
|
+
const handleUserDataOutOfSync = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
if (authToken || !user) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
yield logout('user data out of sync', {
|
|
35
|
+
authToken,
|
|
36
|
+
user,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const handleConnectorBridgeOutOfSync = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
let currentWalletConnectV1Bridge;
|
|
41
|
+
if (walletConnectors) {
|
|
42
|
+
for (const connector of walletConnectors) {
|
|
43
|
+
const session = yield connector.getSession();
|
|
44
|
+
const bridge = session && (session === null || session === void 0 ? void 0 : session.bridge);
|
|
45
|
+
if (bridge) {
|
|
46
|
+
currentWalletConnectV1Bridge = bridge;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!walletConnectV1Bridge ||
|
|
52
|
+
!currentWalletConnectV1Bridge ||
|
|
53
|
+
walletConnectV1Bridge === currentWalletConnectV1Bridge) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
yield logout('connector bridge out of sync', {
|
|
57
|
+
newBridge: walletConnectV1Bridge,
|
|
58
|
+
oldBridge: currentWalletConnectV1Bridge,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
const hasWCV1Data = getLSKeys.getLSKeys().some((key) => key.startsWith('walletconnect') || key.startsWith('walletlink'));
|
|
62
|
+
const hasWCV2Data = getLSKeys.getLSKeys().some((key) => key.startsWith('wc@2'));
|
|
63
|
+
const handleConnectorVersionOutOfSync = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
if (!wcVersion ||
|
|
65
|
+
(wcVersion === 2 && !hasWCV1Data) ||
|
|
66
|
+
(wcVersion === 1 && !hasWCV2Data)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
yield logout('connector version out of sync', {
|
|
70
|
+
newVersion: wcVersion,
|
|
71
|
+
oldVersion: hasWCV1Data ? 1 : 2,
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
handleUserDataOutOfSync();
|
|
75
|
+
handleConnectorBridgeOutOfSync();
|
|
76
|
+
handleConnectorVersionOutOfSync();
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
exports.useValidateSession = useValidateSession;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UserProfile } from '../../../shared';
|
|
2
|
+
import { WalletConnector } from '../../../..';
|
|
3
|
+
type Props = {
|
|
4
|
+
handleLogOut: () => Promise<void>;
|
|
5
|
+
user: UserProfile | undefined;
|
|
6
|
+
authToken: string | undefined;
|
|
7
|
+
walletConnectV1Bridge: string | undefined;
|
|
8
|
+
walletConnectors: WalletConnector[] | undefined;
|
|
9
|
+
wcVersion: number | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const useValidateSession: ({ handleLogOut, user, authToken, walletConnectV1Bridge, walletConnectors, wcVersion, }: Props) => void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import '@dynamic-labs/sdk-api';
|
|
4
|
+
import { logger } from '../../../shared/logger.js';
|
|
5
|
+
import '../../../config/LSSuffix.js';
|
|
6
|
+
import { getLSKeys } from '../../../shared/utils/functions/storage/getLSKeys.js';
|
|
7
|
+
import '@dynamic-labs/iconic';
|
|
8
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
9
|
+
import 'react/jsx-runtime';
|
|
10
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import '@dynamic-labs/utils';
|
|
12
|
+
import '../../constants/colors.js';
|
|
13
|
+
import 'ethers';
|
|
14
|
+
import '../../../shared/consts/index.js';
|
|
15
|
+
|
|
16
|
+
const useValidateSession = ({ handleLogOut, user, authToken, walletConnectV1Bridge, walletConnectors, wcVersion, }) => {
|
|
17
|
+
const [hasLoggedOut, setHasLoggedOut] = useState(false);
|
|
18
|
+
if (hasLoggedOut) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const logout = (reason, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
setHasLoggedOut(true);
|
|
23
|
+
logger.debug(`Logging out - Reason: ${reason}`, Object.assign({}, params));
|
|
24
|
+
yield handleLogOut();
|
|
25
|
+
});
|
|
26
|
+
const handleUserDataOutOfSync = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
if (authToken || !user) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
yield logout('user data out of sync', {
|
|
31
|
+
authToken,
|
|
32
|
+
user,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
const handleConnectorBridgeOutOfSync = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
let currentWalletConnectV1Bridge;
|
|
37
|
+
if (walletConnectors) {
|
|
38
|
+
for (const connector of walletConnectors) {
|
|
39
|
+
const session = yield connector.getSession();
|
|
40
|
+
const bridge = session && (session === null || session === void 0 ? void 0 : session.bridge);
|
|
41
|
+
if (bridge) {
|
|
42
|
+
currentWalletConnectV1Bridge = bridge;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!walletConnectV1Bridge ||
|
|
48
|
+
!currentWalletConnectV1Bridge ||
|
|
49
|
+
walletConnectV1Bridge === currentWalletConnectV1Bridge) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
yield logout('connector bridge out of sync', {
|
|
53
|
+
newBridge: walletConnectV1Bridge,
|
|
54
|
+
oldBridge: currentWalletConnectV1Bridge,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
const hasWCV1Data = getLSKeys().some((key) => key.startsWith('walletconnect') || key.startsWith('walletlink'));
|
|
58
|
+
const hasWCV2Data = getLSKeys().some((key) => key.startsWith('wc@2'));
|
|
59
|
+
const handleConnectorVersionOutOfSync = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
if (!wcVersion ||
|
|
61
|
+
(wcVersion === 2 && !hasWCV1Data) ||
|
|
62
|
+
(wcVersion === 1 && !hasWCV2Data)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
yield logout('connector version out of sync', {
|
|
66
|
+
newVersion: wcVersion,
|
|
67
|
+
oldVersion: hasWCV1Data ? 1 : 2,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
handleUserDataOutOfSync();
|
|
71
|
+
handleConnectorBridgeOutOfSync();
|
|
72
|
+
handleConnectorVersionOutOfSync();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export { useValidateSession };
|
|
@@ -130,13 +130,13 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
130
130
|
};
|
|
131
131
|
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
132
132
|
const walletProvider = getWalletProvider.getWalletProvider(walletConnector);
|
|
133
|
-
const network = yield walletConnector.getNetwork();
|
|
134
|
-
const _isSupportedNetwork = isSupportedNetwork.isSupportedNetwork({
|
|
135
|
-
network,
|
|
136
|
-
walletConnector,
|
|
137
|
-
});
|
|
138
133
|
try {
|
|
139
134
|
const Jwt = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
135
|
+
const network = yield walletConnector.getNetwork();
|
|
136
|
+
const _isSupportedNetwork = isSupportedNetwork.isSupportedNetwork({
|
|
137
|
+
network,
|
|
138
|
+
walletConnector,
|
|
139
|
+
});
|
|
140
140
|
const decodedJwt = decodeJwt.decodeJwt(Jwt);
|
|
141
141
|
if (decodedJwt === undefined)
|
|
142
142
|
throw new utils.DynamicError('Invalid token!');
|
|
@@ -126,13 +126,13 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
126
126
|
};
|
|
127
127
|
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
128
|
const walletProvider = getWalletProvider(walletConnector);
|
|
129
|
-
const network = yield walletConnector.getNetwork();
|
|
130
|
-
const _isSupportedNetwork = isSupportedNetwork({
|
|
131
|
-
network,
|
|
132
|
-
walletConnector,
|
|
133
|
-
});
|
|
134
129
|
try {
|
|
135
130
|
const Jwt = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
131
|
+
const network = yield walletConnector.getNetwork();
|
|
132
|
+
const _isSupportedNetwork = isSupportedNetwork({
|
|
133
|
+
network,
|
|
134
|
+
walletConnector,
|
|
135
|
+
});
|
|
136
136
|
const decodedJwt = decodeJwt(Jwt);
|
|
137
137
|
if (decodedJwt === undefined)
|
|
138
138
|
throw new DynamicError('Invalid token!');
|