@dynamic-labs/sdk-react-core 0.18.100-viem.2 → 0.18.100-viem.21
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 +179 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +10 -10
- package/src/index.cjs +3 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
- package/src/lib/components/MenuList/Dropdown/Dropdown.cjs +1 -1
- package/src/lib/components/MenuList/Dropdown/Dropdown.js +1 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.cjs +6 -2
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.d.ts +2 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.js +6 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +2 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +2 -2
- package/src/lib/components/SignMessagePreview/SignMessagePreview.cjs +27 -0
- package/src/lib/components/SignMessagePreview/SignMessagePreview.d.ts +6 -0
- package/src/lib/components/SignMessagePreview/SignMessagePreview.js +23 -0
- package/src/lib/components/SignMessagePreview/SignMessagePreview.types.d.ts +8 -0
- package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/SignTypedDataPreview.cjs +44 -0
- package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/SignTypedDataPreview.d.ts +8 -0
- package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/SignTypedDataPreview.js +40 -0
- package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/components/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/isSignTypedData/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/isSignTypedData/isSignTypedData.cjs +17 -0
- package/src/lib/components/SignMessagePreview/utils/isSignTypedData/isSignTypedData.d.ts +2 -0
- package/src/lib/components/SignMessagePreview/utils/isSignTypedData/isSignTypedData.js +13 -0
- package/src/lib/components/Typography/Typography.cjs +1 -0
- package/src/lib/components/Typography/Typography.js +1 -0
- package/src/lib/components/Typography/Typography.types.d.ts +1 -1
- package/src/lib/components/UserProfile/UserProfile.cjs +1 -1
- package/src/lib/components/UserProfile/UserProfile.js +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -1
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +22 -7
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +11 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +23 -8
- package/src/lib/context/DynamicContext/helpers.cjs +42 -3
- package/src/lib/context/DynamicContext/helpers.d.ts +7 -1
- package/src/lib/context/DynamicContext/helpers.js +38 -4
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.cjs +5 -2
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.d.ts +4 -2
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.js +5 -2
- package/src/lib/context/DynamicContext/internalEvents/index.d.ts +2 -0
- package/src/lib/context/DynamicContext/internalEvents/internalEvents.cjs +14 -0
- package/src/lib/context/DynamicContext/internalEvents/internalEvents.d.ts +8 -0
- package/src/lib/context/DynamicContext/internalEvents/internalEvents.js +6 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +7 -1
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext.js +2 -1
- package/src/lib/context/ErrorContext/ErrorContext.cjs +1 -0
- package/src/lib/context/ErrorContext/ErrorContext.js +1 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +2 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +2 -1
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/context/WalletContext/WalletContext.cjs +2 -16
- package/src/lib/context/WalletContext/WalletContext.js +2 -16
- package/src/lib/data/api.cjs +37 -13
- package/src/lib/data/api.d.ts +5 -3
- package/src/lib/data/api.js +37 -14
- package/src/lib/main.global.cjs +1 -1
- package/src/lib/main.global.js +1 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +2 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +2 -1
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +2 -1
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +2 -1
- package/src/lib/shared/types/index.d.ts +4 -0
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.cjs +28 -2
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.js +28 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/localStorage.cjs +4 -0
- package/src/lib/utils/constants/localStorage.d.ts +2 -0
- package/src/lib/utils/constants/localStorage.js +3 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.cjs +1 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.js +1 -1
- package/src/lib/utils/functions/digestSHA256/digestSHA256.cjs +11 -0
- package/src/lib/utils/functions/digestSHA256/digestSHA256.d.ts +1 -0
- package/src/lib/utils/functions/digestSHA256/digestSHA256.js +7 -0
- package/src/lib/utils/functions/digestSHA256/index.d.ts +1 -0
- package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.cjs +14 -0
- package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.d.ts +1 -0
- package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.js +10 -0
- package/src/lib/utils/functions/encodeBase64URL/index.d.ts +1 -0
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.cjs +6 -1
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.js +6 -1
- package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.cjs +33 -0
- package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.d.ts +1 -0
- package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.js +29 -0
- package/src/lib/utils/functions/getRedirectURIOrigin/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +6 -0
- package/src/lib/utils/functions/randomString/index.d.ts +1 -0
- package/src/lib/utils/functions/randomString/randomString.cjs +14 -0
- package/src/lib/utils/functions/randomString/randomString.d.ts +1 -0
- package/src/lib/utils/functions/randomString/randomString.js +10 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +1 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +48 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +18 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +43 -0
- package/src/lib/utils/functions/stringifyURIQuery/index.d.ts +1 -0
- package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.cjs +13 -0
- package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.d.ts +1 -0
- package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.js +9 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +10 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +10 -5
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +6 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +6 -2
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +13 -4
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -19
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +13 -4
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +22 -32
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +23 -33
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +7 -6
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +7 -6
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +10 -1
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +10 -1
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.cjs +15 -1
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.js +15 -1
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +6 -2
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +2 -1
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +132 -24
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +5 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +134 -26
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +13 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +13 -3
- package/src/lib/utils/hooks/useWallets/useWallets.cjs +20 -26
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +3 -2
- package/src/lib/utils/hooks/useWallets/useWallets.js +21 -27
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -3
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -1
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -1
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +3 -2
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +3 -2
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +3 -2
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +3 -2
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +4 -10
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +4 -10
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.cjs +1 -0
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.js +1 -0
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +1 -1
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +1 -1
- package/src/lib/views/WalletList/data.cjs +2 -14
- package/src/lib/views/WalletList/data.d.ts +4 -2
- package/src/lib/views/WalletList/data.js +2 -13
- package/src/lib/views/viewToComponentMap.cjs +1 -0
- package/src/lib/views/viewToComponentMap.js +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.cjs +3 -3
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.js +3 -3
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +7 -10
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +8 -11
- package/src/lib/widgets/DynamicWidget/hooks/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs +4 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js +4 -1
- package/src/lib/widgets/DynamicWidget/hooks/useViewController/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/hooks/useViewController/useViewController.cjs +17 -0
- package/src/lib/widgets/DynamicWidget/hooks/useViewController/useViewController.d.ts +6 -0
- package/src/lib/widgets/DynamicWidget/hooks/useViewController/useViewController.js +13 -0
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +3 -3
- package/src/lib/widgets/DynamicWidget/views/SendBalanceWidgetView/SendBalanceWidgetView.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/views/SendBalanceWidgetView/SendBalanceWidgetView.js +2 -3
- package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.cjs +13 -0
- package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.d.ts +2 -0
- package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.js +9 -0
- package/src/lib/widgets/OAuthIFrameContainer/index.d.ts +1 -0
- package/src/lib/widgets/index.d.ts +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useState, useMemo } from 'react';
|
|
2
|
+
import { useState, useRef, useMemo } from 'react';
|
|
3
3
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
4
|
-
import { unlinkOAuth, verifyOAuth } from '../../../data/api.js';
|
|
4
|
+
import { getOauthLoginUrl, unlinkOAuth, verifyOAuth } from '../../../data/api.js';
|
|
5
5
|
import { useUpdateUserProfileByJWTCallback } from '../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js';
|
|
6
6
|
import '@dynamic-labs/sdk-api';
|
|
7
7
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -11,14 +11,20 @@ import 'react/jsx-runtime';
|
|
|
11
11
|
import '../../../context/ViewContext/ViewContext.js';
|
|
12
12
|
import '@dynamic-labs/wallet-book';
|
|
13
13
|
import '@dynamic-labs/utils';
|
|
14
|
+
import { PRIMARY_WALLET_ID } from '../../constants/localStorage.js';
|
|
14
15
|
import '../../constants/colors.js';
|
|
15
|
-
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
16
|
+
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
16
17
|
import 'viem';
|
|
17
18
|
import '../../../shared/consts/index.js';
|
|
18
19
|
import '@dynamic-labs/multi-wallet';
|
|
19
20
|
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
20
21
|
import { getEnabledOAuthProviders } from '../../functions/getEnabledOAuthProviders/index.js';
|
|
21
22
|
import { isSocialKycEnabled } from '../../functions/isSocialKycEnabled/isSocialKycEnabled.js';
|
|
23
|
+
import { randomString } from '../../functions/randomString/randomString.js';
|
|
24
|
+
import { stringifyURIQuery } from '../../functions/stringifyURIQuery/stringifyURIQuery.js';
|
|
25
|
+
import { digestSHA256 } from '../../functions/digestSHA256/digestSHA256.js';
|
|
26
|
+
import { encodeBase64URL } from '../../functions/encodeBase64URL/encodeBase64URL.js';
|
|
27
|
+
import { getRedirectURIOrigin } from '../../functions/getRedirectURIOrigin/getRedirectURIOrigin.js';
|
|
22
28
|
|
|
23
29
|
const socialProviders = [
|
|
24
30
|
'discord',
|
|
@@ -29,12 +35,20 @@ const socialProviders = [
|
|
|
29
35
|
'twitch',
|
|
30
36
|
'twitter',
|
|
31
37
|
];
|
|
32
|
-
|
|
38
|
+
// pkce params are only required for twitter and break if added for other providers, like google
|
|
39
|
+
// so we should only add provider that support pkce to this list
|
|
40
|
+
const providersRequiringPkce = ['twitter', 'github'];
|
|
41
|
+
const providersWithoutWindowOpenerRefence = ['twitter'];
|
|
42
|
+
const useSocialAccounts = ({ sessionTimeout } = {
|
|
43
|
+
sessionTimeout: 10000,
|
|
44
|
+
}) => {
|
|
33
45
|
var _a;
|
|
34
46
|
const { environmentId, user, projectSettings, onboardingOnlyJwt } = useInternalDynamicContext();
|
|
35
47
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
36
48
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
37
49
|
const [error, setError] = useState();
|
|
50
|
+
const providersWaitingOauthMessages = useRef({});
|
|
51
|
+
const authWindowInterval = useRef();
|
|
38
52
|
const userJwt = (_a = getAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
39
53
|
const oauthProviders = getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
40
54
|
const verifiedOAuthCredentialsMap = useMemo(() => {
|
|
@@ -53,6 +67,23 @@ const useSocialAccounts = () => {
|
|
|
53
67
|
setIsProcessing(false);
|
|
54
68
|
setError(message);
|
|
55
69
|
};
|
|
70
|
+
const addOAuthIFrame = (url) => {
|
|
71
|
+
const container = document.getElementById('oauth-iframe-container');
|
|
72
|
+
let oauthIFrame = document.getElementById('oauth-iframe');
|
|
73
|
+
if (!container || oauthIFrame) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
oauthIFrame = document.createElement('iframe');
|
|
77
|
+
oauthIFrame.setAttribute('id', 'oauth-iframe');
|
|
78
|
+
oauthIFrame.setAttribute('src', url);
|
|
79
|
+
container.appendChild(oauthIFrame);
|
|
80
|
+
};
|
|
81
|
+
const removeOAuthIFrame = () => {
|
|
82
|
+
const oauthIFrame = document.getElementById('oauth-iframe');
|
|
83
|
+
if (oauthIFrame) {
|
|
84
|
+
oauthIFrame.remove();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
56
87
|
const checkValidProvider = (provider) => {
|
|
57
88
|
if (!provider) {
|
|
58
89
|
handleError('Provider is required');
|
|
@@ -64,38 +95,73 @@ const useSocialAccounts = () => {
|
|
|
64
95
|
}
|
|
65
96
|
return true;
|
|
66
97
|
};
|
|
67
|
-
const
|
|
68
|
-
setError(undefined);
|
|
69
|
-
setIsProcessing(true);
|
|
98
|
+
const checkValidOAuthLinking = (provider) => {
|
|
70
99
|
if (!isSocialKycEnabled(projectSettings)) {
|
|
71
100
|
handleError('Social linking is not enabled on the dashboard');
|
|
72
|
-
return;
|
|
101
|
+
return false;
|
|
73
102
|
}
|
|
74
103
|
if (!checkValidProvider(provider)) {
|
|
75
|
-
return;
|
|
104
|
+
return false;
|
|
76
105
|
}
|
|
77
106
|
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
78
107
|
if (verifiedCredential) {
|
|
79
108
|
handleError(`Account already linked for provider: ${provider}`);
|
|
80
|
-
return;
|
|
109
|
+
return false;
|
|
81
110
|
}
|
|
82
111
|
const oauthProvider = oauthProviders.find((p) => p.provider === provider);
|
|
83
112
|
if (!oauthProvider) {
|
|
84
113
|
handleError(`Provider is not enabled on the dashboard: ${provider}`);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
};
|
|
118
|
+
const linkSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
+
var _b;
|
|
120
|
+
clearInterval(authWindowInterval.current);
|
|
121
|
+
setError(undefined);
|
|
122
|
+
setIsProcessing(true);
|
|
123
|
+
// invalid linking request
|
|
124
|
+
if (!checkValidOAuthLinking(provider)) {
|
|
85
125
|
return;
|
|
86
126
|
}
|
|
127
|
+
const state = randomString(8);
|
|
128
|
+
const verifier = randomString(43);
|
|
129
|
+
const clearListeners = () => {
|
|
130
|
+
removeOAuthIFrame();
|
|
131
|
+
window.removeEventListener('message', handleAuthWindowMessage);
|
|
132
|
+
providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: false });
|
|
133
|
+
};
|
|
87
134
|
const handleAuthWindowMessage = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
-
var
|
|
89
|
-
|
|
90
|
-
|
|
135
|
+
var _c;
|
|
136
|
+
const message = event.data;
|
|
137
|
+
const isAuthorizationMessage = (message === null || message === void 0 ? void 0 : message.type) === 'authorization_response';
|
|
138
|
+
if (isAuthorizationMessage) {
|
|
139
|
+
logger.debug('Message received', { data: message });
|
|
140
|
+
}
|
|
141
|
+
const isValidMessage = isAuthorizationMessage && (message === null || message === void 0 ? void 0 : message.provider) === provider;
|
|
142
|
+
// don't process imvalid messages for provider
|
|
143
|
+
if (!isValidMessage) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
setIsProcessing(true);
|
|
147
|
+
if (!((_c = providersWaitingOauthMessages.current) === null || _c === void 0 ? void 0 : _c[provider])) {
|
|
148
|
+
handleError(`Linking ${provider} account session timeout.`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
clearListeners();
|
|
152
|
+
const { code, error } = message;
|
|
153
|
+
if (error && error !== 'undefined') {
|
|
154
|
+
handleError(`Failed to link ${provider} social account: ${error}`);
|
|
155
|
+
return;
|
|
91
156
|
}
|
|
92
|
-
if (
|
|
93
|
-
(
|
|
157
|
+
if (!code) {
|
|
158
|
+
handleError(`Failed to link ${provider} social account: no authorization code`);
|
|
94
159
|
return;
|
|
95
160
|
}
|
|
96
|
-
const { code } = event.data;
|
|
97
161
|
const jwt = yield verifyOAuth(environmentId, provider, {
|
|
98
162
|
code,
|
|
163
|
+
codeVerifier: verifier,
|
|
164
|
+
state,
|
|
99
165
|
}, String(userJwt));
|
|
100
166
|
if (!jwt) {
|
|
101
167
|
handleError(`Failed to link social account: ${provider}`);
|
|
@@ -104,18 +170,58 @@ const useSocialAccounts = () => {
|
|
|
104
170
|
yield updateUserProfileByJWT(jwt);
|
|
105
171
|
setIsProcessing(false);
|
|
106
172
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
173
|
+
const loginUrl = yield getOauthLoginUrl(environmentId, provider, String(userJwt));
|
|
174
|
+
if (!loginUrl) {
|
|
175
|
+
handleError(`Failed to get login url to link social account: ${provider}`);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
// we need to use an iframe to be the intermediary in communications between the popup and the sdk
|
|
179
|
+
// because of twitter limitations with accessing the window.opener and BroadcastChannel not working between
|
|
180
|
+
// different origins (our api redirect page and the app where the sdk is running)
|
|
181
|
+
const oauthIFrameUrl = `${getRedirectURIOrigin(loginUrl)}/sdkoauth`;
|
|
182
|
+
addOAuthIFrame(oauthIFrameUrl);
|
|
183
|
+
let oauthLoginUrl = loginUrl;
|
|
184
|
+
if (providersRequiringPkce.includes(provider)) {
|
|
185
|
+
const digest = yield digestSHA256(verifier);
|
|
186
|
+
const pkceParams = stringifyURIQuery({
|
|
187
|
+
code_challenge: encodeBase64URL(digest),
|
|
188
|
+
code_challenge_method: 'S256',
|
|
189
|
+
state: state,
|
|
190
|
+
});
|
|
191
|
+
oauthLoginUrl = `${loginUrl}&${pkceParams}`;
|
|
192
|
+
}
|
|
193
|
+
if (!((_b = providersWaitingOauthMessages.current) === null || _b === void 0 ? void 0 : _b[provider])) {
|
|
194
|
+
window.addEventListener('message', handleAuthWindowMessage);
|
|
195
|
+
providersWaitingOauthMessages.current = Object.assign(Object.assign({}, providersWaitingOauthMessages.current), { [provider]: true });
|
|
196
|
+
}
|
|
197
|
+
const authWindow = window.open(oauthLoginUrl, '_blank', 'width=500,height=600');
|
|
198
|
+
if (!providersWithoutWindowOpenerRefence.includes(provider)) {
|
|
199
|
+
// For provider that support window.opener, we need to clear all states/listeners when the window is closed
|
|
200
|
+
authWindowInterval.current = setInterval(() => {
|
|
201
|
+
if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed)) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
clearInterval(authWindowInterval.current);
|
|
113
205
|
setIsProcessing(false);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
// For provider that don't support window.opener, we need to use a timeout to try to detect when the
|
|
210
|
+
// window is closed
|
|
211
|
+
authWindowInterval.current = setInterval(() => {
|
|
212
|
+
var _a;
|
|
213
|
+
// user didn't complete oauth
|
|
214
|
+
if ((_a = providersWaitingOauthMessages.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
215
|
+
clearListeners();
|
|
216
|
+
handleError(`Linking ${provider} account window timeout.`);
|
|
217
|
+
}
|
|
218
|
+
setIsProcessing(false);
|
|
219
|
+
clearInterval(authWindowInterval.current);
|
|
220
|
+
}, sessionTimeout);
|
|
221
|
+
}
|
|
116
222
|
});
|
|
117
223
|
const unlinkSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
-
var
|
|
224
|
+
var _d;
|
|
119
225
|
setError(undefined);
|
|
120
226
|
setIsProcessing(true);
|
|
121
227
|
if (!checkValidProvider(provider)) {
|
|
@@ -127,9 +233,11 @@ const useSocialAccounts = () => {
|
|
|
127
233
|
return;
|
|
128
234
|
}
|
|
129
235
|
try {
|
|
236
|
+
const primaryWalletId = LocalStorage.getFromLS(PRIMARY_WALLET_ID);
|
|
130
237
|
const jwt = yield unlinkOAuth({
|
|
131
238
|
environmentId,
|
|
132
|
-
|
|
239
|
+
primaryWalletId,
|
|
240
|
+
verifiedCrentialId: (_d = verifiedCredential.id) !== null && _d !== void 0 ? _d : '',
|
|
133
241
|
}, String(userJwt));
|
|
134
242
|
if (!jwt) {
|
|
135
243
|
handleError(`Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
|
|
@@ -38,7 +38,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
38
38
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
39
39
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
40
40
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
41
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
41
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
42
42
|
// If the user is not already logged it means that we only need to verify
|
|
43
43
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
44
44
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -68,7 +68,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
68
68
|
if (Jwt === undefined)
|
|
69
69
|
throw new utils.DynamicError('Could not obtain a valid JWT');
|
|
70
70
|
// TODO DYN-523: add verification here that the JWT is valid with the publicKey
|
|
71
|
-
return Jwt;
|
|
71
|
+
return { Jwt, verifyArgs };
|
|
72
72
|
});
|
|
73
73
|
// Overrides the stored primary wallet id when the
|
|
74
74
|
// user logs in for the first time.
|
|
@@ -143,13 +143,23 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
+
var _a;
|
|
146
147
|
const walletProvider = getWalletProvider.getWalletProvider(walletConnector);
|
|
147
148
|
try {
|
|
148
149
|
setIsVerificationInProgress(true);
|
|
149
|
-
const Jwt = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
150
|
+
const { Jwt, verifyArgs } = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
150
151
|
const decodedJwt = decodeJwt.decodeJwt(Jwt);
|
|
151
152
|
if (decodedJwt === undefined)
|
|
152
153
|
throw new utils.DynamicError('Invalid token!');
|
|
154
|
+
try {
|
|
155
|
+
(_a = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onSignedMessage) === null || _a === void 0 ? void 0 : _a.call(eventsCallbacks, {
|
|
156
|
+
messageToSign: verifyArgs.messageToSign,
|
|
157
|
+
signedMessage: verifyArgs.signedMessage,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
catch (_b) {
|
|
161
|
+
logger.logger.warn('Error calling onSignedMessage callback');
|
|
162
|
+
}
|
|
153
163
|
const user = yield createUserProfile.createUserProfile(decodedJwt);
|
|
154
164
|
const isKycRequired = decodedJwt.missingFields.length;
|
|
155
165
|
setOnboardingOnlyJwt(Jwt);
|
|
@@ -34,7 +34,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
34
34
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
35
35
|
const { setView, goToInitialView } = useViewContext();
|
|
36
36
|
const { setErrorMessage, setError } = useErrorContext();
|
|
37
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
37
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, } = useInternalDynamicContext();
|
|
38
38
|
// If the user is not already logged it means that we only need to verify
|
|
39
39
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
40
40
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -64,7 +64,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
64
64
|
if (Jwt === undefined)
|
|
65
65
|
throw new DynamicError('Could not obtain a valid JWT');
|
|
66
66
|
// TODO DYN-523: add verification here that the JWT is valid with the publicKey
|
|
67
|
-
return Jwt;
|
|
67
|
+
return { Jwt, verifyArgs };
|
|
68
68
|
});
|
|
69
69
|
// Overrides the stored primary wallet id when the
|
|
70
70
|
// user logs in for the first time.
|
|
@@ -139,13 +139,23 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
141
|
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
+
var _a;
|
|
142
143
|
const walletProvider = getWalletProvider(walletConnector);
|
|
143
144
|
try {
|
|
144
145
|
setIsVerificationInProgress(true);
|
|
145
|
-
const Jwt = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
146
|
+
const { Jwt, verifyArgs } = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
146
147
|
const decodedJwt = decodeJwt(Jwt);
|
|
147
148
|
if (decodedJwt === undefined)
|
|
148
149
|
throw new DynamicError('Invalid token!');
|
|
150
|
+
try {
|
|
151
|
+
(_a = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onSignedMessage) === null || _a === void 0 ? void 0 : _a.call(eventsCallbacks, {
|
|
152
|
+
messageToSign: verifyArgs.messageToSign,
|
|
153
|
+
signedMessage: verifyArgs.signedMessage,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch (_b) {
|
|
157
|
+
logger.warn('Error calling onSignedMessage callback');
|
|
158
|
+
}
|
|
149
159
|
const user = yield createUserProfile(decodedJwt);
|
|
150
160
|
const isKycRequired = decodedJwt.missingFields.length;
|
|
151
161
|
setOnboardingOnlyJwt(Jwt);
|
|
@@ -6,35 +6,28 @@ var React = require('react');
|
|
|
6
6
|
var data = require('../../../views/WalletList/data.cjs');
|
|
7
7
|
var verifyMagicIsSetup = require('./utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
8
8
|
|
|
9
|
-
const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }) => {
|
|
9
|
+
const useWallets = ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }) => {
|
|
10
10
|
const wallets = React.useMemo(() => {
|
|
11
|
-
if (!projectSettings ||
|
|
11
|
+
if (!projectSettings ||
|
|
12
|
+
!Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length ||
|
|
13
|
+
!networkConfigurations)
|
|
12
14
|
return [];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
return data.getWallets({
|
|
16
|
+
getSupportedWalletOpts: {
|
|
17
|
+
appLogoUrl,
|
|
18
|
+
appName,
|
|
19
|
+
customerApiProviders: projectSettings.providers || [],
|
|
20
|
+
deepLinkPreference,
|
|
21
|
+
flowNetwork,
|
|
22
|
+
networkConfigurations,
|
|
23
|
+
skipMemo: true,
|
|
24
|
+
walletBook,
|
|
25
|
+
walletConnectV1Bridge,
|
|
26
|
+
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
27
|
+
walletUiUtils,
|
|
28
|
+
},
|
|
29
|
+
settings: projectSettings,
|
|
24
30
|
});
|
|
25
|
-
const notInstalledWallets = data.getNotInstalledWallets(projectSettings, {
|
|
26
|
-
appLogoUrl,
|
|
27
|
-
appName,
|
|
28
|
-
customerApiProviders: projectSettings.providers || [],
|
|
29
|
-
flowNetwork,
|
|
30
|
-
networkConfigurations,
|
|
31
|
-
skipMemo: true,
|
|
32
|
-
walletBook,
|
|
33
|
-
walletConnectV1Bridge,
|
|
34
|
-
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
35
|
-
walletUiUtils,
|
|
36
|
-
});
|
|
37
|
-
return [...installedWallets, ...notInstalledWallets];
|
|
38
31
|
// Cannot include walletUiUtils in the dependency array because it will cause an infinite loop
|
|
39
32
|
}, [
|
|
40
33
|
appLogoUrl,
|
|
@@ -45,6 +38,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, network
|
|
|
45
38
|
walletConnectV1Bridge,
|
|
46
39
|
flowNetwork,
|
|
47
40
|
Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length,
|
|
41
|
+
networkConfigurations,
|
|
48
42
|
]);
|
|
49
43
|
React.useEffect(() => {
|
|
50
44
|
if (!projectSettings || wallets.length === 0)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
2
2
|
import { NetworkConfigurationMap, WalletUiUtils } from '@dynamic-labs/types';
|
|
3
|
-
import { WalletConnector, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { DeepLinkVariant, WalletConnector, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
5
5
|
type Props = {
|
|
6
6
|
appLogoUrl?: string;
|
|
7
7
|
appName?: string;
|
|
8
|
+
deepLinkPreference?: DeepLinkVariant;
|
|
8
9
|
flowNetwork?: 'mainnet' | 'testnet';
|
|
9
10
|
networkConfigurations: NetworkConfigurationMap | undefined;
|
|
10
11
|
projectSettings: ProjectSettings | undefined;
|
|
@@ -13,7 +14,7 @@ type Props = {
|
|
|
13
14
|
walletConnectorsProp?: WalletConnectorsMethod[];
|
|
14
15
|
walletUiUtils: WalletUiUtils<WalletConnector>;
|
|
15
16
|
};
|
|
16
|
-
export declare const useWallets: ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }: Props) => {
|
|
17
|
+
export declare const useWallets: ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }: Props) => {
|
|
17
18
|
wallets: import("../../../shared").WalletOption[];
|
|
18
19
|
};
|
|
19
20
|
export {};
|
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
import { useMemo, useEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { getWallets } from '../../../views/WalletList/data.js';
|
|
3
3
|
import { verifyMagicIsSetup } from './utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
4
4
|
|
|
5
|
-
const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }) => {
|
|
5
|
+
const useWallets = ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }) => {
|
|
6
6
|
const wallets = useMemo(() => {
|
|
7
|
-
if (!projectSettings ||
|
|
7
|
+
if (!projectSettings ||
|
|
8
|
+
!Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length ||
|
|
9
|
+
!networkConfigurations)
|
|
8
10
|
return [];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
return getWallets({
|
|
12
|
+
getSupportedWalletOpts: {
|
|
13
|
+
appLogoUrl,
|
|
14
|
+
appName,
|
|
15
|
+
customerApiProviders: projectSettings.providers || [],
|
|
16
|
+
deepLinkPreference,
|
|
17
|
+
flowNetwork,
|
|
18
|
+
networkConfigurations,
|
|
19
|
+
skipMemo: true,
|
|
20
|
+
walletBook,
|
|
21
|
+
walletConnectV1Bridge,
|
|
22
|
+
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
23
|
+
walletUiUtils,
|
|
24
|
+
},
|
|
25
|
+
settings: projectSettings,
|
|
20
26
|
});
|
|
21
|
-
const notInstalledWallets = getNotInstalledWallets(projectSettings, {
|
|
22
|
-
appLogoUrl,
|
|
23
|
-
appName,
|
|
24
|
-
customerApiProviders: projectSettings.providers || [],
|
|
25
|
-
flowNetwork,
|
|
26
|
-
networkConfigurations,
|
|
27
|
-
skipMemo: true,
|
|
28
|
-
walletBook,
|
|
29
|
-
walletConnectV1Bridge,
|
|
30
|
-
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
31
|
-
walletUiUtils,
|
|
32
|
-
});
|
|
33
|
-
return [...installedWallets, ...notInstalledWallets];
|
|
34
27
|
// Cannot include walletUiUtils in the dependency array because it will cause an infinite loop
|
|
35
28
|
}, [
|
|
36
29
|
appLogoUrl,
|
|
@@ -41,6 +34,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, network
|
|
|
41
34
|
walletConnectV1Bridge,
|
|
42
35
|
flowNetwork,
|
|
43
36
|
Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length,
|
|
37
|
+
networkConfigurations,
|
|
44
38
|
]);
|
|
45
39
|
useEffect(() => {
|
|
46
40
|
if (!projectSettings || wallets.length === 0)
|
|
@@ -48,7 +48,7 @@ var index = require('../UserDataFields/index.cjs');
|
|
|
48
48
|
var useUserDataForm = require('../../../utils/hooks/useUserDataForm/useUserDataForm.cjs');
|
|
49
49
|
|
|
50
50
|
const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
|
|
51
|
-
const { policiesConsentInnerComponent, onboardingOnlyJwt,
|
|
51
|
+
const { policiesConsentInnerComponent, onboardingOnlyJwt, internalSetShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
52
52
|
const { setView, view } = ViewContext.useViewContext();
|
|
53
53
|
const decodedJwt = decodeJwt.decodeJwt(onboardingOnlyJwt);
|
|
54
54
|
const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
|
|
@@ -67,9 +67,9 @@ const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
|
|
|
67
67
|
setView(view);
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
internalSetShowAuthFlow(false);
|
|
71
71
|
setCallback('authSuccess');
|
|
72
|
-
}), [setCallback,
|
|
72
|
+
}), [setCallback, internalSetShowAuthFlow, setView, updateUser]);
|
|
73
73
|
const { fetch: loading, formikInitialValues, formikValidationSchema, enforcePolicies, onFormSubmit, } = useUserDataForm.useUserDataForm({
|
|
74
74
|
fields: (decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) || [],
|
|
75
75
|
onSubmit,
|
|
@@ -44,7 +44,7 @@ import { UserDataFields } from '../UserDataFields/index.js';
|
|
|
44
44
|
import { useUserDataForm } from '../../../utils/hooks/useUserDataForm/useUserDataForm.js';
|
|
45
45
|
|
|
46
46
|
const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
|
|
47
|
-
const { policiesConsentInnerComponent, onboardingOnlyJwt,
|
|
47
|
+
const { policiesConsentInnerComponent, onboardingOnlyJwt, internalSetShowAuthFlow, setCallback, } = useInternalDynamicContext();
|
|
48
48
|
const { setView, view } = useViewContext();
|
|
49
49
|
const decodedJwt = decodeJwt(onboardingOnlyJwt);
|
|
50
50
|
const { updateUser } = useUserUpdateRequestInternal({
|
|
@@ -63,9 +63,9 @@ const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
|
|
|
63
63
|
setView(view);
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
internalSetShowAuthFlow(false);
|
|
67
67
|
setCallback('authSuccess');
|
|
68
|
-
}), [setCallback,
|
|
68
|
+
}), [setCallback, internalSetShowAuthFlow, setView, updateUser]);
|
|
69
69
|
const { fetch: loading, formikInitialValues, formikValidationSchema, enforcePolicies, onFormSubmit, } = useUserDataForm({
|
|
70
70
|
fields: (decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) || [],
|
|
71
71
|
onSubmit,
|
|
@@ -65,7 +65,7 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
65
65
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation.useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
66
66
|
onFailure: (error) => setError(error),
|
|
67
67
|
});
|
|
68
|
-
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
|
|
68
|
+
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true, successBannerText: 'Sign in to access your email based wallet' }));
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
exports.EmailWalletOTPVerificationView = EmailWalletOTPVerificationView;
|
|
@@ -61,7 +61,7 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
61
61
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
62
62
|
onFailure: (error) => setError(error),
|
|
63
63
|
});
|
|
64
|
-
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
|
|
64
|
+
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true, successBannerText: 'Sign in to access your email based wallet' }));
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
export { EmailWalletOTPVerificationView };
|
|
@@ -51,10 +51,10 @@ require('formik');
|
|
|
51
51
|
require('yup');
|
|
52
52
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
53
53
|
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
54
|
+
var capitalize = require('../../../../shared/utils/functions/capitalize/capitalize.cjs');
|
|
54
55
|
var SocialRedirectContext = require('../../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
55
56
|
var OverlayCard = require('../../../../components/OverlayCard/OverlayCard.cjs');
|
|
56
57
|
require('../../../../components/OverlayCard/OverlayCard.context.cjs');
|
|
57
|
-
var capitalize = require('../../../../shared/utils/functions/capitalize/capitalize.cjs');
|
|
58
58
|
|
|
59
59
|
const SocialSignIn = () => {
|
|
60
60
|
const { socialProvidersFilter = (providers) => providers } = useInternalDynamicContext.useInternalDynamicContext();
|
|
@@ -47,10 +47,10 @@ import 'formik';
|
|
|
47
47
|
import 'yup';
|
|
48
48
|
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
49
49
|
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
50
|
+
import { capitalize } from '../../../../shared/utils/functions/capitalize/capitalize.js';
|
|
50
51
|
import { useSocialRedirectContext } from '../../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
51
52
|
import { OverlayCard } from '../../../../components/OverlayCard/OverlayCard.js';
|
|
52
53
|
import '../../../../components/OverlayCard/OverlayCard.context.js';
|
|
53
|
-
import { capitalize } from '../../../../shared/utils/functions/capitalize/capitalize.js';
|
|
54
54
|
|
|
55
55
|
const SocialSignIn = () => {
|
|
56
56
|
const { socialProvidersFilter = (providers) => providers } = useInternalDynamicContext();
|
|
@@ -53,12 +53,13 @@ var SelectNetworkButton = require('../../components/SelectNetworkButton/SelectNe
|
|
|
53
53
|
var useApplyWalletConnectorNetwork = require('../../utils/hooks/useApplyWalletConnectorNetwork/useApplyWalletConnectorNetwork.cjs');
|
|
54
54
|
|
|
55
55
|
const NetworkNotSupported = () => {
|
|
56
|
-
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, isFullyConnected, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
56
|
+
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, isFullyConnected, setShowAuthFlow, walletsToConnectByChain, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
57
57
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
58
58
|
const { data: walletConnectorNetwork } = usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
|
|
59
59
|
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
60
60
|
shouldCallCallback: false,
|
|
61
|
-
shouldUpdateWallets: !isFullyConnected
|
|
61
|
+
shouldUpdateWallets: !isFullyConnected ||
|
|
62
|
+
(isFullyConnected && Boolean(walletsToConnectByChain === null || walletsToConnectByChain === void 0 ? void 0 : walletsToConnectByChain.length)),
|
|
62
63
|
});
|
|
63
64
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
64
65
|
// Finishes auth flow when wallet switches to proper network
|
|
@@ -49,12 +49,13 @@ import { SelectNetworkButton } from '../../components/SelectNetworkButton/Select
|
|
|
49
49
|
import { useApplyWalletConnectorNetwork } from '../../utils/hooks/useApplyWalletConnectorNetwork/useApplyWalletConnectorNetwork.js';
|
|
50
50
|
|
|
51
51
|
const NetworkNotSupported = () => {
|
|
52
|
-
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, isFullyConnected, setShowAuthFlow, } = useInternalDynamicContext();
|
|
52
|
+
const { network, onboardingImageUrl, selectedWalletConnector: walletConnector, connectedWallets, primaryWallet, isFullyConnected, setShowAuthFlow, walletsToConnectByChain, } = useInternalDynamicContext();
|
|
53
53
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
54
54
|
const { data: walletConnectorNetwork } = usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
|
|
55
55
|
const finishConnectAndSign = useConnectAndSign({
|
|
56
56
|
shouldCallCallback: false,
|
|
57
|
-
shouldUpdateWallets: !isFullyConnected
|
|
57
|
+
shouldUpdateWallets: !isFullyConnected ||
|
|
58
|
+
(isFullyConnected && Boolean(walletsToConnectByChain === null || walletsToConnectByChain === void 0 ? void 0 : walletsToConnectByChain.length)),
|
|
58
59
|
});
|
|
59
60
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
|
|
60
61
|
// Finishes auth flow when wallet switches to proper network
|
|
@@ -54,14 +54,15 @@ var useApplyWalletConnectorNetwork = require('../../utils/hooks/useApplyWalletCo
|
|
|
54
54
|
// as the wallet does not support programmatic network change.
|
|
55
55
|
const NetworkNotSupportedSwitchManual = () => {
|
|
56
56
|
var _a, _b;
|
|
57
|
-
const { user, selectedWalletConnector: walletConnector, connectedWallets, isFullyConnected, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
57
|
+
const { user, selectedWalletConnector: walletConnector, connectedWallets, isFullyConnected, setShowAuthFlow, walletsToConnectByChain, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
58
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
59
59
|
const { data: walletConnectorNetwork } = usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), {
|
|
60
60
|
deps: [walletConnector, connectedWallets],
|
|
61
61
|
});
|
|
62
62
|
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
63
63
|
shouldCallCallback: false,
|
|
64
|
-
shouldUpdateWallets: !isFullyConnected
|
|
64
|
+
shouldUpdateWallets: !isFullyConnected ||
|
|
65
|
+
(isFullyConnected && Boolean(walletsToConnectByChain === null || walletsToConnectByChain === void 0 ? void 0 : walletsToConnectByChain.length)),
|
|
65
66
|
});
|
|
66
67
|
// Finishes auth flow when wallet switches to proper network
|
|
67
68
|
React.useEffect(() => {
|