Commit Graph

7693 Commits

Author SHA1 Message Date
Damien Arrachequesne
8be95b3bd3 chore(release): 4.5.2
Diff: https://github.com/socketio/socket.io/compare/4.5.1...4.5.2
4.5.2
2022-09-02 23:46:14 +01:00
Damien Arrachequesne
ba497ee3eb fix(uws): prevent the server from crashing after upgrade
This should fix a rare case where the Engine.IO connection was upgraded
to WebSocket while the Socket.IO socket was disconnected, which would
result in the following exception:

> TypeError: Cannot read properties of undefined (reading 'forEach')
>    at subscribe (/node_modules/socket.io/dist/uws.js:87:11)
>    at Socket.<anonymous> (/node_modules/socket.io/dist/uws.js:28:17)
>    at Socket.emit (node:events:402:35)
>    at WebSocket.onPacket (/node_modules/engine.io/build/socket.js:214:22)
>    at WebSocket.emit (node:events:390:28)
>    at WebSocket.onPacket (/node_modules/engine.io/build/transport.js:92:14)
>    at WebSocket.onData (/node_modules/engine.io/build/transport.js:101:14)
>    at message (/node_modules/engine.io/build/userver.js:56:30)

Related: https://github.com/socketio/socket.io/issues/4443
2022-09-02 23:42:26 +01:00
Damien Arrachequesne
2d70813729 chore(release): 4.5.2
Diff: https://github.com/socketio/socket.io-client/compare/4.5.1...4.5.2
2022-09-02 23:36:55 +01:00
Damien Arrachequesne
c597023169 fix: handle ill-formatted packet from server
The decoder can throw an error when trying to decode an invalid payload
sent by the server, so the manager will now catch it, close the
connection and then reconnect instead of crashing.

Related:

- https://github.com/socketio/socket.io/issues/4392
- https://github.com/socketio/socket.io-client/issues/1551
2022-09-02 23:28:35 +01:00
Alex
28038715cb ci: add explicit permissions to workflow (#4466)
Reference: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
2022-09-02 23:10:19 +01:00
Daniel Rosenwasser
134226e96c refactor: add missing constraints (#4431)
See also: https://github.com/microsoft/TypeScript/issues/49489
2022-09-01 21:13:55 +01:00
Damien Arrachequesne
5a2ccff9d1 chore(release): 4.2.1
Diff: https://github.com/socketio/socket.io-parser/compare/4.2.0...4.2.1
2022-06-27 15:42:25 +02:00
Damien Arrachequesne
b5d0cb7dc5 fix: check the format of the index of each attachment
A specially crafted packet could be incorrectly decoded.

Example:

```js
const decoder = new Decoder();

decoder.on("decoded", (packet) => {
  console.log(packet.data); // prints [ 'hello', [Function: splice] ]
})

decoder.add('51-["hello",{"_placeholder":true,"num":"splice"}]');
decoder.add(Buffer.from("world"));
```

As usual, please remember not to trust user input.
2022-06-27 15:39:24 +02:00
Damien Arrachequesne
9890b036cf chore: bump dependencies
Production:

- socket.io-parser: ~4.0.4 => ~4.2.0

Development:

- superagent: ^6.1.0 => ^8.0.0
- tsd: ^0.17.0 => ^0.21.0

Related: https://github.com/socketio/socket.io/issues/3709
2022-06-27 09:16:08 +02:00
Damien Arrachequesne
713a6b451b chore: bump mocha to version 10.0.0
Related: https://github.com/socketio/socket.io/issues/3710
2022-06-27 09:00:31 +02:00
Damien Arrachequesne
8c659bcccf chore: regenerate lockfile
For some reason, the lockfile was not in sync anymore with the
package.json file:

> `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync.

That may be linked to a new version of Node.js (v16.15.1).
2022-06-26 08:19:46 +02:00
Lam Wei Li
dfee8ded72 refactor: replace deprecated String.prototype.substr() (#691)
`.substr()` is deprecated so we replace it with `.slice()` which works
similarly but isn't deprecated.

See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr

Signed-off-by: Lam Wei Li <peteriman@mail.com>
2022-06-15 01:49:18 +02:00
Damien Arrachequesne
c814ce2968 feat: add the "maxPayload" field in the handshake
Added in `engine.io@6.2.0` and `socket.io@4.5.0`.

See also: 088dcb4dff
2022-06-12 09:55:08 +02:00
Damien Arrachequesne
1b3bb7cb03 feat: add the "maxPayload" field in the handshake
See also: 088dcb4dff
2022-06-12 09:48:47 +02:00
Lam Wei Li
917d1d29e1 refactor: replace deprecated String.prototype.substr() (#646)
`.substr()` is deprecated so we replace it with `.slice()` which works
similarily but isn't deprecated.

See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr

Signed-off-by: Lam Wei Li <peteriman@mail.com>
2022-06-06 08:42:45 +02:00
Damien Arrachequesne
020801ab8c chore: add changelog for version 3.6.0
Diff: https://github.com/socketio/engine.io/compare/3.5.0...3.6.0
2022-06-06 08:40:21 +02:00
Damien Arrachequesne
18f3fdab12 fix: prevent the socket from joining a room after disconnection
Calling `socket.join()` after disconnection would lead to a memory
leak, because the room was never removed from the memory:

```js
io.on("connection", (socket) => {
  socket.disconnect();
  socket.join("room1"); // leak
});
```

Related:

- https://github.com/socketio/socket.io/issues/4067
- https://github.com/socketio/socket.io/issues/4380
2022-05-25 23:18:42 +02:00
Damien Arrachequesne
3410584a93 refactor: use correct type for BroadcastOptions#except
The 'except' attribute is a set of room IDs, which is then converted to
a set of socket IDs in the computeExceptSids() method.

That wasn't caught because both types are aliases for 'string', but
Room could be extended to all primitive values in the future.

Reference: https://developer.mozilla.org/en-US/docs/Glossary/Primitive

Related: https://github.com/socketio/socket.io-adapter/issues/82
2022-05-25 07:06:27 +02:00
Damien Arrachequesne
5ab8289c0a chore(release): 4.5.1
Diff: https://github.com/socketio/socket.io/compare/4.5.0...4.5.1
4.5.1
2022-05-17 23:38:07 +02:00
Damien Arrachequesne
f0350a0100 chore(release): 4.5.1
Diff: https://github.com/socketio/socket.io-client/compare/4.5.0...4.5.1
2022-05-17 23:34:19 +02:00
Lucas Boemeke
ed1d6f912c test: make test script work on Windows (#643) 2022-05-11 09:00:17 +02:00
Damien Arrachequesne
30430f0985 fix: forward the local flag to the adapter when using fetchSockets()
Related:

- https://github.com/socketio/socket.io/issues/4359
- https://github.com/socketio/socket.io-redis-adapter/issues/454
2022-05-03 15:41:24 +02:00
h110m
9b43c9167c fix(typings): add HTTPS server to accepted types (#4351) 2022-05-03 08:15:22 +02:00
Damien Arrachequesne
1975c5c995 chore(release): 6.2.2
Diff: https://github.com/socketio/engine.io-client/compare/6.2.1...6.2.2
2022-05-02 10:11:32 +02:00
Damien Arrachequesne
7e3fe43965 chore: update caniuse-lite version
See https://github.com/browserslist/browserslist#browsers-data-updating
2022-05-02 10:00:31 +02:00
Damien Arrachequesne
ef1c28295e refactor: use named export for XMLHttpRequest shim 2022-05-02 10:00:27 +02:00
Damien Arrachequesne
f158c8e255 fix: simplify the check for WebSocket availability
This check was added for the flashsocket transport, which has been
deprecated for a while now ([1]). But it fails with latest webpack
versions, as the expression `"__initialize" in WebSocket` gets
evaluated to `true`.

Related:

- https://github.com/socketio/engine.io-client/issues/689
- https://github.com/socketio/socket.io-client/issues/1537

[1]: dbc65f3b5a
2022-05-02 09:48:38 +02:00
yujiosaka
32878ea047 fix: use named export for globalThis shim (#688)
Default export of globalThis seems to have a problem in the "browser"
field when the library is loaded asynchronously with webpack.
2022-05-02 09:47:16 +02:00
Damien Arrachequesne
764c99f136 chore(release): 5.0.4
Diff: https://github.com/socketio/engine.io-parser/compare/5.0.3...5.0.4
2022-04-30 14:13:42 +02:00
Damien Arrachequesne
bc7400a5e8 refactor: include base64-arraybuffer in the repository
In order to reduce the number of dependencies and the attack surface in
case of supply chain attacks.
2022-04-30 13:59:34 +02:00
Damien Arrachequesne
da182cba3e chore: point the CI badge towards the main branch 2022-04-30 13:54:19 +02:00
Damien Arrachequesne
a421bbec7b fix: add missing file extension for ESM import
Related: https://github.com/socketio/engine.io-parser/issues/127
2022-04-30 12:42:03 +02:00
Damien Arrachequesne
039b45cc65 fix(typings): update the type of RawData
We could also split the declaration of RawData with the "browser"
field:

```
// for Node.js
export type RawData = string | Buffer | ArrayBuffer | ArrayBufferView; // no Blob
// for the browser
export type RawData = string | ArrayBuffer | ArrayBufferView | Blob; // no Buffer
```

But it does not seem supported by the TypeScript compiler, so we'll
revert to just using "any" for now.

Related: https://github.com/socketio/engine.io-parser/issues/128
2022-04-30 12:36:57 +02:00
Damien Arrachequesne
43f9ee8d23 chore(release): 0.2.0
Diff: https://github.com/socketio/socket.io-cluster-adapter/compare/0.1.0...0.2.0
2022-04-28 16:16:13 +02:00
Damien Arrachequesne
055b7840d8 feat: broadcast and expect multiple acks
This feature was added in `socket.io@4.5.0`:

```js
io.timeout(1000).emit("some-event", (err, responses) => {
  // ...
});
```

Thanks to this change, it will now work with multiple Socket.IO
servers.

Related: https://github.com/socketio/socket.io/issues/4163
2022-04-28 16:11:12 +02:00
Damien Arrachequesne
8ecfcba5c1 chore(release): 4.5.0
Diff: https://github.com/socketio/socket.io/compare/4.4.1...4.5.0
4.5.0
2022-04-24 00:45:57 +02:00
Damien Arrachequesne
abdba07030 chore(release): 4.5.0
Diff: https://github.com/socketio/socket.io-client/compare/4.4.1...4.5.0
2022-04-24 00:37:51 +02:00
Damien Arrachequesne
faf68a5de1 chore: update default label for bug reports 2022-04-24 00:18:42 +02:00
Damien Arrachequesne
c0ba7344e2 chore: add Node.js 16 in the test matrix
See also: https://github.com/nodejs/Release
2022-04-24 00:17:23 +02:00
Damien Arrachequesne
e8590188ec refactor: replace the disconnected attribute by a getter 2022-04-24 00:13:56 +02:00
Damien Arrachequesne
74e3e601a4 feat: add support for catch-all listeners for outgoing packets
This is similar to `onAny()`, but for outgoing packets.

Syntax:

```js
socket.onAnyOutgoing((event, ...args) => {
  console.log(event);
});
```

Related: 531104d332
2022-04-23 23:57:03 +02:00
Damien Arrachequesne
692d54e9fd chore: point the CI badge towards the main branch 2022-04-23 22:59:48 +02:00
Damien Arrachequesne
6fdf3c9bfa refactor: import single-file 3rd party modules
This commit allows to:

- provide an ESM version of those modules ([1])
- reduce the attack surface in case of supply chain attacks
- reduce the size of the bundle with tree-shaking

As a downside, we won't receive security updates for those modules
anymore.

[1]: socketio/socket.io-client#1536

Related: df32277c3f
2022-04-23 22:55:39 +02:00
Damien Arrachequesne
b862924b7f feat: add details to the disconnect event
The "disconnect" event will now include additional details to help
debugging if anything has gone wrong.

Example when a payload is over the maxHttpBufferSize value in HTTP
long-polling mode:

```js
socket.on("disconnect", (reason, details) => {
  console.log(reason); // "transport error"

  // in that case, details is an error object
  console.log(details.message); "xhr post error"
  console.log(details.description); // 413 (the HTTP status of the response)

  // details.context refers to the XMLHttpRequest object
  console.log(details.context.status); // 413
  console.log(details.context.responseText); // ""
});
```

Related: b9252e2074
2022-04-23 00:57:23 +02:00
Damien Arrachequesne
572133a58d docs(examples): update example with webpack 2022-04-22 23:10:01 +02:00
Damien Arrachequesne
6e1bb62982 chore: bump engine.io to version 6.2.0
Release notes: https://github.com/socketio/engine.io/releases/tag/6.2.0
Diff: https://github.com/socketio/engine.io/compare/6.1.3...6.2.0
2022-04-22 22:43:31 +02:00
Damien Arrachequesne
06e6838b18 docs(examples): add server bundling example with rollup
Related: https://github.com/socketio/socket.io/issues/4329
2022-04-22 22:40:15 +02:00
WD
1f03a44d1f docs(examples): update create-react-app example (#4347) 2022-04-20 22:47:34 +02:00
Damien Arrachequesne
8437600aee chore(release): 6.2.1 2022-04-18 00:46:54 +02:00
Damien Arrachequesne
a2946fc697 chore: bump engine.io-parser to version 5.0.3
In order to make sure the types added in [1] are included.

[1]: ad5bd7ddf5
2022-04-18 00:45:25 +02:00