@dynamic-labs/sdk-react-core 3.8.5 → 3.9.0
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 +13 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/shared/utils/functions/providerLabel/providerLabel.cjs +3 -0
- package/src/lib/shared/utils/functions/providerLabel/providerLabel.js +3 -0
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.cjs +8 -3
- package/src/lib/utils/functions/getOauthLoginUrl/getOauthLoginUrl.js +8 -3
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -0
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -0
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +9 -5
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.d.ts +12 -0
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.9.0](https://github.com/dynamic-labs/DynamicAuth/compare/v3.8.5...v3.9.0) (2024-12-04)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add shopify login ([#7538](https://github.com/dynamic-labs/DynamicAuth/issues/7538)) ([6123447](https://github.com/dynamic-labs/DynamicAuth/commit/6123447218bc477e5b71b3704149ab18b42f1a9d))
|
|
8
|
+
* useWalletOptions provides chain and allows filtering ([#7533](https://github.com/dynamic-labs/DynamicAuth/issues/7533)) ([#7537](https://github.com/dynamic-labs/DynamicAuth/issues/7537)) ([f74f7b9](https://github.com/dynamic-labs/DynamicAuth/commit/f74f7b997f07c828c2e713666aee2d77c25fc0e4))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update twitter to X in social provide label ([#7531](https://github.com/dynamic-labs/DynamicAuth/issues/7531)) ([89a7d70](https://github.com/dynamic-labs/DynamicAuth/commit/89a7d70d2856d472ced17bd77d84a9b53150f8a8))
|
|
14
|
+
|
|
2
15
|
### [3.8.5](https://github.com/dynamic-labs/DynamicAuth/compare/v3.8.4...v3.8.5) (2024-11-29)
|
|
3
16
|
|
|
4
17
|
|
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.
|
|
3
|
+
"version": "3.9.0",
|
|
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.
|
|
21
|
-
"@dynamic-labs/iconic": "3.
|
|
22
|
-
"@dynamic-labs/logger": "3.
|
|
23
|
-
"@dynamic-labs/multi-wallet": "3.
|
|
24
|
-
"@dynamic-labs/rpc-providers": "3.
|
|
25
|
-
"@dynamic-labs/store": "3.
|
|
26
|
-
"@dynamic-labs/types": "3.
|
|
27
|
-
"@dynamic-labs/utils": "3.
|
|
28
|
-
"@dynamic-labs/wallet-book": "3.
|
|
29
|
-
"@dynamic-labs/wallet-connector-core": "3.
|
|
20
|
+
"@dynamic-labs/assert-package-version": "3.9.0",
|
|
21
|
+
"@dynamic-labs/iconic": "3.9.0",
|
|
22
|
+
"@dynamic-labs/logger": "3.9.0",
|
|
23
|
+
"@dynamic-labs/multi-wallet": "3.9.0",
|
|
24
|
+
"@dynamic-labs/rpc-providers": "3.9.0",
|
|
25
|
+
"@dynamic-labs/store": "3.9.0",
|
|
26
|
+
"@dynamic-labs/types": "3.9.0",
|
|
27
|
+
"@dynamic-labs/utils": "3.9.0",
|
|
28
|
+
"@dynamic-labs/wallet-book": "3.9.0",
|
|
29
|
+
"@dynamic-labs/wallet-connector-core": "3.9.0",
|
|
30
30
|
"bs58": "5.0.0",
|
|
31
31
|
"eventemitter3": "5.0.1"
|
|
32
32
|
},
|
|
@@ -10,6 +10,9 @@ const providerLabel = (provider) => {
|
|
|
10
10
|
if (!provider) {
|
|
11
11
|
return undefined;
|
|
12
12
|
}
|
|
13
|
+
if (provider === sdkApiCore.SocialSignInProviderEnum.Twitter) {
|
|
14
|
+
return 'X';
|
|
15
|
+
}
|
|
13
16
|
if (provider === sdkApiCore.SocialSignInProviderEnum.Coinbasesocial) {
|
|
14
17
|
return 'Coinbase';
|
|
15
18
|
}
|
|
@@ -20,7 +20,7 @@ const getMobileOauthUrl = (provider, loginData) => {
|
|
|
20
20
|
return provider.redirectUrl.replace('redirect', 'authorizeHtml');
|
|
21
21
|
};
|
|
22
22
|
const getOauthLoginUrl = (providers, providerType) => {
|
|
23
|
-
var _a, _b;
|
|
23
|
+
var _a, _b, _c;
|
|
24
24
|
const provider = getProviderByType.getProviderByType(providers, providerType);
|
|
25
25
|
if (!(provider === null || provider === void 0 ? void 0 : provider.clientId)) {
|
|
26
26
|
return '';
|
|
@@ -34,7 +34,12 @@ const getOauthLoginUrl = (providers, providerType) => {
|
|
|
34
34
|
loginBaseUrl = (_a = provider.authorizationUrl) !== null && _a !== void 0 ? _a : '';
|
|
35
35
|
}
|
|
36
36
|
else if (provider.baseAuthUrl) {
|
|
37
|
-
|
|
37
|
+
if (providerType === sdkApiCore.ProviderEnum.Shopify) {
|
|
38
|
+
loginBaseUrl = provider.baseAuthUrl.replace('{{shopifyStore}}', (_b = provider.shopifyStore) !== null && _b !== void 0 ? _b : '');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
loginBaseUrl = provider.baseAuthUrl;
|
|
42
|
+
}
|
|
38
43
|
}
|
|
39
44
|
else {
|
|
40
45
|
return '';
|
|
@@ -42,7 +47,7 @@ const getOauthLoginUrl = (providers, providerType) => {
|
|
|
42
47
|
const mobileUrl = getMobileOauthUrl(provider, loginData);
|
|
43
48
|
const baseProps = {
|
|
44
49
|
client_id: provider.clientId,
|
|
45
|
-
redirect_uri: (
|
|
50
|
+
redirect_uri: (_c = provider.redirectUrl) !== null && _c !== void 0 ? _c : '',
|
|
46
51
|
response_type: 'code',
|
|
47
52
|
};
|
|
48
53
|
if (providerType === sdkApiCore.ProviderEnum.Tiktok) {
|
|
@@ -16,7 +16,7 @@ const getMobileOauthUrl = (provider, loginData) => {
|
|
|
16
16
|
return provider.redirectUrl.replace('redirect', 'authorizeHtml');
|
|
17
17
|
};
|
|
18
18
|
const getOauthLoginUrl = (providers, providerType) => {
|
|
19
|
-
var _a, _b;
|
|
19
|
+
var _a, _b, _c;
|
|
20
20
|
const provider = getProviderByType(providers, providerType);
|
|
21
21
|
if (!(provider === null || provider === void 0 ? void 0 : provider.clientId)) {
|
|
22
22
|
return '';
|
|
@@ -30,7 +30,12 @@ const getOauthLoginUrl = (providers, providerType) => {
|
|
|
30
30
|
loginBaseUrl = (_a = provider.authorizationUrl) !== null && _a !== void 0 ? _a : '';
|
|
31
31
|
}
|
|
32
32
|
else if (provider.baseAuthUrl) {
|
|
33
|
-
|
|
33
|
+
if (providerType === ProviderEnum.Shopify) {
|
|
34
|
+
loginBaseUrl = provider.baseAuthUrl.replace('{{shopifyStore}}', (_b = provider.shopifyStore) !== null && _b !== void 0 ? _b : '');
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
loginBaseUrl = provider.baseAuthUrl;
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
else {
|
|
36
41
|
return '';
|
|
@@ -38,7 +43,7 @@ const getOauthLoginUrl = (providers, providerType) => {
|
|
|
38
43
|
const mobileUrl = getMobileOauthUrl(provider, loginData);
|
|
39
44
|
const baseProps = {
|
|
40
45
|
client_id: provider.clientId,
|
|
41
|
-
redirect_uri: (
|
|
46
|
+
redirect_uri: (_c = provider.redirectUrl) !== null && _c !== void 0 ? _c : '',
|
|
42
47
|
response_type: 'code',
|
|
43
48
|
};
|
|
44
49
|
if (providerType === ProviderEnum.Tiktok) {
|
|
@@ -100,21 +100,24 @@ const useWalletOptions = () => {
|
|
|
100
100
|
const { setView } = ViewContext.useViewContext();
|
|
101
101
|
const { navigateToWalletGroup } = WalletGroupContext.useWalletGroupContext();
|
|
102
102
|
const { handleWalletItemClick } = useWalletItemActions.useWalletItemActions();
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
return
|
|
103
|
+
const getFilteredWalletOptions = React.useCallback((filter) => {
|
|
104
|
+
const nonEmbeddedOptions = walletConnectorOptions.filter((option) => !embeddedWalletsKeys.includes(option.walletConnector.key));
|
|
105
|
+
return filter(nonEmbeddedOptions).map((option) => {
|
|
106
106
|
const groupName = option.group && Boolean(Object.keys(walletBook$1).length)
|
|
107
107
|
? walletBook.getWalletGroup(walletBook$1, option.group).name
|
|
108
108
|
: undefined;
|
|
109
109
|
return {
|
|
110
|
+
chain: option.walletConnector.connectedChain,
|
|
110
111
|
group: option.group,
|
|
111
112
|
groupName,
|
|
112
113
|
isInstalledOnBrowser: option.isInstalledOnBrowser,
|
|
114
|
+
isWalletConnect: option.walletConnector.isWalletConnect,
|
|
113
115
|
key: option.walletConnector.key,
|
|
114
116
|
name: option.name,
|
|
115
117
|
};
|
|
116
|
-
})
|
|
118
|
+
});
|
|
117
119
|
}, [walletBook$1, walletConnectorOptions]);
|
|
120
|
+
const allWalletOptions = React.useMemo(() => getFilteredWalletOptions((options) => options), [getFilteredWalletOptions]);
|
|
118
121
|
const selectWalletOption = (walletKey) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
119
122
|
const group = groupWalletOptions.groupWalletOptions(walletBook$1, walletConnectorOptions);
|
|
120
123
|
const walletOption = group.find((wallet) => wallet.key === walletKey);
|
|
@@ -141,8 +144,9 @@ const useWalletOptions = () => {
|
|
|
141
144
|
setShowAuthFlow(true);
|
|
142
145
|
});
|
|
143
146
|
return {
|
|
147
|
+
getFilteredWalletOptions,
|
|
144
148
|
selectWalletOption,
|
|
145
|
-
walletOptions,
|
|
149
|
+
walletOptions: allWalletOptions,
|
|
146
150
|
};
|
|
147
151
|
};
|
|
148
152
|
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
import { WalletOption } from '../../../shared';
|
|
1
2
|
export declare const useWalletOptions: () => {
|
|
3
|
+
getFilteredWalletOptions: (filter: (options: WalletOption[]) => WalletOption[]) => {
|
|
4
|
+
chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | "BTC";
|
|
5
|
+
group: string | undefined;
|
|
6
|
+
groupName: string | undefined;
|
|
7
|
+
isInstalledOnBrowser: boolean;
|
|
8
|
+
isWalletConnect: boolean;
|
|
9
|
+
key: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}[];
|
|
2
12
|
selectWalletOption: (walletKey: string) => Promise<void>;
|
|
3
13
|
walletOptions: {
|
|
14
|
+
chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | "BTC";
|
|
4
15
|
group: string | undefined;
|
|
5
16
|
groupName: string | undefined;
|
|
6
17
|
isInstalledOnBrowser: boolean;
|
|
18
|
+
isWalletConnect: boolean;
|
|
7
19
|
key: string;
|
|
8
20
|
name: string;
|
|
9
21
|
}[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useMemo } from 'react';
|
|
3
|
+
import { useCallback, useMemo } from 'react';
|
|
4
4
|
import { isHardwareWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { useWalletBookContext, getWalletGroup } from '@dynamic-labs/wallet-book';
|
|
6
6
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
@@ -96,21 +96,24 @@ const useWalletOptions = () => {
|
|
|
96
96
|
const { setView } = useViewContext();
|
|
97
97
|
const { navigateToWalletGroup } = useWalletGroupContext();
|
|
98
98
|
const { handleWalletItemClick } = useWalletItemActions();
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
return
|
|
99
|
+
const getFilteredWalletOptions = useCallback((filter) => {
|
|
100
|
+
const nonEmbeddedOptions = walletConnectorOptions.filter((option) => !embeddedWalletsKeys.includes(option.walletConnector.key));
|
|
101
|
+
return filter(nonEmbeddedOptions).map((option) => {
|
|
102
102
|
const groupName = option.group && Boolean(Object.keys(walletBook).length)
|
|
103
103
|
? getWalletGroup(walletBook, option.group).name
|
|
104
104
|
: undefined;
|
|
105
105
|
return {
|
|
106
|
+
chain: option.walletConnector.connectedChain,
|
|
106
107
|
group: option.group,
|
|
107
108
|
groupName,
|
|
108
109
|
isInstalledOnBrowser: option.isInstalledOnBrowser,
|
|
110
|
+
isWalletConnect: option.walletConnector.isWalletConnect,
|
|
109
111
|
key: option.walletConnector.key,
|
|
110
112
|
name: option.name,
|
|
111
113
|
};
|
|
112
|
-
})
|
|
114
|
+
});
|
|
113
115
|
}, [walletBook, walletConnectorOptions]);
|
|
116
|
+
const allWalletOptions = useMemo(() => getFilteredWalletOptions((options) => options), [getFilteredWalletOptions]);
|
|
114
117
|
const selectWalletOption = (walletKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
118
|
const group = groupWalletOptions(walletBook, walletConnectorOptions);
|
|
116
119
|
const walletOption = group.find((wallet) => wallet.key === walletKey);
|
|
@@ -137,8 +140,9 @@ const useWalletOptions = () => {
|
|
|
137
140
|
setShowAuthFlow(true);
|
|
138
141
|
});
|
|
139
142
|
return {
|
|
143
|
+
getFilteredWalletOptions,
|
|
140
144
|
selectWalletOption,
|
|
141
|
-
walletOptions,
|
|
145
|
+
walletOptions: allWalletOptions,
|
|
142
146
|
};
|
|
143
147
|
};
|
|
144
148
|
|