Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Boat sign-in: review fixes

milind-soni5aa411fd4c48
diff --git a/electron/boat-sign-in-store.d.mts b/electron/boat-sign-in-store.d.mts
new file mode 100644
index 0000000000..c052f2cc71
--- /dev/null
+++ b/electron/boat-sign-in-store.d.mts
@@ -0,0 +1,10 @@
+export const BOAT_SIGN_IN_CREDENTIAL: "boatSignIn";
+export const BOAT_SIGN_IN_ENV: "OMB_BOAT_SIGN_IN";
+export function boatSignInEnv(credentials: Record<string, unknown> | null | undefined, packaged: boolean): Record<string, string>;
+export function decodeBoatSignInStoreRequest(rawMessage: unknown): { requestId: string; op: "read" } | { requestId: string; op: "write"; value: string | null } | null;
+export function createBoatSignInStore(options: {
+ packaged: boolean;
+ read: () => Record<string, unknown>;
+ update: (derive: (credentials: Record<string, unknown>) => Record<string, unknown>) => Promise<unknown>;
+ log: (line: string) => void;
+}): { receive(proc: { postMessage(message: unknown): void }, rawMessage: unknown): boolean };
diff --git a/server/boat-call.ts b/server/boat-call.ts
index 523eb29e11..02768ffe8c 100644
--- a/server/boat-call.ts
+++ b/server/boat-call.ts
@@ -34,7 +34,7 @@ const refusal = (status: number, error: string, message: string): Response =>
function words(status: number, code: string, method: string, scope: BoatScope | null): string | null {
if (status === 400) {
return code === "org_required"
- ? `Your Boat account sign-in covers several organizations and none of them is your default. Sign in to Boat again in ${SETTINGS} and tick one place, or set a default organization in boat.dev`
+ ? `Your Boat account sign-in covers several organizations and none of them is your default. Sign in to Boat again in ${SETTINGS} and tick one organization only on that screen, or set a default organization in boat.dev`
: null;
}
if (status === 401) return BOAT_SIGN_IN_PROBLEM["needs-sign-in"];
diff --git a/server/boat-sign-in-host.ts b/server/boat-sign-in-host.ts
index 344acde161..ac328994fb 100644
--- a/server/boat-sign-in-host.ts
+++ b/server/boat-sign-in-host.ts
@@ -37,8 +37,9 @@ export interface BoatSignInHostDeps {
export interface BoatSignInHost {
signIn: BoatSignIn;
- /** For configStatus `box`: whether a key is saved, and the sign-in's state where it is offered. */
- statusPart(): { keySaved: boolean; signIn?: BoatSignInStatus };
+ /** For configStatus `box`, only where sign-in is offered: whether a key is saved, and the sign-in's state. Elsewhere
+ * nothing, so that status is exactly what it was. */
+ statusPart(): { keySaved?: boolean; signIn?: BoatSignInStatus };
/** Answers Boat's redirect; false when the request is not that. Runs before the sign-in gate: the state is the credential. */
callback(req: IncomingMessage, res: ServerResponse, url: URL): Promise<boolean>;
routes: RouteHandler;
@@ -89,7 +90,7 @@ export function createBoatSignInHost(deps: BoatSignInHostDeps): BoatSignInHost {
return {
signIn,
- statusPart: () => ({ keySaved: keySaved(), ...(enabled ? { signIn: signIn.status(keySaved()) } : {}) }),
+ statusPart: () => (enabled ? { keySaved: keySaved(), signIn: signIn.status(keySaved()) } : {}),
receive: (message) => store.receive(message),
async callback(req, res, url) {
if (url.pathname !== BOAT_SIGN_IN_CALLBACK_PATH) return false;
@@ -117,7 +118,8 @@ export function createBoatSignInHost(deps: BoatSignInHostDeps): BoatSignInHost {
}
if (method === "DELETE" && path === "/api/boat/sign-in") {
// Disconnecting changes the credential in use only when the sign-in is that credential.
- const refusal = signIn.used(keySaved())
+ // A sign-in Boat has ended reaches nothing: it is only forgotten here, with nothing to check or revoke.
+ const refusal = signIn.used(keySaved()) && signIn.status(keySaved()).state === "connected"
? await checked(() => boatAccountChangeRefusal({ box: { token: BOAT_SIGN_IN_MARK } }, keySaved() ? { box: { token: deps.cfg.box?.token } } : null, deps.managedBoatOwners()))
: null;
if (refusal) return json(res, 409, { error: refusal });
diff --git a/server/boat-sign-in.test.ts b/server/boat-sign-in.test.ts
index fc78d3d15d..567f051e05 100644
--- a/server/boat-sign-in.test.ts
+++ b/server/boat-sign-in.test.ts
@@ -1,7 +1,7 @@
// "Sign in with Boat" against a local stand-in for Boat (server/testing/fake-boat-oauth.ts): nothing here reaches boat.dev.
import { createServer, request, type IncomingMessage, type Server } from "node:http";
import type { AddressInfo } from "node:net";
-import { mkdtempSync, readFileSync, statSync } from "node:fs";
+import { mkdtempSync, readFileSync, statSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -11,7 +11,9 @@ import { BOAT_SIGN_IN_MARK } from "../shared/boat-sign-in.ts";
import { boatFetch } from "./boat.ts";
import { BOAT_SIGN_IN_CALLBACK_PATH, BOAT_SIGN_IN_CLIENT_ID, BOAT_SIGN_IN_PORTS, BOAT_SIGN_IN_SCOPES, BoatSignIn, boatScopeFor, type BoatSignInPersistence } from "./boat-sign-in.ts";
import { createBoatSignInHost, type BoatSignInHost } from "./boat-sign-in-host.ts";
-import { BOAT_SIGN_IN_ENV, BOAT_SIGN_IN_FILE, createBoatSignInStore } from "./boat-sign-in-store.ts";
+import { BOAT_SIGN_IN_ENV, BOAT_SIGN_IN_FILE, createBoatSignInStore, type BoatSignInStore } from "./boat-sign-in-store.ts";
+import { createBoatSignInStore as createDesktopBoatSignInStore } from "../electron/boat-sign-in-store.mjs";
+import { createSecureCredentialState } from "../electron/secure-credential-state.mjs";
import { setBoatSignIn } from "./boat-sign-in-use.ts";
import { loadConfig, WORKSPACE_CREDENTIAL_ENV, type AppConfig } from "./config.ts";
import { json } from "./harness/http.ts";
@@ -92,7 +94,7 @@ describe("signing in", () => {
const { state, persistence } = memory();
const signIn = signInWith(persistence);
const started = new URL(signIn.start("owner", PORT).url);
- expect(started.origin + started.pathname).toBe(`${fake.origin}/api/boat/oauth2/authorize`);
+ expect(started.origin + started.pathname).toBe(`${fake.origin}/api/box/oauth2/authorize`);
expect(Object.fromEntries(started.searchParams)).toMatchObject({
response_type: "code", client_id: BOAT_SIGN_IN_CLIENT_ID, redirect_uri: `http://127.0.0.1:${PORT}/api/boat/oauth/callback`,
scope: BOAT_SIGN_IN_SCOPES.join(" "), code_challenge_method: "S256",
@@ -402,6 +404,19 @@ describe("what the person allowed", () => {
expect(fake.counts.api).toBe(sent);
});
+ it("a sign-in that cannot see sandboxes, or names no organization, is refused in its own words, never as a rejected API key", async () => {
+ const { state, persistence } = memory();
+ const signIn = signInWith(persistence, { beforeConnect: async () => "boat.dev rejected the Boat API key — update it in Settings → AI → Other services" });
+ const blind = await connect(signIn, { scopes: BOAT_SIGN_IN_SCOPES.filter((scope) => scope !== "sandbox.read") });
+ expect(blind.answer).toMatchObject({ status: 400, text: expect.stringContaining("keep \"sandbox.read\" ticked") });
+ fake.requireOrg(true);
+ const several = await connect(signIn);
+ expect(several.answer).toMatchObject({ status: 400, text: expect.stringContaining("tick one organization only on Boat's screen") });
+ for (const answer of [blind.answer, several.answer]) expect(answer.text).not.toContain("API key");
+ expect(state.value).toBeNull();
+ expect(signIn.status(false, "owner").last).toEqual({ outcome: "refused" });
+ });
+
it("without account.read it connects and shows no account", async () => {
const signIn = signInWith(memory().persistence);
await connect(signIn, { scopes: BOAT_SIGN_IN_SCOPES.filter((scope) => scope !== "account.read") });
@@ -547,6 +562,41 @@ describe("where the connection is kept", () => {
expect(store.persistence.read()).toBeNull();
});
+ it("in the packaged app a key saved beside a sign-in never waits on the queue it is saved through", async () => {
+ // The app's real serialized credential writer, its real store, and the server's store, joined as the private port joins them.
+ const credentials = createSecureCredentialState({}, async () => {});
+ let server: BoatSignInStore;
+ const desktop = createDesktopBoatSignInStore({ packaged: true, read: () => credentials.read(), update: (derive) => credentials.update(derive), log: () => {} });
+ const port = { postMessage: (message: unknown) => { server.receive(message); } };
+ server = createBoatSignInStore({ dataDir: dir, env: { [BOAT_SIGN_IN_ENV]: "" }, post: (message) => desktop.receive(port, message) });
+ const signIn = signInWith(server.persistence);
+ expect((await connect(signIn)).answer.status).toBe(200);
+ const kept = () => JSON.parse(String(credentials.read().boatSignIn)) as { prefer: string; access: string };
+ expect(kept().prefer).toBe("signIn");
+
+ // The app saves a pasted key: the server's part of that save runs inside the writer's turn, as PUT /api/config does.
+ let saving: Promise<void> | undefined;
+ await credentials.update((document) => ({ ...document, boxToken: "boat_pasted_key_0003" }), async () => {
+ saving = signIn.preferKey();
+ // Used at once, though its save can only land after this turn ends.
+ expect(signIn.used(true)).toBe(false);
+ });
+ await saving;
+ expect(kept().prefer).toBe("key");
+ expect(credentials.read().boxToken).toBe("boat_pasted_key_0003");
+
+ // A renewal that comes due inside such a turn is started, not waited for, and is saved once the turn ends.
+ advance(58 * MINUTE);
+ expect(signIn.renewalDue()).toBe(true);
+ const before = kept().access;
+ let renewing: Promise<string> | undefined;
+ await credentials.update((document) => document, async () => { renewing = signIn.accessToken(); });
+ const renewed = await renewing!;
+ expect(renewed).not.toBe(before);
+ expect(kept()).toMatchObject({ access: renewed, prefer: "key" });
+ expect(signIn.renewalDue()).toBe(false);
+ });
+
it("the packaged app's server reads it from its environment once, then asks the app to read and save", async () => {
const env: NodeJS.ProcessEnv = { [BOAT_SIGN_IN_ENV]: "{\"v\":1}" };
const kept = { value: "{\"v\":1}" as string | null };
@@ -707,7 +757,8 @@ describe("on the server", () => {
it("is not offered on a self-hosted server, a hosted Cloud or any other port: paste a key only", async () => {
for (const more of [{ desktop: false }, { hosted: true }, { port: 5199 }, { port: 8800 }]) {
make(more);
- expect(host.statusPart(), JSON.stringify(more)).toEqual({ keySaved: false });
+ // Exactly what the config said before sign-in existed: nothing added.
+ expect(host.statusPart(), JSON.stringify(more)).toEqual({});
expect((await call("POST", "/api/boat/sign-in/start")).status).toBe(403);
expect((await get(`${BOAT_SIGN_IN_CALLBACK_PATH}?code=a&state=b`)).status).toBe(404);
expect(host.signIn.used(false)).toBe(false);
@@ -715,6 +766,25 @@ describe("on the server", () => {
for (const port of BOAT_SIGN_IN_PORTS) expect(make({ port }).statusPart().signIn?.available).toBe(true);
});
+ it("a sign-in Boat has ended can always be disconnected: it is only forgotten", async () => {
+ make();
+ const back = new URL(fake.approve((await call("POST", "/api/boat/sign-in/start")).body.url));
+ expect((await get(back.pathname + back.search)).status).toBe(200);
+ fake.disconnect();
+ // Found out by a call: the connection is now "sign in again".
+ const stored = JSON.parse(readFileSync(join(dir, BOAT_SIGN_IN_FILE), "utf8"));
+ writeFileSync(join(dir, BOAT_SIGN_IN_FILE), JSON.stringify({ ...stored, expiresAt: 0 }));
+ make();
+ Object.assign(cfg, loadConfig());
+ expect(cfg.box?.signIn).toBe(true);
+ expect((await boatFetch(cfg, "/sandboxes?limit=1")).status).toBe(401);
+ expect(host.statusPart().signIn?.state).toBe("needs-sign-in");
+ const revokes = fake.counts.revoke;
+ expect(await call("DELETE", "/api/boat/sign-in")).toEqual({ status: 200, body: { ok: true, revoked: true } });
+ expect(fake.counts.revoke).toBe(revokes);
+ expect(host.statusPart().signIn).toEqual({ available: true, state: "none", keySaved: false });
+ });
+
it("cancelling in the app spends the link", async () => {
make();
const started = await call("POST", "/api/boat/sign-in/start");
diff --git a/server/boat-sign-in.ts b/server/boat-sign-in.ts
index 85f94f5ced..55b2016f06 100644
--- a/server/boat-sign-in.ts
+++ b/server/boat-sign-in.ts
@@ -123,12 +123,13 @@ const sameText = (left: string, right: string): boolean => {
return timingSafeEqual(a, b);
};
-/** The origin the tokens go to: https, or a loopback stand-in in development and tests. */
+/** Boat's authorization server, as its own metadata document (boat.dev/.well-known/oauth-authorization-server) names it:
+ * `/api/box/oauth2/{authorize,token,revoke}` on the API's origin. https, or a loopback stand-in in development and tests. */
export function boatOAuthBase(api: string): string | null {
try {
const parsed = new URL(api);
const loopback = parsed.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(parsed.hostname);
- return parsed.protocol === "https:" || loopback ? `${parsed.origin}/api/boat/oauth2` : null;
+ return parsed.protocol === "https:" || loopback ? `${parsed.origin}/api/box/oauth2` : null;
} catch {
return null;
}
@@ -328,7 +329,8 @@ export class BoatSignIn {
: this.settle(flow, "failed", "Boat did not accept this sign-in. Return to the app and try again.");
}
const scopes = answer.scopes ?? [...BOAT_SIGN_IN_SCOPES];
- const refusal = await this.options.beforeConnect?.(answer.access).catch(() => "The cloud computers this installation remembers could not be checked.");
+ const refusal = await this.unusable(answer.access, scopes)
+ ?? await this.options.beforeConnect?.(answer.access).catch(() => "The cloud computers this installation remembers could not be checked.");
if (refusal) {
await this.giveBack(answer.refresh);
return this.settle(flow, "refused", `Not signed in: ${refusal}`.slice(0, 400));
@@ -360,6 +362,26 @@ export class BoatSignIn {
return this.settle(flow, "connected", "You can close this tab and return to the app.");
}
+ /** Why a sign-in just made cannot run cloud computers at all, in the person's words; null when it can. Asked before the
+ * account check, whose own words are about API keys. */
+ private async unusable(bearer: string, scopes: readonly string[]): Promise<string | null> {
+ const SEE = "the app must be allowed to see your sandboxes. Sign in again and keep \"sandbox.read\" ticked on Boat's screen.";
+ if (!holds(scopes, "sandbox.read")) return SEE;
+ try {
+ const response = await this.fetch(`${this.options.api()}/sandboxes?limit=1`, { headers: { authorization: `Bearer ${bearer}` }, redirect: "error", signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
+ if (response.ok) return null;
+ const body: any = await response.json().catch(() => null);
+ const code = typeof body?.error === "string" ? body.error : body?.error?.code ?? body?.code;
+ if (response.status === 400 && code === "org_required") {
+ return "you ticked several organizations and none of them is your default. Sign in again and tick one organization only on Boat's screen, or set a default organization in boat.dev.";
+ }
+ if (response.status === 403) return code === "api_key_action_forbidden" ? SEE : "boat.dev did not let this sign-in see your sandboxes. Sign in again and tick the organization and environments your cloud computers are in.";
+ return null;
+ } catch {
+ return null;
+ }
+ }
+
/** Tokens Boat issued for a sign-in that was not kept. Revoking gives up the app's access to the account, so it is done
* only when no working connection is held; otherwise they are dropped and run out by themselves. */
private async giveBack(refresh: string): Promise<void> {
@@ -512,7 +534,7 @@ export class BoatSignIn {
}
const next: BoatSignInDocument = {
...document, refresh: answer.refresh, access: answer.access, expiresAt: this.now() + answer.expiresIn * 1000,
- scopes: answer.scopes ?? document.scopes,
+ scopes: answer.scopes ?? document.scopes, prefer: this.document?.prefer ?? document.prefer,
};
// From here the old refresh token is dead at Boat. The new one is saved before its access token goes to any caller.
this.document = next;
@@ -527,18 +549,25 @@ export class BoatSignIn {
return next.access;
}
- /** A pasted key was saved after the sign-in: it is the one used from now on. */
+ /** A pasted key was saved after the sign-in: it is the one used from now on. The switch is made here at once; the
+ * returned promise is its save, which the caller must not wait for inside anything the store itself waits on (the
+ * packaged app saves a key and this connection through one queue). */
preferKey(): Promise<void> {
+ const document = this.document;
+ if (!this.enabled || !document || document.prefer === "key") return Promise.resolve();
+ this.document = { ...document, prefer: "key" };
+ this.changed();
return this.exclusive(async () => {
- const document = this.document;
- if (!this.enabled || !document || document.prefer === "key") return;
- const next = { ...document, prefer: "key" as const };
- await this.save(next);
- this.document = next;
- this.changed();
+ if (this.document) await this.save(this.document);
});
}
+ /** The next Boat call would first renew the token (and save it). */
+ renewalDue(): boolean {
+ const document = this.document;
+ return Boolean(this.enabled && document && !document.needsSignIn && (this.unsaved || document.expiresAt - this.now() <= REFRESH_MARGIN_MS));
+ }
+
/** Disconnect: Boat is told first, then the connection is forgotten here whatever Boat answered. */
signOut(): Promise<{ revoked: boolean }> {
return this.exclusive(async () => {
diff --git a/server/routes/config.ts b/server/routes/config.ts
index a47a3a129b..868ec43a26 100644
--- a/server/routes/config.ts
+++ b/server/routes/config.ts
@@ -298,6 +298,12 @@ export function createConfigRoutes(deps: ConfigRouteDeps): RouteHandler {
const currentBoatToken = cfg.box?.signIn ? BOAT_SIGN_IN_MARK : cfg.box?.token?.trim() ?? "";
const nextBoatToken = patch.box?.token === undefined ? currentBoatToken : patch.box.token || (boatSignIn()?.connected() ? BOAT_SIGN_IN_MARK : "");
const changingBoatToken = patch.box?.token !== undefined && nextBoatToken !== currentBoatToken;
+ // The checks below call Boat with the sign-in. A token due for renewal must be saved before it is used, and the
+ // packaged app's save waits for this very request: renew it outside the request and ask for the save again.
+ if (changingBoatToken && [currentBoatToken, nextBoatToken].includes(BOAT_SIGN_IN_MARK) && url.searchParams.get("secretStorage") === "external" && boatSignIn()?.renewalDue()) {
+ void boatSignIn()?.accessToken().catch(() => undefined);
+ return json(res, 503, { error: "Your Boat account sign-in is being renewed. Save the key again in a moment." });
+ }
const currentVpsAlias = vpsSshAlias(cfg);
const nextVpsAlias = patch.vps === undefined
? currentVpsAlias
@@ -662,8 +668,9 @@ export function createConfigRoutes(deps: ConfigRouteDeps): RouteHandler {
throw error;
}
if (patch.box?.token) {
- // The key was set last, so it is the one used from now on; if that cannot be saved the sign-in stays in use, and Settings shows which.
- await boatSignIn()?.preferKey().catch(() => undefined);
+ // The key was set last, so it is the one used from now on. Never awaited: the packaged app saves this key and the
+ // sign-in through one queue, and this request is inside that queue's turn.
+ void boatSignIn()?.preferKey().catch(() => undefined);
Object.assign(cfg, loadConfig());
}
for (const key of resetKeys) if (key) forgetKey(key);
diff --git a/server/testing/fake-boat-oauth.ts b/server/testing/fake-boat-oauth.ts
index d4a22e7032..5297c256b0 100644
--- a/server/testing/fake-boat-oauth.ts
+++ b/server/testing/fake-boat-oauth.ts
@@ -63,7 +63,7 @@ export async function startFakeBoat(clientId: string, redirectUris: string[], ap
const server = createServer(async (req, res) => {
const url = new URL(req.url ?? "/", "http://fake");
- if (req.method === "POST" && url.pathname === "/api/boat/oauth2/token") {
+ if (req.method === "POST" && url.pathname === "/api/box/oauth2/token") {
counts.token += 1;
const form = new URLSearchParams(await body(req));
if (form.get("client_id") !== clientId) return json(res, 401, { error: "invalid_client" });
@@ -104,7 +104,7 @@ export async function startFakeBoat(clientId: string, redirectUris: string[], ap
}
return json(res, 400, { error: "unsupported_grant_type" });
}
- if (req.method === "POST" && url.pathname === "/api/boat/oauth2/revoke") {
+ if (req.method === "POST" && url.pathname === "/api/box/oauth2/revoke") {
counts.revoke += 1;
const token = new URLSearchParams(await body(req)).get("token") ?? "";
const grant = grants.find((one) => one.refresh === token || one.access === token);
@@ -137,7 +137,7 @@ export async function startFakeBoat(clientId: string, redirectUris: string[], ap
const url = new URL(authorizeUrl);
const params = url.searchParams;
const redirectUri = params.get("redirect_uri") ?? "";
- if (url.origin !== origin || url.pathname !== "/api/boat/oauth2/authorize" || params.get("response_type") !== "code" || params.get("client_id") !== clientId
+ if (url.origin !== origin || url.pathname !== "/api/box/oauth2/authorize" || params.get("response_type") !== "code" || params.get("client_id") !== clientId
|| !redirectUris.includes(redirectUri) || params.get("code_challenge_method") !== "S256" || !params.get("code_challenge") || !params.get("state")) {
throw new Error("fake Boat: not an authorize address it accepts");
}
diff --git a/src/components/keys/BoatSignIn.dom.test.ts b/src/components/keys/BoatSignIn.dom.test.ts
index ee7ba9c4eb..04130a9049 100644
--- a/src/components/keys/BoatSignIn.dom.test.ts
+++ b/src/components/keys/BoatSignIn.dom.test.ts
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, expect, it, vi } from "vitest";
import type { BoatSignInStatus } from "../../../shared/boat-sign-in";
import { setLocale } from "@/lib/i18n";
-const api = vi.fn(async (path: string, _init?: { method?: string }): Promise<unknown> => (path.endsWith("/start") ? { url: "https://boat.dev/api/boat/oauth2/authorize?client_id=x&state=y" } : { ok: true }));
+const api = vi.fn(async (path: string, _init?: { method?: string }): Promise<unknown> => (path.endsWith("/start") ? { url: "https://boat.dev/api/box/oauth2/authorize?client_id=x&state=y" } : { ok: true }));
vi.mock("@/state/api", () => ({ api }));
const openExternalLink = vi.fn(async (_url: string) => {});
vi.mock("@/lib/app-links", () => ({ openExternalLink }));
@@ -39,19 +39,19 @@ it("not connected: the button with Boat's mark first, then \"or paste an API key
expect(host.querySelector("[data-boat-disconnect]")).toBeNull();
await click(button);
expect(api).toHaveBeenCalledWith("/api/boat/sign-in/start", { method: "POST" });
- expect(openExternalLink).toHaveBeenCalledWith("https://boat.dev/api/boat/oauth2/authorize?client_id=x&state=y");
+ expect(openExternalLink).toHaveBeenCalledWith("https://boat.dev/api/box/oauth2/authorize?client_id=x&state=y");
});
it("opens nothing but Boat's own sign-in page, whatever the server answers", async () => {
- api.mockResolvedValueOnce({ url: "https://boat.dev.evil.example/api/boat/oauth2/authorize" });
+ api.mockResolvedValueOnce({ url: "https://boat.dev.evil.example/api/box/oauth2/authorize" });
await show(NONE);
await click(host.querySelector("[data-boat-sign-in]"));
expect(openExternalLink).not.toHaveBeenCalled();
expect(host.querySelector("[role=alert]")?.textContent).toBe("Couldn't open the sign-in page in your browser. Try again.");
- for (const bad of ["https://boat.dev/other", "http://boat.dev/api/boat/oauth2/authorize", "https://[email protected]/api/boat/oauth2/authorize", "javascript:alert(1)", "https://boat.dev:444/api/boat/oauth2/authorize", 7, null]) {
+ for (const bad of ["https://boat.dev/other", "http://boat.dev/api/box/oauth2/authorize", "https://[email protected]/api/box/oauth2/authorize", "javascript:alert(1)", "https://boat.dev:444/api/box/oauth2/authorize", 7, null]) {
expect(isBoatSignInUrl(bad), String(bad)).toBe(false);
}
- expect(isBoatSignInUrl("https://boat.dev/api/boat/oauth2/authorize?state=a")).toBe(true);
+ expect(isBoatSignInUrl("https://boat.dev/api/box/oauth2/authorize?state=a")).toBe(true);
});
it("waiting for Boat: says so, and Cancel spends the link", async () => {
diff --git a/src/lib/boat-sign-in.ts b/src/lib/boat-sign-in.ts
index 568a66c1fa..45e42d02e8 100644
--- a/src/lib/boat-sign-in.ts
+++ b/src/lib/boat-sign-in.ts
@@ -25,7 +25,7 @@ export function isBoatSignInUrl(value: unknown): value is string {
try { url = new URL(value); } catch { return false; }
const boat = url.protocol === "https:" && url.hostname === "boat.dev" && url.port === "";
const standIn = url.protocol === "http:" && LOCAL_HOSTS.includes(url.hostname);
- return (boat || standIn) && url.username === "" && url.password === "" && url.pathname === "/api/boat/oauth2/authorize" && url.hash === "";
+ return (boat || standIn) && url.username === "" && url.password === "" && url.pathname === "/api/box/oauth2/authorize" && url.hash === "";
}
export async function startBoatSignIn(): Promise<void> {