{"version":3,"file":"outlayer.cjs","names":[],"sources":["../../../src/services/auth/outlayer.ts"],"sourcesContent":["import { execa } from \"execa\";\nimport type { CustodyWalletRecord } from \"./session\";\n\nexport interface OutlayerCliResult {\n  status: \"linked\" | \"cli-missing\" | \"error\";\n  network: \"mainnet\" | \"testnet\";\n  detail?: string;\n}\n\nexport async function loginOutlayerCli(\n  custodyWallet: CustodyWalletRecord,\n  env: NodeJS.ProcessEnv = process.env,\n): Promise<OutlayerCliResult> {\n  try {\n    await execa(\"outlayer\", [\"--version\"], { env, stdio: \"pipe\" });\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n      return { status: \"cli-missing\", network: custodyWallet.network };\n    }\n    return {\n      status: \"error\",\n      network: custodyWallet.network,\n      detail: error instanceof Error ? error.message : \"Unknown error\",\n    };\n  }\n\n  const args =\n    custodyWallet.network === \"testnet\"\n      ? [\"login\", \"testnet\", \"--wallet-key\", custodyWallet.apiKey]\n      : [\"login\", \"--wallet-key\", custodyWallet.apiKey];\n  const login = await execa(\"outlayer\", args, { env, stdio: \"pipe\", reject: false });\n  if (login.failed) {\n    return {\n      status: \"error\",\n      network: custodyWallet.network,\n      detail:\n        [login.stderr, login.stdout].filter(Boolean).join(\"\\n\").trim() ||\n        \"OutLayer CLI login failed\",\n    };\n  }\n\n  const whoami = await execa(\"outlayer\", [\"whoami\"], { env, stdio: \"pipe\" }).catch(() => null);\n  return {\n    status: \"linked\",\n    network: custodyWallet.network,\n    detail: whoami?.stdout.trim(),\n  };\n}\n"],"mappings":";;;AASA,eAAsB,iBACpB,eACA,MAAyB,QAAQ,KACL;CAC5B,IAAI;EACF,UAAM,aAAM,YAAY,CAAC,WAAW,GAAG;GAAE;GAAK,OAAO;EAAO,CAAC;CAC/D,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAC5C,OAAO;GAAE,QAAQ;GAAe,SAAS,cAAc;EAAQ;EAEjE,OAAO;GACL,QAAQ;GACR,SAAS,cAAc;GACvB,QAAQ,iBAAiB,QAAQ,MAAM,UAAU;EACnD;CACF;CAEA,MAAM,OACJ,cAAc,YAAY,YACtB;EAAC;EAAS;EAAW;EAAgB,cAAc;CAAM,IACzD;EAAC;EAAS;EAAgB,cAAc;CAAM;CACpD,MAAM,QAAQ,UAAM,aAAM,YAAY,MAAM;EAAE;EAAK,OAAO;EAAQ,QAAQ;CAAM,CAAC;CACjF,IAAI,MAAM,QACR,OAAO;EACL,QAAQ;EACR,SAAS,cAAc;EACvB,QACE,CAAC,MAAM,QAAQ,MAAM,MAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,KAC7D;CACJ;CAGF,MAAM,SAAS,UAAM,aAAM,YAAY,CAAC,QAAQ,GAAG;EAAE;EAAK,OAAO;CAAO,CAAC,CAAC,CAAC,YAAY,IAAI;CAC3F,OAAO;EACL,QAAQ;EACR,SAAS,cAAc;EACvB,QAAQ,QAAQ,OAAO,KAAK;CAC9B;AACF"}