@dynamic-labs/sdk-react-core 1.1.0-alpha.24 → 1.1.0-alpha.26
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 +27 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +12 -12
- package/src/index.cjs +4 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -0
- package/src/lib/components/Icon/Icon.cjs +1 -0
- package/src/lib/components/Icon/Icon.js +1 -0
- package/src/lib/components/Icon/Icon.types.d.ts +1 -1
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.cjs +1 -1
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.js +1 -1
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +13 -60
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +13 -60
- package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.cjs +97 -0
- package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.d.ts +9 -0
- package/src/lib/components/RetrySendVerificationCodeSection/RetrySendVerificationCodeSection.js +93 -0
- package/src/lib/components/RetrySendVerificationCodeSection/index.d.ts +1 -0
- package/src/lib/components/SocialSignIn/SocialSignIn.cjs +2 -2
- package/src/lib/components/SocialSignIn/SocialSignIn.js +2 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -3
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -3
- package/src/lib/context/DynamicContext/helpers/helpers.cjs +1 -0
- package/src/lib/context/DynamicContext/helpers/helpers.js +1 -0
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.cjs +1 -0
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.js +1 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +4 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +4 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +3 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/types.d.ts +2 -4
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +4 -50
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.d.ts +1 -1
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +4 -50
- package/src/lib/events/dynamicEvents.d.ts +2 -0
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +1 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +1 -2
- package/src/lib/shared/utils/functions/index.d.ts +1 -0
- package/src/lib/shared/utils/functions/providerLabel/index.d.ts +1 -0
- package/src/lib/shared/utils/functions/providerLabel/providerLabel.cjs +15 -0
- package/src/lib/shared/utils/functions/providerLabel/providerLabel.d.ts +2 -0
- package/src/lib/shared/utils/functions/providerLabel/providerLabel.js +11 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.cjs +1 -0
- package/src/lib/utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.js +1 -0
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.cjs +4 -0
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.js +4 -0
- package/src/lib/utils/functions/getReferencedAccount/getReferencedAccount.cjs +1 -0
- package/src/lib/utils/functions/getReferencedAccount/getReferencedAccount.js +1 -0
- package/src/lib/utils/functions/getUserWalletsFromVerifiedCredentials/getUserWalletsFromVerifiedCredentials.cjs +1 -0
- package/src/lib/utils/functions/getUserWalletsFromVerifiedCredentials/getUserWalletsFromVerifiedCredentials.js +1 -0
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.cjs +1 -1
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.js +1 -1
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -6
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -6
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +4 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +4 -5
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +38 -5
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +16 -5
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +39 -6
- package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs +1 -1
- package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js +1 -1
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +1 -1
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/index.d.ts +1 -0
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.cjs +21 -0
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.d.ts +4 -0
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.js +17 -0
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.cjs +3 -2
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.js +3 -2
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.cjs +1 -0
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.js +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -1
- package/src/lib/views/AccountExistsView/AccountExistsView.cjs +1 -1
- package/src/lib/views/AccountExistsView/AccountExistsView.js +1 -1
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +1 -1
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.cjs +6 -14
- package/src/lib/views/EmailVerification/EmailVerification.js +6 -14
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -1
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +1 -1
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +1 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +1 -0
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +1 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +1 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +1 -1
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +1 -1
- package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.cjs +1 -1
- package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.js +1 -1
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.cjs +1 -1
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.js +1 -1
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +1 -1
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +1 -1
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +1 -2
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +1 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +6 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +6 -1
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs +1 -1
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.js +1 -1
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -1
- package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.js +1 -1
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +0 -1
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +0 -49
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +0 -18
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +0 -44
|
@@ -13,11 +13,11 @@ import '../../constants/colors.js';
|
|
|
13
13
|
import '../../constants/values.js';
|
|
14
14
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
15
|
import 'viem';
|
|
16
|
+
import '@dynamic-labs/sdk-api';
|
|
16
17
|
import '../../../shared/consts/index.js';
|
|
17
18
|
import { createUserProfile } from '../createUserProfile/createUserProfile.js';
|
|
18
19
|
import '@dynamic-labs/multi-wallet';
|
|
19
20
|
import { getAuthToken } from '../getAuthToken/getAuthToken.js';
|
|
20
|
-
import '@dynamic-labs/sdk-api';
|
|
21
21
|
import { storeAuthToken } from '../storeAuthToken/index.js';
|
|
22
22
|
import 'viem/chains';
|
|
23
23
|
|
|
@@ -45,7 +45,6 @@ export * from './pixelToRem';
|
|
|
45
45
|
export * from './randomString';
|
|
46
46
|
export * from './removeElementById';
|
|
47
47
|
export * from './requiresTwoStepAuthentication';
|
|
48
|
-
export * from './sendTransactionWithAutoNonce';
|
|
49
48
|
export * from './shouldManuallyReconnectOnRefresh';
|
|
50
49
|
export * from './storeAuthToken';
|
|
51
50
|
export * from './stringifyURIQuery';
|
|
@@ -79,7 +79,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
79
79
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
80
80
|
const { engageCaptcha, getCaptchaToken } = CaptchaContext.useCaptchaContext();
|
|
81
81
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
82
|
-
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils,
|
|
82
|
+
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
83
83
|
const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
|
|
84
84
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
85
85
|
consumeNonce,
|
|
@@ -129,11 +129,14 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
129
129
|
setView('wait-for-email-confirmation-view');
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
const connectionResult = yield connectWallet(walletConnector, fetchPublicAddressOpts,
|
|
132
|
+
const connectionResult = yield connectWallet(walletConnector, fetchPublicAddressOpts, {
|
|
133
|
+
applyOnBeforeConnectSuccessConfirmation: shouldCallCallback,
|
|
134
|
+
raiseOnConnect: true,
|
|
135
|
+
});
|
|
133
136
|
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address)) {
|
|
134
137
|
return;
|
|
135
138
|
}
|
|
136
|
-
const { address
|
|
139
|
+
const { address } = connectionResult;
|
|
137
140
|
const walletNetwork = yield walletConnector.getNetwork();
|
|
138
141
|
// When we switch networks on MM/walletconnect, it breaks the flow and doesn't always display the sign message
|
|
139
142
|
// Since it the network doesn't matter for the sign, we don't need to force the user to switch to the supported
|
|
@@ -152,9 +155,6 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
152
155
|
return setView('network-not-supported');
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
|
-
setCallback('connectSuccess', {
|
|
156
|
-
walletId: id,
|
|
157
|
-
});
|
|
158
158
|
if (isConnectOnly.isConnectOnly(user, authMode)) {
|
|
159
159
|
localStorage.LocalStorage.setToLS(localStorage$1.LAST_USED_WALLET, walletConnector.key);
|
|
160
160
|
if (shouldUpdateWallets) {
|
|
@@ -75,7 +75,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
75
75
|
const { setView, goToInitialView } = useViewContext();
|
|
76
76
|
const { engageCaptcha, getCaptchaToken } = useCaptchaContext();
|
|
77
77
|
const { setErrorMessage } = useErrorContext();
|
|
78
|
-
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils,
|
|
78
|
+
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
79
79
|
const { handleWalletsToConnect } = useHandleWalletsToConnect();
|
|
80
80
|
const verifyWallet = useVerifyWallet({
|
|
81
81
|
consumeNonce,
|
|
@@ -125,11 +125,14 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
125
125
|
setView('wait-for-email-confirmation-view');
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
const connectionResult = yield connectWallet(walletConnector, fetchPublicAddressOpts,
|
|
128
|
+
const connectionResult = yield connectWallet(walletConnector, fetchPublicAddressOpts, {
|
|
129
|
+
applyOnBeforeConnectSuccessConfirmation: shouldCallCallback,
|
|
130
|
+
raiseOnConnect: true,
|
|
131
|
+
});
|
|
129
132
|
if (!(connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address)) {
|
|
130
133
|
return;
|
|
131
134
|
}
|
|
132
|
-
const { address
|
|
135
|
+
const { address } = connectionResult;
|
|
133
136
|
const walletNetwork = yield walletConnector.getNetwork();
|
|
134
137
|
// When we switch networks on MM/walletconnect, it breaks the flow and doesn't always display the sign message
|
|
135
138
|
// Since it the network doesn't matter for the sign, we don't need to force the user to switch to the supported
|
|
@@ -148,9 +151,6 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
148
151
|
return setView('network-not-supported');
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
|
-
setCallback('connectSuccess', {
|
|
152
|
-
walletId: id,
|
|
153
|
-
});
|
|
154
154
|
if (isConnectOnly(user, authMode)) {
|
|
155
155
|
LocalStorage.setToLS(LAST_USED_WALLET, walletConnector.key);
|
|
156
156
|
if (shouldUpdateWallets) {
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var utils = require('@dynamic-labs/utils');
|
|
7
|
+
var CaptchaContext = require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
7
8
|
require('react');
|
|
8
9
|
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
9
10
|
require('@dynamic-labs/sdk-api');
|
|
@@ -20,7 +21,6 @@ var localStorage = require('../../../../shared/utils/classes/storage/localStorag
|
|
|
20
21
|
require('viem');
|
|
21
22
|
require('../../../../shared/consts/index.cjs');
|
|
22
23
|
require('../../../../events/dynamicEvents.cjs');
|
|
23
|
-
var CaptchaContext = require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
24
24
|
var ErrorContext = require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
25
|
require('@dynamic-labs/multi-wallet');
|
|
26
26
|
require('viem/chains');
|
|
@@ -77,7 +77,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
77
77
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
78
78
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
79
79
|
const { getCaptchaToken, engageCaptcha } = CaptchaContext.useCaptchaContext();
|
|
80
|
-
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode,
|
|
80
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
81
81
|
const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
|
|
82
82
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
83
83
|
consumeNonce,
|
|
@@ -109,9 +109,8 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
109
109
|
setIsVerificationInProgress(true);
|
|
110
110
|
yield showPendingConnectView.showPendingConnectView(walletConnector, setView);
|
|
111
111
|
try {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
walletId: connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.id,
|
|
112
|
+
yield connectWallet(walletConnector, fetchPublicAddressOpts, {
|
|
113
|
+
raiseOnConnect: true,
|
|
115
114
|
});
|
|
116
115
|
if (isConnectOnly.isConnectOnly(user, authMode)) {
|
|
117
116
|
localStorage.LocalStorage.setToLS(localStorage$1.LAST_USED_WALLET, walletConnector.key);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { MissingPublicAddressError, isMobile } from '@dynamic-labs/utils';
|
|
3
|
+
import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
3
4
|
import 'react';
|
|
4
5
|
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
5
6
|
import '@dynamic-labs/sdk-api';
|
|
@@ -16,7 +17,6 @@ import { LocalStorage } from '../../../../shared/utils/classes/storage/localStor
|
|
|
16
17
|
import 'viem';
|
|
17
18
|
import '../../../../shared/consts/index.js';
|
|
18
19
|
import '../../../../events/dynamicEvents.js';
|
|
19
|
-
import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
20
20
|
import { useErrorContext } from '../../../../context/ErrorContext/ErrorContext.js';
|
|
21
21
|
import '@dynamic-labs/multi-wallet';
|
|
22
22
|
import 'viem/chains';
|
|
@@ -73,7 +73,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
73
73
|
const { setView, goToInitialView } = useViewContext();
|
|
74
74
|
const { setErrorMessage } = useErrorContext();
|
|
75
75
|
const { getCaptchaToken, engageCaptcha } = useCaptchaContext();
|
|
76
|
-
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode,
|
|
76
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
77
77
|
const { handleWalletsToConnect } = useHandleWalletsToConnect();
|
|
78
78
|
const verifyWallet = useVerifyWallet({
|
|
79
79
|
consumeNonce,
|
|
@@ -105,9 +105,8 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
105
105
|
setIsVerificationInProgress(true);
|
|
106
106
|
yield showPendingConnectView(walletConnector, setView);
|
|
107
107
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
walletId: connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.id,
|
|
108
|
+
yield connectWallet(walletConnector, fetchPublicAddressOpts, {
|
|
109
|
+
raiseOnConnect: true,
|
|
111
110
|
});
|
|
112
111
|
if (isConnectOnly(user, authMode)) {
|
|
113
112
|
LocalStorage.setToLS(LAST_USED_WALLET, walletConnector.key);
|
|
@@ -43,3 +43,4 @@ export { useWalletUiUtils } from './useWalletUiUtils';
|
|
|
43
43
|
export { useEmbeddedReveal } from './useEmbeddedReveal';
|
|
44
44
|
export { useWalletConnectorNetwork } from './useWalletConnectorNetwork';
|
|
45
45
|
export { useInitEmbeddedWalletAuthMethod } from './useInitEmbeddedWalletAuthMethod';
|
|
46
|
+
export { useEmbeddedWalletAuthenticator } from './useEmbeddedWalletAuthenticator';
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
9
|
var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
10
10
|
var api = require('../../../data/api.cjs');
|
|
11
11
|
require('@dynamic-labs/sdk-api');
|
|
@@ -22,14 +22,24 @@ require('viem');
|
|
|
22
22
|
var useLocalStorage = require('../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
23
23
|
require('../../../shared/consts/index.cjs');
|
|
24
24
|
require('@dynamic-labs/multi-wallet');
|
|
25
|
+
var getWalletIdentifier = require('../../functions/getWalletIdentifier/getWalletIdentifier.cjs');
|
|
25
26
|
var shouldManuallyReconnectOnRefresh = require('../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.cjs');
|
|
26
27
|
require('viem/chains');
|
|
27
28
|
var getWalletProvider = require('../../functions/getWalletProvider/getWalletProvider.cjs');
|
|
29
|
+
var isConnectOnly = require('../authenticationHooks/helpers/isConnectOnly.cjs');
|
|
30
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
28
31
|
var updateUserWalletsFromConnectedWallets = require('./updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.cjs');
|
|
29
32
|
|
|
30
|
-
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, }) => {
|
|
33
|
+
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, setIsVerificationInProgress, user, }) => {
|
|
31
34
|
const [connectedWalletsInfo, setConnectedWalletsInfo, removeConnectedWalletsInfo,] = useLocalStorage.useLocalStorage(localStorage.CONNECTED_WALLETS_INFO, []);
|
|
32
35
|
const [connectedWallets, _setConnectedWallets] = React.useState([]);
|
|
36
|
+
/**
|
|
37
|
+
* When a new wallet is connected with the onConnect callback enabled,
|
|
38
|
+
* this new wallet's id will hang in this array until we attest that the corresponding wallet object
|
|
39
|
+
* has been successfully built — at which point we raise the callback and pop the id from this array.
|
|
40
|
+
* Should be removed with QNTM-1082 refactor
|
|
41
|
+
*/
|
|
42
|
+
const onConnectWaitList = React.useRef(new Set());
|
|
33
43
|
const { setUserWallets } = UserWalletsContext.useInternalUserWallets();
|
|
34
44
|
/** This wrapper is to ensure userWallets is always properly updated alongside connectedWallets */
|
|
35
45
|
const setConnectedWallets = (newWallets) => {
|
|
@@ -107,7 +117,21 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
107
117
|
return walletObject;
|
|
108
118
|
})))).filter((wallet) => Boolean(wallet));
|
|
109
119
|
setConnectedWallets(updatedConnectedWallets);
|
|
110
|
-
|
|
120
|
+
// Raise any onConnect callbacks in wait list
|
|
121
|
+
for (const walletId of [...onConnectWaitList.current]) {
|
|
122
|
+
const wallet = updatedConnectedWallets.find((wallet) => getWalletIdentifier.getWalletIdentifier(wallet) === walletId);
|
|
123
|
+
if (!wallet)
|
|
124
|
+
continue;
|
|
125
|
+
onConnectWaitList.current.delete(walletId);
|
|
126
|
+
dynamicEvents.dynamicEvents.emit('walletConnected', wallet);
|
|
127
|
+
setIsVerificationInProgress(false);
|
|
128
|
+
}
|
|
129
|
+
}), [
|
|
130
|
+
connectedWalletsInfo,
|
|
131
|
+
setIsVerificationInProgress,
|
|
132
|
+
disconnectWallet,
|
|
133
|
+
walletConnectorOptions,
|
|
134
|
+
]);
|
|
111
135
|
// Generate the connectedWallets list when connectedWalletsInfo (localStorage) or memoized wallet connector updates
|
|
112
136
|
React.useEffect(() => {
|
|
113
137
|
updateConnectedWalletsList();
|
|
@@ -178,12 +202,14 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
178
202
|
});
|
|
179
203
|
});
|
|
180
204
|
const shouldSkipCreatingVisit = authMode === 'connect-only' && !enableVisitTrackingOnConnectOnly;
|
|
181
|
-
const connectWallet = (walletConnector, fetchPublicAddressOpts,
|
|
205
|
+
const connectWallet = (walletConnector, fetchPublicAddressOpts, options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
206
|
+
const { applyOnBeforeConnectSuccessConfirmation = true, raiseOnConnect = false, } = options !== null && options !== void 0 ? options : {};
|
|
182
207
|
const walletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
183
208
|
if (!walletAddress) {
|
|
184
209
|
throw new utils.MissingPublicAddressError();
|
|
185
210
|
}
|
|
186
|
-
if (onBeforeConnectSuccessConfirmation &&
|
|
211
|
+
if (onBeforeConnectSuccessConfirmation &&
|
|
212
|
+
applyOnBeforeConnectSuccessConfirmation) {
|
|
187
213
|
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
188
214
|
address: walletAddress,
|
|
189
215
|
chain: walletConnector.connectedChain,
|
|
@@ -196,6 +222,13 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
196
222
|
}
|
|
197
223
|
}
|
|
198
224
|
const walletId = `connect-wallet-${getNextIdAvailable(connectedWalletsInfo)}`;
|
|
225
|
+
// We are already using the new syntax for wallet ids for this.
|
|
226
|
+
// Eventually the connect-wallet-X syntax will be dropped
|
|
227
|
+
if (raiseOnConnect && isConnectOnly.isConnectOnly(user, authMode))
|
|
228
|
+
onConnectWaitList.current.add(getWalletIdentifier.getWalletIdentifier({
|
|
229
|
+
address: walletAddress,
|
|
230
|
+
connector: walletConnector,
|
|
231
|
+
}));
|
|
199
232
|
if (!primaryWalletId) {
|
|
200
233
|
setPrimaryWalletId(walletId);
|
|
201
234
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Chain, FetchPublicAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
import { ConnectWalletResult } from '../../../context/DynamicContext/types';
|
|
3
|
-
import { AuthModeType, OnBeforeConnectSuccessConfirmation, Wallet, WalletOption } from '../../../shared';
|
|
4
2
|
import { SetShowAuthFlow } from '../../../context/DynamicContext/hooks';
|
|
3
|
+
import { ConnectWalletResult } from '../../../context/DynamicContext/types';
|
|
4
|
+
import { AuthModeType, OnBeforeConnectSuccessConfirmation, UserProfile, Wallet, WalletOption } from '../../../shared';
|
|
5
5
|
export type ConnectedWalletConnectorType = {
|
|
6
6
|
id: string;
|
|
7
7
|
walletChain?: Chain;
|
|
8
8
|
walletConnectorKey: string;
|
|
9
9
|
provider: string;
|
|
10
10
|
};
|
|
11
|
-
type
|
|
11
|
+
export type UseConnectWalletProps = {
|
|
12
12
|
authMode: AuthModeType;
|
|
13
13
|
clearPrimaryWalletId: () => void;
|
|
14
14
|
enableVisitTrackingOnConnectOnly: boolean;
|
|
@@ -21,9 +21,20 @@ type Props = {
|
|
|
21
21
|
removeIsFullyConnected: () => void;
|
|
22
22
|
setShowAuthFlow: SetShowAuthFlow;
|
|
23
23
|
isBridgeFlow: boolean;
|
|
24
|
+
setIsVerificationInProgress: (newValue: boolean, checkWasSetOnDisable?: boolean | undefined) => void;
|
|
25
|
+
user: UserProfile | undefined;
|
|
26
|
+
};
|
|
27
|
+
export type ConnectWalletOptions = {
|
|
28
|
+
/** Whether to call onBeforeConnectSuccessConfirmation */
|
|
29
|
+
applyOnBeforeConnectSuccessConfirmation?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to raise onConnected callback after the connected wallet is built
|
|
32
|
+
* Should be removed after the userWallets refactor (QNTM-1082)
|
|
33
|
+
*/
|
|
34
|
+
raiseOnConnect?: boolean;
|
|
24
35
|
};
|
|
25
36
|
type UseConnectWalletValue = {
|
|
26
|
-
connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts,
|
|
37
|
+
connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts, options?: ConnectWalletOptions) => Promise<ConnectWalletResult | undefined>;
|
|
27
38
|
connectedWallets: Wallet[];
|
|
28
39
|
connectedWalletsInfo: ConnectedWalletConnectorType[];
|
|
29
40
|
getConnectedWalletById: (walletId: string) => Wallet | undefined;
|
|
@@ -31,5 +42,5 @@ type UseConnectWalletValue = {
|
|
|
31
42
|
removeConnectedWalletsInfo: () => void;
|
|
32
43
|
disconnectWallet: (walletId: string) => Promise<void>;
|
|
33
44
|
};
|
|
34
|
-
export declare const useConnectWallet: ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, }:
|
|
45
|
+
export declare const useConnectWallet: ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, setIsVerificationInProgress, user, }: UseConnectWalletProps) => UseConnectWalletValue;
|
|
35
46
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
3
|
-
import { getWalletConnectorByKey, logger } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
4
3
|
import { MissingPublicAddressError } from '@dynamic-labs/utils';
|
|
4
|
+
import { getWalletConnectorByKey, logger } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
6
6
|
import { createVisit } from '../../../data/api.js';
|
|
7
7
|
import '@dynamic-labs/sdk-api';
|
|
@@ -18,14 +18,24 @@ import 'viem';
|
|
|
18
18
|
import { useLocalStorage } from '../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
19
19
|
import '../../../shared/consts/index.js';
|
|
20
20
|
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import { getWalletIdentifier } from '../../functions/getWalletIdentifier/getWalletIdentifier.js';
|
|
21
22
|
import { shouldManuallyReconnectOnRefresh } from '../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
|
|
22
23
|
import 'viem/chains';
|
|
23
24
|
import { getWalletProvider } from '../../functions/getWalletProvider/getWalletProvider.js';
|
|
25
|
+
import { isConnectOnly } from '../authenticationHooks/helpers/isConnectOnly.js';
|
|
26
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
24
27
|
import { updateUserWalletsFromConnectedWallets } from './updateUserWalletsFromConnectedWallets/updateUserWalletsFromConnectedWallets.js';
|
|
25
28
|
|
|
26
|
-
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, }) => {
|
|
29
|
+
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, walletConnectorOptions, onDisconnect, onBeforeConnectSuccessConfirmation, removeIsFullyConnected, setShowAuthFlow, isBridgeFlow, setIsVerificationInProgress, user, }) => {
|
|
27
30
|
const [connectedWalletsInfo, setConnectedWalletsInfo, removeConnectedWalletsInfo,] = useLocalStorage(CONNECTED_WALLETS_INFO, []);
|
|
28
31
|
const [connectedWallets, _setConnectedWallets] = useState([]);
|
|
32
|
+
/**
|
|
33
|
+
* When a new wallet is connected with the onConnect callback enabled,
|
|
34
|
+
* this new wallet's id will hang in this array until we attest that the corresponding wallet object
|
|
35
|
+
* has been successfully built — at which point we raise the callback and pop the id from this array.
|
|
36
|
+
* Should be removed with QNTM-1082 refactor
|
|
37
|
+
*/
|
|
38
|
+
const onConnectWaitList = useRef(new Set());
|
|
29
39
|
const { setUserWallets } = useInternalUserWallets();
|
|
30
40
|
/** This wrapper is to ensure userWallets is always properly updated alongside connectedWallets */
|
|
31
41
|
const setConnectedWallets = (newWallets) => {
|
|
@@ -103,7 +113,21 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
103
113
|
return walletObject;
|
|
104
114
|
})))).filter((wallet) => Boolean(wallet));
|
|
105
115
|
setConnectedWallets(updatedConnectedWallets);
|
|
106
|
-
|
|
116
|
+
// Raise any onConnect callbacks in wait list
|
|
117
|
+
for (const walletId of [...onConnectWaitList.current]) {
|
|
118
|
+
const wallet = updatedConnectedWallets.find((wallet) => getWalletIdentifier(wallet) === walletId);
|
|
119
|
+
if (!wallet)
|
|
120
|
+
continue;
|
|
121
|
+
onConnectWaitList.current.delete(walletId);
|
|
122
|
+
dynamicEvents.emit('walletConnected', wallet);
|
|
123
|
+
setIsVerificationInProgress(false);
|
|
124
|
+
}
|
|
125
|
+
}), [
|
|
126
|
+
connectedWalletsInfo,
|
|
127
|
+
setIsVerificationInProgress,
|
|
128
|
+
disconnectWallet,
|
|
129
|
+
walletConnectorOptions,
|
|
130
|
+
]);
|
|
107
131
|
// Generate the connectedWallets list when connectedWalletsInfo (localStorage) or memoized wallet connector updates
|
|
108
132
|
useEffect(() => {
|
|
109
133
|
updateConnectedWalletsList();
|
|
@@ -174,12 +198,14 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
174
198
|
});
|
|
175
199
|
});
|
|
176
200
|
const shouldSkipCreatingVisit = authMode === 'connect-only' && !enableVisitTrackingOnConnectOnly;
|
|
177
|
-
const connectWallet = (walletConnector, fetchPublicAddressOpts,
|
|
201
|
+
const connectWallet = (walletConnector, fetchPublicAddressOpts, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
202
|
+
const { applyOnBeforeConnectSuccessConfirmation = true, raiseOnConnect = false, } = options !== null && options !== void 0 ? options : {};
|
|
178
203
|
const walletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
179
204
|
if (!walletAddress) {
|
|
180
205
|
throw new MissingPublicAddressError();
|
|
181
206
|
}
|
|
182
|
-
if (onBeforeConnectSuccessConfirmation &&
|
|
207
|
+
if (onBeforeConnectSuccessConfirmation &&
|
|
208
|
+
applyOnBeforeConnectSuccessConfirmation) {
|
|
183
209
|
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
184
210
|
address: walletAddress,
|
|
185
211
|
chain: walletConnector.connectedChain,
|
|
@@ -192,6 +218,13 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
192
218
|
}
|
|
193
219
|
}
|
|
194
220
|
const walletId = `connect-wallet-${getNextIdAvailable(connectedWalletsInfo)}`;
|
|
221
|
+
// We are already using the new syntax for wallet ids for this.
|
|
222
|
+
// Eventually the connect-wallet-X syntax will be dropped
|
|
223
|
+
if (raiseOnConnect && isConnectOnly(user, authMode))
|
|
224
|
+
onConnectWaitList.current.add(getWalletIdentifier({
|
|
225
|
+
address: walletAddress,
|
|
226
|
+
connector: walletConnector,
|
|
227
|
+
}));
|
|
195
228
|
if (!primaryWalletId) {
|
|
196
229
|
setPrimaryWalletId(walletId);
|
|
197
230
|
}
|
package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs
CHANGED
|
@@ -16,6 +16,7 @@ require('../../constants/colors.cjs');
|
|
|
16
16
|
require('../../constants/values.cjs');
|
|
17
17
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
18
|
require('viem');
|
|
19
|
+
require('@dynamic-labs/sdk-api');
|
|
19
20
|
require('@dynamic-labs/utils');
|
|
20
21
|
require('../../../shared/consts/index.cjs');
|
|
21
22
|
require('../../../events/dynamicEvents.cjs');
|
|
@@ -23,7 +24,6 @@ require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
|
23
24
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
25
|
var createUserProfile = require('../../functions/createUserProfile/createUserProfile.cjs');
|
|
25
26
|
require('@dynamic-labs/multi-wallet');
|
|
26
|
-
require('@dynamic-labs/sdk-api');
|
|
27
27
|
var index = require('../../functions/storeAuthToken/index.cjs');
|
|
28
28
|
require('viem/chains');
|
|
29
29
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js
CHANGED
|
@@ -12,6 +12,7 @@ import '../../constants/colors.js';
|
|
|
12
12
|
import '../../constants/values.js';
|
|
13
13
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
14
|
import 'viem';
|
|
15
|
+
import '@dynamic-labs/sdk-api';
|
|
15
16
|
import '@dynamic-labs/utils';
|
|
16
17
|
import '../../../shared/consts/index.js';
|
|
17
18
|
import '../../../events/dynamicEvents.js';
|
|
@@ -19,7 +20,6 @@ import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
|
19
20
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
21
|
import { createUserProfile } from '../../functions/createUserProfile/createUserProfile.js';
|
|
21
22
|
import '@dynamic-labs/multi-wallet';
|
|
22
|
-
import '@dynamic-labs/sdk-api';
|
|
23
23
|
import { storeAuthToken } from '../../functions/storeAuthToken/index.js';
|
|
24
24
|
import 'viem/chains';
|
|
25
25
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
@@ -16,6 +16,7 @@ require('../../constants/colors.cjs');
|
|
|
16
16
|
require('../../constants/values.cjs');
|
|
17
17
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
18
|
require('viem');
|
|
19
|
+
require('@dynamic-labs/sdk-api');
|
|
19
20
|
require('@dynamic-labs/utils');
|
|
20
21
|
require('../../../shared/consts/index.cjs');
|
|
21
22
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
@@ -23,7 +24,6 @@ require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
|
23
24
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
25
|
require('@dynamic-labs/multi-wallet');
|
|
25
26
|
var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
|
|
26
|
-
require('@dynamic-labs/sdk-api');
|
|
27
27
|
var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
|
|
28
28
|
require('viem/chains');
|
|
29
29
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
@@ -12,6 +12,7 @@ import '../../constants/colors.js';
|
|
|
12
12
|
import '../../constants/values.js';
|
|
13
13
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
14
|
import 'viem';
|
|
15
|
+
import '@dynamic-labs/sdk-api';
|
|
15
16
|
import '@dynamic-labs/utils';
|
|
16
17
|
import '../../../shared/consts/index.js';
|
|
17
18
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
@@ -19,7 +20,6 @@ import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
|
19
20
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
21
|
import '@dynamic-labs/multi-wallet';
|
|
21
22
|
import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
|
|
22
|
-
import '@dynamic-labs/sdk-api';
|
|
23
23
|
import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
|
|
24
24
|
import 'viem/chains';
|
|
25
25
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useEmbeddedWalletAuthenticator } from './useEmbeddedWalletAuthenticator';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var usePasskeyRecovery = require('../usePasskeyRecovery/usePasskeyRecovery.cjs');
|
|
7
|
+
|
|
8
|
+
const useEmbeddedWalletAuthenticator = () => {
|
|
9
|
+
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery.usePasskeyRecovery();
|
|
10
|
+
const createOrRefreshAuthenticatorSession = (authenticatorType) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
// user has passkey authenticator set up OR active session
|
|
12
|
+
// there is no need to create or refresh the authenticator
|
|
13
|
+
if (authenticatorType !== 'passkey' && !(yield shouldInitRecovery())) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return initPasskeyRecoveryProcess(authenticatorType);
|
|
17
|
+
});
|
|
18
|
+
return { createOrRefreshAuthenticatorSession };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.useEmbeddedWalletAuthenticator = useEmbeddedWalletAuthenticator;
|
package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AuthenticatorType } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
export declare const useEmbeddedWalletAuthenticator: () => {
|
|
3
|
+
createOrRefreshAuthenticatorSession: (authenticatorType?: AuthenticatorType) => Promise<import("../../../shared").Wallet | undefined>;
|
|
4
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { usePasskeyRecovery } from '../usePasskeyRecovery/usePasskeyRecovery.js';
|
|
3
|
+
|
|
4
|
+
const useEmbeddedWalletAuthenticator = () => {
|
|
5
|
+
const { initPasskeyRecoveryProcess, shouldInitRecovery } = usePasskeyRecovery();
|
|
6
|
+
const createOrRefreshAuthenticatorSession = (authenticatorType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
+
// user has passkey authenticator set up OR active session
|
|
8
|
+
// there is no need to create or refresh the authenticator
|
|
9
|
+
if (authenticatorType !== 'passkey' && !(yield shouldInitRecovery())) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return initPasskeyRecoveryProcess(authenticatorType);
|
|
13
|
+
});
|
|
14
|
+
return { createOrRefreshAuthenticatorSession };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { useEmbeddedWalletAuthenticator };
|
|
@@ -70,6 +70,7 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
|
|
|
70
70
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
71
71
|
|
|
72
72
|
const useIsLoggedIn = () => {
|
|
73
|
+
var _a, _b;
|
|
73
74
|
const { user, primaryWallet, authMode, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
74
75
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
75
76
|
// a user is set even when on connect-only mode if signing in with social,
|
|
@@ -78,8 +79,8 @@ const useIsLoggedIn = () => {
|
|
|
78
79
|
// if turnkey is enabled we need to check if the user that is logged/connected
|
|
79
80
|
// has a primaryWallet to not show the widget without secure
|
|
80
81
|
if (isTurnkeyProviderEnabled &&
|
|
81
|
-
(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.automaticEmbeddedWalletCreation) &&
|
|
82
|
-
(
|
|
82
|
+
((_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
|
|
83
|
+
!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup)) {
|
|
83
84
|
return Boolean(primaryWallet && isLoggedIn);
|
|
84
85
|
}
|
|
85
86
|
// return isLoggedIn;
|
|
@@ -66,6 +66,7 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
|
|
|
66
66
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
67
67
|
|
|
68
68
|
const useIsLoggedIn = () => {
|
|
69
|
+
var _a, _b;
|
|
69
70
|
const { user, primaryWallet, authMode, projectSettings } = useInternalDynamicContext();
|
|
70
71
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
71
72
|
// a user is set even when on connect-only mode if signing in with social,
|
|
@@ -74,8 +75,8 @@ const useIsLoggedIn = () => {
|
|
|
74
75
|
// if turnkey is enabled we need to check if the user that is logged/connected
|
|
75
76
|
// has a primaryWallet to not show the widget without secure
|
|
76
77
|
if (isTurnkeyProviderEnabled &&
|
|
77
|
-
(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.automaticEmbeddedWalletCreation) &&
|
|
78
|
-
(
|
|
78
|
+
((_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
|
|
79
|
+
!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup)) {
|
|
79
80
|
return Boolean(primaryWallet && isLoggedIn);
|
|
80
81
|
}
|
|
81
82
|
// return isLoggedIn;
|
|
@@ -14,6 +14,7 @@ require('../../constants/colors.cjs');
|
|
|
14
14
|
require('../../constants/values.cjs');
|
|
15
15
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
16
16
|
require('viem');
|
|
17
|
+
require('@dynamic-labs/sdk-api');
|
|
17
18
|
require('@dynamic-labs/utils');
|
|
18
19
|
require('../../../shared/consts/index.cjs');
|
|
19
20
|
|
|
@@ -10,6 +10,7 @@ import '../../constants/colors.js';
|
|
|
10
10
|
import '../../constants/values.js';
|
|
11
11
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
12
12
|
import 'viem';
|
|
13
|
+
import '@dynamic-labs/sdk-api';
|
|
13
14
|
import '@dynamic-labs/utils';
|
|
14
15
|
import '../../../shared/consts/index.js';
|
|
15
16
|
|
|
@@ -17,13 +17,13 @@ require('../../../constants/colors.cjs');
|
|
|
17
17
|
require('../../../constants/values.cjs');
|
|
18
18
|
require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
19
|
require('viem');
|
|
20
|
+
require('@dynamic-labs/sdk-api');
|
|
20
21
|
require('@dynamic-labs/utils');
|
|
21
22
|
require('../../../../shared/consts/index.cjs');
|
|
22
23
|
require('../../../../events/dynamicEvents.cjs');
|
|
23
24
|
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
24
25
|
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
26
|
require('@dynamic-labs/multi-wallet');
|
|
26
|
-
require('@dynamic-labs/sdk-api');
|
|
27
27
|
require('viem/chains');
|
|
28
28
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
29
29
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|