@dynamic-labs/sdk-react-core 3.4.1 → 3.4.2
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 +9 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +5 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +5 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +5 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +5 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +3 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +3 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.cjs +3 -2
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
|
|
2
|
+
### [3.4.2](https://github.com/dynamic-labs/DynamicAuth/compare/v3.4.1...v3.4.2) (2024-10-18)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* improve displayed chain name in network switcher ([#7153](https://github.com/dynamic-labs/DynamicAuth/issues/7153)) ([#7160](https://github.com/dynamic-labs/DynamicAuth/issues/7160)) ([838f0ed](https://github.com/dynamic-labs/DynamicAuth/commit/838f0edcda86080459e8aa1dffcdb36e3aa73f1b))
|
|
8
|
+
* surface relevant error message when social pop-up blocked by browser ([#7158](https://github.com/dynamic-labs/DynamicAuth/issues/7158)) ([663e81f](https://github.com/dynamic-labs/DynamicAuth/commit/663e81f45c1ab0c091690dab21a9cafb7f0cccde))
|
|
9
|
+
* use embedded primaryChain when passing undefined chains list to createTurnkeyWallet ([#7156](https://github.com/dynamic-labs/DynamicAuth/issues/7156)) ([f023092](https://github.com/dynamic-labs/DynamicAuth/commit/f023092b3fecef76bcee144632c63a149e5e432f))
|
|
10
|
+
|
|
2
11
|
### [3.4.1](https://github.com/dynamic-labs/DynamicAuth/compare/v3.4.0...v3.4.1) (2024-10-17)
|
|
3
12
|
|
|
4
13
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/assert-package-version": "3.4.
|
|
21
|
-
"@dynamic-labs/iconic": "3.4.
|
|
22
|
-
"@dynamic-labs/logger": "3.4.
|
|
23
|
-
"@dynamic-labs/multi-wallet": "3.4.
|
|
24
|
-
"@dynamic-labs/rpc-providers": "3.4.
|
|
25
|
-
"@dynamic-labs/store": "3.4.
|
|
26
|
-
"@dynamic-labs/types": "3.4.
|
|
27
|
-
"@dynamic-labs/utils": "3.4.
|
|
28
|
-
"@dynamic-labs/wallet-book": "3.4.
|
|
29
|
-
"@dynamic-labs/wallet-connector-core": "3.4.
|
|
20
|
+
"@dynamic-labs/assert-package-version": "3.4.2",
|
|
21
|
+
"@dynamic-labs/iconic": "3.4.2",
|
|
22
|
+
"@dynamic-labs/logger": "3.4.2",
|
|
23
|
+
"@dynamic-labs/multi-wallet": "3.4.2",
|
|
24
|
+
"@dynamic-labs/rpc-providers": "3.4.2",
|
|
25
|
+
"@dynamic-labs/store": "3.4.2",
|
|
26
|
+
"@dynamic-labs/types": "3.4.2",
|
|
27
|
+
"@dynamic-labs/utils": "3.4.2",
|
|
28
|
+
"@dynamic-labs/wallet-book": "3.4.2",
|
|
29
|
+
"@dynamic-labs/wallet-connector-core": "3.4.2",
|
|
30
30
|
"eventemitter3": "5.0.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -45,6 +45,7 @@ var errors = require('../../../constants/errors.cjs');
|
|
|
45
45
|
require('../../../../context/VerificationContext/VerificationContext.cjs');
|
|
46
46
|
require('react-dom');
|
|
47
47
|
var useElementById = require('../../useElementById/useElementById.cjs');
|
|
48
|
+
var findPrimaryEmbeddedChain = require('../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
48
49
|
var WalletContext = require('../../../../context/WalletContext/WalletContext.cjs');
|
|
49
50
|
var useIsTurnkeyWallet = require('../../useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
50
51
|
var turnkeyExport = require('../../../../views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs');
|
|
@@ -151,7 +152,8 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
151
152
|
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
152
153
|
}
|
|
153
154
|
const userWalletsCredentials = getUserWalletsFromVerifiedCredentials.getUserWalletsFromVerifiedCredentials(user$1);
|
|
154
|
-
const
|
|
155
|
+
const primaryChain = findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings);
|
|
156
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(user$1, chains !== null && chains !== void 0 ? chains : [primaryChain]);
|
|
155
157
|
const isManualMode = ((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _e === void 0 ? void 0 : _e.automaticEmbeddedWalletCreation) === false;
|
|
156
158
|
// if user has a wallet and it's not embedded,
|
|
157
159
|
// throw error to follow another flow and set up the right wallet
|
|
@@ -177,7 +179,8 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
177
179
|
throw new Error(errors.USER_NOT_LOGGED_IN);
|
|
178
180
|
}
|
|
179
181
|
validateTurnkeyProviderEnabled.validateTurnkeyProviderEnabled(projectSettings);
|
|
180
|
-
const
|
|
182
|
+
const primaryChain = findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings);
|
|
183
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(user$1, [primaryChain]);
|
|
181
184
|
const turnkeyWalletId = (_g = embeddedWalletVerifiedCredential === null || embeddedWalletVerifiedCredential === void 0 ? void 0 : embeddedWalletVerifiedCredential.walletProperties) === null || _g === void 0 ? void 0 : _g.turnkeyHDWalletId;
|
|
182
185
|
if (!turnkeyWalletId) {
|
|
183
186
|
throw new utils.DynamicError('No HD wallet was found for this user to derive a wallet account. Use createEmbeddedWallet first', 'NoHdWalletFound');
|
|
@@ -41,6 +41,7 @@ import { USER_NOT_LOGGED_IN, ACTIVE_SESSION, SESSION_RESTORED, INVALID_REQUEST,
|
|
|
41
41
|
import '../../../../context/VerificationContext/VerificationContext.js';
|
|
42
42
|
import 'react-dom';
|
|
43
43
|
import { useElementById } from '../../useElementById/useElementById.js';
|
|
44
|
+
import { findPrimaryEmbeddedChain } from '../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
44
45
|
import { useWalletContext } from '../../../../context/WalletContext/WalletContext.js';
|
|
45
46
|
import { useIsTurnkeyWallet } from '../../useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
46
47
|
import { cleanupExport, initExport, exportCredential } from '../../../../views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js';
|
|
@@ -147,7 +148,8 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
147
148
|
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
148
149
|
}
|
|
149
150
|
const userWalletsCredentials = getUserWalletsFromVerifiedCredentials(user);
|
|
150
|
-
const
|
|
151
|
+
const primaryChain = findPrimaryEmbeddedChain(projectSettings);
|
|
152
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(user, chains !== null && chains !== void 0 ? chains : [primaryChain]);
|
|
151
153
|
const isManualMode = ((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _e === void 0 ? void 0 : _e.automaticEmbeddedWalletCreation) === false;
|
|
152
154
|
// if user has a wallet and it's not embedded,
|
|
153
155
|
// throw error to follow another flow and set up the right wallet
|
|
@@ -173,7 +175,8 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
173
175
|
throw new Error(USER_NOT_LOGGED_IN);
|
|
174
176
|
}
|
|
175
177
|
validateTurnkeyProviderEnabled(projectSettings);
|
|
176
|
-
const
|
|
178
|
+
const primaryChain = findPrimaryEmbeddedChain(projectSettings);
|
|
179
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(user, [primaryChain]);
|
|
177
180
|
const turnkeyWalletId = (_g = embeddedWalletVerifiedCredential === null || embeddedWalletVerifiedCredential === void 0 ? void 0 : embeddedWalletVerifiedCredential.walletProperties) === null || _g === void 0 ? void 0 : _g.turnkeyHDWalletId;
|
|
178
181
|
if (!turnkeyWalletId) {
|
|
179
182
|
throw new DynamicError('No HD wallet was found for this user to derive a wallet account. Use createEmbeddedWallet first', 'NoHdWalletFound');
|
|
@@ -193,7 +193,10 @@ const useTurnkey = () => {
|
|
|
193
193
|
const isManualMode = ((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation) === false;
|
|
194
194
|
const shouldCreateV2WalletsByDefault = ((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _d === void 0 ? void 0 : _d.defaultWalletVersion) ===
|
|
195
195
|
sdkApiCore.EmbeddedWalletVersionEnum.V2;
|
|
196
|
-
const
|
|
196
|
+
const primaryChain = findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings);
|
|
197
|
+
// if embedded wallet already exists
|
|
198
|
+
// get the one with the primary chain if `chains` is undefined
|
|
199
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(user, chains !== null && chains !== void 0 ? chains : [primaryChain]);
|
|
197
200
|
const userWalletsCredentials = getUserWalletsFromVerifiedCredentials.getUserWalletsFromVerifiedCredentials(user);
|
|
198
201
|
// If the user doesn't have a wallet, or if the customer is in Manual
|
|
199
202
|
// Mode, we should attempt to create a new wallet. Note that if in manual
|
|
@@ -220,7 +223,7 @@ const useTurnkey = () => {
|
|
|
220
223
|
if (embeddedWalletVerifiedCredential &&
|
|
221
224
|
user.newUser &&
|
|
222
225
|
((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _f === void 0 ? void 0 : _f.automaticEmbeddedWalletCreation)) {
|
|
223
|
-
const walletConnector = findPasskeyEmailWalletConnector.findPasskeyEmailWalletConnector(walletConnectorOptions,
|
|
226
|
+
const walletConnector = findPasskeyEmailWalletConnector.findPasskeyEmailWalletConnector(walletConnectorOptions, primaryChain);
|
|
224
227
|
if (!walletConnector) {
|
|
225
228
|
throw new Error('Could not find the embedded wallet connector');
|
|
226
229
|
}
|
|
@@ -189,7 +189,10 @@ const useTurnkey = () => {
|
|
|
189
189
|
const isManualMode = ((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation) === false;
|
|
190
190
|
const shouldCreateV2WalletsByDefault = ((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _d === void 0 ? void 0 : _d.defaultWalletVersion) ===
|
|
191
191
|
EmbeddedWalletVersionEnum.V2;
|
|
192
|
-
const
|
|
192
|
+
const primaryChain = findPrimaryEmbeddedChain(projectSettings);
|
|
193
|
+
// if embedded wallet already exists
|
|
194
|
+
// get the one with the primary chain if `chains` is undefined
|
|
195
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(user, chains !== null && chains !== void 0 ? chains : [primaryChain]);
|
|
193
196
|
const userWalletsCredentials = getUserWalletsFromVerifiedCredentials(user);
|
|
194
197
|
// If the user doesn't have a wallet, or if the customer is in Manual
|
|
195
198
|
// Mode, we should attempt to create a new wallet. Note that if in manual
|
|
@@ -216,7 +219,7 @@ const useTurnkey = () => {
|
|
|
216
219
|
if (embeddedWalletVerifiedCredential &&
|
|
217
220
|
user.newUser &&
|
|
218
221
|
((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _f === void 0 ? void 0 : _f.automaticEmbeddedWalletCreation)) {
|
|
219
|
-
const walletConnector = findPasskeyEmailWalletConnector(walletConnectorOptions,
|
|
222
|
+
const walletConnector = findPasskeyEmailWalletConnector(walletConnectorOptions, primaryChain);
|
|
220
223
|
if (!walletConnector) {
|
|
221
224
|
throw new Error('Could not find the embedded wallet connector');
|
|
222
225
|
}
|
|
@@ -45,6 +45,7 @@ require('../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
|
45
45
|
require('../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
46
46
|
var useOtpVerificationRequest = require('../../utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs');
|
|
47
47
|
require('react-dom');
|
|
48
|
+
var findPrimaryEmbeddedChain = require('../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
48
49
|
require('../../context/WalletContext/WalletContext.cjs');
|
|
49
50
|
var useIsTurnkeyWallet = require('../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
50
51
|
var usePasskeyRecovery = require('../../utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs');
|
|
@@ -181,11 +182,12 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
181
182
|
(!((_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.forceAuthenticatorAtSignup) ||
|
|
182
183
|
isSessionKeyCompatible));
|
|
183
184
|
if (isUsingPregeneratedWallets) {
|
|
185
|
+
const primaryChain = findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings);
|
|
184
186
|
// Pregenerated wallet was created during an
|
|
185
187
|
// additional email validation step as part of onboarding
|
|
186
188
|
// cannot rely on newUser JWT field here due to session being counted twice
|
|
187
189
|
// when authentication happens followed by a separate email kyc step
|
|
188
|
-
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(createUserProfile.createUserProfileFromSdkUser(updateUserProfileResponse.user));
|
|
190
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(createUserProfile.createUserProfileFromSdkUser(updateUserProfileResponse.user), [primaryChain]);
|
|
189
191
|
if (!embeddedWalletVerifiedCredential) {
|
|
190
192
|
throw new Error('Could not find an embedded wallet');
|
|
191
193
|
}
|
|
@@ -41,6 +41,7 @@ import '../../context/AccountExistsContext/AccountExistsContext.js';
|
|
|
41
41
|
import '../../context/UserWalletsContext/UserWalletsContext.js';
|
|
42
42
|
import { useOtpVerificationRequest } from '../../utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js';
|
|
43
43
|
import 'react-dom';
|
|
44
|
+
import { findPrimaryEmbeddedChain } from '../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
44
45
|
import '../../context/WalletContext/WalletContext.js';
|
|
45
46
|
import { useIsTurnkeyWallet } from '../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
46
47
|
import { usePasskeyRecovery } from '../../utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js';
|
|
@@ -177,11 +178,12 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
177
178
|
(!((_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.forceAuthenticatorAtSignup) ||
|
|
178
179
|
isSessionKeyCompatible));
|
|
179
180
|
if (isUsingPregeneratedWallets) {
|
|
181
|
+
const primaryChain = findPrimaryEmbeddedChain(projectSettings);
|
|
180
182
|
// Pregenerated wallet was created during an
|
|
181
183
|
// additional email validation step as part of onboarding
|
|
182
184
|
// cannot rely on newUser JWT field here due to session being counted twice
|
|
183
185
|
// when authentication happens followed by a separate email kyc step
|
|
184
|
-
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(createUserProfileFromSdkUser(updateUserProfileResponse.user));
|
|
186
|
+
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(createUserProfileFromSdkUser(updateUserProfileResponse.user), [primaryChain]);
|
|
185
187
|
if (!embeddedWalletVerifiedCredential) {
|
|
186
188
|
throw new Error('Could not find an embedded wallet');
|
|
187
189
|
}
|
|
@@ -83,7 +83,7 @@ require('../../../../store/state/tokenBalances.cjs');
|
|
|
83
83
|
|
|
84
84
|
const useFetchChain = (connector) => {
|
|
85
85
|
const fetchChain = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
-
var _a;
|
|
86
|
+
var _a, _b;
|
|
87
87
|
if (!connector)
|
|
88
88
|
return { chainId: undefined, name: '', symbol: undefined };
|
|
89
89
|
const chainId = yield connector.getNetwork();
|
|
@@ -97,7 +97,8 @@ const useFetchChain = (connector) => {
|
|
|
97
97
|
/* istanbul ignore else */
|
|
98
98
|
if (chainId && connector.evmNetworks) {
|
|
99
99
|
const result = connector.evmNetworks.find((element) => element.chainId === chainId);
|
|
100
|
-
chainWithIcon.name =
|
|
100
|
+
chainWithIcon.name =
|
|
101
|
+
(_b = (_a = result === null || result === void 0 ? void 0 : result.vanityName) !== null && _a !== void 0 ? _a : result === null || result === void 0 ? void 0 : result.name) !== null && _b !== void 0 ? _b : chainWithIcon.name;
|
|
101
102
|
chainWithIcon.icon = result === null || result === void 0 ? void 0 : result.iconUrls[0];
|
|
102
103
|
}
|
|
103
104
|
return chainWithIcon;
|
|
@@ -79,7 +79,7 @@ import '../../../../store/state/tokenBalances.js';
|
|
|
79
79
|
|
|
80
80
|
const useFetchChain = (connector) => {
|
|
81
81
|
const fetchChain = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
-
var _a;
|
|
82
|
+
var _a, _b;
|
|
83
83
|
if (!connector)
|
|
84
84
|
return { chainId: undefined, name: '', symbol: undefined };
|
|
85
85
|
const chainId = yield connector.getNetwork();
|
|
@@ -93,7 +93,8 @@ const useFetchChain = (connector) => {
|
|
|
93
93
|
/* istanbul ignore else */
|
|
94
94
|
if (chainId && connector.evmNetworks) {
|
|
95
95
|
const result = connector.evmNetworks.find((element) => element.chainId === chainId);
|
|
96
|
-
chainWithIcon.name =
|
|
96
|
+
chainWithIcon.name =
|
|
97
|
+
(_b = (_a = result === null || result === void 0 ? void 0 : result.vanityName) !== null && _a !== void 0 ? _a : result === null || result === void 0 ? void 0 : result.name) !== null && _b !== void 0 ? _b : chainWithIcon.name;
|
|
97
98
|
chainWithIcon.icon = result === null || result === void 0 ? void 0 : result.iconUrls[0];
|
|
98
99
|
}
|
|
99
100
|
return chainWithIcon;
|