toiljs 0.0.135 → 0.0.136
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 +8 -0
- package/build/compiler/config.d.ts +8 -0
- package/build/compiler/config.js +14 -1
- package/build/compiler/index.d.ts +3 -2
- package/build/compiler/index.js +18 -5
- package/build/compiler/toil-docs.generated.js +5 -5
- package/build/devserver/daemon/index.d.ts +1 -0
- package/build/devserver/daemon/index.js +5 -1
- package/build/devserver/daemon/runtime.d.ts +1 -0
- package/build/devserver/daemon/runtime.js +3 -1
- package/build/devserver/production.d.ts +1 -0
- package/build/devserver/production.js +2 -1
- package/build/devserver/runtime/host.d.ts +1 -0
- package/build/devserver/runtime/host.js +2 -0
- package/build/devserver/runtime/module.d.ts +2 -1
- package/build/devserver/runtime/module.js +6 -4
- package/build/devserver/server.d.ts +1 -0
- package/build/devserver/server.js +3 -2
- package/build/devserver/stream/index.d.ts +1 -1
- package/build/devserver/stream/index.js +3 -2
- package/build/devserver/stream/manager.d.ts +2 -1
- package/build/devserver/stream/manager.js +4 -2
- package/build/devserver/stream/router.d.ts +1 -1
- package/build/devserver/stream/router.js +2 -2
- package/build/logger/index.d.ts +10 -3
- package/build/logger/index.js +24 -5
- package/package.json +1 -1
- package/server/auth/AuthController.ts +17 -0
- package/server/auth/GoogleIdentity.ts +4 -0
- package/server/globals/toil-log.ts +48 -0
- package/server/globals.d.ts +8 -0
- package/tsconfig.logger.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v0.0.136] - 2026-10-27
|
|
4
|
+
|
|
5
|
+
- Enable application server logging by default in development and keep production logs disabled unless `server.logging: true` is configured. Compile the policy into request, stream, and daemon Wasm artifacts, including edge deployments; rebuild after changing it.
|
|
6
|
+
- Support scalars, arrays, typed arrays, generated `@data` JSON, and errors through the ambient `Log` API, with `log` and `debug` convenience methods and matching editor declarations.
|
|
7
|
+
- Reset the log allowance for every stream event so resident connections continue logging after their first 32 messages. Preserve the per-call host limits.
|
|
8
|
+
- Extend the Node/SSR `Logger` with every log level, multiple values, object and error inspection, console formatting, and explicit production opt-in.
|
|
9
|
+
- Add configurable built-in auth route restrictions and cookie regression coverage from the previously unreleased changes on `main`.
|
|
10
|
+
|
|
3
11
|
## [v0.0.135] - 2026-10-22
|
|
4
12
|
|
|
5
13
|
- Re-release the Google sign-in, authenticator security, and dependency updates from v0.0.134 with unchanged runtime behavior and ToilScript 0.1.66 compatibility.
|
|
@@ -43,12 +43,18 @@ export interface DaemonConfig {
|
|
|
43
43
|
readonly gasTick?: number;
|
|
44
44
|
readonly maxTasks?: number;
|
|
45
45
|
}
|
|
46
|
+
export interface AuthRoutesConfig {
|
|
47
|
+
readonly google?: boolean;
|
|
48
|
+
readonly twoFactorSetup?: boolean;
|
|
49
|
+
}
|
|
46
50
|
export interface ServerConfig {
|
|
51
|
+
readonly logging?: boolean;
|
|
47
52
|
readonly srcDir?: string;
|
|
48
53
|
readonly outDir?: string;
|
|
49
54
|
readonly email?: EmailBackendConfig;
|
|
50
55
|
readonly nodeMode?: DevNodeMode;
|
|
51
56
|
readonly auth?: boolean;
|
|
57
|
+
readonly authRoutes?: AuthRoutesConfig;
|
|
52
58
|
readonly daemon?: DaemonConfig;
|
|
53
59
|
readonly threads?: number | 'auto';
|
|
54
60
|
}
|
|
@@ -66,6 +72,7 @@ export interface ToilConfig {
|
|
|
66
72
|
readonly server?: ServerConfig;
|
|
67
73
|
}
|
|
68
74
|
export interface ResolvedToilConfig {
|
|
75
|
+
readonly logging?: boolean;
|
|
69
76
|
readonly root: string;
|
|
70
77
|
readonly srcDir: string;
|
|
71
78
|
readonly clientAbsDir: string;
|
|
@@ -88,6 +95,7 @@ export interface ResolvedToilConfig {
|
|
|
88
95
|
readonly email: EmailBackendConfig | null;
|
|
89
96
|
readonly nodeMode: DevNodeMode;
|
|
90
97
|
readonly auth: boolean;
|
|
98
|
+
readonly authRoutes: AuthRoutesConfig;
|
|
91
99
|
readonly daemon: ResolvedDaemonConfig;
|
|
92
100
|
readonly threads: number | 'auto';
|
|
93
101
|
readonly runtimePath: string;
|
package/build/compiler/config.js
CHANGED
|
@@ -35,7 +35,18 @@ export async function loadConfig(opts = {}) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
const client = user.client ?? {};
|
|
38
|
-
if (
|
|
38
|
+
if (user.server?.logging !== undefined && typeof user.server.logging !== 'boolean')
|
|
39
|
+
throw new Error('server.logging must be a boolean');
|
|
40
|
+
const authRoutes = user.server?.authRoutes ?? {};
|
|
41
|
+
if (typeof authRoutes !== 'object' || Array.isArray(authRoutes))
|
|
42
|
+
throw new Error('server.authRoutes must be an object');
|
|
43
|
+
for (const key of Object.keys(authRoutes)) {
|
|
44
|
+
if (!['google', 'twoFactorSetup'].includes(key) ||
|
|
45
|
+
typeof authRoutes[key] !== 'boolean')
|
|
46
|
+
throw new Error('server.authRoutes accepts only boolean google and twoFactorSetup settings');
|
|
47
|
+
}
|
|
48
|
+
if (client.coop !== undefined &&
|
|
49
|
+
!['same-origin', 'same-origin-allow-popups'].includes(client.coop))
|
|
39
50
|
throw new Error('client.coop must be same-origin or same-origin-allow-popups');
|
|
40
51
|
const srcDir = client.srcDir ?? 'client';
|
|
41
52
|
const routesDir = client.routesDir ?? 'routes';
|
|
@@ -65,8 +76,10 @@ export async function loadConfig(opts = {}) {
|
|
|
65
76
|
: null,
|
|
66
77
|
seo: client.seo ?? null,
|
|
67
78
|
email: user.server?.email ?? null,
|
|
79
|
+
logging: user.server?.logging,
|
|
68
80
|
nodeMode: resolveNodeMode(user.server?.nodeMode),
|
|
69
81
|
auth: user.server?.auth === true,
|
|
82
|
+
authRoutes,
|
|
70
83
|
daemon: resolveDaemonConfig(user.server?.daemon),
|
|
71
84
|
threads: resolveThreads(user.server?.threads),
|
|
72
85
|
runtimePath: resolveRuntimePath(),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ViteDevServer } from 'vite';
|
|
2
2
|
import type { RunningBackend } from 'toiljs/backend';
|
|
3
|
+
import { type AuthRoutesConfig } from './config.js';
|
|
3
4
|
export declare const SURFACE_DECORATOR: RegExp;
|
|
4
|
-
export declare function buildServer(root: string, auth?: boolean): Promise<void>;
|
|
5
|
+
export declare function buildServer(root: string, auth?: boolean, authRoutes?: AuthRoutesConfig, logging?: boolean): Promise<void>;
|
|
5
6
|
export declare function validateDeriveContinuationArtifacts(hot: Buffer | null, cold: Buffer | null): void;
|
|
6
7
|
interface SurfaceSplit {
|
|
7
8
|
readonly hasDaemon: boolean;
|
|
@@ -36,5 +37,5 @@ export type { ScannedRoute } from './routes.js';
|
|
|
36
37
|
export { TOIL_ENV_DTS, TOIL_SERVER_ENV_DTS } from './generate.js';
|
|
37
38
|
export { AI_HELPERS, AI_HELPER_IDS, aiHelperFiles, TOIL_DOCS } from './docs.js';
|
|
38
39
|
export type { AiHelper } from './docs.js';
|
|
39
|
-
export type { ToilConfig, ResolvedToilConfig, ClientConfig, ServerConfig, DevtoolsConfig, DevtoolsAiConfig, } from './config.js';
|
|
40
|
+
export type { ToilConfig, ResolvedToilConfig, ClientConfig, ServerConfig, AuthRoutesConfig, DevtoolsConfig, DevtoolsAiConfig, } from './config.js';
|
|
40
41
|
export type { RunningBackend, BackendOptions } from 'toiljs/backend';
|
package/build/compiler/index.js
CHANGED
|
@@ -135,7 +135,7 @@ function serverAuthEnabled(root, configAuth) {
|
|
|
135
135
|
return false;
|
|
136
136
|
return serverImportsAuth(root, serverEntryFiles(root));
|
|
137
137
|
}
|
|
138
|
-
export async function buildServer(root, auth = false) {
|
|
138
|
+
export async function buildServer(root, auth = false, authRoutes = {}, logging = false) {
|
|
139
139
|
if (!fs.existsSync(path.join(root, 'toilconfig.json')))
|
|
140
140
|
return;
|
|
141
141
|
for (const dir of serverDirs(root)) {
|
|
@@ -150,6 +150,11 @@ export async function buildServer(root, auth = false) {
|
|
|
150
150
|
const files = serverEntryFiles(root);
|
|
151
151
|
const authOn = auth || serverImportsAuth(root, files);
|
|
152
152
|
if (authOn) {
|
|
153
|
+
const authLib = path.join(root, AUTH_EMAILS_LIB_SUBDIR);
|
|
154
|
+
fs.mkdirSync(authLib, { recursive: true });
|
|
155
|
+
fs.writeFileSync(path.join(authLib, '_auth_routes.ts'), `// Generated by toiljs. Rebuild to change auth route policy.\n` +
|
|
156
|
+
`@inline export function __toilAuthGoogleEnabled(): bool { return ${authRoutes.google !== false}; }\n` +
|
|
157
|
+
`@inline export function __toilAuthTwoFactorSetupEnabled(): bool { return ${authRoutes.twoFactorSetup !== false}; }\n`);
|
|
153
158
|
const appHasUser = serverDeclaresUser(root, files);
|
|
154
159
|
const authFiles = authEntryFiles(root, appHasUser);
|
|
155
160
|
const authSet = new Set(authFiles);
|
|
@@ -184,6 +189,7 @@ export async function buildServer(root, auth = false) {
|
|
|
184
189
|
outFile: artifacts.cold,
|
|
185
190
|
withRpc: false,
|
|
186
191
|
authUser: authOn,
|
|
192
|
+
logging,
|
|
187
193
|
});
|
|
188
194
|
if (split.hasStream && split.stream.length > 0)
|
|
189
195
|
await runToilscriptPass(root, binJs, split.stream, {
|
|
@@ -191,6 +197,7 @@ export async function buildServer(root, auth = false) {
|
|
|
191
197
|
outFile: artifacts.stream,
|
|
192
198
|
withRpc: false,
|
|
193
199
|
authUser: authOn,
|
|
200
|
+
logging,
|
|
194
201
|
});
|
|
195
202
|
if (split.request.length > 0)
|
|
196
203
|
await runToilscriptPass(root, binJs, split.request, {
|
|
@@ -199,6 +206,7 @@ export async function buildServer(root, auth = false) {
|
|
|
199
206
|
withRpc: true,
|
|
200
207
|
rpcSurfaceFiles: split.hasStream ? split.stream : undefined,
|
|
201
208
|
authUser: authOn,
|
|
209
|
+
logging,
|
|
202
210
|
});
|
|
203
211
|
if (split.request.length > 0)
|
|
204
212
|
validateDeriveContinuationArtifacts(fs.readFileSync(serverWasmFile(root)), split.hasDaemon ? fs.readFileSync(artifacts.cold) : null);
|
|
@@ -213,6 +221,7 @@ export async function buildServer(root, auth = false) {
|
|
|
213
221
|
outFile: null,
|
|
214
222
|
withRpc: true,
|
|
215
223
|
authUser: authOn,
|
|
224
|
+
logging,
|
|
216
225
|
});
|
|
217
226
|
validateDeriveContinuationArtifacts(fs.readFileSync(serverWasmFile(root)), null);
|
|
218
227
|
}
|
|
@@ -385,6 +394,8 @@ export function assertNoStreamInRequestTier(root, split) {
|
|
|
385
394
|
}
|
|
386
395
|
async function runToilscriptPass(root, binJs, files, opts) {
|
|
387
396
|
const args = [binJs, ...files, '--target', 'release'];
|
|
397
|
+
const logLib = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../server/globals/toil-log.ts');
|
|
398
|
+
args.push('--lib', logLib, '--use', 'Log=ToilLog', '--use', `__TOIL_LOGGING=${opts.logging ? '1' : '0'}`);
|
|
388
399
|
const editorTier = opts.mode === 'cold' ? 'cold' : opts.withRpc ? 'request' : 'stream';
|
|
389
400
|
const editorDir = serverDirs(root)[0] ?? path.join(root, 'server');
|
|
390
401
|
args.push('--editorTypes', path.join(editorDir, `toilscript.${editorTier}.generated.d.ts`));
|
|
@@ -443,7 +454,7 @@ function watchServer(cfg, watcher) {
|
|
|
443
454
|
const authOn = serverAuthEnabled(root, cfg.auth);
|
|
444
455
|
renderEmails(cfg, authOn)
|
|
445
456
|
.then(() => renderAuthEmails(cfg, authOn))
|
|
446
|
-
.then(() => buildServer(root, cfg.auth))
|
|
457
|
+
.then(() => buildServer(root, cfg.auth, cfg.authRoutes, cfg.logging ?? true))
|
|
447
458
|
.then(() => process.stdout.write(pc.green(' ✓ ') + pc.dim('server rebuilt') + '\n'))
|
|
448
459
|
.catch((e) => process.stdout.write(pc.red(` ✗ server rebuild failed: ${String(e)}`) + '\n'))
|
|
449
460
|
.finally(() => {
|
|
@@ -642,7 +653,7 @@ export async function dev(opts = {}) {
|
|
|
642
653
|
generate(cfg);
|
|
643
654
|
if (hasServer)
|
|
644
655
|
await extractServerSlots(cfg);
|
|
645
|
-
await buildServer(cfg.root, cfg.auth);
|
|
656
|
+
await buildServer(cfg.root, cfg.auth, cfg.authRoutes, cfg.logging ?? true);
|
|
646
657
|
if (hasServer)
|
|
647
658
|
process.stdout.write(pc.green(' ✓ ') + pc.dim('server built') + '\n');
|
|
648
659
|
if (!hasServer) {
|
|
@@ -690,6 +701,7 @@ export async function dev(opts = {}) {
|
|
|
690
701
|
streamWasmFile: serverArtifacts(cfg.root).stream,
|
|
691
702
|
nodeMode: cfg.nodeMode,
|
|
692
703
|
daemon: cfg.daemon,
|
|
704
|
+
logging: cfg.logging,
|
|
693
705
|
vite: { host: '127.0.0.1', port: vitePort },
|
|
694
706
|
email: cfg.email ?? undefined,
|
|
695
707
|
ssrTemplates,
|
|
@@ -727,7 +739,7 @@ export async function build(opts = {}) {
|
|
|
727
739
|
await renderAuthEmails(cfg, authOnBuild);
|
|
728
740
|
generate(cfg);
|
|
729
741
|
const priorServerSlots = hasServer ? await extractServerSlots(cfg) : new Map();
|
|
730
|
-
await buildServer(cfg.root, cfg.auth);
|
|
742
|
+
await buildServer(cfg.root, cfg.auth, cfg.authRoutes, cfg.logging ?? false);
|
|
731
743
|
if (opts.serverOnly)
|
|
732
744
|
return;
|
|
733
745
|
if (hasServer)
|
|
@@ -747,7 +759,7 @@ export async function build(opts = {}) {
|
|
|
747
759
|
const ssr = await extractTemplates(cfg, 'edge', priorServerSlots);
|
|
748
760
|
if (ssr.serverSlotsChanged) {
|
|
749
761
|
process.stdout.write(pc.dim(' SSR template changed; recompiling the server with the new hash…') + '\n');
|
|
750
|
-
await buildServer(cfg.root, cfg.auth);
|
|
762
|
+
await buildServer(cfg.root, cfg.auth, cfg.authRoutes, cfg.logging ?? false);
|
|
751
763
|
}
|
|
752
764
|
logSecurityDeployment(cfg);
|
|
753
765
|
}
|
|
@@ -767,6 +779,7 @@ export async function start(opts = {}) {
|
|
|
767
779
|
coldWasmFile: artifacts.cold,
|
|
768
780
|
nodeMode: cfg.nodeMode,
|
|
769
781
|
daemon: cfg.daemon,
|
|
782
|
+
logging: cfg.logging,
|
|
770
783
|
threads: opts.threads ?? cfg.threads,
|
|
771
784
|
port: cfg.port,
|
|
772
785
|
host: cfg.host,
|