- 两阶段接收:POST /internal/email/authorize(accept/reject/temporary_error)+ POST /internal/email/ingest(raw MIME 直传) - Worker-Console 协议:Authorization: WmailHub-Worker + timestamp/nonce/body-hash/HMAC,nonce 防重放,凭据撤销即时生效 - 数据模型:nodes/node_credentials -> cloudflare_accounts/worker_credentials(迁移 0003),emails/domains 归属 account_id - 接入流程 Connect Cloudflare Account:OAuth 自动同步域名 + 部署账号级 Email Worker + 签发 Worker 凭据;rotate 自动重部署 - 动态邮箱:创建/删除/禁用下一封邮件立即生效;拒绝码 DOMAIN_*/MAILBOX_*;超时/5xx 不伪装成邮箱不存在 - 删除 node/ 目录、旧 /api/internal/nodes 协议、ingress/enrollment 概念;dev.ts 简化为 console + email worker 双进程 - 前端:账号页 Email Worker/凭据管理,设置窗口移除默认 Ingress,仪表盘/文案同步;版本 2.0.0 - 测试 62 项全过(新增 authorize 决策矩阵 + Worker 两阶段临时错误语义);本机虚拟 E2E 12 场景全通 - docs 00-10 同步改写;README 更新
56 lines
2.0 KiB
TypeScript
56 lines
2.0 KiB
TypeScript
/** sim 模式的 Cloudflare 授权模拟页:确认后调用 approve,再跳回节点页 */
|
|
import { useEffect, useState } from "react";
|
|
import { useNavigate, useSearchParams } from "react-router-dom";
|
|
import { Button, Card, Space, App } from "antd";
|
|
import { oauthSimApprove } from "../api.ts";
|
|
|
|
/** # 函数
|
|
* 模拟授权页(仅本地 sim 模式;真实部署直接跳 Cloudflare 授权页)
|
|
*/
|
|
export function OAuthSimPage() {
|
|
const [params] = useSearchParams();
|
|
const navigate = useNavigate();
|
|
const { message } = App.useApp();
|
|
const state = params.get("state") ?? "";
|
|
const [busy, setBusy] = useState(false);
|
|
|
|
const approve = async () => {
|
|
setBusy(true);
|
|
try {
|
|
const res = await oauthSimApprove(state);
|
|
if (res.ok) {
|
|
message.success("Cloudflare 授权与自动安装完成");
|
|
navigate(`/accounts?provision=${encodeURIComponent(res.account_id)}`, { replace: true });
|
|
} else {
|
|
message.error(res.error ?? "安装失败");
|
|
navigate("/accounts", { replace: true });
|
|
}
|
|
} catch (err) {
|
|
message.error(err instanceof Error ? err.message : "授权失败");
|
|
navigate("/accounts", { replace: true });
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
};
|
|
|
|
// state 缺失直接回节点页
|
|
useEffect(() => {
|
|
if (!state) navigate("/accounts", { replace: true });
|
|
}, [state, navigate]);
|
|
|
|
return (
|
|
<div className="login-page">
|
|
<Card className="login-card" title="Cloudflare 授权(本地模拟)" styles={{ header: { textAlign: "center" } }}>
|
|
<p>sim 模式下,该页面模拟 Cloudflare OAuth 授权同意流程。</p>
|
|
<p className="muted">真实部署时,这里会跳转到 dash.cloudflare.com 的授权页面。</p>
|
|
<Space style={{ width: "100%", justifyContent: "center", marginTop: 16 }}>
|
|
<Button onClick={() => navigate("/accounts")}>拒绝</Button>
|
|
<Button type="primary" loading={busy} onClick={() => void approve()}>
|
|
同意授权
|
|
</Button>
|
|
</Space>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|