Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Sign-in screen: the one-time link first, the token under Other setups

Pixel (kwant bot)d87e0a79cfa8
diff --git a/frontend/src/auth.ts b/frontend/src/auth.ts
index 0c4b0b67..bbd0e226 100644
--- a/frontend/src/auth.ts
+++ b/frontend/src/auth.ts
@@ -124,16 +124,37 @@ export async function fetchAuthStatus(): Promise<AuthStatus> {
return res.json();
}
-/** Exchanges the token for the session cookie; resolves to false when the token is wrong. */
-export async function startSession(token: string): Promise<boolean> {
+/** What the server said to a token or one-time link code. */
+export type SessionResult = 'ok' | 'wrong_token' | 'link_used_or_expired';
+
+/** One-time sign-in link codes start with this; the API token never does. */
+export const LINK_CODE_PREFIX = 'kl1.';
+
+/** Whether a pasted or linked value is a one-time sign-in link code rather than the API token. */
+export function isLinkCode(value: string): boolean {
+ return value.trim().startsWith(LINK_CODE_PREFIX);
+}
+
+/** Exchanges the token, or a one-time link code, for a session cookie. */
+export async function redeemSignIn(token: string): Promise<SessionResult> {
const res = await fetch('/api/auth/session', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token }),
});
- if (res.status === 401) return false;
+ if (res.status === 401) {
+ const body = await res.json().catch(() => null);
+ // A link this server forgot (it restarted) reads as a wrong token; for a link it's the same story
+ if (body?.reason === 'link_used_or_expired' || isLinkCode(token)) return 'link_used_or_expired';
+ return 'wrong_token';
+ }
if (!res.ok) throw new Error(`The server answered ${res.status}.`);
- return true;
+ return 'ok';
+}
+
+/** Exchanges the token for the session cookie; resolves to false when the token is wrong. */
+export async function startSession(token: string): Promise<boolean> {
+ return (await redeemSignIn(token)) === 'ok';
}
export async function endSession(): Promise<void> {
@@ -142,19 +163,28 @@ export async function endSession(): Promise<void> {
let linkSession: Promise<string | null> | null = null;
+/** What the sign-in screen says when a one-time link was opened a second time or too late. */
+export const LINK_SPENT =
+ 'This sign-in link was already used or has expired. Each link works once, for 15 minutes. Sign in another way below.';
+
/**
- * Signs in with a `#kwnt_token=` link and removes the token from the address bar (and history)
- * before any network call, so React's second effect run finds no token and shares the first one's
- * result. Resolves to an error message when the token was refused.
+ * Signs in with a `#kwnt_token=` link (a one-time code or the API token) and removes it from the
+ * address bar (and history) before any network call, so React's second effect run finds no token
+ * and shares the first one's result. Resolves to an error message when it was refused.
*/
export function consumeTokenLink(): Promise<string | null> {
const { token, rest } = extractHashToken(window.location.hash);
if (token === null) return linkSession ?? Promise.resolve(null);
window.history.replaceState(window.history.state, '', `${window.location.pathname}${window.location.search}${rest}`);
linkSession = !token
- ? Promise.resolve('The link has an empty token.')
- : startSession(token).then(
- (ok) => (ok ? null : "The link's token wasn't accepted. It may have been changed; paste the current one."),
+ ? Promise.resolve('The link is incomplete. Copy the whole link, or sign in another way below.')
+ : redeemSignIn(token).then(
+ (result) =>
+ result === 'ok'
+ ? null
+ : result === 'link_used_or_expired'
+ ? LINK_SPENT
+ : "The link's token wasn't accepted. It may have been changed; sign in another way below.",
(e: unknown) => (e instanceof Error ? e.message : 'Could not reach the server.'),
);
return linkSession;
diff --git a/frontend/src/components/AuthGate.tsx b/frontend/src/components/AuthGate.tsx
index ef871f87..d879f3d8 100644
--- a/frontend/src/components/AuthGate.tsx
+++ b/frontend/src/components/AuthGate.tsx
@@ -6,12 +6,13 @@ import {
PERSON_SIGNED_IN_EVENT,
PERSON_TOKEN_EVENT,
UNAUTHORIZED_EVENT,
+ LINK_SPENT,
consumeTokenLink,
endSession,
extractHashToken,
fetchAuthStatus,
installUnauthorizedListener,
- startSession,
+ redeemSignIn,
} from '../auth';
interface AuthContextValue {
@@ -70,7 +71,7 @@ export const AuthGate: React.FC<{ children: React.ReactNode }> = ({ children })
consumeTokenLink().then((linkError) => {
if (!cancelled) check(linkError);
});
- const onUnauthorized = () => check('Your session ended. Paste the token again to continue.');
+ const onUnauthorized = () => check('Your session ended. Sign in again to continue.');
// A token link opened in a tab that already shows kwnt only changes the hash.
const onHash = () => {
if (window.location.hash.includes('kwnt_token=')) consumeTokenLink().then((linkError) => check(linkError));
@@ -202,6 +203,8 @@ export function tunnelCommand(loc: Pick<Location, 'protocol' | 'hostname' | 'por
const DOCKER_COMMAND = 'docker compose exec kwnt kwnt token --raw';
const FILE_COMMAND = 'cat ~/.kwnt/api-token';
+const DOCKER_LINK_COMMAND = 'docker compose exec kwnt kwnt signin-link';
+const LINK_COMMAND = 'kwnt signin-link';
/** The token from what was pasted: the token itself, or the whole sign-in link. */
export function tokenFromPaste(value: string): string {
@@ -251,16 +254,28 @@ const Command: React.FC<{ children: string }> = ({ children }) => {
);
};
-/** The less common ways to get the token, one line each. Exported for tests. */
-export const OtherSetups: React.FC<{ loc: Pick<Location, 'protocol' | 'hostname' | 'port'>; docker: boolean }> = ({ loc, docker }) => {
+/**
+ * The fallback: paste a link or the API token (`children`), and the ways to get the token, folded
+ * away. `open` when a pasted value was refused, so its error stays in view. Exported for tests.
+ */
+export const OtherSetups: React.FC<{
+ loc: Pick<Location, 'protocol' | 'hostname' | 'port'>;
+ docker: boolean;
+ open?: boolean;
+ onToggle?: (open: boolean) => void;
+ children?: React.ReactNode;
+}> = ({ loc, docker, open, onToggle, children }) => {
const tunnel = tunnelCommand(loc);
return (
- <details className="group text-xs text-zinc-400">
+ <details className="group text-xs text-zinc-400" open={open} onToggle={(e) => onToggle?.((e.currentTarget as HTMLDetailsElement).open)}>
<summary className="flex items-center gap-1 w-fit min-h-[32px] cursor-pointer select-none list-none [&::-webkit-details-marker]:hidden text-zinc-400 hover:text-zinc-200 rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500">
<ChevronRight size={13} className="transition-transform group-open:rotate-90 motion-reduce:transition-none" aria-hidden="true" />
Other setups
</summary>
<div className="mt-2 space-y-2.5 leading-relaxed">
+ {children}
+ <p className="text-[11px] text-zinc-500 leading-snug">Get the access token on the machine running kwant bots:</p>
+ <Setup label={docker ? 'Docker, in the folder with docker-compose.yml' : 'As the user that runs kwant bots'}>{docker ? DOCKER_COMMAND : FILE_COMMAND}</Setup>
{docker ? (
<Setup label="Without Docker, as the user that runs kwant bots">{FILE_COMMAND}</Setup>
) : (
@@ -269,7 +284,7 @@ export const OtherSetups: React.FC<{ loc: Pick<Location, 'protocol' | 'hostname'
<Setup label="systemd service">sudo cat /var/lib/kwnt/api-token</Setup>
<Setup label="Built from source and not on your PATH">./target/release/kwnt token --raw</Setup>
{tunnel && (
- <Setup label={`No token: open an SSH tunnel on this computer, then go to ${tunnel.url} (not for Docker)`}>{tunnel.command}</Setup>
+ <Setup label={`No sign-in: open an SSH tunnel on this computer, then go to ${tunnel.url} (not for Docker)`}>{tunnel.command}</Setup>
)}
</div>
</details>
@@ -303,13 +318,17 @@ export const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void
const [token, setToken] = useState('');
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
+ const [othersOpen, setOthersOpen] = useState(false);
const loc = typeof window === 'undefined' ? { protocol: 'https:', hostname: '', port: '' } : window.location;
// A locked page on loopback is Docker, so its command comes first there
const docker = isLoopback(loc.hostname);
const inputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
- if (error && !busy) selectForRetry(inputRef.current);
+ if (error && !busy) {
+ setOthersOpen(true);
+ selectForRetry(inputRef.current);
+ }
}, [error, busy]);
const submit = async (e: React.FormEvent) => {
@@ -319,12 +338,13 @@ export const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void
setBusy(true);
setError(null);
try {
- if (await startSession(value)) {
+ const result = await redeemSignIn(value);
+ if (result === 'ok') {
setToken('');
onSignedIn();
return;
}
- setError(WRONG_TOKEN);
+ setError(result === 'link_used_or_expired' ? LINK_SPENT : WRONG_TOKEN);
} catch (err) {
setError(err instanceof Error && err.message !== 'Failed to fetch' ? err.message : 'Could not reach the server.');
} finally {
@@ -336,62 +356,71 @@ export const TokenForm: React.FC<{ notice: string | null; onSignedIn: () => void
<form onSubmit={submit} className="space-y-4">
<div className="space-y-1.5">
<h2 id={personOnly ? 'kwnt-person-token-title' : undefined} className="flex items-center gap-2 text-sm font-medium">
- <KeyRound size={15} className="text-sky-400" /> {personOnly ? 'Confirm it’s you' : 'Enter your access token'}
+ <KeyRound size={15} className="text-sky-400" /> {personOnly ? 'Confirm it’s you' : 'Sign in'}
</h2>
{personOnly && (
<p className="text-xs text-zinc-400 leading-relaxed">
- Saved passwords, answers to approval cards and deleting bots or teams need your access token from another computer, so a bot can’t do them for you. You need it once per browser.
+ Saved passwords, answers to approval cards and deleting bots or teams need you signed in from another computer, so a bot can’t do them for you. You need it once per browser.
</p>
)}
- <p className="text-xs text-zinc-400 leading-relaxed">Find it on the machine running kwant bots:</p>
</div>
- <Command>{docker ? DOCKER_COMMAND : FILE_COMMAND}</Command>
- {notice && <p className="text-xs text-amber-300" role="status">{notice}</p>}
- <div>
- <label htmlFor="kwnt-token" className="sr-only">
- Token
- </label>
- <input
- id="kwnt-token"
- ref={inputRef}
- type="password"
- autoComplete="off"
- spellCheck={false}
- autoFocus
- value={token}
- onChange={(e) => setToken(e.target.value)}
- aria-invalid={!!error}
- aria-describedby={error ? 'kwnt-token-error' : undefined}
- className="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs font-mono text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors"
- placeholder="Paste the token or the sign-in link"
- />
- {error && (
- <p id="kwnt-token-error" className="mt-1.5 text-[11px] text-rose-400 leading-snug" role="alert">
- {error}
- {error === WRONG_TOKEN && ` ${OWN_TOKEN_HINT}`}
- </p>
- )}
+ {notice && (
+ <p className={`text-xs leading-relaxed ${notice === LINK_SPENT ? 'text-rose-300' : 'text-amber-300'}`} role="status">
+ {notice}
+ </p>
+ )}
+ <div className="space-y-1.5">
+ <p className="text-xs text-zinc-400 leading-relaxed">
+ Open the one-time sign-in link kwant bots printed when it started, or scan its QR code with your phone. Used or lost it? Make a new one on the
+ machine running kwant bots:
+ </p>
+ <Command>{docker ? DOCKER_LINK_COMMAND : LINK_COMMAND}</Command>
</div>
- <div className="flex gap-2">
- {onCancel && (
- <button
- type="button"
- onClick={onCancel}
- className="flex-1 px-4 py-2 rounded-lg text-xs font-medium text-zinc-200 bg-zinc-800 hover:bg-zinc-700 border border-zinc-700 transition-colors"
- >
- Not now
- </button>
- )}
+ <OtherSetups loc={loc} docker={docker} open={othersOpen} onToggle={setOthersOpen}>
+ <div className="space-y-1.5">
+ <label htmlFor="kwnt-token" className="block text-[11px] text-zinc-500 leading-snug">
+ Paste a sign-in link or the access token
+ </label>
+ <div className="flex gap-2">
+ <input
+ id="kwnt-token"
+ ref={inputRef}
+ type="password"
+ autoComplete="off"
+ spellCheck={false}
+ value={token}
+ onChange={(e) => setToken(e.target.value)}
+ aria-invalid={!!error}
+ aria-describedby={error ? 'kwnt-token-error' : undefined}
+ className="flex-1 min-w-0 bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-xs font-mono text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none transition-colors"
+ placeholder="Link or token"
+ />
+ <button
+ type="submit"
+ disabled={busy || !token.trim()}
+ className="shrink-0 flex items-center justify-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium text-white bg-sky-600 hover:bg-sky-500 transition-colors disabled:opacity-50"
+ >
+ {busy && <Loader2 size={13} className="animate-spin motion-reduce:animate-none" />} Continue
+ </button>
+ </div>
+ {error && (
+ <p id="kwnt-token-error" className="text-[11px] text-rose-400 leading-snug" role="alert">
+ {error}
+ {error === WRONG_TOKEN && ` ${OWN_TOKEN_HINT}`}
+ </p>
+ )}
+ </div>
+ </OtherSetups>
+ <p className="text-[11px] text-zinc-500">Stays signed in for a year. Anyone with a sign-in link or the token controls this server.</p>
+ {onCancel && (
<button
- type="submit"
- disabled={busy || !token.trim()}
- className="flex-1 w-full flex items-center justify-center gap-1.5 px-4 py-2 rounded-lg text-xs font-medium text-white bg-sky-600 hover:bg-sky-500 transition-colors disabled:opacity-50"
+ type="button"
+ onClick={onCancel}
+ className="w-full px-4 py-2 rounded-lg text-xs font-medium text-zinc-200 bg-zinc-800 hover:bg-zinc-700 border border-zinc-700 transition-colors"
>
- {busy && <Loader2 size={13} className="animate-spin motion-reduce:animate-none" />} Continue
+ Not now
</button>
- </div>
- <OtherSetups loc={loc} docker={docker} />
- <p className="text-[11px] text-zinc-500">Stays signed in for a year. Anyone with the token controls this server.</p>
+ )}
</form>
);
};
diff --git a/frontend/tests/savedPasswords.test.mjs b/frontend/tests/savedPasswords.test.mjs
index 37809d9e..5015dccf 100644
--- a/frontend/tests/savedPasswords.test.mjs
+++ b/frontend/tests/savedPasswords.test.mjs
@@ -219,9 +219,9 @@ test('the token dialog says why it is asked from another computer and can be dis
assert.match(html, /aria-modal="true"/);
const t = text(html);
assert.match(t, /Confirm it's you/);
- assert.match(t, /deleting bots or teams need your access token from another computer, so a bot can't do them for you/);
+ assert.match(t, /deleting bots or teams need you signed in from another computer, so a bot can't do them for you/);
assert.ok(!t.includes('even on this computer'), 'this computer never asks');
- assert.match(t, /Find it on the machine running kwant bots:/);
+ assert.match(t, /Open the one-time sign-in link/);
assert.match(t, /Other setups/);
assert.match(t, /kwnt token --raw/);
assert.ok(buttons(html).includes('Not now'));
diff --git a/frontend/tests/signinLink.test.mjs b/frontend/tests/signinLink.test.mjs
new file mode 100644
index 00000000..c0d31b70
--- /dev/null
+++ b/frontend/tests/signinLink.test.mjs
@@ -0,0 +1,82 @@
+// One-time sign-in links (#kwnt_token=kl1.…): opening one signs in with no paste, and a used or
+// expired one says so and points to the other ways in.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { loadBundled } from './bundle.mjs';
+
+const m = await loadBundled(`
+ export { LINK_SPENT, consumeTokenLink, isLinkCode, redeemSignIn } from './src/auth';
+`);
+
+/** A server that answers POST /api/auth/session with `status` and `body`, recording what it got. */
+function server(status, body = null) {
+ const calls = [];
+ globalThis.fetch = async (url, init) => {
+ calls.push({ url, init, body: JSON.parse(init.body) });
+ return new Response(status === 204 ? null : JSON.stringify(body), { status });
+ };
+ return calls;
+}
+
+/** A page opened at `hash`, with replaceState recorded. */
+function page(hash) {
+ const replaced = [];
+ globalThis.window = {
+ location: { hash, pathname: '/', search: '' },
+ history: { state: null, replaceState: (_s, _t, url) => replaced.push(url) },
+ };
+ return replaced;
+}
+
+test('link codes are told apart from the API token', () => {
+ assert.ok(m.isLinkCode('kl1.abcdef'));
+ assert.ok(m.isLinkCode(' kl1.abcdef '));
+ assert.ok(!m.isLinkCode('abcdefghijklmnopqrstuvwxyz012345'));
+});
+
+test('a live link signs in: the code is posted, then cleared from the address bar', async () => {
+ const calls = server(204);
+ const replaced = page('#kwnt_token=kl1.live');
+ const err = await m.consumeTokenLink();
+ assert.equal(err, null);
+ assert.equal(calls.length, 1);
+ assert.equal(calls[0].url, '/api/auth/session');
+ assert.equal(calls[0].init.method, 'POST');
+ assert.deepEqual(calls[0].body, { token: 'kl1.live' });
+ assert.deepEqual(replaced, ['/'], 'the code leaves the address bar and history');
+});
+
+test('a used or expired link says so, not "wrong token"', async () => {
+ server(401, { error: 'this sign-in link was already used or has expired', reason: 'link_used_or_expired' });
+ page('#kwnt_token=kl1.spent');
+ assert.equal(await m.consumeTokenLink(), m.LINK_SPENT);
+ assert.match(m.LINK_SPENT, /already used or has expired.*works once, for 15 minutes.*Sign in another way below/);
+});
+
+test('a link the server forgot (it restarted) reads as expired too', async () => {
+ server(401, { error: 'wrong token', reason: 'wrong_token' });
+ assert.equal(await m.redeemSignIn('kl1.forgotten'), 'link_used_or_expired');
+ page('#kwnt_token=kl1.forgotten');
+ assert.equal(await m.consumeTokenLink(), m.LINK_SPENT);
+});
+
+test('a wrong API token stays a wrong token', async () => {
+ server(401, { error: 'wrong token', reason: 'wrong_token' });
+ assert.equal(await m.redeemSignIn('not-the-token'), 'wrong_token');
+ page('#kwnt_token=not-the-token');
+ assert.match(await m.consumeTokenLink(), /token wasn't accepted/);
+});
+
+test('an old server without a reason still works', async () => {
+ server(401, { error: 'wrong token' });
+ assert.equal(await m.redeemSignIn('not-the-token'), 'wrong_token');
+ server(204);
+ assert.equal(await m.redeemSignIn('the-token'), 'ok');
+});
+
+test('an empty link and a server error are explained', async () => {
+ page('#kwnt_token=');
+ assert.match(await m.consumeTokenLink(), /incomplete/);
+ server(500, {});
+ await assert.rejects(m.redeemSignIn('kl1.x'), /500/);
+});
diff --git a/frontend/tests/tokenSteps.test.mjs b/frontend/tests/tokenSteps.test.mjs
index dcaea88c..b2c68c0a 100644
--- a/frontend/tests/tokenSteps.test.mjs
+++ b/frontend/tests/tokenSteps.test.mjs
@@ -1,4 +1,5 @@
-// The token screen: one command up front, other setups folded away, steps that work without kwnt on the PATH.
+// The sign-in screen: the one-time link up front, the token folded away under "Other setups", steps that work
+// without kwnt on the PATH.
import assert from 'node:assert/strict';
import test from 'node:test';
import { loadBundled } from './bundle.mjs';
@@ -7,27 +8,40 @@ const m = await loadBundled(`
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server.browser';
import { OWN_TOKEN_HINT, OtherSetups, TokenForm, WRONG_TOKEN, isLoopback, selectForRetry, tokenFromPaste, tunnelCommand } from './src/components/AuthGate';
- export { OWN_TOKEN_HINT, WRONG_TOKEN, isLoopback, selectForRetry, tokenFromPaste, tunnelCommand };
- export const form = () => renderToStaticMarkup(React.createElement(TokenForm, { notice: null, onSignedIn: () => {} }));
+ import { LINK_SPENT } from './src/auth';
+ export { LINK_SPENT, OWN_TOKEN_HINT, WRONG_TOKEN, isLoopback, selectForRetry, tokenFromPaste, tunnelCommand };
+ export const form = (notice = null) => renderToStaticMarkup(React.createElement(TokenForm, { notice, onSignedIn: () => {} }));
export const other = (loc, docker = false) => renderToStaticMarkup(React.createElement(OtherSetups, { loc, docker }));
`);
const text = (html) => html.replace(/<[^>]+>/g, ' ').replace(/&#x27;|&#39;/g, "'").replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/\s+/g, ' ');
const http = (hostname, port = '8799') => ({ protocol: 'http:', hostname, port });
-test('the default view: one command, the token box and a folded "Other setups", no picker', () => {
+test('the default view: the one-time link and how to make one, the token box folded into "Other setups"', () => {
const html = m.form();
const t = text(html);
- assert.match(t, /Find it on the machine running kwant bots:/);
- assert.match(t, /cat ~\/\.kwnt\/api-token/);
- assert.match(html, /placeholder="Paste the token or the sign-in link"/);
+ assert.match(t, /^ ?Sign in /);
+ assert.match(t, /Open the one-time sign-in link kwant bots printed when it started, or scan its QR code with your phone/);
+ assert.match(t, /Used or lost it\? Make a new one on the machine running kwant bots: kwnt signin-link/);
assert.match(html, /<details class="[^"]*">/, 'closed by default');
- assert.match(t, /Other setups/);
- assert.match(t, /Stays signed in for a year\. Anyone with the token controls this server\./);
+ // The token stays as the fallback, inside the fold, after the link
+ const fold = html.slice(html.indexOf('<details'));
+ assert.match(fold, /Paste a sign-in link or the access token/);
+ assert.match(fold, /id="kwnt-token"/);
+ assert.match(text(fold), /cat ~\/\.kwnt\/api-token/);
+ assert.ok(t.indexOf('kwnt signin-link') < t.indexOf('Other setups'));
+ assert.match(t, /Stays signed in for a year\. Anyone with a sign-in link or the token controls this server\./);
assert.ok(!/Where does kwant bots run|On a server|type="radio"/.test(html));
assert.ok(!t.includes(m.OWN_TOKEN_HINT.slice(0, 30)), 'the own-token hint only shows with a wrong token');
});
+test('a used or expired link: the notice says so and the other ways to sign in are still there', () => {
+ const t = text(m.form(m.LINK_SPENT));
+ assert.match(t, /This sign-in link was already used or has expired\. Each link works once, for 15 minutes\. Sign in another way below\./);
+ assert.match(t, /kwnt signin-link/);
+ assert.match(t, /Other setups/);
+});
+
test('other setups: Docker, systemd and a source build, so it works without kwnt on the PATH', () => {
const t = text(m.other(http('vps.example.com')));
assert.match(t, /docker compose exec kwnt kwnt token --raw/);
@@ -35,10 +49,11 @@ test('other setups: Docker, systemd and a source build, so it works without kwnt
assert.match(t, /\.\/target\/release\/kwnt token --raw/);
});
-test('on loopback (Docker) the Docker command leads and the file command moves into other setups', () => {
+test('on loopback (Docker) the Docker commands lead: the link up front, the token first in other setups', () => {
const t = text(m.other(http('127.0.0.1'), true));
- assert.match(t, /cat ~\/\.kwnt\/api-token/);
- assert.ok(!t.includes('docker compose'));
+ assert.ok(t.indexOf('docker compose exec kwnt kwnt token --raw') < t.indexOf('cat ~/.kwnt/api-token'));
+ const t2 = text(m.other(http('vps.example.com')));
+ assert.ok(t2.indexOf('cat ~/.kwnt/api-token') < t2.indexOf('docker compose'));
});
test('SSH tunnel: on plain http at a network address with a port, using that port', () => {
diff --git a/frontend/tests/wording.test.mjs b/frontend/tests/wording.test.mjs
index 46fb4ca5..20c702aa 100644
--- a/frontend/tests/wording.test.mjs
+++ b/frontend/tests/wording.test.mjs
@@ -19,7 +19,7 @@ const files = (dir) =>
const BAD = /\b(kwants?|kwnt|agents?)\b/i;
// The product term (headings, tagline), the CLI commands and token file shown on the sign-in screen, and
// Agent Maestro, the VS Code extension's own name (a Custom API preset).
-const ALLOWED = /\bkwant bots?\b|\b(?:exec kwnt )?kwnt token\b|~\/\.kwnt\/api-token/gi;
+const ALLOWED = /\bkwant bots?\b|\b(?:exec kwnt )?kwnt (?:token|signin-link)\b|~\/\.kwnt\/api-token/gi;
const MAESTRO = /\bAgent Maestro\b/g;
/** Whether a literal reads like text a person sees (a sentence, or a capitalised word). */