feat(ui): Add an automated Web Crypto environment check (#908)

* feat: add web crypto environment check
* fix: auto check env
* refactor:  WebCryptoEnvironmentCheck  swtich to map
This commit is contained in:
Ember
2025-11-12 10:22:55 +08:00
committed by GitHub
parent 7afe1f1bad
commit dbb05f7fde
5 changed files with 297 additions and 27 deletions

View File

@@ -786,6 +786,36 @@ export const translations = {
faqGetHelpAnswer:
'Check GitHub Discussions, join our Telegram Community, or open an issue on GitHub.',
// Web Crypto Environment Check
environmentCheck: {
button: 'Check Secure Environment',
checking: 'Checking...',
description:
'Automatically verifying whether this browser context allows Web Crypto before entering sensitive keys.',
secureTitle: 'Secure context detected',
secureDesc:
'Web Crypto API is available. You can continue entering secrets with encryption enabled.',
insecureTitle: 'Insecure context detected',
insecureDesc:
'This page is not running over HTTPS or a trusted localhost origin, so browsers block Web Crypto calls.',
tipsTitle: 'How to fix:',
tipHTTPS:
'Serve the dashboard over HTTPS with a valid certificate (IP origins also need TLS).',
tipLocalhost:
'During development, open the app via http://localhost or 127.0.0.1.',
tipIframe:
'Avoid embedding the app in insecure HTTP iframes or reverse proxies that strip HTTPS.',
unsupportedTitle: 'Browser does not expose Web Crypto',
unsupportedDesc:
'Open NOFX over HTTPS (or http://localhost during development) and avoid insecure iframes/reverse proxies so the browser can enable Web Crypto.',
summary: 'Current origin: {origin} • Protocol: {protocol}',
},
environmentSteps: {
checkTitle: '1. Environment check',
selectTitle: '2. Select exchange',
},
// Two-Stage Key Modal
twoStageKey: {
title: 'Two-Stage Private Key Input',
@@ -1550,6 +1580,33 @@ export const translations = {
faqGetHelpAnswer:
'查看 GitHub Discussions、加入 Telegram 社区或在 GitHub 上提出 issue。',
// Web Crypto Environment Check
environmentCheck: {
button: '一键检测环境',
checking: '正在检测...',
description: '系统将自动检测当前浏览器是否允许使用 Web Crypto。',
secureTitle: '环境安全,已启用 Web Crypto',
secureDesc: '页面处于安全上下文,可继续输入敏感信息并使用加密传输。',
insecureTitle: '检测到非安全环境',
insecureDesc:
'当前访问未通过 HTTPS 或可信 localhost浏览器会阻止 Web Crypto 调用。',
tipsTitle: '修改建议:',
tipHTTPS:
'通过 HTTPS 访问(即使是 IP 也需证书),或部署到支持 TLS 的域名。',
tipLocalhost: '开发阶段请使用 http://localhost 或 127.0.0.1。',
tipIframe:
'避免把应用嵌入在不安全的 HTTP iframe 或会降级协议的反向代理中。',
unsupportedTitle: '浏览器未提供 Web Crypto',
unsupportedDesc:
'请通过 HTTPS 或本机 localhost 访问 NOFX并避免嵌入不安全 iframe/反向代理,以符合浏览器的 Web Crypto 规则。',
summary: '当前来源:{origin} · 协议:{protocol}',
},
environmentSteps: {
checkTitle: '1. 环境检测',
selectTitle: '2. 选择交易所',
},
// Two-Stage Key Modal
twoStageKey: {
title: '两阶段私钥输入',