@plitzi/sdk-server 0.38.24 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +162 -1
- package/README.md +55 -9
- package/dist/actions.d.ts +4 -1
- package/dist/actions.js +3 -2
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +5 -4
- package/dist/core/auth/api/accounts.d.ts +11 -0
- package/dist/core/auth/api/accounts.js +175 -0
- package/dist/core/auth/api/admin.d.ts +41 -0
- package/dist/core/auth/api/admin.js +146 -0
- package/dist/core/auth/api/context.d.ts +119 -0
- package/dist/core/auth/api/context.js +262 -0
- package/dist/core/auth/api/factors.d.ts +31 -0
- package/dist/core/auth/api/factors.js +209 -0
- package/dist/core/auth/api/index.d.ts +94 -0
- package/dist/core/auth/api/index.js +43 -0
- package/dist/core/auth/api/profile.d.ts +43 -0
- package/dist/core/auth/api/profile.js +243 -0
- package/dist/core/auth/api/session.d.ts +62 -0
- package/dist/core/auth/api/session.js +312 -0
- package/dist/core/auth/{api.d.ts → api/types.d.ts} +41 -195
- package/dist/core/auth/api/values.d.ts +67 -0
- package/dist/core/auth/api/values.js +90 -0
- package/dist/core/auth/createAuth.d.ts +49 -39
- package/dist/core/auth/createAuth.js +21 -1
- package/dist/core/auth/oauth/client.d.ts +2 -2
- package/dist/core/auth/oauth/client.js +6 -1
- package/dist/core/auth/oauth/index.d.ts +30 -7
- package/dist/core/auth/oauth/index.js +33 -14
- package/dist/core/auth/oauth/providers/github.js +1 -1
- package/dist/core/auth/oauth/providers/google.js +1 -1
- package/dist/core/auth/oauth/providers/oidc.d.ts +40 -0
- package/dist/core/auth/oauth/providers/oidc.js +197 -0
- package/dist/core/auth/oauth/state.d.ts +2 -0
- package/dist/core/auth/oauth/state.js +2 -0
- package/dist/core/auth/oauth/types.d.ts +21 -3
- package/dist/core/auth/oauth/types.js +4 -1
- package/dist/core/auth/routes.js +1 -1
- package/dist/core/auth/tokens.d.ts +3 -1
- package/dist/core/auth/tokens.js +2 -1
- package/dist/core/configSeam.d.ts +0 -4
- package/dist/core/configSeam.js +12 -1
- package/dist/core/createServer.js +16 -4
- package/dist/core/freePort.d.ts +10 -0
- package/dist/core/freePort.js +39 -1
- package/dist/core/handlers/socialRouteHandlers.d.ts +9 -1
- package/dist/core/handlers/socialRouteHandlers.js +46 -12
- package/dist/core/health.d.ts +1 -0
- package/dist/core/health.js +2 -1
- package/dist/core/http/stages/authRoutes.d.ts +6 -0
- package/dist/core/http/stages/authRoutes.js +42 -1
- package/dist/core/http/stages/images.js +5 -3
- package/dist/core/http/stages/livePages.js +1 -1
- package/dist/core/server/fleet/relay.js +9 -1
- package/dist/core/server/fleet/stores.d.ts +7 -0
- package/dist/core/server/fleet/stores.js +15 -2
- package/dist/core/server/pageServer.js +5 -1
- package/dist/core/services/realtime.js +4 -2
- package/dist/core/services/registry.js +7 -1
- package/dist/core/services/robotsTxt.d.ts +16 -0
- package/dist/core/services/robotsTxt.js +50 -0
- package/dist/core/services/servedSpace.d.ts +8 -0
- package/dist/core/services/servedSpace.js +16 -0
- package/dist/core/services/sitemapXml.d.ts +7 -0
- package/dist/core/services/sitemapXml.js +37 -0
- package/dist/functions-api.d.ts +69 -2
- package/dist/helpers/fileStore.d.ts +60 -0
- package/dist/helpers/fileStore.js +127 -0
- package/dist/helpers/outboundGuard.d.ts +32 -3
- package/dist/helpers/outboundGuard.js +50 -5
- package/dist/hosts/project/agentRuns.d.ts +24 -0
- package/dist/hosts/project/agentRuns.js +107 -0
- package/dist/hosts/project/laterAsks.d.ts +41 -0
- package/dist/hosts/project/laterAsks.js +117 -0
- package/dist/hosts/project/plugins.js +11 -4
- package/dist/hosts/project/serveProject.d.ts +18 -1
- package/dist/hosts/project/serveProject.js +89 -25
- package/dist/hosts/project/spaceFailure.d.ts +4 -0
- package/dist/hosts/project/spaceFailure.js +10 -0
- package/dist/hosts/project/watchSpace.d.ts +5 -5
- package/dist/hosts/project/watchSpace.js +15 -6
- package/dist/index.js +2 -2
- package/dist/kernel.js +1 -1
- package/dist/modules/actions/connectorWrite.js +3 -1
- package/dist/modules/actions/index.js +1 -1
- package/dist/modules/actions/jobs/fileQueue.d.ts +34 -0
- package/dist/modules/actions/jobs/fileQueue.js +72 -0
- package/dist/modules/actions/jobs/index.js +3 -3
- package/dist/modules/actions/jobs/memoryQueue.js +6 -215
- package/dist/modules/actions/jobs/queueDocument.d.ts +14 -0
- package/dist/modules/actions/jobs/queueDocument.js +22 -0
- package/dist/modules/actions/jobs/queueRules.d.ts +39 -0
- package/dist/modules/actions/jobs/queueRules.js +270 -0
- package/dist/modules/actions/moduleFor.js +2 -0
- package/dist/modules/actions/runtime/fileKv.d.ts +3 -1
- package/dist/modules/actions/runtime/fileKv.js +12 -98
- package/dist/modules/actions/runtime/guards.d.ts +19 -1
- package/dist/modules/actions/runtime/guards.js +10 -1
- package/dist/modules/actions/runtime/kvChange.d.ts +40 -0
- package/dist/modules/actions/runtime/kvChange.js +23 -1
- package/dist/modules/actions/runtime/kvList.d.ts +4 -0
- package/dist/modules/actions/runtime/kvList.js +5 -1
- package/dist/modules/actions/runtime/kvStore.js +15 -1
- package/dist/modules/actions/runtime/namespaceKv.js +2 -0
- package/dist/modules/actions/runtime/renderResolver.js +31 -5
- package/dist/modules/actions/runtime/runAction.js +16 -6
- package/dist/modules/actions/runtime/scope.js +11 -0
- package/dist/modules/actions/runtime/taskContext.js +11 -32
- package/dist/modules/actions/tasks/auth.js +2 -0
- package/dist/modules/actions/tasks/connector.js +6 -2
- package/dist/modules/actions/tasks/flow.js +5 -0
- package/dist/modules/actions/tasks/http.js +2 -1
- package/dist/modules/actions/tasks/kv.js +5 -0
- package/dist/modules/actions/tasks/list.js +11 -2
- package/dist/modules/actions/tasks/transform.js +2 -0
- package/dist/modules/actions/transport/callHandler.js +25 -4
- package/dist/modules/actions/types.d.ts +46 -1
- package/dist/modules/connectors/engine.d.ts +7 -2
- package/dist/modules/connectors/engine.js +4 -4
- package/dist/modules/connectors/resolver.d.ts +2 -1
- package/dist/modules/connectors/resolver.js +3 -2
- package/dist/modules/functions/build.d.ts +7 -2
- package/dist/modules/functions/build.js +90 -6
- package/dist/modules/functions/capabilities.js +16 -0
- package/dist/modules/functions/context.js +6 -2
- package/dist/modules/functions/contract.d.ts +39 -1
- package/dist/modules/functions/driver.d.ts +2 -1
- package/dist/modules/functions/driver.js +35 -0
- package/dist/modules/functions/load.d.ts +1 -1
- package/dist/modules/functions/load.js +2 -2
- package/dist/modules/functions/manifest.js +7 -1
- package/dist/modules/functions/oauth.d.ts +1 -1
- package/dist/modules/functions/oauth.js +4 -4
- package/dist/modules/functions/protocol.d.ts +6 -0
- package/dist/modules/functions/sandbox/guest/bytes.d.ts +27 -0
- package/dist/modules/functions/sandbox/guest/bytes.js +108 -0
- package/dist/modules/functions/sandbox/guest/crypto.d.ts +47 -0
- package/dist/modules/functions/sandbox/guest/crypto.js +144 -0
- package/dist/modules/functions/sandbox/guest/events.d.ts +152 -0
- package/dist/modules/functions/sandbox/guest/events.js +143 -0
- package/dist/modules/functions/sandbox/guest/fetch.d.ts +305 -0
- package/dist/modules/functions/sandbox/guest/fetch.js +237 -0
- package/dist/modules/functions/sandbox/guest/index.d.ts +28 -0
- package/dist/modules/functions/sandbox/guest/index.js +130 -0
- package/dist/modules/functions/sandbox/{guest.d.ts → guest/types.d.ts} +5 -12
- package/dist/modules/functions/sandbox/isolate.js +20 -6
- package/dist/modules/functions/space.js +2 -8
- package/dist/modules/images/imageProxy.d.ts +3 -2
- package/dist/modules/images/imageProxy.js +2 -2
- package/dist/modules/mongo/jobQueue.js +0 -19
- package/dist/modules/mysql/accounts.js +12 -5
- package/dist/modules/mysql/jobs/index.d.ts +1 -1
- package/dist/modules/mysql/jobs/schema.d.ts +0 -6
- package/dist/modules/mysql/jobs/schema.js +2 -46
- package/dist/modules/mysql/schema.js +26 -1
- package/dist/modules/mysql/sessions.js +2 -1
- package/dist/modules/realtime/handlers.d.ts +9 -4
- package/dist/modules/realtime/handlers.js +20 -3
- package/dist/modules/realtime/hub.d.ts +4 -2
- package/dist/modules/realtime/hub.js +36 -4
- package/dist/modules/realtime/index.d.ts +14 -0
- package/dist/modules/realtime/index.js +14 -1
- package/dist/modules/realtime/presence.d.ts +33 -0
- package/dist/modules/realtime/presence.js +56 -0
- package/dist/modules/realtime/socket.d.ts +3 -1
- package/dist/modules/realtime/socket.js +2 -2
- package/dist/modules/rsc/connectorRscData.d.ts +6 -1
- package/dist/modules/rsc/connectorRscData.js +27 -6
- package/dist/modules/rsc/externalQueryReader.d.ts +28 -0
- package/dist/modules/rsc/externalQueryReader.js +43 -0
- package/dist/modules/rsc/handler.js +1 -1
- package/dist/modules/rsc/resolveRscData.d.ts +11 -1
- package/dist/modules/rsc/resolveRscData.js +86 -16
- package/dist/modules/runtime/inside.js +1 -1
- package/dist/modules/runtime/runner.js +2 -1
- package/dist/modules/sqlite/jobQueue.d.ts +35 -0
- package/dist/modules/sqlite/jobQueue.js +56 -0
- package/dist/modules/sqlite/kv.d.ts +1 -1
- package/dist/modules/sqlite/kv.js +2 -10
- package/dist/modules/sqlite/open.d.ts +3 -0
- package/dist/modules/sqlite/open.js +13 -0
- package/dist/modules/ssr/Component.d.ts +5 -1
- package/dist/modules/ssr/Component.js +3 -1
- package/dist/modules/ssr/applySSRResult.d.ts +8 -1
- package/dist/modules/ssr/applySSRResult.js +23 -3
- package/dist/modules/ssr/handler.js +30 -5
- package/dist/modules/ssr/prepareRender.js +31 -8
- package/dist/modules/ssr/preview.d.ts +2 -0
- package/dist/modules/ssr/preview.js +6 -3
- package/dist/modules/ssr/registerExternalPlugins.d.ts +2 -6
- package/dist/modules/ssr/registerExternalPlugins.js +2 -2
- package/dist/modules/ssr/resolvePageSeo.d.ts +11 -0
- package/dist/modules/ssr/resolvePageSeo.js +13 -2
- package/dist/modules/ssr/streamBody.js +2 -2
- package/dist/modules/ssr/views/template.ejs +21 -17
- package/dist/mysql.d.ts +1 -1
- package/dist/mysql.js +2 -2
- package/dist/plugins/manager.d.ts +5 -0
- package/dist/plugins/manager.js +9 -0
- package/dist/sqlite.d.ts +8 -1
- package/dist/sqlite.js +3 -1
- package/package.json +5 -5
- package/skills/plitzi-authoring/CHEATSHEET.md +6 -6
- package/skills/plitzi-authoring/SKILL.md +4 -2
- package/skills/plitzi-authoring/recipes/accordion.ts +2 -1
- package/skills/plitzi-authoring/recipes/carousel.ts +24 -3
- package/skills/plitzi-authoring/recipes/detail-page.ts +0 -1
- package/skills/plitzi-authoring/recipes/embed-and-svg.ts +3 -1
- package/skills/plitzi-authoring/recipes/filter-a-list.ts +0 -1
- package/skills/plitzi-authoring/recipes/show-data.ts +0 -1
- package/skills/plitzi-authoring/recipes/typed-data.ts +0 -1
- package/skills/plitzi-authoring/reference/accessibility.md +10 -2
- package/skills/plitzi-authoring/reference/auth.md +15 -4
- package/skills/plitzi-authoring/reference/authoring-errors.md +55 -12
- package/skills/plitzi-authoring/reference/colours-and-motion.md +7 -1
- package/skills/plitzi-authoring/reference/components.md +4 -1
- package/skills/plitzi-authoring/reference/data-and-visibility.md +31 -22
- package/skills/plitzi-authoring/reference/efficiency.md +2 -1
- package/skills/plitzi-authoring/reference/elements-and-styles.md +16 -15
- package/skills/plitzi-authoring/reference/flows.md +29 -17
- package/skills/plitzi-authoring/reference/kept-state.md +20 -0
- package/skills/plitzi-authoring/reference/layouts.md +18 -2
- package/skills/plitzi-authoring/reference/lists.md +20 -4
- package/skills/plitzi-authoring/reference/plugin-reach.md +12 -0
- package/skills/plitzi-authoring/reference/plugins.md +17 -3
- package/skills/plitzi-authoring/reference/realtime.md +8 -5
- package/skills/plitzi-authoring/reference/structure.md +17 -1
- package/skills/plitzi-authoring/reference/templates.md +11 -3
- package/skills/plitzi-authoring/reference/testing.md +82 -5
- package/skills/plitzi-authoring/reference/typed-sources.md +6 -0
- package/skills/plitzi-authoring/reference/validation.md +1 -1
- package/dist/core/auth/api.js +0 -1323
- package/dist/modules/functions/sandbox/guest.js +0 -662
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,166 @@
|
|
|
1
1
|
# @plitzi/sdk-server
|
|
2
2
|
|
|
3
|
+
## 0.39.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f174a61: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [f174a61]
|
|
10
|
+
- @plitzi/plitzi-sdk@0.39.1
|
|
11
|
+
- @plitzi/sdk-shared@0.39.1
|
|
12
|
+
|
|
13
|
+
## 0.39.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 587c35b: A team of agents on one project (`plitzi run`, `plitzi task`), the page tools those agents measure with, tests kept in
|
|
18
|
+
the space, and what authoring and the elements learnt from the runs. Each command and option is in the CLI's README;
|
|
19
|
+
how the runs work, in `docs/en/agent-runs.md`.
|
|
20
|
+
|
|
21
|
+
## To do when you upgrade
|
|
22
|
+
- **Node 24.** `engines` is `^24.22.1 || >=26.12.1`; Node 22 is no longer supported (`plitzi doctor` says it,
|
|
23
|
+
`doctor --fix` raises an older project's `engines`).
|
|
24
|
+
- **`createServer({ outbound: { privateOrigins } })` replaces `allowPrivatePluginHosts`:** a space's requests reach no
|
|
25
|
+
private address but the origins named (`privateOrigins: ['http://localhost:9000']`).
|
|
26
|
+
- **Job queues from 0.38.20 or before are recreated, not upgraded:** `createMongoJobQueue` / `createMysqlJobQueue` empty
|
|
27
|
+
or drop the old `action_jobs` / `action_kv` and make them again; `mysqlJobSchemaUpgrades` is gone.
|
|
28
|
+
- **`PLITZI_KV_FILE` is `PLITZI_STATE_DIR`**, a folder holding the server's `kv` and job queue.
|
|
29
|
+
- **A social provider's `fetchProfile` takes `{ accessToken, idToken, nonce }`**, and `createSocialAuth(...).start` is
|
|
30
|
+
async.
|
|
31
|
+
- **A `DraftStore` of a deployment's own keeps `inspected`** beside `reusable`, or a test session renders without the
|
|
32
|
+
state bridge.
|
|
33
|
+
- **`navigation.navigate(url, { external, replace })`** takes an object where it took `navigate(url, true)`.
|
|
34
|
+
- **`window.__plitzi.setSource` / `setAttribute` may answer `{ refused }`**: read it before treating the answer as written.
|
|
35
|
+
- **Renamed:** `stepText` → `e2eStepText` (a run's `said` is the step in words); `OverQuotaNotice` → `QuotaNotice` and
|
|
36
|
+
its classes `plitzi-quota-notice…`; `sightOf` / `sightText` come from `@plitzi/sdk-shared/devTools/sight`.
|
|
37
|
+
- **`SchemaVariables` and `StyleVariables` draw no add button of their own:** the holder passes `adding`, `onAddingEnd`
|
|
38
|
+
and optionally `empty`.
|
|
39
|
+
- **A page handed to `runE2eTest`** has `selectOption`, `position` in `click`/`hover` and `evaluate(fn, arg)`, as a
|
|
40
|
+
Playwright locator: a hand-written page adds them.
|
|
41
|
+
- **Journey steps play as the page commands do:** `scroll` with `dx`/`dy` scrolls the element's content, `waitFor`
|
|
42
|
+
waits 10 s, `type` replaces a field's value.
|
|
43
|
+
- **Authoring refuses more:** two flows of one element naming a step alike (`step-duplicate`), `visible` written as an
|
|
44
|
+
expression (`visible-expression`), a step condition naming a source by id alone (`condition-short-source`).
|
|
45
|
+
`navbar` / `navbarItem` are no longer read by `specFromSpace`.
|
|
46
|
+
- **`/robots.txt` ends naming its sitemap** unless the space's own text does.
|
|
47
|
+
- **The CLI's part of a project is `.plitzi/`** (it was split with `plitzi/`): `plitzi doctor --fix` moves it, and a
|
|
48
|
+
tsconfig names `.plitzi/**/*`.
|
|
49
|
+
- **`plitzi upgrade`** brings the new scripts (`start:preview`, the visual suite's server on 8400, `test`), the ignores
|
|
50
|
+
for `.plitzi/plitzi-reports/` and the skills. `test` runs the project's own tests, so red tests now fail
|
|
51
|
+
`plitzi verify` and a run's checks.
|
|
52
|
+
- **Reports to Plitzi live in `.plitzi/plitzi-reports/`**, committed: a run's in `runs/<run>/`, an agent's in
|
|
53
|
+
`agents/<date>/`. The old files are read no more.
|
|
54
|
+
- **The CLI's surface is smaller — one command for each thing.** Old names and flags are refused naming the new one;
|
|
55
|
+
`plitzi upgrade skills --write` updates the agents' skills. The main moves: `run plan` / `run rehearse` →
|
|
56
|
+
`run open --dry-run [--rehearse]`; `run extend` → `run open <stage>`; `run purge` → `run abort`; `task take` →
|
|
57
|
+
`task next <task>`; `task ask` / `block` / `note` → `task tell --ask | --blocked | --handoff`; `task wait` / `release`
|
|
58
|
+
→ `task claim --wait | --release`; `task request` → `task propose --file`; `task check --before | --mutate` →
|
|
59
|
+
`task prove`; `run feedback` → `run report --plitzi`; `functions pull|push` → `space pull|push functions`;
|
|
60
|
+
`runtime push` → `space push runtime`; `page shot --live` / `--clip` → `--fresh` / `--within`; `PLITZI_TASK_TOKEN` →
|
|
61
|
+
`PLITZI_TOKEN`.
|
|
62
|
+
- **Research and reviews are cards on one board:** `task spike` and the separate UI review are gone; a card's `review`
|
|
63
|
+
names its roles in order. Runs opened before keep working.
|
|
64
|
+
- **Page commands:** `page check --expect` fails only on what it expects; every page command reads at 900 px tall
|
|
65
|
+
(`--height`); a page that sends a guest away is read signed in as the project's account (`--as`, `--guest`).
|
|
66
|
+
- **`create --from`** names page files by the page's name; a space's functions are pushed without their tests.
|
|
67
|
+
|
|
68
|
+
## A space's tests (`@plitzi/sdk-authoring`, `@plitzi/sdk-shared`, `@plitzi/plitzi-builder`, `@plitzi/sdk-mcp`)
|
|
69
|
+
- **Tests are part of the space's document** (`Schema.tests`): unit tests (element checks) and journeys (what a visitor
|
|
70
|
+
does), authored in code, edited in the builder's Tests area, played on the canvas or the server. See
|
|
71
|
+
`docs/en/space-tests.md`.
|
|
72
|
+
- **Journeys play signed in as test accounts** (`tests.accounts`), carry tags, can be held and stopped
|
|
73
|
+
(`runE2eTest`'s `beforeStep`), and hold element checks (`e2e.expectCheck`).
|
|
74
|
+
- **`plitzi test [id…]`** runs a project's tests; **`plitzi_test`** lets an agent run them over the MCP. What a plan
|
|
75
|
+
allows (`journeysPerSpace`, `serverRunsPerMonth`) is in its entitlements; a `canTest` grant writes tests alone.
|
|
76
|
+
|
|
77
|
+
## Several agents on one project (`@plitzi/cli`)
|
|
78
|
+
- **A run is a kanban:** a lead plans, reviews and closes; developers, testers, designers and scouts take cards with
|
|
79
|
+
`task next`, each in its own copy of the project; every card is reviewed by the roles it names, step by step.
|
|
80
|
+
Nothing reaches the project until a person applies the run (`run finish --apply`).
|
|
81
|
+
- **Files are owned by imports:** one agent per file, shared files taken by turns or changed by agreement
|
|
82
|
+
(`task propose`), merged line by line, checked on the whole result.
|
|
83
|
+
- **The run keeps itself going:** a keeper starts the agents work is waiting for, and holds
|
|
84
|
+
starts after the harness's limit or repeated quick exits until the lead allows them (`run hold`, `run allow`).
|
|
85
|
+
- **`run monitor`:** the run live in a terminal — board, flow, agents, spend, activity — with an emergency panel (`!`)
|
|
86
|
+
to pause, resume, hold or allow agents.
|
|
87
|
+
- **A change mid-run says what it reaches:** `run open <stage> --dry-run` and `run amend --dry-run` name the approved
|
|
88
|
+
tasks, tasks at work and tests each change touches, read off the import graph.
|
|
89
|
+
- **Reviews see what goes in:** a review taken says whether the task merges with the run's newer work and, if not, the
|
|
90
|
+
failing lines; `task show <file> --merged` and `task look --merged` read and serve the merge;
|
|
91
|
+
`task look --alone <element> --with '{…}'` draws a component or plugin no page places yet. A step's time stops while
|
|
92
|
+
its reviewer proves or looks.
|
|
93
|
+
- **Proofs:** `task prove --before` (what each acceptance line proves against the run before the task) and
|
|
94
|
+
`--mutate` (whether a task's tests catch a broken change, with a control run).
|
|
95
|
+
- **The finish:** `run finish` checks the whole result and stops at the first failing line; `--every-line` reports
|
|
96
|
+
them all. The run then leaves its reports in `.plitzi/plitzi-reports/runs/<run>/`.
|
|
97
|
+
- **A report to Plitzi holds nothing of the person or the project:** a run's `feedback.md` writes over names, emails,
|
|
98
|
+
addresses, IPs, the project's files, tasks and elements, leaves out what was said of the project alone, and lists
|
|
99
|
+
quoted passages for the person to read before sending. `plitzi feedback` carries no project name, asks the developer
|
|
100
|
+
before anything of the project goes in, and `plitzi feedback --check <file>` names what a filled report still holds.
|
|
101
|
+
|
|
102
|
+
## Page tools (`@plitzi/cli`, `@plitzi/sdk-authoring`)
|
|
103
|
+
- **`page measure`** reads what an element draws (`--only drawn`, `box-*`, `attr:<name>`, `accessible-name`,
|
|
104
|
+
`scroll-*`, custom properties) and holds bounds and positions (`--expect "width<=44px"`, `"a.bottom + 8 <= b.top"`).
|
|
105
|
+
- **`page play`** plays steps — `drag … hold`, `scroll page 1500`, `click <el> 30%,60%` — reads what is drawn, not
|
|
106
|
+
what is in the DOM, and `--motion` plays animations moving. A press is made once and waits for the page to take it.
|
|
107
|
+
- **`page check`** says what a visitor cannot reach, text cut or spilling, canvases left blank, the server's error page
|
|
108
|
+
when the space does not author, and holds a text whole (`=`) or in part (`~`).
|
|
109
|
+
- **`page shot`** waits for canvases, pictures hovers (`--hover`, `--frames`) and parts (`--within`), and says what it
|
|
110
|
+
could not picture.
|
|
111
|
+
- **Every page command reads a page as one visitor from the same flags** (`--as`, `--guest`, `--width`, `--height`,
|
|
112
|
+
`--fresh`), with a browser driver of the CLI's own.
|
|
113
|
+
|
|
114
|
+
## Authoring (`@plitzi/sdk-authoring`)
|
|
115
|
+
- **New checks:** a server provider the page server cannot read (`server-query-unresolved`) or that reads browser state
|
|
116
|
+
(`server-when-unknown`), an action without `runtime: 'server'` (`server-source-in-browser`), class overrides,
|
|
117
|
+
messages arriving while a flow runs, unused plugins.
|
|
118
|
+
- **New authoring:** `focus('field')`, a factory for every trigger, the scroll family's sides, `pagesIn(...)` to
|
|
119
|
+
register pages by folder, channel topics with a choice, a plugin's imported stylesheets read for its tokens.
|
|
120
|
+
- **An element drawn alone:** a server started with `PLITZI_PREVIEW_FILE` gets a page for one element at
|
|
121
|
+
`/plitzi-preview` (`withPreview`, `SpacePreviewError`) — what `task look --alone` uses.
|
|
122
|
+
|
|
123
|
+
## Elements and the SDK (`@plitzi/sdk-elements`, `@plitzi/plitzi-sdk`, `@plitzi/sdk-shared`)
|
|
124
|
+
- **Navigation:** `navigate` can replace the address, and a navigation inside the site leaves the scroll as a page
|
|
125
|
+
load would.
|
|
126
|
+
- **Providers:** a `when` holds the same in the browser and on the page server; a server provider can read another
|
|
127
|
+
site's address while the page is built.
|
|
128
|
+
- **Plans and roles in the contract:** entitlements (`TSpaceEntitlements`), the space role (`TSpaceAccess`), the quota
|
|
129
|
+
warning at 80% (`render.quotaNear`) and the "Made with Plitzi" badge (`PlitziBadge`).
|
|
130
|
+
- **Fixes:** a binding's `sourceTo` is the previous value; an element with no tag and no `visible` draws nothing;
|
|
131
|
+
placeholder words never reach a page; notifications stay open for a visitor who asked for less motion.
|
|
132
|
+
|
|
133
|
+
## Server (`@plitzi/sdk-server`, `@plitzi/sdk-auth`, `@plitzi/sdk-mcp`)
|
|
134
|
+
- **`/sitemap.xml`** for every space, and `/robots.txt` naming it.
|
|
135
|
+
- **Accounts:** terms accepted at sign-up (MySQL schema version 7), single sign-on with any OpenID Connect issuer
|
|
136
|
+
(`createOidcProvider`), providers resolved at run time, a password that may not sign in, `/auth/continue` with a step
|
|
137
|
+
of the deployment's own, a signed-out visitor never signed back in by a stale answer.
|
|
138
|
+
- **Policy adapters:** metering can hold a page back (503), decide the badge and `noindex`; the MCP can cap tool calls
|
|
139
|
+
and names the space's plan; realtime admits spaces per deployment.
|
|
140
|
+
- **Dev server:** a removed plugin folder is unregistered (`PluginRegistry.unregister`), and a space that does not
|
|
141
|
+
author is said whole, with no stack.
|
|
142
|
+
|
|
143
|
+
## The builder (`@plitzi/plitzi-builder`)
|
|
144
|
+
- **A Tests area** with journeys played beside the page at the journey's device, and element checks.
|
|
145
|
+
- **One way to build a panel**, a header grouped by what its controls do, and the layout's mask dimming only what the
|
|
146
|
+
layout draws.
|
|
147
|
+
- **Plans and roles shown:** what the role allows (`useSpaceAccess`), what the plan leaves out shown locked, the plan
|
|
148
|
+
and its spend in the header; pages left out of the sitemap marked.
|
|
149
|
+
|
|
150
|
+
## Dev tools (`@plitzi/sdk-dev-tools`)
|
|
151
|
+
- **`element(id).visible` is what a visitor sees** (`sightOf`), with why not; `element(id).resolved` says what each
|
|
152
|
+
binding gave; a refused server action is a `refused` step.
|
|
153
|
+
- **Report what you see** in the Run tab of a run's preview, and the panel docks at the bottom under 900 px.
|
|
154
|
+
|
|
155
|
+
## The workspace
|
|
156
|
+
- **No file past 600 lines of code** (`max-lines`), and ESLint's `quotes` rule is gone — Prettier writes them.
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- Updated dependencies [587c35b]
|
|
161
|
+
- @plitzi/plitzi-sdk@0.39.0
|
|
162
|
+
- @plitzi/sdk-shared@0.39.0
|
|
163
|
+
|
|
3
164
|
## 0.38.24
|
|
4
165
|
|
|
5
166
|
### Patch Changes
|
|
@@ -3562,7 +3723,7 @@ author`, `plitzi_validate`/`plitzi_apply`, `plitzi explain` and the builder's pr
|
|
|
3562
3723
|
- **Devices are listed by device, not by session.** `GET /devices/sessions` groups sessions by what they were created
|
|
3563
3724
|
from and answers this device apart; a browser that signed in forty times is one row saying "40 sessions". The list
|
|
3564
3725
|
had shipped and drawn every session — 1,218 for one account a test suite signs in as — inside a box that scrolled.
|
|
3565
|
-
- **Every device is named for what it is**: the application as it registered over OAuth (`Plitzi CLI on
|
|
3726
|
+
- **Every device is named for what it is**: the application as it registered over OAuth (`Plitzi CLI on dev-laptop`,
|
|
3566
3727
|
`Plitzi Desktop on studio`), a browser and its system, an automated client (Playwright, headless Chrome) — never a
|
|
3567
3728
|
raw user agent. Sessions record their address and **when they were last used** (at most every five minutes, on the
|
|
3568
3729
|
lookup a request already makes). A sign-in deletes the account's dead sessions.
|
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ server.listen(3001, '127.0.0.1');
|
|
|
107
107
|
|
|
108
108
|
```bash
|
|
109
109
|
yarn add @plitzi/sdk-server react react-dom
|
|
110
|
-
node server.ts # http://127.0.0.1:3001/ — Node
|
|
110
|
+
node server.ts # http://127.0.0.1:3001/ — Node 24 runs TypeScript itself
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
No transpiler in front of it: Node strips the types. A loader such as `tsx` costs a page server more memory than the
|
|
@@ -184,7 +184,10 @@ await serveProject({ space: authorProjectSpace, actions, connectors, serverOptio
|
|
|
184
184
|
`space` — `dist/space/index.js` when the server runs what `build` emitted (`projectModule` of
|
|
185
185
|
`@plitzi/sdk-shared/project`, the rule the runtime is found by too) — and authors it with `projectAuthoring()`. A
|
|
186
186
|
module that exports no `space` is refused saying what to export (`ProjectSpaceError`), and a space that does not author
|
|
187
|
-
with every problem (`SpaceRefusedError`): each printed as the report it is, and the process exits with 1.
|
|
187
|
+
with every problem (`SpaceRefusedError`): each printed as the report it is, and the process exits with 1. Started with
|
|
188
|
+
`PLITZI_PREVIEW_FILE` (`PREVIEW_FILE_ENV`) naming an element to draw alone — what `plitzi task look --alone` sets for
|
|
189
|
+
its own server — the space gets a page for it at `/plitzi-preview`; a name that is no component or element type is
|
|
190
|
+
refused saying which there are (`SpacePreviewError`).
|
|
188
191
|
|
|
189
192
|
The project is the working directory — where every script of its `package.json` runs it, and where a deployment runs
|
|
190
193
|
`node dist/main.js` — never worked out from where a file is: `serveProject` and `authorProjectSpace` refuse to start
|
|
@@ -202,7 +205,7 @@ a plugin with no `declaration.ts`, no `.env.example` — is printed while develo
|
|
|
202
205
|
|
|
203
206
|
| Option | What it is |
|
|
204
207
|
|---|---|
|
|
205
|
-
| `space` | The space held in the project: a function that authors it — `authorProjectSpace` — called once the project's layout is checked (a save while developing is authored again by
|
|
208
|
+
| `space` | The space held in the project: a function that authors it — `authorProjectSpace` — called once the project's layout is checked (a save while developing is authored again by `.plitzi/author.ts`, in a process of its own). Served from memory; its `warnings` are printed at boot. |
|
|
206
209
|
| `cloud` | Instead of `space`: `{ name }` — the space stays in Plitzi and is read with `createCloudAdapters`, from `PLITZI_HOST_KEY` (required), `PLITZI_ENVIRONMENT` (`main` by default), `PLITZI_REVISION` and `PLITZI_SERVER_URL`. `name` is what `/health` answers with. |
|
|
207
210
|
| `actions`, `connectors` | The space's server actions, found by their id, and the connectors they call. Left out, the server runs no actions. |
|
|
208
211
|
| `serverOptions` | The project's `src/config/serverOptions.ts`, typed `ProjectServerOptions`: what `createServer` takes but for what `serveProject` wires, spread before it — `logLevel` and `logger` (`warn`, to the console; `--verbose` on the command line: `info`), `auth`, `images`, `rsc`, `action.limits`, `action.kv` are the project's to set. |
|
|
@@ -230,14 +233,15 @@ What it wires from the project:
|
|
|
230
233
|
`dist/runtime/index.js` when the process was started on what `build` emitted (`process.argv[1]` under `dist/`), or
|
|
231
234
|
`vendor/runtime.bundle` — in this process, its endpoints answered before anything else.
|
|
232
235
|
- **Its files.** `public/` served as it is, `src/data/` read and never served (`dataDir`), the `kv` in `state/kv.json`
|
|
233
|
-
(`createFileKv`), `
|
|
236
|
+
(`createFileKv`) and the job queue beside it, `state/jobs.json` (`createFileJobQueue`: a `ctx.later` due while the
|
|
237
|
+
server was down runs once it is back), `PLITZI_SIGNING_SECRET` what `ctx.sign` signs with.
|
|
234
238
|
- **Where it is.** `/health` answers with the space's permanent URL (or the cloud `name`), and `tmp/dev-server.json`
|
|
235
239
|
records the name, the port, the URL this machine reaches it at (`https` with a certificate), its network addresses
|
|
236
240
|
and its `publicUrl` — for `plitzi page check`, `shot`, `verify` and `visual`. A signal closes it (`closeOnSignals`).
|
|
237
241
|
|
|
238
242
|
While developing — `NODE_ENV` other than `production` — `devMode` and `livePages` are on, and:
|
|
239
243
|
|
|
240
|
-
- **A save to the space is authored again** by the project's
|
|
244
|
+
- **A save to the space is authored again** by the project's `.plitzi/author.ts`, in a process of its own (an import is
|
|
241
245
|
never read twice in one process), run with `--ipc`: it hands the documents back over the IPC channel, the server
|
|
242
246
|
swaps them in memory and hands them to every open page, which swaps the space where it stands — its state, scroll and
|
|
243
247
|
focus kept (`updatePages`); a page with elements the server draws loads again instead. What the script refuses it
|
|
@@ -277,8 +281,8 @@ what `serveProject` wires itself (see [Projects](#projects)).
|
|
|
277
281
|
| `pluginsCacheDir` | `string` | `tmp/.sdk-plugins` | Directory where compiled plugin files are stored — under `tmp/`, with everything else the server writes for itself. |
|
|
278
282
|
| `pluginsTtlMs` | `number` | `604800000` | TTL in milliseconds for compiled plugins (default: 1 week). |
|
|
279
283
|
| `autoLoadSchemaPlugins` | `boolean` | `true` | Auto-download and cache plugins declared in the schema's `offlineData.plugins` list. A type the deployment registers itself (`plugins`, named in `pluginNames`) is never looked for there: its own build is the one rendered. Set to `false` to manage plugin loading manually. |
|
|
280
|
-
| `
|
|
281
|
-
| `publicDir` | `string` | — | Absolute path to a directory served at the root URL level (e.g. `
|
|
284
|
+
| `outbound` | `{ privateOrigins?: string[] }` | — | What the requests a space's documents write may reach from inside this server — a server provider's `query`, `http.request`, a connector, a function's `fetch`, a plugin's address. None reaches a private address (`localhost`, this server's network, the cloud's metadata) but the origins named in `privateOrigins` — the deployment's own storage, CDN or API on its network (`http://localhost:9000` for a local S3), each `scheme://host:port`, no path. |
|
|
285
|
+
| `publicDir` | `string` | — | Absolute path to a directory served at the root URL level (e.g. `favicon.png`, a verification file). Files are checked before `static` prefix routes. **Everything in it is public:** served to anyone who asks, with no check. A `robots.txt` or `sitemap.xml` there shadows the space's own — see [Search engines](#search-engines). |
|
|
282
286
|
| `dataDir` | `string` | — | The project's own data, never served: a provider resolved on the server (`runtime: 'server'`) whose `query` is `/data/<file>` reads `<dataDir>/<file>`, and a function reads it with `ctx.data(file)` — the space's `getData` when the deployment gives none. See [Project data](#project-data). |
|
|
283
287
|
| `static` | `Record<string, string>` | — | URL prefix → filesystem path mappings for static file serving. |
|
|
284
288
|
| `images` | `{ domains, cacheDir? }` | — | Pictures from other sites resized at `/_plitzi/img`, for an `image` to offer as a `srcset` (see [Images](#images)). |
|
|
@@ -578,7 +582,8 @@ with `resize: false` keeps its `src` as written. Resizing needs `sharp`
|
|
|
578
582
|
|
|
579
583
|
### Public directory
|
|
580
584
|
|
|
581
|
-
Use `publicDir` to serve your own root-level files (e.g. `
|
|
585
|
+
Use `publicDir` to serve your own root-level files (e.g. `favicon.png`, a search console's verification file) without
|
|
586
|
+
prefixes:
|
|
582
587
|
|
|
583
588
|
```ts
|
|
584
589
|
createServer({
|
|
@@ -595,6 +600,20 @@ some visitors may read in it: that is served by a server action whose `access` c
|
|
|
595
600
|
|
|
596
601
|
`/.well-known/` paths follow the same lookup order: served from `publicDir` if a matching file exists, otherwise `404 Not Found`. They are never handled by the SSR renderer.
|
|
597
602
|
|
|
603
|
+
### Search engines
|
|
604
|
+
|
|
605
|
+
Every space answers its own `/robots.txt` and `/sitemap.xml`, at the address it is asked on — its own domain or another:
|
|
606
|
+
|
|
607
|
+
- `/robots.txt` is the space's `settings.robotsTxt` (`User-agent: *` / `Allow: /` when it says none), then — with
|
|
608
|
+
`settings.blockAiCrawlers: true` — a `Disallow: /` for each crawler that trains AI models (`AI_CRAWLERS`), then
|
|
609
|
+
`Sitemap: <origin>/sitemap.xml` unless its own text names a sitemap.
|
|
610
|
+
- `/sitemap.xml` lists every page a search engine may read (`sitemapPaths` in `@plitzi/sdk-shared/navigation`): not a
|
|
611
|
+
page only signed-in visitors or a role may open, one whose slug takes a parameter or is `*`, one that says `noindex` or
|
|
612
|
+
one behind a feature flag.
|
|
613
|
+
|
|
614
|
+
Both are read off the space, so they follow it as it changes. A `robots.txt` or `sitemap.xml` in `publicDir` is answered
|
|
615
|
+
first and shadows them for every space this server serves: put none there unless that is the point.
|
|
616
|
+
|
|
598
617
|
### Project data
|
|
599
618
|
|
|
600
619
|
A project with no backend keeps its data as JSON files, and `dataDir` is where they stay off the internet: nothing
|
|
@@ -1098,7 +1117,10 @@ There is no third argument for the security-relevant parts, on purpose: password
|
|
|
1098
1117
|
is rate-limited in memory, mailed links expire, and CSRF is on. Each of those used to be an option with no default —
|
|
1099
1118
|
which meant the ordinary deployment went without, because nobody configures what they have not read about. Supply
|
|
1100
1119
|
`api.hashPassword`/`verifyPassword` to keep an existing algorithm (a store of bcrypt hashes needs bcrypt), and
|
|
1101
|
-
`api.rateLimit` to put one counter behind a fleet.
|
|
1120
|
+
`api.rateLimit` to put one counter behind a fleet. Name the terms accounts are opened under — `api.terms: { version }`
|
|
1121
|
+
— and `/auth/signup` refuses a sign-up without `acceptedTerms: true` (400, `field: 'acceptedTerms'`) and hands
|
|
1122
|
+
`createAccount` the version accepted and when (`termsAccepted`), for the account store to keep; named none, sign-up asks
|
|
1123
|
+
for nothing more.
|
|
1102
1124
|
|
|
1103
1125
|
`auth` on the server is the whole of the wiring: it mounts the `/auth` flows, answers the identity adapters a page
|
|
1104
1126
|
server asks for, and carries the cookie naming with it — so there is no second place to keep in step. It also tells
|
|
@@ -1166,11 +1188,25 @@ Postgres, MySQL, Mongo or an identity service:
|
|
|
1166
1188
|
| `findByRefreshToken(token)` | renewal — the row is its revocation switch. `refreshExpiresAt` overrides the token's own expiry |
|
|
1167
1189
|
| `findMembership(userId, spaceId)` | space-level permission checks (`auth.can`) |
|
|
1168
1190
|
| `createAccount`, `findByEmail`, `setResetToken`, `sendMail`, … | signup, password reset, verification |
|
|
1191
|
+
| `passwordSignInRefused(account)` | an organization's own sign-in required: asked once the password is proved, its words a 401 `sso-required` |
|
|
1169
1192
|
|
|
1170
1193
|
**What is absent decides what the deployment offers.** No `createAccount`, no signup — and the route answers 404
|
|
1171
1194
|
rather than failing at runtime. Declining a flow is one act: do not implement it. `GET /auth/capabilities` publishes
|
|
1172
1195
|
the result, so a sign-in page renders what the backend actually answers instead of a button that dead-ends.
|
|
1173
1196
|
|
|
1197
|
+
### Signing in through a provider
|
|
1198
|
+
|
|
1199
|
+
`createSocialAuth` (`@plitzi/sdk-server/auth`) is the authorization-code grant with PKCE, its state in a signed cookie,
|
|
1200
|
+
and `mountSocialAuthRoutes` (`@plitzi/sdk-server/handlers`) its routes: `/providers`, `/<provider>/login`,
|
|
1201
|
+
`/<provider>/callback`, `/continue`, `/sso`. Google and GitHub are built in — credentials alone register one — and
|
|
1202
|
+
`createOidcProvider({ id, label, issuer, clientId, clientSecret, redirectUri })` is any OpenID Connect issuer: its
|
|
1203
|
+
discovery document read and checked to be the issuer's, the profile read from the ID token verified against its
|
|
1204
|
+
published keys (asymmetric only), for this client, with the flow's `nonce`. What stays yours is `linkAccount(provider,
|
|
1205
|
+
profile)` — who comes back — and, for an organization's own sign-in set up by its administrators rather than by the
|
|
1206
|
+
deployment (single sign-on), `resolveProvider(id, redirectUri)`, a provider resolved per request, with
|
|
1207
|
+
`providerForEmail(email)`: which one signs an address in, what `GET /sso?email=` answers. A refusal of yours is an
|
|
1208
|
+
`OAuthFailure(reason, message, detail?)`: the browser lands on its target with `?error=<reason>&detail=<detail>`.
|
|
1209
|
+
|
|
1174
1210
|
### …or don't: `@plitzi/sdk-server/mysql`
|
|
1175
1211
|
|
|
1176
1212
|
If you are standing a user store up rather than adapting one you have, the table above is ceremony. Import the
|
|
@@ -1202,6 +1238,16 @@ schema, because it is written as the set of questions your adapters have to answ
|
|
|
1202
1238
|
sign-out also answer a full-page form submission with a `303` so the view re-renders, which a `fetch` client does
|
|
1203
1239
|
not need and a `<form>` does.
|
|
1204
1240
|
|
|
1241
|
+
Signing out everywhere takes a scope: `POST /auth/sessions/revoke { "scope": "site" }` ends the account's sessions
|
|
1242
|
+
signed in on the host asked (each session records it, `SessionClient.host`), `"all"` (or none) every one; a page server
|
|
1243
|
+
answers the same at `/auth/logout-everywhere` (`endSessions`, `logoutEverywherePath`) for its own host — a space's visitor
|
|
1244
|
+
signing out of that space on their phone too.
|
|
1245
|
+
|
|
1246
|
+
A write a page makes with the session cookie — `/auth/sessions/revoke`, `/auth/profile`,
|
|
1247
|
+
`/auth/password` — carries the CSRF token in the header `GET /auth/csrf` names (`{ token, headerName }`); one sent with
|
|
1248
|
+
`Authorization: Bearer` needs none. A sign-up refused because the account exists says which field to change:
|
|
1249
|
+
`400 { error, field: 'username' | 'email' }`.
|
|
1250
|
+
|
|
1205
1251
|
**Changing an email is a confirmation, not a write.** Supply `setPendingEmail` / `findByPendingEmail` /
|
|
1206
1252
|
`clearPendingEmail` (the MySQL store has them) and `POST /auth/profile` parks the new address instead of applying
|
|
1207
1253
|
it: the account keeps signing in with the old one until `POST /auth/confirm-email` proves somebody reads the new
|
package/dist/actions.d.ts
CHANGED
|
@@ -21,10 +21,13 @@ export { createActionsModule, spaceKvPatterns } from './modules/actions';
|
|
|
21
21
|
*
|
|
22
22
|
* `createActionsModule` already assembles these from `jobs` — a deployment reaches for them directly only to run a
|
|
23
23
|
* sweep from its own cron, to build a worker in a process that serves no pages, or to hold the queue itself for an
|
|
24
|
-
* operator's panel. The in-memory queue is the default and is correct for exactly one replica
|
|
24
|
+
* operator's panel. The in-memory queue is the default and is correct for exactly one replica; `createFileJobQueue` keeps
|
|
25
|
+
* one process's in a JSON file, through a restart (a project's server keeps `state/jobs.json`).
|
|
25
26
|
*/
|
|
26
27
|
export { createActionJobs, createJobWorker, createMemoryJobQueue, createScheduler } from './modules/actions/jobs';
|
|
28
|
+
export { createFileJobQueue } from './modules/actions/jobs/fileQueue';
|
|
27
29
|
export { DEFAULT_MAX_ATTEMPTS, scheduleFor, scheduleJobId, schedulesFor } from './modules/actions/jobs';
|
|
30
|
+
export type { FileJobQueue, FileJobQueueOptions } from './modules/actions/jobs/fileQueue';
|
|
28
31
|
/**
|
|
29
32
|
* An operator's hold on the jobs from a process that serves no pages — a Queue panel's API: pause, resume, cancel and
|
|
30
33
|
* requeue, each said on `$job:<id>` to whoever watches a job of the spaces' functions.
|
package/dist/actions.js
CHANGED
|
@@ -3,11 +3,11 @@ import { DEFAULT_MAX_ATTEMPTS, scheduleFor, scheduleJobId, schedulesFor } from "
|
|
|
3
3
|
import { createScheduler } from "./modules/actions/jobs/scheduler.js";
|
|
4
4
|
import { ActionRefusal, ActionRunError } from "./modules/actions/runtime/errors.js";
|
|
5
5
|
import { createJobWorker } from "./modules/actions/jobs/worker.js";
|
|
6
|
+
import { createMemoryKv } from "./modules/actions/runtime/memoryKv.js";
|
|
6
7
|
import { createActionJobs } from "./modules/actions/jobs/index.js";
|
|
7
8
|
import { MAX_LIST_BYTES, MAX_LIST_ENTRIES } from "./modules/actions/runtime/kvList.js";
|
|
8
9
|
import { createKvStore } from "./modules/actions/runtime/kvStore.js";
|
|
9
10
|
import { DEFAULT_LIMITS } from "./modules/actions/runtime/limits.js";
|
|
10
|
-
import { createMemoryKv } from "./modules/actions/runtime/memoryKv.js";
|
|
11
11
|
import { spaceKvPatterns } from "./modules/actions/runtime/namespaceKv.js";
|
|
12
12
|
import { MIN_SIGNING_SECRET_LENGTH } from "./modules/actions/runtime/signing.js";
|
|
13
13
|
import { createTaskRegistry, taskName } from "./modules/actions/tasks/registry.js";
|
|
@@ -15,8 +15,9 @@ import { checkAction } from "./modules/actions/runtime/check.js";
|
|
|
15
15
|
import { createRejectLogger, createRunLogger } from "./modules/actions/runtime/runLogger.js";
|
|
16
16
|
import { describeCatalog, describeTask } from "./modules/actions/taskCatalog.js";
|
|
17
17
|
import { createActionsModule } from "./modules/actions/index.js";
|
|
18
|
+
import { createFileJobQueue } from "./modules/actions/jobs/fileQueue.js";
|
|
18
19
|
import { createJobControl } from "./modules/functions/jobControl.js";
|
|
19
20
|
import { createFileKv } from "./modules/actions/runtime/fileKv.js";
|
|
20
21
|
import { createRedisKv } from "./modules/actions/runtime/redisKv.js";
|
|
21
22
|
import { cronFiresBetween, cronMatches, cronNextFire, parseCron } from "@plitzi/sdk-shared/actions";
|
|
22
|
-
export { ActionRefusal, ActionRunError, DEFAULT_LIMITS, DEFAULT_MAX_ATTEMPTS, MAX_LIST_BYTES, MAX_LIST_ENTRIES, MIN_SIGNING_SECRET_LENGTH, checkAction, createActionJobs, createActionsModule, createFileKv, createJobControl, createJobWorker, createKvStore, createMemoryJobQueue, createMemoryKv, createRedisKv, createRejectLogger, createRunLogger, createScheduler, createTaskRegistry, cronFiresBetween, cronMatches, cronNextFire, describeCatalog, describeTask, parseCron, scheduleFor, scheduleJobId, schedulesFor, spaceKvPatterns, taskName };
|
|
23
|
+
export { ActionRefusal, ActionRunError, DEFAULT_LIMITS, DEFAULT_MAX_ATTEMPTS, MAX_LIST_BYTES, MAX_LIST_ENTRIES, MIN_SIGNING_SECRET_LENGTH, checkAction, createActionJobs, createActionsModule, createFileJobQueue, createFileKv, createJobControl, createJobWorker, createKvStore, createMemoryJobQueue, createMemoryKv, createRedisKv, createRejectLogger, createRunLogger, createScheduler, createTaskRegistry, cronFiresBetween, cronMatches, cronNextFire, describeCatalog, describeTask, parseCron, scheduleFor, scheduleJobId, schedulesFor, spaceKvPatterns, taskName };
|
package/dist/auth.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { createCarriers, presentedOrigin } from './core/auth/credentials';
|
|
|
29
29
|
export { ANY_DOMAIN, corsOrigins, domainAllowed, frameAncestors, hostnameOf, normalizeDomain } from './core/auth/domains';
|
|
30
30
|
export { createIdentity } from './core/auth/identity';
|
|
31
31
|
export { generateToken, hashPassword, verifyPassword } from './core/auth/passwords';
|
|
32
|
-
export { BUILT_IN_PROVIDERS, OAuthFailure, createSocialAuth, requestProfileJson } from './core/auth/oauth';
|
|
32
|
+
export { BUILT_IN_PROVIDERS, OAuthFailure, createOidcProvider, createSocialAuth, discoverOidc, requestProfileJson } from './core/auth/oauth';
|
|
33
33
|
export { createRedirectPolicy } from './core/auth/redirects';
|
|
34
34
|
export { isDocumentNavigation, renewForNavigation } from './core/auth/renewal';
|
|
35
35
|
export type { RenewalOptions } from './core/auth/renewal';
|
|
@@ -46,7 +46,7 @@ export type { AuthPolicy, AuthorizeResult, Authorizer, MembershipFacts, PathMatc
|
|
|
46
46
|
export type { CredentialCarrier } from './core/auth/credentials';
|
|
47
47
|
export type { Csrf, CsrfCarrier, CsrfConfig, CsrfFailure, CsrfResult, CsrfSubject } from './core/auth/csrf';
|
|
48
48
|
export type { Actor, ActorResult, Grant, GrantOptions, GrantResult, Identity, IdentityAdapters, IdentityConfig, SpaceMembership, StoredSpaceToken } from './core/auth/identity';
|
|
49
|
-
export type { CompletedFlow, OAuthFailureReason, OAuthProfile, OAuthProvider, OAuthProviderConfig, SocialAuth, SocialAuthAdapters, SocialAuthConfig, StartedFlow } from './core/auth/oauth';
|
|
49
|
+
export type { CompletedFlow, ListedProvider, OAuthFailureReason, OAuthProfile, OAuthProvider, OAuthProviderConfig, OAuthTokens, OidcDiscovery, OidcProviderOptions, SocialAuth, SocialAuthAdapters, SocialAuthConfig, StartedFlow } from './core/auth/oauth';
|
|
50
50
|
export type { AuthRequest, AuthRoute } from './core/auth/routes';
|
|
51
51
|
export type { CookieCarrier, CookieSink, SessionCookieParams, SessionCookies, SessionHint } from './core/auth/session';
|
|
52
52
|
export type { SpaceTokenAdapters, SpaceTokenApi, SpaceTokenContext, SpaceTokenOutcome, SpaceTokenRecord, SpaceTokenSummary } from './core/auth/spaceTokens';
|
package/dist/auth.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createMemoryRateLimit } from "./core/auth/throttle.js";
|
|
1
2
|
import { createCarriers, presentedOrigin } from "./core/auth/credentials.js";
|
|
2
3
|
import { appendCookies, clearFlowCookie, clearSessionCookies, createSessionCookies, isLocalHost, parseSessionHint, readFlowCookie, readRefreshToken, readSessionHint, readSessionToken, sessionCookieParams, sessionHintValue, sessionReturnTarget, writeFlowCookie, writeSessionCookies } from "./core/auth/session.js";
|
|
3
4
|
import { createCsrf, csrfFailureMessage } from "./core/auth/csrf.js";
|
|
@@ -6,16 +7,16 @@ import { isDocumentNavigation, renewForNavigation } from "./core/auth/renewal.js
|
|
|
6
7
|
import { ANY_DOMAIN, corsOrigins, domainAllowed, frameAncestors, hostnameOf, normalizeDomain } from "./core/auth/domains.js";
|
|
7
8
|
import { checkPermission, checkSpaceAccess, createAuthorizer, requirementFor } from "./core/auth/authorize.js";
|
|
8
9
|
import { generateToken, hashPassword, verifyPassword } from "./core/auth/passwords.js";
|
|
9
|
-
import { createMemoryRateLimit } from "./core/auth/throttle.js";
|
|
10
|
-
import { SCOPES, authFailureMessage, createTokens, userIdOf } from "./core/auth/tokens.js";
|
|
11
10
|
import { generateRecoveryCodes, generateTotpSecret, normalizeRecoveryCode, randomCode, totpCode, totpStep, totpUri, verifyTotp } from "./core/auth/totp.js";
|
|
12
|
-
import {
|
|
11
|
+
import { SCOPES, authFailureMessage, createTokens, userIdOf } from "./core/auth/tokens.js";
|
|
12
|
+
import { createAuthApi } from "./core/auth/api/index.js";
|
|
13
13
|
import { createIdentity } from "./core/auth/identity.js";
|
|
14
14
|
import { createAuth } from "./core/auth/createAuth.js";
|
|
15
15
|
import { SESSION_ACTIVITY_RESOLUTION_SECONDS, activityDue } from "./core/auth/sessionActivity.js";
|
|
16
16
|
import { OAuthFailure } from "./core/auth/oauth/types.js";
|
|
17
17
|
import { requestProfileJson } from "./core/auth/oauth/client.js";
|
|
18
18
|
import { createRedirectPolicy } from "./core/auth/redirects.js";
|
|
19
|
+
import { createOidcProvider, discoverOidc } from "./core/auth/oauth/providers/oidc.js";
|
|
19
20
|
import { BUILT_IN_PROVIDERS, createSocialAuth } from "./core/auth/oauth/index.js";
|
|
20
21
|
import { createSpaceTokenApi } from "./core/auth/spaceTokens.js";
|
|
21
|
-
export { ANY_DOMAIN, BUILT_IN_PROVIDERS, OAuthFailure, SCOPES, SESSION_ACTIVITY_RESOLUTION_SECONDS, activityDue, appendCookies, applySessionOutcome, authFailureMessage, authPolicyRules, authRoutes, checkPermission, checkSpaceAccess, clearFlowCookie, clearSessionCookies, corsOrigins, createAuth, createAuthApi, createAuthorizer, createCarriers, createCsrf, createIdentity, createMemoryRateLimit, createRedirectPolicy, createSessionCookies, createSocialAuth, createSpaceTokenApi, createTokens, csrfFailureMessage, domainAllowed, frameAncestors, generateRecoveryCodes, generateToken, generateTotpSecret, hashPassword, hostnameOf, isDocumentNavigation, isLocalHost, normalizeDomain, normalizeRecoveryCode, parseSessionHint, presentedOrigin, randomCode, readFlowCookie, readRefreshToken, readSessionHint, readSessionToken, renewForNavigation, requestProfileJson, requirementFor, sessionCookieParams, sessionHintValue, sessionReturnTarget, totpCode, totpStep, totpUri, userIdOf, verifyPassword, verifyTotp, writeFlowCookie, writeSessionCookies };
|
|
22
|
+
export { ANY_DOMAIN, BUILT_IN_PROVIDERS, OAuthFailure, SCOPES, SESSION_ACTIVITY_RESOLUTION_SECONDS, activityDue, appendCookies, applySessionOutcome, authFailureMessage, authPolicyRules, authRoutes, checkPermission, checkSpaceAccess, clearFlowCookie, clearSessionCookies, corsOrigins, createAuth, createAuthApi, createAuthorizer, createCarriers, createCsrf, createIdentity, createMemoryRateLimit, createOidcProvider, createRedirectPolicy, createSessionCookies, createSocialAuth, createSpaceTokenApi, createTokens, csrfFailureMessage, discoverOidc, domainAllowed, frameAncestors, generateRecoveryCodes, generateToken, generateTotpSecret, hashPassword, hostnameOf, isDocumentNavigation, isLocalHost, normalizeDomain, normalizeRecoveryCode, parseSessionHint, presentedOrigin, randomCode, readFlowCookie, readRefreshToken, readSessionHint, readSessionToken, renewForNavigation, requestProfileJson, requirementFor, sessionCookieParams, sessionHintValue, sessionReturnTarget, totpCode, totpStep, totpUri, userIdOf, verifyPassword, verifyTotp, writeFlowCookie, writeSessionCookies };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthContext } from './context';
|
|
2
|
+
import { AuthOutcome } from './types';
|
|
3
|
+
/** An account made and recovered: signing up, verifying the address, forgetting and resetting the password. */
|
|
4
|
+
export declare const accountsFlows: ({ adapters, hashPassword, generateToken, verifyOnSignup, terms, record, mintLink, linkExpired, deliver, throttled, rejectPassword, capabilities }: AuthContext) => {
|
|
5
|
+
signup: (fields: Record<string, unknown>) => Promise<AuthOutcome>;
|
|
6
|
+
/** Answers the same either way: whether an address has an account here is not something a stranger may probe. */
|
|
7
|
+
forgotPassword: (email: string) => Promise<AuthOutcome>;
|
|
8
|
+
resetPassword: (token: string, password: string) => Promise<AuthOutcome>;
|
|
9
|
+
validateAccount: (token: string) => Promise<AuthOutcome>;
|
|
10
|
+
resendVerification: (email: string, redirect?: string) => Promise<AuthOutcome>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { LIFETIME, NOT_OFFERED, asString, asText, destinationOf, refuse } from "./values.js";
|
|
2
|
+
//#region src/core/auth/api/accounts.ts
|
|
3
|
+
/** An account made and recovered: signing up, verifying the address, forgetting and resetting the password. */
|
|
4
|
+
var accountsFlows = ({ adapters, hashPassword, generateToken, verifyOnSignup, terms, record, mintLink, linkExpired, deliver, throttled, rejectPassword, capabilities }) => ({
|
|
5
|
+
signup: async (fields) => {
|
|
6
|
+
if (!capabilities.signup) return NOT_OFFERED;
|
|
7
|
+
const username = asString(fields.username);
|
|
8
|
+
const email = asString(fields.email);
|
|
9
|
+
const password = asText(fields.password);
|
|
10
|
+
if (!username || !email || !password) return refuse(400, "A username, an email and a password are required");
|
|
11
|
+
if (terms && fields.acceptedTerms !== true && fields.acceptedTerms !== "true") return {
|
|
12
|
+
ok: false,
|
|
13
|
+
status: 400,
|
|
14
|
+
body: {
|
|
15
|
+
error: "Accept the terms of service to create an account",
|
|
16
|
+
field: "acceptedTerms"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const weak = await rejectPassword(password, {
|
|
20
|
+
username,
|
|
21
|
+
email
|
|
22
|
+
});
|
|
23
|
+
if (weak) return weak;
|
|
24
|
+
const limited = await throttled({
|
|
25
|
+
action: "signup",
|
|
26
|
+
key: email
|
|
27
|
+
});
|
|
28
|
+
if (limited) return limited;
|
|
29
|
+
const takenBy = async () => {
|
|
30
|
+
const taken = await adapters.findByUsername?.(username) ? "username" : await adapters.findByEmail?.(email) ? "email" : void 0;
|
|
31
|
+
return taken ? {
|
|
32
|
+
ok: false,
|
|
33
|
+
status: 400,
|
|
34
|
+
body: {
|
|
35
|
+
error: taken === "username" ? "That username is already taken" : "An account with that email already exists",
|
|
36
|
+
field: taken
|
|
37
|
+
}
|
|
38
|
+
} : void 0;
|
|
39
|
+
};
|
|
40
|
+
const takenBefore = await takenBy();
|
|
41
|
+
if (takenBefore) return takenBefore;
|
|
42
|
+
if (!adapters.createAccount) return NOT_OFFERED;
|
|
43
|
+
const createAccount = adapters.createAccount;
|
|
44
|
+
/**
|
|
45
|
+
* Taken in the meantime, by a sign-up with the same name or address that got there first: what the store refused
|
|
46
|
+
* is said as the check above says it. Two at once (a double submit, two tabs) answered one of them a 500.
|
|
47
|
+
*/
|
|
48
|
+
const account = await createAccount({
|
|
49
|
+
username,
|
|
50
|
+
email,
|
|
51
|
+
passwordHash: await hashPassword(password),
|
|
52
|
+
...terms ? { termsAccepted: {
|
|
53
|
+
version: terms.version,
|
|
54
|
+
at: /* @__PURE__ */ new Date()
|
|
55
|
+
} } : {}
|
|
56
|
+
}).catch(async (error) => {
|
|
57
|
+
const takenSince = await takenBy();
|
|
58
|
+
if (takenSince) return takenSince;
|
|
59
|
+
throw error;
|
|
60
|
+
});
|
|
61
|
+
if ("ok" in account) return account;
|
|
62
|
+
if (!verifyOnSignup && capabilities.emailVerification && adapters.setValidationToken) {
|
|
63
|
+
const validationToken = mintLink(generateToken(), LIFETIME.confirmLink);
|
|
64
|
+
await adapters.setValidationToken(account.id, validationToken);
|
|
65
|
+
await deliver({
|
|
66
|
+
to: email,
|
|
67
|
+
template: "validation",
|
|
68
|
+
data: {
|
|
69
|
+
username,
|
|
70
|
+
validationToken,
|
|
71
|
+
...destinationOf(fields.redirect)
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
record({
|
|
76
|
+
type: "signup",
|
|
77
|
+
userId: account.id
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
ok: true,
|
|
81
|
+
status: 201,
|
|
82
|
+
body: {
|
|
83
|
+
message: "User created successfully",
|
|
84
|
+
userId: account.id
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
/** Answers the same either way: whether an address has an account here is not something a stranger may probe. */
|
|
89
|
+
forgotPassword: async (email) => {
|
|
90
|
+
if (!capabilities.passwordReset) return NOT_OFFERED;
|
|
91
|
+
const limited = await throttled({
|
|
92
|
+
action: "forgotPassword",
|
|
93
|
+
key: asString(email)
|
|
94
|
+
});
|
|
95
|
+
if (limited) return limited;
|
|
96
|
+
const account = await adapters.findByEmail?.(asString(email));
|
|
97
|
+
if (account) {
|
|
98
|
+
const resetToken = mintLink(generateToken(), LIFETIME.resetLink);
|
|
99
|
+
await adapters.setResetToken?.(account.id, resetToken);
|
|
100
|
+
await deliver({
|
|
101
|
+
to: account.email,
|
|
102
|
+
template: "password-reset",
|
|
103
|
+
data: {
|
|
104
|
+
username: account.username,
|
|
105
|
+
resetToken
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
ok: true,
|
|
111
|
+
body: { message: "Password reset email sent" }
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
resetPassword: async (token, password) => {
|
|
115
|
+
if (!capabilities.passwordReset) return NOT_OFFERED;
|
|
116
|
+
if (!token || !password) return refuse(400, "A token and a password are required");
|
|
117
|
+
const limited = await throttled({
|
|
118
|
+
action: "resetPassword",
|
|
119
|
+
key: token
|
|
120
|
+
});
|
|
121
|
+
if (limited) return limited;
|
|
122
|
+
const account = linkExpired(token) ? void 0 : await adapters.findByResetToken?.(token);
|
|
123
|
+
if (!account) return refuse(400, "Invalid or expired token");
|
|
124
|
+
const weak = await rejectPassword(password, {
|
|
125
|
+
username: account.username,
|
|
126
|
+
email: account.email
|
|
127
|
+
});
|
|
128
|
+
if (weak) return weak;
|
|
129
|
+
await adapters.setPassword?.(account.id, await hashPassword(password));
|
|
130
|
+
await adapters.setResetToken?.(account.id, "");
|
|
131
|
+
await adapters.clearSession({ userId: account.id });
|
|
132
|
+
record({
|
|
133
|
+
type: "password.reset",
|
|
134
|
+
userId: account.id
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
ok: true,
|
|
138
|
+
body: { message: "Password reset successfully" },
|
|
139
|
+
endSession: true
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
validateAccount: async (token) => {
|
|
143
|
+
if (!capabilities.emailVerification) return NOT_OFFERED;
|
|
144
|
+
const account = linkExpired(token) ? void 0 : await adapters.findByValidationToken?.(token);
|
|
145
|
+
if (!account) return refuse(400, "Invalid or expired token");
|
|
146
|
+
await adapters.setVerified?.(account.id, true);
|
|
147
|
+
return {
|
|
148
|
+
ok: true,
|
|
149
|
+
body: { message: "Account validated successfully" }
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
resendVerification: async (email, redirect) => {
|
|
153
|
+
if (!capabilities.emailVerification) return NOT_OFFERED;
|
|
154
|
+
const account = await adapters.findByEmail?.(asString(email));
|
|
155
|
+
if (account && !account.verified) {
|
|
156
|
+
const validationToken = mintLink(generateToken(), LIFETIME.confirmLink);
|
|
157
|
+
await adapters.setValidationToken?.(account.id, validationToken);
|
|
158
|
+
await deliver({
|
|
159
|
+
to: account.email,
|
|
160
|
+
template: "validation",
|
|
161
|
+
data: {
|
|
162
|
+
username: account.username,
|
|
163
|
+
validationToken,
|
|
164
|
+
...destinationOf(redirect)
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
ok: true,
|
|
170
|
+
body: { message: "Verification email resent" }
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
//#endregion
|
|
175
|
+
export { accountsFlows };
|