import { writeFileSync, mkdirSync, chmodSync } from "fs";
const securedDirs = new Set();
export function clearCache() {
    securedDirs.clear();
}
function applyPermissions(targetPath, mode) {
    if (process.platform === "win32")
        return; // ACL hardening → v2.4 backlog
    chmodSync(targetPath, mode);
}
export function ensureSecureDir(dirPath) {
    if (securedDirs.has(dirPath)) {
        return;
    }
    applyPermissions(dirPath, 0o700);
    securedDirs.add(dirPath);
}
export function secureWriteFileSync(filePath, data, options) {
    writeFileSync(filePath, data, options);
    applyPermissions(filePath, 0o600);
}
export function secureMkdirSync(dirPath, options) {
    mkdirSync(dirPath, { recursive: options?.recursive ?? true });
    ensureSecureDir(dirPath);
}
//# sourceMappingURL=secureWrite.js.map