aedes 0.51.3 → 1.0.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.
Files changed (68) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/.github/actions/sticky-pr-comment/action.yml +55 -0
  3. package/.github/workflows/benchmark-compare-serial.yml +60 -0
  4. package/.github/workflows/ci.yml +12 -17
  5. package/.release-it.json +18 -0
  6. package/.taprc +15 -6
  7. package/README.md +6 -4
  8. package/aedes.d.ts +0 -6
  9. package/aedes.js +270 -242
  10. package/benchmarks/README.md +33 -0
  11. package/benchmarks/pingpong.js +94 -25
  12. package/benchmarks/receiver.js +77 -0
  13. package/benchmarks/report.js +150 -0
  14. package/benchmarks/runBenchmarks.js +118 -0
  15. package/benchmarks/sender.js +86 -0
  16. package/benchmarks/server.js +19 -18
  17. package/checkVersion.js +20 -0
  18. package/docs/Aedes.md +66 -8
  19. package/docs/Client.md +3 -4
  20. package/docs/Examples.md +39 -22
  21. package/docs/MIGRATION.md +50 -0
  22. package/eslint.config.js +8 -0
  23. package/example.js +51 -40
  24. package/examples/clusters/index.js +28 -23
  25. package/examples/clusters/package.json +10 -6
  26. package/lib/client.js +405 -306
  27. package/lib/handlers/connect.js +42 -38
  28. package/lib/handlers/index.js +9 -11
  29. package/lib/handlers/ping.js +2 -3
  30. package/lib/handlers/puback.js +5 -5
  31. package/lib/handlers/publish.js +29 -14
  32. package/lib/handlers/pubrec.js +9 -17
  33. package/lib/handlers/pubrel.js +34 -25
  34. package/lib/handlers/subscribe.js +47 -43
  35. package/lib/handlers/unsubscribe.js +16 -19
  36. package/lib/qos-packet.js +14 -17
  37. package/lib/utils.js +5 -12
  38. package/lib/write.js +4 -5
  39. package/package.json +139 -136
  40. package/test/auth.js +468 -804
  41. package/test/basic.js +613 -575
  42. package/test/bridge.js +44 -40
  43. package/test/client-pub-sub.js +531 -504
  44. package/test/close_socket_by_other_party.js +137 -102
  45. package/test/connect.js +487 -484
  46. package/test/drain-timeout.js +593 -0
  47. package/test/drain-toxiproxy.js +620 -0
  48. package/test/events.js +173 -145
  49. package/test/helper.js +351 -73
  50. package/test/keep-alive.js +40 -67
  51. package/test/meta.js +257 -210
  52. package/test/not-blocking.js +93 -197
  53. package/test/qos1.js +464 -554
  54. package/test/qos2.js +308 -393
  55. package/test/regr-21.js +39 -21
  56. package/test/require.cjs +22 -0
  57. package/test/retain.js +349 -398
  58. package/test/topics.js +176 -183
  59. package/test/types/aedes.test-d.ts +4 -8
  60. package/test/will.js +310 -428
  61. package/types/instance.d.ts +40 -35
  62. package/types/packet.d.ts +10 -10
  63. package/.coveralls.yml +0 -1
  64. package/benchmarks/bombing.js +0 -34
  65. package/benchmarks/bombingQoS1.js +0 -36
  66. package/benchmarks/throughputCounter.js +0 -23
  67. package/benchmarks/throughputCounterQoS1.js +0 -33
  68. package/types/.eslintrc.json +0 -47
@@ -0,0 +1,12 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "mcp__github__get_issue",
5
+ "Bash(npm run:*)",
6
+ "Bash(git checkout:*)",
7
+ "Bash(git push:*)",
8
+ "Bash(gh pr:*)",
9
+ "mcp__github__add_issue_comment"
10
+ ]
11
+ }
12
+ }
@@ -0,0 +1,55 @@
1
+ name: "Sticky PR Comment"
2
+ description: "Posts or updates a pull request comment identified by a tag."
3
+ inputs:
4
+ file:
5
+ description: "Path to the file whose contents are to be posted"
6
+ required: true
7
+ tag:
8
+ description: "Unique tag to identify the comment (e.g. <!-- BENCHMARK_REPORT_COMMENT -->)"
9
+ required: true
10
+ runs:
11
+ using: "composite"
12
+ steps:
13
+ - name: Read file and set as output
14
+ id: file
15
+ shell: bash
16
+ run: |
17
+ echo "body<<EOF" >> $GITHUB_OUTPUT
18
+ cat "${{ inputs.file }}" >> $GITHUB_OUTPUT
19
+ echo "EOF" >> $GITHUB_OUTPUT
20
+
21
+ - name: Post or update PR comment
22
+ uses: actions/github-script@v7
23
+ with:
24
+ github-token: ${{ github.token }}
25
+ script: |
26
+ const tag = `${{ inputs.tag }}`;
27
+ const body = `${tag}\n${{ steps.file.outputs.body }}`;
28
+ const pr = context.payload.pull_request?.number;
29
+ if (!pr) {
30
+ core.setFailed("No pull request found in context.");
31
+ return;
32
+ }
33
+ const { data: comments } = await github.rest.issues.listComments({
34
+ owner: context.repo.owner,
35
+ repo: context.repo.repo,
36
+ issue_number: pr,
37
+ });
38
+ const tagged = comments.find(comment =>
39
+ comment.body.includes(tag)
40
+ );
41
+ if (tagged) {
42
+ await github.rest.issues.updateComment({
43
+ owner: context.repo.owner,
44
+ repo: context.repo.repo,
45
+ comment_id: tagged.id,
46
+ body: body,
47
+ });
48
+ } else {
49
+ await github.rest.issues.createComment({
50
+ owner: context.repo.owner,
51
+ repo: context.repo.repo,
52
+ issue_number: pr,
53
+ body: body,
54
+ });
55
+ }
@@ -0,0 +1,60 @@
1
+ name: "Benchmark Report"
2
+
3
+ description: "Runs benchmarks and posts or updates a sticky PR comment with the results."
4
+
5
+ on:
6
+ pull_request:
7
+ types: [opened, synchronize, reopened]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ benchmark:
14
+ name: Benchmark
15
+ runs-on: ubuntu-latest
16
+ env:
17
+ nodeVersion: 20
18
+ mainRef: "main"
19
+ steps:
20
+ - name: Set up Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: ${{ env.nodeVersion }}
24
+
25
+ # Run benchmark on main branch
26
+ - name: Checkout main branch
27
+ uses: actions/checkout@v4
28
+ with:
29
+ ref: ${{ env.mainRef }}
30
+ path: main-source
31
+
32
+ - name: Install dependencies (main)
33
+ run: npm install --ignore-scripts
34
+ working-directory: main-source
35
+
36
+ - name: Run benchmark on main
37
+ run: node benchmarks/runBenchmarks.js > ../results.main.csv
38
+ working-directory: main-source
39
+
40
+ # Run benchmark on PR branch
41
+ - name: Checkout PR branch
42
+ uses: actions/checkout@v4
43
+ with:
44
+ path: pr-source
45
+
46
+ - name: Install dependencies (PR)
47
+ run: npm install --ignore-scripts
48
+ working-directory: pr-source
49
+
50
+ - name: Run benchmark on PR branch
51
+ run: node benchmarks/runBenchmarks.js > ../results.branch.csv
52
+ working-directory: pr-source
53
+
54
+ # Generate the report
55
+ - name: Generate report
56
+ shell: bash
57
+ run: |
58
+ cat results.main.csv results.branch.csv | node main-source/benchmarks/report.js >> $GITHUB_STEP_SUMMARY
59
+
60
+
@@ -31,7 +31,7 @@ jobs:
31
31
  runs-on: ${{ matrix.os }}
32
32
  strategy:
33
33
  matrix:
34
- node-version: [16, 18, 20]
34
+ node-version: [ 20, 22, 24]
35
35
  os: [ubuntu-latest, windows-latest, macOS-latest]
36
36
  fail-fast: false
37
37
  steps:
@@ -59,20 +59,15 @@ jobs:
59
59
  - name: Run tests
60
60
  run: |
61
61
  npm run test:ci
62
-
63
- - name: Coveralls Parallel
64
- uses: coverallsapp/github-action@master
65
- with:
66
- github-token: ${{ secrets.github_token }}
67
- parallel: true
68
- flag-name: run-${{ matrix.node-version }}-${{ matrix.os }}
69
-
70
- coverage:
71
- needs: test
72
- runs-on: ubuntu-latest
73
- steps:
74
- - name: Coveralls Finished
75
- uses: coverallsapp/github-action@master
62
+
63
+ - name: Upload coverage reports to Codecov
64
+ # only let the first job upload coverage info
65
+ if: strategy.job-index == 0
66
+ uses: codecov/codecov-action@v5
76
67
  with:
77
- github-token: ${{ secrets.GITHUB_TOKEN }}
78
- parallel-finished: true
68
+ directory: coverage
69
+ fail_ci_if_error: true
70
+ flags: unittests
71
+ name: codecov-aedes
72
+ token: ${{ secrets.CODECOV_TOKEN }}
73
+ verbose: true
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://unpkg.com/release-it@19/schema/release-it.json",
3
+ "github": {
4
+ "release": true
5
+ },
6
+ "git": {
7
+ "tagName": "v${version}",
8
+ "requireBranch": "main"
9
+ },
10
+ "hooks": {
11
+ "before:init": [
12
+ "npm run test:ci"
13
+ ]
14
+ },
15
+ "npm": {
16
+ "publish": true
17
+ }
18
+ }
package/.taprc CHANGED
@@ -1,6 +1,15 @@
1
- ts: false
2
- jsx: false
3
- flow: false
4
- coverage: true
5
- strict: true
6
- check-coverage: false
1
+ # vim: set filetype=yaml :
2
+ coverage-report:
3
+ - text
4
+ allow-incomplete-coverage: true
5
+ browser: false
6
+ timeout: 60
7
+ include:
8
+ - "**/@(test?(s)|__test?(s)__)/**/*.@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
9
+ - "**/*.@(test?(s)|spec).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
10
+ - "**/test?(s).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
11
+ exclude:
12
+ - "**/@(fixture*(s)|dist)/**"
13
+ snapshot-clean-cwd: true
14
+ color: true
15
+ reporter: tap
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
6
6
  [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/moscajs/aedes/graphs/commit-activity)
7
7
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/moscajs/aedes/pulls)\
8
- [![Coverage Status](https://coveralls.io/repos/moscajs/aedes/badge.svg?branch=main&service=github)](https://coveralls.io/github/moscajs/aedes?branch=main)
8
+ [![codecov](https://codecov.io/gh/moscajs/aedes/graph/badge.svg?token=6SdoJIgIjg)](https://codecov.io/gh/moscajs/aedes)
9
9
  [![Known Vulnerabilities](https://snyk.io/test/github/moscajs/aedes/badge.svg)](https://snyk.io/test/github/moscajs/aedes)\
10
10
  ![node](https://img.shields.io/node/v/aedes)
11
11
  [![NPM version](https://img.shields.io/npm/v/aedes.svg?style=flat)](https://www.npmjs.com/aedes)
@@ -22,6 +22,7 @@ Barebone MQTT server that can run on any stream servers
22
22
  - [Features](#features)
23
23
  - [Examples](#examples)
24
24
  - [Clusters](#clusters)
25
+ - [Bridge connections](#bridge-connections)
25
26
  - [Extensions](#extensions)
26
27
  - [Middleware Plugins](#middleware-plugins)
27
28
  - [Persistence](#persistence)
@@ -37,6 +38,7 @@ Barebone MQTT server that can run on any stream servers
37
38
  - [Made with Aedes](#made-with-aedes)
38
39
  - [Collaborators](#collaborators)
39
40
  - [Contribution](#contribution)
41
+ - [Security notice](#security-notice)
40
42
  - [Support](#support)
41
43
  - [Backers](#backers)
42
44
  - [Sponsors](#sponsors)
@@ -52,12 +54,12 @@ npm install aedes
52
54
 
53
55
  ## Docker
54
56
 
55
- Check Docker docs [here](https://github.com/moscajs/aedes-cli#docker)
57
+ Check the [Docker docs](https://github.com/moscajs/aedes-cli#docker)
56
58
 
57
59
  ## API
58
60
 
59
- - [Aedes object](./docs/Aedes.md)
60
- - [Client object](./docs/Client.md)
61
+ - [Aedes class](./docs/Aedes.md)
62
+ - [Client class](./docs/Client.md)
61
63
 
62
64
  ## Features
63
65
 
package/aedes.d.ts CHANGED
@@ -1,9 +1,3 @@
1
- import Aedes, { AedesOptions } from './types/instance'
2
-
3
- export declare function createBroker(options?: AedesOptions): Aedes
4
-
5
1
  export * from './types/instance'
6
2
  export * from './types/packet'
7
3
  export * from './types/client'
8
-
9
- export { default } from './types/instance'