@dynamic-labs/sdk-react-core 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/index.d.ts +1 -1
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +9 -1
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +9 -1
- package/src/lib/context/LoadingContext/LoadingContext.cjs +1 -1
- package/src/lib/context/LoadingContext/LoadingContext.js +1 -1
- package/src/lib/data/api/user/user.cjs +3 -2
- package/src/lib/data/api/user/user.js +3 -2
- package/src/lib/events/auth.d.ts +25 -0
- package/src/lib/events/dynamicEvents.d.ts +8 -31
- package/src/lib/events/embeddedWallet.d.ts +14 -0
- package/src/lib/events/otp.d.ts +5 -0
- package/src/lib/events/passkey.d.ts +5 -0
- package/src/lib/events/social.d.ts +3 -0
- package/src/lib/events/ui.d.ts +10 -0
- package/src/lib/events/wallet.d.ts +7 -0
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +21 -5
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +21 -5
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +12 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +2 -2
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.cjs +27 -14
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +27 -14
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +6 -6
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +6 -6
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +35 -24
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +35 -24
- 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/useVerifyWallet/useVerifyWallet.cjs +13 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +13 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -0
- package/src/lib/views/EmailVerification/EmailVerification.js +2 -0
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +4 -0
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +4 -0
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.cjs +9 -1
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.js +9 -1
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +5 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +5 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.js +3 -3
|
@@ -101,17 +101,17 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
101
101
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
|
|
102
102
|
const checkValidOAuthLinking = (provider) => {
|
|
103
103
|
if (!isSocialKycEnabled(projectSettings)) {
|
|
104
|
-
handleError(SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled on the dashboard');
|
|
104
|
+
handleError(provider, SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled on the dashboard');
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
107
|
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
108
108
|
if (verifiedCredential) {
|
|
109
|
-
handleError(SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`);
|
|
109
|
+
handleError(provider, SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`);
|
|
110
110
|
return false;
|
|
111
111
|
}
|
|
112
112
|
const oauthProvider = oauthProviders.find((p) => p.provider === provider);
|
|
113
113
|
if (!oauthProvider) {
|
|
114
|
-
handleError(SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}`);
|
|
114
|
+
handleError(provider, SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}`);
|
|
115
115
|
return false;
|
|
116
116
|
}
|
|
117
117
|
return true;
|
|
@@ -128,7 +128,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
128
128
|
}
|
|
129
129
|
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
130
130
|
if (!verifiedCredential) {
|
|
131
|
-
handleError(SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}`);
|
|
131
|
+
handleError(undefined, SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}`);
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
try {
|
|
@@ -139,14 +139,14 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
139
139
|
verifiedCrentialId: (_b = verifiedCredential.id) !== null && _b !== void 0 ? _b : '',
|
|
140
140
|
}, String(userJwt));
|
|
141
141
|
if (!response) {
|
|
142
|
-
handleError(SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
|
|
142
|
+
handleError(undefined, SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
145
|
yield updateUserProfileByJWT(response.jwt, response.minifiedJwt);
|
|
146
146
|
setIsProcessing(false);
|
|
147
147
|
}
|
|
148
148
|
catch (err) {
|
|
149
|
-
handleError(SocialOAuthErrorCode.GENERAL_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
|
|
149
|
+
handleError(undefined, SocialOAuthErrorCode.GENERAL_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
const isLinked = (provider) => Boolean(verifiedOAuthCredentialsMap[provider]);
|
|
@@ -19,7 +19,7 @@ require('../../constants/colors.cjs');
|
|
|
19
19
|
require('../../constants/values.cjs');
|
|
20
20
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
21
21
|
require('../../../shared/consts/index.cjs');
|
|
22
|
-
require('../../../events/dynamicEvents.cjs');
|
|
22
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
23
23
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
24
24
|
var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
25
|
var digestSHA256 = require('../../functions/digestSHA256/digestSHA256.cjs');
|
|
@@ -123,13 +123,22 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
123
123
|
setError(undefined);
|
|
124
124
|
setContextError(undefined);
|
|
125
125
|
};
|
|
126
|
-
const
|
|
126
|
+
const onFailed = (provider, reason) => {
|
|
127
|
+
onError === null || onError === void 0 ? void 0 : onError();
|
|
128
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
129
|
+
if (provider)
|
|
130
|
+
dynamicEvents.dynamicEvents.emit('authFailure', {
|
|
131
|
+
option: provider,
|
|
132
|
+
type: 'social',
|
|
133
|
+
}, reason);
|
|
134
|
+
};
|
|
135
|
+
const handleError = (provider, code, message) => {
|
|
136
|
+
const error = { code, message };
|
|
127
137
|
logger.logger.error(message);
|
|
128
138
|
setIsProcessing(false);
|
|
129
|
-
setError(
|
|
139
|
+
setError(error);
|
|
130
140
|
setErrorMessage(code);
|
|
131
|
-
|
|
132
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
141
|
+
onFailed(provider, { error });
|
|
133
142
|
};
|
|
134
143
|
const poolOauthResult = (provider, state) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
135
144
|
if (!shouldPool.current) {
|
|
@@ -153,11 +162,11 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
153
162
|
});
|
|
154
163
|
const checkValidProvider = (provider) => {
|
|
155
164
|
if (!provider) {
|
|
156
|
-
handleError(types.SocialOAuthErrorCode.NO_PROVIDER, 'Provider is required');
|
|
165
|
+
handleError(provider, types.SocialOAuthErrorCode.NO_PROVIDER, 'Provider is required');
|
|
157
166
|
return false;
|
|
158
167
|
}
|
|
159
168
|
if (!socialProviders.includes(provider)) {
|
|
160
|
-
handleError(types.SocialOAuthErrorCode.INVALID_PROVIDER, `Invalid social provider. Valid providers are: ${socialProviders.join(', ')}`);
|
|
169
|
+
handleError(provider, types.SocialOAuthErrorCode.INVALID_PROVIDER, `Invalid social provider. Valid providers are: ${socialProviders.join(', ')}`);
|
|
161
170
|
return false;
|
|
162
171
|
}
|
|
163
172
|
return true;
|
|
@@ -166,7 +175,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
166
175
|
try {
|
|
167
176
|
const response = yield apiCall();
|
|
168
177
|
if (!response) {
|
|
169
|
-
handleError(types.SocialOAuthErrorCode.VERIFICATION_ERROR, `Failed to link social account: ${provider}`);
|
|
178
|
+
handleError(provider, types.SocialOAuthErrorCode.VERIFICATION_ERROR, `Failed to link social account: ${provider}`);
|
|
170
179
|
return;
|
|
171
180
|
}
|
|
172
181
|
yield updateUserProfileByJWT(response.jwt, response.minifiedJwt);
|
|
@@ -174,7 +183,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
174
183
|
}
|
|
175
184
|
catch (error) {
|
|
176
185
|
if (error instanceof utils.SocialAccountAlreadyExistsError) {
|
|
177
|
-
handleError(types.SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_PROFILE, `Social account already linked to a different profile: ${provider}`);
|
|
186
|
+
handleError(provider, types.SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_PROFILE, `Social account already linked to a different profile: ${provider}`);
|
|
178
187
|
}
|
|
179
188
|
}
|
|
180
189
|
});
|
|
@@ -183,7 +192,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
183
192
|
try {
|
|
184
193
|
const response = yield apiCall();
|
|
185
194
|
if (!response) {
|
|
186
|
-
handleError(types.SocialOAuthErrorCode.SIGNIN_ERROR, `Failed to sign-in with social account: ${provider}`);
|
|
195
|
+
handleError(provider, types.SocialOAuthErrorCode.SIGNIN_ERROR, `Failed to sign-in with social account: ${provider}`);
|
|
187
196
|
return;
|
|
188
197
|
}
|
|
189
198
|
const decodedJwt = decodeJwt.decodeJwt(response.jwt);
|
|
@@ -219,7 +228,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
219
228
|
setView('account-exists');
|
|
220
229
|
return;
|
|
221
230
|
}
|
|
222
|
-
handleError(types.SocialOAuthErrorCode.GENERAL_ERROR, error);
|
|
231
|
+
handleError(provider, types.SocialOAuthErrorCode.GENERAL_ERROR, error);
|
|
223
232
|
}
|
|
224
233
|
});
|
|
225
234
|
const connectSocialAccount = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ provider, validator, captchaToken, }) {
|
|
@@ -234,9 +243,12 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
234
243
|
if (validator && !validator(provider)) {
|
|
235
244
|
return;
|
|
236
245
|
}
|
|
246
|
+
dynamicEvents.dynamicEvents.emit('authInit', {
|
|
247
|
+
option: provider,
|
|
248
|
+
type: 'social',
|
|
249
|
+
});
|
|
237
250
|
if (provider === sdkApiCore.ProviderEnum.Farcaster) {
|
|
238
|
-
connectWithFarcaster();
|
|
239
|
-
return;
|
|
251
|
+
return connectWithFarcaster();
|
|
240
252
|
}
|
|
241
253
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
242
254
|
const state = randomString.randomString(8);
|
|
@@ -287,13 +299,13 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
287
299
|
}
|
|
288
300
|
setIsProcessing(true);
|
|
289
301
|
if (!((_h = providersWaitingOauthMessage.current) === null || _h === void 0 ? void 0 : _h[provider])) {
|
|
290
|
-
handleError(types.SocialOAuthErrorCode.SESSION_TIMEOUT, `Connecting ${provider} account session timeout.`);
|
|
302
|
+
handleError(provider, types.SocialOAuthErrorCode.SESSION_TIMEOUT, `Connecting ${provider} account session timeout.`);
|
|
291
303
|
return;
|
|
292
304
|
}
|
|
293
305
|
clearListeners();
|
|
294
306
|
const { code, error, state: authState } = message;
|
|
295
307
|
if (error && error !== 'undefined') {
|
|
296
|
-
handleError(types.SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: ${error}`);
|
|
308
|
+
handleError(provider, types.SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: ${error}`);
|
|
297
309
|
return;
|
|
298
310
|
}
|
|
299
311
|
// check that the state we receive from message is the same state we calculated earlier
|
|
@@ -301,11 +313,11 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
301
313
|
// this state check is used only by providers with an open window opener reference (eg, not twitter)
|
|
302
314
|
if (!providersWithoutWindowOpenerRefence.includes(provider) &&
|
|
303
315
|
state !== authState) {
|
|
304
|
-
handleError(types.SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: Invalid random state`);
|
|
316
|
+
handleError(provider, types.SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: Invalid random state`);
|
|
305
317
|
return;
|
|
306
318
|
}
|
|
307
319
|
if (!code) {
|
|
308
|
-
handleError(types.SocialOAuthErrorCode.NO_AUTH_CODE, `Failed to connect ${provider} social account: no authorization code`);
|
|
320
|
+
handleError(provider, types.SocialOAuthErrorCode.NO_AUTH_CODE, `Failed to connect ${provider} social account: no authorization code`);
|
|
309
321
|
return;
|
|
310
322
|
}
|
|
311
323
|
if (authMode === 'signin') {
|
|
@@ -329,7 +341,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
329
341
|
});
|
|
330
342
|
const loginUrl = getOauthLoginUrl.getOauthLoginUrl((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _e !== void 0 ? _e : [], provider);
|
|
331
343
|
if (!loginUrl) {
|
|
332
|
-
handleError(types.SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`);
|
|
344
|
+
handleError(provider, types.SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`);
|
|
333
345
|
return;
|
|
334
346
|
}
|
|
335
347
|
if (!((_f = providersWaitingOauthMessage.current) === null || _f === void 0 ? void 0 : _f[provider])) {
|
|
@@ -362,8 +374,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
362
374
|
setIsProcessing(false);
|
|
363
375
|
// user didn't complete oauth
|
|
364
376
|
if ((_a = providersWaitingOauthMessage.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
365
|
-
|
|
366
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
377
|
+
onFailed(provider, 'user-cancelled');
|
|
367
378
|
}
|
|
368
379
|
}, 2000);
|
|
369
380
|
}
|
|
@@ -385,7 +396,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
385
396
|
// clear all states/listeners, assuming user closed the window before completing oauth
|
|
386
397
|
if ((_j = providersWaitingOauthMessage.current) === null || _j === void 0 ? void 0 : _j[provider]) {
|
|
387
398
|
clearListeners();
|
|
388
|
-
handleError(types.SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Connecting ${provider} account window timeout.`);
|
|
399
|
+
handleError(provider, types.SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Connecting ${provider} account window timeout.`);
|
|
389
400
|
}
|
|
390
401
|
clearInterval(authWindowInterval.current);
|
|
391
402
|
setIsProcessing(false);
|
|
@@ -403,7 +414,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
403
414
|
siweUri: window.location.origin,
|
|
404
415
|
});
|
|
405
416
|
if (!(data === null || data === void 0 ? void 0 : data.url) || !(data === null || data === void 0 ? void 0 : data.channelToken)) {
|
|
406
|
-
handleError(types.SocialOAuthErrorCode.GENERAL_ERROR, "Farcaster didn't return a valid url.");
|
|
417
|
+
handleError(sdkApiCore.ProviderEnum.Farcaster, types.SocialOAuthErrorCode.GENERAL_ERROR, "Farcaster didn't return a valid url.");
|
|
407
418
|
return;
|
|
408
419
|
}
|
|
409
420
|
// If on mobile, we want to redirect to the Warpcast app.
|
|
@@ -428,7 +439,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
428
439
|
!(status === null || status === void 0 ? void 0 : status.custody) ||
|
|
429
440
|
!(status === null || status === void 0 ? void 0 : status.signature) ||
|
|
430
441
|
!(status === null || status === void 0 ? void 0 : status.nonce)) {
|
|
431
|
-
handleError(types.SocialOAuthErrorCode.GENERAL_ERROR, "Farcaster didn't return valid data.");
|
|
442
|
+
handleError(sdkApiCore.ProviderEnum.Farcaster, types.SocialOAuthErrorCode.GENERAL_ERROR, "Farcaster didn't return valid data.");
|
|
432
443
|
return;
|
|
433
444
|
}
|
|
434
445
|
const { custody: address, message, signature, nonce } = status;
|
|
@@ -443,7 +454,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
443
454
|
yield signInAccount(sdkApiCore.ProviderEnum.Farcaster, apiCall);
|
|
444
455
|
}
|
|
445
456
|
else {
|
|
446
|
-
handleError(types.SocialOAuthErrorCode.GENERAL_ERROR, 'Linking with Farcaster is not supported at the moment.');
|
|
457
|
+
handleError(sdkApiCore.ProviderEnum.Farcaster, types.SocialOAuthErrorCode.GENERAL_ERROR, 'Linking with Farcaster is not supported at the moment.');
|
|
447
458
|
}
|
|
448
459
|
setIsProcessing(false);
|
|
449
460
|
});
|
|
@@ -16,7 +16,7 @@ export declare const useSocialAuth: ({ sessionTimeout, authMode, onSettled, onEr
|
|
|
16
16
|
captchaToken?: string;
|
|
17
17
|
}) => Promise<void>;
|
|
18
18
|
readonly error: SocialOAuthError | undefined;
|
|
19
|
-
readonly handleError: (code: SocialOAuthErrorCode, message: string) => void;
|
|
19
|
+
readonly handleError: (provider: ProviderEnum | undefined, code: SocialOAuthErrorCode, message: string) => void;
|
|
20
20
|
readonly isProcessing: boolean;
|
|
21
21
|
readonly setError: import("react").Dispatch<import("react").SetStateAction<SocialOAuthError | undefined>>;
|
|
22
22
|
readonly setIsProcessing: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
@@ -15,7 +15,7 @@ import '../../constants/colors.js';
|
|
|
15
15
|
import '../../constants/values.js';
|
|
16
16
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
17
17
|
import '../../../shared/consts/index.js';
|
|
18
|
-
import '../../../events/dynamicEvents.js';
|
|
18
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
19
19
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
20
20
|
import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
|
|
21
21
|
import { digestSHA256 } from '../../functions/digestSHA256/digestSHA256.js';
|
|
@@ -119,13 +119,22 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
119
119
|
setError(undefined);
|
|
120
120
|
setContextError(undefined);
|
|
121
121
|
};
|
|
122
|
-
const
|
|
122
|
+
const onFailed = (provider, reason) => {
|
|
123
|
+
onError === null || onError === void 0 ? void 0 : onError();
|
|
124
|
+
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
125
|
+
if (provider)
|
|
126
|
+
dynamicEvents.emit('authFailure', {
|
|
127
|
+
option: provider,
|
|
128
|
+
type: 'social',
|
|
129
|
+
}, reason);
|
|
130
|
+
};
|
|
131
|
+
const handleError = (provider, code, message) => {
|
|
132
|
+
const error = { code, message };
|
|
123
133
|
logger.error(message);
|
|
124
134
|
setIsProcessing(false);
|
|
125
|
-
setError(
|
|
135
|
+
setError(error);
|
|
126
136
|
setErrorMessage(code);
|
|
127
|
-
|
|
128
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
137
|
+
onFailed(provider, { error });
|
|
129
138
|
};
|
|
130
139
|
const poolOauthResult = (provider, state) => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
140
|
if (!shouldPool.current) {
|
|
@@ -149,11 +158,11 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
149
158
|
});
|
|
150
159
|
const checkValidProvider = (provider) => {
|
|
151
160
|
if (!provider) {
|
|
152
|
-
handleError(SocialOAuthErrorCode.NO_PROVIDER, 'Provider is required');
|
|
161
|
+
handleError(provider, SocialOAuthErrorCode.NO_PROVIDER, 'Provider is required');
|
|
153
162
|
return false;
|
|
154
163
|
}
|
|
155
164
|
if (!socialProviders.includes(provider)) {
|
|
156
|
-
handleError(SocialOAuthErrorCode.INVALID_PROVIDER, `Invalid social provider. Valid providers are: ${socialProviders.join(', ')}`);
|
|
165
|
+
handleError(provider, SocialOAuthErrorCode.INVALID_PROVIDER, `Invalid social provider. Valid providers are: ${socialProviders.join(', ')}`);
|
|
157
166
|
return false;
|
|
158
167
|
}
|
|
159
168
|
return true;
|
|
@@ -162,7 +171,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
162
171
|
try {
|
|
163
172
|
const response = yield apiCall();
|
|
164
173
|
if (!response) {
|
|
165
|
-
handleError(SocialOAuthErrorCode.VERIFICATION_ERROR, `Failed to link social account: ${provider}`);
|
|
174
|
+
handleError(provider, SocialOAuthErrorCode.VERIFICATION_ERROR, `Failed to link social account: ${provider}`);
|
|
166
175
|
return;
|
|
167
176
|
}
|
|
168
177
|
yield updateUserProfileByJWT(response.jwt, response.minifiedJwt);
|
|
@@ -170,7 +179,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
170
179
|
}
|
|
171
180
|
catch (error) {
|
|
172
181
|
if (error instanceof SocialAccountAlreadyExistsError) {
|
|
173
|
-
handleError(SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_PROFILE, `Social account already linked to a different profile: ${provider}`);
|
|
182
|
+
handleError(provider, SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_PROFILE, `Social account already linked to a different profile: ${provider}`);
|
|
174
183
|
}
|
|
175
184
|
}
|
|
176
185
|
});
|
|
@@ -179,7 +188,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
179
188
|
try {
|
|
180
189
|
const response = yield apiCall();
|
|
181
190
|
if (!response) {
|
|
182
|
-
handleError(SocialOAuthErrorCode.SIGNIN_ERROR, `Failed to sign-in with social account: ${provider}`);
|
|
191
|
+
handleError(provider, SocialOAuthErrorCode.SIGNIN_ERROR, `Failed to sign-in with social account: ${provider}`);
|
|
183
192
|
return;
|
|
184
193
|
}
|
|
185
194
|
const decodedJwt = decodeJwt(response.jwt);
|
|
@@ -215,7 +224,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
215
224
|
setView('account-exists');
|
|
216
225
|
return;
|
|
217
226
|
}
|
|
218
|
-
handleError(SocialOAuthErrorCode.GENERAL_ERROR, error);
|
|
227
|
+
handleError(provider, SocialOAuthErrorCode.GENERAL_ERROR, error);
|
|
219
228
|
}
|
|
220
229
|
});
|
|
221
230
|
const connectSocialAccount = (_d) => __awaiter(void 0, [_d], void 0, function* ({ provider, validator, captchaToken, }) {
|
|
@@ -230,9 +239,12 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
230
239
|
if (validator && !validator(provider)) {
|
|
231
240
|
return;
|
|
232
241
|
}
|
|
242
|
+
dynamicEvents.emit('authInit', {
|
|
243
|
+
option: provider,
|
|
244
|
+
type: 'social',
|
|
245
|
+
});
|
|
233
246
|
if (provider === ProviderEnum.Farcaster) {
|
|
234
|
-
connectWithFarcaster();
|
|
235
|
-
return;
|
|
247
|
+
return connectWithFarcaster();
|
|
236
248
|
}
|
|
237
249
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
238
250
|
const state = randomString(8);
|
|
@@ -283,13 +295,13 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
283
295
|
}
|
|
284
296
|
setIsProcessing(true);
|
|
285
297
|
if (!((_h = providersWaitingOauthMessage.current) === null || _h === void 0 ? void 0 : _h[provider])) {
|
|
286
|
-
handleError(SocialOAuthErrorCode.SESSION_TIMEOUT, `Connecting ${provider} account session timeout.`);
|
|
298
|
+
handleError(provider, SocialOAuthErrorCode.SESSION_TIMEOUT, `Connecting ${provider} account session timeout.`);
|
|
287
299
|
return;
|
|
288
300
|
}
|
|
289
301
|
clearListeners();
|
|
290
302
|
const { code, error, state: authState } = message;
|
|
291
303
|
if (error && error !== 'undefined') {
|
|
292
|
-
handleError(SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: ${error}`);
|
|
304
|
+
handleError(provider, SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: ${error}`);
|
|
293
305
|
return;
|
|
294
306
|
}
|
|
295
307
|
// check that the state we receive from message is the same state we calculated earlier
|
|
@@ -297,11 +309,11 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
297
309
|
// this state check is used only by providers with an open window opener reference (eg, not twitter)
|
|
298
310
|
if (!providersWithoutWindowOpenerRefence.includes(provider) &&
|
|
299
311
|
state !== authState) {
|
|
300
|
-
handleError(SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: Invalid random state`);
|
|
312
|
+
handleError(provider, SocialOAuthErrorCode.OAUTH_ERROR, `Failed to connect ${provider} social account: Invalid random state`);
|
|
301
313
|
return;
|
|
302
314
|
}
|
|
303
315
|
if (!code) {
|
|
304
|
-
handleError(SocialOAuthErrorCode.NO_AUTH_CODE, `Failed to connect ${provider} social account: no authorization code`);
|
|
316
|
+
handleError(provider, SocialOAuthErrorCode.NO_AUTH_CODE, `Failed to connect ${provider} social account: no authorization code`);
|
|
305
317
|
return;
|
|
306
318
|
}
|
|
307
319
|
if (authMode === 'signin') {
|
|
@@ -325,7 +337,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
325
337
|
});
|
|
326
338
|
const loginUrl = getOauthLoginUrl((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _e !== void 0 ? _e : [], provider);
|
|
327
339
|
if (!loginUrl) {
|
|
328
|
-
handleError(SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`);
|
|
340
|
+
handleError(provider, SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`);
|
|
329
341
|
return;
|
|
330
342
|
}
|
|
331
343
|
if (!((_f = providersWaitingOauthMessage.current) === null || _f === void 0 ? void 0 : _f[provider])) {
|
|
@@ -358,8 +370,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
358
370
|
setIsProcessing(false);
|
|
359
371
|
// user didn't complete oauth
|
|
360
372
|
if ((_a = providersWaitingOauthMessage.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
361
|
-
|
|
362
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
373
|
+
onFailed(provider, 'user-cancelled');
|
|
363
374
|
}
|
|
364
375
|
}, 2000);
|
|
365
376
|
}
|
|
@@ -381,7 +392,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
381
392
|
// clear all states/listeners, assuming user closed the window before completing oauth
|
|
382
393
|
if ((_j = providersWaitingOauthMessage.current) === null || _j === void 0 ? void 0 : _j[provider]) {
|
|
383
394
|
clearListeners();
|
|
384
|
-
handleError(SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Connecting ${provider} account window timeout.`);
|
|
395
|
+
handleError(provider, SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Connecting ${provider} account window timeout.`);
|
|
385
396
|
}
|
|
386
397
|
clearInterval(authWindowInterval.current);
|
|
387
398
|
setIsProcessing(false);
|
|
@@ -399,7 +410,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
399
410
|
siweUri: window.location.origin,
|
|
400
411
|
});
|
|
401
412
|
if (!(data === null || data === void 0 ? void 0 : data.url) || !(data === null || data === void 0 ? void 0 : data.channelToken)) {
|
|
402
|
-
handleError(SocialOAuthErrorCode.GENERAL_ERROR, "Farcaster didn't return a valid url.");
|
|
413
|
+
handleError(ProviderEnum.Farcaster, SocialOAuthErrorCode.GENERAL_ERROR, "Farcaster didn't return a valid url.");
|
|
403
414
|
return;
|
|
404
415
|
}
|
|
405
416
|
// If on mobile, we want to redirect to the Warpcast app.
|
|
@@ -424,7 +435,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
424
435
|
!(status === null || status === void 0 ? void 0 : status.custody) ||
|
|
425
436
|
!(status === null || status === void 0 ? void 0 : status.signature) ||
|
|
426
437
|
!(status === null || status === void 0 ? void 0 : status.nonce)) {
|
|
427
|
-
handleError(SocialOAuthErrorCode.GENERAL_ERROR, "Farcaster didn't return valid data.");
|
|
438
|
+
handleError(ProviderEnum.Farcaster, SocialOAuthErrorCode.GENERAL_ERROR, "Farcaster didn't return valid data.");
|
|
428
439
|
return;
|
|
429
440
|
}
|
|
430
441
|
const { custody: address, message, signature, nonce } = status;
|
|
@@ -439,7 +450,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
439
450
|
yield signInAccount(ProviderEnum.Farcaster, apiCall);
|
|
440
451
|
}
|
|
441
452
|
else {
|
|
442
|
-
handleError(SocialOAuthErrorCode.GENERAL_ERROR, 'Linking with Farcaster is not supported at the moment.');
|
|
453
|
+
handleError(ProviderEnum.Farcaster, SocialOAuthErrorCode.GENERAL_ERROR, 'Linking with Farcaster is not supported at the moment.');
|
|
443
454
|
}
|
|
444
455
|
setIsProcessing(false);
|
|
445
456
|
});
|
|
@@ -77,7 +77,7 @@ const useUserDataForm = ({ onSubmit, onError, userProfile, shouldEnforcePolicies
|
|
|
77
77
|
formikHelper.setErrors({ username: 'Username already exists' });
|
|
78
78
|
}
|
|
79
79
|
else if (e instanceof utils.InvalidPhoneNumberError) {
|
|
80
|
-
formikHelper.setErrors({ phoneNumber:
|
|
80
|
+
formikHelper.setErrors({ phoneNumber: e.message });
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
83
|
formikHelper.setErrors({
|
|
@@ -73,7 +73,7 @@ const useUserDataForm = ({ onSubmit, onError, userProfile, shouldEnforcePolicies
|
|
|
73
73
|
formikHelper.setErrors({ username: 'Username already exists' });
|
|
74
74
|
}
|
|
75
75
|
else if (e instanceof InvalidPhoneNumberError) {
|
|
76
|
-
formikHelper.setErrors({ phoneNumber:
|
|
76
|
+
formikHelper.setErrors({ phoneNumber: e.message });
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
79
|
formikHelper.setErrors({
|
|
@@ -21,7 +21,7 @@ require('../../constants/colors.cjs');
|
|
|
21
21
|
require('../../constants/values.cjs');
|
|
22
22
|
var localStorage = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
23
23
|
require('../../../shared/consts/index.cjs');
|
|
24
|
-
require('../../../events/dynamicEvents.cjs');
|
|
24
|
+
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
25
25
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
26
26
|
var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
27
27
|
var createUserProfile = require('../../functions/createUserProfile/createUserProfile.cjs');
|
|
@@ -90,7 +90,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
90
90
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
91
91
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
92
92
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
93
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, events, primaryWallet, enableConnectOnlyFallback, setMultiWalletWidgetState, setLogInWithEmail, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
93
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, events, primaryWallet, enableConnectOnlyFallback, setMultiWalletWidgetState, setLogInWithEmail, selectedWalletConnector, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
94
94
|
const { addedWalletsIds } = UserWalletsContext.useInternalUserWallets();
|
|
95
95
|
// If the user is not already logged it means that we only need to verify
|
|
96
96
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
@@ -171,6 +171,13 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
171
171
|
if (e.message === 'ignore') {
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
|
+
// Emit failure if this wallet connector was currently selected for auth
|
|
175
|
+
if (selectedWalletConnector &&
|
|
176
|
+
selectedWalletConnector.key === walletConnector.key)
|
|
177
|
+
dynamicEvents.dynamicEvents.emit('authFailure', {
|
|
178
|
+
option: walletConnector.name,
|
|
179
|
+
type: 'wallet',
|
|
180
|
+
}, { error: e });
|
|
174
181
|
if (e instanceof utils.WalletUsedError) {
|
|
175
182
|
handleDisconnectWallet({ endSession: false, walletConnector });
|
|
176
183
|
return handleWalletUsedError(e);
|
|
@@ -230,6 +237,10 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
230
237
|
return (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, }) {
|
|
231
238
|
var _b;
|
|
232
239
|
const walletProvider = getWalletProvider.getWalletProvider(walletConnector);
|
|
240
|
+
dynamicEvents.dynamicEvents.emit('authInit', {
|
|
241
|
+
option: walletConnector.name,
|
|
242
|
+
type: 'wallet',
|
|
243
|
+
});
|
|
233
244
|
try {
|
|
234
245
|
const { response, verifyArgs } = yield generateJWT(walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride);
|
|
235
246
|
const decodedJwt = decodeJwt.decodeJwt(response.jwt);
|
|
@@ -17,7 +17,7 @@ import '../../constants/colors.js';
|
|
|
17
17
|
import '../../constants/values.js';
|
|
18
18
|
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
19
19
|
import '../../../shared/consts/index.js';
|
|
20
|
-
import '../../../events/dynamicEvents.js';
|
|
20
|
+
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
21
21
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
22
22
|
import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
|
|
23
23
|
import { createUserProfile } from '../../functions/createUserProfile/createUserProfile.js';
|
|
@@ -86,7 +86,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
86
86
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
87
87
|
const { setView, goToInitialView } = useViewContext();
|
|
88
88
|
const { setErrorMessage, setError } = useErrorContext();
|
|
89
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, events, primaryWallet, enableConnectOnlyFallback, setMultiWalletWidgetState, setLogInWithEmail, } = useInternalDynamicContext();
|
|
89
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, events, primaryWallet, enableConnectOnlyFallback, setMultiWalletWidgetState, setLogInWithEmail, selectedWalletConnector, } = useInternalDynamicContext();
|
|
90
90
|
const { addedWalletsIds } = useInternalUserWallets();
|
|
91
91
|
// If the user is not already logged it means that we only need to verify
|
|
92
92
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
@@ -167,6 +167,13 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
167
167
|
if (e.message === 'ignore') {
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
|
+
// Emit failure if this wallet connector was currently selected for auth
|
|
171
|
+
if (selectedWalletConnector &&
|
|
172
|
+
selectedWalletConnector.key === walletConnector.key)
|
|
173
|
+
dynamicEvents.emit('authFailure', {
|
|
174
|
+
option: walletConnector.name,
|
|
175
|
+
type: 'wallet',
|
|
176
|
+
}, { error: e });
|
|
170
177
|
if (e instanceof WalletUsedError) {
|
|
171
178
|
handleDisconnectWallet({ endSession: false, walletConnector });
|
|
172
179
|
return handleWalletUsedError(e);
|
|
@@ -226,6 +233,10 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
226
233
|
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, }) {
|
|
227
234
|
var _b;
|
|
228
235
|
const walletProvider = getWalletProvider(walletConnector);
|
|
236
|
+
dynamicEvents.emit('authInit', {
|
|
237
|
+
option: walletConnector.name,
|
|
238
|
+
type: 'wallet',
|
|
239
|
+
});
|
|
229
240
|
try {
|
|
230
241
|
const { response, verifyArgs } = yield generateJWT(walletConnector, walletProvider, getAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride);
|
|
231
242
|
const decodedJwt = decodeJwt(response.jwt);
|
|
@@ -125,6 +125,8 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
125
125
|
if (!callCallbackOnUnmount.current)
|
|
126
126
|
return;
|
|
127
127
|
dynamicEvents.dynamicEvents.emit('emailVerificationResult', isValidatedRef.current, email$1 !== null && email$1 !== void 0 ? email$1 : '');
|
|
128
|
+
if (!isValidatedRef.current)
|
|
129
|
+
dynamicEvents.dynamicEvents.emit('authFailure', { option: email$1 !== null && email$1 !== void 0 ? email$1 : '', type: 'email' }, 'user-cancelled');
|
|
128
130
|
if (!email$1)
|
|
129
131
|
logger.logger.warn("WARNING: emitted emailVerificationResult with incomplete params because useVerification's displayedDestination was undefined");
|
|
130
132
|
});
|
|
@@ -121,6 +121,8 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
121
121
|
if (!callCallbackOnUnmount.current)
|
|
122
122
|
return;
|
|
123
123
|
dynamicEvents.emit('emailVerificationResult', isValidatedRef.current, email !== null && email !== void 0 ? email : '');
|
|
124
|
+
if (!isValidatedRef.current)
|
|
125
|
+
dynamicEvents.emit('authFailure', { option: email !== null && email !== void 0 ? email : '', type: 'email' }, 'user-cancelled');
|
|
124
126
|
if (!email)
|
|
125
127
|
logger.warn("WARNING: emitted emailVerificationResult with incomplete params because useVerification's displayedDestination was undefined");
|
|
126
128
|
});
|
|
@@ -91,6 +91,10 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
91
91
|
const handleBackClick = () => {
|
|
92
92
|
emailWalletConnector.clearEmail();
|
|
93
93
|
clearStatesOnBackClick();
|
|
94
|
+
dynamicEvents.dynamicEvents.emit('authFailure', {
|
|
95
|
+
option: email,
|
|
96
|
+
type: 'email',
|
|
97
|
+
}, 'user-cancelled');
|
|
94
98
|
setView('login-with-email-or-wallet');
|
|
95
99
|
};
|
|
96
100
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation.useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
@@ -87,6 +87,10 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
87
87
|
const handleBackClick = () => {
|
|
88
88
|
emailWalletConnector.clearEmail();
|
|
89
89
|
clearStatesOnBackClick();
|
|
90
|
+
dynamicEvents.emit('authFailure', {
|
|
91
|
+
option: email,
|
|
92
|
+
type: 'email',
|
|
93
|
+
}, 'user-cancelled');
|
|
90
94
|
setView('login-with-email-or-wallet');
|
|
91
95
|
};
|
|
92
96
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
@@ -20,7 +20,7 @@ require('../../../../../utils/constants/colors.cjs');
|
|
|
20
20
|
require('../../../../../utils/constants/values.cjs');
|
|
21
21
|
require('../../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
22
22
|
require('../../../../../shared/consts/index.cjs');
|
|
23
|
-
require('../../../../../events/dynamicEvents.cjs');
|
|
23
|
+
var dynamicEvents = require('../../../../../events/dynamicEvents.cjs');
|
|
24
24
|
require('../../../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
25
|
require('@dynamic-labs/multi-wallet');
|
|
26
26
|
var formatPhone = require('../../../../../utils/functions/formatPhone/formatPhone.cjs');
|
|
@@ -106,6 +106,14 @@ const useSubmitPhoneNumber = ({ onSubmit, onSubmitError, country, phone, setInva
|
|
|
106
106
|
setView('login-with-sms-verification');
|
|
107
107
|
setDisplayedDestination(formatPhone.formatPhone(phone));
|
|
108
108
|
setVerificationUUID(verificationUUID);
|
|
109
|
+
dynamicEvents.dynamicEvents.emit('authInit', {
|
|
110
|
+
option: {
|
|
111
|
+
dialCode: country.dialCode,
|
|
112
|
+
iso2: country.iso2,
|
|
113
|
+
phone: phoneNumber,
|
|
114
|
+
},
|
|
115
|
+
type: 'sms',
|
|
116
|
+
});
|
|
109
117
|
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit();
|
|
110
118
|
}
|
|
111
119
|
catch (error) {
|
|
@@ -16,7 +16,7 @@ import '../../../../../utils/constants/colors.js';
|
|
|
16
16
|
import '../../../../../utils/constants/values.js';
|
|
17
17
|
import '../../../../../shared/utils/classes/storage/localStorage.js';
|
|
18
18
|
import '../../../../../shared/consts/index.js';
|
|
19
|
-
import '../../../../../events/dynamicEvents.js';
|
|
19
|
+
import { dynamicEvents } from '../../../../../events/dynamicEvents.js';
|
|
20
20
|
import '../../../../../context/ErrorContext/ErrorContext.js';
|
|
21
21
|
import '@dynamic-labs/multi-wallet';
|
|
22
22
|
import { formatPhone } from '../../../../../utils/functions/formatPhone/formatPhone.js';
|
|
@@ -102,6 +102,14 @@ const useSubmitPhoneNumber = ({ onSubmit, onSubmitError, country, phone, setInva
|
|
|
102
102
|
setView('login-with-sms-verification');
|
|
103
103
|
setDisplayedDestination(formatPhone(phone));
|
|
104
104
|
setVerificationUUID(verificationUUID);
|
|
105
|
+
dynamicEvents.emit('authInit', {
|
|
106
|
+
option: {
|
|
107
|
+
dialCode: country.dialCode,
|
|
108
|
+
iso2: country.iso2,
|
|
109
|
+
phone: phoneNumber,
|
|
110
|
+
},
|
|
111
|
+
type: 'sms',
|
|
112
|
+
});
|
|
105
113
|
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit();
|
|
106
114
|
}
|
|
107
115
|
catch (error) {
|