@procedures/peer 0.44.0 → 0.46.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 +23 -0
- package/README.md +28 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/host/faces.d.ts +41 -3
- package/dist/host/faces.d.ts.map +1 -1
- package/dist/host/faces.js +31 -3
- package/dist/host/faces.js.map +1 -1
- package/dist/host/index.d.ts +5 -6
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/host/faces.ts +75 -5
- package/src/host/index.ts +7 -8
- package/src/index.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @procedures/peer
|
|
2
2
|
|
|
3
|
+
## 0.46.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [10dcc3c]
|
|
8
|
+
- @procedures/client@0.46.0
|
|
9
|
+
|
|
10
|
+
## 0.45.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- fbb50fa: `httpFace()` and `wsFace()` of `@procedures/peer` take two optional options, `narrowing` and `expose` (AG1-B). With them, a host serves a read-only face for a browser next to its full faces. This change is additive. Thus it is a PATCH of the client group (decision D13).
|
|
15
|
+
|
|
16
|
+
- `narrowing` is the narrowing of `mcpFace({ narrowing })` (CLI-43). The face adds it as one more source of the narrowing key. The server applies the meet of all the sources, so a header of the caller cannot make the face wider.
|
|
17
|
+
- `expose` is a list of patterns, a tool surface or a function, as `hostPolicy({ expose })`. The server meets it with the rule of the host, for the call and for each nested call. A path outside it gets `NOT_FOUND`.
|
|
18
|
+
- `@procedures/client` exports `faceRules()`, the one helper of these rules. `mcpFace()` of `@procedures/mcp-server` uses it too.
|
|
19
|
+
- `ServerRequest` has the optional field `expose`: the expose rule of the face that took the request. A face sets it, not the caller.
|
|
20
|
+
- A face without these options serves the same calls as before.
|
|
21
|
+
- Updated dependencies [fbb50fa]
|
|
22
|
+
- Updated dependencies [845902b]
|
|
23
|
+
- Updated dependencies [70b2245]
|
|
24
|
+
- @procedures/client@0.45.0
|
|
25
|
+
|
|
3
26
|
## 0.44.0
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -165,6 +165,34 @@ const client = new Client({ transport: local.transport });
|
|
|
165
165
|
- `probes: { prefix }` changes the prefix. `probes: false` turns the probes off, for example when the process has a probe server on a port of its own (`probeServer()`, or the option `probes` of `runProcedureHost()`).
|
|
166
166
|
- `host.info.probes()` gives the base URL of the probes on each listener. Without `listen`, the app mounts `probeHandler()` on its own listener.
|
|
167
167
|
|
|
168
|
+
### A read-only face for a browser
|
|
169
|
+
|
|
170
|
+
`httpFace()` and `wsFace()` take two optional options for the calls of the face (AG1-B). With them, a host serves a second face pair next to its full faces. The server enforces the rules of each face, so a page cannot go around them.
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { createProcedureHost, httpFace, wsFace, LOCAL_LISTENER_KNOBS } from "@procedures/peer";
|
|
174
|
+
|
|
175
|
+
const read = {
|
|
176
|
+
narrowing: { effects: { writes: [] } },
|
|
177
|
+
expose: ["programs.list", "programs.get", "procedure.get", "client.trace", "graphapi.*"],
|
|
178
|
+
};
|
|
179
|
+
const host = createProcedureHost({
|
|
180
|
+
registry,
|
|
181
|
+
faces: {
|
|
182
|
+
http: { basePath: "/rpc" },
|
|
183
|
+
ws: { path: "/rpc/ws" },
|
|
184
|
+
readHttp: httpFace({ basePath: "/rpc/read", ...read }),
|
|
185
|
+
readWs: wsFace({ path: "/rpc/read/ws", ...read }),
|
|
186
|
+
},
|
|
187
|
+
listen: [{ port: 3000, knobs: LOCAL_LISTENER_KNOBS }],
|
|
188
|
+
});
|
|
189
|
+
// The page opens a second WebSocketTransport to /rpc/read/ws for its read calls
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
- **`narrowing`** (`CapabilityRequest` or a list of them): a narrower capability for each call of the face, as `mcpFace({ narrowing })` (CLI-43). The face adds it as one more source of the narrowing key (CLI-30). The server applies the meet of all the sources, so a `Procedure-Narrowing` header of the page cannot make the face wider. The nested calls of a call get the narrowed capability. Thus `client.chain` and a program of `procedure.define` cannot write through the face. A narrowing that is not valid stops the host with an error.
|
|
193
|
+
- **`expose`** (a list of patterns, a tool surface or a function): the procedures that the callers of the face reach, as `hostPolicy({ expose })`. The server meets it with the expose rule of the host, for the call and for each nested call. A call outside it gets `NOT_FOUND`, and a nested call of a data-driven procedure outside it gets `NOT_EXPOSED`. The rule applies to each procedure, also to `host.health`, `host.info`, `host.metrics` and `events.subscribe`.
|
|
194
|
+
- A face without these options serves the same calls as before. The option objects of `faces.http` and `faces.ws` take them too.
|
|
195
|
+
|
|
168
196
|
### Creating a Server Peer
|
|
169
197
|
|
|
170
198
|
`createPeer()` is for a process that has no service of its own: a test, or a host that a procedure starts (`server.create`). The peer builds a host with `createProcedureHost()`, declares its parts in a service of its own, and starts `run()` of `@mark1russell7/service` on a process port that installs no signal handler and never ends the process. `stop()` asks that lifecycle for its shutdown. A process that has a service of its own uses `createProcedureHost()` and `host.declare(svc)` in place of a peer.
|