@dynamic-labs/sdk-react-core 4.50.5 → 4.51.2

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +14 -14
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.ts +1 -1
  7. package/src/index.js +1 -0
  8. package/src/lib/context/CaptchaContext/CaptchaContext.cjs +88 -1
  9. package/src/lib/context/CaptchaContext/CaptchaContext.js +88 -1
  10. package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +19 -0
  11. package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +20 -1
  12. package/src/lib/data/api/constants.cjs +12 -0
  13. package/src/lib/data/api/constants.d.ts +3 -0
  14. package/src/lib/data/api/constants.js +6 -0
  15. package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +12 -1
  16. package/src/lib/data/api/embeddedWallets/embeddedWallets.js +12 -1
  17. package/src/lib/data/api/user/user.cjs +19 -0
  18. package/src/lib/data/api/user/user.d.ts +5 -0
  19. package/src/lib/data/api/user/user.js +19 -1
  20. package/src/lib/store/stateConfig.cjs +39 -35
  21. package/src/lib/store/stateConfig.js +39 -35
  22. package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.cjs +33 -1
  23. package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.d.ts +11 -0
  24. package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.js +32 -2
  25. package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.cjs +1 -32
  26. package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.js +1 -32
  27. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -1
  28. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -1
  29. package/src/lib/utils/hooks/useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.cjs +1 -1
  30. package/src/lib/utils/hooks/useAuthenticatePasskeyMFA/useAuthenticatePasskeyMFA.js +1 -1
  31. package/src/lib/utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.cjs +1 -4
  32. package/src/lib/utils/hooks/useIsMfaRequiredForAction/useIsMfaRequiredForAction.js +1 -4
  33. package/src/lib/utils/hooks/useRegisterPasskey/useRegisterPasskey.cjs +8 -1
  34. package/src/lib/utils/hooks/useRegisterPasskey/useRegisterPasskey.js +8 -1
  35. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +2 -1
  36. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +4 -1
  37. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +2 -1
  38. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +1 -1
  39. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +1 -1
  40. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +1 -1
  41. package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.cjs +131 -0
  42. package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.d.ts +6 -0
  43. package/src/lib/utils/hooks/useUserUpdateRequest/unlinkUserEmail/unlinkUserEmail.js +127 -0
  44. package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +3 -1
  45. package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.d.ts +2 -0
  46. package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +3 -1
  47. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +38 -15
  48. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.d.ts +8 -2
  49. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +38 -15
  50. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +14 -2
  51. package/src/lib/views/SendBalanceView/SendBalanceView.js +15 -3
  52. package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.cjs +10 -2
  53. package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.js +10 -2
  54. package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.cjs +18 -18
  55. package/src/lib/widgets/DynamicWidget/views/WalletsDelegatedSettingsView/WalletsDelegatedSettingsView.js +18 -18
@@ -6,41 +6,45 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  /**
7
7
  * Returns the initial state for the SdkStore
8
8
  */
9
- const createInitialState = (dynamicContextProps) => ({
10
- authMode: 'connect-and-sign',
11
- connectedWalletsInfo: [],
12
- connectorsInitializing: {},
13
- dynamicContextProps,
14
- loadingAndLifecycle: {
15
- initialWalletVerificationInProgress: false,
16
- sessionValidation: false,
17
- },
18
- multichainTokenBalancesState: {
19
- error: undefined,
20
- isError: false,
21
- isLoading: false,
22
- multichainTokenBalances: undefined,
23
- requestsKey: undefined,
24
- },
25
- nonce: { expiresAt: undefined, nonce: undefined },
26
- primaryWalletId: undefined,
27
- sendBalanceState: {
28
- amount: undefined,
29
- chainName: undefined,
30
- nativePrice: undefined,
31
- },
32
- tokenBalancesState: {
33
- error: undefined,
34
- isError: false,
35
- isLoading: false,
36
- tokenBalances: undefined,
37
- },
38
- user: undefined,
39
- walletOptions: {
40
- groups: {},
41
- walletConnectorOptions: [],
42
- },
43
- });
9
+ const createInitialState = (dynamicContextProps) => {
10
+ var _a, _b;
11
+ const initialAuthMode = (_b = (_a = dynamicContextProps.settings) === null || _a === void 0 ? void 0 : _a.initialAuthenticationMode) !== null && _b !== void 0 ? _b : 'connect-and-sign';
12
+ return {
13
+ authMode: initialAuthMode,
14
+ connectedWalletsInfo: [],
15
+ connectorsInitializing: {},
16
+ dynamicContextProps,
17
+ loadingAndLifecycle: {
18
+ initialWalletVerificationInProgress: false,
19
+ sessionValidation: false,
20
+ },
21
+ multichainTokenBalancesState: {
22
+ error: undefined,
23
+ isError: false,
24
+ isLoading: false,
25
+ multichainTokenBalances: undefined,
26
+ requestsKey: undefined,
27
+ },
28
+ nonce: { expiresAt: undefined, nonce: undefined },
29
+ primaryWalletId: undefined,
30
+ sendBalanceState: {
31
+ amount: undefined,
32
+ chainName: undefined,
33
+ nativePrice: undefined,
34
+ },
35
+ tokenBalancesState: {
36
+ error: undefined,
37
+ isError: false,
38
+ isLoading: false,
39
+ tokenBalances: undefined,
40
+ },
41
+ user: undefined,
42
+ walletOptions: {
43
+ groups: {},
44
+ walletConnectorOptions: [],
45
+ },
46
+ };
47
+ };
44
48
  /**
45
49
  * Filters out which variables should be stored to local storage.
46
50
  * Also allows transforming them before storage.
@@ -2,41 +2,45 @@
2
2
  /**
3
3
  * Returns the initial state for the SdkStore
4
4
  */
5
- const createInitialState = (dynamicContextProps) => ({
6
- authMode: 'connect-and-sign',
7
- connectedWalletsInfo: [],
8
- connectorsInitializing: {},
9
- dynamicContextProps,
10
- loadingAndLifecycle: {
11
- initialWalletVerificationInProgress: false,
12
- sessionValidation: false,
13
- },
14
- multichainTokenBalancesState: {
15
- error: undefined,
16
- isError: false,
17
- isLoading: false,
18
- multichainTokenBalances: undefined,
19
- requestsKey: undefined,
20
- },
21
- nonce: { expiresAt: undefined, nonce: undefined },
22
- primaryWalletId: undefined,
23
- sendBalanceState: {
24
- amount: undefined,
25
- chainName: undefined,
26
- nativePrice: undefined,
27
- },
28
- tokenBalancesState: {
29
- error: undefined,
30
- isError: false,
31
- isLoading: false,
32
- tokenBalances: undefined,
33
- },
34
- user: undefined,
35
- walletOptions: {
36
- groups: {},
37
- walletConnectorOptions: [],
38
- },
39
- });
5
+ const createInitialState = (dynamicContextProps) => {
6
+ var _a, _b;
7
+ const initialAuthMode = (_b = (_a = dynamicContextProps.settings) === null || _a === void 0 ? void 0 : _a.initialAuthenticationMode) !== null && _b !== void 0 ? _b : 'connect-and-sign';
8
+ return {
9
+ authMode: initialAuthMode,
10
+ connectedWalletsInfo: [],
11
+ connectorsInitializing: {},
12
+ dynamicContextProps,
13
+ loadingAndLifecycle: {
14
+ initialWalletVerificationInProgress: false,
15
+ sessionValidation: false,
16
+ },
17
+ multichainTokenBalancesState: {
18
+ error: undefined,
19
+ isError: false,
20
+ isLoading: false,
21
+ multichainTokenBalances: undefined,
22
+ requestsKey: undefined,
23
+ },
24
+ nonce: { expiresAt: undefined, nonce: undefined },
25
+ primaryWalletId: undefined,
26
+ sendBalanceState: {
27
+ amount: undefined,
28
+ chainName: undefined,
29
+ nativePrice: undefined,
30
+ },
31
+ tokenBalancesState: {
32
+ error: undefined,
33
+ isError: false,
34
+ isLoading: false,
35
+ tokenBalances: undefined,
36
+ },
37
+ user: undefined,
38
+ walletOptions: {
39
+ groups: {},
40
+ walletConnectorOptions: [],
41
+ },
42
+ };
43
+ };
40
44
  /**
41
45
  * Filters out which variables should be stored to local storage.
42
46
  * Also allows transforming them before storage.
@@ -18,7 +18,20 @@ require('../../constants/colors.cjs');
18
18
  require('../../constants/values.cjs');
19
19
  require('@dynamic-labs/sdk-api-core');
20
20
  require('../../../shared/consts/index.cjs');
21
+ require('@dynamic-labs-sdk/client/core');
22
+ require('../../../client/client.cjs');
23
+ require('@dynamic-labs-sdk/client');
24
+ require('../../../config/ApiEndpoint.cjs');
25
+ require('@dynamic-labs/multi-wallet');
26
+ require('react-international-phone');
27
+ require('../../../store/state/nonce/nonce.cjs');
28
+ require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
29
+ require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
30
+ require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
21
31
  var constants = require('./constants.cjs');
32
+ require('../../../events/dynamicEvents.cjs');
33
+ var utils$1 = require('../../../data/api/utils.cjs');
34
+ require('@dynamic-labs/locale');
22
35
 
23
36
  const getClientSessionKeys = () => {
24
37
  const sessionKeysSS = utils.StorageService.getItem(sessionStorage.CLIENT_SESSION_KEYS, sessionStorage.CLIENT_SESSION_KEYS_STORAGE_OPTIONS);
@@ -42,6 +55,7 @@ const generateKeyPair = () => _tslib.__awaiter(void 0, void 0, void 0, function*
42
55
  return { privateKey, privateKeyJwk: privateJwk, publicKey };
43
56
  });
44
57
  const generateSessionSignature = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ privateKeyJwk, sessionId, }) { return keyService.p256Sign(privateKeyJwk, sessionId); });
58
+ const generateNonceSignature = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ privateKeyJwk, nonce, }) { return keyService.p256Sign(privateKeyJwk, nonce); });
45
59
  const generateClientSessionKeys = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
46
60
  // check if session keys are already stored in session storage
47
61
  const clientSessionKeysSS = getClientSessionKeys();
@@ -62,7 +76,7 @@ const getClientSessionPublicKey = () => {
62
76
  const clientSessionKeys = getClientSessionKeys();
63
77
  return clientSessionKeys === null || clientSessionKeys === void 0 ? void 0 : clientSessionKeys.publicKey;
64
78
  };
65
- const getClientSessionSignature = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ sessionId, }) {
79
+ const getClientSessionSignature = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ sessionId, }) {
66
80
  const clientSessionKeys = getClientSessionKeys();
67
81
  if (!clientSessionKeys) {
68
82
  throw new Error('Client session keys not found');
@@ -74,6 +88,22 @@ const getClientSessionSignature = (_b) => _tslib.__awaiter(void 0, [_b], void 0,
74
88
  });
75
89
  return { publicKey, sessionSignature };
76
90
  });
91
+ const getClientSessionNonceSignature = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ environmentId, }) {
92
+ const clientSessionKeys = getClientSessionKeys();
93
+ if (!clientSessionKeys) {
94
+ throw new Error('Client session keys not found');
95
+ }
96
+ const { publicKey, privateKeyJwk } = clientSessionKeys;
97
+ const nonce = yield utils$1.getNonce(environmentId);
98
+ if (!nonce) {
99
+ throw new Error('Nonce not found');
100
+ }
101
+ const nonceSignature = yield generateNonceSignature({
102
+ nonce,
103
+ privateKeyJwk,
104
+ });
105
+ return { nonce, nonceSignature, publicKey };
106
+ });
77
107
  const clearClientSessionKeys = () => {
78
108
  const clientSessionKeys = getClientSessionKeys();
79
109
  logger.logger.instrument('[SessionChaining] Clearing client session keys', {
@@ -87,7 +117,9 @@ const clearClientSessionKeys = () => {
87
117
  exports.clearClientSessionKeys = clearClientSessionKeys;
88
118
  exports.generateClientSessionKeys = generateClientSessionKeys;
89
119
  exports.generateKeyPair = generateKeyPair;
120
+ exports.generateNonceSignature = generateNonceSignature;
90
121
  exports.generateSessionSignature = generateSessionSignature;
91
122
  exports.getClientSessionKeys = getClientSessionKeys;
123
+ exports.getClientSessionNonceSignature = getClientSessionNonceSignature;
92
124
  exports.getClientSessionPublicKey = getClientSessionPublicKey;
93
125
  exports.getClientSessionSignature = getClientSessionSignature;
@@ -5,6 +5,10 @@ export declare const generateSessionSignature: ({ privateKeyJwk, sessionId, }: {
5
5
  privateKeyJwk: JsonWebKey;
6
6
  sessionId: string;
7
7
  }) => Promise<string>;
8
+ export declare const generateNonceSignature: ({ privateKeyJwk, nonce, }: {
9
+ privateKeyJwk: JsonWebKey;
10
+ nonce: string;
11
+ }) => Promise<string>;
8
12
  export declare const generateClientSessionKeys: () => Promise<{
9
13
  publicKey: string;
10
14
  }>;
@@ -15,4 +19,11 @@ export declare const getClientSessionSignature: ({ sessionId, }: {
15
19
  publicKey: string;
16
20
  sessionSignature: string;
17
21
  }>;
22
+ export declare const getClientSessionNonceSignature: ({ environmentId, }: {
23
+ environmentId: string;
24
+ }) => Promise<{
25
+ nonce: string;
26
+ nonceSignature: string;
27
+ publicKey: string;
28
+ }>;
18
29
  export declare const clearClientSessionKeys: () => void;
@@ -14,7 +14,20 @@ import '../../constants/colors.js';
14
14
  import '../../constants/values.js';
15
15
  import '@dynamic-labs/sdk-api-core';
16
16
  import '../../../shared/consts/index.js';
17
+ import '@dynamic-labs-sdk/client/core';
18
+ import '../../../client/client.js';
19
+ import '@dynamic-labs-sdk/client';
20
+ import '../../../config/ApiEndpoint.js';
21
+ import '@dynamic-labs/multi-wallet';
22
+ import 'react-international-phone';
23
+ import '../../../store/state/nonce/nonce.js';
24
+ import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
25
+ import '../../../store/state/primaryWalletId/primaryWalletId.js';
26
+ import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
17
27
  import { clientSessionKeyLogScope } from './constants.js';
28
+ import '../../../events/dynamicEvents.js';
29
+ import { getNonce } from '../../../data/api/utils.js';
30
+ import '@dynamic-labs/locale';
18
31
 
19
32
  const getClientSessionKeys = () => {
20
33
  const sessionKeysSS = StorageService.getItem(CLIENT_SESSION_KEYS, CLIENT_SESSION_KEYS_STORAGE_OPTIONS);
@@ -38,6 +51,7 @@ const generateKeyPair = () => __awaiter(void 0, void 0, void 0, function* () {
38
51
  return { privateKey, privateKeyJwk: privateJwk, publicKey };
39
52
  });
40
53
  const generateSessionSignature = (_a) => __awaiter(void 0, [_a], void 0, function* ({ privateKeyJwk, sessionId, }) { return p256Sign(privateKeyJwk, sessionId); });
54
+ const generateNonceSignature = (_b) => __awaiter(void 0, [_b], void 0, function* ({ privateKeyJwk, nonce, }) { return p256Sign(privateKeyJwk, nonce); });
41
55
  const generateClientSessionKeys = () => __awaiter(void 0, void 0, void 0, function* () {
42
56
  // check if session keys are already stored in session storage
43
57
  const clientSessionKeysSS = getClientSessionKeys();
@@ -58,7 +72,7 @@ const getClientSessionPublicKey = () => {
58
72
  const clientSessionKeys = getClientSessionKeys();
59
73
  return clientSessionKeys === null || clientSessionKeys === void 0 ? void 0 : clientSessionKeys.publicKey;
60
74
  };
61
- const getClientSessionSignature = (_b) => __awaiter(void 0, [_b], void 0, function* ({ sessionId, }) {
75
+ const getClientSessionSignature = (_c) => __awaiter(void 0, [_c], void 0, function* ({ sessionId, }) {
62
76
  const clientSessionKeys = getClientSessionKeys();
63
77
  if (!clientSessionKeys) {
64
78
  throw new Error('Client session keys not found');
@@ -70,6 +84,22 @@ const getClientSessionSignature = (_b) => __awaiter(void 0, [_b], void 0, functi
70
84
  });
71
85
  return { publicKey, sessionSignature };
72
86
  });
87
+ const getClientSessionNonceSignature = (_d) => __awaiter(void 0, [_d], void 0, function* ({ environmentId, }) {
88
+ const clientSessionKeys = getClientSessionKeys();
89
+ if (!clientSessionKeys) {
90
+ throw new Error('Client session keys not found');
91
+ }
92
+ const { publicKey, privateKeyJwk } = clientSessionKeys;
93
+ const nonce = yield getNonce(environmentId);
94
+ if (!nonce) {
95
+ throw new Error('Nonce not found');
96
+ }
97
+ const nonceSignature = yield generateNonceSignature({
98
+ nonce,
99
+ privateKeyJwk,
100
+ });
101
+ return { nonce, nonceSignature, publicKey };
102
+ });
73
103
  const clearClientSessionKeys = () => {
74
104
  const clientSessionKeys = getClientSessionKeys();
75
105
  logger.instrument('[SessionChaining] Clearing client session keys', {
@@ -80,4 +110,4 @@ const clearClientSessionKeys = () => {
80
110
  StorageService.removeItem(CLIENT_SESSION_KEYS, CLIENT_SESSION_KEYS_STORAGE_OPTIONS);
81
111
  };
82
112
 
83
- export { clearClientSessionKeys, generateClientSessionKeys, generateKeyPair, generateSessionSignature, getClientSessionKeys, getClientSessionPublicKey, getClientSessionSignature };
113
+ export { clearClientSessionKeys, generateClientSessionKeys, generateKeyPair, generateNonceSignature, generateSessionSignature, getClientSessionKeys, getClientSessionNonceSignature, getClientSessionPublicKey, getClientSessionSignature };
@@ -3,42 +3,11 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- require('@dynamic-labs-sdk/client/core');
7
- require('@dynamic-labs/sdk-api-core');
8
- require('../../../../client/client.cjs');
9
- require('react');
10
- require('@dynamic-labs-sdk/client');
11
- require('../../../../config/ApiEndpoint.cjs');
12
- require('@dynamic-labs/iconic');
13
- require('@dynamic-labs/wallet-connector-core');
14
- require('react/jsx-runtime');
15
- require('../../../../context/ViewContext/ViewContext.cjs');
16
- require('../../../../shared/logger.cjs');
17
- require('@dynamic-labs/wallet-book');
18
- require('@dynamic-labs/utils');
19
- require('../../../constants/colors.cjs');
20
- require('../../../constants/values.cjs');
21
- require('../../../../shared/consts/index.cjs');
22
- require('../../../../../../_virtual/_tslib.cjs');
23
- require('@dynamic-labs/multi-wallet');
24
- require('react-international-phone');
25
- require('../../../../store/state/nonce/nonce.cjs');
26
- require('@dynamic-labs/locale');
27
- require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
28
- require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
29
- require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
30
- require('../../../../events/dynamicEvents.cjs');
31
- var getUserProfile = require('../../../../client/extension/user/getUserProfile/getUserProfile.cjs');
32
6
  var authMode = require('../../../../store/state/authMode/authMode.cjs');
33
7
 
34
8
  const isConnectOnly = () => {
35
9
  const authMode$1 = authMode.getAuthMode();
36
- const user = getUserProfile.getUserProfile();
37
- // we need to check for user because of connect-only (authenticated)
38
- // and linking a new wallet in mutliwallet
39
- const linking = user !== undefined;
40
- const connectOnly = authMode$1 === 'connect-only' && !linking;
41
- return connectOnly;
10
+ return authMode$1 === 'connect-only';
42
11
  };
43
12
 
44
13
  exports.isConnectOnly = isConnectOnly;
@@ -1,40 +1,9 @@
1
1
  'use client'
2
- import '@dynamic-labs-sdk/client/core';
3
- import '@dynamic-labs/sdk-api-core';
4
- import '../../../../client/client.js';
5
- import 'react';
6
- import '@dynamic-labs-sdk/client';
7
- import '../../../../config/ApiEndpoint.js';
8
- import '@dynamic-labs/iconic';
9
- import '@dynamic-labs/wallet-connector-core';
10
- import 'react/jsx-runtime';
11
- import '../../../../context/ViewContext/ViewContext.js';
12
- import '../../../../shared/logger.js';
13
- import '@dynamic-labs/wallet-book';
14
- import '@dynamic-labs/utils';
15
- import '../../../constants/colors.js';
16
- import '../../../constants/values.js';
17
- import '../../../../shared/consts/index.js';
18
- import '../../../../../../_virtual/_tslib.js';
19
- import '@dynamic-labs/multi-wallet';
20
- import 'react-international-phone';
21
- import '../../../../store/state/nonce/nonce.js';
22
- import '@dynamic-labs/locale';
23
- import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
24
- import '../../../../store/state/primaryWalletId/primaryWalletId.js';
25
- import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
26
- import '../../../../events/dynamicEvents.js';
27
- import { getUserProfile } from '../../../../client/extension/user/getUserProfile/getUserProfile.js';
28
2
  import { getAuthMode } from '../../../../store/state/authMode/authMode.js';
29
3
 
30
4
  const isConnectOnly = () => {
31
5
  const authMode = getAuthMode();
32
- const user = getUserProfile();
33
- // we need to check for user because of connect-only (authenticated)
34
- // and linking a new wallet in mutliwallet
35
- const linking = user !== undefined;
36
- const connectOnly = authMode === 'connect-only' && !linking;
37
- return connectOnly;
6
+ return authMode === 'connect-only';
38
7
  };
39
8
 
40
9
  export { isConnectOnly };
@@ -115,7 +115,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
115
115
  const { pushView, clearStackAndPushInitialView, replaceView } = ViewContext.useViewContext();
116
116
  const { engageCaptcha, getCaptchaToken } = CaptchaContext.useCaptchaContext();
117
117
  const { setErrorMessage, setError, setDefaultError } = ErrorContext.useErrorContext();
118
- const { connectWallet, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, walletUiUtils, } = useInternalDynamicContext.useInternalDynamicContext();
118
+ const { connectWallet, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, setShowAuthFlow, walletUiUtils, } = useInternalDynamicContext.useInternalDynamicContext();
119
119
  const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
120
120
  const verifyWallet = useVerifyWallet.useVerifyWallet({
121
121
  displaySiweStatement,
@@ -127,6 +127,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
127
127
  if (!walletConnectorCore.isEmailWalletConnector(walletConnector) ||
128
128
  walletConnectorCore.isBloctoConnector(walletConnector)) {
129
129
  replaceView('pending-signature');
130
+ setShowAuthFlow(true);
130
131
  }
131
132
  else {
132
133
  walletUiUtils.disabledConfirmationOnce();
@@ -111,7 +111,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
111
111
  const { pushView, clearStackAndPushInitialView, replaceView } = useViewContext();
112
112
  const { engageCaptcha, getCaptchaToken } = useCaptchaContext();
113
113
  const { setErrorMessage, setError, setDefaultError } = useErrorContext();
114
- const { connectWallet, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, walletUiUtils, } = useInternalDynamicContext();
114
+ const { connectWallet, displaySiweStatement, environmentId, projectSettings, networkValidationMode, setIsSingleWalletAccount, setShowAuthFlow, walletUiUtils, } = useInternalDynamicContext();
115
115
  const { handleWalletsToConnect } = useHandleWalletsToConnect();
116
116
  const verifyWallet = useVerifyWallet({
117
117
  displaySiweStatement,
@@ -123,6 +123,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
123
123
  if (!isEmailWalletConnector(walletConnector) ||
124
124
  isBloctoConnector(walletConnector)) {
125
125
  replaceView('pending-signature');
126
+ setShowAuthFlow(true);
126
127
  }
127
128
  else {
128
129
  walletUiUtils.disabledConfirmationOnce();
@@ -36,6 +36,6 @@ const useAuthenticatePasskeyMFA = () => React.useCallback((props) => _tslib.__aw
36
36
  mfaToken: result.mfaToken,
37
37
  });
38
38
  return result.mfaToken;
39
- }), [dynamicEvents.dynamicEvents]);
39
+ }), []);
40
40
 
41
41
  exports.useAuthenticatePasskeyMFA = useAuthenticatePasskeyMFA;
@@ -32,6 +32,6 @@ const useAuthenticatePasskeyMFA = () => useCallback((props) => __awaiter(void 0,
32
32
  mfaToken: result.mfaToken,
33
33
  });
34
34
  return result.mfaToken;
35
- }), [dynamicEvents]);
35
+ }), []);
36
36
 
37
37
  export { useAuthenticatePasskeyMFA };
@@ -26,9 +26,6 @@ var client = require('@dynamic-labs-sdk/client');
26
26
  * );
27
27
  * }
28
28
  */
29
- const useIsMfaRequiredForAction = () => React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ mfaAction }) {
30
- const response = yield client.isMfaRequiredForAction({ mfaAction });
31
- return response !== null && response !== void 0 ? response : false;
32
- }), []);
29
+ const useIsMfaRequiredForAction = () => React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ mfaAction }) { return client.isMfaRequiredForAction({ mfaAction }); }), []);
33
30
 
34
31
  exports.useIsMfaRequiredForAction = useIsMfaRequiredForAction;
@@ -22,9 +22,6 @@ import { isMfaRequiredForAction } from '@dynamic-labs-sdk/client';
22
22
  * );
23
23
  * }
24
24
  */
25
- const useIsMfaRequiredForAction = () => useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ mfaAction }) {
26
- const response = yield isMfaRequiredForAction({ mfaAction });
27
- return response !== null && response !== void 0 ? response : false;
28
- }), []);
25
+ const useIsMfaRequiredForAction = () => useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ mfaAction }) { return isMfaRequiredForAction({ mfaAction }); }), []);
29
26
 
30
27
  export { useIsMfaRequiredForAction };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
7
7
  var React = require('react');
8
8
  var client = require('@dynamic-labs-sdk/client');
9
+ var dynamicEvents = require('../../../events/dynamicEvents.cjs');
9
10
 
10
11
  /**
11
12
  * Register passkey
@@ -26,6 +27,12 @@ var client = require('@dynamic-labs-sdk/client');
26
27
  * );
27
28
  * }
28
29
  */
29
- const useRegisterPasskey = () => React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () { return client.registerPasskey(); }), []);
30
+ const useRegisterPasskey = () => React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
31
+ const response = yield client.registerPasskey();
32
+ dynamicEvents.dynamicEvents.emit('mfaCompletionSuccess', {
33
+ mfaToken: response.mfaToken,
34
+ });
35
+ return response;
36
+ }), []);
30
37
 
31
38
  exports.useRegisterPasskey = useRegisterPasskey;
@@ -2,6 +2,7 @@
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { useCallback } from 'react';
4
4
  import { registerPasskey } from '@dynamic-labs-sdk/client';
5
+ import { dynamicEvents } from '../../../events/dynamicEvents.js';
5
6
 
6
7
  /**
7
8
  * Register passkey
@@ -22,6 +23,12 @@ import { registerPasskey } from '@dynamic-labs-sdk/client';
22
23
  * );
23
24
  * }
24
25
  */
25
- const useRegisterPasskey = () => useCallback(() => __awaiter(void 0, void 0, void 0, function* () { return registerPasskey(); }), []);
26
+ const useRegisterPasskey = () => useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
27
+ const response = yield registerPasskey();
28
+ dynamicEvents.emit('mfaCompletionSuccess', {
29
+ mfaToken: response.mfaToken,
30
+ });
31
+ return response;
32
+ }), []);
26
33
 
27
34
  export { useRegisterPasskey };
@@ -108,7 +108,7 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
108
108
  var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
109
109
 
110
110
  // Hook exposed to customers and used internally to handle social account linking
111
- const useSocialAccounts = () => {
111
+ const useSocialAccounts = ({ onError } = {}) => {
112
112
  var _a;
113
113
  const { environmentId, user, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
114
114
  const { pushView } = ViewContext.useViewContext();
@@ -132,6 +132,7 @@ const useSocialAccounts = () => {
132
132
  },
133
133
  }), [pushView, setSocialProvider]);
134
134
  const { handleError, setError, checkValidProvider, error, connectSocialAccount, } = useSocialAuth.useSocialAuth({
135
+ onError,
135
136
  onFarcasterUrl: handleFarcasterUrl,
136
137
  });
137
138
  const verifiedOAuthCredentialsMap = React.useMemo(() => {
@@ -21,7 +21,10 @@ type ConnectSocialProps = {
21
21
  */
22
22
  payingWithDynamic?: PayWithDynamicProps;
23
23
  };
24
- export declare const useSocialAccounts: () => {
24
+ type UseSocialAccountsProps = {
25
+ onError?: (error: unknown) => void;
26
+ };
27
+ export declare const useSocialAccounts: ({ onError }?: UseSocialAccountsProps) => {
25
28
  readonly error: import("@dynamic-labs/types").SocialOAuthError | undefined;
26
29
  readonly getAllLinkedAccounts: () => SocialAccountInformation[];
27
30
  readonly getLinkedAccountInformation: (provider: ProviderEnum, verifiedCredentialId?: string) => SocialAccountInformation | undefined;
@@ -104,7 +104,7 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
104
104
  import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
105
105
 
106
106
  // Hook exposed to customers and used internally to handle social account linking
107
- const useSocialAccounts = () => {
107
+ const useSocialAccounts = ({ onError } = {}) => {
108
108
  var _a;
109
109
  const { environmentId, user, projectSettings } = useInternalDynamicContext();
110
110
  const { pushView } = useViewContext();
@@ -128,6 +128,7 @@ const useSocialAccounts = () => {
128
128
  },
129
129
  }), [pushView, setSocialProvider]);
130
130
  const { handleError, setError, checkValidProvider, error, connectSocialAccount, } = useSocialAuth({
131
+ onError,
131
132
  onFarcasterUrl: handleFarcasterUrl,
132
133
  });
133
134
  const verifiedOAuthCredentialsMap = useMemo(() => {
@@ -159,7 +159,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
159
159
  }, [setContextError]);
160
160
  const onFailed = React.useCallback((provider, reason, options) => {
161
161
  setIsProcessing(false);
162
- onError === null || onError === void 0 ? void 0 : onError();
162
+ onError === null || onError === void 0 ? void 0 : onError(reason.error);
163
163
  onSettled === null || onSettled === void 0 ? void 0 : onSettled();
164
164
  if (provider && (options === null || options === void 0 ? void 0 : options.raiseAuthFailure))
165
165
  dynamicEvents.dynamicEvents.emit('authFailure', {
@@ -5,7 +5,7 @@ import { PayWithDynamicProps } from '../usePayWithDynamic/usePayWithDynamic';
5
5
  export type SocialAuthMode = 'link' | 'signin' | 'unlink';
6
6
  type UseSocialAuthProps = {
7
7
  onSettled?: () => void;
8
- onError?: () => void;
8
+ onError?: (error: unknown) => void;
9
9
  onFarcasterUrl?: (url: string) => void;
10
10
  };
11
11
  export type ConnectSocialAccountProps = {
@@ -155,7 +155,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
155
155
  }, [setContextError]);
156
156
  const onFailed = useCallback((provider, reason, options) => {
157
157
  setIsProcessing(false);
158
- onError === null || onError === void 0 ? void 0 : onError();
158
+ onError === null || onError === void 0 ? void 0 : onError(reason.error);
159
159
  onSettled === null || onSettled === void 0 ? void 0 : onSettled();
160
160
  if (provider && (options === null || options === void 0 ? void 0 : options.raiseAuthFailure))
161
161
  dynamicEvents.emit('authFailure', {