toiljs 0.0.137 → 0.0.139
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/CHANGELOG.md +15 -0
- package/build/cli/index.js +2 -2
- package/build/compiler/client-publication.d.ts +5 -0
- package/build/compiler/client-publication.js +93 -0
- package/build/compiler/compiler-build.js +5 -2
- package/build/compiler/compiler-cache.d.ts +1 -0
- package/build/compiler/compiler-cache.js +22 -1
- package/build/compiler/config.d.ts +1 -0
- package/build/compiler/config.js +2 -2
- package/build/compiler/index.js +22 -18
- package/build/compiler/toil-docs.generated.js +9 -7
- package/build/compiler/toilscript-worker.js +2 -1
- package/build/devserver/config/ratelimit.d.ts +1 -0
- package/build/devserver/config/ratelimit.js +29 -0
- package/build/devserver/daemon/index.js +2 -0
- package/package.json +3 -3
- package/server/auth/AuthController.ts +19 -9
- package/server/auth/AuthMaintenance.ts +126 -0
- package/server/auth/AuthReads.ts +19 -0
- package/server/auth/AuthStateDb.ts +4 -0
- package/server/auth/AuthStore.ts +7 -0
- package/server/auth/Authenticator.ts +6 -0
- package/server/auth/SessionEpochs.ts +44 -1
- package/server/globals/auth.ts +7 -2
- package/server/globals/ratelimit.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v0.0.139] - 2026-10-28
|
|
4
|
+
|
|
5
|
+
- Build the client in isolated staging through integrity generation, prerendering and SSR extraction. Publish assets before HTML, then prune obsolete output. Compilation failures and cancellation preserve the previous client output instead of exposing missing or partially written chunks.
|
|
6
|
+
|
|
7
|
+
## [v0.0.138] - 2026-10-28
|
|
8
|
+
|
|
9
|
+
- Erase historical two-factor settings and replay counters during account deletion, with bounded retryable cleanup, raw-byte release of old schemas, and generation fences that preserve session revocation across account recreation.
|
|
10
|
+
- Add `server.authRoutes.deleteAccount`; disabling factor setup still allows proof-backed removal of an existing factor.
|
|
11
|
+
- Build cold artifacts with the minimal collector and collect between resident calls on updated Node/native hosts, preserving daemon state without incremental barriers.
|
|
12
|
+
- Add exact `RateLimit.TrailingWindow` on Node and native hosts. Require ToilScript 0.1.67; deploy toil-backend 0.1.1 before using the new strategy or minimal cold runtime.
|
|
13
|
+
- Sort build-cache library listings and expose per-tier miss reasons with `TOILJS_BUILD_CACHE_DEBUG=1`.
|
|
14
|
+
- Correct auth/config and derive permission documentation; document native gas prices, measurement, routing, byte/write accounting, continuation polling and fresh Scylla keyspace readiness.
|
|
15
|
+
|
|
16
|
+
Validation: 808 framework tests pass with normal and strict database limits, alongside browser auth checks, both example builds/typechecks/lints, and a clean starter installation from a cached older CLI. See [the release audit](docs/release-audit-2026-10-28.md) for all sixteen report items, additional regression fixes, and verification limits.
|
|
17
|
+
|
|
3
18
|
## [v0.0.137] - 2026-10-27
|
|
4
19
|
|
|
5
20
|
- Compile request, stream, and daemon tiers in bounded parallel processes, dividing Binaryen's CPU budget among active jobs while preserving configured optimization levels and assertions.
|
package/build/cli/index.js
CHANGED
|
@@ -4156,7 +4156,7 @@ function scaffold(name, template, features, aiTools, images) {
|
|
|
4156
4156
|
oxlint: "^1.89.0",
|
|
4157
4157
|
"oxlint-tsgolint": "^7.0.2004",
|
|
4158
4158
|
prettier: "^3.9.10",
|
|
4159
|
-
toilscript: ">=0.1.
|
|
4159
|
+
toilscript: ">=0.1.67",
|
|
4160
4160
|
typescript: "^7.0.2"
|
|
4161
4161
|
};
|
|
4162
4162
|
for (const dep of requiredPackages(features).sort()) {
|
|
@@ -5136,7 +5136,7 @@ function checkWasmBuilt(exists) {
|
|
|
5136
5136
|
fix: "Run your server build (toilscript) before toiljs start."
|
|
5137
5137
|
};
|
|
5138
5138
|
}
|
|
5139
|
-
var RPC_TOILSCRIPT_MIN = "0.1.
|
|
5139
|
+
var RPC_TOILSCRIPT_MIN = "0.1.67";
|
|
5140
5140
|
function checkRpcWiring(f) {
|
|
5141
5141
|
const missing = [];
|
|
5142
5142
|
if (!f.toilscriptOk) missing.push(`toilscript >=${RPC_TOILSCRIPT_MIN}`);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export class ClientPublication {
|
|
4
|
+
static async run(cfg, compile) {
|
|
5
|
+
const destination = path.resolve(cfg.root, cfg.outDir);
|
|
6
|
+
const home = path.join(cfg.root, '.toil', 'compiler');
|
|
7
|
+
if (destination === path.parse(destination).root ||
|
|
8
|
+
home === destination ||
|
|
9
|
+
home.startsWith(destination + path.sep))
|
|
10
|
+
throw new Error('client.outDir must be a dedicated directory outside the compiler staging directory.');
|
|
11
|
+
fs.mkdirSync(home, { recursive: true });
|
|
12
|
+
const staging = fs.mkdtempSync(path.join(home, `pending-${process.pid}-`));
|
|
13
|
+
const output = path.join(staging, 'client');
|
|
14
|
+
let cancelled = false;
|
|
15
|
+
const stop = () => {
|
|
16
|
+
cancelled = true;
|
|
17
|
+
process.exitCode = 130;
|
|
18
|
+
};
|
|
19
|
+
process.once('SIGINT', stop);
|
|
20
|
+
process.once('SIGTERM', stop);
|
|
21
|
+
try {
|
|
22
|
+
await compile({
|
|
23
|
+
...cfg,
|
|
24
|
+
outDir: output,
|
|
25
|
+
vite: {
|
|
26
|
+
...cfg.vite,
|
|
27
|
+
build: { ...cfg.vite.build, outDir: output, emptyOutDir: true },
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
if (cancelled)
|
|
31
|
+
throw new Error('Client build cancelled');
|
|
32
|
+
if (!fs.existsSync(path.join(output, 'index.html')))
|
|
33
|
+
throw new Error('Client build did not produce index.html. The previous output was preserved.');
|
|
34
|
+
const files = ClientPublication.#files(output);
|
|
35
|
+
const ordered = [...files].sort((left, right) => Number(left.endsWith('.html')) - Number(right.endsWith('.html')) ||
|
|
36
|
+
Number(left === 'index.html') - Number(right === 'index.html') ||
|
|
37
|
+
left.localeCompare(right));
|
|
38
|
+
for (const file of ordered)
|
|
39
|
+
ClientPublication.#publish(path.join(output, file), path.join(destination, file));
|
|
40
|
+
if (cfg.vite.build?.emptyOutDir !== false)
|
|
41
|
+
ClientPublication.#prune(destination, new Set(files), '');
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
process.off('SIGINT', stop);
|
|
45
|
+
process.off('SIGTERM', stop);
|
|
46
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
static #files(directory, prefix = '') {
|
|
50
|
+
const files = [];
|
|
51
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
52
|
+
const relative = path.join(prefix, entry.name);
|
|
53
|
+
if (entry.isDirectory())
|
|
54
|
+
files.push(...ClientPublication.#files(path.join(directory, entry.name), relative));
|
|
55
|
+
else if (entry.isFile())
|
|
56
|
+
files.push(relative);
|
|
57
|
+
else
|
|
58
|
+
throw new Error(`Unsupported client output: ${relative}`);
|
|
59
|
+
}
|
|
60
|
+
return files;
|
|
61
|
+
}
|
|
62
|
+
static #publish(source, destination) {
|
|
63
|
+
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
|
64
|
+
try {
|
|
65
|
+
fs.renameSync(source, destination);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (!(error instanceof Error) || !('code' in error) || error.code !== 'EXDEV')
|
|
69
|
+
throw error;
|
|
70
|
+
const temporary = destination + `.toil-${process.pid}.tmp`;
|
|
71
|
+
try {
|
|
72
|
+
fs.copyFileSync(source, temporary);
|
|
73
|
+
fs.renameSync(temporary, destination);
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
fs.rmSync(temporary, { force: true });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
static #prune(directory, current, prefix) {
|
|
81
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
82
|
+
const relative = path.join(prefix, entry.name);
|
|
83
|
+
const location = path.join(directory, entry.name);
|
|
84
|
+
if (entry.isDirectory()) {
|
|
85
|
+
ClientPublication.#prune(location, current, relative);
|
|
86
|
+
if (fs.readdirSync(location).length === 0)
|
|
87
|
+
fs.rmdirSync(location);
|
|
88
|
+
}
|
|
89
|
+
else if (!current.has(relative))
|
|
90
|
+
fs.unlinkSync(location);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import { availableParallelism } from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { compilerFingerprint, digest, fileDigest, inputsCurrent, outputsCurrent, readCompilerManifest, standardCompilerConfig, } from './compiler-cache.js';
|
|
6
|
+
import { compilerFingerprint, compilerCacheMiss, digest, fileDigest, inputsCurrent, outputsCurrent, readCompilerManifest, standardCompilerConfig, } from './compiler-cache.js';
|
|
7
7
|
function runProcess(root, args, name, signal, cores) {
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
9
|
let failure;
|
|
@@ -80,7 +80,10 @@ export async function runCompilerPasses(root, bin, passes, finalize, options = {
|
|
|
80
80
|
const cache = path.join(home, `${pass.name}.json`);
|
|
81
81
|
const key = digest(JSON.stringify({ version: 1, root, fingerprint, args: pass.args }));
|
|
82
82
|
const saved = cacheable ? readCompilerManifest(cache) : null;
|
|
83
|
-
const
|
|
83
|
+
const miss = compilerCacheMiss(saved, key);
|
|
84
|
+
const cached = cacheable && miss === null ? saved : null;
|
|
85
|
+
if (process.env.TOILJS_BUILD_CACHE_DEBUG === '1')
|
|
86
|
+
process.stdout.write(` server cache ${pass.name}: ${cached ? 'hit' : !cacheable ? 'disabled' : miss}\n`);
|
|
84
87
|
return { pass, cache, key, cached };
|
|
85
88
|
});
|
|
86
89
|
const concurrency = Math.max(1, Math.min(plans.filter((plan) => !plan.cached).length, 3, cpus, jobs));
|
|
@@ -22,6 +22,7 @@ export declare function digest(value: string | Uint8Array): string;
|
|
|
22
22
|
export declare function fileDigest(file: string): string | null;
|
|
23
23
|
export declare function libraryEntries(dir: string): string[] | null;
|
|
24
24
|
export declare function inputsCurrent(manifest: CompilerManifest): boolean;
|
|
25
|
+
export declare function compilerCacheMiss(manifest: CompilerManifest | null, key: string): string | null;
|
|
25
26
|
export declare function outputsCurrent(manifest: CompilerManifest): boolean;
|
|
26
27
|
export declare function readCompilerManifest(file: string): CompilerManifest | null;
|
|
27
28
|
export declare function standardCompilerConfig(root: string): boolean;
|
|
@@ -16,7 +16,8 @@ export function libraryEntries(dir) {
|
|
|
16
16
|
try {
|
|
17
17
|
return fs
|
|
18
18
|
.readdirSync(dir)
|
|
19
|
-
.filter((name) => name.endsWith('.ts') && !name.endsWith('.d.ts'))
|
|
19
|
+
.filter((name) => name.endsWith('.ts') && !name.endsWith('.d.ts'))
|
|
20
|
+
.sort();
|
|
20
21
|
}
|
|
21
22
|
catch {
|
|
22
23
|
return null;
|
|
@@ -27,6 +28,26 @@ export function inputsCurrent(manifest) {
|
|
|
27
28
|
manifest.inputs.every((input) => fileDigest(input.path) === input.hash) &&
|
|
28
29
|
manifest.directories.every((dir) => JSON.stringify(libraryEntries(dir.path)) === JSON.stringify(dir.entries)));
|
|
29
30
|
}
|
|
31
|
+
export function compilerCacheMiss(manifest, key) {
|
|
32
|
+
if (!manifest)
|
|
33
|
+
return 'manifest missing or invalid';
|
|
34
|
+
if (manifest.key !== key)
|
|
35
|
+
return 'compiler, options, or build environment changed';
|
|
36
|
+
if (!manifest.stable)
|
|
37
|
+
return 'inputs changed while the previous compiler was reading them';
|
|
38
|
+
for (const input of manifest.inputs)
|
|
39
|
+
if (fileDigest(input.path) !== input.hash)
|
|
40
|
+
return `input changed: ${input.path}`;
|
|
41
|
+
for (const dir of manifest.directories)
|
|
42
|
+
if (JSON.stringify(libraryEntries(dir.path)) !== JSON.stringify(dir.entries))
|
|
43
|
+
return `library entries changed: ${dir.path}`;
|
|
44
|
+
if (manifest.outputs.length === 0)
|
|
45
|
+
return 'no recorded outputs';
|
|
46
|
+
for (const output of manifest.outputs)
|
|
47
|
+
if (fileDigest(output.path) !== output.hash)
|
|
48
|
+
return `output changed or missing: ${output.path}`;
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
30
51
|
export function outputsCurrent(manifest) {
|
|
31
52
|
return (manifest.outputs.length > 0 &&
|
|
32
53
|
manifest.outputs.every((output) => fileDigest(output.path) === output.hash));
|
package/build/compiler/config.js
CHANGED
|
@@ -41,9 +41,9 @@ export async function loadConfig(opts = {}) {
|
|
|
41
41
|
if (typeof authRoutes !== 'object' || Array.isArray(authRoutes))
|
|
42
42
|
throw new Error('server.authRoutes must be an object');
|
|
43
43
|
for (const key of Object.keys(authRoutes)) {
|
|
44
|
-
if (!['google', 'twoFactorSetup'].includes(key) ||
|
|
44
|
+
if (!['google', 'twoFactorSetup', 'deleteAccount'].includes(key) ||
|
|
45
45
|
typeof authRoutes[key] !== 'boolean')
|
|
46
|
-
throw new Error('server.authRoutes accepts only boolean google and
|
|
46
|
+
throw new Error('server.authRoutes accepts only boolean google, twoFactorSetup and deleteAccount settings');
|
|
47
47
|
}
|
|
48
48
|
if (client.coop !== undefined &&
|
|
49
49
|
!['same-origin', 'same-origin-allow-popups'].includes(client.coop))
|
package/build/compiler/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { createViteConfig } from './vite.js';
|
|
|
16
16
|
import { logSecurityDeployment } from './security-deployment.js';
|
|
17
17
|
import { runCompilerPasses } from './compiler-build.js';
|
|
18
18
|
import { withCompilerLock } from './compiler-lock.js';
|
|
19
|
+
import { ClientPublication } from './client-publication.js';
|
|
19
20
|
export const SURFACE_DECORATOR = /^[ \t]*@(data|rest|service|remote|stream|daemon|scheduled)\b/m;
|
|
20
21
|
function toilconfigEntries(root) {
|
|
21
22
|
try {
|
|
@@ -160,7 +161,8 @@ async function buildServerLocked(root, auth, authRoutes, logging) {
|
|
|
160
161
|
fs.mkdirSync(authLib, { recursive: true });
|
|
161
162
|
fs.writeFileSync(path.join(authLib, '_auth_routes.ts'), `// Generated by toiljs. Rebuild to change auth route policy.\n` +
|
|
162
163
|
`@inline export function __toilAuthGoogleEnabled(): bool { return ${authRoutes.google !== false}; }\n` +
|
|
163
|
-
`@inline export function __toilAuthTwoFactorSetupEnabled(): bool { return ${authRoutes.twoFactorSetup !== false}; }\n`
|
|
164
|
+
`@inline export function __toilAuthTwoFactorSetupEnabled(): bool { return ${authRoutes.twoFactorSetup !== false}; }\n` +
|
|
165
|
+
`@inline export function __toilAuthDeleteAccountEnabled(): bool { return ${authRoutes.deleteAccount !== false}; }\n`);
|
|
164
166
|
const appHasUser = serverDeclaresUser(root, files);
|
|
165
167
|
const authFiles = authEntryFiles(root, appHasUser);
|
|
166
168
|
const authSet = new Set(authFiles);
|
|
@@ -419,7 +421,7 @@ function toilscriptPass(root, files, opts) {
|
|
|
419
421
|
if (opts.mode !== null)
|
|
420
422
|
args.push('--targetMode', opts.mode);
|
|
421
423
|
if (opts.mode === 'cold')
|
|
422
|
-
args.push('--runtime', '
|
|
424
|
+
args.push('--runtime', 'minimal', '--exportRuntime');
|
|
423
425
|
if (opts.outFile !== null)
|
|
424
426
|
args.push('--outFile', opts.outFile);
|
|
425
427
|
if (opts.withRpc)
|
|
@@ -774,22 +776,24 @@ async function buildLocked(opts) {
|
|
|
774
776
|
if (hasServer)
|
|
775
777
|
process.stdout.write(pc.green(' ✓ ') + pc.dim('server built; building the client (vite)…') + '\n');
|
|
776
778
|
const prevNodeEnv = process.env.NODE_ENV;
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
779
|
+
await ClientPublication.run(cfg, async (staged) => {
|
|
780
|
+
process.env.NODE_ENV = 'production';
|
|
781
|
+
try {
|
|
782
|
+
await viteBuild(mergeConfig(await createViteConfig(staged), { mode: 'production' }));
|
|
783
|
+
}
|
|
784
|
+
finally {
|
|
785
|
+
if (prevNodeEnv === undefined)
|
|
786
|
+
delete process.env.NODE_ENV;
|
|
787
|
+
else
|
|
788
|
+
process.env.NODE_ENV = prevNodeEnv;
|
|
789
|
+
}
|
|
790
|
+
await prerenderStaticParams(staged);
|
|
791
|
+
const ssr = await extractTemplates(staged, 'edge', priorServerSlots);
|
|
792
|
+
if (ssr.serverSlotsChanged) {
|
|
793
|
+
process.stdout.write(pc.dim(' SSR template changed; recompiling the server with the new hash…') + '\n');
|
|
794
|
+
await buildServerLocked(cfg.root, cfg.auth, cfg.authRoutes, cfg.logging ?? false);
|
|
795
|
+
}
|
|
796
|
+
});
|
|
793
797
|
logSecurityDeployment(cfg);
|
|
794
798
|
}
|
|
795
799
|
export async function start(opts = {}) {
|