Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite as native ES Module using moden JS syntax #1

Merged
merged 59 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
88072ce
build(package): lock file
gr2m Dec 4, 2021
87c7121
build: remove `Makefile`
gr2m Dec 4, 2021
b7a97e1
build: remove `.travis.yml`
gr2m Dec 4, 2021
9cf59a6
build: remove `.npmignore`
gr2m Dec 4, 2021
78a6a57
build: remove `.editorconfig`
gr2m Dec 4, 2021
86cf7b1
build(gitignore): -`/*.tgz`
gr2m Dec 4, 2021
3ffce2e
build(scripts): test script without Makefile
gr2m Dec 4, 2021
eeae2a7
build(deps): `nyc`
gr2m Dec 4, 2021
5dc9c4d
build(package): lock file
gr2m Dec 4, 2021
299ef6b
build(gitignore): `.nyc_output/`
gr2m Dec 4, 2021
b098aea
build(deps): prettier
gr2m Dec 4, 2021
08597f2
build(package): lock file
gr2m Dec 4, 2021
651b7ae
style: prettier
gr2m Dec 4, 2021
c21b504
build(gitignore): `coverage/`
gr2m Dec 4, 2021
627ecbf
build(engines): node 14+
gr2m Dec 4, 2021
77be99f
refactor: remove obosolete code for Node < 14
gr2m Dec 4, 2021
6beb167
test: 100% test coverage
gr2m Dec 4, 2021
3b17b70
fix(deps): -`semver`
gr2m Dec 4, 2021
a380701
fix(deps): -`underscore`
gr2m Dec 4, 2021
8917a24
build(package): lock file
gr2m Dec 4, 2021
71ce3c6
refactor: remove usage of `underscore`
gr2m Dec 4, 2021
9ccf2c6
build(deps): -`mocha`, +`uvu`
gr2m Dec 4, 2021
6748bce
build(deps): -`mocha`, +`uvu`
gr2m Dec 4, 2021
4bcc494
build(package): lock file
gr2m Dec 4, 2021
33bf6c6
refactor: replace `mocha with uvu
gr2m Dec 4, 2021
ca7cfb6
refactor: remove obsolete `net._normalizeConnectArgs`
gr2m Dec 4, 2021
67de0e1
refactor: use `Buffer.from()`
gr2m Dec 4, 2021
a41abdc
refactor: replace `var` with `const` and `let`
gr2m Dec 4, 2021
8ffd11b
refactor: make it a native ES Module
gr2m Dec 4, 2021
0785d59
refactor: use rest spread instead of Array.prototype.slice on arguments
gr2m Dec 4, 2021
cbe84cf
refactor: make Mitm a Class
gr2m Dec 4, 2021
6a897df
refactor: rewrite `lib/socket.js` and `lib/tls_socket.js` using classes
gr2m Dec 5, 2021
667b8cf
ci: test
gr2m Dec 5, 2021
ddfeb90
docs: replace travis badge with actions badge
gr2m Dec 5, 2021
b7a94ba
docs: remove npm badge temporarily
gr2m Dec 5, 2021
546210c
test: remove test_matrix workaround
gr2m Dec 5, 2021
e44fb61
ci(test): run `test` npm script
gr2m Dec 5, 2021
1250c81
docs: add comment to TLSSocket overwrite class
gr2m Dec 5, 2021
52c8e6e
refactor: use classes in `lib/internal_socket.js`
gr2m Dec 5, 2021
726bfe8
build: remove obsolete `test/mocha.opts`
gr2m Dec 5, 2021
67a02bc
refactor: make `Stubs` a class
gr2m Dec 5, 2021
87d79d1
test: add comments to explain why we no longer use `instanceof(tls.TL…
gr2m Dec 5, 2021
bbe8649
build(deps): -`must`
gr2m Dec 5, 2021
3093a05
build(package): lock file
gr2m Dec 5, 2021
760d595
test: replace `must` with `uvu/assert`
gr2m Dec 5, 2021
4a0b720
build(deps): -`nyc`, +`c8`
gr2m Dec 5, 2021
32121c2
build(deps): update `sinon` from v2 to v12
gr2m Dec 5, 2021
ca3eb6b
build(package): lock file
gr2m Dec 5, 2021
f4228bf
test: adapt to `sinon@12`
gr2m Dec 5, 2021
4ac7345
refactor: move all imports from Node-internals into `lib/node_interna…
gr2m Dec 5, 2021
e890739
refactor: add type checks, update some comments
gr2m Dec 5, 2021
b117eb4
build(pkg): add `typecheck` script
gr2m Dec 5, 2021
965065d
build(package): lock file
gr2m Dec 5, 2021
5b64c83
ci: run `typecheck`
gr2m Dec 5, 2021
a2c5c7f
refactor: add some types, rename some variables fro clarity
gr2m Dec 5, 2021
0fc47d4
build: rename module to `mitm-esm`
gr2m Dec 5, 2021
21bd148
build(pkg): set verion to `"0.0.0-development"`
gr2m Dec 5, 2021
6976151
ci: release
gr2m Dec 5, 2021
239d003
test: stop testing in Node 12
gr2m Dec 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .editorconfig

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release
"on":
push:
branches:
- master
- next
- beta
- "*.x"
jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm ci
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test

on:
push:
branches:
- master
- main
- esm-and-other-musings
# renovate/** branches are generated by https://github.com/apps/renovate
- renovate/**

pull_request:
types:
- opened
- synchronize

jobs:
test_matrix:
strategy:
matrix:
node-version:
- 14
- 16
- 17

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- run: git config --global user.name github-actions
- run: git config --global user.email [email protected]
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm test

# separate job to set as required in branch protection,
# as the build names above change each time Node versions change
test:
runs-on: ubuntu-latest
needs: test_matrix
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm run lint
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules/
/*.tgz
.nyc_output/
coverage/
node_modules/
3 changes: 0 additions & 3 deletions .npmignore

This file was deleted.

89 changes: 0 additions & 89 deletions .travis.yml

This file was deleted.

40 changes: 34 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
## 1.7.2 (May 1, 2021)

- Increases the upper-bound on [Underscore.js](https://underscorejs.org) dependency to v1.13 (inclusive).
Thanks, [Martin Caruso](https://github.com/mcaruso85), for the heads-up.

## 1.7.1 (Jun 13, 2020)

- Fixes one test for Node v12.4.
- Fixes the socket "close" event on Node v12.16.3.

## 1.7.0 (Jan 30, 2019)

- Adds compatibility with Node v10.15.1.

## 1.6.0 (Jan 26, 2019)

- Adds compatibility with Node v11.8.

## 1.5.0 (Nov 29, 2018)

- Adds compatibility with Node v11.1.
- Adds compatibility with Node v11.2.

## 1.4.0 (Sep 17, 2018)

- Adds Node v8.12, Node v9 and Node v10 support.
Thanks to [Andreas Lind](https://github.com/papandreou) for help in debugging! Also thanks to him for providing [mitm-papandreou](https://www.npmjs.com/package/mitm-papandreou) while Mitm.js-proper incorporated his fixes.

## 1.3.3 (Sep 16, 2017)

- Fixes `getAsyncId` error on Node v8 when using an `Http.Agent` with the `keepAlive` option.

## 1.3.2 (Nov 10, 2016)

- Adds compatibility with Node v7.
Thanks, [Eric Hacke](https://github.com/ehacke), for the help!

## 1.3.1 (Sep 6, 2016)

- Fixes calling `Socket.prototype.ref` and `Socket.prototype.unref` on the returned client and server sockets.
Thanks, [Vincent Voyer](http://function.fr), for the help!

## 1.3.0 (Aug 17, 2016)

- Adds compatibility with Node v6.4.
Thanks to [Andreas Lind](https://github.com/papandreou)!

## 1.2.1 (Mar 30, 2016)

- Fixes writing to sockets returned by Mitm by postponing writing until the next
tick. Brings it in line with Node's behavior.
Thanks, [Maarten Winter](https://github.com/mwoc), for the help!
Expand All @@ -46,10 +57,12 @@
and given a callback, bind it to `secureConnect` rather than `connect`.

## 1.2.0 (Sep 1, 2015)

- Adds Io.js v3 support. Io.js v2.4.0 worked previously
Thanks, [Vincent Voyer](http://function.fr), for the help!

## 1.1.0 (Apr 25, 2015)

- Returns an instance of `Tls.TLSSocket` from `Tls.connect`.
The returned socket has both `encrypted` and `authorized` set.
Thanks to [Andreas Lind](https://github.com/papandreou) for the initial
Expand All @@ -59,35 +72,43 @@
`encrypted` and `authorized` properties set.

## 1.0.3 (Jan 26, 2015)

- Adds `Mitm.prototype.addListener` to look more like an EventEmitter.
Thanks to [Alex Wolfe](https://github.com/alexkwolfe)!

## 1.0.2 (Nov 23, 2014)

- Fixes tests by locking Mocha to v0.18.
For more info on Mocha's ill-behavior, see
[#1195](https://github.com/mochajs/mocha/issues/1195).

## 1.0.1 (Nov 23, 2014)

- Fixes bypassing TLS connections.
Thanks to [Roman Shtylman](https://github.com/defunctzombie)!

## 1.0.0 (Sep 29, 2014)

- Adds compatibility with Node v0.11.14.

## 0.5.1 (May 28, 2014)

- Fixes `Mitm.prototype.off` to remove bound events with
(`mitm.off("request", listener)`).

## 0.5.0 (May 19, 2014)

- Adds bypass functionality to not intercept a particular outgoing connection
and let it connect as usual.
Let a connection happen by calling `bypass` on the socket object given to the
`connect` event:

```javascript
var mitm = Mitm()
mitm.on("connect", function(socket) { socket.bypass() })
Net.connect({host: "example.org", port: 25})
var mitm = Mitm();
mitm.on("connect", function (socket) {
socket.bypass();
});
Net.connect({ host: "example.org", port: 25 });
```

- Emits `connect` and `connection` on Mitm with the _options_ object given to
Expand All @@ -101,9 +122,11 @@
```

## 0.4.1 (May 4, 2014)

- Adds [Travis CI](https://travis-ci.org) badge to the README.

## 0.4.0 (May 4, 2014)

- Adds support for Node v0.10.24 and up.
- Adds the `connection` event to Mitm to get the remote `Net.Socket`. You can
use this to intercept and test any TCP code.
Expand All @@ -118,22 +141,27 @@
you assert on the content of `POST` requests.

```javascript
var mitm = Mitm()
Http.request({host: "x.org"}).end()
mitm.on("request", function(req) { req.headers.host.must.equal("x.org") })
var mitm = Mitm();
Http.request({ host: "x.org" }).end();
mitm.on("request", function (req) {
req.headers.host.must.equal("x.org");
});
```

- Replaces [Concert.js](https://github.com/moll/js-concert) with Node's
EventEmitter for now as I was not sure the extra features were required.
Remember kids, _if in doubt, leave it out_.

## 0.3.0 (Apr 26, 2014)

- Adds support for calling `Net.connect` with `port` and `host` arguments.

## 0.2.0 (Apr 19, 2014)

- Does not store requests on an instance of `Mitm` any longer.
- Adds `socket` event to `Mitm`.
- Updated to work with Node v0.11.12.

## 0.1.337 (Mar 11, 2014)

- First private release.
36 changes: 0 additions & 36 deletions Makefile

This file was deleted.

Loading