@dynamic-labs/sdk-react-core 2.2.0-alpha.3 → 2.2.0-alpha.5

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,21 @@
1
1
 
2
+ ## [2.2.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.4...v2.2.0-alpha.5) (2024-06-08)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * find solana provider from wallet standard ([#5897](https://github.com/dynamic-labs/DynamicAuth/issues/5897)) ([2144041](https://github.com/dynamic-labs/DynamicAuth/commit/21440410c3a75983195260ce57f4442177480c65))
8
+ * remove force consent and account selection even for returning google users ([#5911](https://github.com/dynamic-labs/DynamicAuth/issues/5911)) ([8b2a358](https://github.com/dynamic-labs/DynamicAuth/commit/8b2a3586ee559c553a1615a57c34226c175db2f9))
9
+ * retrieve connected account from cache when MagicEden wallet is secondary and locked ([#5885](https://github.com/dynamic-labs/DynamicAuth/issues/5885)) ([fb35a65](https://github.com/dynamic-labs/DynamicAuth/commit/fb35a651dc18dbdc2bfaad87b7528bfae977f7e3))
10
+
11
+ ## [2.2.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.3...v2.2.0-alpha.4) (2024-06-06)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * btc getBalance should use ordinal address if payment not available ([#5882](https://github.com/dynamic-labs/DynamicAuth/issues/5882)) ([803a055](https://github.com/dynamic-labs/DynamicAuth/commit/803a05518ae9d2353d50f51b29047dff01136710))
17
+ * connect prompt when switching to xverse ([#5888](https://github.com/dynamic-labs/DynamicAuth/issues/5888)) ([181a7c4](https://github.com/dynamic-labs/DynamicAuth/commit/181a7c4af8217dab7ed2776d56ec2e3725a0ee6a))
18
+
2
19
  ## [2.2.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.2...v2.2.0-alpha.3) (2024-06-05)
3
20
 
4
21
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "2.2.0-alpha.3";
6
+ var version = "2.2.0-alpha.5";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.460",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "2.2.0-alpha.3";
2
+ var version = "2.2.0-alpha.5";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.460",
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": "2.2.0-alpha.3",
3
+ "version": "2.2.0-alpha.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.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/iconic": "2.2.0-alpha.3",
21
- "@dynamic-labs/logger": "2.2.0-alpha.3",
22
- "@dynamic-labs/multi-wallet": "2.2.0-alpha.3",
23
- "@dynamic-labs/rpc-provider-ethereum": "2.2.0-alpha.3",
24
- "@dynamic-labs/rpc-provider-solana": "2.2.0-alpha.3",
25
- "@dynamic-labs/rpc-providers": "2.2.0-alpha.3",
26
- "@dynamic-labs/store": "2.2.0-alpha.3",
27
- "@dynamic-labs/types": "2.2.0-alpha.3",
28
- "@dynamic-labs/utils": "2.2.0-alpha.3",
29
- "@dynamic-labs/viem-utils": "2.2.0-alpha.3",
30
- "@dynamic-labs/wallet-book": "2.2.0-alpha.3",
31
- "@dynamic-labs/wallet-connector-core": "2.2.0-alpha.3",
20
+ "@dynamic-labs/iconic": "2.2.0-alpha.5",
21
+ "@dynamic-labs/logger": "2.2.0-alpha.5",
22
+ "@dynamic-labs/multi-wallet": "2.2.0-alpha.5",
23
+ "@dynamic-labs/rpc-provider-ethereum": "2.2.0-alpha.5",
24
+ "@dynamic-labs/rpc-provider-solana": "2.2.0-alpha.5",
25
+ "@dynamic-labs/rpc-providers": "2.2.0-alpha.5",
26
+ "@dynamic-labs/store": "2.2.0-alpha.5",
27
+ "@dynamic-labs/types": "2.2.0-alpha.5",
28
+ "@dynamic-labs/utils": "2.2.0-alpha.5",
29
+ "@dynamic-labs/viem-utils": "2.2.0-alpha.5",
30
+ "@dynamic-labs/wallet-book": "2.2.0-alpha.5",
31
+ "@dynamic-labs/wallet-connector-core": "2.2.0-alpha.5",
32
32
  "eventemitter3": "5.0.1"
33
33
  },
34
34
  "devDependencies": {
@@ -15,7 +15,7 @@ require('../../../ViewContext/ViewContext.cjs');
15
15
  require('@dynamic-labs/wallet-book');
16
16
  var localStorage$1 = require('../../../../utils/constants/localStorage.cjs');
17
17
  require('../../../../utils/constants/colors.cjs');
18
- require('../../../../utils/constants/values.cjs');
18
+ var values = require('../../../../utils/constants/values.cjs');
19
19
  var localStorage = require('../../../../shared/utils/classes/storage/localStorage.cjs');
20
20
  require('../../../../shared/consts/index.cjs');
21
21
  require('../../../../config/ApiEndpoint.cjs');
@@ -97,6 +97,9 @@ const useHandleLogout = (params) => {
97
97
  p.setShowBridgeWidget(false);
98
98
  p.resetLoginWithEmail();
99
99
  if (p.user) {
100
+ // this deletes the auth cookie, if it exists
101
+ // if the cookie doesn't exist, this sets a new cookie which would expire immediately
102
+ document.cookie = `${values.DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`;
100
103
  // do not await this async call - just fire and forget
101
104
  session.revokeSession({
102
105
  environmentId: p.environmentId,
@@ -11,7 +11,7 @@ import '../../../ViewContext/ViewContext.js';
11
11
  import '@dynamic-labs/wallet-book';
12
12
  import { AUTH_TOKEN, AUTH_MIN_TOKEN, WALLET_PICKER_SEARCH_KEY, PHANTOM_SIGNATURE_STATE } from '../../../../utils/constants/localStorage.js';
13
13
  import '../../../../utils/constants/colors.js';
14
- import '../../../../utils/constants/values.js';
14
+ import { DYNAMIC_AUTH_COOKIE_NAME } from '../../../../utils/constants/values.js';
15
15
  import { LocalStorage } from '../../../../shared/utils/classes/storage/localStorage.js';
16
16
  import '../../../../shared/consts/index.js';
17
17
  import '../../../../config/ApiEndpoint.js';
@@ -93,6 +93,9 @@ const useHandleLogout = (params) => {
93
93
  p.setShowBridgeWidget(false);
94
94
  p.resetLoginWithEmail();
95
95
  if (p.user) {
96
+ // this deletes the auth cookie, if it exists
97
+ // if the cookie doesn't exist, this sets a new cookie which would expire immediately
98
+ document.cookie = `${DYNAMIC_AUTH_COOKIE_NAME}=; Max-Age=-99999999; path=/; SameSite=Lax`;
96
99
  // do not await this async call - just fire and forget
97
100
  revokeSession({
98
101
  environmentId: p.environmentId,
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  require('@dynamic-labs/wallet-connector-core');
7
7
  var createUserProfile = require('../../../utils/functions/createUserProfile/createUserProfile.cjs');
8
8
  require('@dynamic-labs/sdk-api-core');
9
- require('../../../utils/constants/values.cjs');
9
+ var values = require('../../../utils/constants/values.cjs');
10
10
  require('@dynamic-labs/utils');
11
11
  require('../../../../../_virtual/_tslib.cjs');
12
12
  require('@dynamic-labs/multi-wallet');
@@ -26,6 +26,7 @@ require('viem/chains');
26
26
  require('../../../config/ApiEndpoint.cjs');
27
27
  var userActions = require('../../actions/userActions/userActions.cjs');
28
28
  require('../../../locale/locale.cjs');
29
+ var isCookieEnabled = require('../../../utils/functions/isCookieEnabled/isCookieEnabled.cjs');
29
30
  var storeExpiresAt = require('../../../utils/functions/storeExpiresAt/storeExpiresAt.cjs');
30
31
 
31
32
  const storeAuthTokenAndUser = ({ user, jwt, minifiedJwt, expiresAt, }) => {
@@ -33,6 +34,12 @@ const storeAuthTokenAndUser = ({ user, jwt, minifiedJwt, expiresAt, }) => {
33
34
  storeExpiresAt.storeExpiresAt(expiresAt);
34
35
  if (jwt && minifiedJwt) {
35
36
  index.storeAuthToken(jwt, minifiedJwt);
37
+ if (isCookieEnabled.isCookieEnabled()) {
38
+ // if cookie is enabled, but the backend returns a JWT, then use JS to store the cookie
39
+ const expireDate = new Date(expiresAt * 1000).toUTCString();
40
+ const authCookie = `${values.DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`;
41
+ document.cookie = authCookie;
42
+ }
36
43
  }
37
44
  const userProfile = createUserProfile.createUserProfileFromSdkUser(user);
38
45
  userActions.setUser(userProfile);
@@ -2,7 +2,7 @@
2
2
  import '@dynamic-labs/wallet-connector-core';
3
3
  import { createUserProfileFromSdkUser } from '../../../utils/functions/createUserProfile/createUserProfile.js';
4
4
  import '@dynamic-labs/sdk-api-core';
5
- import '../../../utils/constants/values.js';
5
+ import { DYNAMIC_AUTH_COOKIE_NAME } from '../../../utils/constants/values.js';
6
6
  import '@dynamic-labs/utils';
7
7
  import '../../../../../_virtual/_tslib.js';
8
8
  import '@dynamic-labs/multi-wallet';
@@ -22,6 +22,7 @@ import 'viem/chains';
22
22
  import '../../../config/ApiEndpoint.js';
23
23
  import { setUser } from '../../actions/userActions/userActions.js';
24
24
  import '../../../locale/locale.js';
25
+ import { isCookieEnabled } from '../../../utils/functions/isCookieEnabled/isCookieEnabled.js';
25
26
  import { storeExpiresAt } from '../../../utils/functions/storeExpiresAt/storeExpiresAt.js';
26
27
 
27
28
  const storeAuthTokenAndUser = ({ user, jwt, minifiedJwt, expiresAt, }) => {
@@ -29,6 +30,12 @@ const storeAuthTokenAndUser = ({ user, jwt, minifiedJwt, expiresAt, }) => {
29
30
  storeExpiresAt(expiresAt);
30
31
  if (jwt && minifiedJwt) {
31
32
  storeAuthToken(jwt, minifiedJwt);
33
+ if (isCookieEnabled()) {
34
+ // if cookie is enabled, but the backend returns a JWT, then use JS to store the cookie
35
+ const expireDate = new Date(expiresAt * 1000).toUTCString();
36
+ const authCookie = `${DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`;
37
+ document.cookie = authCookie;
38
+ }
32
39
  }
33
40
  const userProfile = createUserProfileFromSdkUser(user);
34
41
  setUser(userProfile);
@@ -2,5 +2,5 @@ export { AUTH_TOKEN, AUTH_MIN_TOKEN, STORE_STORAGE_KEY, LAST_USED_WALLET, NETWOR
2
2
  export { BASE_LIGHT_1, BASE_LIGHT_2, BASE_LIGHT_3, BASE_LIGHT_4, BASE_LIGHT_5, BASE_DARK_5, TEXT_LIGHT_PRIMARY, TEXT_LIGHT_SECONDARY, TEXT_LIGHT_TERTIARY, TEXT_LIGHT_LINK, CONNECTION_LIGHT_GREEN, CONNECTION_LIGHT_ORANGE, ERROR_LIGHT_1, ERROR_LIGHT_2, OVERLAY_LIGHT, HOVER_LIGHT, LOADING_ANIMATION_GRADIENT_LIGHT, BASE_DARK_1, BASE_DARK_2, BASE_DARK_3, BASE_DARK_4, DYNAMIC_CONNECT_BUTTON_BACKGROUND, DYNAMIC_CONNECT_BUTTON_BORDER, DYNAMIC_CONNECT_BUTTON_COLOR, TEXT_DARK_PRIMARY, TEXT_DARK_SECONDARY, TEXT_DARK_TERTIARY, TEXT_DARK_LINK, BRAND_HOVER, BRAND_PRIMARY, BRAND_SECONDARY, CONNECTION_DARK_GREEN, CONNECTION_DARK_ORANGE, ERROR_DARK_1, ERROR_DARK_2, OVERLAY_DARK, HOVER_DARK, LOADING_ANIMATION_GRADIENT_DARK, SHADOW_DOWN_1, SHADOW_DOWN_2, SHADOW_DOWN_3, SHADOW_UP_1, BRAND_HOVER_COLOR, BRAND_PRIMARY_COLOR, BRAND_SECONDARY_COLOR, } from './colors';
3
3
  export { BORDER_SQUARE, BORDER_ROUNDED, BORDER_RADIUS } from './theme';
4
4
  export { TITLE, BODY_NORMAL, BODY_SMALL, BODY_MINI, BUTTON_PRIMARY, BUTTON_SECONDARY, NUMBERS_BIG, NUMBERS_MEDIUM, } from './typography';
5
- export { DEFAULT_NUMBER_OF_WALLETS_TO_SHOW } from './values';
5
+ export { DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, DYNAMIC_AUTH_COOKIE_NAME, } from './values';
6
6
  export * from './fields';
@@ -28,7 +28,9 @@ const VerifiedCredentialNameToChainEnum = {
28
28
  solana: sdkApiCore.ChainEnum.Sol,
29
29
  starknet: sdkApiCore.ChainEnum.Stark,
30
30
  };
31
+ const DYNAMIC_AUTH_COOKIE_NAME = 'DYNAMIC_JWT_TOKEN';
31
32
 
32
33
  exports.ChainEnumToVerifiedCredentialName = ChainEnumToVerifiedCredentialName;
33
34
  exports.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW;
35
+ exports.DYNAMIC_AUTH_COOKIE_NAME = DYNAMIC_AUTH_COOKIE_NAME;
34
36
  exports.VerifiedCredentialNameToChainEnum = VerifiedCredentialNameToChainEnum;
@@ -7,3 +7,4 @@ export declare const VerifiedCredentialNameToChainEnum: {
7
7
  [key: string]: ChainEnum;
8
8
  };
9
9
  export declare const LAMPORTS_PER_SOL = 1000000000;
10
+ export declare const DYNAMIC_AUTH_COOKIE_NAME = "DYNAMIC_JWT_TOKEN";
@@ -24,5 +24,6 @@ const VerifiedCredentialNameToChainEnum = {
24
24
  solana: ChainEnum.Sol,
25
25
  starknet: ChainEnum.Stark,
26
26
  };
27
+ const DYNAMIC_AUTH_COOKIE_NAME = 'DYNAMIC_JWT_TOKEN';
27
28
 
28
- export { ChainEnumToVerifiedCredentialName, DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, VerifiedCredentialNameToChainEnum };
29
+ export { ChainEnumToVerifiedCredentialName, DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, DYNAMIC_AUTH_COOKIE_NAME, VerifiedCredentialNameToChainEnum };
@@ -32,7 +32,6 @@ const OAUTH_LOGIN_DATA = {
32
32
  url: 'https://github.com/login/oauth/authorize',
33
33
  },
34
34
  google: {
35
- prompt: ['select_account', 'consent'],
36
35
  scope: ['profile', 'email'],
37
36
  url: 'https://accounts.google.com/o/oauth2/v2/auth',
38
37
  },
@@ -28,7 +28,6 @@ const OAUTH_LOGIN_DATA = {
28
28
  url: 'https://github.com/login/oauth/authorize',
29
29
  },
30
30
  google: {
31
- prompt: ['select_account', 'consent'],
32
31
  scope: ['profile', 'email'],
33
32
  url: 'https://accounts.google.com/o/oauth2/v2/auth',
34
33
  },
@@ -5,11 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
7
  var React = require('react');
8
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
9
  var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
9
10
  require('@dynamic-labs/sdk-api-core');
10
11
  require('../../../shared/logger.cjs');
11
12
  require('@dynamic-labs/iconic');
12
- require('@dynamic-labs/wallet-connector-core');
13
13
  require('react/jsx-runtime');
14
14
  require('../../../context/ViewContext/ViewContext.cjs');
15
15
  require('@dynamic-labs/wallet-book');
@@ -53,6 +53,11 @@ const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWall
53
53
  const numberOfLinkedWallets = verifiedCredentials.filter((account) => account.walletName === ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.key) || '')).length;
54
54
  // If there's only 1, it's the one being removed and we can kill the session
55
55
  if (numberOfLinkedWallets === 1) {
56
+ if (wallet && walletConnectorCore.isBitcoinConnector(wallet.connector)) {
57
+ // to avoid the infinite wallet popup issue experienced with the ME wallet
58
+ // we only want to clear the cached connected accounts when we unlink, but not on logout
59
+ yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.clearConnectedAccounts());
60
+ }
56
61
  yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.endSession());
57
62
  }
58
63
  removedWalletsIds.current.push(walletId);
@@ -1,11 +1,11 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { useCallback } from 'react';
4
+ import { isBitcoinConnector } from '@dynamic-labs/wallet-connector-core';
4
5
  import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
5
6
  import '@dynamic-labs/sdk-api-core';
6
7
  import '../../../shared/logger.js';
7
8
  import '@dynamic-labs/iconic';
8
- import '@dynamic-labs/wallet-connector-core';
9
9
  import 'react/jsx-runtime';
10
10
  import '../../../context/ViewContext/ViewContext.js';
11
11
  import '@dynamic-labs/wallet-book';
@@ -49,6 +49,11 @@ const useHandleUnlinkWallet = ({ verifiedCredentials, environmentId, primaryWall
49
49
  const numberOfLinkedWallets = verifiedCredentials.filter((account) => account.walletName === ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.key) || '')).length;
50
50
  // If there's only 1, it's the one being removed and we can kill the session
51
51
  if (numberOfLinkedWallets === 1) {
52
+ if (wallet && isBitcoinConnector(wallet.connector)) {
53
+ // to avoid the infinite wallet popup issue experienced with the ME wallet
54
+ // we only want to clear the cached connected accounts when we unlink, but not on logout
55
+ yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.clearConnectedAccounts());
56
+ }
52
57
  yield (wallet === null || wallet === void 0 ? void 0 : wallet.connector.endSession());
53
58
  }
54
59
  removedWalletsIds.current.push(walletId);