@dynamic-labs/sdk-react-core 0.19.0-alpha.7 → 0.19.0-alpha.8
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 +24 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +10 -10
- package/src/index.d.ts +1 -1
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +2 -2
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +2 -2
- package/src/lib/components/IconWithStatus/IconWithStatus.cjs +3 -3
- package/src/lib/components/IconWithStatus/IconWithStatus.d.ts +2 -2
- package/src/lib/components/IconWithStatus/IconWithStatus.js +3 -3
- package/src/lib/components/MockedQrCode/MockedQrCode.cjs +1 -1
- package/src/lib/components/MockedQrCode/MockedQrCode.js +1 -1
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +2 -2
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.d.ts +1 -1
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +2 -2
- package/src/lib/components/SocialSignIn/SocialSignIn.cjs +26 -14
- package/src/lib/components/SocialSignIn/SocialSignIn.d.ts +8 -7
- package/src/lib/components/SocialSignIn/SocialSignIn.js +26 -14
- package/src/lib/components/TransactionOriginDestination/TransactionOriginDestination.d.ts +1 -1
- package/src/lib/components/UserProfile/UserProfile.cjs +4 -1
- package/src/lib/components/UserProfile/UserProfile.js +4 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +15 -13
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +15 -13
- package/src/lib/context/DynamicContext/helpers.cjs +22 -10
- package/src/lib/context/DynamicContext/helpers.d.ts +4 -2
- package/src/lib/context/DynamicContext/helpers.js +20 -10
- package/src/lib/context/ErrorContext/ErrorContext.cjs +4 -1
- package/src/lib/context/ErrorContext/ErrorContext.js +4 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +7 -4
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.d.ts +5 -5
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +7 -4
- package/src/lib/data/api.cjs +48 -16
- package/src/lib/data/api.d.ts +1 -0
- package/src/lib/data/api.js +50 -19
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.cjs +1 -1
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.js +1 -1
- package/src/lib/locale/en/translation.cjs +2 -4
- package/src/lib/locale/en/translation.js +2 -4
- package/src/lib/shared/types/index.d.ts +4 -0
- package/src/lib/shared/utils/functions/wallet/createWallet.cjs +1 -1
- package/src/lib/shared/utils/functions/wallet/createWallet.js +1 -1
- 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 -2
- package/src/lib/utils/constants/localStorage.d.ts +2 -1
- package/src/lib/utils/constants/localStorage.js +3 -2
- package/src/lib/utils/functions/getActiveOauthCredential/getActiveOauthCredential.cjs +11 -0
- package/src/lib/utils/functions/getActiveOauthCredential/getActiveOauthCredential.d.ts +2 -0
- package/src/lib/utils/functions/getActiveOauthCredential/getActiveOauthCredential.js +7 -0
- package/src/lib/utils/functions/getActiveOauthCredential/index.d.ts +1 -0
- package/src/lib/utils/functions/getEnabledSocialSignInProvidersAsProviderEnum/getEnabledSocialSignInProvidersAsProviderEnum.d.ts +2 -0
- package/src/lib/utils/functions/getEnabledSocialSignInProvidersAsProviderEnum/index.d.ts +1 -0
- package/src/lib/utils/functions/getProviderEnumForSocialSignInProvider/getProviderEnumForSocialSignInProvider.cjs +19 -0
- package/src/lib/utils/functions/getProviderEnumForSocialSignInProvider/getProviderEnumForSocialSignInProvider.d.ts +2 -0
- package/src/lib/utils/functions/getProviderEnumForSocialSignInProvider/getProviderEnumForSocialSignInProvider.js +15 -0
- package/src/lib/utils/functions/getProviderEnumForSocialSignInProvider/index.d.ts +1 -0
- package/src/lib/utils/functions/getSocialSignInProviderForProviderEnum/getSocialSignInProviderForProviderEnum.cjs +19 -0
- package/src/lib/utils/functions/getSocialSignInProviderForProviderEnum/getSocialSignInProviderForProviderEnum.d.ts +2 -0
- package/src/lib/utils/functions/getSocialSignInProviderForProviderEnum/getSocialSignInProviderForProviderEnum.js +15 -0
- package/src/lib/utils/functions/getSocialSignInProviderForProviderEnum/index.d.ts +1 -0
- package/src/lib/utils/functions/getSocialSignInProviderFromString/getSocialSignInProviderFromString.cjs +19 -0
- package/src/lib/utils/functions/getSocialSignInProviderFromString/getSocialSignInProviderFromString.d.ts +2 -0
- package/src/lib/utils/functions/getSocialSignInProviderFromString/getSocialSignInProviderFromString.js +15 -0
- package/src/lib/utils/functions/getSocialSignInProviderFromString/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +5 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +3 -3
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +4 -4
- 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/useSocialAccounts/useSocialAccounts.cjs +10 -164
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +2 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +12 -166
- package/src/lib/utils/hooks/useSocialAuth/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +278 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +20 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +274 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +13 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +13 -3
- package/src/lib/views/AccountExistsView/AccountExistsView.cjs +4 -2
- package/src/lib/views/AccountExistsView/AccountExistsView.js +4 -2
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +1 -1
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +1 -1
- package/src/lib/views/LoginView/LoginView.cjs +1 -1
- package/src/lib/views/LoginView/LoginView.js +1 -1
- package/src/lib/views/LoginView/sections/LoginWidget.d.ts +5 -0
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +77 -0
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.d.ts +3 -0
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +73 -0
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/index.d.ts +1 -0
- package/src/lib/views/LoginView/sections/SocialSignInSection/MagicSocialSignIn/MagicSocialSignIn.cjs +3 -2
- package/src/lib/views/LoginView/sections/SocialSignInSection/MagicSocialSignIn/MagicSocialSignIn.d.ts +2 -1
- package/src/lib/views/LoginView/sections/SocialSignInSection/MagicSocialSignIn/MagicSocialSignIn.js +3 -2
- package/src/lib/views/LoginView/sections/SocialSignInSection/SocialSignInSection.cjs +18 -4
- package/src/lib/views/LoginView/sections/SocialSignInSection/SocialSignInSection.d.ts +6 -1
- package/src/lib/views/LoginView/sections/SocialSignInSection/SocialSignInSection.js +18 -4
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSignInSection.cjs +3 -2
- package/src/lib/views/LoginView/sections/WalletSignInSection/WalletSignInSection.js +3 -2
- package/src/lib/views/LoginView/useLoginView.cjs +9 -10
- package/src/lib/views/LoginView/useLoginView.js +9 -10
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +1 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +1 -1
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -1
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -1
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +1 -1
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +1 -1
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.cjs +2 -2
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.js +2 -2
- package/src/lib/views/PendingConnectView/PendingConnectView.cjs +1 -1
- package/src/lib/views/PendingConnectView/PendingConnectView.js +1 -1
- package/src/lib/views/PendingSignatureView/PendingSignatureView.cjs +1 -1
- package/src/lib/views/PendingSignatureView/PendingSignatureView.js +1 -1
- package/src/lib/views/QrCodeView/QRCode.cjs +3 -3
- package/src/lib/views/QrCodeView/QRCode.d.ts +2 -2
- package/src/lib/views/QrCodeView/QRCode.js +3 -3
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.cjs +2 -2
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.d.ts +2 -1
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.js +2 -2
- package/src/lib/views/QrCodeView/QrCodeView.cjs +2 -2
- package/src/lib/views/QrCodeView/QrCodeView.js +2 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -1
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +4 -6
- package/src/lib/views/SocialRedirectView/SocialRedirectView.d.ts +1 -1
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +4 -6
- package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.cjs +1 -1
- package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.js +1 -1
- package/src/lib/views/WalletGroupView/WalletGroupView.cjs +1 -1
- package/src/lib/views/WalletGroupView/WalletGroupView.js +1 -1
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +2 -2
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +2 -2
- package/src/lib/views/WalletLockedView/WalletLockedView.cjs +1 -1
- package/src/lib/views/WalletLockedView/WalletLockedView.js +1 -1
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +2 -2
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -1
- package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.d.ts +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.cjs +18 -3
- package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.js +18 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +9 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +9 -1
- package/src/lib/widgets/DynamicWidget/components/WalletIconWithStatus/WalletIconWithStatus.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/WalletIconWithStatus/WalletIconWithStatus.d.ts +2 -2
- package/src/lib/widgets/DynamicWidget/components/WalletIconWithStatus/WalletIconWithStatus.js +2 -2
- package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.js +3 -3
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.cjs +6 -5
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.js +6 -5
package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js
CHANGED
|
@@ -14,7 +14,7 @@ import '../../../../utils/constants/colors.js';
|
|
|
14
14
|
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
15
15
|
import 'ethers';
|
|
16
16
|
import '../../../../shared/consts/index.js';
|
|
17
|
-
import '../../../../context/DynamicContext/
|
|
17
|
+
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
18
18
|
import '@dynamic-labs/multi-wallet';
|
|
19
19
|
import '../../../ShadowDOM/ShadowDOM.js';
|
|
20
20
|
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
@@ -53,22 +53,24 @@ import { ConnectedAccountAvatar } from './components/ConnectedAccountAvatar/Conn
|
|
|
53
53
|
|
|
54
54
|
const UserProfileSocialAccount = ({ provider, }) => {
|
|
55
55
|
var _a;
|
|
56
|
+
const { user, primaryWallet } = useInternalDynamicContext();
|
|
56
57
|
const { linkSocialAccount, unlinkSocialAccount, isProcessing, isLinked, getLinkedAccountInformation, } = useSocialAccounts();
|
|
57
58
|
const isProviderLinked = isLinked(provider);
|
|
58
59
|
const connectedAccountInfo = getLinkedAccountInformation(provider);
|
|
59
60
|
const iconThemeVariant = useIconThemeVariant();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
const isActiveCredential = !primaryWallet &&
|
|
62
|
+
connectedAccountInfo &&
|
|
63
|
+
(connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.id) === (user === null || user === void 0 ? void 0 : user.lastVerifiedCredentialId);
|
|
64
|
+
const renderButton = () => (jsx(Button, Object.assign({ buttonClassName: 'user-profile-social-account__button', buttonVariant: 'secondary', buttonRounded: 'small', buttonPadding: 'none', onClick: () => isProviderLinked
|
|
65
|
+
? unlinkSocialAccount(provider)
|
|
66
|
+
: linkSocialAccount(provider), loading: isProcessing, dataTestId: `social-account-${isProviderLinked ? 'disconnect' : 'connect'}-button`, typographyProps: {
|
|
67
|
+
color: 'secondary',
|
|
68
|
+
variant: 'button_tertiary',
|
|
69
|
+
// weight: 'medium',
|
|
70
|
+
}, startSlot:
|
|
71
|
+
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
72
|
+
jsx(Icon, Object.assign({ color: 'text-tertiary', size: 'small' }, { children: isProviderLinked ? jsx(SvgUnlink, {}) : jsx(SvgAdd, {}) })) }, { children: isProviderLinked ? null : 'Connect' })));
|
|
73
|
+
return (jsxs("div", Object.assign({ className: 'user-profile-social-account', "data-testid": `social-account-${provider}` }, { children: [jsx("div", Object.assign({ className: 'user-profile-social-account__icon' }, { children: isProviderLinked ? (jsx(ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar })) : (jsx(SocialIcon, { name: provider, variant: iconThemeVariant })) })), jsx("div", Object.assign({ className: 'user-profile-social-account__label' }, { children: jsx(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary' }, { children: (_a = connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.publicIdentifier) !== null && _a !== void 0 ? _a : capitalize(provider) })) })), !isActiveCredential ? renderButton() : null] })));
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
export { UserProfileSocialAccount };
|
|
@@ -18,7 +18,8 @@ require('ethers');
|
|
|
18
18
|
var getAuthToken = require('../../utils/functions/getAuthToken/getAuthToken.cjs');
|
|
19
19
|
|
|
20
20
|
let logoutTimer;
|
|
21
|
-
let
|
|
21
|
+
let dynamicContextSettingsTimer;
|
|
22
|
+
let wagmiSettingsTimer;
|
|
22
23
|
const sdkSettingsTimeout = 24 * 60 * 60 * 1000; // 24 hours
|
|
23
24
|
const isAuthTokenExpired = (token) => {
|
|
24
25
|
const decoded = decodeJwt.decodeJwt(token);
|
|
@@ -68,13 +69,22 @@ const getInitialView = ({ connectedWallets, isBridgeFlow, isFullyConnected, isAu
|
|
|
68
69
|
}
|
|
69
70
|
return 'login-with-email-or-wallet';
|
|
70
71
|
};
|
|
71
|
-
const
|
|
72
|
+
const setDynamicContextSessionSettings = () => {
|
|
73
|
+
setSessionSettings(localStorage$1.DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS);
|
|
74
|
+
dynamicContextSettingsTimer = setTimeout(isDynamicContextSessionSettingExpired, sdkSettingsTimeout);
|
|
75
|
+
};
|
|
76
|
+
const setWagmiSessionSettings = () => {
|
|
77
|
+
setSessionSettings(localStorage$1.WAGMI_LAST_SESSION_SETTINGS);
|
|
78
|
+
wagmiSettingsTimer = setTimeout(isWagmiSessionSettingExpired, sdkSettingsTimeout);
|
|
79
|
+
};
|
|
80
|
+
const setSessionSettings = (lsKey) => {
|
|
72
81
|
const timestamp = new Date().getTime();
|
|
73
|
-
localStorage.LocalStorage.setToLS(
|
|
74
|
-
sdkSettingsTimer = setTimeout(isSDKSessionSettingExpired, sdkSettingsTimeout);
|
|
82
|
+
localStorage.LocalStorage.setToLS(lsKey, timestamp.toString());
|
|
75
83
|
};
|
|
76
|
-
const
|
|
77
|
-
|
|
84
|
+
const isDynamicContextSessionSettingExpired = () => isSettingExpired(localStorage$1.DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, dynamicContextSettingsTimer);
|
|
85
|
+
const isWagmiSessionSettingExpired = () => isSettingExpired(localStorage$1.WAGMI_LAST_SESSION_SETTINGS, wagmiSettingsTimer);
|
|
86
|
+
const isSettingExpired = (lsKey, timer) => {
|
|
87
|
+
const lastSentTime = localStorage.LocalStorage.getFromLS(lsKey);
|
|
78
88
|
// should set new time
|
|
79
89
|
if (!lastSentTime) {
|
|
80
90
|
return true;
|
|
@@ -83,8 +93,8 @@ const isSDKSessionSettingExpired = () => {
|
|
|
83
93
|
const currentTime = new Date().getTime();
|
|
84
94
|
if (currentTime - lastSentTimestamp > sdkSettingsTimeout) {
|
|
85
95
|
// Reset session-related data here
|
|
86
|
-
clearTimeout(
|
|
87
|
-
localStorage.LocalStorage.removeFromLS(
|
|
96
|
+
clearTimeout(timer);
|
|
97
|
+
localStorage.LocalStorage.removeFromLS(lsKey);
|
|
88
98
|
return true;
|
|
89
99
|
}
|
|
90
100
|
return false;
|
|
@@ -93,6 +103,8 @@ const isSDKSessionSettingExpired = () => {
|
|
|
93
103
|
exports.getInitialView = getInitialView;
|
|
94
104
|
exports.initExpirationTime = initExpirationTime;
|
|
95
105
|
exports.isAuthTokenExpired = isAuthTokenExpired;
|
|
96
|
-
exports.
|
|
106
|
+
exports.isDynamicContextSessionSettingExpired = isDynamicContextSessionSettingExpired;
|
|
107
|
+
exports.isWagmiSessionSettingExpired = isWagmiSessionSettingExpired;
|
|
97
108
|
exports.sdkSettingsTimeout = sdkSettingsTimeout;
|
|
98
|
-
exports.
|
|
109
|
+
exports.setDynamicContextSessionSettings = setDynamicContextSessionSettings;
|
|
110
|
+
exports.setWagmiSessionSettings = setWagmiSessionSettings;
|
|
@@ -10,5 +10,7 @@ export declare const getInitialView: ({ connectedWallets, isBridgeFlow, isFullyC
|
|
|
10
10
|
isFullyConnected: boolean;
|
|
11
11
|
isMultiWalletEnabled: boolean;
|
|
12
12
|
}) => ViewType;
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
13
|
+
export declare const setDynamicContextSessionSettings: () => void;
|
|
14
|
+
export declare const setWagmiSessionSettings: () => void;
|
|
15
|
+
export declare const isDynamicContextSessionSettingExpired: () => boolean;
|
|
16
|
+
export declare const isWagmiSessionSettingExpired: () => boolean;
|
|
@@ -7,14 +7,15 @@ import 'react';
|
|
|
7
7
|
import '../../shared/logger.js';
|
|
8
8
|
import '@dynamic-labs/wallet-book';
|
|
9
9
|
import '@dynamic-labs/utils';
|
|
10
|
-
import {
|
|
10
|
+
import { DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, WAGMI_LAST_SESSION_SETTINGS } from '../../utils/constants/localStorage.js';
|
|
11
11
|
import '../../utils/constants/colors.js';
|
|
12
12
|
import { LocalStorage } from '../../shared/utils/classes/storage/localStorage.js';
|
|
13
13
|
import 'ethers';
|
|
14
14
|
import { getAuthToken } from '../../utils/functions/getAuthToken/getAuthToken.js';
|
|
15
15
|
|
|
16
16
|
let logoutTimer;
|
|
17
|
-
let
|
|
17
|
+
let dynamicContextSettingsTimer;
|
|
18
|
+
let wagmiSettingsTimer;
|
|
18
19
|
const sdkSettingsTimeout = 24 * 60 * 60 * 1000; // 24 hours
|
|
19
20
|
const isAuthTokenExpired = (token) => {
|
|
20
21
|
const decoded = decodeJwt(token);
|
|
@@ -64,13 +65,22 @@ const getInitialView = ({ connectedWallets, isBridgeFlow, isFullyConnected, isAu
|
|
|
64
65
|
}
|
|
65
66
|
return 'login-with-email-or-wallet';
|
|
66
67
|
};
|
|
67
|
-
const
|
|
68
|
+
const setDynamicContextSessionSettings = () => {
|
|
69
|
+
setSessionSettings(DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS);
|
|
70
|
+
dynamicContextSettingsTimer = setTimeout(isDynamicContextSessionSettingExpired, sdkSettingsTimeout);
|
|
71
|
+
};
|
|
72
|
+
const setWagmiSessionSettings = () => {
|
|
73
|
+
setSessionSettings(WAGMI_LAST_SESSION_SETTINGS);
|
|
74
|
+
wagmiSettingsTimer = setTimeout(isWagmiSessionSettingExpired, sdkSettingsTimeout);
|
|
75
|
+
};
|
|
76
|
+
const setSessionSettings = (lsKey) => {
|
|
68
77
|
const timestamp = new Date().getTime();
|
|
69
|
-
LocalStorage.setToLS(
|
|
70
|
-
sdkSettingsTimer = setTimeout(isSDKSessionSettingExpired, sdkSettingsTimeout);
|
|
78
|
+
LocalStorage.setToLS(lsKey, timestamp.toString());
|
|
71
79
|
};
|
|
72
|
-
const
|
|
73
|
-
|
|
80
|
+
const isDynamicContextSessionSettingExpired = () => isSettingExpired(DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, dynamicContextSettingsTimer);
|
|
81
|
+
const isWagmiSessionSettingExpired = () => isSettingExpired(WAGMI_LAST_SESSION_SETTINGS, wagmiSettingsTimer);
|
|
82
|
+
const isSettingExpired = (lsKey, timer) => {
|
|
83
|
+
const lastSentTime = LocalStorage.getFromLS(lsKey);
|
|
74
84
|
// should set new time
|
|
75
85
|
if (!lastSentTime) {
|
|
76
86
|
return true;
|
|
@@ -79,11 +89,11 @@ const isSDKSessionSettingExpired = () => {
|
|
|
79
89
|
const currentTime = new Date().getTime();
|
|
80
90
|
if (currentTime - lastSentTimestamp > sdkSettingsTimeout) {
|
|
81
91
|
// Reset session-related data here
|
|
82
|
-
clearTimeout(
|
|
83
|
-
LocalStorage.removeFromLS(
|
|
92
|
+
clearTimeout(timer);
|
|
93
|
+
LocalStorage.removeFromLS(lsKey);
|
|
84
94
|
return true;
|
|
85
95
|
}
|
|
86
96
|
return false;
|
|
87
97
|
};
|
|
88
98
|
|
|
89
|
-
export { getInitialView, initExpirationTime, isAuthTokenExpired,
|
|
99
|
+
export { getInitialView, initExpirationTime, isAuthTokenExpired, isDynamicContextSessionSettingExpired, isWagmiSessionSettingExpired, sdkSettingsTimeout, setDynamicContextSessionSettings, setWagmiSessionSettings };
|
|
@@ -15,10 +15,13 @@ const errorMessageMap = {
|
|
|
15
15
|
4001: 'Message signature denied.',
|
|
16
16
|
5001: 'Message signature denied.',
|
|
17
17
|
5002: 'Message signature denied.',
|
|
18
|
+
account_already_linked_to_different_profile: 'This social account is already linked to a different profile.',
|
|
18
19
|
connection_rejected: 'Connection rejected. Please try again.',
|
|
19
|
-
metamask_timeout: '
|
|
20
|
+
metamask_timeout: 'Whoops. Looks like something went wrong. Please try again.',
|
|
20
21
|
'missing-nonce': 'Something went wrong. Please try again.',
|
|
21
22
|
'missing-public-address': 'Connection cancelled. Please try again',
|
|
23
|
+
oauth_window_blocked: 'To connect to your social account, enable popups in your browser and then try again.',
|
|
24
|
+
oauth_window_timeout: 'Session time out. Please try again.',
|
|
22
25
|
too_many_email_verification_attempts: 'Too many email verification attempts, please try again later',
|
|
23
26
|
'user-cancelled': '',
|
|
24
27
|
wallet_not_deployed: 'Your smart wallet has not been deployed.',
|
|
@@ -11,10 +11,13 @@ const errorMessageMap = {
|
|
|
11
11
|
4001: 'Message signature denied.',
|
|
12
12
|
5001: 'Message signature denied.',
|
|
13
13
|
5002: 'Message signature denied.',
|
|
14
|
+
account_already_linked_to_different_profile: 'This social account is already linked to a different profile.',
|
|
14
15
|
connection_rejected: 'Connection rejected. Please try again.',
|
|
15
|
-
metamask_timeout: '
|
|
16
|
+
metamask_timeout: 'Whoops. Looks like something went wrong. Please try again.',
|
|
16
17
|
'missing-nonce': 'Something went wrong. Please try again.',
|
|
17
18
|
'missing-public-address': 'Connection cancelled. Please try again',
|
|
19
|
+
oauth_window_blocked: 'To connect to your social account, enable popups in your browser and then try again.',
|
|
20
|
+
oauth_window_timeout: 'Session time out. Please try again.',
|
|
18
21
|
too_many_email_verification_attempts: 'Too many email verification attempts, please try again later',
|
|
19
22
|
'user-cancelled': '',
|
|
20
23
|
wallet_not_deployed: 'Your smart wallet has not been deployed.',
|
|
@@ -50,7 +50,7 @@ require('../UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
|
50
50
|
|
|
51
51
|
const SocialRedirectContext = React.createContext(undefined);
|
|
52
52
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
53
|
-
var _a, _b;
|
|
53
|
+
var _a, _b, _c, _d;
|
|
54
54
|
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, connectWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
55
55
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
56
56
|
const { setView } = ViewContext.useViewContext();
|
|
@@ -61,10 +61,11 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
61
61
|
projectSettings,
|
|
62
62
|
setIsSingleWalletAccount,
|
|
63
63
|
});
|
|
64
|
-
const
|
|
65
|
-
const
|
|
64
|
+
const signInProvider = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.socialSignIn) === null || _a === void 0 ? void 0 : _a.signInProvider;
|
|
65
|
+
const enabledSocialProvidersInDb = (_c = (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.socialSignIn) === null || _b === void 0 ? void 0 : _b.providers) !== null && _c !== void 0 ? _c : [];
|
|
66
|
+
const enabledSocialProviders = (_d = enabledSocialProvidersInDb
|
|
66
67
|
.filter((provider) => provider.enabled)
|
|
67
|
-
.map((provider) => provider.provider);
|
|
68
|
+
.map((provider) => provider.provider)) !== null && _d !== void 0 ? _d : [];
|
|
68
69
|
const socialWalletConnector = wallets
|
|
69
70
|
.map(({ walletConnector }) => walletConnector)
|
|
70
71
|
.find(walletConnectorCore.isSocialWalletConnector);
|
|
@@ -187,11 +188,13 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
187
188
|
walletUiUtils,
|
|
188
189
|
wallet,
|
|
189
190
|
handleError,
|
|
191
|
+
connectWallet,
|
|
190
192
|
]);
|
|
191
193
|
return (jsxRuntime.jsx(SocialRedirectContext.Provider, Object.assign({ value: {
|
|
192
194
|
enabledSocialProviders,
|
|
193
195
|
redirectStatus,
|
|
194
196
|
setSocialProvider,
|
|
197
|
+
signInProvider,
|
|
195
198
|
socialAccount,
|
|
196
199
|
socialProvider,
|
|
197
200
|
socialWalletConnector,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api';
|
|
2
|
+
import { JwtVerifiedCredential, SignInProviderEnum, SocialSignInProviderEnum } from '@dynamic-labs/sdk-api';
|
|
4
3
|
import { WalletConnector } from '../../..';
|
|
5
4
|
type SocialRedirectStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
6
5
|
export type SocialContextReturnType = {
|
|
7
|
-
enabledSocialProviders:
|
|
6
|
+
enabledSocialProviders: SocialSignInProviderEnum[];
|
|
8
7
|
redirectStatus: SocialRedirectStatus;
|
|
9
|
-
setSocialProvider: (val
|
|
8
|
+
setSocialProvider: (val?: SocialSignInProviderEnum) => void;
|
|
10
9
|
socialAccount: JwtVerifiedCredential | undefined;
|
|
11
|
-
socialProvider:
|
|
10
|
+
socialProvider: SocialSignInProviderEnum | undefined;
|
|
12
11
|
socialWalletConnector: WalletConnector | undefined;
|
|
12
|
+
signInProvider: SignInProviderEnum | undefined;
|
|
13
13
|
};
|
|
14
14
|
export declare const SocialRedirectContext: import("react").Context<SocialContextReturnType | undefined>;
|
|
15
15
|
export declare const SocialRedirectContextProvider: ({ children, }: {
|
|
@@ -46,7 +46,7 @@ import '../UserFieldEditorContext/UserFieldEditorContext.js';
|
|
|
46
46
|
|
|
47
47
|
const SocialRedirectContext = createContext(undefined);
|
|
48
48
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
49
|
-
var _a, _b;
|
|
49
|
+
var _a, _b, _c, _d;
|
|
50
50
|
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, connectWallet, } = useInternalDynamicContext();
|
|
51
51
|
const { setErrorMessage } = useErrorContext();
|
|
52
52
|
const { setView } = useViewContext();
|
|
@@ -57,10 +57,11 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
57
57
|
projectSettings,
|
|
58
58
|
setIsSingleWalletAccount,
|
|
59
59
|
});
|
|
60
|
-
const
|
|
61
|
-
const
|
|
60
|
+
const signInProvider = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.socialSignIn) === null || _a === void 0 ? void 0 : _a.signInProvider;
|
|
61
|
+
const enabledSocialProvidersInDb = (_c = (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.socialSignIn) === null || _b === void 0 ? void 0 : _b.providers) !== null && _c !== void 0 ? _c : [];
|
|
62
|
+
const enabledSocialProviders = (_d = enabledSocialProvidersInDb
|
|
62
63
|
.filter((provider) => provider.enabled)
|
|
63
|
-
.map((provider) => provider.provider);
|
|
64
|
+
.map((provider) => provider.provider)) !== null && _d !== void 0 ? _d : [];
|
|
64
65
|
const socialWalletConnector = wallets
|
|
65
66
|
.map(({ walletConnector }) => walletConnector)
|
|
66
67
|
.find(isSocialWalletConnector);
|
|
@@ -183,11 +184,13 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
183
184
|
walletUiUtils,
|
|
184
185
|
wallet,
|
|
185
186
|
handleError,
|
|
187
|
+
connectWallet,
|
|
186
188
|
]);
|
|
187
189
|
return (jsx(SocialRedirectContext.Provider, Object.assign({ value: {
|
|
188
190
|
enabledSocialProviders,
|
|
189
191
|
redirectStatus,
|
|
190
192
|
setSocialProvider,
|
|
193
|
+
signInProvider,
|
|
191
194
|
socialAccount,
|
|
192
195
|
socialProvider,
|
|
193
196
|
socialWalletConnector,
|
package/src/lib/data/api.cjs
CHANGED
|
@@ -369,6 +369,10 @@ const verifyOAuth = (environmentId, providerType, { code, codeVerifier, state },
|
|
|
369
369
|
}
|
|
370
370
|
catch (e) {
|
|
371
371
|
logger.logger.error(e);
|
|
372
|
+
const data = yield e.json();
|
|
373
|
+
if (data.code === 'social_account_already_exists') {
|
|
374
|
+
throw new utils.SocialAccountAlreadyExistsError();
|
|
375
|
+
}
|
|
372
376
|
return undefined;
|
|
373
377
|
}
|
|
374
378
|
});
|
|
@@ -386,6 +390,34 @@ const unlinkOAuth = ({ environmentId, verifiedCrentialId, }, userJwt) => _tslib.
|
|
|
386
390
|
return undefined;
|
|
387
391
|
}
|
|
388
392
|
});
|
|
393
|
+
const signInOAuth = (environmentId, providerType, { code, codeVerifier, state }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
394
|
+
const oauthRequest = {
|
|
395
|
+
code,
|
|
396
|
+
codeVerifier,
|
|
397
|
+
state,
|
|
398
|
+
};
|
|
399
|
+
try {
|
|
400
|
+
const { jwt } = yield sdkApi().oauthSignIn({
|
|
401
|
+
environmentId,
|
|
402
|
+
oauthRequest,
|
|
403
|
+
providerType,
|
|
404
|
+
});
|
|
405
|
+
return jwt;
|
|
406
|
+
}
|
|
407
|
+
catch (e) {
|
|
408
|
+
logger.logger.error(e);
|
|
409
|
+
const data = yield e.json();
|
|
410
|
+
if (data.error.code === 'gate_blocked') {
|
|
411
|
+
throw new utils.GateBlockedError(data.payload.walletPublicKey);
|
|
412
|
+
}
|
|
413
|
+
if (data.error.code === 'missing_from_list') {
|
|
414
|
+
throw new utils.NoAccessError({
|
|
415
|
+
walletPublicKey: data.payload.walletPublicKey,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
return undefined;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
389
421
|
const getOnrampProviders = ({ chain, environmentId, networkId, token, walletAddress, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
390
422
|
const { onramps } = yield sdkApi().getSupportedOnramps({
|
|
391
423
|
chain,
|
|
@@ -401,26 +433,25 @@ const getOnrampProviders = ({ chain, environmentId, networkId, token, walletAddr
|
|
|
401
433
|
});
|
|
402
434
|
const sendDynamicProps = (environmentId, settingsToSend) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
403
435
|
try {
|
|
404
|
-
const isSettingsExpired = helpers.isSDKSessionSettingExpired();
|
|
405
|
-
// sent once. no need to send again
|
|
406
|
-
if (!isSettingsExpired) {
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
436
|
const { dynamicContextProps, dynamicWagmiSettings } = settingsToSend;
|
|
410
|
-
if (dynamicContextProps
|
|
411
|
-
yield
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
dynamicWagmiSettings,
|
|
416
|
-
},
|
|
417
|
-
});
|
|
437
|
+
if (dynamicContextProps) {
|
|
438
|
+
yield sendDynamicContextSettings(environmentId, { dynamicContextProps }, helpers.isDynamicContextSessionSettingExpired, helpers.setDynamicContextSessionSettings);
|
|
439
|
+
}
|
|
440
|
+
if (dynamicWagmiSettings) {
|
|
441
|
+
yield sendDynamicContextSettings(environmentId, { dynamicWagmiSettings }, helpers.isWagmiSessionSettingExpired, helpers.setWagmiSessionSettings);
|
|
418
442
|
}
|
|
419
|
-
helpers.setSDKSessionSettings();
|
|
420
443
|
}
|
|
421
|
-
catch (
|
|
422
|
-
logger.logger.error
|
|
444
|
+
catch (error) {
|
|
445
|
+
logger.logger.warn('Error caught when sending sdkSettings to api. Please notify Dynamic, and send the DynamicContextProvider settings you currently have configured', { error });
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
const sendDynamicContextSettings = (environmentId, sdkSettingsRequest, isSdkSettingExpired, setSDKSessionSettings) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
449
|
+
// sent once. no need to send again
|
|
450
|
+
if (!isSdkSettingExpired()) {
|
|
451
|
+
return;
|
|
423
452
|
}
|
|
453
|
+
yield sdkApi().logDynamicSdkSettings({ environmentId, sdkSettingsRequest });
|
|
454
|
+
setSDKSessionSettings();
|
|
424
455
|
});
|
|
425
456
|
const mergeUserAccounts = (userJwt, environmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
426
457
|
try {
|
|
@@ -451,6 +482,7 @@ exports.mergeUserAccounts = mergeUserAccounts;
|
|
|
451
482
|
exports.retryEmailVerification = retryEmailVerification;
|
|
452
483
|
exports.revokeSession = revokeSession;
|
|
453
484
|
exports.sendDynamicProps = sendDynamicProps;
|
|
485
|
+
exports.signInOAuth = signInOAuth;
|
|
454
486
|
exports.signInWithEmailVerification = signInWithEmailVerification;
|
|
455
487
|
exports.transferWallet = transferWallet;
|
|
456
488
|
exports.unlinkOAuth = unlinkOAuth;
|
package/src/lib/data/api.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export declare const unlinkOAuth: ({ environmentId, verifiedCrentialId, }: {
|
|
|
56
56
|
environmentId: string;
|
|
57
57
|
verifiedCrentialId: string;
|
|
58
58
|
}, userJwt: string) => Promise<string | undefined>;
|
|
59
|
+
export declare const signInOAuth: (environmentId: string, providerType: ProviderEnum, { code, codeVerifier, state }: OauthRequest) => Promise<string | undefined>;
|
|
59
60
|
export declare const getOnrampProviders: ({ chain, environmentId, networkId, token, walletAddress, }: {
|
|
60
61
|
chain: string;
|
|
61
62
|
environmentId: string;
|
package/src/lib/data/api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
2
|
-
import { NoAccessError, AccountExistsError, EmailVerificationError, UserHasAccountWithEmailError, DynamicError, EmailAlreadyExistsError, UsernameAlreadyExistsError, EmailProviderError, WalletUsedError, WalletNotDeployedError, ChainalysisError, GateBlockedError } from '@dynamic-labs/utils';
|
|
2
|
+
import { NoAccessError, AccountExistsError, EmailVerificationError, UserHasAccountWithEmailError, DynamicError, EmailAlreadyExistsError, UsernameAlreadyExistsError, EmailProviderError, WalletUsedError, WalletNotDeployedError, ChainalysisError, GateBlockedError, SocialAccountAlreadyExistsError } from '@dynamic-labs/utils';
|
|
3
3
|
import { UnprocessableEntityErrorCode, SDKApi, Configuration, VerifyRequestFromJSON, ChainEnum, WalletProviderEnum, AuthModeEnum } from '@dynamic-labs/sdk-api';
|
|
4
4
|
import { VERSION, API_VERSION } from '../../version.js';
|
|
5
5
|
import ApiEndpoint from '../config/ApiEndpoint.js';
|
|
@@ -14,7 +14,7 @@ import '../utils/constants/colors.js';
|
|
|
14
14
|
import '../shared/utils/classes/storage/localStorage.js';
|
|
15
15
|
import 'ethers';
|
|
16
16
|
import '../shared/consts/index.js';
|
|
17
|
-
import {
|
|
17
|
+
import { isDynamicContextSessionSettingExpired, setDynamicContextSessionSettings, isWagmiSessionSettingExpired, setWagmiSessionSettings } from '../context/DynamicContext/helpers.js';
|
|
18
18
|
|
|
19
19
|
const sdkApi = (jwt) => {
|
|
20
20
|
const settings = {
|
|
@@ -365,6 +365,10 @@ const verifyOAuth = (environmentId, providerType, { code, codeVerifier, state },
|
|
|
365
365
|
}
|
|
366
366
|
catch (e) {
|
|
367
367
|
logger.error(e);
|
|
368
|
+
const data = yield e.json();
|
|
369
|
+
if (data.code === 'social_account_already_exists') {
|
|
370
|
+
throw new SocialAccountAlreadyExistsError();
|
|
371
|
+
}
|
|
368
372
|
return undefined;
|
|
369
373
|
}
|
|
370
374
|
});
|
|
@@ -382,6 +386,34 @@ const unlinkOAuth = ({ environmentId, verifiedCrentialId, }, userJwt) => __await
|
|
|
382
386
|
return undefined;
|
|
383
387
|
}
|
|
384
388
|
});
|
|
389
|
+
const signInOAuth = (environmentId, providerType, { code, codeVerifier, state }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
390
|
+
const oauthRequest = {
|
|
391
|
+
code,
|
|
392
|
+
codeVerifier,
|
|
393
|
+
state,
|
|
394
|
+
};
|
|
395
|
+
try {
|
|
396
|
+
const { jwt } = yield sdkApi().oauthSignIn({
|
|
397
|
+
environmentId,
|
|
398
|
+
oauthRequest,
|
|
399
|
+
providerType,
|
|
400
|
+
});
|
|
401
|
+
return jwt;
|
|
402
|
+
}
|
|
403
|
+
catch (e) {
|
|
404
|
+
logger.error(e);
|
|
405
|
+
const data = yield e.json();
|
|
406
|
+
if (data.error.code === 'gate_blocked') {
|
|
407
|
+
throw new GateBlockedError(data.payload.walletPublicKey);
|
|
408
|
+
}
|
|
409
|
+
if (data.error.code === 'missing_from_list') {
|
|
410
|
+
throw new NoAccessError({
|
|
411
|
+
walletPublicKey: data.payload.walletPublicKey,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
return undefined;
|
|
415
|
+
}
|
|
416
|
+
});
|
|
385
417
|
const getOnrampProviders = ({ chain, environmentId, networkId, token, walletAddress, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
386
418
|
const { onramps } = yield sdkApi().getSupportedOnramps({
|
|
387
419
|
chain,
|
|
@@ -397,26 +429,25 @@ const getOnrampProviders = ({ chain, environmentId, networkId, token, walletAddr
|
|
|
397
429
|
});
|
|
398
430
|
const sendDynamicProps = (environmentId, settingsToSend) => __awaiter(void 0, void 0, void 0, function* () {
|
|
399
431
|
try {
|
|
400
|
-
const isSettingsExpired = isSDKSessionSettingExpired();
|
|
401
|
-
// sent once. no need to send again
|
|
402
|
-
if (!isSettingsExpired) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
432
|
const { dynamicContextProps, dynamicWagmiSettings } = settingsToSend;
|
|
406
|
-
if (dynamicContextProps
|
|
407
|
-
yield
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
dynamicWagmiSettings,
|
|
412
|
-
},
|
|
413
|
-
});
|
|
433
|
+
if (dynamicContextProps) {
|
|
434
|
+
yield sendDynamicContextSettings(environmentId, { dynamicContextProps }, isDynamicContextSessionSettingExpired, setDynamicContextSessionSettings);
|
|
435
|
+
}
|
|
436
|
+
if (dynamicWagmiSettings) {
|
|
437
|
+
yield sendDynamicContextSettings(environmentId, { dynamicWagmiSettings }, isWagmiSessionSettingExpired, setWagmiSessionSettings);
|
|
414
438
|
}
|
|
415
|
-
setSDKSessionSettings();
|
|
416
439
|
}
|
|
417
|
-
catch (
|
|
418
|
-
logger.error
|
|
440
|
+
catch (error) {
|
|
441
|
+
logger.warn('Error caught when sending sdkSettings to api. Please notify Dynamic, and send the DynamicContextProvider settings you currently have configured', { error });
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
const sendDynamicContextSettings = (environmentId, sdkSettingsRequest, isSdkSettingExpired, setSDKSessionSettings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
445
|
+
// sent once. no need to send again
|
|
446
|
+
if (!isSdkSettingExpired()) {
|
|
447
|
+
return;
|
|
419
448
|
}
|
|
449
|
+
yield sdkApi().logDynamicSdkSettings({ environmentId, sdkSettingsRequest });
|
|
450
|
+
setSDKSessionSettings();
|
|
420
451
|
});
|
|
421
452
|
const mergeUserAccounts = (userJwt, environmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
422
453
|
try {
|
|
@@ -431,4 +462,4 @@ const mergeUserAccounts = (userJwt, environmentId) => __awaiter(void 0, void 0,
|
|
|
431
462
|
}
|
|
432
463
|
});
|
|
433
464
|
|
|
434
|
-
export { createEmailVerification, createVisit, fetchNetworkSettings, fetchNonce, fetchProjectSettings, getEmailProvider, getOauthLoginUrl, getOnrampProviders, linkWallet, mapAuthModeTypeToEnum, mapChainToChainEnum, mapProviderToProviderEnum, mergeUserAccounts, retryEmailVerification, revokeSession, sendDynamicProps, signInWithEmailVerification, transferWallet, unlinkOAuth, unlinkWallet, updateUserProfileFields, verifyEmail, verifyOAuth, verifyWallet };
|
|
465
|
+
export { createEmailVerification, createVisit, fetchNetworkSettings, fetchNonce, fetchProjectSettings, getEmailProvider, getOauthLoginUrl, getOnrampProviders, linkWallet, mapAuthModeTypeToEnum, mapChainToChainEnum, mapProviderToProviderEnum, mergeUserAccounts, retryEmailVerification, revokeSession, sendDynamicProps, signInOAuth, signInWithEmailVerification, transferWallet, unlinkOAuth, unlinkWallet, updateUserProfileFields, verifyEmail, verifyOAuth, verifyWallet };
|
package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.cjs
CHANGED
|
@@ -91,7 +91,7 @@ const WalletListHelpContent = ({ chains, newToWeb3WalletChainMap, }) => {
|
|
|
91
91
|
if (!Object.keys((_b = walletBook$1 === null || walletBook$1 === void 0 ? void 0 : walletBook$1.wallets) !== null && _b !== void 0 ? _b : {}).length) {
|
|
92
92
|
return jsxRuntime.jsx(Skeleton.Skeleton, { className: 'walletlist-footer-content__container' });
|
|
93
93
|
}
|
|
94
|
-
return (jsxRuntime.jsx("div", Object.assign({ className: 'walletlist-help-content__container' }, { children: jsxRuntime.jsxs(EnterTileAnimation.EnterTileAnimation, Object.assign({ delay: '300ms' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'walletlist-help-content__icon' }, { children: jsxRuntime.jsx(walletBook.WalletIcon, {
|
|
94
|
+
return (jsxRuntime.jsx("div", Object.assign({ className: 'walletlist-help-content__container' }, { children: jsxRuntime.jsxs(EnterTileAnimation.EnterTileAnimation, Object.assign({ delay: '300ms' }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'walletlist-help-content__icon' }, { children: jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: walletName, style: { height: pixelToRem.pixelToRem(56), width: pixelToRem.pixelToRem(56) } }) })), jsxRuntime.jsxs("div", Object.assign({ className: 'walletlist-help-content__typography-wrapper' }, { children: [jsxRuntime.jsxs(Typography.Typography, Object.assign({ as: 'p', variant: 'title', weight: 'medium' }, { children: ["We recommend installing", ' ', walletBook.getWalletBookWallet(walletBook$1, walletName).name] })), jsxRuntime.jsx(Typography.Typography, Object.assign({ as: 'label', variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'walletlist-help-content__typography--label' }, { children: "Select your preferred option below:" }))] })), jsxRuntime.jsx("div", Object.assign({ className: 'walletlist-help-content__buttons-wrapper' }, { children: walletLinksElements.map((element, i) => element.isEnabled ? (jsxRuntime.jsx("button", Object.assign({ onClick: () => setSelectedUrl(element.url) }, { children: jsxRuntime.jsx(Item.Item, { StartIcon: element.icon, heading: element.content, url: element.url }) }), i)) : undefined) })), isCustodialServiceWallet && (jsxRuntime.jsxs("div", Object.assign({ className: 'walletlist-help-content__custodial-wallet-area' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ className: 'walletlist-help-content__custodial-wallet-area--title', as: 'p', color: 'secondary', variant: 'body_normal', weight: 'regular' }, { children: "If you don't want to install a wallet, then use:" })), jsxRuntime.jsx(NewToWeb3WalletItem.NewToWeb3WalletItem, { wallet: newToWeb3Wallet })] }))), jsxRuntime.jsx(WalletExtensionOrAppContinueButton.WalletExtensionOrAppContinueButton, { selectedUrl: selectedUrl, wallet: newToWeb3Wallet })] })) })));
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
exports.WalletListHelpContent = WalletListHelpContent;
|
package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.js
CHANGED
|
@@ -87,7 +87,7 @@ const WalletListHelpContent = ({ chains, newToWeb3WalletChainMap, }) => {
|
|
|
87
87
|
if (!Object.keys((_b = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _b !== void 0 ? _b : {}).length) {
|
|
88
88
|
return jsx(Skeleton, { className: 'walletlist-footer-content__container' });
|
|
89
89
|
}
|
|
90
|
-
return (jsx("div", Object.assign({ className: 'walletlist-help-content__container' }, { children: jsxs(EnterTileAnimation, Object.assign({ delay: '300ms' }, { children: [jsx("div", Object.assign({ className: 'walletlist-help-content__icon' }, { children: jsx(WalletIcon, {
|
|
90
|
+
return (jsx("div", Object.assign({ className: 'walletlist-help-content__container' }, { children: jsxs(EnterTileAnimation, Object.assign({ delay: '300ms' }, { children: [jsx("div", Object.assign({ className: 'walletlist-help-content__icon' }, { children: jsx(WalletIcon, { walletKey: walletName, style: { height: pixelToRem(56), width: pixelToRem(56) } }) })), jsxs("div", Object.assign({ className: 'walletlist-help-content__typography-wrapper' }, { children: [jsxs(Typography, Object.assign({ as: 'p', variant: 'title', weight: 'medium' }, { children: ["We recommend installing", ' ', getWalletBookWallet(walletBook, walletName).name] })), jsx(Typography, Object.assign({ as: 'label', variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'walletlist-help-content__typography--label' }, { children: "Select your preferred option below:" }))] })), jsx("div", Object.assign({ className: 'walletlist-help-content__buttons-wrapper' }, { children: walletLinksElements.map((element, i) => element.isEnabled ? (jsx("button", Object.assign({ onClick: () => setSelectedUrl(element.url) }, { children: jsx(Item, { StartIcon: element.icon, heading: element.content, url: element.url }) }), i)) : undefined) })), isCustodialServiceWallet && (jsxs("div", Object.assign({ className: 'walletlist-help-content__custodial-wallet-area' }, { children: [jsx(Typography, Object.assign({ className: 'walletlist-help-content__custodial-wallet-area--title', as: 'p', color: 'secondary', variant: 'body_normal', weight: 'regular' }, { children: "If you don't want to install a wallet, then use:" })), jsx(NewToWeb3WalletItem, { wallet: newToWeb3Wallet })] }))), jsx(WalletExtensionOrAppContinueButton, { selectedUrl: selectedUrl, wallet: newToWeb3Wallet })] })) })));
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
export { WalletListHelpContent };
|
|
@@ -27,9 +27,7 @@ var dyn_login = {
|
|
|
27
27
|
wallet_only: "Get your first wallet"
|
|
28
28
|
},
|
|
29
29
|
separators: {
|
|
30
|
-
|
|
31
|
-
email_or_wallets: "Or continue with a wallet",
|
|
32
|
-
wallets_or_email: "Or continue with"
|
|
30
|
+
"default": "Or"
|
|
33
31
|
},
|
|
34
32
|
title: {
|
|
35
33
|
all: "Log in or Sign up",
|
|
@@ -37,7 +35,7 @@ var dyn_login = {
|
|
|
37
35
|
wallet_only: "Select your wallet"
|
|
38
36
|
},
|
|
39
37
|
wallet_list: {
|
|
40
|
-
button_only: "
|
|
38
|
+
button_only: "Continue with a wallet"
|
|
41
39
|
}
|
|
42
40
|
};
|
|
43
41
|
var dyn_no_access = {
|
|
@@ -23,9 +23,7 @@ var dyn_login = {
|
|
|
23
23
|
wallet_only: "Get your first wallet"
|
|
24
24
|
},
|
|
25
25
|
separators: {
|
|
26
|
-
|
|
27
|
-
email_or_wallets: "Or continue with a wallet",
|
|
28
|
-
wallets_or_email: "Or continue with"
|
|
26
|
+
"default": "Or"
|
|
29
27
|
},
|
|
30
28
|
title: {
|
|
31
29
|
all: "Log in or Sign up",
|
|
@@ -33,7 +31,7 @@ var dyn_login = {
|
|
|
33
31
|
wallet_only: "Select your wallet"
|
|
34
32
|
},
|
|
35
33
|
wallet_list: {
|
|
36
|
-
button_only: "
|
|
34
|
+
button_only: "Continue with a wallet"
|
|
37
35
|
}
|
|
38
36
|
};
|
|
39
37
|
var dyn_no_access = {
|
|
@@ -144,6 +144,10 @@ export type DynamicRPCProviders = {
|
|
|
144
144
|
solanaProviders: SolanaRpcProvider[] | undefined;
|
|
145
145
|
};
|
|
146
146
|
export type DynamicEventsCallbacks = {
|
|
147
|
+
onSignedMessage?: (params: {
|
|
148
|
+
messageToSign: string;
|
|
149
|
+
signedMessage: string;
|
|
150
|
+
}) => void;
|
|
147
151
|
onAuthFlowClose?: () => void;
|
|
148
152
|
onAuthFlowOpen?: () => void;
|
|
149
153
|
onAuthSuccess?: OnAuthSuccess;
|
|
@@ -7,7 +7,7 @@ var walletBook = require('@dynamic-labs/wallet-book');
|
|
|
7
7
|
const createWallet = (walletBook$1, wallet) => {
|
|
8
8
|
var _a, _b;
|
|
9
9
|
return ({
|
|
10
|
-
group: (_a = walletBook.findWalletBookWallet(walletBook$1, wallet.
|
|
10
|
+
group: (_a = walletBook.findWalletBookWallet(walletBook$1, wallet.key)) === null || _a === void 0 ? void 0 : _a.group,
|
|
11
11
|
isInstalledOnBrowser: (_b = wallet.isInstalledOnBrowser()) !== null && _b !== void 0 ? _b : false,
|
|
12
12
|
key: wallet.key,
|
|
13
13
|
name: wallet.name,
|