@dynamic-labs/sdk-react-core 2.1.0-alpha.4 → 2.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +12 -12
  5. package/src/index.cjs +6 -0
  6. package/src/index.d.ts +1 -0
  7. package/src/index.js +3 -0
  8. package/src/lib/Main.cjs +2 -0
  9. package/src/lib/Main.js +2 -0
  10. package/src/lib/context/DynamicContext/DynamicContext.cjs +17 -5
  11. package/src/lib/context/DynamicContext/DynamicContext.d.ts +5 -0
  12. package/src/lib/context/DynamicContext/DynamicContext.js +14 -2
  13. package/src/lib/context/ErrorBoundary/ErrorBoundary.cjs +64 -0
  14. package/src/lib/context/ErrorBoundary/ErrorBoundary.d.ts +3 -0
  15. package/src/lib/context/ErrorBoundary/ErrorBoundary.js +60 -0
  16. package/src/lib/context/ErrorBoundary/ErrorBoundaryBase.cjs +40 -0
  17. package/src/lib/context/ErrorBoundary/ErrorBoundaryBase.d.ts +14 -0
  18. package/src/lib/context/ErrorBoundary/ErrorBoundaryBase.js +36 -0
  19. package/src/lib/context/ErrorBoundary/ErrorBoundaryContext.cjs +24 -0
  20. package/src/lib/context/ErrorBoundary/ErrorBoundaryContext.d.ts +5 -0
  21. package/src/lib/context/ErrorBoundary/ErrorBoundaryContext.js +18 -0
  22. package/src/lib/context/ErrorBoundary/ErrorBoundaryExclude.cjs +17 -0
  23. package/src/lib/context/ErrorBoundary/ErrorBoundaryExclude.d.ts +4 -0
  24. package/src/lib/context/ErrorBoundary/ErrorBoundaryExclude.js +13 -0
  25. package/src/lib/context/ErrorBoundary/ErrorBoundaryInclude.cjs +17 -0
  26. package/src/lib/context/ErrorBoundary/ErrorBoundaryInclude.d.ts +4 -0
  27. package/src/lib/context/ErrorBoundary/ErrorBoundaryInclude.js +13 -0
  28. package/src/lib/context/ErrorBoundary/index.d.ts +3 -0
  29. package/src/lib/context/ErrorBoundary/types.d.ts +13 -0
  30. package/src/lib/utils/functions/findTurnkeyWallet/findTurnkeyWallet.cjs +2 -1
  31. package/src/lib/utils/functions/findTurnkeyWallet/findTurnkeyWallet.js +3 -2
  32. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +7 -8
  33. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +7 -8
  34. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +27 -34
  35. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +28 -35
  36. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +31 -9
  37. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +31 -9
  38. package/src/lib/views/EmailVerification/EmailVerification.cjs +38 -11
  39. package/src/lib/views/EmailVerification/EmailVerification.js +38 -11
  40. package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +6 -7
  41. package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +6 -7
  42. package/src/lib/views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs +16 -0
  43. package/src/lib/views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.d.ts +2 -0
  44. package/src/lib/views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js +12 -0
  45. package/src/lib/views/Passkey/utils/findPrimaryEmbeddedChain/index.d.ts +1 -0
@@ -27,6 +27,7 @@ require('../../shared/consts/index.cjs');
27
27
  var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
28
28
  require('../../context/CaptchaContext/CaptchaContext.cjs');
29
29
  var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
30
+ var findEmbeddedWalletFromVerifiedCredentials = require('../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.cjs');
30
31
  require('@dynamic-labs/multi-wallet');
31
32
  require('react-international-phone');
32
33
  var shortenEmail = require('../../shared/utils/functions/shortenEmail/shortenEmail.cjs');
@@ -100,7 +101,7 @@ require('../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection
100
101
  const SECONDS_TO_RETRY = 15;
101
102
  const sleepToShowSuccessMessage = () => utils.sleep(1500);
102
103
  const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
103
- var _a, _b, _c, _d;
104
+ var _a, _b, _c, _d, _e, _f;
104
105
  const [showRetryButton, setShowRetryButton] = React.useState(_showRetryButton);
105
106
  const [showTransferMessage, setShowTransferMessage] = React.useState(_showTransferMessage);
106
107
  const { handleVerifiedUserWithJWT } = useHandleVerifiedUser.useHandleVerifiedUser();
@@ -135,7 +136,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
135
136
  const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback.useCreateUserProfileByJWTCallback();
136
137
  const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
137
138
  const handleComplete = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
138
- var _e, _f, _g;
139
+ var _g, _h, _j, _k, _l, _m, _o;
139
140
  setError(undefined);
140
141
  setLoading(true);
141
142
  if (!verificationUUID || (!authToken && !onboardingOnlyJwt)) {
@@ -172,16 +173,41 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
172
173
  if (isTurnkeyWallet &&
173
174
  hasTurnkeyVerifiedCredentialAuthenticator &&
174
175
  !hasRecoveryEmail &&
175
- ((_e = updateUserProfileResponse === null || updateUserProfileResponse === void 0 ? void 0 : updateUserProfileResponse.user) === null || _e === void 0 ? void 0 : _e.email)) {
176
+ ((_g = updateUserProfileResponse === null || updateUserProfileResponse === void 0 ? void 0 : updateUserProfileResponse.user) === null || _g === void 0 ? void 0 : _g.email)) {
176
177
  setUser(updateJWTAndCreateUserProfile.updateJWTAndCreateUserProfile(updateUserProfileResponse.jwt, updateUserProfileResponse.minifiedJwt));
177
178
  yield addRecoveryEmail(updateUserProfileResponse.user.email);
178
179
  setShowAuthFlow(false);
179
180
  return;
180
181
  }
181
- if (isTurnkeyProviderEnabled &&
182
- !((_g = (_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _f === void 0 ? void 0 : _f.embeddedWallets) === null || _g === void 0 ? void 0 : _g.automaticEmbeddedWalletCreation)) {
183
- setShowAuthFlow(false);
184
- return;
182
+ if (isTurnkeyProviderEnabled) {
183
+ const isManualMode = !((_j = (_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _h === void 0 ? void 0 : _h.embeddedWallets) === null || _j === void 0 ? void 0 : _j.automaticEmbeddedWalletCreation);
184
+ const isUsingPregeneratedWallets = Boolean(((_l = (_k = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _k === void 0 ? void 0 : _k.embeddedWallets) === null || _l === void 0 ? void 0 : _l.automaticEmbeddedWalletCreation) &&
185
+ !((_o = (_m = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _m === void 0 ? void 0 : _m.embeddedWallets) === null || _o === void 0 ? void 0 : _o.forceAuthenticatorAtSignup));
186
+ if (isUsingPregeneratedWallets) {
187
+ // Pregenerated wallet was created during an
188
+ // additional email validation step as part of onboarding
189
+ // cannot rely on newUser JWT field here due to session being counted twice
190
+ // when authentication happens followed by a separate email kyc step
191
+ const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(updateUserProfileResponse.jwt);
192
+ if (!embeddedWalletVerifiedCredential) {
193
+ throw new Error('Could not find an embedded wallet');
194
+ }
195
+ const wallet = {
196
+ address: embeddedWalletVerifiedCredential.address,
197
+ authenticated: false,
198
+ chain: embeddedWalletVerifiedCredential.chain,
199
+ connected: true,
200
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
201
+ // @ts-ignore
202
+ connector: undefined,
203
+ id: embeddedWalletVerifiedCredential.id,
204
+ };
205
+ dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt);
206
+ }
207
+ if (isUsingPregeneratedWallets || isManualMode) {
208
+ setShowAuthFlow(false);
209
+ return;
210
+ }
185
211
  }
186
212
  // this function will check turnkey wallet enabled and create wallet if needed
187
213
  // if not enabled, it will throw an error.
@@ -217,7 +243,6 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
217
243
  hasTurnkeyVerifiedCredentialAuthenticator,
218
244
  hasRecoveryEmail,
219
245
  isTurnkeyProviderEnabled,
220
- (_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,
221
246
  createEmbeddedWallet,
222
247
  setOnboardingOnlyJwt,
223
248
  setView,
@@ -226,10 +251,12 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
226
251
  setUser,
227
252
  addRecoveryEmail,
228
253
  setShowAuthFlow,
254
+ (_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,
255
+ (_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,
229
256
  setErrorMessage,
230
257
  ]);
231
258
  const handleEmailLogin = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
232
- var _h, _j;
259
+ var _p, _q;
233
260
  setError(undefined);
234
261
  setLoading(true);
235
262
  if (!verificationUUID) {
@@ -264,7 +291,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
264
291
  yield sleepToShowSuccessMessage();
265
292
  yield createUserProfileByJWT(jwt, minifiedJwt);
266
293
  if (isTurnkeyProviderEnabled &&
267
- !((_j = (_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _h === void 0 ? void 0 : _h.embeddedWallets) === null || _j === void 0 ? void 0 : _j.automaticEmbeddedWalletCreation)) {
294
+ !((_q = (_p = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _p === void 0 ? void 0 : _p.embeddedWallets) === null || _q === void 0 ? void 0 : _q.automaticEmbeddedWalletCreation)) {
268
295
  setShowAuthFlow(false);
269
296
  return;
270
297
  }
@@ -297,7 +324,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
297
324
  setCallback,
298
325
  createUserProfileByJWT,
299
326
  isTurnkeyProviderEnabled,
300
- (_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.automaticEmbeddedWalletCreation,
327
+ (_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _e === void 0 ? void 0 : _e.embeddedWallets) === null || _f === void 0 ? void 0 : _f.automaticEmbeddedWalletCreation,
301
328
  createEmbeddedWallet,
302
329
  setOnboardingOnlyJwt,
303
330
  setView,
@@ -23,6 +23,7 @@ import '../../shared/consts/index.js';
23
23
  import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
24
24
  import '../../context/CaptchaContext/CaptchaContext.js';
25
25
  import { useErrorContext } from '../../context/ErrorContext/ErrorContext.js';
26
+ import { findEmbeddedWalletFromVerifiedCredentials } from '../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.js';
26
27
  import '@dynamic-labs/multi-wallet';
27
28
  import 'react-international-phone';
28
29
  import { shortenEmail } from '../../shared/utils/functions/shortenEmail/shortenEmail.js';
@@ -96,7 +97,7 @@ import '../LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.
96
97
  const SECONDS_TO_RETRY = 15;
97
98
  const sleepToShowSuccessMessage = () => sleep(1500);
98
99
  const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _showRetryButton = true, showTransferMessage: _showTransferMessage = false, }) => {
99
- var _a, _b, _c, _d;
100
+ var _a, _b, _c, _d, _e, _f;
100
101
  const [showRetryButton, setShowRetryButton] = useState(_showRetryButton);
101
102
  const [showTransferMessage, setShowTransferMessage] = useState(_showTransferMessage);
102
103
  const { handleVerifiedUserWithJWT } = useHandleVerifiedUser();
@@ -131,7 +132,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
131
132
  const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback();
132
133
  const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
133
134
  const handleComplete = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
134
- var _e, _f, _g;
135
+ var _g, _h, _j, _k, _l, _m, _o;
135
136
  setError(undefined);
136
137
  setLoading(true);
137
138
  if (!verificationUUID || (!authToken && !onboardingOnlyJwt)) {
@@ -168,16 +169,41 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
168
169
  if (isTurnkeyWallet &&
169
170
  hasTurnkeyVerifiedCredentialAuthenticator &&
170
171
  !hasRecoveryEmail &&
171
- ((_e = updateUserProfileResponse === null || updateUserProfileResponse === void 0 ? void 0 : updateUserProfileResponse.user) === null || _e === void 0 ? void 0 : _e.email)) {
172
+ ((_g = updateUserProfileResponse === null || updateUserProfileResponse === void 0 ? void 0 : updateUserProfileResponse.user) === null || _g === void 0 ? void 0 : _g.email)) {
172
173
  setUser(updateJWTAndCreateUserProfile(updateUserProfileResponse.jwt, updateUserProfileResponse.minifiedJwt));
173
174
  yield addRecoveryEmail(updateUserProfileResponse.user.email);
174
175
  setShowAuthFlow(false);
175
176
  return;
176
177
  }
177
- if (isTurnkeyProviderEnabled &&
178
- !((_g = (_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _f === void 0 ? void 0 : _f.embeddedWallets) === null || _g === void 0 ? void 0 : _g.automaticEmbeddedWalletCreation)) {
179
- setShowAuthFlow(false);
180
- return;
178
+ if (isTurnkeyProviderEnabled) {
179
+ const isManualMode = !((_j = (_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _h === void 0 ? void 0 : _h.embeddedWallets) === null || _j === void 0 ? void 0 : _j.automaticEmbeddedWalletCreation);
180
+ const isUsingPregeneratedWallets = Boolean(((_l = (_k = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _k === void 0 ? void 0 : _k.embeddedWallets) === null || _l === void 0 ? void 0 : _l.automaticEmbeddedWalletCreation) &&
181
+ !((_o = (_m = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _m === void 0 ? void 0 : _m.embeddedWallets) === null || _o === void 0 ? void 0 : _o.forceAuthenticatorAtSignup));
182
+ if (isUsingPregeneratedWallets) {
183
+ // Pregenerated wallet was created during an
184
+ // additional email validation step as part of onboarding
185
+ // cannot rely on newUser JWT field here due to session being counted twice
186
+ // when authentication happens followed by a separate email kyc step
187
+ const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(updateUserProfileResponse.jwt);
188
+ if (!embeddedWalletVerifiedCredential) {
189
+ throw new Error('Could not find an embedded wallet');
190
+ }
191
+ const wallet = {
192
+ address: embeddedWalletVerifiedCredential.address,
193
+ authenticated: false,
194
+ chain: embeddedWalletVerifiedCredential.chain,
195
+ connected: true,
196
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
197
+ // @ts-ignore
198
+ connector: undefined,
199
+ id: embeddedWalletVerifiedCredential.id,
200
+ };
201
+ dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, updateUserProfileResponse.jwt);
202
+ }
203
+ if (isUsingPregeneratedWallets || isManualMode) {
204
+ setShowAuthFlow(false);
205
+ return;
206
+ }
181
207
  }
182
208
  // this function will check turnkey wallet enabled and create wallet if needed
183
209
  // if not enabled, it will throw an error.
@@ -213,7 +239,6 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
213
239
  hasTurnkeyVerifiedCredentialAuthenticator,
214
240
  hasRecoveryEmail,
215
241
  isTurnkeyProviderEnabled,
216
- (_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,
217
242
  createEmbeddedWallet,
218
243
  setOnboardingOnlyJwt,
219
244
  setView,
@@ -222,10 +247,12 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
222
247
  setUser,
223
248
  addRecoveryEmail,
224
249
  setShowAuthFlow,
250
+ (_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,
251
+ (_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,
225
252
  setErrorMessage,
226
253
  ]);
227
254
  const handleEmailLogin = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
228
- var _h, _j;
255
+ var _p, _q;
229
256
  setError(undefined);
230
257
  setLoading(true);
231
258
  if (!verificationUUID) {
@@ -260,7 +287,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
260
287
  yield sleepToShowSuccessMessage();
261
288
  yield createUserProfileByJWT(jwt, minifiedJwt);
262
289
  if (isTurnkeyProviderEnabled &&
263
- !((_j = (_h = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _h === void 0 ? void 0 : _h.embeddedWallets) === null || _j === void 0 ? void 0 : _j.automaticEmbeddedWalletCreation)) {
290
+ !((_q = (_p = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _p === void 0 ? void 0 : _p.embeddedWallets) === null || _q === void 0 ? void 0 : _q.automaticEmbeddedWalletCreation)) {
264
291
  setShowAuthFlow(false);
265
292
  return;
266
293
  }
@@ -293,7 +320,7 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
293
320
  setCallback,
294
321
  createUserProfileByJWT,
295
322
  isTurnkeyProviderEnabled,
296
- (_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.automaticEmbeddedWalletCreation,
323
+ (_f = (_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _e === void 0 ? void 0 : _e.embeddedWallets) === null || _f === void 0 ? void 0 : _f.automaticEmbeddedWalletCreation,
297
324
  createEmbeddedWallet,
298
325
  setOnboardingOnlyJwt,
299
326
  setView,
@@ -89,10 +89,9 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
89
89
  var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
90
90
 
91
91
  const PasskeyIntroView = () => {
92
- var _a, _b, _c;
93
- const { walletConnectorOptions, environmentId, handleLogOut, onboardingOnlyJwt, projectSettings, decodedAuthToken, } = useInternalDynamicContext.useInternalDynamicContext();
94
- const allowSkippingAuthenticatorAtSignup = (_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.allowSkippingAuthenticatorAtSignup;
95
- const isEmailRecoveryFlow = ((_c = decodedAuthToken === null || decodedAuthToken === void 0 ? void 0 : decodedAuthToken.verifiedCredentials) === null || _c === void 0 ? void 0 : _c.length) === 1 &&
92
+ var _a;
93
+ const { walletConnectorOptions, environmentId, handleLogOut, onboardingOnlyJwt, decodedAuthToken, } = useInternalDynamicContext.useInternalDynamicContext();
94
+ const isEmailRecoveryFlow = ((_a = decodedAuthToken === null || decodedAuthToken === void 0 ? void 0 : decodedAuthToken.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
96
95
  !getUserVerifiedCredentialType.getUserVerifiedCredentialType(decodedAuthToken, sdkApiCore.JwtVerifiedCredentialFormatEnum.Email);
97
96
  const { t } = reactI18next.useTranslation();
98
97
  // TODO(GVTY-1137): send a metric when we detect passkeys are not enabled by the browser/device
@@ -104,8 +103,8 @@ const PasskeyIntroView = () => {
104
103
  React.useEffect(() => localStorage.LocalStorage.removeFromLS(localStorage$1.LAST_USED_WALLET), []);
105
104
  const { createDynamicEmbeddedWalletMutation, isLoading, error } = useCreateDynamicEmbeddedWalletMutation.useCreateDynamicEmbeddedWalletMutation();
106
105
  const handleCreateEmbeddedWallet = (withAuthenticator) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
107
- var _d;
108
- const jwt = (_d = getAuthToken.getAuthToken()) !== null && _d !== void 0 ? _d : onboardingOnlyJwt;
106
+ var _b;
107
+ const jwt = (_b = getAuthToken.getAuthToken()) !== null && _b !== void 0 ? _b : onboardingOnlyJwt;
109
108
  const decodedJwt = decodeJwt.decodeJwt(jwt);
110
109
  if (!jwt || !decodedJwt) {
111
110
  throw new Error('User is not logged in');
@@ -130,7 +129,7 @@ const PasskeyIntroView = () => {
130
129
  }, [error]);
131
130
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', copykey: 'dyn_passkey_intro.title', children: t('dyn_passkey_intro.title') }) }), jsxRuntime.jsxs("div", { className: 'passkey-intro-view', children: [jsxRuntime.jsx("div", { className: 'passkey-intro-view__header', children: jsxRuntime.jsx(passkeyIntro2.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', copykey: 'dyn_passkey_intro.subtitle', children: t('dyn_passkey_intro.subtitle') }), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsx(AuthChoiceInfo.AuthChoiceInfo, { choice: 'passkey', variant: isEmailRecoveryFlow ? 'noEmailSignup' : 'default' }), jsxRuntime.jsxs("div", { className: 'passkey-intro-view__actions', children: [jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'large', onClick: () => handleCreateEmbeddedWallet(true), dataTestId: 'setup-passkey-button', loading: isLoading && createWalletWithAuthenticator, disabled: isLoading, typographyProps: {
132
131
  color: 'inherit',
133
- }, children: jsxRuntime.jsxs("div", { className: 'passkey-intro-view__inline-button', children: [jsxRuntime.jsx(PasskeyDeviceIcon.PasskeyDeviceIcon, { size: 'small' }), jsxRuntime.jsx(Typography.Typography, { copykey: 'dyn_passkey_intro.button', children: t('dyn_passkey_intro.button') })] }) }), allowSkippingAuthenticatorAtSignup && !isEmailRecoveryFlow ? (jsxRuntime.jsx(TextButton.TextButton, { "data-testid": 'setup-passkey-skip-button', className: 'passkey-intro-view__skip', onClick: () => handleCreateEmbeddedWallet(false), copykey: 'dyn_passkey_intro.button_skip', children: t('dyn_passkey_intro.button_skip') })) : (jsxRuntime.jsx(TextButton.TextButton, { "data-testid": 'setup-passkey-logout-button', className: 'passkey-intro-view__log-out', onClick: handleLogOut, copykey: 'dyn_passkey_intro.button_logout', children: t('dyn_passkey_intro.button_logout') }))] })] })] }));
132
+ }, children: jsxRuntime.jsxs("div", { className: 'passkey-intro-view__inline-button', children: [jsxRuntime.jsx(PasskeyDeviceIcon.PasskeyDeviceIcon, { size: 'small' }), jsxRuntime.jsx(Typography.Typography, { copykey: 'dyn_passkey_intro.button', children: t('dyn_passkey_intro.button') })] }) }), jsxRuntime.jsx(TextButton.TextButton, { "data-testid": 'setup-passkey-logout-button', className: 'passkey-intro-view__log-out', onClick: handleLogOut, copykey: 'dyn_passkey_intro.button_logout', children: t('dyn_passkey_intro.button_logout') })] })] })] }));
134
133
  };
135
134
 
136
135
  exports.PasskeyIntroView = PasskeyIntroView;
@@ -85,10 +85,9 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
85
85
  import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
86
86
 
87
87
  const PasskeyIntroView = () => {
88
- var _a, _b, _c;
89
- const { walletConnectorOptions, environmentId, handleLogOut, onboardingOnlyJwt, projectSettings, decodedAuthToken, } = useInternalDynamicContext();
90
- const allowSkippingAuthenticatorAtSignup = (_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.allowSkippingAuthenticatorAtSignup;
91
- const isEmailRecoveryFlow = ((_c = decodedAuthToken === null || decodedAuthToken === void 0 ? void 0 : decodedAuthToken.verifiedCredentials) === null || _c === void 0 ? void 0 : _c.length) === 1 &&
88
+ var _a;
89
+ const { walletConnectorOptions, environmentId, handleLogOut, onboardingOnlyJwt, decodedAuthToken, } = useInternalDynamicContext();
90
+ const isEmailRecoveryFlow = ((_a = decodedAuthToken === null || decodedAuthToken === void 0 ? void 0 : decodedAuthToken.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
92
91
  !getUserVerifiedCredentialType(decodedAuthToken, JwtVerifiedCredentialFormatEnum.Email);
93
92
  const { t } = useTranslation();
94
93
  // TODO(GVTY-1137): send a metric when we detect passkeys are not enabled by the browser/device
@@ -100,8 +99,8 @@ const PasskeyIntroView = () => {
100
99
  useEffect(() => LocalStorage.removeFromLS(LAST_USED_WALLET), []);
101
100
  const { createDynamicEmbeddedWalletMutation, isLoading, error } = useCreateDynamicEmbeddedWalletMutation();
102
101
  const handleCreateEmbeddedWallet = (withAuthenticator) => __awaiter(void 0, void 0, void 0, function* () {
103
- var _d;
104
- const jwt = (_d = getAuthToken()) !== null && _d !== void 0 ? _d : onboardingOnlyJwt;
102
+ var _b;
103
+ const jwt = (_b = getAuthToken()) !== null && _b !== void 0 ? _b : onboardingOnlyJwt;
105
104
  const decodedJwt = decodeJwt(jwt);
106
105
  if (!jwt || !decodedJwt) {
107
106
  throw new Error('User is not logged in');
@@ -126,7 +125,7 @@ const PasskeyIntroView = () => {
126
125
  }, [error]);
127
126
  return (jsxs(Fragment, { children: [jsx(ModalHeader, { children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', copykey: 'dyn_passkey_intro.title', children: t('dyn_passkey_intro.title') }) }), jsxs("div", { className: 'passkey-intro-view', children: [jsx("div", { className: 'passkey-intro-view__header', children: jsx(SvgPasskeyIntro2, {}) }), jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', copykey: 'dyn_passkey_intro.subtitle', children: t('dyn_passkey_intro.subtitle') }), errorText && jsx(ErrorContainer, { children: errorText }), jsx(AuthChoiceInfo, { choice: 'passkey', variant: isEmailRecoveryFlow ? 'noEmailSignup' : 'default' }), jsxs("div", { className: 'passkey-intro-view__actions', children: [jsx(TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'large', onClick: () => handleCreateEmbeddedWallet(true), dataTestId: 'setup-passkey-button', loading: isLoading && createWalletWithAuthenticator, disabled: isLoading, typographyProps: {
128
127
  color: 'inherit',
129
- }, children: jsxs("div", { className: 'passkey-intro-view__inline-button', children: [jsx(PasskeyDeviceIcon, { size: 'small' }), jsx(Typography, { copykey: 'dyn_passkey_intro.button', children: t('dyn_passkey_intro.button') })] }) }), allowSkippingAuthenticatorAtSignup && !isEmailRecoveryFlow ? (jsx(TextButton, { "data-testid": 'setup-passkey-skip-button', className: 'passkey-intro-view__skip', onClick: () => handleCreateEmbeddedWallet(false), copykey: 'dyn_passkey_intro.button_skip', children: t('dyn_passkey_intro.button_skip') })) : (jsx(TextButton, { "data-testid": 'setup-passkey-logout-button', className: 'passkey-intro-view__log-out', onClick: handleLogOut, copykey: 'dyn_passkey_intro.button_logout', children: t('dyn_passkey_intro.button_logout') }))] })] })] }));
128
+ }, children: jsxs("div", { className: 'passkey-intro-view__inline-button', children: [jsx(PasskeyDeviceIcon, { size: 'small' }), jsx(Typography, { copykey: 'dyn_passkey_intro.button', children: t('dyn_passkey_intro.button') })] }) }), jsx(TextButton, { "data-testid": 'setup-passkey-logout-button', className: 'passkey-intro-view__log-out', onClick: handleLogOut, copykey: 'dyn_passkey_intro.button_logout', children: t('dyn_passkey_intro.button_logout') })] })] })] }));
130
129
  };
131
130
 
132
131
  export { PasskeyIntroView };
@@ -0,0 +1,16 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
7
+
8
+ const findPrimaryEmbeddedChain = (projectSettings) => {
9
+ var _a, _b, _c;
10
+ const embeddedChainConfig = ((_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.chainConfigurations) || [];
11
+ return ((_c = embeddedChainConfig.find((chain) => chain.primary)) === null || _c === void 0 ? void 0 : _c.name) === 'SOL'
12
+ ? sdkApiCore.ChainEnum.Sol
13
+ : sdkApiCore.ChainEnum.Evm;
14
+ };
15
+
16
+ exports.findPrimaryEmbeddedChain = findPrimaryEmbeddedChain;
@@ -0,0 +1,2 @@
1
+ import { ChainEnum, ProjectSettings } from '@dynamic-labs/sdk-api-core';
2
+ export declare const findPrimaryEmbeddedChain: (projectSettings?: ProjectSettings) => ChainEnum;
@@ -0,0 +1,12 @@
1
+ 'use client'
2
+ import { ChainEnum } from '@dynamic-labs/sdk-api-core';
3
+
4
+ const findPrimaryEmbeddedChain = (projectSettings) => {
5
+ var _a, _b, _c;
6
+ const embeddedChainConfig = ((_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.chainConfigurations) || [];
7
+ return ((_c = embeddedChainConfig.find((chain) => chain.primary)) === null || _c === void 0 ? void 0 : _c.name) === 'SOL'
8
+ ? ChainEnum.Sol
9
+ : ChainEnum.Evm;
10
+ };
11
+
12
+ export { findPrimaryEmbeddedChain };
@@ -0,0 +1 @@
1
+ export { findPrimaryEmbeddedChain } from './findPrimaryEmbeddedChain';