openlimiter 0.1.0 → 0.4.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/dist/cli.d.ts +11 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +237 -42
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +112 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +253 -8
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/ingest.d.ts +24 -1
- package/dist/ingest.d.ts.map +1 -1
- package/dist/ingest.js +34 -0
- package/dist/ingest.js.map +1 -1
- package/dist/render.d.ts +138 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +357 -0
- package/dist/render.js.map +1 -0
- package/dist/serve.d.ts +36 -3
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +220 -128
- package/dist/serve.js.map +1 -1
- package/dist/statusline.d.ts +91 -0
- package/dist/statusline.d.ts.map +1 -0
- package/dist/statusline.js +328 -0
- package/dist/statusline.js.map +1 -0
- package/package.json +4 -4
package/dist/serve.js
CHANGED
|
@@ -21,8 +21,12 @@ import { encodeQr, renderQr } from "./qr.js";
|
|
|
21
21
|
* Four gates stand between the socket and that payload:
|
|
22
22
|
*
|
|
23
23
|
* 1. A random token is generated on every start and is required on every
|
|
24
|
-
* route. It lives only in memory, is never written to
|
|
25
|
-
* the moment the command stops.
|
|
24
|
+
* route that carries data. It lives only in memory, is never written to
|
|
25
|
+
* disk, and is void the moment the command stops. The empty page shell at
|
|
26
|
+
* the root is the one route served without it, because the token travels
|
|
27
|
+
* in the URL fragment and a fragment never reaches a server. The shell
|
|
28
|
+
* holds no quota state, no token and no account detail: it is markup that
|
|
29
|
+
* then has to authenticate before anything is filled in.
|
|
26
30
|
* 2. The Host header must be an address literal or localhost, which is what
|
|
27
31
|
* closes a DNS rebinding attack from a page on an attacker's domain.
|
|
28
32
|
* 3. Cross origin requests are refused outright. The page this server hands
|
|
@@ -41,8 +45,31 @@ export const DEFAULT_SERVE_PORT = 7317;
|
|
|
41
45
|
export const DEFAULT_SERVE_HOST = "0.0.0.0";
|
|
42
46
|
/** Payload schema version. Bumped only on a breaking shape change. */
|
|
43
47
|
export const SERVE_SCHEMA = 1;
|
|
44
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Name the token travels under. Short, because it goes in a QR symbol.
|
|
50
|
+
*
|
|
51
|
+
* It is the key in the URL FRAGMENT of every address this command prints, and
|
|
52
|
+
* for one more release it is also accepted as a query parameter so an address
|
|
53
|
+
* saved from an older build keeps working.
|
|
54
|
+
*/
|
|
45
55
|
export const TOKEN_PARAMETER = "t";
|
|
56
|
+
/**
|
|
57
|
+
* Why the token is in the fragment rather than the query.
|
|
58
|
+
*
|
|
59
|
+
* A query string is part of the request line. It lands in the phone's browser
|
|
60
|
+
* history, in the omnibox suggestions, in whatever cloud that browser syncs
|
|
61
|
+
* history to, and in the Referer of any link the page might carry. A fragment
|
|
62
|
+
* is never sent to a server at all: it stays in the address bar until the page
|
|
63
|
+
* itself reads it, and the page's first act is to move it into sessionStorage
|
|
64
|
+
* and rewrite the address to a clean one. From that point the token exists only
|
|
65
|
+
* in the tab's own memory and is sent as an Authorization header, so no URL
|
|
66
|
+
* anywhere on the phone carries the capability.
|
|
67
|
+
*
|
|
68
|
+
* docs/SYNC_ARCHITECTURE.md already required exactly this of pairing links.
|
|
69
|
+
*/
|
|
70
|
+
export const TOKEN_FRAGMENT_PREFIX = "#" + TOKEN_PARAMETER + "=";
|
|
71
|
+
/** Key the page keeps the token under, inside its own tab and nowhere else. */
|
|
72
|
+
const TOKEN_STORAGE_KEY = "openlimiter.token";
|
|
46
73
|
/** Longest request target this server will look at. */
|
|
47
74
|
const MAX_TARGET_LENGTH = 512;
|
|
48
75
|
/** Bounds on the socket, so a stalled client cannot hold a slot forever. */
|
|
@@ -104,6 +131,25 @@ export function isAllowedHostHeader(header, boundPort) {
|
|
|
104
131
|
const literal = hostname.startsWith("[") ? hostname.slice(1, -1) : hostname;
|
|
105
132
|
return isIP(literal) !== 0;
|
|
106
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Read the token a request presents.
|
|
136
|
+
*
|
|
137
|
+
* The header is the supported way and is read first. The query parameter is a
|
|
138
|
+
* fallback kept for one release so an address copied out of an older build
|
|
139
|
+
* still answers; nothing this command prints uses it any more.
|
|
140
|
+
*/
|
|
141
|
+
export function presentedToken(authorization, target) {
|
|
142
|
+
if (typeof authorization === "string") {
|
|
143
|
+
const space = authorization.indexOf(" ");
|
|
144
|
+
if (space > 0 && authorization.slice(0, space).toLowerCase() === "bearer") {
|
|
145
|
+
const value = authorization.slice(space + 1).trim();
|
|
146
|
+
if (value !== "")
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
return target.searchParams.get(TOKEN_PARAMETER);
|
|
152
|
+
}
|
|
107
153
|
function constantTimeEquals(left, right) {
|
|
108
154
|
const a = Buffer.from(left, "utf8");
|
|
109
155
|
const b = Buffer.from(right, "utf8");
|
|
@@ -184,122 +230,160 @@ function sendHtml(request, response, status, html) {
|
|
|
184
230
|
* site, and the whole thing follows the reader's own light or dark setting.
|
|
185
231
|
*/
|
|
186
232
|
export function mobilePage() {
|
|
187
|
-
return `<!doctype html>
|
|
188
|
-
<html lang="en">
|
|
189
|
-
<head>
|
|
190
|
-
<meta charset="utf-8">
|
|
191
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
192
|
-
<meta name="robots" content="noindex, nofollow">
|
|
193
|
-
<meta name="color-scheme" content="light dark">
|
|
194
|
-
<title>OpenLimiter quota</title>
|
|
195
|
-
<style>
|
|
196
|
-
:root{color-scheme:light dark;--canvas:#fff;--surface:#f6f6f7;--track:#e2e2e6;--hairline:#e5e5e8;--heading:#0d0d0f;--body:#53535c;--muted:#62626c;--accent:#0866ff;--warn:#b45309;--stop:#b42318}
|
|
197
|
-
@media (prefers-color-scheme:dark){:root{--canvas:#0a0a0b;--surface:#121214;--track:#26262b;--hairline:#232327;--heading:#f2f2f3;--body:#adadb6;--muted:#94949e;--accent:#6ba6ff;--warn:#f0b429;--stop:#ff6b6b}}
|
|
198
|
-
*{box-sizing:border-box}
|
|
199
|
-
body{margin:0;padding:20px 16px 48px;background:var(--canvas);color:var(--body);font:15px/1.5 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased}
|
|
200
|
-
main{max-width:520px;margin:0 auto}
|
|
201
|
-
h1{margin:0 0 2px;font-size:19px;font-weight:600;letter-spacing:-.01em;color:var(--heading)}
|
|
202
|
-
.sub{margin:0 0 20px;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted)}
|
|
203
|
-
.state{display:inline-flex;align-items:center;gap:7px;border:1px solid var(--hairline);border-radius:8px;padding:5px 10px;font:11px/1 ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);background:var(--surface)}
|
|
204
|
-
.dot{width:7px;height:7px;border-radius:50%;background:var(--accent)}
|
|
205
|
-
.card{border:1px solid var(--hairline);border-radius:14px;background:var(--surface);padding:14px 16px;margin-top:10px}
|
|
206
|
-
.row{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
|
|
207
|
-
.name{font-size:14px;font-weight:600;color:var(--heading);letter-spacing:.01em}
|
|
208
|
-
.pct{font:600 20px/1 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--heading);font-variant-numeric:tabular-nums}
|
|
209
|
-
.bar{margin-top:10px;height:6px;border-radius:999px;background:var(--track);overflow:hidden}
|
|
210
|
-
.fill{height:100%;border-radius:999px;background:var(--accent);transition:width .3s ease}
|
|
211
|
-
.fill.near{background:var(--warn)}
|
|
212
|
-
.fill.at{background:var(--stop)}
|
|
213
|
-
.meta{margin-top:8px;display:flex;gap:10px;flex-wrap:wrap;font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted)}
|
|
214
|
-
.note{margin-top:22px;font-size:12px;line-height:1.6;color:var(--muted)}
|
|
215
|
-
.err{color:var(--stop)}
|
|
216
|
-
</style>
|
|
217
|
-
</head>
|
|
218
|
-
<body>
|
|
219
|
-
<main>
|
|
220
|
-
<h1>OpenLimiter</h1>
|
|
221
|
-
<p class="sub" id="stamp">Loading quota from this machine.</p>
|
|
222
|
-
<p><span class="state"><span class="dot" id="dot"></span><span id="reason">reading</span></span></p>
|
|
223
|
-
<div id="cards"></div>
|
|
224
|
-
<p class="note" id="unknown"></p>
|
|
225
|
-
<p class="note">
|
|
226
|
-
Served from the machine running OpenLimiter, over your own network. Nothing here
|
|
227
|
-
left that machine, nothing was uploaded, and this page can only read.
|
|
228
|
-
</p>
|
|
229
|
-
</main>
|
|
230
|
-
<script>
|
|
231
|
-
(function(){
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
? ""
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
.
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
.
|
|
290
|
-
.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
233
|
+
return `<!doctype html>
|
|
234
|
+
<html lang="en">
|
|
235
|
+
<head>
|
|
236
|
+
<meta charset="utf-8">
|
|
237
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
238
|
+
<meta name="robots" content="noindex, nofollow">
|
|
239
|
+
<meta name="color-scheme" content="light dark">
|
|
240
|
+
<title>OpenLimiter quota</title>
|
|
241
|
+
<style>
|
|
242
|
+
:root{color-scheme:light dark;--canvas:#fff;--surface:#f6f6f7;--track:#e2e2e6;--hairline:#e5e5e8;--heading:#0d0d0f;--body:#53535c;--muted:#62626c;--accent:#0866ff;--warn:#b45309;--stop:#b42318}
|
|
243
|
+
@media (prefers-color-scheme:dark){:root{--canvas:#0a0a0b;--surface:#121214;--track:#26262b;--hairline:#232327;--heading:#f2f2f3;--body:#adadb6;--muted:#94949e;--accent:#6ba6ff;--warn:#f0b429;--stop:#ff6b6b}}
|
|
244
|
+
*{box-sizing:border-box}
|
|
245
|
+
body{margin:0;padding:20px 16px 48px;background:var(--canvas);color:var(--body);font:15px/1.5 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased}
|
|
246
|
+
main{max-width:520px;margin:0 auto}
|
|
247
|
+
h1{margin:0 0 2px;font-size:19px;font-weight:600;letter-spacing:-.01em;color:var(--heading)}
|
|
248
|
+
.sub{margin:0 0 20px;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted)}
|
|
249
|
+
.state{display:inline-flex;align-items:center;gap:7px;border:1px solid var(--hairline);border-radius:8px;padding:5px 10px;font:11px/1 ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);background:var(--surface)}
|
|
250
|
+
.dot{width:7px;height:7px;border-radius:50%;background:var(--accent)}
|
|
251
|
+
.card{border:1px solid var(--hairline);border-radius:14px;background:var(--surface);padding:14px 16px;margin-top:10px}
|
|
252
|
+
.row{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
|
|
253
|
+
.name{font-size:14px;font-weight:600;color:var(--heading);letter-spacing:.01em}
|
|
254
|
+
.pct{font:600 20px/1 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--heading);font-variant-numeric:tabular-nums}
|
|
255
|
+
.bar{margin-top:10px;height:6px;border-radius:999px;background:var(--track);overflow:hidden}
|
|
256
|
+
.fill{height:100%;border-radius:999px;background:var(--accent);transition:width .3s ease}
|
|
257
|
+
.fill.near{background:var(--warn)}
|
|
258
|
+
.fill.at{background:var(--stop)}
|
|
259
|
+
.meta{margin-top:8px;display:flex;gap:10px;flex-wrap:wrap;font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted)}
|
|
260
|
+
.note{margin-top:22px;font-size:12px;line-height:1.6;color:var(--muted)}
|
|
261
|
+
.err{color:var(--stop)}
|
|
262
|
+
</style>
|
|
263
|
+
</head>
|
|
264
|
+
<body>
|
|
265
|
+
<main>
|
|
266
|
+
<h1>OpenLimiter</h1>
|
|
267
|
+
<p class="sub" id="stamp">Loading quota from this machine.</p>
|
|
268
|
+
<p><span class="state"><span class="dot" id="dot"></span><span id="reason">reading</span></span></p>
|
|
269
|
+
<div id="cards"></div>
|
|
270
|
+
<p class="note" id="unknown"></p>
|
|
271
|
+
<p class="note">
|
|
272
|
+
Served from the machine running OpenLimiter, over your own network. Nothing here
|
|
273
|
+
left that machine, nothing was uploaded, and this page can only read.
|
|
274
|
+
</p>
|
|
275
|
+
</main>
|
|
276
|
+
<script>
|
|
277
|
+
(function(){
|
|
278
|
+
/* The token arrives in the fragment, which no server ever sees. Move it into
|
|
279
|
+
this tab's own memory and wipe the address, so the history entry the phone
|
|
280
|
+
keeps, and syncs, carries no capability.
|
|
281
|
+
|
|
282
|
+
The query is read as well, and first, because an address printed by an
|
|
283
|
+
older build put the token there. Such an address still reaches this page,
|
|
284
|
+
and a page that only looked at the fragment would sit at 401 forever with
|
|
285
|
+
the token visible in the address bar the whole time. Reading it, then
|
|
286
|
+
scrubbing BOTH the query and the fragment in one replaceState, turns the
|
|
287
|
+
old address into the new behaviour on its first load. */
|
|
288
|
+
var key = ${JSON.stringify(TOKEN_STORAGE_KEY)};
|
|
289
|
+
var name = ${JSON.stringify(TOKEN_PARAMETER)};
|
|
290
|
+
var prefix = ${JSON.stringify(TOKEN_FRAGMENT_PREFIX)};
|
|
291
|
+
var token = "";
|
|
292
|
+
var fromAddress = false;
|
|
293
|
+
try {
|
|
294
|
+
var queried = new URLSearchParams(location.search).get(name);
|
|
295
|
+
if (queried) {
|
|
296
|
+
token = queried;
|
|
297
|
+
fromAddress = true;
|
|
298
|
+
} else if (location.hash.indexOf(prefix) === 0) {
|
|
299
|
+
token = decodeURIComponent(location.hash.slice(prefix.length));
|
|
300
|
+
fromAddress = true;
|
|
301
|
+
}
|
|
302
|
+
} catch (error) {
|
|
303
|
+
token = "";
|
|
304
|
+
}
|
|
305
|
+
if (fromAddress) {
|
|
306
|
+
try { sessionStorage.setItem(key, token); } catch (error) {}
|
|
307
|
+
/* One rewrite, dropping the query and the fragment together. */
|
|
308
|
+
try { history.replaceState(null, "", location.pathname); } catch (error) {}
|
|
309
|
+
} else {
|
|
310
|
+
try { token = sessionStorage.getItem(key) || ""; } catch (error) { token = ""; }
|
|
311
|
+
}
|
|
312
|
+
var cards = document.getElementById("cards");
|
|
313
|
+
var stamp = document.getElementById("stamp");
|
|
314
|
+
var reason = document.getElementById("reason");
|
|
315
|
+
var dot = document.getElementById("dot");
|
|
316
|
+
var unknown = document.getElementById("unknown");
|
|
317
|
+
function tone(value){ return value >= 100 ? "at" : value >= 80 ? "near" : ""; }
|
|
318
|
+
function clock(value){
|
|
319
|
+
if (value === null) return "no reset";
|
|
320
|
+
var when = new Date(value);
|
|
321
|
+
return isNaN(when.getTime()) ? "no reset" : "resets " + when.toLocaleString();
|
|
322
|
+
}
|
|
323
|
+
function draw(document_){
|
|
324
|
+
reason.textContent = document_.reason.toLowerCase().replace("_"," ");
|
|
325
|
+
dot.style.background = document_.reason === "AT_CAP" ? "var(--stop)"
|
|
326
|
+
: document_.reason === "NEAR_CAP" ? "var(--warn)" : "var(--accent)";
|
|
327
|
+
stamp.textContent = "Updated " + new Date(document_.generatedAt).toLocaleTimeString();
|
|
328
|
+
stamp.className = "sub";
|
|
329
|
+
cards.textContent = "";
|
|
330
|
+
document_.providers.forEach(function(entry){
|
|
331
|
+
var card = document.createElement("div");
|
|
332
|
+
card.className = "card";
|
|
333
|
+
var row = document.createElement("div");
|
|
334
|
+
row.className = "row";
|
|
335
|
+
var name = document.createElement("span");
|
|
336
|
+
name.className = "name";
|
|
337
|
+
name.textContent = entry.provider;
|
|
338
|
+
var pct = document.createElement("span");
|
|
339
|
+
pct.className = "pct";
|
|
340
|
+
pct.textContent = entry.usagePercent.toFixed(1) + "%";
|
|
341
|
+
row.appendChild(name); row.appendChild(pct);
|
|
342
|
+
var bar = document.createElement("div");
|
|
343
|
+
bar.className = "bar";
|
|
344
|
+
var fill = document.createElement("div");
|
|
345
|
+
fill.className = "fill " + tone(entry.usagePercent);
|
|
346
|
+
fill.style.width = Math.min(100, Math.max(0, entry.usagePercent)) + "%";
|
|
347
|
+
bar.appendChild(fill);
|
|
348
|
+
var meta = document.createElement("div");
|
|
349
|
+
meta.className = "meta";
|
|
350
|
+
var state = document.createElement("span");
|
|
351
|
+
state.textContent = entry.state;
|
|
352
|
+
var reset = document.createElement("span");
|
|
353
|
+
reset.textContent = clock(entry.resetAt);
|
|
354
|
+
meta.appendChild(state); meta.appendChild(reset);
|
|
355
|
+
card.appendChild(row); card.appendChild(bar); card.appendChild(meta);
|
|
356
|
+
cards.appendChild(card);
|
|
357
|
+
});
|
|
358
|
+
unknown.textContent = document_.unknown.length === 0
|
|
359
|
+
? ""
|
|
360
|
+
: "Unknown, so nothing is claimed for them: " + document_.unknown.join(", ") + ".";
|
|
361
|
+
}
|
|
362
|
+
function load(){
|
|
363
|
+
/* The token goes in a header, never in a URL, so nothing that repeats every
|
|
364
|
+
fifteen seconds can write it into a log or a history entry. */
|
|
365
|
+
fetch("/quota.json", {
|
|
366
|
+
cache: "no-store",
|
|
367
|
+
headers: { "authorization": "Bearer " + token }
|
|
368
|
+
})
|
|
369
|
+
.then(function(response){
|
|
370
|
+
if (!response.ok) throw new Error(String(response.status));
|
|
371
|
+
return response.json();
|
|
372
|
+
})
|
|
373
|
+
.then(draw)
|
|
374
|
+
.catch(function(error){
|
|
375
|
+
stamp.className = "sub err";
|
|
376
|
+
stamp.textContent = error.message === "401"
|
|
377
|
+
? "The token in this address is not valid. Scan the code again."
|
|
378
|
+
: "Cannot reach the machine running OpenLimiter.";
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
load();
|
|
382
|
+
setInterval(load, 15000);
|
|
383
|
+
})();
|
|
384
|
+
</script>
|
|
385
|
+
</body>
|
|
386
|
+
</html>
|
|
303
387
|
`;
|
|
304
388
|
}
|
|
305
389
|
/**
|
|
@@ -346,15 +430,22 @@ export async function startQuotaServer(options = {}) {
|
|
|
346
430
|
sendJson(request, response, 400, { error: "bad_request" });
|
|
347
431
|
return;
|
|
348
432
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
433
|
+
/*
|
|
434
|
+
* The shell is served before the token is looked at, and only the shell.
|
|
435
|
+
* It has to be, because the token is in the fragment and the fragment never
|
|
436
|
+
* arrives here. It carries no reading, no token and no account detail, so
|
|
437
|
+
* anyone who fetches it learns only that this command is running, which the
|
|
438
|
+
* open port already told them.
|
|
439
|
+
*/
|
|
354
440
|
if (target.pathname === "/") {
|
|
355
441
|
sendHtml(request, response, 200, mobilePage());
|
|
356
442
|
return;
|
|
357
443
|
}
|
|
444
|
+
const presented = presentedToken(request.headers.authorization, target);
|
|
445
|
+
if (presented === null || !constantTimeEquals(presented, token)) {
|
|
446
|
+
sendJson(request, response, 401, { error: "token_required" });
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
358
449
|
if (target.pathname === "/quota.json") {
|
|
359
450
|
sendJson(request, response, 200, await quotaDocument(stateDirectory, clock()));
|
|
360
451
|
return;
|
|
@@ -393,7 +484,8 @@ export async function startQuotaServer(options = {}) {
|
|
|
393
484
|
server.once("listening", onListening);
|
|
394
485
|
server.listen(port, host);
|
|
395
486
|
});
|
|
396
|
-
|
|
487
|
+
/* Fragment, not query. See TOKEN_FRAGMENT_PREFIX above for why. */
|
|
488
|
+
const suffix = "/" + TOKEN_FRAGMENT_PREFIX + token;
|
|
397
489
|
const advertised = host === "0.0.0.0" || host === "::"
|
|
398
490
|
? lanAddress() ?? "127.0.0.1"
|
|
399
491
|
: host;
|
|
@@ -401,8 +493,8 @@ export async function startQuotaServer(options = {}) {
|
|
|
401
493
|
host,
|
|
402
494
|
port: listeningPort,
|
|
403
495
|
token,
|
|
404
|
-
url: "http://" + authority(advertised, listeningPort) +
|
|
405
|
-
localUrl: "http://" + authority("127.0.0.1", listeningPort) +
|
|
496
|
+
url: "http://" + authority(advertised, listeningPort) + suffix,
|
|
497
|
+
localUrl: "http://" + authority("127.0.0.1", listeningPort) + suffix,
|
|
406
498
|
close: async () => {
|
|
407
499
|
await new Promise((resolve) => {
|
|
408
500
|
server.close(() => {
|
|
@@ -435,7 +527,7 @@ export function serveBanner(handle, options = {}) {
|
|
|
435
527
|
lines.push("The address is too long to draw as a scannable code.", "");
|
|
436
528
|
}
|
|
437
529
|
}
|
|
438
|
-
lines.push("On this machine: " + handle.localUrl, "", "Scan the code with a phone on the same network, or type the address.", "The token changes every time this command starts, and nothing answers without it.", "Read only: no route here can change anything on this machine, and no", "credential, provider payload, or account detail is ever served.", "Meant for a trusted home or office network.
|
|
530
|
+
lines.push("On this machine: " + handle.localUrl, "", "Scan the code with a phone on the same network, or type the address.", "The token changes every time this command starts, and nothing answers without it.", "The code and the address ARE the key: anyone who can see this screen, or a", "photograph of it, can read your quota for as long as this command runs.", "Read only: no route here can change anything on this machine, and no", "credential, provider payload, or account detail is ever served.", "Meant for a trusted home or office network. This listens on every interface", "on this machine, so do not port forward this port and do not open it on a", "firewall: nothing but your router's default is keeping it off the internet.", "", "Press Ctrl C to stop.");
|
|
439
531
|
return lines.join("\n");
|
|
440
532
|
}
|
|
441
533
|
//# sourceMappingURL=serve.js.map
|
package/dist/serve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,YAAY,EAIb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,WAAW,EACX,aAAa,EACb,UAAU,EACV,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEvC,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,sEAAsE;AACtE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAE9B,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC,uDAAuD;AACvD,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,4E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,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAClC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;oBAChB,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC/B,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AASD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,MAAyB,EACzB,UAA8B,EAAE;IAEhC,MAAM,KAAK,GAAG;QACZ,+DAA+D;QAC/D,EAAE;QACF,IAAI,GAAG,MAAM,CAAC,GAAG;QACjB,EAAE;KACH,CAAC;IACF,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC;YACH,KAAK,CAAC,IAAI,CACR,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK,EAAE,CAAC,EACjE,EAAE,CACH,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,KAAK,CAAC,IAAI,CAAC,sDAAsD,EAAE,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IACD,KAAK,CAAC,IAAI,CACR,mBAAmB,GAAG,MAAM,CAAC,QAAQ,EACrC,EAAE,EACF,sEAAsE,EACtE,mFAAmF,EACnF,4EAA4E,EAC5E,yEAAyE,EACzE,sEAAsE,EACtE,iEAAiE,EACjE,6EAA6E,EAC7E,2EAA2E,EAC3E,6EAA6E,EAC7E,EAAE,EACF,uBAAuB,CACxB,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type Advice, type ProviderCode, type Snapshot } from "@openlimiter/core";
|
|
2
|
+
import type { StatuslineColor, StatuslineConfig } from "./config.js";
|
|
3
|
+
export declare const DEFAULT_PROVIDER_ORDER: readonly ProviderCode[];
|
|
4
|
+
/**
|
|
5
|
+
* The order the configured ids ask for, completed by the built in order.
|
|
6
|
+
*
|
|
7
|
+
* An id this version does not know, and an id named twice, are both dropped
|
|
8
|
+
* rather than rejected. This runs on every redraw of somebody else's status
|
|
9
|
+
* row; a stale provider id left in a configuration file is not a reason to
|
|
10
|
+
* stop drawing the providers that are still there.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveProviderOrder(configured: readonly string[]): readonly ProviderCode[];
|
|
13
|
+
export type MeterClass = "session" | "daily" | "weekly" | "monthly" | "credits" | "other";
|
|
14
|
+
/**
|
|
15
|
+
* Which kind of window a reading measures.
|
|
16
|
+
*
|
|
17
|
+
* The window's own duration decides it wherever a connector states one,
|
|
18
|
+
* because a duration is a fact and a name is a label. The name table is the
|
|
19
|
+
* fallback for the connectors that state a window kind and no length.
|
|
20
|
+
*/
|
|
21
|
+
export declare function meterClass(snapshot: Snapshot): MeterClass;
|
|
22
|
+
export interface StatuslineCell {
|
|
23
|
+
/** The cell with no escape codes, which is what the width budget measures. */
|
|
24
|
+
readonly plain: string;
|
|
25
|
+
/** The cell as printed, painted when colour is allowed. */
|
|
26
|
+
readonly painted: string;
|
|
27
|
+
/** The reading behind it, which decides what survives when cells are shed. */
|
|
28
|
+
readonly percent: number;
|
|
29
|
+
}
|
|
30
|
+
/** Two spaces between cells, so a reader can tell one cell from the next. */
|
|
31
|
+
export declare const CELL_GAP = " ";
|
|
32
|
+
/**
|
|
33
|
+
* One cell per provider, or one per meter.
|
|
34
|
+
*
|
|
35
|
+
* The filter is the same one the advice policy uses, so the cells and the
|
|
36
|
+
* reason code leading them are always describing the same set of readings. A
|
|
37
|
+
* provider with several meters shows its worst one, because a status row exists
|
|
38
|
+
* to tell you what is about to stop you, and the meter closest to its cap is
|
|
39
|
+
* that. The full set is one `openlimiter snapshot` away, and `meters all` puts
|
|
40
|
+
* it back in the row for anyone who wants it there.
|
|
41
|
+
*
|
|
42
|
+
* `wide` is the terminal's 256 colour claim, handed straight to the shared bar
|
|
43
|
+
* so a statusline cell and a table row draw the same reading in the same band
|
|
44
|
+
* colour. Left off, the bar reads the environment for itself.
|
|
45
|
+
*/
|
|
46
|
+
export declare function statuslineCells(snapshots: readonly Snapshot[], now: string, order: readonly ProviderCode[], meters: StatuslineConfig["meters"], color: boolean, wide?: boolean): readonly StatuslineCell[];
|
|
47
|
+
/**
|
|
48
|
+
* Everything that is not a cell.
|
|
49
|
+
*
|
|
50
|
+
* The reason code, the recommendation and the unknown list are the same three
|
|
51
|
+
* fields the 0.1.0 line carried and they carry the same words, moved to the
|
|
52
|
+
* front so that the row can end wherever the cells end. They are never wrapped
|
|
53
|
+
* and never dropped: a row of bars with no verdict in front of it is a picture,
|
|
54
|
+
* not a status.
|
|
55
|
+
*/
|
|
56
|
+
export declare function statuslineHead(advice: Advice): string;
|
|
57
|
+
export interface StatuslineLayoutInput {
|
|
58
|
+
advice: Advice;
|
|
59
|
+
snapshots: readonly Snapshot[];
|
|
60
|
+
now: string;
|
|
61
|
+
config: StatuslineConfig;
|
|
62
|
+
color: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the host terminal claims a 256 colour palette.
|
|
65
|
+
*
|
|
66
|
+
* Only the orange band at 80 depends on it, and only a test ever states it.
|
|
67
|
+
* Left off, the bar asks the environment, which is the right answer for every
|
|
68
|
+
* caller that is a real terminal or a statusline host standing in for one.
|
|
69
|
+
*/
|
|
70
|
+
wide?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** What the statusline says when it has nothing bounded to say. */
|
|
73
|
+
export declare const STATUSLINE_UNKNOWN = "OpenLimiter UNKNOWN";
|
|
74
|
+
/**
|
|
75
|
+
* Draw the whole line, stacking it rather than truncating it.
|
|
76
|
+
*
|
|
77
|
+
* The budget is a budget, not a terminal measurement: nothing here asks the
|
|
78
|
+
* operating system how wide the window is, because a statusline host runs this
|
|
79
|
+
* command with no terminal attached and the answer would be an invention. The
|
|
80
|
+
* number in the configuration is the number that is honoured.
|
|
81
|
+
*/
|
|
82
|
+
export declare function renderStatuslineLayout(input: StatuslineLayoutInput): string;
|
|
83
|
+
/**
|
|
84
|
+
* Whether this render may paint.
|
|
85
|
+
*
|
|
86
|
+
* `NO_COLOR` wins over every setting, including `always`. It is the one
|
|
87
|
+
* convention a person can set once, for every tool on the machine, and a
|
|
88
|
+
* configuration file inside one tool is not the place to overrule it.
|
|
89
|
+
*/
|
|
90
|
+
export declare function statuslineColor(setting: StatuslineColor, environment: Readonly<Record<string, string | undefined>>, automatic: boolean): boolean;
|
|
91
|
+
//# sourceMappingURL=statusline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusline.d.ts","sourceRoot":"","sources":["../src/statusline.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA2CrE,eAAO,MAAM,sBAAsB,EAAE,SAAS,YAAY,EAGzD,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,SAAS,YAAY,EAAE,CAazB;AAID,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,OAAO,GACP,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAyCZ;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAazD;AAID,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,6EAA6E;AAC7E,eAAO,M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