@dynamic-labs/sdk-react-core 2.0.0-alpha.8 → 2.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +1 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +1 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useTurnkey/useTurnkey.cjs +2 -9
- package/src/lib/utils/hooks/useEmbeddedWallet/useTurnkey/useTurnkey.js +2 -9
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.cjs +10 -5
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.js +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.0.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.8...v2.0.0-alpha.9) (2024-03-06)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* solana connector new sendTransaction method ([#4842](https://github.com/dynamic-labs/DynamicAuth/issues/4842)) ([0b198e3](https://github.com/dynamic-labs/DynamicAuth/commit/0b198e30d83fbbc8d506654d87cbfad403fda289))
|
|
8
|
+
* specify solana network when using phantom redirect deeplinking ([#4863](https://github.com/dynamic-labs/DynamicAuth/issues/4863)) ([fb4ee7c](https://github.com/dynamic-labs/DynamicAuth/commit/fb4ee7cfc0493c9c85b6ccb31954842556c58aa4))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* isLoggedIn should return true even when there is no primary wallet ([#4875](https://github.com/dynamic-labs/DynamicAuth/issues/4875)) ([f396e22](https://github.com/dynamic-labs/DynamicAuth/commit/f396e22b9d809b05ac52194ffa4346f3591d17fe))
|
|
14
|
+
* update btckit network conversion for signPsbt ([a6009e1](https://github.com/dynamic-labs/DynamicAuth/commit/a6009e18c453b4e65545455fea0e52ed7a983b4d))
|
|
15
|
+
* user getting logged out when signing in with email linked to a unavailable wallet ([#4858](https://github.com/dynamic-labs/DynamicAuth/issues/4858)) ([8653e13](https://github.com/dynamic-labs/DynamicAuth/commit/8653e13d2067dd0161e660b4374c08a9fe0bc203))
|
|
16
|
+
|
|
2
17
|
## [2.0.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.7...v2.0.0-alpha.8) (2024-03-04)
|
|
3
18
|
|
|
4
19
|
## [2.0.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) (2024-02-28)
|
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": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/ethereum": "2.0.0-alpha.
|
|
21
|
-
"@dynamic-labs/iconic": "2.0.0-alpha.
|
|
22
|
-
"@dynamic-labs/logger": "2.0.0-alpha.
|
|
23
|
-
"@dynamic-labs/multi-wallet": "2.0.0-alpha.
|
|
24
|
-
"@dynamic-labs/rpc-provider-ethereum": "2.0.0-alpha.
|
|
25
|
-
"@dynamic-labs/rpc-provider-solana": "2.0.0-alpha.
|
|
26
|
-
"@dynamic-labs/rpc-providers": "2.0.0-alpha.
|
|
27
|
-
"@dynamic-labs/types": "2.0.0-alpha.
|
|
28
|
-
"@dynamic-labs/utils": "2.0.0-alpha.
|
|
29
|
-
"@dynamic-labs/viem-utils": "2.0.0-alpha.
|
|
30
|
-
"@dynamic-labs/wallet-book": "2.0.0-alpha.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.
|
|
20
|
+
"@dynamic-labs/ethereum": "2.0.0-alpha.9",
|
|
21
|
+
"@dynamic-labs/iconic": "2.0.0-alpha.9",
|
|
22
|
+
"@dynamic-labs/logger": "2.0.0-alpha.9",
|
|
23
|
+
"@dynamic-labs/multi-wallet": "2.0.0-alpha.9",
|
|
24
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.0.0-alpha.9",
|
|
25
|
+
"@dynamic-labs/rpc-provider-solana": "2.0.0-alpha.9",
|
|
26
|
+
"@dynamic-labs/rpc-providers": "2.0.0-alpha.9",
|
|
27
|
+
"@dynamic-labs/types": "2.0.0-alpha.9",
|
|
28
|
+
"@dynamic-labs/utils": "2.0.0-alpha.9",
|
|
29
|
+
"@dynamic-labs/viem-utils": "2.0.0-alpha.9",
|
|
30
|
+
"@dynamic-labs/wallet-book": "2.0.0-alpha.9",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.9",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -88,7 +88,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
88
88
|
|
|
89
89
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
90
90
|
const useEmbeddedWallet = () => {
|
|
91
|
-
const { projectSettings, onboardingOnlyJwt,
|
|
91
|
+
const { projectSettings, onboardingOnlyJwt, walletConnectorOptions } = useInternalDynamicContext.useInternalDynamicContext();
|
|
92
92
|
const { createPassword: internalCreatePassword } = useEmbeddedWalletPassword.useEmbeddedWalletPassword();
|
|
93
93
|
const { createCoinbaseMPCWallet } = useCoinbaseMPC.useCoinbaseMPC();
|
|
94
94
|
const { createTurnkeyWallet } = useTurnkey.useTurnkey();
|
|
@@ -113,11 +113,6 @@ const useEmbeddedWallet = () => {
|
|
|
113
113
|
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
114
114
|
// if user has a wallet and it's not embedded, set it as primary and return,
|
|
115
115
|
if ((userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.length) && !embeddedWalletVerifiedCredential) {
|
|
116
|
-
if (!primaryWallet) {
|
|
117
|
-
// user logged in through an email linked to a third party wallet
|
|
118
|
-
// at this point primary wallet is still undefined and we need to set it
|
|
119
|
-
setPrimaryWalletId(userWaletsCredentials[0].id);
|
|
120
|
-
}
|
|
121
116
|
throw new Error('Primary wallet is not an embedded wallet');
|
|
122
117
|
}
|
|
123
118
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
@@ -153,10 +148,8 @@ const useEmbeddedWallet = () => {
|
|
|
153
148
|
createTurnkeyWallet,
|
|
154
149
|
internalCreatePassword,
|
|
155
150
|
onboardingOnlyJwt,
|
|
156
|
-
primaryWallet,
|
|
157
151
|
projectSettings,
|
|
158
152
|
setIsLoadingEmbeddedWallet,
|
|
159
|
-
setPrimaryWalletId,
|
|
160
153
|
walletConnectorOptions,
|
|
161
154
|
]);
|
|
162
155
|
return {
|
|
@@ -84,7 +84,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
84
84
|
|
|
85
85
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
86
86
|
const useEmbeddedWallet = () => {
|
|
87
|
-
const { projectSettings, onboardingOnlyJwt,
|
|
87
|
+
const { projectSettings, onboardingOnlyJwt, walletConnectorOptions } = useInternalDynamicContext();
|
|
88
88
|
const { createPassword: internalCreatePassword } = useEmbeddedWalletPassword();
|
|
89
89
|
const { createCoinbaseMPCWallet } = useCoinbaseMPC();
|
|
90
90
|
const { createTurnkeyWallet } = useTurnkey();
|
|
@@ -109,11 +109,6 @@ const useEmbeddedWallet = () => {
|
|
|
109
109
|
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
110
110
|
// if user has a wallet and it's not embedded, set it as primary and return,
|
|
111
111
|
if ((userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.length) && !embeddedWalletVerifiedCredential) {
|
|
112
|
-
if (!primaryWallet) {
|
|
113
|
-
// user logged in through an email linked to a third party wallet
|
|
114
|
-
// at this point primary wallet is still undefined and we need to set it
|
|
115
|
-
setPrimaryWalletId(userWaletsCredentials[0].id);
|
|
116
|
-
}
|
|
117
112
|
throw new Error('Primary wallet is not an embedded wallet');
|
|
118
113
|
}
|
|
119
114
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
@@ -149,10 +144,8 @@ const useEmbeddedWallet = () => {
|
|
|
149
144
|
createTurnkeyWallet,
|
|
150
145
|
internalCreatePassword,
|
|
151
146
|
onboardingOnlyJwt,
|
|
152
|
-
primaryWallet,
|
|
153
147
|
projectSettings,
|
|
154
148
|
setIsLoadingEmbeddedWallet,
|
|
155
|
-
setPrimaryWalletId,
|
|
156
149
|
walletConnectorOptions,
|
|
157
150
|
]);
|
|
158
151
|
return {
|
|
@@ -81,7 +81,7 @@ var useInternalDynamicContext = require('../../../../context/DynamicContext/useD
|
|
|
81
81
|
|
|
82
82
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
83
83
|
const useTurnkey = () => {
|
|
84
|
-
const { projectSettings, setPrimaryWalletId, walletConnectorOptions, setShowAuthFlow,
|
|
84
|
+
const { projectSettings, setPrimaryWalletId, walletConnectorOptions, setShowAuthFlow, environmentId, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
85
85
|
const { setView } = ViewContext.useViewContext();
|
|
86
86
|
const { createDynamicEmbeddedWalletMutation } = useCreateDynamicEmbeddedWalletMutation.useCreateDynamicEmbeddedWalletMutation();
|
|
87
87
|
const startPregeneratedWalletCreationFlow = React.useCallback((jwt, decodedJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -173,12 +173,7 @@ const useTurnkey = () => {
|
|
|
173
173
|
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
174
174
|
// if user logged in with MM for example, just continue the flow
|
|
175
175
|
if (!embeddedWalletVerifiedCredential) {
|
|
176
|
-
|
|
177
|
-
// at this point primary wallet is still undefined and we need to set it
|
|
178
|
-
if (!primaryWallet) {
|
|
179
|
-
setPrimaryWalletId(userWaletsCredentials[0].id);
|
|
180
|
-
}
|
|
181
|
-
return Promise.resolve(primaryWallet);
|
|
176
|
+
throw new Error('Primary wallet is not an embedded wallet');
|
|
182
177
|
}
|
|
183
178
|
// if user already has embedded wallet, returns it
|
|
184
179
|
return returnEmbeddedWallet(jwt, embeddedWalletVerifiedCredential);
|
|
@@ -188,8 +183,6 @@ const useTurnkey = () => {
|
|
|
188
183
|
returnEmbeddedWallet,
|
|
189
184
|
startEmbeddedWalletCreationFlow,
|
|
190
185
|
startPregeneratedWalletCreationFlow,
|
|
191
|
-
primaryWallet,
|
|
192
|
-
setPrimaryWalletId,
|
|
193
186
|
]);
|
|
194
187
|
return {
|
|
195
188
|
createTurnkeyWallet,
|
|
@@ -77,7 +77,7 @@ import { useInternalDynamicContext } from '../../../../context/DynamicContext/us
|
|
|
77
77
|
|
|
78
78
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
79
79
|
const useTurnkey = () => {
|
|
80
|
-
const { projectSettings, setPrimaryWalletId, walletConnectorOptions, setShowAuthFlow,
|
|
80
|
+
const { projectSettings, setPrimaryWalletId, walletConnectorOptions, setShowAuthFlow, environmentId, } = useInternalDynamicContext();
|
|
81
81
|
const { setView } = useViewContext();
|
|
82
82
|
const { createDynamicEmbeddedWalletMutation } = useCreateDynamicEmbeddedWalletMutation();
|
|
83
83
|
const startPregeneratedWalletCreationFlow = useCallback((jwt, decodedJwt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -169,12 +169,7 @@ const useTurnkey = () => {
|
|
|
169
169
|
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
170
170
|
// if user logged in with MM for example, just continue the flow
|
|
171
171
|
if (!embeddedWalletVerifiedCredential) {
|
|
172
|
-
|
|
173
|
-
// at this point primary wallet is still undefined and we need to set it
|
|
174
|
-
if (!primaryWallet) {
|
|
175
|
-
setPrimaryWalletId(userWaletsCredentials[0].id);
|
|
176
|
-
}
|
|
177
|
-
return Promise.resolve(primaryWallet);
|
|
172
|
+
throw new Error('Primary wallet is not an embedded wallet');
|
|
178
173
|
}
|
|
179
174
|
// if user already has embedded wallet, returns it
|
|
180
175
|
return returnEmbeddedWallet(jwt, embeddedWalletVerifiedCredential);
|
|
@@ -184,8 +179,6 @@ const useTurnkey = () => {
|
|
|
184
179
|
returnEmbeddedWallet,
|
|
185
180
|
startEmbeddedWalletCreationFlow,
|
|
186
181
|
startPregeneratedWalletCreationFlow,
|
|
187
|
-
primaryWallet,
|
|
188
|
-
setPrimaryWalletId,
|
|
189
182
|
]);
|
|
190
183
|
return {
|
|
191
184
|
createTurnkeyWallet,
|
|
@@ -75,20 +75,25 @@ require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCa
|
|
|
75
75
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
76
76
|
|
|
77
77
|
const useIsLoggedIn = () => {
|
|
78
|
-
var _a, _b;
|
|
78
|
+
var _a, _b, _c;
|
|
79
79
|
const { user, primaryWallet, authMode, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
80
80
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
81
81
|
// a user is set even when on connect-only mode if signing in with social,
|
|
82
82
|
// but it won't have a primaryWallet in this case
|
|
83
83
|
const isLoggedIn = Boolean(user) || (authMode === 'connect-only' && Boolean(primaryWallet));
|
|
84
|
+
const userWaletsCredentials = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.filter(({ walletProvider }) => walletProvider);
|
|
85
|
+
const hasEmbeddedWalletVerifiedCredential = Boolean(userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.find(({ walletProvider }) => walletProvider === 'embeddedWallet'));
|
|
86
|
+
const isTurnkeyPregen = isTurnkeyProviderEnabled &&
|
|
87
|
+
((_c = (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.embeddedWallets) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation) &&
|
|
88
|
+
!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup);
|
|
89
|
+
const shouldHaveTurnkeyWallet = isTurnkeyPregen &&
|
|
90
|
+
// if user doesn't have a branded wallet only
|
|
91
|
+
(!(userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.length) || hasEmbeddedWalletVerifiedCredential);
|
|
84
92
|
// if turnkey is enabled we need to check if the user that is logged/connected
|
|
85
93
|
// has a primaryWallet to not show the widget without secure
|
|
86
|
-
if (
|
|
87
|
-
((_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) &&
|
|
88
|
-
!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup)) {
|
|
94
|
+
if (shouldHaveTurnkeyWallet) {
|
|
89
95
|
return Boolean(primaryWallet && isLoggedIn);
|
|
90
96
|
}
|
|
91
|
-
// return isLoggedIn;
|
|
92
97
|
return isLoggedIn;
|
|
93
98
|
};
|
|
94
99
|
|
|
@@ -71,20 +71,25 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
|
|
|
71
71
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
72
72
|
|
|
73
73
|
const useIsLoggedIn = () => {
|
|
74
|
-
var _a, _b;
|
|
74
|
+
var _a, _b, _c;
|
|
75
75
|
const { user, primaryWallet, authMode, projectSettings } = useInternalDynamicContext();
|
|
76
76
|
const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
77
77
|
// a user is set even when on connect-only mode if signing in with social,
|
|
78
78
|
// but it won't have a primaryWallet in this case
|
|
79
79
|
const isLoggedIn = Boolean(user) || (authMode === 'connect-only' && Boolean(primaryWallet));
|
|
80
|
+
const userWaletsCredentials = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.filter(({ walletProvider }) => walletProvider);
|
|
81
|
+
const hasEmbeddedWalletVerifiedCredential = Boolean(userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.find(({ walletProvider }) => walletProvider === 'embeddedWallet'));
|
|
82
|
+
const isTurnkeyPregen = isTurnkeyProviderEnabled &&
|
|
83
|
+
((_c = (_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.embeddedWallets) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation) &&
|
|
84
|
+
!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup);
|
|
85
|
+
const shouldHaveTurnkeyWallet = isTurnkeyPregen &&
|
|
86
|
+
// if user doesn't have a branded wallet only
|
|
87
|
+
(!(userWaletsCredentials === null || userWaletsCredentials === void 0 ? void 0 : userWaletsCredentials.length) || hasEmbeddedWalletVerifiedCredential);
|
|
80
88
|
// if turnkey is enabled we need to check if the user that is logged/connected
|
|
81
89
|
// has a primaryWallet to not show the widget without secure
|
|
82
|
-
if (
|
|
83
|
-
((_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) &&
|
|
84
|
-
!(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets.forceAuthenticatorAtSignup)) {
|
|
90
|
+
if (shouldHaveTurnkeyWallet) {
|
|
85
91
|
return Boolean(primaryWallet && isLoggedIn);
|
|
86
92
|
}
|
|
87
|
-
// return isLoggedIn;
|
|
88
93
|
return isLoggedIn;
|
|
89
94
|
};
|
|
90
95
|
|