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

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 CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ ## [2.1.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.4...v2.1.0-alpha.5) (2024-04-23)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * get embedded wallet checking the wrong chain enum ([#5458](https://github.com/dynamic-labs/DynamicAuth/issues/5458)) ([ed1c523](https://github.com/dynamic-labs/DynamicAuth/commit/ed1c523ca14cd4d21c00181ab40802f876c02b80))
8
+
2
9
  ## [2.1.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.3...v2.1.0-alpha.4) (2024-04-23)
3
10
 
4
11
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "2.1.0-alpha.4";
6
+ var version = "2.1.0-alpha.5";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.425",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "2.1.0-alpha.4";
2
+ var version = "2.1.0-alpha.5";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.425",
5
5
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "2.1.0-alpha.4",
3
+ "version": "2.1.0-alpha.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -17,17 +17,17 @@
17
17
  "react-i18next": "13.5.0",
18
18
  "yup": "0.32.11",
19
19
  "react-international-phone": "4.2.5",
20
- "@dynamic-labs/iconic": "2.1.0-alpha.4",
21
- "@dynamic-labs/logger": "2.1.0-alpha.4",
22
- "@dynamic-labs/multi-wallet": "2.1.0-alpha.4",
23
- "@dynamic-labs/rpc-provider-ethereum": "2.1.0-alpha.4",
24
- "@dynamic-labs/rpc-provider-solana": "2.1.0-alpha.4",
25
- "@dynamic-labs/rpc-providers": "2.1.0-alpha.4",
26
- "@dynamic-labs/types": "2.1.0-alpha.4",
27
- "@dynamic-labs/utils": "2.1.0-alpha.4",
28
- "@dynamic-labs/viem-utils": "2.1.0-alpha.4",
29
- "@dynamic-labs/wallet-book": "2.1.0-alpha.4",
30
- "@dynamic-labs/wallet-connector-core": "2.1.0-alpha.4",
20
+ "@dynamic-labs/iconic": "2.1.0-alpha.5",
21
+ "@dynamic-labs/logger": "2.1.0-alpha.5",
22
+ "@dynamic-labs/multi-wallet": "2.1.0-alpha.5",
23
+ "@dynamic-labs/rpc-provider-ethereum": "2.1.0-alpha.5",
24
+ "@dynamic-labs/rpc-provider-solana": "2.1.0-alpha.5",
25
+ "@dynamic-labs/rpc-providers": "2.1.0-alpha.5",
26
+ "@dynamic-labs/types": "2.1.0-alpha.5",
27
+ "@dynamic-labs/utils": "2.1.0-alpha.5",
28
+ "@dynamic-labs/viem-utils": "2.1.0-alpha.5",
29
+ "@dynamic-labs/wallet-book": "2.1.0-alpha.5",
30
+ "@dynamic-labs/wallet-connector-core": "2.1.0-alpha.5",
31
31
  "eventemitter3": "5.0.1"
32
32
  },
33
33
  "devDependencies": {
@@ -17,7 +17,8 @@ const findTurnkeyWalletByPrimaryChain = (walletOptions, chainConfigurations, ver
17
17
  var _a;
18
18
  const primaryEmbeddedChain = ((_a = chainConfigurations === null || chainConfigurations === void 0 ? void 0 : chainConfigurations.find((chain) => chain.primary)) === null || _a === void 0 ? void 0 : _a.name) || sdkApiCore.ChainEnum.Evm;
19
19
  const walletConnector = findTurnkeyWalletByChain(walletOptions, values.ChainEnumToVerifiedCredentialName[primaryEmbeddedChain]);
20
- const turnkeyVC = verifiedCredentials === null || verifiedCredentials === void 0 ? void 0 : verifiedCredentials.find(({ walletName, chain }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && chain === primaryEmbeddedChain);
20
+ const turnkeyVC = verifiedCredentials === null || verifiedCredentials === void 0 ? void 0 : verifiedCredentials.find(({ walletName, chain }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) &&
21
+ chain === values.ChainEnumToVerifiedCredentialName[primaryEmbeddedChain]);
21
22
  if (!turnkeyVC || !walletConnector) {
22
23
  return undefined;
23
24
  }
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { ChainEnum } from '@dynamic-labs/sdk-api-core';
3
3
  import '@dynamic-labs/utils';
4
- import { VerifiedCredentialNameToChainEnum, ChainEnumToVerifiedCredentialName } from '../../constants/values.js';
4
+ import { ChainEnumToVerifiedCredentialName, VerifiedCredentialNameToChainEnum } from '../../constants/values.js';
5
5
 
6
6
  const findTurnkeyWalletByChain = (walletOptions, chainName) => {
7
7
  const chain = chainName
@@ -13,7 +13,8 @@ const findTurnkeyWalletByPrimaryChain = (walletOptions, chainConfigurations, ver
13
13
  var _a;
14
14
  const primaryEmbeddedChain = ((_a = chainConfigurations === null || chainConfigurations === void 0 ? void 0 : chainConfigurations.find((chain) => chain.primary)) === null || _a === void 0 ? void 0 : _a.name) || ChainEnum.Evm;
15
15
  const walletConnector = findTurnkeyWalletByChain(walletOptions, ChainEnumToVerifiedCredentialName[primaryEmbeddedChain]);
16
- const turnkeyVC = verifiedCredentials === null || verifiedCredentials === void 0 ? void 0 : verifiedCredentials.find(({ walletName, chain }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && chain === primaryEmbeddedChain);
16
+ const turnkeyVC = verifiedCredentials === null || verifiedCredentials === void 0 ? void 0 : verifiedCredentials.find(({ walletName, chain }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) &&
17
+ chain === ChainEnumToVerifiedCredentialName[primaryEmbeddedChain]);
17
18
  if (!turnkeyVC || !walletConnector) {
18
19
  return undefined;
19
20
  }
@@ -38,6 +38,7 @@ var createEmbeddedWalletWithPasskey = require('../../../views/Passkey/utils/crea
38
38
  var findPasskeyEmailWalletConnector = require('../../../views/Passkey/utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.cjs');
39
39
  var createPregeneratedWallet = require('../../../views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.cjs');
40
40
  var smartWallet = require('../useWalletConnectors/utils/smartWallet/smartWallet.cjs');
41
+ var findPrimaryEmbeddedChain = require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
41
42
  require('../../../context/WalletContext/WalletContext.cjs');
42
43
  require('../../../context/ThemeContext/ThemeContext.cjs');
43
44
  require('@dynamic-labs/types');
@@ -82,19 +83,17 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
82
83
 
83
84
  // This hook needs to be async that's why it's not using useMutation
84
85
  const useCreateDynamicEmbeddedWalletMutation = () => {
85
- var _a, _b, _c;
86
+ var _a, _b;
86
87
  const { setPrimaryWalletId, setCallback, setUser, user, setShowAuthFlow, projectSettings, } = useInternalDynamicContext.useInternalDynamicContext();
87
88
  const [isLoading, setIsLoading] = React.useState(false);
88
89
  const [error, setError] = React.useState();
89
90
  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) || [];
90
- const primaryEmbeddedChain = ((_c = embeddedChainConfig.find((chain) => chain.primary)) === null || _c === void 0 ? void 0 : _c.name) === 'SOL'
91
- ? sdkApiCore.ChainEnum.Sol
92
- : sdkApiCore.ChainEnum.Evm;
91
+ const primaryEmbeddedChain = findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings);
93
92
  const embeddedChains = embeddedChainConfig
94
93
  .filter((chain) => chain.enabled)
95
94
  .map((c) => (c.name === 'SOL' ? sdkApiCore.ChainEnum.Sol : sdkApiCore.ChainEnum.Evm));
96
- const createDynamicEmbeddedWalletMutation = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ authToken, decodedJwt, environmentId, walletConnectorOptions, withAuthenticator, }) {
97
- var _e, _f;
95
+ const createDynamicEmbeddedWalletMutation = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ authToken, decodedJwt, environmentId, walletConnectorOptions, withAuthenticator, }) {
96
+ var _d, _e;
98
97
  setIsLoading(true);
99
98
  const createEmbeddedWalletMethodToUse = withAuthenticator
100
99
  ? createEmbeddedWalletWithPasskey.createEmbeddedWalletWithPasskey
@@ -107,9 +106,9 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
107
106
  user: user !== null && user !== void 0 ? user : createUserProfile.createUserProfile(decodedJwt),
108
107
  walletConnector: findPasskeyEmailWalletConnector.findPasskeyEmailWalletConnector(walletConnectorOptions, primaryEmbeddedChain),
109
108
  });
110
- const turnkeyVerifiedCredentials = (_e = updatedDecodedJwt === null || updatedDecodedJwt === void 0 ? void 0 : updatedDecodedJwt.verifiedCredentials) === null || _e === void 0 ? void 0 : _e.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
109
+ const turnkeyVerifiedCredentials = (_d = updatedDecodedJwt === null || updatedDecodedJwt === void 0 ? void 0 : updatedDecodedJwt.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
111
110
  /** It's not authenticated if it's a turnkey wallet that still hasn't created a passkey */
112
- const authenticated = Boolean((_f = turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.walletProperties) === null || _f === void 0 ? void 0 : _f.isAuthenticatorAttached);
111
+ const authenticated = Boolean((_e = turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.walletProperties) === null || _e === void 0 ? void 0 : _e.isAuthenticatorAttached);
113
112
  const passkeyWallet = {
114
113
  address: (yield walletConnector.getAddress()) || '',
115
114
  authenticated,
@@ -34,6 +34,7 @@ import { createEmbeddedWalletWithPasskey } from '../../../views/Passkey/utils/cr
34
34
  import { findPasskeyEmailWalletConnector } from '../../../views/Passkey/utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.js';
35
35
  import { createPregeneratedWallet } from '../../../views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.js';
36
36
  import { findSmartWallet, initializeSmartWallet } from '../useWalletConnectors/utils/smartWallet/smartWallet.js';
37
+ import { findPrimaryEmbeddedChain } from '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
37
38
  import '../../../context/WalletContext/WalletContext.js';
38
39
  import '../../../context/ThemeContext/ThemeContext.js';
39
40
  import '@dynamic-labs/types';
@@ -78,19 +79,17 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
78
79
 
79
80
  // This hook needs to be async that's why it's not using useMutation
80
81
  const useCreateDynamicEmbeddedWalletMutation = () => {
81
- var _a, _b, _c;
82
+ var _a, _b;
82
83
  const { setPrimaryWalletId, setCallback, setUser, user, setShowAuthFlow, projectSettings, } = useInternalDynamicContext();
83
84
  const [isLoading, setIsLoading] = useState(false);
84
85
  const [error, setError] = useState();
85
86
  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) || [];
86
- const primaryEmbeddedChain = ((_c = embeddedChainConfig.find((chain) => chain.primary)) === null || _c === void 0 ? void 0 : _c.name) === 'SOL'
87
- ? ChainEnum.Sol
88
- : ChainEnum.Evm;
87
+ const primaryEmbeddedChain = findPrimaryEmbeddedChain(projectSettings);
89
88
  const embeddedChains = embeddedChainConfig
90
89
  .filter((chain) => chain.enabled)
91
90
  .map((c) => (c.name === 'SOL' ? ChainEnum.Sol : ChainEnum.Evm));
92
- const createDynamicEmbeddedWalletMutation = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ authToken, decodedJwt, environmentId, walletConnectorOptions, withAuthenticator, }) {
93
- var _e, _f;
91
+ const createDynamicEmbeddedWalletMutation = useCallback((_c) => __awaiter(void 0, [_c], void 0, function* ({ authToken, decodedJwt, environmentId, walletConnectorOptions, withAuthenticator, }) {
92
+ var _d, _e;
94
93
  setIsLoading(true);
95
94
  const createEmbeddedWalletMethodToUse = withAuthenticator
96
95
  ? createEmbeddedWalletWithPasskey
@@ -103,9 +102,9 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
103
102
  user: user !== null && user !== void 0 ? user : createUserProfile(decodedJwt),
104
103
  walletConnector: findPasskeyEmailWalletConnector(walletConnectorOptions, primaryEmbeddedChain),
105
104
  });
106
- const turnkeyVerifiedCredentials = (_e = updatedDecodedJwt === null || updatedDecodedJwt === void 0 ? void 0 : updatedDecodedJwt.verifiedCredentials) === null || _e === void 0 ? void 0 : _e.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
105
+ const turnkeyVerifiedCredentials = (_d = updatedDecodedJwt === null || updatedDecodedJwt === void 0 ? void 0 : updatedDecodedJwt.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
107
106
  /** It's not authenticated if it's a turnkey wallet that still hasn't created a passkey */
108
- const authenticated = Boolean((_f = turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.walletProperties) === null || _f === void 0 ? void 0 : _f.isAuthenticatorAttached);
107
+ const authenticated = Boolean((_e = turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.walletProperties) === null || _e === void 0 ? void 0 : _e.isAuthenticatorAttached);
109
108
  const passkeyWallet = {
110
109
  address: (yield walletConnector.getAddress()) || '',
111
110
  authenticated,
@@ -40,6 +40,8 @@ require('react-dom');
40
40
  var useCreateDynamicEmbeddedWalletMutation = require('../../../useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs');
41
41
  require('../../../../../context/WalletContext/WalletContext.cjs');
42
42
  var smartWallet = require('../../../useWalletConnectors/utils/smartWallet/smartWallet.cjs');
43
+ var findPrimaryEmbeddedChain = require('../../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
44
+ var findPasskeyEmailWalletConnector = require('../../../../../views/Passkey/utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.cjs');
43
45
  require('../../../../../context/ThemeContext/ThemeContext.cjs');
44
46
  require('@dynamic-labs/types');
45
47
  require('yup');
@@ -160,26 +162,46 @@ const useTurnkey = () => {
160
162
  return Promise.resolve(passkeyWallet);
161
163
  }), [setPrimaryWalletId, walletConnectorOptions]);
162
164
  const createTurnkeyWallet = React.useCallback((jwt, decodedJwt, chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
163
- var _e, _f;
165
+ var _e, _f, _g, _h;
164
166
  const isManualMode = ((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _e === void 0 ? void 0 : _e.automaticEmbeddedWalletCreation) === false;
165
167
  const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
166
- const userWaletsCredentials = getUserWalletsFromVerifiedCredentials.getUserWalletsFromVerifiedCredentials(jwt);
168
+ const userWalletsCredentials = getUserWalletsFromVerifiedCredentials.getUserWalletsFromVerifiedCredentials(jwt);
167
169
  // If the user doesn't have a wallet, or if the customer is in Manual
168
170
  // Mode, we should attempt to create a new wallet. Note that if in manual
169
171
  // mode, the check for the existance of an embedded wallet was arbitrarily
170
172
  // added as a safeguard given the pre-existing condition we're overriding.
171
- if (!(userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.length) ||
173
+ if (!(userWalletsCredentials === null || userWalletsCredentials === void 0 ? void 0 : userWalletsCredentials.length) ||
172
174
  (!embeddedWalletVerifiedCredential && isManualMode)) {
173
175
  const hasEmailVC = getUserVerifiedCredentialType.getUserVerifiedCredentialType(decodedJwt, sdkApiCore.JwtVerifiedCredentialFormatEnum.Email);
174
- // create wallet without authenticator
175
- // if users log in and doesn't have an email vc they won't be able to use passkey recovery
176
- // and it means that they need to create it while creating a wallet
177
176
  if (!((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _f === void 0 ? void 0 : _f.forceAuthenticatorAtSignup) &&
178
- Boolean(hasEmailVC)) {
177
+ hasEmailVC) {
179
178
  return startPregeneratedWalletCreationFlow(jwt, decodedJwt);
180
179
  }
181
- // show the passkey view to create an embedded wallet
182
- return startEmbeddedWalletCreationFlow();
180
+ else {
181
+ // show the passkey view to create an embedded wallet
182
+ return startEmbeddedWalletCreationFlow();
183
+ }
184
+ }
185
+ else {
186
+ // the pregenerated wallet must have been created at this point in the
187
+ // backend if this called as part of a new user sign up.
188
+ if (embeddedWalletVerifiedCredential &&
189
+ decodedJwt.newUser &&
190
+ ((_g = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _g === void 0 ? void 0 : _g.automaticEmbeddedWalletCreation)) {
191
+ const walletConnector = findPasskeyEmailWalletConnector.findPasskeyEmailWalletConnector(walletConnectorOptions, findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings));
192
+ if (!walletConnector) {
193
+ throw new Error('Could not find the Embedded wallet connector');
194
+ }
195
+ const wallet = {
196
+ address: (yield walletConnector.getAddress()) || '',
197
+ authenticated: Boolean((_h = embeddedWalletVerifiedCredential === null || embeddedWalletVerifiedCredential === void 0 ? void 0 : embeddedWalletVerifiedCredential.walletProperties) === null || _h === void 0 ? void 0 : _h.isAuthenticatorAttached),
198
+ chain: walletConnector.connectedChain || '',
199
+ connected: true,
200
+ connector: walletConnector,
201
+ id: embeddedWalletVerifiedCredential.id,
202
+ };
203
+ dynamicEvents.dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, jwt);
204
+ }
183
205
  }
184
206
  setShowAuthFlow(false, { performMultiWalletChecks: false });
185
207
  // if user logged in with MM for example, just continue the flow
@@ -36,6 +36,8 @@ import 'react-dom';
36
36
  import { useCreateDynamicEmbeddedWalletMutation } from '../../../useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js';
37
37
  import '../../../../../context/WalletContext/WalletContext.js';
38
38
  import { findSmartWallet, initializeSmartWallet } from '../../../useWalletConnectors/utils/smartWallet/smartWallet.js';
39
+ import { findPrimaryEmbeddedChain } from '../../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
40
+ import { findPasskeyEmailWalletConnector } from '../../../../../views/Passkey/utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.js';
39
41
  import '../../../../../context/ThemeContext/ThemeContext.js';
40
42
  import '@dynamic-labs/types';
41
43
  import 'yup';
@@ -156,26 +158,46 @@ const useTurnkey = () => {
156
158
  return Promise.resolve(passkeyWallet);
157
159
  }), [setPrimaryWalletId, walletConnectorOptions]);
158
160
  const createTurnkeyWallet = useCallback((jwt, decodedJwt, chain) => __awaiter(void 0, void 0, void 0, function* () {
159
- var _e, _f;
161
+ var _e, _f, _g, _h;
160
162
  const isManualMode = ((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _e === void 0 ? void 0 : _e.automaticEmbeddedWalletCreation) === false;
161
163
  const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
162
- const userWaletsCredentials = getUserWalletsFromVerifiedCredentials(jwt);
164
+ const userWalletsCredentials = getUserWalletsFromVerifiedCredentials(jwt);
163
165
  // If the user doesn't have a wallet, or if the customer is in Manual
164
166
  // Mode, we should attempt to create a new wallet. Note that if in manual
165
167
  // mode, the check for the existance of an embedded wallet was arbitrarily
166
168
  // added as a safeguard given the pre-existing condition we're overriding.
167
- if (!(userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.length) ||
169
+ if (!(userWalletsCredentials === null || userWalletsCredentials === void 0 ? void 0 : userWalletsCredentials.length) ||
168
170
  (!embeddedWalletVerifiedCredential && isManualMode)) {
169
171
  const hasEmailVC = getUserVerifiedCredentialType(decodedJwt, JwtVerifiedCredentialFormatEnum.Email);
170
- // create wallet without authenticator
171
- // if users log in and doesn't have an email vc they won't be able to use passkey recovery
172
- // and it means that they need to create it while creating a wallet
173
172
  if (!((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _f === void 0 ? void 0 : _f.forceAuthenticatorAtSignup) &&
174
- Boolean(hasEmailVC)) {
173
+ hasEmailVC) {
175
174
  return startPregeneratedWalletCreationFlow(jwt, decodedJwt);
176
175
  }
177
- // show the passkey view to create an embedded wallet
178
- return startEmbeddedWalletCreationFlow();
176
+ else {
177
+ // show the passkey view to create an embedded wallet
178
+ return startEmbeddedWalletCreationFlow();
179
+ }
180
+ }
181
+ else {
182
+ // the pregenerated wallet must have been created at this point in the
183
+ // backend if this called as part of a new user sign up.
184
+ if (embeddedWalletVerifiedCredential &&
185
+ decodedJwt.newUser &&
186
+ ((_g = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _g === void 0 ? void 0 : _g.automaticEmbeddedWalletCreation)) {
187
+ const walletConnector = findPasskeyEmailWalletConnector(walletConnectorOptions, findPrimaryEmbeddedChain(projectSettings));
188
+ if (!walletConnector) {
189
+ throw new Error('Could not find the Embedded wallet connector');
190
+ }
191
+ const wallet = {
192
+ address: (yield walletConnector.getAddress()) || '',
193
+ authenticated: Boolean((_h = embeddedWalletVerifiedCredential === null || embeddedWalletVerifiedCredential === void 0 ? void 0 : embeddedWalletVerifiedCredential.walletProperties) === null || _h === void 0 ? void 0 : _h.isAuthenticatorAttached),
194
+ chain: walletConnector.connectedChain || '',
195
+ connected: true,
196
+ connector: walletConnector,
197
+ id: embeddedWalletVerifiedCredential.id,
198
+ };
199
+ dynamicEvents.emit('embeddedWalletCreated', wallet, embeddedWalletVerifiedCredential, jwt);
200
+ }
179
201
  }
180
202
  setShowAuthFlow(false, { performMultiWalletChecks: false });
181
203
  // if user logged in with MM for example, just continue the flow
@@ -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';