import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
import { writeFileSync, mkdirSync, chmodSync, existsSync } from "fs";
import { dirname } from "path";
function writeFileSecure(filePath, data) {
  const dir = dirname(filePath);
  if (!existsSync(dir)) {
    mkdirSync(dir, { recursive: true, mode: 448 });
  }
  writeFileSync(filePath, data);
  chmodSync(filePath, 384);
}
function ensureSecureDir(dirPath) {
  if (!existsSync(dirPath)) {
    mkdirSync(dirPath, { recursive: true, mode: 448 });
  } else {
    try {
      chmodSync(dirPath, 448);
    } catch {
    }
  }
}
export {
  ensureSecureDir,
  writeFileSecure
};
//# sourceMappingURL=secure-fs.js.map
