mqtt-plus 1.4.15 → 1.4.17
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/.claude/CLAUDE.md +1 -0
- package/.gemini/settings.json +5 -0
- package/AGENTS.md +86 -95
- package/CHANGELOG.md +49 -0
- package/README.md +1 -1
- package/doc/mqtt-plus-api.md +36 -18
- package/doc/mqtt-plus-architecture.md +1 -1
- package/doc/mqtt-plus-broker-setup.md +2 -2
- package/doc/mqtt-plus-comm.md +5 -3
- package/doc/mqtt-plus-internals.md +11 -1
- package/dst-stage1/mqtt-plus-auth.js +2 -13
- package/dst-stage1/mqtt-plus-auth.js.map +1 -1
- package/dst-stage1/mqtt-plus-base.d.ts +2 -1
- package/dst-stage1/mqtt-plus-base.js +14 -3
- package/dst-stage1/mqtt-plus-base.js.map +1 -1
- package/dst-stage1/mqtt-plus-error.d.ts +1 -0
- package/dst-stage1/mqtt-plus-error.js +62 -38
- package/dst-stage1/mqtt-plus-error.js.map +1 -1
- package/dst-stage1/mqtt-plus-event.d.ts +2 -0
- package/dst-stage1/mqtt-plus-event.js +60 -12
- package/dst-stage1/mqtt-plus-event.js.map +1 -1
- package/dst-stage1/mqtt-plus-info.d.ts +5 -1
- package/dst-stage1/mqtt-plus-msg.d.ts +5 -3
- package/dst-stage1/mqtt-plus-msg.js +10 -8
- package/dst-stage1/mqtt-plus-msg.js.map +1 -1
- package/dst-stage1/mqtt-plus-service.d.ts +2 -0
- package/dst-stage1/mqtt-plus-service.js +128 -21
- package/dst-stage1/mqtt-plus-service.js.map +1 -1
- package/dst-stage1/mqtt-plus-sink.d.ts +5 -0
- package/dst-stage1/mqtt-plus-sink.js +369 -89
- package/dst-stage1/mqtt-plus-sink.js.map +1 -1
- package/dst-stage1/mqtt-plus-source.d.ts +2 -0
- package/dst-stage1/mqtt-plus-source.js +217 -78
- package/dst-stage1/mqtt-plus-source.js.map +1 -1
- package/dst-stage1/mqtt-plus-subscription.js +14 -8
- package/dst-stage1/mqtt-plus-subscription.js.map +1 -1
- package/dst-stage1/mqtt-plus-timer.d.ts +2 -0
- package/dst-stage1/mqtt-plus-timer.js +48 -0
- package/dst-stage1/mqtt-plus-timer.js.map +1 -1
- package/dst-stage1/mqtt-plus-trace.js +3 -1
- package/dst-stage1/mqtt-plus-trace.js.map +1 -1
- package/dst-stage1/mqtt-plus-util.d.ts +17 -2
- package/dst-stage1/mqtt-plus-util.js +56 -14
- package/dst-stage1/mqtt-plus-util.js.map +1 -1
- package/dst-stage1/mqtt-plus-version.d.ts +2 -0
- package/dst-stage1/mqtt-plus-version.js +3 -0
- package/dst-stage1/mqtt-plus-version.js.map +1 -1
- package/dst-stage1/tsc.tsbuildinfo +1 -1
- package/dst-stage2/{mqtt-plus.cjs.js → mqtt-plus.cjs.cjs} +806 -254
- package/dst-stage2/mqtt-plus.esm.js +806 -254
- package/dst-stage2/mqtt-plus.umd.js +11 -11
- package/etc/d2.mts +19 -13
- package/etc/knip.jsonc +2 -1
- package/etc/stx.conf +24 -17
- package/etc/tsc.json +0 -1
- package/etc/vite.mts +3 -2
- package/package.d/@typescript-eslint+typescript-estree+8.57.2.patch +12 -0
- package/package.d/{vite+8.0.0.patch → vite+8.0.3.patch} +2 -2
- package/package.json +25 -19
- package/src/mqtt-plus-auth.ts +3 -15
- package/src/mqtt-plus-base.ts +22 -8
- package/src/mqtt-plus-error.ts +68 -40
- package/src/mqtt-plus-event.ts +66 -13
- package/src/mqtt-plus-info.ts +9 -3
- package/src/mqtt-plus-msg.ts +24 -18
- package/src/mqtt-plus-service.ts +135 -21
- package/src/mqtt-plus-sink.ts +399 -99
- package/src/mqtt-plus-source.ts +232 -83
- package/src/mqtt-plus-subscription.ts +17 -9
- package/src/mqtt-plus-timer.ts +54 -2
- package/src/mqtt-plus-trace.ts +3 -1
- package/src/mqtt-plus-util.ts +62 -14
- package/src/mqtt-plus-version.ts +5 -1
- package/tst/.c8/index.html +59 -59
- package/tst/.c8/mqtt-plus-auth.ts.html +2 -2
- package/tst/.c8/mqtt-plus-base.ts.html +100 -97
- package/tst/.c8/mqtt-plus-codec.ts.html +1 -1
- package/tst/.c8/mqtt-plus-encode.ts.html +1 -1
- package/tst/.c8/mqtt-plus-error.ts.html +67 -67
- package/tst/.c8/mqtt-plus-event.ts.html +34 -10
- package/tst/.c8/mqtt-plus-meta.ts.html +1 -1
- package/tst/.c8/mqtt-plus-msg.ts.html +25 -16
- package/tst/.c8/mqtt-plus-options.ts.html +10 -10
- package/tst/.c8/mqtt-plus-service.ts.html +34 -10
- package/tst/.c8/mqtt-plus-sink.ts.html +830 -140
- package/tst/.c8/mqtt-plus-source.ts.html +452 -89
- package/tst/.c8/mqtt-plus-subscription.ts.html +6 -6
- package/tst/.c8/mqtt-plus-timer.ts.html +12 -12
- package/tst/.c8/mqtt-plus-trace.ts.html +8 -8
- package/tst/.c8/mqtt-plus-util.ts.html +245 -128
- package/tst/.c8/mqtt-plus-version.ts.html +10 -10
- package/tst/.c8/mqtt-plus.ts.html +1 -1
- package/tst/.c8/tmp/coverage-55051-1774563847819-2.json +1 -0
- package/tst/.c8/tmp/coverage-55051-1774563847829-1.json +1 -0
- package/tst/.c8/tmp/coverage-55051-1774563847850-0.json +1 -0
- package/tst/.c8/tmp/{coverage-6578-1773528089194-0.json → coverage-55052-1774563837907-0.json} +1 -1
- package/tst/mqtt-plus-0-broker-mosquitto.ts +2 -2
- package/tst/mqtt-plus-5-source.spec.ts +3 -3
- package/tst/mqtt-plus-7-spool.spec.ts +65 -0
- package/tst/tsc.cov.json +1 -3
- package/tst/tsc.std.json +1 -3
- package/tst/.c8/tmp/coverage-6577-1773528098323-2.json +0 -1
- package/tst/.c8/tmp/coverage-6577-1773528098331-1.json +0 -1
- package/tst/.c8/tmp/coverage-6577-1773528098353-0.json +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@../AGENTS.md
|
package/AGENTS.md
CHANGED
|
@@ -1,47 +1,41 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
======
|
|
2
|
+
# Overview for AI Agents
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
## Project Abstract
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
MQTT+ (`mqtt-plus`) is a TypeScript library implementing four MQTT
|
|
7
|
+
communication patterns with full type safety: Event Emission, Service
|
|
8
|
+
Call (RPC), Source Fetch, and Sink Push. It uses `mqtt` as a peer
|
|
9
|
+
dependency and builds to ESM, CJS, and UMD formats.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
with full type safety: Event Emission, Service Call (RPC), Source Fetch, and Sink Push.
|
|
12
|
-
It uses `mqtt` as a peer dependency and builds to ESM, CJS, and UMD formats.
|
|
11
|
+
## Technology Stack
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
Build-Tools: npm, @rse/stx, vite, eslint, typescript
|
|
14
|
+
Language: TypeScript
|
|
15
|
+
Libraries: nanoid, cbor2, p-lazy, valibot, jose, @stablelib/pbkdf2, @stablelib/sha256
|
|
16
|
+
Runtime: Browser, Node.js
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
## Build Commands
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
npm install # install dependencies
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Build and development commands use STX (`@rse/stx`) as the task runner:
|
|
20
|
+
Build and development commands use NPM and STX (`@rse/stx`) as the task runner:
|
|
24
21
|
|
|
25
22
|
```bash
|
|
26
|
-
npm
|
|
27
|
-
npm start build # standard: build everything
|
|
28
|
-
npm start test # standard: run unit test suite
|
|
23
|
+
npm install # install dependencies
|
|
29
24
|
|
|
30
|
-
npm start
|
|
31
|
-
npm start
|
|
32
|
-
npm start
|
|
25
|
+
npm start lint # standard: perform static code analysis
|
|
26
|
+
npm start build # standard: build everything
|
|
27
|
+
npm start test # standard: run unit test suite
|
|
33
28
|
|
|
34
|
-
npm start
|
|
35
|
-
npm start
|
|
36
|
-
npm start
|
|
37
|
-
```
|
|
29
|
+
npm start build-doc # generate SVG diagrams from D2 sources only
|
|
30
|
+
npm start dev # development watch mode (rebuild on change)
|
|
31
|
+
npm start sample # run sample/sample.ts via `tsx`
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
npm start clean # remove dst-stage1/ and dst-stage2/
|
|
34
|
+
npm start distclean # remove node_modules/ and package-lock.json
|
|
35
|
+
npm start publish # publish to npm (restricted to maintainer host)
|
|
36
|
+
```
|
|
42
37
|
|
|
43
|
-
Build Pipeline
|
|
44
|
-
--------------
|
|
38
|
+
## Build Pipeline
|
|
45
39
|
|
|
46
40
|
Two-stage build:
|
|
47
41
|
|
|
@@ -52,16 +46,22 @@ Two-stage build:
|
|
|
52
46
|
`mqtt-plus.esm.js`, `mqtt-plus.cjs.js`, `mqtt-plus.umd.js`.
|
|
53
47
|
UMD build includes Node polyfills (events, stream, buffer).
|
|
54
48
|
|
|
55
|
-
Configuration lives in `etc/`: `tsc.json`, `vite.mts`, `eslint.mts`,
|
|
49
|
+
Configuration lives in `etc/`: `tsc.json`, `vite.mts`, `eslint.mts`,
|
|
50
|
+
`knip.jsonc`, `stx.conf`, `d2.mts`, `d2.theme.d2`, `logo.ai`,
|
|
51
|
+
`logo.svg`.
|
|
52
|
+
|
|
53
|
+
Tests require an MQTT broker under run-time; the test suite starts/stops
|
|
54
|
+
one automatically. If Docker is available, a Mosquitto broker is used;
|
|
55
|
+
otherwise, the Aedes in-process broker serves as the fallback.
|
|
56
|
+
For regression testing always use the all-in-one command `npm start build test`.
|
|
56
57
|
|
|
57
|
-
Architecture
|
|
58
|
-
------------
|
|
58
|
+
## Architecture
|
|
59
59
|
|
|
60
60
|
### Trait-Based Mixin Tower
|
|
61
61
|
|
|
62
62
|
The library is composed as a vertical chain of trait classes (mixins),
|
|
63
|
-
each extending the previous. The final exported class `MQTTp` sits
|
|
64
|
-
the bottom of this chain:
|
|
63
|
+
each extending the previous one. The final exported class `MQTTp` sits
|
|
64
|
+
at the bottom of this chain:
|
|
65
65
|
|
|
66
66
|
```
|
|
67
67
|
OptionsTrait — configuration (id, codec, timeout, share, chunkSize, chunkCredit, topicMake/topicMatch)
|
|
@@ -85,63 +85,55 @@ Each trait lives in its own file: `src/mqtt-plus-<trait>.ts`.
|
|
|
85
85
|
|
|
86
86
|
### Key Source Files
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
- `
|
|
117
|
-
- `
|
|
118
|
-
- `
|
|
119
|
-
- `
|
|
120
|
-
- `
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
- `
|
|
124
|
-
- `
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
| `tst/mqtt-plus-0-broker-mosquitto.ts` | Helper for starting/stopping the Mosquitto MQTT broker |
|
|
138
|
-
| `tst/mqtt-plus-1-api.spec.ts` | API type and endpoint definition tests |
|
|
139
|
-
| `tst/mqtt-plus-2-event.spec.ts` | Event Emission pattern tests |
|
|
140
|
-
| `tst/mqtt-plus-3-service.spec.ts` | Service Call / RPC pattern tests |
|
|
141
|
-
| `tst/mqtt-plus-4-sink.spec.ts` | Sink Push pattern tests |
|
|
142
|
-
| `tst/mqtt-plus-5-source.spec.ts` | Source Fetch pattern tests |
|
|
143
|
-
| `tst/mqtt-plus-6-misc.spec.ts` | Miscellaneous / edge-case tests |
|
|
144
|
-
| `tst/tsc.json` | TypeScript configuration for the test directory |
|
|
88
|
+
- `src/mqtt-plus.ts`: Main entry point, re-exports public API types and the final MQTTp class
|
|
89
|
+
- `src/mqtt-plus-api.ts`: Branded endpoint type definitions (Event, Service, Source, Sink) and APISchema generic
|
|
90
|
+
- `src/mqtt-plus-info.ts`: Info/context object types passed to pattern callbacks (sender metadata, etc.)
|
|
91
|
+
- `src/mqtt-plus-error.ts`: Spool (resource cleanup) and run (error handling) utilities
|
|
92
|
+
- `src/mqtt-plus-util.ts`: PLazy, CreditGate flow control, and stream/buffer collection utilities
|
|
93
|
+
- `src/mqtt-plus-version.ts`: Version utility for converting version strings to numeric format
|
|
94
|
+
- `src/mqtt-plus-options.ts`: OptionsTrait — configuration (id, codec, timeout, share, chunkSize, chunkCredit, topicMake/topicMatch)
|
|
95
|
+
- `src/mqtt-plus-codec.ts`: CodecTrait — CBOR and JSON codec encoding/decoding
|
|
96
|
+
- `src/mqtt-plus-encode.ts`: EncodeTrait — string/buffer conversion utilities (str2buf, buf2str)
|
|
97
|
+
- `src/mqtt-plus-msg.ts`: MsgTrait — message class definitions, valibot schemas, and parsing logic
|
|
98
|
+
- `src/mqtt-plus-trace.ts`: TraceTrait — EventEmitter and structured logging
|
|
99
|
+
- `src/mqtt-plus-base.ts`: BaseTrait — MQTT client connection, subscription management, message routing
|
|
100
|
+
- `src/mqtt-plus-subscription.ts`: SubscriptionTrait — RefCountedSubscription class and ref-counted MQTT topic subscription management
|
|
101
|
+
- `src/mqtt-plus-timer.ts`: TimerTrait — named timer management (refresh/clear)
|
|
102
|
+
- `src/mqtt-plus-meta.ts`: MetaTrait — instance and per-request metadata management
|
|
103
|
+
- `src/mqtt-plus-auth.ts`: AuthTrait — JWT authentication (jose) and role-based access control
|
|
104
|
+
- `src/mqtt-plus-event.ts`: EventTrait — Event Emission communication pattern (event/emit)
|
|
105
|
+
- `src/mqtt-plus-service.ts`: ServiceTrait — Service Call / RPC communication pattern (service/call)
|
|
106
|
+
- `src/mqtt-plus-source.ts`: SourceTrait — Source Fetch communication pattern (source/fetch)
|
|
107
|
+
- `src/mqtt-plus-sink.ts`: SinkTrait — Sink Push communication pattern (sink/push)
|
|
108
|
+
|
|
109
|
+
### Key Test Files
|
|
110
|
+
|
|
111
|
+
- `tst/mqtt-plus-0-fixture.ts`: Shared test fixture setup (broker, MQTTp instances, etc.)
|
|
112
|
+
- `tst/mqtt-plus-0-broker.ts`: Broker dispatch: creates Aedes or Mosquitto broker based on env
|
|
113
|
+
- `tst/mqtt-plus-0-broker-aedes.ts`: Helper for starting/stopping the Aedes MQTT broker
|
|
114
|
+
- `tst/mqtt-plus-0-broker-mosquitto.ts`: Helper for starting/stopping the Mosquitto MQTT broker
|
|
115
|
+
- `tst/mqtt-plus-1-api.spec.ts`: API type and endpoint definition tests
|
|
116
|
+
- `tst/mqtt-plus-2-event.spec.ts`: Event Emission pattern tests
|
|
117
|
+
- `tst/mqtt-plus-3-service.spec.ts`: Service Call / RPC pattern tests
|
|
118
|
+
- `tst/mqtt-plus-4-sink.spec.ts`: Sink Push pattern tests
|
|
119
|
+
- `tst/mqtt-plus-5-source.spec.ts`: Source Fetch pattern tests
|
|
120
|
+
- `tst/mqtt-plus-6-misc.spec.ts`: Miscellaneous / edge-case tests
|
|
121
|
+
- `tst/mqtt-plus-7-spool.spec.ts`: Spool (resource cleanup) utility tests
|
|
122
|
+
- `tst/mqtt-plus-8-run.spec.ts`: Run (error handling) utility tests
|
|
123
|
+
- `tst/tsc.std.json`: TypeScript configuration for the test directory (standard)
|
|
124
|
+
- `tst/tsc.cov.json`: TypeScript configuration for the test directory (coverage)
|
|
125
|
+
|
|
126
|
+
### Key Documentation Files
|
|
127
|
+
|
|
128
|
+
- `doc/mqtt-plus-api.md`: public API reference
|
|
129
|
+
- `doc/mqtt-plus-architecture.{d2,svg,md}`: architecture overview (diagram + docs)
|
|
130
|
+
- `doc/mqtt-plus-broker-setup.md`: MQTT broker setup guide
|
|
131
|
+
- `doc/mqtt-plus-comm.md`: communication patterns overview
|
|
132
|
+
- `doc/mqtt-plus-comm-event-emission.{d2,svg}`: Event Emission pattern diagram
|
|
133
|
+
- `doc/mqtt-plus-comm-service-call.{d2,svg}`: Service Call pattern diagram
|
|
134
|
+
- `doc/mqtt-plus-comm-sink-push.{d2,svg}`: Sink Push pattern diagram
|
|
135
|
+
- `doc/mqtt-plus-comm-source-fetch.{d2,svg}`: Source Fetch pattern diagram
|
|
136
|
+
- `doc/mqtt-plus-internals.md`: internal implementation details
|
|
145
137
|
|
|
146
138
|
### Type System
|
|
147
139
|
|
|
@@ -150,8 +142,7 @@ The API uses branded types (`Event<...>`, `Service<...>`, `Source<...>`,
|
|
|
150
142
|
type parameter threads through the trait tower, enabling full type
|
|
151
143
|
inference for pattern names and parameter types.
|
|
152
144
|
|
|
153
|
-
Coding Style
|
|
154
|
-
------------
|
|
145
|
+
## Coding Style
|
|
155
146
|
|
|
156
147
|
- 4-space indentation, double quotes, no semicolons
|
|
157
148
|
- Stroustrup brace style (`else`/`catch`/`finally` on new line after closing brace)
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,55 @@
|
|
|
2
2
|
ChangeLog
|
|
3
3
|
=========
|
|
4
4
|
|
|
5
|
+
1.4.17 (2026-04-11)
|
|
6
|
+
-------------------
|
|
7
|
+
|
|
8
|
+
- IMPROVEMENT: add "signal" field to info of service and event callbacks for signalling abortion
|
|
9
|
+
- IMPROVEMENT: add more utility functions related to timers
|
|
10
|
+
- IMPROVEMENT: support cancelling push operations with a credit of zero
|
|
11
|
+
- IMPROVEMENT: let Spool.unroll() always execute the cleanup callback
|
|
12
|
+
- IMPROVEMENT: perform a minimum version check in the protocol
|
|
13
|
+
- IMPROVEMENT: log invalid requests with missing senders
|
|
14
|
+
- IMPROVEMENT: add upper bound for the nanoid iteration
|
|
15
|
+
- IMPROVEMENT: perform topic receiver matching and validate service response names
|
|
16
|
+
- IMPROVEMENT: move the destroyed flag to the base class and protect other methods
|
|
17
|
+
- IMPROVEMENT: send errors to peer and provide AggregateError to not lose errors
|
|
18
|
+
- IMPROVEMENT: bump minimum Node version to 20 for ES2022
|
|
19
|
+
- BUGFIX: Spool.unroll() silently skipped remaining cleanups on first async failure
|
|
20
|
+
- BUGFIX: improve semantics of info.authenticated field for event/service/sink/source in case of optional authentication
|
|
21
|
+
- BUGFIX: in the ReadableTee class, do not run read() twice: once ourself and once via the base class
|
|
22
|
+
- BUGFIX: correctly propagate description in run() also to finally callback
|
|
23
|
+
- BUGFIX: fix resource handling in source trait
|
|
24
|
+
- BUGFIX: avoid race conditions and unhandled promise rejections in async processing
|
|
25
|
+
- BUGFIX: fix cleanup and error handling across sink/source traits
|
|
26
|
+
- BUGFIX: fix Mosqitto ACL
|
|
27
|
+
- UPDATE: upgrade NPM dependencies
|
|
28
|
+
- CLEANUP: various code cleanups (callback handling, settle code, destroy handling, termination, subscriptions)
|
|
29
|
+
- CLEANUP: align with ensureError code and fix typos
|
|
30
|
+
|
|
31
|
+
1.4.16 (2026-03-27)
|
|
32
|
+
-------------------
|
|
33
|
+
|
|
34
|
+
- IMPROVEMENT: allow source/sink operations to be aborted via a signal
|
|
35
|
+
- IMPROVEMENT: support `info.buffer` to be a plain `Uint8Array` for sources
|
|
36
|
+
- IMPROVEMENT: provide callback indicating which field is consumed
|
|
37
|
+
- IMPROVEMENT: improve credit-based flow control enforcement
|
|
38
|
+
- IMPROVEMENT: validate and deduplicate request IDs
|
|
39
|
+
- IMPROVEMENT: lock responder for communication
|
|
40
|
+
- IMPROVEMENT: improve backpressure and stream handling
|
|
41
|
+
- IMPROVEMENT: improve meta handling
|
|
42
|
+
- IMPROVEMENT: improve typing
|
|
43
|
+
- IMPROVEMENT: use cross-env for better script portability
|
|
44
|
+
- IMPROVEMENT: switch "npm start test" procedure to individual tasks for portability
|
|
45
|
+
- BUGFIX: in sink and source traits: do not miss stream data in case the stream is consumed as a buffer
|
|
46
|
+
- BUGFIX: fix error handling and prevent unhandled exceptions in sink and source traits
|
|
47
|
+
- BUGFIX: fix message name mismatch and cancellation handling
|
|
48
|
+
- BUGFIX: guard for already destroyed streams
|
|
49
|
+
- BUGFIX: use .cjs for file extension of CJS variant
|
|
50
|
+
- CLEANUP: align and track spool handling in source trait
|
|
51
|
+
- CLEANUP: align and guard timer handling
|
|
52
|
+
- CLEANUP: merge handlers into one
|
|
53
|
+
|
|
5
54
|
1.4.15 (2026-03-14)
|
|
6
55
|
-------------------
|
|
7
56
|
|
package/README.md
CHANGED
|
@@ -165,7 +165,7 @@ Main documentation:
|
|
|
165
165
|
- [**Communication Patterns**](doc/mqtt-plus-comm.md)
|
|
166
166
|
- [**Application Programming Interface (API)**](doc/mqtt-plus-api.md)
|
|
167
167
|
|
|
168
|
-
Additional
|
|
168
|
+
Additional auxiliary documentation:
|
|
169
169
|
|
|
170
170
|
- [Extra: Architecture Overview](doc/mqtt-plus-architecture.md)
|
|
171
171
|
- [Extra: Internal Protocol](doc/mqtt-plus-internals.md)
|
package/doc/mqtt-plus-api.md
CHANGED
|
@@ -250,9 +250,10 @@ Register for an event.
|
|
|
250
250
|
- The optional `auth` enables authentication validation on incoming events.
|
|
251
251
|
When set to a role name string (e.g., `"admin"`), authentication is required
|
|
252
252
|
and the token must include that role. When set to an object `{ mode, roles }`,
|
|
253
|
-
the mode can be `"require"` (reject unauthenticated
|
|
254
|
-
|
|
255
|
-
the
|
|
253
|
+
the mode can be `"require"` (reject unauthenticated, so `info.authenticated`
|
|
254
|
+
is always `true` in the callback) or `"optional"` (accept all, but set
|
|
255
|
+
`info.authenticated` to `true` or `false` to reflect the validation result),
|
|
256
|
+
and roles specifies the required role names.
|
|
256
257
|
|
|
257
258
|
- Internally, on the MQTT broker, the topics generated by
|
|
258
259
|
`topicMake(name, "event-emission")` (default: `${name}/event-emission/any` and
|
|
@@ -380,9 +381,10 @@ Register a service.
|
|
|
380
381
|
- The optional `auth` enables authentication validation on incoming service calls.
|
|
381
382
|
When set to a role name string (e.g., `"admin"`), authentication is required
|
|
382
383
|
and the token must include that role. When set to an object `{ mode, roles }`,
|
|
383
|
-
the mode can be `"require"` (reject unauthenticated with error response
|
|
384
|
-
`
|
|
385
|
-
|
|
384
|
+
the mode can be `"require"` (reject unauthenticated with error response, so
|
|
385
|
+
`info.authenticated` is always `true` in the callback) or `"optional"` (accept
|
|
386
|
+
all, but set `info.authenticated` to `true` or `false` to reflect the validation
|
|
387
|
+
result), and roles specifies the required role names.
|
|
386
388
|
|
|
387
389
|
- Internally, on the MQTT broker, the topics generated by
|
|
388
390
|
`topicMake(name, "service-call-request")` (default: `${name}/service-call-request/any` and
|
|
@@ -437,6 +439,7 @@ Sink Registration
|
|
|
437
439
|
receiver?: string,
|
|
438
440
|
authenticated?: boolean,
|
|
439
441
|
meta?: Record<string, any>,
|
|
442
|
+
signal: AbortSignal,
|
|
440
443
|
stream: Readable,
|
|
441
444
|
buffer: Promise<Uint8Array>
|
|
442
445
|
}
|
|
@@ -451,6 +454,7 @@ Sink Registration
|
|
|
451
454
|
receiver?: string,
|
|
452
455
|
authenticated?: boolean,
|
|
453
456
|
meta?: Record<string, any>,
|
|
457
|
+
signal: AbortSignal,
|
|
454
458
|
stream: Readable,
|
|
455
459
|
buffer: Promise<Uint8Array>
|
|
456
460
|
}
|
|
@@ -467,6 +471,11 @@ Register a sink for receiving data.
|
|
|
467
471
|
- The `callback` is called with the `params` passed to a remote `push()`.
|
|
468
472
|
The `info.stream` provides a Node.js `Readable` stream for consuming the pushed data.
|
|
469
473
|
The `info.buffer` provides a lazy `Promise<Uint8Array>` that resolves to the complete data once the stream ends.
|
|
474
|
+
The `info.signal` is aborted when the push request is cancelled, times out, or is otherwise torn down,
|
|
475
|
+
allowing the sink handler to stop any related side work cooperatively.
|
|
476
|
+
When the sink handler's stream closes abnormally (before normal completion),
|
|
477
|
+
a cancel signal (`credit=0`) is automatically sent to the pusher to abort
|
|
478
|
+
the data transfer on the sender side.
|
|
470
479
|
The `info.meta` contains optional metadata sent by the pusher via `push()`.
|
|
471
480
|
|
|
472
481
|
- The optional `options` allows setting MQTT.js `subscribe()` options like `qos`.
|
|
@@ -482,9 +491,10 @@ Register a sink for receiving data.
|
|
|
482
491
|
When set to a role name string (e.g., `"admin"`), authentication
|
|
483
492
|
is required and the token must include that role. When set to an
|
|
484
493
|
object `{ mode, roles }`, the mode can be `"require"` (reject
|
|
485
|
-
unauthenticated
|
|
486
|
-
|
|
487
|
-
|
|
494
|
+
unauthenticated, so `info.authenticated` is always `true` in the
|
|
495
|
+
callback) or `"optional"` (accept all, but set `info.authenticated`
|
|
496
|
+
to `true` or `false` to reflect the validation result), and roles
|
|
497
|
+
specifies the required role names.
|
|
488
498
|
|
|
489
499
|
- Internally, on the MQTT broker, the topics generated by
|
|
490
500
|
`topicMake(name, "sink-push-request")`
|
|
@@ -528,9 +538,12 @@ Pushes data to all established sinks or a specific sink handler.
|
|
|
528
538
|
configurable via `chunkSize` option) and sent over MQTT until the
|
|
529
539
|
stream is closed or the buffer is fully transferred.
|
|
530
540
|
The returned `Promise` resolves when the entire data has been pushed.
|
|
541
|
+
If the receiver cancels the push (via a cancel signal with `credit=0`),
|
|
542
|
+
the returned `Promise` rejects with a cancellation error.
|
|
531
543
|
|
|
532
544
|
- The remote `sink()` `callback` is called with `params` and an `info` object
|
|
533
|
-
containing `
|
|
545
|
+
containing `signal` (`AbortSignal`) for cooperative cancellation,
|
|
546
|
+
`stream` (`Readable`) for consuming the pushed data,
|
|
534
547
|
`buffer` (lazy `Promise<Uint8Array>`) that resolves to the complete
|
|
535
548
|
data once the stream ends, and `meta` (`Record<string, any> |
|
|
536
549
|
undefined`) containing the metadata sent by the pusher.
|
|
@@ -559,8 +572,9 @@ Source Registration
|
|
|
559
572
|
receiver?: string,
|
|
560
573
|
authenticated?: boolean,
|
|
561
574
|
meta?: Record<string, any>,
|
|
575
|
+
signal: AbortSignal,
|
|
562
576
|
stream?: Readable,
|
|
563
|
-
buffer?: Promise<Uint8Array>
|
|
577
|
+
buffer?: Promise<Uint8Array> | Uint8Array
|
|
564
578
|
}
|
|
565
579
|
) => void | Promise<void>
|
|
566
580
|
): Promise<Registration>
|
|
@@ -573,8 +587,9 @@ Source Registration
|
|
|
573
587
|
receiver?: string,
|
|
574
588
|
authenticated?: boolean,
|
|
575
589
|
meta?: Record<string, any>,
|
|
590
|
+
signal: AbortSignal,
|
|
576
591
|
stream?: Readable,
|
|
577
|
-
buffer?: Promise<Uint8Array>
|
|
592
|
+
buffer?: Promise<Uint8Array> | Uint8Array
|
|
578
593
|
}
|
|
579
594
|
) => void | Promise<void>,
|
|
580
595
|
options?: MQTT::IClientSubscribeOptions,
|
|
@@ -588,7 +603,9 @@ Register a source for sending data.
|
|
|
588
603
|
|
|
589
604
|
- The `callback` is called with the `params` passed to a remote `fetch()`.
|
|
590
605
|
The `callback` should set `info.stream` to a `Readable` or
|
|
591
|
-
`info.buffer` to a `Promise<Uint8Array>` containing the data.
|
|
606
|
+
`info.buffer` to a `Promise<Uint8Array>` or `Uint8Array` containing the data.
|
|
607
|
+
The `info.signal` is aborted when the fetch request is cancelled, times out,
|
|
608
|
+
or is otherwise torn down, allowing the source handler to stop producing data.
|
|
592
609
|
Optionally, the `callback` can set `info.meta` to a `Record<string,
|
|
593
610
|
any>` to send metadata back with the response.
|
|
594
611
|
|
|
@@ -605,9 +622,10 @@ Register a source for sending data.
|
|
|
605
622
|
When set to a role name string (e.g., `"admin"`), authentication
|
|
606
623
|
is required and the token must include that role. When set to an
|
|
607
624
|
object `{ mode, roles }`, the mode can be `"require"` (reject
|
|
608
|
-
unauthenticated
|
|
609
|
-
|
|
610
|
-
|
|
625
|
+
unauthenticated, so `info.authenticated` is always `true` in the
|
|
626
|
+
callback) or `"optional"` (accept all, but set `info.authenticated`
|
|
627
|
+
to `true` or `false` to reflect the validation result), and roles
|
|
628
|
+
specifies the required role names.
|
|
611
629
|
|
|
612
630
|
- Internally, on the MQTT broker, the topics generated by
|
|
613
631
|
`topicMake(name, "source-fetch-request")`
|
|
@@ -658,7 +676,8 @@ Fetches data from any source or from a specific source.
|
|
|
658
676
|
optional metadata sent by the source when the first chunk arrives.
|
|
659
677
|
|
|
660
678
|
- The remote `source()` `callback` is called with `params` and
|
|
661
|
-
|
|
679
|
+
receives `info.signal` (`AbortSignal`) for cooperative cancellation
|
|
680
|
+
and should set `info.stream` to a `Readable` or `info.buffer` to
|
|
662
681
|
a `Promise<Uint8Array>` containing the data. Optionally, the
|
|
663
682
|
`callback` can set `info.meta` to send metadata back with the
|
|
664
683
|
response. If the remote `callback` throws an exception, this
|
|
@@ -703,4 +722,3 @@ Example:
|
|
|
703
722
|
const ui8a = mqttp.arr2buf(buffer)
|
|
704
723
|
const buffer = mqttp.buf2arr(ui8a, Buffer)
|
|
705
724
|
const i8a = mqttp.buf2arr(ui8a, Int8Array)
|
|
706
|
-
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
MQTT+ Architecture
|
|
3
3
|
==================
|
|
4
4
|
|
|
5
|
-
**MQTT+** is composed as a vertical chain of API and
|
|
5
|
+
**MQTT+** is composed as a vertical chain of API and infrastructure trait
|
|
6
6
|
classes (mixins), each extending the previous. Additionally, some base
|
|
7
7
|
modules complement the functionality.
|
|
8
8
|
|
|
@@ -69,7 +69,7 @@ pattern read example/server/+/service-call-response/%c
|
|
|
69
69
|
|
|
70
70
|
topic read example/client/+/service-call-request/any
|
|
71
71
|
pattern read example/client/+/service-call-request/%c
|
|
72
|
-
pattern write example/client/+/service-call-response
|
|
72
|
+
pattern write example/client/+/service-call-response/+
|
|
73
73
|
|
|
74
74
|
# ---- source fetch ----
|
|
75
75
|
|
|
@@ -87,7 +87,7 @@ pattern read example/server/+/sink-push-response/%c
|
|
|
87
87
|
|
|
88
88
|
topic read example/client/+/sink-push-request/any
|
|
89
89
|
pattern read example/client/+/sink-push-request/%c
|
|
90
|
-
pattern write example/client/+/sink-push-response
|
|
90
|
+
pattern write example/client/+/sink-push-response/+
|
|
91
91
|
|
|
92
92
|
# ==== server/authenticated ACL ====
|
|
93
93
|
|
package/doc/mqtt-plus-comm.md
CHANGED
|
@@ -50,7 +50,9 @@ chunks as a stream with arguments.
|
|
|
50
50
|
> In contrast to the regular MQTT message publish/subscribe, this
|
|
51
51
|
> pattern allows to transfer arbitrary amounts of arbitrary data by
|
|
52
52
|
> chunking the data via a stream. Additionally, it supports authentication
|
|
53
|
-
> and meta-data,
|
|
53
|
+
> and meta-data, provides an `AbortSignal` to the sink handler for
|
|
54
|
+
> cooperative cancellation, and allows the receiver to cancel an
|
|
55
|
+
> in-progress push via a cancel signal (`credit=0`), etc.
|
|
54
56
|
|
|
55
57
|

|
|
56
58
|
|
|
@@ -67,7 +69,7 @@ data chunks as a stream with arguments.
|
|
|
67
69
|
> In contrast to the regular MQTT message publish/subscribe, this
|
|
68
70
|
> pattern allows to transfer arbitrary amounts of arbitrary data by
|
|
69
71
|
> chunking the data via a stream. Additionally, it supports
|
|
70
|
-
> authentication and meta-data,
|
|
72
|
+
> authentication and meta-data, and provides an `AbortSignal` to the
|
|
73
|
+
> source handler for cooperative cancellation, etc.
|
|
71
74
|
|
|
72
75
|

|
|
73
|
-
|
|
@@ -138,7 +138,7 @@ Exactly one of `result` or `error` is present.
|
|
|
138
138
|
| Field | Type | Required | Description |
|
|
139
139
|
|----------|-----------|----------|-------------------------------------|
|
|
140
140
|
| `name` | `string` | yes | Sink endpoint name |
|
|
141
|
-
| `credit` | `integer` | yes | Number of additional credits (min
|
|
141
|
+
| `credit` | `integer` | yes | Number of additional credits (min 0). A value of `0` is a **cancel signal**, indicating that the receiver wants to abort the push stream. |
|
|
142
142
|
|
|
143
143
|
### `source-fetch-request`
|
|
144
144
|
|
|
@@ -272,6 +272,16 @@ Setting `chunkCredit` to `0` disables flow control entirely.
|
|
|
272
272
|
| Sink Push | Sink | Pusher | `sink-push-credit` |
|
|
273
273
|
| Source Fetch | Fetcher | Source | `source-fetch-credit` |
|
|
274
274
|
|
|
275
|
+
### Receiver-Initiated Cancellation (Sink Push)
|
|
276
|
+
|
|
277
|
+
The sink (receiver) can cancel an in-progress push by sending a
|
|
278
|
+
`sink-push-credit` message with `credit` set to `0`. This acts as
|
|
279
|
+
a **cancel signal**: the pusher aborts the data transfer immediately
|
|
280
|
+
and does not send an error chunk back to the receiver (since the
|
|
281
|
+
cancellation originated from the receiver itself). On the receiver
|
|
282
|
+
side, the `AbortSignal` provided to the sink callback is triggered
|
|
283
|
+
when the push stream closes abnormally.
|
|
284
|
+
|
|
275
285
|
Authentication
|
|
276
286
|
--------------
|
|
277
287
|
|
|
@@ -86,16 +86,8 @@ export class AuthTrait extends MetaTrait {
|
|
|
86
86
|
async authenticated(clientId, tokens, option) {
|
|
87
87
|
let authenticated = false;
|
|
88
88
|
/* determine authentication configuration */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (typeof option === "string") {
|
|
92
|
-
mode = "require";
|
|
93
|
-
roles = [option];
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
mode = option.mode;
|
|
97
|
-
roles = option.roles;
|
|
98
|
-
}
|
|
89
|
+
const roles = typeof option === "string"
|
|
90
|
+
? [option] : option.roles;
|
|
99
91
|
/* iterate over all roles and try to authenticate token (first-match, max 8) */
|
|
100
92
|
if (tokens !== undefined) {
|
|
101
93
|
for (const token of tokens.slice(0, 8)) {
|
|
@@ -120,9 +112,6 @@ export class AuthTrait extends MetaTrait {
|
|
|
120
112
|
break;
|
|
121
113
|
}
|
|
122
114
|
}
|
|
123
|
-
/* handle optional case */
|
|
124
|
-
if (!authenticated && mode === "optional")
|
|
125
|
-
authenticated = true;
|
|
126
115
|
return authenticated;
|
|
127
116
|
}
|
|
128
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mqtt-plus-auth.js","sourceRoot":"","sources":["../src/mqtt-plus-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE;AAEF,6BAA6B;AAC7B,OAAO,EAAE,OAAO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CAAC,EAAE,CAAC;gBACrC,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI;oBACnB,SAAQ;gBACZ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;gBAC/C,IAAI,OAAO,KAAK,IAAI;oBAChB,SAAQ;gBACZ,IAAI,OAAO,CAAC,EAAE,IAAI,OAAO,CAAC,EAAE,KAAK,QAAQ;oBACrC,SAAQ;gBACZ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;oBAC7B,SAAQ;gBACZ,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE;oBACzB,SAAQ;gBACZ,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACvB,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC/B,aAAa,GAAG,IAAI,CAAA;wBACpB,MAAK;oBACT,CAAC;gBACL,CAAC;gBACD,IAAI,aAAa;oBACb,MAAK;YACb,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAA;IACxB,CAAC;CACJ"}
|
|
@@ -6,11 +6,12 @@ import { Spool } from "./mqtt-plus-error";
|
|
|
6
6
|
export declare class BaseTrait<T extends APISchema = APISchema> extends TraceTrait<T> {
|
|
7
7
|
private mqtt;
|
|
8
8
|
private messageHandler;
|
|
9
|
+
protected destroyed: boolean;
|
|
9
10
|
protected onRequest: Map<string, (message: any, topicName: string) => void | Promise<void>>;
|
|
10
11
|
protected onResponse: Map<string, (message: any, topicName: string) => void | Promise<void>>;
|
|
11
12
|
constructor(mqtt: MqttClient | null, options?: Partial<APIOptions>);
|
|
12
13
|
destroy(): Promise<void>;
|
|
13
|
-
protected makeRegistration(spool: Spool, kind: string, name: string
|
|
14
|
+
protected makeRegistration(spool: Spool, kind: string, name: string): Registration;
|
|
14
15
|
protected subscribeTopic(topic: string, options?: Partial<IClientSubscribeOptions>): Promise<void>;
|
|
15
16
|
protected unsubscribeTopic(topic: string): Promise<void>;
|
|
16
17
|
protected publishToTopic(topic: string, message: string | Uint8Array, options?: IClientPublishOptions): Promise<void>;
|