@selvajs/cli 4.20.0 → 4.20.1-beta.1
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/package.json +1 -1
- package/src/checks/config.js +1 -1
- package/src/env-migration.js +1 -1
- package/src/generated/config.js +255 -177
package/package.json
CHANGED
package/src/checks/config.js
CHANGED
|
@@ -365,7 +365,7 @@ export function checkKeyRotation(env, now = Date.now()) {
|
|
|
365
365
|
if (state === 'expired') {
|
|
366
366
|
return [
|
|
367
367
|
yellow(
|
|
368
|
-
`${previous}
|
|
368
|
+
`${previous} is no longer accepted: its deadline (${expires}) has passed, is not an ISO date or is too far out. ` +
|
|
369
369
|
`Remove it: npx selva keys rotate ${target} --finish`
|
|
370
370
|
)
|
|
371
371
|
];
|
package/src/env-migration.js
CHANGED
|
@@ -48,7 +48,7 @@ function canonical(value) {
|
|
|
48
48
|
function meaning(spec, env, { legacy }) {
|
|
49
49
|
if (EFFECTIVE[spec.key]) return EFFECTIVE[spec.key](env);
|
|
50
50
|
const name = [spec.key, ...(spec.aliases ?? [])].find(
|
|
51
|
-
(k) => env[k] !== undefined && env[k] !== ''
|
|
51
|
+
(k) => env[k] !== undefined && env[k].trim() !== ''
|
|
52
52
|
);
|
|
53
53
|
if (name === undefined) return spec.default;
|
|
54
54
|
const raw = env[name];
|
package/src/generated/config.js
CHANGED
|
@@ -18,6 +18,41 @@ function composeManifest(parts) {
|
|
|
18
18
|
}
|
|
19
19
|
return out;
|
|
20
20
|
}
|
|
21
|
+
// ../platform/src/utils/trim.ts
|
|
22
|
+
function trimTrailing(s, ch) {
|
|
23
|
+
let end = s.length;
|
|
24
|
+
while (end > 0 && s[end - 1] === ch) end--;
|
|
25
|
+
return s.slice(0, end);
|
|
26
|
+
}
|
|
27
|
+
// ../platform/src/computeServer/key32.ts
|
|
28
|
+
/**
|
|
29
|
+
* A 32-byte key written as 64 hex characters or base64 (padding optional), or
|
|
30
|
+
* null. No `node:crypto` here: the config boot check imports this too.
|
|
31
|
+
*/
|
|
32
|
+
function parseKey32(raw) {
|
|
33
|
+
const key = raw.trim();
|
|
34
|
+
if (/^[0-9a-fA-F]{64}$/.test(key)) return Buffer.from(key, 'hex');
|
|
35
|
+
const buf = Buffer.from(key, 'base64');
|
|
36
|
+
return buf.length === 32 && trimTrailing(buf.toString('base64'), '=') === trimTrailing(key, '=')
|
|
37
|
+
? buf
|
|
38
|
+
: null;
|
|
39
|
+
}
|
|
40
|
+
// ../platform/src/config/raw-value.ts
|
|
41
|
+
/**
|
|
42
|
+
* The text a setting reads and the name it came from: its own key, else the
|
|
43
|
+
* first alias that is set. Blank counts as unset, so a `KEY=` line with stray
|
|
44
|
+
* spaces can't hide an alias or pass a required key as an empty string.
|
|
45
|
+
*/
|
|
46
|
+
function rawValue(spec, env) {
|
|
47
|
+
for (const name of [spec.key, ...(spec.aliases ?? [])]) {
|
|
48
|
+
const raw = env[name];
|
|
49
|
+
if (raw !== void 0 && raw.trim() !== '')
|
|
50
|
+
return {
|
|
51
|
+
name,
|
|
52
|
+
raw
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
21
56
|
// ../platform/src/config/resolve.ts
|
|
22
57
|
var TRUE = /* @__PURE__ */ new Set(['true', '1', 'yes', 'on']);
|
|
23
58
|
var FALSE = /* @__PURE__ */ new Set(['false', '0', 'no', 'off']);
|
|
@@ -35,7 +70,7 @@ function parse(spec, raw) {
|
|
|
35
70
|
value: v
|
|
36
71
|
};
|
|
37
72
|
case 'key':
|
|
38
|
-
return
|
|
73
|
+
return parseKey32(v)
|
|
39
74
|
? {
|
|
40
75
|
ok: true,
|
|
41
76
|
value: v
|
|
@@ -44,26 +79,45 @@ function parse(spec, raw) {
|
|
|
44
79
|
ok: false,
|
|
45
80
|
problem: 'must be 32 bytes as 64 hex characters or base64'
|
|
46
81
|
};
|
|
47
|
-
case 'url':
|
|
82
|
+
case 'url': {
|
|
83
|
+
const value = trimTrailing(v, '/');
|
|
84
|
+
let url;
|
|
48
85
|
try {
|
|
49
|
-
new URL(
|
|
50
|
-
return {
|
|
51
|
-
ok: true,
|
|
52
|
-
value: v.replace(/\/+$/, '')
|
|
53
|
-
};
|
|
86
|
+
url = new URL(value);
|
|
54
87
|
} catch {
|
|
55
88
|
return {
|
|
56
89
|
ok: false,
|
|
57
90
|
problem: 'must be an absolute URL'
|
|
58
91
|
};
|
|
59
92
|
}
|
|
93
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:')
|
|
94
|
+
return {
|
|
95
|
+
ok: false,
|
|
96
|
+
problem: 'must start with http:// or https://'
|
|
97
|
+
};
|
|
98
|
+
if (spec.origin && (url.username || url.password || url.pathname !== '/' || /[?#]/.test(v)))
|
|
99
|
+
return {
|
|
100
|
+
ok: false,
|
|
101
|
+
problem:
|
|
102
|
+
'must be an origin such as https://selva.example.com: no path, query or credentials'
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
ok: true,
|
|
106
|
+
value
|
|
107
|
+
};
|
|
108
|
+
}
|
|
60
109
|
case 'int': {
|
|
61
|
-
|
|
62
|
-
if (!Number.isInteger(n))
|
|
110
|
+
if (!/^[+-]?\d+$/.test(v))
|
|
63
111
|
return {
|
|
64
112
|
ok: false,
|
|
65
113
|
problem: 'must be a whole number'
|
|
66
114
|
};
|
|
115
|
+
const n = Number(v);
|
|
116
|
+
if (!Number.isSafeInteger(n))
|
|
117
|
+
return {
|
|
118
|
+
ok: false,
|
|
119
|
+
problem: 'is too large'
|
|
120
|
+
};
|
|
67
121
|
if (spec.min !== void 0 && n < spec.min)
|
|
68
122
|
return {
|
|
69
123
|
ok: false,
|
|
@@ -76,7 +130,7 @@ function parse(spec, raw) {
|
|
|
76
130
|
};
|
|
77
131
|
return {
|
|
78
132
|
ok: true,
|
|
79
|
-
value: n
|
|
133
|
+
value: n === 0 ? 0 : n
|
|
80
134
|
};
|
|
81
135
|
}
|
|
82
136
|
case 'bool': {
|
|
@@ -119,11 +173,6 @@ function parse(spec, raw) {
|
|
|
119
173
|
};
|
|
120
174
|
}
|
|
121
175
|
}
|
|
122
|
-
function isKey32(v) {
|
|
123
|
-
if (/^[0-9a-fA-F]{64}$/.test(v)) return true;
|
|
124
|
-
const buf = Buffer.from(v, 'base64');
|
|
125
|
-
return buf.length === 32 && buf.toString('base64').replace(/=+$/, '') === v.replace(/=+$/, '');
|
|
126
|
-
}
|
|
127
176
|
/** What `raw` meant to the reader before it parsed strictly. */
|
|
128
177
|
function legacyValue(spec, raw) {
|
|
129
178
|
const legacy = spec.legacy;
|
|
@@ -135,54 +184,51 @@ function legacyValue(spec, raw) {
|
|
|
135
184
|
return parsed.ok ? parsed.value : void 0;
|
|
136
185
|
}
|
|
137
186
|
function resolveKey(spec, env) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const base = {
|
|
147
|
-
key: spec.key,
|
|
148
|
-
spec,
|
|
149
|
-
...(alias ? { alias } : {})
|
|
150
|
-
};
|
|
151
|
-
if (raw === void 0) {
|
|
187
|
+
const found = rawValue(spec, env);
|
|
188
|
+
if (!found) {
|
|
189
|
+
const source = spec.default !== void 0 ? 'default' : 'unset';
|
|
190
|
+
const base = {
|
|
191
|
+
key: spec.key,
|
|
192
|
+
spec,
|
|
193
|
+
source
|
|
194
|
+
};
|
|
152
195
|
if (spec.required)
|
|
153
196
|
return {
|
|
154
197
|
...base,
|
|
155
|
-
source,
|
|
156
198
|
status: 'error',
|
|
157
199
|
value: void 0,
|
|
158
200
|
problem: 'is required'
|
|
159
201
|
};
|
|
160
202
|
return {
|
|
161
203
|
...base,
|
|
162
|
-
source,
|
|
163
204
|
status: 'ok',
|
|
164
205
|
value: spec.default
|
|
165
206
|
};
|
|
166
207
|
}
|
|
167
|
-
const
|
|
208
|
+
const alias = found.name === spec.key ? void 0 : found.name;
|
|
209
|
+
const source = alias ? 'alias' : 'env';
|
|
210
|
+
const base = {
|
|
211
|
+
key: spec.key,
|
|
212
|
+
spec,
|
|
213
|
+
source,
|
|
214
|
+
...(alias ? { alias } : {})
|
|
215
|
+
};
|
|
216
|
+
const parsed = parse(spec, found.raw);
|
|
168
217
|
if (parsed.ok)
|
|
169
218
|
return {
|
|
170
219
|
...base,
|
|
171
|
-
source,
|
|
172
220
|
status: 'ok',
|
|
173
221
|
value: parsed.value
|
|
174
222
|
};
|
|
175
223
|
if (spec.onInvalid === 'fail')
|
|
176
224
|
return {
|
|
177
225
|
...base,
|
|
178
|
-
source,
|
|
179
226
|
status: 'error',
|
|
180
227
|
value: void 0,
|
|
181
228
|
problem: parsed.problem
|
|
182
229
|
};
|
|
183
230
|
return {
|
|
184
231
|
...base,
|
|
185
|
-
source,
|
|
186
232
|
status: 'invalid',
|
|
187
233
|
value: spec.default,
|
|
188
234
|
problem: parsed.problem
|
|
@@ -257,7 +303,6 @@ function buildConfigReport(manifest, env, options = {}) {
|
|
|
257
303
|
const resolved = resolveConfig(manifest, env, options);
|
|
258
304
|
const rows = manifest.map((spec) => {
|
|
259
305
|
const k = resolved.keys[spec.key];
|
|
260
|
-
const raw = k.source === 'alias' ? env[k.alias] : env[spec.key];
|
|
261
306
|
return {
|
|
262
307
|
key: spec.key,
|
|
263
308
|
...(spec.label ? { label: spec.label } : {}),
|
|
@@ -271,7 +316,7 @@ function buildConfigReport(manifest, env, options = {}) {
|
|
|
271
316
|
...(spec.impact ? { impact: spec.impact } : {}),
|
|
272
317
|
source: k.source,
|
|
273
318
|
status: k.status,
|
|
274
|
-
display: display(spec
|
|
319
|
+
display: display(spec, k, rawValue(spec, env)?.raw),
|
|
275
320
|
...(k.problem ? { problem: k.problem } : {}),
|
|
276
321
|
...(k.alias ? { alias: k.alias } : {})
|
|
277
322
|
};
|
|
@@ -282,12 +327,11 @@ function buildConfigReport(manifest, env, options = {}) {
|
|
|
282
327
|
unknown: resolved.unknown
|
|
283
328
|
};
|
|
284
329
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
if (
|
|
288
|
-
if (sensitive) return 'set';
|
|
289
|
-
|
|
290
|
-
return raw.trim();
|
|
330
|
+
/** `raw` is the env text the value came from, undefined when it is the default. */
|
|
331
|
+
function display(spec, k, raw) {
|
|
332
|
+
if (k.source === 'unset') return '';
|
|
333
|
+
if (spec.sensitive) return raw !== void 0 && spec.generated ? fingerprint(raw) : 'set';
|
|
334
|
+
return raw === void 0 ? formatValue(k.value) : raw.trim();
|
|
291
335
|
}
|
|
292
336
|
function formatValue(value) {
|
|
293
337
|
if (Array.isArray(value)) return value.join(',');
|
|
@@ -298,29 +342,36 @@ function fingerprint(value) {
|
|
|
298
342
|
return `sha256:${createHash('sha256').update(value.trim()).digest('hex').slice(0, 8)}`;
|
|
299
343
|
}
|
|
300
344
|
// ../platform/src/config/snapshot.ts
|
|
301
|
-
|
|
345
|
+
var SENSITIVE_MARKER = 'set';
|
|
346
|
+
function takeSnapshot(manifest, env, salt) {
|
|
347
|
+
const key = typeof salt === 'string' && salt !== '' ? salt : randomBytes(16).toString('hex');
|
|
302
348
|
const values = {};
|
|
303
349
|
const sensitive = [];
|
|
304
350
|
for (const spec of manifest) {
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
);
|
|
308
|
-
if (name === void 0) continue;
|
|
309
|
-
const raw = env[name].trim();
|
|
351
|
+
const found = rawValue(spec, env);
|
|
352
|
+
if (!found) continue;
|
|
353
|
+
const raw = found.raw.trim();
|
|
310
354
|
if (spec.sensitive) {
|
|
311
|
-
values[spec.key] =
|
|
355
|
+
values[spec.key] = spec.generated
|
|
356
|
+
? createHmac('sha256', key).update(raw).digest('hex').slice(0, 16)
|
|
357
|
+
: SENSITIVE_MARKER;
|
|
312
358
|
sensitive.push(spec.key);
|
|
313
359
|
} else values[spec.key] = raw;
|
|
314
360
|
}
|
|
315
361
|
return {
|
|
316
362
|
version: 1,
|
|
317
|
-
salt,
|
|
363
|
+
salt: key,
|
|
318
364
|
values,
|
|
319
365
|
sensitive
|
|
320
366
|
};
|
|
321
367
|
}
|
|
322
|
-
/**
|
|
368
|
+
/**
|
|
369
|
+
* What changed since `before`, the previous snapshot as read from disk; anything
|
|
370
|
+
* that is not a snapshot counts as none. Take `after` with `before.salt`, or every
|
|
371
|
+
* generated key reads as changed.
|
|
372
|
+
*/
|
|
323
373
|
function diffSnapshots(before, after) {
|
|
374
|
+
if (!isSnapshot(before)) return [];
|
|
324
375
|
const secret = /* @__PURE__ */ new Set([...before.sensitive, ...after.sensitive]);
|
|
325
376
|
const changes = [];
|
|
326
377
|
const plain = (key, from, to) =>
|
|
@@ -354,9 +405,25 @@ function diffSnapshots(before, after) {
|
|
|
354
405
|
});
|
|
355
406
|
return changes;
|
|
356
407
|
}
|
|
408
|
+
function isSnapshot(value) {
|
|
409
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
410
|
+
const { version, salt, values, sensitive } = value;
|
|
411
|
+
return (
|
|
412
|
+
version === 1 &&
|
|
413
|
+
typeof salt === 'string' &&
|
|
414
|
+
salt !== '' &&
|
|
415
|
+
typeof values === 'object' &&
|
|
416
|
+
values !== null &&
|
|
417
|
+
!Array.isArray(values) &&
|
|
418
|
+
Object.values(values).every((v) => typeof v === 'string') &&
|
|
419
|
+
Array.isArray(sensitive) &&
|
|
420
|
+
sensitive.every((k) => typeof k === 'string')
|
|
421
|
+
);
|
|
422
|
+
}
|
|
357
423
|
// ../platform/src/config/previous-key.ts
|
|
358
424
|
/** How long `selva keys rotate` keeps the previous key accepted. */
|
|
359
425
|
var PREVIOUS_KEY_DAYS = 30;
|
|
426
|
+
var MAX_DEADLINE_DAYS = 90;
|
|
360
427
|
var DAY_MS = 864e5;
|
|
361
428
|
/**
|
|
362
429
|
* The previous key for `base` (`SELVA_HMAC_KEY` or `SELVA_AT_REST_KEY`), if it
|
|
@@ -372,8 +439,8 @@ function previousKey(env, base, now = Date.now()) {
|
|
|
372
439
|
state: 'no-deadline',
|
|
373
440
|
key
|
|
374
441
|
};
|
|
375
|
-
const at =
|
|
376
|
-
if (
|
|
442
|
+
const at = parseDeadline(expires);
|
|
443
|
+
if (at === null || at <= now || at - now > MAX_DEADLINE_DAYS * DAY_MS)
|
|
377
444
|
return {
|
|
378
445
|
state: 'expired',
|
|
379
446
|
expires
|
|
@@ -385,32 +452,34 @@ function previousKey(env, base, now = Date.now()) {
|
|
|
385
452
|
daysLeft: Math.ceil((at - now) / DAY_MS)
|
|
386
453
|
};
|
|
387
454
|
}
|
|
388
|
-
|
|
455
|
+
var ISO_DEADLINE =
|
|
456
|
+
/^(\d{4})-(\d{2})-(\d{2})(?:T([01]\d|2[0-3]):([0-5]\d)(?::([0-5]\d)(\.\d+)?)?(Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)?)?$/;
|
|
389
457
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* The app wires a real logger at its composition root; a consumer that wires
|
|
393
|
-
* nothing gets silence rather than unsolicited stdout writes.
|
|
458
|
+
* `YYYY-MM-DD`, or an ISO timestamp, UTC unless it names an offset. Not
|
|
459
|
+
* `Date.parse`: it reads `12.1.2027` as 1 December and rolls `2026-11-31` over.
|
|
394
460
|
*/
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
461
|
+
function parseDeadline(text) {
|
|
462
|
+
const m = ISO_DEADLINE.exec(text);
|
|
463
|
+
if (!m) return null;
|
|
464
|
+
const [, year, month, day, hour = '0', minute = '0', second = '0', fraction = '', zone = 'Z'] = m;
|
|
465
|
+
const midnight = Date.UTC(Number(year), Number(month) - 1, Number(day));
|
|
466
|
+
const date = new Date(midnight);
|
|
467
|
+
if (
|
|
468
|
+
date.getUTCFullYear() !== Number(year) ||
|
|
469
|
+
date.getUTCMonth() !== Number(month) - 1 ||
|
|
470
|
+
date.getUTCDate() !== Number(day)
|
|
471
|
+
)
|
|
472
|
+
return null;
|
|
473
|
+
const offsetMinutes =
|
|
474
|
+
zone === 'Z'
|
|
475
|
+
? 0
|
|
476
|
+
: (zone.startsWith('-') ? -1 : 1) * (Number(zone.slice(1, 3)) * 60 + Number(zone.slice(4)));
|
|
477
|
+
return (
|
|
478
|
+
midnight +
|
|
479
|
+
((Number(hour) * 60 + Number(minute) - offsetMinutes) * 60 + Number(second)) * 1e3 +
|
|
480
|
+
Math.floor(Number(`0${fraction}`) * 1e3)
|
|
481
|
+
);
|
|
482
|
+
}
|
|
414
483
|
// ../server/src/config/settings.ts
|
|
415
484
|
var flag = (key, label, description, impact) =>
|
|
416
485
|
defineSetting({
|
|
@@ -436,6 +505,95 @@ var tunableInt = (key, fallback, label, description, extra = {}) =>
|
|
|
436
505
|
...extra
|
|
437
506
|
});
|
|
438
507
|
var MB = 1048576;
|
|
508
|
+
var SIGN_IN_MAX_AGE_SETTING = defineSetting({
|
|
509
|
+
key: 'SIGN_IN_MAX_AGE_DAYS',
|
|
510
|
+
label: 'Force sign-in again after',
|
|
511
|
+
type: 'int',
|
|
512
|
+
min: 0,
|
|
513
|
+
default: 0,
|
|
514
|
+
onInvalid: 'fail',
|
|
515
|
+
class: 'setting',
|
|
516
|
+
summary: true,
|
|
517
|
+
zero: 'Never',
|
|
518
|
+
unit: 'days',
|
|
519
|
+
description: 'Days before users must sign in at the identity provider again. 0 is never.',
|
|
520
|
+
impact: 'API tokens of anyone who has not signed in within this many days are revoked.'
|
|
521
|
+
});
|
|
522
|
+
var COMPUTE_LIMIT_SETTINGS = composeManifest([
|
|
523
|
+
tunableInt(
|
|
524
|
+
'COMPUTE_RATE_LIMIT_MAX',
|
|
525
|
+
120,
|
|
526
|
+
'Solves per window',
|
|
527
|
+
'Solves per user or share link per 100-second window.'
|
|
528
|
+
),
|
|
529
|
+
tunableInt('MAX_DEFINITION_FILE_SIZE_BYTES', 50 * MB, 'Max .gh upload', 'Largest .gh upload.', {
|
|
530
|
+
unit: 'bytes'
|
|
531
|
+
}),
|
|
532
|
+
tunableInt(
|
|
533
|
+
'COMPUTE_MAX_QUEUE_DEPTH',
|
|
534
|
+
0,
|
|
535
|
+
'Solve queue length',
|
|
536
|
+
'Solves allowed to wait per compute server. 0 is unbounded.',
|
|
537
|
+
{
|
|
538
|
+
min: 0,
|
|
539
|
+
zero: 'No limit'
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
tunableInt(
|
|
543
|
+
'COMPUTE_QUEUE_WAIT_MS',
|
|
544
|
+
0,
|
|
545
|
+
'Max queue wait',
|
|
546
|
+
'Longest a solve may wait queued. 0 is no deadline.',
|
|
547
|
+
{
|
|
548
|
+
min: 0,
|
|
549
|
+
unit: 'ms',
|
|
550
|
+
zero: 'No limit'
|
|
551
|
+
}
|
|
552
|
+
),
|
|
553
|
+
tunableInt(
|
|
554
|
+
'COMPUTE_DEFINITION_CACHE_MB',
|
|
555
|
+
256,
|
|
556
|
+
'Definition cache size',
|
|
557
|
+
'Definition cache budget. 0 turns it off.',
|
|
558
|
+
{
|
|
559
|
+
min: 0,
|
|
560
|
+
unit: 'mb',
|
|
561
|
+
zero: 'Off',
|
|
562
|
+
aliases: ['COMPUTE_DEFINITION_BYTE_CACHE_MB']
|
|
563
|
+
}
|
|
564
|
+
),
|
|
565
|
+
tunableInt(
|
|
566
|
+
'COMPUTE_SOLVE_CACHE_MB',
|
|
567
|
+
256,
|
|
568
|
+
'Solve cache size',
|
|
569
|
+
'Solve cache budget per warm compute server. 0 turns it off.',
|
|
570
|
+
{
|
|
571
|
+
min: 0,
|
|
572
|
+
unit: 'mb',
|
|
573
|
+
zero: 'Off',
|
|
574
|
+
aliases: ['COMPUTE_RESPONSE_CACHE_MB']
|
|
575
|
+
}
|
|
576
|
+
),
|
|
577
|
+
defineSetting({
|
|
578
|
+
key: 'COMPUTE_SERVER_CACHESOLVE',
|
|
579
|
+
label: 'Compute server solve cache',
|
|
580
|
+
type: 'bool',
|
|
581
|
+
default: true,
|
|
582
|
+
onInvalid: 'default',
|
|
583
|
+
class: 'tunable',
|
|
584
|
+
description: 'Ask Rhino.Compute to cache solve results server-side.'
|
|
585
|
+
})
|
|
586
|
+
]);
|
|
587
|
+
var API_TOKEN_RATE_LIMIT_SETTING = tunableInt(
|
|
588
|
+
'API_TOKEN_RATE_LIMIT_MAX',
|
|
589
|
+
600,
|
|
590
|
+
'API requests per minute',
|
|
591
|
+
'Requests per API token per minute. 0 is off.',
|
|
592
|
+
{
|
|
593
|
+
min: 0,
|
|
594
|
+
zero: 'Off'
|
|
595
|
+
}
|
|
596
|
+
);
|
|
439
597
|
var ENGINE_SETTINGS = composeManifest([
|
|
440
598
|
...[
|
|
441
599
|
[
|
|
@@ -575,20 +733,7 @@ var ENGINE_SETTINGS = composeManifest([
|
|
|
575
733
|
description:
|
|
576
734
|
'While no instance admin exists, only this address may become one. For first setup and lockouts.'
|
|
577
735
|
}),
|
|
578
|
-
|
|
579
|
-
key: 'SIGN_IN_MAX_AGE_DAYS',
|
|
580
|
-
label: 'Force sign-in again after',
|
|
581
|
-
type: 'int',
|
|
582
|
-
min: 0,
|
|
583
|
-
default: 0,
|
|
584
|
-
onInvalid: 'fail',
|
|
585
|
-
class: 'setting',
|
|
586
|
-
summary: true,
|
|
587
|
-
zero: 'Never',
|
|
588
|
-
unit: 'days',
|
|
589
|
-
description: 'Days before users must sign in at the identity provider again. 0 is never.',
|
|
590
|
-
impact: 'API tokens of anyone who has not signed in within this many days are revoked.'
|
|
591
|
-
}),
|
|
736
|
+
SIGN_IN_MAX_AGE_SETTING,
|
|
592
737
|
flag('ALLOW_ORG_CREATION', 'Users create orgs', 'Self-service org creation (read by host apps).'),
|
|
593
738
|
flag(
|
|
594
739
|
'ALLOW_CROSS_ORG_PUBLIC',
|
|
@@ -682,79 +827,8 @@ var ENGINE_SETTINGS = composeManifest([
|
|
|
682
827
|
description: 'Override the TLS mode inferred from the port.',
|
|
683
828
|
legacy: { bool: 'exact-true' }
|
|
684
829
|
}),
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
120,
|
|
688
|
-
'Solves per window',
|
|
689
|
-
'Solves per user or share link per 100-second window.'
|
|
690
|
-
),
|
|
691
|
-
tunableInt('MAX_DEFINITION_FILE_SIZE_BYTES', 50 * MB, 'Max .gh upload', 'Largest .gh upload.', {
|
|
692
|
-
unit: 'bytes'
|
|
693
|
-
}),
|
|
694
|
-
tunableInt(
|
|
695
|
-
'COMPUTE_MAX_QUEUE_DEPTH',
|
|
696
|
-
0,
|
|
697
|
-
'Solve queue length',
|
|
698
|
-
'Solves allowed to wait per compute server. 0 is unbounded.',
|
|
699
|
-
{
|
|
700
|
-
min: 0,
|
|
701
|
-
zero: 'No limit'
|
|
702
|
-
}
|
|
703
|
-
),
|
|
704
|
-
tunableInt(
|
|
705
|
-
'COMPUTE_QUEUE_WAIT_MS',
|
|
706
|
-
0,
|
|
707
|
-
'Max queue wait',
|
|
708
|
-
'Longest a solve may wait queued. 0 is no deadline.',
|
|
709
|
-
{
|
|
710
|
-
min: 0,
|
|
711
|
-
unit: 'ms',
|
|
712
|
-
zero: 'No limit'
|
|
713
|
-
}
|
|
714
|
-
),
|
|
715
|
-
tunableInt(
|
|
716
|
-
'COMPUTE_DEFINITION_CACHE_MB',
|
|
717
|
-
256,
|
|
718
|
-
'Definition cache size',
|
|
719
|
-
'Definition cache budget. 0 turns it off.',
|
|
720
|
-
{
|
|
721
|
-
min: 0,
|
|
722
|
-
unit: 'mb',
|
|
723
|
-
zero: 'Off',
|
|
724
|
-
aliases: ['COMPUTE_DEFINITION_BYTE_CACHE_MB']
|
|
725
|
-
}
|
|
726
|
-
),
|
|
727
|
-
tunableInt(
|
|
728
|
-
'COMPUTE_SOLVE_CACHE_MB',
|
|
729
|
-
256,
|
|
730
|
-
'Solve cache size',
|
|
731
|
-
'Solve cache budget per warm compute server. 0 turns it off.',
|
|
732
|
-
{
|
|
733
|
-
min: 0,
|
|
734
|
-
unit: 'mb',
|
|
735
|
-
zero: 'Off',
|
|
736
|
-
aliases: ['COMPUTE_RESPONSE_CACHE_MB']
|
|
737
|
-
}
|
|
738
|
-
),
|
|
739
|
-
defineSetting({
|
|
740
|
-
key: 'COMPUTE_SERVER_CACHESOLVE',
|
|
741
|
-
label: 'Compute server solve cache',
|
|
742
|
-
type: 'bool',
|
|
743
|
-
default: true,
|
|
744
|
-
onInvalid: 'default',
|
|
745
|
-
class: 'tunable',
|
|
746
|
-
description: 'Ask Rhino.Compute to cache solve results server-side.'
|
|
747
|
-
}),
|
|
748
|
-
tunableInt(
|
|
749
|
-
'API_TOKEN_RATE_LIMIT_MAX',
|
|
750
|
-
DEFAULT_API_RATE_LIMIT.maxPerWindow,
|
|
751
|
-
'API requests per minute',
|
|
752
|
-
'Requests per API token per minute. 0 is off.',
|
|
753
|
-
{
|
|
754
|
-
min: 0,
|
|
755
|
-
zero: 'Off'
|
|
756
|
-
}
|
|
757
|
-
)
|
|
830
|
+
COMPUTE_LIMIT_SETTINGS,
|
|
831
|
+
API_TOKEN_RATE_LIMIT_SETTING
|
|
758
832
|
]);
|
|
759
833
|
// ../providers/header-auth/src/config.ts
|
|
760
834
|
var header = (key, fallback, slot) =>
|
|
@@ -895,12 +969,24 @@ var SUPABASE_SETTINGS = composeManifest([
|
|
|
895
969
|
})
|
|
896
970
|
]);
|
|
897
971
|
// src/lib/server/config/settings.ts
|
|
972
|
+
var COMPUTE_DEBUG = defineSetting({
|
|
973
|
+
key: 'SELVA_FLAG_COMPUTE_DEBUG',
|
|
974
|
+
label: 'Compute debug logging',
|
|
975
|
+
type: 'string',
|
|
976
|
+
default: 'off',
|
|
977
|
+
onInvalid: 'default',
|
|
978
|
+
class: 'setting',
|
|
979
|
+
description:
|
|
980
|
+
'off, on (cache and timing lines per solve) or verbose (adds Compute’s raw error bodies).',
|
|
981
|
+
impact: 'verbose can write what was solved to the log, which erasure cannot reach.'
|
|
982
|
+
});
|
|
898
983
|
/** Keys only this app reads. adapter-node's own keys are here too: they decide whether it works. */
|
|
899
984
|
var APP_SETTINGS = composeManifest([
|
|
900
985
|
defineSetting({
|
|
901
986
|
key: 'ORIGIN',
|
|
902
987
|
label: 'Public address',
|
|
903
988
|
type: 'url',
|
|
989
|
+
origin: true,
|
|
904
990
|
onInvalid: 'fail',
|
|
905
991
|
class: 'bootstrap',
|
|
906
992
|
summary: true,
|
|
@@ -1010,6 +1096,7 @@ var APP_SETTINGS = composeManifest([
|
|
|
1010
1096
|
key: 'SELVA_EVENT_CALLBACK_ORIGIN',
|
|
1011
1097
|
label: 'Solve event callback address',
|
|
1012
1098
|
type: 'url',
|
|
1099
|
+
origin: true,
|
|
1013
1100
|
onInvalid: 'fail',
|
|
1014
1101
|
class: 'bootstrap',
|
|
1015
1102
|
description:
|
|
@@ -1033,17 +1120,7 @@ var APP_SETTINGS = composeManifest([
|
|
|
1033
1120
|
class: 'setting',
|
|
1034
1121
|
description: 'Lowest severity written to the log. Default info (debug in development).'
|
|
1035
1122
|
}),
|
|
1036
|
-
|
|
1037
|
-
key: 'SELVA_FLAG_COMPUTE_DEBUG',
|
|
1038
|
-
label: 'Compute debug logging',
|
|
1039
|
-
type: 'string',
|
|
1040
|
-
default: 'off',
|
|
1041
|
-
onInvalid: 'default',
|
|
1042
|
-
class: 'setting',
|
|
1043
|
-
description:
|
|
1044
|
-
'off, on (cache and timing lines per solve) or verbose (adds Compute’s raw error bodies).',
|
|
1045
|
-
impact: 'verbose can write what was solved to the log, which erasure cannot reach.'
|
|
1046
|
-
}),
|
|
1123
|
+
COMPUTE_DEBUG,
|
|
1047
1124
|
defineSetting({
|
|
1048
1125
|
key: 'SENTRY_DSN',
|
|
1049
1126
|
label: 'Sentry error reporting',
|
|
@@ -1107,7 +1184,8 @@ var RETIRED_KEYS = {
|
|
|
1107
1184
|
SUPABASE_PRIVATE_URL_PREFIX: 'fixed at /api/files',
|
|
1108
1185
|
COMPUTE_SOLVE_DEADLINE_MS: 'set --timeout (RHINO_COMPUTE_TIMEOUT) on the compute server',
|
|
1109
1186
|
MAX_SOLVE_DURATION_MS: 'set --timeout (RHINO_COMPUTE_TIMEOUT) on the compute server',
|
|
1110
|
-
COMPUTE_REUSE_DEFINITION_CACHE: 'on whenever the compute server reports /limits'
|
|
1187
|
+
COMPUTE_REUSE_DEFINITION_CACHE: 'on whenever the compute server reports /limits',
|
|
1188
|
+
COMPUTE_CACHE_ERRORED_SOLVES: 'removed'
|
|
1111
1189
|
};
|
|
1112
1190
|
/**
|
|
1113
1191
|
* The manifest for this deployment: engine and app keys, plus the slices of
|