@owlmeans/server-socket 0.1.18-rc.2 → 0.1.18-rc.20
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/README.md +5 -5
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-socket/SKILL.md +127 -10
- package/build/service.d.ts.map +1 -1
- package/build/service.js +4 -6
- package/build/service.js.map +1 -1
- package/package.json +10 -10
- package/src/service.ts +5 -7
- package/build/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -12,12 +12,12 @@ Server-side WebSocket connection handler and service for OwlMeans backends.
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
bun add @owlmeans/server-socket
|
|
15
|
+
bun add @owlmeans/server-socket@^0.1.18-rc.17
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
|
-
Handle a WebSocket connection on
|
|
20
|
+
Handle a WebSocket connection on an entrypoint route:
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
23
|
import { handleConnection } from '@owlmeans/server-socket'
|
|
@@ -33,7 +33,7 @@ export const watch = handleConnection<Connection>(async (conn, context, req) =>
|
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
// Push updates to the client
|
|
36
|
-
const
|
|
36
|
+
const unsubscribeStore = await ctx.fileStore().subscribe(record => {
|
|
37
37
|
conn.notify('file-update', record)
|
|
38
38
|
})
|
|
39
39
|
})
|
|
@@ -41,7 +41,7 @@ export const watch = handleConnection<Connection>(async (conn, context, req) =>
|
|
|
41
41
|
|
|
42
42
|
## API
|
|
43
43
|
|
|
44
|
-
### `handleConnection<T>(handler):
|
|
44
|
+
### `handleConnection<T>(handler): RefedEntrypointHandler`
|
|
45
45
|
|
|
46
46
|
Wraps a WebSocket handler. The handler receives `(conn: T, ctx, req, res)`.
|
|
47
47
|
|
|
@@ -73,7 +73,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
73
73
|
your project's skill store (`.agents/skills/`):
|
|
74
74
|
|
|
75
75
|
```sh
|
|
76
|
-
npx @owlmeans/agent-skills
|
|
76
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.14
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/server-socket",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-
|
|
4
|
+
"version": "0.1.18-rc.20",
|
|
5
|
+
"generatedAt": "2026-09-10T23:12:07.514Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: server-socket
|
|
3
|
-
description: How to use @owlmeans/server-socket — Fastify WebSocket
|
|
3
|
+
description: How to use @owlmeans/server-socket — the Fastify WebSocket carrier that serves entrypoints whose route protocol is SOCKET, handleConnection, guard and gate enforcement on the upgrade, token-on-query authentication and the system close frame. Auto-invoked when importing server socket primitives or wiring WebSocket support.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
@@ -8,25 +8,142 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/server-socket
|
|
9
9
|
|
|
10
10
|
**Layer:** Server
|
|
11
|
-
**Install:** `"@owlmeans/server-socket": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/server-socket": "^0.1.18-rc.20"` in `dependencies`
|
|
12
|
+
|
|
13
|
+
The server carrier for `@owlmeans/socket`, mounted on the same Fastify instance
|
|
14
|
+
`@owlmeans/server-api` runs. It supplies the abstract members of the connection model and hands a
|
|
15
|
+
handler a plain `Connection`.
|
|
12
16
|
|
|
13
17
|
## Key Exports
|
|
14
18
|
|
|
15
19
|
| Export | Description |
|
|
16
20
|
|--------|-------------|
|
|
17
|
-
| `
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
+
| `createSocketService(alias?)` | Factory for the WebSocket server service |
|
|
22
|
+
| `appendSocketService(ctx, alias?)` | Register it on the context |
|
|
23
|
+
| `createSocketMiddleware(web?, socket?)` | Loading-stage context middleware that attaches the service to the API server. Marks the config so a re-run does not register twice |
|
|
24
|
+
| `handleConnection(fn)` | Wrap `(conn, ctx, req, res) => Promise<void>` as an entrypoint handler |
|
|
25
|
+
| `SocketService` | Service interface — `update(api: ApiServer)` |
|
|
26
|
+
| `Config` / `Context` | The server config and context types this package expects |
|
|
27
|
+
| Constants | `DEFAULT_ALIAS` (`socket-server`) |
|
|
28
|
+
|
|
29
|
+
## How a socket call is carried
|
|
30
|
+
|
|
31
|
+
An entrypoint declared with `socket(...)` carries `RouteProtocols.SOCKET`, and the protocol is what
|
|
32
|
+
decides the carrier. The HTTP server skips those entrypoints; this service claims them, registering
|
|
33
|
+
each at `entrypoint.mount()` on the same Fastify instance with `websocket: true`. So a declaration
|
|
34
|
+
moves between HTTP and a socket by changing its protocol, and neither the handler nor the caller is
|
|
35
|
+
rewritten.
|
|
36
|
+
|
|
37
|
+
The same enforcement runs first: a `preHandler` hook matches each candidate with
|
|
38
|
+
`entrypoint.route.match(req, entrypoint.mount())`, authorizes it against `getGuards()`, and asserts
|
|
39
|
+
every pair from `getGates()` — inherited guards and gates included — before the connection is handed
|
|
40
|
+
to the handler. A refusal is rendered by the entrypoint's `fixer` when it declares one, so an
|
|
41
|
+
unauthorized upgrade fails the HTTP request rather than opening a socket that answers nothing.
|
|
42
|
+
|
|
43
|
+
The route's `filter` becomes the Fastify schema for the upgrade request — `query`, `params`,
|
|
44
|
+
`headers` — so a malformed connection query is refused before the handler exists.
|
|
21
45
|
|
|
22
46
|
## Usage
|
|
23
47
|
|
|
48
|
+
Wire the carrier once, where the application composes its context:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { appendSocketService, createSocketMiddleware } from '@owlmeans/server-socket'
|
|
52
|
+
|
|
53
|
+
appendSocketService(context)
|
|
54
|
+
context.registerMiddleware(createSocketMiddleware())
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Declare the entrypoint with `socket()` — the `@owlmeans/route` builder that stamps
|
|
58
|
+
`RouteProtocols.SOCKET` on a backend route — in the package both halves import, so the browser
|
|
59
|
+
dials the very declaration the server binds:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { entrypoint } from '@owlmeans/entrypoint'
|
|
63
|
+
import { backend, route, socket } from '@owlmeans/route'
|
|
64
|
+
|
|
65
|
+
export const entrypoints = [
|
|
66
|
+
entrypoint(route(PROJECT, '/project', backend())),
|
|
67
|
+
entrypoint(route(PROJECT_STREAM, '/watch', socket(PROJECT))),
|
|
68
|
+
]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Then attach the handler with `elevate`, exactly as for an HTTP entrypoint — the protocol is what
|
|
72
|
+
sends it to this carrier instead of to the HTTP server. Nothing is served until this step runs:
|
|
73
|
+
|
|
24
74
|
```typescript
|
|
25
|
-
import {
|
|
26
|
-
|
|
75
|
+
import { elevate } from '@owlmeans/server-entrypoint'
|
|
76
|
+
import { handleConnection } from '@owlmeans/server-socket'
|
|
77
|
+
import { MessageType } from '@owlmeans/socket'
|
|
78
|
+
import type { EventMessage } from '@owlmeans/socket'
|
|
79
|
+
|
|
80
|
+
elevate(entrypoints, PROJECT_STREAM, handleConnection(async (conn, ctx, req) => {
|
|
81
|
+
const stop = await subscribeSomewhere(async value => await conn.notify('update', value))
|
|
82
|
+
|
|
83
|
+
conn.listen(async message => {
|
|
84
|
+
const msg = message as EventMessage<{ code: number }>
|
|
85
|
+
if (typeof message === 'object' && msg.type === MessageType.System && msg.event === 'close') {
|
|
86
|
+
await stop()
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}))
|
|
27
90
|
```
|
|
28
91
|
|
|
92
|
+
**A socket handler never resolves its response.** Resolving sends the value down the socket and,
|
|
93
|
+
with `EntrypointOutcome.Ok`, closes it immediately; rejecting closes it with code 1011 and the
|
|
94
|
+
marshalled error. `handleConnection` returns the response's value only for signature compatibility.
|
|
95
|
+
A long-lived subscription therefore returns without resolving, and lives on the listeners it
|
|
96
|
+
registered.
|
|
97
|
+
|
|
98
|
+
## Who the connection belongs to
|
|
99
|
+
|
|
100
|
+
A WebSocket handshake carries no Authorization header a browser can set, so the token travels as
|
|
101
|
+
the `AUTH_QUERY` query parameter. The carrier reads it lazily, on the first frame in either
|
|
102
|
+
direction, and unseals it as an envelope: an `Auth` or `AuthCredentials` payload becomes the
|
|
103
|
+
connection's subject, anything else leaves it anonymous.
|
|
104
|
+
|
|
105
|
+
That subject is what stamps frames, as `profileId ?? userId`: an arriving frame is given it as
|
|
106
|
+
`recipient` and the service's own name as `sender`, a departing one is given it as `sender`. It is
|
|
107
|
+
the same pair every ownership rule in the framework keys on, so one profile of a multi-profile
|
|
108
|
+
account never reads another's stream.
|
|
109
|
+
|
|
110
|
+
`conn.authenticate(stage, payload)` runs the in-band sequence instead:
|
|
111
|
+
|
|
112
|
+
| Stage and payload | Answer |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `Authenticate` with an `AuthToken` | Checked against the context's auth service. Its answer is unsealed as an envelope to become the subject, and the reply carries `Authenticated`. A null answer throws `SocketUnauthorized` |
|
|
115
|
+
| `Authenticate` with an already-minted `Auth` | Taken as the subject as it stands, and answered with the SAME stage — not `Authenticated` |
|
|
116
|
+
| `Authenticated` | Answers the subject already captured, or throws `SocketUnauthorized` when there is none |
|
|
117
|
+
| anything else | `SocketUnsupported('auth-service')` — including a payload at `Authenticate` that is neither of the two above |
|
|
118
|
+
|
|
119
|
+
## Liveness and shutdown
|
|
120
|
+
|
|
121
|
+
- A protocol-level ping (the WebSocket control frame) is answered with a pong and goes no further.
|
|
122
|
+
- A JSON `{ type: 'ping' }` frame is answered with a protocol pong and a `{ type: 'pong' }` frame,
|
|
123
|
+
and is then handed to the connection model like any other frame. Its `type` matches no
|
|
124
|
+
`MessageType`, so it is routed nowhere, but it still reaches every `conn.listen` listener as an
|
|
125
|
+
object whose `type` is `'ping'` — a listener has to recognise the frames it wants rather than
|
|
126
|
+
assume every one it is given is a message.
|
|
127
|
+
- A closing socket reaches the handler as a system frame — `MessageType.System`, `event: 'close'`,
|
|
128
|
+
payload `{ code }` — delivered to every `conn.listen` listener. It is the only disconnect notice,
|
|
129
|
+
so every subscription a handler opened is released there.
|
|
130
|
+
- Fastify's `preClose` closes every live connection with code 1001 before the server stops, so a
|
|
131
|
+
rollout does not leave sockets hanging on a process that is going away.
|
|
132
|
+
|
|
29
133
|
## Depends On
|
|
30
134
|
|
|
31
|
-
- `@owlmeans/socket`,
|
|
32
|
-
- `@
|
|
135
|
+
- `@owlmeans/socket` — `createBasicConnection`, `MessageType`, the error classes
|
|
136
|
+
- `@owlmeans/entrypoint`, `@owlmeans/server-entrypoint` — `getGuards` / `getGates`, `mount()`
|
|
137
|
+
- `@owlmeans/server-api` — the Fastify instance and its request pipeline (`/utils`)
|
|
138
|
+
- `@owlmeans/server-auth` — the auth service the in-band sequence calls
|
|
139
|
+
- `@owlmeans/auth` — `AUTH_QUERY`, `AuthenticationStage`, and the `isAuth` / `isAuthToken` guards
|
|
140
|
+
- `@owlmeans/basic-envelope` — reading the token off the connection query
|
|
141
|
+
- `@owlmeans/context`, `@owlmeans/server-context` — service registration and the config type
|
|
142
|
+
- `@fastify/websocket` (runtime), `fastify` (peer)
|
|
143
|
+
|
|
144
|
+
## Related
|
|
145
|
+
|
|
146
|
+
- `socket` — the message model, and the verbs a handler answers with
|
|
147
|
+
- `route` — `socket()`, and what a route's protocol decides
|
|
148
|
+
- `client-socket` — the browser carrier that dials these entrypoints
|
|
149
|
+
- `server-job` — `watchJobs`, a worked handler built on `handleConnection`
|
package/build/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAW,MAAM,sBAAsB,CAAA;AAWpE,eAAO,MAAM,mBAAmB,WAAW,MAAM,KAAmB,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAW,MAAM,sBAAsB,CAAA;AAWpE,eAAO,MAAM,mBAAmB,WAAW,MAAM,KAAmB,aA0GnE,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,OACnE,CAAC,UAAS,MAAM,KACpB,CAOF,CAAA"}
|
package/build/service.js
CHANGED
|
@@ -20,8 +20,7 @@ export const createSocketService = (alias = DEFAULT_ALIAS) => {
|
|
|
20
20
|
.filter(module => canServerModule(context, module) && !module.route.isIntermediate())
|
|
21
21
|
.reduce(async (ctx, module) => {
|
|
22
22
|
let context = await ctx;
|
|
23
|
-
|
|
24
|
-
if (!module.route.match(req)) {
|
|
23
|
+
if (!module.route.match(req, module.mount())) {
|
|
25
24
|
return context;
|
|
26
25
|
}
|
|
27
26
|
if (reply.sent) {
|
|
@@ -55,12 +54,11 @@ export const createSocketService = (alias = DEFAULT_ALIAS) => {
|
|
|
55
54
|
return context;
|
|
56
55
|
}, Promise.resolve(context));
|
|
57
56
|
});
|
|
58
|
-
|
|
59
|
-
await module.resolve();
|
|
57
|
+
ctx.entrypoints().filter(module => canServerModule(ctx, module) && !module.route.isIntermediate()).forEach(module => {
|
|
60
58
|
if (module.handle == null) {
|
|
61
59
|
return;
|
|
62
60
|
}
|
|
63
|
-
server.get(module.
|
|
61
|
+
server.get(module.mount(), {
|
|
64
62
|
schema: {
|
|
65
63
|
querystring: module.filter?.query ?? {},
|
|
66
64
|
params: module.filter?.params ?? {},
|
|
@@ -92,7 +90,7 @@ export const createSocketService = (alias = DEFAULT_ALIAS) => {
|
|
|
92
90
|
}
|
|
93
91
|
});
|
|
94
92
|
});
|
|
95
|
-
})
|
|
93
|
+
});
|
|
96
94
|
});
|
|
97
95
|
}
|
|
98
96
|
}, service => async () => {
|
package/build/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGhE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACrI,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAK,GAAW,aAAa,EAAiB,EAAE;IAClF,MAAM,OAAO,GAAkB,aAAa,CAAgB,KAAK,EAAE;QACjE,MAAM,EAAE,KAAK,EAAC,GAAG,EAAC,EAAE;YAClB,MAAM,cAAc,GAAuB,EAAE,CAAA;YAC7C,MAAM,GAAG,GAAG,aAAa,CAAkB,OAAO,CAAC,GAAc,EAAE,KAAK,CAAC,CAAA;YACzE,MAAM,GAAG,CAAC,MAAM,CAAC,QAAQ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,OAAO,GAAG,GAAQ,CAAA;IAExB,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAEhC,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/server-socket",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@fastify/websocket": "^11.0.1",
|
|
34
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
35
|
-
"@owlmeans/basic-envelope": "^0.1.18-rc.
|
|
36
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
37
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
38
|
-
"@owlmeans/server-api": "^0.1.18-rc.
|
|
39
|
-
"@owlmeans/server-auth": "^0.1.18-rc.
|
|
40
|
-
"@owlmeans/server-context": "^0.1.18-rc.
|
|
41
|
-
"@owlmeans/server-entrypoint": "^0.1.18-rc.
|
|
42
|
-
"@owlmeans/socket": "^0.1.18-rc.
|
|
34
|
+
"@owlmeans/auth": "^0.1.18-rc.11",
|
|
35
|
+
"@owlmeans/basic-envelope": "^0.1.18-rc.14",
|
|
36
|
+
"@owlmeans/context": "^0.1.18-rc.10",
|
|
37
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.13",
|
|
38
|
+
"@owlmeans/server-api": "^0.1.18-rc.19",
|
|
39
|
+
"@owlmeans/server-auth": "^0.1.18-rc.20",
|
|
40
|
+
"@owlmeans/server-context": "^0.1.18-rc.14",
|
|
41
|
+
"@owlmeans/server-entrypoint": "^0.1.18-rc.13",
|
|
42
|
+
"@owlmeans/socket": "^0.1.18-rc.11"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
package/src/service.ts
CHANGED
|
@@ -27,9 +27,8 @@ export const createSocketService = (alias: string = DEFAULT_ALIAS): SocketServic
|
|
|
27
27
|
.filter(module => canServerModule(context, module) && !module.route.isIntermediate())
|
|
28
28
|
.reduce<Promise<Context>>(async (ctx, module) => {
|
|
29
29
|
let context = await ctx
|
|
30
|
-
await module.resolve()
|
|
31
30
|
|
|
32
|
-
if (!module.route.match(req)) {
|
|
31
|
+
if (!module.route.match(req, module.mount())) {
|
|
33
32
|
return context
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -68,15 +67,14 @@ export const createSocketService = (alias: string = DEFAULT_ALIAS): SocketServic
|
|
|
68
67
|
}, Promise.resolve(context))
|
|
69
68
|
})
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
ctx.entrypoints<ServerEntrypoint<Request>>().filter(
|
|
72
71
|
module => canServerModule(ctx, module) && !module.route.isIntermediate()
|
|
73
|
-
).
|
|
74
|
-
await module.resolve()
|
|
72
|
+
).forEach(module => {
|
|
75
73
|
if (module.handle == null) {
|
|
76
74
|
return
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
server.get(module.
|
|
77
|
+
server.get(module.mount(), {
|
|
80
78
|
schema: {
|
|
81
79
|
querystring: module.filter?.query ?? {},
|
|
82
80
|
params: module.filter?.params ?? {},
|
|
@@ -111,7 +109,7 @@ export const createSocketService = (alias: string = DEFAULT_ALIAS): SocketServic
|
|
|
111
109
|
}
|
|
112
110
|
})
|
|
113
111
|
})
|
|
114
|
-
})
|
|
112
|
+
})
|
|
115
113
|
})
|
|
116
114
|
}
|
|
117
115
|
}, service => async () => {
|
package/build/.gitkeep
DELETED
|
File without changes
|