everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
54 lines (52 loc) • 1.28 kB
JavaScript
let execa = require("execa");
//#region src/services/auth/outlayer.ts
async function loginOutlayerCli(custodyWallet, env = process.env) {
try {
await (0, execa.execa)("outlayer", ["--version"], {
env,
stdio: "pipe"
});
} catch (error) {
if (error.code === "ENOENT") return {
status: "cli-missing",
network: custodyWallet.network
};
return {
status: "error",
network: custodyWallet.network,
detail: error instanceof Error ? error.message : "Unknown error"
};
}
const args = custodyWallet.network === "testnet" ? [
"login",
"testnet",
"--wallet-key",
custodyWallet.apiKey
] : [
"login",
"--wallet-key",
custodyWallet.apiKey
];
const login = await (0, execa.execa)("outlayer", args, {
env,
stdio: "pipe",
reject: false
});
if (login.failed) return {
status: "error",
network: custodyWallet.network,
detail: [login.stderr, login.stdout].filter(Boolean).join("\n").trim() || "OutLayer CLI login failed"
};
const whoami = await (0, execa.execa)("outlayer", ["whoami"], {
env,
stdio: "pipe"
}).catch(() => null);
return {
status: "linked",
network: custodyWallet.network,
detail: whoami?.stdout.trim()
};
}
//#endregion
exports.loginOutlayerCli = loginOutlayerCli;
//# sourceMappingURL=outlayer.cjs.map