toiljs 0.0.115 → 0.0.117
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 +10 -0
- package/README.md +16 -7
- package/TYPESCRIPT_LAW.md +1946 -2073
- package/build/backend/.tsbuildinfo +1 -1
- package/build/cli/.tsbuildinfo +1 -1
- package/build/cli/index.js +2375 -258
- package/build/client/.tsbuildinfo +1 -1
- package/build/client/dev/devtools.js +1 -1
- package/build/client/dev/error-overlay.js +1 -1
- package/build/client/routing/mount.js +1 -1
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/auth-emails.js +7 -3
- package/build/compiler/emails.js +1 -1
- package/build/compiler/index.d.ts +1 -0
- package/build/compiler/index.js +25 -4
- package/build/compiler/pages.js +2 -3
- package/build/compiler/prerender.d.ts +3 -8
- package/build/compiler/prerender.js +88 -127
- package/build/compiler/ssg.js +3 -4
- package/build/compiler/template-build.js +3 -4
- package/build/compiler/toil-docs.generated.js +6 -5
- package/build/compiler/vite.js +3 -6
- package/build/devserver/.tsbuildinfo +1 -1
- package/build/devserver/db/database.js +7 -3
- package/build/devserver/db/types.js +1 -1
- package/build/devserver/production.js +4 -3
- package/build/devserver/runtime/crypto.d.ts +1 -1
- package/build/io/.tsbuildinfo +1 -1
- package/build/logger/.tsbuildinfo +1 -1
- package/build/shared/.tsbuildinfo +1 -1
- package/examples/basic/client/routes/analytics.tsx +7 -5
- package/examples/basic/server/tsconfig.json +1 -3
- package/package.json +45 -44
- package/presets/no-uint8array-tostring.js +120 -153
- package/presets/oxlint.d.ts +5 -0
- package/presets/oxlint.js +224 -0
- package/server/runtime/tsconfig.json +1 -3
- package/tsconfig.json +2 -11
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -43
- package/.github/changelog-config.json +0 -45
- package/.github/dependabot.yml +0 -27
- package/.github/workflows/ci.yml +0 -222
- package/.vscode/settings.json +0 -10
- package/docs/README.md +0 -107
- package/docs/auth/README.md +0 -104
- package/docs/auth/configuration.md +0 -105
- package/docs/auth/emails.md +0 -92
- package/docs/auth/extending.md +0 -202
- package/docs/auth/how-it-works.md +0 -138
- package/docs/auth/usage.md +0 -188
- package/docs/backend/README.md +0 -143
- package/docs/backend/data.md +0 -351
- package/docs/backend/rest.md +0 -402
- package/docs/backend/rpc.md +0 -226
- package/docs/background/README.md +0 -114
- package/docs/background/daemons.md +0 -276
- package/docs/background/derive.md +0 -179
- package/docs/cli/README.md +0 -379
- package/docs/concepts/ai-guide.md +0 -132
- package/docs/concepts/config.md +0 -416
- package/docs/concepts/decorators.md +0 -127
- package/docs/concepts/security.md +0 -108
- package/docs/concepts/tiers.md +0 -166
- package/docs/concepts/types.md +0 -216
- package/docs/database/README.md +0 -143
- package/docs/database/capacity.md +0 -350
- package/docs/database/counters.md +0 -174
- package/docs/database/documents.md +0 -277
- package/docs/database/events.md +0 -307
- package/docs/database/membership.md +0 -246
- package/docs/database/setup.md +0 -155
- package/docs/database/unique.md +0 -216
- package/docs/database/views.md +0 -246
- package/docs/frontend/README.md +0 -104
- package/docs/frontend/components.md +0 -286
- package/docs/frontend/data-fetching.md +0 -260
- package/docs/frontend/images.md +0 -148
- package/docs/frontend/metadata.md +0 -344
- package/docs/frontend/navigation.md +0 -296
- package/docs/frontend/rendering.md +0 -236
- package/docs/frontend/routing.md +0 -346
- package/docs/frontend/scripts.md +0 -118
- package/docs/frontend/search.md +0 -191
- package/docs/frontend/styling.md +0 -147
- package/docs/frontend/toil-global.md +0 -216
- package/docs/getting-started/README.md +0 -81
- package/docs/getting-started/create-project.md +0 -131
- package/docs/getting-started/deploy.md +0 -101
- package/docs/getting-started/first-app.md +0 -215
- package/docs/getting-started/installation.md +0 -124
- package/docs/getting-started/migrating.md +0 -125
- package/docs/getting-started/project-structure.md +0 -163
- package/docs/introduction/README.md +0 -66
- package/docs/introduction/design-principles.md +0 -81
- package/docs/introduction/distributed.md +0 -91
- package/docs/introduction/how-it-works.md +0 -121
- package/docs/introduction/hyperscale.md +0 -70
- package/docs/introduction/modern-stack.md +0 -85
- package/docs/introduction/vs-other-frameworks.md +0 -64
- package/docs/introduction/why-toil.md +0 -99
- package/docs/llms.txt +0 -95
- package/docs/realtime/README.md +0 -102
- package/docs/realtime/channels.md +0 -211
- package/docs/realtime/streams.md +0 -369
- package/docs/services/README.md +0 -60
- package/docs/services/analytics.md +0 -279
- package/docs/services/caching.md +0 -175
- package/docs/services/cookies.md +0 -235
- package/docs/services/crypto.md +0 -209
- package/docs/services/email.md +0 -289
- package/docs/services/environment.md +0 -141
- package/docs/services/ratelimit.md +0 -174
- package/docs/services/time.md +0 -85
- package/eslint.config.js +0 -57
- package/examples/basic/client/routes/docs/[...slug].tsx +0 -12
- package/presets/eslint.js +0 -88
- package/src/backend/index.ts +0 -204
- package/src/cli/configure.ts +0 -363
- package/src/cli/create.ts +0 -924
- package/src/cli/db.ts +0 -158
- package/src/cli/diagnostics.ts +0 -665
- package/src/cli/doctor.ts +0 -982
- package/src/cli/features.ts +0 -170
- package/src/cli/index.ts +0 -326
- package/src/cli/notify.ts +0 -120
- package/src/cli/proc.ts +0 -56
- package/src/cli/ui.ts +0 -169
- package/src/cli/update.ts +0 -248
- package/src/cli/updates.ts +0 -92
- package/src/cli/validate.ts +0 -31
- package/src/cli/version-check.ts +0 -125
- package/src/client/auth.ts +0 -869
- package/src/client/channel/channel.ts +0 -146
- package/src/client/components/Form.tsx +0 -65
- package/src/client/components/Image.tsx +0 -160
- package/src/client/components/Script.tsx +0 -113
- package/src/client/components/Slot.tsx +0 -21
- package/src/client/dev/devtools.tsx +0 -1089
- package/src/client/dev/error-overlay.tsx +0 -225
- package/src/client/errors.ts +0 -11
- package/src/client/head/head.ts +0 -182
- package/src/client/head/metadata.ts +0 -110
- package/src/client/index.ts +0 -130
- package/src/client/navigation/Link.tsx +0 -108
- package/src/client/navigation/NavLink.tsx +0 -86
- package/src/client/navigation/navigation.ts +0 -235
- package/src/client/navigation/prefetch.ts +0 -169
- package/src/client/navigation/scroll.ts +0 -53
- package/src/client/routing/Router.tsx +0 -216
- package/src/client/routing/action.ts +0 -122
- package/src/client/routing/error-boundary.tsx +0 -43
- package/src/client/routing/hooks.ts +0 -140
- package/src/client/routing/lazy.ts +0 -77
- package/src/client/routing/loader.ts +0 -381
- package/src/client/routing/match.ts +0 -47
- package/src/client/routing/mount.tsx +0 -90
- package/src/client/routing/params-context.ts +0 -10
- package/src/client/routing/slot-context.ts +0 -7
- package/src/client/rpc.ts +0 -97
- package/src/client/search/search.ts +0 -189
- package/src/client/search/use-page-search.ts +0 -73
- package/src/client/ssr/markers.tsx +0 -172
- package/src/client/stream/client.ts +0 -237
- package/src/client/types.ts +0 -73
- package/src/compiler/auth-emails.ts +0 -312
- package/src/compiler/config.ts +0 -369
- package/src/compiler/docs.ts +0 -127
- package/src/compiler/email-preview.ts +0 -314
- package/src/compiler/emails.ts +0 -404
- package/src/compiler/fonts.ts +0 -89
- package/src/compiler/generate.ts +0 -471
- package/src/compiler/image-blur.ts +0 -42
- package/src/compiler/image-report.ts +0 -88
- package/src/compiler/index.ts +0 -1362
- package/src/compiler/pages.ts +0 -49
- package/src/compiler/plugin.ts +0 -391
- package/src/compiler/prerender.ts +0 -263
- package/src/compiler/routes.ts +0 -170
- package/src/compiler/seo.ts +0 -415
- package/src/compiler/sri.ts +0 -144
- package/src/compiler/ssg.ts +0 -177
- package/src/compiler/ssr-codegen.ts +0 -85
- package/src/compiler/template-build.ts +0 -676
- package/src/compiler/template.ts +0 -262
- package/src/compiler/toil-docs.generated.ts +0 -77
- package/src/compiler/vite.ts +0 -245
- package/src/devserver/analytics/index.ts +0 -317
- package/src/devserver/config/dotenv.ts +0 -102
- package/src/devserver/config/env.ts +0 -30
- package/src/devserver/config/ratelimit.ts +0 -123
- package/src/devserver/daemon/catalog.ts +0 -120
- package/src/devserver/daemon/cron.ts +0 -87
- package/src/devserver/daemon/host.ts +0 -134
- package/src/devserver/daemon/index.ts +0 -369
- package/src/devserver/daemon/runtime.ts +0 -48
- package/src/devserver/db/catalog.ts +0 -109
- package/src/devserver/db/database.ts +0 -1834
- package/src/devserver/db/derives.ts +0 -121
- package/src/devserver/db/index.ts +0 -20
- package/src/devserver/db/routeKinds.ts +0 -191
- package/src/devserver/db/types.ts +0 -168
- package/src/devserver/email/caps.ts +0 -0
- package/src/devserver/email/config.ts +0 -141
- package/src/devserver/email/console.ts +0 -348
- package/src/devserver/email/index.ts +0 -155
- package/src/devserver/email/providers.ts +0 -131
- package/src/devserver/email/status.ts +0 -23
- package/src/devserver/email/validate.ts +0 -37
- package/src/devserver/email/wire.ts +0 -55
- package/src/devserver/http/cache.ts +0 -0
- package/src/devserver/http/envelope.ts +0 -157
- package/src/devserver/http/proxy.ts +0 -172
- package/src/devserver/http/runtime.ts +0 -387
- package/src/devserver/index.ts +0 -43
- package/src/devserver/production-ipc.ts +0 -63
- package/src/devserver/production-worker.ts +0 -83
- package/src/devserver/production.ts +0 -718
- package/src/devserver/runtime/crypto.ts +0 -587
- package/src/devserver/runtime/host.ts +0 -427
- package/src/devserver/runtime/module.ts +0 -442
- package/src/devserver/server.ts +0 -251
- package/src/devserver/ssr.ts +0 -208
- package/src/devserver/stream/catalog.ts +0 -106
- package/src/devserver/stream/host.ts +0 -42
- package/src/devserver/stream/index.ts +0 -301
- package/src/devserver/stream/manager.ts +0 -167
- package/src/devserver/stream/router.ts +0 -101
- package/src/devserver/stream/wire.ts +0 -58
- package/src/devserver/stream/ws.ts +0 -78
- package/src/devserver/wasm/sections.ts +0 -59
- package/src/devserver/wasm/surface.ts +0 -115
- package/src/io/FastMap.ts +0 -151
- package/src/io/FastSet.ts +0 -113
- package/src/io/codec.ts +0 -362
- package/src/io/index.ts +0 -10
- package/src/io/lengths.ts +0 -14
- package/src/io/types.ts +0 -19
- package/src/logger/index.ts +0 -22
- package/src/shared/index.ts +0 -46
- package/test/analytics-dev.test.ts +0 -113
- package/test/assembly/aspect-shim.ts +0 -33
- package/test/assembly/cookie.spec.ts +0 -303
- package/test/assembly/example.spec.ts +0 -22
- package/test/assembly/ssr.spec.ts +0 -95
- package/test/assembly.test.ts +0 -59
- package/test/auth-emails.test.ts +0 -118
- package/test/built-ssr.test.ts +0 -148
- package/test/channel.test.ts +0 -21
- package/test/config-host-port.test.ts +0 -59
- package/test/configure.test.ts +0 -94
- package/test/daemon-build.test.ts +0 -278
- package/test/daemon-catalog.test.ts +0 -349
- package/test/daemon-emulation.test.ts +0 -256
- package/test/db.test.ts +0 -0
- package/test/devserver-database.test.ts +0 -1102
- package/test/devserver-email.test.ts +0 -306
- package/test/devserver-pqauth.test.ts +0 -93
- package/test/devserver-secrets.test.ts +0 -63
- package/test/devserver.test.ts +0 -259
- package/test/doctor.test.ts +0 -298
- package/test/dom/Image.test.tsx +0 -144
- package/test/dom/Link.test.tsx +0 -67
- package/test/dom/NavLink.test.tsx +0 -37
- package/test/dom/Script.test.tsx +0 -48
- package/test/dom/action.test.tsx +0 -146
- package/test/dom/error-overlay.test.tsx +0 -44
- package/test/dom/loader.test.tsx +0 -121
- package/test/dom/navigation.test.ts +0 -59
- package/test/dom/revalidate.test.tsx +0 -38
- package/test/dom/route-head.test.tsx +0 -56
- package/test/dom/router-loading.test.tsx +0 -44
- package/test/dom/scroll.test.ts +0 -56
- package/test/dom/slot.test.tsx +0 -131
- package/test/dom/use-metadata.test.tsx +0 -58
- package/test/dom/view-transitions.test.tsx +0 -53
- package/test/dynamic-routing.test.ts +0 -132
- package/test/email-console.test.ts +0 -86
- package/test/email-preview.test.ts +0 -73
- package/test/emails.test.ts +0 -58
- package/test/errors.test.ts +0 -21
- package/test/example-guestbook.test.ts +0 -123
- package/test/features.test.ts +0 -149
- package/test/fixtures/bignum-wire/spec.ts +0 -25
- package/test/fixtures/daemon-app.ts +0 -65
- package/test/fixtures/stream-echo.ts +0 -26
- package/test/fixtures/stream-gate.ts +0 -28
- package/test/fixtures/stream-trap.ts +0 -18
- package/test/fixtures/stream-typed.ts +0 -41
- package/test/fonts.test.ts +0 -28
- package/test/global-setup.ts +0 -17
- package/test/head.test.ts +0 -42
- package/test/image-blur.test.ts +0 -50
- package/test/io.test.ts +0 -117
- package/test/metadata.test.ts +0 -40
- package/test/navlink.test.ts +0 -28
- package/test/pages.test.ts +0 -105
- package/test/placeholder.test.ts +0 -9
- package/test/pqauth-e2e.test.ts +0 -216
- package/test/pqauth-email.test.ts +0 -801
- package/test/prerender.test.ts +0 -116
- package/test/prettier-plugin.test.ts +0 -46
- package/test/routes.test.ts +0 -76
- package/test/rpc-bignum-wire.test.ts +0 -164
- package/test/rpc-dispatch.test.ts +0 -132
- package/test/rpc-kinds.test.ts +0 -18
- package/test/rpc.test.ts +0 -66
- package/test/search.test.ts +0 -114
- package/test/seo.test.ts +0 -175
- package/test/slot-layouts.test.ts +0 -69
- package/test/sri.test.ts +0 -129
- package/test/ssg.test.ts +0 -36
- package/test/ssr-hydration.test.tsx +0 -122
- package/test/ssr-render.test.ts +0 -197
- package/test/ssr-template.test.tsx +0 -482
- package/test/stream-emulation.test.ts +0 -479
- package/test/ui.test.ts +0 -40
- package/test/update.test.ts +0 -58
- package/test/validate.test.ts +0 -42
- package/test/version-check.test.ts +0 -130
- package/tests/data-parity/generated-parity.ts +0 -99
- package/tests/data-parity/parity.ts +0 -80
- package/tests/data-parity/spec.ts +0 -46
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
name: Bug Report
|
|
2
|
-
description: Report a bug in toiljs
|
|
3
|
-
title: "[Bug]: "
|
|
4
|
-
labels: ["bug", "triage"]
|
|
5
|
-
body:
|
|
6
|
-
- type: markdown
|
|
7
|
-
attributes:
|
|
8
|
-
value: |
|
|
9
|
-
Thanks for taking the time to report a bug.
|
|
10
|
-
|
|
11
|
-
**Security Notice**: If this is a security vulnerability, DO NOT create a public issue. Report it privately via [GitHub Security Advisories](https://github.com/dacely-cloud/toiljs/security/advisories/new).
|
|
12
|
-
|
|
13
|
-
- type: textarea
|
|
14
|
-
id: description
|
|
15
|
-
attributes:
|
|
16
|
-
label: Bug Description
|
|
17
|
-
description: A clear and concise description of the bug.
|
|
18
|
-
placeholder: Describe the bug...
|
|
19
|
-
validations:
|
|
20
|
-
required: true
|
|
21
|
-
|
|
22
|
-
- type: textarea
|
|
23
|
-
id: reproduction
|
|
24
|
-
attributes:
|
|
25
|
-
label: Steps to Reproduce
|
|
26
|
-
description: Steps to reproduce the behavior.
|
|
27
|
-
placeholder: |
|
|
28
|
-
1. ...
|
|
29
|
-
2. ...
|
|
30
|
-
3. ...
|
|
31
|
-
validations:
|
|
32
|
-
required: true
|
|
33
|
-
|
|
34
|
-
- type: textarea
|
|
35
|
-
id: expected
|
|
36
|
-
attributes:
|
|
37
|
-
label: Expected Behavior
|
|
38
|
-
description: What did you expect to happen?
|
|
39
|
-
validations:
|
|
40
|
-
required: true
|
|
41
|
-
|
|
42
|
-
- type: textarea
|
|
43
|
-
id: actual
|
|
44
|
-
attributes:
|
|
45
|
-
label: Actual Behavior
|
|
46
|
-
description: What actually happened?
|
|
47
|
-
validations:
|
|
48
|
-
required: true
|
|
49
|
-
|
|
50
|
-
- type: input
|
|
51
|
-
id: version
|
|
52
|
-
attributes:
|
|
53
|
-
label: toiljs Version
|
|
54
|
-
description: What version of toiljs are you using?
|
|
55
|
-
placeholder: "0.0.1"
|
|
56
|
-
validations:
|
|
57
|
-
required: true
|
|
58
|
-
|
|
59
|
-
- type: input
|
|
60
|
-
id: node-version
|
|
61
|
-
attributes:
|
|
62
|
-
label: Node.js Version
|
|
63
|
-
description: What version of Node.js are you using?
|
|
64
|
-
placeholder: "22.0.0"
|
|
65
|
-
validations:
|
|
66
|
-
required: true
|
|
67
|
-
|
|
68
|
-
- type: textarea
|
|
69
|
-
id: code
|
|
70
|
-
attributes:
|
|
71
|
-
label: Code Example
|
|
72
|
-
description: Minimal code that reproduces the issue.
|
|
73
|
-
render: typescript
|
|
74
|
-
|
|
75
|
-
- type: textarea
|
|
76
|
-
id: logs
|
|
77
|
-
attributes:
|
|
78
|
-
label: Relevant Logs
|
|
79
|
-
description: Please copy and paste any relevant log output.
|
|
80
|
-
render: shell
|
|
81
|
-
|
|
82
|
-
- type: checkboxes
|
|
83
|
-
id: terms
|
|
84
|
-
attributes:
|
|
85
|
-
label: Checklist
|
|
86
|
-
options:
|
|
87
|
-
- label: I have searched existing issues to ensure this bug hasn't been reported
|
|
88
|
-
required: true
|
|
89
|
-
- label: This is NOT a security vulnerability (those should be reported privately)
|
|
90
|
-
required: true
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
blank_issues_enabled: true
|
|
2
|
-
contact_links:
|
|
3
|
-
- name: Security Vulnerability
|
|
4
|
-
url: https://github.com/dacely-cloud/toiljs/security/advisories/new
|
|
5
|
-
about: Report a security vulnerability privately. DO NOT create a public issue for security vulnerabilities.
|
|
6
|
-
- name: Toil Website
|
|
7
|
-
url: https://toil.org/
|
|
8
|
-
about: Visit the Toil homepage for documentation and support.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Feature request
|
|
3
|
-
about: Suggest an idea for this project
|
|
4
|
-
title: ''
|
|
5
|
-
labels: ''
|
|
6
|
-
assignees: ''
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Is your feature request related to a problem? Please describe.**
|
|
11
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
-
|
|
13
|
-
**Describe the solution you'd like**
|
|
14
|
-
A clear and concise description of what you want to happen.
|
|
15
|
-
|
|
16
|
-
**Describe alternatives you've considered**
|
|
17
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
-
|
|
19
|
-
**Additional context**
|
|
20
|
-
Add any other context or screenshots about the feature request here.
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
## Description
|
|
2
|
-
<!-- Brief description of the changes in this PR -->
|
|
3
|
-
|
|
4
|
-
## Type of Change
|
|
5
|
-
<!-- Mark the relevant option with an "x" -->
|
|
6
|
-
|
|
7
|
-
- [ ] Bug fix (non-breaking change that fixes an issue)
|
|
8
|
-
- [ ] New feature (non-breaking change that adds functionality)
|
|
9
|
-
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
|
10
|
-
- [ ] Performance improvement
|
|
11
|
-
- [ ] Refactoring (no functional changes)
|
|
12
|
-
- [ ] Documentation update
|
|
13
|
-
- [ ] CI/CD changes
|
|
14
|
-
- [ ] Dependencies update
|
|
15
|
-
|
|
16
|
-
## Checklist
|
|
17
|
-
|
|
18
|
-
### Build & Tests
|
|
19
|
-
- [ ] `npm install` completes without errors
|
|
20
|
-
- [ ] `npm test` passes all tests
|
|
21
|
-
|
|
22
|
-
### Code Quality
|
|
23
|
-
- [ ] Code follows the project's coding standards
|
|
24
|
-
- [ ] No new compiler warnings introduced
|
|
25
|
-
- [ ] Error handling is appropriate
|
|
26
|
-
|
|
27
|
-
### Documentation
|
|
28
|
-
- [ ] Code comments added for complex logic
|
|
29
|
-
- [ ] Public APIs are documented
|
|
30
|
-
- [ ] README updated (if applicable)
|
|
31
|
-
|
|
32
|
-
### Security
|
|
33
|
-
- [ ] No sensitive data (keys, credentials) committed
|
|
34
|
-
- [ ] No new security vulnerabilities introduced
|
|
35
|
-
|
|
36
|
-
## Testing
|
|
37
|
-
<!-- Describe how you tested these changes -->
|
|
38
|
-
|
|
39
|
-
## Related Issues
|
|
40
|
-
<!-- Link any related issues: Fixes #123, Relates to #456 -->
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
By submitting this PR, I confirm that my contribution is made under the terms of the project's license.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"categories": [
|
|
3
|
-
{
|
|
4
|
-
"title": "### Breaking Changes",
|
|
5
|
-
"labels": ["breaking", "breaking-change", "BREAKING-CHANGE"]
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"title": "### Features",
|
|
9
|
-
"labels": ["feature", "feat", "enhancement"]
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"title": "### Bug Fixes",
|
|
13
|
-
"labels": ["bug", "fix", "bugfix"]
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"title": "### Performance",
|
|
17
|
-
"labels": ["performance", "perf"]
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"title": "### Documentation",
|
|
21
|
-
"labels": ["documentation", "docs"]
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"title": "### Dependencies",
|
|
25
|
-
"labels": ["dependencies", "deps"]
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"title": "### Other Changes",
|
|
29
|
-
"labels": []
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
"sort": {
|
|
33
|
-
"order": "ASC",
|
|
34
|
-
"on_property": "mergedAt"
|
|
35
|
-
},
|
|
36
|
-
"template": "#{{CHANGELOG}}",
|
|
37
|
-
"pr_template": "- #{{TITLE}} (#{{NUMBER}}) by @#{{AUTHOR}}",
|
|
38
|
-
"empty_template": "- No changes",
|
|
39
|
-
"max_tags_to_fetch": 200,
|
|
40
|
-
"max_pull_requests": 200,
|
|
41
|
-
"max_back_track_time_days": 365,
|
|
42
|
-
"tag_resolver": {
|
|
43
|
-
"method": "semver"
|
|
44
|
-
}
|
|
45
|
-
}
|
package/.github/dependabot.yml
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
|
|
3
|
-
updates:
|
|
4
|
-
- package-ecosystem: 'npm'
|
|
5
|
-
directory: '/'
|
|
6
|
-
schedule:
|
|
7
|
-
interval: 'daily'
|
|
8
|
-
time: '06:00'
|
|
9
|
-
timezone: 'America/Toronto'
|
|
10
|
-
open-pull-requests-limit: 10
|
|
11
|
-
rebase-strategy: 'auto'
|
|
12
|
-
|
|
13
|
-
groups:
|
|
14
|
-
production-deps:
|
|
15
|
-
dependency-type: 'production'
|
|
16
|
-
update-types: ['minor', 'patch']
|
|
17
|
-
dev-deps:
|
|
18
|
-
dependency-type: 'development'
|
|
19
|
-
update-types: ['minor', 'patch']
|
|
20
|
-
|
|
21
|
-
commit-message:
|
|
22
|
-
prefix: '⬆️'
|
|
23
|
-
include: scope
|
|
24
|
-
|
|
25
|
-
labels:
|
|
26
|
-
- 'dependencies'
|
|
27
|
-
- 'npm'
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
name: CI for TOILJS
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
tags:
|
|
8
|
-
- 'v*'
|
|
9
|
-
pull_request:
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
test:
|
|
13
|
-
name: Build & test
|
|
14
|
-
# Runs on PRs and pushes to main, but not on the version-tag publish runs.
|
|
15
|
-
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
|
|
16
|
-
runs-on: ubuntu-latest
|
|
17
|
-
steps:
|
|
18
|
-
- name: Checkout code
|
|
19
|
-
uses: actions/checkout@v6
|
|
20
|
-
|
|
21
|
-
- name: Setup Node.js
|
|
22
|
-
uses: actions/setup-node@v6
|
|
23
|
-
with:
|
|
24
|
-
node-version: '24.x'
|
|
25
|
-
|
|
26
|
-
- name: Install dependencies
|
|
27
|
-
run: npm install
|
|
28
|
-
|
|
29
|
-
- name: Build
|
|
30
|
-
run: npm run build
|
|
31
|
-
|
|
32
|
-
- name: Test
|
|
33
|
-
# The example wasm is not built here, so the wasm-gated end-to-end specs
|
|
34
|
-
# (ssr-render, example-guestbook) skip; the SSR unit tests (golden
|
|
35
|
-
# byte-identity, attr holes, extraction, codegen) and the rest run.
|
|
36
|
-
run: npx vitest run
|
|
37
|
-
|
|
38
|
-
publish:
|
|
39
|
-
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
40
|
-
runs-on: ubuntu-latest
|
|
41
|
-
|
|
42
|
-
permissions:
|
|
43
|
-
contents: write
|
|
44
|
-
id-token: write
|
|
45
|
-
|
|
46
|
-
steps:
|
|
47
|
-
- name: Checkout code
|
|
48
|
-
uses: actions/checkout@v6
|
|
49
|
-
with:
|
|
50
|
-
fetch-depth: 0
|
|
51
|
-
|
|
52
|
-
- name: Setup Node.js
|
|
53
|
-
uses: actions/setup-node@v6
|
|
54
|
-
with:
|
|
55
|
-
node-version: '24.x'
|
|
56
|
-
registry-url: 'https://registry.npmjs.org'
|
|
57
|
-
|
|
58
|
-
- name: Update npm
|
|
59
|
-
run: npm install -g npm@11.18.0 # pinned: npm 12's global install drops `sigstore`, breaking --provenance
|
|
60
|
-
|
|
61
|
-
- name: Install dependencies
|
|
62
|
-
run: npm install
|
|
63
|
-
|
|
64
|
-
- name: Build the project
|
|
65
|
-
run: npm run build
|
|
66
|
-
|
|
67
|
-
- name: Determine npm tag
|
|
68
|
-
id: npm_tag
|
|
69
|
-
run: |
|
|
70
|
-
VERSION="${{ github.ref_name }}"
|
|
71
|
-
if [[ "$VERSION" == *"-alpha"* ]]; then
|
|
72
|
-
echo "tag=alpha" >> $GITHUB_OUTPUT
|
|
73
|
-
elif [[ "$VERSION" == *"-beta"* ]]; then
|
|
74
|
-
echo "tag=beta" >> $GITHUB_OUTPUT
|
|
75
|
-
elif [[ "$VERSION" == *"-rc"* ]]; then
|
|
76
|
-
echo "tag=rc" >> $GITHUB_OUTPUT
|
|
77
|
-
else
|
|
78
|
-
echo "tag=latest" >> $GITHUB_OUTPUT
|
|
79
|
-
fi
|
|
80
|
-
echo "Determined npm tag: $(cat $GITHUB_OUTPUT | grep tag | cut -d= -f2)"
|
|
81
|
-
|
|
82
|
-
- name: Publish to npm
|
|
83
|
-
run: npm publish --access public --tag ${{ steps.npm_tag.outputs.tag }}
|
|
84
|
-
env:
|
|
85
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
86
|
-
|
|
87
|
-
release:
|
|
88
|
-
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
89
|
-
runs-on: ubuntu-latest
|
|
90
|
-
needs: publish
|
|
91
|
-
|
|
92
|
-
permissions:
|
|
93
|
-
contents: write
|
|
94
|
-
|
|
95
|
-
steps:
|
|
96
|
-
- name: Checkout code
|
|
97
|
-
uses: actions/checkout@v6
|
|
98
|
-
with:
|
|
99
|
-
fetch-depth: 0
|
|
100
|
-
|
|
101
|
-
- name: Determine if prerelease
|
|
102
|
-
id: prerelease
|
|
103
|
-
run: |
|
|
104
|
-
VERSION="${{ github.ref_name }}"
|
|
105
|
-
if [[ "$VERSION" == *"-alpha"* ]] || [[ "$VERSION" == *"-beta"* ]] || [[ "$VERSION" == *"-rc"* ]]; then
|
|
106
|
-
echo "is_prerelease=true" >> $GITHUB_OUTPUT
|
|
107
|
-
else
|
|
108
|
-
echo "is_prerelease=false" >> $GITHUB_OUTPUT
|
|
109
|
-
fi
|
|
110
|
-
|
|
111
|
-
- name: Generate changelog
|
|
112
|
-
id: changelog
|
|
113
|
-
uses: mikepenz/release-changelog-builder-action@v6
|
|
114
|
-
with:
|
|
115
|
-
ignorePreReleases: ${{ steps.prerelease.outputs.is_prerelease == 'false' }}
|
|
116
|
-
configurationJson: |
|
|
117
|
-
{
|
|
118
|
-
"categories": [
|
|
119
|
-
{
|
|
120
|
-
"title": "### Breaking Changes",
|
|
121
|
-
"labels": ["breaking", "breaking-change", "BREAKING-CHANGE"]
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"title": "### Features",
|
|
125
|
-
"labels": ["feature", "feat", "enhancement"]
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"title": "### Bug Fixes",
|
|
129
|
-
"labels": ["bug", "fix", "bugfix"]
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"title": "### Performance",
|
|
133
|
-
"labels": ["performance", "perf"]
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
"title": "### Documentation",
|
|
137
|
-
"labels": ["documentation", "docs"]
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"title": "### Dependencies",
|
|
141
|
-
"labels": ["dependencies", "deps"]
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
"title": "### Other Changes",
|
|
145
|
-
"labels": []
|
|
146
|
-
}
|
|
147
|
-
],
|
|
148
|
-
"sort": {
|
|
149
|
-
"order": "ASC",
|
|
150
|
-
"on_property": "mergedAt"
|
|
151
|
-
},
|
|
152
|
-
"template": "#{{CHANGELOG}}",
|
|
153
|
-
"pr_template": "- #{{TITLE}} ([##{{NUMBER}}](#{{URL}})) by @#{{AUTHOR}}",
|
|
154
|
-
"empty_template": "- No changes",
|
|
155
|
-
"max_tags_to_fetch": 200,
|
|
156
|
-
"max_pull_requests": 200,
|
|
157
|
-
"max_back_track_time_days": 365,
|
|
158
|
-
"tag_resolver": {
|
|
159
|
-
"method": "semver"
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
env:
|
|
163
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
164
|
-
|
|
165
|
-
- name: Update CHANGELOG.md
|
|
166
|
-
env:
|
|
167
|
-
CHANGELOG_CONTENT: ${{ steps.changelog.outputs.changelog }}
|
|
168
|
-
run: |
|
|
169
|
-
TAG="${{ github.ref_name }}"
|
|
170
|
-
DATE=$(date +%Y-%m-%d)
|
|
171
|
-
NEW_HEADER="## [$TAG] - $DATE"
|
|
172
|
-
|
|
173
|
-
# Write changelog content to temp file using env var (avoids shell escaping)
|
|
174
|
-
printf '%s\n' "$CHANGELOG_CONTENT" > /tmp/new_entry.md
|
|
175
|
-
|
|
176
|
-
if [ -f CHANGELOG.md ]; then
|
|
177
|
-
# Create new file with entry inserted after header line
|
|
178
|
-
{
|
|
179
|
-
head -n 1 CHANGELOG.md
|
|
180
|
-
echo ""
|
|
181
|
-
echo "$NEW_HEADER"
|
|
182
|
-
echo ""
|
|
183
|
-
cat /tmp/new_entry.md
|
|
184
|
-
echo ""
|
|
185
|
-
tail -n +2 CHANGELOG.md
|
|
186
|
-
} > /tmp/CHANGELOG_NEW.md
|
|
187
|
-
mv /tmp/CHANGELOG_NEW.md CHANGELOG.md
|
|
188
|
-
else
|
|
189
|
-
# Create new CHANGELOG.md
|
|
190
|
-
{
|
|
191
|
-
echo "# Changelog"
|
|
192
|
-
echo ""
|
|
193
|
-
echo "All notable changes to this project will be documented in this file."
|
|
194
|
-
echo ""
|
|
195
|
-
echo "This changelog is automatically generated from merged pull requests."
|
|
196
|
-
echo ""
|
|
197
|
-
echo "$NEW_HEADER"
|
|
198
|
-
echo ""
|
|
199
|
-
cat /tmp/new_entry.md
|
|
200
|
-
} > CHANGELOG.md
|
|
201
|
-
fi
|
|
202
|
-
|
|
203
|
-
rm -f /tmp/new_entry.md
|
|
204
|
-
|
|
205
|
-
- name: Commit changelog
|
|
206
|
-
run: |
|
|
207
|
-
git config user.name "github-actions[bot]"
|
|
208
|
-
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
209
|
-
git add CHANGELOG.md
|
|
210
|
-
git diff --staged --quiet || git commit -m "docs: update CHANGELOG.md for ${{ github.ref_name }}"
|
|
211
|
-
git push origin HEAD:main || echo "No changes to push or push failed"
|
|
212
|
-
|
|
213
|
-
- name: Create GitHub Release
|
|
214
|
-
uses: softprops/action-gh-release@v3
|
|
215
|
-
with:
|
|
216
|
-
tag_name: ${{ github.ref_name }}
|
|
217
|
-
name: Release ${{ github.ref_name }}
|
|
218
|
-
body: ${{ steps.changelog.outputs.changelog }}
|
|
219
|
-
prerelease: ${{ steps.prerelease.outputs.is_prerelease == 'true' }}
|
|
220
|
-
generate_release_notes: false
|
|
221
|
-
env:
|
|
222
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/.vscode/settings.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"eslint.validate": ["javascript", "typescript"],
|
|
3
|
-
"prettier.useEditorConfig": false,
|
|
4
|
-
"prettier.useTabs": false,
|
|
5
|
-
"prettier.configPath": ".prettierrc.json",
|
|
6
|
-
"prettier.requireConfig": true,
|
|
7
|
-
"prettier.tabWidth": 4,
|
|
8
|
-
"prettier.singleQuote": true,
|
|
9
|
-
"editor.formatOnSave": true,
|
|
10
|
-
}
|
package/docs/README.md
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# toiljs
|
|
2
|
-
|
|
3
|
-
toiljs is a full-stack web framework. You write your **frontend in React** and your **backend in
|
|
4
|
-
TypeScript**, and toiljs turns the backend into a tiny, fast **WebAssembly** program that runs at the edge
|
|
5
|
-
(on servers close to your users, all over the world). One language, one project, one deploy.
|
|
6
|
-
|
|
7
|
-
If you have used Next.js, this will feel familiar: file-based routes, server code next to client code, a dev
|
|
8
|
-
server with hot reload. The difference is what happens underneath. Your server code is compiled by
|
|
9
|
-
**toilscript** (a TypeScript-to-WebAssembly compiler) into a sandboxed `.wasm` module, and it runs on the
|
|
10
|
-
**Dacely edge** with a built-in worldwide database (**ToilDB**), streaming, background jobs, and auth all
|
|
11
|
-
included.
|
|
12
|
-
|
|
13
|
-
## The mental model
|
|
14
|
-
|
|
15
|
-
```mermaid
|
|
16
|
-
flowchart LR
|
|
17
|
-
A["Your project<br/>(TypeScript + React)"] -->|toiljs build| B["client bundle<br/>(React, runs in the browser)"]
|
|
18
|
-
A -->|toilscript compile| C["server.wasm<br/>(your backend, sandboxed)"]
|
|
19
|
-
B --> U["User's browser"]
|
|
20
|
-
C --> E["Dacely edge<br/>(worldwide)"]
|
|
21
|
-
E --> D[("ToilDB<br/>global database")]
|
|
22
|
-
U <-->|HTTP / WebTransport| E
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
- **client/** is your React app (pages, components, styles). It runs in the browser.
|
|
26
|
-
- **server/** is your backend (routes, database, auth). It compiles to WebAssembly and runs on the edge.
|
|
27
|
-
- **shared/** is the typed bridge: toiljs generates a client here so the browser calls your server with full
|
|
28
|
-
type safety.
|
|
29
|
-
|
|
30
|
-
## Hello, toiljs
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
// server/routes/Hello.ts (a backend HTTP route)
|
|
34
|
-
import { Response } from 'toiljs/server/runtime';
|
|
35
|
-
|
|
36
|
-
@rest('hello')
|
|
37
|
-
class Hello {
|
|
38
|
-
@get('/')
|
|
39
|
-
public hi(): Response {
|
|
40
|
-
return Response.text('Hello from the edge!\n');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
```tsx
|
|
46
|
-
// client/routes/index.tsx (a frontend page)
|
|
47
|
-
export default function Home() {
|
|
48
|
-
return <main><h1>Welcome</h1></main>;
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Run `toiljs dev`, open the browser, and both are live with hot reload. That is the whole loop.
|
|
53
|
-
|
|
54
|
-
## Learn toiljs
|
|
55
|
-
|
|
56
|
-
**Understand toil first**
|
|
57
|
-
- [Understanding toil](./introduction/README.md): what toil is and the one big idea, then
|
|
58
|
-
[why toil and who it is for](./introduction/why-toil.md),
|
|
59
|
-
[the modern stack you get](./introduction/modern-stack.md),
|
|
60
|
-
[how it works](./introduction/how-it-works.md),
|
|
61
|
-
[what makes it hyper-scalable](./introduction/hyperscale.md),
|
|
62
|
-
[how it is distributed](./introduction/distributed.md),
|
|
63
|
-
[toil versus other frameworks](./introduction/vs-other-frameworks.md), and
|
|
64
|
-
[why it is built this way](./introduction/design-principles.md).
|
|
65
|
-
|
|
66
|
-
**Start here**
|
|
67
|
-
- [Getting started](./getting-started/README.md): install, create a project, project structure, your first
|
|
68
|
-
app, and migrating an existing React app.
|
|
69
|
-
- [The CLI](./cli/README.md): `dev`, `build`, `create`, `doctor`, and every flag.
|
|
70
|
-
- [Deploy](./getting-started/deploy.md): build for production, self-host it, and how the managed edge fits in.
|
|
71
|
-
|
|
72
|
-
**Build the frontend**
|
|
73
|
-
- [Frontend overview](./frontend/README.md), [Routing](./frontend/routing.md),
|
|
74
|
-
[Navigation](./frontend/navigation.md), [Components](./frontend/components.md),
|
|
75
|
-
[Rendering and SSR](./frontend/rendering.md), [Styling](./frontend/styling.md),
|
|
76
|
-
[Images](./frontend/images.md), [Metadata and SEO](./frontend/metadata.md),
|
|
77
|
-
[Fetching data](./frontend/data-fetching.md), [Scripts](./frontend/scripts.md),
|
|
78
|
-
[Search](./frontend/search.md), [The Toil global (reference)](./frontend/toil-global.md).
|
|
79
|
-
|
|
80
|
-
**Build the backend**
|
|
81
|
-
- [Backend overview](./backend/README.md), [HTTP routes (`@rest`)](./backend/rest.md),
|
|
82
|
-
[Typed RPC (`@service`/`@remote`)](./backend/rpc.md), [Data types (`@data`)](./backend/data.md).
|
|
83
|
-
|
|
84
|
-
**The database (ToilDB)**
|
|
85
|
-
- [Database overview and choosing a family](./database/README.md), [Setup (`@database`)](./database/setup.md),
|
|
86
|
-
[Documents](./database/documents.md), [Unique](./database/unique.md), [Counters](./database/counters.md),
|
|
87
|
-
[Events](./database/events.md), [Views and `@derive`](./database/views.md),
|
|
88
|
-
[Membership](./database/membership.md), [Capacity](./database/capacity.md).
|
|
89
|
-
|
|
90
|
-
**Auth**: [the full auth guide](./auth/README.md) covers post-quantum login, sessions, and `ToilUserId`;
|
|
91
|
-
[customizing the auth emails](./auth/emails.md) shows how to brand the verification, reset, and 2FA mail.
|
|
92
|
-
|
|
93
|
-
**Realtime and background**
|
|
94
|
-
- [Streams](./realtime/README.md) and [channels](./realtime/channels.md), [Daemons and scheduled
|
|
95
|
-
jobs](./background/daemons.md), [Derived views (`@derive`)](./background/derive.md).
|
|
96
|
-
|
|
97
|
-
**Platform services**
|
|
98
|
-
- [Caching](./services/caching.md), [Rate limiting](./services/ratelimit.md),
|
|
99
|
-
[Environment and secrets](./services/environment.md), [Email and 2FA](./services/email.md),
|
|
100
|
-
[Analytics](./services/analytics.md), [Crypto](./services/crypto.md), [Cookies](./services/cookies.md),
|
|
101
|
-
[Time](./services/time.md).
|
|
102
|
-
|
|
103
|
-
**Concepts and reference**
|
|
104
|
-
- [Writing toiljs correctly (AI + human quick rules)](./concepts/ai-guide.md),
|
|
105
|
-
[Compute tiers (L1 to L4)](./concepts/tiers.md), [Types (u64, u256, and friends)](./concepts/types.md),
|
|
106
|
-
[Every decorator](./concepts/decorators.md), [Configuration](./concepts/config.md),
|
|
107
|
-
[Security and SRI](./concepts/security.md).
|
package/docs/auth/README.md
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# Authentication
|
|
2
|
-
|
|
3
|
-
Toil ships a complete, **post-quantum password login** you turn on with one line. No passwords on your
|
|
4
|
-
server, no third-party identity provider, no hand-written crypto: enable it and you get a `/auth/*` API,
|
|
5
|
-
signed sessions, `@auth`-guarded routes, and a stable per-user identity.
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
// toil.config.ts
|
|
9
|
-
import { defineConfig } from 'toiljs/compiler';
|
|
10
|
-
|
|
11
|
-
export default defineConfig({
|
|
12
|
-
server: { auth: true }, // ← mounts the full /auth/* API + sessions
|
|
13
|
-
});
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
That is the whole setup. The build appends the framework's auth controller to your server, so `/auth/*`
|
|
17
|
-
is live and `@auth` works everywhere.
|
|
18
|
-
|
|
19
|
-
## What you get
|
|
20
|
-
|
|
21
|
-
| Endpoint | Purpose |
|
|
22
|
-
| --- | --- |
|
|
23
|
-
| `POST /auth/register/start`, `/register/finish` | Create an account (password never leaves the browser) |
|
|
24
|
-
| `POST /auth/login/start`, `/login/finish` | Log in; sets a signed session cookie |
|
|
25
|
-
| `GET /auth/me` *(`@auth`)* | The current user (`toilUserId` + `username`) |
|
|
26
|
-
| `POST /auth/logout` *(`@auth`)* | Clear the session |
|
|
27
|
-
|
|
28
|
-
Plus, in your own code:
|
|
29
|
-
|
|
30
|
-
- **`@auth`** on any route (or a whole `@rest` class) → 401 unless there's a valid session.
|
|
31
|
-
- **`AuthService.getUser()`** → the typed logged-in user.
|
|
32
|
-
- **`AuthService.userId()`** → the stable [`ToilUserId`](./extending.md#toiluserid) (a 256-bit id you can
|
|
33
|
-
key your data on).
|
|
34
|
-
- **The client**: `import { Auth } from 'toiljs/client'`, then `Auth.register(username, password)` /
|
|
35
|
-
`Auth.login(username, password)`. It does all the browser-side crypto and talks to `/auth/*` for you.
|
|
36
|
-
|
|
37
|
-
## A login page in full
|
|
38
|
-
|
|
39
|
-
```tsx
|
|
40
|
-
// client/routes/login.tsx
|
|
41
|
-
import { useState } from 'react';
|
|
42
|
-
import { Auth } from 'toiljs/client';
|
|
43
|
-
|
|
44
|
-
export default function Login() {
|
|
45
|
-
const [u, setU] = useState('');
|
|
46
|
-
const [p, setP] = useState('');
|
|
47
|
-
const [msg, setMsg] = useState('');
|
|
48
|
-
|
|
49
|
-
const register = async () => {
|
|
50
|
-
try { await Auth.register(u, p); setMsg('registered, now log in'); }
|
|
51
|
-
catch (e) { setMsg(parseError(e)); }
|
|
52
|
-
};
|
|
53
|
-
const login = async () => {
|
|
54
|
-
try { await Auth.login(u, p); setMsg('logged in'); } // sets the session cookie
|
|
55
|
-
catch (e) { setMsg(parseError(e)); }
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<main>
|
|
60
|
-
<input value={u} onChange={(e) => setU(e.currentTarget.value)} placeholder="username" />
|
|
61
|
-
<input value={p} type="password" onChange={(e) => setP(e.currentTarget.value)} placeholder="password" />
|
|
62
|
-
<button onClick={register}>Register</button>
|
|
63
|
-
<button onClick={login}>Log in</button>
|
|
64
|
-
<p>{msg}</p>
|
|
65
|
-
</main>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
// server/routes/Secret.ts, a route only a logged-in user can reach
|
|
72
|
-
import { Response } from 'toiljs/server/runtime';
|
|
73
|
-
|
|
74
|
-
@rest('secret')
|
|
75
|
-
class Secret {
|
|
76
|
-
@auth // 401 without a valid session
|
|
77
|
-
@get('/')
|
|
78
|
-
public secret(): Response {
|
|
79
|
-
const user = AuthService.getUser()!; // typed: { toilUserId, username }
|
|
80
|
-
return Response.text('hello ' + user.username + '\n');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
That's a real, production-grade auth system, the password is stretched with Argon2id in the browser into
|
|
86
|
-
an ML-DSA-44 key pair, your server only ever stores a public key, and login is a mutually-authenticated
|
|
87
|
-
ML-KEM-768 challenge. You didn't write any of it.
|
|
88
|
-
|
|
89
|
-
## Where to go next
|
|
90
|
-
|
|
91
|
-
- **[How it works](./how-it-works.md)**: the protocol (OPRF + Argon2id + ML-DSA + ML-KEM), sessions,
|
|
92
|
-
cookies, and the `ToilUserId`, with sequence diagrams.
|
|
93
|
-
- **[Usage](./usage.md)**: enabling it, the client API, guarding routes, reading the user, the full wire
|
|
94
|
-
contract of each endpoint.
|
|
95
|
-
- **[Configuration](./configuration.md)**: the secrets a deployment MUST set, the audience/domain, tuning
|
|
96
|
-
Argon2id, and the deploy checklist.
|
|
97
|
-
- **[Extending & integrating](./extending.md)**: `ToilUserId`, keying your own data on a user, a custom
|
|
98
|
-
user shape / opting out, and the `AuthService` primitive reference.
|
|
99
|
-
- **[Customizing the auth emails](./emails.md)**: replace the verification, password-reset, and 2FA
|
|
100
|
-
emails with your own branded React templates by dropping `emails/auth-*.tsx` files.
|
|
101
|
-
|
|
102
|
-
> **One rule before you ship:** built-in auth runs with **insecure DEV fallback secrets** so it Just Works
|
|
103
|
-
> locally. A deployment MUST set `AUTH_SESSION_SECRET`, `AUTH_OPRF_SEED`, and `AUTH_KEM_SK`. See
|
|
104
|
-
> [Configuration](./configuration.md).
|