Commit Graph

7693 Commits

Author SHA1 Message Date
Damien Arrachequesne
a883e3238e chore(release): 3.0.2
Diff: https://github.com/socketio/socket.io-client/compare/3.0.1...3.0.2
2020-11-18 00:00:42 +01:00
Damien Arrachequesne
719307801a fix(typings): export withCredentials option
Related: https://github.com/socketio/socket.io-client/issues/1405
2020-11-17 23:54:57 +01:00
Damien Arrachequesne
625d146f28 chore: bump engine.io-client version
Diff: https://github.com/socketio/engine.io-client/compare/4.0.2...4.0.4
2020-11-17 23:54:57 +01:00
Damien Arrachequesne
7b3ec9fad9 fix: add io as named exports
The TypeScript (build/index.d.ts) and ES modules exports did not match,
which caused issues with webpack and ts-loader.

Related: https://github.com/socketio/socket.io-client/issues/1396
2020-11-17 23:54:56 +01:00
Damien Arrachequesne
43705d7a91 fix: merge Engine.IO options
So that the following example:

```js
const io = require('socket.io')({
  pingTimeout: 10000
});

io.listen(3000);
```

behaves the same as:

```js
const io = require('socket.io')(3000, {
  pingTimeout: 10000
});
```

Before this change, the options in the first example were not forwarded
to the Engine.IO constructor, which is not really intuitive.

The previous syntax (which is still valid):

```js
const io = require('socket.io')();

io.listen(3000, {
  pingTimeout: 10000
});
```
2020-11-17 23:33:18 +01:00
Damien Arrachequesne
c2981c6040 chore(release): 4.0.4
Diff: https://github.com/socketio/engine.io/compare/4.0.3...4.0.4
2020-11-17 22:51:56 +01:00
Damien Arrachequesne
118cc686a1 chore: add 3rd party types in the list of dependencies
Those types are mandatory for TypeScript users.

Related:

- https://github.com/socketio/socket.io/issues/3690
- https://github.com/microsoft/types-publisher/issues/81#issuecomment-234051345
2020-11-17 11:55:41 +01:00
Damien Arrachequesne
091a619405 chore(release): 4.0.4
Diff: https://github.com/socketio/engine.io-client/compare/4.0.3...4.0.4
2020-11-17 11:37:29 +01:00
Damien Arrachequesne
1c8cba8818 fix: check the type of the initial packet
Before this fix, the client could mark the polling transport as open
even though the handshake packet was not received properly (for
example, after a parsing error).

This could lead to writes (POST requests) without "sid" query param,
which failed with:

```
{"code":2,"message":"Bad handshake method"}
```

Related:

- https://github.com/socketio/engine.io-client/issues/636
- https://github.com/socketio/socket.io-client/issues/1390
2020-11-17 11:19:07 +01:00
Damien Arrachequesne
4873a237f1 fix: restore the cherry-picking of the WebSocket options
The previous commit ([1]) makes the Engine.IO tests with Node.js SSL
options fail.

[1]: 177b95fe46
2020-11-17 11:15:53 +01:00
Damien Arrachequesne
67ca12c533 chore(release): 4.0.3
Diff: https://github.com/socketio/engine.io/compare/4.0.2...4.0.3
2020-11-17 10:06:52 +01:00
Damien Arrachequesne
c596e54343 docs(examples): update React Native example
This includes `engine.io-client@4.0.3`, which fixes two issues with
React Native.

See also:

- 177b95fe46
- ccb99e3718

[skip ci]
2020-11-17 09:44:05 +01:00
Damien Arrachequesne
8228a43335 chore(release): 4.0.3
Diff: https://github.com/socketio/engine.io-client/compare/4.0.2...4.0.3
2020-11-17 09:25:41 +01:00
Damien Arrachequesne
89cb771cf0 refactor: remove binary handling for the polling transport (bis)
The `supportsBinary` attribute and the `forceBase64` option are kept
untouched, though they are not used by the polling transport, which
now always converts the payloads to base64.

Related: https://github.com/socketio/socket.io-client/issues/1391
2020-11-17 09:19:28 +01:00
Yusuke Sakurai
96cd2c9ae4 fix(typings): export ManagerOptions (#1398) 2020-11-17 00:03:22 +01:00
Damien Arrachequesne
177b95fe46 fix(react-native): exclude the localAddress option
React Native only supports the "headers" option in the WebSocket constructor.

Related: https://github.com/socketio/socket.io-client/issues/1397
2020-11-16 23:17:21 +01:00
Damien Arrachequesne
ccb99e3718 fix(react-native): add a default value for the withCredentials option
The undefined value breaks React Native on Android with a rather cryptic error message:

```
Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue() on a null object reference
```

This bug was introduced by [1].

[1]: 5f47a50ee5

Related: https://github.com/socketio/socket.io-client/issues/1403
2020-11-16 23:17:21 +01:00
Damien Arrachequesne
567231e27a docs: minor fix
Related: https://github.com/socketio/socket.io-client-swift/pull/1309#issuecomment-723518797
2020-11-09 11:31:38 +01:00
Damien Arrachequesne
f7e0009120 docs(examples): update TypeScript example
In order to test 50671d984a

[skip ci]
2020-11-09 10:47:50 +01:00
Damien Arrachequesne
e69d0ad602 chore: bump socket.io-client version 2020-11-09 10:32:10 +01:00
Damien Arrachequesne
0317a077be chore(release): 3.0.1
Diff: https://github.com/socketio/socket.io/compare/3.0.0...3.0.1
3.0.1
2020-11-09 10:27:58 +01:00
Damien Arrachequesne
969d5c95f8 chore(release): 3.0.1
Diff: https://github.com/socketio/socket.io-client/compare/3.0.0...3.0.1
2020-11-09 10:27:33 +01:00
Damien Arrachequesne
ca34eddf4b chore: bump engine.io-client version 2020-11-09 10:23:42 +01:00
Damien Arrachequesne
d00c0c0d9d docs(examples): update examples to Socket.IO v3
Other examples need some additional work (Redis adapter migration, ...).
2020-11-09 10:19:40 +01:00
Damien Arrachequesne
82987d5efb chore: bump engine.io version 2020-11-09 10:12:02 +01:00
Damien Arrachequesne
9ddccf398e chore: bump engine.io-client 2020-11-09 10:11:20 +01:00
Damien Arrachequesne
b6df250c5c chore(release): 4.0.2
Diff: https://github.com/socketio/engine.io-client/compare/4.0.1...4.0.2
2020-11-09 10:03:19 +01:00
Damien Arrachequesne
16fd658274 chore(release): 4.0.2
Diff: https://github.com/socketio/engine.io/compare/4.0.1...4.0.2
2020-11-09 10:03:04 +01:00
Avi Vahl
19ab1e9e4e fix(typings): export Socket and SocketOptions types (#1394)
These were exposed by @types/socket.io-client.
2020-11-09 09:00:07 +01:00
Avi Vahl
f62f180eda fix: export ServerOptions and Namespace types (#3684)
@types/socket.io used to export these.
2020-11-09 08:58:14 +01:00
Damien Arrachequesne
ec3f677e92 refactor: remove binary handling for the polling transport
Since Engine.IO v4, the binary payloads are always encoded as base64
with the polling transport.

See https://github.com/socketio/engine.io-protocol#difference-between-v3-and-v4

Possibly related: https://github.com/socketio/socket.io-client/issues/1391
2020-11-08 02:12:11 +01:00
Andrew Stoker
17b8c2f199 fix: add extension in the package.json main entry (#608)
The `main` entry for the `package.json` file is for defining the entry
point. The entry is currently missing the required `.js` extension,
this PR brings it back.
2020-11-08 02:00:54 +01:00
Damien Arrachequesne
50671d984a fix(typings): update the signature of the emit method
The previous signature was not compatible with EventEmitter.emit(). The typescript compilation threw:

```
node_modules/socket.io/dist/namespace.d.ts(89,5): error TS2416: Property 'emit' in type 'Namespace' is not assignable to the same property in base type 'EventEmitter'.
  Type '(ev: string, ...args: any[]) => Namespace' is not assignable to type '(event: string | symbol, ...args: any[]) => boolean'.
    Type 'Namespace' is not assignable to type 'boolean'.
node_modules/socket.io/dist/socket.d.ts(84,5): error TS2416: Property 'emit' in type 'Socket' is not assignable to the same property in base type 'EventEmitter'.
  Type '(ev: string, ...args: any[]) => this' is not assignable to type '(event: string | symbol, ...args: any[]) => boolean'.
    Type 'this' is not assignable to type 'boolean'.
      Type 'Socket' is not assignable to type 'boolean'.
```

Note: the emit calls cannot be chained anymore:

```js
socket.emit("hello").emit("world"); // will not work anymore
```
2020-11-08 00:07:56 +01:00
Damien Arrachequesne
3add3e1b82 chore: restore package-lock.json file 2020-11-05 22:27:32 +01:00
Damien Arrachequesne
8a69f15437 chore: restore package-lock.json file 2020-11-05 22:25:35 +01:00
Damien Arrachequesne
1af3267e3f chore(release): 3.0.0
Diff: https://github.com/socketio/socket.io/compare/2.3.0...3.0.0
3.0.0
2020-11-05 22:07:47 +01:00
Damien Arrachequesne
b7e07ba633 chore(release): 3.0.0
Diff: https://github.com/socketio/socket.io-client/compare/2.3.1...3.0.0
2020-11-05 22:06:25 +01:00
Damien Arrachequesne
e73271e652 chore(release): 2.0.3
Diff: https://github.com/socketio/socket.io-adapter/compare/1.1.2...2.0.3
2020-11-05 16:19:45 +01:00
Damien Arrachequesne
c04443375f docs: add compatibility table 2020-11-05 16:16:36 +01:00
Damien Arrachequesne
e339323654 chore(release): 4.0.1
Diff: https://github.com/socketio/socket.io-parser/compare/3.4.1...4.0.1
2020-11-05 16:07:35 +01:00
Damien Arrachequesne
b80de070cb docs: describe the 5th revision of the protocol
This revision will be included in Socket.IO v3.
2020-11-05 11:36:59 +01:00
Damien Arrachequesne
02951c4391 chore(release): 3.0.0-rc4
Diff: https://github.com/socketio/socket.io/compare/3.0.0-rc3...3.0.0-rc4
3.0.0-rc4
2020-10-30 23:02:43 +01:00
Damien Arrachequesne
ffa280450d chore(release): 3.0.0-rc4
Diff: https://github.com/socketio/socket.io-client/compare/3.0.0-rc3...3.0.0-rc4
2020-10-30 23:02:06 +01:00
Damien Arrachequesne
09393952e3 feat: emit an Error object upon middleware error
See 54bf4a44e9
2020-10-30 22:54:13 +01:00
Damien Arrachequesne
54bf4a44e9 feat: emit an Error object upon middleware error
This commit restores the ability to send additional data in the
middleware functions, which was removed during the rewrite to
Typescript ([1]).

The only difference with the previous implementation is that the client
will now emit a "connect_error" (previously, "error") event with an
actual Error object, with both the message and an optional "data"
attribute.

```js
// server-side
io.use((socket, next) => {
  const err = new Error("not authorized");
  err.data = { content: "Please retry later" };
  next(err);
});

// client-side
socket.on("connect_error", err => {
  console.log(err.message); // not authorized
  console.log(err.data.content); // Please retry later
});
```

[1]: a5581a9789
2020-10-30 22:52:08 +01:00
Damien Arrachequesne
aa7574f884 feat: serve msgpack bundle
See 71d60480af
2020-10-27 23:17:12 +01:00
Damien Arrachequesne
969debe88c refactor: rework of the Manager events
- rename "connect_error" to "error"
- remove "reconnecting" (duplicate of "reconnect_attempt")

The updated list of events emitted by the Manager:

- open:                successful (re)connection
- error:               (re)connection failure (previously: "connect_error") or error after a successful connection
- close:               disconnection

- ping:                ping packet
- packet:              data packet

- reconnect_attempt:   reconnection attempt (previously: "reconnect_attempt" & "reconnecting")
- reconnect:           successful reconnection
- reconnect_error:     reconnection failure
- reconnect_failed:    reconnection failure after all attempts

For reference, the Socket instance emits the following events:

- connect:             successful connection to a Namespace
- connect_error:       connection failure
- disconnect:          disconnection
2020-10-27 23:07:44 +01:00
Damien Arrachequesne
64056d6616 docs(examples): update TypeScript example 2020-10-27 22:18:07 +01:00
Damien Arrachequesne
cacad7029a chore(release): 3.0.0-rc3
Diff: https://github.com/socketio/socket.io/compare/3.0.0-rc2...3.0.0-rc3
3.0.0-rc3
2020-10-27 00:44:30 +01:00
Damien Arrachequesne
a9127cee83 chore(release): 3.0.0-rc3
Diff: https://github.com/socketio/socket.io-client/compare/3.0.0-rc2...3.0.0-rc3
2020-10-27 00:41:32 +01:00