UNPKG

@particle-network/authkit

Version:

Auth Core provides MPC (Multi-Party Computation)-based threshold signatures.

94 lines (90 loc) 6.47 kB
"use client"; import { input_password_default } from "./chunk-H4INWTYF.mjs"; import "./chunk-7CCHEXYF.mjs"; import { power_footer_default } from "./chunk-LKTXGNTI.mjs"; import { useCustomNavigate, useMessage_default, useParticleAuth, useTranslation } from "./chunk-ZXD6ZGNS.mjs"; import "./chunk-55PCA22M.mjs"; // src/pages/account/masterPasswordVerify/index.tsx import { RecordType } from "@particle-network/analytics"; import { analyticsRecord, restoreWallet } from "@particle-network/auth-core"; import { useRequest } from "ahooks"; import { Button, Form, Space, Typography } from "antd"; import React, { useEffect, useState } from "react"; // src/pages/account/masterPasswordVerify/index.less var masterPasswordVerify_default = ".mp-verify-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n height: 100%;\n overflow: auto;\n font-size: 14px;\n color: var(--text-color);\n background-color: var(--theme-background-color);\n}\n.mp-verify-container .ant-form {\n display: flex;\n flex: 1;\n flex-direction: column;\n width: 100%;\n max-width: 800px;\n min-height: 360px;\n}\n.mp-verify-container .ant-form .scroll-content {\n flex: 1;\n width: 100%;\n padding-left: 18px;\n padding-right: 18px;\n}\n.mp-verify-container .ant-form-item {\n margin-bottom: 0;\n}\n.mp-verify-container .mp-verify-title {\n margin-top: 16px;\n font-weight: 500;\n font-size: 18px;\n line-height: 28px;\n color: var(--text-color);\n}\n.mp-verify-container .mp-input-name {\n align-self: flex-start;\n margin-top: 30px;\n font-weight: 400;\n}\n.mp-verify-container .mp-input {\n margin-top: 6px;\n}\n.mp-verify-container .mp-input-error {\n align-self: flex-start;\n margin-top: 8px;\n color: var(--error-color);\n}\n.mp-verify-container .mp-tip-space {\n width: 100%;\n margin-top: 25px;\n margin-bottom: 110px;\n line-height: 20px;\n}\n.mp-verify-container .mp-tip-space span {\n color: var(--text-color);\n}\n.mp-verify-container .bottom-container {\n width: 100%;\n}\n.mp-verify-container .bottom-container.footer {\n padding-left: 18px;\n padding-right: 18px;\n}\n.mp-verify-container .bottom-container .mp-next {\n position: relative;\n display: block;\n width: 100%;\n max-width: 800px;\n margin: auto;\n}\n.mp-verify-container .bottom-container .footer-box {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 100%;\n height: var(--footer-height);\n margin: 0;\n}\n.mp-verify-container .bottom-container .footer-box img {\n margin: 0;\n}\n"; // src/pages/account/masterPasswordVerify/index.tsx var MasterPasswordVerify = (props) => { const { Text, Link } = Typography; const navigate = useCustomNavigate(); const [showPasswordError, setShowPasswordError] = useState(false); const { t } = useTranslation(); const { loginVerifyMasterPassword } = props || {}; const containerRef = React.useRef(null); const [nextDisabled, setNextDisabled] = useState(true); const { loginSuccessRedirectToApp } = useParticleAuth(); const message = useMessage_default(); const { run: runCheckMasterPassword, loading } = useRequest(restoreWallet, { manual: true, onBefore: () => { analyticsRecord({ record_type: RecordType.PAGE_MASTER_PASSWORD_VERIFY }); }, onSuccess: (result) => { if (result) { analyticsRecord({ record_type: RecordType.PAGE_MASTER_PASSWORD_VERIFY_SUCCESS }); if (loginVerifyMasterPassword) { loginSuccessRedirectToApp(); } else { navigate(-1); } } else { setShowPasswordError(true); } }, onError: (error) => { console.log("checkMasterPassword error", error); message.error((error == null ? void 0 : error.message) || "check master password error"); } }); const toDecription = () => { navigate("/account/master-password/description"); }; const verifyMasterPassword = (values) => { const { password } = values; if ((password == null ? void 0 : password.length) >= 6 && (password == null ? void 0 : password.length) <= 20) { setShowPasswordError(false); runCheckMasterPassword(password); } else { setShowPasswordError(true); } }; const onValuesChange = (values) => { const { password } = values; setShowPasswordError(false); setNextDisabled(!password); }; useEffect(() => { setTimeout(() => { var _a, _b; (_b = (_a = containerRef.current) == null ? void 0 : _a.querySelector(".password-input input")) == null ? void 0 : _b.focus(); }, 200); }, []); return /* @__PURE__ */ React.createElement("div", { className: "mp-verify-container", ref: containerRef }, /* @__PURE__ */ React.createElement("style", null, masterPasswordVerify_default), /* @__PURE__ */ React.createElement("div", { className: "mp-verify-title" }, t("account.restore_wallet")), /* @__PURE__ */ React.createElement(Form, { layout: "vertical", onFinish: verifyMasterPassword, onValuesChange }, /* @__PURE__ */ React.createElement("div", { className: "scroll-content" }, /* @__PURE__ */ React.createElement("div", { className: "mp-input-name padding-top-16" }, t("account.master_password")), /* @__PURE__ */ React.createElement(Form.Item, { name: "password" }, /* @__PURE__ */ React.createElement(input_password_default, { className: "mp-input" })), showPasswordError && /* @__PURE__ */ React.createElement("div", { className: "mp-input-error" }, t("account.password_error")), /* @__PURE__ */ React.createElement(Space, { direction: "vertical", className: "mp-tip-space" }, /* @__PURE__ */ React.createElement(Text, null, t("account.mpc_tss_intro")), /* @__PURE__ */ React.createElement(Text, null, t("account.input_decrypt_hint"), " ", /* @__PURE__ */ React.createElement(Link, { onClick: toDecription, className: "more-text-btn" }, t("account.learn_more_period"))))), /* @__PURE__ */ React.createElement(Form.Item, null, /* @__PURE__ */ React.createElement("div", { className: "bottom-container footer" }, /* @__PURE__ */ React.createElement(Button, { className: "primary-antd-btn mp-next", htmlType: "submit", loading, disabled: nextDisabled }, t("common.confirm")), /* @__PURE__ */ React.createElement(power_footer_default, { className: "footer-box-v2" }))))); }; var masterPasswordVerify_default2 = MasterPasswordVerify; export { masterPasswordVerify_default2 as default }; //# sourceMappingURL=masterPasswordVerify-KNZVTMLD.mjs.map