Commit Graph

8736 Commits

Author SHA1 Message Date
Nitzan Uziely
2c7ad38c75
dgram: support AbortSignal in createSocket
PR-URL: https://github.com/nodejs/node/pull/37026
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-02 10:41:59 +01:00
Mattias Runge-Broberg
75124298d5
readline: add history event and option to set initial history
Add a history event which is emitted when the history has
been changed. This enables persisting of the history in
some way but also to allows a listener to alter the
history. One use-case could be to prevent passwords from
ending up in the history.

A constructor option is also added to allow for setting
an initial history list when creating a Readline interface.

PR-URL: https://github.com/nodejs/node/pull/33662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-02-02 10:41:57 +01:00
Antoine du Hamel
175f6f0be3
fs: use throwIfNoEntry option on statSync calls
PR-URL: https://github.com/nodejs/node/pull/36975
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-02 10:41:57 +01:00
raisinten
4a1fc42178
lib: refactor to use optional chaining in internal/options.js
PR-URL: https://github.com/nodejs/node/pull/36939
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-02 10:41:57 +01:00
ZiJian Liu
ab64d74791
crypto: throw error on invalid object in diffieHellman()
PR-URL: https://github.com/nodejs/node/pull/37016
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-02 10:41:56 +01:00
ZiJian Liu
b533485f32
quic: remove duplicate checks
PR-URL: https://github.com/nodejs/node/pull/37017
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-02 10:41:56 +01:00
Mattias Runge-Broberg
4e757eab96
readline: add support for the AbortController to the question method
In some cases a question asked needs to be canceled. For instance
it might be desirable to cancel a question when a user presses
ctrl+c and triggers the SIGINT event.
Also an initial empty string was set for this.line since the
cursor methods fail if line is not initialized.
Added custom promisify support to the question method.

PR-URL: https://github.com/nodejs/node/pull/33676
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2021-02-02 10:41:55 +01:00
Carlos Fuentes
7b78c6773d
child_process: allow promisified exec to be cancel
Using new AbortController, add support for promisified
exec to be cancelled.

PR-URL: https://github.com/nodejs/node/pull/34249
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-02-02 10:41:55 +01:00
ZiJian Liu
d76400a264
lib: refactor to use validateString
PR-URL: https://github.com/nodejs/node/pull/37006
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-02-02 10:41:55 +01:00
ZiJian Liu
a29da64b46
lib: refactor to use validateNumber
PR-URL: https://github.com/nodejs/node/pull/36993
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-02-02 10:41:55 +01:00
Darshan Sen
97fc7d8396
fs: refactor to remove redundant validation
The function makeCallback already calls validateCallback, so the call
inside copyFile can be removed.

PR-URL: https://github.com/nodejs/node/pull/36984
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-02-02 10:41:55 +01:00
ZiJian Liu
c4cab1f408
lib: refactor to use validateBoolean
PR-URL: https://github.com/nodejs/node/pull/36983
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-02-02 10:41:54 +01:00
James M Snell
53a0bdff47
crypto: experimental (Ed/X)25519/(Ed/X)448 support
Implements initial experimental support for Curve25519 and
Curve448 support for both ECDH and sign/verify in Web Crypto.

Introduced as a Node.js-specific extension to Web Crypto.

Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: https://github.com/nodejs/node/issues/36076

PR-URL: https://github.com/nodejs/node/pull/36879
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2021-02-02 10:41:54 +01:00
ZiJian Liu
8aeba3cb92
lib: refactor to use validateArray
PR-URL: https://github.com/nodejs/node/pull/36982
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-01-24 21:43:39 -05:00
ExE Boss
f2704170a3
util: prefer Reflect.ownKeys(…)
PR-URL: https://github.com/nodejs/node/pull/36740
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-01-24 21:43:37 -05:00
Juan José Arboleda
743dd8f89d
lib: remove non used getter in lib/perf_hooks.js
PR-URL: https://github.com/nodejs/node/pull/36907
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-01-24 21:43:36 -05:00
Ian Storm Taylor
70ee7dce62
http: attach request as res.req
This change makes it possible for userland http-related modules
to pave over edge cases that require referencing the original request
when handling a response--making a "Lodash for HTTP" library possible.
More information and research in https://github.com/nodejs/node/issues/28673

Fixes: https://github.com/nodejs/node/issues/28673

PR-URL: https://github.com/nodejs/node/pull/36505
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2021-01-24 21:43:36 -05:00
Robert Nagy
f07e1c9d03
http: abortIncoming only on socket close
Don't call abortIncombin twice for same socket, i.e. both during
'end' and 'close'.

PR-URL: https://github.com/nodejs/node/pull/36821
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-24 21:43:35 -05:00
James M Snell
775b34b822
buffer: introduce Blob
The `Blob` object is an immutable data buffer. This is a first step
towards alignment with the `Blob` Web API.

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36811
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2021-01-24 21:43:34 -05:00
ZiJian Liu
3f75a60b51
perf_hooks: throw ERR_INVALID_ARG_VALUE if histogram.percentile param is NaN
Fixes: https://github.com/nodejs/node/issues/36936

PR-URL: https://github.com/nodejs/node/pull/36937
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-01-24 21:43:32 -05:00
raisinten
9951daefbd
repl: refactor to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36663
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-24 21:43:32 -05:00
Antoine du Hamel
5290d63e7f
module: simplify tryStatSync with throwIfNoEntry option
PR-URL: https://github.com/nodejs/node/pull/36971
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-24 21:43:32 -05:00
ZiJian Liu
dc596d0607
events: remove error listener on signal abort
Fixes: https://github.com/nodejs/node/issues/36949

PR-URL: https://github.com/nodejs/node/pull/36969
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-01-24 21:43:31 -05:00
Filip Skokan
832cd015d5
buffer: add base64url encoding option
PR-URL: https://github.com/nodejs/node/pull/36952
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-01-21 17:57:33 -05:00
ZiJian Liu
889654d36c
url: align url format behavior with browsers
Fixes: https://github.com/nodejs/node/issues/36887

PR-URL: https://github.com/nodejs/node/pull/36903
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
2021-01-21 17:48:11 -05:00
Antoine du Hamel
f2ac4bb8e2
lib: expose primordials object
Expose the internal `primordials` object to help with Node.js core
development.

```console
$ node --expose-internals -r internal/test/binding lib/fs.js
(node:5299) internal/test/binding: These APIs are for internal testing
only. Do not use them.
(Use `node --trace-warnings ...` to show where the warning was created)
```

PR-URL: https://github.com/nodejs/node/pull/36872
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-21 17:48:10 -05:00
ExE Boss
850d3578b6
lib: refactor primordials.makeSafe to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36865
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-01-21 17:48:10 -05:00
zhangyongsheng
64fed319ef
url: expose urlToHttpOptions utility
PR-URL: https://github.com/nodejs/node/pull/35960
Fixes: https://github.com/nodejs/node/issues/34349
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2021-01-21 17:48:10 -05:00
Robert Nagy
aa7243e3d4
http: refactor ClientRequest destroy
PR-URL: https://github.com/nodejs/node/pull/36863
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2021-01-21 17:48:09 -05:00
Robert Nagy
80051abfcb
http: cleanup ClientRequest oncreate
PR-URL: https://github.com/nodejs/node/pull/36862
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daniele Belardi <dwon.dnl@gmail.com>
2021-01-21 17:48:09 -05:00
Antoine du Hamel
f5b8e7b068
http2: refactor to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36700
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-01-21 17:48:07 -05:00
Mateusz Krawczuk
864b97b24d
tls: use recently added matching SecureContext in default SNICallback
PR-URL: https://github.com/nodejs/node/pull/36072
Fixes: https://github.com/nodejs/node/issues/34110
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-01-21 17:48:05 -05:00
Tobias Nießen
b7d8e61ef1
crypto: fix randomInt bias
Co-authored-by: Andrey Pechkurov <apechkurov@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36894
Refs: https://github.com/nodejs/node/pull/34600
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-21 17:48:05 -05:00
Filip Skokan
1149af6265
crypto: add keyObject.asymmetricKeyDetails for asymmetric keys
This API exposes key details. It is conceptually different from the
previously discussed keyObject.fields property since it does not give
access to information that could compromise the security of the key, and
the obtained information cannot be used to uniquely identify a key.

The intended purpose is to determine "security properties" of keys, e.g.
to generate a new key pair with the same parameters, or to decide
whether a key is secure enough.

closes #30045

PR-URL: https://github.com/nodejs/node/pull/36188
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-01-21 17:48:04 -05:00
Antoine du Hamel
b86c48cc91
lib: refactor source_map to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36733
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-21 17:48:03 -05:00
Antoine du Hamel
403b595ef5
zlib: refactor to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36722
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
2021-01-21 17:48:03 -05:00
Antoine du Hamel
1ef92f61fa
lib: refactor source_map to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36734
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
2021-01-21 17:48:03 -05:00
Antoine du Hamel
0d719476e0
vm: refactor to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36752
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-21 17:48:03 -05:00
Antoine du Hamel
bf695ebdb1
worker: refactor to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36735
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-21 17:48:02 -05:00
raisinten
c4cdf1d830
fs: allow position parameter to be a BigInt in read and readSync
Fixes: https://github.com/nodejs/node/issues/36185

PR-URL: https://github.com/nodejs/node/pull/36190
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-01-21 17:48:02 -05:00
ZiJian Liu
d858c9576a
http: remove dead code from internal/http.js
PR-URL: https://github.com/nodejs/node/pull/36630
Backport-PR-URL: https://github.com/nodejs/node/pull/36890
Refs: https://github.com/nodejs/node/pull/32329
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-01-13 10:12:11 -05:00
ZiJian Liu
7e3ad1be32
Revert "http: remove dead code from internal/http.js"
This reverts commit 9156f430b5.

PR-URL: https://github.com/nodejs/node/pull/36890
Refs: https://github.com/nodejs/node/pull/32329
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
2021-01-13 09:48:44 -05:00
ExE Boss
1db3772c95
lib: simplify primordials.uncurryThis
PR-URL: https://github.com/nodejs/node/pull/36866
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
2021-01-12 17:55:54 -05:00
Guy Bedford
01213c71b9
module: fix Windows folder exports deprecation warning
PR-URL: https://github.com/nodejs/node/pull/36859
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2021-01-12 17:55:53 -05:00
Robert Nagy
a9a2dd32e3
http: don't cork noop .end()
Calling .end() a second time should be a noop and not
leave the socket corked.

Fixes: https://github.com/nodejs/node/issues/36620

PR-URL: https://github.com/nodejs/node/pull/36633
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
2021-01-12 07:11:45 -05:00
Robert Nagy
abae61e230
stream: finished waits for 'close' on OutgoingMessage
Don't invoke finished callback until OutgoingMessagehas
emitted 'close'.

PR-URL: https://github.com/nodejs/node/pull/36648
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-12 07:11:44 -05:00
James M Snell
53cf996270
crypto: implement basic secure heap support
Adds two new command line arguments:

* `--secure-heap=n`, which causes node.js to initialize
  an openssl secure heap of `n` bytes on openssl initialization.
* `--secure-heap-min=n`, which specifies the minimum allocation
  from the secure heap.
* A new method `crypto.secureHeapUsed()` that returns details
  about the total and used secure heap allocation.

The secure heap is an openssl feature that allows certain kinds
of potentially sensitive information (such as private key
BigNums) to be allocated from a dedicated memory area that is
protected against pointer over- and underruns.

The secure heap is a fixed size, so it's important that users
pick a large enough size to cover the crypto operations they
intend to utilize.

The secure heap is disabled by default.

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36779
Refs: https://github.com/nodejs/node/pull/36729
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-12 07:11:43 -05:00
James M Snell
42aca13953
crypto: fixup bug in keygen error handling
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36779
Refs: https://github.com/nodejs/node/pull/36729
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-12 07:11:42 -05:00
Robert Nagy
4c819d65f9
stream: fix .end() error propagation
PR-URL: https://github.com/nodejs/node/pull/36817
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-01-12 07:11:42 -05:00
Antoine du Hamel
c23cca2de9
tls: refactor to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36772
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-01-12 07:11:40 -05:00