@dynamic-labs/sdk-react-core 1.4.17 → 1.4.19
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 +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -4
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -4
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +0 -1
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.cjs +21 -28
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.d.ts +3 -8
- package/src/lib/shared/utils/hooks/useGlobalLoading/useGlobalLoading.js +22 -29
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
### [1.4.19](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.18...v1.4.19) (2024-08-23)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* allow twitter popup to close ([#6699](https://github.com/dynamic-labs/DynamicAuth/issues/6699)) ([b8f9484](https://github.com/dynamic-labs/DynamicAuth/commit/b8f9484af974efd9be473452ff05de0059e15ac2))
|
|
8
|
+
|
|
9
|
+
### [1.4.18](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.17...v1.4.18) (2024-07-31)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* sdkHasLoaded flipping back to false with otp ([#6256](https://github.com/dynamic-labs/DynamicAuth/issues/6256)) ([#6451](https://github.com/dynamic-labs/DynamicAuth/issues/6451)) ([b4c86df](https://github.com/dynamic-labs/DynamicAuth/commit/b4c86dff136cc5a866c70610a12ffc75a8ae6d4f)), closes [/github.com/dynamic-labs/dynamic-auth/commit/4fc047f02f6f06d5c129d8de4eed42ee35b4545e#diff-cf5bbeb2e3bd88281d04fe5d30137f9f135011803101c2dec57d5f35cbb47aa0](https://github.com/dynamic-labs//github.com/dynamic-labs/dynamic-auth/commit/4fc047f02f6f06d5c129d8de4eed42ee35b4545e/issues/diff-cf5bbeb2e3bd88281d04fe5d30137f9f135011803101c2dec57d5f35cbb47aa0)
|
|
15
|
+
|
|
2
16
|
### [1.4.17](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.16...v1.4.17) (2024-07-25)
|
|
3
17
|
|
|
4
18
|
|
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": "1.4.
|
|
3
|
+
"version": "1.4.19",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
"react-focus-lock": "2.9.2",
|
|
17
17
|
"react-i18next": "^13.2.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
|
-
"@dynamic-labs/ethereum": "1.4.
|
|
20
|
-
"@dynamic-labs/iconic": "1.4.
|
|
21
|
-
"@dynamic-labs/logger": "1.4.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "1.4.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "1.4.
|
|
24
|
-
"@dynamic-labs/types": "1.4.
|
|
25
|
-
"@dynamic-labs/utils": "1.4.
|
|
26
|
-
"@dynamic-labs/viem-utils": "1.4.
|
|
27
|
-
"@dynamic-labs/wallet-book": "1.4.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "1.4.
|
|
19
|
+
"@dynamic-labs/ethereum": "1.4.19",
|
|
20
|
+
"@dynamic-labs/iconic": "1.4.19",
|
|
21
|
+
"@dynamic-labs/logger": "1.4.19",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "1.4.19",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "1.4.19",
|
|
24
|
+
"@dynamic-labs/types": "1.4.19",
|
|
25
|
+
"@dynamic-labs/utils": "1.4.19",
|
|
26
|
+
"@dynamic-labs/viem-utils": "1.4.19",
|
|
27
|
+
"@dynamic-labs/wallet-book": "1.4.19",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "1.4.19",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -267,7 +267,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale
|
|
|
267
267
|
setIsFullyConnected(!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length) && Boolean(primaryWallet));
|
|
268
268
|
}, [bridgeChainsToConnect, primaryWallet]);
|
|
269
269
|
const walletConnectors = linkedOrConnectedWallets.map((wallet) => wallet.connector);
|
|
270
|
-
const
|
|
270
|
+
const sdkHasLoaded = useGlobalLoading.useGlobalLoading({
|
|
271
271
|
authMode,
|
|
272
272
|
connectedInfo: connectedWalletsInfo[0],
|
|
273
273
|
connectedWallets,
|
|
@@ -309,7 +309,6 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale
|
|
|
309
309
|
setLegacyIsVerifying,
|
|
310
310
|
setMultiWalletWidgetState,
|
|
311
311
|
setOnboardingOnlyJwt,
|
|
312
|
-
setSdkHasLoaded,
|
|
313
312
|
setSelectedWalletConnectorKey,
|
|
314
313
|
setShowAuthFlow,
|
|
315
314
|
setShowBridgeWidget,
|
|
@@ -525,7 +524,6 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale
|
|
|
525
524
|
setPrimaryWallet,
|
|
526
525
|
setPrimaryWalletId,
|
|
527
526
|
setQrcodeUri,
|
|
528
|
-
setSdkHasLoaded,
|
|
529
527
|
setSelectedWalletConnectorKey,
|
|
530
528
|
setSelectedWalletWithAction,
|
|
531
529
|
setShowAuthFlow,
|
|
@@ -638,7 +636,6 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale
|
|
|
638
636
|
setNetwork,
|
|
639
637
|
setPrimaryWallet,
|
|
640
638
|
setPrimaryWalletId,
|
|
641
|
-
setSdkHasLoaded,
|
|
642
639
|
setSelectedWalletConnectorKey,
|
|
643
640
|
setShowAuthFlow,
|
|
644
641
|
setShowLinkNewWalletModal,
|
|
@@ -263,7 +263,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
263
263
|
setIsFullyConnected(!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length) && Boolean(primaryWallet));
|
|
264
264
|
}, [bridgeChainsToConnect, primaryWallet]);
|
|
265
265
|
const walletConnectors = linkedOrConnectedWallets.map((wallet) => wallet.connector);
|
|
266
|
-
const
|
|
266
|
+
const sdkHasLoaded = useGlobalLoading({
|
|
267
267
|
authMode,
|
|
268
268
|
connectedInfo: connectedWalletsInfo[0],
|
|
269
269
|
connectedWallets,
|
|
@@ -305,7 +305,6 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
305
305
|
setLegacyIsVerifying,
|
|
306
306
|
setMultiWalletWidgetState,
|
|
307
307
|
setOnboardingOnlyJwt,
|
|
308
|
-
setSdkHasLoaded,
|
|
309
308
|
setSelectedWalletConnectorKey,
|
|
310
309
|
setShowAuthFlow,
|
|
311
310
|
setShowBridgeWidget,
|
|
@@ -521,7 +520,6 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
521
520
|
setPrimaryWallet,
|
|
522
521
|
setPrimaryWalletId,
|
|
523
522
|
setQrcodeUri,
|
|
524
|
-
setSdkHasLoaded,
|
|
525
523
|
setSelectedWalletConnectorKey,
|
|
526
524
|
setSelectedWalletWithAction,
|
|
527
525
|
setShowAuthFlow,
|
|
@@ -634,7 +632,6 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
634
632
|
setNetwork,
|
|
635
633
|
setPrimaryWallet,
|
|
636
634
|
setPrimaryWalletId,
|
|
637
|
-
setSdkHasLoaded,
|
|
638
635
|
setSelectedWalletConnectorKey,
|
|
639
636
|
setShowAuthFlow,
|
|
640
637
|
setShowLinkNewWalletModal,
|
|
@@ -6,7 +6,6 @@ import { ChainsToConnect } from '../../types';
|
|
|
6
6
|
import { SetShowAuthFlow } from '../useShowAuthFlow';
|
|
7
7
|
export type UseHandleLogoutParams = {
|
|
8
8
|
removeUser: () => void;
|
|
9
|
-
setSdkHasLoaded: Dispatch<SetStateAction<boolean>>;
|
|
10
9
|
clearAllWalletConnectSessions: () => void;
|
|
11
10
|
bridgeChains: ChainsToConnect[] | undefined;
|
|
12
11
|
setSelectedWalletConnectorKey: Dispatch<SetStateAction<string | null>>;
|
|
@@ -78,7 +78,6 @@ const useHandleLogout = (params) => {
|
|
|
78
78
|
paramsRef.current = params;
|
|
79
79
|
const logout = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
80
80
|
const p = paramsRef.current;
|
|
81
|
-
p.setSdkHasLoaded(false);
|
|
82
81
|
p.setSelectedWalletConnectorKey(null);
|
|
83
82
|
p.clearAllWalletConnectSessions();
|
|
84
83
|
p.setShowDynamicUserProfile(false);
|
|
@@ -74,7 +74,6 @@ const useHandleLogout = (params) => {
|
|
|
74
74
|
paramsRef.current = params;
|
|
75
75
|
const logout = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
76
|
const p = paramsRef.current;
|
|
77
|
-
p.setSdkHasLoaded(false);
|
|
78
77
|
p.setSelectedWalletConnectorKey(null);
|
|
79
78
|
p.clearAllWalletConnectSessions();
|
|
80
79
|
p.setShowDynamicUserProfile(false);
|
|
@@ -6,37 +6,30 @@ var React = require('react');
|
|
|
6
6
|
var index = require('../../functions/lastAuthenticatedAccount/index.cjs');
|
|
7
7
|
|
|
8
8
|
const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSettings, primaryWallet, user, walletBook, }) => {
|
|
9
|
-
var _a;
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
9
|
+
var _a, _b;
|
|
10
|
+
// Once we declare the SDK as loaded, we do not ever want to flip back to false
|
|
11
|
+
const hasLoaded = React.useRef(false);
|
|
12
|
+
const finishLoading = () => {
|
|
13
|
+
if (hasLoaded.current)
|
|
14
|
+
return;
|
|
15
|
+
hasLoaded.current = true;
|
|
16
|
+
};
|
|
17
|
+
if (hasLoaded.current)
|
|
18
|
+
return true;
|
|
19
|
+
const hasWalletBookLoaded = Boolean(Object.keys((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {}).length);
|
|
20
|
+
const isPrimaryWalletLoading = user &&
|
|
21
|
+
((_b = index.lastAuthenticatedAccount(user)) === null || _b === void 0 ? void 0 : _b.format) === 'blockchain' &&
|
|
13
22
|
!primaryWallet;
|
|
14
|
-
const
|
|
23
|
+
const isConnectOnlyWalletsLoading = authMode === 'connect-only' &&
|
|
15
24
|
connectedInfo &&
|
|
16
25
|
connectedWallets.length === 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
setSdkHasLoaded(true);
|
|
27
|
-
}
|
|
28
|
-
}, [
|
|
29
|
-
projectSettings,
|
|
30
|
-
primaryWallet,
|
|
31
|
-
user,
|
|
32
|
-
primaryWalletIsLoading,
|
|
33
|
-
connectOnlyUserIsLoading,
|
|
34
|
-
walletBook,
|
|
35
|
-
]);
|
|
36
|
-
return {
|
|
37
|
-
sdkHasLoaded,
|
|
38
|
-
setSdkHasLoaded,
|
|
39
|
-
};
|
|
26
|
+
if (hasWalletBookLoaded &&
|
|
27
|
+
Boolean(projectSettings) &&
|
|
28
|
+
!isPrimaryWalletLoading &&
|
|
29
|
+
!isConnectOnlyWalletsLoading) {
|
|
30
|
+
finishLoading();
|
|
31
|
+
}
|
|
32
|
+
return hasLoaded.current;
|
|
40
33
|
};
|
|
41
34
|
|
|
42
35
|
exports.useGlobalLoading = useGlobalLoading;
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
3
1
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
4
|
-
import { UserProfile, Wallet } from '../../../types';
|
|
5
2
|
import { ConnectedWalletConnectorType } from '../../../../utils/hooks/useConnectWallet/useConnectWallet';
|
|
3
|
+
import { UserProfile, Wallet } from '../../../types';
|
|
6
4
|
type Props = {
|
|
7
5
|
authMode: string;
|
|
8
6
|
connectedInfo: ConnectedWalletConnectorType | null;
|
|
9
7
|
connectedWallets: Wallet[];
|
|
10
8
|
primaryWallet: Wallet | null;
|
|
11
|
-
projectSettings:
|
|
9
|
+
projectSettings: any;
|
|
12
10
|
user: UserProfile | undefined;
|
|
13
11
|
walletBook: WalletBookSchema;
|
|
14
12
|
};
|
|
15
|
-
export declare const useGlobalLoading: ({ authMode, connectedInfo, connectedWallets, projectSettings, primaryWallet, user, walletBook, }: Props) =>
|
|
16
|
-
sdkHasLoaded: boolean;
|
|
17
|
-
setSdkHasLoaded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
18
|
-
};
|
|
13
|
+
export declare const useGlobalLoading: ({ authMode, connectedInfo, connectedWallets, projectSettings, primaryWallet, user, walletBook, }: Props) => boolean;
|
|
19
14
|
export {};
|
|
@@ -1,38 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef } from 'react';
|
|
2
2
|
import { lastAuthenticatedAccount } from '../../functions/lastAuthenticatedAccount/index.js';
|
|
3
3
|
|
|
4
4
|
const useGlobalLoading = ({ authMode, connectedInfo, connectedWallets, projectSettings, primaryWallet, user, walletBook, }) => {
|
|
5
|
-
var _a;
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
5
|
+
var _a, _b;
|
|
6
|
+
// Once we declare the SDK as loaded, we do not ever want to flip back to false
|
|
7
|
+
const hasLoaded = useRef(false);
|
|
8
|
+
const finishLoading = () => {
|
|
9
|
+
if (hasLoaded.current)
|
|
10
|
+
return;
|
|
11
|
+
hasLoaded.current = true;
|
|
12
|
+
};
|
|
13
|
+
if (hasLoaded.current)
|
|
14
|
+
return true;
|
|
15
|
+
const hasWalletBookLoaded = Boolean(Object.keys((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {}).length);
|
|
16
|
+
const isPrimaryWalletLoading = user &&
|
|
17
|
+
((_b = lastAuthenticatedAccount(user)) === null || _b === void 0 ? void 0 : _b.format) === 'blockchain' &&
|
|
9
18
|
!primaryWallet;
|
|
10
|
-
const
|
|
19
|
+
const isConnectOnlyWalletsLoading = authMode === 'connect-only' &&
|
|
11
20
|
connectedInfo &&
|
|
12
21
|
connectedWallets.length === 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
setSdkHasLoaded(true);
|
|
23
|
-
}
|
|
24
|
-
}, [
|
|
25
|
-
projectSettings,
|
|
26
|
-
primaryWallet,
|
|
27
|
-
user,
|
|
28
|
-
primaryWalletIsLoading,
|
|
29
|
-
connectOnlyUserIsLoading,
|
|
30
|
-
walletBook,
|
|
31
|
-
]);
|
|
32
|
-
return {
|
|
33
|
-
sdkHasLoaded,
|
|
34
|
-
setSdkHasLoaded,
|
|
35
|
-
};
|
|
22
|
+
if (hasWalletBookLoaded &&
|
|
23
|
+
Boolean(projectSettings) &&
|
|
24
|
+
!isPrimaryWalletLoading &&
|
|
25
|
+
!isConnectOnlyWalletsLoading) {
|
|
26
|
+
finishLoading();
|
|
27
|
+
}
|
|
28
|
+
return hasLoaded.current;
|
|
36
29
|
};
|
|
37
30
|
|
|
38
31
|
export { useGlobalLoading };
|
|
@@ -98,7 +98,7 @@ const socialProviders = [
|
|
|
98
98
|
// pkce params are only required for twitter and break if added for other providers, like google
|
|
99
99
|
// so we should only add provider that support pkce to this list
|
|
100
100
|
const providersRequiringPkce = ['twitter', 'github'];
|
|
101
|
-
const providersWithoutWindowOpenerRefence = [
|
|
101
|
+
const providersWithoutWindowOpenerRefence = [];
|
|
102
102
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
103
103
|
const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
104
104
|
var _a;
|
|
@@ -94,7 +94,7 @@ const socialProviders = [
|
|
|
94
94
|
// pkce params are only required for twitter and break if added for other providers, like google
|
|
95
95
|
// so we should only add provider that support pkce to this list
|
|
96
96
|
const providersRequiringPkce = ['twitter', 'github'];
|
|
97
|
-
const providersWithoutWindowOpenerRefence = [
|
|
97
|
+
const providersWithoutWindowOpenerRefence = [];
|
|
98
98
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
99
99
|
const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
100
100
|
var _a;
|