@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 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
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "3.8.5";
6
+ var version = "3.9.0";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.570",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "3.8.5";
2
+ var version = "3.9.0";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.570",
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": "3.8.5",
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.8.5",
21
- "@dynamic-labs/iconic": "3.8.5",
22
- "@dynamic-labs/logger": "3.8.5",
23
- "@dynamic-labs/multi-wallet": "3.8.5",
24
- "@dynamic-labs/rpc-providers": "3.8.5",
25
- "@dynamic-labs/store": "3.8.5",
26
- "@dynamic-labs/types": "3.8.5",
27
- "@dynamic-labs/utils": "3.8.5",
28
- "@dynamic-labs/wallet-book": "3.8.5",
29
- "@dynamic-labs/wallet-connector-core": "3.8.5",
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
  }
@@ -6,6 +6,9 @@ const providerLabel = (provider) => {
6
6
  if (!provider) {
7
7
  return undefined;
8
8
  }
9
+ if (provider === SocialSignInProviderEnum.Twitter) {
10
+ return 'X';
11
+ }
9
12
  if (provider === SocialSignInProviderEnum.Coinbasesocial) {
10
13
  return 'Coinbase';
11
14
  }
@@ -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
- loginBaseUrl = provider.baseAuthUrl;
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: (_b = provider.redirectUrl) !== null && _b !== void 0 ? _b : '',
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
- loginBaseUrl = provider.baseAuthUrl;
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: (_b = provider.redirectUrl) !== null && _b !== void 0 ? _b : '',
46
+ redirect_uri: (_c = provider.redirectUrl) !== null && _c !== void 0 ? _c : '',
42
47
  response_type: 'code',
43
48
  };
44
49
  if (providerType === ProviderEnum.Tiktok) {
@@ -104,6 +104,7 @@ const socialProviders = [
104
104
  'google',
105
105
  'instagram',
106
106
  'line',
107
+ 'shopify',
107
108
  'spotify',
108
109
  'tiktok',
109
110
  'telegram',
@@ -100,6 +100,7 @@ const socialProviders = [
100
100
  'google',
101
101
  'instagram',
102
102
  'line',
103
+ 'shopify',
103
104
  'spotify',
104
105
  'tiktok',
105
106
  'telegram',
@@ -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 walletOptions = React.useMemo(() => {
104
- var _a;
105
- return (_a = walletConnectorOptions === null || walletConnectorOptions === void 0 ? void 0 : walletConnectorOptions.filter((option) => !embeddedWalletsKeys.includes(option.walletConnector.key)).map((option) => {
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
- })) !== null && _a !== void 0 ? _a : [];
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 walletOptions = useMemo(() => {
100
- var _a;
101
- return (_a = walletConnectorOptions === null || walletConnectorOptions === void 0 ? void 0 : walletConnectorOptions.filter((option) => !embeddedWalletsKeys.includes(option.walletConnector.key)).map((option) => {
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
- })) !== null && _a !== void 0 ? _a : [];
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