toiljs 0.0.33 → 0.0.36
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 +19 -0
- package/README.md +1 -0
- package/as-pect.config.js +8 -2
- package/build/cli/.tsbuildinfo +1 -1
- package/build/cli/index.js +124 -7
- package/build/client/.tsbuildinfo +1 -1
- package/build/client/auth.d.ts +42 -0
- package/build/client/auth.js +179 -0
- package/build/client/index.d.ts +5 -1
- package/build/client/index.js +3 -1
- package/build/client/routing/loader.d.ts +1 -0
- package/build/client/routing/loader.js +37 -0
- package/build/client/routing/mount.js +32 -1
- package/build/client/ssr/markers.d.ts +34 -0
- package/build/client/ssr/markers.js +49 -0
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/docs.js +88 -1
- package/build/compiler/generate.d.ts +2 -0
- package/build/compiler/generate.js +2 -2
- package/build/compiler/index.js +2 -0
- package/build/compiler/ssr-codegen.d.ts +2 -0
- package/build/compiler/ssr-codegen.js +36 -0
- package/build/compiler/template-build.d.ts +29 -0
- package/build/compiler/template-build.js +150 -0
- package/build/compiler/template.d.ts +22 -0
- package/build/compiler/template.js +169 -0
- package/build/devserver/.tsbuildinfo +1 -1
- package/build/devserver/cache.d.ts +8 -0
- package/build/devserver/cache.js +0 -0
- package/build/devserver/crypto.js +15 -0
- package/build/devserver/host.js +1 -0
- package/build/devserver/index.js +10 -1
- package/build/devserver/module.d.ts +1 -0
- package/build/devserver/module.js +23 -1
- package/docs/README.md +56 -0
- package/docs/auth.md +261 -0
- package/docs/caching.md +115 -0
- package/docs/cookies.md +457 -0
- package/docs/crypto.md +130 -0
- package/docs/data.md +131 -0
- package/docs/getting-started.md +128 -0
- package/docs/routing.md +259 -0
- package/docs/rpc.md +149 -0
- package/docs/ssr.md +184 -0
- package/docs/time.md +43 -0
- package/examples/basic/client/routes/auth.tsx +198 -0
- package/examples/basic/client/routes/cookies.tsx +199 -0
- package/examples/basic/client/routes/features/index.tsx +34 -10
- package/examples/basic/client/routes/hello.tsx +43 -0
- package/examples/basic/client/routes/pq.tsx +135 -0
- package/examples/basic/server/AuthTestHandler.ts +15 -0
- package/examples/basic/server/AuthVerifyHandler.ts +23 -0
- package/examples/basic/server/CacheHandler.ts +25 -0
- package/examples/basic/server/DecoCache.ts +18 -0
- package/examples/basic/server/FastTrapHandler.ts +8 -0
- package/examples/basic/server/README.md +19 -0
- package/examples/basic/server/SpinHandler.ts +18 -0
- package/examples/basic/server/SsrGreetingRender.ts +27 -0
- package/examples/basic/server/authexample-main.ts +8 -0
- package/examples/basic/server/authtest-main.ts +8 -0
- package/examples/basic/server/authverify-main.ts +8 -0
- package/examples/basic/server/cache-main.ts +8 -0
- package/examples/basic/server/core/AppHandler.ts +290 -0
- package/examples/basic/server/core/store.ts +31 -0
- package/examples/basic/server/deco-main.ts +18 -0
- package/examples/basic/server/main.ts +13 -2
- package/examples/basic/server/models/NewPlayer.ts +5 -0
- package/examples/basic/server/models/Player.ts +8 -0
- package/examples/basic/server/models/ScoreDelta.ts +5 -0
- package/examples/basic/server/models/Standings.ts +7 -0
- package/examples/basic/server/routes/Auth.ts +184 -0
- package/examples/basic/server/routes/Leaderboard.ts +20 -0
- package/examples/basic/server/routes/Players.ts +53 -0
- package/examples/basic/server/routes/PqDemo.ts +109 -0
- package/examples/basic/server/routes/Session.ts +73 -0
- package/examples/basic/server/scheduled/README.md +7 -0
- package/examples/basic/server/services/Stats.ts +11 -0
- package/examples/basic/server/services/remotes.ts +7 -0
- package/examples/basic/server/spin-main.ts +13 -0
- package/examples/basic/server/ssr/greeting.slots.ts +19 -0
- package/examples/basic/server/ssr-main.ts +18 -0
- package/examples/basic/server/toil-server-env.d.ts +94 -0
- package/examples/basic/server/trap-main.ts +8 -0
- package/package.json +5 -3
- package/server/globals/auth.ts +281 -0
- package/server/runtime/README.md +61 -0
- package/server/runtime/env/Server.ts +12 -0
- package/server/runtime/exports/index.ts +17 -0
- package/server/runtime/exports/render.ts +51 -0
- package/server/runtime/http/base64.ts +104 -0
- package/server/runtime/http/cookie.ts +416 -0
- package/server/runtime/http/cookies.ts +197 -0
- package/server/runtime/http/date.ts +72 -0
- package/server/runtime/http/percent.ts +76 -0
- package/server/runtime/http/securecookies.ts +224 -0
- package/server/runtime/index.ts +17 -0
- package/server/runtime/request.ts +24 -0
- package/server/runtime/response.ts +85 -0
- package/server/runtime/ssr/Ssr.ts +43 -0
- package/server/runtime/ssr/encode.ts +110 -0
- package/server/runtime/ssr/escape.ts +83 -0
- package/server/runtime/ssr/slots.ts +144 -0
- package/server/runtime/time.ts +29 -0
- package/src/cli/create.ts +159 -14
- package/src/client/auth.ts +322 -0
- package/src/client/index.ts +5 -1
- package/src/client/routing/loader.ts +56 -0
- package/src/client/routing/mount.tsx +37 -1
- package/src/client/ssr/markers.tsx +140 -0
- package/src/compiler/docs.ts +88 -1
- package/src/compiler/generate.ts +2 -2
- package/src/compiler/index.ts +5 -0
- package/src/compiler/ssr-codegen.ts +85 -0
- package/src/compiler/template-build.ts +275 -0
- package/src/compiler/template.ts +265 -0
- package/src/devserver/cache.ts +0 -0
- package/src/devserver/crypto.ts +23 -0
- package/src/devserver/host.ts +4 -0
- package/src/devserver/index.ts +21 -1
- package/src/devserver/module.ts +39 -1
- package/test/assembly/cookie.spec.ts +302 -0
- package/test/assembly/example.spec.ts +5 -1
- package/test/assembly/ssr.spec.ts +94 -0
- package/test/devserver.test.ts +48 -4
- package/test/fixtures/bignum-wire/spec.ts +27 -0
- package/test/rpc-bignum-wire.test.ts +164 -0
- package/test/ssr-render.test.ts +128 -0
- package/test/ssr-template.test.tsx +348 -0
- package/examples/basic/server/HelloHandler.ts +0 -42
- package/examples/basic/server/api.ts +0 -137
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Response, RouteContext, SecureCookies, base64UrlEncode, base64UrlDecode } from 'toiljs/server/runtime';
|
|
2
|
+
import { DataReader, DataWriter } from 'data';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Post-quantum identity demo (server half), challenge-response.
|
|
6
|
+
*
|
|
7
|
+
* 1. GET /pq/challenge -> the edge mints a fresh nonce + cid + iat/exp and
|
|
8
|
+
* returns them PLUS an HMAC-signed `token` over those values. The token is
|
|
9
|
+
* the server-issued challenge: signed with a server-only key, it proves
|
|
10
|
+
* "the edge issued exactly this" WITHOUT any cross-request storage (the
|
|
11
|
+
* guest's memory is wiped every request).
|
|
12
|
+
* 2. POST /pq/verify -> the client signs the login message built from the
|
|
13
|
+
* SERVER's nonce/cid/iat/exp (ML-DSA-44, derived from the password) and
|
|
14
|
+
* returns {sub, token, publicKey, signature}. The edge re-opens the token
|
|
15
|
+
* (rejecting a forged or expired one), rebuilds the message from the values
|
|
16
|
+
* INSIDE the token (never client-echoed), and verifies the signature via
|
|
17
|
+
* `crypto.mldsa_verify` (`AuthService.verifyLogin`).
|
|
18
|
+
*
|
|
19
|
+
* The nonce is server-chosen and tamper-proof, and the challenge is time-bound,
|
|
20
|
+
* so a client cannot pre-sign or substitute its own nonce. What this stateless
|
|
21
|
+
* form does NOT have is single-use: within the TTL a captured {token, signature}
|
|
22
|
+
* could be replayed, because that needs an atomic consume against a store (Redis
|
|
23
|
+
* GETDEL / SQL DELETE RETURNING). The production login in server/routes/Auth.ts
|
|
24
|
+
* does exactly that; see docs/auth.md. Pairs with client/routes/pq.tsx.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const AUD = 'pq-demo'; // this demo's audience id (server config; never client-echoed)
|
|
28
|
+
const CHALLENGE_TTL_SECS: u64 = 120;
|
|
29
|
+
|
|
30
|
+
/** Server-only key for signing challenge tokens (demo constant; a real
|
|
31
|
+
* deployment uses a per-deployment secret, like the session secret). */
|
|
32
|
+
function challengeKey(): Uint8Array {
|
|
33
|
+
return crypto.sha256Text('toil-pq-demo-challenge-key-v1');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function randomBytes(n: i32): Uint8Array {
|
|
37
|
+
const b = new Uint8Array(n);
|
|
38
|
+
crypto.getRandomValues(b);
|
|
39
|
+
return b;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@rest('pq')
|
|
43
|
+
class PqDemo {
|
|
44
|
+
/** GET /pq/challenge
|
|
45
|
+
* resp: str(aud) bytes(cid) bytes(nonce) u64(iat) u64(exp) str(token) */
|
|
46
|
+
@get('/challenge')
|
|
47
|
+
public challenge(_ctx: RouteContext): Response {
|
|
48
|
+
const cid = randomBytes(16);
|
|
49
|
+
const nonce = randomBytes(32);
|
|
50
|
+
const iat = Time.nowSeconds();
|
|
51
|
+
const exp = iat + CHALLENGE_TTL_SECS;
|
|
52
|
+
|
|
53
|
+
// Sign (iat, exp, cid, nonce) so /verify can confirm the edge issued
|
|
54
|
+
// this exact challenge with no stored state.
|
|
55
|
+
const blob = new DataWriter()
|
|
56
|
+
.writeU64(iat)
|
|
57
|
+
.writeU64(exp)
|
|
58
|
+
.writeBytes(cid)
|
|
59
|
+
.writeBytes(nonce)
|
|
60
|
+
.toBytes();
|
|
61
|
+
const token = SecureCookies.signed(challengeKey()).sign('pqchal', base64UrlEncode(blob));
|
|
62
|
+
|
|
63
|
+
const w = new DataWriter();
|
|
64
|
+
w.writeString(AUD);
|
|
65
|
+
w.writeBytes(cid);
|
|
66
|
+
w.writeBytes(nonce);
|
|
67
|
+
w.writeU64(iat);
|
|
68
|
+
w.writeU64(exp);
|
|
69
|
+
w.writeString(token);
|
|
70
|
+
return Response.bytes(w.toBytes());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** POST /pq/verify
|
|
74
|
+
* body: str(sub) str(token) bytes(publicKey 1312) bytes(signature 2420)
|
|
75
|
+
* resp: text VALID / INVALID */
|
|
76
|
+
@post('/verify')
|
|
77
|
+
public verify(ctx: RouteContext): Response {
|
|
78
|
+
const r = new DataReader(ctx.request.body);
|
|
79
|
+
const sub = r.readString();
|
|
80
|
+
const token = r.readString();
|
|
81
|
+
const pk = r.readBytes();
|
|
82
|
+
const sig = r.readBytes();
|
|
83
|
+
if (!r.ok) return Response.text('malformed envelope\n', 400);
|
|
84
|
+
|
|
85
|
+
// 1. Re-open the challenge token: must be server-issued + untampered.
|
|
86
|
+
const blobB64 = SecureCookies.signed(challengeKey()).unsign('pqchal', token);
|
|
87
|
+
if (blobB64 == null) return Response.text('INVALID: forged or unsigned challenge\n', 401);
|
|
88
|
+
const blob = base64UrlDecode(blobB64);
|
|
89
|
+
if (blob == null) return Response.text('INVALID: malformed challenge\n', 401);
|
|
90
|
+
const br = new DataReader(blob);
|
|
91
|
+
const iat = br.readU64();
|
|
92
|
+
const exp = br.readU64();
|
|
93
|
+
const cid = br.readBytes();
|
|
94
|
+
const nonce = br.readBytes();
|
|
95
|
+
if (!br.ok) return Response.text('INVALID: malformed challenge\n', 401);
|
|
96
|
+
if (Time.nowSeconds() >= exp) return Response.text('INVALID: challenge expired\n', 401);
|
|
97
|
+
|
|
98
|
+
// 2. Rebuild the message from the SERVER's values (inside the token,
|
|
99
|
+
// never client-echoed) and verify the ML-DSA-44 signature.
|
|
100
|
+
const message = AuthService.buildLoginMessage(sub, AUD, cid, nonce, iat, exp);
|
|
101
|
+
const ok = AuthService.verifyLogin(pk, message, sig);
|
|
102
|
+
return Response.text(
|
|
103
|
+
ok
|
|
104
|
+
? 'VALID: server-issued challenge signed and verified (ML-DSA-44, FIPS 204)\n'
|
|
105
|
+
: 'INVALID: signature did not verify\n',
|
|
106
|
+
ok ? 200 : 401,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Response, RouteContext } from 'toiljs/server/runtime';
|
|
2
|
+
import { DataReader, DataWriter } from 'data';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Session demo: the `@user` / `@auth` / typed `AuthService.getUser()` surface.
|
|
6
|
+
*
|
|
7
|
+
* `@user` declares the authenticated user's shape; it becomes a binary codec
|
|
8
|
+
* (like `@data`) AND registers the type of `AuthService.getUser()` everywhere,
|
|
9
|
+
* server and generated client, with NO type argument.
|
|
10
|
+
*
|
|
11
|
+
* `@auth` on a route (or a whole `@rest` class) makes the generated dispatcher
|
|
12
|
+
* verify a valid signed session BEFORE the handler runs (401 otherwise).
|
|
13
|
+
*
|
|
14
|
+
* The session is an HMAC-signed `__Host-` cookie minted by `AuthService.mintSession`.
|
|
15
|
+
* In a real app you mint it in `Auth.loginFinish` AFTER `verifyLogin` succeeds;
|
|
16
|
+
* this `/session/dev-login` mints one for a caller-named demo user so the flow is
|
|
17
|
+
* runnable without the external account store the login example stubs out.
|
|
18
|
+
*
|
|
19
|
+
* The server secret defaults to a well-known DEV placeholder; a real deployment
|
|
20
|
+
* calls `AuthService.setSecret(...)` once at startup (see server/main.ts).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// @user: the authenticated-user shape. Exactly one per program.
|
|
24
|
+
@user
|
|
25
|
+
class Account {
|
|
26
|
+
username: string = '';
|
|
27
|
+
admin: bool = false;
|
|
28
|
+
score: u64 = 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@rest('session')
|
|
32
|
+
class Session {
|
|
33
|
+
/** POST /session/dev-login body: str(username) -> sets the session cookie.
|
|
34
|
+
* DEV ONLY: a real app mints in loginFinish after the signature verifies. */
|
|
35
|
+
@post('/dev-login')
|
|
36
|
+
public devLogin(ctx: RouteContext): Response {
|
|
37
|
+
const username = new DataReader(ctx.request.body).readString();
|
|
38
|
+
const u = new Account();
|
|
39
|
+
u.username = username;
|
|
40
|
+
u.admin = username == 'root';
|
|
41
|
+
u.score = 0;
|
|
42
|
+
|
|
43
|
+
const data = u.encode();
|
|
44
|
+
const resp = Response.text('ok\n', 200);
|
|
45
|
+
resp.setCookie(AuthService.mintSession(data, 3600)); // HttpOnly signed session
|
|
46
|
+
resp.setCookie(AuthService.userCookie(data, 3600)); // readable companion (client getUser)
|
|
47
|
+
return resp;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** GET /session/me (@auth: 401 without a valid session) -> the typed user.
|
|
51
|
+
* `AuthService.getUser()` is auto-typed to `Account` with no type argument. */
|
|
52
|
+
@auth
|
|
53
|
+
@get('/me')
|
|
54
|
+
public me(_ctx: RouteContext): Response {
|
|
55
|
+
const u = AuthService.getUser();
|
|
56
|
+
if (u == null) return Response.text('no session\n', 401);
|
|
57
|
+
const w = new DataWriter();
|
|
58
|
+
w.writeString(u.username);
|
|
59
|
+
w.writeBool(u.admin);
|
|
60
|
+
w.writeU64(u.score);
|
|
61
|
+
return Response.bytes(w.toBytes());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** POST /session/logout (@auth) -> clears the session cookie. */
|
|
65
|
+
@auth
|
|
66
|
+
@post('/logout')
|
|
67
|
+
public logout(_ctx: RouteContext): Response {
|
|
68
|
+
const resp = Response.text('bye\n', 200);
|
|
69
|
+
resp.setCookie(AuthService.clearSession());
|
|
70
|
+
resp.setCookie(AuthService.clearUserCookie());
|
|
71
|
+
return resp;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# scheduled/
|
|
2
|
+
|
|
3
|
+
Reserved for scheduled tasks: cron-style jobs that will run on the Toil edge runtime.
|
|
4
|
+
|
|
5
|
+
The scheduling API has not shipped yet. The folder convention exists today so your project
|
|
6
|
+
layout will not change when it lands; until then, anything in here is ignored by the build
|
|
7
|
+
(only `.ts` files with a server surface are compiled).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { store } from '../core/store';
|
|
2
|
+
|
|
3
|
+
/** Typed RPC service (transport still a TODO): reached as `Server.stats.playerCount()` on the client. */
|
|
4
|
+
@service
|
|
5
|
+
class Stats {
|
|
6
|
+
/** Number of seeded players (the RPC transport is a TODO, so this throws on the client for now). */
|
|
7
|
+
@remote
|
|
8
|
+
public playerCount(): i32 {
|
|
9
|
+
return store.size;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Server } from 'toiljs/server/runtime';
|
|
2
|
+
import { revertOnError } from 'toiljs/server/runtime/abort/abort';
|
|
3
|
+
import { SpinHandler } from './SpinHandler';
|
|
4
|
+
|
|
5
|
+
Server.handler = () => {
|
|
6
|
+
return new SpinHandler();
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export * from 'toiljs/server/runtime/exports';
|
|
10
|
+
|
|
11
|
+
export function abort(message: string, fileName: string, line: u32, column: u32): void {
|
|
12
|
+
revertOnError(message, fileName, line, column);
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// AUTO-GENERATED by toil (edge SSR). Do not edit.
|
|
2
|
+
// Route: greeting. Slot ids match the deployed .slots manifest; HASH is the
|
|
3
|
+
// coherence hash the host checks against the template (deploy-skew guard).
|
|
4
|
+
//
|
|
5
|
+
// (For this example the values are hand-fixed; in a real build `template.ts`
|
|
6
|
+
// computes them from the route's rendered template.)
|
|
7
|
+
|
|
8
|
+
/** Stable hole ids for this route's template. */
|
|
9
|
+
export enum Slot {
|
|
10
|
+
greeting = 0,
|
|
11
|
+
count = 1,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Coherence hash (32 bytes) baked into the guest and echoed in every values
|
|
15
|
+
* envelope; the host rejects a response whose hash != the deployed template. */
|
|
16
|
+
export const HASH: StaticArray<u8> = [
|
|
17
|
+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
|
18
|
+
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
|
19
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge-SSR example entry. Registers the `/hello` render (side-effect import),
|
|
3
|
+
* sets a no-op HTTP handler (so the `handle` export is well-formed), and
|
|
4
|
+
* surfaces the wasm exports — including `render(i32, i32) -> i64`.
|
|
5
|
+
*/
|
|
6
|
+
import { Server, ToilHandler } from 'toiljs/server/runtime';
|
|
7
|
+
import { revertOnError } from 'toiljs/server/runtime/abort/abort';
|
|
8
|
+
import './SsrGreetingRender';
|
|
9
|
+
|
|
10
|
+
Server.handler = () => {
|
|
11
|
+
return new ToilHandler();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export * from 'toiljs/server/runtime/exports';
|
|
15
|
+
|
|
16
|
+
export function abort(message: string, fileName: string, line: u32, column: u32): void {
|
|
17
|
+
revertOnError(message, fileName, line, column);
|
|
18
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor-only ambient declarations for the toiljs cookie globals.
|
|
3
|
+
*
|
|
4
|
+
* `Cookie`, `Cookies`, `SecureCookies`, and the `SameSite` / `CookieEncoding` /
|
|
5
|
+
* `CookiePrefix` enums are `@global` in the toiljs server runtime, so a handler
|
|
6
|
+
* uses them with no import (exactly like `crypto`). The toilscript compiler
|
|
7
|
+
* registers them from the runtime; this file just gives the editor their shapes
|
|
8
|
+
* so it does not flag the unimported names. It is auto-included by the server
|
|
9
|
+
* `tsconfig.json` (`include: ["./**/*.ts"]`) and ignored by the compiler.
|
|
10
|
+
*
|
|
11
|
+
* `toiljs create` scaffolds this file; keep it in sync with
|
|
12
|
+
* `toiljs/server/runtime/http/*`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
declare enum SameSite {
|
|
16
|
+
Default = 0,
|
|
17
|
+
None = 1,
|
|
18
|
+
Lax = 2,
|
|
19
|
+
Strict = 3,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare enum CookieEncoding {
|
|
23
|
+
Percent = 0,
|
|
24
|
+
Raw = 1,
|
|
25
|
+
Base64Url = 2,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare enum CookiePrefix {
|
|
29
|
+
None = 0,
|
|
30
|
+
Secure = 1,
|
|
31
|
+
Host = 2,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare class CookieValidation {
|
|
35
|
+
valid: bool;
|
|
36
|
+
errors: Array<string>;
|
|
37
|
+
fail(msg: string): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare class Cookie {
|
|
41
|
+
name: string;
|
|
42
|
+
value: string;
|
|
43
|
+
encoding: CookieEncoding;
|
|
44
|
+
constructor(name: string, value: string);
|
|
45
|
+
static create(name: string, value: string): Cookie;
|
|
46
|
+
domain(v: string): Cookie;
|
|
47
|
+
path(v: string): Cookie;
|
|
48
|
+
maxAge(seconds: i64): Cookie;
|
|
49
|
+
expires(epochSeconds: i64): Cookie;
|
|
50
|
+
expiresRaw(date: string): Cookie;
|
|
51
|
+
secure(on?: bool): Cookie;
|
|
52
|
+
httpOnly(on?: bool): Cookie;
|
|
53
|
+
sameSite(s: SameSite): Cookie;
|
|
54
|
+
partitioned(on?: bool): Cookie;
|
|
55
|
+
priority(p: string): Cookie;
|
|
56
|
+
extension(av: string): Cookie;
|
|
57
|
+
withEncoding(e: CookieEncoding): Cookie;
|
|
58
|
+
asSecurePrefixed(): Cookie;
|
|
59
|
+
asHostPrefixed(): Cookie;
|
|
60
|
+
detectedPrefix(): CookiePrefix;
|
|
61
|
+
encodedValue(): string;
|
|
62
|
+
validate(): CookieValidation;
|
|
63
|
+
serialize(strict?: bool): string;
|
|
64
|
+
toString(): string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare class CookieMap {
|
|
68
|
+
set(name: string, value: string): void;
|
|
69
|
+
get(name: string): string | null;
|
|
70
|
+
has(name: string): bool;
|
|
71
|
+
names(): Array<string>;
|
|
72
|
+
readonly size: i32;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
declare class Cookies {
|
|
76
|
+
static parse(cookieHeader: string): CookieMap;
|
|
77
|
+
static get(cookieHeader: string, name: string): string | null;
|
|
78
|
+
static serialize(name: string, value: string): string;
|
|
79
|
+
static parseSetCookie(setCookie: string): Cookie;
|
|
80
|
+
static encodeValue(raw: string): string;
|
|
81
|
+
static decodeValue(enc: string): string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare class SecureCookies {
|
|
85
|
+
static signed(key: Uint8Array): SecureCookies;
|
|
86
|
+
static encrypted(key: Uint8Array): SecureCookies;
|
|
87
|
+
addKey(key: Uint8Array): SecureCookies;
|
|
88
|
+
sign(name: string, value: string): string;
|
|
89
|
+
unsign(name: string, sealed: string): string | null;
|
|
90
|
+
encrypt(name: string, value: string): string;
|
|
91
|
+
decrypt(name: string, sealed: string): string | null;
|
|
92
|
+
seal(cookie: Cookie): Cookie;
|
|
93
|
+
open(jar: CookieMap, name: string): string | null;
|
|
94
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Server } from 'toiljs/server/runtime';
|
|
2
|
+
import { revertOnError } from 'toiljs/server/runtime/abort/abort';
|
|
3
|
+
import { FastTrapHandler } from './FastTrapHandler';
|
|
4
|
+
Server.handler = () => { return new FastTrapHandler(); };
|
|
5
|
+
export * from 'toiljs/server/runtime/exports';
|
|
6
|
+
export function abort(message: string, fileName: string, line: u32, column: u32): void {
|
|
7
|
+
revertOnError(message, fileName, line, column);
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toiljs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.36",
|
|
5
5
|
"author": "Dacely",
|
|
6
6
|
"description": "The modern React framework: a file-based React frontend and a ToilScript-compiled WebAssembly backend.",
|
|
7
7
|
"repository": {
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
},
|
|
96
96
|
"scripts": {
|
|
97
97
|
"watch": "tsc -p tsconfig.json --watch",
|
|
98
|
-
"build": "npm run build:shared && npm run build:logger && npm run build:
|
|
98
|
+
"build": "npm run build:shared && npm run build:logger && npm run build:io && npm run build:client && npm run build:backend && npm run build:devserver && npm run build:compiler && npm run build:cli",
|
|
99
99
|
"build:shared": "tsc -p tsconfig.shared.json",
|
|
100
100
|
"build:logger": "tsc -p tsconfig.logger.json",
|
|
101
101
|
"build:client": "tsc -p tsconfig.client.json",
|
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
"setup": "npm i && npm run build"
|
|
117
117
|
},
|
|
118
118
|
"dependencies": {
|
|
119
|
+
"@btc-vision/post-quantum": "^0.5.3",
|
|
119
120
|
"@dacely/hyper-express": "6.17.4",
|
|
120
121
|
"@dacely/toilscript-loader": "^0.1.0",
|
|
121
122
|
"@eslint-react/eslint-plugin": "^5.8.8",
|
|
@@ -124,9 +125,10 @@
|
|
|
124
125
|
"@vitejs/plugin-react": "^6.0.2",
|
|
125
126
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
126
127
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
128
|
+
"hash-wasm": "^4.12.0",
|
|
127
129
|
"picocolors": "^1.1.1",
|
|
128
130
|
"sharp": "^0.35.0",
|
|
129
|
-
"toilscript": "^0.1.
|
|
131
|
+
"toilscript": "^0.1.22",
|
|
130
132
|
"typescript-eslint": "^8.60.0",
|
|
131
133
|
"vite": "^8.0.14",
|
|
132
134
|
"vite-imagetools": "^10.0.0",
|