@digital-agora/zola-web 0.0.0-stage → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 digital-agora
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,68 @@
1
- # Temporary Holding Version
1
+ # @digital-agora/zola-web
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Zola in the browser, GitHub only. Connect GitHub, pick repositories, and start a Zola work session that opens in
4
+ code-server, at `https://code.neoncapybara.link/?workspace=…`. It also reopens your sessions and adds repositories
5
+ to them. It is a small Node server with no dependencies and no build step. `zola-remote install --web` sets it up.
6
+
7
+ ## What it does
8
+
9
+ - **GitHub**: *Connect GitHub* starts GitHub's device flow (scopes `repo read:org`). You enter the code at
10
+ github.com/login/device. The token goes straight to `gh auth login --with-token` on stdin, and gh is the only place
11
+ it is stored: it is never shown, logged or put on a command line. The page shows Connected or Signed out, and
12
+ *Log out* runs `gh auth logout`.
13
+ - **Repositories**: `zola session repos --provider github --json`, grouped by owner (you and your organizations).
14
+ - **Start**: `zola start <name> github:<owner>/<repo>… --root <sessionsRoot> --agent --json`, then the session's
15
+ workspace opens in code-server in a new tab.
16
+ - **Sessions**: `zola session list --json`. *Open* reopens one; *Add repos* runs `zola session add <id> … --json`.
17
+
18
+ Every zola and gh call is a program started with fixed arguments, never through a shell. Before anything runs, the
19
+ session name, owners and repository names are checked against what zola and GitHub allow.
20
+
21
+ ## Security
22
+
23
+ - Listens on **127.0.0.1 only** (default port 8081); the Cloudflare Tunnel reaches it.
24
+ - Every request, the page included, needs Cloudflare Access's signed JWT (`Cf-Access-Jwt-Assertion`). It must be
25
+ signed by your team's keys, be for this application (`aud`) and your team (`iss`), and be unexpired, and its
26
+ `email` must be the one configured: **one user**. Otherwise the answer is 403.
27
+ - Every action (POST) needs the page's CSRF token and `Origin: https://zola.neoncapybara.link`, with a JSON body up
28
+ to 16 KB.
29
+ - Strict CSP (`default-src 'none'`, scripts from itself only), no framing, `no-store`.
30
+ - Its log holds status lines only: no tokens, no command output.
31
+
32
+ ## Configuration
33
+
34
+ `~/.config/zola-web/config.json` (mode 0600; `ZOLA_WEB_CONFIG` or `--config` moves it). It holds no secrets.
35
+ `zola-remote install --web` writes it.
36
+
37
+ ```json
38
+ {
39
+ "accessTeam": "<your Zero Trust team name>",
40
+ "accessAud": "<the zola app's Application Audience (AUD) tag>",
41
+ "email": "you@example.com",
42
+ "githubClientId": "<OAuth App client ID>",
43
+ "codeUrl": "https://code.neoncapybara.link",
44
+ "webUrl": "https://zola.neoncapybara.link",
45
+ "port": 8081,
46
+ "sessionsRoot": "/home/you/work"
47
+ }
48
+ ```
49
+
50
+ `zola-web --check` validates it, and `zola-web --version` prints the version, which is always Zola's own.
51
+
52
+ ## The GitHub OAuth App (once)
53
+
54
+ GitHub › Digital-Agora › Settings › Developer settings › OAuth Apps › *New OAuth App*:
55
+
56
+ - Name: *Zola web*.
57
+ - Homepage URL: `https://zola.neoncapybara.link`.
58
+ - Authorization callback URL: the same, since the device flow doesn't use it.
59
+ - Tick **Enable Device Flow**, then *Register*. Copy the **Client ID**; no client secret is needed.
60
+
61
+ If the organization restricts third-party OAuth apps, approve *Zola web* under the org's *Third-party access*
62
+ settings.
63
+
64
+ ## Development
65
+
66
+ ```bash
67
+ npm --prefix apps/zola-web test # Access JWT, CSRF, device flow, gh handoff, zola calls, server
68
+ ```
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // zola-web: Zola in the browser, behind Cloudflare Access. See README.md.
4
+ // zola-web [--config <file>] serve on 127.0.0.1:<port>
5
+ // zola-web --check [--config …] check the config and exit (zola-remote doctor uses it)
6
+ // zola-web --version
7
+
8
+ const path = require('node:path');
9
+ const pkg = require('../package.json');
10
+ const { loadConfig, configPath } = require('../src/config');
11
+ const { createAccessVerifier } = require('../src/access');
12
+ const { createGithub } = require('../src/github');
13
+ const { createZola } = require('../src/zola');
14
+ const { createApp, listen } = require('../src/server');
15
+
16
+ const args = process.argv.slice(2);
17
+ if (args.includes('--version')) {
18
+ console.log(pkg.version);
19
+ process.exit(0);
20
+ }
21
+ const ci = args.indexOf('--config');
22
+ const file = ci >= 0 ? path.resolve(args[ci + 1] || '') : configPath();
23
+ const log = (msg) => console.error(`${new Date().toISOString()} ${msg}`);
24
+
25
+ let cfg;
26
+ let access;
27
+ try {
28
+ cfg = loadConfig(file);
29
+ access = createAccessVerifier({ team: cfg.accessTeam, aud: cfg.accessAud, email: cfg.email });
30
+ } catch (e) {
31
+ console.error(`zola-web: ${e.message}`);
32
+ process.exit(2);
33
+ }
34
+ if (args.includes('--check')) {
35
+ console.log(`ok: ${cfg.webUrl} on 127.0.0.1:${cfg.port}, Access team ${cfg.accessTeam}, ${cfg.githubClientId ? 'GitHub client set' : 'no GitHub client ID'}`);
36
+ process.exit(0);
37
+ }
38
+
39
+ const github = createGithub({ clientId: cfg.githubClientId, log });
40
+ const zola = createZola({ entry: cfg.zolaEntry || undefined, sessionsRoot: cfg.sessionsRoot });
41
+ const app = createApp({ access, github, zola, codeUrl: cfg.codeUrl, origin: cfg.webUrl, log });
42
+ listen(app, { port: cfg.port }).then(
43
+ () => log(`zola-web ${pkg.version} on http://127.0.0.1:${cfg.port} for ${cfg.webUrl}`),
44
+ (e) => {
45
+ console.error(`zola-web: ${e.message}`);
46
+ process.exit(1);
47
+ },
48
+ );
package/package.json CHANGED
@@ -1,6 +1,30 @@
1
1
  {
2
2
  "name": "@digital-agora/zola-web",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.12.0",
4
+ "description": "Zola in the browser, GitHub only: connect GitHub with the device flow, then start, reopen and grow Zola work sessions that open in code-server. Runs on 127.0.0.1 behind Cloudflare Access.",
5
+ "type": "commonjs",
6
+ "bin": {
7
+ "zola-web": "bin/zola-web.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "src",
12
+ "public",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "engines": {
17
+ "node": ">=22"
18
+ },
19
+ "scripts": {
20
+ "test": "node --test test/access.test.js test/github.test.js test/zola.test.js test/server.test.js",
21
+ "start": "node bin/zola-web.js"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/Digital-Agora/zola.git",
26
+ "directory": "apps/zola-web"
27
+ },
28
+ "license": "MIT",
29
+ "publishConfig": {}
30
+ }
package/public/app.css ADDED
@@ -0,0 +1,26 @@
1
+ :root { color-scheme: light dark; --fg: #1c1c1e; --bg: #f6f6f7; --card: #fff; --muted: #6b6b70; --accent: #2f6fdb; --line: #dcdce0; }
2
+ @media (prefers-color-scheme: dark) { :root { --fg: #ececef; --bg: #141416; --card: #1d1d20; --muted: #9a9aa2; --accent: #6d9cf0; --line: #2d2d32; } }
3
+ * { box-sizing: border-box; }
4
+ body { margin: 0; font: 15px/1.45 system-ui, sans-serif; color: var(--fg); background: var(--bg); }
5
+ header, main { max-width: 860px; margin: 0 auto; padding: 16px; }
6
+ h1 { margin: 8px 0 12px; font-size: 22px; }
7
+ h2 { margin: 0 0 10px; font-size: 17px; }
8
+ .card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
9
+ .muted { color: var(--muted); }
10
+ .list { list-style: none; padding: 0; margin: 0; }
11
+ .list li { padding: 8px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
12
+ .list li:first-child { border-top: 0; }
13
+ .repos { max-height: 340px; overflow: auto; }
14
+ .grow { flex: 1; }
15
+ .row { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
16
+ label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
17
+ input, select, button { font: inherit; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
18
+ button, a.button { cursor: pointer; background: var(--accent); color: #fff; border: 0; text-decoration: none; padding: 6px 12px; border-radius: 6px; }
19
+ button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
20
+ button:disabled { opacity: .5; cursor: default; }
21
+ code.big { font-size: 22px; letter-spacing: 2px; }
22
+ .repo-name { font-weight: 600; }
23
+ .spacer { flex: 1; }
24
+ #message { min-height: 1.5em; }
25
+ .error { color: #d23c3c; }
26
+ .repo-row { flex-direction: row; align-items: center; gap: 10px; font-size: 15px; color: var(--fg); cursor: pointer; }
package/public/app.js ADDED
@@ -0,0 +1,167 @@
1
+ 'use strict';
2
+ // zola-web's page: GitHub status, sessions, and a new-session form. Talks only to its own /api.
3
+ const csrf = document.querySelector('meta[name="csrf-token"]').content;
4
+ const $ = (id) => document.getElementById(id);
5
+ let repos = [];
6
+ let pollTimer = null;
7
+
8
+ async function api(method, path, body) {
9
+ const r = await fetch(path, {
10
+ method,
11
+ headers: method === 'POST' ? { 'content-type': 'application/json', 'x-csrf-token': csrf } : {},
12
+ body: method === 'POST' ? JSON.stringify(body || {}) : undefined,
13
+ credentials: 'same-origin',
14
+ });
15
+ const data = await r.json().catch(() => ({}));
16
+ if (!r.ok) throw new Error(data.error || `HTTP ${r.status}`);
17
+ return data;
18
+ }
19
+
20
+ function el(tag, props = {}, ...children) {
21
+ const e = document.createElement(tag);
22
+ for (const [k, v] of Object.entries(props)) {
23
+ if (k === 'onclick') e.addEventListener('click', v);
24
+ else if (k === 'text') e.textContent = v;
25
+ else e.setAttribute(k, v);
26
+ }
27
+ for (const c of children) e.append(c);
28
+ return e;
29
+ }
30
+
31
+ function say(text, isError) {
32
+ const m = $('message');
33
+ m.textContent = text || '';
34
+ m.className = isError ? 'error' : '';
35
+ }
36
+
37
+ async function run(what, fn) {
38
+ try {
39
+ say(`${what}…`);
40
+ await fn();
41
+ say('');
42
+ } catch (e) {
43
+ say(e.message, true);
44
+ }
45
+ }
46
+
47
+ function renderGithub(gh) {
48
+ const box = $('github');
49
+ box.replaceChildren();
50
+ if (gh.connected) {
51
+ box.append(el('p', {}, 'GitHub: connected as ', el('strong', { text: gh.login }), ' ',
52
+ el('button', { class: 'secondary', onclick: () => run('Signing out', async () => { await api('POST', '/api/github/logout'); await refresh(); }) }, 'Log out')));
53
+ return;
54
+ }
55
+ if (gh.device) {
56
+ box.append(
57
+ el('p', {}, 'Open ', el('a', { href: gh.device.verificationUri, target: '_blank', rel: 'noopener noreferrer', text: gh.device.verificationUri }), ' and enter this code:'),
58
+ el('p', {}, el('code', { class: 'big', text: gh.device.userCode })),
59
+ el('p', { class: 'muted', text: 'This page updates by itself once GitHub confirms.' }),
60
+ );
61
+ if (!pollTimer) pollTimer = setInterval(refresh, 5000);
62
+ return;
63
+ }
64
+ if (pollTimer) { clearInterval(pollTimer); pollTimer = null; }
65
+ box.append(el('p', {}, 'GitHub: signed out ',
66
+ gh.clientConfigured
67
+ ? el('button', { onclick: () => run('Asking GitHub for a code', async () => { await api('POST', '/api/github/connect'); await refresh(); }) }, 'Connect GitHub')
68
+ : el('span', { class: 'error', text: '(no GitHub OAuth App client ID configured)' })));
69
+ if (gh.error) box.append(el('p', { class: 'error', text: gh.error }));
70
+ }
71
+
72
+ function renderSessions(list) {
73
+ const ul = $('sessions');
74
+ ul.replaceChildren();
75
+ if (!list.length) { ul.append(el('li', { class: 'muted', text: 'No sessions yet.' })); return; }
76
+ for (const s of list) {
77
+ const li = el('li', {},
78
+ el('span', { class: 'repo-name', text: s.label }),
79
+ el('span', { class: 'muted', text: s.repos.map((r) => r.repo).join(', ') }),
80
+ el('span', { class: 'spacer' }));
81
+ if (s.url) li.append(el('a', { class: 'button', href: s.url, target: '_blank', rel: 'noopener noreferrer', text: 'Open' }));
82
+ li.append(el('button', { class: 'secondary', onclick: () => addTo(s) }, 'Add repos'));
83
+ ul.append(li);
84
+ }
85
+ }
86
+
87
+ function picked() {
88
+ return [...document.querySelectorAll('#repos input:checked')].map((i) => i.value);
89
+ }
90
+
91
+ function renderRepos() {
92
+ const owner = $('owner').value;
93
+ const q = $('filter').value.trim().toLowerCase();
94
+ const before = new Set(picked());
95
+ const ul = $('repos');
96
+ ul.replaceChildren();
97
+ const shown = repos.filter((r) => (!owner || r.owner === owner) && (!q || r.full.toLowerCase().includes(q))).slice(0, 300);
98
+ if (!shown.length) ul.append(el('li', { class: 'muted', text: repos.length ? 'No match.' : 'No repositories (connect GitHub first).' }));
99
+ for (const r of shown) {
100
+ const box = el('input', { type: 'checkbox', value: r.full });
101
+ if (before.has(r.full)) box.checked = true;
102
+ box.addEventListener('change', updatePicked);
103
+ ul.append(el('li', {}, el('label', { class: 'repo-row' }, box, el('span', { class: 'repo-name', text: r.full }), el('span', { class: 'muted', text: r.description || '' }))));
104
+ }
105
+ updatePicked();
106
+ }
107
+
108
+ function updatePicked() {
109
+ const n = picked().length;
110
+ $('picked').textContent = n ? `${n} selected` : '';
111
+ }
112
+
113
+ async function loadRepos() {
114
+ repos = (await api('GET', '/api/repos')).repos;
115
+ const owners = [...new Set(repos.map((r) => r.owner))].sort();
116
+ $('owner').replaceChildren(el('option', { value: '', text: 'All' }), ...owners.map((o) => el('option', { value: o, text: o })));
117
+ renderRepos();
118
+ }
119
+
120
+ async function addTo(s) {
121
+ const have = new Set(s.repos.map((r) => r.repo));
122
+ const list = picked().filter((r) => !have.has(r));
123
+ if (!list.length) { say(`Tick repositories ${s.label} does not have yet in "New session", then press "Add repos" on it.`, true); return; }
124
+ await run(`Adding ${list.length} to ${s.label}`, async () => {
125
+ await api('POST', '/api/sessions/repos', { id: s.id, repos: list });
126
+ await loadSessions();
127
+ });
128
+ }
129
+
130
+ async function loadSessions() {
131
+ renderSessions((await api('GET', '/api/sessions')).sessions);
132
+ }
133
+
134
+ async function refresh() {
135
+ const st = await api('GET', '/api/state');
136
+ renderGithub(st.github);
137
+ if (st.github.connected && !repos.length) await loadRepos().catch((e) => say(e.message, true));
138
+ }
139
+
140
+ $('owner').addEventListener('change', renderRepos);
141
+ $('filter').addEventListener('input', renderRepos);
142
+ $('start').addEventListener('submit', (ev) => {
143
+ ev.preventDefault();
144
+ const name = $('name').value.trim();
145
+ const list = picked();
146
+ if (!list.length) { say('Pick at least one repository.', true); return; }
147
+ const tab = window.open('about:blank', '_blank'); // opened now, while it is still a click, so no pop-up blocker
148
+ run(`Starting ${name} (cloning ${list.length})`, async () => {
149
+ $('startBtn').disabled = true;
150
+ try {
151
+ const { session } = await api('POST', '/api/sessions', { name, repos: list });
152
+ if (tab && session.url) tab.location.href = session.url;
153
+ else if (session.url) say(`Started: open ${session.url}`);
154
+ await loadSessions();
155
+ } catch (e) {
156
+ if (tab) tab.close();
157
+ throw e;
158
+ } finally {
159
+ $('startBtn').disabled = false;
160
+ }
161
+ });
162
+ });
163
+
164
+ run('Loading', async () => {
165
+ await refresh();
166
+ await loadSessions();
167
+ });
@@ -0,0 +1,36 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="csrf-token" content="__CSRF__">
7
+ <title>Zola</title>
8
+ <link rel="stylesheet" href="/app.css">
9
+ <script src="/app.js" defer></script>
10
+ </head>
11
+ <body>
12
+ <header>
13
+ <h1>Zola</h1>
14
+ <div id="github" class="card"><p class="muted">Checking GitHub…</p></div>
15
+ </header>
16
+ <main>
17
+ <section class="card">
18
+ <h2>Sessions</h2>
19
+ <ul id="sessions" class="list"><li class="muted">Loading…</li></ul>
20
+ </section>
21
+ <section class="card">
22
+ <h2>New session</h2>
23
+ <form id="start" autocomplete="off">
24
+ <label>Name <input id="name" name="name" required maxlength="48" pattern="[a-z0-9][a-z0-9._\-]{0,47}" placeholder="checkout-redesign"></label>
25
+ <div class="row">
26
+ <label>Owner <select id="owner"><option value="">All</option></select></label>
27
+ <label class="grow">Filter <input id="filter" type="search" placeholder="repository name"></label>
28
+ </div>
29
+ <ul id="repos" class="list repos"><li class="muted">Connect GitHub to list your repositories.</li></ul>
30
+ <p><button id="startBtn" type="submit">Start session</button> <span id="picked" class="muted"></span></p>
31
+ </form>
32
+ </section>
33
+ <p id="message" role="status" aria-live="polite"></p>
34
+ </main>
35
+ </body>
36
+ </html>
package/src/access.js ADDED
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+ // Cloudflare Access in front of zola-web: every request must carry the signed JWT Access adds
3
+ // (Cf-Access-Jwt-Assertion), for this Access application (aud), from your team (iss), still valid, and for the one
4
+ // configured email. The signing keys come from https://<team>.cloudflareaccess.com/cdn-cgi/access/certs.
5
+ // The token itself is never logged.
6
+
7
+ const crypto = require('node:crypto');
8
+
9
+ const TEAM_RE = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;
10
+
11
+ function b64urlJson(part) {
12
+ return JSON.parse(Buffer.from(part, 'base64url').toString('utf8'));
13
+ }
14
+
15
+ /** Fetch JSON over HTTPS (Node's fetch). */
16
+ async function defaultFetchJson(url) {
17
+ const r = await fetch(url, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(10_000) });
18
+ if (!r.ok) throw new Error(`HTTP ${r.status} from ${url}`);
19
+ return r.json();
20
+ }
21
+
22
+ /**
23
+ * verify(token) → { email } or throws an Error whose message says why (for the log, never the token).
24
+ * Keys are cached by kid; an unknown kid refreshes them, at most once a minute.
25
+ */
26
+ function createAccessVerifier({ team, aud, email, fetchJson = defaultFetchJson, now = () => Math.floor(Date.now() / 1000), leeway = 60 }) {
27
+ if (!TEAM_RE.test(team || '')) throw new Error('accessTeam must be your Cloudflare Zero Trust team name (the part before .cloudflareaccess.com)');
28
+ if (!aud || !/^[A-Za-z0-9]{16,128}$/.test(aud)) throw new Error('accessAud must be the Access application AUD tag');
29
+ if (!email || !/^[^@\s]+@[^@\s]+$/.test(email)) throw new Error('email must be the one address allowed in');
30
+ const issuer = `https://${team}.cloudflareaccess.com`;
31
+ const certsUrl = `${issuer}/cdn-cgi/access/certs`;
32
+ const want = email.toLowerCase();
33
+ let keys = new Map();
34
+ let fetchedAt = 0;
35
+
36
+ async function refresh() {
37
+ const body = await fetchJson(certsUrl);
38
+ const next = new Map();
39
+ for (const jwk of body.keys || []) {
40
+ if (jwk.kty !== 'RSA' || !jwk.kid) continue;
41
+ next.set(jwk.kid, crypto.createPublicKey({ key: jwk, format: 'jwk' }));
42
+ }
43
+ keys = next;
44
+ fetchedAt = now();
45
+ }
46
+
47
+ async function keyFor(kid) {
48
+ if (!keys.has(kid) && now() - fetchedAt >= 60) await refresh();
49
+ const key = keys.get(kid);
50
+ if (!key) throw new Error('unknown signing key');
51
+ return key;
52
+ }
53
+
54
+ async function verify(token) {
55
+ if (typeof token !== 'string' || !token) throw new Error('no Cf-Access-Jwt-Assertion header');
56
+ const parts = token.split('.');
57
+ if (parts.length !== 3) throw new Error('malformed token');
58
+ let header;
59
+ let payload;
60
+ try {
61
+ header = b64urlJson(parts[0]);
62
+ payload = b64urlJson(parts[1]);
63
+ } catch {
64
+ throw new Error('malformed token');
65
+ }
66
+ if (header.alg !== 'RS256') throw new Error(`unexpected alg ${String(header.alg).slice(0, 10)}`);
67
+ const key = await keyFor(header.kid);
68
+ const ok = crypto.verify('RSA-SHA256', Buffer.from(`${parts[0]}.${parts[1]}`), key, Buffer.from(parts[2], 'base64url'));
69
+ if (!ok) throw new Error('bad signature');
70
+ const auds = Array.isArray(payload.aud) ? payload.aud : [payload.aud];
71
+ if (!auds.includes(aud)) throw new Error('wrong audience');
72
+ if (payload.iss !== issuer) throw new Error('wrong issuer');
73
+ const t = now();
74
+ if (typeof payload.exp !== 'number' || payload.exp + leeway < t) throw new Error('expired');
75
+ if (typeof payload.nbf === 'number' && payload.nbf - leeway > t) throw new Error('not valid yet');
76
+ if (String(payload.email || '').toLowerCase() !== want) throw new Error('not the configured user');
77
+ return { email: payload.email };
78
+ }
79
+
80
+ return { verify, issuer, certsUrl };
81
+ }
82
+
83
+ module.exports = { createAccessVerifier };
package/src/config.js ADDED
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+ // zola-web's settings: ~/.config/zola-web/config.json (ZOLA_WEB_CONFIG or --config moves it). No secrets in it:
3
+ // the GitHub token lives in gh, the login is Cloudflare Access.
4
+
5
+ const fs = require('node:fs');
6
+ const os = require('node:os');
7
+ const path = require('node:path');
8
+
9
+ const DEFAULTS = {
10
+ codeUrl: 'https://code.neoncapybara.link',
11
+ webUrl: 'https://zola.neoncapybara.link',
12
+ port: 8081,
13
+ sessionsRoot: path.join(os.homedir(), 'work'),
14
+ };
15
+
16
+ const configPath = (env = process.env) => env.ZOLA_WEB_CONFIG || path.join(env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'zola-web', 'config.json');
17
+
18
+ function httpsOrigin(u, key) {
19
+ let url;
20
+ try {
21
+ url = new URL(u);
22
+ } catch {
23
+ throw new Error(`${key} must be a URL`);
24
+ }
25
+ if (url.protocol !== 'https:' || url.pathname !== '/' || url.search || url.username) throw new Error(`${key} must be https://<host> with no path`);
26
+ return url.origin;
27
+ }
28
+
29
+ /** Read and check the config: { accessTeam, accessAud, email, githubClientId, codeUrl, webUrl, port, sessionsRoot, zolaEntry? }. */
30
+ function loadConfig(file = configPath()) {
31
+ let raw;
32
+ try {
33
+ raw = JSON.parse(fs.readFileSync(file, 'utf8'));
34
+ } catch (e) {
35
+ throw new Error(`cannot read ${file}: ${e.code === 'ENOENT' ? 'missing' : 'not JSON'}`);
36
+ }
37
+ const c = { ...DEFAULTS, ...raw };
38
+ for (const k of ['accessTeam', 'accessAud', 'email']) if (!c[k]) throw new Error(`${file}: "${k}" is required`);
39
+ c.codeUrl = httpsOrigin(c.codeUrl, 'codeUrl');
40
+ c.webUrl = httpsOrigin(c.webUrl, 'webUrl');
41
+ c.port = Number(c.port);
42
+ if (!Number.isInteger(c.port) || c.port < 1024 || c.port > 65535) throw new Error(`${file}: "port" must be 1024-65535`);
43
+ if (c.githubClientId && !/^[A-Za-z0-9._-]{8,64}$/.test(c.githubClientId)) throw new Error(`${file}: "githubClientId" does not look like an OAuth App client ID`);
44
+ if (c.sessionsRoot && !path.isAbsolute(c.sessionsRoot)) throw new Error(`${file}: "sessionsRoot" must be an absolute path`);
45
+ return c;
46
+ }
47
+
48
+ module.exports = { loadConfig, configPath, DEFAULTS };
package/src/github.js ADDED
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+ // GitHub for zola-web: the OAuth device flow, and gh as the only place the token lives.
3
+ // The token from the device flow goes straight to `gh auth login --with-token` on stdin and is then dropped: it is
4
+ // never logged, returned to the browser or put on a command line. zola uses gh for everything after that.
5
+
6
+ const { runFile } = require('./run');
7
+
8
+ const HOST = 'github.com';
9
+ const SCOPES = 'repo read:org';
10
+ const LOGIN_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
11
+
12
+ async function postForm(url, form, fetchImpl) {
13
+ const r = await fetchImpl(url, {
14
+ method: 'POST',
15
+ headers: { accept: 'application/json', 'content-type': 'application/x-www-form-urlencoded' },
16
+ body: new URLSearchParams(form).toString(),
17
+ signal: AbortSignal.timeout(15_000),
18
+ });
19
+ if (!r.ok) throw new Error(`GitHub answered HTTP ${r.status}`);
20
+ return r.json();
21
+ }
22
+
23
+ /**
24
+ * One GitHub connection. `state()` is what the page shows: { connected, login, device?, error? }.
25
+ * `connect()` starts a device flow and polls it in the background; `logout()` signs gh out.
26
+ */
27
+ function createGithub({ clientId, fetchImpl = fetch, run = runFile, env = process.env, sleep = (ms) => new Promise((r) => setTimeout(r, ms)), log = () => {}, now = () => Date.now() }) {
28
+ let device = null; // { userCode, verificationUri, expiresAt } shown to the user; device_code stays here
29
+ let lastError = null;
30
+ let polling = null;
31
+ const gh = (args, opts = {}) => run('gh', args, { env, timeout: 60_000, ...opts });
32
+
33
+ async function login() {
34
+ const st = await gh(['auth', 'status', '--hostname', HOST]);
35
+ if (!st.ok) return null;
36
+ const u = await gh(['api', 'user', '--jq', '.login']);
37
+ const name = (u.stdout || '').trim();
38
+ return u.ok && LOGIN_RE.test(name) ? name : '(connected)';
39
+ }
40
+
41
+ async function state() {
42
+ const who = await login();
43
+ return {
44
+ connected: !!who,
45
+ login: who,
46
+ clientConfigured: !!clientId,
47
+ device: device && !who ? { userCode: device.userCode, verificationUri: device.verificationUri, expiresAt: device.expiresAt } : null,
48
+ error: lastError,
49
+ };
50
+ }
51
+
52
+ async function handOff(token) {
53
+ const r = await gh(['auth', 'login', '--hostname', HOST, '--git-protocol', 'https', '--with-token'], { input: `${token}\n` });
54
+ if (!r.ok) throw new Error('gh auth login refused the token');
55
+ await gh(['auth', 'setup-git', '--hostname', HOST]);
56
+ }
57
+
58
+ async function poll(dev) {
59
+ let interval = Math.max(5, Number(dev.interval) || 5);
60
+ while (device === dev.public && now() < dev.public.expiresAt) {
61
+ await sleep(interval * 1000);
62
+ if (device !== dev.public) return;
63
+ let body;
64
+ try {
65
+ body = await postForm(`https://${HOST}/login/oauth/access_token`, { client_id: clientId, device_code: dev.deviceCode, grant_type: 'urn:ietf:params:oauth:grant-type:device_code' }, fetchImpl);
66
+ } catch (e) {
67
+ log(`github: poll failed (${e.message}), retrying`);
68
+ continue;
69
+ }
70
+ if (body.access_token) {
71
+ let token = body.access_token;
72
+ body.access_token = undefined;
73
+ try {
74
+ await handOff(token);
75
+ log('github: connected (token handed to gh)');
76
+ lastError = null;
77
+ } catch (e) {
78
+ lastError = e.message;
79
+ log(`github: ${e.message}`);
80
+ } finally {
81
+ token = null;
82
+ device = null;
83
+ }
84
+ return;
85
+ }
86
+ if (body.error === 'authorization_pending') continue;
87
+ if (body.error === 'slow_down') {
88
+ interval = Number(body.interval) || interval + 5;
89
+ continue;
90
+ }
91
+ lastError = body.error === 'access_denied' ? 'You cancelled the GitHub authorization.' : body.error === 'expired_token' ? 'The code expired: connect again.' : `GitHub: ${String(body.error || 'unexpected answer').slice(0, 60)}`;
92
+ log(`github: device flow ended (${body.error})`);
93
+ device = null;
94
+ return;
95
+ }
96
+ if (device === dev.public) {
97
+ lastError = 'The code expired: connect again.';
98
+ device = null;
99
+ }
100
+ }
101
+
102
+ async function connect() {
103
+ if (!clientId) throw new Error('No GitHub OAuth App client ID is configured (githubClientId).');
104
+ const body = await postForm(`https://${HOST}/login/device/code`, { client_id: clientId, scope: SCOPES }, fetchImpl);
105
+ if (!body.device_code || !body.user_code) throw new Error(`GitHub did not start the device flow${body.error ? ` (${String(body.error).slice(0, 60)})` : ''}`);
106
+ lastError = null;
107
+ const pub = { userCode: String(body.user_code), verificationUri: String(body.verification_uri || `https://${HOST}/login/device`), expiresAt: now() + (Number(body.expires_in) || 900) * 1000 };
108
+ device = pub;
109
+ log('github: device flow started');
110
+ polling = poll({ public: pub, deviceCode: body.device_code, interval: body.interval });
111
+ return { userCode: pub.userCode, verificationUri: pub.verificationUri, expiresAt: pub.expiresAt };
112
+ }
113
+
114
+ async function logout() {
115
+ device = null;
116
+ const who = await login();
117
+ if (!who) return { ok: true };
118
+ const args = ['auth', 'logout', '--hostname', HOST];
119
+ if (LOGIN_RE.test(who)) args.push('--user', who);
120
+ const r = await gh(args);
121
+ log(`github: logout ${r.ok ? 'done' : 'failed'}`);
122
+ if (!r.ok) throw new Error('gh auth logout failed');
123
+ return { ok: true };
124
+ }
125
+
126
+ return { state, connect, logout, _polling: () => polling };
127
+ }
128
+
129
+ module.exports = { createGithub, SCOPES, LOGIN_RE };
package/src/run.js ADDED
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+ // Run a program without a shell. `input` goes to its stdin (how a token reaches gh), never to argv.
3
+ const { spawn } = require('node:child_process');
4
+
5
+ function runFile(cmd, args, { input, env, timeout = 120_000, cwd } = {}) {
6
+ return new Promise((resolve) => {
7
+ let stdout = '';
8
+ let stderr = '';
9
+ let done = false;
10
+ const child = spawn(cmd, args, { env: env || process.env, cwd, stdio: ['pipe', 'pipe', 'pipe'], shell: false });
11
+ const timer = setTimeout(() => child.kill('SIGTERM'), timeout);
12
+ const finish = (code) => {
13
+ if (done) return;
14
+ done = true;
15
+ clearTimeout(timer);
16
+ resolve({ code, ok: code === 0, stdout, stderr });
17
+ };
18
+ child.stdout.on('data', (d) => { stdout += d; if (stdout.length > 16 * 1024 * 1024) child.kill('SIGTERM'); });
19
+ child.stderr.on('data', (d) => { stderr += d; if (stderr.length > 1024 * 1024) stderr = stderr.slice(-65536); });
20
+ child.on('error', () => finish(127));
21
+ child.on('close', (code) => finish(code ?? 1));
22
+ child.stdin.on('error', () => {});
23
+ child.stdin.end(input ?? '');
24
+ });
25
+ }
26
+
27
+ module.exports = { runFile };
package/src/server.js ADDED
@@ -0,0 +1,139 @@
1
+ 'use strict';
2
+ // zola-web's HTTP server. Listens on 127.0.0.1 only; Cloudflare Access in front is the login.
3
+ // Every request: a valid Access JWT for the configured user. Every action (POST): the page's CSRF token and the
4
+ // app's own Origin. JSON in, JSON out; static files from public/.
5
+
6
+ const http = require('node:http');
7
+ const crypto = require('node:crypto');
8
+ const fs = require('node:fs');
9
+ const path = require('node:path');
10
+ const { workspaceUrl } = require('./zola');
11
+
12
+ const PUBLIC = path.join(__dirname, '..', 'public');
13
+ const STATIC = { '/app.js': ['app.js', 'text/javascript; charset=utf-8'], '/app.css': ['app.css', 'text/css; charset=utf-8'] };
14
+ const MAX_BODY = 16 * 1024;
15
+ const SECURITY_HEADERS = {
16
+ 'content-security-policy': "default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src 'self' data:; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",
17
+ 'x-content-type-options': 'nosniff',
18
+ 'referrer-policy': 'no-referrer',
19
+ 'x-frame-options': 'DENY',
20
+ 'cache-control': 'no-store',
21
+ };
22
+
23
+ class HttpError extends Error {
24
+ constructor(status, message) {
25
+ super(message);
26
+ this.status = status;
27
+ }
28
+ }
29
+
30
+ function send(res, status, body, type = 'application/json; charset=utf-8') {
31
+ const data = typeof body === 'string' ? body : JSON.stringify(body);
32
+ res.writeHead(status, { ...SECURITY_HEADERS, 'content-type': type, 'content-length': Buffer.byteLength(data) });
33
+ res.end(data);
34
+ }
35
+
36
+ function readJson(req) {
37
+ return new Promise((resolve, reject) => {
38
+ if (!/^application\/json\b/i.test(req.headers['content-type'] || '')) return reject(new HttpError(415, 'JSON only'));
39
+ let size = 0;
40
+ const chunks = [];
41
+ req.on('data', (c) => {
42
+ size += c.length;
43
+ if (size > MAX_BODY) {
44
+ // Answer 413, and drain the rest instead of cutting the connection.
45
+ req.removeAllListeners('data');
46
+ req.resume();
47
+ reject(new HttpError(413, 'request too large'));
48
+ } else chunks.push(c);
49
+ });
50
+ req.on('end', () => {
51
+ try {
52
+ resolve(chunks.length ? JSON.parse(Buffer.concat(chunks).toString('utf8')) : {});
53
+ } catch {
54
+ reject(new HttpError(400, 'bad JSON'));
55
+ }
56
+ });
57
+ req.on('error', reject);
58
+ });
59
+ }
60
+
61
+ const sameToken = (a, b) => typeof a === 'string' && a.length === b.length && crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b));
62
+
63
+ /**
64
+ * createApp({ access, github, zola, codeUrl, origin, log }) → request handler.
65
+ * access.verify(token), github.{state,connect,logout}, zola.{repos,sessions,start,addRepos}.
66
+ */
67
+ function createApp({ access, github, zola, codeUrl, origin, log = () => {}, csrf = crypto.randomBytes(32).toString('base64url') }) {
68
+ const index = fs.readFileSync(path.join(PUBLIC, 'index.html'), 'utf8').replace('__CSRF__', csrf);
69
+ const withUrl = (s) => ({ ...s, url: s.workspace ? workspaceUrl(codeUrl, s.workspace) : null });
70
+
71
+ const routes = {
72
+ 'GET /api/state': async () => ({ github: await github.state(), codeUrl }),
73
+ 'POST /api/github/connect': async () => ({ device: await github.connect() }),
74
+ 'POST /api/github/logout': async () => github.logout(),
75
+ 'GET /api/repos': async () => ({ repos: await zola.repos() }),
76
+ 'GET /api/sessions': async () => ({ sessions: (await zola.sessions()).map(withUrl) }),
77
+ 'POST /api/sessions': async (body) => {
78
+ const s = await zola.start(body.name, body.repos);
79
+ log(`session started (${(body.repos || []).length} repos)`);
80
+ return { session: withUrl(s) };
81
+ },
82
+ 'POST /api/sessions/repos': async (body) => {
83
+ const s = await zola.addRepos(String(body.id || ''), body.repos);
84
+ log('repositories added to a session');
85
+ return { session: withUrl(s) };
86
+ },
87
+ };
88
+
89
+ return async function handle(req, res) {
90
+ const url = new URL(req.url, 'http://127.0.0.1');
91
+ try {
92
+ try {
93
+ await access.verify(req.headers['cf-access-jwt-assertion']);
94
+ } catch (e) {
95
+ log(`refused ${req.method} ${url.pathname}: ${e.message}`);
96
+ throw new HttpError(403, 'Forbidden');
97
+ }
98
+ if (req.method === 'GET' && url.pathname === '/') return send(res, 200, index, 'text/html; charset=utf-8');
99
+ if (req.method === 'GET' && STATIC[url.pathname]) {
100
+ const [file, type] = STATIC[url.pathname];
101
+ return send(res, 200, fs.readFileSync(path.join(PUBLIC, file), 'utf8'), type);
102
+ }
103
+ const route = routes[`${req.method} ${url.pathname}`];
104
+ if (!route) throw new HttpError(404, 'Not found');
105
+ let body = {};
106
+ if (req.method === 'POST') {
107
+ if (req.headers.origin !== origin) {
108
+ log(`refused ${url.pathname}: origin`);
109
+ throw new HttpError(403, 'Forbidden');
110
+ }
111
+ if (!sameToken(req.headers['x-csrf-token'], csrf)) {
112
+ log(`refused ${url.pathname}: csrf`);
113
+ throw new HttpError(403, 'Forbidden');
114
+ }
115
+ body = await readJson(req);
116
+ if (!body || typeof body !== 'object' || Array.isArray(body)) throw new HttpError(400, 'bad JSON');
117
+ }
118
+ return send(res, 200, await route(body));
119
+ } catch (e) {
120
+ if (e instanceof HttpError) return send(res, e.status, { error: e.message });
121
+ log(`${req.method} ${url.pathname}: ${String(e.message).split('\n')[0]}`);
122
+ return send(res, 400, { error: String(e.message).split('\n')[0].slice(0, 300) });
123
+ }
124
+ };
125
+ }
126
+
127
+ /** Listen on 127.0.0.1 only. */
128
+ async function listen(handler, { host = '127.0.0.1', port = 8081 } = {}) {
129
+ if (host !== '127.0.0.1' && host !== '::1') throw new Error(`zola-web listens on 127.0.0.1 only (asked for ${host})`);
130
+ const server = http.createServer(handler);
131
+ server.headersTimeout = 20_000;
132
+ server.requestTimeout = 20 * 60_000; // starting a session clones repositories
133
+ return new Promise((resolve, reject) => {
134
+ server.once('error', reject);
135
+ server.listen(port, host, () => resolve(server));
136
+ });
137
+ }
138
+
139
+ module.exports = { createApp, listen, SECURITY_HEADERS };
package/src/zola.js ADDED
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+ // The zola CLI for zola-web: always `node zola.mjs …` with fixed, validated arguments, never a shell, with
3
+ // ZOLA_AGENT=1 (no prompts, JSON out). GitHub repositories only.
4
+
5
+ const path = require('node:path');
6
+ const os = require('node:os');
7
+ const { runFile } = require('./run');
8
+
9
+ const NAME_RE = /^[a-z0-9][a-z0-9._-]{0,47}$/;
10
+ const OWNER_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
11
+ const REPO_RE = /^[A-Za-z0-9._-]{1,100}$/;
12
+ const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
13
+ const MAX_REPOS = 20;
14
+
15
+ /** "owner/repo" → "github:owner/repo", or throws. */
16
+ function repoSpec(full) {
17
+ const m = /^([^/]+)\/([^/]+)$/.exec(String(full || ''));
18
+ if (!m || !OWNER_RE.test(m[1]) || !REPO_RE.test(m[2]) || m[2] === '.' || m[2] === '..') throw new Error(`"${String(full).slice(0, 80)}" is not owner/repo`);
19
+ return `github:${m[1]}/${m[2]}`;
20
+ }
21
+
22
+ function repoSpecs(list) {
23
+ if (!Array.isArray(list) || !list.length) throw new Error('pick at least one repository');
24
+ if (list.length > MAX_REPOS) throw new Error(`at most ${MAX_REPOS} repositories at a time`);
25
+ return [...new Set(list.map(repoSpec))];
26
+ }
27
+
28
+ function sessionName(name) {
29
+ const n = String(name || '').trim().toLowerCase();
30
+ if (!NAME_RE.test(n)) throw new Error('a session name is lowercase letters, digits, ".", "_" or "-", up to 48, starting with a letter or digit');
31
+ return n;
32
+ }
33
+
34
+ /** The URL code-server opens a workspace at: <codeUrl>/?workspace=<absolute path>, each segment encoded. */
35
+ function workspaceUrl(codeUrl, workspace) {
36
+ if (!path.isAbsolute(workspace || '')) throw new Error('zola returned no workspace path');
37
+ return `${String(codeUrl).replace(/\/+$/, '')}/?workspace=${workspace.split('/').map(encodeURIComponent).join('/')}`;
38
+ }
39
+
40
+ function defaultEntry(env = process.env) {
41
+ return path.join(env.VSCODE_CONFIG_HOME || path.join(env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'vscode-config'), 'zola', 'zola.mjs');
42
+ }
43
+
44
+ function createZola({ node = process.execPath, entry = defaultEntry(), sessionsRoot, run = runFile, env = process.env }) {
45
+ async function zola(args, timeout = 120_000) {
46
+ const r = await run(node, [entry, ...args], { env: { ...env, ZOLA_AGENT: '1', NO_COLOR: '1' }, timeout });
47
+ let out;
48
+ try {
49
+ out = JSON.parse(r.stdout);
50
+ } catch {
51
+ throw new Error(`zola ${args[0]} ${args[1] || ''} did not answer in JSON`.trim());
52
+ }
53
+ if (!r.ok || out.ok === false) throw new Error(String(out.error || `zola ${args[0]} failed`).split('\n')[0].slice(0, 300));
54
+ return out;
55
+ }
56
+
57
+ /** [{ full: 'owner/repo', owner, name, description, private }] from gh, through zola. */
58
+ async function repos() {
59
+ const out = await zola(['session', 'repos', '--provider', 'github', '--json'], 180_000);
60
+ return (out.repos || [])
61
+ .filter((r) => (r.provider || 'github') === 'github' && /^[^/]+\/[^/]+$/.test(r.repo || ''))
62
+ .map((r) => {
63
+ const [owner, name] = r.repo.split('/');
64
+ return { full: r.repo, owner, name, description: String(r.description || '').slice(0, 200), private: !!r.private };
65
+ })
66
+ .filter((r) => OWNER_RE.test(r.owner) && REPO_RE.test(r.name));
67
+ }
68
+
69
+ async function sessions() {
70
+ const out = await zola(['session', 'list', '--json']);
71
+ return (out.sessions || []).filter((s) => s && (ID_RE.test(s.id || '') || NAME_RE.test(s.name || ''))).map((s) => ({
72
+ id: ID_RE.test(s.id || '') ? s.id : s.name,
73
+ name: s.name,
74
+ label: s.label || s.name,
75
+ dir: s.dir,
76
+ workspace: s.workspace,
77
+ repos: (s.repos || []).map((r) => ({ repo: r.repo, folder: r.folder, branch: r.branch })),
78
+ }));
79
+ }
80
+
81
+ async function start(name, list) {
82
+ const n = sessionName(name);
83
+ const specs = repoSpecs(list);
84
+ const args = ['start', n, ...specs, '--agent', '--json'];
85
+ if (sessionsRoot) args.push('--root', sessionsRoot);
86
+ const out = await zola(args, 15 * 60_000);
87
+ if (!out.session) throw new Error('zola start returned no session');
88
+ return out.session;
89
+ }
90
+
91
+ async function addRepos(id, list) {
92
+ const known = await sessions();
93
+ const s = known.find((x) => x.id === id);
94
+ if (!s) throw new Error('no such session');
95
+ const out = await zola(['session', 'add', s.id, ...repoSpecs(list), '--json'], 15 * 60_000);
96
+ return out.session || s;
97
+ }
98
+
99
+ return { repos, sessions, start, addRepos };
100
+ }
101
+
102
+ module.exports = { createZola, repoSpec, repoSpecs, sessionName, workspaceUrl, defaultEntry, NAME_RE, OWNER_RE, REPO_RE, MAX_REPOS };