62 lines
2.3 KiB
TypeScript
62 lines
2.3 KiB
TypeScript
|
|
export type DomainAccessStage = 'checking' | 'login-required' | 'identity-verified' | 'runtime-ready';
|
||
|
|
|
||
|
|
export interface DomainAccessProjection {
|
||
|
|
blockers: string[];
|
||
|
|
runtimeReady: boolean;
|
||
|
|
stage: DomainAccessStage;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface DomainConnectionStep {
|
||
|
|
id: 'identity' | 'manifest' | 'capability' | 'receipt';
|
||
|
|
label: string;
|
||
|
|
state: 'checking' | 'blocked' | 'verified';
|
||
|
|
detail: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
const blockerToStep: Record<string, DomainConnectionStep['id']> = {
|
||
|
|
account_node_identity_missing: 'identity',
|
||
|
|
verified_domain_manifest_missing: 'manifest',
|
||
|
|
scoped_session_capability_missing: 'capability',
|
||
|
|
matching_connection_receipt_missing: 'receipt',
|
||
|
|
desktop_runtime_required: 'identity',
|
||
|
|
domain_access_probe_failed: 'identity',
|
||
|
|
};
|
||
|
|
|
||
|
|
const stepCopy: Record<DomainConnectionStep['id'], { label: string; pending: string; verified: string }> = {
|
||
|
|
identity: {
|
||
|
|
label: '账户与登记节点',
|
||
|
|
pending: '需要由已登记的本地终端节点或云常驻节点完成身份证明',
|
||
|
|
verified: '账户声明和节点编号已经验证',
|
||
|
|
},
|
||
|
|
manifest: {
|
||
|
|
label: '目标域签名清单',
|
||
|
|
pending: '等待目标域可信签名人签发并验证域 manifest',
|
||
|
|
verified: '目标域 manifest 与可信签名来源一致',
|
||
|
|
},
|
||
|
|
capability: {
|
||
|
|
label: '域会话能力',
|
||
|
|
pending: '等待签发仅允许进入当前域的短期会话能力',
|
||
|
|
verified: '当前节点持有有效的 domain:enter 能力',
|
||
|
|
},
|
||
|
|
receipt: {
|
||
|
|
label: '在线连接回执',
|
||
|
|
pending: '等待目标域运行体返回与节点、清单一致的在线回执',
|
||
|
|
verified: '连接回执已回读并与当前会话一致',
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
export function projectDomainConnectionSteps(access: DomainAccessProjection): DomainConnectionStep[] {
|
||
|
|
const blockers = new Set(access.blockers.map(blocker => blockerToStep[blocker]).filter(Boolean));
|
||
|
|
const ordered: DomainConnectionStep['id'][] = ['identity', 'manifest', 'capability', 'receipt'];
|
||
|
|
return ordered.map(id => {
|
||
|
|
const copy = stepCopy[id];
|
||
|
|
const verified = access.runtimeReady || (!blockers.has(id) && access.stage !== 'checking');
|
||
|
|
return {
|
||
|
|
id,
|
||
|
|
label: copy.label,
|
||
|
|
state: access.stage === 'checking' ? 'checking' : verified ? 'verified' : 'blocked',
|
||
|
|
detail: access.stage === 'checking' ? '正在核对当前接入证据' : verified ? copy.verified : copy.pending,
|
||
|
|
};
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|