@dynamic-labs/sdk-react-core 0.18.0-RC.17 → 0.18.0-RC.19
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 +28 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/lib/context/DynamicContext/DynamicContext.cjs +10 -9
- package/src/lib/context/DynamicContext/DynamicContext.js +11 -10
- package/src/lib/context/DynamicContext/helpers.cjs +2 -2
- package/src/lib/context/DynamicContext/helpers.d.ts +2 -2
- package/src/lib/context/DynamicContext/helpers.js +2 -2
- package/src/lib/context/DynamicContext/types/index.d.ts +2 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -2
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext.js +2 -2
- package/src/lib/utils/constants/localStorage.cjs +3 -1
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +3 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +5 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +5 -2
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.cjs +4 -4
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.js +4 -4
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +22 -5
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.d.ts +8 -4
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +22 -5
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +10 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.18.0-RC.19](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.18...v0.18.0-RC.19) (2023-07-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* it updates the variable name isUserConnected to isFullyConnected
|
|
8
|
+
to better reflect its purpose in the codebase. user should be reserved for fully authenticated entities
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* Update WalletConnect wallet registry ([#2744](https://github.com/dynamic-labs/DynamicAuth/issues/2744)) ([46285ad](https://github.com/dynamic-labs/DynamicAuth/commit/46285adc77d12cdfe43d0ce1296308f4905fbfb5))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* missing field handling on email verification ([#2740](https://github.com/dynamic-labs/DynamicAuth/issues/2740)) ([3a42804](https://github.com/dynamic-labs/DynamicAuth/commit/3a428049a1f56a263135d636a335e597b3195b51))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
* rename isUserConnected to isFullyConnected ([#2739](https://github.com/dynamic-labs/DynamicAuth/issues/2739)) ([951780b](https://github.com/dynamic-labs/DynamicAuth/commit/951780be79acdc5191ffb8a6a525a2701832a2ad))
|
|
21
|
+
|
|
22
|
+
## [0.18.0-RC.18](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.17...v0.18.0-RC.18) (2023-07-24)
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* do not call connectSuccess when already connected ([#2705](https://github.com/dynamic-labs/DynamicAuth/issues/2705)) ([12a65fb](https://github.com/dynamic-labs/DynamicAuth/commit/12a65fb5e59a38de0f5fb0e7eab3ce3d558f201f))
|
|
27
|
+
* do not proceed to authSuccess if there are still missing fields ([#2712](https://github.com/dynamic-labs/DynamicAuth/issues/2712)) ([2fb10ed](https://github.com/dynamic-labs/DynamicAuth/commit/2fb10ed7f9c28476d61856887b517bdae10b80f4))
|
|
28
|
+
* add legacy safari detection ([#2733](https://github.com/dynamic-labs/DynamicAuth/issues/2733)) ([1b21c57](https://github.com/dynamic-labs/DynamicAuth/commit/1b21c57c1fd7c458f499cc09ef60364c314b0464))
|
|
29
|
+
|
|
2
30
|
## [0.18.0-RC.17](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.16...v0.18.0-RC.17) (2023-07-24)
|
|
3
31
|
|
|
4
32
|
|
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.0-RC.
|
|
3
|
+
"version": "0.18.0-RC.19",
|
|
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.18.0-RC.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "0.18.0-RC.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "0.18.0-RC.
|
|
22
|
-
"@dynamic-labs/types": "0.18.0-RC.
|
|
23
|
-
"@dynamic-labs/utils": "0.18.0-RC.
|
|
24
|
-
"@dynamic-labs/wallet-book": "0.18.0-RC.
|
|
25
|
-
"@dynamic-labs/wallet-connector-core": "0.18.0-RC.
|
|
19
|
+
"@dynamic-labs/logger": "0.18.0-RC.19",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "0.18.0-RC.19",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "0.18.0-RC.19",
|
|
22
|
+
"@dynamic-labs/types": "0.18.0-RC.19",
|
|
23
|
+
"@dynamic-labs/utils": "0.18.0-RC.19",
|
|
24
|
+
"@dynamic-labs/wallet-book": "0.18.0-RC.19",
|
|
25
|
+
"@dynamic-labs/wallet-connector-core": "0.18.0-RC.19"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"semver": "7.3.8"
|
|
@@ -116,7 +116,9 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
116
116
|
const [bridgeChainToConnect, setBridgeChainToConnect] = React.useState(undefined);
|
|
117
117
|
const [onboardingOnlyJwt, setOnboardingOnlyJwt] = React.useState(undefined);
|
|
118
118
|
const [showAuthFlow, setShowAuthFlow] = React.useState(false);
|
|
119
|
-
|
|
119
|
+
// state to track the full connectivity status of the individual's wallets.
|
|
120
|
+
// Set to true once the predetermined number of wallets is connected.
|
|
121
|
+
const [isFullyConnected, setIsFullyConnected, removeIsFullyConnected] = useLocalStorage.useLocalStorage(localStorage$1.IS_FULLY_CONNECTED, false);
|
|
120
122
|
const [walletsToConnectByChain, setWalletsToConnectByChain] = React.useState(walletsByChain);
|
|
121
123
|
// Allows clients to control widget flow without need to click on AccountControl
|
|
122
124
|
const [showDynamicUserProfile, setShowDynamicUserProfile] = React.useState(false);
|
|
@@ -277,7 +279,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
277
279
|
handleRemoveLsNetworks();
|
|
278
280
|
setOnboardingOnlyJwt(undefined);
|
|
279
281
|
removeConnectedWalletsInfo();
|
|
280
|
-
|
|
282
|
+
removeIsFullyConnected();
|
|
281
283
|
clearPrimaryWalletId();
|
|
282
284
|
removeConnectedNameService();
|
|
283
285
|
(_k = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLogout) === null || _k === void 0 ? void 0 : _k.call(eventsCallbacks, user);
|
|
@@ -292,7 +294,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
292
294
|
removeAuthTokenAndUser,
|
|
293
295
|
handleRemoveLsNetworks,
|
|
294
296
|
removeConnectedWalletsInfo,
|
|
295
|
-
|
|
297
|
+
removeIsFullyConnected,
|
|
296
298
|
clearPrimaryWalletId,
|
|
297
299
|
removeConnectedNameService,
|
|
298
300
|
eventsCallbacks,
|
|
@@ -355,7 +357,6 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
355
357
|
onLinkSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLinkSuccess,
|
|
356
358
|
onUserProfileUpdate: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onUserProfileUpdate,
|
|
357
359
|
},
|
|
358
|
-
connectedWallets,
|
|
359
360
|
handleLogOut,
|
|
360
361
|
isAuthenticated,
|
|
361
362
|
ongoingVerifications,
|
|
@@ -439,9 +440,9 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
439
440
|
: handleUnlinkWallet,
|
|
440
441
|
isAuthenticated,
|
|
441
442
|
isBridgeFlow,
|
|
443
|
+
isFullyConnected,
|
|
442
444
|
isProjectSettingsLoading,
|
|
443
445
|
isSingleWalletAccount,
|
|
444
|
-
isUserConnected,
|
|
445
446
|
linkedWallets,
|
|
446
447
|
loadingNetwork,
|
|
447
448
|
loginWithEmail,
|
|
@@ -470,8 +471,8 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
470
471
|
setAuthorizationViewDisplayOrder,
|
|
471
472
|
setBridgeChainToConnect,
|
|
472
473
|
setCallback,
|
|
473
|
-
setConnectedUser,
|
|
474
474
|
setDesktopUri,
|
|
475
|
+
setIsFullyConnected,
|
|
475
476
|
setIsSingleWalletAccount,
|
|
476
477
|
setLogInWithEmail,
|
|
477
478
|
setMultiWallet,
|
|
@@ -551,7 +552,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
551
552
|
isBridgeFlow,
|
|
552
553
|
isProjectSettingsLoading,
|
|
553
554
|
isSingleWalletAccount,
|
|
554
|
-
|
|
555
|
+
isFullyConnected,
|
|
555
556
|
primaryWallet,
|
|
556
557
|
secondaryWallets,
|
|
557
558
|
ongoingVerifications,
|
|
@@ -579,7 +580,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
579
580
|
setAuthMode,
|
|
580
581
|
setAuthorizationViewDisplayOrder,
|
|
581
582
|
setCallback,
|
|
582
|
-
|
|
583
|
+
setIsFullyConnected,
|
|
583
584
|
setLogInWithEmail,
|
|
584
585
|
setMultiWallet,
|
|
585
586
|
setMultiWalletWidgetState,
|
|
@@ -658,7 +659,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
658
659
|
return (jsxRuntime.jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsxRuntime.jsx(walletBook.WalletBookContextProvider, Object.assign({ walletBook: walletBook$1 }, { children: jsxRuntime.jsx(ThemeContext.ThemeContextProvider, Object.assign({ customerTheme: parseTheme.parseTheme(theme, ((_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _h === void 0 ? void 0 : _h.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: helpers.getInitialView({
|
|
659
660
|
connectedWallets,
|
|
660
661
|
isBridgeFlow,
|
|
661
|
-
|
|
662
|
+
isFullyConnected,
|
|
662
663
|
loginWithEmail,
|
|
663
664
|
}) }, { children: jsxRuntime.jsx(WalletContext.WalletContextProvider, Object.assign({ canSync: didConnectedStateLoad }, { 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.jsx(SendBalanceContext.SendBalanceContextProvider, { children: jsxRuntime.jsxs(WalletGroupContext.WalletGroupContextProvider, { children: [jsxRuntime.jsx(app.DynamicAuthFlow, {}), jsxRuntime.jsx(Toolkit.Toolkit, {}), jsxRuntime.jsx(FundingWidget.FundingWidget, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) })) })) }) })) })) })));
|
|
664
665
|
};
|
|
@@ -10,7 +10,7 @@ import { Toolkit } from '../../components/Toolkit/Toolkit.js';
|
|
|
10
10
|
import { decodeJwt } from '../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
11
11
|
import { ViewContextProvider } from '../ViewContext/ViewContext.js';
|
|
12
12
|
import { logger } from '../../shared/logger.js';
|
|
13
|
-
import { AUTH_TOKEN, AUTH_USER, AUTH_MODE, WALLET_PICKER_SEARCH_KEY } from '../../utils/constants/localStorage.js';
|
|
13
|
+
import { IS_FULLY_CONNECTED, AUTH_TOKEN, AUTH_USER, AUTH_MODE, WALLET_PICKER_SEARCH_KEY } from '../../utils/constants/localStorage.js';
|
|
14
14
|
import '../../utils/constants/colors.js';
|
|
15
15
|
import { DEFAULT_NUMBER_OF_WALLETS_TO_SHOW } from '../../utils/constants/values.js';
|
|
16
16
|
import { LocalStorage } from '../../shared/utils/classes/storage/localStorage.js';
|
|
@@ -112,7 +112,9 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
112
112
|
const [bridgeChainToConnect, setBridgeChainToConnect] = useState(undefined);
|
|
113
113
|
const [onboardingOnlyJwt, setOnboardingOnlyJwt] = useState(undefined);
|
|
114
114
|
const [showAuthFlow, setShowAuthFlow] = useState(false);
|
|
115
|
-
|
|
115
|
+
// state to track the full connectivity status of the individual's wallets.
|
|
116
|
+
// Set to true once the predetermined number of wallets is connected.
|
|
117
|
+
const [isFullyConnected, setIsFullyConnected, removeIsFullyConnected] = useLocalStorage(IS_FULLY_CONNECTED, false);
|
|
116
118
|
const [walletsToConnectByChain, setWalletsToConnectByChain] = useState(walletsByChain);
|
|
117
119
|
// Allows clients to control widget flow without need to click on AccountControl
|
|
118
120
|
const [showDynamicUserProfile, setShowDynamicUserProfile] = useState(false);
|
|
@@ -273,7 +275,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
273
275
|
handleRemoveLsNetworks();
|
|
274
276
|
setOnboardingOnlyJwt(undefined);
|
|
275
277
|
removeConnectedWalletsInfo();
|
|
276
|
-
|
|
278
|
+
removeIsFullyConnected();
|
|
277
279
|
clearPrimaryWalletId();
|
|
278
280
|
removeConnectedNameService();
|
|
279
281
|
(_k = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLogout) === null || _k === void 0 ? void 0 : _k.call(eventsCallbacks, user);
|
|
@@ -288,7 +290,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
288
290
|
removeAuthTokenAndUser,
|
|
289
291
|
handleRemoveLsNetworks,
|
|
290
292
|
removeConnectedWalletsInfo,
|
|
291
|
-
|
|
293
|
+
removeIsFullyConnected,
|
|
292
294
|
clearPrimaryWalletId,
|
|
293
295
|
removeConnectedNameService,
|
|
294
296
|
eventsCallbacks,
|
|
@@ -351,7 +353,6 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
351
353
|
onLinkSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLinkSuccess,
|
|
352
354
|
onUserProfileUpdate: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onUserProfileUpdate,
|
|
353
355
|
},
|
|
354
|
-
connectedWallets,
|
|
355
356
|
handleLogOut,
|
|
356
357
|
isAuthenticated,
|
|
357
358
|
ongoingVerifications,
|
|
@@ -435,9 +436,9 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
435
436
|
: handleUnlinkWallet,
|
|
436
437
|
isAuthenticated,
|
|
437
438
|
isBridgeFlow,
|
|
439
|
+
isFullyConnected,
|
|
438
440
|
isProjectSettingsLoading,
|
|
439
441
|
isSingleWalletAccount,
|
|
440
|
-
isUserConnected,
|
|
441
442
|
linkedWallets,
|
|
442
443
|
loadingNetwork,
|
|
443
444
|
loginWithEmail,
|
|
@@ -466,8 +467,8 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
466
467
|
setAuthorizationViewDisplayOrder,
|
|
467
468
|
setBridgeChainToConnect,
|
|
468
469
|
setCallback,
|
|
469
|
-
setConnectedUser,
|
|
470
470
|
setDesktopUri,
|
|
471
|
+
setIsFullyConnected,
|
|
471
472
|
setIsSingleWalletAccount,
|
|
472
473
|
setLogInWithEmail,
|
|
473
474
|
setMultiWallet,
|
|
@@ -547,7 +548,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
547
548
|
isBridgeFlow,
|
|
548
549
|
isProjectSettingsLoading,
|
|
549
550
|
isSingleWalletAccount,
|
|
550
|
-
|
|
551
|
+
isFullyConnected,
|
|
551
552
|
primaryWallet,
|
|
552
553
|
secondaryWallets,
|
|
553
554
|
ongoingVerifications,
|
|
@@ -575,7 +576,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
575
576
|
setAuthMode,
|
|
576
577
|
setAuthorizationViewDisplayOrder,
|
|
577
578
|
setCallback,
|
|
578
|
-
|
|
579
|
+
setIsFullyConnected,
|
|
579
580
|
setLogInWithEmail,
|
|
580
581
|
setMultiWallet,
|
|
581
582
|
setMultiWalletWidgetState,
|
|
@@ -654,7 +655,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
654
655
|
return (jsx(DynamicContext.Provider, Object.assign({ value: value }, { children: jsx(WalletBookContextProvider, Object.assign({ walletBook: walletBook }, { children: jsx(ThemeContextProvider, Object.assign({ customerTheme: parseTheme(theme, ((_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design) === null || _h === void 0 ? void 0 : _h.modal) || undefined), designSettings: projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design }, { children: jsx(LoadingContextProvider, { children: jsx(ViewContextProvider, Object.assign({ initialView: getInitialView({
|
|
655
656
|
connectedWallets,
|
|
656
657
|
isBridgeFlow,
|
|
657
|
-
|
|
658
|
+
isFullyConnected,
|
|
658
659
|
loginWithEmail,
|
|
659
660
|
}) }, { children: jsx(WalletContextProvider, Object.assign({ canSync: didConnectedStateLoad }, { 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: jsx(SendBalanceContextProvider, { children: jsxs(WalletGroupContextProvider, { children: [jsx(DynamicAuthFlow, {}), jsx(Toolkit, {}), jsx(FundingWidget, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) })) })) }) })) })) })));
|
|
660
661
|
};
|
|
@@ -54,11 +54,11 @@ const initExpirationTime = (logout) => {
|
|
|
54
54
|
const expiryTimeout = Math.min(expirationTimeInMs, 2147483647);
|
|
55
55
|
logoutTimer = setTimeout(logout, expiryTimeout);
|
|
56
56
|
};
|
|
57
|
-
const getInitialView = ({ connectedWallets, loginWithEmail, isBridgeFlow,
|
|
57
|
+
const getInitialView = ({ connectedWallets, loginWithEmail, isBridgeFlow, isFullyConnected, }) => {
|
|
58
58
|
if (loginWithEmail) {
|
|
59
59
|
return 'login-with-email-or-wallet';
|
|
60
60
|
}
|
|
61
|
-
if (
|
|
61
|
+
if (isFullyConnected) {
|
|
62
62
|
return 'wallet-list';
|
|
63
63
|
}
|
|
64
64
|
if (isBridgeFlow && !connectedWallets.length) {
|
|
@@ -2,9 +2,9 @@ import { Wallet } from '../../shared';
|
|
|
2
2
|
import { ViewType } from '../ViewContext';
|
|
3
3
|
export declare const isAuthTokenExpired: (token: string) => boolean;
|
|
4
4
|
export declare const initExpirationTime: (logout: VoidFunction) => void;
|
|
5
|
-
export declare const getInitialView: ({ connectedWallets, loginWithEmail, isBridgeFlow,
|
|
5
|
+
export declare const getInitialView: ({ connectedWallets, loginWithEmail, isBridgeFlow, isFullyConnected, }: {
|
|
6
6
|
connectedWallets: Wallet[];
|
|
7
7
|
loginWithEmail: boolean;
|
|
8
8
|
isBridgeFlow: boolean;
|
|
9
|
-
|
|
9
|
+
isFullyConnected: boolean;
|
|
10
10
|
}) => ViewType;
|
|
@@ -50,11 +50,11 @@ const initExpirationTime = (logout) => {
|
|
|
50
50
|
const expiryTimeout = Math.min(expirationTimeInMs, 2147483647);
|
|
51
51
|
logoutTimer = setTimeout(logout, expiryTimeout);
|
|
52
52
|
};
|
|
53
|
-
const getInitialView = ({ connectedWallets, loginWithEmail, isBridgeFlow,
|
|
53
|
+
const getInitialView = ({ connectedWallets, loginWithEmail, isBridgeFlow, isFullyConnected, }) => {
|
|
54
54
|
if (loginWithEmail) {
|
|
55
55
|
return 'login-with-email-or-wallet';
|
|
56
56
|
}
|
|
57
|
-
if (
|
|
57
|
+
if (isFullyConnected) {
|
|
58
58
|
return 'wallet-list';
|
|
59
59
|
}
|
|
60
60
|
if (isBridgeFlow && !connectedWallets.length) {
|
|
@@ -43,8 +43,8 @@ export interface IDynamicContext {
|
|
|
43
43
|
connectedWallet: Wallet | null;
|
|
44
44
|
connectedWallets: Wallet[];
|
|
45
45
|
linkedWallets: Wallet[];
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
isFullyConnected: boolean;
|
|
47
|
+
setIsFullyConnected: (value: boolean | ((val: boolean) => boolean)) => void;
|
|
48
48
|
consumeNonce: () => string | undefined;
|
|
49
49
|
cssOverrides?: string | JSX.Element;
|
|
50
50
|
customPrivacyPolicy?: ReactNode;
|
|
@@ -11,7 +11,7 @@ const useDynamicContext = () => {
|
|
|
11
11
|
if (context === undefined) {
|
|
12
12
|
throw new Error('useDynamicContext must be used within a DynamicContextProvider');
|
|
13
13
|
}
|
|
14
|
-
const { accountSwitchState, authMode, authToken, awaitingSignatureState, connectedWallets, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated,
|
|
14
|
+
const { accountSwitchState, authMode, authToken, awaitingSignatureState, connectedWallets, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, isFullyConnected, linkedWallets, loadingNetwork, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, rpcProviders, sdkHasLoaded, secondaryWallets, setLogInWithEmail, setMultiWalletWidgetState, setNetwork, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, ongoingVerifications, walletConnector, wallets, walletsByChain, walletsToConnectByChain, primaryWallet, } = context;
|
|
15
15
|
return {
|
|
16
16
|
accountSwitchState,
|
|
17
17
|
authMode,
|
|
@@ -22,7 +22,7 @@ const useDynamicContext = () => {
|
|
|
22
22
|
handleLogOut,
|
|
23
23
|
handleUnlinkWallet,
|
|
24
24
|
isAuthenticated,
|
|
25
|
-
|
|
25
|
+
isFullyConnected,
|
|
26
26
|
linkedWallets,
|
|
27
27
|
loadingNetwork,
|
|
28
28
|
loginWithEmail,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDynamicContext } from './types';
|
|
2
|
-
export type UseDynamicContext = Pick<IDynamicContext, 'accountSwitchState' | 'authMode' | 'authToken' | 'awaitingSignatureState' | 'connectedWallets' | 'getNameService' | 'handleLogOut' | 'handleUnlinkWallet' | 'isAuthenticated' | '
|
|
2
|
+
export type UseDynamicContext = Pick<IDynamicContext, 'accountSwitchState' | 'authMode' | 'authToken' | 'awaitingSignatureState' | 'connectedWallets' | 'getNameService' | 'handleLogOut' | 'handleUnlinkWallet' | 'isAuthenticated' | 'isFullyConnected' | 'linkedWallets' | 'loadingNetwork' | 'loginWithEmail' | 'multiWalletWidgetState' | 'network' | 'networkConfigurations' | 'primaryWallet' | 'qrcodeUri' | 'rpcProviders' | 'sdkHasLoaded' | 'secondaryWallets' | 'setLogInWithEmail' | 'setMultiWalletWidgetState' | 'setNetwork' | 'setPrimaryWallet' | 'setShowAuthFlow' | 'setShowDynamicUserProfile' | 'setShowQrcodeModal' | 'shadowDOMEnabled' | 'showAuthFlow' | 'showQrcodeModal' | 'user' | 'walletConnector' | 'wallets' | 'walletsByChain' | 'walletsToConnectByChain'> & {
|
|
3
3
|
ongoingVerifications: Pick<IDynamicContext['ongoingVerifications'], 'authVerification' | 'connectAndSignVerification'>;
|
|
4
4
|
};
|
|
5
5
|
export declare const useDynamicContext: () => UseDynamicContext;
|
|
@@ -7,7 +7,7 @@ const useDynamicContext = () => {
|
|
|
7
7
|
if (context === undefined) {
|
|
8
8
|
throw new Error('useDynamicContext must be used within a DynamicContextProvider');
|
|
9
9
|
}
|
|
10
|
-
const { accountSwitchState, authMode, authToken, awaitingSignatureState, connectedWallets, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated,
|
|
10
|
+
const { accountSwitchState, authMode, authToken, awaitingSignatureState, connectedWallets, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, isFullyConnected, linkedWallets, loadingNetwork, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, rpcProviders, sdkHasLoaded, secondaryWallets, setLogInWithEmail, setMultiWalletWidgetState, setNetwork, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, ongoingVerifications, walletConnector, wallets, walletsByChain, walletsToConnectByChain, primaryWallet, } = context;
|
|
11
11
|
return {
|
|
12
12
|
accountSwitchState,
|
|
13
13
|
authMode,
|
|
@@ -18,7 +18,7 @@ const useDynamicContext = () => {
|
|
|
18
18
|
handleLogOut,
|
|
19
19
|
handleUnlinkWallet,
|
|
20
20
|
isAuthenticated,
|
|
21
|
-
|
|
21
|
+
isFullyConnected,
|
|
22
22
|
linkedWallets,
|
|
23
23
|
loadingNetwork,
|
|
24
24
|
loginWithEmail,
|
|
@@ -13,13 +13,15 @@ const WALLET_PICKER_SEARCH_KEY = 'dynamic_wallet_picker_search';
|
|
|
13
13
|
const NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY = 'dynamic_newtoweb3_wallet_extension_installed';
|
|
14
14
|
const CONNECTED_WALLETS_INFO = 'dynamic_connected_wallets';
|
|
15
15
|
const AUTH_MODE = 'dynamic_auth_mode';
|
|
16
|
-
const CONNECTED_WALLET_NAME_SERVICE = 'dynamic_connected_wallet_ns';
|
|
16
|
+
const CONNECTED_WALLET_NAME_SERVICE = 'dynamic_connected_wallet_ns';
|
|
17
|
+
const IS_FULLY_CONNECTED = 'dynamic_fully_connected';
|
|
17
18
|
|
|
18
19
|
exports.AUTH_MODE = AUTH_MODE;
|
|
19
20
|
exports.AUTH_TOKEN = AUTH_TOKEN;
|
|
20
21
|
exports.AUTH_USER = AUTH_USER;
|
|
21
22
|
exports.CONNECTED_WALLETS_INFO = CONNECTED_WALLETS_INFO;
|
|
22
23
|
exports.CONNECTED_WALLET_NAME_SERVICE = CONNECTED_WALLET_NAME_SERVICE;
|
|
24
|
+
exports.IS_FULLY_CONNECTED = IS_FULLY_CONNECTED;
|
|
23
25
|
exports.LAST_USED_WALLET = LAST_USED_WALLET;
|
|
24
26
|
exports.NETWORKS_STORAGE_KEY = NETWORKS_STORAGE_KEY;
|
|
25
27
|
exports.NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY = NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY;
|
|
@@ -11,3 +11,4 @@ export declare const NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY = "dynamic_newtoweb3_wa
|
|
|
11
11
|
export declare const CONNECTED_WALLETS_INFO = "dynamic_connected_wallets";
|
|
12
12
|
export declare const AUTH_MODE = "dynamic_auth_mode";
|
|
13
13
|
export declare const CONNECTED_WALLET_NAME_SERVICE = "dynamic_connected_wallet_ns";
|
|
14
|
+
export declare const IS_FULLY_CONNECTED = "dynamic_fully_connected";
|
|
@@ -9,6 +9,7 @@ const WALLET_PICKER_SEARCH_KEY = 'dynamic_wallet_picker_search';
|
|
|
9
9
|
const NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY = 'dynamic_newtoweb3_wallet_extension_installed';
|
|
10
10
|
const CONNECTED_WALLETS_INFO = 'dynamic_connected_wallets';
|
|
11
11
|
const AUTH_MODE = 'dynamic_auth_mode';
|
|
12
|
-
const CONNECTED_WALLET_NAME_SERVICE = 'dynamic_connected_wallet_ns';
|
|
12
|
+
const CONNECTED_WALLET_NAME_SERVICE = 'dynamic_connected_wallet_ns';
|
|
13
|
+
const IS_FULLY_CONNECTED = 'dynamic_fully_connected';
|
|
13
14
|
|
|
14
|
-
export { AUTH_MODE, AUTH_TOKEN, AUTH_USER, CONNECTED_WALLETS_INFO, CONNECTED_WALLET_NAME_SERVICE, LAST_USED_WALLET, NETWORKS_STORAGE_KEY, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, NONCE_STORAGE_KEY, PRIMARY_WALLET_ID, PROJECT_SETTINGS_STORAGE_KEY, WALLET_PICKER_SEARCH_KEY };
|
|
15
|
+
export { AUTH_MODE, AUTH_TOKEN, AUTH_USER, CONNECTED_WALLETS_INFO, CONNECTED_WALLET_NAME_SERVICE, IS_FULLY_CONNECTED, LAST_USED_WALLET, NETWORKS_STORAGE_KEY, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, NONCE_STORAGE_KEY, PRIMARY_WALLET_ID, PROJECT_SETTINGS_STORAGE_KEY, WALLET_PICKER_SEARCH_KEY };
|
|
@@ -32,7 +32,7 @@ const useConnectAndSign = () => {
|
|
|
32
32
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
33
33
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
34
34
|
const { captchaToken } = CaptchaContext.useCaptchaContext();
|
|
35
|
-
const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, ongoingVerifications, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
35
|
+
const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, ongoingVerifications, isFullyConnected, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
36
36
|
const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
|
|
37
37
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
38
38
|
consumeNonce,
|
|
@@ -56,7 +56,6 @@ const useConnectAndSign = () => {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
const publicWalletAddress = yield connectWallet(walletConnector, fetchPublicAddressOpts);
|
|
59
|
-
setCallback('connectSuccess');
|
|
60
59
|
const walletNetwork = yield walletConnector.getNetwork();
|
|
61
60
|
const usesSupportedNetwork = isSupportedNetwork.isSupportedNetwork({
|
|
62
61
|
network: walletNetwork,
|
|
@@ -71,8 +70,12 @@ const useConnectAndSign = () => {
|
|
|
71
70
|
if (isConnectOnly.isConnectOnly(user, authMode)) {
|
|
72
71
|
localStorage.LocalStorage.setToLS(localStorage$1.LAST_USED_WALLET, walletConnector.name);
|
|
73
72
|
handleWalletsToConnect();
|
|
73
|
+
if (!isFullyConnected) {
|
|
74
|
+
setCallback('connectSuccess');
|
|
75
|
+
}
|
|
74
76
|
return;
|
|
75
77
|
}
|
|
78
|
+
setCallback('connectSuccess');
|
|
76
79
|
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
77
80
|
setView('captcha');
|
|
78
81
|
return;
|
|
@@ -28,7 +28,7 @@ const useConnectAndSign = () => {
|
|
|
28
28
|
const { setView, goToInitialView } = useViewContext();
|
|
29
29
|
const { setErrorMessage } = useErrorContext();
|
|
30
30
|
const { captchaToken } = useCaptchaContext();
|
|
31
|
-
const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, ongoingVerifications, } = useInternalDynamicContext();
|
|
31
|
+
const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, ongoingVerifications, isFullyConnected, } = useInternalDynamicContext();
|
|
32
32
|
const { handleWalletsToConnect } = useHandleWalletsToConnect();
|
|
33
33
|
const verifyWallet = useVerifyWallet({
|
|
34
34
|
consumeNonce,
|
|
@@ -52,7 +52,6 @@ const useConnectAndSign = () => {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
const publicWalletAddress = yield connectWallet(walletConnector, fetchPublicAddressOpts);
|
|
55
|
-
setCallback('connectSuccess');
|
|
56
55
|
const walletNetwork = yield walletConnector.getNetwork();
|
|
57
56
|
const usesSupportedNetwork = isSupportedNetwork({
|
|
58
57
|
network: walletNetwork,
|
|
@@ -67,8 +66,12 @@ const useConnectAndSign = () => {
|
|
|
67
66
|
if (isConnectOnly(user, authMode)) {
|
|
68
67
|
LocalStorage.setToLS(LAST_USED_WALLET, walletConnector.name);
|
|
69
68
|
handleWalletsToConnect();
|
|
69
|
+
if (!isFullyConnected) {
|
|
70
|
+
setCallback('connectSuccess');
|
|
71
|
+
}
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
74
|
+
setCallback('connectSuccess');
|
|
72
75
|
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
73
76
|
setView('captcha');
|
|
74
77
|
return;
|
|
@@ -6,11 +6,11 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useInte
|
|
|
6
6
|
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
7
7
|
|
|
8
8
|
const useHandleWalletsToConnect = () => {
|
|
9
|
-
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow,
|
|
9
|
+
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow, setIsFullyConnected, isFullyConnected, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
10
10
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
11
11
|
const handleWalletsToConnect = () => {
|
|
12
12
|
if (!walletsToConnectByChain) {
|
|
13
|
-
|
|
13
|
+
setIsFullyConnected(true);
|
|
14
14
|
setShowAuthFlow(false);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -32,8 +32,8 @@ const useHandleWalletsToConnect = () => {
|
|
|
32
32
|
setWalletsToConnectByChain(restOfTheWallets);
|
|
33
33
|
const allWalletsConnected = restOfTheWallets.length === 0;
|
|
34
34
|
if (allWalletsConnected) {
|
|
35
|
-
if (!
|
|
36
|
-
|
|
35
|
+
if (!isFullyConnected) {
|
|
36
|
+
setIsFullyConnected(true);
|
|
37
37
|
setView('bridge-summary');
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
@@ -2,11 +2,11 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useIn
|
|
|
2
2
|
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
3
3
|
|
|
4
4
|
const useHandleWalletsToConnect = () => {
|
|
5
|
-
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow,
|
|
5
|
+
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow, setIsFullyConnected, isFullyConnected, } = useInternalDynamicContext();
|
|
6
6
|
const { setView, goToInitialView } = useViewContext();
|
|
7
7
|
const handleWalletsToConnect = () => {
|
|
8
8
|
if (!walletsToConnectByChain) {
|
|
9
|
-
|
|
9
|
+
setIsFullyConnected(true);
|
|
10
10
|
setShowAuthFlow(false);
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
@@ -28,8 +28,8 @@ const useHandleWalletsToConnect = () => {
|
|
|
28
28
|
setWalletsToConnectByChain(restOfTheWallets);
|
|
29
29
|
const allWalletsConnected = restOfTheWallets.length === 0;
|
|
30
30
|
if (allWalletsConnected) {
|
|
31
|
-
if (!
|
|
32
|
-
|
|
31
|
+
if (!isFullyConnected) {
|
|
32
|
+
setIsFullyConnected(true);
|
|
33
33
|
setView('bridge-summary');
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
@@ -11,6 +11,18 @@ var isEmailVerificationRequired = require('../../functions/authenication/isEmail
|
|
|
11
11
|
var EmailVerificationContext = require('../../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
12
12
|
var useEmailVerificationRequest = require('../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs');
|
|
13
13
|
var useUpdateUserProfileByJWTCallback = require('../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
|
|
14
|
+
var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
15
|
+
require('@dynamic-labs/iconic');
|
|
16
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
17
|
+
require('react/jsx-runtime');
|
|
18
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
19
|
+
require('../../../shared/logger.cjs');
|
|
20
|
+
require('@dynamic-labs/wallet-book');
|
|
21
|
+
require('@dynamic-labs/utils');
|
|
22
|
+
require('../../constants/colors.cjs');
|
|
23
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
24
|
+
require('ethers');
|
|
25
|
+
require('../../../shared/consts/index.cjs');
|
|
14
26
|
|
|
15
27
|
// User Fields Schema without captchaToken and policiesConsent properties
|
|
16
28
|
const userFieldsSchema = yup.object().shape({
|
|
@@ -33,23 +45,27 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
33
45
|
const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest.useEmailVerificationRequest();
|
|
34
46
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
35
47
|
const updateUser = React.useCallback((userFields, userEnvironmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
var _a, _b;
|
|
48
|
+
var _a, _b, _c;
|
|
37
49
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
38
50
|
stripUnknown: validationSchemaStripUnknown,
|
|
39
51
|
});
|
|
40
52
|
const updateUserProfileResponse = yield api.updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
|
|
53
|
+
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
54
|
+
const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
|
|
55
|
+
const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
|
|
41
56
|
const _isEmailVerificationRequired = isEmailVerificationRequired.isEmailVerificationRequired(updateUserProfileResponse);
|
|
42
57
|
if (!_isEmailVerificationRequired) {
|
|
43
58
|
// If email verification is not needed then we can update the user profile immediately.
|
|
44
59
|
yield updateUserProfileByJWT(updateUserProfileResponse.jwt);
|
|
45
60
|
return {
|
|
46
|
-
isEmailVerificationRequired:
|
|
61
|
+
isEmailVerificationRequired: false,
|
|
62
|
+
missingFields,
|
|
47
63
|
updateUserProfileResponse,
|
|
48
64
|
};
|
|
49
65
|
}
|
|
50
66
|
// We update EmailContext to use this information in the Email Verification view
|
|
51
|
-
setEmail((
|
|
52
|
-
setVerificationUUID((
|
|
67
|
+
setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
|
|
68
|
+
setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
|
|
53
69
|
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
54
70
|
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
55
71
|
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
@@ -58,7 +74,8 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
58
74
|
return verifyEmailFn(verificationToken, (_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.verificationUUID);
|
|
59
75
|
};
|
|
60
76
|
return {
|
|
61
|
-
isEmailVerificationRequired:
|
|
77
|
+
isEmailVerificationRequired: true,
|
|
78
|
+
missingFields,
|
|
62
79
|
updateUserProfileResponse,
|
|
63
80
|
verifyEmailFn: scopedVerifyEmailFn,
|
|
64
81
|
};
|
|
@@ -4,22 +4,26 @@ export declare const useUserUpdateRequestInternal: ({ validationSchemaStripUnkno
|
|
|
4
4
|
validationSchemaStripUnknown: boolean;
|
|
5
5
|
}) => {
|
|
6
6
|
updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
|
|
7
|
-
isEmailVerificationRequired:
|
|
7
|
+
isEmailVerificationRequired: boolean;
|
|
8
|
+
missingFields: import("@dynamic-labs/sdk-api").ProjectSettingsKyc[];
|
|
8
9
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
9
10
|
verifyEmailFn?: undefined;
|
|
10
11
|
} | {
|
|
11
|
-
isEmailVerificationRequired:
|
|
12
|
+
isEmailVerificationRequired: boolean;
|
|
13
|
+
missingFields: import("@dynamic-labs/sdk-api").ProjectSettingsKyc[];
|
|
12
14
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
13
15
|
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
14
16
|
}>;
|
|
15
17
|
};
|
|
16
18
|
export declare const useUserUpdateRequest: () => {
|
|
17
19
|
updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
|
|
18
|
-
isEmailVerificationRequired:
|
|
20
|
+
isEmailVerificationRequired: boolean;
|
|
21
|
+
missingFields: import("@dynamic-labs/sdk-api").ProjectSettingsKyc[];
|
|
19
22
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
20
23
|
verifyEmailFn?: undefined;
|
|
21
24
|
} | {
|
|
22
|
-
isEmailVerificationRequired:
|
|
25
|
+
isEmailVerificationRequired: boolean;
|
|
26
|
+
missingFields: import("@dynamic-labs/sdk-api").ProjectSettingsKyc[];
|
|
23
27
|
updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
|
|
24
28
|
verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
|
|
25
29
|
}>;
|
|
@@ -7,6 +7,18 @@ import { isEmailVerificationRequired } from '../../functions/authenication/isEma
|
|
|
7
7
|
import { useEmailVerificationContext } from '../../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
8
8
|
import { useEmailVerificationRequest } from '../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js';
|
|
9
9
|
import { useUpdateUserProfileByJWTCallback } from '../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js';
|
|
10
|
+
import { decodeJwt } from '../../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
11
|
+
import '@dynamic-labs/iconic';
|
|
12
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
13
|
+
import 'react/jsx-runtime';
|
|
14
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
15
|
+
import '../../../shared/logger.js';
|
|
16
|
+
import '@dynamic-labs/wallet-book';
|
|
17
|
+
import '@dynamic-labs/utils';
|
|
18
|
+
import '../../constants/colors.js';
|
|
19
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
20
|
+
import 'ethers';
|
|
21
|
+
import '../../../shared/consts/index.js';
|
|
10
22
|
|
|
11
23
|
// User Fields Schema without captchaToken and policiesConsent properties
|
|
12
24
|
const userFieldsSchema = object().shape({
|
|
@@ -29,23 +41,27 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
29
41
|
const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest();
|
|
30
42
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
31
43
|
const updateUser = useCallback((userFields, userEnvironmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
var _a, _b;
|
|
44
|
+
var _a, _b, _c;
|
|
33
45
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
34
46
|
stripUnknown: validationSchemaStripUnknown,
|
|
35
47
|
});
|
|
36
48
|
const updateUserProfileResponse = yield updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
|
|
49
|
+
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
50
|
+
const decodedJwt = decodeJwt(updateUserProfileResponse.jwt);
|
|
51
|
+
const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
|
|
37
52
|
const _isEmailVerificationRequired = isEmailVerificationRequired(updateUserProfileResponse);
|
|
38
53
|
if (!_isEmailVerificationRequired) {
|
|
39
54
|
// If email verification is not needed then we can update the user profile immediately.
|
|
40
55
|
yield updateUserProfileByJWT(updateUserProfileResponse.jwt);
|
|
41
56
|
return {
|
|
42
|
-
isEmailVerificationRequired:
|
|
57
|
+
isEmailVerificationRequired: false,
|
|
58
|
+
missingFields,
|
|
43
59
|
updateUserProfileResponse,
|
|
44
60
|
};
|
|
45
61
|
}
|
|
46
62
|
// We update EmailContext to use this information in the Email Verification view
|
|
47
|
-
setEmail((
|
|
48
|
-
setVerificationUUID((
|
|
63
|
+
setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
|
|
64
|
+
setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
|
|
49
65
|
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
50
66
|
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
51
67
|
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
@@ -54,7 +70,8 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
54
70
|
return verifyEmailFn(verificationToken, (_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.verificationUUID);
|
|
55
71
|
};
|
|
56
72
|
return {
|
|
57
|
-
isEmailVerificationRequired:
|
|
73
|
+
isEmailVerificationRequired: true,
|
|
74
|
+
missingFields,
|
|
58
75
|
updateUserProfileResponse,
|
|
59
76
|
verifyEmailFn: scopedVerifyEmailFn,
|
|
60
77
|
};
|
|
@@ -48,17 +48,24 @@ var useUserDataForm = require('../../../utils/hooks/useUserDataForm/useUserDataF
|
|
|
48
48
|
|
|
49
49
|
const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
|
|
50
50
|
const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
51
|
-
const { setView } = ViewContext.useViewContext();
|
|
51
|
+
const { setView, view } = ViewContext.useViewContext();
|
|
52
52
|
const decodedJwt = decodeJwt.decodeJwt(onboardingOnlyJwt);
|
|
53
53
|
const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
|
|
54
54
|
validationSchemaStripUnknown: false,
|
|
55
55
|
});
|
|
56
56
|
const onSubmit = React.useCallback((formValues) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
-
const { isEmailVerificationRequired } = yield updateUser(formValues);
|
|
58
|
-
if (isEmailVerificationRequired
|
|
57
|
+
const { isEmailVerificationRequired, missingFields } = yield updateUser(formValues);
|
|
58
|
+
if (isEmailVerificationRequired &&
|
|
59
|
+
missingFields.map((field) => field.name).toString() === 'email') {
|
|
59
60
|
setView('verify-email');
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
63
|
+
else if (missingFields.length > 0) {
|
|
64
|
+
// make sure we capture the fields that are required and still missing!
|
|
65
|
+
// do not change the view, just use the current one
|
|
66
|
+
setView(view);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
62
69
|
setShowAuthFlow(false);
|
|
63
70
|
setCallback('authSuccess');
|
|
64
71
|
}), [setCallback, setShowAuthFlow, setView, updateUser]);
|
|
@@ -44,17 +44,24 @@ import { useUserDataForm } from '../../../utils/hooks/useUserDataForm/useUserDat
|
|
|
44
44
|
|
|
45
45
|
const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
|
|
46
46
|
const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
|
|
47
|
-
const { setView } = useViewContext();
|
|
47
|
+
const { setView, view } = useViewContext();
|
|
48
48
|
const decodedJwt = decodeJwt(onboardingOnlyJwt);
|
|
49
49
|
const { updateUser } = useUserUpdateRequestInternal({
|
|
50
50
|
validationSchemaStripUnknown: false,
|
|
51
51
|
});
|
|
52
52
|
const onSubmit = useCallback((formValues) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
const { isEmailVerificationRequired } = yield updateUser(formValues);
|
|
54
|
-
if (isEmailVerificationRequired
|
|
53
|
+
const { isEmailVerificationRequired, missingFields } = yield updateUser(formValues);
|
|
54
|
+
if (isEmailVerificationRequired &&
|
|
55
|
+
missingFields.map((field) => field.name).toString() === 'email') {
|
|
55
56
|
setView('verify-email');
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
59
|
+
else if (missingFields.length > 0) {
|
|
60
|
+
// make sure we capture the fields that are required and still missing!
|
|
61
|
+
// do not change the view, just use the current one
|
|
62
|
+
setView(view);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
58
65
|
setShowAuthFlow(false);
|
|
59
66
|
setCallback('authSuccess');
|
|
60
67
|
}), [setCallback, setShowAuthFlow, setView, updateUser]);
|