@dynamic-labs/sdk-react-core 2.1.0-alpha.14 → 2.1.0-alpha.16
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 +16 -0
- package/package.cjs +3 -2
- package/package.js +3 -2
- package/package.json +13 -12
- package/src/index.cjs +1 -3
- package/src/index.d.ts +1 -3
- package/src/index.js +1 -2
- package/src/lib/components/Portal/Portal.cjs +3 -1
- package/src/lib/components/Portal/Portal.js +3 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.cjs +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.js +4 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +20 -15
- package/src/lib/context/DynamicContext/DynamicContext.js +20 -15
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +13 -5
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +14 -6
- package/src/lib/context/DynamicContext/types/index.d.ts +4 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +2 -1
- package/src/lib/context/DynamicContext/validators/validators.cjs +0 -29
- package/src/lib/context/DynamicContext/validators/validators.d.ts +0 -2
- package/src/lib/context/DynamicContext/validators/validators.js +1 -29
- package/src/lib/context/FundingContext/FundingContext.cjs +6 -6
- package/src/lib/context/FundingContext/FundingContext.js +6 -6
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +0 -1
- package/src/lib/context/PasskeyContext/PasskeyContext.js +0 -1
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/data/api/api.cjs +25 -3
- package/src/lib/data/api/api.d.ts +1 -1
- package/src/lib/data/api/api.js +25 -3
- package/src/lib/data/api/chains/balances.cjs +2 -2
- package/src/lib/data/api/chains/balances.d.ts +1 -2
- package/src/lib/data/api/chains/balances.js +2 -2
- package/src/lib/data/api/email/email.cjs +2 -2
- package/src/lib/data/api/email/email.d.ts +1 -1
- package/src/lib/data/api/email/email.js +2 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +23 -23
- package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +11 -12
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +23 -23
- package/src/lib/data/api/embeddedWallets/types.d.ts +0 -6
- package/src/lib/data/api/mfa/mfa.cjs +18 -18
- package/src/lib/data/api/mfa/mfa.d.ts +9 -18
- package/src/lib/data/api/mfa/mfa.js +18 -18
- package/src/lib/data/api/oauth/oauth.cjs +4 -4
- package/src/lib/data/api/oauth/oauth.d.ts +3 -3
- package/src/lib/data/api/oauth/oauth.js +4 -4
- package/src/lib/data/api/session/session.cjs +2 -2
- package/src/lib/data/api/session/session.d.ts +1 -1
- package/src/lib/data/api/session/session.js +2 -2
- package/src/lib/data/api/sms/sms.cjs +2 -2
- package/src/lib/data/api/sms/sms.d.ts +1 -1
- package/src/lib/data/api/sms/sms.js +2 -2
- package/src/lib/data/api/user/user.cjs +8 -10
- package/src/lib/data/api/user/user.d.ts +4 -4
- package/src/lib/data/api/user/user.js +9 -11
- package/src/lib/data/api/wallets/wallets.cjs +8 -8
- package/src/lib/data/api/wallets/wallets.d.ts +4 -4
- package/src/lib/data/api/wallets/wallets.js +8 -8
- package/src/lib/locale/en/translation.cjs +18 -0
- package/src/lib/locale/en/translation.d.ts +18 -0
- package/src/lib/locale/en/translation.js +18 -0
- package/src/lib/shared/utils/classes/storage/localStorage.cjs +1 -8
- package/src/lib/shared/utils/classes/storage/localStorage.js +2 -9
- package/src/lib/shared/utils/functions/index.d.ts +0 -1
- package/src/lib/store/actions/storeActions/index.d.ts +1 -0
- package/src/lib/store/actions/storeActions/storeActions.cjs +10 -0
- package/src/lib/store/actions/storeActions/storeActions.d.ts +1 -0
- package/src/lib/store/actions/storeActions/storeActions.js +6 -0
- package/src/lib/store/actions/userActions/index.d.ts +1 -0
- package/src/lib/store/actions/userActions/userActions.cjs +10 -0
- package/src/lib/store/actions/userActions/userActions.d.ts +7 -0
- package/src/lib/store/actions/userActions/userActions.js +6 -0
- package/src/lib/store/hooks/useUser/index.d.ts +1 -0
- package/src/lib/store/hooks/useUser/useUser.cjs +12 -0
- package/src/lib/store/hooks/useUser/useUser.d.ts +1 -0
- package/src/lib/store/hooks/useUser/useUser.js +8 -0
- package/src/lib/store/index.d.ts +4 -0
- package/src/lib/store/store.cjs +24 -0
- package/src/lib/store/store.d.ts +13 -0
- package/src/lib/store/store.js +19 -0
- package/src/lib/store/types.d.ts +4 -0
- package/src/lib/store/utils/createStore/createStore.cjs +21 -0
- package/src/lib/store/utils/createStore/createStore.d.ts +16 -0
- package/src/lib/store/utils/createStore/createStore.js +17 -0
- package/src/lib/store/utils/createStore/index.d.ts +1 -0
- package/src/lib/store/utils/syncLegacyStorage/index.d.ts +1 -0
- package/src/lib/store/utils/syncLegacyStorage/syncLegacyStorage.cjs +30 -0
- package/src/lib/store/utils/syncLegacyStorage/syncLegacyStorage.d.ts +2 -0
- package/src/lib/store/utils/syncLegacyStorage/syncLegacyStorage.js +26 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +4 -2
- package/src/lib/utils/constants/localStorage.d.ts +2 -1
- package/src/lib/utils/constants/localStorage.js +3 -2
- package/src/lib/utils/functions/downloadFile/downloadFile.cjs +15 -0
- package/src/lib/utils/functions/downloadFile/downloadFile.d.ts +1 -0
- package/src/lib/utils/functions/downloadFile/downloadFile.js +11 -0
- package/src/lib/utils/functions/downloadFile/index.d.ts +1 -0
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.cjs +8 -4
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.d.ts +1 -2
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.js +8 -4
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.cjs +31 -0
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.d.ts +1 -0
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.js +27 -0
- package/src/lib/utils/functions/getOnboardingAuthToken/index.d.ts +1 -0
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.cjs +7 -3
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.js +7 -3
- package/src/lib/utils/functions/index.d.ts +2 -0
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +1 -1
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +2 -2
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +2 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +4 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +4 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +4 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +4 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +3 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +3 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +2 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +2 -0
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +4 -4
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +4 -4
- package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.cjs +4 -0
- package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.js +4 -0
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +4 -4
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +4 -4
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +6 -3
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.d.ts +1 -4
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +5 -2
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +1 -3
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +1 -3
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -8
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -8
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +1 -1
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +1 -1
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +7 -3
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +1 -4
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -2
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.cjs +2 -2
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.js +2 -2
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +1 -1
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +1 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +4 -7
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +4 -7
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +11 -14
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +11 -14
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +0 -1
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +0 -1
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +1 -1
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +1 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +6 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +6 -1
- 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/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -1
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +4 -4
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +4 -4
- package/src/lib/views/CreatePasswordView/SavePasswordStep/SavePasswordStep.cjs +5 -10
- package/src/lib/views/CreatePasswordView/SavePasswordStep/SavePasswordStep.js +5 -10
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +2 -5
- package/src/lib/views/EmailUpdate/EmailUpdate.js +2 -5
- package/src/lib/views/EmailVerification/EmailVerification.cjs +3 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +3 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +5 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +5 -2
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +4 -2
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +4 -2
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +111 -0
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.d.ts +2 -0
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +107 -0
- package/src/lib/views/MfaDisplayBackupCodesView/index.d.ts +1 -0
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +3 -3
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +3 -3
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.cjs +0 -2
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.js +0 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +3 -3
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +3 -3
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +4 -9
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +4 -9
- package/src/lib/views/WalletList/WalletListGridTabs/WalletListGridTabs.cjs +1 -1
- package/src/lib/views/WalletList/WalletListGridTabs/WalletListGridTabs.js +1 -1
- package/src/lib/views/WalletList/hooks/useTabState.cjs +4 -1
- package/src/lib/views/WalletList/hooks/useTabState.js +4 -1
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.cjs +22 -0
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.d.ts +2 -0
- package/src/lib/views/WalletList/utils/getInitialTabIndex/getInitialTabIndex.js +18 -0
- package/src/lib/views/WalletList/utils/getInitialTabIndex/index.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/shared/utils/functions/validateType/index.d.ts +0 -1
- package/src/lib/shared/utils/functions/validateType/validateType.cjs +0 -30
- package/src/lib/shared/utils/functions/validateType/validateType.d.ts +0 -1
- package/src/lib/shared/utils/functions/validateType/validateType.js +0 -26
|
@@ -25,7 +25,6 @@ var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
|
25
25
|
var digestSHA256 = require('../../functions/digestSHA256/digestSHA256.cjs');
|
|
26
26
|
var encodeBase64URL = require('../../functions/encodeBase64URL/encodeBase64URL.cjs');
|
|
27
27
|
require('@dynamic-labs/multi-wallet');
|
|
28
|
-
var getMinAuthToken = require('../../functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
29
28
|
require('react-international-phone');
|
|
30
29
|
var getOauthLoginUrl = require('../../functions/getOauthLoginUrl/getOauthLoginUrl.cjs');
|
|
31
30
|
var getProviderByType = require('../../functions/getProviderByType/getProviderByType.cjs');
|
|
@@ -103,8 +102,7 @@ const providersRequiringPkce = ['twitter', 'github'];
|
|
|
103
102
|
const providersWithoutWindowOpenerRefence = ['twitter'];
|
|
104
103
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
105
104
|
const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcasterUrl, }) => {
|
|
106
|
-
|
|
107
|
-
const { environmentId, onboardingOnlyJwt, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
105
|
+
const { environmentId, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
108
106
|
const { setErrorMessage, setError: setContextError } = ErrorContext.useErrorContext();
|
|
109
107
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
110
108
|
const { initAuth } = useUserAuth.useUserAuth({
|
|
@@ -115,7 +113,6 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
115
113
|
const providersWaitingOauthMessage = React.useRef({});
|
|
116
114
|
const authWindowInterval = React.useRef();
|
|
117
115
|
const shouldPool = React.useRef(false);
|
|
118
|
-
const userJwt = (_a = getMinAuthToken.getMinAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
119
116
|
const clearError = () => {
|
|
120
117
|
setError(undefined);
|
|
121
118
|
setContextError(undefined);
|
|
@@ -183,8 +180,8 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
183
180
|
verifyFunction: () => apiCall(),
|
|
184
181
|
});
|
|
185
182
|
});
|
|
186
|
-
const connectSocialAccount = (
|
|
187
|
-
var
|
|
183
|
+
const connectSocialAccount = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ provider, validator, captchaToken, }) {
|
|
184
|
+
var _b, _c;
|
|
188
185
|
clearInterval(authWindowInterval.current);
|
|
189
186
|
clearError();
|
|
190
187
|
setIsProcessing(true);
|
|
@@ -207,9 +204,9 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
207
204
|
providersWaitingOauthMessage.current = Object.assign(Object.assign({}, providersWaitingOauthMessage.current), { [provider]: false });
|
|
208
205
|
};
|
|
209
206
|
const handleAuthWindowMessage = (event) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
210
|
-
var
|
|
207
|
+
var _d, _e;
|
|
211
208
|
const message = event.data;
|
|
212
|
-
const apiProvider = getProviderByType.getProviderByType((
|
|
209
|
+
const apiProvider = getProviderByType.getProviderByType((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _d !== void 0 ? _d : [], provider);
|
|
213
210
|
if (!(apiProvider === null || apiProvider === void 0 ? void 0 : apiProvider.redirectUrl)) {
|
|
214
211
|
return;
|
|
215
212
|
}
|
|
@@ -247,7 +244,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
247
244
|
return;
|
|
248
245
|
}
|
|
249
246
|
setIsProcessing(true);
|
|
250
|
-
if (!((
|
|
247
|
+
if (!((_e = providersWaitingOauthMessage.current) === null || _e === void 0 ? void 0 : _e[provider])) {
|
|
251
248
|
handleError(types.SocialOAuthErrorCode.SESSION_TIMEOUT, `Connecting ${provider} account session timeout.`);
|
|
252
249
|
return;
|
|
253
250
|
}
|
|
@@ -283,17 +280,17 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
283
280
|
code,
|
|
284
281
|
codeVerifier: verifier,
|
|
285
282
|
state,
|
|
286
|
-
}
|
|
283
|
+
});
|
|
287
284
|
yield linkAccount(provider, apiCall);
|
|
288
285
|
}
|
|
289
286
|
setIsProcessing(false);
|
|
290
287
|
});
|
|
291
|
-
const loginUrl = getOauthLoginUrl.getOauthLoginUrl((
|
|
288
|
+
const loginUrl = getOauthLoginUrl.getOauthLoginUrl((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _b !== void 0 ? _b : [], provider);
|
|
292
289
|
if (!loginUrl) {
|
|
293
290
|
handleError(types.SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`);
|
|
294
291
|
return;
|
|
295
292
|
}
|
|
296
|
-
if (!((
|
|
293
|
+
if (!((_c = providersWaitingOauthMessage.current) === null || _c === void 0 ? void 0 : _c[provider])) {
|
|
297
294
|
window.addEventListener('message', handleAuthWindowMessage);
|
|
298
295
|
providersWaitingOauthMessage.current = Object.assign(Object.assign({}, providersWaitingOauthMessage.current), { [provider]: true });
|
|
299
296
|
}
|
|
@@ -341,10 +338,10 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
341
338
|
authWindowTimeout = authWindowTimeout * 3;
|
|
342
339
|
}
|
|
343
340
|
authWindowInterval.current = setInterval(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
344
|
-
var
|
|
341
|
+
var _f;
|
|
345
342
|
shouldPool.current = false;
|
|
346
343
|
// clear all states/listeners, assuming user closed the window before completing oauth
|
|
347
|
-
if ((
|
|
344
|
+
if ((_f = providersWaitingOauthMessage.current) === null || _f === void 0 ? void 0 : _f[provider]) {
|
|
348
345
|
clearListeners();
|
|
349
346
|
handleError(types.SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Connecting ${provider} account window timeout.`);
|
|
350
347
|
}
|
|
@@ -21,7 +21,6 @@ import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
|
|
|
21
21
|
import { digestSHA256 } from '../../functions/digestSHA256/digestSHA256.js';
|
|
22
22
|
import { encodeBase64URL } from '../../functions/encodeBase64URL/encodeBase64URL.js';
|
|
23
23
|
import '@dynamic-labs/multi-wallet';
|
|
24
|
-
import { getMinAuthToken } from '../../functions/getMinAuthToken/getMinAuthToken.js';
|
|
25
24
|
import 'react-international-phone';
|
|
26
25
|
import { getOauthLoginUrl } from '../../functions/getOauthLoginUrl/getOauthLoginUrl.js';
|
|
27
26
|
import { getProviderByType } from '../../functions/getProviderByType/getProviderByType.js';
|
|
@@ -99,8 +98,7 @@ const providersRequiringPkce = ['twitter', 'github'];
|
|
|
99
98
|
const providersWithoutWindowOpenerRefence = ['twitter'];
|
|
100
99
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
101
100
|
const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcasterUrl, }) => {
|
|
102
|
-
|
|
103
|
-
const { environmentId, onboardingOnlyJwt, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext();
|
|
101
|
+
const { environmentId, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext();
|
|
104
102
|
const { setErrorMessage, setError: setContextError } = useErrorContext();
|
|
105
103
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
106
104
|
const { initAuth } = useUserAuth({
|
|
@@ -111,7 +109,6 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
111
109
|
const providersWaitingOauthMessage = useRef({});
|
|
112
110
|
const authWindowInterval = useRef();
|
|
113
111
|
const shouldPool = useRef(false);
|
|
114
|
-
const userJwt = (_a = getMinAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
115
112
|
const clearError = () => {
|
|
116
113
|
setError(undefined);
|
|
117
114
|
setContextError(undefined);
|
|
@@ -179,8 +176,8 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
179
176
|
verifyFunction: () => apiCall(),
|
|
180
177
|
});
|
|
181
178
|
});
|
|
182
|
-
const connectSocialAccount = (
|
|
183
|
-
var
|
|
179
|
+
const connectSocialAccount = (_a) => __awaiter(void 0, [_a], void 0, function* ({ provider, validator, captchaToken, }) {
|
|
180
|
+
var _b, _c;
|
|
184
181
|
clearInterval(authWindowInterval.current);
|
|
185
182
|
clearError();
|
|
186
183
|
setIsProcessing(true);
|
|
@@ -203,9 +200,9 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
203
200
|
providersWaitingOauthMessage.current = Object.assign(Object.assign({}, providersWaitingOauthMessage.current), { [provider]: false });
|
|
204
201
|
};
|
|
205
202
|
const handleAuthWindowMessage = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
206
|
-
var
|
|
203
|
+
var _d, _e;
|
|
207
204
|
const message = event.data;
|
|
208
|
-
const apiProvider = getProviderByType((
|
|
205
|
+
const apiProvider = getProviderByType((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _d !== void 0 ? _d : [], provider);
|
|
209
206
|
if (!(apiProvider === null || apiProvider === void 0 ? void 0 : apiProvider.redirectUrl)) {
|
|
210
207
|
return;
|
|
211
208
|
}
|
|
@@ -243,7 +240,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
243
240
|
return;
|
|
244
241
|
}
|
|
245
242
|
setIsProcessing(true);
|
|
246
|
-
if (!((
|
|
243
|
+
if (!((_e = providersWaitingOauthMessage.current) === null || _e === void 0 ? void 0 : _e[provider])) {
|
|
247
244
|
handleError(SocialOAuthErrorCode.SESSION_TIMEOUT, `Connecting ${provider} account session timeout.`);
|
|
248
245
|
return;
|
|
249
246
|
}
|
|
@@ -279,17 +276,17 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
279
276
|
code,
|
|
280
277
|
codeVerifier: verifier,
|
|
281
278
|
state,
|
|
282
|
-
}
|
|
279
|
+
});
|
|
283
280
|
yield linkAccount(provider, apiCall);
|
|
284
281
|
}
|
|
285
282
|
setIsProcessing(false);
|
|
286
283
|
});
|
|
287
|
-
const loginUrl = getOauthLoginUrl((
|
|
284
|
+
const loginUrl = getOauthLoginUrl((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _b !== void 0 ? _b : [], provider);
|
|
288
285
|
if (!loginUrl) {
|
|
289
286
|
handleError(SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`);
|
|
290
287
|
return;
|
|
291
288
|
}
|
|
292
|
-
if (!((
|
|
289
|
+
if (!((_c = providersWaitingOauthMessage.current) === null || _c === void 0 ? void 0 : _c[provider])) {
|
|
293
290
|
window.addEventListener('message', handleAuthWindowMessage);
|
|
294
291
|
providersWaitingOauthMessage.current = Object.assign(Object.assign({}, providersWaitingOauthMessage.current), { [provider]: true });
|
|
295
292
|
}
|
|
@@ -337,10 +334,10 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
337
334
|
authWindowTimeout = authWindowTimeout * 3;
|
|
338
335
|
}
|
|
339
336
|
authWindowInterval.current = setInterval(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
340
|
-
var
|
|
337
|
+
var _f;
|
|
341
338
|
shouldPool.current = false;
|
|
342
339
|
// clear all states/listeners, assuming user closed the window before completing oauth
|
|
343
|
-
if ((
|
|
340
|
+
if ((_f = providersWaitingOauthMessage.current) === null || _f === void 0 ? void 0 : _f[provider]) {
|
|
344
341
|
clearListeners();
|
|
345
342
|
handleError(SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Connecting ${provider} account window timeout.`);
|
|
346
343
|
}
|
|
@@ -112,7 +112,7 @@ const useTransferWallet = () => {
|
|
|
112
112
|
// and if props doesn't have nonce, that means it has messageToSignOverride and signedMessageOverride
|
|
113
113
|
nonce: '', siweStatement: props.overrideSiweStatement, walletProvider: getWalletProvider.getWalletProvider(walletConnector) });
|
|
114
114
|
const verifyArgs = yield getVerifyArgs.getVerifyArgs(args);
|
|
115
|
-
const response = yield wallets.transferWallet(environmentId, verifyArgs
|
|
115
|
+
const response = yield wallets.transferWallet(environmentId, verifyArgs);
|
|
116
116
|
const userProfile = updateJWTAndCreateUserProfile.updateJWTAndCreateUserProfile(response === null || response === void 0 ? void 0 : response.jwt, response === null || response === void 0 ? void 0 : response.minifiedJwt);
|
|
117
117
|
updatePrimaryWalletId(walletConnector, userProfile);
|
|
118
118
|
setUser(userProfile);
|
|
@@ -108,7 +108,7 @@ const useTransferWallet = () => {
|
|
|
108
108
|
// and if props doesn't have nonce, that means it has messageToSignOverride and signedMessageOverride
|
|
109
109
|
nonce: '', siweStatement: props.overrideSiweStatement, walletProvider: getWalletProvider(walletConnector) });
|
|
110
110
|
const verifyArgs = yield getVerifyArgs(args);
|
|
111
|
-
const response = yield transferWallet(environmentId, verifyArgs
|
|
111
|
+
const response = yield transferWallet(environmentId, verifyArgs);
|
|
112
112
|
const userProfile = updateJWTAndCreateUserProfile(response === null || response === void 0 ? void 0 : response.jwt, response === null || response === void 0 ? void 0 : response.minifiedJwt);
|
|
113
113
|
updatePrimaryWalletId(walletConnector, userProfile);
|
|
114
114
|
setUser(userProfile);
|
|
@@ -15,9 +15,10 @@ require('@dynamic-labs/wallet-connector-core');
|
|
|
15
15
|
require('react/jsx-runtime');
|
|
16
16
|
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
17
17
|
require('@dynamic-labs/wallet-book');
|
|
18
|
+
var localStorage$1 = require('../../constants/localStorage.cjs');
|
|
18
19
|
require('../../constants/colors.cjs');
|
|
19
20
|
require('../../constants/values.cjs');
|
|
20
|
-
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
21
|
+
var localStorage = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
21
22
|
require('../../../shared/consts/index.cjs');
|
|
22
23
|
require('../../../events/dynamicEvents.cjs');
|
|
23
24
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
@@ -105,6 +106,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
105
106
|
}
|
|
106
107
|
setMultiWalletWidgetState('idle');
|
|
107
108
|
setOnboardingOnlyJwt(undefined);
|
|
109
|
+
localStorage.LocalStorage.removeFromLS(localStorage$1.AUTH_ONBOARDING_TOKEN);
|
|
108
110
|
yield handleVerifiedUserWithJWT(jwt);
|
|
109
111
|
if (showSuccessMessage) {
|
|
110
112
|
// this timeout is set to make sure that the user will see success message
|
|
@@ -133,6 +135,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
133
135
|
});
|
|
134
136
|
const handleOnboarding = (jwt, showSuccessMessage, onSettled) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
135
137
|
setOnboardingOnlyJwt(jwt);
|
|
138
|
+
localStorage.LocalStorage.setToLS(localStorage$1.AUTH_ONBOARDING_TOKEN, jwt, true);
|
|
136
139
|
if (showSuccessMessage) {
|
|
137
140
|
yield sleepToShowSuccessMessage();
|
|
138
141
|
}
|
|
@@ -204,6 +207,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
204
207
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
205
208
|
onValidUpdatedJwt === null || onValidUpdatedJwt === void 0 ? void 0 : onValidUpdatedJwt();
|
|
206
209
|
setOnboardingOnlyJwt(updateUserProfileResponse.jwt);
|
|
210
|
+
localStorage.LocalStorage.setToLS(localStorage$1.AUTH_ONBOARDING_TOKEN, updateUserProfileResponse.minifiedJwt, true);
|
|
207
211
|
if (isEmailVerificationRequired &&
|
|
208
212
|
missingFields.map((field) => field.name).toString() === 'email') {
|
|
209
213
|
setView('verify-email');
|
|
@@ -223,6 +227,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
223
227
|
if (onboardingOnlyJwt) {
|
|
224
228
|
yield handleVerifiedUserWithJWT(updateUserProfileResponse.jwt);
|
|
225
229
|
setOnboardingOnlyJwt(undefined);
|
|
230
|
+
localStorage.LocalStorage.removeFromLS(localStorage$1.AUTH_ONBOARDING_TOKEN);
|
|
226
231
|
setCallback('authSuccess');
|
|
227
232
|
}
|
|
228
233
|
if (completeSignInFlow) {
|
|
@@ -11,9 +11,10 @@ import '@dynamic-labs/wallet-connector-core';
|
|
|
11
11
|
import 'react/jsx-runtime';
|
|
12
12
|
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
13
13
|
import '@dynamic-labs/wallet-book';
|
|
14
|
+
import { AUTH_ONBOARDING_TOKEN } from '../../constants/localStorage.js';
|
|
14
15
|
import '../../constants/colors.js';
|
|
15
16
|
import '../../constants/values.js';
|
|
16
|
-
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
17
|
+
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
17
18
|
import '../../../shared/consts/index.js';
|
|
18
19
|
import '../../../events/dynamicEvents.js';
|
|
19
20
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
@@ -101,6 +102,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
101
102
|
}
|
|
102
103
|
setMultiWalletWidgetState('idle');
|
|
103
104
|
setOnboardingOnlyJwt(undefined);
|
|
105
|
+
LocalStorage.removeFromLS(AUTH_ONBOARDING_TOKEN);
|
|
104
106
|
yield handleVerifiedUserWithJWT(jwt);
|
|
105
107
|
if (showSuccessMessage) {
|
|
106
108
|
// this timeout is set to make sure that the user will see success message
|
|
@@ -129,6 +131,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
129
131
|
});
|
|
130
132
|
const handleOnboarding = (jwt, showSuccessMessage, onSettled) => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
133
|
setOnboardingOnlyJwt(jwt);
|
|
134
|
+
LocalStorage.setToLS(AUTH_ONBOARDING_TOKEN, jwt, true);
|
|
132
135
|
if (showSuccessMessage) {
|
|
133
136
|
yield sleepToShowSuccessMessage();
|
|
134
137
|
}
|
|
@@ -200,6 +203,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
200
203
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
201
204
|
onValidUpdatedJwt === null || onValidUpdatedJwt === void 0 ? void 0 : onValidUpdatedJwt();
|
|
202
205
|
setOnboardingOnlyJwt(updateUserProfileResponse.jwt);
|
|
206
|
+
LocalStorage.setToLS(AUTH_ONBOARDING_TOKEN, updateUserProfileResponse.minifiedJwt, true);
|
|
203
207
|
if (isEmailVerificationRequired &&
|
|
204
208
|
missingFields.map((field) => field.name).toString() === 'email') {
|
|
205
209
|
setView('verify-email');
|
|
@@ -219,6 +223,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
219
223
|
if (onboardingOnlyJwt) {
|
|
220
224
|
yield handleVerifiedUserWithJWT(updateUserProfileResponse.jwt);
|
|
221
225
|
setOnboardingOnlyJwt(undefined);
|
|
226
|
+
LocalStorage.removeFromLS(AUTH_ONBOARDING_TOKEN);
|
|
222
227
|
setCallback('authSuccess');
|
|
223
228
|
}
|
|
224
229
|
if (completeSignInFlow) {
|
|
@@ -107,7 +107,7 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
107
107
|
const { setRetryData } = VerificationContext.useVerification();
|
|
108
108
|
const { selectedPhoneCountry } = FieldsStateContext.useFieldsState();
|
|
109
109
|
const updateUser = React.useCallback((userFields, options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
-
var _a, _b
|
|
110
|
+
var _a, _b;
|
|
111
111
|
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
112
112
|
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
113
113
|
const { metadata } = userFields;
|
|
@@ -124,10 +124,10 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
124
124
|
iso2: selectedPhoneCountry.current.iso2,
|
|
125
125
|
phone: validatedUserFields.phoneNumber,
|
|
126
126
|
});
|
|
127
|
-
const updateUserProfileResponse = yield user.updateUserProfileFields((_a = options === null || options === void 0 ? void 0 : options.
|
|
127
|
+
const updateUserProfileResponse = yield user.updateUserProfileFields((_a = options === null || options === void 0 ? void 0 : options.userEnvironmentId) !== null && _a !== void 0 ? _a : environmentId, Object.assign(Object.assign({}, validatedUserFields), { metadata }));
|
|
128
128
|
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
129
129
|
const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
|
|
130
|
-
const missingFields = (
|
|
130
|
+
const missingFields = (_b = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _b !== void 0 ? _b : [];
|
|
131
131
|
const requiredVerificationDestination = useHandleVerificationRequired.isVerificationRequired(updateUserProfileResponse);
|
|
132
132
|
if (requiredVerificationDestination && handleVerificationRequired.current)
|
|
133
133
|
return handleVerificationRequired.current({
|
|
@@ -103,7 +103,7 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
103
103
|
const { setRetryData } = useVerification();
|
|
104
104
|
const { selectedPhoneCountry } = useFieldsState();
|
|
105
105
|
const updateUser = useCallback((userFields, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
var _a, _b
|
|
106
|
+
var _a, _b;
|
|
107
107
|
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
108
108
|
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
109
109
|
const { metadata } = userFields;
|
|
@@ -120,10 +120,10 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
120
120
|
iso2: selectedPhoneCountry.current.iso2,
|
|
121
121
|
phone: validatedUserFields.phoneNumber,
|
|
122
122
|
});
|
|
123
|
-
const updateUserProfileResponse = yield updateUserProfileFields((_a = options === null || options === void 0 ? void 0 : options.
|
|
123
|
+
const updateUserProfileResponse = yield updateUserProfileFields((_a = options === null || options === void 0 ? void 0 : options.userEnvironmentId) !== null && _a !== void 0 ? _a : environmentId, Object.assign(Object.assign({}, validatedUserFields), { metadata }));
|
|
124
124
|
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
125
125
|
const decodedJwt = decodeJwt(updateUserProfileResponse.jwt);
|
|
126
|
-
const missingFields = (
|
|
126
|
+
const missingFields = (_b = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _b !== void 0 ? _b : [];
|
|
127
127
|
const requiredVerificationDestination = isVerificationRequired(updateUserProfileResponse);
|
|
128
128
|
if (requiredVerificationDestination && handleVerificationRequired.current)
|
|
129
129
|
return handleVerificationRequired.current({
|
|
@@ -118,7 +118,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
118
118
|
oauth }));
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
|
-
verifyResponse = wallets.linkWallet(environmentId, verifyArgs
|
|
121
|
+
verifyResponse = wallets.linkWallet(environmentId, verifyArgs);
|
|
122
122
|
}
|
|
123
123
|
return { verifyArgs, verifyFunction: () => verifyResponse };
|
|
124
124
|
});
|
|
@@ -114,7 +114,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
114
114
|
oauth }));
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
|
-
verifyResponse = linkWallet(environmentId, verifyArgs
|
|
117
|
+
verifyResponse = linkWallet(environmentId, verifyArgs);
|
|
118
118
|
}
|
|
119
119
|
return { verifyArgs, verifyFunction: () => verifyResponse };
|
|
120
120
|
});
|
|
@@ -26,15 +26,15 @@ require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
|
26
26
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
27
27
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
28
28
|
require('../../../config/ApiEndpoint.cjs');
|
|
29
|
-
require('../../../locale/locale.cjs');
|
|
30
29
|
require('@dynamic-labs/multi-wallet');
|
|
31
|
-
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
32
|
-
var useConnectAndSignSplitSteps = require('../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs');
|
|
33
|
-
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
34
30
|
require('react-international-phone');
|
|
35
31
|
var requiresTwoStepAuthentication = require('../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.cjs');
|
|
36
32
|
require('viem');
|
|
37
33
|
require('viem/chains');
|
|
34
|
+
require('../../../locale/locale.cjs');
|
|
35
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
36
|
+
var useConnectAndSignSplitSteps = require('../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs');
|
|
37
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
38
38
|
require('react-dom');
|
|
39
39
|
require('../../../context/WalletContext/WalletContext.cjs');
|
|
40
40
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
@@ -22,15 +22,15 @@ import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
|
22
22
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
23
23
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
24
24
|
import '../../../config/ApiEndpoint.js';
|
|
25
|
-
import '../../../locale/locale.js';
|
|
26
25
|
import '@dynamic-labs/multi-wallet';
|
|
27
|
-
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
28
|
-
import { useConnectAndSignSplitSteps } from '../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js';
|
|
29
|
-
import '../../../context/VerificationContext/VerificationContext.js';
|
|
30
26
|
import 'react-international-phone';
|
|
31
27
|
import { requiresTwoStepAuthentication } from '../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.js';
|
|
32
28
|
import 'viem';
|
|
33
29
|
import 'viem/chains';
|
|
30
|
+
import '../../../locale/locale.js';
|
|
31
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
32
|
+
import { useConnectAndSignSplitSteps } from '../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js';
|
|
33
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
34
34
|
import 'react-dom';
|
|
35
35
|
import '../../../context/WalletContext/WalletContext.js';
|
|
36
36
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
@@ -33,6 +33,7 @@ require('viem');
|
|
|
33
33
|
require('viem/chains');
|
|
34
34
|
require('../../../config/ApiEndpoint.cjs');
|
|
35
35
|
require('../../../locale/locale.cjs');
|
|
36
|
+
var downloadFile = require('../../../utils/functions/downloadFile/downloadFile.cjs');
|
|
36
37
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
37
38
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
38
39
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -99,22 +100,16 @@ const SavePasswordStep = ({ password, error, isLoading, onSave, onBack, onClose,
|
|
|
99
100
|
e.preventDefault();
|
|
100
101
|
onSave();
|
|
101
102
|
});
|
|
102
|
-
const handleDownloadFile = (e) => {
|
|
103
|
-
e.preventDefault();
|
|
104
|
-
const element = document.createElement('a');
|
|
105
|
-
const file = new Blob([password], { type: 'text/plain' });
|
|
106
|
-
element.href = URL.createObjectURL(file);
|
|
107
|
-
element.download = 'dynamic-wallet-recovery.txt';
|
|
108
|
-
document.body.appendChild(element);
|
|
109
|
-
element.click();
|
|
110
|
-
};
|
|
111
103
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', copykey: 'dyn_save_password.title', children: t('dyn_save_password.title') }) }), jsxRuntime.jsx("div", { className: 'save-password-view', children: jsxRuntime.jsxs("form", { className: 'save-password-view__body', "data-testid": 'save-password-form', onSubmit: handleSavePassword, children: [jsxRuntime.jsx("div", { className: 'save-password-view__body__icon', children: jsxRuntime.jsx(savePasswordHero.ReactComponent, {}) }), jsxRuntime.jsx("div", { className: 'save-password-view__body__icon', children: jsxRuntime.jsx(Badge.Badge, { text: t('dyn_save_password.badge_text'), className: 'save-password-view__body__badge', copykey: 'dyn_save_password.badge_text' }) }), jsxRuntime.jsxs("div", { className: 'save-password-view__body__description', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_save_password.description', children: t('dyn_save_password.description') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', copykey: 'dyn_save_password.description', children: t('dyn_save_password.warning') })] }), error && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: error }), jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Input.Input, { id: 'password', placeholder: t('dyn_save_password.password_input.placeholder'), type: inputType, suffix: inputSuffix, disabled: true, label: t('dyn_save_password.password_input.label'), value: password, autoFocus: true, copykey: 'dyn_save_password.password_input' }) }), jsxRuntime.jsxs("div", { className: 'save-password-view__actions', children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'save-password-copy', buttonPadding: 'small', buttonVariant: 'primary', onClick: (e) => {
|
|
112
104
|
e.preventDefault();
|
|
113
105
|
helpers.copyToClipboard(password);
|
|
114
106
|
setIsCopied(true);
|
|
115
107
|
}, startSlot: jsxRuntime.jsx(copy.ReactComponent, {}), expanded: true, copykey: 'dyn_save_password.copy_button', children: isCopied
|
|
116
108
|
? t('dyn_save_password.copy_button.copied')
|
|
117
|
-
: t('dyn_save_password.copy_button.copy') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'save-password-download', buttonPadding: 'small', buttonVariant: 'primary', onClick:
|
|
109
|
+
: t('dyn_save_password.copy_button.copy') }), jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'save-password-download', buttonPadding: 'small', buttonVariant: 'primary', onClick: (e) => {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
downloadFile.downloadFile('wallet-recovery.txt', password);
|
|
112
|
+
}, startSlot: jsxRuntime.jsx(download.ReactComponent, {}), expanded: true, copykey: 'dyn_save_password.download_button', children: t('dyn_save_password.download_button') })] }), jsxRuntime.jsx("div", { className: 'save-password-view__body__confirm-card', children: jsxRuntime.jsxs("button", { className: 'save-password-view__body__card__acknowledgement', onClick: (e) => {
|
|
118
113
|
e.stopPropagation();
|
|
119
114
|
setAcknowledgement(!acknowledgement);
|
|
120
115
|
}, type: 'button', children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Checkbox.Checkbox, { checked: acknowledgement, onChange: (e) => {
|
|
@@ -29,6 +29,7 @@ import 'viem';
|
|
|
29
29
|
import 'viem/chains';
|
|
30
30
|
import '../../../config/ApiEndpoint.js';
|
|
31
31
|
import '../../../locale/locale.js';
|
|
32
|
+
import { downloadFile } from '../../../utils/functions/downloadFile/downloadFile.js';
|
|
32
33
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
33
34
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
34
35
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -95,22 +96,16 @@ const SavePasswordStep = ({ password, error, isLoading, onSave, onBack, onClose,
|
|
|
95
96
|
e.preventDefault();
|
|
96
97
|
onSave();
|
|
97
98
|
});
|
|
98
|
-
const handleDownloadFile = (e) => {
|
|
99
|
-
e.preventDefault();
|
|
100
|
-
const element = document.createElement('a');
|
|
101
|
-
const file = new Blob([password], { type: 'text/plain' });
|
|
102
|
-
element.href = URL.createObjectURL(file);
|
|
103
|
-
element.download = 'dynamic-wallet-recovery.txt';
|
|
104
|
-
document.body.appendChild(element);
|
|
105
|
-
element.click();
|
|
106
|
-
};
|
|
107
99
|
return (jsxs(Fragment, { children: [jsx(ModalHeader, { leading: backButton, trailing: closeButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', copykey: 'dyn_save_password.title', children: t('dyn_save_password.title') }) }), jsx("div", { className: 'save-password-view', children: jsxs("form", { className: 'save-password-view__body', "data-testid": 'save-password-form', onSubmit: handleSavePassword, children: [jsx("div", { className: 'save-password-view__body__icon', children: jsx(SvgSavePasswordHero, {}) }), jsx("div", { className: 'save-password-view__body__icon', children: jsx(Badge, { text: t('dyn_save_password.badge_text'), className: 'save-password-view__body__badge', copykey: 'dyn_save_password.badge_text' }) }), jsxs("div", { className: 'save-password-view__body__description', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_save_password.description', children: t('dyn_save_password.description') }), jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', copykey: 'dyn_save_password.description', children: t('dyn_save_password.warning') })] }), error && jsx(ErrorContainer, { children: error }), jsx("div", { children: jsx(Input, { id: 'password', placeholder: t('dyn_save_password.password_input.placeholder'), type: inputType, suffix: inputSuffix, disabled: true, label: t('dyn_save_password.password_input.label'), value: password, autoFocus: true, copykey: 'dyn_save_password.password_input' }) }), jsxs("div", { className: 'save-password-view__actions', children: [jsx(TypographyButton, { dataTestId: 'save-password-copy', buttonPadding: 'small', buttonVariant: 'primary', onClick: (e) => {
|
|
108
100
|
e.preventDefault();
|
|
109
101
|
copyToClipboard(password);
|
|
110
102
|
setIsCopied(true);
|
|
111
103
|
}, startSlot: jsx(SvgCopy, {}), expanded: true, copykey: 'dyn_save_password.copy_button', children: isCopied
|
|
112
104
|
? t('dyn_save_password.copy_button.copied')
|
|
113
|
-
: t('dyn_save_password.copy_button.copy') }), jsx(TypographyButton, { dataTestId: 'save-password-download', buttonPadding: 'small', buttonVariant: 'primary', onClick:
|
|
105
|
+
: t('dyn_save_password.copy_button.copy') }), jsx(TypographyButton, { dataTestId: 'save-password-download', buttonPadding: 'small', buttonVariant: 'primary', onClick: (e) => {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
downloadFile('wallet-recovery.txt', password);
|
|
108
|
+
}, startSlot: jsx(SvgDownload, {}), expanded: true, copykey: 'dyn_save_password.download_button', children: t('dyn_save_password.download_button') })] }), jsx("div", { className: 'save-password-view__body__confirm-card', children: jsxs("button", { className: 'save-password-view__body__card__acknowledgement', onClick: (e) => {
|
|
114
109
|
e.stopPropagation();
|
|
115
110
|
setAcknowledgement(!acknowledgement);
|
|
116
111
|
}, type: 'button', children: [jsx("div", { children: jsx(Checkbox, { checked: acknowledgement, onChange: (e) => {
|
|
@@ -85,7 +85,7 @@ const EmailUpdate = () => {
|
|
|
85
85
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
86
86
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
87
87
|
const { displayedDestination: email, setDisplayedDestination: setEmail, setVerificationUUID, } = VerificationContext.useVerification();
|
|
88
|
-
const { environmentId, handleLogOut
|
|
88
|
+
const { environmentId, handleLogOut } = useInternalDynamicContext.useInternalDynamicContext();
|
|
89
89
|
const { t } = reactI18next.useTranslation();
|
|
90
90
|
const [emailError, setEmailError] = React.useState(undefined);
|
|
91
91
|
const handleBackClick = () => {
|
|
@@ -93,9 +93,6 @@ const EmailUpdate = () => {
|
|
|
93
93
|
setError(undefined);
|
|
94
94
|
};
|
|
95
95
|
const backButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'back-button', children: jsxRuntime.jsx(chevronLeft.ReactComponent, {}) }));
|
|
96
|
-
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
97
|
-
// If user tries to update the email in the authFlow, authToken is undefined and onboardingOnlyJwt is defined
|
|
98
|
-
const jwtToken = minAuthToken || onboardingOnlyJwt;
|
|
99
96
|
const handleEmailUpdate = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
100
97
|
try {
|
|
101
98
|
if (!updatedEmail) {
|
|
@@ -103,7 +100,7 @@ const EmailUpdate = () => {
|
|
|
103
100
|
}
|
|
104
101
|
setEmailError(undefined);
|
|
105
102
|
setLoading(true);
|
|
106
|
-
const { emailVerification } = yield user.updateUserProfileFields(
|
|
103
|
+
const { emailVerification } = yield user.updateUserProfileFields(environmentId, { email: updatedEmail });
|
|
107
104
|
if (!emailVerification) {
|
|
108
105
|
yield handleLogOut();
|
|
109
106
|
goToInitialView();
|
|
@@ -81,7 +81,7 @@ const EmailUpdate = () => {
|
|
|
81
81
|
const { loading, setLoading } = useLoadingContext();
|
|
82
82
|
const { setView, goToInitialView } = useViewContext();
|
|
83
83
|
const { displayedDestination: email, setDisplayedDestination: setEmail, setVerificationUUID, } = useVerification();
|
|
84
|
-
const { environmentId, handleLogOut
|
|
84
|
+
const { environmentId, handleLogOut } = useInternalDynamicContext();
|
|
85
85
|
const { t } = useTranslation();
|
|
86
86
|
const [emailError, setEmailError] = useState(undefined);
|
|
87
87
|
const handleBackClick = () => {
|
|
@@ -89,9 +89,6 @@ const EmailUpdate = () => {
|
|
|
89
89
|
setError(undefined);
|
|
90
90
|
};
|
|
91
91
|
const backButton = (jsx(IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'back-button', children: jsx(SvgChevronLeft, {}) }));
|
|
92
|
-
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
93
|
-
// If user tries to update the email in the authFlow, authToken is undefined and onboardingOnlyJwt is defined
|
|
94
|
-
const jwtToken = minAuthToken || onboardingOnlyJwt;
|
|
95
92
|
const handleEmailUpdate = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
93
|
try {
|
|
97
94
|
if (!updatedEmail) {
|
|
@@ -99,7 +96,7 @@ const EmailUpdate = () => {
|
|
|
99
96
|
}
|
|
100
97
|
setEmailError(undefined);
|
|
101
98
|
setLoading(true);
|
|
102
|
-
const { emailVerification } = yield updateUserProfileFields(
|
|
99
|
+
const { emailVerification } = yield updateUserProfileFields(environmentId, { email: updatedEmail });
|
|
103
100
|
if (!emailVerification) {
|
|
104
101
|
yield handleLogOut();
|
|
105
102
|
goToInitialView();
|
|
@@ -98,7 +98,7 @@ require('../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection
|
|
|
98
98
|
const SECONDS_TO_RETRY = 15;
|
|
99
99
|
const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
|
|
100
100
|
var _a, _b, _c, _d;
|
|
101
|
-
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setUser, setShowAuthFlow, projectSettings, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
101
|
+
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setUser, setPrimaryWalletId, setShowAuthFlow, projectSettings, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
102
102
|
const { view, setView, goToInitialView } = ViewContext.useViewContext();
|
|
103
103
|
const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
|
|
104
104
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
@@ -175,6 +175,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
175
175
|
connector: undefined,
|
|
176
176
|
id: embeddedWalletVerifiedCredential.id,
|
|
177
177
|
};
|
|
178
|
+
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
178
179
|
dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt);
|
|
179
180
|
}
|
|
180
181
|
if (isUsingPregeneratedWallets || isManualMode) {
|
|
@@ -192,6 +193,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
192
193
|
isTurnkeyWallet,
|
|
193
194
|
(_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation,
|
|
194
195
|
(_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.embeddedWallets) === null || _d === void 0 ? void 0 : _d.forceAuthenticatorAtSignup,
|
|
196
|
+
setPrimaryWalletId,
|
|
195
197
|
setShowAuthFlow,
|
|
196
198
|
setUser,
|
|
197
199
|
setView,
|
|
@@ -94,7 +94,7 @@ import '../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.
|
|
|
94
94
|
const SECONDS_TO_RETRY = 15;
|
|
95
95
|
const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
|
|
96
96
|
var _a, _b, _c, _d;
|
|
97
|
-
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setUser, setShowAuthFlow, projectSettings, } = useInternalDynamicContext();
|
|
97
|
+
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setUser, setPrimaryWalletId, setShowAuthFlow, projectSettings, } = useInternalDynamicContext();
|
|
98
98
|
const { view, setView, goToInitialView } = useViewContext();
|
|
99
99
|
const { error, setError, setErrorMessage } = useErrorContext();
|
|
100
100
|
const { loading, setLoading } = useLoadingContext();
|
|
@@ -171,6 +171,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
171
171
|
connector: undefined,
|
|
172
172
|
id: embeddedWalletVerifiedCredential.id,
|
|
173
173
|
};
|
|
174
|
+
setPrimaryWalletId(embeddedWalletVerifiedCredential.id);
|
|
174
175
|
dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt);
|
|
175
176
|
}
|
|
176
177
|
if (isUsingPregeneratedWallets || isManualMode) {
|
|
@@ -188,6 +189,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
188
189
|
isTurnkeyWallet,
|
|
189
190
|
(_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation,
|
|
190
191
|
(_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.embeddedWallets) === null || _d === void 0 ? void 0 : _d.forceAuthenticatorAtSignup,
|
|
192
|
+
setPrimaryWalletId,
|
|
191
193
|
setShowAuthFlow,
|
|
192
194
|
setUser,
|
|
193
195
|
setView,
|