UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

29 lines (28 loc) • 1.13 kB
import { w as root } from "./fs-safe-BbWvmdVn.mjs"; import { t as _usingCtx } from "./usingCtx-rhpPzaNq.mjs"; import { o as readFileHandleBounded } from "./file-access-runtime-BD2Fjfbw.mjs"; import path from "node:path"; //#region extensions/browser/src/browser/extension-native-host-file.ts /** Read POSIX native-host artifacts through the descriptor that passed admission. */ async function readPrivateNativeHostFile(e, t) { try { var n = _usingCtx(); const r = path.resolve(e); const i = await root(path.dirname(r)); const a = n.a(await i.open(path.basename(r), { hardlinks: "allow" })); if (a.realPath !== r) throw new Error("unresolved native host file path"); const o = process.getuid?.(); if (o !== void 0 && a.stat.uid !== o) throw new Error("foreign native host file owner"); if ((a.stat.mode & 63) !== 0 || t && (a.stat.mode & 64) === 0) throw new Error("native host file has unsafe mode"); return { realPath: a.realPath, buffer: await readFileHandleBounded(a.handle, Infinity) }; } catch (e) { n.e = e; } finally { await n.d(); } } //#endregion export { readPrivateNativeHostFile as t };