Commit Graph

217 Commits

Author SHA1 Message Date
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
dependabot[bot]
4952193c04 chore: bump cached-path-relative from 1.0.2 to 1.1.0 (#125)
Bumps [cached-path-relative](https://github.com/ashaffer/cached-path-relative) from 1.0.2 to 1.1.0.
- [Release notes](https://github.com/ashaffer/cached-path-relative/releases)
- [Commits](https://github.com/ashaffer/cached-path-relative/commits)

---
updated-dependencies:
- dependency-name: cached-path-relative
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-17 07:48:15 +01:00
dependabot[bot]
2b70ceee63 chore: bump ajv from 6.12.2 to 6.12.6 (#126)
Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.12.2 to 6.12.6.
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](https://github.com/ajv-validator/ajv/compare/v6.12.2...v6.12.6)

---
updated-dependencies:
- dependency-name: ajv
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-16 21:58:23 +01:00
Damien Arrachequesne
8096c122bb chore(release): 5.0.3
Diff: https://github.com/socketio/engine.io-parser/compare/5.0.2...5.0.3
2022-01-17 10:24:51 +01:00
Damien Arrachequesne
ad5bd7ddf5 refactor: add additional types
Merged from https://github.com/socketio/engine.io/pull/630
2022-01-17 10:23:16 +01:00
Damien Arrachequesne
25a4b2bbf5 chore: replace base64-arraybuffer by @socket.io/base64-arraybuffer
The "base64-arraybuffer" package has been temporarily forked to [1],
until changes are merged upstream.

[1]: https://github.com/socketio/base64-arraybuffer

Related:

- https://github.com/niklasvh/base64-arraybuffer/issues/32
- https://github.com/socketio/socket.io-client/issues/1520
- https://github.com/socketio/socket.io-website/issues/313
- https://github.com/socketio/socket.io/discussions/4209
2022-01-17 10:23:11 +01:00
Damien Arrachequesne
cb26d5cbb6 chore(release): 5.0.2
Diff: https://github.com/socketio/engine.io-parser/compare/5.0.1...5.0.2
2021-11-14 07:26:24 +01:00
Damien Arrachequesne
7e271596c3 fix: add package name in nested package.json
Related: https://github.com/socketio/socket.io-client/issues/1513
2021-11-14 07:23:10 +01:00
Damien Arrachequesne
5f22ed0527 fix: fix vite build for CommonJS users
Related: https://github.com/socketio/socket.io-client/issues/1504
2021-11-14 07:23:10 +01:00
dependabot[bot]
ab84c2d2f3 chore: bump ansi-regex from 5.0.0 to 5.0.1 (#123)
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v5.0.0...v5.0.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-08 06:41:27 +01:00
Damien Arrachequesne
fa6d4f6d84 chore(release): 5.0.1
Diff: https://github.com/socketio/engine.io-parser/compare/5.0.0...5.0.1
2021-10-16 01:23:30 +02:00
Damien Arrachequesne
900346ea34 fix: fix vite build
Some bundlers (like vite) do not support having a "browser" field in a
nested package.json.

Related: https://github.com/socketio/socket.io-client/issues/1504
2021-10-16 01:19:51 +02:00
Damien Arrachequesne
965a567ca0 chore(release): 5.0.0
Diff: https://github.com/socketio/engine.io-parser/compare/4.0.3...5.0.0
2021-10-04 11:02:35 +02:00
Damien Arrachequesne
e4d9fce4d8 chore: migrate to TypeScript
This change introduces an ESM build which will allow tree shaking. A
CJS build is also provided for backward compatibility.
2021-10-01 10:39:52 +02:00
Damien Arrachequesne
78cd3bc7b9 test: remove duplicate test 2021-08-29 08:05:05 +02:00
Damien Arrachequesne
412bcc4298 chore(release): 4.0.3
Diff: https://github.com/socketio/engine.io-parser/compare/4.0.2...4.0.3
2021-08-29 07:55:13 +02:00
Damien Arrachequesne
6d7dd76130 fix: respect the offset and length of TypedArray objects
The parser now returns the TypedArray object instead of the underlying
array buffer, so its offset and length are now taken in account (which
is the behavior of the classic WebSocket implementation).

Notes:

- this was already the case for the Node.js implementation

- in v3, the TypedArray object was always converted to an array buffer
because a byte was added at the beginning ("message" type)

- we could also have used "data.slice().buffer", but it would have
resulted in the copy of the buffer

Related:

- https://github.com/socketio/engine.io-parser/issues/122
- https://github.com/socketio/engine.io-client/issues/677
2021-08-29 07:54:03 +02:00
dependabot[bot]
6dfab6970c chore: bump path-parse from 1.0.6 to 1.0.7 (#120)
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-29 07:53:56 +02:00
dependabot[bot]
8b4dcfc04a chore: bump browserslist from 4.12.0 to 4.16.6 (#119)
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.12.0 to 4.16.6.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.12.0...4.16.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-11 15:39:39 +02:00
dependabot[bot]
6ab8af0e07 chore: bump elliptic from 6.5.3 to 6.5.4 (#117)
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.3 to 6.5.4.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.3...v6.5.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-11 15:39:27 +02:00
dependabot[bot]
129094f7a5 chore: bump y18n from 4.0.0 to 4.0.1 (#118)
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-01 10:41:25 +02:00
Damien Arrachequesne
88799daa22 chore(release): 4.0.2
Diff: https://github.com/socketio/engine.io-parser/compare/4.0.1...4.0.2
2020-12-07 10:13:22 +01:00
Damien Arrachequesne
2ccdeb2779 fix: add base64-arraybuffer as prod dependency
The dependency was previously only listed as dev dependency, so that it
was not included when installing the server (the "engine.io" package,
which does not require it) and was explicitly included by the client
(the "engine.io-client" package, which needs it for the browser build).

But it failed with yarn v2, due to its stricter package boundaries:

> ERROR in ../../../.yarn/cache/engine.io-parser-npm-4.0.1-6bdb879e8a-3b71ef8b5a.zip/node_modules/engine.io-parser/lib/decodePacket.browser.js 7:18-47
> Module not found: Error: engine.io-parser tried to access base64-arraybuffer, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

> Required package: base64-arraybuffer (via "base64-arraybuffer")
> Required by: engine.io-parser@npm:4.0.1 (via xxx/.yarn/cache/engine.io-parser-npm-4.0.1-6bdb879e8a-3b71ef8b5a.zip/node_modules/engine.io-parser/lib/)

Related:

- https://dev.to/arcanis/introducing-yarn-2-4eh1#strict-package-boundaries
- https://github.com/socketio/engine.io-parser/issues/116
2020-12-07 09:53:28 +01:00
Damien Arrachequesne
b26993e51b ci: update configuration for GitHub Actions
The specific cron hour is meant to prevent concurrent usage of the
Sauce Labs account.
2020-12-07 09:50:41 +01:00
Damien Arrachequesne
683fc1dd8e docs: update CI badge
[skip ci]
2020-12-03 16:17:47 +01:00
Damien Arrachequesne
f5bdf6c40d ci: migrate to GitHub Actions
Due to the recent changes to the Travis CI platform (see [1]), we will
now use GitHub Actions to run the tests.

Reference: https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-nodejs

[1]: https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing
2020-12-03 16:05:05 +01:00
Damien Arrachequesne
ea8804eee5 docs(changelog): include changelog for release 2.2.1
Merged from the 2.2.x branch.
2020-09-30 15:31:11 +02:00
Damien Arrachequesne
851c1177fc chore(release): 4.0.1
Diff: https://github.com/socketio/engine.io-parser/compare/4.0.0...4.0.1
2020-09-11 00:49:45 +02:00
Damien Arrachequesne
886f9ea7c4 fix: use a terser-compatible representation of the separator
By default, terser (the mangler used by webpack) will replace the '\x1e'
by an unreadable character in the optimized output.

One solution would be to use the 'ascii_only' option:

```
module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          output: {
            ascii_only: true
          }
        }
      })
    ]
  }
};
```

But it would require anyone who tries to bundle the engine.io client to
use this plugin, so we'll rather use String.fromCharCode().

Note: String.fromCharCode(30) === '\u001e' === '\x1e'
2020-09-11 00:24:56 +02:00
Damien Arrachequesne
01df755d4b docs: update README 2020-09-08 23:30:51 +02:00
Damien Arrachequesne
ebf6e8cd49 chore(release): 4.0.0
Diff: https://github.com/socketio/engine.io-parser/compare/v4.0.0-alpha.1...v4.0.0
2020-09-08 23:15:39 +02:00
Damien Arrachequesne
eb2d8cc4c6 test: add Node.js 14 in the test matrix
Ref: https://github.com/nodejs/Release
2020-09-08 01:31:17 +02:00
Damien Arrachequesne
8edf2d1478 fix: keep track of the buffer initial length
The write buffer is mutable, so its initial length must be saved when
encoding the payload.
2020-09-08 01:30:32 +02:00
Damien Arrachequesne
6efedfa0f3 feat: restore the upgrade mechanism
See 660263fae2
2020-09-08 01:30:32 +02:00
Damien Arrachequesne
66287d919f test: pin the Node.js version for the browser tests
The build fails with Node.js 12. Let's pin the version for now, we'll
investigate later.
2020-09-08 01:30:21 +02:00
dependabot[bot]
373886f195 chore: bump elliptic from 6.5.2 to 6.5.3 (#115)
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-07 13:23:44 +02:00
Damien Arrachequesne
3dd2a0ea41 chore(release): 4.0.0-alpha.1
Diff: https://github.com/socketio/engine.io-parser/compare/v4.0.0-alpha.0...v4.0.0-alpha.1
2020-05-19 15:15:20 +02:00
Damien Arrachequesne
cab7db0404 feat: implement the version 4 of the protocol
See https://github.com/socketio/engine.io-protocol for the list of
changes.

Note: The 'base64-arraybuffer' dependency must now be explicitly
included by the client (not needed by the server).
2020-05-19 15:07:53 +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
7f5a903f91 chore(release): 4.0.0-alpha.0 2020-02-04 12:36:20 +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
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
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
f1ce1abdbb [chore] Release 2.2.0
Diff: https://github.com/socketio/engine.io-parser/compare/2.1.3...2.2.0
2019-09-13 11:06:09 +02:00
Gaubee
47893e1145 [perf] use Buffer.from instead of manually copying the ArrayBuffer (#108)
Ref: https://nodejs.org/docs/latest/api/buffer.html#buffer_class_method_buffer_from_arraybuffer_byteoffset_length
2019-09-13 11:01:01 +02:00