@dynamic-labs/sdk-react-core 4.64.0 → 4.66.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 +29 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/index.cjs +4 -0
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -0
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.cjs +1 -1
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.d.ts +5 -1
- package/src/lib/components/LegacySafariCssOverrides/LegacySafariCssOverrides.js +1 -1
- package/src/lib/components/ShadowDOM/ShadowDOM.cjs +6 -6
- package/src/lib/components/ShadowDOM/ShadowDOM.d.ts +4 -1
- package/src/lib/components/ShadowDOM/ShadowDOM.js +6 -6
- package/src/lib/context/DynamicContext/DynamicContext.cjs +4 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +4 -2
- package/src/lib/context/DynamicContext/types/DynamicContextProps.d.ts +6 -0
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +1 -0
- package/src/lib/context/DynamicContext/types/IInternalDynamicContext.d.ts +5 -1
- package/src/lib/context/ThemeContext/ThemeContext.cjs +3 -3
- package/src/lib/context/ThemeContext/ThemeContext.d.ts +1 -0
- package/src/lib/context/ThemeContext/ThemeContext.js +3 -3
- package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.cjs +8 -2
- package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.d.ts +2 -2
- package/src/lib/context/ThemeContext/utils/stylesheetBuilder/stylesheetBuilder.js +8 -2
- package/src/lib/data/api/wallets/wallets.cjs +62 -11
- package/src/lib/data/api/wallets/wallets.d.ts +1 -0
- package/src/lib/data/api/wallets/wallets.js +62 -12
- package/src/lib/shared/types/connectionAndSignature.d.ts +2 -1
- package/src/lib/shared/types/wallets.d.ts +2 -1
- package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
- package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +3 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -5
- package/src/lib/utils/hooks/index.d.ts +3 -0
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +4 -1
- package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +4 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +5 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +5 -2
- package/src/lib/utils/hooks/useSignEip7702Authorization/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.cjs +162 -0
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.d.ts +78 -0
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.js +158 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/index.d.ts +2 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +197 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.d.ts +51 -0
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +193 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +3 -1
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +3 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +8 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +9 -4
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.cjs +53 -1
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.d.ts +6 -0
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.js +53 -1
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +1 -1
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +1 -1
- package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.cjs +5 -21
- package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.js +5 -21
- package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.cjs +9 -1
- package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.js +9 -1
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.cjs +17 -21
- package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/MfaSection/MfaSection.js +17 -21
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.cjs +26 -5
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.js +26 -5
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.cjs +3 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.js +3 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.js +2 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.cjs +30 -22
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.d.ts +2 -1
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.js +30 -22
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
6
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
8
|
var React = require('react');
|
|
9
|
+
var reactI18next = require('react-i18next');
|
|
8
10
|
var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
9
11
|
var SetupPasswordConfirmView = require('../SetupPasswordConfirmView/SetupPasswordConfirmView.cjs');
|
|
10
12
|
var SetupPasswordEnterView = require('../SetupPasswordEnterView/SetupPasswordEnterView.cjs');
|
|
11
|
-
require('../../../../../../_virtual/_tslib.cjs');
|
|
12
13
|
require('@dynamic-labs/utils');
|
|
13
14
|
require('@dynamic-labs/iconic');
|
|
14
15
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
@@ -16,10 +17,13 @@ var SetupPasswordKnowledgeCheckView = require('../SetupPasswordKnowledgeCheckVie
|
|
|
16
17
|
var SetupPasswordSuccessView = require('../SetupPasswordSuccessView/SetupPasswordSuccessView.cjs');
|
|
17
18
|
var SetupPasswordTermsView = require('../SetupPasswordTermsView/SetupPasswordTermsView.cjs');
|
|
18
19
|
|
|
19
|
-
const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }) => {
|
|
20
|
+
const SetupPasswordView = ({ onComplete, onCancel, onDone, skipKnowledgeCheck = false, }) => {
|
|
21
|
+
const { t } = reactI18next.useTranslation();
|
|
20
22
|
const { setDynamicWidgetView, setIsOpen } = DynamicWidgetContext.useWidgetContext();
|
|
21
23
|
const [currentStep, setCurrentStep] = React.useState('terms');
|
|
22
24
|
const [password, setPassword] = React.useState('');
|
|
25
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
26
|
+
const [submitError, setSubmitError] = React.useState(null);
|
|
23
27
|
const goToAccountAndSecurity = React.useCallback(() => {
|
|
24
28
|
setDynamicWidgetView('account-and-security-settings');
|
|
25
29
|
}, [setDynamicWidgetView]);
|
|
@@ -41,20 +45,34 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
41
45
|
const handleEnterBack = React.useCallback(() => {
|
|
42
46
|
setCurrentStep('terms');
|
|
43
47
|
}, []);
|
|
44
|
-
const
|
|
45
|
-
|
|
48
|
+
const runOnComplete = React.useCallback((pwd) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
setIsSubmitting(true);
|
|
50
|
+
setSubmitError(null);
|
|
51
|
+
try {
|
|
52
|
+
yield onComplete(pwd);
|
|
46
53
|
setCurrentStep('success');
|
|
47
54
|
}
|
|
55
|
+
catch (_a) {
|
|
56
|
+
setSubmitError(t('dyn_setup_password.confirm.error.failed'));
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
setIsSubmitting(false);
|
|
60
|
+
}
|
|
61
|
+
}), [onComplete, t]);
|
|
62
|
+
const handleConfirmContinue = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
if (skipKnowledgeCheck) {
|
|
64
|
+
yield runOnComplete(password);
|
|
65
|
+
}
|
|
48
66
|
else {
|
|
49
67
|
setCurrentStep('knowledge-check');
|
|
50
68
|
}
|
|
51
|
-
}, [skipKnowledgeCheck]);
|
|
69
|
+
}), [skipKnowledgeCheck, runOnComplete, password]);
|
|
52
70
|
const handleConfirmBack = React.useCallback(() => {
|
|
53
71
|
setCurrentStep('enter');
|
|
54
72
|
}, []);
|
|
55
|
-
const handleKnowledgeCheckContinue = React.useCallback(() => {
|
|
56
|
-
|
|
57
|
-
}, []);
|
|
73
|
+
const handleKnowledgeCheckContinue = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
yield runOnComplete(password);
|
|
75
|
+
}), [runOnComplete, password]);
|
|
58
76
|
const handleKnowledgeCheckBack = React.useCallback(() => {
|
|
59
77
|
setCurrentStep('confirm');
|
|
60
78
|
}, []);
|
|
@@ -62,10 +80,7 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
62
80
|
setDynamicWidgetView('wallets');
|
|
63
81
|
}, [setDynamicWidgetView]);
|
|
64
82
|
const handleSuccess = React.useCallback(() => {
|
|
65
|
-
|
|
66
|
-
// Navigate to appropriate view based on where we came from:
|
|
67
|
-
// - If onCancel was provided (auto-create flow), go to wallets then close widget
|
|
68
|
-
// - If onCancel wasn't provided (settings flow), go to account settings
|
|
83
|
+
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
69
84
|
if (onCancel) {
|
|
70
85
|
goToWallets();
|
|
71
86
|
setIsOpen(false);
|
|
@@ -73,23 +88,16 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
73
88
|
else {
|
|
74
89
|
goToAccountAndSecurity();
|
|
75
90
|
}
|
|
76
|
-
}, [
|
|
77
|
-
onComplete,
|
|
78
|
-
password,
|
|
79
|
-
onCancel,
|
|
80
|
-
goToAccountAndSecurity,
|
|
81
|
-
goToWallets,
|
|
82
|
-
setIsOpen,
|
|
83
|
-
]);
|
|
91
|
+
}, [onDone, onCancel, goToAccountAndSecurity, goToWallets, setIsOpen]);
|
|
84
92
|
switch (currentStep) {
|
|
85
93
|
case 'terms':
|
|
86
94
|
return (jsxRuntime.jsx(SetupPasswordTermsView.SetupPasswordTermsView, { onContinue: handleTermsContinue, onBack: onCancel ? undefined : handleCancel }));
|
|
87
95
|
case 'enter':
|
|
88
96
|
return (jsxRuntime.jsx(SetupPasswordEnterView.SetupPasswordEnterView, { onContinue: handleEnterContinue, onBack: handleEnterBack }));
|
|
89
97
|
case 'confirm':
|
|
90
|
-
return (jsxRuntime.jsx(SetupPasswordConfirmView.SetupPasswordConfirmView, { password: password, onContinue: handleConfirmContinue, onBack: handleConfirmBack }));
|
|
98
|
+
return (jsxRuntime.jsx(SetupPasswordConfirmView.SetupPasswordConfirmView, { password: password, onContinue: handleConfirmContinue, onBack: handleConfirmBack, isLoading: isSubmitting && skipKnowledgeCheck, error: skipKnowledgeCheck ? submitError : null }));
|
|
91
99
|
case 'knowledge-check':
|
|
92
|
-
return (jsxRuntime.jsx(SetupPasswordKnowledgeCheckView.SetupPasswordKnowledgeCheckView, { onContinue: handleKnowledgeCheckContinue, onBack: handleKnowledgeCheckBack }));
|
|
100
|
+
return (jsxRuntime.jsx(SetupPasswordKnowledgeCheckView.SetupPasswordKnowledgeCheckView, { onContinue: handleKnowledgeCheckContinue, onBack: handleKnowledgeCheckBack, isLoading: isSubmitting, error: submitError }));
|
|
93
101
|
case 'success':
|
|
94
102
|
return jsxRuntime.jsx(SetupPasswordSuccessView.SetupPasswordSuccessView, { onDone: handleSuccess });
|
|
95
103
|
default:
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
export type SetupPasswordViewProps = {
|
|
3
|
-
onComplete: (password: string) => void;
|
|
3
|
+
onComplete: (password: string) => Promise<void> | void;
|
|
4
4
|
onCancel?: () => void;
|
|
5
|
+
onDone?: () => void;
|
|
5
6
|
skipKnowledgeCheck?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export declare const SetupPasswordView: FC<SetupPasswordViewProps>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
3
|
import { jsx } from 'react/jsx-runtime';
|
|
3
4
|
import { useState, useCallback } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
4
6
|
import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
|
|
5
7
|
import { SetupPasswordConfirmView } from '../SetupPasswordConfirmView/SetupPasswordConfirmView.js';
|
|
6
8
|
import { SetupPasswordEnterView } from '../SetupPasswordEnterView/SetupPasswordEnterView.js';
|
|
7
|
-
import '../../../../../../_virtual/_tslib.js';
|
|
8
9
|
import '@dynamic-labs/utils';
|
|
9
10
|
import '@dynamic-labs/iconic';
|
|
10
11
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
@@ -12,10 +13,13 @@ import { SetupPasswordKnowledgeCheckView } from '../SetupPasswordKnowledgeCheckV
|
|
|
12
13
|
import { SetupPasswordSuccessView } from '../SetupPasswordSuccessView/SetupPasswordSuccessView.js';
|
|
13
14
|
import { SetupPasswordTermsView } from '../SetupPasswordTermsView/SetupPasswordTermsView.js';
|
|
14
15
|
|
|
15
|
-
const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }) => {
|
|
16
|
+
const SetupPasswordView = ({ onComplete, onCancel, onDone, skipKnowledgeCheck = false, }) => {
|
|
17
|
+
const { t } = useTranslation();
|
|
16
18
|
const { setDynamicWidgetView, setIsOpen } = useWidgetContext();
|
|
17
19
|
const [currentStep, setCurrentStep] = useState('terms');
|
|
18
20
|
const [password, setPassword] = useState('');
|
|
21
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
22
|
+
const [submitError, setSubmitError] = useState(null);
|
|
19
23
|
const goToAccountAndSecurity = useCallback(() => {
|
|
20
24
|
setDynamicWidgetView('account-and-security-settings');
|
|
21
25
|
}, [setDynamicWidgetView]);
|
|
@@ -37,20 +41,34 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
37
41
|
const handleEnterBack = useCallback(() => {
|
|
38
42
|
setCurrentStep('terms');
|
|
39
43
|
}, []);
|
|
40
|
-
const
|
|
41
|
-
|
|
44
|
+
const runOnComplete = useCallback((pwd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
setIsSubmitting(true);
|
|
46
|
+
setSubmitError(null);
|
|
47
|
+
try {
|
|
48
|
+
yield onComplete(pwd);
|
|
42
49
|
setCurrentStep('success');
|
|
43
50
|
}
|
|
51
|
+
catch (_a) {
|
|
52
|
+
setSubmitError(t('dyn_setup_password.confirm.error.failed'));
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
setIsSubmitting(false);
|
|
56
|
+
}
|
|
57
|
+
}), [onComplete, t]);
|
|
58
|
+
const handleConfirmContinue = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
if (skipKnowledgeCheck) {
|
|
60
|
+
yield runOnComplete(password);
|
|
61
|
+
}
|
|
44
62
|
else {
|
|
45
63
|
setCurrentStep('knowledge-check');
|
|
46
64
|
}
|
|
47
|
-
}, [skipKnowledgeCheck]);
|
|
65
|
+
}), [skipKnowledgeCheck, runOnComplete, password]);
|
|
48
66
|
const handleConfirmBack = useCallback(() => {
|
|
49
67
|
setCurrentStep('enter');
|
|
50
68
|
}, []);
|
|
51
|
-
const handleKnowledgeCheckContinue = useCallback(() => {
|
|
52
|
-
|
|
53
|
-
}, []);
|
|
69
|
+
const handleKnowledgeCheckContinue = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
yield runOnComplete(password);
|
|
71
|
+
}), [runOnComplete, password]);
|
|
54
72
|
const handleKnowledgeCheckBack = useCallback(() => {
|
|
55
73
|
setCurrentStep('confirm');
|
|
56
74
|
}, []);
|
|
@@ -58,10 +76,7 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
58
76
|
setDynamicWidgetView('wallets');
|
|
59
77
|
}, [setDynamicWidgetView]);
|
|
60
78
|
const handleSuccess = useCallback(() => {
|
|
61
|
-
|
|
62
|
-
// Navigate to appropriate view based on where we came from:
|
|
63
|
-
// - If onCancel was provided (auto-create flow), go to wallets then close widget
|
|
64
|
-
// - If onCancel wasn't provided (settings flow), go to account settings
|
|
79
|
+
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
65
80
|
if (onCancel) {
|
|
66
81
|
goToWallets();
|
|
67
82
|
setIsOpen(false);
|
|
@@ -69,23 +84,16 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
69
84
|
else {
|
|
70
85
|
goToAccountAndSecurity();
|
|
71
86
|
}
|
|
72
|
-
}, [
|
|
73
|
-
onComplete,
|
|
74
|
-
password,
|
|
75
|
-
onCancel,
|
|
76
|
-
goToAccountAndSecurity,
|
|
77
|
-
goToWallets,
|
|
78
|
-
setIsOpen,
|
|
79
|
-
]);
|
|
87
|
+
}, [onDone, onCancel, goToAccountAndSecurity, goToWallets, setIsOpen]);
|
|
80
88
|
switch (currentStep) {
|
|
81
89
|
case 'terms':
|
|
82
90
|
return (jsx(SetupPasswordTermsView, { onContinue: handleTermsContinue, onBack: onCancel ? undefined : handleCancel }));
|
|
83
91
|
case 'enter':
|
|
84
92
|
return (jsx(SetupPasswordEnterView, { onContinue: handleEnterContinue, onBack: handleEnterBack }));
|
|
85
93
|
case 'confirm':
|
|
86
|
-
return (jsx(SetupPasswordConfirmView, { password: password, onContinue: handleConfirmContinue, onBack: handleConfirmBack }));
|
|
94
|
+
return (jsx(SetupPasswordConfirmView, { password: password, onContinue: handleConfirmContinue, onBack: handleConfirmBack, isLoading: isSubmitting && skipKnowledgeCheck, error: skipKnowledgeCheck ? submitError : null }));
|
|
87
95
|
case 'knowledge-check':
|
|
88
|
-
return (jsx(SetupPasswordKnowledgeCheckView, { onContinue: handleKnowledgeCheckContinue, onBack: handleKnowledgeCheckBack }));
|
|
96
|
+
return (jsx(SetupPasswordKnowledgeCheckView, { onContinue: handleKnowledgeCheckContinue, onBack: handleKnowledgeCheckBack, isLoading: isSubmitting, error: submitError }));
|
|
89
97
|
case 'success':
|
|
90
98
|
return jsx(SetupPasswordSuccessView, { onDone: handleSuccess });
|
|
91
99
|
default:
|