openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
25 lines (24 loc) • 1.11 kB
JavaScript
import { n as pluginSecretRefSetup } from "./secret-ref-runtime-yIA1xrYi.mjs";
import path from "node:path";
//#region extensions/onepassword/onepassword-op-path.js
function errorCode(e) {
return e && typeof e === "object" && "code" in e ? e.code : void 0;
}
const resolveTrustedExecutablePath = pluginSecretRefSetup.resolveTrustedExecutablePath;
async function resolveTrustedOnePasswordCli(e = {}) {
const t = e.configuredPath?.trim();
if (t && !path.isAbsolute(t)) throw new Error(`1Password CLI path must be absolute: ${t}`);
const n = process.platform === "win32" ? "op.exe" : "op";
const r = t ? [t] : (e.pathEnv ?? process.env.PATH ?? "").split(path.delimiter).filter(Boolean).map((e) => path.resolve(e, n));
let i;
for (const e of r) try {
return await resolveTrustedExecutablePath(e);
} catch (n) {
if (errorCode(n) === "ENOENT" || errorCode(n) === "ENOTDIR") continue;
i = new Error(`Refusing unsafe 1Password CLI path "${e}": ${n instanceof Error ? n.message : String(n)}`, { cause: n });
if (t) throw i;
}
if (i) throw i;
}
//#endregion
export { resolveTrustedOnePasswordCli as t };