{"draft":null,"from":85,"to":86,"files":[{"path":"client/src/join-commands.ts","added":46,"removed":11,"diff":"--- a/client/src/join-commands.ts\n+++ b/client/src/join-commands.ts\n@@ -128,21 +128,54 @@\n const SITE_OWNER = \"christopher\";\n \n /**\n- * Why a join failed signed out. The client reads only as an agent, which needs a\n- * sign-in; a public project is read signed out on the website. Whether the\n- * project is public is asked of the server with no credentials.\n+ * Whether anyone can read the project: its status answers with no credentials. Only the answer's code\n+ * counts, never its body, and no redirect is followed. A private project and a missing one look the same.\n  */\n-async function signedOut(server: string, project: string): Promise<string> {\n-\tlet open = false;\n+export async function isPublic(server: string, project: string): Promise<boolean> {\n \ttry {\n-\t\tconst response = await fetch(new URL(`/p/${project}/status`, server), { signal: AbortSignal.timeout(3000) });\n-\t\topen = response.ok;\n-\t} catch {}\n-\treturn open\n-\t\t? `${project} is public: read it at ${siteOf(server)}/${SITE_OWNER}/${project} (every page is also JSON). The client needs a sign-in, even to read: abso login.`\n+\t\tconst response = await fetch(new URL(`/p/${encodeURIComponent(project)}/status`, server), {\n+\t\t\tredirect: \"error\",\n+\t\t\tcredentials: \"omit\",\n+\t\t\tsignal: AbortSignal.timeout(3000),\n+\t\t});\n+\t\treturn response.status === 200;\n+\t} catch {\n+\t\treturn false;\n+\t}\n+}\n+\n+/**\n+ * Why a join failed signed out. Without --reader, the client reads only as an agent, which needs a\n+ * sign-in; a public project is read signed out on the website, or with abso join --reader.\n+ */\n+async function signedOut(server: string, project: string): Promise<string> {\n+\treturn (await isPublic(server, project))\n+\t\t? `${project} is public: read it at ${siteOf(server)}/${SITE_OWNER}/${project} (every page is also JSON), or here with abso join ${project} --reader. To work on it: abso login.`\n \t\t: `This box isn't signed in to ${server}. abso login signs it in.`;\n }\n \n+/** A folder that reads a public project signed out: no agent, no key, no copy of the files. */\n+async function joinAsVisitor(root: string, server: string, project: string, env: Env): Promise<Output> {\n+\twriteConfig(root, { server, project, agent: \"\", visitor: true });\n+\tconst api = new Api(readConfig(root, env.env));\n+\tlet version: number;\n+\ttry {\n+\t\tversion = (await api.status()).version;\n+\t} catch (error) {\n+\t\trmSync(stateDir(root), { recursive: true, force: true });\n+\t\tthrow error;\n+\t}\n+\treturn {\n+\t\ttext: [\n+\t\t\t`Joined ${project} to read it signed out, at version ${version}, in ${root}. Nothing is sent with a sign-in, and nothing here is recorded.`,\n+\t\t\t`This folder holds no copy of the files: abso files lists them, abso show ${version}:<file> prints one, and status, log, blame, why, where, issues, issue and search read the rest.`,\n+\t\t\t`To work on ${project}: abso login, then abso join ${project} in a new folder.`,\n+\t\t\t...(root === resolve(env.cwd) ? [] : [`cd ${relative(env.cwd, root) || root}`]),\n+\t\t].join(\"\\n\"),\n+\t\tjson: { project, visitor: true, version, root },\n+\t};\n+}\n+\n export async function runJoin(args: Parsed, env: Env): Promise<Output> {\n \tif (args.positionals.length !== 1) throw new UsageError(\"join takes the project name: abso join <project>\");\n \tconst project = args.positionals[0]!;\n@@ -163,7 +196,9 @@\n \t\tagent = agentFrom(args);\n \t\tminted = box && !hasKey ? await mintKey(box, project, agent) : undefined;\n \t} else {\n-\t\t// No --agent: the box's name, or the next free -2, -3.\n+\t\t// No --agent: the box's name, or the next free -2, -3. Not signed in, --reader reads a public project signed out.\n+\t\tif (!box && reader && !hasKey && (await isPublic(server, project)))\n+\t\t\treturn joinAsVisitor(root, server, project, env);\n \t\tif (!box)\n \t\t\tthrow new UsageError(\n \t\t\t\t`${await signedOut(server, project)} (A folder that already has a key joins with --agent <name>.)`,"}],"unmatched":[]}