7687 Commits

Author SHA1 Message Date
Damien Arrachequesne
ca397f3afe fix(types): ensure compatibility with TypeScript < 4.5
"import { type ... }" was added in TypeScript 4.5.

Reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/

Related:

- https://github.com/socketio/socket.io-adapter/issues/86
- https://github.com/socketio/socket.io/issues/3891
2024-02-22 07:54:48 +01:00
Damien Arrachequesne
549156c064 chore(release): 2.5.3
Diff: https://github.com/socketio/socket.io-adapter/compare/2.5.2...2.5.3
2024-02-21 12:33:48 +01:00
Damien Arrachequesne
5dcd182736 refactor(cluster): make onMessage() method synchronous
The fetchSockets() method of the parent class is synchronous, so the
onMessage() method does not need to be asynchronous.
2024-02-21 12:09:29 +01:00
Damien Arrachequesne
1d8da64514 ci: upgrade to actions/checkout@4 and actions/setup-node@4
Reference: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
2024-02-21 11:46:21 +01:00
Damien Arrachequesne
48eddc19ea ci: use Node.js 20
Reference: https://github.com/nodejs/Release
2024-02-21 11:46:21 +01:00
Damien Arrachequesne
2df5e94c81 test(cluster): init the test suite for the clustered adapter
The test suite is imported from [1].

[1]: 193883b9ca/test/index.ts
2024-02-21 11:38:16 +01:00
Damien Arrachequesne
2a6a215600 refactor(cluster): add explicit types 2024-02-20 16:49:23 +01:00
Damien Arrachequesne
d99a71b558 perf(cluster): use timer.refresh()
Reference: https://nodejs.org/api/timers.html#timeoutrefresh
2024-02-20 16:49:23 +01:00
Damien Arrachequesne
39d4220814 refactor(cluster): catch publish errors
Note: the current API does not currently allow the user to handle those
errors (and retry, for example). This might be worth investigating for
the next major version, maybe something like:

```js
try {
  await io.emit("hello");
} catch (e) {
  // something went wrong
}
```

Related: https://github.com/socketio/socket.io-mongo-adapter/issues/15
2024-02-20 16:49:12 +01:00
Damien Arrachequesne
1011ab3bfb refactor(cluster): allow to call onMessage() with a cluster response
The Redis adapter is currently the only adapter which makes a
distinction between publishing messages (one channel for all) and
responses (one channel for each node).
2024-02-20 16:21:50 +01:00
Damien Arrachequesne
0e23ff0cc6 fix(cluster): notify the other nodes when closing
The clustered adapter will now:

- periodically check if a node has left the cluster
- send an event when it leaves the cluster

This should reduce the number of "timeout reached: only x responses
received out of y" errors.
2024-02-20 16:12:47 +01:00
Damien Arrachequesne
80af4e939c fix(cluster): fix count in fetchSockets() method
Related: bd32763043
2024-02-20 15:53:08 +01:00
Damien Arrachequesne
b2d36951ef refactor(cluster): add explicit message types 2024-02-20 15:53:04 +01:00
Damien Arrachequesne
b157e9e1ac refactor: import the ClusterAdapter abstract class
Imported from ef5f0da0b4/lib/cluster-adapter.ts

This abstract class is currently used by the sharded Redis adapter. We
import it here because the logic can be reused by the other adapters,
which will then only need to handle the pub/sub mechanism.
2024-02-20 15:46:13 +01:00
Wang Guan
b9ce6a25d1 refactor: create specific adapter for parent namespaces (#4950) 2024-02-19 22:01:29 +01:00
Damien Arrachequesne
54dabe5bff ci: upgrade to actions/checkout@4 and actions/setup-node@4
Reference: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
2024-02-12 18:16:10 +01:00
Damien Arrachequesne
e426f3e8e1 fix: remove duplicate pipeline when serving bundle
Related: https://github.com/socketio/socket.io/issues/4946
2024-02-12 18:11:38 +01:00
Damien Arrachequesne
69d02dd754 chore(release): 5.2.2
Diff: https://github.com/socketio/engine.io-parser/compare/5.2.1...5.2.2
engine.io-parser@5.2.2
2024-02-05 18:35:35 +01:00
Damien Arrachequesne
0305b4a7a5 fix(typescript): properly import the TransformStream type
When compiling with TypeScript with module set to "node16" and
moduleResolution to "node16", the following error would be thrown:

> node_modules/engine.io-parser/build/cjs/index.d.ts:6:54 - error TS2304: Cannot find name 'TransformStream'.
> 6 export declare function createPacketEncoderStream(): TransformStream<Packet, any>;
>                                                        ~~~~~~~~~~~~~~~
> node_modules/engine.io-parser/build/cjs/index.d.ts:7:96 - error TS2304: Cannot find name 'TransformStream'.
> 7 export declare function createPacketDecoderStream(maxPayload: number, binaryType: BinaryType): TransformStream<Uint8Array, any>;
>                                                                                                  ~~~~~~~~~~~~~~~
> Found 2 errors in the same file, starting at: node_modules/engine.io-parser/build/cjs/index.d.ts:6

This is because the TransformStream object is not exposed in the global
scope in the `@types/node` package, even though it is since Node.js
`v18.0.0`.

Reference: https://nodejs.org/api/webstreams.html#class-transformstream

Note: we only import the TransformStream type (not value) because it
isn't defined on older Node.js versions.

Related:

- https://github.com/socketio/engine.io-parser/issues/136
- https://github.com/socketio/socket.io-client/issues/1606
2024-02-05 18:20:49 +01:00
Damien Arrachequesne
08cff77a48 chore: bump prettier to version 3
This change is necessary to be able to write "import type { ... }".
2024-02-05 18:20:30 +01:00
Damien Arrachequesne
e36062ca2d docs: update the webtransport example
Reference: https://github.com/fails-components/webtransport#changes-for-version-1xx
2024-01-17 13:01:57 +01:00
Damien Arrachequesne
0bbe8aec77 docs: only execute the passport middleware once
Before this change, the session and user context were retrieved once
per HTTP request and not once per session.
2024-01-13 17:56:17 +01:00
Damien Arrachequesne
914a8bd2b9 docs: add example with JWT
Related: https://github.com/socketio/socket.io/issues/4910
2024-01-13 17:14:01 +01:00
Damien Arrachequesne
d943c3e0b0 docs: update the Passport.js example 2024-01-12 17:08:19 +01:00
Damien Arrachequesne
6ab2509d52 chore(release): 4.7.4
Diff: https://github.com/socketio/socket.io/compare/4.7.3...4.7.4
4.7.4
2024-01-12 11:09:14 +01:00
Damien Arrachequesne
8cfea8c30b chore(release): 4.7.4
Diff: https://github.com/socketio/socket.io-client/compare/4.7.3...4.7.4
2024-01-12 11:03:23 +01:00
Zachary Soare
d9fb2f64b6 chore(tests): add a test for noArgs in a namespace 2024-01-08 06:38:57 +01:00
Zachary Soare
2c0a81cd87 chore(tests): fix issues due to client#id type change 2024-01-08 06:38:57 +01:00
Zachary Soare
f8d2644921 chore(tests): add type defs for expectjs and fix invalid expectations 2024-01-08 06:38:57 +01:00
Zachary Soare
04640d68cf chore(tests): indicate a future ts error with version 2024-01-08 06:38:57 +01:00
Zachary Soare
cb6d2e02aa fix(typings): calling io.emit with no arguments incorrectly errored
Refs: #4914
2024-01-08 06:38:57 +01:00
Damien Arrachequesne
80b2c34478 chore: bump socket.io-client version 2024-01-03 21:37:25 +01:00
Damien Arrachequesne
0d893196f8 chore(release): 4.7.3
Diff: https://github.com/socketio/socket.io/compare/4.7.2...4.7.3
4.7.3
2024-01-03 21:33:29 +01:00
Damien Arrachequesne
ca5d50ebac chore(release): 4.7.3
Diff: https://github.com/socketio/socket.io-client/compare/4.7.2...4.7.3
2024-01-03 21:25:21 +01:00
BCCSTeam
df8e70f798 fix: return the first response when broadcasting to a single socket (#4878) 2024-01-02 17:43:10 +01:00
Damien Arrachequesne
f9c16f2265 fix(typings): fix the type of the socket#id attribute
Related: https://github.com/socketio/socket.io/issues/4884
2024-01-02 15:55:56 +01:00
Damien Arrachequesne
b3f0cab1a0 ci: add Node.js 20 in the test matrix
Reference: https://github.com/nodejs/Release
2023-11-24 08:48:19 +01:00
Damien Arrachequesne
5a3eafed1c fix(typings): accept string | undefined as init argument
Related: https://github.com/socketio/socket.io/issues/4873
2023-11-24 08:48:08 +01:00
Xì Gà
8c9ebc30e5 fix(typings): allow to bind to a non-secure Http2Server (#4853) 2023-11-22 17:48:59 +01:00
Damien Arrachequesne
efb5c21e85 docs(examples): add Vue client with CRUD example 2023-11-22 10:12:17 +01:00
Damien Arrachequesne
3848280125 docs(examples): upgrade basic-crud-application to Angular v17
Related: https://github.com/socketio/socket.io/issues/4875
2023-11-21 14:15:50 +01:00
dependabot[bot]
23213858c6 chore: bump browserify-sign from 4.2.1 to 4.2.2 (#138)
Bumps [browserify-sign](https://github.com/crypto-browserify/browserify-sign) from 4.2.1 to 4.2.2.
- [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md)
- [Commits](https://github.com/crypto-browserify/browserify-sign/compare/v4.2.1...v4.2.2)

---
updated-dependencies:
- dependency-name: browserify-sign
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-10 18:12:46 +01:00
Damien Arrachequesne
ff0fbfb61f chore(release): 6.5.4
Diff: https://github.com/socketio/engine.io/compare/6.5.3...6.5.4
2023-11-09 18:07:45 +01:00
Damien Arrachequesne
09acb177a6 ci: add Node.js 20 in the test matrix
Reference: https://github.com/nodejs/Release
2023-11-09 18:04:07 +01:00
Damien Arrachequesne
fa47916425 chore(release): 6.5.3
Diff: https://github.com/socketio/engine.io-client/compare/6.5.2...6.5.3
2023-11-09 16:28:04 +01:00
Damien Arrachequesne
ef9ad7d1d6 ci: add Node.js 20 in the test matrix
Reference: https://github.com/nodejs/Release
2023-11-09 16:16:41 +01:00
Damien Arrachequesne
707597df26 fix: add a maximum length for the URL
The regular expression used to parse the URL provided by the user has a
time complexity of O(n^2), hence the length limitation.

Please note that this does not seem realistically exploitable, as an
attacker would have to be able to provide a malicious URL to the user
and inject it in the Engine.IO client.

We could also have:

- modified the regex, but there are a lot of edge cases and the current test coverage is probably not sufficient
- use the built-in URL object, but we would have to add a polyfill for old platforms like IE

Thanks to Young-jin Hwang from the Soonchunhyang University for the
responsible disclosure.
2023-11-09 15:35:57 +01:00
dependabot[bot]
8d86e0d892 chore: bump browserify-sign from 4.2.1 to 4.2.2 (#713)
Bumps [browserify-sign](https://github.com/crypto-browserify/browserify-sign) from 4.2.1 to 4.2.2.
- [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md)
- [Commits](https://github.com/crypto-browserify/browserify-sign/compare/v4.2.1...v4.2.2)

---
updated-dependencies:
- dependency-name: browserify-sign
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-09 15:19:00 +01:00
dependabot[bot]
f2aca29494 chore: bump @babel/traverse from 7.12.9 to 7.23.2 (#712)
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.12.9 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-09 15:18:47 +01:00
Damien Arrachequesne
39937f8f4d refactor: minor cleanups 2023-11-09 12:18:55 +01:00