@dynamic-labs/sdk-react-core 4.71.0 → 4.72.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 +15 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/lib/client/extension/functions/generateChainingSignature/generateChainingSignature.cjs +15 -0
- package/src/lib/client/extension/functions/generateChainingSignature/generateChainingSignature.d.ts +1 -0
- package/src/lib/client/extension/functions/generateChainingSignature/generateChainingSignature.js +11 -0
- package/src/lib/client/extension/functions/generateSessionKeys/generateSessionKeys.cjs +11 -0
- package/src/lib/client/extension/functions/generateSessionKeys/generateSessionKeys.d.ts +1 -0
- package/src/lib/client/extension/functions/generateSessionKeys/generateSessionKeys.js +7 -0
- package/src/lib/client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.cjs +33 -0
- package/src/lib/client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.d.ts +16 -0
- package/src/lib/client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.js +29 -0
- package/src/lib/client/extension/functions/getSessionKeys/getSessionKeys.d.ts +1 -0
- package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.cjs +5 -9
- package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.d.ts +4 -0
- package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.js +6 -10
- package/src/lib/client/extension/functions/migrateClientSessionKey/migrateClientSessionKey.cjs +51 -0
- package/src/lib/client/extension/functions/migrateClientSessionKey/migrateClientSessionKey.d.ts +1 -0
- package/src/lib/client/extension/functions/migrateClientSessionKey/migrateClientSessionKey.js +47 -0
- package/src/lib/client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.cjs +5 -6
- package/src/lib/client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.js +5 -6
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.cjs +2 -0
- package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.js +2 -0
- package/src/lib/client/extension/index.d.ts +4 -0
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +2 -2
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +2 -2
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +2 -2
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +2 -2
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +2 -2
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +2 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +0 -3
- package/src/lib/context/DynamicContext/DynamicContext.js +0 -3
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +3 -4
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +3 -4
- package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +10 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +0 -2
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +0 -2
- package/src/lib/data/api/api.cjs +1 -1
- package/src/lib/data/api/api.js +1 -1
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +2 -4
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +2 -4
- package/src/lib/store/state/dynamicContextProps/defaultDynamicSettings.cjs +2 -0
- package/src/lib/store/state/dynamicContextProps/defaultDynamicSettings.d.ts +3 -3
- package/src/lib/store/state/dynamicContextProps/defaultDynamicSettings.js +2 -0
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.cjs +0 -88
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.d.ts +0 -25
- package/src/lib/utils/functions/clientSessionKeys/getClientSessionKeys.js +2 -83
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +0 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +0 -2
- package/src/lib/utils/hooks/index.d.ts +0 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +4 -12
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +4 -12
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +1 -1
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +2 -2
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +2 -2
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +2 -3
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +2 -3
- package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.cjs +14 -14
- package/src/lib/utils/hooks/useSignInWithPasskey/useSignInWithPasskey.js +14 -14
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +3 -3
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +3 -3
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +14 -38
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +14 -38
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.types.d.ts +3 -2
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptMfa.cjs +4 -1
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptMfa.js +4 -1
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptReauth.cjs +22 -6
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpPromptReauth.js +22 -6
- package/src/lib/utils/hooks/useSyncDeviceRegistrationFlow/useSyncDeviceRegistrationFlow.cjs +5 -1
- package/src/lib/utils/hooks/useSyncDeviceRegistrationFlow/useSyncDeviceRegistrationFlow.js +5 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +0 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +0 -2
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +1 -1
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -2
- package/src/lib/views/EmailVerification/EmailVerification.js +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +2 -2
- package/src/lib/views/StepUpReauthOtpView/StepUpReauthOtpView.cjs +1 -109
- package/src/lib/views/StepUpReauthOtpView/StepUpReauthOtpView.js +1 -109
- package/src/lib/views/StepUpReauthSocialView/StepUpReauthSocialView.cjs +1 -2
- package/src/lib/views/StepUpReauthSocialView/StepUpReauthSocialView.js +1 -2
- package/src/lib/views/StepUpReauthWalletView/StepUpReauthWalletView.cjs +2 -96
- package/src/lib/views/StepUpReauthWalletView/StepUpReauthWalletView.js +2 -96
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.d.ts +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.cjs +60 -5
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/EmbeddedWalletExportSection/EmbeddedWalletExportSection.js +61 -6
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +12 -54
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +12 -54
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.js +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.js +2 -2
- package/src/lib/utils/functions/clientSessionKeys/constants.cjs +0 -8
- package/src/lib/utils/functions/clientSessionKeys/constants.js +0 -4
- package/src/lib/utils/hooks/useClientSessionKeys/index.d.ts +0 -1
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +0 -101
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.d.ts +0 -4
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +0 -97
|
@@ -23,10 +23,10 @@ import { createSmsVerification, signInWithSmsVerification } from '../../../data/
|
|
|
23
23
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
24
24
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
25
25
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
26
|
-
import { generateClientSessionKeys } from '../../../utils/functions/clientSessionKeys/getClientSessionKeys.js';
|
|
27
26
|
import '../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
28
27
|
import '../../../events/dynamicEvents.js';
|
|
29
28
|
import { storeTokenAndUser } from '../../../client/extension/storeTokenAndUser/storeTokenAndUser.js';
|
|
29
|
+
import { generateSessionKeys } from '../../../client/extension/functions/generateSessionKeys/generateSessionKeys.js';
|
|
30
30
|
|
|
31
31
|
const createSmsHandler = (environmentId, { shouldRegisterSessionKeysOnSignin, generateSessionKey, }) => (phone, captchaToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
32
|
const { verificationUUID } = yield createSmsVerification({
|
|
@@ -44,7 +44,7 @@ const createSmsHandler = (environmentId, { shouldRegisterSessionKeysOnSignin, ge
|
|
|
44
44
|
const keypair = yield generateSessionKey();
|
|
45
45
|
sessionPublicKey = keypair.publicKey;
|
|
46
46
|
}
|
|
47
|
-
yield
|
|
47
|
+
yield generateSessionKeys();
|
|
48
48
|
const response = yield signInWithSmsVerification({
|
|
49
49
|
captchaToken,
|
|
50
50
|
environmentId,
|
|
@@ -88,7 +88,6 @@ require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
88
88
|
var useEndUserWarning = require('../../utils/hooks/useEndUserWarning/useEndUserWarning.cjs');
|
|
89
89
|
var useDeviceFingerprint = require('../../utils/hooks/useDeviceFingerprint/useDeviceFingerprint.cjs');
|
|
90
90
|
var useAggregateWalletEvents = require('../../utils/hooks/useAggregateWalletEvents/useAggregateWalletEvents.cjs');
|
|
91
|
-
var useClientSessionKeys = require('../../utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs');
|
|
92
91
|
require('../../utils/hooks/useGetMfaToken/useGetMfaToken.cjs');
|
|
93
92
|
var OnrampContext = require('../OnrampContext/OnrampContext.cjs');
|
|
94
93
|
require('../../../index.cjs');
|
|
@@ -238,8 +237,6 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
238
237
|
}
|
|
239
238
|
// Calculates and stores a device fingerprint
|
|
240
239
|
useDeviceFingerprint.useDeviceFingerprint();
|
|
241
|
-
// Generate client session keys
|
|
242
|
-
useClientSessionKeys.useClientSessionKeys();
|
|
243
240
|
const isAuthenticated = Boolean(user);
|
|
244
241
|
const [qrcodeUri, setQrcodeUri] = React.useState('');
|
|
245
242
|
const [desktopUri, setDesktopUri] = React.useState('');
|
|
@@ -84,7 +84,6 @@ import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
84
84
|
import { useEndUserWarning } from '../../utils/hooks/useEndUserWarning/useEndUserWarning.js';
|
|
85
85
|
import { useDeviceFingerprint } from '../../utils/hooks/useDeviceFingerprint/useDeviceFingerprint.js';
|
|
86
86
|
import { useAggregateWalletEvents } from '../../utils/hooks/useAggregateWalletEvents/useAggregateWalletEvents.js';
|
|
87
|
-
import { useClientSessionKeys } from '../../utils/hooks/useClientSessionKeys/useClientSessionKeys.js';
|
|
88
87
|
import '../../utils/hooks/useGetMfaToken/useGetMfaToken.js';
|
|
89
88
|
import { OnrampContextProvider } from '../OnrampContext/OnrampContext.js';
|
|
90
89
|
import '../../../index.js';
|
|
@@ -234,8 +233,6 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
234
233
|
}
|
|
235
234
|
// Calculates and stores a device fingerprint
|
|
236
235
|
useDeviceFingerprint();
|
|
237
|
-
// Generate client session keys
|
|
238
|
-
useClientSessionKeys();
|
|
239
236
|
const isAuthenticated = Boolean(user);
|
|
240
237
|
const [qrcodeUri, setQrcodeUri] = useState('');
|
|
241
238
|
const [desktopUri, setDesktopUri] = useState('');
|
|
@@ -35,7 +35,6 @@ require('../../../../config/ApiEndpoint.cjs');
|
|
|
35
35
|
require('../../../../events/dynamicEvents.cjs');
|
|
36
36
|
require('@dynamic-labs/locale');
|
|
37
37
|
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
38
|
-
var getClientSessionKeys = require('../../../../utils/functions/clientSessionKeys/getClientSessionKeys.cjs');
|
|
39
38
|
require('../../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
40
39
|
require('../../../AccessDeniedContext/AccessDeniedContext.cjs');
|
|
41
40
|
require('../../../AccountExistsContext/AccountExistsContext.cjs');
|
|
@@ -136,7 +135,6 @@ const useHandleLogout = (params) => {
|
|
|
136
135
|
utils.StorageService.removeItem(localStorage.EXCHANGE_PICKER_SEARCH_KEY);
|
|
137
136
|
utils.StorageService.removeItem(localStorage.PHANTOM_SIGNATURE_STATE);
|
|
138
137
|
utils.StorageService.removeItem(localStorage.DELEGATION_STATE);
|
|
139
|
-
getClientSessionKeys.clearClientSessionKeys();
|
|
140
138
|
authMode.setAuthMode(p.initialAuthenticationMode);
|
|
141
139
|
p.setShowAuthFlow(false, {
|
|
142
140
|
emitCancelAuth: false,
|
|
@@ -162,9 +160,10 @@ const useHandleLogout = (params) => {
|
|
|
162
160
|
}), [logoutReactSdk]);
|
|
163
161
|
/** Trigger a logout when the SDK failed to load data from storage */
|
|
164
162
|
React.useEffect(() => {
|
|
165
|
-
|
|
163
|
+
const handler = () => logout();
|
|
164
|
+
utils.StorageService.events.on('parseFailure', handler);
|
|
166
165
|
return () => {
|
|
167
|
-
utils.StorageService.events.off('parseFailure',
|
|
166
|
+
utils.StorageService.events.off('parseFailure', handler);
|
|
168
167
|
};
|
|
169
168
|
}, [logout]);
|
|
170
169
|
/** Allows triggering a logout from anywhere in the code */
|
|
@@ -31,7 +31,6 @@ import '../../../../config/ApiEndpoint.js';
|
|
|
31
31
|
import '../../../../events/dynamicEvents.js';
|
|
32
32
|
import '@dynamic-labs/locale';
|
|
33
33
|
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
34
|
-
import { clearClientSessionKeys } from '../../../../utils/functions/clientSessionKeys/getClientSessionKeys.js';
|
|
35
34
|
import '../../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
36
35
|
import '../../../AccessDeniedContext/AccessDeniedContext.js';
|
|
37
36
|
import '../../../AccountExistsContext/AccountExistsContext.js';
|
|
@@ -132,7 +131,6 @@ const useHandleLogout = (params) => {
|
|
|
132
131
|
StorageService.removeItem(EXCHANGE_PICKER_SEARCH_KEY);
|
|
133
132
|
StorageService.removeItem(PHANTOM_SIGNATURE_STATE);
|
|
134
133
|
StorageService.removeItem(DELEGATION_STATE);
|
|
135
|
-
clearClientSessionKeys();
|
|
136
134
|
setAuthMode(p.initialAuthenticationMode);
|
|
137
135
|
p.setShowAuthFlow(false, {
|
|
138
136
|
emitCancelAuth: false,
|
|
@@ -158,9 +156,10 @@ const useHandleLogout = (params) => {
|
|
|
158
156
|
}), [logoutReactSdk]);
|
|
159
157
|
/** Trigger a logout when the SDK failed to load data from storage */
|
|
160
158
|
useEffect(() => {
|
|
161
|
-
|
|
159
|
+
const handler = () => logout$1();
|
|
160
|
+
StorageService.events.on('parseFailure', handler);
|
|
162
161
|
return () => {
|
|
163
|
-
StorageService.events.off('parseFailure',
|
|
162
|
+
StorageService.events.off('parseFailure', handler);
|
|
164
163
|
};
|
|
165
164
|
}, [logout$1]);
|
|
166
165
|
/** Allows triggering a logout from anywhere in the code */
|
|
@@ -105,6 +105,16 @@ export interface DynamicContextProps {
|
|
|
105
105
|
* Hidden tokens will not count towards the user's total balance.
|
|
106
106
|
*/
|
|
107
107
|
tokensFilter?: (tokens: TokenBalance[]) => TokenBalance[];
|
|
108
|
+
/**
|
|
109
|
+
* Controls the device registration modal behavior.
|
|
110
|
+
* When set to { enabled: false }, the SDK will not automatically show the
|
|
111
|
+
* device registration modal. Customers can build their own headless experience
|
|
112
|
+
* using `isDeviceRegistrationRequired` from @dynamic-labs-sdk/client.
|
|
113
|
+
* @default { enabled: true }
|
|
114
|
+
*/
|
|
115
|
+
deviceRegistrationModal?: {
|
|
116
|
+
enabled: boolean;
|
|
117
|
+
};
|
|
108
118
|
transactionConfirmation?: TransactionConfirmationSettings;
|
|
109
119
|
/**
|
|
110
120
|
* If true, the Metamask SDK will be used to connect to the wallet.
|
|
@@ -24,7 +24,6 @@ var updatePrimaryWalletId = require('../../utils/functions/updatePrimaryWalletId
|
|
|
24
24
|
require('../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
25
25
|
require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
26
26
|
require('../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
27
|
-
var getClientSessionKeys = require('../../utils/functions/clientSessionKeys/getClientSessionKeys.cjs');
|
|
28
27
|
require('@dynamic-labs-sdk/client');
|
|
29
28
|
require('@dynamic-labs-sdk/client/core');
|
|
30
29
|
require('../../client/client.cjs');
|
|
@@ -239,7 +238,6 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
239
238
|
yield connectWallet(socialWalletConnector);
|
|
240
239
|
const address = yield socialWalletConnector.getAddress();
|
|
241
240
|
walletUiUtils.disabledConfirmationOnce();
|
|
242
|
-
yield getClientSessionKeys.generateClientSessionKeys();
|
|
243
241
|
yield verifyWallet({
|
|
244
242
|
captchaToken: getCaptchaToken(),
|
|
245
243
|
oauth: {
|
|
@@ -20,7 +20,6 @@ import { updatePrimaryWalletId } from '../../utils/functions/updatePrimaryWallet
|
|
|
20
20
|
import '../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
21
21
|
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
22
22
|
import '../../store/state/primaryWalletId/primaryWalletId.js';
|
|
23
|
-
import { generateClientSessionKeys } from '../../utils/functions/clientSessionKeys/getClientSessionKeys.js';
|
|
24
23
|
import '@dynamic-labs-sdk/client';
|
|
25
24
|
import '@dynamic-labs-sdk/client/core';
|
|
26
25
|
import '../../client/client.js';
|
|
@@ -235,7 +234,6 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
235
234
|
yield connectWallet(socialWalletConnector);
|
|
236
235
|
const address = yield socialWalletConnector.getAddress();
|
|
237
236
|
walletUiUtils.disabledConfirmationOnce();
|
|
238
|
-
yield generateClientSessionKeys();
|
|
239
237
|
yield verifyWallet({
|
|
240
238
|
captchaToken: getCaptchaToken(),
|
|
241
239
|
oauth: {
|
package/src/lib/data/api/api.cjs
CHANGED
|
@@ -19,10 +19,10 @@ require('@dynamic-labs/wallet-book');
|
|
|
19
19
|
require('../../utils/constants/colors.cjs');
|
|
20
20
|
require('../../utils/constants/values.cjs');
|
|
21
21
|
require('../../shared/consts/index.cjs');
|
|
22
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
22
23
|
var getApiHeaders = require('../../client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.cjs');
|
|
23
24
|
require('../../events/dynamicEvents.cjs');
|
|
24
25
|
var getProjectSettings = require('../../client/extension/projectSettings/getProjectSettings/getProjectSettings.cjs');
|
|
25
|
-
require('../../../../_virtual/_tslib.cjs');
|
|
26
26
|
var isCookieEnabled = require('../../client/extension/functions/isCookieEnabled/isCookieEnabled.cjs');
|
|
27
27
|
var getMinAuthToken = require('../../client/extension/functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
28
28
|
var createDeviceSignatureHeadersMiddleware = require('../../client/extension/functions/createDeviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.cjs');
|
package/src/lib/data/api/api.js
CHANGED
|
@@ -15,10 +15,10 @@ import '@dynamic-labs/wallet-book';
|
|
|
15
15
|
import '../../utils/constants/colors.js';
|
|
16
16
|
import '../../utils/constants/values.js';
|
|
17
17
|
import '../../shared/consts/index.js';
|
|
18
|
+
import '../../../../_virtual/_tslib.js';
|
|
18
19
|
import { getApiHeaders } from '../../client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.js';
|
|
19
20
|
import '../../events/dynamicEvents.js';
|
|
20
21
|
import { getProjectSettings } from '../../client/extension/projectSettings/getProjectSettings/getProjectSettings.js';
|
|
21
|
-
import '../../../../_virtual/_tslib.js';
|
|
22
22
|
import { isCookieEnabled } from '../../client/extension/functions/isCookieEnabled/isCookieEnabled.js';
|
|
23
23
|
import { getMinAuthToken } from '../../client/extension/functions/getMinAuthToken/getMinAuthToken.js';
|
|
24
24
|
import { createDeviceSignatureHeadersMiddleware } from '../../client/extension/functions/createDeviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.js';
|
|
@@ -29,10 +29,10 @@ require('@dynamic-labs/locale');
|
|
|
29
29
|
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
30
30
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
31
31
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
32
|
-
var getClientSessionKeys = require('../../../utils/functions/clientSessionKeys/getClientSessionKeys.cjs');
|
|
33
32
|
require('../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
34
33
|
require('../../../events/dynamicEvents.cjs');
|
|
35
34
|
var storeTokenAndUser = require('../../../client/extension/storeTokenAndUser/storeTokenAndUser.cjs');
|
|
35
|
+
var getClientSessionNonceHeaders = require('../../../client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.cjs');
|
|
36
36
|
|
|
37
37
|
const createTurnkeyEmbeddedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ attestation, challenge, environmentId, chains = [sdkApiCore.EmbeddedWalletChainEnum.Evm], passkeyAlias, sessionPublicKey, }) {
|
|
38
38
|
const embeddedWallets = [
|
|
@@ -159,9 +159,7 @@ const exportEmbeddedWallet = (_g) => _tslib.__awaiter(void 0, [_g], void 0, func
|
|
|
159
159
|
const registerSessionKey = (_h) => _tslib.__awaiter(void 0, [_h], void 0, function* ({ environmentId, walletId, publicKey, prevSessionKeySignature, }) {
|
|
160
160
|
let response;
|
|
161
161
|
try {
|
|
162
|
-
const { nonce, nonceSignature, publicKey: sessionPublicKey, } = yield
|
|
163
|
-
environmentId,
|
|
164
|
-
});
|
|
162
|
+
const { nonce, nonceSignature, publicKey: sessionPublicKey, } = yield getClientSessionNonceHeaders.getClientSessionNonceHeaders();
|
|
165
163
|
response = yield api.sdkApi({
|
|
166
164
|
customHeaders: {
|
|
167
165
|
[constants.DYNAMIC_SESSION_NONCE_HEADER]: nonce,
|
|
@@ -25,10 +25,10 @@ import '@dynamic-labs/locale';
|
|
|
25
25
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
26
26
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
27
27
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
28
|
-
import { getClientSessionNonceSignature } from '../../../utils/functions/clientSessionKeys/getClientSessionKeys.js';
|
|
29
28
|
import '../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
30
29
|
import '../../../events/dynamicEvents.js';
|
|
31
30
|
import { storeTokenAndUser } from '../../../client/extension/storeTokenAndUser/storeTokenAndUser.js';
|
|
31
|
+
import { getClientSessionNonceHeaders } from '../../../client/extension/functions/getClientSessionNonceHeaders/getClientSessionNonceHeaders.js';
|
|
32
32
|
|
|
33
33
|
const createTurnkeyEmbeddedWallet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ attestation, challenge, environmentId, chains = [EmbeddedWalletChainEnum.Evm], passkeyAlias, sessionPublicKey, }) {
|
|
34
34
|
const embeddedWallets = [
|
|
@@ -155,9 +155,7 @@ const exportEmbeddedWallet = (_g) => __awaiter(void 0, [_g], void 0, function* (
|
|
|
155
155
|
const registerSessionKey = (_h) => __awaiter(void 0, [_h], void 0, function* ({ environmentId, walletId, publicKey, prevSessionKeySignature, }) {
|
|
156
156
|
let response;
|
|
157
157
|
try {
|
|
158
|
-
const { nonce, nonceSignature, publicKey: sessionPublicKey, } = yield
|
|
159
|
-
environmentId,
|
|
160
|
-
});
|
|
158
|
+
const { nonce, nonceSignature, publicKey: sessionPublicKey, } = yield getClientSessionNonceHeaders();
|
|
161
159
|
response = yield sdkApi({
|
|
162
160
|
customHeaders: {
|
|
163
161
|
[DYNAMIC_SESSION_NONCE_HEADER]: nonce,
|
|
@@ -7,12 +7,14 @@ const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = '2762a57b-faa4-41ce-9f16-abff9300e2c9
|
|
|
7
7
|
/**
|
|
8
8
|
* These values will override undefined values in the dynamic context settings.
|
|
9
9
|
*/
|
|
10
|
+
const deviceRegistrationModalDefault = { enabled: true };
|
|
10
11
|
const defaultDynamicSettings = {
|
|
11
12
|
appLogoUrl: 'https://demo.dynamic.xyz/assets/dynamic-logo.svg',
|
|
12
13
|
appName: 'Dynamic Example',
|
|
13
14
|
debugError: false,
|
|
14
15
|
deepLinkPreference: 'native',
|
|
15
16
|
detectNewWalletsForLinking: false,
|
|
17
|
+
deviceRegistrationModal: deviceRegistrationModalDefault,
|
|
16
18
|
displaySiweStatement: true,
|
|
17
19
|
enableConnectOnlyFallback: false,
|
|
18
20
|
enableVisitTrackingOnConnectOnly: true,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = "2762a57b-faa4-41ce-9f16-abff9300e2c9";
|
|
2
|
-
/**
|
|
3
|
-
* These values will override undefined values in the dynamic context settings.
|
|
4
|
-
*/
|
|
5
2
|
export declare const defaultDynamicSettings: {
|
|
6
3
|
appLogoUrl: string;
|
|
7
4
|
appName: string;
|
|
8
5
|
debugError: false;
|
|
9
6
|
deepLinkPreference: "native";
|
|
10
7
|
detectNewWalletsForLinking: false;
|
|
8
|
+
deviceRegistrationModal: {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
};
|
|
11
11
|
displaySiweStatement: true;
|
|
12
12
|
enableConnectOnlyFallback: false;
|
|
13
13
|
enableVisitTrackingOnConnectOnly: true;
|
|
@@ -3,12 +3,14 @@ const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = '2762a57b-faa4-41ce-9f16-abff9300e2c9
|
|
|
3
3
|
/**
|
|
4
4
|
* These values will override undefined values in the dynamic context settings.
|
|
5
5
|
*/
|
|
6
|
+
const deviceRegistrationModalDefault = { enabled: true };
|
|
6
7
|
const defaultDynamicSettings = {
|
|
7
8
|
appLogoUrl: 'https://demo.dynamic.xyz/assets/dynamic-logo.svg',
|
|
8
9
|
appName: 'Dynamic Example',
|
|
9
10
|
debugError: false,
|
|
10
11
|
deepLinkPreference: 'native',
|
|
11
12
|
detectNewWalletsForLinking: false,
|
|
13
|
+
deviceRegistrationModal: deviceRegistrationModalDefault,
|
|
12
14
|
displaySiweStatement: true,
|
|
13
15
|
enableConnectOnlyFallback: false,
|
|
14
16
|
enableVisitTrackingOnConnectOnly: true,
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
6
|
var utils = require('@dynamic-labs/utils');
|
|
8
7
|
var sessionStorage = require('../../constants/sessionStorage.cjs');
|
|
9
|
-
var keyService = require('../keyService/keyService.cjs');
|
|
10
8
|
require('@dynamic-labs/iconic');
|
|
11
9
|
require('@dynamic-labs/wallet-connector-core');
|
|
12
10
|
require('react');
|
|
@@ -18,21 +16,6 @@ require('../../constants/colors.cjs');
|
|
|
18
16
|
require('../../constants/values.cjs');
|
|
19
17
|
require('@dynamic-labs/sdk-api-core');
|
|
20
18
|
require('../../../shared/consts/index.cjs');
|
|
21
|
-
require('@dynamic-labs-sdk/client');
|
|
22
|
-
require('@dynamic-labs-sdk/client/core');
|
|
23
|
-
require('../../../client/client.cjs');
|
|
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');
|
|
31
|
-
var constants = require('./constants.cjs');
|
|
32
|
-
require('../getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
33
|
-
require('../../../events/dynamicEvents.cjs');
|
|
34
|
-
var utils$1 = require('../../../data/api/utils.cjs');
|
|
35
|
-
require('@dynamic-labs/locale');
|
|
36
19
|
|
|
37
20
|
const getClientSessionKeys = () => {
|
|
38
21
|
const sessionKeysSS = utils.StorageService.getItem(sessionStorage.CLIENT_SESSION_KEYS, sessionStorage.CLIENT_SESSION_KEYS_STORAGE_OPTIONS);
|
|
@@ -41,70 +24,6 @@ const getClientSessionKeys = () => {
|
|
|
41
24
|
: undefined;
|
|
42
25
|
return decodedSessionKeys;
|
|
43
26
|
};
|
|
44
|
-
const generateKeyPair = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
const { private: privateKey, public: publicKey, privateJwk, } = yield keyService.p256Keygen();
|
|
46
|
-
// convert to base64 and store the session keys in session storage
|
|
47
|
-
utils.StorageService.setItem(sessionStorage.CLIENT_SESSION_KEYS, keyService.toEncodedFormat(publicKey, privateKey, privateJwk, false), sessionStorage.CLIENT_SESSION_KEYS_STORAGE_OPTIONS);
|
|
48
|
-
logger.logger.instrument('[SessionChaining] Generated new session key pair', {
|
|
49
|
-
key: 'generated_session_key_pair',
|
|
50
|
-
sessionPublicKey: publicKey,
|
|
51
|
-
time: 0,
|
|
52
|
-
});
|
|
53
|
-
utils.tracing.logEvent(constants.clientSessionKeyLogScope, 'Generated new session key pair', utils.tracing.formatObject({
|
|
54
|
-
publicKey,
|
|
55
|
-
}));
|
|
56
|
-
return { privateKey, privateKeyJwk: privateJwk, publicKey };
|
|
57
|
-
});
|
|
58
|
-
const generateSessionSignature = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ privateKeyJwk, sessionId, }) { return keyService.p256Sign(privateKeyJwk, sessionId); });
|
|
59
|
-
const generateNonceSignature = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ privateKeyJwk, nonce, }) { return keyService.p256Sign(privateKeyJwk, nonce); });
|
|
60
|
-
const generateClientSessionKeys = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
-
// check if session keys are already stored in session storage
|
|
62
|
-
const clientSessionKeysSS = getClientSessionKeys();
|
|
63
|
-
utils.tracing.logEvent(constants.clientSessionKeyLogScope, 'getClientSessionKeys', utils.tracing.formatObject({
|
|
64
|
-
hasDecodedSessionKeys: Boolean(clientSessionKeysSS),
|
|
65
|
-
publicKey: clientSessionKeysSS === null || clientSessionKeysSS === void 0 ? void 0 : clientSessionKeysSS.publicKey,
|
|
66
|
-
}));
|
|
67
|
-
let publicKey;
|
|
68
|
-
if (clientSessionKeysSS) {
|
|
69
|
-
({ publicKey } = clientSessionKeysSS);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
({ publicKey } = yield generateKeyPair());
|
|
73
|
-
}
|
|
74
|
-
return { publicKey };
|
|
75
|
-
});
|
|
76
|
-
const getClientSessionPublicKey = () => {
|
|
77
|
-
const clientSessionKeys = getClientSessionKeys();
|
|
78
|
-
return clientSessionKeys === null || clientSessionKeys === void 0 ? void 0 : clientSessionKeys.publicKey;
|
|
79
|
-
};
|
|
80
|
-
const getClientSessionSignature = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ sessionId, }) {
|
|
81
|
-
const clientSessionKeys = getClientSessionKeys();
|
|
82
|
-
if (!clientSessionKeys) {
|
|
83
|
-
throw new Error('Client session keys not found');
|
|
84
|
-
}
|
|
85
|
-
const { publicKey, privateKeyJwk } = clientSessionKeys;
|
|
86
|
-
const sessionSignature = yield generateSessionSignature({
|
|
87
|
-
privateKeyJwk,
|
|
88
|
-
sessionId,
|
|
89
|
-
});
|
|
90
|
-
return { publicKey, sessionSignature };
|
|
91
|
-
});
|
|
92
|
-
const getClientSessionNonceSignature = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ environmentId, }) {
|
|
93
|
-
const clientSessionKeys = getClientSessionKeys();
|
|
94
|
-
if (!clientSessionKeys) {
|
|
95
|
-
throw new Error('Client session keys not found');
|
|
96
|
-
}
|
|
97
|
-
const { publicKey, privateKeyJwk } = clientSessionKeys;
|
|
98
|
-
const nonce = yield utils$1.getNonce(environmentId);
|
|
99
|
-
if (!nonce) {
|
|
100
|
-
throw new Error('Nonce not found');
|
|
101
|
-
}
|
|
102
|
-
const nonceSignature = yield generateNonceSignature({
|
|
103
|
-
nonce,
|
|
104
|
-
privateKeyJwk,
|
|
105
|
-
});
|
|
106
|
-
return { nonce, nonceSignature, publicKey };
|
|
107
|
-
});
|
|
108
27
|
const clearClientSessionKeys = () => {
|
|
109
28
|
const clientSessionKeys = getClientSessionKeys();
|
|
110
29
|
logger.logger.instrument('[SessionChaining] Clearing client session keys', {
|
|
@@ -116,11 +35,4 @@ const clearClientSessionKeys = () => {
|
|
|
116
35
|
};
|
|
117
36
|
|
|
118
37
|
exports.clearClientSessionKeys = clearClientSessionKeys;
|
|
119
|
-
exports.generateClientSessionKeys = generateClientSessionKeys;
|
|
120
|
-
exports.generateKeyPair = generateKeyPair;
|
|
121
|
-
exports.generateNonceSignature = generateNonceSignature;
|
|
122
|
-
exports.generateSessionSignature = generateSessionSignature;
|
|
123
38
|
exports.getClientSessionKeys = getClientSessionKeys;
|
|
124
|
-
exports.getClientSessionNonceSignature = getClientSessionNonceSignature;
|
|
125
|
-
exports.getClientSessionPublicKey = getClientSessionPublicKey;
|
|
126
|
-
exports.getClientSessionSignature = getClientSessionSignature;
|
|
@@ -1,29 +1,4 @@
|
|
|
1
1
|
import { ClientSessionKey } from './types';
|
|
2
2
|
export declare const getClientSessionKeys: () => ClientSessionKey | undefined;
|
|
3
|
-
export declare const generateKeyPair: () => Promise<ClientSessionKey>;
|
|
4
|
-
export declare const generateSessionSignature: ({ privateKeyJwk, sessionId, }: {
|
|
5
|
-
privateKeyJwk: JsonWebKey;
|
|
6
|
-
sessionId: string;
|
|
7
|
-
}) => Promise<string>;
|
|
8
|
-
export declare const generateNonceSignature: ({ privateKeyJwk, nonce, }: {
|
|
9
|
-
privateKeyJwk: JsonWebKey;
|
|
10
|
-
nonce: string;
|
|
11
|
-
}) => Promise<string>;
|
|
12
|
-
export declare const generateClientSessionKeys: () => Promise<{
|
|
13
|
-
publicKey: string;
|
|
14
|
-
}>;
|
|
15
3
|
export declare const getClientSessionPublicKey: () => string | undefined;
|
|
16
|
-
export declare const getClientSessionSignature: ({ sessionId, }: {
|
|
17
|
-
sessionId: string;
|
|
18
|
-
}) => Promise<{
|
|
19
|
-
publicKey: string;
|
|
20
|
-
sessionSignature: string;
|
|
21
|
-
}>;
|
|
22
|
-
export declare const getClientSessionNonceSignature: ({ environmentId, }: {
|
|
23
|
-
environmentId: string;
|
|
24
|
-
}) => Promise<{
|
|
25
|
-
nonce: string;
|
|
26
|
-
nonceSignature: string;
|
|
27
|
-
publicKey: string;
|
|
28
|
-
}>;
|
|
29
4
|
export declare const clearClientSessionKeys: () => void;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import {
|
|
3
|
-
import { StorageService, tracing } from '@dynamic-labs/utils';
|
|
2
|
+
import { StorageService } from '@dynamic-labs/utils';
|
|
4
3
|
import { CLIENT_SESSION_KEYS, CLIENT_SESSION_KEYS_STORAGE_OPTIONS } from '../../constants/sessionStorage.js';
|
|
5
|
-
import { p256Keygen, toEncodedFormat, p256Sign } from '../keyService/keyService.js';
|
|
6
4
|
import '@dynamic-labs/iconic';
|
|
7
5
|
import '@dynamic-labs/wallet-connector-core';
|
|
8
6
|
import 'react';
|
|
@@ -14,21 +12,6 @@ import '../../constants/colors.js';
|
|
|
14
12
|
import '../../constants/values.js';
|
|
15
13
|
import '@dynamic-labs/sdk-api-core';
|
|
16
14
|
import '../../../shared/consts/index.js';
|
|
17
|
-
import '@dynamic-labs-sdk/client';
|
|
18
|
-
import '@dynamic-labs-sdk/client/core';
|
|
19
|
-
import '../../../client/client.js';
|
|
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';
|
|
27
|
-
import { clientSessionKeyLogScope } from './constants.js';
|
|
28
|
-
import '../getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
29
|
-
import '../../../events/dynamicEvents.js';
|
|
30
|
-
import { getNonce } from '../../../data/api/utils.js';
|
|
31
|
-
import '@dynamic-labs/locale';
|
|
32
15
|
|
|
33
16
|
const getClientSessionKeys = () => {
|
|
34
17
|
const sessionKeysSS = StorageService.getItem(CLIENT_SESSION_KEYS, CLIENT_SESSION_KEYS_STORAGE_OPTIONS);
|
|
@@ -37,70 +20,6 @@ const getClientSessionKeys = () => {
|
|
|
37
20
|
: undefined;
|
|
38
21
|
return decodedSessionKeys;
|
|
39
22
|
};
|
|
40
|
-
const generateKeyPair = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
-
const { private: privateKey, public: publicKey, privateJwk, } = yield p256Keygen();
|
|
42
|
-
// convert to base64 and store the session keys in session storage
|
|
43
|
-
StorageService.setItem(CLIENT_SESSION_KEYS, toEncodedFormat(publicKey, privateKey, privateJwk, false), CLIENT_SESSION_KEYS_STORAGE_OPTIONS);
|
|
44
|
-
logger.instrument('[SessionChaining] Generated new session key pair', {
|
|
45
|
-
key: 'generated_session_key_pair',
|
|
46
|
-
sessionPublicKey: publicKey,
|
|
47
|
-
time: 0,
|
|
48
|
-
});
|
|
49
|
-
tracing.logEvent(clientSessionKeyLogScope, 'Generated new session key pair', tracing.formatObject({
|
|
50
|
-
publicKey,
|
|
51
|
-
}));
|
|
52
|
-
return { privateKey, privateKeyJwk: privateJwk, publicKey };
|
|
53
|
-
});
|
|
54
|
-
const generateSessionSignature = (_a) => __awaiter(void 0, [_a], void 0, function* ({ privateKeyJwk, sessionId, }) { return p256Sign(privateKeyJwk, sessionId); });
|
|
55
|
-
const generateNonceSignature = (_b) => __awaiter(void 0, [_b], void 0, function* ({ privateKeyJwk, nonce, }) { return p256Sign(privateKeyJwk, nonce); });
|
|
56
|
-
const generateClientSessionKeys = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
-
// check if session keys are already stored in session storage
|
|
58
|
-
const clientSessionKeysSS = getClientSessionKeys();
|
|
59
|
-
tracing.logEvent(clientSessionKeyLogScope, 'getClientSessionKeys', tracing.formatObject({
|
|
60
|
-
hasDecodedSessionKeys: Boolean(clientSessionKeysSS),
|
|
61
|
-
publicKey: clientSessionKeysSS === null || clientSessionKeysSS === void 0 ? void 0 : clientSessionKeysSS.publicKey,
|
|
62
|
-
}));
|
|
63
|
-
let publicKey;
|
|
64
|
-
if (clientSessionKeysSS) {
|
|
65
|
-
({ publicKey } = clientSessionKeysSS);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
({ publicKey } = yield generateKeyPair());
|
|
69
|
-
}
|
|
70
|
-
return { publicKey };
|
|
71
|
-
});
|
|
72
|
-
const getClientSessionPublicKey = () => {
|
|
73
|
-
const clientSessionKeys = getClientSessionKeys();
|
|
74
|
-
return clientSessionKeys === null || clientSessionKeys === void 0 ? void 0 : clientSessionKeys.publicKey;
|
|
75
|
-
};
|
|
76
|
-
const getClientSessionSignature = (_c) => __awaiter(void 0, [_c], void 0, function* ({ sessionId, }) {
|
|
77
|
-
const clientSessionKeys = getClientSessionKeys();
|
|
78
|
-
if (!clientSessionKeys) {
|
|
79
|
-
throw new Error('Client session keys not found');
|
|
80
|
-
}
|
|
81
|
-
const { publicKey, privateKeyJwk } = clientSessionKeys;
|
|
82
|
-
const sessionSignature = yield generateSessionSignature({
|
|
83
|
-
privateKeyJwk,
|
|
84
|
-
sessionId,
|
|
85
|
-
});
|
|
86
|
-
return { publicKey, sessionSignature };
|
|
87
|
-
});
|
|
88
|
-
const getClientSessionNonceSignature = (_d) => __awaiter(void 0, [_d], void 0, function* ({ environmentId, }) {
|
|
89
|
-
const clientSessionKeys = getClientSessionKeys();
|
|
90
|
-
if (!clientSessionKeys) {
|
|
91
|
-
throw new Error('Client session keys not found');
|
|
92
|
-
}
|
|
93
|
-
const { publicKey, privateKeyJwk } = clientSessionKeys;
|
|
94
|
-
const nonce = yield getNonce(environmentId);
|
|
95
|
-
if (!nonce) {
|
|
96
|
-
throw new Error('Nonce not found');
|
|
97
|
-
}
|
|
98
|
-
const nonceSignature = yield generateNonceSignature({
|
|
99
|
-
nonce,
|
|
100
|
-
privateKeyJwk,
|
|
101
|
-
});
|
|
102
|
-
return { nonce, nonceSignature, publicKey };
|
|
103
|
-
});
|
|
104
23
|
const clearClientSessionKeys = () => {
|
|
105
24
|
const clientSessionKeys = getClientSessionKeys();
|
|
106
25
|
logger.instrument('[SessionChaining] Clearing client session keys', {
|
|
@@ -111,4 +30,4 @@ const clearClientSessionKeys = () => {
|
|
|
111
30
|
StorageService.removeItem(CLIENT_SESSION_KEYS, CLIENT_SESSION_KEYS_STORAGE_OPTIONS);
|
|
112
31
|
};
|
|
113
32
|
|
|
114
|
-
export { clearClientSessionKeys,
|
|
33
|
+
export { clearClientSessionKeys, getClientSessionKeys };
|
|
@@ -74,7 +74,6 @@ export * from './getWalletUniqueId';
|
|
|
74
74
|
export * from './openPopup';
|
|
75
75
|
export * from './hasAllRequiredWalletsConnected';
|
|
76
76
|
export * from './isZKSyncEnabled';
|
|
77
|
-
export * from './clientSessionKeys';
|
|
78
77
|
export * from './usingV3Wallets';
|
|
79
78
|
export * from './isPasskeyProviderEnabled';
|
|
80
79
|
export * from './exportWalletCredential';
|
|
@@ -35,7 +35,6 @@ require('@dynamic-labs/locale');
|
|
|
35
35
|
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
36
36
|
require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
37
37
|
require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
38
|
-
var getClientSessionKeys = require('../../../functions/clientSessionKeys/getClientSessionKeys.cjs');
|
|
39
38
|
require('../../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
40
39
|
var useHandleWalletsToConnect = require('../../useHandleWalletsToConnect/useHandleWalletsToConnect.cjs');
|
|
41
40
|
var useVerifyWallet = require('../../useVerifyWallet/useVerifyWallet.cjs');
|
|
@@ -139,7 +138,6 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
139
138
|
else {
|
|
140
139
|
walletUiUtils.disabledConfirmationOnce();
|
|
141
140
|
}
|
|
142
|
-
yield getClientSessionKeys.generateClientSessionKeys();
|
|
143
141
|
return verifyWallet({
|
|
144
142
|
captchaToken,
|
|
145
143
|
publicWalletAddress,
|
|
@@ -31,7 +31,6 @@ import '@dynamic-labs/locale';
|
|
|
31
31
|
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
32
32
|
import '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
33
33
|
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
34
|
-
import { generateClientSessionKeys } from '../../../functions/clientSessionKeys/getClientSessionKeys.js';
|
|
35
34
|
import '../../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
36
35
|
import { useHandleWalletsToConnect } from '../../useHandleWalletsToConnect/useHandleWalletsToConnect.js';
|
|
37
36
|
import { useVerifyWallet } from '../../useVerifyWallet/useVerifyWallet.js';
|
|
@@ -135,7 +134,6 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
135
134
|
else {
|
|
136
135
|
walletUiUtils.disabledConfirmationOnce();
|
|
137
136
|
}
|
|
138
|
-
yield generateClientSessionKeys();
|
|
139
137
|
return verifyWallet({
|
|
140
138
|
captchaToken,
|
|
141
139
|
publicWalletAddress,
|
|
@@ -35,7 +35,6 @@ require('@dynamic-labs/locale');
|
|
|
35
35
|
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
36
36
|
require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
37
37
|
require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
38
|
-
var getClientSessionKeys = require('../../../functions/clientSessionKeys/getClientSessionKeys.cjs');
|
|
39
38
|
require('../../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
40
39
|
var useHandleWalletsToConnect = require('../../useHandleWalletsToConnect/useHandleWalletsToConnect.cjs');
|
|
41
40
|
var useVerifyWallet = require('../../useVerifyWallet/useVerifyWallet.cjs');
|
|
@@ -196,7 +195,6 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
196
195
|
}
|
|
197
196
|
return pushView('network-not-supported');
|
|
198
197
|
}
|
|
199
|
-
yield getClientSessionKeys.generateClientSessionKeys();
|
|
200
198
|
yield verifyWallet({
|
|
201
199
|
captchaToken: getCaptchaToken(),
|
|
202
200
|
publicWalletAddress: connectionResult.address,
|
|
@@ -31,7 +31,6 @@ import '@dynamic-labs/locale';
|
|
|
31
31
|
import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
32
32
|
import '../../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
33
33
|
import '../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
34
|
-
import { generateClientSessionKeys } from '../../../functions/clientSessionKeys/getClientSessionKeys.js';
|
|
35
34
|
import '../../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
36
35
|
import { useHandleWalletsToConnect } from '../../useHandleWalletsToConnect/useHandleWalletsToConnect.js';
|
|
37
36
|
import { useVerifyWallet } from '../../useVerifyWallet/useVerifyWallet.js';
|
|
@@ -192,7 +191,6 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
192
191
|
}
|
|
193
192
|
return pushView('network-not-supported');
|
|
194
193
|
}
|
|
195
|
-
yield generateClientSessionKeys();
|
|
196
194
|
yield verifyWallet({
|
|
197
195
|
captchaToken: getCaptchaToken(),
|
|
198
196
|
publicWalletAddress: connectionResult.address,
|