@dynamic-labs/sdk-react-core 3.0.0-alpha.31 → 3.0.0-alpha.33
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 +15 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +2 -2
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +2 -2
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.cjs +2 -0
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.js +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +17 -11
- package/src/lib/context/DynamicContext/DynamicContext.js +17 -11
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +1 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +2 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +2 -2
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +3 -3
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +3 -3
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +5 -6
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +5 -6
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +1 -1
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +2 -2
- package/src/lib/data/api/embeddedWallets/types.d.ts +2 -2
- package/src/lib/data/api/externalAuth/externalAuth.cjs +20 -0
- package/src/lib/data/api/externalAuth/externalAuth.d.ts +4 -0
- package/src/lib/data/api/externalAuth/externalAuth.js +20 -1
- package/src/lib/events/auth.d.ts +12 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs +14 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.d.ts +2 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js +10 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/index.d.ts +1 -0
- package/src/lib/shared/utils/functions/index.d.ts +1 -0
- package/src/lib/store/hooks/useUser/useUser.cjs +24 -6
- package/src/lib/store/hooks/useUser/useUser.d.ts +6 -3
- package/src/lib/store/hooks/useUser/useUser.js +24 -6
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +1 -1
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +3 -3
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +3 -3
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.cjs +2 -0
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.js +2 -0
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +2 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +2 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +3 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.d.ts +2 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +4 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.d.ts +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.d.ts +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.d.ts +2 -2
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +30 -1
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.d.ts +1 -0
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +31 -2
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +8 -28
- package/src/lib/utils/hooks/useMfa/useMfa.d.ts +1 -7
- package/src/lib/utils/hooks/useMfa/useMfa.js +8 -28
- package/src/lib/utils/hooks/useResetCookieLocalStorage/index.d.ts +1 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.cjs +143 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.d.ts +8 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.js +139 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +4 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +8 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +4 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +6 -5
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +2 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +6 -5
- package/src/lib/utils/hooks/useSyncMfaFlow/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs +152 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.d.ts +4 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js +148 -0
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.cjs +9 -7
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.js +9 -7
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +8 -14
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +8 -14
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +3 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +3 -3
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +4 -4
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +4 -4
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -3
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs +3 -3
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js +3 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +4 -4
- package/src/lib/views/EmailVerification/EmailVerification.js +4 -4
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +2 -2
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.d.ts +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +2 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.d.ts +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +3 -3
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +3 -3
- package/src/lib/views/viewToComponentMap.d.ts +1 -1
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/index.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.cjs +0 -8
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.d.ts +0 -2
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.js +0 -4
|
@@ -3,13 +3,19 @@ import { SocialAccountInformation } from '@dynamic-labs/types';
|
|
|
3
3
|
type UseSocialAccountsProps = {
|
|
4
4
|
sessionTimeout: number;
|
|
5
5
|
};
|
|
6
|
+
type ConnectSocialProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Overrides the redirectUrl provided by DynamicContextProvider
|
|
9
|
+
*/
|
|
10
|
+
redirectUrl?: string;
|
|
11
|
+
};
|
|
6
12
|
export declare const useSocialAccounts: ({ sessionTimeout }?: UseSocialAccountsProps) => {
|
|
7
13
|
readonly error: import("@dynamic-labs/types").SocialOAuthError | undefined;
|
|
8
14
|
readonly getLinkedAccountInformation: (provider: ProviderEnum) => SocialAccountInformation | undefined;
|
|
9
15
|
readonly isLinked: (provider: ProviderEnum) => boolean;
|
|
10
16
|
readonly isProcessing: boolean;
|
|
11
|
-
readonly linkSocialAccount: (provider: ProviderEnum) => Promise<void>;
|
|
12
|
-
readonly signInWithSocialAccount: (provider: ProviderEnum) => Promise<void>;
|
|
17
|
+
readonly linkSocialAccount: (provider: ProviderEnum, { redirectUrl }?: ConnectSocialProps) => Promise<void>;
|
|
18
|
+
readonly signInWithSocialAccount: (provider: ProviderEnum, { redirectUrl }?: ConnectSocialProps) => Promise<void>;
|
|
13
19
|
readonly unlinkSocialAccount: (provider: ProviderEnum) => Promise<void>;
|
|
14
20
|
};
|
|
15
21
|
export {};
|
|
@@ -131,10 +131,11 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
131
131
|
}
|
|
132
132
|
return true;
|
|
133
133
|
}, [handleError, projectSettings, verifiedOAuthCredentialsMap]);
|
|
134
|
-
const linkSocialAccount = useCallback((
|
|
134
|
+
const linkSocialAccount = useCallback((provider_1, ...args_1) => __awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { redirectUrl } = { redirectUrl: undefined }) {
|
|
135
135
|
connectSocialAccount({
|
|
136
136
|
authMode: 'link',
|
|
137
137
|
provider,
|
|
138
|
+
redirectUrl,
|
|
138
139
|
validator: checkValidOAuthLinking,
|
|
139
140
|
});
|
|
140
141
|
}), [checkValidOAuthLinking, connectSocialAccount]);
|
|
@@ -201,10 +202,11 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
201
202
|
}
|
|
202
203
|
return true;
|
|
203
204
|
}, [handleError, (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.socialSignIn) === null || _a === void 0 ? void 0 : _a.providers]);
|
|
204
|
-
const signInWithSocialAccount = useCallback((
|
|
205
|
+
const signInWithSocialAccount = useCallback((provider_2, ...args_2) => __awaiter(void 0, [provider_2, ...args_2], void 0, function* (provider, { redirectUrl } = { redirectUrl: undefined }) {
|
|
205
206
|
return connectSocialAccount({
|
|
206
207
|
authMode: 'signin',
|
|
207
208
|
provider,
|
|
209
|
+
redirectUrl,
|
|
208
210
|
validator: checkValidOAuthSignIn,
|
|
209
211
|
});
|
|
210
212
|
}), [checkValidOAuthSignIn, connectSocialAccount]);
|
|
@@ -178,7 +178,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
178
178
|
verifyFunction: () => apiCall(),
|
|
179
179
|
});
|
|
180
180
|
});
|
|
181
|
-
const connectSocialAccount = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ authMode, provider, validator, captchaToken, }) {
|
|
181
|
+
const connectSocialAccount = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ authMode, provider, validator, captchaToken, redirectUrl, }) {
|
|
182
182
|
var _b, _c;
|
|
183
183
|
clearError();
|
|
184
184
|
setIsProcessing(true);
|
|
@@ -199,8 +199,8 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
199
199
|
type: 'social',
|
|
200
200
|
});
|
|
201
201
|
if (provider === sdkApiCore.ProviderEnum.Farcaster)
|
|
202
|
-
return connectWithFarcaster(authMode, { captchaToken });
|
|
203
|
-
const state = randomString.randomString(
|
|
202
|
+
return connectWithFarcaster(authMode, { captchaToken, redirectUrl });
|
|
203
|
+
const state = randomString.randomString(32);
|
|
204
204
|
const verifier = randomString.randomString(43);
|
|
205
205
|
const loginUrlString = getOauthLoginUrl.getOauthLoginUrl((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _b !== void 0 ? _b : [], provider);
|
|
206
206
|
if (!loginUrlString) {
|
|
@@ -225,6 +225,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
225
225
|
oauthLoginUrl,
|
|
226
226
|
onSettled,
|
|
227
227
|
provider,
|
|
228
|
+
redirectUrl,
|
|
228
229
|
sessionTimeout,
|
|
229
230
|
setIsProcessing,
|
|
230
231
|
state,
|
|
@@ -274,13 +275,13 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
277
|
});
|
|
277
|
-
const connectWithFarcaster = (authMode_1, _d) => _tslib.__awaiter(void 0, [authMode_1, _d], void 0, function* (authMode, { captchaToken }) {
|
|
278
|
+
const connectWithFarcaster = (authMode_1, _d) => _tslib.__awaiter(void 0, [authMode_1, _d], void 0, function* (authMode, { captchaToken, redirectUrl: redirectUrlOverride, }) {
|
|
278
279
|
const dynamicNonce = consumeNonce();
|
|
279
280
|
const domain = utils.PlatformService.getHost();
|
|
280
281
|
const data = yield farcaster.connect({
|
|
281
282
|
domain,
|
|
282
283
|
nonce: dynamicNonce,
|
|
283
|
-
redirectUrl,
|
|
284
|
+
redirectUrl: redirectUrlOverride !== null && redirectUrlOverride !== void 0 ? redirectUrlOverride : redirectUrl,
|
|
284
285
|
siweUri: utils.PlatformService.getOrigin(),
|
|
285
286
|
});
|
|
286
287
|
if (!(data === null || data === void 0 ? void 0 : data.url) || !(data === null || data === void 0 ? void 0 : data.channelToken)) {
|
|
@@ -13,10 +13,11 @@ export type ConnectSocialAccountProps = {
|
|
|
13
13
|
provider: ProviderEnum;
|
|
14
14
|
validator?: (provider: ProviderEnum) => boolean;
|
|
15
15
|
captchaToken?: string;
|
|
16
|
+
redirectUrl?: string;
|
|
16
17
|
};
|
|
17
18
|
export declare const useSocialAuth: ({ sessionTimeout, onSettled, onError, onFarcasterUrl, }: UseSocialAuthProps) => {
|
|
18
19
|
readonly checkValidProvider: (provider: ProviderEnum, authMode: SocialAuthMode) => boolean;
|
|
19
|
-
readonly connectSocialAccount: ({ authMode, provider, validator, captchaToken, }: ConnectSocialAccountProps) => Promise<void>;
|
|
20
|
+
readonly connectSocialAccount: ({ authMode, provider, validator, captchaToken, redirectUrl, }: ConnectSocialAccountProps) => Promise<void>;
|
|
20
21
|
readonly error: SocialOAuthError | undefined;
|
|
21
22
|
readonly handleError: (provider: ProviderEnum | undefined, code: SocialOAuthErrorCode, message: string, options?: {
|
|
22
23
|
raiseAuthFailure?: boolean | undefined;
|
|
@@ -174,7 +174,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
174
174
|
verifyFunction: () => apiCall(),
|
|
175
175
|
});
|
|
176
176
|
});
|
|
177
|
-
const connectSocialAccount = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authMode, provider, validator, captchaToken, }) {
|
|
177
|
+
const connectSocialAccount = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authMode, provider, validator, captchaToken, redirectUrl, }) {
|
|
178
178
|
var _b, _c;
|
|
179
179
|
clearError();
|
|
180
180
|
setIsProcessing(true);
|
|
@@ -195,8 +195,8 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
195
195
|
type: 'social',
|
|
196
196
|
});
|
|
197
197
|
if (provider === ProviderEnum.Farcaster)
|
|
198
|
-
return connectWithFarcaster(authMode, { captchaToken });
|
|
199
|
-
const state = randomString(
|
|
198
|
+
return connectWithFarcaster(authMode, { captchaToken, redirectUrl });
|
|
199
|
+
const state = randomString(32);
|
|
200
200
|
const verifier = randomString(43);
|
|
201
201
|
const loginUrlString = getOauthLoginUrl((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _b !== void 0 ? _b : [], provider);
|
|
202
202
|
if (!loginUrlString) {
|
|
@@ -221,6 +221,7 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
221
221
|
oauthLoginUrl,
|
|
222
222
|
onSettled,
|
|
223
223
|
provider,
|
|
224
|
+
redirectUrl,
|
|
224
225
|
sessionTimeout,
|
|
225
226
|
setIsProcessing,
|
|
226
227
|
state,
|
|
@@ -270,13 +271,13 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
});
|
|
273
|
-
const connectWithFarcaster = (authMode_1, _d) => __awaiter(void 0, [authMode_1, _d], void 0, function* (authMode, { captchaToken }) {
|
|
274
|
+
const connectWithFarcaster = (authMode_1, _d) => __awaiter(void 0, [authMode_1, _d], void 0, function* (authMode, { captchaToken, redirectUrl: redirectUrlOverride, }) {
|
|
274
275
|
const dynamicNonce = consumeNonce();
|
|
275
276
|
const domain = PlatformService.getHost();
|
|
276
277
|
const data = yield connect({
|
|
277
278
|
domain,
|
|
278
279
|
nonce: dynamicNonce,
|
|
279
|
-
redirectUrl,
|
|
280
|
+
redirectUrl: redirectUrlOverride !== null && redirectUrlOverride !== void 0 ? redirectUrlOverride : redirectUrl,
|
|
280
281
|
siweUri: PlatformService.getOrigin(),
|
|
281
282
|
});
|
|
282
283
|
if (!(data === null || data === void 0 ? void 0 : data.url) || !(data === null || data === void 0 ? void 0 : data.channelToken)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSyncMfaFlow } from './useSyncMfaFlow';
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var React = require('react');
|
|
7
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
8
|
+
require('@dynamic-labs/sdk-api-core');
|
|
9
|
+
require('../../../shared/logger.cjs');
|
|
10
|
+
require('@dynamic-labs/iconic');
|
|
11
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
require('react/jsx-runtime');
|
|
13
|
+
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
14
|
+
require('@dynamic-labs/wallet-book');
|
|
15
|
+
require('../../constants/colors.cjs');
|
|
16
|
+
require('../../constants/values.cjs');
|
|
17
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
|
+
require('../../../shared/utils/classes/storage/sessionStorage.cjs');
|
|
19
|
+
var hasPendingMfaAction = require('../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs');
|
|
20
|
+
require('@dynamic-labs/utils');
|
|
21
|
+
require('../../../shared/consts/index.cjs');
|
|
22
|
+
require('../../../events/dynamicEvents.cjs');
|
|
23
|
+
require('../../../../../_virtual/_tslib.cjs');
|
|
24
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
25
|
+
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
26
|
+
require('@dynamic-labs/multi-wallet');
|
|
27
|
+
require('react-international-phone');
|
|
28
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
29
|
+
require('@dynamic-labs/store');
|
|
30
|
+
require('../../../locale/locale.cjs');
|
|
31
|
+
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
32
|
+
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
33
|
+
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
34
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
35
|
+
require('react-dom');
|
|
36
|
+
require('../../../context/WalletContext/WalletContext.cjs');
|
|
37
|
+
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
38
|
+
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
39
|
+
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
40
|
+
require('@dynamic-labs/types');
|
|
41
|
+
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
42
|
+
require('yup');
|
|
43
|
+
require('../../../context/MockContext/MockContext.cjs');
|
|
44
|
+
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
45
|
+
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
46
|
+
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
47
|
+
require('@dynamic-labs/rpc-providers');
|
|
48
|
+
require('react-i18next');
|
|
49
|
+
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
50
|
+
require('../../../components/Alert/Alert.cjs');
|
|
51
|
+
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
52
|
+
require('../../../components/IconButton/IconButton.cjs');
|
|
53
|
+
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
54
|
+
require('../../../components/Input/Input.cjs');
|
|
55
|
+
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
56
|
+
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
57
|
+
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
58
|
+
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
59
|
+
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
60
|
+
require('../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
61
|
+
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
62
|
+
require('../../../components/Popper/Popper/Popper.cjs');
|
|
63
|
+
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
64
|
+
require('react-focus-lock');
|
|
65
|
+
require('qrcode');
|
|
66
|
+
require('formik');
|
|
67
|
+
require('../../../views/WalletList/WalletList.cjs');
|
|
68
|
+
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
69
|
+
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
70
|
+
require('@hcaptcha/react-hcaptcha');
|
|
71
|
+
require('../../../context/FooterAnimationContext/index.cjs');
|
|
72
|
+
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
73
|
+
var useMfa = require('../useMfa/useMfa.cjs');
|
|
74
|
+
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
75
|
+
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
76
|
+
require('../../../context/MfaSettingsContext/MfaSettingsContext.cjs');
|
|
77
|
+
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
78
|
+
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
79
|
+
require('../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
80
|
+
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
81
|
+
require('../../../../polyfills.cjs');
|
|
82
|
+
require('../../../context/ErrorBoundary/ErrorBoundaryBase.cjs');
|
|
83
|
+
require('../../../context/ErrorBoundary/ErrorBoundaryContext.cjs');
|
|
84
|
+
require('../../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs');
|
|
85
|
+
require('../../../widgets/DynamicWidget/components/DynamicWidgetCard/DynamicWidgetCard.cjs');
|
|
86
|
+
require('../../../context/WidgetRegistry/WidgetRegistryContextProvider.cjs');
|
|
87
|
+
require('../../../context/FundingContext/FundingContext.cjs');
|
|
88
|
+
require('../../../context/SendBalanceContext/SendBalanceContext.cjs');
|
|
89
|
+
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
90
|
+
require('../../../context/ConnectWithOtpContext/constants.cjs');
|
|
91
|
+
require('../../../context/ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
92
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* This hook is used to ensure we show the correct MFA view on page refresh
|
|
96
|
+
*/
|
|
97
|
+
const useSyncMfaFlow = () => {
|
|
98
|
+
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded } = useInternalDynamicContext.useInternalDynamicContext();
|
|
99
|
+
const { setView } = ViewContext.useViewContext();
|
|
100
|
+
const { getUserDevices } = useMfa.useMfa();
|
|
101
|
+
// this is used to make sure we only trigger the effect once
|
|
102
|
+
const triggered = React.useRef(false);
|
|
103
|
+
React.useEffect(() => {
|
|
104
|
+
var _a;
|
|
105
|
+
// boilterplate: we don't want to run the sync logic if the sdk hasn't finished loading,
|
|
106
|
+
// or if the effect has already been triggered
|
|
107
|
+
if (!sdkHasLoaded || triggered.current) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// this is the case when the user has fully logged in and completed all mfa steps if needed,
|
|
111
|
+
// like accepting their backup codes after enrolling
|
|
112
|
+
if (!userWithMissingInfo || !hasPendingMfaAction.hasPendingMfaAction(userWithMissingInfo)) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
triggered.current = true;
|
|
116
|
+
/**
|
|
117
|
+
* There are two scenarios:
|
|
118
|
+
* 1. The user has not yet completed mfa
|
|
119
|
+
* 2. The user has completed mfa, but has not yet acknowledged their backup codes
|
|
120
|
+
*
|
|
121
|
+
* In scenario 1, the user scope will contain 'requiresAdditionalAuth'. In this case, we need
|
|
122
|
+
* to show the enrollment view or verification view, depending on whether the user has devices
|
|
123
|
+
*
|
|
124
|
+
* In scenario 2, the user scope will not contain 'requiresAdditionalAuth', and the user
|
|
125
|
+
* mfaBackupCodeAcknowledgement field will be 'pending'. In this case, we need to show the
|
|
126
|
+
* backup codes view
|
|
127
|
+
*/
|
|
128
|
+
setShowAuthFlow(true);
|
|
129
|
+
if ((_a = userWithMissingInfo.scope) === null || _a === void 0 ? void 0 : _a.includes('requiresAdditionalAuth')) {
|
|
130
|
+
getUserDevices().then((devices) => {
|
|
131
|
+
if (devices.length === 0) {
|
|
132
|
+
setView('mfa-choose-device');
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
setView('mfa-verification');
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
setView('mfa-display-backup-codes');
|
|
141
|
+
}
|
|
142
|
+
// TODO: Add / call handler for customers using headless
|
|
143
|
+
}, [
|
|
144
|
+
getUserDevices,
|
|
145
|
+
sdkHasLoaded,
|
|
146
|
+
setShowAuthFlow,
|
|
147
|
+
setView,
|
|
148
|
+
userWithMissingInfo,
|
|
149
|
+
]);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
exports.useSyncMfaFlow = useSyncMfaFlow;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
4
|
+
import '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import '../../../shared/logger.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import '../../constants/values.js';
|
|
13
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import '../../../shared/utils/classes/storage/sessionStorage.js';
|
|
15
|
+
import { hasPendingMfaAction } from '../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js';
|
|
16
|
+
import '@dynamic-labs/utils';
|
|
17
|
+
import '../../../shared/consts/index.js';
|
|
18
|
+
import '../../../events/dynamicEvents.js';
|
|
19
|
+
import '../../../../../_virtual/_tslib.js';
|
|
20
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
21
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
22
|
+
import '@dynamic-labs/multi-wallet';
|
|
23
|
+
import 'react-international-phone';
|
|
24
|
+
import '../../../config/ApiEndpoint.js';
|
|
25
|
+
import '@dynamic-labs/store';
|
|
26
|
+
import '../../../locale/locale.js';
|
|
27
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
28
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
29
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
30
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
31
|
+
import 'react-dom';
|
|
32
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
33
|
+
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
34
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
35
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
36
|
+
import '@dynamic-labs/types';
|
|
37
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
38
|
+
import 'yup';
|
|
39
|
+
import '../../../context/MockContext/MockContext.js';
|
|
40
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
41
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
42
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
43
|
+
import '@dynamic-labs/rpc-providers';
|
|
44
|
+
import 'react-i18next';
|
|
45
|
+
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
46
|
+
import '../../../components/Alert/Alert.js';
|
|
47
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
48
|
+
import '../../../components/IconButton/IconButton.js';
|
|
49
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
50
|
+
import '../../../components/Input/Input.js';
|
|
51
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
52
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
53
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
54
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
55
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
56
|
+
import '../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
57
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
58
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
59
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
60
|
+
import 'react-focus-lock';
|
|
61
|
+
import 'qrcode';
|
|
62
|
+
import 'formik';
|
|
63
|
+
import '../../../views/WalletList/WalletList.js';
|
|
64
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
65
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
66
|
+
import '@hcaptcha/react-hcaptcha';
|
|
67
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
68
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
69
|
+
import { useMfa } from '../useMfa/useMfa.js';
|
|
70
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
71
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
72
|
+
import '../../../context/MfaSettingsContext/MfaSettingsContext.js';
|
|
73
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
74
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
75
|
+
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
76
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
77
|
+
import '../../../../polyfills.js';
|
|
78
|
+
import '../../../context/ErrorBoundary/ErrorBoundaryBase.js';
|
|
79
|
+
import '../../../context/ErrorBoundary/ErrorBoundaryContext.js';
|
|
80
|
+
import '../../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
|
|
81
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetCard/DynamicWidgetCard.js';
|
|
82
|
+
import '../../../context/WidgetRegistry/WidgetRegistryContextProvider.js';
|
|
83
|
+
import '../../../context/FundingContext/FundingContext.js';
|
|
84
|
+
import '../../../context/SendBalanceContext/SendBalanceContext.js';
|
|
85
|
+
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
86
|
+
import '../../../context/ConnectWithOtpContext/constants.js';
|
|
87
|
+
import '../../../context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
88
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* This hook is used to ensure we show the correct MFA view on page refresh
|
|
92
|
+
*/
|
|
93
|
+
const useSyncMfaFlow = () => {
|
|
94
|
+
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded } = useInternalDynamicContext();
|
|
95
|
+
const { setView } = useViewContext();
|
|
96
|
+
const { getUserDevices } = useMfa();
|
|
97
|
+
// this is used to make sure we only trigger the effect once
|
|
98
|
+
const triggered = useRef(false);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
var _a;
|
|
101
|
+
// boilterplate: we don't want to run the sync logic if the sdk hasn't finished loading,
|
|
102
|
+
// or if the effect has already been triggered
|
|
103
|
+
if (!sdkHasLoaded || triggered.current) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// this is the case when the user has fully logged in and completed all mfa steps if needed,
|
|
107
|
+
// like accepting their backup codes after enrolling
|
|
108
|
+
if (!userWithMissingInfo || !hasPendingMfaAction(userWithMissingInfo)) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
triggered.current = true;
|
|
112
|
+
/**
|
|
113
|
+
* There are two scenarios:
|
|
114
|
+
* 1. The user has not yet completed mfa
|
|
115
|
+
* 2. The user has completed mfa, but has not yet acknowledged their backup codes
|
|
116
|
+
*
|
|
117
|
+
* In scenario 1, the user scope will contain 'requiresAdditionalAuth'. In this case, we need
|
|
118
|
+
* to show the enrollment view or verification view, depending on whether the user has devices
|
|
119
|
+
*
|
|
120
|
+
* In scenario 2, the user scope will not contain 'requiresAdditionalAuth', and the user
|
|
121
|
+
* mfaBackupCodeAcknowledgement field will be 'pending'. In this case, we need to show the
|
|
122
|
+
* backup codes view
|
|
123
|
+
*/
|
|
124
|
+
setShowAuthFlow(true);
|
|
125
|
+
if ((_a = userWithMissingInfo.scope) === null || _a === void 0 ? void 0 : _a.includes('requiresAdditionalAuth')) {
|
|
126
|
+
getUserDevices().then((devices) => {
|
|
127
|
+
if (devices.length === 0) {
|
|
128
|
+
setView('mfa-choose-device');
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
setView('mfa-verification');
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
setView('mfa-display-backup-codes');
|
|
137
|
+
}
|
|
138
|
+
// TODO: Add / call handler for customers using headless
|
|
139
|
+
}, [
|
|
140
|
+
getUserDevices,
|
|
141
|
+
sdkHasLoaded,
|
|
142
|
+
setShowAuthFlow,
|
|
143
|
+
setView,
|
|
144
|
+
userWithMissingInfo,
|
|
145
|
+
]);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export { useSyncMfaFlow };
|
|
@@ -18,6 +18,7 @@ require('../../constants/colors.cjs');
|
|
|
18
18
|
require('../../constants/values.cjs');
|
|
19
19
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
20
20
|
require('../../../shared/utils/classes/storage/sessionStorage.cjs');
|
|
21
|
+
var hasPendingMfaAction = require('../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs');
|
|
21
22
|
require('@dynamic-labs/utils');
|
|
22
23
|
require('../../../shared/consts/index.cjs');
|
|
23
24
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
@@ -93,7 +94,7 @@ require('../../../context/ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
|
93
94
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
94
95
|
|
|
95
96
|
const useSyncOnboardingFlow = () => {
|
|
96
|
-
const { setShowAuthFlow,
|
|
97
|
+
const { setShowAuthFlow, userWithMissingInfo, handlers, headless, sdkHasLoaded, setSelectedWalletConnectorKey, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
97
98
|
const { setView } = ViewContext.useViewContext();
|
|
98
99
|
const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
|
|
99
100
|
validationSchemaStripUnknown: false,
|
|
@@ -113,12 +114,12 @@ const useSyncOnboardingFlow = () => {
|
|
|
113
114
|
const handleHeadlessOnboarding = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
114
115
|
var _b;
|
|
115
116
|
if (!(handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) ||
|
|
116
|
-
!((_b =
|
|
117
|
+
!((_b = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.missingFields) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
120
|
triggeredOnboarding.current = true;
|
|
120
121
|
try {
|
|
121
|
-
const missingFieldsRequestInput =
|
|
122
|
+
const missingFieldsRequestInput = userWithMissingInfo.missingFields.map((field) => ({
|
|
122
123
|
isCustom: field.type === 'custom',
|
|
123
124
|
key: field.name,
|
|
124
125
|
label: field.label,
|
|
@@ -126,7 +127,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
126
127
|
}));
|
|
127
128
|
const onboardingResponse = yield handlers.handleUserOnboarding(missingFieldsRequestInput);
|
|
128
129
|
const userFields = {};
|
|
129
|
-
const customFields = Object.assign({},
|
|
130
|
+
const customFields = Object.assign({}, userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.metadata);
|
|
130
131
|
onboardingResponse.forEach((field) => {
|
|
131
132
|
if (field.isCustom) {
|
|
132
133
|
customFields[field.key] = field.value;
|
|
@@ -147,7 +148,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
147
148
|
const handleOnboarding = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
148
149
|
triggeredOnboarding.current = true;
|
|
149
150
|
setShowAuthFlow(true);
|
|
150
|
-
const lastVerifiedCredential =
|
|
151
|
+
const lastVerifiedCredential = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.verifiedCredentials.find((vc) => vc.id === (userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.lastVerifiedCredentialId));
|
|
151
152
|
if (lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName) {
|
|
152
153
|
setSelectedWalletConnectorKey(lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName);
|
|
153
154
|
}
|
|
@@ -170,7 +171,8 @@ const useSyncOnboardingFlow = () => {
|
|
|
170
171
|
});
|
|
171
172
|
if (!sdkHasLoaded ||
|
|
172
173
|
triggeredOnboarding.current ||
|
|
173
|
-
!((_a =
|
|
174
|
+
!((_a = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.missingFields) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
175
|
+
hasPendingMfaAction.hasPendingMfaAction(userWithMissingInfo)) {
|
|
174
176
|
return;
|
|
175
177
|
}
|
|
176
178
|
if (handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) {
|
|
@@ -185,7 +187,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
185
187
|
return;
|
|
186
188
|
}, [
|
|
187
189
|
sdkHasLoaded,
|
|
188
|
-
|
|
190
|
+
userWithMissingInfo,
|
|
189
191
|
handlers,
|
|
190
192
|
completeAuth,
|
|
191
193
|
updateUser,
|
|
@@ -14,6 +14,7 @@ import '../../constants/colors.js';
|
|
|
14
14
|
import '../../constants/values.js';
|
|
15
15
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
16
16
|
import '../../../shared/utils/classes/storage/sessionStorage.js';
|
|
17
|
+
import { hasPendingMfaAction } from '../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js';
|
|
17
18
|
import '@dynamic-labs/utils';
|
|
18
19
|
import '../../../shared/consts/index.js';
|
|
19
20
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
@@ -89,7 +90,7 @@ import '../../../context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
|
89
90
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
90
91
|
|
|
91
92
|
const useSyncOnboardingFlow = () => {
|
|
92
|
-
const { setShowAuthFlow,
|
|
93
|
+
const { setShowAuthFlow, userWithMissingInfo, handlers, headless, sdkHasLoaded, setSelectedWalletConnectorKey, } = useInternalDynamicContext();
|
|
93
94
|
const { setView } = useViewContext();
|
|
94
95
|
const { updateUser } = useUserUpdateRequestInternal({
|
|
95
96
|
validationSchemaStripUnknown: false,
|
|
@@ -109,12 +110,12 @@ const useSyncOnboardingFlow = () => {
|
|
|
109
110
|
const handleHeadlessOnboarding = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
111
|
var _b;
|
|
111
112
|
if (!(handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) ||
|
|
112
|
-
!((_b =
|
|
113
|
+
!((_b = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.missingFields) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
116
|
triggeredOnboarding.current = true;
|
|
116
117
|
try {
|
|
117
|
-
const missingFieldsRequestInput =
|
|
118
|
+
const missingFieldsRequestInput = userWithMissingInfo.missingFields.map((field) => ({
|
|
118
119
|
isCustom: field.type === 'custom',
|
|
119
120
|
key: field.name,
|
|
120
121
|
label: field.label,
|
|
@@ -122,7 +123,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
122
123
|
}));
|
|
123
124
|
const onboardingResponse = yield handlers.handleUserOnboarding(missingFieldsRequestInput);
|
|
124
125
|
const userFields = {};
|
|
125
|
-
const customFields = Object.assign({},
|
|
126
|
+
const customFields = Object.assign({}, userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.metadata);
|
|
126
127
|
onboardingResponse.forEach((field) => {
|
|
127
128
|
if (field.isCustom) {
|
|
128
129
|
customFields[field.key] = field.value;
|
|
@@ -143,7 +144,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
143
144
|
const handleOnboarding = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
145
|
triggeredOnboarding.current = true;
|
|
145
146
|
setShowAuthFlow(true);
|
|
146
|
-
const lastVerifiedCredential =
|
|
147
|
+
const lastVerifiedCredential = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.verifiedCredentials.find((vc) => vc.id === (userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.lastVerifiedCredentialId));
|
|
147
148
|
if (lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName) {
|
|
148
149
|
setSelectedWalletConnectorKey(lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName);
|
|
149
150
|
}
|
|
@@ -166,7 +167,8 @@ const useSyncOnboardingFlow = () => {
|
|
|
166
167
|
});
|
|
167
168
|
if (!sdkHasLoaded ||
|
|
168
169
|
triggeredOnboarding.current ||
|
|
169
|
-
!((_a =
|
|
170
|
+
!((_a = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.missingFields) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
171
|
+
hasPendingMfaAction(userWithMissingInfo)) {
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
174
|
if (handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) {
|
|
@@ -181,7 +183,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
181
183
|
return;
|
|
182
184
|
}, [
|
|
183
185
|
sdkHasLoaded,
|
|
184
|
-
|
|
186
|
+
userWithMissingInfo,
|
|
185
187
|
handlers,
|
|
186
188
|
completeAuth,
|
|
187
189
|
updateUser,
|