Commit Graph

7697 Commits

Author SHA1 Message Date
Chris West (Faux)
27fa6949f3 refactor: remove indexof dependency
This is a polyfill for indexOf(), which we use literally everywhere else.
2020-04-16 10:06:44 +02:00
Damien Arrachequesne
415332fc7c test: actually test empty payload handling (#113)
Fixes https://github.com/socketio/engine.io-parser/issues/112
2020-04-15 14:53:41 +02:00
Damien Arrachequesne
dcdbccb3dd fix: ignore errors when forcefully closing the socket (#601)
In order to catch the following errors:

```
events.js:288
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:154:25)
    at writeGeneric (internal/stream_base_commons.js:145:3)
    at Socket._writeGeneric (net.js:780:11)
    at Socket._write (net.js:792:8)
    at doWrite (_stream_writable.js:441:12)
    at writeOrBuffer (_stream_writable.js:425:5)
    at Socket.Writable.write (_stream_writable.js:316:11)
    at abortConnection (<myproject>/node_modules/engine.io/lib/server.js:506:12)
    at <myproject>/node_modules/engine.io/lib/server.js:353:7
    at Server.verify (<myproject>/node_modules/engine.io/lib/server.js:158:14)
    at Server.handleUpgrade (<myproject>/node_modules/engine.io/lib/server.js:351:8)
```

Closes https://github.com/socketio/engine.io/issues/596, https://github.com/socketio/engine.io/pull/598
2020-04-15 11:42:31 +02:00
Damien Arrachequesne
281de9ed47 docs(tweet-stream-example): migrate example
From https://github.com/darrachequesne/socket.io-tweet-stream
2020-04-14 10:17:47 +02:00
Damien Arrachequesne
edb95ea221 docs(whiteboard-example): update dependencies 2020-04-14 10:04:27 +02:00
Damien Arrachequesne
b74bb80122 docs(chat-example): remove dependency to the parent project 2020-04-14 09:56:42 +02:00
Damien Arrachequesne
71ece3ebf6 chore(release): 4.0.0-alpha.1 2020-02-12 08:33:47 +01:00
Damien Arrachequesne
804e871d4a chore(release): 4.0.0-alpha.1 2020-02-12 08:26:52 +01:00
Damien Arrachequesne
7c7f1a9fe2 fix: properly assign options when creating the transport
The query attribute was overwritten, due to the order of arguments in
the assignment. The bug was introduced in the refactor (5f47a50).
2020-02-12 08:14:51 +01:00
Damien Arrachequesne
b27215dcee chore(release): 4.0.0-alpha.0 2020-02-12 07:50:43 +01:00
Damien Arrachequesne
d37534e052 chore(release): 4.0.0-alpha.0 2020-02-12 07:45:56 +01:00
Damien Arrachequesne
5f47a50ee5 refactor: refactor the handling of the options 2020-02-11 23:33:34 +01:00
Damien Arrachequesne
41a1bcf1f5 chore: bump ws dependency
Diff: https://github.com/websockets/ws/compare/6.1.0...7.2.1
2020-02-11 23:17:43 +01:00
Damien Arrachequesne
4d311495af test: add Node.js 12 and 13 in the test matrix 2020-02-11 08:05:58 +01:00
Damien Arrachequesne
734f9d1268 feat: decrease the default value of maxHttpBufferSize
This change reduces the default value from 100 mb to a more sane 1 mb.

This helps protect the server against denial of service attacks by
malicious clients sending huge amounts of data.
2020-02-11 07:59:13 +01:00
Damien Arrachequesne
61b949259e feat: use the cors module to handle cross-origin requests
We'll now rely on the standard cors module (https://github.com/expressjs/cors),
instead of the custom implementation that is error-prone and not
really user-friendly.

Breaking change: the handlePreflightRequest option is removed by the
change.

Before:

```
new Server({
  handlePreflightRequest: (req, res) => {
    res.writeHead(200, {
      "Access-Control-Allow-Origin": 'https://example.com',
      "Access-Control-Allow-Methods": 'GET',
      "Access-Control-Allow-Headers": 'Authorization',
      "Access-Control-Allow-Credentials": true
    });
    res.end();
  }
})
```

After:

```
new Server({
  cors: {
    origin: "https://example.com",
    methods: ["GET"],
    allowedHeaders: ["Authorization"],
    credentials: true
  }
})
```
2020-02-11 07:54:25 +01:00
Damien Arrachequesne
bafe684a19 refactor: refactor the handling of the options 2020-02-10 12:07:41 +01:00
Damien Arrachequesne
61e639b257 test: add Node.js 10, 12 and 13 in the test matrix
uws is no longer maintained, and did not support Node.js >= 10.

We now use a fork in order to support the newer versions of Node.js.
It is maintained there: https://github.com/mmdevries/uws

And can be installed with: `npm i github:mmdevries/uws#2.4.1`

We could also try to support uWebSockets.js, but it does not have the
same API as ws.

The "engines" attribute has also been added in the package.json file,
since we broke the support for Node.js 6 in the latest minor release.

Source: https://github.com/mmdevries/uws
Related: https://github.com/socketio/engine.io/pull/583
2020-02-06 13:36:13 +01:00
Damien Arrachequesne
a374471d06 feat: disable cookie by default and add sameSite attribute
The cookie might be used for sticky-session, but is not mandatory so it
makes sense to disable it by default.

The change also add a SameSite=Lax attribute by default.

Breaking change: the syntax has changed from

```
new Server({
  cookieName: "test",
  cookieHttpOnly: false,
  cookiePath: "/custom"
})
```

to

```
new Server({
  cookie: {
    name: "test",
    httpOnly: false,
    path: "/custom"
  }
})
```

All other options (domain, maxAge, sameSite, ...) are now supported.

Reference: https://github.com/jshttp/cookie#options-1
2020-02-05 08:33:00 +01:00
Damien Arrachequesne
7f5a903f91 chore(release): 4.0.0-alpha.0 2020-02-04 12:36:20 +01:00
Damien Arrachequesne
31ff87593f feat: reverse the ping-pong mechanism
The ping packets will now be sent by the server, because the timers set
in the browsers are not reliable enough. We suspect that a lot of
timeout problems came from timers being delayed on the client-side.

Breaking change: v3.x clients will not be able to connect anymore (they
will send a ping packet and timeout while waiting for a pong packet).

Related: https://github.com/socketio/engine.io/issues/312
2020-02-04 12:31:44 +01:00
Damien Arrachequesne
81d7171c6b feat: reverse the ping-pong mechanism
The ping packets will now be sent by the server, because the timers set
in the browsers are not reliable enough. We suspect that a lot of
timeout problems came from timers being delayed on the client-side.

Breaking change: v3.x clients will not be able to connect anymore (they
will send a ping packet and timeout while waiting for a pong packet).

Related: https://github.com/socketio/engine.io/issues/312
2020-02-04 12:29:37 +01:00
Damien Arrachequesne
840145d3e5 test: add node.js 12 in the test matrix
See https://github.com/nodejs/Release
2020-01-15 08:52:14 +01:00
Damien Arrachequesne
581cefff2d refactor: remove gulp from the build
Plain npm scripts should be sufficient for our use case.
2020-01-15 08:46:15 +01:00
Damien Arrachequesne
50853738e0 fix: properly decode binary packets
This fixes the previous commit, allowing to properly decode binary packets in the browser (based on
the binaryType attribute).
2020-01-15 00:00:33 +01:00
Damien Arrachequesne
2ae2520a34 chore: point towards the v4 branch 2020-01-14 23:08:07 +01:00
Damien Arrachequesne
eb88094a0e chore: point towards the v4 branch 2020-01-14 23:02:25 +01:00
Damien Arrachequesne
08aff9487f refactor: use prettier to format code 2020-01-14 22:58:35 +01:00
Damien Arrachequesne
f3c291fa61 feat: generateId method can now return a Promise
Related:

- https://github.com/socketio/engine.io/issues/538
- https://github.com/socketio/engine.io/pull/535
2020-01-14 21:58:42 +01:00
Damien Arrachequesne
33564b2391 refactor: use prettier to format code 2020-01-14 21:58:38 +01:00
Damien Arrachequesne
a947ae59a2 feat: remove packet type when encoding binary packets
Only packets of 'message' type can contain binary data, so it makes sense to remove the prefix in
order to avoid the concatenation of the packet type.

Breaking change: the packet containing binary data will now be sent without any transformation

Protocol v3: { type: 'message', data: <Buffer 01 02 03> } => <Buffer 04 01 02 03>
Protocol v4: { type: 'message', data: <Buffer 01 02 03> } => <Buffer 01 02 03>
2020-01-14 21:54:05 +01:00
Damien Arrachequesne
8eb58a689a refactor: remove Object.keys polyfill
This polyfill is now useless, as we do not plan to support IE < 9 anymore.
2020-01-14 21:54:05 +01:00
Damien Arrachequesne
744bf40d4f refactor: migrate to ES6 syntax and use prettier to format code 2020-01-14 13:28:12 +01:00
Damien Arrachequesne
da93fb6ef3 refactor: migrate to ES6 syntax 2020-01-12 22:47:18 +01:00
Damien Arrachequesne
0fcc5417ac refactor: migrate to ES6 syntax 2020-01-10 07:29:26 +01:00
Damien Arrachequesne
11dc4f3a56 chore: migrate to webpack 4
Breaking change: the output bundle will now be found in the dist/ folder.
2020-01-10 07:27:02 +01:00
Damien Arrachequesne
ae23c7ef4c [chore] release 1.1.2 2019-11-25 13:19:48 +01:00
Joway
b9074fa36f [fix] fix memory leak when leave a room after socket close (#58) 2019-11-25 13:14:47 +01:00
Darío Hereñú
f7ab50cc59 [docs] Remove duplicate word (#57) 2019-11-25 13:13:53 +01:00
Damien Arrachequesne
661f1e7fac [chore] Release 2.3.0
Diff: https://github.com/socketio/socket.io-client/compare/2.2.0...2.3.0
2019-09-20 12:22:41 +02:00
Damien Arrachequesne
47161a65d4 [chore] Release 2.3.0
Diff: https://github.com/socketio/socket.io/compare/2.2.0...2.3.0
2.3.0
2019-09-20 12:18:39 +02:00
Damien Arrachequesne
71d7b79965 [chore] Bump engine.io-client to version 3.4.0
Also includes the bump of the debug dependency.

Diff: https://github.com/socketio/engine.io-client/compare/3.3.1...3.4.0
2019-09-20 12:02:21 +02:00
Lukas Drgon
8b4a539e7a [docs] Add CDN link (#1318) 2019-09-20 12:01:51 +02:00
Damien Arrachequesne
40cf185574 [ci] use Node.js 10 for compatibility with Gulp v3
It seems Node.js 12 (which is now 'latest') does not work with Gulp v3. In the future, we will
either have to migrate to Gulp v4, or remove Gulp from the build system.
2019-09-20 11:25:13 +02:00
Damien Arrachequesne
cf39362014 [chore] Bump socket.io-parser to version 3.4.0
Diff: https://github.com/socketio/socket.io-parser/compare/3.3.0...3.4.0
2019-09-20 11:04:11 +02:00
Damien Arrachequesne
652402a856 [chore] Release 3.4.0
The build failure is due to some ES6 usage in the debug dependency, which will have to be fixed
in the future (by using Babel for example).

Diff: https://github.com/socketio/socket.io-parser/compare/3.3.0...3.4.0
2019-09-20 11:00:03 +02:00
Dimitar Nestorov
9b3572ea23 [chore] Bump debug to version 4.1.0 (#92) 2019-09-20 10:51:26 +02:00
flaambe
4d01b2c84c test: remove deprecated Buffer usage (#3481) 2019-09-20 10:50:12 +02:00
Jonatan Juárez
82271921db [docs] Fix the default value of the 'origins' parameter (#3464)
Fix documentation about default origins value. The default should read `*:*` instead of `*
2019-09-20 10:37:54 +02:00
Damien Arrachequesne
1150eb50e9 [chore] Bump engine.io to version 3.4.0
Diff: https://github.com/socketio/engine.io/compare/3.3.1...3.4.0
2019-09-20 10:31:25 +02:00