INNER CODE UNIT · JavaScript
assetExists
tiliondev/fortress · sdk/node/index.js:102
async function assetExists(plat, host) {
try { return (await fetch(`${host}/${ASSETS[plat].asset}`, { method: "HEAD" })).ok; }
catch { return false; }
}
async function waitCdp(port, timeoutMs = 90000) {
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
try { const r = await fetch(`http://127.0.0.1:${port}/json/version`); if (r.ok) return (await r.json()).webSocketDebuggerUrl; }
catch {}
await new Promise((r) => setTimeout(r, 500));
}
throw new Error("Fortress CDP endpoint did not come up");
}
export class Fortress {
constructor({ port = 9222, persona = null, extraArgs = [], headless = true, channel = DEFAULT_CHANNEL } = {}) {
if (!CHANNELS[channel]) throw new Error(`unknown channel '${channel}'; use one of ${Object.keys(CHANNELS)}`);