mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
66deeb8dd9
* feat(vault): 新增 FinalShell 主机导入功能 本次提交完整实现了 FinalShell 连接的导入支持,包括: 1. 新增导入格式检测与解析逻辑,支持解密 FinalShell 加密密码 2. 适配导入流程 UI,新增导入选项与批量目录导入支持 3. 补充多语言国际化文案与测试用例 4. 更新所有相关文档与配置文件 * fix(vault): align FinalShell import guards and agent guidance * fix(vault): detect FinalShell connections without usernames * fix(vault): keep password validation lint compliant * fix(ci): use archived Bullseye security packages for ARM builds * fix(vault): retain FinalShell profiles and accept BOM JSON * fix(ci): align archived security source with main --------- Co-authored-by: YS-zdck <admin@zdck8.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import type {
|
|
VaultImportDestination,
|
|
VaultImportFormat,
|
|
} from "../../domain/vaultImport";
|
|
|
|
export type VaultImportDestinationMode = "preserve" | "existing" | "new";
|
|
|
|
export function getVaultImportPickerMode(
|
|
format: VaultImportFormat,
|
|
source: "folder" | "file" = "folder",
|
|
): {
|
|
directory: boolean;
|
|
multiple: boolean;
|
|
} {
|
|
const isBatchFolder = (format === "securecrt" || format === "finalshell")
|
|
&& source === "folder";
|
|
return {
|
|
directory: isBatchFolder,
|
|
multiple: isBatchFolder,
|
|
};
|
|
}
|
|
|
|
export function selectVaultImportFiles(
|
|
format: VaultImportFormat,
|
|
files: ArrayLike<File>,
|
|
): File[] {
|
|
const selected = Array.from(files);
|
|
return format === "securecrt" || format === "finalshell"
|
|
? selected
|
|
: selected.slice(0, 1);
|
|
}
|
|
|
|
const normalizeGroup = (raw: string | undefined): string | undefined => {
|
|
const parts = raw
|
|
?.replace(/\\/g, "/")
|
|
.split("/")
|
|
.map((part) => part.trim())
|
|
.filter(Boolean);
|
|
return parts && parts.length > 0 ? parts.join("/") : undefined;
|
|
};
|
|
|
|
export function buildVaultImportDestination({
|
|
mode,
|
|
existingGroup,
|
|
newGroup,
|
|
availableGroups,
|
|
}: {
|
|
mode: VaultImportDestinationMode;
|
|
existingGroup?: string;
|
|
newGroup?: string;
|
|
availableGroups?: string[];
|
|
}): VaultImportDestination | null {
|
|
if (mode === "preserve") return { mode: "preserve" };
|
|
const group = normalizeGroup(mode === "existing" ? existingGroup : newGroup);
|
|
if (
|
|
mode === "existing"
|
|
&& availableGroups
|
|
&& (!group || !availableGroups.includes(group))
|
|
) return null;
|
|
return group ? { mode: "group", group } : null;
|
|
}
|