@dynamic-labs/sdk-react-core 3.9.4 → 3.9.6

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +11 -11
  5. package/src/lib/components/TransactionCard/TransactionCard.cjs +3 -2
  6. package/src/lib/components/TransactionCard/TransactionCard.d.ts +1 -0
  7. package/src/lib/components/TransactionCard/TransactionCard.js +3 -2
  8. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +2 -2
  9. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.d.ts +1 -0
  10. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +2 -2
  11. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +7 -7
  12. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +7 -7
  13. package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +5 -5
  14. package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +5 -5
  15. package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.cjs +4 -4
  16. package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.js +4 -4
  17. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +6 -6
  18. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +6 -6
  19. package/src/lib/context/FundingContext/FundingContext.cjs +5 -5
  20. package/src/lib/context/FundingContext/FundingContext.js +5 -5
  21. package/src/lib/data/api/email/email.cjs +17 -32
  22. package/src/lib/data/api/email/email.js +6 -21
  23. package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +21 -32
  24. package/src/lib/data/api/embeddedWallets/embeddedWallets.js +17 -28
  25. package/src/lib/data/api/externalAuth/externalAuth.cjs +10 -23
  26. package/src/lib/data/api/externalAuth/externalAuth.js +3 -16
  27. package/src/lib/data/api/mfa/mfa.cjs +15 -33
  28. package/src/lib/data/api/mfa/mfa.js +11 -29
  29. package/src/lib/data/api/oauth/oauth.cjs +11 -12
  30. package/src/lib/data/api/oauth/oauth.js +4 -5
  31. package/src/lib/data/api/session/session.cjs +7 -19
  32. package/src/lib/data/api/session/session.js +3 -15
  33. package/src/lib/data/api/sms/sms.cjs +14 -16
  34. package/src/lib/data/api/sms/sms.js +5 -7
  35. package/src/lib/data/api/user/user.cjs +13 -11
  36. package/src/lib/data/api/user/user.js +6 -4
  37. package/src/lib/data/api/utils.cjs +24 -0
  38. package/src/lib/data/api/utils.d.ts +1 -0
  39. package/src/lib/data/api/utils.js +24 -1
  40. package/src/lib/data/api/wallets/wallets.cjs +17 -28
  41. package/src/lib/data/api/wallets/wallets.js +6 -17
  42. package/src/lib/locale/en/translation.cjs +2 -1
  43. package/src/lib/locale/en/translation.d.ts +1 -0
  44. package/src/lib/locale/en/translation.js +2 -1
  45. package/src/lib/store/state/projectSettings/projectSettings.cjs +5 -5
  46. package/src/lib/store/state/projectSettings/projectSettings.js +5 -5
  47. package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.cjs +5 -5
  48. package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.js +5 -5
  49. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +6 -6
  50. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +6 -6
  51. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +5 -5
  52. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +5 -5
  53. package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +5 -5
  54. package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +5 -5
  55. package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.cjs +7 -7
  56. package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.js +7 -7
  57. package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +3 -3
  58. package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +3 -3
  59. package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +5 -5
  60. package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +5 -5
  61. package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +2 -0
  62. package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +2 -0
  63. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +6 -6
  64. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +6 -6
  65. package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +6 -6
  66. package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +6 -6
  67. package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +8 -8
  68. package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +8 -8
  69. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +5 -3
  70. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +5 -3
@@ -2,18 +2,8 @@
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { MFADeviceType } from '@dynamic-labs/sdk-api-core';
4
4
  import { MfaInvalidOtpError, MfaRateLimitedError } from '@dynamic-labs/utils';
5
- import { logger } from '../../../shared/logger.js';
6
- import '@dynamic-labs/iconic';
7
- import '@dynamic-labs/wallet-connector-core';
8
- import 'react/jsx-runtime';
9
- import '../../../context/ViewContext/ViewContext.js';
10
- import 'react';
11
- import '@dynamic-labs/wallet-book';
12
- import '../../../utils/constants/colors.js';
13
- import '../../../utils/constants/values.js';
14
- import '../../../store/state/loadingAndLifecycle.js';
15
- import '../../../shared/consts/index.js';
16
5
  import { sdkApi } from '../api.js';
6
+ import { logResponseError } from '../utils.js';
17
7
 
18
8
  const getUserMfaDevices = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, }) {
19
9
  try {
@@ -23,8 +13,7 @@ const getUserMfaDevices = (_a) => __awaiter(void 0, [_a], void 0, function* ({ e
23
13
  return devices;
24
14
  }
25
15
  catch (e) {
26
- const data = yield e.json();
27
- logger.error(data.error);
16
+ yield logResponseError(e, 'Error getting mfa devices');
28
17
  return [];
29
18
  }
30
19
  });
@@ -39,8 +28,8 @@ const addMfaDevice = (_b) => __awaiter(void 0, [_b], void 0, function* ({ enviro
39
28
  throw new Error('Unsupported MFA device type');
40
29
  }
41
30
  catch (e) {
42
- const message = e instanceof Error ? e.message : (yield e.json()).error;
43
- logger.error(message);
31
+ const responseError = yield logResponseError(e, 'Error adding mfa device');
32
+ const message = e instanceof Error ? e.message : responseError.error;
44
33
  throw new Error(message);
45
34
  }
46
35
  });
@@ -52,8 +41,7 @@ const updateUserMfaDevice = (_c) => __awaiter(void 0, [_c], void 0, function* ({
52
41
  });
53
42
  }
54
43
  catch (e) {
55
- const data = yield e.json();
56
- logger.error(data.error);
44
+ yield logResponseError(e, 'Error updating mfa device');
57
45
  }
58
46
  });
59
47
  const deleteMfaDevice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ environmentId, mfaDeviceId, mfaAuthToken, }) {
@@ -65,8 +53,7 @@ const deleteMfaDevice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ env
65
53
  });
66
54
  }
67
55
  catch (e) {
68
- const data = yield e.json();
69
- logger.error(data.error);
56
+ yield logResponseError(e, 'Error delete mfa device');
70
57
  }
71
58
  });
72
59
  // used when verifying a device added after the user is already logged in
@@ -87,8 +74,7 @@ const verifyMfaDevice = (_e) => __awaiter(void 0, [_e], void 0, function* ({ env
87
74
  throw new Error('Unsupported MFA device type');
88
75
  }
89
76
  catch (e) {
90
- const message = e instanceof Error ? e.message : (yield e.json()).error;
91
- logger.error(message);
77
+ yield logResponseError(e, 'Error verify mfa device');
92
78
  return undefined;
93
79
  }
94
80
  });
@@ -111,9 +97,8 @@ const authMfaDevice = (_f) => __awaiter(void 0, [_f], void 0, function* ({ devic
111
97
  throw new Error('Unsupported MFA device type');
112
98
  }
113
99
  catch (error) {
114
- logger.error(error);
100
+ const responseError = yield logResponseError(error, 'Error auth mfa devices');
115
101
  if (error instanceof Response) {
116
- const responseError = yield error.json();
117
102
  if (responseError.code === 'mfa_invalid_code') {
118
103
  throw new MfaInvalidOtpError();
119
104
  }
@@ -132,8 +117,7 @@ const getRecoveryCodes = (_g) => __awaiter(void 0, [_g], void 0, function* ({ en
132
117
  return recoveryCodes;
133
118
  }
134
119
  catch (e) {
135
- const data = yield e.json();
136
- logger.error(data.error);
120
+ yield logResponseError(e, 'Error get mfa recovery codes');
137
121
  return [];
138
122
  }
139
123
  });
@@ -145,8 +129,7 @@ const createNewRecoveryCodes = (_h) => __awaiter(void 0, [_h], void 0, function*
145
129
  return recoveryCodes;
146
130
  }
147
131
  catch (e) {
148
- const data = yield e.json();
149
- logger.error(data.error);
132
+ yield logResponseError(e, 'Error create mfa recovery codes');
150
133
  return [];
151
134
  }
152
135
  });
@@ -164,9 +147,8 @@ const authMfaRecovery = (_j) => __awaiter(void 0, [_j], void 0, function* ({ env
164
147
  return response;
165
148
  }
166
149
  catch (error) {
167
- logger.error(error);
150
+ const responseError = yield logResponseError(error, 'Error mfa recovery');
168
151
  if (error instanceof Response) {
169
- const responseError = yield error.json();
170
152
  if (responseError.code === 'mfa_invalid_code') {
171
153
  throw new MfaInvalidOtpError();
172
154
  }
@@ -4,7 +4,7 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
- var utils = require('@dynamic-labs/utils');
7
+ var utils$1 = require('@dynamic-labs/utils');
8
8
  require('@dynamic-labs/sdk-api-core');
9
9
  var logger = require('../../../shared/logger.cjs');
10
10
  require('@dynamic-labs/iconic');
@@ -20,6 +20,7 @@ require('../../../shared/consts/index.cjs');
20
20
  var api = require('../api.cjs');
21
21
  var storeAuthTokenAndUser = require('../../../store/state/user/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs');
22
22
  require('../../../store/state/user/user.cjs');
23
+ var utils = require('../utils.cjs');
23
24
 
24
25
  const initAuth = (environmentId, providerType, oauthInitAuthRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
25
26
  try {
@@ -102,7 +103,7 @@ const getOAuthResult = (environmentId_3, providerType_3, _d) => _tslib.__awaiter
102
103
  return result;
103
104
  }
104
105
  catch (e) {
105
- logger.logger.error(e);
106
+ yield utils.logResponseError(e, 'error getting oauth result');
106
107
  return undefined;
107
108
  }
108
109
  });
@@ -171,35 +172,33 @@ const telegramVerify = (environmentId, oauthResultRequest) => _tslib.__awaiter(v
171
172
  }
172
173
  });
173
174
  const handleVerifyError = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
174
- logger.logger.error(e);
175
- const data = yield e.json();
175
+ const data = yield utils.logResponseError(e, 'error verifying social');
176
176
  if (data.code === 'social_account_already_exists') {
177
- throw new utils.SocialAccountAlreadyExistsError();
177
+ throw new utils$1.SocialAccountAlreadyExistsError();
178
178
  }
179
179
  if (data.error.code === 'sandbox_maximum_threshold_reached') {
180
- throw new utils.SandboxMaximumThresholdReachedError(data.error.message);
180
+ throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
181
181
  }
182
182
  return undefined;
183
183
  });
184
184
  const handleSignInError = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
185
185
  var _e, _f, _g;
186
- logger.logger.error(e);
187
- const data = yield e.json();
186
+ const data = yield utils.logResponseError(e, 'error signin social');
188
187
  if (data.error.code === 'gate_blocked') {
189
- throw new utils.GateBlockedError(data.payload.walletPublicKey);
188
+ throw new utils$1.GateBlockedError(data.payload.walletPublicKey);
190
189
  }
191
190
  if (data.error.code === 'missing_from_list') {
192
- throw new utils.NoAccessError({
191
+ throw new utils$1.NoAccessError({
193
192
  socialProvider: (_e = data === null || data === void 0 ? void 0 : data.payload) === null || _e === void 0 ? void 0 : _e.socialProvider,
194
193
  socialUsername: (_f = data === null || data === void 0 ? void 0 : data.payload) === null || _f === void 0 ? void 0 : _f.socialUsername,
195
194
  walletPublicKey: (_g = data === null || data === void 0 ? void 0 : data.payload) === null || _g === void 0 ? void 0 : _g.walletPublicKey,
196
195
  });
197
196
  }
198
197
  if (data.code === 'email_associated_with_different_provider') {
199
- throw new utils.AccountExistsError(data.error, data.payload);
198
+ throw new utils$1.AccountExistsError(data.error, data.payload);
200
199
  }
201
200
  if (data.error.code === 'sandbox_maximum_threshold_reached') {
202
- throw new utils.SandboxMaximumThresholdReachedError(data.error.message);
201
+ throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
203
202
  }
204
203
  return undefined;
205
204
  });
@@ -16,6 +16,7 @@ import '../../../shared/consts/index.js';
16
16
  import { sdkApi } from '../api.js';
17
17
  import { storeAuthTokenAndUser } from '../../../store/state/user/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
18
18
  import '../../../store/state/user/user.js';
19
+ import { logResponseError } from '../utils.js';
19
20
 
20
21
  const initAuth = (environmentId, providerType, oauthInitAuthRequest) => __awaiter(void 0, void 0, void 0, function* () {
21
22
  try {
@@ -98,7 +99,7 @@ const getOAuthResult = (environmentId_3, providerType_3, _d) => __awaiter(void 0
98
99
  return result;
99
100
  }
100
101
  catch (e) {
101
- logger.error(e);
102
+ yield logResponseError(e, 'error getting oauth result');
102
103
  return undefined;
103
104
  }
104
105
  });
@@ -167,8 +168,7 @@ const telegramVerify = (environmentId, oauthResultRequest) => __awaiter(void 0,
167
168
  }
168
169
  });
169
170
  const handleVerifyError = (e) => __awaiter(void 0, void 0, void 0, function* () {
170
- logger.error(e);
171
- const data = yield e.json();
171
+ const data = yield logResponseError(e, 'error verifying social');
172
172
  if (data.code === 'social_account_already_exists') {
173
173
  throw new SocialAccountAlreadyExistsError();
174
174
  }
@@ -179,8 +179,7 @@ const handleVerifyError = (e) => __awaiter(void 0, void 0, void 0, function* ()
179
179
  });
180
180
  const handleSignInError = (e) => __awaiter(void 0, void 0, void 0, function* () {
181
181
  var _e, _f, _g;
182
- logger.error(e);
183
- const data = yield e.json();
182
+ const data = yield logResponseError(e, 'error signin social');
184
183
  if (data.error.code === 'gate_blocked') {
185
184
  throw new GateBlockedError(data.payload.walletPublicKey);
186
185
  }
@@ -4,20 +4,10 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
- var utils = require('@dynamic-labs/utils');
7
+ var utils$1 = require('@dynamic-labs/utils');
8
8
  var sdkApiCore = require('@dynamic-labs/sdk-api-core');
9
- var logger = require('../../../shared/logger.cjs');
10
- require('@dynamic-labs/iconic');
11
- require('@dynamic-labs/wallet-connector-core');
12
- require('react/jsx-runtime');
13
- require('../../../context/ViewContext/ViewContext.cjs');
14
- require('react');
15
- require('@dynamic-labs/wallet-book');
16
- require('../../../utils/constants/colors.cjs');
17
- require('../../../utils/constants/values.cjs');
18
- require('../../../store/state/loadingAndLifecycle.cjs');
19
- require('../../../shared/consts/index.cjs');
20
9
  var api = require('../api.cjs');
10
+ var utils = require('../utils.cjs');
21
11
 
22
12
  const revokeSession = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, sessionId, }) {
23
13
  try {
@@ -26,28 +16,27 @@ const revokeSession = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* (
26
16
  });
27
17
  }
28
18
  catch (error) {
29
- const body = yield error.json();
30
- logger.logger.error(Error(body.error.message));
19
+ yield utils.logResponseError(error, 'Error revoking session');
31
20
  }
32
21
  });
33
22
  const mapChainToChainEnum = (chain) => {
34
23
  const foundChain = Object.values(sdkApiCore.ChainEnum).find((value) => value === chain);
35
24
  if (!foundChain) {
36
- throw new utils.DynamicError(`Invalid chain ${chain}`);
25
+ throw new utils$1.DynamicError(`Invalid chain ${chain}`);
37
26
  }
38
27
  return foundChain;
39
28
  };
40
29
  const mapProviderToProviderEnum = (provider) => {
41
30
  const foundProvider = Object.values(sdkApiCore.WalletProviderEnum).find((value) => value === provider);
42
31
  if (!foundProvider) {
43
- throw new utils.DynamicError(`Invalid provider ${provider}`);
32
+ throw new utils$1.DynamicError(`Invalid provider ${provider}`);
44
33
  }
45
34
  return foundProvider;
46
35
  };
47
36
  const mapAuthModeTypeToEnum = (authMode) => {
48
37
  const found = Object.values(sdkApiCore.AuthModeEnum).find((value) => value === authMode);
49
38
  if (!found) {
50
- throw new utils.DynamicError(`Invalid authMode ${authMode}`);
39
+ throw new utils$1.DynamicError(`Invalid authMode ${authMode}`);
51
40
  }
52
41
  return found;
53
42
  };
@@ -66,8 +55,7 @@ const createVisit = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({
66
55
  });
67
56
  }
68
57
  catch (error) {
69
- // log error to console, don't do anything else
70
- logger.logger.error(error);
58
+ yield utils.logResponseError(error, 'Error creating visit');
71
59
  }
72
60
  });
73
61
 
@@ -2,18 +2,8 @@
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { DynamicError } from '@dynamic-labs/utils';
4
4
  import { ChainEnum, WalletProviderEnum, AuthModeEnum } from '@dynamic-labs/sdk-api-core';
5
- import { logger } from '../../../shared/logger.js';
6
- import '@dynamic-labs/iconic';
7
- import '@dynamic-labs/wallet-connector-core';
8
- import 'react/jsx-runtime';
9
- import '../../../context/ViewContext/ViewContext.js';
10
- import 'react';
11
- import '@dynamic-labs/wallet-book';
12
- import '../../../utils/constants/colors.js';
13
- import '../../../utils/constants/values.js';
14
- import '../../../store/state/loadingAndLifecycle.js';
15
- import '../../../shared/consts/index.js';
16
5
  import { sdkApi } from '../api.js';
6
+ import { logResponseError } from '../utils.js';
17
7
 
18
8
  const revokeSession = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, sessionId, }) {
19
9
  try {
@@ -22,8 +12,7 @@ const revokeSession = (_a) => __awaiter(void 0, [_a], void 0, function* ({ envir
22
12
  });
23
13
  }
24
14
  catch (error) {
25
- const body = yield error.json();
26
- logger.error(Error(body.error.message));
15
+ yield logResponseError(error, 'Error revoking session');
27
16
  }
28
17
  });
29
18
  const mapChainToChainEnum = (chain) => {
@@ -62,8 +51,7 @@ const createVisit = (_b) => __awaiter(void 0, [_b], void 0, function* ({ authMod
62
51
  });
63
52
  }
64
53
  catch (error) {
65
- // log error to console, don't do anything else
66
- logger.error(error);
54
+ yield logResponseError(error, 'Error creating visit');
67
55
  }
68
56
  });
69
57
 
@@ -4,7 +4,7 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
- var utils = require('@dynamic-labs/utils');
7
+ var utils$1 = require('@dynamic-labs/utils');
8
8
  var locale = require('../../../locale/locale.cjs');
9
9
  require('@dynamic-labs/sdk-api-core');
10
10
  var logger = require('../../../shared/logger.cjs');
@@ -19,6 +19,7 @@ require('../../../utils/constants/values.cjs');
19
19
  require('../../../store/state/loadingAndLifecycle.cjs');
20
20
  require('../../../shared/consts/index.cjs');
21
21
  var api = require('../api.cjs');
22
+ var utils = require('../utils.cjs');
22
23
 
23
24
  const createSmsVerification = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ isoCountryCode, phoneNumber, phoneCountryCode, environmentId, captchaToken, }) {
24
25
  try {
@@ -33,9 +34,8 @@ const createSmsVerification = (_a) => _tslib.__awaiter(void 0, [_a], void 0, fun
33
34
  });
34
35
  }
35
36
  catch (e) {
36
- const data = yield e.json();
37
- logger.logger.error(data.error);
38
- throw new utils.SmsVerificationError(data.error, data.code);
37
+ const data = yield utils.logResponseError(e, 'Error creating phone number verification');
38
+ throw new utils$1.SmsVerificationError(data.error, data.code);
39
39
  }
40
40
  });
41
41
  const signInWithSmsVerification = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ verificationToken, verificationUUID, environmentId, captchaToken, sessionPublicKey, }) {
@@ -52,18 +52,17 @@ const signInWithSmsVerification = (_b) => _tslib.__awaiter(void 0, [_b], void 0,
52
52
  });
53
53
  }
54
54
  catch (e) {
55
- const data = yield e.json();
56
- logger.logger.error(data.error);
55
+ const data = yield utils.logResponseError(e, 'Error signin phone number');
57
56
  if (((_c = data.error) === null || _c === void 0 ? void 0 : _c.code) === 'missing_from_list') {
58
- throw new utils.NoAccessError({ phoneNumber: data.payload.phoneNumber });
57
+ throw new utils$1.NoAccessError({ phoneNumber: data.payload.phoneNumber });
59
58
  }
60
59
  if (data.code === 'wrong_sms_verification_token') {
61
- throw new utils.SmsVerificationError(locale.Locale.getInstance().t('dyn_login.helper.phone_number_form.invalid_sms_verification'), data.code);
60
+ throw new utils$1.SmsVerificationError(locale.Locale.getInstance().t('dyn_login.helper.phone_number_form.invalid_sms_verification'), data.code);
62
61
  }
63
62
  if (data.error.code === 'sandbox_maximum_threshold_reached') {
64
- throw new utils.SandboxMaximumThresholdReachedError(data.error.message);
63
+ throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
65
64
  }
66
- throw new utils.SmsVerificationError(data.error, data.code);
65
+ throw new utils$1.SmsVerificationError(data.error, data.code);
67
66
  }
68
67
  });
69
68
  const retrySmsVerification = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ isoCountryCode, phoneCountryCode, phoneNumber, environmentId, verificationUUID, }) {
@@ -79,9 +78,8 @@ const retrySmsVerification = (_d) => _tslib.__awaiter(void 0, [_d], void 0, func
79
78
  });
80
79
  }
81
80
  catch (e) {
82
- const data = yield e.json();
83
- logger.logger.error(data.error);
84
- throw new utils.SmsVerificationError(data.error, data.code);
81
+ const data = yield utils.logResponseError(e, 'Error retrying phone number verification');
82
+ throw new utils$1.SmsVerificationError(data.error, data.code);
85
83
  }
86
84
  });
87
85
  const verifySms = (_e) => _tslib.__awaiter(void 0, [_e], void 0, function* ({ verificationToken, verificationUUID, environmentId, }) {
@@ -95,12 +93,12 @@ const verifySms = (_e) => _tslib.__awaiter(void 0, [_e], void 0, function* ({ ve
95
93
  });
96
94
  }
97
95
  catch (e) {
98
- const data = yield e.json();
96
+ const data = yield utils.logResponseError(e, 'Error verifying phone number');
99
97
  logger.logger.error(data.error);
100
98
  if (data.error.code === 'sandbox_maximum_threshold_reached') {
101
- throw new utils.SandboxMaximumThresholdReachedError(data.error.message);
99
+ throw new utils$1.SandboxMaximumThresholdReachedError(data.error.message);
102
100
  }
103
- throw new utils.SmsVerificationError(data.error, data.code);
101
+ throw new utils$1.SmsVerificationError(data.error, data.code);
104
102
  }
105
103
  });
106
104
 
@@ -15,6 +15,7 @@ import '../../../utils/constants/values.js';
15
15
  import '../../../store/state/loadingAndLifecycle.js';
16
16
  import '../../../shared/consts/index.js';
17
17
  import { sdkApi } from '../api.js';
18
+ import { logResponseError } from '../utils.js';
18
19
 
19
20
  const createSmsVerification = (_a) => __awaiter(void 0, [_a], void 0, function* ({ isoCountryCode, phoneNumber, phoneCountryCode, environmentId, captchaToken, }) {
20
21
  try {
@@ -29,8 +30,7 @@ const createSmsVerification = (_a) => __awaiter(void 0, [_a], void 0, function*
29
30
  });
30
31
  }
31
32
  catch (e) {
32
- const data = yield e.json();
33
- logger.error(data.error);
33
+ const data = yield logResponseError(e, 'Error creating phone number verification');
34
34
  throw new SmsVerificationError(data.error, data.code);
35
35
  }
36
36
  });
@@ -48,8 +48,7 @@ const signInWithSmsVerification = (_b) => __awaiter(void 0, [_b], void 0, functi
48
48
  });
49
49
  }
50
50
  catch (e) {
51
- const data = yield e.json();
52
- logger.error(data.error);
51
+ const data = yield logResponseError(e, 'Error signin phone number');
53
52
  if (((_c = data.error) === null || _c === void 0 ? void 0 : _c.code) === 'missing_from_list') {
54
53
  throw new NoAccessError({ phoneNumber: data.payload.phoneNumber });
55
54
  }
@@ -75,8 +74,7 @@ const retrySmsVerification = (_d) => __awaiter(void 0, [_d], void 0, function* (
75
74
  });
76
75
  }
77
76
  catch (e) {
78
- const data = yield e.json();
79
- logger.error(data.error);
77
+ const data = yield logResponseError(e, 'Error retrying phone number verification');
80
78
  throw new SmsVerificationError(data.error, data.code);
81
79
  }
82
80
  });
@@ -91,7 +89,7 @@ const verifySms = (_e) => __awaiter(void 0, [_e], void 0, function* ({ verificat
91
89
  });
92
90
  }
93
91
  catch (e) {
94
- const data = yield e.json();
92
+ const data = yield logResponseError(e, 'Error verifying phone number');
95
93
  logger.error(data.error);
96
94
  if (data.error.code === 'sandbox_maximum_threshold_reached') {
97
95
  throw new SandboxMaximumThresholdReachedError(data.error.message);
@@ -4,7 +4,7 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
- var utils = require('@dynamic-labs/utils');
7
+ var utils$1 = require('@dynamic-labs/utils');
8
8
  require('@dynamic-labs/sdk-api-core');
9
9
  var logger = require('../../../shared/logger.cjs');
10
10
  require('@dynamic-labs/iconic');
@@ -20,6 +20,7 @@ require('../../../shared/consts/index.cjs');
20
20
  var api = require('../api.cjs');
21
21
  var storeAuthTokenAndUser = require('../../../store/state/user/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs');
22
22
  require('../../../store/state/user/user.cjs');
23
+ var utils = require('../utils.cjs');
23
24
 
24
25
  const updateUserProfileFields = (environmentId, fields) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
25
26
  try {
@@ -31,24 +32,23 @@ const updateUserProfileFields = (environmentId, fields) => _tslib.__awaiter(void
31
32
  return Object.assign(Object.assign({}, response), { userProfile });
32
33
  }
33
34
  catch (e) {
34
- logger.logger.error(e);
35
+ const error = yield utils.logResponseError(e, 'Error updateUserProfileFields');
35
36
  if (e instanceof Response) {
36
- const error = yield e.json();
37
37
  if (error.code === 'email_already_exists') {
38
- throw new utils.EmailAlreadyExistsError();
38
+ throw new utils$1.EmailAlreadyExistsError();
39
39
  }
40
40
  else if (error.code === 'custom_field_data_not_unique') {
41
- throw new utils.CustomFieldNotUniqueError();
41
+ throw new utils$1.CustomFieldNotUniqueError();
42
42
  }
43
43
  else if (error.code === 'username_already_exists') {
44
- throw new utils.UsernameAlreadyExistsError();
44
+ throw new utils$1.UsernameAlreadyExistsError();
45
45
  }
46
46
  else if (error.code === 'too_many_verification_attempts') {
47
- throw new utils.TooManyEmailVerificationsError();
47
+ throw new utils$1.TooManyEmailVerificationsError();
48
48
  }
49
49
  else if (error.code === 'invalid_phone' ||
50
50
  error.code === 'invalid_sms_verification') {
51
- throw new utils.InvalidPhoneNumberError(error.error);
51
+ throw new utils$1.InvalidPhoneNumberError(error.error);
52
52
  }
53
53
  }
54
54
  throw e;
@@ -63,7 +63,7 @@ const mergeUserAccounts = (environmentId) => _tslib.__awaiter(void 0, void 0, vo
63
63
  return user;
64
64
  }
65
65
  catch (e) {
66
- logger.logger.error(e);
66
+ yield utils.logResponseError(e, 'Error mergeUserAccounts');
67
67
  throw e;
68
68
  }
69
69
  });
@@ -79,7 +79,7 @@ const verifyMergeUsers = (environmentId, mergeConflictResolutions) => _tslib.__a
79
79
  return user;
80
80
  }
81
81
  catch (e) {
82
- logger.logger.error(e);
82
+ yield utils.logResponseError(e, 'Error verifyMergeUsers');
83
83
  throw e;
84
84
  }
85
85
  });
@@ -92,6 +92,7 @@ const refreshUserJwt = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function*
92
92
  return user;
93
93
  }
94
94
  catch (e) {
95
+ yield utils.logResponseError(e, 'Error refreshUserJwt');
95
96
  return undefined;
96
97
  }
97
98
  });
@@ -102,11 +103,12 @@ const getAuthenticatedUser = (_b) => _tslib.__awaiter(void 0, [_b], void 0, func
102
103
  });
103
104
  }
104
105
  catch (e) {
106
+ yield utils.logResponseError(e, 'Error getAuthenticatedUser');
105
107
  // only explicitly throw `CookieInvalidError` when we attempt to get the authenticated user
106
108
  // and the backend returns a 401, indicating that there is no valid auth for the request
107
109
  if (e.status === 401) {
108
110
  logger.logger.error('No valid auth for getAuthenticatedUser', e);
109
- throw new utils.CookieInvalidError();
111
+ throw new utils$1.CookieInvalidError();
110
112
  }
111
113
  logger.logger.error('Other error getting authenticated user', e);
112
114
  return undefined;
@@ -16,6 +16,7 @@ import '../../../shared/consts/index.js';
16
16
  import { sdkApi } from '../api.js';
17
17
  import { storeAuthTokenAndUser } from '../../../store/state/user/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
18
18
  import '../../../store/state/user/user.js';
19
+ import { logResponseError } from '../utils.js';
19
20
 
20
21
  const updateUserProfileFields = (environmentId, fields) => __awaiter(void 0, void 0, void 0, function* () {
21
22
  try {
@@ -27,9 +28,8 @@ const updateUserProfileFields = (environmentId, fields) => __awaiter(void 0, voi
27
28
  return Object.assign(Object.assign({}, response), { userProfile });
28
29
  }
29
30
  catch (e) {
30
- logger.error(e);
31
+ const error = yield logResponseError(e, 'Error updateUserProfileFields');
31
32
  if (e instanceof Response) {
32
- const error = yield e.json();
33
33
  if (error.code === 'email_already_exists') {
34
34
  throw new EmailAlreadyExistsError();
35
35
  }
@@ -59,7 +59,7 @@ const mergeUserAccounts = (environmentId) => __awaiter(void 0, void 0, void 0, f
59
59
  return user;
60
60
  }
61
61
  catch (e) {
62
- logger.error(e);
62
+ yield logResponseError(e, 'Error mergeUserAccounts');
63
63
  throw e;
64
64
  }
65
65
  });
@@ -75,7 +75,7 @@ const verifyMergeUsers = (environmentId, mergeConflictResolutions) => __awaiter(
75
75
  return user;
76
76
  }
77
77
  catch (e) {
78
- logger.error(e);
78
+ yield logResponseError(e, 'Error verifyMergeUsers');
79
79
  throw e;
80
80
  }
81
81
  });
@@ -88,6 +88,7 @@ const refreshUserJwt = (_a) => __awaiter(void 0, [_a], void 0, function* ({ envi
88
88
  return user;
89
89
  }
90
90
  catch (e) {
91
+ yield logResponseError(e, 'Error refreshUserJwt');
91
92
  return undefined;
92
93
  }
93
94
  });
@@ -98,6 +99,7 @@ const getAuthenticatedUser = (_b) => __awaiter(void 0, [_b], void 0, function* (
98
99
  });
99
100
  }
100
101
  catch (e) {
102
+ yield logResponseError(e, 'Error getAuthenticatedUser');
101
103
  // only explicitly throw `CookieInvalidError` when we attempt to get the authenticated user
102
104
  // and the backend returns a 401, indicating that there is no valid auth for the request
103
105
  if (e.status === 401) {
@@ -4,8 +4,31 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../_virtual/_tslib.cjs');
7
+ require('@dynamic-labs/sdk-api-core');
8
+ var logger = require('../../shared/logger.cjs');
9
+ require('@dynamic-labs/iconic');
10
+ require('@dynamic-labs/wallet-connector-core');
11
+ require('react/jsx-runtime');
12
+ require('../../context/ViewContext/ViewContext.cjs');
13
+ require('react');
14
+ require('@dynamic-labs/wallet-book');
15
+ require('@dynamic-labs/utils');
16
+ require('../../utils/constants/colors.cjs');
17
+ require('../../utils/constants/values.cjs');
18
+ require('../../store/state/loadingAndLifecycle.cjs');
19
+ require('../../shared/consts/index.cjs');
7
20
  var api = require('./api.cjs');
8
21
 
22
+ const logResponseError = (e, message) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
23
+ if (e instanceof Response) {
24
+ const data = yield e.json();
25
+ logger.logger.error(message, { error: data.error, status: e.status });
26
+ return data;
27
+ }
28
+ else if (e instanceof Error) {
29
+ logger.logger.error(message, e);
30
+ }
31
+ });
9
32
  const fetchNonce = (environmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
10
33
  try {
11
34
  const res = yield api.sdkApi().getNonce({
@@ -19,3 +42,4 @@ const fetchNonce = (environmentId) => _tslib.__awaiter(void 0, void 0, void 0, f
19
42
  });
20
43
 
21
44
  exports.fetchNonce = fetchNonce;
45
+ exports.logResponseError = logResponseError;
@@ -1 +1,2 @@
1
+ export declare const logResponseError: (e: any, message: string) => Promise<any>;
1
2
  export declare const fetchNonce: (environmentId: string) => Promise<string | undefined>;