@procedures/server 0.4.0 → 0.5.0
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 +33 -0
- package/README.md +26 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +53 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/run.d.ts +5 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +43 -1
- package/dist/run.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/config.ts +52 -1
- package/src/index.ts +1 -1
- package/src/run.ts +47 -1
- package/src/types.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @procedures/server
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a47bee6: The hosts can confine the file procedures to a root (roadmap R33).
|
|
8
|
+
|
|
9
|
+
- `confineFsProcedures(registry, root)` of `@procedures/fs` replaces the handler of each `fs.*` procedure of a registry with the handler of `createFsModule({ root })`. It adds no procedure. A nested `fs.*` call of another procedure is confined too. The root must be a folder that exists.
|
|
10
|
+
- `mark --fs-root <folder>` confines the `fs.*` procedures of each mode and host of `mark`: a command, the REPL, `--server`, `serve` and `mcp`. Give the flag before the command.
|
|
11
|
+
- A `mark` command uses a CLI server only when the server has the same root. The lockfile of `@procedures/peer` has the new field `fsRoot`, and `findServer()` compares it.
|
|
12
|
+
- `procedure-server --fs-root <folder>` and `mark serve --fs-root <folder>` confine the procedures of the server.
|
|
13
|
+
- The MCP server reads `MCP_FS_ROOT`, and `mark mcp` has the flag `--fs-root`. `fs` is not a tool namespace, so the tools do not change.
|
|
14
|
+
- A path outside the root gives `FORBIDDEN` with the reason `outside-root`. A procedure that reads files with `node:fs`, or that starts a program, is not confined.
|
|
15
|
+
- `@procedures/lib/cli-flags` has the global flags `--fs-root` and `--events`, and the field `repeatable`.
|
|
16
|
+
- a47bee6: The hosts serve the remote events (`documentation/EVENTS.md`).
|
|
17
|
+
|
|
18
|
+
- `hostPolicy()` takes the option `events`: the topic rule, with an optional bus, `allow` function and buffer. `procedureServerOptions()` gives it to the `ProcedureServer`, which pins `events.subscribe`. `HostPolicy` has the new field `events`.
|
|
19
|
+
- `procedure-server` and `mark serve` have the option `--events <patterns>`. The option is repeatable, and it takes comma-separated patterns: exact names, prefixes (`orders.*`) or `*`. `parseTopicPatterns()` checks them.
|
|
20
|
+
- `mark --server` has the same option `--events`.
|
|
21
|
+
- These hosts always serve `events.subscribe`. Without `--events`, they serve no topic, and each subscription gets `TOPIC_NOT_FOUND`. The bus is the global bus, which is also the `ctx.bus` of their procedures.
|
|
22
|
+
- The MCP server serves no events, because its transport carries only MCP.
|
|
23
|
+
- `mark --port`, `--host`, `--transport` and `--events` without `--server` are an error now, also before `serve` and `mcp`. Before, `mark --port 4000 serve` ignored `--port`.
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [0f75644]
|
|
28
|
+
- Updated dependencies [09e5566]
|
|
29
|
+
- Updated dependencies [ab77f75]
|
|
30
|
+
- Updated dependencies [a47bee6]
|
|
31
|
+
- Updated dependencies [a47bee6]
|
|
32
|
+
- Updated dependencies [bc74091]
|
|
33
|
+
- @procedures/client@0.5.0
|
|
34
|
+
- @procedures/peer@0.5.0
|
|
35
|
+
|
|
3
36
|
## 0.4.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -163,10 +163,35 @@ procedure-server -p @procedures/mongo/register -t http,websocket
|
|
|
163
163
|
| `--token` | - | `SERVER_TOKEN`, or a random token that the server prints | The token that every request sends: `Authorization: Bearer <token>`, or `?token=` for WebSocket |
|
|
164
164
|
| `--no-token` | - | - | Serve without a token (only on a trusted host) |
|
|
165
165
|
| `--expose` | `-e` | every loaded procedure | Comma-separated procedures to serve: exact keys (`git.status`) or prefixes (`git.*`) |
|
|
166
|
+
| `--events` | - | no topics | The topics of the event bus that a peer can subscribe to. Exact names (`orders.created`), prefixes (`orders.*`) or `*`. Repeat the option, or separate the patterns with commas. |
|
|
167
|
+
| `--fs-root` | - | no root | The folder that confines each path of the `fs.*` procedures, also in their nested calls |
|
|
166
168
|
| `--verbose` | `-v` | - | Verbose output |
|
|
167
169
|
| `--help` | `-h` | - | Show help |
|
|
168
170
|
|
|
169
|
-
`mark serve` takes the same options and starts the same server.
|
|
171
|
+
`mark serve` takes the same options and starts the same server. `mark --fs-root <folder> serve` gives the root to the server too.
|
|
172
|
+
|
|
173
|
+
### Remote events
|
|
174
|
+
|
|
175
|
+
The server always serves the procedure `events.subscribe` ([EVENTS.md](../documentation/EVENTS.md)). The `--events` patterns are its topic rule:
|
|
176
|
+
|
|
177
|
+
- Without `--events`, the rule is empty. Each subscription gets `TOPIC_NOT_FOUND`.
|
|
178
|
+
- The `--expose` list does not apply to `events.subscribe`. The topic rule is its expose rule.
|
|
179
|
+
- The bus is the global bus of the process. The procedures of the server get it as `ctx.bus`, so a procedure publishes with `ctx.bus.emit()`.
|
|
180
|
+
- The token applies to a subscription as to each call. The server has no capability, so it permits each subscription to a topic of the rule.
|
|
181
|
+
- A subscriber uses WebSocket (`transport.subscribe()`) or HTTP with NDJSON (`subscribeRemote()`).
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
procedure-server -p ./my-procedures.js -t http,websocket --events "orders.*" --events audit.created
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### The root of the file procedures
|
|
188
|
+
|
|
189
|
+
With `--fs-root <folder>`, the server starts `confineFsProcedures()` of `@procedures/fs` after it builds its registry (roadmap R33):
|
|
190
|
+
|
|
191
|
+
- Each `fs.*` procedure refuses a path outside the folder with `FORBIDDEN` and the reason `outside-root`. A relative path starts at the folder.
|
|
192
|
+
- A nested `fs.*` call of another procedure is confined too.
|
|
193
|
+
- The server does not start when the folder does not exist, or when it cannot load `@procedures/fs`.
|
|
194
|
+
- A procedure that reads files with `node:fs`, or that starts a program, is not confined. The [README of the MCP server](../impl-mcp-dev/README.md) lists them.
|
|
170
195
|
|
|
171
196
|
The server has a registry of its own (roadmap 3.1): the `server.*` procedures and the `./module` entry of each `--procedures` package. The `server.*` procedures come from two modules: the module of `@procedures/peer` (`server.create`, `server.call` and the others) and the module of this package. Two servers in one process serve only their own packages. `pkg/register`, the form of the old examples, gives the module of `pkg`. A package without a `./module` entry still works: the server takes the procedures that its import registers. The token, the `--expose` list and the browser checks come from `hostPolicy()` of `@procedures/client`.
|
|
172
197
|
|