Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Docs: Your keys in public sign-up, backing up secrets.key, and the end-to-end check

Adarsh69768651823a
diff --git a/docs/SELF-HOSTING.md b/docs/SELF-HOSTING.md
index 2cc9397b..e40fec20 100644
--- a/docs/SELF-HOSTING.md
+++ b/docs/SELF-HOSTING.md
@@ -82,7 +82,7 @@ Public sign-up, guest browsing and connecting your own GPU to a shared install a
| `FUOBE_ALLOWED_ORIGINS` | Extra hosts Fuobe is reached at, comma-separated. Without a password, Fuobe answers only on IP addresses, localhost, single-label and LAN names (`.local`, `.lan`, `.home.arpa`, `.internal`) and the machine's hostname; add any other domain (a reverse proxy, a tunnel, a Tailscale name), or `*` to turn the check off. Also counts as "same site" for the cross-site write check behind a proxy that forwards neither Host nor X-Forwarded-Host |
| `FUOBE_TRUST_PROXY=1` | Behind a reverse proxy: trust the last `X-Forwarded-For` hop, so wrong passwords, and too many wrong share links, lock out only that visitor (60 s). Without it, everyone shares one limit: passwords are slowed to one attempt every 4 s and never locked, and wrong share links past 100 a minute get 429 while real links still open |
| `FUOBE_ALLOW_PRIVATE_URLS=1` | Let inputs, product links and project sources be fetched from private / LAN addresses (they are refused by default), and let Assist connectors use plain http beyond localhost (without it a connector needs https unless it is on localhost; a private https address is accepted, with a warning that Claude can only reach it through a public tunnel) |
-| `FUOBE_DATA_DIR` | Where the database, files and `auth.json` live (default `./data`) |
+| `FUOBE_DATA_DIR` | Where the database, files and `auth.json` live (default `./data`). Back up `secrets.key` there with `auth.json`: it opens the fal.ai and Replicate keys accounts saved ([Your keys](public-signup.md#your-keys)), which must be added again without it |
| `FUOBE_DEMO_MODE` | `auto` (default: demo outputs only when a model's provider isn't connected), `on` or `off` |
| `FUOBE_SKILLS_DIR` | Where Assist's built-in skills are read from (default `./skills`) |
| `FUOBE_ENGINE_MODE`, `FUOBE_CLOUD_PROVIDER`, `FUOBE_ENHANCE_PROVIDER`, `FUOBE_LLM_PROVIDER` | The Settings choices above |
diff --git a/docs/public-signup.md b/docs/public-signup.md
index 74d83c2c..37ed23d4 100644
--- a/docs/public-signup.md
+++ b/docs/public-signup.md
@@ -69,10 +69,10 @@ An account is signed in, but it sees the owner's studio as a guest does:
- **Settings, keys and tokens are the owner's.** Changing settings or model switches, the password,
API tokens, Public sign-up, LoRA downloads, Assist connectors and the MCP endpoint answer 403 for
an account.
-- **Accounts never run on the owner's keys or GPU.** An account runs only on its own ComfyUI (see
- [Your GPU](#your-gpu)). Without one, anything that would reach a model (a generation, an AI
- helper, a retry) answers 403 with `code: "connect-gpu"`, and the studio shows a "Connect your GPU
- to run this" card.
+- **Accounts never run on the owner's keys or GPU.** An account runs on its own ComfyUI (see
+ [Your GPU](#your-gpu)) or its own fal.ai or Replicate key (see [Your keys](#your-keys)). With
+ neither, anything that would reach a model (a generation, an AI helper, a retry) answers 403
+ with `code: "connect-gpu"`, and the studio shows a "Connect your GPU to run this" card.
- **Its own runs are its own.** The runs an account starts on its GPU appear in its own lists
(`GET /api/generations`), and it can open, cancel and delete them and download their files. They
stay out of the owner's Library and live feed, and no other account can open them. The studio's
@@ -216,11 +216,49 @@ cloudflared tunnel --url http://localhost:8188 # or: ngrok http 8188
`GET /api/models` lists the open-source models for a visitor, and the studios price a visitor's
run as it would go on its own GPU. The studio's own settings page isn't shown to visitors.
+## Your keys
+
+An account can add its own fal.ai key or Replicate token in **Settings → Your keys** (below Your
+GPU), or from the "Add your key" card that opens when it picks a paid model it has no key for. With
+a key it runs that provider's paid models (Nano Banana, Seedream, Kling, Veo…), billed to its own
+account with that provider. The studio's own keys are never used for an account's run.
+
+- **Checked first.** `PUT /api/account/keys/fal` (or `/replicate`) with `{ key }` checks the key
+ with the provider before it is saved: a free call that runs nothing (fal.ai: the status of a
+ request that doesn't exist; Replicate: `GET /v1/account`). A refused key answers 422, a provider
+ out of reach 502, and nothing is saved. `?test=1` only checks. 10 checks a minute per account,
+ 120 for all accounts together.
+- **Stored encrypted.** The key is sealed with AES-256-GCM under a server key in
+ `data/secrets.key`, made the first time a key is saved, and kept on the account's record in
+ `auth.json`. The server key isn't derived from the sign-in secret, so a new password or "Sign
+ everyone out" leaves saved keys working. Without `secrets.key` (lost, or restored from another
+ server), saved keys can't be opened: accounts are asked to add them again, and the studio's keys
+ are never used instead.
+- **Never shown.** `GET /api/account/keys` gives each key's last 4 characters, when it was added,
+ whether this server can still open it, and whether the provider refused it in a run. No answer,
+ log or error holds a key: a provider's error that echoes the request has it replaced with "••••".
+ The owner's **Settings → Accounts** shows which providers an account has a key for (the CSV has
+ `fal_key` and `replicate_key`), never the key.
+- **Removed with the account.** Deleting an account (by itself or by the owner) switches it off,
+ stops its running jobs at the provider with its own key, then removes its runs, files and record,
+ keys included. Removing or replacing a key that runs are going on answers 409 `runs-going` first;
+ with `{ stopRuns: true }` those runs are stopped with the old key before it changes.
+- **What it changes in the studios.** `GET /api/status` lists the account's keys
+ (`viewer.keys`) and its engine mode: `both` while it has a key and the studio isn't open-source
+ only, else `open`. The model pickers dim the paid models it has no key for ("Add your Replicate
+ key"), and prices say who pays ("≈ $0.15 · your fal.ai account"). A paid run without the key
+ answers 403 with `code: "add-key"` and an `x-fuobe-add-key` header naming the provider.
+- **Limits.** Every account limit applies to paid runs too (4 at once, 60 an hour, 4 outputs a run,
+ its space), checked before anything reaches the provider. Runs with a key send the prompt and the
+ attached files to that provider. civitai LoRAs are left out of runs on an account's key (copying
+ them would use the studio's civitai key). Assist, text steps, 3D and the other tools stay closed.
+- An account on a studio set to **Open source only** keeps its keys, but they aren't used.
+
## Uploads
-An account with its own ComfyUI connected can upload files (`POST /api/uploads`, the file as the
-request body with its type in `Content-Type` and its name in `X-File-Name`; an older page's
-multipart form works up to 26 MB). Without a connected GPU it answers 403 with
+An account with its own ComfyUI connected, or its own key, can upload files (`POST /api/uploads`,
+the file as the request body with its type in `Content-Type` and its name in `X-File-Name`; an
+older page's multipart form works up to 26 MB). With neither it answers 403 with
`code: "connect-gpu"`, and a guest gets 401 with the sign-up card.
| What | Types | Largest |
@@ -250,7 +288,11 @@ account? }`.
The rules are in `src/lib/guest-access.ts` (which paths guests and accounts may use) and
`src/proxy.ts` (where they are applied). Your GPU is `src/server/account-gpu.ts`, `onOwnGpu` in
`src/server/providers/comfyui.ts` and `accountRun` in `src/server/generations.ts`; what an account's
-work may read is `src/server/tenant.ts`. Uploads are `src/app/api/uploads/route.ts` (which makes the
+work may read is `src/server/tenant.ts`. Your keys are `src/server/account-keys.ts` (storage),
+`src/server/secret-box.ts` (encryption), `src/server/provider-keys.ts` (`cloudKey`, the one place a
+fal.ai or Replicate key is read) and `src/app/api/account/keys`; their tests are the
+`tests/account-keys*.test.ts` files, `tests/secret-box.test.ts`, `tests/byo-keys-static.test.ts` and
+`tests/e2e/byo-keys.mjs` (against stand-in providers). Uploads are `src/app/api/uploads/route.ts` (which makes the
proxy's checks itself, `src/server/direct-gate.ts`), the limits are in `src/server/account-files.ts`
and the clean-up in `src/server/account-sweep.ts`. The owner's view of what accounts make is
`src/server/account-admin.ts`. The tests are in `tests/public-signup.test.ts`,
diff --git a/src/server/generations.ts b/src/server/generations.ts
index 281bed6f..e3a503a4 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -58,7 +58,6 @@ import { comfyLoraFiles, computerScope, onOwnGpu, outputFetch, outsideOwnGpu, OW
import { accountById, accountGpu, gpuLink, type AccountGpu } from "./auth";
import { accountEngineMode, accountKey, paidAllowed } from "./account-keys";
import { addKeyMessage, isCloudProvider, keyRemovedMessage, type CloudProvider } from "@/lib/your-keys";
-import type { ProviderAdapter } from "./providers/types";
import { CONNECT_GPU_MESSAGE, GUEST_RUN_MESSAGE, OWN_GPU_TOOL_MESSAGE } from "@/lib/guest-access";
import { outsideTenant, runAsTenant, tenant, tenantAccount } from "./tenant";
import { generationAccount } from "./account-library";
@@ -72,7 +71,7 @@ import { ensureLorasOnComfy, prepareCloudLoras, withoutUnreachableCivitai } from
import { ACCESS_PLACE } from "@/lib/model-access";
import { offeredLoras, offeredRoutes, requireOffered } from "./model-access";
import { llmBackends, llmLabel, llmMissing, llmUsesClaude, probeLocal } from "./providers/llm";
-import type { PollContext, PollResult, RemoteOutput } from "./providers/types";
+import type { PollContext, PollResult, ProviderAdapter, RemoteOutput } from "./providers/types";
import { mediaFacts } from "./media-facts";
import { modelToFinish, startModelFinish, startTurntable, stopModelFinish, type OutputStore } from "./model3d-finish";
import { convertMask, decodePng, encodePng } from "./png";
diff --git a/tests/e2e/byo-keys.mjs b/tests/e2e/byo-keys.mjs
new file mode 100644
index 00000000..734d2f1f
--- /dev/null
+++ b/tests/e2e/byo-keys.mjs
@@ -0,0 +1,251 @@
+// Your keys, end to end (DESIGN: an account brings its own fal.ai or Replicate key). Starts stand-in fal.ai and
+// Replicate servers (tests/helpers/fake-cloud.ts) on 3391/3392 and `next dev` on 3390 with a throwaway data folder, the
+// owner's sentinel keys in the environment and Settings, and FUOBE_DEV_FAL_URL / FUOBE_DEV_REPLICATE_URL pointing at
+// the stand-ins. No real key, no paid call. Everything it starts is stopped at the end.
+//
+// node tests/e2e/byo-keys.mjs [screenshots folder]
+//
+// BYO_PORT moves all three (app, fal.ai, Replicate on the next two ports) when 3390–3392 are taken.
+//
+// Checks: the owner's runs send the owner's key; an account without a key can't run a paid model; an account adds a
+// bad key (refused) and a good one; its paid run sends only its key; removing the key with a run going asks first and
+// stops the run with that key; no key shows in any answer, page or server log. Screenshots: Settings → Your keys and
+// the model picker, on a phone and a desktop.
+import { spawn, execSync } from "node:child_process";
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { DESKTOP, launch, PHONE, root } from "./_browser.mjs";
+import { startFakeFal, startFakeReplicate } from "../helpers/fake-cloud.ts";
+
+const APP_PORT = Number(process.env.BYO_PORT ?? 3390);
+const APP = `http://127.0.0.1:${APP_PORT}`;
+const shots = path.resolve(process.argv[2] ?? fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-byo-shots-")));
+fs.mkdirSync(shots, { recursive: true });
+const data = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-byo-data-"));
+const logFile = path.join(data, "..", `${path.basename(data)}-server.log`);
+
+const PASSWORD = "owner password for the smoke";
+const OWNER_FAL = "owner-fal-db-key:owner-fal-db-secret";
+const OWNER_ENV = { FAL_KEY: "owner-fal-env:owner-fal-env-secret", REPLICATE_API_TOKEN: "r8_ownerEnvToken" };
+const ACCT_FAL = "acct-smoke-key-id:acct-smoke-secret-9f3a";
+const BAD_FAL = "acct-wrong-key-id:acct-wrong-secret-0000";
+const SECRETS = [OWNER_FAL, "owner-fal-db-secret", OWNER_ENV.FAL_KEY, OWNER_ENV.REPLICATE_API_TOKEN, ACCT_FAL, "acct-smoke-secret-9f3a", BAD_FAL, "acct-wrong-secret-0000"];
+
+const failures = [];
+const check = (ok, what) => {
+ console.log(`${ok ? "ok " : "FAIL"} ${what}`);
+ if (!ok) failures.push(what);
+};
+const wait = (ms) => new Promise((r) => setTimeout(r, ms));
+
+const fal = await startFakeFal(APP_PORT + 1);
+const rep = await startFakeReplicate(APP_PORT + 2);
+for (const k of [OWNER_FAL, OWNER_ENV.FAL_KEY, ACCT_FAL]) fal.keys[k] = "good";
+rep.keys[OWNER_ENV.REPLICATE_API_TOKEN] = "good";
+
+const log = fs.openSync(logFile, "w");
+const server = spawn(process.execPath, [path.join(root, "node_modules/next/dist/bin/next"), "dev", "-p", String(APP_PORT), "-H", "127.0.0.1"], {
+ cwd: root,
+ env: {
+ ...process.env,
+ ...OWNER_ENV,
+ NODE_ENV: "development",
+ FUOBE_DATA_DIR: data,
+ FUOBE_PASSWORD: PASSWORD,
+ FUOBE_PUBLIC_SIGNUP: "1",
+ FUOBE_DEV_FAL_URL: fal.url,
+ FUOBE_DEV_REPLICATE_URL: rep.url,
+ COMFYUI_URL: "http://127.0.0.1:9",
+ FUOBE_ACCOUNT_DISK_FREE_GB: "0",
+ },
+ stdio: ["ignore", log, log],
+});
+
+async function stopAll() {
+ try {
+ if (process.platform === "win32") execSync(`taskkill /pid ${server.pid} /T /F`, { stdio: "ignore" });
+ else server.kill("SIGTERM");
+ } catch {}
+ await fal.close();
+ await rep.close();
+}
+
+/** fetch with a cookie jar of one cookie. */
+const api = async (route, { method = "GET", body, cookie } = {}) => {
+ const res = await fetch(APP + route, { method, headers: { "Content-Type": "application/json", Origin: APP, ...(cookie && { cookie }) }, ...(body !== undefined && { body: JSON.stringify(body) }) });
+ const text = await res.text();
+ let json = null;
+ try {
+ json = JSON.parse(text);
+ } catch {}
+ return { status: res.status, text, json, headers: res.headers };
+};
+const cookieOf = (res) => /fuobe_session=[^;]+/.exec(res.headers.get("set-cookie") ?? "")?.[0];
+const readable = [];
+
+try {
+ // The server is up (first compile can take a while).
+ for (let i = 0; i < 240; i++) {
+ try {
+ const r = await fetch(`${APP}/login`);
+ if (r.status < 500) break;
+ } catch {}
+ await wait(1000);
+ }
+
+ // The owner: signs in, sets the studio's own fal.ai key in Settings, runs a paid model on it.
+ const ownerLogin = await api("/api/auth/login", { method: "POST", body: { password: PASSWORD } });
+ const owner = cookieOf(ownerLogin);
+ check(!!owner, "owner signs in");
+ check((await api("/api/settings", { method: "PUT", cookie: owner, body: { falKey: OWNER_FAL } })).status === 200, "owner saves the studio's fal.ai key");
+ fal.log.length = 0;
+ const ownerRun = await api("/api/generations", { method: "POST", cookie: owner, body: { feature: "image", modelId: "nano-banana-pro", engine: "cloud", prompt: "the owner's harbour" } });
+ check(ownerRun.status === 201, `owner's paid run starts (${ownerRun.status})`);
+ for (let i = 0; i < 60 && !fal.log.some((r) => r.method === "POST"); i++) await wait(500);
+ check(fal.log.length > 0 && fal.log.every((r) => r.authorization === `Key ${OWNER_FAL}`), "the owner's run sends the owner's key");
+
+ // An account signs up: no key, no GPU.
+ const signup = await api("/api/auth/signup", { method: "POST", body: { email: "[email protected]", password: "account password" } });
+ const acct = cookieOf(signup);
+ check(!!acct, "an account signs up");
+ fal.log.length = 0;
+ rep.log.length = 0;
+ const noKey = await api("/api/generations", { method: "POST", cookie: acct, body: { feature: "image", modelId: "nano-banana-pro", engine: "cloud", prompt: "x" } });
+ check(noKey.status === 403 && fal.log.length === 0 && rep.log.length === 0, `an account without a key can't run a paid model, and nothing reaches a provider (${noKey.status}: ${noKey.json?.error})`);
+ readable.push(noKey.text);
+
+ const browser = await launch();
+ const [name, value] = acct.split("=");
+ const contexts = [];
+ for (const [label, opts] of [
+ ["desktop", DESKTOP],
+ ["phone", PHONE],
+ ]) {
+ const ctx = await browser.newContext({ ...opts, baseURL: APP });
+ await ctx.addCookies([{ name, value, url: APP }]);
+ contexts.push([label, ctx]);
+ }
+ const [, desk] = contexts[0];
+ const page = await desk.newPage();
+
+ // The Image studio: the switch is locked on open source, pointing at Your keys.
+ await page.goto("/image", { waitUntil: "load", timeout: 180_000 });
+ await page.waitForTimeout(2500);
+ const lockedSwitch = page.getByRole("link", { name: /Open source only/ }).first();
+ check((await lockedSwitch.getAttribute("href").catch(() => null)) === "/settings#your-keys", "the engine switch is locked on open source, linking to Your keys");
+
+ // Settings → Your keys: a bad key, then a good one.
+ await page.goto("/settings#your-keys", { waitUntil: "load", timeout: 180_000 });
+ await page.getByRole("heading", { name: "Your keys" }).waitFor({ timeout: 60_000 });
+ await page.screenshot({ path: path.join(shots, "your-keys-empty-desktop.png"), fullPage: false });
+ const falField = page.getByLabel("fal.ai API key");
+ await falField.fill(BAD_FAL);
+ await page.getByRole("button", { name: "Check and save" }).first().click();
+ await page.getByText("fal.ai didn't accept this key").waitFor({ timeout: 30_000 });
+ check(true, "a bad key is refused with plain words");
+ await page.screenshot({ path: path.join(shots, "your-keys-refused-desktop.png") });
+ await falField.fill(ACCT_FAL);
+ await page.getByRole("button", { name: "Check and save" }).first().click();
+ await page.getByText("Key ending in").waitFor({ timeout: 30_000 });
+ check((await page.content()).includes("9f3a"), "a good key is saved and shown by its last 4 characters");
+ await page.waitForTimeout(800);
+ await page.screenshot({ path: path.join(shots, "your-keys-saved-desktop.png") });
+ readable.push(await page.content());
+
+ // The Image studio again: the switch opens, the picker dims Replicate-only models, the price says who pays.
+ await page.goto("/image", { waitUntil: "load", timeout: 180_000 });
+ await page.waitForTimeout(2500);
+ const radio = page.getByRole("radiogroup", { name: "Engine" }).first();
+ check(await radio.isVisible().catch(() => false), "with a key, the engine switch switches");
+ await page.getByRole("radio", { name: "Cloud" }).first().click().catch(() => {});
+ // The price shows once there is something to run.
+ await page.locator("textarea").first().fill("a quiet harbour at dawn");
+ await page.waitForTimeout(800);
+ const chip = await page.locator("text=/your fal\\.ai account/").first().textContent().catch(() => null);
+ check(!!chip, `the price says who pays (${chip?.trim()})`);
+ await page.screenshot({ path: path.join(shots, "studio-price-desktop.png") });
+ await page.getByRole("button", { name: /^Model: / }).first().click();
+ await page.getByPlaceholder(/Search/).first().fill("imagen");
+ await page.waitForTimeout(800);
+ check(await page.getByText("Add your Replicate key").first().isVisible().catch(() => false), "the picker dims a Replicate-only model with Add your Replicate key");
+ await page.screenshot({ path: path.join(shots, "picker-desktop.png") });
+ await page.getByText("Add your Replicate key").first().click();
+ await page.getByRole("dialog").getByText("Add your Replicate key").waitFor({ timeout: 10_000 });
+ check(true, "choosing a dimmed model opens Add your Replicate key");
+ await page.screenshot({ path: path.join(shots, "add-key-dialog-desktop.png") });
+ await page.keyboard.press("Escape");
+ readable.push(await page.content());
+
+ // A paid run on the account's key: only its key reaches fal.ai, and a result arrives.
+ fal.log.length = 0;
+ const run = await api("/api/generations", { method: "POST", cookie: acct, body: { feature: "image", modelId: "nano-banana-pro", engine: "cloud", prompt: "the account's harbour" } });
+ check(run.status === 201, `the account's paid run starts (${run.status})`);
+ readable.push(run.text);
+ const id = run.json?.items?.[0]?.id;
+ let done = null;
+ for (let i = 0; i < 80 && id; i++) {
+ const g = await api(`/api/generations/${id}`, { cookie: acct });
+ if (g.json && !["queued", "running"].includes(g.json.status)) {
+ done = g.json;
+ readable.push(g.text);
+ break;
+ }
+ await wait(500);
+ }
+ check(done?.status === "succeeded" && done.outputs?.length > 0, `a result arrives (${done?.status} ${done?.error ?? ""})`);
+ check(fal.log.length > 0 && fal.log.every((r) => r.authorization === `Key ${ACCT_FAL}`), "the provider saw only the account's key");
+
+ // Remove the key while a run is going: it asks first, then stops the run with that key.
+ fal.pollsToFinish = Infinity;
+ fal.log.length = 0;
+ const slow = await api("/api/generations", { method: "POST", cookie: acct, body: { feature: "image", modelId: "nano-banana-pro", engine: "cloud", prompt: "a slow harbour" } });
+ for (let i = 0; i < 40 && !fal.log.some((r) => r.method === "POST"); i++) await wait(250);
+ await page.goto("/settings#your-keys", { waitUntil: "load", timeout: 180_000 });
+ await page.getByText("Key ending in").waitFor({ timeout: 60_000 });
+ await page.getByRole("button", { name: "Remove", exact: true }).first().click();
+ await page.getByRole("button", { name: "Remove key" }).click();
+ await page.getByText(/run is using this key now/).waitFor({ timeout: 20_000 });
+ await page.screenshot({ path: path.join(shots, "your-keys-runs-going-desktop.png") });
+ await page.getByRole("button", { name: "Stop runs and remove" }).click();
+ await page.getByText("Your fal.ai key is removed from this studio.").waitFor({ timeout: 20_000 });
+ const cancel = fal.log.find((r) => r.path.endsWith("/cancel"));
+ check(cancel?.authorization === `Key ${ACCT_FAL}`, "removing the key stopped the running job at fal.ai with that key");
+ const slowRow = await api(`/api/generations/${slow.json?.items?.[0]?.id}`, { cookie: acct });
+ check(slowRow.json?.status === "canceled", `the run going on it stopped (${slowRow.json?.status})`);
+
+ // Phones: Settings → Your keys and the studio, no sideways scroll.
+ const [, phone] = contexts[1];
+ const p2 = await phone.newPage();
+ await p2.goto("/settings#your-keys", { waitUntil: "load", timeout: 180_000 });
+ await p2.getByRole("heading", { name: "Your keys" }).waitFor({ timeout: 60_000 });
+ await p2.waitForTimeout(800);
+ await p2.screenshot({ path: path.join(shots, "your-keys-phone.png"), fullPage: true });
+ const sideways = await p2.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
+ check(sideways <= 0, `no sideways scroll on a phone (${sideways}px)`);
+
+ // Every answer and page the account read, every provider log and the server log: no key, anywhere.
+ readable.push((await api("/api/account/keys", { cookie: acct })).text, (await api("/api/status", { cookie: acct })).text, (await api("/api/auth/me", { cookie: acct })).text);
+ readable.push((await api("/api/admin/accounts", { cookie: owner })).text, (await api("/api/admin/accounts?format=csv", { cookie: owner })).text);
+ const serverLog = fs.readFileSync(logFile, "utf8");
+ const leaks = SECRETS.filter((s) => readable.some((t) => t.includes(s)) || serverLog.includes(s));
+ check(leaks.length === 0, `no key in any answer, page or the server log${leaks.length ? `: ${leaks.join(", ")}` : ""}`);
+ const ownerAtProvider = [...fal.log, ...rep.log].some((r) => [OWNER_FAL, OWNER_ENV.FAL_KEY, OWNER_ENV.REPLICATE_API_TOKEN].some((k) => r.authorization?.includes(k)));
+ check(!ownerAtProvider, "the owner's keys never reached a provider during the account's work");
+
+ await browser.close();
+} catch (e) {
+ failures.push(`crashed: ${e.stack ?? e}`);
+ console.error(e);
+} finally {
+ await stopAll();
+ console.log(`\nscreenshots: ${shots}\nserver log: ${logFile}`);
+ try {
+ fs.rmSync(data, { recursive: true, force: true });
+ } catch {}
+}
+if (failures.length) {
+ console.log(`\n${failures.length} failed`);
+ process.exit(1);
+}
+console.log("\nall passed");