@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
|
@@ -16,7 +16,7 @@ import { getOnrampProviders } from './utils/getOnrampProviders.js';
|
|
|
16
16
|
|
|
17
17
|
const OnrampContext = createContext(undefined);
|
|
18
18
|
const OnrampContextProvider = ({ children, }) => {
|
|
19
|
-
var _a, _b, _c, _d, _e;
|
|
19
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
20
20
|
const promiseRef = useRef(null);
|
|
21
21
|
const [selectedOnrampProvider, setSelectedOnrampProvider] = useState();
|
|
22
22
|
const [showOnramp, _setShowOnramp] = useState(false);
|
|
@@ -25,12 +25,17 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
25
25
|
const { environmentId, network, primaryWallet, projectSettings, overrides } = useInternalDynamicContext();
|
|
26
26
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
27
27
|
const [enabledOnrampProvidersTarget, setEnabledOnrampProvidersTarget] = useState({});
|
|
28
|
-
//
|
|
29
|
-
const [
|
|
28
|
+
// Manual trigger for programmatic flows (openOnramp, setEnabledOnrampProvidersTargetValue)
|
|
29
|
+
const [manualFetchTriggered, setManualFetchTriggered] = useState(false);
|
|
30
|
+
// Auto-fetch when onramps are configured in the dashboard so the Buy button
|
|
31
|
+
// is available in the funding-methods view. When unconfigured, skip the fetch
|
|
32
|
+
// to avoid wasting bandwidth on SDK mount (esp. on slow mobile connections).
|
|
33
|
+
const hasOnrampsConfigured = Boolean((_c = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.funding) === null || _b === void 0 ? void 0 : _b.onramps) === null || _c === void 0 ? void 0 : _c.length);
|
|
34
|
+
const shouldFetchOnramps = manualFetchTriggered || hasOnrampsConfigured;
|
|
30
35
|
const setShowOnramp = useCallback((value) => {
|
|
31
36
|
_setShowOnramp(value);
|
|
32
37
|
if (!value && promiseRef.current) {
|
|
33
|
-
rejectPromiseRef(promiseRef, new DynamicError('User cancelled'));
|
|
38
|
+
rejectPromiseRef(promiseRef, new DynamicError('User cancelled', 'user_cancelled'));
|
|
34
39
|
}
|
|
35
40
|
}, []);
|
|
36
41
|
const setEnabledOnrampProvidersTargetValue = useCallback(({ address, token, network, tokenAmount, chainName, currency, }) => {
|
|
@@ -44,7 +49,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
44
49
|
});
|
|
45
50
|
// Trigger fetch when target is set with specific parameters
|
|
46
51
|
if (address || token || network || tokenAmount || chainName || currency) {
|
|
47
|
-
|
|
52
|
+
setManualFetchTriggered(true);
|
|
48
53
|
}
|
|
49
54
|
}, []);
|
|
50
55
|
const resetOverrides = useCallback(() => {
|
|
@@ -56,7 +61,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
56
61
|
includeDisabled: true,
|
|
57
62
|
network,
|
|
58
63
|
primaryWallet,
|
|
59
|
-
projectSettingsOnramps: (
|
|
64
|
+
projectSettingsOnramps: (_e = (_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _d === void 0 ? void 0 : _d.funding) === null || _e === void 0 ? void 0 : _e.onramps,
|
|
60
65
|
shouldFetch: shouldFetchOnramps,
|
|
61
66
|
target: enabledOnrampProvidersTarget,
|
|
62
67
|
});
|
|
@@ -97,7 +102,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
97
102
|
return Boolean(((_c = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.funding) === null || _b === void 0 ? void 0 : _b.onramps) === null || _c === void 0 ? void 0 : _c.length) &&
|
|
98
103
|
enabledOnrampProvidersInDashboard.length);
|
|
99
104
|
}, [
|
|
100
|
-
(
|
|
105
|
+
(_h = (_g = (_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _f === void 0 ? void 0 : _f.funding) === null || _g === void 0 ? void 0 : _g.onramps) === null || _h === void 0 ? void 0 : _h.length,
|
|
101
106
|
enabledOnrampProvidersInDashboard.length,
|
|
102
107
|
onrampOverrides.length,
|
|
103
108
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
@@ -127,8 +132,8 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
127
132
|
onrampOverrides,
|
|
128
133
|
overrides === null || overrides === void 0 ? void 0 : overrides.onrampOptions,
|
|
129
134
|
]);
|
|
130
|
-
const openOnramp = useCallback((
|
|
131
|
-
var
|
|
135
|
+
const openOnramp = useCallback((_j) => __awaiter(void 0, [_j], void 0, function* ({ onrampProvider, address, token, tokenAmount, network: networkOverride, chainName, currency, overrideOnRamp, payingWithDynamic, merchantName, }) {
|
|
136
|
+
var _k, _l, _m, _o;
|
|
132
137
|
if (!onrampEnabled && !overrideOnRamp && !payingWithDynamic) {
|
|
133
138
|
throw new Error('Onramp is not enabled');
|
|
134
139
|
}
|
|
@@ -138,8 +143,8 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
138
143
|
}
|
|
139
144
|
promiseRef.current = new DeferredPromise();
|
|
140
145
|
// Trigger onramp providers fetch if not already done
|
|
141
|
-
if (!
|
|
142
|
-
|
|
146
|
+
if (!manualFetchTriggered) {
|
|
147
|
+
setManualFetchTriggered(true);
|
|
143
148
|
}
|
|
144
149
|
let localOnrampProviders = enabledOnrampProvidersInDashboardOptions;
|
|
145
150
|
const networkToUse = networkOverride || network;
|
|
@@ -158,7 +163,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
158
163
|
Boolean(address);
|
|
159
164
|
if (payingWithDynamic && !allPayingParameters) {
|
|
160
165
|
rejectPromiseRef(promiseRef, new Error('PayingWithDynamic: Missing parameters'));
|
|
161
|
-
return (
|
|
166
|
+
return (_k = promiseRef.current) === null || _k === void 0 ? void 0 : _k.promise;
|
|
162
167
|
}
|
|
163
168
|
if (shouldOverrideOnrampProviders)
|
|
164
169
|
setOverride(true);
|
|
@@ -180,15 +185,15 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
180
185
|
const onrampOption = localOnrampProviders.find((p) => p.id === onrampProvider);
|
|
181
186
|
if (payingWithDynamic && !onrampOption) {
|
|
182
187
|
rejectPromiseRef(promiseRef, new Error('PayingWithDynamic: Onramp provider not found'));
|
|
183
|
-
return (
|
|
188
|
+
return (_l = promiseRef.current) === null || _l === void 0 ? void 0 : _l.promise;
|
|
184
189
|
}
|
|
185
190
|
if (!onrampOption) {
|
|
186
191
|
rejectPromiseRef(promiseRef, new Error('Onramp provider not found'));
|
|
187
|
-
return (
|
|
192
|
+
return (_m = promiseRef.current) === null || _m === void 0 ? void 0 : _m.promise;
|
|
188
193
|
}
|
|
189
194
|
setOverrideOnrampProvider(onrampOption);
|
|
190
195
|
setSelectedAndShowOnramp({ payingWithDynamic, provider: onrampOption });
|
|
191
|
-
return (
|
|
196
|
+
return (_o = promiseRef.current) === null || _o === void 0 ? void 0 : _o.promise;
|
|
192
197
|
}), [
|
|
193
198
|
enabledOnrampProvidersInDashboardOptions,
|
|
194
199
|
environmentId,
|
|
@@ -196,7 +201,7 @@ const OnrampContextProvider = ({ children, }) => {
|
|
|
196
201
|
primaryWallet,
|
|
197
202
|
network,
|
|
198
203
|
setSelectedAndShowOnramp,
|
|
199
|
-
|
|
204
|
+
manualFetchTriggered,
|
|
200
205
|
]);
|
|
201
206
|
const selectedOnramp = useMemo(() => {
|
|
202
207
|
let selected;
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var utils = require('@dynamic-labs/utils');
|
|
7
7
|
|
|
8
|
-
const noWalletError = new utils.DynamicError('No wallet connected');
|
|
9
|
-
const invalidWalletTypeError = new utils.DynamicError('Primary wallet must use embedded wallet');
|
|
8
|
+
const noWalletError = new utils.DynamicError('No wallet connected', 'no_wallet_connected');
|
|
9
|
+
const invalidWalletTypeError = new utils.DynamicError('Primary wallet must use embedded wallet', 'invalid_wallet_type');
|
|
10
10
|
|
|
11
11
|
exports.invalidWalletTypeError = invalidWalletTypeError;
|
|
12
12
|
exports.noWalletError = noWalletError;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
3
3
|
|
|
4
|
-
const noWalletError = new DynamicError('No wallet connected');
|
|
5
|
-
const invalidWalletTypeError = new DynamicError('Primary wallet must use embedded wallet');
|
|
4
|
+
const noWalletError = new DynamicError('No wallet connected', 'no_wallet_connected');
|
|
5
|
+
const invalidWalletTypeError = new DynamicError('Primary wallet must use embedded wallet', 'invalid_wallet_type');
|
|
6
6
|
|
|
7
7
|
export { invalidWalletTypeError, noWalletError };
|
|
@@ -172,14 +172,14 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
172
172
|
// Update UI to reflect the original state
|
|
173
173
|
if (socialStorageItem.mode === 'signin') {
|
|
174
174
|
if (client.getDynamicClient().user) {
|
|
175
|
-
logger.logger.error(new utils.DynamicError('User is already logged in'));
|
|
175
|
+
logger.logger.error(new utils.DynamicError('User is already logged in', 'user_is_already_logged_in'));
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
178
|
updateInterfaceStateForSignIn(socialStorageItem);
|
|
179
179
|
}
|
|
180
180
|
else if (socialStorageItem.mode === 'link') {
|
|
181
181
|
if (!client.getDynamicClient().user) {
|
|
182
|
-
logger.logger.error(new utils.DynamicError('User not logged in'));
|
|
182
|
+
logger.logger.error(new utils.DynamicError('User not logged in', 'user_not_logged_in'));
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
// Link was called from the widget, so show the profile on redirect
|
|
@@ -190,7 +190,7 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
190
190
|
}
|
|
191
191
|
else if (socialStorageItem.mode === 'stepup') {
|
|
192
192
|
if (!client.getDynamicClient().user) {
|
|
193
|
-
logger.logger.error(new utils.DynamicError('User not logged in'));
|
|
193
|
+
logger.logger.error(new utils.DynamicError('User not logged in', 'user_not_logged_in'));
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
196
|
}
|
|
@@ -168,14 +168,14 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
168
168
|
// Update UI to reflect the original state
|
|
169
169
|
if (socialStorageItem.mode === 'signin') {
|
|
170
170
|
if (getDynamicClient().user) {
|
|
171
|
-
logger.error(new DynamicError('User is already logged in'));
|
|
171
|
+
logger.error(new DynamicError('User is already logged in', 'user_is_already_logged_in'));
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
updateInterfaceStateForSignIn(socialStorageItem);
|
|
175
175
|
}
|
|
176
176
|
else if (socialStorageItem.mode === 'link') {
|
|
177
177
|
if (!getDynamicClient().user) {
|
|
178
|
-
logger.error(new DynamicError('User not logged in'));
|
|
178
|
+
logger.error(new DynamicError('User not logged in', 'user_not_logged_in'));
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
// Link was called from the widget, so show the profile on redirect
|
|
@@ -186,7 +186,7 @@ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
|
|
|
186
186
|
}
|
|
187
187
|
else if (socialStorageItem.mode === 'stepup') {
|
|
188
188
|
if (!getDynamicClient().user) {
|
|
189
|
-
logger.error(new DynamicError('User not logged in'));
|
|
189
|
+
logger.error(new DynamicError('User not logged in', 'user_not_logged_in'));
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -43,13 +43,16 @@ const signInWithEmailVerification = (_b) => _tslib.__awaiter(void 0, [_b], void
|
|
|
43
43
|
catch (e) {
|
|
44
44
|
const data = yield utils.logResponseError(e, 'Error email signin');
|
|
45
45
|
if (data.error.code === 'missing_from_list') {
|
|
46
|
-
throw new utils$1.NoAccessError({
|
|
46
|
+
throw new utils$1.NoAccessError({
|
|
47
|
+
code: data.error.code,
|
|
48
|
+
email: data.payload.email,
|
|
49
|
+
});
|
|
47
50
|
}
|
|
48
51
|
if (data.code === 'credential_not_enabled_for_sign_in') {
|
|
49
52
|
throw new utils$1.DynamicError(data.error, utils$1.ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN);
|
|
50
53
|
}
|
|
51
54
|
if (data.code === 'email_associated_with_different_provider') {
|
|
52
|
-
throw new utils$1.AccountExistsError(data.error, data.payload);
|
|
55
|
+
throw new utils$1.AccountExistsError(data.error, data.payload, data.code);
|
|
53
56
|
}
|
|
54
57
|
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
55
58
|
throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
|
|
@@ -94,7 +97,7 @@ const verifyEmail = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({
|
|
|
94
97
|
catch (e) {
|
|
95
98
|
const data = yield utils.logResponseError(e, 'Error linking email');
|
|
96
99
|
if (data.code === sdkApiCore.UnprocessableEntityErrorCode.UserHasAlreadyAccountWithEmail) {
|
|
97
|
-
throw new utils$1.UserHasAccountWithEmailError(data.error);
|
|
100
|
+
throw new utils$1.UserHasAccountWithEmailError(data.error, data.code);
|
|
98
101
|
}
|
|
99
102
|
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
100
103
|
throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
|
|
@@ -39,13 +39,16 @@ const signInWithEmailVerification = (_b) => __awaiter(void 0, [_b], void 0, func
|
|
|
39
39
|
catch (e) {
|
|
40
40
|
const data = yield logResponseError(e, 'Error email signin');
|
|
41
41
|
if (data.error.code === 'missing_from_list') {
|
|
42
|
-
throw new NoAccessError({
|
|
42
|
+
throw new NoAccessError({
|
|
43
|
+
code: data.error.code,
|
|
44
|
+
email: data.payload.email,
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
if (data.code === 'credential_not_enabled_for_sign_in') {
|
|
45
48
|
throw new DynamicError(data.error, ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN);
|
|
46
49
|
}
|
|
47
50
|
if (data.code === 'email_associated_with_different_provider') {
|
|
48
|
-
throw new AccountExistsError(data.error, data.payload);
|
|
51
|
+
throw new AccountExistsError(data.error, data.payload, data.code);
|
|
49
52
|
}
|
|
50
53
|
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
51
54
|
throw new SandboxMaximumThresholdReachedError(data.error.message);
|
|
@@ -90,7 +93,7 @@ const verifyEmail = (_d) => __awaiter(void 0, [_d], void 0, function* ({ verific
|
|
|
90
93
|
catch (e) {
|
|
91
94
|
const data = yield logResponseError(e, 'Error linking email');
|
|
92
95
|
if (data.code === UnprocessableEntityErrorCode.UserHasAlreadyAccountWithEmail) {
|
|
93
|
-
throw new UserHasAccountWithEmailError(data.error);
|
|
96
|
+
throw new UserHasAccountWithEmailError(data.error, data.code);
|
|
94
97
|
}
|
|
95
98
|
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
96
99
|
throw new SandboxMaximumThresholdReachedError(data.error.message);
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
8
|
-
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var utils$1 = require('@dynamic-labs/utils');
|
|
9
9
|
require('@dynamic-labs/iconic');
|
|
10
10
|
require('@dynamic-labs/wallet-connector-core');
|
|
11
11
|
require('react');
|
|
@@ -17,6 +17,7 @@ require('../../../utils/constants/colors.cjs');
|
|
|
17
17
|
require('../../../utils/constants/values.cjs');
|
|
18
18
|
require('../../../shared/consts/index.cjs');
|
|
19
19
|
var api = require('../api.cjs');
|
|
20
|
+
var utils = require('../utils.cjs');
|
|
20
21
|
require('@dynamic-labs-sdk/client/core');
|
|
21
22
|
require('eventemitter3');
|
|
22
23
|
require('@dynamic-labs-sdk/client');
|
|
@@ -109,7 +110,7 @@ const updatePasskeyRecoveryEmail = (_d) => _tslib.__awaiter(void 0, [_d], void 0
|
|
|
109
110
|
}
|
|
110
111
|
catch (e) {
|
|
111
112
|
yield logResponse(e, 'Error while trying to update recovery email');
|
|
112
|
-
throw new utils.DynamicError('Error updating recovery email');
|
|
113
|
+
throw new utils$1.DynamicError('Error updating recovery email', 'updating_recovery_email');
|
|
113
114
|
}
|
|
114
115
|
});
|
|
115
116
|
const getUserPasskeys = (_e) => _tslib.__awaiter(void 0, [_e], void 0, function* ({ environmentId, }) {
|
|
@@ -177,24 +178,24 @@ const registerSessionKey = (_h) => _tslib.__awaiter(void 0, [_h], void 0, functi
|
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
180
|
catch (error) {
|
|
180
|
-
if (error
|
|
181
|
-
const responseError = yield utils.ResponseError.fromResponse({
|
|
181
|
+
if (utils.isResponseLike(error)) {
|
|
182
|
+
const responseError = yield utils$1.ResponseError.fromResponse({
|
|
182
183
|
cause: error,
|
|
183
184
|
message: 'Error register session key',
|
|
184
185
|
});
|
|
185
186
|
logger.logger.error(responseError, { prevSessionKeySignature, publicKey });
|
|
186
|
-
utils.tracing.logEvent('session-key', 'Error registering session key', utils.tracing.formatObject({
|
|
187
|
+
utils$1.tracing.logEvent('session-key', 'Error registering session key', utils$1.tracing.formatObject({
|
|
187
188
|
prevSessionKeySignature,
|
|
188
189
|
publicKey,
|
|
189
190
|
walletId,
|
|
190
191
|
}));
|
|
191
|
-
if (utils.PlatformService.isNativeMobile) {
|
|
192
|
-
logger.logger.instrument(utils.tracing.packScopes());
|
|
192
|
+
if (utils$1.PlatformService.isNativeMobile) {
|
|
193
|
+
logger.logger.instrument(utils$1.tracing.packScopes());
|
|
193
194
|
}
|
|
194
195
|
if (responseError.response.status === 422) {
|
|
195
196
|
if (responseError.json.code ===
|
|
196
197
|
sdkApiCore.UnprocessableEntityErrorCode.InvalidSessionPublicKey) {
|
|
197
|
-
throw new utils.InvalidEmbeddedWalletSessionKeyError(responseError.json.error);
|
|
198
|
+
throw new utils$1.InvalidEmbeddedWalletSessionKeyError(responseError.json.error);
|
|
198
199
|
}
|
|
199
200
|
}
|
|
200
201
|
throw responseError;
|
|
@@ -216,7 +217,7 @@ const getCreateEmbeddedWalletAccountRequest = (_j) => _tslib.__awaiter(void 0, [
|
|
|
216
217
|
}
|
|
217
218
|
catch (e) {
|
|
218
219
|
yield logResponse(e, 'Error fetching create embedded wallet account request', { chain });
|
|
219
|
-
throw new utils.DynamicError('Error fetching create embedded wallet account request');
|
|
220
|
+
throw new utils$1.DynamicError('Error fetching create embedded wallet account request', 'create_embedded_wallet_account_request_error');
|
|
220
221
|
}
|
|
221
222
|
});
|
|
222
223
|
const createEmbeddedWalletAccount = (_k) => _tslib.__awaiter(void 0, [_k], void 0, function* ({ environmentId, createEmbeddedWalletAccountRequest, }) {
|
|
@@ -233,7 +234,7 @@ const createEmbeddedWalletAccount = (_k) => _tslib.__awaiter(void 0, [_k], void
|
|
|
233
234
|
yield logResponse(e, '[createEmbeddedWalletAccount] Error creating embedded wallet account', {
|
|
234
235
|
createEmbeddedWalletAccountRequest,
|
|
235
236
|
});
|
|
236
|
-
throw new utils.DynamicError('[createEmbeddedWalletAccount] Error creating embedded wallet account');
|
|
237
|
+
throw new utils$1.DynamicError('[createEmbeddedWalletAccount] Error creating embedded wallet account', 'create_embedded_wallet_account_error');
|
|
237
238
|
}
|
|
238
239
|
});
|
|
239
240
|
const getDeleteEmbeddedWalletsRequest = (_l) => _tslib.__awaiter(void 0, [_l], void 0, function* ({ environmentId, walletId, }) {
|
|
@@ -246,7 +247,7 @@ const getDeleteEmbeddedWalletsRequest = (_l) => _tslib.__awaiter(void 0, [_l], v
|
|
|
246
247
|
}
|
|
247
248
|
catch (e) {
|
|
248
249
|
yield logResponse(e, 'Error fetching delete embedded wallet request');
|
|
249
|
-
throw new utils.DynamicError('Error fetching delete embedded wallets request');
|
|
250
|
+
throw new utils$1.DynamicError('Error fetching delete embedded wallets request', 'fetching_delete_embedded_wallets_request');
|
|
250
251
|
}
|
|
251
252
|
});
|
|
252
253
|
const deleteEmbeddedWallets = (_m) => _tslib.__awaiter(void 0, [_m], void 0, function* ({ environmentId, deleteEmbeddedWalletsRequest, }) {
|
|
@@ -263,12 +264,12 @@ const deleteEmbeddedWallets = (_m) => _tslib.__awaiter(void 0, [_m], void 0, fun
|
|
|
263
264
|
yield logResponse(e, 'Error deleting embedded wallets', {
|
|
264
265
|
deleteEmbeddedWalletsRequest,
|
|
265
266
|
});
|
|
266
|
-
throw new utils.DynamicError('Error deleting embedded wallets');
|
|
267
|
+
throw new utils$1.DynamicError('Error deleting embedded wallets', 'deleting_embedded_wallets');
|
|
267
268
|
}
|
|
268
269
|
});
|
|
269
270
|
const logResponse = (error, message, data) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
270
|
-
if (error
|
|
271
|
-
const responseError = yield utils.ResponseError.fromResponse({
|
|
271
|
+
if (utils.isResponseLike(error)) {
|
|
272
|
+
const responseError = yield utils$1.ResponseError.fromResponse({
|
|
272
273
|
cause: error,
|
|
273
274
|
message,
|
|
274
275
|
});
|
|
@@ -13,6 +13,7 @@ import '../../../utils/constants/colors.js';
|
|
|
13
13
|
import '../../../utils/constants/values.js';
|
|
14
14
|
import '../../../shared/consts/index.js';
|
|
15
15
|
import { sdkApi } from '../api.js';
|
|
16
|
+
import { isResponseLike } from '../utils.js';
|
|
16
17
|
import '@dynamic-labs-sdk/client/core';
|
|
17
18
|
import 'eventemitter3';
|
|
18
19
|
import '@dynamic-labs-sdk/client';
|
|
@@ -105,7 +106,7 @@ const updatePasskeyRecoveryEmail = (_d) => __awaiter(void 0, [_d], void 0, funct
|
|
|
105
106
|
}
|
|
106
107
|
catch (e) {
|
|
107
108
|
yield logResponse(e, 'Error while trying to update recovery email');
|
|
108
|
-
throw new DynamicError('Error updating recovery email');
|
|
109
|
+
throw new DynamicError('Error updating recovery email', 'updating_recovery_email');
|
|
109
110
|
}
|
|
110
111
|
});
|
|
111
112
|
const getUserPasskeys = (_e) => __awaiter(void 0, [_e], void 0, function* ({ environmentId, }) {
|
|
@@ -173,7 +174,7 @@ const registerSessionKey = (_h) => __awaiter(void 0, [_h], void 0, function* ({
|
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
176
|
catch (error) {
|
|
176
|
-
if (error
|
|
177
|
+
if (isResponseLike(error)) {
|
|
177
178
|
const responseError = yield ResponseError.fromResponse({
|
|
178
179
|
cause: error,
|
|
179
180
|
message: 'Error register session key',
|
|
@@ -212,7 +213,7 @@ const getCreateEmbeddedWalletAccountRequest = (_j) => __awaiter(void 0, [_j], vo
|
|
|
212
213
|
}
|
|
213
214
|
catch (e) {
|
|
214
215
|
yield logResponse(e, 'Error fetching create embedded wallet account request', { chain });
|
|
215
|
-
throw new DynamicError('Error fetching create embedded wallet account request');
|
|
216
|
+
throw new DynamicError('Error fetching create embedded wallet account request', 'create_embedded_wallet_account_request_error');
|
|
216
217
|
}
|
|
217
218
|
});
|
|
218
219
|
const createEmbeddedWalletAccount = (_k) => __awaiter(void 0, [_k], void 0, function* ({ environmentId, createEmbeddedWalletAccountRequest, }) {
|
|
@@ -229,7 +230,7 @@ const createEmbeddedWalletAccount = (_k) => __awaiter(void 0, [_k], void 0, func
|
|
|
229
230
|
yield logResponse(e, '[createEmbeddedWalletAccount] Error creating embedded wallet account', {
|
|
230
231
|
createEmbeddedWalletAccountRequest,
|
|
231
232
|
});
|
|
232
|
-
throw new DynamicError('[createEmbeddedWalletAccount] Error creating embedded wallet account');
|
|
233
|
+
throw new DynamicError('[createEmbeddedWalletAccount] Error creating embedded wallet account', 'create_embedded_wallet_account_error');
|
|
233
234
|
}
|
|
234
235
|
});
|
|
235
236
|
const getDeleteEmbeddedWalletsRequest = (_l) => __awaiter(void 0, [_l], void 0, function* ({ environmentId, walletId, }) {
|
|
@@ -242,7 +243,7 @@ const getDeleteEmbeddedWalletsRequest = (_l) => __awaiter(void 0, [_l], void 0,
|
|
|
242
243
|
}
|
|
243
244
|
catch (e) {
|
|
244
245
|
yield logResponse(e, 'Error fetching delete embedded wallet request');
|
|
245
|
-
throw new DynamicError('Error fetching delete embedded wallets request');
|
|
246
|
+
throw new DynamicError('Error fetching delete embedded wallets request', 'fetching_delete_embedded_wallets_request');
|
|
246
247
|
}
|
|
247
248
|
});
|
|
248
249
|
const deleteEmbeddedWallets = (_m) => __awaiter(void 0, [_m], void 0, function* ({ environmentId, deleteEmbeddedWalletsRequest, }) {
|
|
@@ -259,11 +260,11 @@ const deleteEmbeddedWallets = (_m) => __awaiter(void 0, [_m], void 0, function*
|
|
|
259
260
|
yield logResponse(e, 'Error deleting embedded wallets', {
|
|
260
261
|
deleteEmbeddedWalletsRequest,
|
|
261
262
|
});
|
|
262
|
-
throw new DynamicError('Error deleting embedded wallets');
|
|
263
|
+
throw new DynamicError('Error deleting embedded wallets', 'deleting_embedded_wallets');
|
|
263
264
|
}
|
|
264
265
|
});
|
|
265
266
|
const logResponse = (error, message, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
266
|
-
if (error
|
|
267
|
+
if (isResponseLike(error)) {
|
|
267
268
|
const responseError = yield ResponseError.fromResponse({
|
|
268
269
|
cause: error,
|
|
269
270
|
message,
|
|
@@ -27,7 +27,7 @@ const getUserExchangeAccounts = (_a) => _tslib.__awaiter(void 0, [_a], void 0, f
|
|
|
27
27
|
}
|
|
28
28
|
catch (e) {
|
|
29
29
|
const data = yield utils.logResponseError(e, 'Error retrieving accounts');
|
|
30
|
-
throw new utils$1.DynamicError(data.error);
|
|
30
|
+
throw new utils$1.DynamicError(data.error, data.code);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
/**
|
|
@@ -100,7 +100,7 @@ const getExchangeAccountTransactions = (_c) => _tslib.__awaiter(void 0, [_c], vo
|
|
|
100
100
|
}
|
|
101
101
|
catch (e) {
|
|
102
102
|
const data = yield utils.logResponseError(e, 'Error retrieving transactions');
|
|
103
|
-
throw new utils$1.DynamicError(data.error);
|
|
103
|
+
throw new utils$1.DynamicError(data.error, data.code);
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
/**
|
|
@@ -128,7 +128,7 @@ const getExchangeTransferDestinations = (_d) => _tslib.__awaiter(void 0, [_d], v
|
|
|
128
128
|
}
|
|
129
129
|
catch (e) {
|
|
130
130
|
const data = yield utils.logResponseError(e, 'Error retrieving transfer destinations');
|
|
131
|
-
throw new utils$1.DynamicError(data.error);
|
|
131
|
+
throw new utils$1.DynamicError(data.error, data.code);
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
|
|
@@ -23,7 +23,7 @@ const getUserExchangeAccounts = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
23
23
|
}
|
|
24
24
|
catch (e) {
|
|
25
25
|
const data = yield logResponseError(e, 'Error retrieving accounts');
|
|
26
|
-
throw new DynamicError(data.error);
|
|
26
|
+
throw new DynamicError(data.error, data.code);
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
/**
|
|
@@ -96,7 +96,7 @@ const getExchangeAccountTransactions = (_c) => __awaiter(void 0, [_c], void 0, f
|
|
|
96
96
|
}
|
|
97
97
|
catch (e) {
|
|
98
98
|
const data = yield logResponseError(e, 'Error retrieving transactions');
|
|
99
|
-
throw new DynamicError(data.error);
|
|
99
|
+
throw new DynamicError(data.error, data.code);
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
/**
|
|
@@ -124,7 +124,7 @@ const getExchangeTransferDestinations = (_d) => __awaiter(void 0, [_d], void 0,
|
|
|
124
124
|
}
|
|
125
125
|
catch (e) {
|
|
126
126
|
const data = yield logResponseError(e, 'Error retrieving transfer destinations');
|
|
127
|
-
throw new DynamicError(data.error);
|
|
127
|
+
throw new DynamicError(data.error, data.code);
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
|
|
@@ -216,7 +216,7 @@ const handleVerifyError = (e) => _tslib.__awaiter(void 0, void 0, void 0, functi
|
|
|
216
216
|
throw new utils$1.DynamicError(data.error, utils$1.ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN);
|
|
217
217
|
}
|
|
218
218
|
if (data.code === 'social_account_already_exists') {
|
|
219
|
-
throw new utils$1.SocialAccountAlreadyExistsError();
|
|
219
|
+
throw new utils$1.SocialAccountAlreadyExistsError(data.error, data.code);
|
|
220
220
|
}
|
|
221
221
|
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
222
222
|
throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
|
|
@@ -234,13 +234,14 @@ const handleSignInError = (e) => _tslib.__awaiter(void 0, void 0, void 0, functi
|
|
|
234
234
|
}
|
|
235
235
|
if (data.error.code === 'missing_from_list') {
|
|
236
236
|
throw new utils$1.NoAccessError({
|
|
237
|
+
code: data.error.code,
|
|
237
238
|
socialProvider: (_f = data === null || data === void 0 ? void 0 : data.payload) === null || _f === void 0 ? void 0 : _f.socialProvider,
|
|
238
239
|
socialUsername: (_g = data === null || data === void 0 ? void 0 : data.payload) === null || _g === void 0 ? void 0 : _g.socialUsername,
|
|
239
240
|
walletPublicKey: (_h = data === null || data === void 0 ? void 0 : data.payload) === null || _h === void 0 ? void 0 : _h.walletPublicKey,
|
|
240
241
|
});
|
|
241
242
|
}
|
|
242
243
|
if (data.code === 'email_associated_with_different_provider') {
|
|
243
|
-
throw new utils$1.AccountExistsError(data.error, data.payload);
|
|
244
|
+
throw new utils$1.AccountExistsError(data.error, data.payload, data.code);
|
|
244
245
|
}
|
|
245
246
|
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
246
247
|
throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
|
|
@@ -212,7 +212,7 @@ const handleVerifyError = (e) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
212
212
|
throw new DynamicError(data.error, ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN);
|
|
213
213
|
}
|
|
214
214
|
if (data.code === 'social_account_already_exists') {
|
|
215
|
-
throw new SocialAccountAlreadyExistsError();
|
|
215
|
+
throw new SocialAccountAlreadyExistsError(data.error, data.code);
|
|
216
216
|
}
|
|
217
217
|
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
218
218
|
throw new SandboxMaximumThresholdReachedError(data.error.message);
|
|
@@ -230,13 +230,14 @@ const handleSignInError = (e) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
230
230
|
}
|
|
231
231
|
if (data.error.code === 'missing_from_list') {
|
|
232
232
|
throw new NoAccessError({
|
|
233
|
+
code: data.error.code,
|
|
233
234
|
socialProvider: (_f = data === null || data === void 0 ? void 0 : data.payload) === null || _f === void 0 ? void 0 : _f.socialProvider,
|
|
234
235
|
socialUsername: (_g = data === null || data === void 0 ? void 0 : data.payload) === null || _g === void 0 ? void 0 : _g.socialUsername,
|
|
235
236
|
walletPublicKey: (_h = data === null || data === void 0 ? void 0 : data.payload) === null || _h === void 0 ? void 0 : _h.walletPublicKey,
|
|
236
237
|
});
|
|
237
238
|
}
|
|
238
239
|
if (data.code === 'email_associated_with_different_provider') {
|
|
239
|
-
throw new AccountExistsError(data.error, data.payload);
|
|
240
|
+
throw new AccountExistsError(data.error, data.payload, data.code);
|
|
240
241
|
}
|
|
241
242
|
if (data.error.code === 'sandbox_maximum_threshold_reached') {
|
|
242
243
|
throw new SandboxMaximumThresholdReachedError(data.error.message);
|
|
@@ -12,21 +12,21 @@ var utils = require('../utils.cjs');
|
|
|
12
12
|
const mapChainToChainEnum = (chain) => {
|
|
13
13
|
const foundChain = Object.values(sdkApiCore.ChainEnum).find((value) => value === chain);
|
|
14
14
|
if (!foundChain) {
|
|
15
|
-
throw new utils$1.DynamicError(`Invalid chain ${chain}
|
|
15
|
+
throw new utils$1.DynamicError(`Invalid chain ${chain}`, 'invalid_chain');
|
|
16
16
|
}
|
|
17
17
|
return foundChain;
|
|
18
18
|
};
|
|
19
19
|
const mapProviderToProviderEnum = (provider) => {
|
|
20
20
|
const foundProvider = Object.values(sdkApiCore.WalletProviderEnum).find((value) => value === provider);
|
|
21
21
|
if (!foundProvider) {
|
|
22
|
-
throw new utils$1.DynamicError(`Invalid provider ${provider}
|
|
22
|
+
throw new utils$1.DynamicError(`Invalid provider ${provider}`, 'invalid_provider');
|
|
23
23
|
}
|
|
24
24
|
return foundProvider;
|
|
25
25
|
};
|
|
26
26
|
const mapAuthModeToEnum = (authMode) => {
|
|
27
27
|
const found = Object.values(sdkApiCore.AuthModeEnum).find((value) => value === authMode);
|
|
28
28
|
if (!found) {
|
|
29
|
-
throw new utils$1.DynamicError(`Invalid authMode ${authMode}
|
|
29
|
+
throw new utils$1.DynamicError(`Invalid authMode ${authMode}`, 'invalid_auth_mode');
|
|
30
30
|
}
|
|
31
31
|
return found;
|
|
32
32
|
};
|
|
@@ -8,21 +8,21 @@ import { logResponseError } from '../utils.js';
|
|
|
8
8
|
const mapChainToChainEnum = (chain) => {
|
|
9
9
|
const foundChain = Object.values(ChainEnum).find((value) => value === chain);
|
|
10
10
|
if (!foundChain) {
|
|
11
|
-
throw new DynamicError(`Invalid chain ${chain}
|
|
11
|
+
throw new DynamicError(`Invalid chain ${chain}`, 'invalid_chain');
|
|
12
12
|
}
|
|
13
13
|
return foundChain;
|
|
14
14
|
};
|
|
15
15
|
const mapProviderToProviderEnum = (provider) => {
|
|
16
16
|
const foundProvider = Object.values(WalletProviderEnum).find((value) => value === provider);
|
|
17
17
|
if (!foundProvider) {
|
|
18
|
-
throw new DynamicError(`Invalid provider ${provider}
|
|
18
|
+
throw new DynamicError(`Invalid provider ${provider}`, 'invalid_provider');
|
|
19
19
|
}
|
|
20
20
|
return foundProvider;
|
|
21
21
|
};
|
|
22
22
|
const mapAuthModeToEnum = (authMode) => {
|
|
23
23
|
const found = Object.values(AuthModeEnum).find((value) => value === authMode);
|
|
24
24
|
if (!found) {
|
|
25
|
-
throw new DynamicError(`Invalid authMode ${authMode}
|
|
25
|
+
throw new DynamicError(`Invalid authMode ${authMode}`, 'invalid_auth_mode');
|
|
26
26
|
}
|
|
27
27
|
return found;
|
|
28
28
|
};
|
|
@@ -58,7 +58,10 @@ const signInWithSmsVerification = (_b) => _tslib.__awaiter(void 0, [_b], void 0,
|
|
|
58
58
|
throw new utils$1.DynamicError(data.error, utils$1.ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN);
|
|
59
59
|
}
|
|
60
60
|
if (((_c = data.error) === null || _c === void 0 ? void 0 : _c.code) === 'missing_from_list') {
|
|
61
|
-
throw new utils$1.NoAccessError({
|
|
61
|
+
throw new utils$1.NoAccessError({
|
|
62
|
+
code: data.error.code,
|
|
63
|
+
phoneNumber: data.payload.phoneNumber,
|
|
64
|
+
});
|
|
62
65
|
}
|
|
63
66
|
if (data.code === 'wrong_sms_verification_token') {
|
|
64
67
|
throw new utils$1.SmsVerificationError(locale.Locale.getInstance().t('dyn_login.helper.phone_number_form.invalid_sms_verification'), data.code);
|
|
@@ -54,7 +54,10 @@ const signInWithSmsVerification = (_b) => __awaiter(void 0, [_b], void 0, functi
|
|
|
54
54
|
throw new DynamicError(data.error, ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN);
|
|
55
55
|
}
|
|
56
56
|
if (((_c = data.error) === null || _c === void 0 ? void 0 : _c.code) === 'missing_from_list') {
|
|
57
|
-
throw new NoAccessError({
|
|
57
|
+
throw new NoAccessError({
|
|
58
|
+
code: data.error.code,
|
|
59
|
+
phoneNumber: data.payload.phoneNumber,
|
|
60
|
+
});
|
|
58
61
|
}
|
|
59
62
|
if (data.code === 'wrong_sms_verification_token') {
|
|
60
63
|
throw new SmsVerificationError(Locale.getInstance().t('dyn_login.helper.phone_number_form.invalid_sms_verification'), data.code);
|
|
@@ -46,22 +46,22 @@ const updateUserProfileFields = (environmentId, fields) => _tslib.__awaiter(void
|
|
|
46
46
|
}
|
|
47
47
|
catch (e) {
|
|
48
48
|
const error = yield utils.logResponseError(e, 'Error updateUserProfileFields');
|
|
49
|
-
if (e
|
|
49
|
+
if (utils.isResponseLike(e)) {
|
|
50
50
|
if (error.code === 'email_already_exists') {
|
|
51
|
-
throw new utils$1.EmailAlreadyExistsError();
|
|
51
|
+
throw new utils$1.EmailAlreadyExistsError(error.error, error.code);
|
|
52
52
|
}
|
|
53
53
|
else if (error.code === 'custom_field_data_not_unique') {
|
|
54
54
|
throw new utils$1.CustomFieldNotUniqueError();
|
|
55
55
|
}
|
|
56
56
|
else if (error.code === 'username_already_exists') {
|
|
57
|
-
throw new utils$1.UsernameAlreadyExistsError();
|
|
57
|
+
throw new utils$1.UsernameAlreadyExistsError(error.error, error.code);
|
|
58
58
|
}
|
|
59
59
|
else if (error.code === 'too_many_verification_attempts') {
|
|
60
|
-
throw new utils$1.TooManyEmailVerificationsError();
|
|
60
|
+
throw new utils$1.TooManyEmailVerificationsError(error.error, error.code);
|
|
61
61
|
}
|
|
62
62
|
else if (error.code === 'invalid_phone' ||
|
|
63
63
|
error.code === 'invalid_sms_verification') {
|
|
64
|
-
throw new utils$1.InvalidPhoneNumberError(error.error);
|
|
64
|
+
throw new utils$1.InvalidPhoneNumberError(error.error, error.code);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
throw e;
|