@dynamic-labs/sdk-react-core 4.20.2 → 4.20.4

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,18 @@
1
1
 
2
+ ### [4.20.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.3...v4.20.4) (2025-06-13)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * expose sign authorization on react native ([#8954](https://github.com/dynamic-labs/dynamic-auth/issues/8954)) ([dbc2f44](https://github.com/dynamic-labs/dynamic-auth/commit/dbc2f4447efe61fc100146662bc76ed72bcb0fd2))
8
+
9
+ ### [4.20.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.2...v4.20.3) (2025-06-13)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * use minified jwt for waas wallet client auth ([#8938](https://github.com/dynamic-labs/dynamic-auth/issues/8938)) ([f7b9e14](https://github.com/dynamic-labs/dynamic-auth/commit/f7b9e1435e397a64fdf4f42f9b3ad354314e0191))
15
+
2
16
  ### [4.20.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.1...v4.20.2) (2025-06-11)
3
17
 
4
18
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.20.2";
6
+ var version = "4.20.4";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.681",
9
9
  "@dynamic-labs-sdk/client": "0.0.1-alpha.5",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "4.20.2";
2
+ var version = "4.20.4";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.681",
5
5
  "@dynamic-labs-sdk/client": "0.0.1-alpha.5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "4.20.2",
3
+ "version": "4.20.4",
4
4
  "dependencies": {
5
5
  "@dynamic-labs/sdk-api-core": "0.0.681",
6
6
  "@dynamic-labs-sdk/client": "0.0.1-alpha.5",
@@ -15,16 +15,16 @@
15
15
  "yup": "0.32.11",
16
16
  "react-international-phone": "4.2.5",
17
17
  "bs58": "5.0.0",
18
- "@dynamic-labs/assert-package-version": "4.20.2",
19
- "@dynamic-labs/iconic": "4.20.2",
20
- "@dynamic-labs/logger": "4.20.2",
21
- "@dynamic-labs/multi-wallet": "4.20.2",
22
- "@dynamic-labs/rpc-providers": "4.20.2",
23
- "@dynamic-labs/store": "4.20.2",
24
- "@dynamic-labs/types": "4.20.2",
25
- "@dynamic-labs/utils": "4.20.2",
26
- "@dynamic-labs/wallet-book": "4.20.2",
27
- "@dynamic-labs/wallet-connector-core": "4.20.2",
18
+ "@dynamic-labs/assert-package-version": "4.20.4",
19
+ "@dynamic-labs/iconic": "4.20.4",
20
+ "@dynamic-labs/logger": "4.20.4",
21
+ "@dynamic-labs/multi-wallet": "4.20.4",
22
+ "@dynamic-labs/rpc-providers": "4.20.4",
23
+ "@dynamic-labs/store": "4.20.4",
24
+ "@dynamic-labs/types": "4.20.4",
25
+ "@dynamic-labs/utils": "4.20.4",
26
+ "@dynamic-labs/wallet-book": "4.20.4",
27
+ "@dynamic-labs/wallet-connector-core": "4.20.4",
28
28
  "eventemitter3": "5.0.1"
29
29
  },
30
30
  "devDependencies": {
@@ -77,3 +77,4 @@ export { useDeleteUserAccount } from './useDeleteUserAccount';
77
77
  export { useDynamicWaas } from './useDynamicWaas';
78
78
  export { useSyncDynamicWaas } from './useSyncDynamicWaas';
79
79
  export { useExchangeAccounts } from './useExchangeAccounts';
80
+ export { useConnectExchangeForFunding } from './useConnectExchangeForFunding';
@@ -0,0 +1 @@
1
+ export * from './useConnectExchangeForFunding';
@@ -0,0 +1,6 @@
1
+ import { ExchangeKeyEnum } from '@dynamic-labs/sdk-api-core';
2
+ type ConnectExchangeForFundingProps = {
3
+ initiatedByWidget: boolean;
4
+ };
5
+ export declare const useConnectExchangeForFunding: () => (props: ConnectExchangeForFundingProps) => Promise<ExchangeKeyEnum>;
6
+ export {};
@@ -10,9 +10,9 @@ var utils = require('@dynamic-labs/utils');
10
10
  var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
11
11
  require('../../constants/values.cjs');
12
12
  require('@dynamic-labs/multi-wallet');
13
- var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
14
13
  require('../../../shared/logger.cjs');
15
14
  require('../../constants/colors.cjs');
15
+ var getMinAuthToken = require('../../functions/getMinAuthToken/getMinAuthToken.cjs');
16
16
  require('react-international-phone');
17
17
  require('@dynamic-labs/iconic');
18
18
  require('@dynamic-labs/wallet-connector-core');
@@ -45,6 +45,7 @@ require('../../../context/VerificationContext/VerificationContext.cjs');
45
45
  require('react-dom');
46
46
  var smartWallet = require('../useWalletConnectors/utils/smartWallet/smartWallet.cjs');
47
47
  require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
48
+ var useEmbeddedWalletSessionKeys = require('../useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs');
48
49
  require('../../../context/ThemeContext/ThemeContext.cjs');
49
50
  require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
50
51
  require('bs58');
@@ -105,11 +106,12 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
105
106
  var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
106
107
 
107
108
  const dynamicWaasKey = 'dynamicwaas';
108
- const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, }) => {
109
+ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, }) => {
109
110
  var _a;
110
111
  walletConnector.setEnvironmentId(environmentId);
111
112
  walletConnector.setBaseApiUrl((_a = (apiBaseUrl || apiUrl.DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
112
113
  walletConnector.setGetAuthTokenFunction(() => authToken !== null && authToken !== void 0 ? authToken : '');
114
+ walletConnector.setGetSignedSessionIdFunction(getSignedSessionId);
113
115
  walletConnector.setRelayUrl(relayUrl);
114
116
  return walletConnector;
115
117
  };
@@ -132,7 +134,10 @@ const useDynamicWaas = () => {
132
134
  const automaticEmbeddedWalletCreationForExternalEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreationForExternal;
133
135
  const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
134
136
  const dynamicWaasIsEnabled = defaultWalletVersion === sdkApiCore.EmbeddedWalletVersionEnum.V3;
135
- const authToken = getAuthToken.getAuthToken();
137
+ const authToken = getMinAuthToken.getMinAuthToken();
138
+ const { getSignedSessionId } = useEmbeddedWalletSessionKeys.useEmbeddedWalletSessionKeys({
139
+ environmentId,
140
+ });
136
141
  const isCookieAuthEnabled = projectSettings$1 && isCookieEnabled.isCookieEnabled(projectSettings$1);
137
142
  const getWalletConnector = React.useCallback((chainName) => {
138
143
  var _a;
@@ -150,6 +155,7 @@ const useDynamicWaas = () => {
150
155
  apiBaseUrl: apiBaseUrl || apiUrl.DEFAULT_WAAS_API_URL,
151
156
  authToken,
152
157
  environmentId,
158
+ getSignedSessionId,
153
159
  relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
154
160
  walletConnector,
155
161
  });
@@ -1,11 +1,12 @@
1
1
  import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
2
2
  import { ChainEnum } from '@dynamic-labs/sdk-api-core';
3
- export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, }: {
3
+ export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, }: {
4
4
  walletConnector: IDynamicWaasConnector;
5
5
  environmentId: string;
6
6
  apiBaseUrl: string;
7
7
  authToken: string | undefined;
8
8
  relayUrl: string;
9
+ getSignedSessionId: () => Promise<string>;
9
10
  }) => IDynamicWaasConnector;
10
11
  export declare const useDynamicWaas: () => {
11
12
  createWalletAccount: (chainNames: ChainEnum[]) => Promise<({
@@ -6,9 +6,9 @@ import { DynamicError } from '@dynamic-labs/utils';
6
6
  import { useUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
7
7
  import '../../constants/values.js';
8
8
  import '@dynamic-labs/multi-wallet';
9
- import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
10
9
  import '../../../shared/logger.js';
11
10
  import '../../constants/colors.js';
11
+ import { getMinAuthToken } from '../../functions/getMinAuthToken/getMinAuthToken.js';
12
12
  import 'react-international-phone';
13
13
  import '@dynamic-labs/iconic';
14
14
  import '@dynamic-labs/wallet-connector-core';
@@ -41,6 +41,7 @@ import '../../../context/VerificationContext/VerificationContext.js';
41
41
  import 'react-dom';
42
42
  import { findSmartWallet } from '../useWalletConnectors/utils/smartWallet/smartWallet.js';
43
43
  import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
44
+ import { useEmbeddedWalletSessionKeys } from '../useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js';
44
45
  import '../../../context/ThemeContext/ThemeContext.js';
45
46
  import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
46
47
  import 'bs58';
@@ -101,11 +102,12 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
101
102
  import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
102
103
 
103
104
  const dynamicWaasKey = 'dynamicwaas';
104
- const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, }) => {
105
+ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, getSignedSessionId, }) => {
105
106
  var _a;
106
107
  walletConnector.setEnvironmentId(environmentId);
107
108
  walletConnector.setBaseApiUrl((_a = (apiBaseUrl || DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
108
109
  walletConnector.setGetAuthTokenFunction(() => authToken !== null && authToken !== void 0 ? authToken : '');
110
+ walletConnector.setGetSignedSessionIdFunction(getSignedSessionId);
109
111
  walletConnector.setRelayUrl(relayUrl);
110
112
  return walletConnector;
111
113
  };
@@ -128,7 +130,10 @@ const useDynamicWaas = () => {
128
130
  const automaticEmbeddedWalletCreationForExternalEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreationForExternal;
129
131
  const defaultWalletVersion = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.defaultWalletVersion;
130
132
  const dynamicWaasIsEnabled = defaultWalletVersion === EmbeddedWalletVersionEnum.V3;
131
- const authToken = getAuthToken();
133
+ const authToken = getMinAuthToken();
134
+ const { getSignedSessionId } = useEmbeddedWalletSessionKeys({
135
+ environmentId,
136
+ });
132
137
  const isCookieAuthEnabled = projectSettings && isCookieEnabled(projectSettings);
133
138
  const getWalletConnector = useCallback((chainName) => {
134
139
  var _a;
@@ -146,6 +151,7 @@ const useDynamicWaas = () => {
146
151
  apiBaseUrl: apiBaseUrl || DEFAULT_WAAS_API_URL,
147
152
  authToken,
148
153
  environmentId,
154
+ getSignedSessionId,
149
155
  relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
150
156
  walletConnector,
151
157
  });
@@ -157,6 +157,21 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
157
157
  const sessionKeysString = JSON.stringify(sessionKeys);
158
158
  return Buffer.from(sessionKeysString).toString('base64');
159
159
  };
160
+ const getSignedSessionId = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
161
+ const sessionId = user$1 === null || user$1 === void 0 ? void 0 : user$1.sessionId;
162
+ if (!sessionId) {
163
+ throw new Error('Session ID not found');
164
+ }
165
+ const sessionKeysSS = utils.StorageService.getItem(localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS, localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
166
+ const decodedSessionKeys = sessionKeysSS
167
+ ? JSON.parse(Buffer.from(sessionKeysSS, 'base64').toString())
168
+ : undefined;
169
+ if (!(decodedSessionKeys === null || decodedSessionKeys === void 0 ? void 0 : decodedSessionKeys.privateKeyJwk)) {
170
+ throw new Error('Private key JWK not found');
171
+ }
172
+ const signedSessionId = yield utils$1.p256Sign(decodedSessionKeys.privateKeyJwk, sessionId);
173
+ return signedSessionId;
174
+ });
160
175
  const removeSessionKey = React.useCallback(() => {
161
176
  utils.tracing.logEvent('session-key', 'removeSessionKey');
162
177
  utils.StorageService.removeItem(localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS, localStorage.SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
@@ -164,6 +179,7 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
164
179
  return {
165
180
  generateSessionKey,
166
181
  getSessionPublicKey,
182
+ getSignedSessionId,
167
183
  registerEmbeddedWalletSessionKey,
168
184
  removeSessionKey,
169
185
  shouldRegisterSessionKeysOnSignin,
@@ -16,6 +16,7 @@ export declare const useEmbeddedWalletSessionKeys: ({ environmentId, projectSett
16
16
  publicKey: string;
17
17
  }>;
18
18
  getSessionPublicKey: () => string;
19
+ getSignedSessionId: () => Promise<string>;
19
20
  registerEmbeddedWalletSessionKey: ({ ignoreRestore, }?: {
20
21
  ignoreRestore?: boolean;
21
22
  }) => Promise<SessionKey | {
@@ -153,6 +153,21 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
153
153
  const sessionKeysString = JSON.stringify(sessionKeys);
154
154
  return Buffer.from(sessionKeysString).toString('base64');
155
155
  };
156
+ const getSignedSessionId = () => __awaiter(void 0, void 0, void 0, function* () {
157
+ const sessionId = user === null || user === void 0 ? void 0 : user.sessionId;
158
+ if (!sessionId) {
159
+ throw new Error('Session ID not found');
160
+ }
161
+ const sessionKeysSS = StorageService.getItem(SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
162
+ const decodedSessionKeys = sessionKeysSS
163
+ ? JSON.parse(Buffer.from(sessionKeysSS, 'base64').toString())
164
+ : undefined;
165
+ if (!(decodedSessionKeys === null || decodedSessionKeys === void 0 ? void 0 : decodedSessionKeys.privateKeyJwk)) {
166
+ throw new Error('Private key JWK not found');
167
+ }
168
+ const signedSessionId = yield p256Sign(decodedSessionKeys.privateKeyJwk, sessionId);
169
+ return signedSessionId;
170
+ });
156
171
  const removeSessionKey = useCallback(() => {
157
172
  tracing.logEvent('session-key', 'removeSessionKey');
158
173
  StorageService.removeItem(SECURE_ENCLAVE_WALLET_SESSION_KEYS, SECURE_ENCLAVE_WALLET_SESSION_KEYS_STORAGE_OPTIONS);
@@ -160,6 +175,7 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
160
175
  return {
161
176
  generateSessionKey,
162
177
  getSessionPublicKey,
178
+ getSignedSessionId,
163
179
  registerEmbeddedWalletSessionKey,
164
180
  removeSessionKey,
165
181
  shouldRegisterSessionKeysOnSignin,
@@ -23,7 +23,7 @@ require('../../../store/state/authMode/authMode.cjs');
23
23
  require('../../../context/CaptchaContext/CaptchaContext.cjs');
24
24
  require('../../../context/ErrorContext/ErrorContext.cjs');
25
25
  require('@dynamic-labs/multi-wallet');
26
- var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
26
+ var getMinAuthToken = require('../../functions/getMinAuthToken/getMinAuthToken.cjs');
27
27
  require('react-international-phone');
28
28
  require('../../../store/state/nonce/nonce.cjs');
29
29
  require('../../../store/state/projectSettings/projectSettings.cjs');
@@ -102,8 +102,8 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
102
102
 
103
103
  const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSettings) => {
104
104
  const apiBaseUrl = dynamicContextProps.useApiBaseUrl();
105
- const authToken = getAuthToken.getAuthToken();
106
- const { registerEmbeddedWalletSessionKey, removeSessionKey } = useEmbeddedWalletSessionKeys.useEmbeddedWalletSessionKeys({ environmentId, projectSettings });
105
+ const authToken = getMinAuthToken.getMinAuthToken();
106
+ const { registerEmbeddedWalletSessionKey, removeSessionKey, getSignedSessionId, } = useEmbeddedWalletSessionKeys.useEmbeddedWalletSessionKeys({ environmentId, projectSettings });
107
107
  if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
108
108
  return;
109
109
  walletOptions.forEach((walletOption) => {
@@ -117,6 +117,7 @@ const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSett
117
117
  apiBaseUrl: apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : apiUrl.DEFAULT_WAAS_API_URL,
118
118
  authToken,
119
119
  environmentId,
120
+ getSignedSessionId,
120
121
  relayUrl: (_e = (_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.waas) === null || _d === void 0 ? void 0 : _d.relayUrl) !== null && _e !== void 0 ? _e : '',
121
122
  walletConnector: walletOption.walletConnector,
122
123
  });
@@ -19,7 +19,7 @@ import '../../../store/state/authMode/authMode.js';
19
19
  import '../../../context/CaptchaContext/CaptchaContext.js';
20
20
  import '../../../context/ErrorContext/ErrorContext.js';
21
21
  import '@dynamic-labs/multi-wallet';
22
- import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
22
+ import { getMinAuthToken } from '../../functions/getMinAuthToken/getMinAuthToken.js';
23
23
  import 'react-international-phone';
24
24
  import '../../../store/state/nonce/nonce.js';
25
25
  import '../../../store/state/projectSettings/projectSettings.js';
@@ -98,8 +98,8 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
98
98
 
99
99
  const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSettings) => {
100
100
  const apiBaseUrl = useApiBaseUrl();
101
- const authToken = getAuthToken();
102
- const { registerEmbeddedWalletSessionKey, removeSessionKey } = useEmbeddedWalletSessionKeys({ environmentId, projectSettings });
101
+ const authToken = getMinAuthToken();
102
+ const { registerEmbeddedWalletSessionKey, removeSessionKey, getSignedSessionId, } = useEmbeddedWalletSessionKeys({ environmentId, projectSettings });
103
103
  if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
104
104
  return;
105
105
  walletOptions.forEach((walletOption) => {
@@ -113,6 +113,7 @@ const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSett
113
113
  apiBaseUrl: apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : DEFAULT_WAAS_API_URL,
114
114
  authToken,
115
115
  environmentId,
116
+ getSignedSessionId,
116
117
  relayUrl: (_e = (_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.waas) === null || _d === void 0 ? void 0 : _d.relayUrl) !== null && _e !== void 0 ? _e : '',
117
118
  walletConnector: walletOption.walletConnector,
118
119
  });
@@ -0,0 +1 @@
1
+ export * from './useExchangeTokensForFunding';
@@ -0,0 +1,9 @@
1
+ import { Account } from '@dynamic-labs/sdk-api-core';
2
+ import { FundingTokenData } from '../../types';
3
+ type UseExchangeTokensForFundingProps = {
4
+ accounts: Account[];
5
+ };
6
+ export declare const useExchangeTokensForFunding: ({ accounts, }: UseExchangeTokensForFundingProps) => {
7
+ tokens: FundingTokenData[];
8
+ };
9
+ export {};