@particle-network/authkit
Version:
Auth Core provides MPC (Multi-Party Computation)-based threshold signatures.
90 lines (86 loc) • 5.79 kB
JavaScript
"use client";
import {
input_password_default
} from "./chunk-OWXESKIP.mjs";
import {
header_default
} from "./chunk-DARAQXIQ.mjs";
import "./chunk-4JO427F5.mjs";
import {
power_footer_default
} from "./chunk-5I7YWW7H.mjs";
import {
useCustomNavigate,
useMessage_default,
useTranslation
} from "./chunk-PD7RGPWB.mjs";
import "./chunk-55PCA22M.mjs";
// src/pages/account/masterPasswordChange/index.tsx
import { verifyMasterPassword } from "@particle-network/auth-core";
import { useRequest } from "ahooks";
import { Button, Form, Space, Typography } from "antd";
import React, { useState } from "react";
// src/pages/account/masterPasswordChange/index.less
var masterPasswordChange_default = ".mp-change-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}\n.mp-change-container .wapper {\n flex: 1;\n width: 100%;\n padding: 0 18px;\n}\n.mp-change-container .ant-form {\n display: flex;\n flex-direction: column;\n width: 100%;\n max-width: 800px;\n height: 100%;\n}\n.mp-change-container .ant-form .ant-form-item {\n margin-bottom: 0;\n}\n.mp-change-container .ant-form .scroll-content {\n flex: 1;\n width: 100%;\n}\n.mp-change-container .mp-change-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-change-container .mp-input-name {\n align-self: flex-start;\n margin-top: 10px;\n font-weight: 400;\n}\n.mp-change-container .mp-input {\n margin-top: 6px;\n}\n.mp-change-container .mp-input-error {\n align-self: flex-start;\n margin-top: 8px;\n color: var(--error-color);\n}\n.mp-change-container .mp-tip-space {\n width: 100%;\n margin-top: 25px;\n margin-bottom: 110px;\n line-height: 20px;\n}\n.mp-change-container .mp-tip-space span {\n color: var(--text-color);\n}\n.mp-change-container .bottom-container .mp-next {\n width: 100%;\n}\n.mp-change-container .bottom-container .footer-box {\n display: flex;\n justify-content: center;\n align-items: center;\n height: var(--footer-height);\n margin: 0;\n}\n.mp-change-container .bottom-container .footer-box .footer {\n margin: 0;\n}\n";
// src/pages/account/masterPasswordChange/index.tsx
var MasterPasswordChange = () => {
const navigate = useCustomNavigate();
const { t } = useTranslation();
const { Text, Link } = Typography;
const [showError, setShowError] = useState(false);
const message = useMessage_default();
const [nextDisabled, setNextDisabled] = useState(true);
const { run: runCheckMasterPassword, loading } = useRequest(
(password) => {
return verifyMasterPassword(password).then((res) => {
if (!res) {
throw new Error("Master password decryption error");
}
return res;
});
},
{
manual: true,
onSuccess: (result) => {
setNewMasterPassword();
},
onError: (error) => {
console.log("checkMasterPassword error", error);
if ((error == null ? void 0 : error.message) === "Master password decryption error") {
setShowError(true);
} else {
message.error((error == null ? void 0 : error.message) || "check master password error");
}
}
}
);
const setNewMasterPassword = () => {
navigate("/account/master-password", {
state: {
setNewMasterPassword: true
}
});
};
const onInputFinish = (values) => {
const { password } = values;
if (password && password.length >= 6 && password.length <= 20) {
runCheckMasterPassword(password);
} else {
setShowError(true);
}
};
const onValuesChange = (values) => {
setShowError(false);
const { password } = values;
setNextDisabled(!password);
};
const toDecription = () => {
navigate("/account/master-password/description");
};
return /* @__PURE__ */ React.createElement("div", { className: "mp-change-container" }, /* @__PURE__ */ React.createElement("style", null, masterPasswordChange_default), /* @__PURE__ */ React.createElement(header_default, { displayBackBtn: true }, t("account.current_master_password")), /* @__PURE__ */ React.createElement("div", { className: "wapper" }, /* @__PURE__ */ React.createElement(Form, { onFinish: onInputFinish, layout: "vertical", onValuesChange }, /* @__PURE__ */ React.createElement("div", { className: "scroll-content" }, /* @__PURE__ */ React.createElement("div", { className: "mp-input-name padding-top-16" }, t("account.input_master_password")), /* @__PURE__ */ React.createElement(Form.Item, { name: "password" }, /* @__PURE__ */ React.createElement(input_password_default, { className: "mp-input" })), showError && /* @__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" }, /* @__PURE__ */ React.createElement(Button, { className: "primary-antd-btn mp-next", htmlType: "submit", loading, disabled: nextDisabled }, t("common.next")), /* @__PURE__ */ React.createElement(power_footer_default, null))))));
};
var masterPasswordChange_default2 = MasterPasswordChange;
export {
masterPasswordChange_default2 as default
};
//# sourceMappingURL=masterPasswordChange-TZRX5IFR.mjs.map