@dynamic-labs/sdk-react-core 4.91.2 → 4.91.4
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 +20 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/lib/client/client.cjs +1 -1
- package/src/lib/client/client.js +1 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +4 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +4 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +3 -0
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +3 -0
- package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.cjs +1 -1
- package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.js +1 -1
- package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +13 -1
- package/src/lib/context/ErrorContext/ErrorContext.cjs +48 -28
- package/src/lib/context/ErrorContext/ErrorContext.js +49 -29
- package/src/lib/context/OnrampContext/OnrampContext.cjs +21 -16
- package/src/lib/context/OnrampContext/OnrampContext.js +21 -16
- package/src/lib/context/SendBalanceContext/SendBalanceContext.errors.cjs +2 -2
- package/src/lib/context/SendBalanceContext/SendBalanceContext.errors.js +2 -2
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +3 -3
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +3 -3
- package/src/lib/data/api/email/email.cjs +6 -3
- package/src/lib/data/api/email/email.js +6 -3
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +15 -14
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +8 -7
- package/src/lib/data/api/exchangeAccounts/exchangeAccounts.cjs +3 -3
- package/src/lib/data/api/exchangeAccounts/exchangeAccounts.js +3 -3
- package/src/lib/data/api/oauth/oauth.cjs +3 -2
- package/src/lib/data/api/oauth/oauth.js +3 -2
- package/src/lib/data/api/session/session.cjs +3 -3
- package/src/lib/data/api/session/session.js +3 -3
- package/src/lib/data/api/sms/sms.cjs +4 -1
- package/src/lib/data/api/sms/sms.js +4 -1
- package/src/lib/data/api/user/user.cjs +5 -5
- package/src/lib/data/api/user/user.js +6 -6
- package/src/lib/data/api/utils.cjs +6 -1
- package/src/lib/data/api/utils.d.ts +1 -0
- package/src/lib/data/api/utils.js +6 -2
- package/src/lib/data/api/wallets/wallets.cjs +17 -15
- package/src/lib/data/api/wallets/wallets.js +18 -16
- package/src/lib/events/auth.d.ts +3 -2
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +2 -1
- package/src/lib/store/state/nonce/nonce.cjs +1 -1
- package/src/lib/store/state/nonce/nonce.js +1 -1
- package/src/lib/utils/functions/generateMessages/index.cjs +3 -3
- package/src/lib/utils/functions/generateMessages/index.js +3 -3
- package/src/lib/utils/functions/getEmbeddedWalletAuthHandler/getEmbeddedWalletAuthHandler.cjs +1 -1
- package/src/lib/utils/functions/getEmbeddedWalletAuthHandler/getEmbeddedWalletAuthHandler.js +1 -1
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.cjs +30 -0
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.d.ts +17 -0
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.js +29 -1
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.cjs +13 -1
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.d.ts +2 -1
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.js +14 -2
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.cjs +4 -0
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.js +5 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +2 -2
- package/src/lib/utils/hooks/useAuthenticateConnectedUser/useAuthenticateConnectedUser.cjs +2 -2
- package/src/lib/utils/hooks/useAuthenticateConnectedUser/useAuthenticateConnectedUser.js +2 -2
- package/src/lib/utils/hooks/useConfirmationPortal/useConfirmationPortal.cjs +1 -1
- package/src/lib/utils/hooks/useConfirmationPortal/useConfirmationPortal.js +1 -1
- package/src/lib/utils/hooks/useConnectExchangeForFunding/useConnectExchangeForFunding.cjs +1 -1
- package/src/lib/utils/hooks/useConnectExchangeForFunding/useConnectExchangeForFunding.js +1 -1
- package/src/lib/utils/hooks/useConnectUnifiedForFunding/useConnectUnifiedForFunding.cjs +2 -2
- package/src/lib/utils/hooks/useConnectUnifiedForFunding/useConnectUnifiedForFunding.js +2 -2
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.cjs +1 -1
- package/src/lib/utils/hooks/useConnectWallet/HandleConnectWalletRejectionError.js +1 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +1 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +1 -1
- package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/errors/ConnectorSetupError.cjs +1 -1
- package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/errors/ConnectorSetupError.js +1 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +8 -8
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +8 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +4 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +4 -4
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +9 -9
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +9 -9
- package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.cjs +2 -2
- package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.js +2 -2
- package/src/lib/utils/hooks/useFundingHelpers/useFundingHelpers.cjs +2 -2
- package/src/lib/utils/hooks/useFundingHelpers/useFundingHelpers.js +2 -2
- package/src/lib/utils/hooks/useGetMfaToken/useGetMfaToken.cjs +1 -1
- package/src/lib/utils/hooks/useGetMfaToken/useGetMfaToken.js +1 -1
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.cjs +2 -2
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.js +2 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +2 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +2 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +2 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +2 -2
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +2 -2
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +2 -2
- package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.cjs +3 -3
- package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.js +3 -3
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +1 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +1 -1
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.cjs +1 -1
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.js +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.cjs +3 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.js +3 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.cjs +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.js +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -2
- package/src/lib/utils/hooks/useViewSettings/useViewSettings.d.ts +5 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +1 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +1 -1
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +1 -1
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +1 -1
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.cjs +1 -1
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.js +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.cjs +4 -4
- package/src/lib/views/EmailVerification/EmailVerification.js +4 -4
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +2 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +2 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +2 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +2 -2
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.cjs +2 -2
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.js +2 -2
- package/src/lib/views/ExportSharesView/ExportSharesView.cjs +2 -2
- package/src/lib/views/ExportSharesView/ExportSharesView.js +2 -2
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +2 -2
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +2 -2
- package/src/lib/views/LoginView/useLoginView/useLoginView.cjs +1 -1
- package/src/lib/views/LoginView/useLoginView/useLoginView.js +1 -1
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +1 -1
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +1 -1
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +2 -2
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +2 -2
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.js +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.js +1 -1
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +3 -3
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +3 -3
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +14 -14
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +14 -14
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +2 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.js +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +2 -2
- package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.cjs +1 -1
- package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.js +1 -1
- package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.cjs +1 -1
- package/src/lib/views/WalletUpgradeFlowView/WalletUpgradeFlowView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/getPromptAmountParams/getPromptAmountParams.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/getPromptAmountParams/getPromptAmountParams.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useSubmitWalletFunding/useSubmitWalletFunding.cjs +10 -1
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useSubmitWalletFunding/useSubmitWalletFunding.js +10 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isAccountAbstractionConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { supportsUserOpPath, findBlockExplorerPattern } from './blockExplorerPatterns.js';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
const USER_OP_PATH_PREFIX = '/op/';
|
|
7
|
+
const getTransactionLink = (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, transactionHash, userOpSupportedExplorers, }) {
|
|
6
8
|
try {
|
|
7
9
|
if (!walletConnector) {
|
|
8
10
|
return undefined;
|
|
@@ -10,6 +12,16 @@ const getTransactionLink = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
10
12
|
const [blockExplorerUrl] = yield walletConnector.getBlockExplorerUrlsForCurrentNetwork();
|
|
11
13
|
if (!blockExplorerUrl)
|
|
12
14
|
return undefined;
|
|
15
|
+
// AA connectors (e.g. ZeroDev) return a userOp hash, which should
|
|
16
|
+
// link to /op/{hash} on supported block explorers instead of /tx/{hash}.
|
|
17
|
+
// Not all block explorers support the /op/ route, so we check against
|
|
18
|
+
// a known list plus any customer-provided overrides.
|
|
19
|
+
if (isAccountAbstractionConnector(walletConnector) &&
|
|
20
|
+
supportsUserOpPath(blockExplorerUrl, userOpSupportedExplorers)) {
|
|
21
|
+
const url = new URL(blockExplorerUrl);
|
|
22
|
+
url.pathname = `${USER_OP_PATH_PREFIX}${transactionHash}`;
|
|
23
|
+
return url.toString();
|
|
24
|
+
}
|
|
13
25
|
// Find the appropriate pattern for this block explorer
|
|
14
26
|
const pattern = findBlockExplorerPattern(blockExplorerUrl);
|
|
15
27
|
// Generate the transaction URL using the pattern
|
|
@@ -59,6 +59,10 @@ const getVerifyArgs = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* (
|
|
|
59
59
|
});
|
|
60
60
|
return result;
|
|
61
61
|
}
|
|
62
|
+
if (!nonce.getNonce()) {
|
|
63
|
+
logger.logger.debug('[getVerifyArgs] Nonce missing, attempting to fetch');
|
|
64
|
+
yield nonce.fetchAndStoreNonce();
|
|
65
|
+
}
|
|
62
66
|
const nonce$1 = nonce.consumeNonce();
|
|
63
67
|
// generate message to sign and then initiate signing step to prove ownership
|
|
64
68
|
const { messageToSign, signedMessage } = yield index.generateMessages(publicWalletAddress, walletConnector, nonce$1, environmentId, displaySiweStatement, siweStatement);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { logger } from '../../../shared/logger.js';
|
|
4
4
|
import { generateMessages } from '../generateMessages/index.js';
|
|
5
|
-
import { consumeNonce } from '../../../store/state/nonce/nonce.js';
|
|
5
|
+
import { getNonce, fetchAndStoreNonce, consumeNonce } from '../../../store/state/nonce/nonce.js';
|
|
6
6
|
|
|
7
7
|
// TODO - This function is doing too much we should split it up.
|
|
8
8
|
const getVerifyArgs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, signedMessageOverride, messageToSignOverride, }) {
|
|
@@ -55,6 +55,10 @@ const getVerifyArgs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ walle
|
|
|
55
55
|
});
|
|
56
56
|
return result;
|
|
57
57
|
}
|
|
58
|
+
if (!getNonce()) {
|
|
59
|
+
logger.debug('[getVerifyArgs] Nonce missing, attempting to fetch');
|
|
60
|
+
yield fetchAndStoreNonce();
|
|
61
|
+
}
|
|
58
62
|
const nonce = consumeNonce();
|
|
59
63
|
// generate message to sign and then initiate signing step to prove ownership
|
|
60
64
|
const { messageToSign, signedMessage } = yield generateMessages(publicWalletAddress, walletConnector, nonce, environmentId, displaySiweStatement, siweStatement);
|
|
@@ -76,7 +76,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
76
76
|
});
|
|
77
77
|
const handleWalletVerifyError = (err) => {
|
|
78
78
|
var _a;
|
|
79
|
-
const userCancelled = (err === null || err === void 0 ? void 0 : err.code) ===
|
|
79
|
+
const userCancelled = (err === null || err === void 0 ? void 0 : err.code) === utils.SdkErrorCode.USER_CANCELLED;
|
|
80
80
|
if (!userCancelled)
|
|
81
81
|
logger.logger.debug(err);
|
|
82
82
|
instrumentAuthLoginFailed.instrumentAuthLoginFailed(err, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { DeferredPromise, StorageService, CustomError, GetAddressCancelledError } from '@dynamic-labs/utils';
|
|
3
|
+
import { DeferredPromise, StorageService, SdkErrorCode, CustomError, GetAddressCancelledError } from '@dynamic-labs/utils';
|
|
4
4
|
import { isEmailWalletConnector, isEmailOTPWalletConnector, isBloctoConnector, getWalletProvider, isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
6
6
|
import '../../../../context/DynamicContext/useDynamicContext/useDynamicContext.js';
|
|
@@ -72,7 +72,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
72
72
|
});
|
|
73
73
|
const handleWalletVerifyError = (err) => {
|
|
74
74
|
var _a;
|
|
75
|
-
const userCancelled = (err === null || err === void 0 ? void 0 : err.code) ===
|
|
75
|
+
const userCancelled = (err === null || err === void 0 ? void 0 : err.code) === SdkErrorCode.USER_CANCELLED;
|
|
76
76
|
if (!userCancelled)
|
|
77
77
|
logger.debug(err);
|
|
78
78
|
instrumentAuthLoginFailed(err, {
|
|
@@ -129,11 +129,11 @@ const useOtpVerificationRequestRaw = () => {
|
|
|
129
129
|
const verifyOtp = React.useCallback((handleVerificationRequired, verificationToken, destination, localVerificationUUID) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
130
130
|
var _a;
|
|
131
131
|
if (!user && !userWithMissingInfo)
|
|
132
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
132
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
133
133
|
// VerificationUUID is saved in the context in case the view changes
|
|
134
134
|
// after a profile update (changing the view from edit profile to verify email)
|
|
135
135
|
if (!localVerificationUUID && !contextVerificationUUID)
|
|
136
|
-
throw new utils.DynamicError('No verification UUID is available');
|
|
136
|
+
throw new utils.DynamicError('No verification UUID is available', 'no_verification_uuid_is_available');
|
|
137
137
|
const verificationUUID = (localVerificationUUID !== null && localVerificationUUID !== void 0 ? localVerificationUUID : contextVerificationUUID);
|
|
138
138
|
const verify = destination === 'email' ? email.verifyEmail : sms.verifySms;
|
|
139
139
|
const updateSelfResponse = yield verify({
|
|
@@ -125,11 +125,11 @@ const useOtpVerificationRequestRaw = () => {
|
|
|
125
125
|
const verifyOtp = useCallback((handleVerificationRequired, verificationToken, destination, localVerificationUUID) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
126
|
var _a;
|
|
127
127
|
if (!user && !userWithMissingInfo)
|
|
128
|
-
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
128
|
+
throw new DynamicError(USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
129
129
|
// VerificationUUID is saved in the context in case the view changes
|
|
130
130
|
// after a profile update (changing the view from edit profile to verify email)
|
|
131
131
|
if (!localVerificationUUID && !contextVerificationUUID)
|
|
132
|
-
throw new DynamicError('No verification UUID is available');
|
|
132
|
+
throw new DynamicError('No verification UUID is available', 'no_verification_uuid_is_available');
|
|
133
133
|
const verificationUUID = (localVerificationUUID !== null && localVerificationUUID !== void 0 ? localVerificationUUID : contextVerificationUUID);
|
|
134
134
|
const verify = destination === 'email' ? verifyEmail : verifySms;
|
|
135
135
|
const updateSelfResponse = yield verify({
|
|
@@ -120,10 +120,10 @@ const useAuthenticateConnectedUser = () => {
|
|
|
120
120
|
const [isAuthenticating, setIsAuthenticating] = React.useState(false);
|
|
121
121
|
const authenticateUser = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
122
122
|
if (user) {
|
|
123
|
-
throw new utils.DynamicError('User is already authenticated');
|
|
123
|
+
throw new utils.DynamicError('User is already authenticated', 'user_is_already_authenticated');
|
|
124
124
|
}
|
|
125
125
|
if (connectedWallets.length === 0) {
|
|
126
|
-
throw new utils.DynamicError('No connected wallet');
|
|
126
|
+
throw new utils.DynamicError('No connected wallet', 'no_connected_wallet');
|
|
127
127
|
}
|
|
128
128
|
const connectedWallet = connectedWallets[0];
|
|
129
129
|
setIsAuthenticating(true);
|
|
@@ -116,10 +116,10 @@ const useAuthenticateConnectedUser = () => {
|
|
|
116
116
|
const [isAuthenticating, setIsAuthenticating] = useState(false);
|
|
117
117
|
const authenticateUser = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
118
|
if (user) {
|
|
119
|
-
throw new DynamicError('User is already authenticated');
|
|
119
|
+
throw new DynamicError('User is already authenticated', 'user_is_already_authenticated');
|
|
120
120
|
}
|
|
121
121
|
if (connectedWallets.length === 0) {
|
|
122
|
-
throw new DynamicError('No connected wallet');
|
|
122
|
+
throw new DynamicError('No connected wallet', 'no_connected_wallet');
|
|
123
123
|
}
|
|
124
124
|
const connectedWallet = connectedWallets[0];
|
|
125
125
|
setIsAuthenticating(true);
|
|
@@ -30,7 +30,7 @@ const useConfirmationPortal = ({ onResolve, onReject, defaultErrorMessage, }) =>
|
|
|
30
30
|
return onResolve(successResponseRef.current);
|
|
31
31
|
}
|
|
32
32
|
const error = errorRef.current ||
|
|
33
|
-
new utils.DynamicError(defaultErrorMessage || 'Something went wrong');
|
|
33
|
+
new utils.DynamicError(defaultErrorMessage || 'Something went wrong', 'defaulterrormessage_something_went_wrong');
|
|
34
34
|
return onReject(error);
|
|
35
35
|
}, [onResolve, onReject, defaultErrorMessage]);
|
|
36
36
|
const onSuccess = (response, closePortal = true) => {
|
|
@@ -26,7 +26,7 @@ const useConfirmationPortal = ({ onResolve, onReject, defaultErrorMessage, }) =>
|
|
|
26
26
|
return onResolve(successResponseRef.current);
|
|
27
27
|
}
|
|
28
28
|
const error = errorRef.current ||
|
|
29
|
-
new DynamicError(defaultErrorMessage || 'Something went wrong');
|
|
29
|
+
new DynamicError(defaultErrorMessage || 'Something went wrong', 'defaulterrormessage_something_went_wrong');
|
|
30
30
|
return onReject(error);
|
|
31
31
|
}, [onResolve, onReject, defaultErrorMessage]);
|
|
32
32
|
const onSuccess = (response, closePortal = true) => {
|
|
@@ -19,7 +19,7 @@ const useConnectExchangeForFunding = () => {
|
|
|
19
19
|
const { selectExchangeConfig } = useFundingExchangeHelpers.useFundingExchangeHelpers();
|
|
20
20
|
const promiseRef = React.useRef(null);
|
|
21
21
|
useDynamicEvents.useInternalDynamicEvents('authFlowClose', () => {
|
|
22
|
-
rejectPromiseRef.rejectPromiseRef(promiseRef, new utils.DynamicError('User cancelled'));
|
|
22
|
+
rejectPromiseRef.rejectPromiseRef(promiseRef, new utils.DynamicError('User cancelled', 'user_cancelled'));
|
|
23
23
|
});
|
|
24
24
|
return React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ initiatedByWidget }) {
|
|
25
25
|
if (promiseRef.current)
|
|
@@ -15,7 +15,7 @@ const useConnectExchangeForFunding = () => {
|
|
|
15
15
|
const { selectExchangeConfig } = useFundingExchangeHelpers();
|
|
16
16
|
const promiseRef = useRef(null);
|
|
17
17
|
useInternalDynamicEvents('authFlowClose', () => {
|
|
18
|
-
rejectPromiseRef(promiseRef, new DynamicError('User cancelled'));
|
|
18
|
+
rejectPromiseRef(promiseRef, new DynamicError('User cancelled', 'user_cancelled'));
|
|
19
19
|
});
|
|
20
20
|
return useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ initiatedByWidget }) {
|
|
21
21
|
if (promiseRef.current)
|
|
@@ -24,7 +24,7 @@ const useConnectUnifiedForFunding = () => {
|
|
|
24
24
|
const { selectExchangeConfig } = useFundingExchangeHelpers.useFundingExchangeHelpers();
|
|
25
25
|
const promiseRef = React.useRef(null);
|
|
26
26
|
useDynamicEvents.useInternalDynamicEvents('authFlowClose', () => {
|
|
27
|
-
rejectPromiseRef.rejectPromiseRef(promiseRef, new utils.DynamicError('User cancelled'));
|
|
27
|
+
rejectPromiseRef.rejectPromiseRef(promiseRef, new utils.DynamicError('User cancelled', 'user_cancelled'));
|
|
28
28
|
});
|
|
29
29
|
const openList = React.useCallback((initiatedByWidget) => {
|
|
30
30
|
const { onSelectExchange } = selectExchangeConfig({
|
|
@@ -61,7 +61,7 @@ const useConnectUnifiedForFunding = () => {
|
|
|
61
61
|
initiatedByWidgetRef.current = initiatedByWidget;
|
|
62
62
|
const walletAddress = yield getWalletAddress(walletConnector);
|
|
63
63
|
if (!walletAddress) {
|
|
64
|
-
rejectPromiseRef.rejectPromiseRef(promiseRef, new utils.DynamicError('No wallet address found'));
|
|
64
|
+
rejectPromiseRef.rejectPromiseRef(promiseRef, new utils.DynamicError('No wallet address found', 'no_wallet_address_found'));
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
const wallet = walletConnector.createWallet({
|
|
@@ -20,7 +20,7 @@ const useConnectUnifiedForFunding = () => {
|
|
|
20
20
|
const { selectExchangeConfig } = useFundingExchangeHelpers();
|
|
21
21
|
const promiseRef = useRef(null);
|
|
22
22
|
useInternalDynamicEvents('authFlowClose', () => {
|
|
23
|
-
rejectPromiseRef(promiseRef, new DynamicError('User cancelled'));
|
|
23
|
+
rejectPromiseRef(promiseRef, new DynamicError('User cancelled', 'user_cancelled'));
|
|
24
24
|
});
|
|
25
25
|
const openList = useCallback((initiatedByWidget) => {
|
|
26
26
|
const { onSelectExchange } = selectExchangeConfig({
|
|
@@ -57,7 +57,7 @@ const useConnectUnifiedForFunding = () => {
|
|
|
57
57
|
initiatedByWidgetRef.current = initiatedByWidget;
|
|
58
58
|
const walletAddress = yield getWalletAddress(walletConnector);
|
|
59
59
|
if (!walletAddress) {
|
|
60
|
-
rejectPromiseRef(promiseRef, new DynamicError('No wallet address found'));
|
|
60
|
+
rejectPromiseRef(promiseRef, new DynamicError('No wallet address found', 'no_wallet_address_found'));
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
const wallet = walletConnector.createWallet({
|
|
@@ -7,7 +7,7 @@ var utils = require('@dynamic-labs/utils');
|
|
|
7
7
|
|
|
8
8
|
class HandleConnectWalletRejectionError extends utils.DynamicError {
|
|
9
9
|
constructor(walletConnector) {
|
|
10
|
-
super(`Connection was not established because handleConnectedWallet returned false for wallet connector ${walletConnector.key}
|
|
10
|
+
super(`Connection was not established because handleConnectedWallet returned false for wallet connector ${walletConnector.key}`, 'handle_connect_wallet_rejection');
|
|
11
11
|
this.walletConnector = walletConnector;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -3,7 +3,7 @@ import { DynamicError } from '@dynamic-labs/utils';
|
|
|
3
3
|
|
|
4
4
|
class HandleConnectWalletRejectionError extends DynamicError {
|
|
5
5
|
constructor(walletConnector) {
|
|
6
|
-
super(`Connection was not established because handleConnectedWallet returned false for wallet connector ${walletConnector.key}
|
|
6
|
+
super(`Connection was not established because handleConnectedWallet returned false for wallet connector ${walletConnector.key}`, 'handle_connect_wallet_rejection');
|
|
7
7
|
this.walletConnector = walletConnector;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -66,7 +66,7 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
66
66
|
var _d, _e;
|
|
67
67
|
setIsLoading(true);
|
|
68
68
|
if (!user) {
|
|
69
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
69
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
70
70
|
}
|
|
71
71
|
let sessionPublicKey;
|
|
72
72
|
// get the session public key that was created in the login/signup flow
|
|
@@ -62,7 +62,7 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
62
62
|
var _d, _e;
|
|
63
63
|
setIsLoading(true);
|
|
64
64
|
if (!user) {
|
|
65
|
-
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
65
|
+
throw new DynamicError(USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
66
66
|
}
|
|
67
67
|
let sessionPublicKey;
|
|
68
68
|
// get the session public key that was created in the login/signup flow
|
package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/errors/ConnectorSetupError.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var utils = require('@dynamic-labs/utils');
|
|
|
7
7
|
|
|
8
8
|
class ConnectorSetupError extends utils.DynamicError {
|
|
9
9
|
constructor(providerName, connectorName) {
|
|
10
|
-
super(`${providerName} is enabled but ${connectorName} is not in your walletConnectors list. See https://docs.dynamic.xyz/react-sdk/wallet-connectors for more information
|
|
10
|
+
super(`${providerName} is enabled but ${connectorName} is not in your walletConnectors list. See https://docs.dynamic.xyz/react-sdk/wallet-connectors for more information.`, 'connector_setup_error');
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
package/src/lib/utils/hooks/useCreateWalletConnectorOptions/utils/errors/ConnectorSetupError.js
CHANGED
|
@@ -3,7 +3,7 @@ import { DynamicError } from '@dynamic-labs/utils';
|
|
|
3
3
|
|
|
4
4
|
class ConnectorSetupError extends DynamicError {
|
|
5
5
|
constructor(providerName, connectorName) {
|
|
6
|
-
super(`${providerName} is enabled but ${connectorName} is not in your walletConnectors list. See https://docs.dynamic.xyz/react-sdk/wallet-connectors for more information
|
|
6
|
+
super(`${providerName} is enabled but ${connectorName} is not in your walletConnectors list. See https://docs.dynamic.xyz/react-sdk/wallet-connectors for more information.`, 'connector_setup_error');
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -150,7 +150,7 @@ const useDynamicWaas = () => {
|
|
|
150
150
|
normalizeWaasChainName.normalizeWaasChainName(option.walletConnector.connectedChain) ===
|
|
151
151
|
normalizeWaasChainName.normalizeWaasChainName(chainName))) === null || _a === void 0 ? void 0 : _a.walletConnector;
|
|
152
152
|
if (!walletConnector) {
|
|
153
|
-
throw new utils.DynamicError(constants.DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR);
|
|
153
|
+
throw new utils.DynamicError(constants.DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, 'dynamicwaasconnectornotfounderror');
|
|
154
154
|
}
|
|
155
155
|
const configuredWalletConnector = configWaasWalletConnector({
|
|
156
156
|
apiBaseUrl: apiBaseUrl || apiUrl.DEFAULT_WAAS_API_URL,
|
|
@@ -282,7 +282,7 @@ const useDynamicWaas = () => {
|
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
284
|
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
285
|
-
throw new utils.DynamicError(constants.NO_ENABLED_CHAINS_ERROR);
|
|
285
|
+
throw new utils.DynamicError(constants.NO_ENABLED_CHAINS_ERROR, 'no_enabled_chains');
|
|
286
286
|
}
|
|
287
287
|
// Convert legacy ChainEnum[] format to WalletCreationRequirement[]
|
|
288
288
|
const requirements = normalizeWalletRequirements.normalizeWalletRequirements(requirementsOrChainNames, bitcoinConfig);
|
|
@@ -291,7 +291,7 @@ const useDynamicWaas = () => {
|
|
|
291
291
|
const allChains = reqs.map((req) => req.chain);
|
|
292
292
|
const invalidChains = allChains.filter((chain) => !enabledChainNames.includes(chain));
|
|
293
293
|
if (invalidChains.length > 0) {
|
|
294
|
-
throw new utils.DynamicError(`${constants.INVALID_CHAINS_ERROR}: ${invalidChains.join(', ')}
|
|
294
|
+
throw new utils.DynamicError(`${constants.INVALID_CHAINS_ERROR}: ${invalidChains.join(', ')}`, 'invalid_chains');
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
297
|
validateChains(requirements);
|
|
@@ -324,7 +324,7 @@ const useDynamicWaas = () => {
|
|
|
324
324
|
});
|
|
325
325
|
if (failedChains.length > 0) {
|
|
326
326
|
refresh();
|
|
327
|
-
throw new utils.DynamicError(`${constants.WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}. Errors: ${errors.join('; ')}
|
|
327
|
+
throw new utils.DynamicError(`${constants.WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}. Errors: ${errors.join('; ')}`, 'wallet_creation_failed');
|
|
328
328
|
}
|
|
329
329
|
return settledResults.map((r) => r.status === 'fulfilled' ? r.value : undefined);
|
|
330
330
|
};
|
|
@@ -474,13 +474,13 @@ const useDynamicWaas = () => {
|
|
|
474
474
|
const upgradeToDynamicWaas = React.useCallback((_j) => _tslib.__awaiter(void 0, [_j], void 0, function* ({ privateKey, wallet, password, }) {
|
|
475
475
|
isUpgrading.current = true;
|
|
476
476
|
if (!wallet) {
|
|
477
|
-
throw new utils.DynamicError('Wallet to upgrade was not provided');
|
|
477
|
+
throw new utils.DynamicError('Wallet to upgrade was not provided', 'wallet_to_upgrade_was_not_provided');
|
|
478
478
|
}
|
|
479
479
|
const chainName = wallet.chain;
|
|
480
480
|
const walletId = wallet.id;
|
|
481
481
|
const walletConnector = getWaasWalletConnector(chainName);
|
|
482
482
|
if (!walletConnector) {
|
|
483
|
-
throw new utils.DynamicError('Wallet connector not found');
|
|
483
|
+
throw new utils.DynamicError('Wallet connector not found', 'wallet_connector_not_found');
|
|
484
484
|
}
|
|
485
485
|
let softDeleteSucceeded = false;
|
|
486
486
|
// 7702 wallets have a -zerodev suffix because it's a credential created on the fly
|
|
@@ -515,9 +515,9 @@ const useDynamicWaas = () => {
|
|
|
515
515
|
}
|
|
516
516
|
const errorMessage = (error === null || error === void 0 ? void 0 : error.message) || '';
|
|
517
517
|
if (errorMessage.includes('Public address mismatch')) {
|
|
518
|
-
throw new utils.DynamicError('Public address mismatch. Ensure the private key is copied correctly.');
|
|
518
|
+
throw new utils.DynamicError('Public address mismatch. Ensure the private key is copied correctly.', 'public_address_mismatch');
|
|
519
519
|
}
|
|
520
|
-
throw new utils.DynamicError('Upgrade failed, please try again.');
|
|
520
|
+
throw new utils.DynamicError('Upgrade failed, please try again.', 'upgrade_failed');
|
|
521
521
|
}
|
|
522
522
|
}), [environmentId, getWaasWalletConnector, refresh]);
|
|
523
523
|
/**
|
|
@@ -146,7 +146,7 @@ const useDynamicWaas = () => {
|
|
|
146
146
|
normalizeWaasChainName(option.walletConnector.connectedChain) ===
|
|
147
147
|
normalizeWaasChainName(chainName))) === null || _a === void 0 ? void 0 : _a.walletConnector;
|
|
148
148
|
if (!walletConnector) {
|
|
149
|
-
throw new DynamicError(DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR);
|
|
149
|
+
throw new DynamicError(DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, 'dynamicwaasconnectornotfounderror');
|
|
150
150
|
}
|
|
151
151
|
const configuredWalletConnector = configWaasWalletConnector({
|
|
152
152
|
apiBaseUrl: apiBaseUrl || DEFAULT_WAAS_API_URL,
|
|
@@ -278,7 +278,7 @@ const useDynamicWaas = () => {
|
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
280
|
if (!(enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.length)) {
|
|
281
|
-
throw new DynamicError(NO_ENABLED_CHAINS_ERROR);
|
|
281
|
+
throw new DynamicError(NO_ENABLED_CHAINS_ERROR, 'no_enabled_chains');
|
|
282
282
|
}
|
|
283
283
|
// Convert legacy ChainEnum[] format to WalletCreationRequirement[]
|
|
284
284
|
const requirements = normalizeWalletRequirements(requirementsOrChainNames, bitcoinConfig);
|
|
@@ -287,7 +287,7 @@ const useDynamicWaas = () => {
|
|
|
287
287
|
const allChains = reqs.map((req) => req.chain);
|
|
288
288
|
const invalidChains = allChains.filter((chain) => !enabledChainNames.includes(chain));
|
|
289
289
|
if (invalidChains.length > 0) {
|
|
290
|
-
throw new DynamicError(`${INVALID_CHAINS_ERROR}: ${invalidChains.join(', ')}
|
|
290
|
+
throw new DynamicError(`${INVALID_CHAINS_ERROR}: ${invalidChains.join(', ')}`, 'invalid_chains');
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
293
|
validateChains(requirements);
|
|
@@ -320,7 +320,7 @@ const useDynamicWaas = () => {
|
|
|
320
320
|
});
|
|
321
321
|
if (failedChains.length > 0) {
|
|
322
322
|
refresh();
|
|
323
|
-
throw new DynamicError(`${WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}. Errors: ${errors.join('; ')}
|
|
323
|
+
throw new DynamicError(`${WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}. Errors: ${errors.join('; ')}`, 'wallet_creation_failed');
|
|
324
324
|
}
|
|
325
325
|
return settledResults.map((r) => r.status === 'fulfilled' ? r.value : undefined);
|
|
326
326
|
};
|
|
@@ -470,13 +470,13 @@ const useDynamicWaas = () => {
|
|
|
470
470
|
const upgradeToDynamicWaas = useCallback((_j) => __awaiter(void 0, [_j], void 0, function* ({ privateKey, wallet, password, }) {
|
|
471
471
|
isUpgrading.current = true;
|
|
472
472
|
if (!wallet) {
|
|
473
|
-
throw new DynamicError('Wallet to upgrade was not provided');
|
|
473
|
+
throw new DynamicError('Wallet to upgrade was not provided', 'wallet_to_upgrade_was_not_provided');
|
|
474
474
|
}
|
|
475
475
|
const chainName = wallet.chain;
|
|
476
476
|
const walletId = wallet.id;
|
|
477
477
|
const walletConnector = getWaasWalletConnector(chainName);
|
|
478
478
|
if (!walletConnector) {
|
|
479
|
-
throw new DynamicError('Wallet connector not found');
|
|
479
|
+
throw new DynamicError('Wallet connector not found', 'wallet_connector_not_found');
|
|
480
480
|
}
|
|
481
481
|
let softDeleteSucceeded = false;
|
|
482
482
|
// 7702 wallets have a -zerodev suffix because it's a credential created on the fly
|
|
@@ -511,9 +511,9 @@ const useDynamicWaas = () => {
|
|
|
511
511
|
}
|
|
512
512
|
const errorMessage = (error === null || error === void 0 ? void 0 : error.message) || '';
|
|
513
513
|
if (errorMessage.includes('Public address mismatch')) {
|
|
514
|
-
throw new DynamicError('Public address mismatch. Ensure the private key is copied correctly.');
|
|
514
|
+
throw new DynamicError('Public address mismatch. Ensure the private key is copied correctly.', 'public_address_mismatch');
|
|
515
515
|
}
|
|
516
|
-
throw new DynamicError('Upgrade failed, please try again.');
|
|
516
|
+
throw new DynamicError('Upgrade failed, please try again.', 'upgrade_failed');
|
|
517
517
|
}
|
|
518
518
|
}), [environmentId, getWaasWalletConnector, refresh]);
|
|
519
519
|
/**
|
|
@@ -67,10 +67,10 @@ const useEmbeddedWallet = () => {
|
|
|
67
67
|
const userHasEmbeddedWallet = React.useCallback(() => hasEmbeddedWallet.hasEmbeddedWallet(user), [user]);
|
|
68
68
|
const getWalletVersion = React.useCallback(() => {
|
|
69
69
|
if (!user) {
|
|
70
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
70
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
71
71
|
}
|
|
72
72
|
if (!userHasEmbeddedWallet()) {
|
|
73
|
-
throw new utils.DynamicError('Embedded wallet not found');
|
|
73
|
+
throw new utils.DynamicError('Embedded wallet not found', 'embedded_wallet_not_found');
|
|
74
74
|
}
|
|
75
75
|
if (isTurnkeyWallet) {
|
|
76
76
|
return getTurnkeyWalletVersion();
|
|
@@ -94,10 +94,10 @@ const useEmbeddedWallet = () => {
|
|
|
94
94
|
*/
|
|
95
95
|
const revealWalletKey = (options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
96
96
|
if (!user) {
|
|
97
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
97
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
98
98
|
}
|
|
99
99
|
if (!userHasEmbeddedWallet()) {
|
|
100
|
-
throw new utils.DynamicError('Embedded wallet not found');
|
|
100
|
+
throw new utils.DynamicError('Embedded wallet not found', 'embedded_wallet_not_found');
|
|
101
101
|
}
|
|
102
102
|
return revealTurnkeyEmbeddedWalletKey(options);
|
|
103
103
|
});
|
|
@@ -63,10 +63,10 @@ const useEmbeddedWallet = () => {
|
|
|
63
63
|
const userHasEmbeddedWallet = useCallback(() => hasEmbeddedWallet(user), [user]);
|
|
64
64
|
const getWalletVersion = useCallback(() => {
|
|
65
65
|
if (!user) {
|
|
66
|
-
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
66
|
+
throw new DynamicError(USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
67
67
|
}
|
|
68
68
|
if (!userHasEmbeddedWallet()) {
|
|
69
|
-
throw new DynamicError('Embedded wallet not found');
|
|
69
|
+
throw new DynamicError('Embedded wallet not found', 'embedded_wallet_not_found');
|
|
70
70
|
}
|
|
71
71
|
if (isTurnkeyWallet) {
|
|
72
72
|
return getTurnkeyWalletVersion();
|
|
@@ -90,10 +90,10 @@ const useEmbeddedWallet = () => {
|
|
|
90
90
|
*/
|
|
91
91
|
const revealWalletKey = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
92
|
if (!user) {
|
|
93
|
-
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
93
|
+
throw new DynamicError(USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
94
94
|
}
|
|
95
95
|
if (!userHasEmbeddedWallet()) {
|
|
96
|
-
throw new DynamicError('Embedded wallet not found');
|
|
96
|
+
throw new DynamicError('Embedded wallet not found', 'embedded_wallet_not_found');
|
|
97
97
|
}
|
|
98
98
|
return revealTurnkeyEmbeddedWalletKey(options);
|
|
99
99
|
});
|
|
@@ -107,7 +107,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
107
107
|
const createEmbeddedWallet = React.useCallback((chains, options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
108
108
|
var _f;
|
|
109
109
|
if (!user$1) {
|
|
110
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
110
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
111
111
|
}
|
|
112
112
|
const userWalletsCredentials = getUserWalletsFromVerifiedCredentials.getUserWalletsFromVerifiedCredentials(user$1);
|
|
113
113
|
const primaryChain = findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings);
|
|
@@ -185,7 +185,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
185
185
|
const createOrRestoreSession = React.useCallback((options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
186
186
|
var _l, _m, _o, _p, _q, _r, _s;
|
|
187
187
|
if (!user$1) {
|
|
188
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
188
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
189
189
|
}
|
|
190
190
|
const primaryConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
191
191
|
if (primaryConnector &&
|
|
@@ -227,7 +227,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
227
227
|
throw new utils.DynamicError('User does not have a secure enclave wallet or a verified email', errors.INVALID_WALLET_DATA);
|
|
228
228
|
}
|
|
229
229
|
if (!primaryWallet) {
|
|
230
|
-
throw new utils.DynamicError('No primary wallet found');
|
|
230
|
+
throw new utils.DynamicError('No primary wallet found', 'no_primary_wallet_found');
|
|
231
231
|
}
|
|
232
232
|
const primaryTurnkeyWalletId = getTurnkeyWalletId.getTurnkeyWalletId(primaryWallet.id, (user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials) || []);
|
|
233
233
|
const organizationId = (_s = (_r = (_q = (_p = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials) === null || _p === void 0 ? void 0 : _p.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === primaryTurnkeyWalletId)) === null || _q === void 0 ? void 0 : _q.walletProperties) === null || _r === void 0 ? void 0 : _r.turnkeySubOrganizationId) !== null && _s !== void 0 ? _s : undefined;
|
|
@@ -256,7 +256,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
256
256
|
const createPasskey = React.useCallback((options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
257
257
|
var _t, _u;
|
|
258
258
|
if (!user$1) {
|
|
259
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
259
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
260
260
|
}
|
|
261
261
|
validateTurnkeyProviderEnabled.validateTurnkeyProviderEnabled(projectSettings);
|
|
262
262
|
const turnkeyWallet = findTurnkeyWallet.findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (_t = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _t === void 0 ? void 0 : _t.chainConfigurations, user$1.verifiedCredentials);
|
|
@@ -294,7 +294,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
294
294
|
walletId: turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.id,
|
|
295
295
|
});
|
|
296
296
|
if (!updatedUser) {
|
|
297
|
-
throw new utils.DynamicError('Error completing passkey recovery');
|
|
297
|
+
throw new utils.DynamicError('Error completing passkey recovery', 'completing_passkey_recovery');
|
|
298
298
|
}
|
|
299
299
|
return { attestation, challenge, displayName };
|
|
300
300
|
}), [
|
|
@@ -310,7 +310,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
310
310
|
*/
|
|
311
311
|
const getPasskeys = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
312
312
|
if (!user$1) {
|
|
313
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
313
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
314
314
|
}
|
|
315
315
|
const data = yield embeddedWallets.getUserPasskeys({
|
|
316
316
|
environmentId: environmentId,
|
|
@@ -341,7 +341,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
341
341
|
const revealEmbeddedWalletKey = React.useCallback((_v) => _tslib.__awaiter(void 0, [_v], void 0, function* ({ type, htmlContainerId, }) {
|
|
342
342
|
var _w, _x, _y, _z, _0, _1;
|
|
343
343
|
if (!user$1) {
|
|
344
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
344
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
345
345
|
}
|
|
346
346
|
yield turnkeyExport.cleanupExport({
|
|
347
347
|
wallet: wallet,
|
|
@@ -410,7 +410,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
410
410
|
const sendOneTimeCode = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
411
411
|
var _2, _3;
|
|
412
412
|
if (!user$1) {
|
|
413
|
-
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
413
|
+
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN, 'user_not_logged_in');
|
|
414
414
|
}
|
|
415
415
|
const targetTurnkeyWallet = findTurnkeyWallet.findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (_2 = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _2 === void 0 ? void 0 : _2.chainConfigurations, user$1.verifiedCredentials);
|
|
416
416
|
if (!targetTurnkeyWallet || !('id' in targetTurnkeyWallet)) {
|
|
@@ -425,7 +425,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
425
425
|
const turnkeyAuthIframeContainerRef = createRootElement(constants.iframeContainerId);
|
|
426
426
|
const publicKey = yield turnkeyAuthenticatorHandler.initRecovery('email', turnkeyAuthIframeContainerRef.current, constants.iframeElementId, getEmbeddedWalletSessionExpiration.getEmbeddedWalletSessionExpiration((_3 = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _3 === void 0 ? void 0 : _3.sessionKeyDuration));
|
|
427
427
|
if (!publicKey) {
|
|
428
|
-
throw new utils.DynamicError(errors.ERROR_SENDING_CODE);
|
|
428
|
+
throw new utils.DynamicError(errors.ERROR_SENDING_CODE, 'error_sending_code');
|
|
429
429
|
}
|
|
430
430
|
const response = yield embeddedWallets.initEmbeddedWalletSession({
|
|
431
431
|
authenticatorType: 'email',
|