2012-02-27 11:08:02 -08:00
|
|
|
# Crypto
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2017-01-22 19:16:21 -08:00
|
|
|
<!--introduced_in=v0.3.6-->
|
|
|
|
|
2016-07-16 00:35:38 +02:00
|
|
|
> Stability: 2 - Stable
|
2012-03-02 15:14:03 -08:00
|
|
|
|
2020-06-22 13:56:08 -04:00
|
|
|
<!-- source_link=lib/crypto.js -->
|
|
|
|
|
2022-04-20 10:23:41 +02:00
|
|
|
The `node:crypto` module provides cryptographic functionality that includes a
|
|
|
|
set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify
|
|
|
|
functions.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { createHmac } = await import('node:crypto');
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const secret = 'abcdefg';
|
|
|
|
const hash = createHmac('sha256', secret)
|
|
|
|
.update('I love cupcakes')
|
|
|
|
.digest('hex');
|
|
|
|
console.log(hash);
|
|
|
|
// Prints:
|
|
|
|
// c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2023-02-26 18:24:24 +10:30
|
|
|
const { createHmac } = require('node:crypto');
|
2016-01-17 18:39:07 +01:00
|
|
|
|
|
|
|
const secret = 'abcdefg';
|
2023-02-26 18:24:24 +10:30
|
|
|
const hash = createHmac('sha256', secret)
|
|
|
|
.update('I love cupcakes')
|
|
|
|
.digest('hex');
|
2016-01-17 18:39:07 +01:00
|
|
|
console.log(hash);
|
2016-11-08 21:04:57 +01:00
|
|
|
// Prints:
|
|
|
|
// c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2016-03-08 15:31:31 -08:00
|
|
|
## Determining if crypto support is unavailable
|
|
|
|
|
|
|
|
It is possible for Node.js to be built without including support for the
|
2022-04-20 10:23:41 +02:00
|
|
|
`node:crypto` module. In such cases, attempting to `import` from `crypto` or
|
|
|
|
calling `require('node:crypto')` will result in an error being thrown.
|
2016-03-08 15:31:31 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
When using CommonJS, the error thrown can be caught using try/catch:
|
|
|
|
|
2023-11-22 20:03:33 +01:00
|
|
|
<!-- eslint-disable no-global-assign -->
|
2022-02-14 17:14:49 +01:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```cjs
|
2017-01-20 03:42:50 +02:00
|
|
|
let crypto;
|
2016-03-08 15:31:31 -08:00
|
|
|
try {
|
2022-04-20 10:23:41 +02:00
|
|
|
crypto = require('node:crypto');
|
2016-03-08 15:31:31 -08:00
|
|
|
} catch (err) {
|
2022-12-07 03:47:15 +03:00
|
|
|
console.error('crypto support is disabled!');
|
2016-03-08 15:31:31 -08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-11-22 20:03:33 +01:00
|
|
|
<!-- eslint-enable no-global-assign -->
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
When using the lexical ESM `import` keyword, the error can only be
|
|
|
|
caught if a handler for `process.on('uncaughtException')` is registered
|
2022-03-03 20:45:30 +01:00
|
|
|
_before_ any attempt to load the module is made (using, for instance,
|
|
|
|
a preload module).
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
When using ESM, if there is a chance that the code may be run on a build
|
|
|
|
of Node.js where crypto support is not enabled, consider using the
|
2022-04-09 13:41:30 +02:00
|
|
|
[`import()`][] function instead of the lexical `import` keyword:
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
```mjs
|
|
|
|
let crypto;
|
|
|
|
try {
|
2022-04-20 10:23:41 +02:00
|
|
|
crypto = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
} catch (err) {
|
2022-12-07 03:47:15 +03:00
|
|
|
console.error('crypto support is disabled!');
|
2021-03-03 14:25:03 -08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
## Class: `Certificate`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.8
|
|
|
|
-->
|
2012-10-13 01:26:14 +02:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
SPKAC is a Certificate Signing Request mechanism originally implemented by
|
2023-05-27 08:51:13 -07:00
|
|
|
Netscape and was specified formally as part of HTML5's `keygen` element.
|
2018-02-11 20:55:16 +01:00
|
|
|
|
2019-06-20 14:01:15 -06:00
|
|
|
`<keygen>` is deprecated since [HTML 5.2][] and new projects
|
2018-02-11 20:55:16 +01:00
|
|
|
should not use this element anymore.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2022-04-20 10:23:41 +02:00
|
|
|
The `node:crypto` module provides the `Certificate` class for working with SPKAC
|
2015-12-26 20:54:01 -08:00
|
|
|
data. The most common usage is handling output generated by the HTML5
|
|
|
|
`<keygen>` element. Node.js uses [OpenSSL's SPKAC implementation][] internally.
|
|
|
|
|
2021-02-03 11:08:23 +01:00
|
|
|
### Static method: `Certificate.exportChallenge(spkac[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2017-09-06 08:10:34 -07:00
|
|
|
<!-- YAML
|
2017-09-01 09:50:47 -07:00
|
|
|
added: v9.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The spkac argument can be an ArrayBuffer. Limited the size of
|
|
|
|
the spkac argument to a maximum of 2**31 - 1 bytes.
|
2017-09-06 08:10:34 -07:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `spkac` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `encoding` {string} The [encoding][] of the `spkac` string.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer} The challenge component of the `spkac` data structure, which
|
2018-04-06 18:28:20 +03:00
|
|
|
includes a public key and a challenge.
|
2017-09-06 08:10:34 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
const challenge = Certificate.exportChallenge(spkac);
|
|
|
|
console.log(challenge.toString('utf8'));
|
|
|
|
// Prints: the challenge as a UTF8 string
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = require('node:crypto');
|
2017-09-06 08:10:34 -07:00
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
const challenge = Certificate.exportChallenge(spkac);
|
|
|
|
console.log(challenge.toString('utf8'));
|
|
|
|
// Prints: the challenge as a UTF8 string
|
|
|
|
```
|
|
|
|
|
2021-02-03 11:08:23 +01:00
|
|
|
### Static method: `Certificate.exportPublicKey(spkac[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2017-09-06 08:10:34 -07:00
|
|
|
<!-- YAML
|
2017-09-01 09:50:47 -07:00
|
|
|
added: v9.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The spkac argument can be an ArrayBuffer. Limited the size of
|
|
|
|
the spkac argument to a maximum of 2**31 - 1 bytes.
|
2017-09-06 08:10:34 -07:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `spkac` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the `spkac` string.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer} The public key component of the `spkac` data structure,
|
2018-04-06 18:28:20 +03:00
|
|
|
which includes a public key and a challenge.
|
2017-09-06 08:10:34 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
const publicKey = Certificate.exportPublicKey(spkac);
|
|
|
|
console.log(publicKey);
|
|
|
|
// Prints: the public key as <Buffer ...>
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = require('node:crypto');
|
2017-09-06 08:10:34 -07:00
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
const publicKey = Certificate.exportPublicKey(spkac);
|
|
|
|
console.log(publicKey);
|
|
|
|
// Prints: the public key as <Buffer ...>
|
|
|
|
```
|
|
|
|
|
2021-02-03 11:08:23 +01:00
|
|
|
### Static method: `Certificate.verifySpkac(spkac[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2017-09-06 08:10:34 -07:00
|
|
|
<!-- YAML
|
2017-09-01 09:50:47 -07:00
|
|
|
added: v9.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The spkac argument can be an ArrayBuffer. Added encoding.
|
|
|
|
Limited the size of the spkac argument to a maximum of
|
|
|
|
2**31 - 1 bytes.
|
2017-09-06 08:10:34 -07:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `spkac` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `encoding` {string} The [encoding][] of the `spkac` string.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {boolean} `true` if the given `spkac` data structure is valid,
|
2018-04-06 18:28:20 +03:00
|
|
|
`false` otherwise.
|
2017-09-06 08:10:34 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
|
|
|
const { Certificate } = await import('node:crypto');
|
2021-06-15 10:09:29 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
console.log(Certificate.verifySpkac(Buffer.from(spkac)));
|
|
|
|
// Prints: true or false
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Buffer } = require('node:buffer');
|
2023-02-26 18:24:59 +10:30
|
|
|
const { Certificate } = require('node:crypto');
|
2021-06-15 10:09:29 -07:00
|
|
|
|
2017-09-06 08:10:34 -07:00
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
console.log(Certificate.verifySpkac(Buffer.from(spkac)));
|
|
|
|
// Prints: true or false
|
|
|
|
```
|
|
|
|
|
|
|
|
### Legacy API
|
|
|
|
|
2020-08-16 09:54:27 -07:00
|
|
|
> Stability: 0 - Deprecated
|
|
|
|
|
|
|
|
As a legacy interface, it is possible to create new instances of
|
2020-08-09 14:29:00 -07:00
|
|
|
the `crypto.Certificate` class as illustrated in the examples below.
|
2017-09-06 08:10:34 -07:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
#### `new crypto.Certificate()`
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
Instances of the `Certificate` class can be created using the `new` keyword
|
|
|
|
or by calling `crypto.Certificate()` as a function:
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const cert1 = new Certificate();
|
|
|
|
const cert2 = Certificate();
|
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const cert1 = new Certificate();
|
|
|
|
const cert2 = Certificate();
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2012-10-13 01:26:14 +02:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
#### `certificate.exportChallenge(spkac[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.8
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `spkac` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `encoding` {string} The [encoding][] of the `spkac` string.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer} The challenge component of the `spkac` data structure, which
|
2018-04-06 18:28:20 +03:00
|
|
|
includes a public key and a challenge.
|
2012-10-13 01:26:14 +02:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
const cert = Certificate();
|
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
const challenge = cert.exportChallenge(spkac);
|
|
|
|
console.log(challenge.toString('utf8'));
|
|
|
|
// Prints: the challenge as a UTF8 string
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
const cert = Certificate();
|
2016-01-17 18:39:07 +01:00
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
const challenge = cert.exportChallenge(spkac);
|
|
|
|
console.log(challenge.toString('utf8'));
|
2016-11-08 21:04:57 +01:00
|
|
|
// Prints: the challenge as a UTF8 string
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2012-10-13 01:26:14 +02:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
#### `certificate.exportPublicKey(spkac[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.8
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `spkac` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `encoding` {string} The [encoding][] of the `spkac` string.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer} The public key component of the `spkac` data structure,
|
2018-04-06 18:28:20 +03:00
|
|
|
which includes a public key and a challenge.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
const cert = Certificate();
|
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
const publicKey = cert.exportPublicKey(spkac);
|
|
|
|
console.log(publicKey);
|
|
|
|
// Prints: the public key as <Buffer ...>
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Certificate } = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
const cert = Certificate();
|
2016-01-17 18:39:07 +01:00
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
const publicKey = cert.exportPublicKey(spkac);
|
|
|
|
console.log(publicKey);
|
2016-11-08 21:04:57 +01:00
|
|
|
// Prints: the public key as <Buffer ...>
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2012-10-13 02:44:11 +02:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
#### `certificate.verifySpkac(spkac[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.8
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `spkac` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `encoding` {string} The [encoding][] of the `spkac` string.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {boolean} `true` if the given `spkac` data structure is valid,
|
2018-04-06 18:28:20 +03:00
|
|
|
`false` otherwise.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
|
|
|
const { Certificate } = await import('node:crypto');
|
2021-06-15 10:09:29 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const cert = Certificate();
|
|
|
|
const spkac = getSpkacSomehow();
|
|
|
|
console.log(cert.verifySpkac(Buffer.from(spkac)));
|
|
|
|
// Prints: true or false
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Buffer } = require('node:buffer');
|
2023-02-26 18:24:59 +10:30
|
|
|
const { Certificate } = require('node:crypto');
|
2021-06-15 10:09:29 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const cert = Certificate();
|
2016-01-17 18:39:07 +01:00
|
|
|
const spkac = getSpkacSomehow();
|
2016-04-25 10:36:57 +08:00
|
|
|
console.log(cert.verifySpkac(Buffer.from(spkac)));
|
2016-11-08 21:04:57 +01:00
|
|
|
// Prints: true or false
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2012-10-13 02:44:11 +02:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
## Class: `Cipheriv`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
|
|
|
-->
|
2012-10-13 02:44:11 +02:00
|
|
|
|
2019-08-24 18:16:48 -07:00
|
|
|
* Extends: {stream.Transform}
|
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Instances of the `Cipheriv` class are used to encrypt data. The class can be
|
2015-12-26 20:54:01 -08:00
|
|
|
used in one of two ways:
|
2012-10-13 02:44:11 +02:00
|
|
|
|
2019-09-13 00:22:29 -04:00
|
|
|
* As a [stream][] that is both readable and writable, where plain unencrypted
|
2015-12-26 20:54:01 -08:00
|
|
|
data is written to produce encrypted data on the readable side, or
|
2019-09-13 00:22:29 -04:00
|
|
|
* Using the [`cipher.update()`][] and [`cipher.final()`][] methods to produce
|
2016-02-15 03:40:53 +03:00
|
|
|
the encrypted data.
|
2015-06-08 12:26:16 -04:00
|
|
|
|
2023-12-15 22:00:52 +08:00
|
|
|
The [`crypto.createCipheriv()`][] method is
|
2025-03-01 16:25:58 -08:00
|
|
|
used to create `Cipheriv` instances. `Cipheriv` objects are not to be created
|
2016-02-15 03:40:53 +03:00
|
|
|
directly using the `new` keyword.
|
2015-06-08 12:26:16 -04:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Example: Using `Cipheriv` objects as streams:
|
2015-06-08 12:26:16 -04:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
|
|
|
scrypt,
|
|
|
|
randomFill,
|
2022-11-17 08:19:12 -05:00
|
|
|
createCipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2018-11-05 20:55:47 +05:30
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
// First, we'll generate the key. The key length is dependent on the algorithm.
|
|
|
|
// In this case for aes192, it is 24 bytes (192 bits).
|
2021-03-03 14:25:03 -08:00
|
|
|
scrypt(password, 'salt', 24, (err, key) => {
|
2020-08-25 10:05:51 -07:00
|
|
|
if (err) throw err;
|
|
|
|
// Then, we'll generate a random initialization vector
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(new Uint8Array(16), (err, iv) => {
|
2020-08-25 10:05:51 -07:00
|
|
|
if (err) throw err;
|
|
|
|
|
|
|
|
// Once we have the key and iv, we can create and use the cipher...
|
2021-03-03 14:25:03 -08:00
|
|
|
const cipher = createCipheriv(algorithm, key, iv);
|
|
|
|
|
|
|
|
let encrypted = '';
|
|
|
|
cipher.setEncoding('hex');
|
|
|
|
|
|
|
|
cipher.on('data', (chunk) => encrypted += chunk);
|
|
|
|
cipher.on('end', () => console.log(encrypted));
|
|
|
|
|
|
|
|
cipher.write('some clear text data');
|
|
|
|
cipher.end();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
scrypt,
|
|
|
|
randomFill,
|
2022-11-17 08:19:12 -05:00
|
|
|
createCipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
|
|
|
|
// First, we'll generate the key. The key length is dependent on the algorithm.
|
|
|
|
// In this case for aes192, it is 24 bytes (192 bits).
|
|
|
|
scrypt(password, 'salt', 24, (err, key) => {
|
|
|
|
if (err) throw err;
|
|
|
|
// Then, we'll generate a random initialization vector
|
|
|
|
randomFill(new Uint8Array(16), (err, iv) => {
|
|
|
|
if (err) throw err;
|
|
|
|
|
|
|
|
// Once we have the key and iv, we can create and use the cipher...
|
|
|
|
const cipher = createCipheriv(algorithm, key, iv);
|
2015-06-08 12:26:16 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
let encrypted = '';
|
|
|
|
cipher.setEncoding('hex');
|
2015-06-08 12:26:16 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
cipher.on('data', (chunk) => encrypted += chunk);
|
|
|
|
cipher.on('end', () => console.log(encrypted));
|
|
|
|
|
|
|
|
cipher.write('some clear text data');
|
|
|
|
cipher.end();
|
|
|
|
});
|
|
|
|
});
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Example: Using `Cipheriv` and piped streams:
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
import {
|
|
|
|
createReadStream,
|
|
|
|
createWriteStream,
|
2022-07-30 17:11:50 +02:00
|
|
|
} from 'node:fs';
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
import {
|
2022-11-17 08:19:12 -05:00
|
|
|
pipeline,
|
2022-07-30 17:11:50 +02:00
|
|
|
} from 'node:stream';
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const {
|
|
|
|
scrypt,
|
|
|
|
randomFill,
|
2022-11-17 08:19:12 -05:00
|
|
|
createCipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2018-11-05 20:55:47 +05:30
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
// First, we'll generate the key. The key length is dependent on the algorithm.
|
|
|
|
// In this case for aes192, it is 24 bytes (192 bits).
|
2021-03-03 14:25:03 -08:00
|
|
|
scrypt(password, 'salt', 24, (err, key) => {
|
2020-08-25 10:05:51 -07:00
|
|
|
if (err) throw err;
|
|
|
|
// Then, we'll generate a random initialization vector
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(new Uint8Array(16), (err, iv) => {
|
2020-08-25 10:05:51 -07:00
|
|
|
if (err) throw err;
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const cipher = createCipheriv(algorithm, key, iv);
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const input = createReadStream('test.js');
|
|
|
|
const output = createWriteStream('test.enc');
|
|
|
|
|
|
|
|
pipeline(input, cipher, output, (err) => {
|
|
|
|
if (err) throw err;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createReadStream,
|
|
|
|
createWriteStream,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:fs');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
pipeline,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:stream');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const {
|
|
|
|
scrypt,
|
|
|
|
randomFill,
|
|
|
|
createCipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
|
|
|
|
// First, we'll generate the key. The key length is dependent on the algorithm.
|
|
|
|
// In this case for aes192, it is 24 bytes (192 bits).
|
|
|
|
scrypt(password, 'salt', 24, (err, key) => {
|
|
|
|
if (err) throw err;
|
|
|
|
// Then, we'll generate a random initialization vector
|
|
|
|
randomFill(new Uint8Array(16), (err, iv) => {
|
|
|
|
if (err) throw err;
|
|
|
|
|
|
|
|
const cipher = createCipheriv(algorithm, key, iv);
|
|
|
|
|
|
|
|
const input = createReadStream('test.js');
|
|
|
|
const output = createWriteStream('test.enc');
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
pipeline(input, cipher, output, (err) => {
|
|
|
|
if (err) throw err;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-02-15 03:40:53 +03:00
|
|
|
Example: Using the [`cipher.update()`][] and [`cipher.final()`][] methods:
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
|
|
|
scrypt,
|
|
|
|
randomFill,
|
2022-11-17 08:19:12 -05:00
|
|
|
createCipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
|
|
|
|
// First, we'll generate the key. The key length is dependent on the algorithm.
|
|
|
|
// In this case for aes192, it is 24 bytes (192 bits).
|
|
|
|
scrypt(password, 'salt', 24, (err, key) => {
|
|
|
|
if (err) throw err;
|
|
|
|
// Then, we'll generate a random initialization vector
|
|
|
|
randomFill(new Uint8Array(16), (err, iv) => {
|
|
|
|
if (err) throw err;
|
|
|
|
|
|
|
|
const cipher = createCipheriv(algorithm, key, iv);
|
|
|
|
|
|
|
|
let encrypted = cipher.update('some clear text data', 'utf8', 'hex');
|
|
|
|
encrypted += cipher.final('hex');
|
|
|
|
console.log(encrypted);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
scrypt,
|
|
|
|
randomFill,
|
|
|
|
createCipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2018-11-05 20:55:47 +05:30
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
// First, we'll generate the key. The key length is dependent on the algorithm.
|
|
|
|
// In this case for aes192, it is 24 bytes (192 bits).
|
2021-03-03 14:25:03 -08:00
|
|
|
scrypt(password, 'salt', 24, (err, key) => {
|
2020-08-25 10:05:51 -07:00
|
|
|
if (err) throw err;
|
|
|
|
// Then, we'll generate a random initialization vector
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(new Uint8Array(16), (err, iv) => {
|
2020-08-25 10:05:51 -07:00
|
|
|
if (err) throw err;
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const cipher = createCipheriv(algorithm, key, iv);
|
2020-08-25 10:05:51 -07:00
|
|
|
|
|
|
|
let encrypted = cipher.update('some clear text data', 'utf8', 'hex');
|
|
|
|
encrypted += cipher.final('hex');
|
|
|
|
console.log(encrypted);
|
|
|
|
});
|
|
|
|
});
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `cipher.final([outputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `outputEncoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string} Any remaining enciphered contents.
|
2018-11-07 12:27:47 -08:00
|
|
|
If `outputEncoding` is specified, a string is
|
2018-04-11 15:15:25 +02:00
|
|
|
returned. If an `outputEncoding` is not provided, a [`Buffer`][] is returned.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Once the `cipher.final()` method has been called, the `Cipheriv` object can no
|
2015-12-26 20:54:01 -08:00
|
|
|
longer be used to encrypt data. Attempts to call `cipher.final()` more than
|
|
|
|
once will result in an error being thrown.
|
2014-06-25 14:11:09 +04:00
|
|
|
|
2021-02-20 05:18:19 -08:00
|
|
|
### `cipher.getAuthTag()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-02-20 05:18:19 -08:00
|
|
|
<!-- YAML
|
|
|
|
added: v1.0.0
|
|
|
|
-->
|
|
|
|
|
2022-02-06 18:57:53 +01:00
|
|
|
* Returns: {Buffer} When using an authenticated encryption mode (`GCM`, `CCM`,
|
2022-03-21 17:41:39 +01:00
|
|
|
`OCB`, and `chacha20-poly1305` are currently supported), the
|
|
|
|
`cipher.getAuthTag()` method returns a
|
2021-02-20 05:18:19 -08:00
|
|
|
[`Buffer`][] containing the _authentication tag_ that has been computed from
|
|
|
|
the given data.
|
|
|
|
|
|
|
|
The `cipher.getAuthTag()` method should only be called after encryption has
|
|
|
|
been completed using the [`cipher.final()`][] method.
|
|
|
|
|
2021-11-03 17:14:55 +01:00
|
|
|
If the `authTagLength` option was set during the `cipher` instance's creation,
|
|
|
|
this function will return exactly `authTagLength` bytes.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `cipher.setAAD(buffer[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v1.0.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `buffer` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* `options` {Object} [`stream.transform` options][]
|
2019-09-13 00:22:29 -04:00
|
|
|
* `plaintextLength` {number}
|
2020-08-25 10:05:51 -07:00
|
|
|
* `encoding` {string} The string encoding to use when `buffer` is a string.
|
2025-03-01 16:25:58 -08:00
|
|
|
* Returns: {Cipheriv} The same `Cipheriv` instance for method chaining.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2022-03-21 17:41:39 +01:00
|
|
|
When using an authenticated encryption mode (`GCM`, `CCM`, `OCB`, and
|
|
|
|
`chacha20-poly1305` are
|
2018-06-14 15:18:14 +02:00
|
|
|
currently supported), the `cipher.setAAD()` method sets the value used for the
|
2015-12-26 20:54:01 -08:00
|
|
|
_additional authenticated data_ (AAD) input parameter.
|
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
The `plaintextLength` option is optional for `GCM` and `OCB`. When using `CCM`,
|
|
|
|
the `plaintextLength` option must be specified and its value must match the
|
|
|
|
length of the plaintext in bytes. See [CCM mode][].
|
2017-12-18 13:22:08 +01:00
|
|
|
|
2016-11-01 23:02:20 +03:00
|
|
|
The `cipher.setAAD()` method must be called before [`cipher.update()`][].
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `cipher.setAutoPadding([autoPadding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.1
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `autoPadding` {boolean} **Default:** `true`
|
2025-03-01 16:25:58 -08:00
|
|
|
* Returns: {Cipheriv} The same `Cipheriv` instance for method chaining.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
When using block encryption algorithms, the `Cipheriv` class will automatically
|
2015-12-26 20:54:01 -08:00
|
|
|
add padding to the input data to the appropriate block size. To disable the
|
|
|
|
default padding call `cipher.setAutoPadding(false)`.
|
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
When `autoPadding` is `false`, the length of the entire input data must be a
|
2018-04-29 20:46:41 +03:00
|
|
|
multiple of the cipher's block size or [`cipher.final()`][] will throw an error.
|
2015-12-26 20:54:01 -08:00
|
|
|
Disabling automatic padding is useful for non-standard padding, for instance
|
|
|
|
using `0x0` instead of PKCS padding.
|
|
|
|
|
2016-11-01 23:02:20 +03:00
|
|
|
The `cipher.setAutoPadding()` method must be called before
|
|
|
|
[`cipher.final()`][].
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `cipher.update(data[, inputEncoding][, outputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
2017-06-06 11:00:32 +02:00
|
|
|
description: The default `inputEncoding` changed from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `data` {string|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `inputEncoding` {string} The [encoding][] of the data.
|
|
|
|
* `outputEncoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
Updates the cipher with `data`. If the `inputEncoding` argument is given,
|
2018-11-07 12:27:47 -08:00
|
|
|
the `data`
|
2017-06-06 11:00:32 +02:00
|
|
|
argument is a string using the specified encoding. If the `inputEncoding`
|
2017-04-04 15:59:30 -07:00
|
|
|
argument is not given, `data` must be a [`Buffer`][], `TypedArray`, or
|
2018-04-02 08:38:48 +03:00
|
|
|
`DataView`. If `data` is a [`Buffer`][], `TypedArray`, or `DataView`, then
|
2017-06-06 11:00:32 +02:00
|
|
|
`inputEncoding` is ignored.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
The `outputEncoding` specifies the output format of the enciphered
|
2018-11-07 12:27:47 -08:00
|
|
|
data. If the `outputEncoding`
|
2015-12-26 20:54:01 -08:00
|
|
|
is specified, a string using the specified encoding is returned. If no
|
2017-06-06 11:00:32 +02:00
|
|
|
`outputEncoding` is provided, a [`Buffer`][] is returned.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `cipher.update()` method can be called multiple times with new data until
|
2016-02-15 03:40:53 +03:00
|
|
|
[`cipher.final()`][] is called. Calling `cipher.update()` after
|
|
|
|
[`cipher.final()`][] will result in an error being thrown.
|
2011-04-03 01:09:00 -07:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
## Class: `Decipheriv`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
|
|
|
-->
|
2011-04-03 01:09:00 -07:00
|
|
|
|
2019-08-24 18:16:48 -07:00
|
|
|
* Extends: {stream.Transform}
|
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Instances of the `Decipheriv` class are used to decrypt data. The class can be
|
2015-12-26 20:54:01 -08:00
|
|
|
used in one of two ways:
|
|
|
|
|
2019-09-13 00:22:29 -04:00
|
|
|
* As a [stream][] that is both readable and writable, where plain encrypted
|
2015-12-26 20:54:01 -08:00
|
|
|
data is written to produce unencrypted data on the readable side, or
|
2019-09-13 00:22:29 -04:00
|
|
|
* Using the [`decipher.update()`][] and [`decipher.final()`][] methods to
|
2016-02-15 03:40:53 +03:00
|
|
|
produce the unencrypted data.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2023-12-15 22:00:52 +08:00
|
|
|
The [`crypto.createDecipheriv()`][] method is
|
2025-03-01 16:25:58 -08:00
|
|
|
used to create `Decipheriv` instances. `Decipheriv` objects are not to be created
|
2015-12-26 20:54:01 -08:00
|
|
|
directly using the `new` keyword.
|
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Example: Using `Decipheriv` objects as streams:
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
scryptSync,
|
2022-11-17 08:19:12 -05:00
|
|
|
createDecipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2018-11-05 20:55:47 +05:30
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
// Key length is dependent on the algorithm. In this case for aes192, it is
|
|
|
|
// 24 bytes (192 bits).
|
|
|
|
// Use the async `crypto.scrypt()` instead.
|
2021-03-03 14:25:03 -08:00
|
|
|
const key = scryptSync(password, 'salt', 24);
|
2018-11-05 20:55:47 +05:30
|
|
|
// The IV is usually passed along with the ciphertext.
|
|
|
|
const iv = Buffer.alloc(16, 0); // Initialization vector.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const decipher = createDecipheriv(algorithm, key, iv);
|
|
|
|
|
|
|
|
let decrypted = '';
|
|
|
|
decipher.on('readable', () => {
|
2022-07-30 17:11:50 +02:00
|
|
|
let chunk;
|
2021-03-03 14:25:03 -08:00
|
|
|
while (null !== (chunk = decipher.read())) {
|
|
|
|
decrypted += chunk.toString('utf8');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
decipher.on('end', () => {
|
|
|
|
console.log(decrypted);
|
|
|
|
// Prints: some clear text data
|
|
|
|
});
|
|
|
|
|
|
|
|
// Encrypted with same algorithm, key and iv.
|
|
|
|
const encrypted =
|
|
|
|
'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';
|
|
|
|
decipher.write(encrypted, 'hex');
|
|
|
|
decipher.end();
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
scryptSync,
|
|
|
|
createDecipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
// Key length is dependent on the algorithm. In this case for aes192, it is
|
|
|
|
// 24 bytes (192 bits).
|
|
|
|
// Use the async `crypto.scrypt()` instead.
|
|
|
|
const key = scryptSync(password, 'salt', 24);
|
|
|
|
// The IV is usually passed along with the ciphertext.
|
|
|
|
const iv = Buffer.alloc(16, 0); // Initialization vector.
|
|
|
|
|
|
|
|
const decipher = createDecipheriv(algorithm, key, iv);
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2017-01-20 03:42:50 +02:00
|
|
|
let decrypted = '';
|
2016-01-17 18:39:07 +01:00
|
|
|
decipher.on('readable', () => {
|
2022-07-30 17:11:50 +02:00
|
|
|
let chunk;
|
2019-01-07 15:37:34 +01:00
|
|
|
while (null !== (chunk = decipher.read())) {
|
|
|
|
decrypted += chunk.toString('utf8');
|
|
|
|
}
|
2016-01-22 12:04:39 +10:00
|
|
|
});
|
|
|
|
decipher.on('end', () => {
|
|
|
|
console.log(decrypted);
|
|
|
|
// Prints: some clear text data
|
2016-01-17 18:39:07 +01:00
|
|
|
});
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2018-11-05 20:55:47 +05:30
|
|
|
// Encrypted with same algorithm, key and iv.
|
2017-04-21 17:38:31 +03:00
|
|
|
const encrypted =
|
2018-11-05 20:55:47 +05:30
|
|
|
'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';
|
2016-01-22 12:04:39 +10:00
|
|
|
decipher.write(encrypted, 'hex');
|
2016-01-17 18:39:07 +01:00
|
|
|
decipher.end();
|
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Example: Using `Decipheriv` and piped streams:
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
import {
|
|
|
|
createReadStream,
|
|
|
|
createWriteStream,
|
2022-07-30 17:11:50 +02:00
|
|
|
} from 'node:fs';
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
scryptSync,
|
2022-11-17 08:19:12 -05:00
|
|
|
createDecipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2018-11-05 20:55:47 +05:30
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
// Use the async `crypto.scrypt()` instead.
|
2021-03-03 14:25:03 -08:00
|
|
|
const key = scryptSync(password, 'salt', 24);
|
2018-11-05 20:55:47 +05:30
|
|
|
// The IV is usually passed along with the ciphertext.
|
|
|
|
const iv = Buffer.alloc(16, 0); // Initialization vector.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const decipher = createDecipheriv(algorithm, key, iv);
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const input = createReadStream('test.enc');
|
|
|
|
const output = createWriteStream('test.js');
|
|
|
|
|
|
|
|
input.pipe(decipher).pipe(output);
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createReadStream,
|
|
|
|
createWriteStream,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:fs');
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
scryptSync,
|
|
|
|
createDecipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
// Use the async `crypto.scrypt()` instead.
|
|
|
|
const key = scryptSync(password, 'salt', 24);
|
|
|
|
// The IV is usually passed along with the ciphertext.
|
|
|
|
const iv = Buffer.alloc(16, 0); // Initialization vector.
|
|
|
|
|
|
|
|
const decipher = createDecipheriv(algorithm, key, iv);
|
|
|
|
|
|
|
|
const input = createReadStream('test.enc');
|
|
|
|
const output = createWriteStream('test.js');
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
input.pipe(decipher).pipe(output);
|
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-02-15 03:40:53 +03:00
|
|
|
Example: Using the [`decipher.update()`][] and [`decipher.final()`][] methods:
|
2011-04-03 01:09:00 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
scryptSync,
|
2022-11-17 08:19:12 -05:00
|
|
|
createDecipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2011-04-03 01:09:00 -07:00
|
|
|
|
2018-11-05 20:55:47 +05:30
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
// Use the async `crypto.scrypt()` instead.
|
2021-03-03 14:25:03 -08:00
|
|
|
const key = scryptSync(password, 'salt', 24);
|
2018-11-05 20:55:47 +05:30
|
|
|
// The IV is usually passed along with the ciphertext.
|
|
|
|
const iv = Buffer.alloc(16, 0); // Initialization vector.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const decipher = createDecipheriv(algorithm, key, iv);
|
|
|
|
|
|
|
|
// Encrypted using same algorithm, key and iv.
|
|
|
|
const encrypted =
|
|
|
|
'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';
|
|
|
|
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
|
|
|
|
decrypted += decipher.final('utf8');
|
|
|
|
console.log(decrypted);
|
|
|
|
// Prints: some clear text data
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
scryptSync,
|
|
|
|
createDecipheriv,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const algorithm = 'aes-192-cbc';
|
|
|
|
const password = 'Password used to generate key';
|
|
|
|
// Use the async `crypto.scrypt()` instead.
|
|
|
|
const key = scryptSync(password, 'salt', 24);
|
|
|
|
// The IV is usually passed along with the ciphertext.
|
|
|
|
const iv = Buffer.alloc(16, 0); // Initialization vector.
|
|
|
|
|
|
|
|
const decipher = createDecipheriv(algorithm, key, iv);
|
2018-11-05 20:55:47 +05:30
|
|
|
|
|
|
|
// Encrypted using same algorithm, key and iv.
|
2017-04-21 17:38:31 +03:00
|
|
|
const encrypted =
|
2018-11-05 20:55:47 +05:30
|
|
|
'e5f79c5915c02171eec6b212d5520d44480993d7d622a7c4c2da32f6efda0ffa';
|
2017-01-20 03:42:50 +02:00
|
|
|
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
|
2016-01-22 12:04:39 +10:00
|
|
|
decrypted += decipher.final('utf8');
|
|
|
|
console.log(decrypted);
|
2016-11-08 21:04:57 +01:00
|
|
|
// Prints: some clear text data
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2011-04-03 01:09:00 -07:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `decipher.final([outputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `outputEncoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string} Any remaining deciphered contents.
|
2018-11-07 12:27:47 -08:00
|
|
|
If `outputEncoding` is specified, a string is
|
2018-04-11 15:15:25 +02:00
|
|
|
returned. If an `outputEncoding` is not provided, a [`Buffer`][] is returned.
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Once the `decipher.final()` method has been called, the `Decipheriv` object can
|
2015-12-26 20:54:01 -08:00
|
|
|
no longer be used to decrypt data. Attempts to call `decipher.final()` more
|
|
|
|
than once will result in an error being thrown.
|
2012-10-30 15:46:43 -07:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `decipher.setAAD(buffer[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v1.0.0
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
2020-10-01 20:35:23 +02:00
|
|
|
description: The buffer argument can be a string or ArrayBuffer and is
|
2020-08-25 10:05:51 -07:00
|
|
|
limited to no more than 2 ** 31 - 1 bytes.
|
2017-02-21 23:38:44 +01:00
|
|
|
- version: v7.2.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/9398
|
|
|
|
description: This method now returns a reference to `decipher`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `buffer` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* `options` {Object} [`stream.transform` options][]
|
2019-09-13 00:22:29 -04:00
|
|
|
* `plaintextLength` {number}
|
2020-08-25 10:05:51 -07:00
|
|
|
* `encoding` {string} String encoding to use when `buffer` is a string.
|
2025-03-01 16:25:58 -08:00
|
|
|
* Returns: {Decipheriv} The same Decipher for method chaining.
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2022-03-21 17:41:39 +01:00
|
|
|
When using an authenticated encryption mode (`GCM`, `CCM`, `OCB`, and
|
|
|
|
`chacha20-poly1305` are
|
2018-06-14 15:18:14 +02:00
|
|
|
currently supported), the `decipher.setAAD()` method sets the value used for the
|
2015-12-26 20:54:01 -08:00
|
|
|
_additional authenticated data_ (AAD) input parameter.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2018-06-20 20:24:30 +10:00
|
|
|
The `options` argument is optional for `GCM`. When using `CCM`, the
|
|
|
|
`plaintextLength` option must be specified and its value must match the length
|
2020-04-27 08:30:42 -07:00
|
|
|
of the ciphertext in bytes. See [CCM mode][].
|
2018-06-20 20:24:30 +10:00
|
|
|
|
2016-11-01 23:02:20 +03:00
|
|
|
The `decipher.setAAD()` method must be called before [`decipher.update()`][].
|
|
|
|
|
2021-02-06 16:51:50 +01:00
|
|
|
When passing a string as the `buffer`, please consider
|
|
|
|
[caveats when using strings as inputs to cryptographic APIs][].
|
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
### `decipher.setAuthTag(buffer[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v1.0.0
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
2024-05-02 11:31:36 +02:00
|
|
|
- version:
|
|
|
|
- v22.0.0
|
|
|
|
- v20.13.0
|
2024-04-10 10:16:33 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/52345
|
|
|
|
description: Using GCM tag lengths other than 128 bits without specifying
|
|
|
|
the `authTagLength` option when creating `decipher` is
|
|
|
|
deprecated.
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
2020-10-01 20:35:23 +02:00
|
|
|
description: The buffer argument can be a string or ArrayBuffer and is
|
2020-08-25 10:05:51 -07:00
|
|
|
limited to no more than 2 ** 31 - 1 bytes.
|
2018-10-02 16:01:19 -07:00
|
|
|
- version: v11.0.0
|
2017-12-28 14:33:19 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/17825
|
|
|
|
description: This method now throws if the GCM tag length is invalid.
|
2017-02-21 23:38:44 +01:00
|
|
|
- version: v7.2.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/9398
|
|
|
|
description: This method now returns a reference to `decipher`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `buffer` {string|Buffer|ArrayBuffer|TypedArray|DataView}
|
|
|
|
* `encoding` {string} String encoding to use when `buffer` is a string.
|
2025-03-01 16:25:58 -08:00
|
|
|
* Returns: {Decipheriv} The same Decipher for method chaining.
|
2012-10-10 15:44:47 -07:00
|
|
|
|
2022-03-21 17:41:39 +01:00
|
|
|
When using an authenticated encryption mode (`GCM`, `CCM`, `OCB`, and
|
|
|
|
`chacha20-poly1305` are
|
2018-06-14 15:18:14 +02:00
|
|
|
currently supported), the `decipher.setAuthTag()` method is used to pass in the
|
2016-02-15 03:40:53 +03:00
|
|
|
received _authentication tag_. If no tag is provided, or if the cipher text
|
2017-12-28 13:00:03 +01:00
|
|
|
has been tampered with, [`decipher.final()`][] will throw, indicating that the
|
2017-12-28 14:33:19 +01:00
|
|
|
cipher text should be discarded due to failed authentication. If the tag length
|
2018-06-21 17:59:49 +02:00
|
|
|
is invalid according to [NIST SP 800-38D][] or does not match the value of the
|
|
|
|
`authTagLength` option, `decipher.setAuthTag()` will throw an error.
|
2018-01-25 16:50:05 +01:00
|
|
|
|
2020-04-27 09:19:30 -07:00
|
|
|
The `decipher.setAuthTag()` method must be called before [`decipher.update()`][]
|
2022-03-21 17:41:39 +01:00
|
|
|
for `CCM` mode or before [`decipher.final()`][] for `GCM` and `OCB` modes and
|
|
|
|
`chacha20-poly1305`.
|
2020-04-27 09:19:30 -07:00
|
|
|
`decipher.setAuthTag()` can only be called once.
|
2016-11-01 23:02:20 +03:00
|
|
|
|
2021-02-06 16:51:50 +01:00
|
|
|
When passing a string as the authentication tag, please consider
|
|
|
|
[caveats when using strings as inputs to cryptographic APIs][].
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `decipher.setAutoPadding([autoPadding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.1
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `autoPadding` {boolean} **Default:** `true`
|
2025-03-01 16:25:58 -08:00
|
|
|
* Returns: {Decipheriv} The same Decipher for method chaining.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
When data has been encrypted without standard block padding, calling
|
2016-04-04 13:43:35 -05:00
|
|
|
`decipher.setAutoPadding(false)` will disable automatic padding to prevent
|
2016-02-15 03:40:53 +03:00
|
|
|
[`decipher.final()`][] from checking for and removing padding.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
Turning auto padding off will only work if the input data's length is a
|
|
|
|
multiple of the ciphers block size.
|
|
|
|
|
|
|
|
The `decipher.setAutoPadding()` method must be called before
|
2016-11-01 23:02:20 +03:00
|
|
|
[`decipher.final()`][].
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `decipher.update(data[, inputEncoding][, outputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
2017-06-06 11:00:32 +02:00
|
|
|
description: The default `inputEncoding` changed from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `data` {string|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `inputEncoding` {string} The [encoding][] of the `data` string.
|
|
|
|
* `outputEncoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2011-07-30 03:03:58 +09:00
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
Updates the decipher with `data`. If the `inputEncoding` argument is given,
|
2018-11-07 12:27:47 -08:00
|
|
|
the `data`
|
2017-06-06 11:00:32 +02:00
|
|
|
argument is a string using the specified encoding. If the `inputEncoding`
|
2015-12-26 20:54:01 -08:00
|
|
|
argument is not given, `data` must be a [`Buffer`][]. If `data` is a
|
2017-06-06 11:00:32 +02:00
|
|
|
[`Buffer`][] then `inputEncoding` is ignored.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
The `outputEncoding` specifies the output format of the enciphered
|
2018-11-07 12:27:47 -08:00
|
|
|
data. If the `outputEncoding`
|
2015-12-26 20:54:01 -08:00
|
|
|
is specified, a string using the specified encoding is returned. If no
|
2017-06-06 11:00:32 +02:00
|
|
|
`outputEncoding` is provided, a [`Buffer`][] is returned.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
The `decipher.update()` method can be called multiple times with new data until
|
2016-02-15 03:40:53 +03:00
|
|
|
[`decipher.final()`][] is called. Calling `decipher.update()` after
|
|
|
|
[`decipher.final()`][] will result in an error being thrown.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2024-07-11 15:40:39 +02:00
|
|
|
Even if the underlying cipher implements authentication, the authenticity and
|
|
|
|
integrity of the plaintext returned from this function may be uncertain at this
|
|
|
|
time. For authenticated encryption algorithms, authenticity is generally only
|
|
|
|
established when the application calls [`decipher.final()`][].
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
## Class: `DiffieHellman`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `DiffieHellman` class is a utility for creating Diffie-Hellman key
|
|
|
|
exchanges.
|
|
|
|
|
|
|
|
Instances of the `DiffieHellman` class can be created using the
|
2016-02-15 03:40:53 +03:00
|
|
|
[`crypto.createDiffieHellman()`][] function.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import assert from 'node:assert';
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createDiffieHellman,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
// Generate Alice's keys...
|
|
|
|
const alice = createDiffieHellman(2048);
|
|
|
|
const aliceKey = alice.generateKeys();
|
|
|
|
|
|
|
|
// Generate Bob's keys...
|
|
|
|
const bob = createDiffieHellman(alice.getPrime(), alice.getGenerator());
|
|
|
|
const bobKey = bob.generateKeys();
|
|
|
|
|
|
|
|
// Exchange and generate the secret...
|
|
|
|
const aliceSecret = alice.computeSecret(bobKey);
|
|
|
|
const bobSecret = bob.computeSecret(aliceKey);
|
|
|
|
|
|
|
|
// OK
|
|
|
|
assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const assert = require('node:assert');
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
createDiffieHellman,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
// Generate Alice's keys...
|
2021-03-03 14:25:03 -08:00
|
|
|
const alice = createDiffieHellman(2048);
|
2017-01-20 03:42:50 +02:00
|
|
|
const aliceKey = alice.generateKeys();
|
2012-10-30 15:46:43 -07:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
// Generate Bob's keys...
|
2021-03-03 14:25:03 -08:00
|
|
|
const bob = createDiffieHellman(alice.getPrime(), alice.getGenerator());
|
2017-01-20 03:42:50 +02:00
|
|
|
const bobKey = bob.generateKeys();
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
// Exchange and generate the secret...
|
2017-01-20 03:42:50 +02:00
|
|
|
const aliceSecret = alice.computeSecret(bobKey);
|
|
|
|
const bobSecret = bob.computeSecret(aliceKey);
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-03-01 09:26:32 -08:00
|
|
|
// OK
|
2017-01-20 03:42:50 +02:00
|
|
|
assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `diffieHellman.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `otherPublicKey` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `inputEncoding` {string} The [encoding][] of an `otherPublicKey` string.
|
|
|
|
* `outputEncoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
Computes the shared secret using `otherPublicKey` as the other
|
2015-12-26 20:54:01 -08:00
|
|
|
party's public key and returns the computed shared secret. The supplied
|
2017-06-06 11:00:32 +02:00
|
|
|
key is interpreted using the specified `inputEncoding`, and secret is
|
2018-11-07 12:27:47 -08:00
|
|
|
encoded using specified `outputEncoding`.
|
|
|
|
If the `inputEncoding` is not
|
2017-06-06 11:00:32 +02:00
|
|
|
provided, `otherPublicKey` is expected to be a [`Buffer`][],
|
2017-04-04 15:59:30 -07:00
|
|
|
`TypedArray`, or `DataView`.
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
If `outputEncoding` is given a string is returned; otherwise, a
|
2015-12-26 20:54:01 -08:00
|
|
|
[`Buffer`][] is returned.
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `diffieHellman.generateKeys([encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2010-10-28 23:18:16 +11:00
|
|
|
|
doc,test: clarify behavior of DH generateKeys
The DiffieHellman class is an old and thin wrapper around certain
OpenSSL functions, many of which are deprecated in OpenSSL 3.0. Because
the Node.js API mirrors the OpenSSL API, it adopts some of its
peculiarities, but the Node.js documentation does not properly reflect
these. Most importantly, despite the documentation saying otherwise,
diffieHellman.generateKeys() does not generate a new private key when
one has already been set or generated. Based on the documentation alone,
users may be led to misuse the API in a way that results in key reuse,
which can have drastic negative consequences for subsequent operations
that consume the shared secret.
These design issues in this old API have been around for many years, and
we are not currently aware of any misuse in the ecosystem that falls
into the above scenario. Changing the behavior of the API would be a
significant breaking change and is thus not appropriate for a security
release (nor is it a goal.) The reported issue is treated as CWE-1068
(after a vast amount of uncertainty whether to treat it as a
vulnerability at all), therefore, this change only updates the
documentation to match the actual behavior. Tests are also added that
demonstrate this particular oddity.
Newer APIs exist that can be used for some, but not all, Diffie-Hellman
operations (e.g., crypto.diffieHellman() that was added in 2020). We
should keep modernizing crypto APIs, but that is a non-goal for this
security release.
The ECDH class mirrors the DiffieHellman class in many ways, but it does
not appear to be affected by this particular peculiarity. In particular,
ecdh.generateKeys() does appear to always generate a new private key.
PR-URL: https://github.com/nodejs-private/node-private/pull/426
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
CVE-ID: CVE-2023-30590
2023-06-12 19:44:48 +02:00
|
|
|
Generates private and public Diffie-Hellman key values unless they have been
|
|
|
|
generated or computed already, and returns
|
2015-12-26 20:54:01 -08:00
|
|
|
the public key in the specified `encoding`. This key should be
|
2018-11-07 12:27:47 -08:00
|
|
|
transferred to the other party.
|
|
|
|
If `encoding` is provided a string is returned; otherwise a
|
2015-12-26 20:54:01 -08:00
|
|
|
[`Buffer`][] is returned.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
doc,test: clarify behavior of DH generateKeys
The DiffieHellman class is an old and thin wrapper around certain
OpenSSL functions, many of which are deprecated in OpenSSL 3.0. Because
the Node.js API mirrors the OpenSSL API, it adopts some of its
peculiarities, but the Node.js documentation does not properly reflect
these. Most importantly, despite the documentation saying otherwise,
diffieHellman.generateKeys() does not generate a new private key when
one has already been set or generated. Based on the documentation alone,
users may be led to misuse the API in a way that results in key reuse,
which can have drastic negative consequences for subsequent operations
that consume the shared secret.
These design issues in this old API have been around for many years, and
we are not currently aware of any misuse in the ecosystem that falls
into the above scenario. Changing the behavior of the API would be a
significant breaking change and is thus not appropriate for a security
release (nor is it a goal.) The reported issue is treated as CWE-1068
(after a vast amount of uncertainty whether to treat it as a
vulnerability at all), therefore, this change only updates the
documentation to match the actual behavior. Tests are also added that
demonstrate this particular oddity.
Newer APIs exist that can be used for some, but not all, Diffie-Hellman
operations (e.g., crypto.diffieHellman() that was added in 2020). We
should keep modernizing crypto APIs, but that is a non-goal for this
security release.
The ECDH class mirrors the DiffieHellman class in many ways, but it does
not appear to be affected by this particular peculiarity. In particular,
ecdh.generateKeys() does appear to always generate a new private key.
PR-URL: https://github.com/nodejs-private/node-private/pull/426
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
CVE-ID: CVE-2023-30590
2023-06-12 19:44:48 +02:00
|
|
|
This function is a thin wrapper around [`DH_generate_key()`][]. In particular,
|
|
|
|
once a private key has been generated or set, calling this function only updates
|
|
|
|
the public key but does not generate a new private key.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `diffieHellman.getGenerator([encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
Returns the Diffie-Hellman generator in the specified `encoding`.
|
|
|
|
If `encoding` is provided a string is
|
2015-12-26 20:54:01 -08:00
|
|
|
returned; otherwise a [`Buffer`][] is returned.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `diffieHellman.getPrime([encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2011-07-30 03:03:58 +09:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
Returns the Diffie-Hellman prime in the specified `encoding`.
|
|
|
|
If `encoding` is provided a string is
|
2015-12-26 20:54:01 -08:00
|
|
|
returned; otherwise a [`Buffer`][] is returned.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `diffieHellman.getPrivateKey([encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
Returns the Diffie-Hellman private key in the specified `encoding`.
|
|
|
|
If `encoding` is provided a
|
2015-12-26 20:54:01 -08:00
|
|
|
string is returned; otherwise a [`Buffer`][] is returned.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `diffieHellman.getPublicKey([encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2011-07-24 15:56:23 +09:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
Returns the Diffie-Hellman public key in the specified `encoding`.
|
|
|
|
If `encoding` is provided a
|
2015-12-26 20:54:01 -08:00
|
|
|
string is returned; otherwise a [`Buffer`][] is returned.
|
2012-10-30 15:46:43 -07:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `diffieHellman.setPrivateKey(privateKey[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `privateKey` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the `privateKey` string.
|
2014-10-19 10:31:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
Sets the Diffie-Hellman private key. If the `encoding` argument is provided,
|
|
|
|
`privateKey` is expected
|
2017-06-06 11:00:32 +02:00
|
|
|
to be a string. If no `encoding` is provided, `privateKey` is expected
|
2017-04-04 15:59:30 -07:00
|
|
|
to be a [`Buffer`][], `TypedArray`, or `DataView`.
|
2014-10-19 10:31:22 -04:00
|
|
|
|
doc,test: clarify behavior of DH generateKeys
The DiffieHellman class is an old and thin wrapper around certain
OpenSSL functions, many of which are deprecated in OpenSSL 3.0. Because
the Node.js API mirrors the OpenSSL API, it adopts some of its
peculiarities, but the Node.js documentation does not properly reflect
these. Most importantly, despite the documentation saying otherwise,
diffieHellman.generateKeys() does not generate a new private key when
one has already been set or generated. Based on the documentation alone,
users may be led to misuse the API in a way that results in key reuse,
which can have drastic negative consequences for subsequent operations
that consume the shared secret.
These design issues in this old API have been around for many years, and
we are not currently aware of any misuse in the ecosystem that falls
into the above scenario. Changing the behavior of the API would be a
significant breaking change and is thus not appropriate for a security
release (nor is it a goal.) The reported issue is treated as CWE-1068
(after a vast amount of uncertainty whether to treat it as a
vulnerability at all), therefore, this change only updates the
documentation to match the actual behavior. Tests are also added that
demonstrate this particular oddity.
Newer APIs exist that can be used for some, but not all, Diffie-Hellman
operations (e.g., crypto.diffieHellman() that was added in 2020). We
should keep modernizing crypto APIs, but that is a non-goal for this
security release.
The ECDH class mirrors the DiffieHellman class in many ways, but it does
not appear to be affected by this particular peculiarity. In particular,
ecdh.generateKeys() does appear to always generate a new private key.
PR-URL: https://github.com/nodejs-private/node-private/pull/426
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
CVE-ID: CVE-2023-30590
2023-06-12 19:44:48 +02:00
|
|
|
This function does not automatically compute the associated public key. Either
|
|
|
|
[`diffieHellman.setPublicKey()`][] or [`diffieHellman.generateKeys()`][] can be
|
|
|
|
used to manually provide the public key or to automatically derive it.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `diffieHellman.setPublicKey(publicKey[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `publicKey` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the `publicKey` string.
|
2011-07-24 15:56:23 +09:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
Sets the Diffie-Hellman public key. If the `encoding` argument is provided,
|
|
|
|
`publicKey` is expected
|
2017-06-06 11:00:32 +02:00
|
|
|
to be a string. If no `encoding` is provided, `publicKey` is expected
|
2017-04-04 15:59:30 -07:00
|
|
|
to be a [`Buffer`][], `TypedArray`, or `DataView`.
|
2011-07-24 15:56:23 +09:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `diffieHellman.verifyError`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.12
|
|
|
|
-->
|
2012-06-12 22:02:35 +02:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
A bit field containing any warnings and/or errors resulting from a check
|
|
|
|
performed during initialization of the `DiffieHellman` object.
|
|
|
|
|
2022-04-20 10:23:41 +02:00
|
|
|
The following values are valid for this property (as defined in `node:constants` module):
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-11-04 11:23:03 -05:00
|
|
|
* `DH_CHECK_P_NOT_SAFE_PRIME`
|
|
|
|
* `DH_CHECK_P_NOT_PRIME`
|
|
|
|
* `DH_UNABLE_TO_CHECK_GENERATOR`
|
|
|
|
* `DH_NOT_SUITABLE_GENERATOR`
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
## Class: `DiffieHellmanGroup`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-07-07 16:33:18 +09:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.5
|
|
|
|
-->
|
|
|
|
|
2021-04-22 23:28:19 +03:00
|
|
|
The `DiffieHellmanGroup` class takes a well-known modp group as its argument.
|
|
|
|
It works the same as `DiffieHellman`, except that it does not allow changing
|
|
|
|
its keys after creation. In other words, it does not implement `setPublicKey()`
|
|
|
|
or `setPrivateKey()` methods.
|
2019-07-07 16:33:18 +09:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { createDiffieHellmanGroup } = await import('node:crypto');
|
2022-09-10 22:19:36 +02:00
|
|
|
const dh = createDiffieHellmanGroup('modp16');
|
2021-03-03 14:25:03 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { createDiffieHellmanGroup } = require('node:crypto');
|
2022-09-10 22:19:36 +02:00
|
|
|
const dh = createDiffieHellmanGroup('modp16');
|
2019-07-07 16:33:18 +09:00
|
|
|
```
|
|
|
|
|
2022-07-27 22:20:02 +02:00
|
|
|
The following groups are supported:
|
|
|
|
|
|
|
|
* `'modp14'` (2048 bits, [RFC 3526][] Section 3)
|
|
|
|
* `'modp15'` (3072 bits, [RFC 3526][] Section 4)
|
|
|
|
* `'modp16'` (4096 bits, [RFC 3526][] Section 5)
|
|
|
|
* `'modp17'` (6144 bits, [RFC 3526][] Section 6)
|
|
|
|
* `'modp18'` (8192 bits, [RFC 3526][] Section 7)
|
2019-07-07 16:33:18 +09:00
|
|
|
|
2022-09-13 00:29:27 +02:00
|
|
|
The following groups are still supported but deprecated (see [Caveats][]):
|
|
|
|
|
|
|
|
* `'modp1'` (768 bits, [RFC 2409][] Section 6.1) <span class="deprecated-inline"></span>
|
|
|
|
* `'modp2'` (1024 bits, [RFC 2409][] Section 6.2) <span class="deprecated-inline"></span>
|
|
|
|
* `'modp5'` (1536 bits, [RFC 3526][] Section 2) <span class="deprecated-inline"></span>
|
|
|
|
|
|
|
|
These deprecated groups might be removed in future versions of Node.js.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
## Class: `ECDH`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
|
|
|
-->
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH)
|
|
|
|
key exchanges.
|
|
|
|
|
|
|
|
Instances of the `ECDH` class can be created using the
|
2016-02-15 03:40:53 +03:00
|
|
|
[`crypto.createECDH()`][] function.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import assert from 'node:assert';
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createECDH,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
// Generate Alice's keys...
|
|
|
|
const alice = createECDH('secp521r1');
|
|
|
|
const aliceKey = alice.generateKeys();
|
|
|
|
|
|
|
|
// Generate Bob's keys...
|
|
|
|
const bob = createECDH('secp521r1');
|
|
|
|
const bobKey = bob.generateKeys();
|
|
|
|
|
|
|
|
// Exchange and generate the secret...
|
|
|
|
const aliceSecret = alice.computeSecret(bobKey);
|
|
|
|
const bobSecret = bob.computeSecret(aliceKey);
|
|
|
|
|
|
|
|
assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
|
|
|
|
// OK
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const assert = require('node:assert');
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
createECDH,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
// Generate Alice's keys...
|
2021-03-03 14:25:03 -08:00
|
|
|
const alice = createECDH('secp521r1');
|
2017-01-20 03:42:50 +02:00
|
|
|
const aliceKey = alice.generateKeys();
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
// Generate Bob's keys...
|
2021-03-03 14:25:03 -08:00
|
|
|
const bob = createECDH('secp521r1');
|
2017-01-20 03:42:50 +02:00
|
|
|
const bobKey = bob.generateKeys();
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
// Exchange and generate the secret...
|
2017-01-20 03:42:50 +02:00
|
|
|
const aliceSecret = alice.computeSecret(bobKey);
|
|
|
|
const bobSecret = bob.computeSecret(aliceKey);
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2017-01-20 03:42:50 +02:00
|
|
|
assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex'));
|
2017-06-27 13:32:32 -07:00
|
|
|
// OK
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2012-10-30 15:46:43 -07:00
|
|
|
|
2020-08-06 22:19:11 -07:00
|
|
|
### Static method: `ECDH.convertKey(key, curve[, inputEncoding[, outputEncoding[, format]]])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-03-01 17:13:12 -08:00
|
|
|
<!-- YAML
|
2018-03-02 09:53:46 -08:00
|
|
|
added: v10.0.0
|
2018-03-01 17:13:12 -08:00
|
|
|
-->
|
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `key` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* `curve` {string}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `inputEncoding` {string} The [encoding][] of the `key` string.
|
|
|
|
* `outputEncoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* `format` {string} **Default:** `'uncompressed'`
|
|
|
|
* Returns: {Buffer | string}
|
2018-03-01 17:13:12 -08:00
|
|
|
|
|
|
|
Converts the EC Diffie-Hellman public key specified by `key` and `curve` to the
|
|
|
|
format specified by `format`. The `format` argument specifies point encoding
|
|
|
|
and can be `'compressed'`, `'uncompressed'` or `'hybrid'`. The supplied key is
|
|
|
|
interpreted using the specified `inputEncoding`, and the returned key is encoded
|
2018-11-07 12:27:47 -08:00
|
|
|
using the specified `outputEncoding`.
|
2018-03-01 17:13:12 -08:00
|
|
|
|
|
|
|
Use [`crypto.getCurves()`][] to obtain a list of available curve names.
|
|
|
|
On recent OpenSSL releases, `openssl ecparam -list_curves` will also display
|
|
|
|
the name and description of each available elliptic curve.
|
|
|
|
|
|
|
|
If `format` is not specified the point will be returned in `'uncompressed'`
|
|
|
|
format.
|
|
|
|
|
|
|
|
If the `inputEncoding` is not provided, `key` is expected to be a [`Buffer`][],
|
|
|
|
`TypedArray`, or `DataView`.
|
|
|
|
|
|
|
|
Example (uncompressing a key):
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
|
|
|
createECDH,
|
2022-11-17 08:19:12 -05:00
|
|
|
ECDH,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const ecdh = createECDH('secp256k1');
|
|
|
|
ecdh.generateKeys();
|
|
|
|
|
|
|
|
const compressedKey = ecdh.getPublicKey('hex', 'compressed');
|
|
|
|
|
|
|
|
const uncompressedKey = ECDH.convertKey(compressedKey,
|
|
|
|
'secp256k1',
|
|
|
|
'hex',
|
|
|
|
'hex',
|
|
|
|
'uncompressed');
|
|
|
|
|
|
|
|
// The converted key and the uncompressed public key should be the same
|
|
|
|
console.log(uncompressedKey === ecdh.getPublicKey('hex'));
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createECDH,
|
|
|
|
ECDH,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2018-03-01 17:13:12 -08:00
|
|
|
|
2018-09-03 10:51:13 +02:00
|
|
|
const ecdh = createECDH('secp256k1');
|
2018-03-01 17:13:12 -08:00
|
|
|
ecdh.generateKeys();
|
|
|
|
|
|
|
|
const compressedKey = ecdh.getPublicKey('hex', 'compressed');
|
|
|
|
|
|
|
|
const uncompressedKey = ECDH.convertKey(compressedKey,
|
|
|
|
'secp256k1',
|
|
|
|
'hex',
|
|
|
|
'hex',
|
|
|
|
'uncompressed');
|
|
|
|
|
2018-12-03 17:15:45 +01:00
|
|
|
// The converted key and the uncompressed public key should be the same
|
2018-03-01 17:13:12 -08:00
|
|
|
console.log(uncompressedKey === ecdh.getPublicKey('hex'));
|
|
|
|
```
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `ecdh.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
2018-03-02 09:53:46 -08:00
|
|
|
- version: v10.0.0
|
2017-11-06 17:22:42 -05:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/16849
|
|
|
|
description: Changed error format to better support invalid public key
|
2020-10-01 20:35:23 +02:00
|
|
|
error.
|
2020-10-01 20:49:03 +02:00
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
|
|
|
description: The default `inputEncoding` changed from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `otherPublicKey` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `inputEncoding` {string} The [encoding][] of the `otherPublicKey` string.
|
|
|
|
* `outputEncoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
Computes the shared secret using `otherPublicKey` as the other
|
2015-12-26 20:54:01 -08:00
|
|
|
party's public key and returns the computed shared secret. The supplied
|
2017-06-06 11:00:32 +02:00
|
|
|
key is interpreted using specified `inputEncoding`, and the returned secret
|
2018-11-07 12:27:47 -08:00
|
|
|
is encoded using the specified `outputEncoding`.
|
|
|
|
If the `inputEncoding` is not
|
2017-06-06 11:00:32 +02:00
|
|
|
provided, `otherPublicKey` is expected to be a [`Buffer`][], `TypedArray`, or
|
2017-04-04 15:59:30 -07:00
|
|
|
`DataView`.
|
2011-12-27 17:43:58 +09:00
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
If `outputEncoding` is given a string will be returned; otherwise a
|
2015-12-26 20:54:01 -08:00
|
|
|
[`Buffer`][] is returned.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2017-11-06 17:22:42 -05:00
|
|
|
`ecdh.computeSecret` will throw an
|
|
|
|
`ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY` error when `otherPublicKey`
|
|
|
|
lies outside of the elliptic curve. Since `otherPublicKey` is
|
|
|
|
usually supplied from a remote user over an insecure network,
|
2020-08-09 14:34:32 -07:00
|
|
|
be sure to handle this exception accordingly.
|
2017-11-06 17:22:42 -05:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `ecdh.generateKeys([encoding[, format]])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* `format` {string} **Default:** `'uncompressed'`
|
|
|
|
* Returns: {Buffer | string}
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-11-04 11:23:03 -05:00
|
|
|
Generates private and public EC Diffie-Hellman key values, and returns
|
2015-12-26 20:54:01 -08:00
|
|
|
the public key in the specified `format` and `encoding`. This key should be
|
2015-11-04 11:23:03 -05:00
|
|
|
transferred to the other party.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2016-01-27 14:38:07 -08:00
|
|
|
The `format` argument specifies point encoding and can be `'compressed'` or
|
|
|
|
`'uncompressed'`. If `format` is not specified, the point will be returned in
|
|
|
|
`'uncompressed'` format.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
If `encoding` is provided a string is returned; otherwise a [`Buffer`][]
|
2015-12-26 20:54:01 -08:00
|
|
|
is returned.
|
2011-07-30 03:03:58 +09:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `ecdh.getPrivateKey([encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
|
|
|
* Returns: {Buffer | string} The EC Diffie-Hellman in the specified `encoding`.
|
|
|
|
|
|
|
|
If `encoding` is specified, a string is returned; otherwise a [`Buffer`][] is
|
|
|
|
returned.
|
2011-12-02 21:04:13 +01:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `ecdh.getPublicKey([encoding][, format])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* `format` {string} **Default:** `'uncompressed'`
|
|
|
|
* Returns: {Buffer | string} The EC Diffie-Hellman public key in the specified
|
2018-04-06 18:28:20 +03:00
|
|
|
`encoding` and `format`.
|
2013-11-19 22:38:15 +01:00
|
|
|
|
2016-01-27 14:38:07 -08:00
|
|
|
The `format` argument specifies point encoding and can be `'compressed'` or
|
|
|
|
`'uncompressed'`. If `format` is not specified the point will be returned in
|
|
|
|
`'uncompressed'` format.
|
2014-03-04 00:05:23 -05:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
If `encoding` is specified, a string is returned; otherwise a [`Buffer`][] is
|
2015-12-26 20:54:01 -08:00
|
|
|
returned.
|
2014-03-04 00:05:23 -05:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `ecdh.setPrivateKey(privateKey[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `privateKey` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the `privateKey` string.
|
2011-07-30 03:03:58 +09:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
Sets the EC Diffie-Hellman private key.
|
|
|
|
If `encoding` is provided, `privateKey` is expected
|
2017-06-06 11:00:32 +02:00
|
|
|
to be a string; otherwise `privateKey` is expected to be a [`Buffer`][],
|
2017-04-04 15:59:30 -07:00
|
|
|
`TypedArray`, or `DataView`.
|
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
If `privateKey` is not valid for the curve specified when the `ECDH` object was
|
2015-12-26 20:54:01 -08:00
|
|
|
created, an error is thrown. Upon setting the private key, the associated
|
2018-04-29 20:46:41 +03:00
|
|
|
public point (key) is also generated and set in the `ECDH` object.
|
2015-11-19 14:00:00 -05:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `ecdh.setPublicKey(publicKey[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
|
|
|
deprecated: v5.2.0
|
|
|
|
-->
|
2015-11-19 14:00:00 -05:00
|
|
|
|
2016-07-16 00:35:38 +02:00
|
|
|
> Stability: 0 - Deprecated
|
2015-11-19 14:00:00 -05:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `publicKey` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the `publicKey` string.
|
2017-03-10 22:30:48 -08:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
Sets the EC Diffie-Hellman public key.
|
|
|
|
If `encoding` is provided `publicKey` is expected to
|
2017-04-04 15:59:30 -07:00
|
|
|
be a string; otherwise a [`Buffer`][], `TypedArray`, or `DataView` is expected.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2019-06-20 14:01:15 -06:00
|
|
|
There is not normally a reason to call this method because `ECDH`
|
2015-12-26 20:54:01 -08:00
|
|
|
only requires a private key and the other party's public key to compute the
|
2016-02-15 03:40:53 +03:00
|
|
|
shared secret. Typically either [`ecdh.generateKeys()`][] or
|
|
|
|
[`ecdh.setPrivateKey()`][] will be called. The [`ecdh.setPrivateKey()`][] method
|
|
|
|
attempts to generate the public point/key associated with the private key being
|
|
|
|
set.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-11-04 11:23:03 -05:00
|
|
|
Example (obtaining a shared secret):
|
2011-07-24 15:56:23 +09:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
|
|
|
createECDH,
|
2022-11-17 08:19:12 -05:00
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const alice = createECDH('secp256k1');
|
|
|
|
const bob = createECDH('secp256k1');
|
2011-07-24 15:56:23 +09:00
|
|
|
|
2018-10-26 19:27:40 +03:00
|
|
|
// This is a shortcut way of specifying one of Alice's previous private
|
2016-01-17 18:39:07 +01:00
|
|
|
// keys. It would be unwise to use such a predictable private key in a real
|
|
|
|
// application.
|
|
|
|
alice.setPrivateKey(
|
2022-11-17 08:19:12 -05:00
|
|
|
createHash('sha256').update('alice', 'utf8').digest(),
|
2021-03-03 14:25:03 -08:00
|
|
|
);
|
|
|
|
|
|
|
|
// Bob uses a newly generated cryptographically strong
|
|
|
|
// pseudorandom key pair
|
|
|
|
bob.generateKeys();
|
|
|
|
|
|
|
|
const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
|
|
|
|
const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');
|
|
|
|
|
|
|
|
// aliceSecret and bobSecret should be the same shared secret value
|
|
|
|
console.log(aliceSecret === bobSecret);
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createECDH,
|
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const alice = createECDH('secp256k1');
|
|
|
|
const bob = createECDH('secp256k1');
|
|
|
|
|
|
|
|
// This is a shortcut way of specifying one of Alice's previous private
|
|
|
|
// keys. It would be unwise to use such a predictable private key in a real
|
|
|
|
// application.
|
|
|
|
alice.setPrivateKey(
|
2022-11-17 08:19:12 -05:00
|
|
|
createHash('sha256').update('alice', 'utf8').digest(),
|
2016-01-17 18:39:07 +01:00
|
|
|
);
|
2015-11-19 14:00:00 -05:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
// Bob uses a newly generated cryptographically strong
|
2017-01-20 03:42:50 +02:00
|
|
|
// pseudorandom key pair
|
|
|
|
bob.generateKeys();
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2017-01-20 03:42:50 +02:00
|
|
|
const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
|
|
|
|
const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2017-01-20 03:42:50 +02:00
|
|
|
// aliceSecret and bobSecret should be the same shared secret value
|
|
|
|
console.log(aliceSecret === bobSecret);
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2012-10-30 15:46:43 -07:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
## Class: `Hash`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
|
|
|
-->
|
2011-12-27 17:43:58 +09:00
|
|
|
|
2019-08-24 18:16:48 -07:00
|
|
|
* Extends: {stream.Transform}
|
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `Hash` class is a utility for creating hash digests of data. It can be
|
|
|
|
used in one of two ways:
|
|
|
|
|
2019-09-13 00:22:29 -04:00
|
|
|
* As a [stream][] that is both readable and writable, where data is written
|
2015-12-26 20:54:01 -08:00
|
|
|
to produce a computed hash digest on the readable side, or
|
2019-09-13 00:22:29 -04:00
|
|
|
* Using the [`hash.update()`][] and [`hash.digest()`][] methods to produce the
|
2015-12-26 20:54:01 -08:00
|
|
|
computed hash.
|
|
|
|
|
2016-02-15 03:40:53 +03:00
|
|
|
The [`crypto.createHash()`][] method is used to create `Hash` instances. `Hash`
|
2015-12-26 20:54:01 -08:00
|
|
|
objects are not to be created directly using the `new` keyword.
|
|
|
|
|
|
|
|
Example: Using `Hash` objects as streams:
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hash = createHash('sha256');
|
|
|
|
|
|
|
|
hash.on('readable', () => {
|
|
|
|
// Only one element is going to be produced by the
|
|
|
|
// hash stream.
|
|
|
|
const data = hash.read();
|
|
|
|
if (data) {
|
|
|
|
console.log(data.toString('hex'));
|
|
|
|
// Prints:
|
|
|
|
// 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
hash.write('some data to hash');
|
|
|
|
hash.end();
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hash = createHash('sha256');
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
hash.on('readable', () => {
|
2019-01-07 15:37:34 +01:00
|
|
|
// Only one element is going to be produced by the
|
|
|
|
// hash stream.
|
2017-01-20 03:42:50 +02:00
|
|
|
const data = hash.read();
|
2017-06-27 13:32:32 -07:00
|
|
|
if (data) {
|
2016-01-17 18:39:07 +01:00
|
|
|
console.log(data.toString('hex'));
|
|
|
|
// Prints:
|
|
|
|
// 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
|
2017-06-27 13:32:32 -07:00
|
|
|
}
|
2016-01-17 18:39:07 +01:00
|
|
|
});
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
hash.write('some data to hash');
|
|
|
|
hash.end();
|
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
Example: Using `Hash` and piped streams:
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { createReadStream } from 'node:fs';
|
|
|
|
import { stdout } from 'node:process';
|
|
|
|
const { createHash } = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hash = createHash('sha256');
|
|
|
|
|
|
|
|
const input = createReadStream('test.js');
|
2021-06-15 10:09:29 -07:00
|
|
|
input.pipe(hash).setEncoding('hex').pipe(stdout);
|
2021-03-03 14:25:03 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { createReadStream } = require('node:fs');
|
|
|
|
const { createHash } = require('node:crypto');
|
|
|
|
const { stdout } = require('node:process');
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const hash = createHash('sha256');
|
|
|
|
|
|
|
|
const input = createReadStream('test.js');
|
2021-06-15 10:09:29 -07:00
|
|
|
input.pipe(hash).setEncoding('hex').pipe(stdout);
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2016-02-15 03:40:53 +03:00
|
|
|
Example: Using the [`hash.update()`][] and [`hash.digest()`][] methods:
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hash = createHash('sha256');
|
|
|
|
|
|
|
|
hash.update('some data to hash');
|
|
|
|
console.log(hash.digest('hex'));
|
|
|
|
// Prints:
|
|
|
|
// 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hash = createHash('sha256');
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
hash.update('some data to hash');
|
|
|
|
console.log(hash.digest('hex'));
|
2016-11-08 21:04:57 +01:00
|
|
|
// Prints:
|
|
|
|
// 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `hash.copy([options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-10-10 00:33:15 +02:00
|
|
|
<!-- YAML
|
2019-11-05 10:55:13 +01:00
|
|
|
added: v13.1.0
|
2019-10-10 00:33:15 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `options` {Object} [`stream.transform` options][]
|
|
|
|
* Returns: {Hash}
|
|
|
|
|
|
|
|
Creates a new `Hash` object that contains a deep copy of the internal state
|
|
|
|
of the current `Hash` object.
|
|
|
|
|
|
|
|
The optional `options` argument controls stream behavior. For XOF hash
|
|
|
|
functions such as `'shake256'`, the `outputLength` option can be used to
|
|
|
|
specify the desired output length in bytes.
|
|
|
|
|
|
|
|
An error is thrown when an attempt is made to copy the `Hash` object after
|
|
|
|
its [`hash.digest()`][] method has been called.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2019-10-10 00:33:15 +02:00
|
|
|
// Calculate a rolling hash.
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hash = createHash('sha256');
|
|
|
|
|
|
|
|
hash.update('one');
|
|
|
|
console.log(hash.copy().digest('hex'));
|
|
|
|
|
|
|
|
hash.update('two');
|
|
|
|
console.log(hash.copy().digest('hex'));
|
|
|
|
|
|
|
|
hash.update('three');
|
|
|
|
console.log(hash.copy().digest('hex'));
|
|
|
|
|
|
|
|
// Etc.
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
// Calculate a rolling hash.
|
|
|
|
const {
|
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hash = createHash('sha256');
|
2019-10-10 00:33:15 +02:00
|
|
|
|
|
|
|
hash.update('one');
|
|
|
|
console.log(hash.copy().digest('hex'));
|
|
|
|
|
|
|
|
hash.update('two');
|
|
|
|
console.log(hash.copy().digest('hex'));
|
|
|
|
|
|
|
|
hash.update('three');
|
|
|
|
console.log(hash.copy().digest('hex'));
|
|
|
|
|
|
|
|
// Etc.
|
|
|
|
```
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `hash.digest([encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Calculates the digest of all of the data passed to be hashed (using the
|
2018-11-07 12:27:47 -08:00
|
|
|
[`hash.update()`][] method).
|
|
|
|
If `encoding` is provided a string will be returned; otherwise
|
2015-12-26 20:54:01 -08:00
|
|
|
a [`Buffer`][] is returned.
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `Hash` object can not be used again after `hash.digest()` method has been
|
|
|
|
called. Multiple calls will cause an error to be thrown.
|
2011-07-30 03:03:58 +09:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `hash.update(data[, inputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
2017-06-06 11:00:32 +02:00
|
|
|
description: The default `inputEncoding` changed from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `data` {string|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `inputEncoding` {string} The [encoding][] of the `data` string.
|
2011-12-02 21:04:13 +01:00
|
|
|
|
2015-11-04 11:23:03 -05:00
|
|
|
Updates the hash content with the given `data`, the encoding of which
|
2018-11-07 12:27:47 -08:00
|
|
|
is given in `inputEncoding`.
|
|
|
|
If `encoding` is not provided, and the `data` is a string, an
|
2017-04-04 15:59:30 -07:00
|
|
|
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray`, or
|
2017-06-06 11:00:32 +02:00
|
|
|
`DataView`, then `inputEncoding` is ignored.
|
2011-12-02 21:04:13 +01:00
|
|
|
|
2015-11-04 11:23:03 -05:00
|
|
|
This can be called many times with new data as it is streamed.
|
2013-11-19 22:38:15 +01:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
## Class: `Hmac`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
|
|
|
-->
|
2013-11-19 22:38:15 +01:00
|
|
|
|
2019-08-24 18:16:48 -07:00
|
|
|
* Extends: {stream.Transform}
|
|
|
|
|
2019-01-11 11:43:58 -08:00
|
|
|
The `Hmac` class is a utility for creating cryptographic HMAC digests. It can
|
2015-12-26 20:54:01 -08:00
|
|
|
be used in one of two ways:
|
|
|
|
|
2019-09-13 00:22:29 -04:00
|
|
|
* As a [stream][] that is both readable and writable, where data is written
|
2015-12-26 20:54:01 -08:00
|
|
|
to produce a computed HMAC digest on the readable side, or
|
2019-09-13 00:22:29 -04:00
|
|
|
* Using the [`hmac.update()`][] and [`hmac.digest()`][] methods to produce the
|
2015-12-26 20:54:01 -08:00
|
|
|
computed HMAC digest.
|
|
|
|
|
2016-02-15 03:40:53 +03:00
|
|
|
The [`crypto.createHmac()`][] method is used to create `Hmac` instances. `Hmac`
|
2015-12-26 20:54:01 -08:00
|
|
|
objects are not to be created directly using the `new` keyword.
|
|
|
|
|
|
|
|
Example: Using `Hmac` objects as streams:
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createHmac,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hmac = createHmac('sha256', 'a secret');
|
|
|
|
|
|
|
|
hmac.on('readable', () => {
|
|
|
|
// Only one element is going to be produced by the
|
|
|
|
// hash stream.
|
|
|
|
const data = hmac.read();
|
|
|
|
if (data) {
|
|
|
|
console.log(data.toString('hex'));
|
|
|
|
// Prints:
|
|
|
|
// 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
hmac.write('some data to hash');
|
|
|
|
hmac.end();
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createHmac,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hmac = createHmac('sha256', 'a secret');
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
hmac.on('readable', () => {
|
2019-01-07 15:37:34 +01:00
|
|
|
// Only one element is going to be produced by the
|
|
|
|
// hash stream.
|
2017-01-20 03:42:50 +02:00
|
|
|
const data = hmac.read();
|
2017-06-27 13:32:32 -07:00
|
|
|
if (data) {
|
2016-01-17 18:39:07 +01:00
|
|
|
console.log(data.toString('hex'));
|
|
|
|
// Prints:
|
|
|
|
// 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
|
2017-06-27 13:32:32 -07:00
|
|
|
}
|
2016-01-17 18:39:07 +01:00
|
|
|
});
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
hmac.write('some data to hash');
|
|
|
|
hmac.end();
|
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
Example: Using `Hmac` and piped streams:
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { createReadStream } from 'node:fs';
|
|
|
|
import { stdout } from 'node:process';
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createHmac,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hmac = createHmac('sha256', 'a secret');
|
|
|
|
|
|
|
|
const input = createReadStream('test.js');
|
2021-06-15 10:09:29 -07:00
|
|
|
input.pipe(hmac).pipe(stdout);
|
2021-03-03 14:25:03 -08:00
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createReadStream,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:fs');
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
createHmac,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
|
|
|
const { stdout } = require('node:process');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hmac = createHmac('sha256', 'a secret');
|
|
|
|
|
|
|
|
const input = createReadStream('test.js');
|
2021-06-15 10:09:29 -07:00
|
|
|
input.pipe(hmac).pipe(stdout);
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2014-03-04 00:05:23 -05:00
|
|
|
|
2016-02-15 03:40:53 +03:00
|
|
|
Example: Using the [`hmac.update()`][] and [`hmac.digest()`][] methods:
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createHmac,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hmac = createHmac('sha256', 'a secret');
|
|
|
|
|
|
|
|
hmac.update('some data to hash');
|
|
|
|
console.log(hmac.digest('hex'));
|
|
|
|
// Prints:
|
|
|
|
// 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createHmac,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hmac = createHmac('sha256', 'a secret');
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
hmac.update('some data to hash');
|
|
|
|
console.log(hmac.digest('hex'));
|
2016-11-08 21:04:57 +01:00
|
|
|
// Prints:
|
|
|
|
// 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2014-03-04 00:05:23 -05:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `hmac.digest([encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
* `encoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2013-11-19 22:38:15 +01:00
|
|
|
|
2016-02-15 03:40:53 +03:00
|
|
|
Calculates the HMAC digest of all of the data passed using [`hmac.update()`][].
|
2018-11-07 12:27:47 -08:00
|
|
|
If `encoding` is
|
2016-02-15 03:40:53 +03:00
|
|
|
provided a string is returned; otherwise a [`Buffer`][] is returned;
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `Hmac` object can not be used again after `hmac.digest()` has been
|
|
|
|
called. Multiple calls to `hmac.digest()` will result in an error being thrown.
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `hmac.update(data[, inputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
2017-06-06 11:00:32 +02:00
|
|
|
description: The default `inputEncoding` changed from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `data` {string|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `inputEncoding` {string} The [encoding][] of the `data` string.
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2016-02-29 21:03:14 -05:00
|
|
|
Updates the `Hmac` content with the given `data`, the encoding of which
|
2018-11-07 12:27:47 -08:00
|
|
|
is given in `inputEncoding`.
|
|
|
|
If `encoding` is not provided, and the `data` is a string, an
|
2017-04-04 15:59:30 -07:00
|
|
|
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray`, or
|
2017-06-06 11:00:32 +02:00
|
|
|
`DataView`, then `inputEncoding` is ignored.
|
2016-02-29 21:03:14 -05:00
|
|
|
|
|
|
|
This can be called many times with new data as it is streamed.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
## Class: `KeyObject`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
<!-- YAML
|
2018-12-21 18:13:09 -05:00
|
|
|
added: v11.6.0
|
2019-03-11 21:26:22 +01:00
|
|
|
changes:
|
2020-09-28 10:54:13 -07:00
|
|
|
- version:
|
|
|
|
- v14.5.0
|
|
|
|
- v12.19.0
|
2020-05-11 17:55:37 +00:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/33360
|
|
|
|
description: Instances of this class can now be passed to worker threads
|
|
|
|
using `postMessage`.
|
2019-03-27 22:43:03 +01:00
|
|
|
- version: v11.13.0
|
2019-03-11 21:26:22 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26438
|
|
|
|
description: This class is now exported.
|
2018-09-20 19:53:44 +02:00
|
|
|
-->
|
|
|
|
|
2019-03-11 21:26:22 +01:00
|
|
|
Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key,
|
|
|
|
and each kind of key exposes different functions. The
|
|
|
|
[`crypto.createSecretKey()`][], [`crypto.createPublicKey()`][] and
|
|
|
|
[`crypto.createPrivateKey()`][] methods are used to create `KeyObject`
|
|
|
|
instances. `KeyObject` objects are not to be created directly using the `new`
|
|
|
|
keyword.
|
2018-09-20 19:53:44 +02:00
|
|
|
|
|
|
|
Most applications should consider using the new `KeyObject` API instead of
|
|
|
|
passing keys as strings or `Buffer`s due to improved security features.
|
|
|
|
|
2020-05-11 17:55:37 +00:00
|
|
|
`KeyObject` instances can be passed to other threads via [`postMessage()`][].
|
|
|
|
The receiver obtains a cloned `KeyObject`, and the `KeyObject` does not need to
|
|
|
|
be listed in the `transferList` argument.
|
|
|
|
|
2021-02-03 11:08:23 +01:00
|
|
|
### Static method: `KeyObject.from(key)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-02-03 11:08:23 +01:00
|
|
|
<!-- YAML
|
|
|
|
added: v15.0.0
|
|
|
|
-->
|
|
|
|
|
|
|
|
* `key` {CryptoKey}
|
|
|
|
* Returns: {KeyObject}
|
|
|
|
|
|
|
|
Example: Converting a `CryptoKey` instance to a `KeyObject`:
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-12-11 19:02:21 +01:00
|
|
|
const { KeyObject } = await import('node:crypto');
|
|
|
|
const { subtle } = globalThis.crypto;
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const key = await subtle.generateKey({
|
|
|
|
name: 'HMAC',
|
|
|
|
hash: 'SHA-256',
|
2022-11-17 08:19:12 -05:00
|
|
|
length: 256,
|
2021-03-03 14:25:03 -08:00
|
|
|
}, true, ['sign', 'verify']);
|
|
|
|
|
|
|
|
const keyObject = KeyObject.from(key);
|
|
|
|
console.log(keyObject.symmetricKeySize);
|
|
|
|
// Prints: 32 (symmetric key size in bytes)
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-12-11 19:02:21 +01:00
|
|
|
const { KeyObject } = require('node:crypto');
|
|
|
|
const { subtle } = globalThis.crypto;
|
2021-02-03 11:08:23 +01:00
|
|
|
|
|
|
|
(async function() {
|
|
|
|
const key = await subtle.generateKey({
|
|
|
|
name: 'HMAC',
|
|
|
|
hash: 'SHA-256',
|
2022-11-17 08:19:12 -05:00
|
|
|
length: 256,
|
2021-02-03 11:08:23 +01:00
|
|
|
}, true, ['sign', 'verify']);
|
|
|
|
|
|
|
|
const keyObject = KeyObject.from(key);
|
|
|
|
console.log(keyObject.symmetricKeySize);
|
|
|
|
// Prints: 32 (symmetric key size in bytes)
|
|
|
|
})();
|
|
|
|
```
|
|
|
|
|
2020-11-20 12:59:13 +01:00
|
|
|
### `keyObject.asymmetricKeyDetails`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-11-20 12:59:13 +01:00
|
|
|
<!-- YAML
|
2021-01-21 21:37:00 -05:00
|
|
|
added: v15.7.0
|
2021-08-23 12:34:30 +00:00
|
|
|
changes:
|
2021-09-06 09:44:13 +02:00
|
|
|
- version: v16.9.0
|
2021-08-23 12:34:30 +00:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/39851
|
|
|
|
description: Expose `RSASSA-PSS-params` sequence parameters
|
|
|
|
for RSA-PSS keys.
|
2020-11-20 12:59:13 +01:00
|
|
|
-->
|
|
|
|
|
|
|
|
* {Object}
|
|
|
|
* `modulusLength`: {number} Key size in bits (RSA, DSA).
|
|
|
|
* `publicExponent`: {bigint} Public exponent (RSA).
|
2021-08-23 12:34:30 +00:00
|
|
|
* `hashAlgorithm`: {string} Name of the message digest (RSA-PSS).
|
|
|
|
* `mgf1HashAlgorithm`: {string} Name of the message digest used by
|
|
|
|
MGF1 (RSA-PSS).
|
|
|
|
* `saltLength`: {number} Minimal salt length in bytes (RSA-PSS).
|
2020-11-20 12:59:13 +01:00
|
|
|
* `divisorLength`: {number} Size of `q` in bits (DSA).
|
|
|
|
* `namedCurve`: {string} Name of the curve (EC).
|
|
|
|
|
|
|
|
This property exists only on asymmetric keys. Depending on the type of the key,
|
|
|
|
this object contains information about the key. None of the information obtained
|
|
|
|
through this property can be used to uniquely identify a key or to compromise
|
|
|
|
the security of the key.
|
|
|
|
|
2021-08-23 12:34:30 +00:00
|
|
|
For RSA-PSS keys, if the key material contains a `RSASSA-PSS-params` sequence,
|
|
|
|
the `hashAlgorithm`, `mgf1HashAlgorithm`, and `saltLength` properties will be
|
|
|
|
set.
|
|
|
|
|
|
|
|
Other key details might be exposed via this API using additional attributes.
|
2020-11-20 12:59:13 +01:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `keyObject.asymmetricKeyType`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
<!-- YAML
|
2018-12-21 18:13:09 -05:00
|
|
|
added: v11.6.0
|
2019-02-26 05:24:38 -05:00
|
|
|
changes:
|
2020-05-01 14:43:14 +02:00
|
|
|
- version:
|
|
|
|
- v13.9.0
|
|
|
|
- v12.17.0
|
2019-12-29 15:52:01 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/31178
|
|
|
|
description: Added support for `'dh'`.
|
2019-03-22 13:19:46 +00:00
|
|
|
- version: v12.0.0
|
2019-03-16 23:51:26 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26960
|
2020-10-01 20:35:23 +02:00
|
|
|
description: Added support for `'rsa-pss'`.
|
2019-03-22 13:19:46 +00:00
|
|
|
- version: v12.0.0
|
2019-03-19 21:38:23 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26786
|
|
|
|
description: This property now returns `undefined` for KeyObject
|
|
|
|
instances of unrecognized type instead of aborting.
|
2019-03-22 13:19:46 +00:00
|
|
|
- version: v12.0.0
|
2019-03-19 12:09:01 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26774
|
2020-10-01 20:35:23 +02:00
|
|
|
description: Added support for `'x25519'` and `'x448'`.
|
2019-03-22 13:19:46 +00:00
|
|
|
- version: v12.0.0
|
2019-02-26 05:24:38 -05:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26319
|
2019-03-19 21:38:23 +01:00
|
|
|
description: Added support for `'ed25519'` and `'ed448'`.
|
2018-09-20 19:53:44 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
* {string}
|
|
|
|
|
2019-03-16 23:51:26 +01:00
|
|
|
For asymmetric keys, this property represents the type of the key. Supported key
|
|
|
|
types are:
|
|
|
|
|
|
|
|
* `'rsa'` (OID 1.2.840.113549.1.1.1)
|
|
|
|
* `'rsa-pss'` (OID 1.2.840.113549.1.1.10)
|
|
|
|
* `'dsa'` (OID 1.2.840.10040.4.1)
|
|
|
|
* `'ec'` (OID 1.2.840.10045.2.1)
|
|
|
|
* `'x25519'` (OID 1.3.101.110)
|
|
|
|
* `'x448'` (OID 1.3.101.111)
|
|
|
|
* `'ed25519'` (OID 1.3.101.112)
|
|
|
|
* `'ed448'` (OID 1.3.101.113)
|
2019-12-29 15:52:01 +01:00
|
|
|
* `'dh'` (OID 1.2.840.113549.1.3.1)
|
2019-03-16 23:51:26 +01:00
|
|
|
|
2019-03-19 21:38:23 +01:00
|
|
|
This property is `undefined` for unrecognized `KeyObject` types and symmetric
|
|
|
|
keys.
|
2018-09-20 19:53:44 +02:00
|
|
|
|
2024-11-23 18:10:44 +01:00
|
|
|
### `keyObject.equals(otherKeyObject)`
|
|
|
|
|
|
|
|
<!-- YAML
|
|
|
|
added:
|
|
|
|
- v17.7.0
|
|
|
|
- v16.15.0
|
|
|
|
-->
|
|
|
|
|
|
|
|
* `otherKeyObject`: {KeyObject} A `KeyObject` with which to
|
|
|
|
compare `keyObject`.
|
|
|
|
* Returns: {boolean}
|
|
|
|
|
|
|
|
Returns `true` or `false` depending on whether the keys have exactly the same
|
|
|
|
type, value, and parameters. This method is not
|
|
|
|
[constant time](https://en.wikipedia.org/wiki/Timing_attack).
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `keyObject.export([options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
<!-- YAML
|
2018-12-21 18:13:09 -05:00
|
|
|
added: v11.6.0
|
crypto: add keyObject.export() 'jwk' format option
Adds [JWK](https://tools.ietf.org/html/rfc7517) keyObject.export format
option.
Supported key types: `ec`, `rsa`, `ed25519`, `ed448`, `x25519`, `x448`,
and symmetric keys, resulting in JWK `kty` (Key Type) values `EC`,
`RSA`, `OKP`, and `oct`.
`rsa-pss` is not supported since the JWK format does not support
PSS Parameters.
`EC` JWK curves supported are `P-256`, `secp256k1`, `P-384`, and `P-521`
PR-URL: https://github.com/nodejs/node/pull/37081
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 18:21:14 +01:00
|
|
|
changes:
|
2021-02-17 08:16:22 -05:00
|
|
|
- version: v15.9.0
|
crypto: add keyObject.export() 'jwk' format option
Adds [JWK](https://tools.ietf.org/html/rfc7517) keyObject.export format
option.
Supported key types: `ec`, `rsa`, `ed25519`, `ed448`, `x25519`, `x448`,
and symmetric keys, resulting in JWK `kty` (Key Type) values `EC`,
`RSA`, `OKP`, and `oct`.
`rsa-pss` is not supported since the JWK format does not support
PSS Parameters.
`EC` JWK curves supported are `P-256`, `secp256k1`, `P-384`, and `P-521`
PR-URL: https://github.com/nodejs/node/pull/37081
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 18:21:14 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/37081
|
|
|
|
description: Added support for `'jwk'` format.
|
2018-09-20 19:53:44 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
* `options`: {Object}
|
crypto: add keyObject.export() 'jwk' format option
Adds [JWK](https://tools.ietf.org/html/rfc7517) keyObject.export format
option.
Supported key types: `ec`, `rsa`, `ed25519`, `ed448`, `x25519`, `x448`,
and symmetric keys, resulting in JWK `kty` (Key Type) values `EC`,
`RSA`, `OKP`, and `oct`.
`rsa-pss` is not supported since the JWK format does not support
PSS Parameters.
`EC` JWK curves supported are `P-256`, `secp256k1`, `P-384`, and `P-521`
PR-URL: https://github.com/nodejs/node/pull/37081
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 18:21:14 +01:00
|
|
|
* Returns: {string | Buffer | Object}
|
2018-09-20 19:53:44 +02:00
|
|
|
|
crypto: add keyObject.export() 'jwk' format option
Adds [JWK](https://tools.ietf.org/html/rfc7517) keyObject.export format
option.
Supported key types: `ec`, `rsa`, `ed25519`, `ed448`, `x25519`, `x448`,
and symmetric keys, resulting in JWK `kty` (Key Type) values `EC`,
`RSA`, `OKP`, and `oct`.
`rsa-pss` is not supported since the JWK format does not support
PSS Parameters.
`EC` JWK curves supported are `P-256`, `secp256k1`, `P-384`, and `P-521`
PR-URL: https://github.com/nodejs/node/pull/37081
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 18:21:14 +01:00
|
|
|
For symmetric keys, the following encoding options can be used:
|
2018-09-20 19:53:44 +02:00
|
|
|
|
crypto: add keyObject.export() 'jwk' format option
Adds [JWK](https://tools.ietf.org/html/rfc7517) keyObject.export format
option.
Supported key types: `ec`, `rsa`, `ed25519`, `ed448`, `x25519`, `x448`,
and symmetric keys, resulting in JWK `kty` (Key Type) values `EC`,
`RSA`, `OKP`, and `oct`.
`rsa-pss` is not supported since the JWK format does not support
PSS Parameters.
`EC` JWK curves supported are `P-256`, `secp256k1`, `P-384`, and `P-521`
PR-URL: https://github.com/nodejs/node/pull/37081
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 18:21:14 +01:00
|
|
|
* `format`: {string} Must be `'buffer'` (default) or `'jwk'`.
|
2018-09-20 19:53:44 +02:00
|
|
|
|
|
|
|
For public keys, the following encoding options can be used:
|
|
|
|
|
|
|
|
* `type`: {string} Must be one of `'pkcs1'` (RSA only) or `'spki'`.
|
crypto: add keyObject.export() 'jwk' format option
Adds [JWK](https://tools.ietf.org/html/rfc7517) keyObject.export format
option.
Supported key types: `ec`, `rsa`, `ed25519`, `ed448`, `x25519`, `x448`,
and symmetric keys, resulting in JWK `kty` (Key Type) values `EC`,
`RSA`, `OKP`, and `oct`.
`rsa-pss` is not supported since the JWK format does not support
PSS Parameters.
`EC` JWK curves supported are `P-256`, `secp256k1`, `P-384`, and `P-521`
PR-URL: https://github.com/nodejs/node/pull/37081
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 18:21:14 +01:00
|
|
|
* `format`: {string} Must be `'pem'`, `'der'`, or `'jwk'`.
|
2018-09-20 19:53:44 +02:00
|
|
|
|
|
|
|
For private keys, the following encoding options can be used:
|
|
|
|
|
|
|
|
* `type`: {string} Must be one of `'pkcs1'` (RSA only), `'pkcs8'` or
|
|
|
|
`'sec1'` (EC only).
|
crypto: add keyObject.export() 'jwk' format option
Adds [JWK](https://tools.ietf.org/html/rfc7517) keyObject.export format
option.
Supported key types: `ec`, `rsa`, `ed25519`, `ed448`, `x25519`, `x448`,
and symmetric keys, resulting in JWK `kty` (Key Type) values `EC`,
`RSA`, `OKP`, and `oct`.
`rsa-pss` is not supported since the JWK format does not support
PSS Parameters.
`EC` JWK curves supported are `P-256`, `secp256k1`, `P-384`, and `P-521`
PR-URL: https://github.com/nodejs/node/pull/37081
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 18:21:14 +01:00
|
|
|
* `format`: {string} Must be `'pem'`, `'der'`, or `'jwk'`.
|
2018-09-20 19:53:44 +02:00
|
|
|
* `cipher`: {string} If specified, the private key will be encrypted with
|
2021-10-10 21:55:04 -07:00
|
|
|
the given `cipher` and `passphrase` using PKCS#5 v2.0 password based
|
|
|
|
encryption.
|
2018-09-20 19:53:44 +02:00
|
|
|
* `passphrase`: {string | Buffer} The passphrase to use for encryption, see
|
|
|
|
`cipher`.
|
|
|
|
|
crypto: add keyObject.export() 'jwk' format option
Adds [JWK](https://tools.ietf.org/html/rfc7517) keyObject.export format
option.
Supported key types: `ec`, `rsa`, `ed25519`, `ed448`, `x25519`, `x448`,
and symmetric keys, resulting in JWK `kty` (Key Type) values `EC`,
`RSA`, `OKP`, and `oct`.
`rsa-pss` is not supported since the JWK format does not support
PSS Parameters.
`EC` JWK curves supported are `P-256`, `secp256k1`, `P-384`, and `P-521`
PR-URL: https://github.com/nodejs/node/pull/37081
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 18:21:14 +01:00
|
|
|
The result type depends on the selected encoding format, when PEM the
|
|
|
|
result is a string, when DER it will be a buffer containing the data
|
|
|
|
encoded as DER, when [JWK][] it will be an object.
|
|
|
|
|
|
|
|
When [JWK][] encoding format was selected, all other encoding options are
|
|
|
|
ignored.
|
2018-09-20 19:53:44 +02:00
|
|
|
|
2018-10-13 01:29:46 +02:00
|
|
|
PKCS#1, SEC1, and PKCS#8 type keys can be encrypted by using a combination of
|
|
|
|
the `cipher` and `format` options. The PKCS#8 `type` can be used with any
|
|
|
|
`format` to encrypt any key algorithm (RSA, EC, or DH) by specifying a
|
|
|
|
`cipher`. PKCS#1 and SEC1 can only be encrypted by specifying a `cipher`
|
|
|
|
when the PEM `format` is used. For maximum compatibility, use PKCS#8 for
|
|
|
|
encrypted private keys. Since PKCS#8 defines its own
|
|
|
|
encryption mechanism, PEM-level encryption is not supported when encrypting
|
|
|
|
a PKCS#8 key. See [RFC 5208][] for PKCS#8 encryption and [RFC 1421][] for
|
|
|
|
PKCS#1 and SEC1 encryption.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `keyObject.symmetricKeySize`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
<!-- YAML
|
2018-12-21 18:13:09 -05:00
|
|
|
added: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
* {number}
|
|
|
|
|
|
|
|
For secret keys, this property represents the size of the key in bytes. This
|
|
|
|
property is `undefined` for asymmetric keys.
|
|
|
|
|
2024-10-06 20:09:02 +02:00
|
|
|
### `keyObject.toCryptoKey(algorithm, extractable, keyUsages)`
|
|
|
|
|
|
|
|
<!-- YAML
|
2024-10-10 00:12:22 +02:00
|
|
|
added:
|
|
|
|
- v23.0.0
|
|
|
|
- v22.10.0
|
2024-10-06 20:09:02 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
|
|
|
|
|
|
|
* `algorithm`: {AlgorithmIdentifier|RsaHashedImportParams|EcKeyImportParams|HmacImportParams}
|
|
|
|
|
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
|
|
|
|
|
|
|
* `extractable`: {boolean}
|
|
|
|
* `keyUsages`: {string\[]} See [Key usages][].
|
|
|
|
* Returns: {CryptoKey}
|
|
|
|
|
|
|
|
Converts a `KeyObject` instance to a `CryptoKey`.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `keyObject.type`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
<!-- YAML
|
2018-12-21 18:13:09 -05:00
|
|
|
added: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
* {string}
|
|
|
|
|
|
|
|
Depending on the type of this `KeyObject`, this property is either
|
|
|
|
`'secret'` for secret (symmetric) keys, `'public'` for public (asymmetric) keys
|
|
|
|
or `'private'` for private (asymmetric) keys.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
## Class: `Sign`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
|
|
|
-->
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2019-08-24 18:16:48 -07:00
|
|
|
* Extends: {stream.Writable}
|
|
|
|
|
2019-01-11 11:43:58 -08:00
|
|
|
The `Sign` class is a utility for generating signatures. It can be used in one
|
2015-12-26 20:54:01 -08:00
|
|
|
of two ways:
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2019-09-13 00:22:29 -04:00
|
|
|
* As a writable [stream][], where data to be signed is written and the
|
2016-02-15 03:40:53 +03:00
|
|
|
[`sign.sign()`][] method is used to generate and return the signature, or
|
2019-09-13 00:22:29 -04:00
|
|
|
* Using the [`sign.update()`][] and [`sign.sign()`][] methods to produce the
|
2015-12-26 20:54:01 -08:00
|
|
|
signature.
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2017-09-09 18:41:56 -04:00
|
|
|
The [`crypto.createSign()`][] method is used to create `Sign` instances. The
|
|
|
|
argument is the string name of the hash function to use. `Sign` objects are not
|
|
|
|
to be created directly using the `new` keyword.
|
2012-10-30 15:46:43 -07:00
|
|
|
|
2019-01-11 11:43:58 -08:00
|
|
|
Example: Using `Sign` and [`Verify`][] objects as streams:
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
|
|
|
generateKeyPairSync,
|
|
|
|
createSign,
|
2022-11-17 08:19:12 -05:00
|
|
|
createVerify,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2013-10-04 12:59:38 +01:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const { privateKey, publicKey } = generateKeyPairSync('ec', {
|
2022-11-17 08:19:12 -05:00
|
|
|
namedCurve: 'sect239k1',
|
2019-01-11 11:43:58 -08:00
|
|
|
});
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const sign = createSign('SHA256');
|
2016-01-17 18:39:07 +01:00
|
|
|
sign.write('some data to sign');
|
|
|
|
sign.end();
|
2019-01-11 11:43:58 -08:00
|
|
|
const signature = sign.sign(privateKey, 'hex');
|
2013-10-04 12:59:38 +01:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const verify = createVerify('SHA256');
|
|
|
|
verify.write('some data to sign');
|
|
|
|
verify.end();
|
|
|
|
console.log(verify.verify(publicKey, signature, 'hex'));
|
|
|
|
// Prints: true
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
generateKeyPairSync,
|
|
|
|
createSign,
|
|
|
|
createVerify,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const { privateKey, publicKey } = generateKeyPairSync('ec', {
|
2022-11-17 08:19:12 -05:00
|
|
|
namedCurve: 'sect239k1',
|
2021-03-03 14:25:03 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
const sign = createSign('SHA256');
|
|
|
|
sign.write('some data to sign');
|
|
|
|
sign.end();
|
|
|
|
const signature = sign.sign(privateKey, 'hex');
|
|
|
|
|
|
|
|
const verify = createVerify('SHA256');
|
2019-01-11 11:43:58 -08:00
|
|
|
verify.write('some data to sign');
|
|
|
|
verify.end();
|
2020-01-11 15:07:49 +08:00
|
|
|
console.log(verify.verify(publicKey, signature, 'hex'));
|
|
|
|
// Prints: true
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2019-01-11 11:43:58 -08:00
|
|
|
Example: Using the [`sign.update()`][] and [`verify.update()`][] methods:
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
|
|
|
generateKeyPairSync,
|
|
|
|
createSign,
|
2022-11-17 08:19:12 -05:00
|
|
|
createVerify,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const { privateKey, publicKey } = generateKeyPairSync('rsa', {
|
|
|
|
modulusLength: 2048,
|
|
|
|
});
|
|
|
|
|
|
|
|
const sign = createSign('SHA256');
|
|
|
|
sign.update('some data to sign');
|
|
|
|
sign.end();
|
|
|
|
const signature = sign.sign(privateKey);
|
|
|
|
|
|
|
|
const verify = createVerify('SHA256');
|
|
|
|
verify.update('some data to sign');
|
|
|
|
verify.end();
|
|
|
|
console.log(verify.verify(publicKey, signature));
|
|
|
|
// Prints: true
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
generateKeyPairSync,
|
|
|
|
createSign,
|
|
|
|
createVerify,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2016-04-07 15:38:00 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const { privateKey, publicKey } = generateKeyPairSync('rsa', {
|
2019-01-11 11:43:58 -08:00
|
|
|
modulusLength: 2048,
|
|
|
|
});
|
2016-04-07 15:38:00 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const sign = createSign('SHA256');
|
2016-04-07 15:38:00 -07:00
|
|
|
sign.update('some data to sign');
|
2019-01-11 11:43:58 -08:00
|
|
|
sign.end();
|
|
|
|
const signature = sign.sign(privateKey);
|
2016-04-07 15:38:00 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const verify = createVerify('SHA256');
|
2019-01-11 11:43:58 -08:00
|
|
|
verify.update('some data to sign');
|
|
|
|
verify.end();
|
|
|
|
console.log(verify.verify(publicKey, signature));
|
|
|
|
// Prints: true
|
2016-04-07 15:38:00 -07:00
|
|
|
```
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `sign.sign(privateKey[, outputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
2017-03-06 00:41:26 +01:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The privateKey can also be an ArrayBuffer and CryptoKey.
|
2020-10-12 12:38:29 +02:00
|
|
|
- version:
|
|
|
|
- v13.2.0
|
2020-11-08 13:35:46 +01:00
|
|
|
- v12.16.0
|
2020-10-12 12:38:29 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/29292
|
|
|
|
description: This function now supports IEEE-P1363 DSA and ECDSA signatures.
|
2019-03-22 13:19:46 +00:00
|
|
|
- version: v12.0.0
|
2019-03-16 23:51:26 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26960
|
|
|
|
description: This function now supports RSA-PSS keys.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: This function now supports key objects.
|
2017-03-15 20:26:14 -07:00
|
|
|
- version: v8.0.0
|
2017-03-06 00:41:26 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/11705
|
|
|
|
description: Support for RSASSA-PSS and additional options was added.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `privateKey` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
2019-08-21 00:05:55 +02:00
|
|
|
* `dsaEncoding` {string}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `padding` {integer}
|
|
|
|
* `saltLength` {integer}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `outputEncoding` {string} The [encoding][] of the return value.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer | string}
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
Calculates the signature on all the data passed through using either
|
2016-02-15 03:40:53 +03:00
|
|
|
[`sign.update()`][] or [`sign.write()`][stream-writable-write].
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
If `privateKey` is not a [`KeyObject`][], this function behaves as if
|
|
|
|
`privateKey` had been passed to [`crypto.createPrivateKey()`][]. If it is an
|
|
|
|
object, the following additional properties can be passed:
|
2013-10-04 12:59:38 +01:00
|
|
|
|
2019-08-21 00:05:55 +02:00
|
|
|
* `dsaEncoding` {string} For DSA and ECDSA, this option specifies the
|
|
|
|
format of the generated signature. It can be one of the following:
|
|
|
|
* `'der'` (default): DER-encoded ASN.1 signature structure encoding `(r, s)`.
|
|
|
|
* `'ieee-p1363'`: Signature format `r || s` as proposed in IEEE-P1363.
|
2019-10-23 21:28:42 -07:00
|
|
|
* `padding` {integer} Optional padding value for RSA, one of the following:
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2017-03-06 00:41:26 +01:00
|
|
|
* `crypto.constants.RSA_PKCS1_PADDING` (default)
|
|
|
|
* `crypto.constants.RSA_PKCS1_PSS_PADDING`
|
|
|
|
|
2019-06-20 14:01:15 -06:00
|
|
|
`RSA_PKCS1_PSS_PADDING` will use MGF1 with the same hash function
|
2019-03-16 23:51:26 +01:00
|
|
|
used to sign the message as specified in section 3.1 of [RFC 4055][], unless
|
|
|
|
an MGF1 hash function has been specified as part of the key in compliance with
|
|
|
|
section 3.3 of [RFC 4055][].
|
2019-10-23 21:28:42 -07:00
|
|
|
* `saltLength` {integer} Salt length for when padding is
|
2017-03-06 00:41:26 +01:00
|
|
|
`RSA_PKCS1_PSS_PADDING`. The special value
|
|
|
|
`crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest
|
|
|
|
size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the
|
|
|
|
maximum permissible value.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2018-11-07 12:27:47 -08:00
|
|
|
If `outputEncoding` is provided a string is returned; otherwise a [`Buffer`][]
|
|
|
|
is returned.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `Sign` object can not be again used after `sign.sign()` method has been
|
|
|
|
called. Multiple calls to `sign.sign()` will result in an error being thrown.
|
2011-07-30 03:03:58 +09:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `sign.update(data[, inputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
2017-06-06 11:00:32 +02:00
|
|
|
description: The default `inputEncoding` changed from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `data` {string|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `inputEncoding` {string} The [encoding][] of the `data` string.
|
2016-02-29 21:03:14 -05:00
|
|
|
|
|
|
|
Updates the `Sign` content with the given `data`, the encoding of which
|
2018-11-07 12:27:47 -08:00
|
|
|
is given in `inputEncoding`.
|
|
|
|
If `encoding` is not provided, and the `data` is a string, an
|
2017-04-04 15:59:30 -07:00
|
|
|
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray`, or
|
2017-06-06 11:00:32 +02:00
|
|
|
`DataView`, then `inputEncoding` is ignored.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2016-02-29 21:03:14 -05:00
|
|
|
This can be called many times with new data as it is streamed.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
## Class: `Verify`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
|
|
|
-->
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2019-08-24 18:16:48 -07:00
|
|
|
* Extends: {stream.Writable}
|
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `Verify` class is a utility for verifying signatures. It can be used in one
|
|
|
|
of two ways:
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2019-09-13 00:22:29 -04:00
|
|
|
* As a writable [stream][] where written data is used to validate against the
|
2015-12-26 20:54:01 -08:00
|
|
|
supplied signature, or
|
2019-09-13 00:22:29 -04:00
|
|
|
* Using the [`verify.update()`][] and [`verify.verify()`][] methods to verify
|
2016-02-15 03:40:53 +03:00
|
|
|
the signature.
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2016-11-25 15:07:24 +08:00
|
|
|
The [`crypto.createVerify()`][] method is used to create `Verify` instances.
|
|
|
|
`Verify` objects are not to be created directly using the `new` keyword.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2019-01-11 11:43:58 -08:00
|
|
|
See [`Sign`][] for examples.
|
2012-10-30 15:46:43 -07:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `verify.update(data[, inputEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
2017-06-06 11:00:32 +02:00
|
|
|
description: The default `inputEncoding` changed from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `data` {string|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `inputEncoding` {string} The [encoding][] of the `data` string.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2016-02-29 21:03:14 -05:00
|
|
|
Updates the `Verify` content with the given `data`, the encoding of which
|
2018-11-07 12:27:47 -08:00
|
|
|
is given in `inputEncoding`.
|
|
|
|
If `inputEncoding` is not provided, and the `data` is a string, an
|
2017-04-04 15:59:30 -07:00
|
|
|
encoding of `'utf8'` is enforced. If `data` is a [`Buffer`][], `TypedArray`, or
|
2017-06-06 11:00:32 +02:00
|
|
|
`DataView`, then `inputEncoding` is ignored.
|
2016-02-29 21:03:14 -05:00
|
|
|
|
|
|
|
This can be called many times with new data as it is streamed.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `verify.verify(object, signature[, signatureEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
2017-03-06 00:41:26 +01:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The object can also be an ArrayBuffer and CryptoKey.
|
2020-10-12 12:38:29 +02:00
|
|
|
- version:
|
|
|
|
- v13.2.0
|
2020-11-08 13:35:46 +01:00
|
|
|
- v12.16.0
|
2020-10-12 12:38:29 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/29292
|
|
|
|
description: This function now supports IEEE-P1363 DSA and ECDSA signatures.
|
2019-03-22 13:19:46 +00:00
|
|
|
- version: v12.0.0
|
2019-03-16 23:51:26 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26960
|
|
|
|
description: This function now supports RSA-PSS keys.
|
2019-01-16 15:55:55 +01:00
|
|
|
- version: v11.7.0
|
2018-12-25 13:13:52 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/25217
|
|
|
|
description: The key can now be a private key.
|
2017-03-15 20:26:14 -07:00
|
|
|
- version: v8.0.0
|
2017-03-06 00:41:26 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/11705
|
|
|
|
description: Support for RSASSA-PSS and additional options was added.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `object` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
2019-08-21 00:05:55 +02:00
|
|
|
* `dsaEncoding` {string}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `padding` {integer}
|
|
|
|
* `saltLength` {integer}
|
2020-08-25 10:05:51 -07:00
|
|
|
* `signature` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `signatureEncoding` {string} The [encoding][] of the `signature` string.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {boolean} `true` or `false` depending on the validity of the
|
2018-04-06 18:28:20 +03:00
|
|
|
signature for the data and public key.
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Verifies the provided data using the given `object` and `signature`.
|
2017-03-06 00:41:26 +01:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
If `object` is not a [`KeyObject`][], this function behaves as if
|
|
|
|
`object` had been passed to [`crypto.createPublicKey()`][]. If it is an
|
|
|
|
object, the following additional properties can be passed:
|
|
|
|
|
2019-08-21 00:05:55 +02:00
|
|
|
* `dsaEncoding` {string} For DSA and ECDSA, this option specifies the
|
2021-02-20 21:02:31 +01:00
|
|
|
format of the signature. It can be one of the following:
|
2019-08-21 00:05:55 +02:00
|
|
|
* `'der'` (default): DER-encoded ASN.1 signature structure encoding `(r, s)`.
|
|
|
|
* `'ieee-p1363'`: Signature format `r || s` as proposed in IEEE-P1363.
|
2019-10-23 21:28:42 -07:00
|
|
|
* `padding` {integer} Optional padding value for RSA, one of the following:
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2017-03-06 00:41:26 +01:00
|
|
|
* `crypto.constants.RSA_PKCS1_PADDING` (default)
|
|
|
|
* `crypto.constants.RSA_PKCS1_PSS_PADDING`
|
|
|
|
|
2019-06-20 14:01:15 -06:00
|
|
|
`RSA_PKCS1_PSS_PADDING` will use MGF1 with the same hash function
|
2019-03-16 23:51:26 +01:00
|
|
|
used to verify the message as specified in section 3.1 of [RFC 4055][], unless
|
|
|
|
an MGF1 hash function has been specified as part of the key in compliance with
|
|
|
|
section 3.3 of [RFC 4055][].
|
2019-10-23 21:28:42 -07:00
|
|
|
* `saltLength` {integer} Salt length for when padding is
|
2017-03-06 00:41:26 +01:00
|
|
|
`RSA_PKCS1_PSS_PADDING`. The special value
|
|
|
|
`crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest
|
|
|
|
size, `crypto.constants.RSA_PSS_SALTLEN_AUTO` (default) causes it to be
|
|
|
|
determined automatically.
|
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `signature` argument is the previously calculated signature for the data, in
|
2018-11-07 12:27:47 -08:00
|
|
|
the `signatureEncoding`.
|
|
|
|
If a `signatureEncoding` is specified, the `signature` is expected to be a
|
2017-04-04 15:59:30 -07:00
|
|
|
string; otherwise `signature` is expected to be a [`Buffer`][],
|
|
|
|
`TypedArray`, or `DataView`.
|
2010-10-28 23:18:16 +11:00
|
|
|
|
2017-07-25 09:16:01 +02:00
|
|
|
The `verify` object can not be used again after `verify.verify()` has been
|
2015-12-26 20:54:01 -08:00
|
|
|
called. Multiple calls to `verify.verify()` will result in an error being
|
|
|
|
thrown.
|
2011-07-30 03:03:58 +09:00
|
|
|
|
2018-12-25 13:13:52 +01:00
|
|
|
Because public keys can be derived from private keys, a private key may
|
|
|
|
be passed instead of a public key.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
## Class: `X509Certificate`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
Encapsulates an X509 certificate and provides read-only access to
|
2021-01-13 16:22:14 +01:00
|
|
|
its information.
|
2021-01-04 21:27:20 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { X509Certificate } = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const x509 = new X509Certificate('{... pem encoded cert ...}');
|
|
|
|
|
|
|
|
console.log(x509.subject);
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { X509Certificate } = require('node:crypto');
|
2021-01-04 21:27:20 -08:00
|
|
|
|
|
|
|
const x509 = new X509Certificate('{... pem encoded cert ...}');
|
|
|
|
|
|
|
|
console.log(x509.subject);
|
|
|
|
```
|
|
|
|
|
|
|
|
### `new X509Certificate(buffer)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `buffer` {string|TypedArray|Buffer|DataView} A PEM or DER encoded
|
|
|
|
X509 Certificate.
|
|
|
|
|
|
|
|
### `x509.ca`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
2022-02-04 04:46:30 +01:00
|
|
|
* Type: {boolean} Will be `true` if this is a Certificate Authority (CA)
|
2021-01-04 21:27:20 -08:00
|
|
|
certificate.
|
|
|
|
|
|
|
|
### `x509.checkEmail(email[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2022-01-17 14:35:47 +00:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-19 19:05:53 +00:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/41600
|
|
|
|
description: The subject option now defaults to `'default'`.
|
2022-03-03 10:26:49 -05:00
|
|
|
- version:
|
|
|
|
- v17.5.0
|
|
|
|
- v16.14.1
|
2022-01-19 18:12:13 +00:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/41599
|
|
|
|
description: The `wildcards`, `partialWildcards`, `multiLabelWildcards`, and
|
|
|
|
`singleLabelSubdomains` options have been removed since they
|
|
|
|
had no effect.
|
2022-04-23 21:03:46 -04:00
|
|
|
- version:
|
|
|
|
- v17.5.0
|
|
|
|
- v16.15.0
|
2022-01-17 14:35:47 +00:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/41569
|
|
|
|
description: The subject option can now be set to `'default'`.
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `email` {string}
|
|
|
|
* `options` {Object}
|
2022-01-17 14:35:47 +00:00
|
|
|
* `subject` {string} `'default'`, `'always'`, or `'never'`.
|
2022-01-19 19:05:53 +00:00
|
|
|
**Default:** `'default'`.
|
2021-01-04 21:27:20 -08:00
|
|
|
* Returns: {string|undefined} Returns `email` if the certificate matches,
|
|
|
|
`undefined` if it does not.
|
|
|
|
|
|
|
|
Checks whether the certificate matches the given email address.
|
|
|
|
|
2022-01-19 19:05:53 +00:00
|
|
|
If the `'subject'` option is undefined or set to `'default'`, the certificate
|
|
|
|
subject is only considered if the subject alternative name extension either does
|
|
|
|
not exist or does not contain any email addresses.
|
|
|
|
|
2022-01-17 14:35:47 +00:00
|
|
|
If the `'subject'` option is set to `'always'` and if the subject alternative
|
|
|
|
name extension either does not exist or does not contain a matching email
|
|
|
|
address, the certificate subject is considered.
|
|
|
|
|
|
|
|
If the `'subject'` option is set to `'never'`, the certificate subject is never
|
|
|
|
considered, even if the certificate contains no subject alternative names.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.checkHost(name[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2022-01-17 14:35:47 +00:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-19 19:05:53 +00:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/41600
|
|
|
|
description: The subject option now defaults to `'default'`.
|
2022-04-23 21:03:46 -04:00
|
|
|
- version:
|
|
|
|
- v17.5.0
|
|
|
|
- v16.15.0
|
2022-01-17 14:35:47 +00:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/41569
|
|
|
|
description: The subject option can now be set to `'default'`.
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `name` {string}
|
|
|
|
* `options` {Object}
|
2022-01-17 14:35:47 +00:00
|
|
|
* `subject` {string} `'default'`, `'always'`, or `'never'`.
|
2022-01-19 19:05:53 +00:00
|
|
|
**Default:** `'default'`.
|
2021-02-15 13:21:50 -05:00
|
|
|
* `wildcards` {boolean} **Default:** `true`.
|
|
|
|
* `partialWildcards` {boolean} **Default:** `true`.
|
|
|
|
* `multiLabelWildcards` {boolean} **Default:** `false`.
|
|
|
|
* `singleLabelSubdomains` {boolean} **Default:** `false`.
|
2022-01-11 03:39:51 +01:00
|
|
|
* Returns: {string|undefined} Returns a subject name that matches `name`,
|
|
|
|
or `undefined` if no subject name matches `name`.
|
2021-01-04 21:27:20 -08:00
|
|
|
|
|
|
|
Checks whether the certificate matches the given host name.
|
|
|
|
|
2022-01-11 03:39:51 +01:00
|
|
|
If the certificate matches the given host name, the matching subject name is
|
|
|
|
returned. The returned name might be an exact match (e.g., `foo.example.com`)
|
|
|
|
or it might contain wildcards (e.g., `*.example.com`). Because host name
|
|
|
|
comparisons are case-insensitive, the returned subject name might also differ
|
|
|
|
from the given `name` in capitalization.
|
|
|
|
|
2022-01-19 19:05:53 +00:00
|
|
|
If the `'subject'` option is undefined or set to `'default'`, the certificate
|
|
|
|
subject is only considered if the subject alternative name extension either does
|
|
|
|
not exist or does not contain any DNS names. This behavior is consistent with
|
|
|
|
[RFC 2818][] ("HTTP Over TLS").
|
|
|
|
|
2022-01-17 14:35:47 +00:00
|
|
|
If the `'subject'` option is set to `'always'` and if the subject alternative
|
|
|
|
name extension either does not exist or does not contain a matching DNS name,
|
|
|
|
the certificate subject is considered.
|
|
|
|
|
|
|
|
If the `'subject'` option is set to `'never'`, the certificate subject is never
|
|
|
|
considered, even if the certificate contains no subject alternative names.
|
|
|
|
|
2022-01-17 15:48:51 +00:00
|
|
|
### `x509.checkIP(ip)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2022-01-17 15:48:51 +00:00
|
|
|
changes:
|
2022-03-03 10:26:49 -05:00
|
|
|
- version:
|
|
|
|
- v17.5.0
|
|
|
|
- v16.14.1
|
2022-01-17 15:48:51 +00:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/41571
|
|
|
|
description: The `options` argument has been removed since it had no effect.
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `ip` {string}
|
|
|
|
* Returns: {string|undefined} Returns `ip` if the certificate matches,
|
|
|
|
`undefined` if it does not.
|
|
|
|
|
|
|
|
Checks whether the certificate matches the given IP address (IPv4 or IPv6).
|
|
|
|
|
2022-01-17 15:48:51 +00:00
|
|
|
Only [RFC 5280][] `iPAddress` subject alternative names are considered, and they
|
|
|
|
must match the given `ip` address exactly. Other subject alternative names as
|
|
|
|
well as the subject field of the certificate are ignored.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.checkIssued(otherCert)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `otherCert` {X509Certificate}
|
|
|
|
* Returns: {boolean}
|
|
|
|
|
|
|
|
Checks whether this certificate was issued by the given `otherCert`.
|
|
|
|
|
|
|
|
### `x509.checkPrivateKey(privateKey)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `privateKey` {KeyObject} A private key.
|
|
|
|
* Returns: {boolean}
|
|
|
|
|
|
|
|
Checks whether the public key for this certificate is consistent with
|
|
|
|
the given private key.
|
|
|
|
|
2024-11-23 18:10:44 +01:00
|
|
|
### `x509.extKeyUsage`
|
|
|
|
|
|
|
|
<!-- YAML
|
|
|
|
added: v15.6.0
|
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string\[]}
|
|
|
|
|
|
|
|
An array detailing the key extended usages for this certificate.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.fingerprint`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
|
|
|
The SHA-1 fingerprint of this certificate.
|
|
|
|
|
2022-04-01 12:35:27 +02:00
|
|
|
Because SHA-1 is cryptographically broken and because the security of SHA-1 is
|
|
|
|
significantly worse than that of algorithms that are commonly used to sign
|
|
|
|
certificates, consider using [`x509.fingerprint256`][] instead.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.fingerprint256`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
|
|
|
The SHA-256 fingerprint of this certificate.
|
|
|
|
|
2021-08-30 15:31:28 +09:00
|
|
|
### `x509.fingerprint512`
|
2021-11-10 09:16:43 -08:00
|
|
|
|
2021-08-30 15:31:28 +09:00
|
|
|
<!-- YAML
|
2022-02-01 00:34:51 -05:00
|
|
|
added:
|
|
|
|
- v17.2.0
|
|
|
|
- v16.14.0
|
2021-08-30 15:31:28 +09:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
|
|
|
The SHA-512 fingerprint of this certificate.
|
|
|
|
|
2022-04-01 12:35:27 +02:00
|
|
|
Because computing the SHA-256 fingerprint is usually faster and because it is
|
|
|
|
only half the size of the SHA-512 fingerprint, [`x509.fingerprint256`][] may be
|
|
|
|
a better choice. While SHA-512 presumably provides a higher level of security in
|
|
|
|
general, the security of SHA-256 matches that of most algorithms that are
|
|
|
|
commonly used to sign certificates.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.infoAccess`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-12-07 00:21:28 +00:00
|
|
|
changes:
|
2022-01-10, Version 17.3.1 (Current)
This is a security release.
Notable changes:
Improper handling of URI Subject Alternative Names (Medium)(CVE-2021-44531)
- Accepting arbitrary Subject Alternative Name (SAN) types, unless a PKI
is specifically defined to use a particular SAN type, can result in
bypassing name-constrained intermediates. Node.js was accepting URI SAN
types, which PKIs are often not defined to use. Additionally, when a
protocol allows URI SANs, Node.js did not match the URI correctly.
- Versions of Node.js with the fix for this disable the URI SAN type when
checking a certificate against a hostname. This behavior can be
reverted through the `--security-revert` command-line option.
- More details will be available at
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44531
Certificate Verification Bypass via String Injection (Medium)(CVE-2021-44532)
- Node.js converts SANs (Subject Alternative Names) to a string format.
It uses this string to check peer certificates against hostnames when
validating connections. The string format was subject to an injection
vulnerability when name constraints were used within a certificate
chain, allowing the bypass of these name constraints.
- Versions of Node.js with the fix for this escape SANs containing the
problematic characters in order to prevent the injection. This
behavior can be reverted through the `--security-revert` command-line
option.
- More details will be available at
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
Incorrect handling of certificate subject and issuer fields (Medium)(CVE-2021-44533)
- Node.js did not handle multi-value Relative Distinguished Names
correctly. Attackers could craft certificate subjects containing a
single-value Relative Distinguished Name that would be interpreted as a
multi-value Relative Distinguished Name, for example, in order to inject
a Common Name that would allow bypassing the certificate subject
verification.
- Affected versions of Node.js do not accept multi-value Relative
Distinguished Names and are thus not vulnerable to such attacks
themselves. However, third-party code that uses node's ambiguous
presentation of certificate subjects may be vulnerable.
- More details will be available at
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44533
Prototype pollution via `console.table` properties (Low)(CVE-2022-21824)
- Due to the formatting logic of the `console.table()` function it was
not safe to allow user controlled input to be passed to the `properties`
parameter while simultaneously passing a plain object with at least one
property as the first parameter, which could be `__proto__`. The
prototype pollution has very limited control, in that it only allows an
empty string to be assigned numerical keys of the object prototype.
- Versions of Node.js with the fix for this use a null protoype for the
object these properties are being assigned to.
- More details will be available at
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-21824
PR-URL: https://github.com/nodejs-private/node-private/pull/311
2022-01-08 01:38:03 +00:00
|
|
|
- version:
|
|
|
|
- v17.3.1
|
|
|
|
- v16.13.2
|
2021-12-07 00:21:28 +00:00
|
|
|
pr-url: https://github.com/nodejs-private/node-private/pull/300
|
|
|
|
description: Parts of this string may be encoded as JSON string literals
|
|
|
|
in response to CVE-2021-44532.
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
2021-12-07 00:21:28 +00:00
|
|
|
A textual representation of the certificate's authority information access
|
|
|
|
extension.
|
|
|
|
|
|
|
|
This is a line feed separated list of access descriptions. Each line begins with
|
|
|
|
the access method and the kind of the access location, followed by a colon and
|
|
|
|
the value associated with the access location.
|
|
|
|
|
|
|
|
After the prefix denoting the access method and the kind of the access location,
|
|
|
|
the remainder of each line might be enclosed in quotes to indicate that the
|
|
|
|
value is a JSON string literal. For backward compatibility, Node.js only uses
|
|
|
|
JSON string literals within this property when necessary to avoid ambiguity.
|
|
|
|
Third-party code should be prepared to handle both possible entry formats.
|
2021-01-04 21:27:20 -08:00
|
|
|
|
|
|
|
### `x509.issuer`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
|
|
|
The issuer identification included in this certificate.
|
|
|
|
|
2021-01-25 16:38:51 -08:00
|
|
|
### `x509.issuerCertificate`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-25 16:38:51 -08:00
|
|
|
<!-- YAML
|
2021-02-17 08:16:22 -05:00
|
|
|
added: v15.9.0
|
2021-01-25 16:38:51 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {X509Certificate}
|
|
|
|
|
|
|
|
The issuer certificate or `undefined` if the issuer certificate is not
|
|
|
|
available.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.publicKey`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {KeyObject}
|
|
|
|
|
|
|
|
The public key {KeyObject} for this certificate.
|
|
|
|
|
|
|
|
### `x509.raw`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {Buffer}
|
|
|
|
|
|
|
|
A `Buffer` containing the DER encoding of this certificate.
|
|
|
|
|
|
|
|
### `x509.serialNumber`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
|
|
|
The serial number of this certificate.
|
|
|
|
|
2022-04-01 12:35:27 +02:00
|
|
|
Serial numbers are assigned by certificate authorities and do not uniquely
|
|
|
|
identify certificates. Consider using [`x509.fingerprint256`][] as a unique
|
|
|
|
identifier instead.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.subject`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
|
|
|
The complete subject of this certificate.
|
|
|
|
|
|
|
|
### `x509.subjectAltName`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-12-07 00:21:28 +00:00
|
|
|
changes:
|
2022-01-10, Version 17.3.1 (Current)
This is a security release.
Notable changes:
Improper handling of URI Subject Alternative Names (Medium)(CVE-2021-44531)
- Accepting arbitrary Subject Alternative Name (SAN) types, unless a PKI
is specifically defined to use a particular SAN type, can result in
bypassing name-constrained intermediates. Node.js was accepting URI SAN
types, which PKIs are often not defined to use. Additionally, when a
protocol allows URI SANs, Node.js did not match the URI correctly.
- Versions of Node.js with the fix for this disable the URI SAN type when
checking a certificate against a hostname. This behavior can be
reverted through the `--security-revert` command-line option.
- More details will be available at
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44531
Certificate Verification Bypass via String Injection (Medium)(CVE-2021-44532)
- Node.js converts SANs (Subject Alternative Names) to a string format.
It uses this string to check peer certificates against hostnames when
validating connections. The string format was subject to an injection
vulnerability when name constraints were used within a certificate
chain, allowing the bypass of these name constraints.
- Versions of Node.js with the fix for this escape SANs containing the
problematic characters in order to prevent the injection. This
behavior can be reverted through the `--security-revert` command-line
option.
- More details will be available at
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
Incorrect handling of certificate subject and issuer fields (Medium)(CVE-2021-44533)
- Node.js did not handle multi-value Relative Distinguished Names
correctly. Attackers could craft certificate subjects containing a
single-value Relative Distinguished Name that would be interpreted as a
multi-value Relative Distinguished Name, for example, in order to inject
a Common Name that would allow bypassing the certificate subject
verification.
- Affected versions of Node.js do not accept multi-value Relative
Distinguished Names and are thus not vulnerable to such attacks
themselves. However, third-party code that uses node's ambiguous
presentation of certificate subjects may be vulnerable.
- More details will be available at
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44533
Prototype pollution via `console.table` properties (Low)(CVE-2022-21824)
- Due to the formatting logic of the `console.table()` function it was
not safe to allow user controlled input to be passed to the `properties`
parameter while simultaneously passing a plain object with at least one
property as the first parameter, which could be `__proto__`. The
prototype pollution has very limited control, in that it only allows an
empty string to be assigned numerical keys of the object prototype.
- Versions of Node.js with the fix for this use a null protoype for the
object these properties are being assigned to.
- More details will be available at
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-21824
PR-URL: https://github.com/nodejs-private/node-private/pull/311
2022-01-08 01:38:03 +00:00
|
|
|
- version:
|
|
|
|
- v17.3.1
|
|
|
|
- v16.13.2
|
2021-12-07 00:21:28 +00:00
|
|
|
pr-url: https://github.com/nodejs-private/node-private/pull/300
|
|
|
|
description: Parts of this string may be encoded as JSON string literals
|
|
|
|
in response to CVE-2021-44532.
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
|
|
|
The subject alternative name specified for this certificate.
|
|
|
|
|
2021-12-07 00:21:28 +00:00
|
|
|
This is a comma-separated list of subject alternative names. Each entry begins
|
|
|
|
with a string identifying the kind of the subject alternative name followed by
|
|
|
|
a colon and the value associated with the entry.
|
|
|
|
|
|
|
|
Earlier versions of Node.js incorrectly assumed that it is safe to split this
|
|
|
|
property at the two-character sequence `', '` (see [CVE-2021-44532][]). However,
|
|
|
|
both malicious and legitimate certificates can contain subject alternative names
|
|
|
|
that include this sequence when represented as a string.
|
|
|
|
|
|
|
|
After the prefix denoting the type of the entry, the remainder of each entry
|
|
|
|
might be enclosed in quotes to indicate that the value is a JSON string literal.
|
|
|
|
For backward compatibility, Node.js only uses JSON string literals within this
|
|
|
|
property when necessary to avoid ambiguity. Third-party code should be prepared
|
|
|
|
to handle both possible entry formats.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.toJSON()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
|
|
|
There is no standard JSON encoding for X509 certificates. The
|
|
|
|
`toJSON()` method returns a string containing the PEM encoded
|
|
|
|
certificate.
|
|
|
|
|
|
|
|
### `x509.toLegacyObject()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {Object}
|
|
|
|
|
|
|
|
Returns information about this certificate using the legacy
|
|
|
|
[certificate object][] encoding.
|
|
|
|
|
|
|
|
### `x509.toString()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
|
|
|
Returns the PEM-encoded certificate.
|
|
|
|
|
|
|
|
### `x509.validFrom`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
2023-12-20 10:45:58 -08:00
|
|
|
The date/time from which this certificate is valid.
|
2021-01-04 21:27:20 -08:00
|
|
|
|
2024-09-18 09:56:24 +09:00
|
|
|
### `x509.validFromDate`
|
|
|
|
|
|
|
|
<!-- YAML
|
2024-10-10 00:12:22 +02:00
|
|
|
added:
|
|
|
|
- v23.0.0
|
|
|
|
- v22.10.0
|
2024-09-18 09:56:24 +09:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {Date}
|
|
|
|
|
|
|
|
The date/time from which this certificate is valid, encapsulated in a `Date` object.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.validTo`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {string}
|
|
|
|
|
2023-12-20 10:45:58 -08:00
|
|
|
The date/time until which this certificate is valid.
|
2021-01-04 21:27:20 -08:00
|
|
|
|
2024-09-18 09:56:24 +09:00
|
|
|
### `x509.validToDate`
|
|
|
|
|
|
|
|
<!-- YAML
|
2024-10-10 00:12:22 +02:00
|
|
|
added:
|
|
|
|
- v23.0.0
|
|
|
|
- v22.10.0
|
2024-09-18 09:56:24 +09:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {Date}
|
|
|
|
|
|
|
|
The date/time until which this certificate is valid, encapsulated in a `Date` object.
|
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
### `x509.verify(publicKey)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 21:27:20 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 21:27:20 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `publicKey` {KeyObject} A public key.
|
|
|
|
* Returns: {boolean}
|
|
|
|
|
|
|
|
Verifies that this certificate was signed by the given public key.
|
|
|
|
Does not perform any other validation checks on the certificate.
|
|
|
|
|
2022-04-20 10:23:41 +02:00
|
|
|
## `node:crypto` module methods and properties
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2022-08-21 00:08:53 +02:00
|
|
|
### `crypto.checkPrime(candidate[, options], callback)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-18 23:03:58 -08:00
|
|
|
<!-- YAML
|
2021-02-02 11:17:42 +01:00
|
|
|
added: v15.8.0
|
2022-01-24 19:39:16 +03:30
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2021-01-18 23:03:58 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `candidate` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
|
|
|
|
A possible prime encoded as a sequence of big endian octets of arbitrary
|
|
|
|
length.
|
|
|
|
* `options` {Object}
|
|
|
|
* `checks` {number} The number of Miller-Rabin probabilistic primality
|
|
|
|
iterations to perform. When the value is `0` (zero), a number of checks
|
|
|
|
is used that yields a false positive rate of at most 2<sup>-64</sup> for
|
|
|
|
random input. Care must be used when selecting a number of checks. Refer
|
|
|
|
to the OpenSSL documentation for the [`BN_is_prime_ex`][] function `nchecks`
|
2021-02-15 13:21:50 -05:00
|
|
|
options for more details. **Default:** `0`
|
2021-01-18 23:03:58 -08:00
|
|
|
* `callback` {Function}
|
2021-02-08 21:49:28 +05:30
|
|
|
* `err` {Error} Set to an {Error} object if an error occurred during check.
|
2021-01-18 23:03:58 -08:00
|
|
|
* `result` {boolean} `true` if the candidate is a prime with an error
|
|
|
|
probability less than `0.25 ** options.checks`.
|
|
|
|
|
|
|
|
Checks the primality of the `candidate`.
|
|
|
|
|
|
|
|
### `crypto.checkPrimeSync(candidate[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-18 23:03:58 -08:00
|
|
|
<!-- YAML
|
2021-02-02 11:17:42 +01:00
|
|
|
added: v15.8.0
|
2021-01-18 23:03:58 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `candidate` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
|
|
|
|
A possible prime encoded as a sequence of big endian octets of arbitrary
|
|
|
|
length.
|
|
|
|
* `options` {Object}
|
|
|
|
* `checks` {number} The number of Miller-Rabin probabilistic primality
|
|
|
|
iterations to perform. When the value is `0` (zero), a number of checks
|
|
|
|
is used that yields a false positive rate of at most 2<sup>-64</sup> for
|
|
|
|
random input. Care must be used when selecting a number of checks. Refer
|
|
|
|
to the OpenSSL documentation for the [`BN_is_prime_ex`][] function `nchecks`
|
2021-02-15 13:21:50 -05:00
|
|
|
options for more details. **Default:** `0`
|
2021-01-18 23:03:58 -08:00
|
|
|
* Returns: {boolean} `true` if the candidate is a prime with an error
|
|
|
|
probability less than `0.25 ** options.checks`.
|
|
|
|
|
|
|
|
Checks the primality of the `candidate`.
|
|
|
|
|
2024-11-23 18:10:44 +01:00
|
|
|
### `crypto.constants`
|
|
|
|
|
|
|
|
<!-- YAML
|
|
|
|
added: v6.3.0
|
|
|
|
-->
|
|
|
|
|
|
|
|
* {Object}
|
|
|
|
|
|
|
|
An object containing commonly used constants for crypto and security related
|
|
|
|
operations. The specific constants currently defined are described in
|
|
|
|
[Crypto constants][].
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createCipheriv(algorithm, key, iv[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-02-08 19:53:22 +01:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
2018-02-07 16:20:21 +01:00
|
|
|
changes:
|
2022-08-16, Version 16.17.0 'Gallium' (LTS)
Notable changes:
Adds `util.parseArgs` helper for higher level command-line argument
parsing.
Contributed by Benjamin Coe, John Gee, Darcy Clarke, Joe Sepi,
Kevin Gibbons, Aaron Casanova, Jessica Nahulan, and Jordan Harband.
https://github.com/nodejs/node/pull/42675
Node.js ESM Loader hooks now support multiple custom loaders, and
composition is achieved via "chaining": `foo-loader` calls `bar-loader`
calls `qux-loader` (a custom loader _must_ now signal a short circuit
when intentionally not calling the next). See the ESM docs
(https://nodejs.org/dist/latest-v16.x/docs/api/esm.html) for details.
Contributed by Jacob Smith, Geoffrey Booth, and Bradley Farias.
https://github.com/nodejs/node/pull/42623
The `node:test` module, which was initially introduced in Node.js
v18.0.0, is now available with all the changes done to it up to Node.js
v18.7.0.
To better align Node.js' experimental implementation of the Web Crypto
API with other runtimes, several changes were made:
* Support for CFRG curves was added, with the `'Ed25519'`, `'Ed448'`,
`'X25519'`, and `'X448'` algorithms.
* The proprietary `'NODE-DSA'`, `'NODE-DH'`, `'NODE-SCRYPT'`,
`'NODE-ED25519'`, `'NODE-ED448'`, `'NODE-X25519'`, and `'NODE-X448'`
algorithms were removed.
* The proprietary `'node.keyObject'` import/export format was removed.
Contributed by Filip Skokan.
https://github.com/nodejs/node/pull/42507
https://github.com/nodejs/node/pull/43310
Updated Corepack to 0.12.1 - https://github.com/nodejs/node/pull/43965
Updated ICU to 71.1 - https://github.com/nodejs/node/pull/42655
Updated npm to 8.15.0 - https://github.com/nodejs/node/pull/43917
Updated Undici to 5.8.0 - https://github.com/nodejs/node/pull/43886
(SEMVER-MINOR) crypto: make authTagLength optional for CC20P1305 (Tobias Nießen) https://github.com/nodejs/node/pull/42427
(SEMVER-MINOR) crypto: align webcrypto RSA key import/export with other implementations (Filip Skokan) https://github.com/nodejs/node/pull/42816
(SEMVER-MINOR) dns: export error code constants from `dns/promises` (Feng Yu) https://github.com/nodejs/node/pull/43176
doc: deprecate coercion to integer in process.exit (Daeyeon Jeong) https://github.com/nodejs/node/pull/43738
(SEMVER-MINOR) doc: deprecate diagnostics_channel object subscribe method (Stephen Belanger) https://github.com/nodejs/node/pull/42714
(SEMVER-MINOR) errors: add support for cause in aborterror (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) events: expose CustomEvent on global with CLI flag (Daeyeon Jeong) https://github.com/nodejs/node/pull/43885
(SEMVER-MINOR) events: add `CustomEvent` (Daeyeon Jeong) https://github.com/nodejs/node/pull/43514
(SEMVER-MINOR) events: propagate abortsignal reason in new AbortError ctor in events (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) fs: propagate abortsignal reason in new AbortSignal constructors (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) https://github.com/nodejs/node/pull/42601
(SEMVER-MINOR) fs: add `read(buffer[, options])` versions (LiviaMedeiros) https://github.com/nodejs/node/pull/42768
(SEMVER-MINOR) http: add drop request event for http server (theanarkh) https://github.com/nodejs/node/pull/43806
(SEMVER-MINOR) http: add diagnostics channel for http client (theanarkh) https://github.com/nodejs/node/pull/43580
(SEMVER-MINOR) http: add perf_hooks detail for http request and client (theanarkh) https://github.com/nodejs/node/pull/43361
(SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) https://github.com/nodejs/node/pull/41397
(SEMVER-MINOR) http2: propagate abortsignal reason in new AbortError constructor (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) http2: compat support for array headers (OneNail) https://github.com/nodejs/node/pull/42901
(SEMVER-MINOR) lib: propagate abortsignal reason in new AbortError constructor in blob (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) lib: add abortSignal.throwIfAborted() (James M Snell) https://github.com/nodejs/node/pull/40951
(SEMVER-MINOR) lib: improved diagnostics_channel subscribe/unsubscribe (Stephen Belanger) https://github.com/nodejs/node/pull/42714
(SEMVER-MINOR) module: add isBuiltIn method (hemanth.hm) https://github.com/nodejs/node/pull/43396
(SEMVER-MINOR) module,repl: support 'node:'-only core modules (Colin Ihrig) https://github.com/nodejs/node/pull/42325
(SEMVER-MINOR) net: add drop event for net server (theanarkh) https://github.com/nodejs/node/pull/43582
(SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) https://github.com/nodejs/node/pull/43112
(SEMVER-MINOR) node-api: emit uncaught-exception on unhandled tsfn callbacks (Chengzhong Wu) https://github.com/nodejs/node/pull/36510
(SEMVER-MINOR) perf_hooks: add PerformanceResourceTiming (RafaelGSS) https://github.com/nodejs/node/pull/42725
(SEMVER-MINOR) report: add more heap infos in process report (theanarkh) https://github.com/nodejs/node/pull/43116
(SEMVER-MINOR) src: add --openssl-legacy-provider option (Daniel Bevenius) https://github.com/nodejs/node/pull/40478
(SEMVER-MINOR) src: define fs.constants.S_IWUSR & S_IRUSR for Win (Liviu Ionescu) https://github.com/nodejs/node/pull/42757
(SEMVER-MINOR) src,doc,test: add --openssl-shared-config option (Daniel Bevenius) https://github.com/nodejs/node/pull/43124
(SEMVER-MINOR) stream: use cause options in AbortError constructors (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) stream: add iterator helper find (Nitzan Uziely) https://github.com/nodejs/node/pull/41849
(SEMVER-MINOR) stream: add writableAborted (Robert Nagy) https://github.com/nodejs/node/pull/40802
(SEMVER-MINOR) timers: propagate signal.reason in awaitable timers (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) v8: add v8.startupSnapshot utils (Joyee Cheung) https://github.com/nodejs/node/pull/43329
(SEMVER-MINOR) v8: export more fields in getHeapStatistics (theanarkh) https://github.com/nodejs/node/pull/42784
(SEMVER-MINOR) worker: add hasRef() to MessagePort (Darshan Sen) https://github.com/nodejs/node/pull/42849
PR-URL: https://github.com/nodejs/node/pull/44098
2022-08-02 14:34:18 +02:00
|
|
|
- version:
|
|
|
|
- v17.9.0
|
|
|
|
- v16.17.0
|
2022-03-27 01:28:19 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/42427
|
|
|
|
description: The `authTagLength` option is now optional when using the
|
|
|
|
`chacha20-poly1305` cipher and defaults to 16 bytes.
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The password and iv arguments can be an ArrayBuffer and are
|
|
|
|
each limited to a maximum of 2 ** 31 - 1 bytes.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: The `key` argument can now be a `KeyObject`.
|
2020-04-24 18:43:06 +02:00
|
|
|
- version:
|
|
|
|
- v11.2.0
|
|
|
|
- v10.17.0
|
2018-11-04 00:04:57 -04:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24081
|
2022-03-19 01:11:04 +01:00
|
|
|
description: The cipher `chacha20-poly1305` (the IETF variant of
|
|
|
|
ChaCha20-Poly1305) is now supported.
|
2018-09-06, Version 10.10.0 (Current)
Notable changes:
* child_process:
* `TypedArray` and `DataView` values are now accepted as input by
`execFileSync` and `spawnSync`. https://github.com/nodejs/node/pull/22409
* coverage:
* Native V8 code coverage information can now be output to disk by setting the
environment variable `NODE_V8_COVERAGE` to a directory. https://github.com/nodejs/node/pull/22527
* deps:
* The bundled npm was upgraded to version 6.4.1. https://github.com/nodejs/node/pull/22591
* Changelogs:
[6.3.0-next.0](https://github.com/npm/cli/releases/tag/v6.3.0-next.0)
[6.3.0](https://github.com/npm/cli/releases/tag/v6.3.0)
[6.4.0](https://github.com/npm/cli/releases/tag/v6.4.0)
[6.4.1](https://github.com/npm/cli/releases/tag/v6.4.1)
* fs:
* The methods `fs.read`, `fs.readSync`, `fs.write`, `fs.writeSync`,
`fs.writeFile` and `fs.writeFileSync` now all accept `TypedArray` and
`DataView` objects. https://github.com/nodejs/node/pull/22150
* A new boolean option, `withFileTypes`, can be passed to to `fs.readdir` and
`fs.readdirSync`. If set to true, the methods return an array of directory
entries. These are objects that can be used to determine the type of each
entry and filter them based on that without calling `fs.stat`. https://github.com/nodejs/node/pull/22020
* http2:
* The `http2` module is no longer experimental. https://github.com/nodejs/node/pull/22466
* os:
* Added two new methods: `os.getPriority` and `os.setPriority`, allowing to
manipulate the scheduling priority of processes. https://github.com/nodejs/node/pull/22407
* process:
* Added `process.allowedNodeEnvironmentFlags`. This object can be used to
programmatically validate and list flags that are allowed in the
`NODE_OPTIONS` environment variable. https://github.com/nodejs/node/pull/19335
* src:
* Deprecated option variables in public C++ API. https://github.com/nodejs/node/pull/22515
* Refactored options parsing. https://github.com/nodejs/node/pull/22392
* vm:
* Added `vm.compileFunction`, a method to create new JavaScript functions from
a source body, with options similar to those of the other `vm` methods. https://github.com/nodejs/node/pull/21571
* Added new collaborators:
* [lundibundi](https://github.com/lundibundi) - Denys Otrishko
PR-URL: https://github.com/nodejs/node/pull/22716
2018-09-03 20:14:31 +02:00
|
|
|
- version: v10.10.0
|
2018-06-14 15:18:14 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/21447
|
|
|
|
description: Ciphers in OCB mode are now supported.
|
2018-05-14 20:01:36 +02:00
|
|
|
- version: v10.2.0
|
2018-04-15 14:51:24 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/20235
|
|
|
|
description: The `authTagLength` option can now be used to produce shorter
|
|
|
|
authentication tags in GCM mode and defaults to 16 bytes.
|
2018-03-18 14:45:41 +01:00
|
|
|
- version: v9.9.0
|
2018-02-07 16:20:21 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/18644
|
|
|
|
description: The `iv` parameter may now be `null` for ciphers which do not
|
|
|
|
need an initialization vector.
|
2018-02-08 19:53:22 +01:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `algorithm` {string}
|
2020-08-25 10:05:51 -07:00
|
|
|
* `key` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
|
|
|
* `iv` {string|ArrayBuffer|Buffer|TypedArray|DataView|null}
|
2018-07-12 13:48:11 -04:00
|
|
|
* `options` {Object} [`stream.transform` options][]
|
2025-03-01 16:25:58 -08:00
|
|
|
* Returns: {Cipheriv}
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Creates and returns a `Cipheriv` object, with the given `algorithm`, `key` and
|
2018-04-06 18:28:20 +03:00
|
|
|
initialization vector (`iv`).
|
|
|
|
|
2017-12-18 13:22:08 +01:00
|
|
|
The `options` argument controls stream behavior and is optional except when a
|
2022-03-27 01:28:19 +01:00
|
|
|
cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the
|
2017-12-18 13:22:08 +01:00
|
|
|
`authTagLength` option is required and specifies the length of the
|
2018-04-15 14:51:24 +02:00
|
|
|
authentication tag in bytes, see [CCM mode][]. In GCM mode, the `authTagLength`
|
|
|
|
option is not required but can be used to set the length of the authentication
|
|
|
|
tag that will be returned by `getAuthTag()` and defaults to 16 bytes.
|
2022-03-27 01:28:19 +01:00
|
|
|
For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2016-02-15 03:40:53 +03:00
|
|
|
The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
|
2022-03-08 18:33:27 +01:00
|
|
|
recent OpenSSL releases, `openssl list -cipher-algorithms` will
|
2018-05-03 20:37:19 +05:30
|
|
|
display the available cipher algorithms.
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `key` is the raw key used by the `algorithm` and `iv` is an
|
2017-03-22 07:33:31 +01:00
|
|
|
[initialization vector][]. Both arguments must be `'utf8'` encoded strings,
|
2018-09-20 19:53:44 +02:00
|
|
|
[Buffers][`Buffer`], `TypedArray`, or `DataView`s. The `key` may optionally be
|
|
|
|
a [`KeyObject`][] of type `secret`. If the cipher does not need
|
2018-02-07 16:20:21 +01:00
|
|
|
an initialization vector, `iv` may be `null`.
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2021-02-06 16:51:50 +01:00
|
|
|
When passing strings for `key` or `iv`, please consider
|
|
|
|
[caveats when using strings as inputs to cryptographic APIs][].
|
|
|
|
|
2018-04-05 02:17:56 +05:30
|
|
|
Initialization vectors should be unpredictable and unique; ideally, they will be
|
|
|
|
cryptographically random. They do not have to be secret: IVs are typically just
|
|
|
|
added to ciphertext messages unencrypted. It may sound contradictory that
|
|
|
|
something has to be unpredictable and unique, but does not have to be secret;
|
2019-10-24 15:19:07 -07:00
|
|
|
remember that an attacker must not be able to predict ahead of time what a
|
|
|
|
given IV will be.
|
2018-04-05 02:17:56 +05:30
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createDecipheriv(algorithm, key, iv[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
2018-02-07 16:20:21 +01:00
|
|
|
changes:
|
2022-08-16, Version 16.17.0 'Gallium' (LTS)
Notable changes:
Adds `util.parseArgs` helper for higher level command-line argument
parsing.
Contributed by Benjamin Coe, John Gee, Darcy Clarke, Joe Sepi,
Kevin Gibbons, Aaron Casanova, Jessica Nahulan, and Jordan Harband.
https://github.com/nodejs/node/pull/42675
Node.js ESM Loader hooks now support multiple custom loaders, and
composition is achieved via "chaining": `foo-loader` calls `bar-loader`
calls `qux-loader` (a custom loader _must_ now signal a short circuit
when intentionally not calling the next). See the ESM docs
(https://nodejs.org/dist/latest-v16.x/docs/api/esm.html) for details.
Contributed by Jacob Smith, Geoffrey Booth, and Bradley Farias.
https://github.com/nodejs/node/pull/42623
The `node:test` module, which was initially introduced in Node.js
v18.0.0, is now available with all the changes done to it up to Node.js
v18.7.0.
To better align Node.js' experimental implementation of the Web Crypto
API with other runtimes, several changes were made:
* Support for CFRG curves was added, with the `'Ed25519'`, `'Ed448'`,
`'X25519'`, and `'X448'` algorithms.
* The proprietary `'NODE-DSA'`, `'NODE-DH'`, `'NODE-SCRYPT'`,
`'NODE-ED25519'`, `'NODE-ED448'`, `'NODE-X25519'`, and `'NODE-X448'`
algorithms were removed.
* The proprietary `'node.keyObject'` import/export format was removed.
Contributed by Filip Skokan.
https://github.com/nodejs/node/pull/42507
https://github.com/nodejs/node/pull/43310
Updated Corepack to 0.12.1 - https://github.com/nodejs/node/pull/43965
Updated ICU to 71.1 - https://github.com/nodejs/node/pull/42655
Updated npm to 8.15.0 - https://github.com/nodejs/node/pull/43917
Updated Undici to 5.8.0 - https://github.com/nodejs/node/pull/43886
(SEMVER-MINOR) crypto: make authTagLength optional for CC20P1305 (Tobias Nießen) https://github.com/nodejs/node/pull/42427
(SEMVER-MINOR) crypto: align webcrypto RSA key import/export with other implementations (Filip Skokan) https://github.com/nodejs/node/pull/42816
(SEMVER-MINOR) dns: export error code constants from `dns/promises` (Feng Yu) https://github.com/nodejs/node/pull/43176
doc: deprecate coercion to integer in process.exit (Daeyeon Jeong) https://github.com/nodejs/node/pull/43738
(SEMVER-MINOR) doc: deprecate diagnostics_channel object subscribe method (Stephen Belanger) https://github.com/nodejs/node/pull/42714
(SEMVER-MINOR) errors: add support for cause in aborterror (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) events: expose CustomEvent on global with CLI flag (Daeyeon Jeong) https://github.com/nodejs/node/pull/43885
(SEMVER-MINOR) events: add `CustomEvent` (Daeyeon Jeong) https://github.com/nodejs/node/pull/43514
(SEMVER-MINOR) events: propagate abortsignal reason in new AbortError ctor in events (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) fs: propagate abortsignal reason in new AbortSignal constructors (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) https://github.com/nodejs/node/pull/42601
(SEMVER-MINOR) fs: add `read(buffer[, options])` versions (LiviaMedeiros) https://github.com/nodejs/node/pull/42768
(SEMVER-MINOR) http: add drop request event for http server (theanarkh) https://github.com/nodejs/node/pull/43806
(SEMVER-MINOR) http: add diagnostics channel for http client (theanarkh) https://github.com/nodejs/node/pull/43580
(SEMVER-MINOR) http: add perf_hooks detail for http request and client (theanarkh) https://github.com/nodejs/node/pull/43361
(SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) https://github.com/nodejs/node/pull/41397
(SEMVER-MINOR) http2: propagate abortsignal reason in new AbortError constructor (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) http2: compat support for array headers (OneNail) https://github.com/nodejs/node/pull/42901
(SEMVER-MINOR) lib: propagate abortsignal reason in new AbortError constructor in blob (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) lib: add abortSignal.throwIfAborted() (James M Snell) https://github.com/nodejs/node/pull/40951
(SEMVER-MINOR) lib: improved diagnostics_channel subscribe/unsubscribe (Stephen Belanger) https://github.com/nodejs/node/pull/42714
(SEMVER-MINOR) module: add isBuiltIn method (hemanth.hm) https://github.com/nodejs/node/pull/43396
(SEMVER-MINOR) module,repl: support 'node:'-only core modules (Colin Ihrig) https://github.com/nodejs/node/pull/42325
(SEMVER-MINOR) net: add drop event for net server (theanarkh) https://github.com/nodejs/node/pull/43582
(SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) https://github.com/nodejs/node/pull/43112
(SEMVER-MINOR) node-api: emit uncaught-exception on unhandled tsfn callbacks (Chengzhong Wu) https://github.com/nodejs/node/pull/36510
(SEMVER-MINOR) perf_hooks: add PerformanceResourceTiming (RafaelGSS) https://github.com/nodejs/node/pull/42725
(SEMVER-MINOR) report: add more heap infos in process report (theanarkh) https://github.com/nodejs/node/pull/43116
(SEMVER-MINOR) src: add --openssl-legacy-provider option (Daniel Bevenius) https://github.com/nodejs/node/pull/40478
(SEMVER-MINOR) src: define fs.constants.S_IWUSR & S_IRUSR for Win (Liviu Ionescu) https://github.com/nodejs/node/pull/42757
(SEMVER-MINOR) src,doc,test: add --openssl-shared-config option (Daniel Bevenius) https://github.com/nodejs/node/pull/43124
(SEMVER-MINOR) stream: use cause options in AbortError constructors (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) stream: add iterator helper find (Nitzan Uziely) https://github.com/nodejs/node/pull/41849
(SEMVER-MINOR) stream: add writableAborted (Robert Nagy) https://github.com/nodejs/node/pull/40802
(SEMVER-MINOR) timers: propagate signal.reason in awaitable timers (James M Snell) https://github.com/nodejs/node/pull/41008
(SEMVER-MINOR) v8: add v8.startupSnapshot utils (Joyee Cheung) https://github.com/nodejs/node/pull/43329
(SEMVER-MINOR) v8: export more fields in getHeapStatistics (theanarkh) https://github.com/nodejs/node/pull/42784
(SEMVER-MINOR) worker: add hasRef() to MessagePort (Darshan Sen) https://github.com/nodejs/node/pull/42849
PR-URL: https://github.com/nodejs/node/pull/44098
2022-08-02 14:34:18 +02:00
|
|
|
- version:
|
|
|
|
- v17.9.0
|
|
|
|
- v16.17.0
|
2022-03-27 01:28:19 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/42427
|
|
|
|
description: The `authTagLength` option is now optional when using the
|
|
|
|
`chacha20-poly1305` cipher and defaults to 16 bytes.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: The `key` argument can now be a `KeyObject`.
|
2020-04-24 18:43:06 +02:00
|
|
|
- version:
|
|
|
|
- v11.2.0
|
|
|
|
- v10.17.0
|
2018-11-04 00:04:57 -04:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24081
|
2022-03-19 01:11:04 +01:00
|
|
|
description: The cipher `chacha20-poly1305` (the IETF variant of
|
|
|
|
ChaCha20-Poly1305) is now supported.
|
2018-09-06, Version 10.10.0 (Current)
Notable changes:
* child_process:
* `TypedArray` and `DataView` values are now accepted as input by
`execFileSync` and `spawnSync`. https://github.com/nodejs/node/pull/22409
* coverage:
* Native V8 code coverage information can now be output to disk by setting the
environment variable `NODE_V8_COVERAGE` to a directory. https://github.com/nodejs/node/pull/22527
* deps:
* The bundled npm was upgraded to version 6.4.1. https://github.com/nodejs/node/pull/22591
* Changelogs:
[6.3.0-next.0](https://github.com/npm/cli/releases/tag/v6.3.0-next.0)
[6.3.0](https://github.com/npm/cli/releases/tag/v6.3.0)
[6.4.0](https://github.com/npm/cli/releases/tag/v6.4.0)
[6.4.1](https://github.com/npm/cli/releases/tag/v6.4.1)
* fs:
* The methods `fs.read`, `fs.readSync`, `fs.write`, `fs.writeSync`,
`fs.writeFile` and `fs.writeFileSync` now all accept `TypedArray` and
`DataView` objects. https://github.com/nodejs/node/pull/22150
* A new boolean option, `withFileTypes`, can be passed to to `fs.readdir` and
`fs.readdirSync`. If set to true, the methods return an array of directory
entries. These are objects that can be used to determine the type of each
entry and filter them based on that without calling `fs.stat`. https://github.com/nodejs/node/pull/22020
* http2:
* The `http2` module is no longer experimental. https://github.com/nodejs/node/pull/22466
* os:
* Added two new methods: `os.getPriority` and `os.setPriority`, allowing to
manipulate the scheduling priority of processes. https://github.com/nodejs/node/pull/22407
* process:
* Added `process.allowedNodeEnvironmentFlags`. This object can be used to
programmatically validate and list flags that are allowed in the
`NODE_OPTIONS` environment variable. https://github.com/nodejs/node/pull/19335
* src:
* Deprecated option variables in public C++ API. https://github.com/nodejs/node/pull/22515
* Refactored options parsing. https://github.com/nodejs/node/pull/22392
* vm:
* Added `vm.compileFunction`, a method to create new JavaScript functions from
a source body, with options similar to those of the other `vm` methods. https://github.com/nodejs/node/pull/21571
* Added new collaborators:
* [lundibundi](https://github.com/lundibundi) - Denys Otrishko
PR-URL: https://github.com/nodejs/node/pull/22716
2018-09-03 20:14:31 +02:00
|
|
|
- version: v10.10.0
|
2018-06-14 15:18:14 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/21447
|
|
|
|
description: Ciphers in OCB mode are now supported.
|
2018-05-14 20:01:36 +02:00
|
|
|
- version: v10.2.0
|
2018-04-13 18:02:46 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/20039
|
|
|
|
description: The `authTagLength` option can now be used to restrict accepted
|
|
|
|
GCM authentication tag lengths.
|
2018-03-18 14:45:41 +01:00
|
|
|
- version: v9.9.0
|
2018-02-07 16:20:21 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/18644
|
|
|
|
description: The `iv` parameter may now be `null` for ciphers which do not
|
|
|
|
need an initialization vector.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `algorithm` {string}
|
2020-08-25 10:05:51 -07:00
|
|
|
* `key` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
|
|
|
* `iv` {string|ArrayBuffer|Buffer|TypedArray|DataView|null}
|
2018-07-12 13:48:11 -04:00
|
|
|
* `options` {Object} [`stream.transform` options][]
|
2025-03-01 16:25:58 -08:00
|
|
|
* Returns: {Decipheriv}
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2025-03-01 16:25:58 -08:00
|
|
|
Creates and returns a `Decipheriv` object that uses the given `algorithm`, `key`
|
2017-12-18 13:22:08 +01:00
|
|
|
and initialization vector (`iv`).
|
|
|
|
|
|
|
|
The `options` argument controls stream behavior and is optional except when a
|
2022-03-27 01:28:19 +01:00
|
|
|
cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the
|
2017-12-18 13:22:08 +01:00
|
|
|
`authTagLength` option is required and specifies the length of the
|
2024-04-23 16:38:06 +02:00
|
|
|
authentication tag in bytes, see [CCM mode][].
|
|
|
|
For AES-GCM and `chacha20-poly1305`, the `authTagLength` option defaults to 16
|
|
|
|
bytes and must be set to a different value if a different length is used.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2016-02-15 03:40:53 +03:00
|
|
|
The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
|
2022-03-08 18:33:27 +01:00
|
|
|
recent OpenSSL releases, `openssl list -cipher-algorithms` will
|
2018-05-03 20:37:19 +05:30
|
|
|
display the available cipher algorithms.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
The `key` is the raw key used by the `algorithm` and `iv` is an
|
2018-02-08 19:43:05 +01:00
|
|
|
[initialization vector][]. Both arguments must be `'utf8'` encoded strings,
|
2018-09-20 19:53:44 +02:00
|
|
|
[Buffers][`Buffer`], `TypedArray`, or `DataView`s. The `key` may optionally be
|
|
|
|
a [`KeyObject`][] of type `secret`. If the cipher does not need
|
2018-02-07 16:20:21 +01:00
|
|
|
an initialization vector, `iv` may be `null`.
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2021-02-06 16:51:50 +01:00
|
|
|
When passing strings for `key` or `iv`, please consider
|
|
|
|
[caveats when using strings as inputs to cryptographic APIs][].
|
|
|
|
|
2018-04-05 02:17:56 +05:30
|
|
|
Initialization vectors should be unpredictable and unique; ideally, they will be
|
|
|
|
cryptographically random. They do not have to be secret: IVs are typically just
|
|
|
|
added to ciphertext messages unencrypted. It may sound contradictory that
|
|
|
|
something has to be unpredictable and unique, but does not have to be secret;
|
2019-10-24 15:19:07 -07:00
|
|
|
remember that an attacker must not be able to predict ahead of time what a given
|
|
|
|
IV will be.
|
2018-04-05 02:17:56 +05:30
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createDiffieHellman(prime[, primeEncoding][, generator][, generatorEncoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.12
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
2017-03-15 20:26:14 -07:00
|
|
|
- version: v8.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/12223
|
2017-04-04 15:59:30 -07:00
|
|
|
description: The `prime` argument can be any `TypedArray` or `DataView` now.
|
2017-03-15 20:26:14 -07:00
|
|
|
- version: v8.0.0
|
2017-03-22 07:34:55 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/11983
|
|
|
|
description: The `prime` argument can be a `Uint8Array` now.
|
2017-02-21 23:38:44 +01:00
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
|
|
|
description: The default for the encoding parameters changed
|
|
|
|
from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `prime` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-11-07 12:27:47 -08:00
|
|
|
* `primeEncoding` {string} The [encoding][] of the `prime` string.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `generator` {number|string|ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
**Default:** `2`
|
2018-11-07 12:27:47 -08:00
|
|
|
* `generatorEncoding` {string} The [encoding][] of the `generator` string.
|
2018-10-31 16:53:38 +08:00
|
|
|
* Returns: {DiffieHellman}
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Creates a `DiffieHellman` key exchange object using the supplied `prime` and an
|
2014-02-17 20:57:08 -05:00
|
|
|
optional specific `generator`.
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `generator` argument can be a number, string, or [`Buffer`][]. If
|
|
|
|
`generator` is not specified, the value `2` is used.
|
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
If `primeEncoding` is specified, `prime` is expected to be a string; otherwise
|
2017-04-04 15:59:30 -07:00
|
|
|
a [`Buffer`][], `TypedArray`, or `DataView` is expected.
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2017-06-06 11:00:32 +02:00
|
|
|
If `generatorEncoding` is specified, `generator` is expected to be a string;
|
2017-04-04 15:59:30 -07:00
|
|
|
otherwise a number, [`Buffer`][], `TypedArray`, or `DataView` is expected.
|
2012-02-27 11:08:02 -08:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createDiffieHellman(primeLength[, generator])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `primeLength` {number}
|
2019-12-28 16:27:56 +01:00
|
|
|
* `generator` {number} **Default:** `2`
|
2018-10-31 16:53:38 +08:00
|
|
|
* Returns: {DiffieHellman}
|
2014-02-17 20:57:08 -05:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Creates a `DiffieHellman` key exchange object and generates a prime of
|
2017-06-06 11:00:32 +02:00
|
|
|
`primeLength` bits using an optional specific numeric `generator`.
|
2015-12-26 20:54:01 -08:00
|
|
|
If `generator` is not specified, the value `2` is used.
|
2014-02-17 20:57:08 -05:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createDiffieHellmanGroup(name)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-07-07 16:33:18 +09:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.9.3
|
|
|
|
-->
|
|
|
|
|
|
|
|
* `name` {string}
|
2019-09-25 05:27:37 +09:00
|
|
|
* Returns: {DiffieHellmanGroup}
|
2019-07-07 16:33:18 +09:00
|
|
|
|
|
|
|
An alias for [`crypto.getDiffieHellman()`][]
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createECDH(curveName)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `curveName` {string}
|
2018-10-31 16:53:38 +08:00
|
|
|
* Returns: {ECDH}
|
2014-02-17 20:57:08 -05:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
|
2017-06-06 11:00:32 +02:00
|
|
|
predefined curve specified by the `curveName` string. Use
|
2015-12-26 20:54:01 -08:00
|
|
|
[`crypto.getCurves()`][] to obtain a list of available curve names. On recent
|
|
|
|
OpenSSL releases, `openssl ecparam -list_curves` will also display the name
|
|
|
|
and description of each available elliptic curve.
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createHash(algorithm[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
2019-07-19 02:44:31 +02:00
|
|
|
changes:
|
2019-08-06 15:06:33 +02:00
|
|
|
- version: v12.8.0
|
2019-07-19 02:44:31 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/28805
|
|
|
|
description: The `outputLength` option was added for XOF hash functions.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `algorithm` {string}
|
|
|
|
* `options` {Object} [`stream.transform` options][]
|
|
|
|
* Returns: {Hash}
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
Creates and returns a `Hash` object that can be used to generate hash digests
|
2017-08-15 16:16:14 -04:00
|
|
|
using the given `algorithm`. Optional `options` argument controls stream
|
2019-07-19 02:44:31 +02:00
|
|
|
behavior. For XOF hash functions such as `'shake256'`, the `outputLength` option
|
|
|
|
can be used to specify the desired output length in bytes.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
The `algorithm` is dependent on the available algorithms supported by the
|
|
|
|
version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
2022-03-08 18:33:27 +01:00
|
|
|
On recent releases of OpenSSL, `openssl list -digest-algorithms` will
|
2015-12-26 20:54:01 -08:00
|
|
|
display the available digest algorithms.
|
|
|
|
|
|
|
|
Example: generating the sha256 sum of a file
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
import {
|
2022-11-17 08:19:12 -05:00
|
|
|
createReadStream,
|
2022-07-30 17:11:50 +02:00
|
|
|
} from 'node:fs';
|
2022-04-20 10:23:41 +02:00
|
|
|
import { argv } from 'node:process';
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
2021-06-15 10:09:29 -07:00
|
|
|
const filename = argv[2];
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const hash = createHash('sha256');
|
|
|
|
|
|
|
|
const input = createReadStream(filename);
|
|
|
|
input.on('readable', () => {
|
|
|
|
// Only one element is going to be produced by the
|
|
|
|
// hash stream.
|
|
|
|
const data = input.read();
|
|
|
|
if (data)
|
|
|
|
hash.update(data);
|
|
|
|
else {
|
|
|
|
console.log(`${hash.digest('hex')} ${filename}`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createReadStream,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:fs');
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
createHash,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
|
|
|
const { argv } = require('node:process');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
2021-06-15 10:09:29 -07:00
|
|
|
const filename = argv[2];
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const hash = createHash('sha256');
|
|
|
|
|
|
|
|
const input = createReadStream(filename);
|
2016-01-17 18:39:07 +01:00
|
|
|
input.on('readable', () => {
|
2019-01-07 15:37:34 +01:00
|
|
|
// Only one element is going to be produced by the
|
|
|
|
// hash stream.
|
2017-01-20 03:42:50 +02:00
|
|
|
const data = input.read();
|
2016-01-17 18:39:07 +01:00
|
|
|
if (data)
|
|
|
|
hash.update(data);
|
|
|
|
else {
|
|
|
|
console.log(`${hash.digest('hex')} ${filename}`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
```
|
2015-11-04 11:23:03 -05:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createHmac(algorithm, key[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.94
|
2018-09-20 19:53:44 +02:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The key can also be an ArrayBuffer or CryptoKey. The
|
|
|
|
encoding option was added. The key cannot contain
|
|
|
|
more than 2 ** 32 - 1 bytes.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: The `key` argument can now be a `KeyObject`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `algorithm` {string}
|
2020-08-25 10:05:51 -07:00
|
|
|
* `key` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
2018-07-12 13:48:11 -04:00
|
|
|
* `options` {Object} [`stream.transform` options][]
|
2020-08-25 10:05:51 -07:00
|
|
|
* `encoding` {string} The string encoding to use when `key` is a string.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Hmac}
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
Creates and returns an `Hmac` object that uses the given `algorithm` and `key`.
|
2017-08-15 16:16:14 -04:00
|
|
|
Optional `options` argument controls stream behavior.
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `algorithm` is dependent on the available algorithms supported by the
|
|
|
|
version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
2022-03-08 18:33:27 +01:00
|
|
|
On recent releases of OpenSSL, `openssl list -digest-algorithms` will
|
2015-12-26 20:54:01 -08:00
|
|
|
display the available digest algorithms.
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
The `key` is the HMAC key used to generate the cryptographic HMAC hash. If it is
|
2023-05-24 22:21:07 +02:00
|
|
|
a [`KeyObject`][], its type must be `secret`. If it is a string, please consider
|
|
|
|
[caveats when using strings as inputs to cryptographic APIs][]. If it was
|
|
|
|
obtained from a cryptographically secure source of entropy, such as
|
|
|
|
[`crypto.randomBytes()`][] or [`crypto.generateKey()`][], its length should not
|
|
|
|
exceed the block size of `algorithm` (e.g., 512 bits for SHA-256).
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Example: generating the sha256 HMAC of a file
|
2012-10-22 10:37:20 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
import {
|
2022-11-17 08:19:12 -05:00
|
|
|
createReadStream,
|
2022-07-30 17:11:50 +02:00
|
|
|
} from 'node:fs';
|
2022-04-20 10:23:41 +02:00
|
|
|
import { argv } from 'node:process';
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
createHmac,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
2021-06-15 10:09:29 -07:00
|
|
|
const filename = argv[2];
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const hmac = createHmac('sha256', 'a secret');
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const input = createReadStream(filename);
|
|
|
|
input.on('readable', () => {
|
|
|
|
// Only one element is going to be produced by the
|
|
|
|
// hash stream.
|
|
|
|
const data = input.read();
|
|
|
|
if (data)
|
|
|
|
hmac.update(data);
|
|
|
|
else {
|
|
|
|
console.log(`${hmac.digest('hex')} ${filename}`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
createReadStream,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:fs');
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
createHmac,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
|
|
|
const { argv } = require('node:process');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
2021-06-15 10:09:29 -07:00
|
|
|
const filename = argv[2];
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const hmac = createHmac('sha256', 'a secret');
|
|
|
|
|
|
|
|
const input = createReadStream(filename);
|
2016-01-17 18:39:07 +01:00
|
|
|
input.on('readable', () => {
|
2019-01-07 15:37:34 +01:00
|
|
|
// Only one element is going to be produced by the
|
|
|
|
// hash stream.
|
2017-01-20 03:42:50 +02:00
|
|
|
const data = input.read();
|
2016-01-17 18:39:07 +01:00
|
|
|
if (data)
|
|
|
|
hmac.update(data);
|
|
|
|
else {
|
|
|
|
console.log(`${hmac.digest('hex')} ${filename}`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
```
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createPrivateKey(key)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
<!-- YAML
|
2018-12-21 18:13:09 -05:00
|
|
|
added: v11.6.0
|
2020-08-25 10:05:51 -07:00
|
|
|
changes:
|
2021-03-16 10:46:04 -04:00
|
|
|
- version: v15.12.0
|
2021-02-06 22:44:27 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/37254
|
|
|
|
description: The key can also be a JWK object.
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The key can also be an ArrayBuffer. The encoding option was
|
|
|
|
added. The key cannot contain more than 2 ** 32 - 1 bytes.
|
2018-09-20 19:53:44 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `key` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2021-02-06 22:44:27 +01:00
|
|
|
* `key`: {string|ArrayBuffer|Buffer|TypedArray|DataView|Object} The key
|
|
|
|
material, either in PEM, DER, or JWK format.
|
|
|
|
* `format`: {string} Must be `'pem'`, `'der'`, or '`'jwk'`.
|
|
|
|
**Default:** `'pem'`.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `type`: {string} Must be `'pkcs1'`, `'pkcs8'` or `'sec1'`. This option is
|
2021-10-10 21:55:04 -07:00
|
|
|
required only if the `format` is `'der'` and ignored otherwise.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `passphrase`: {string | Buffer} The passphrase to use for decryption.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `encoding`: {string} The string encoding to use when `key` is a string.
|
2018-09-20 19:53:44 +02:00
|
|
|
* Returns: {KeyObject}
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2018-09-20 19:53:44 +02:00
|
|
|
|
|
|
|
Creates and returns a new key object containing a private key. If `key` is a
|
|
|
|
string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key`
|
|
|
|
must be an object with the properties described above.
|
|
|
|
|
2019-03-30 00:19:39 +01:00
|
|
|
If the private key is encrypted, a `passphrase` must be specified. The length
|
|
|
|
of the passphrase is limited to 1024 bytes.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createPublicKey(key)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
<!-- YAML
|
2018-12-21 18:13:09 -05:00
|
|
|
added: v11.6.0
|
2018-12-25 13:13:52 +01:00
|
|
|
changes:
|
2021-03-16 10:46:04 -04:00
|
|
|
- version: v15.12.0
|
2021-02-06 22:44:27 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/37254
|
|
|
|
description: The key can also be a JWK object.
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The key can also be an ArrayBuffer. The encoding option was
|
|
|
|
added. The key cannot contain more than 2 ** 32 - 1 bytes.
|
2019-03-27 22:43:03 +01:00
|
|
|
- version: v11.13.0
|
2019-01-26 13:28:55 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26278
|
|
|
|
description: The `key` argument can now be a `KeyObject` with type
|
|
|
|
`private`.
|
2019-01-16 15:55:55 +01:00
|
|
|
- version: v11.7.0
|
2018-12-25 13:13:52 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/25217
|
|
|
|
description: The `key` argument can now be a private key.
|
2018-09-20 19:53:44 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `key` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2021-02-06 22:44:27 +01:00
|
|
|
* `key`: {string|ArrayBuffer|Buffer|TypedArray|DataView|Object} The key
|
|
|
|
material, either in PEM, DER, or JWK format.
|
2021-07-17 08:53:16 +03:00
|
|
|
* `format`: {string} Must be `'pem'`, `'der'`, or `'jwk'`.
|
2021-02-06 22:44:27 +01:00
|
|
|
**Default:** `'pem'`.
|
|
|
|
* `type`: {string} Must be `'pkcs1'` or `'spki'`. This option is
|
2021-10-10 21:55:04 -07:00
|
|
|
required only if the `format` is `'der'` and ignored otherwise.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `encoding` {string} The string encoding to use when `key` is a string.
|
2018-09-20 19:53:44 +02:00
|
|
|
* Returns: {KeyObject}
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2018-09-20 19:53:44 +02:00
|
|
|
|
|
|
|
Creates and returns a new key object containing a public key. If `key` is a
|
2019-01-26 13:28:55 +01:00
|
|
|
string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject`
|
|
|
|
with type `'private'`, the public key is derived from the given private key;
|
|
|
|
otherwise, `key` must be an object with the properties described above.
|
2018-09-20 19:53:44 +02:00
|
|
|
|
2018-12-20 00:11:57 +01:00
|
|
|
If the format is `'pem'`, the `'key'` may also be an X.509 certificate.
|
|
|
|
|
2018-12-25 13:13:52 +01:00
|
|
|
Because public keys can be derived from private keys, a private key may be
|
|
|
|
passed instead of a public key. In that case, this function behaves as if
|
|
|
|
[`crypto.createPrivateKey()`][] had been called, except that the type of the
|
2019-01-26 13:28:55 +01:00
|
|
|
returned `KeyObject` will be `'public'` and that the private key cannot be
|
|
|
|
extracted from the returned `KeyObject`. Similarly, if a `KeyObject` with type
|
|
|
|
`'private'` is given, a new `KeyObject` with type `'public'` will be returned
|
|
|
|
and it will be impossible to extract the private key from the returned object.
|
2018-12-25 13:13:52 +01:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
### `crypto.createSecretKey(key[, encoding])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
<!-- YAML
|
2018-12-21 18:13:09 -05:00
|
|
|
added: v11.6.0
|
2020-08-25 10:05:51 -07:00
|
|
|
changes:
|
2022-10-11 14:54:19 -05:00
|
|
|
- version:
|
|
|
|
- v18.8.0
|
|
|
|
- v16.18.0
|
2022-08-11 11:52:41 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/44201
|
|
|
|
description: The key can now be zero-length.
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
2020-10-29 12:56:34 -07:00
|
|
|
description: The key can also be an ArrayBuffer or string. The encoding
|
|
|
|
argument was added. The key cannot contain more than
|
|
|
|
2 ** 32 - 1 bytes.
|
2018-09-20 19:53:44 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `key` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `encoding` {string} The string encoding when `key` is a string.
|
2018-09-20 19:53:44 +02:00
|
|
|
* Returns: {KeyObject}
|
|
|
|
|
|
|
|
Creates and returns a new key object containing a secret key for symmetric
|
|
|
|
encryption or `Hmac`.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createSign(algorithm[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `algorithm` {string}
|
|
|
|
* `options` {Object} [`stream.Writable` options][]
|
|
|
|
* Returns: {Sign}
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2020-06-20 16:46:33 -07:00
|
|
|
Creates and returns a `Sign` object that uses the given `algorithm`. Use
|
2019-01-11 11:43:58 -08:00
|
|
|
[`crypto.getHashes()`][] to obtain the names of the available digest algorithms.
|
|
|
|
Optional `options` argument controls the `stream.Writable` behavior.
|
|
|
|
|
|
|
|
In some cases, a `Sign` instance can be created using the name of a signature
|
|
|
|
algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use
|
|
|
|
the corresponding digest algorithm. This does not work for all signature
|
|
|
|
algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest
|
|
|
|
algorithm names.
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.createVerify(algorithm[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.92
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `algorithm` {string}
|
|
|
|
* `options` {Object} [`stream.Writable` options][]
|
|
|
|
* Returns: {Verify}
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2016-10-11 16:20:51 -07:00
|
|
|
Creates and returns a `Verify` object that uses the given algorithm.
|
|
|
|
Use [`crypto.getHashes()`][] to obtain an array of names of the available
|
2017-08-15 16:16:14 -04:00
|
|
|
signing algorithms. Optional `options` argument controls the
|
|
|
|
`stream.Writable` behavior.
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2019-01-11 11:43:58 -08:00
|
|
|
In some cases, a `Verify` instance can be created using the name of a signature
|
|
|
|
algorithm, such as `'RSA-SHA256'`, instead of a digest algorithm. This will use
|
|
|
|
the corresponding digest algorithm. This does not work for all signature
|
|
|
|
algorithms, such as `'ecdsa-with-SHA256'`, so it is best to always use digest
|
|
|
|
algorithm names.
|
|
|
|
|
2025-03-15 11:44:04 +01:00
|
|
|
### `crypto.diffieHellman(options[, callback])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-01-03 12:01:34 +01:00
|
|
|
<!-- YAML
|
2020-05-01 14:43:14 +02:00
|
|
|
added:
|
|
|
|
- v13.9.0
|
|
|
|
- v12.17.0
|
2025-03-15 11:44:04 +01:00
|
|
|
changes:
|
2025-04-01 11:20:34 +02:00
|
|
|
- version: v23.11.0
|
2025-03-15 11:44:04 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/57274
|
|
|
|
description: Optional callback argument added.
|
2020-01-03 12:01:34 +01:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `options`: {Object}
|
|
|
|
* `privateKey`: {KeyObject}
|
|
|
|
* `publicKey`: {KeyObject}
|
2025-03-15 11:44:04 +01:00
|
|
|
* `callback` {Function}
|
|
|
|
* `err` {Error}
|
|
|
|
* `secret` {Buffer}
|
|
|
|
* Returns: {Buffer} if the `callback` function is not provided.
|
2020-01-03 12:01:34 +01:00
|
|
|
|
|
|
|
Computes the Diffie-Hellman secret based on a `privateKey` and a `publicKey`.
|
|
|
|
Both keys must have the same `asymmetricKeyType`, which must be one of `'dh'`
|
2024-11-02 12:36:25 +00:00
|
|
|
(for Diffie-Hellman), `'ec'`, `'x448'`, or `'x25519'` (for ECDH).
|
2020-01-03 12:01:34 +01:00
|
|
|
|
2025-03-15 11:44:04 +01:00
|
|
|
If the `callback` function is provided this function uses libuv's threadpool.
|
|
|
|
|
2024-11-23 18:10:44 +01:00
|
|
|
### `crypto.fips`
|
2024-01-05 22:17:00 +01:00
|
|
|
|
|
|
|
<!-- YAML
|
2024-11-23 18:10:44 +01:00
|
|
|
added: v6.0.0
|
|
|
|
deprecated: v10.0.0
|
2024-01-05 22:17:00 +01:00
|
|
|
-->
|
|
|
|
|
2024-11-23 18:10:44 +01:00
|
|
|
> Stability: 0 - Deprecated
|
2024-01-05 22:17:00 +01:00
|
|
|
|
2024-11-23 18:10:44 +01:00
|
|
|
Property for checking and controlling whether a FIPS compliant crypto provider
|
|
|
|
is currently in use. Setting to true requires a FIPS build of Node.js.
|
2024-01-05 22:17:00 +01:00
|
|
|
|
2024-11-23 18:10:44 +01:00
|
|
|
This property is deprecated. Please use `crypto.setFips()` and
|
|
|
|
`crypto.getFips()` instead.
|
2024-01-05 22:17:00 +01:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
### `crypto.generateKey(type, options, callback)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!-- YAML
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
added: v15.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2020-08-25 10:05:51 -07:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `type`: {string} The intended use of the generated secret key. Currently
|
|
|
|
accepted values are `'hmac'` and `'aes'`.
|
|
|
|
* `options`: {Object}
|
|
|
|
* `length`: {number} The bit length of the key to generate. This must be a
|
|
|
|
value greater than 0.
|
2022-05-05 03:31:23 +08:00
|
|
|
* If `type` is `'hmac'`, the minimum is 8, and the maximum length is
|
2020-08-25 10:05:51 -07:00
|
|
|
2<sup>31</sup>-1. If the value is not a multiple of 8, the generated
|
|
|
|
key will be truncated to `Math.floor(length / 8)`.
|
2021-01-14 15:01:25 +01:00
|
|
|
* If `type` is `'aes'`, the length must be one of `128`, `192`, or `256`.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `callback`: {Function}
|
|
|
|
* `err`: {Error}
|
|
|
|
* `key`: {KeyObject}
|
|
|
|
|
|
|
|
Asynchronously generates a new random secret key of the given `length`. The
|
|
|
|
`type` will determine which validations will be performed on the `length`.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
generateKey,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
doc: use secure key length for HMAC generateKey
The examples for generateKey() and generateKeySync() generate 64-bit
HMAC keys. That is inadequate for virtually any HMAC instance. As per
common NIST recommendations, the minimum should be roughly 112 bits, or
more commonly 128 bits.
Due to the design of HMAC itself, it is not unreasonable to choose the
underlying hash function's block size as the key length. For many
popular hash functions (SHA-256, SHA-224, SHA-1, MD5, ...) this happens
to be 64 bytes (bytes, not bits!). This is consistent with the HMAC
implementation in .NET, for example, even though it provides virtually
no benefit over a 256-bit key.
PR-URL: https://github.com/nodejs/node/pull/48052
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-05-20 01:58:58 +02:00
|
|
|
generateKey('hmac', { length: 512 }, (err, key) => {
|
2021-03-03 14:25:03 -08:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(key.export().toString('hex')); // 46e..........620
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
generateKey,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2020-08-25 10:05:51 -07:00
|
|
|
|
doc: use secure key length for HMAC generateKey
The examples for generateKey() and generateKeySync() generate 64-bit
HMAC keys. That is inadequate for virtually any HMAC instance. As per
common NIST recommendations, the minimum should be roughly 112 bits, or
more commonly 128 bits.
Due to the design of HMAC itself, it is not unreasonable to choose the
underlying hash function's block size as the key length. For many
popular hash functions (SHA-256, SHA-224, SHA-1, MD5, ...) this happens
to be 64 bytes (bytes, not bits!). This is consistent with the HMAC
implementation in .NET, for example, even though it provides virtually
no benefit over a 256-bit key.
PR-URL: https://github.com/nodejs/node/pull/48052
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-05-20 01:58:58 +02:00
|
|
|
generateKey('hmac', { length: 512 }, (err, key) => {
|
2020-08-25 10:05:51 -07:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(key.export().toString('hex')); // 46e..........620
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2023-05-24 22:21:07 +02:00
|
|
|
The size of a generated HMAC key should not exceed the block size of the
|
|
|
|
underlying hash function. See [`crypto.createHmac()`][] for more information.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.generateKeyPair(type, options, callback)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-02 17:00:01 +02:00
|
|
|
<!-- YAML
|
2018-10-07 14:09:45 +02:00
|
|
|
added: v10.12.0
|
2018-09-20 19:53:44 +02:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2021-09-22 00:43:16 +01:00
|
|
|
- version: v16.10.0
|
2021-08-29 10:09:48 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/39927
|
|
|
|
description: Add ability to define `RSASSA-PSS-params` sequence parameters
|
|
|
|
for RSA-PSS keys pairs.
|
2020-05-01 14:43:14 +02:00
|
|
|
- version:
|
|
|
|
- v13.9.0
|
|
|
|
- v12.17.0
|
2019-12-31 02:12:36 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/31178
|
|
|
|
description: Add support for Diffie-Hellman.
|
2021-08-31 21:52:31 +02:00
|
|
|
- version: v12.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/26960
|
|
|
|
description: Add support for RSA-PSS key pairs.
|
2019-03-22 13:19:46 +00:00
|
|
|
- version: v12.0.0
|
2019-03-19 12:09:01 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26774
|
|
|
|
description: Add ability to generate X25519 and X448 key pairs.
|
2019-03-22 13:19:46 +00:00
|
|
|
- version: v12.0.0
|
2019-03-10 00:51:56 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26554
|
|
|
|
description: Add ability to generate Ed25519 and Ed448 key pairs.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: The `generateKeyPair` and `generateKeyPairSync` functions now
|
|
|
|
produce key objects if no encoding was specified.
|
2018-09-02 17:00:01 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2021-08-31 21:52:31 +02:00
|
|
|
* `type`: {string} Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`,
|
|
|
|
`'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
|
2018-09-02 17:00:01 +02:00
|
|
|
* `options`: {Object}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `modulusLength`: {number} Key size in bits (RSA, DSA).
|
|
|
|
* `publicExponent`: {number} Public exponent (RSA). **Default:** `0x10001`.
|
2021-08-29 10:09:48 +02:00
|
|
|
* `hashAlgorithm`: {string} Name of the message digest (RSA-PSS).
|
|
|
|
* `mgf1HashAlgorithm`: {string} Name of the message digest used by
|
|
|
|
MGF1 (RSA-PSS).
|
|
|
|
* `saltLength`: {number} Minimal salt length in bytes (RSA-PSS).
|
2019-09-13 00:22:29 -04:00
|
|
|
* `divisorLength`: {number} Size of `q` in bits (DSA).
|
|
|
|
* `namedCurve`: {string} Name of the curve to use (EC).
|
2019-12-31 02:12:36 +01:00
|
|
|
* `prime`: {Buffer} The prime parameter (DH).
|
|
|
|
* `primeLength`: {number} Prime length in bits (DH).
|
|
|
|
* `generator`: {number} Custom generator (DH). **Default:** `2`.
|
|
|
|
* `groupName`: {string} Diffie-Hellman group name (DH). See
|
|
|
|
[`crypto.getDiffieHellman()`][].
|
2022-11-21 20:55:28 +01:00
|
|
|
* `paramEncoding`: {string} Must be `'named'` or `'explicit'` (EC).
|
|
|
|
**Default:** `'named'`.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `publicKeyEncoding`: {Object} See [`keyObject.export()`][].
|
|
|
|
* `privateKeyEncoding`: {Object} See [`keyObject.export()`][].
|
2018-09-02 17:00:01 +02:00
|
|
|
* `callback`: {Function}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `err`: {Error}
|
|
|
|
* `publicKey`: {string | Buffer | KeyObject}
|
|
|
|
* `privateKey`: {string | Buffer | KeyObject}
|
2018-09-02 17:00:01 +02:00
|
|
|
|
2021-08-31 21:52:31 +02:00
|
|
|
Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
|
|
|
|
Ed25519, Ed448, X25519, X448, and DH are currently supported.
|
2018-09-02 17:00:01 +02:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
|
|
|
|
behaves as if [`keyObject.export()`][] had been called on its result. Otherwise,
|
2019-10-02 00:31:57 -04:00
|
|
|
the respective part of the key is returned as a [`KeyObject`][].
|
2018-09-20 19:53:44 +02:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
It is recommended to encode public keys as `'spki'` and private keys as
|
|
|
|
`'pkcs8'` with encryption for long-term storage:
|
|
|
|
|
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
generateKeyPair,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
generateKeyPair('rsa', {
|
|
|
|
modulusLength: 4096,
|
|
|
|
publicKeyEncoding: {
|
|
|
|
type: 'spki',
|
2022-11-17 08:19:12 -05:00
|
|
|
format: 'pem',
|
2021-03-03 14:25:03 -08:00
|
|
|
},
|
|
|
|
privateKeyEncoding: {
|
|
|
|
type: 'pkcs8',
|
|
|
|
format: 'pem',
|
|
|
|
cipher: 'aes-256-cbc',
|
2022-11-17 08:19:12 -05:00
|
|
|
passphrase: 'top secret',
|
|
|
|
},
|
2021-03-03 14:25:03 -08:00
|
|
|
}, (err, publicKey, privateKey) => {
|
|
|
|
// Handle errors and use the generated key pair.
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
generateKeyPair,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2018-09-02 17:00:01 +02:00
|
|
|
|
|
|
|
generateKeyPair('rsa', {
|
|
|
|
modulusLength: 4096,
|
|
|
|
publicKeyEncoding: {
|
|
|
|
type: 'spki',
|
2022-11-17 08:19:12 -05:00
|
|
|
format: 'pem',
|
2018-09-02 17:00:01 +02:00
|
|
|
},
|
|
|
|
privateKeyEncoding: {
|
|
|
|
type: 'pkcs8',
|
|
|
|
format: 'pem',
|
|
|
|
cipher: 'aes-256-cbc',
|
2022-11-17 08:19:12 -05:00
|
|
|
passphrase: 'top secret',
|
|
|
|
},
|
2018-09-02 17:00:01 +02:00
|
|
|
}, (err, publicKey, privateKey) => {
|
|
|
|
// Handle errors and use the generated key pair.
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
On completion, `callback` will be called with `err` set to `undefined` and
|
2018-09-20 19:53:44 +02:00
|
|
|
`publicKey` / `privateKey` representing the generated key pair.
|
2018-09-02 17:00:01 +02:00
|
|
|
|
2018-09-10 22:36:14 +02:00
|
|
|
If this method is invoked as its [`util.promisify()`][]ed version, it returns
|
|
|
|
a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.generateKeyPairSync(type, options)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-09-02 17:00:01 +02:00
|
|
|
<!-- YAML
|
2018-10-07 14:09:45 +02:00
|
|
|
added: v10.12.0
|
2018-09-20 19:53:44 +02:00
|
|
|
changes:
|
2021-09-22 00:43:16 +01:00
|
|
|
- version: v16.10.0
|
2021-08-29 10:09:48 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/39927
|
|
|
|
description: Add ability to define `RSASSA-PSS-params` sequence parameters
|
|
|
|
for RSA-PSS keys pairs.
|
2020-05-01 14:43:14 +02:00
|
|
|
- version:
|
|
|
|
- v13.9.0
|
|
|
|
- v12.17.0
|
2019-12-31 02:12:36 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/31178
|
|
|
|
description: Add support for Diffie-Hellman.
|
2021-08-31 21:52:31 +02:00
|
|
|
- version: v12.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/26960
|
|
|
|
description: Add support for RSA-PSS key pairs.
|
|
|
|
- version: v12.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/26774
|
|
|
|
description: Add ability to generate X25519 and X448 key pairs.
|
2019-03-22 13:19:46 +00:00
|
|
|
- version: v12.0.0
|
2019-03-10 00:51:56 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26554
|
|
|
|
description: Add ability to generate Ed25519 and Ed448 key pairs.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: The `generateKeyPair` and `generateKeyPairSync` functions now
|
|
|
|
produce key objects if no encoding was specified.
|
2018-09-02 17:00:01 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2021-08-31 21:52:31 +02:00
|
|
|
* `type`: {string} Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`,
|
|
|
|
`'ed448'`, `'x25519'`, `'x448'`, or `'dh'`.
|
2018-09-02 17:00:01 +02:00
|
|
|
* `options`: {Object}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `modulusLength`: {number} Key size in bits (RSA, DSA).
|
|
|
|
* `publicExponent`: {number} Public exponent (RSA). **Default:** `0x10001`.
|
2021-08-29 10:09:48 +02:00
|
|
|
* `hashAlgorithm`: {string} Name of the message digest (RSA-PSS).
|
|
|
|
* `mgf1HashAlgorithm`: {string} Name of the message digest used by
|
|
|
|
MGF1 (RSA-PSS).
|
|
|
|
* `saltLength`: {number} Minimal salt length in bytes (RSA-PSS).
|
2019-09-13 00:22:29 -04:00
|
|
|
* `divisorLength`: {number} Size of `q` in bits (DSA).
|
|
|
|
* `namedCurve`: {string} Name of the curve to use (EC).
|
2019-12-31 02:12:36 +01:00
|
|
|
* `prime`: {Buffer} The prime parameter (DH).
|
|
|
|
* `primeLength`: {number} Prime length in bits (DH).
|
|
|
|
* `generator`: {number} Custom generator (DH). **Default:** `2`.
|
|
|
|
* `groupName`: {string} Diffie-Hellman group name (DH). See
|
|
|
|
[`crypto.getDiffieHellman()`][].
|
2022-11-21 20:55:28 +01:00
|
|
|
* `paramEncoding`: {string} Must be `'named'` or `'explicit'` (EC).
|
|
|
|
**Default:** `'named'`.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `publicKeyEncoding`: {Object} See [`keyObject.export()`][].
|
|
|
|
* `privateKeyEncoding`: {Object} See [`keyObject.export()`][].
|
2018-09-02 17:00:01 +02:00
|
|
|
* Returns: {Object}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `publicKey`: {string | Buffer | KeyObject}
|
|
|
|
* `privateKey`: {string | Buffer | KeyObject}
|
2018-09-02 17:00:01 +02:00
|
|
|
|
2021-08-31 21:52:31 +02:00
|
|
|
Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
|
|
|
|
Ed25519, Ed448, X25519, X448, and DH are currently supported.
|
2018-09-02 17:00:01 +02:00
|
|
|
|
2019-01-03 18:59:34 +01:00
|
|
|
If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
|
|
|
|
behaves as if [`keyObject.export()`][] had been called on its result. Otherwise,
|
2019-10-02 00:31:57 -04:00
|
|
|
the respective part of the key is returned as a [`KeyObject`][].
|
2019-01-03 18:59:34 +01:00
|
|
|
|
|
|
|
When encoding public keys, it is recommended to use `'spki'`. When encoding
|
2020-05-01 13:19:45 +08:00
|
|
|
private keys, it is recommended to use `'pkcs8'` with a strong passphrase,
|
|
|
|
and to keep the passphrase confidential.
|
2018-09-02 17:00:01 +02:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
generateKeyPairSync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const {
|
|
|
|
publicKey,
|
|
|
|
privateKey,
|
|
|
|
} = generateKeyPairSync('rsa', {
|
|
|
|
modulusLength: 4096,
|
|
|
|
publicKeyEncoding: {
|
|
|
|
type: 'spki',
|
2022-11-17 08:19:12 -05:00
|
|
|
format: 'pem',
|
2021-03-03 14:25:03 -08:00
|
|
|
},
|
|
|
|
privateKeyEncoding: {
|
|
|
|
type: 'pkcs8',
|
|
|
|
format: 'pem',
|
|
|
|
cipher: 'aes-256-cbc',
|
2022-11-17 08:19:12 -05:00
|
|
|
passphrase: 'top secret',
|
|
|
|
},
|
2021-03-03 14:25:03 -08:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
generateKeyPairSync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const {
|
|
|
|
publicKey,
|
|
|
|
privateKey,
|
|
|
|
} = generateKeyPairSync('rsa', {
|
2018-09-02 17:00:01 +02:00
|
|
|
modulusLength: 4096,
|
|
|
|
publicKeyEncoding: {
|
|
|
|
type: 'spki',
|
2022-11-17 08:19:12 -05:00
|
|
|
format: 'pem',
|
2018-09-02 17:00:01 +02:00
|
|
|
},
|
|
|
|
privateKeyEncoding: {
|
|
|
|
type: 'pkcs8',
|
|
|
|
format: 'pem',
|
|
|
|
cipher: 'aes-256-cbc',
|
2022-11-17 08:19:12 -05:00
|
|
|
passphrase: 'top secret',
|
|
|
|
},
|
2018-09-02 17:00:01 +02:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
The return value `{ publicKey, privateKey }` represents the generated key pair.
|
|
|
|
When PEM encoding was selected, the respective key will be a string, otherwise
|
|
|
|
it will be a buffer containing the data encoded as DER.
|
|
|
|
|
2021-02-13 06:23:24 -08:00
|
|
|
### `crypto.generateKeySync(type, options)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-02-13 06:23:24 -08:00
|
|
|
<!-- YAML
|
|
|
|
added: v15.0.0
|
|
|
|
-->
|
|
|
|
|
|
|
|
* `type`: {string} The intended use of the generated secret key. Currently
|
|
|
|
accepted values are `'hmac'` and `'aes'`.
|
|
|
|
* `options`: {Object}
|
|
|
|
* `length`: {number} The bit length of the key to generate.
|
2022-05-05 03:31:23 +08:00
|
|
|
* If `type` is `'hmac'`, the minimum is 8, and the maximum length is
|
2021-02-13 06:23:24 -08:00
|
|
|
2<sup>31</sup>-1. If the value is not a multiple of 8, the generated
|
|
|
|
key will be truncated to `Math.floor(length / 8)`.
|
|
|
|
* If `type` is `'aes'`, the length must be one of `128`, `192`, or `256`.
|
|
|
|
* Returns: {KeyObject}
|
|
|
|
|
|
|
|
Synchronously generates a new random secret key of the given `length`. The
|
|
|
|
`type` will determine which validations will be performed on the `length`.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
generateKeySync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
doc: use secure key length for HMAC generateKey
The examples for generateKey() and generateKeySync() generate 64-bit
HMAC keys. That is inadequate for virtually any HMAC instance. As per
common NIST recommendations, the minimum should be roughly 112 bits, or
more commonly 128 bits.
Due to the design of HMAC itself, it is not unreasonable to choose the
underlying hash function's block size as the key length. For many
popular hash functions (SHA-256, SHA-224, SHA-1, MD5, ...) this happens
to be 64 bytes (bytes, not bits!). This is consistent with the HMAC
implementation in .NET, for example, even though it provides virtually
no benefit over a 256-bit key.
PR-URL: https://github.com/nodejs/node/pull/48052
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-05-20 01:58:58 +02:00
|
|
|
const key = generateKeySync('hmac', { length: 512 });
|
2021-03-03 14:25:03 -08:00
|
|
|
console.log(key.export().toString('hex')); // e89..........41e
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
generateKeySync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-02-13 06:23:24 -08:00
|
|
|
|
doc: use secure key length for HMAC generateKey
The examples for generateKey() and generateKeySync() generate 64-bit
HMAC keys. That is inadequate for virtually any HMAC instance. As per
common NIST recommendations, the minimum should be roughly 112 bits, or
more commonly 128 bits.
Due to the design of HMAC itself, it is not unreasonable to choose the
underlying hash function's block size as the key length. For many
popular hash functions (SHA-256, SHA-224, SHA-1, MD5, ...) this happens
to be 64 bytes (bytes, not bits!). This is consistent with the HMAC
implementation in .NET, for example, even though it provides virtually
no benefit over a 256-bit key.
PR-URL: https://github.com/nodejs/node/pull/48052
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-05-20 01:58:58 +02:00
|
|
|
const key = generateKeySync('hmac', { length: 512 });
|
2021-02-13 06:23:24 -08:00
|
|
|
console.log(key.export().toString('hex')); // e89..........41e
|
|
|
|
```
|
|
|
|
|
2023-05-24 22:21:07 +02:00
|
|
|
The size of a generated HMAC key should not exceed the block size of the
|
|
|
|
underlying hash function. See [`crypto.createHmac()`][] for more information.
|
|
|
|
|
2021-01-18 23:03:58 -08:00
|
|
|
### `crypto.generatePrime(size[, options[, callback]])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-18 23:03:58 -08:00
|
|
|
<!-- YAML
|
2021-02-02 11:17:42 +01:00
|
|
|
added: v15.8.0
|
2022-01-24 19:39:16 +03:30
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2021-01-18 23:03:58 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `size` {number} The size (in bits) of the prime to generate.
|
|
|
|
* `options` {Object}
|
|
|
|
* `add` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
|
|
|
|
* `rem` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
|
2021-02-15 13:21:50 -05:00
|
|
|
* `safe` {boolean} **Default:** `false`.
|
2021-01-18 23:03:58 -08:00
|
|
|
* `bigint` {boolean} When `true`, the generated prime is returned
|
|
|
|
as a `bigint`.
|
|
|
|
* `callback` {Function}
|
|
|
|
* `err` {Error}
|
|
|
|
* `prime` {ArrayBuffer|bigint}
|
|
|
|
|
2021-04-10 22:23:34 -07:00
|
|
|
Generates a pseudorandom prime of `size` bits.
|
2021-01-18 23:03:58 -08:00
|
|
|
|
|
|
|
If `options.safe` is `true`, the prime will be a safe prime -- that is,
|
|
|
|
`(prime - 1) / 2` will also be a prime.
|
|
|
|
|
2021-01-26 20:40:57 +01:00
|
|
|
The `options.add` and `options.rem` parameters can be used to enforce additional
|
|
|
|
requirements, e.g., for Diffie-Hellman:
|
|
|
|
|
|
|
|
* If `options.add` and `options.rem` are both set, the prime will satisfy the
|
|
|
|
condition that `prime % add = rem`.
|
|
|
|
* If only `options.add` is set and `options.safe` is not `true`, the prime will
|
|
|
|
satisfy the condition that `prime % add = 1`.
|
|
|
|
* If only `options.add` is set and `options.safe` is set to `true`, the prime
|
|
|
|
will instead satisfy the condition that `prime % add = 3`. This is necessary
|
|
|
|
because `prime % add = 1` for `options.add > 2` would contradict the condition
|
|
|
|
enforced by `options.safe`.
|
|
|
|
* `options.rem` is ignored if `options.add` is not given.
|
2021-01-18 23:03:58 -08:00
|
|
|
|
|
|
|
Both `options.add` and `options.rem` must be encoded as big-endian sequences
|
|
|
|
if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or
|
|
|
|
`DataView`.
|
|
|
|
|
|
|
|
By default, the prime is encoded as a big-endian sequence of octets
|
|
|
|
in an {ArrayBuffer}. If the `bigint` option is `true`, then a {bigint}
|
|
|
|
is provided.
|
|
|
|
|
2025-01-03 15:22:12 -08:00
|
|
|
The `size` of the prime will have a direct impact on how long it takes to
|
|
|
|
generate the prime. The larger the size, the longer it will take. Because
|
|
|
|
we use OpenSSL's `BN_generate_prime_ex` function, which provides only
|
|
|
|
minimal control over our ability to interrupt the generation process,
|
|
|
|
it is not recommended to generate overly large primes, as doing so may make
|
|
|
|
the process unresponsive.
|
|
|
|
|
2021-01-18 23:03:58 -08:00
|
|
|
### `crypto.generatePrimeSync(size[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-18 23:03:58 -08:00
|
|
|
<!-- YAML
|
2021-02-02 11:17:42 +01:00
|
|
|
added: v15.8.0
|
2021-01-18 23:03:58 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `size` {number} The size (in bits) of the prime to generate.
|
|
|
|
* `options` {Object}
|
|
|
|
* `add` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
|
|
|
|
* `rem` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
|
2021-02-15 13:21:50 -05:00
|
|
|
* `safe` {boolean} **Default:** `false`.
|
2021-01-18 23:03:58 -08:00
|
|
|
* `bigint` {boolean} When `true`, the generated prime is returned
|
|
|
|
as a `bigint`.
|
|
|
|
* Returns: {ArrayBuffer|bigint}
|
|
|
|
|
2021-04-10 22:23:34 -07:00
|
|
|
Generates a pseudorandom prime of `size` bits.
|
2021-01-18 23:03:58 -08:00
|
|
|
|
|
|
|
If `options.safe` is `true`, the prime will be a safe prime -- that is,
|
2021-01-26 20:40:57 +01:00
|
|
|
`(prime - 1) / 2` will also be a prime.
|
|
|
|
|
|
|
|
The `options.add` and `options.rem` parameters can be used to enforce additional
|
|
|
|
requirements, e.g., for Diffie-Hellman:
|
|
|
|
|
|
|
|
* If `options.add` and `options.rem` are both set, the prime will satisfy the
|
|
|
|
condition that `prime % add = rem`.
|
|
|
|
* If only `options.add` is set and `options.safe` is not `true`, the prime will
|
|
|
|
satisfy the condition that `prime % add = 1`.
|
|
|
|
* If only `options.add` is set and `options.safe` is set to `true`, the prime
|
|
|
|
will instead satisfy the condition that `prime % add = 3`. This is necessary
|
|
|
|
because `prime % add = 1` for `options.add > 2` would contradict the condition
|
|
|
|
enforced by `options.safe`.
|
|
|
|
* `options.rem` is ignored if `options.add` is not given.
|
2021-01-18 23:03:58 -08:00
|
|
|
|
|
|
|
Both `options.add` and `options.rem` must be encoded as big-endian sequences
|
|
|
|
if given as an `ArrayBuffer`, `SharedArrayBuffer`, `TypedArray`, `Buffer`, or
|
|
|
|
`DataView`.
|
|
|
|
|
|
|
|
By default, the prime is encoded as a big-endian sequence of octets
|
|
|
|
in an {ArrayBuffer}. If the `bigint` option is `true`, then a {bigint}
|
|
|
|
is provided.
|
|
|
|
|
2025-01-03 15:22:12 -08:00
|
|
|
The `size` of the prime will have a direct impact on how long it takes to
|
|
|
|
generate the prime. The larger the size, the longer it will take. Because
|
|
|
|
we use OpenSSL's `BN_generate_prime_ex` function, which provides only
|
|
|
|
minimal control over our ability to interrupt the generation process,
|
|
|
|
it is not recommended to generate overly large primes, as doing so may make
|
|
|
|
the process unresponsive.
|
|
|
|
|
2020-09-26 19:20:03 -07:00
|
|
|
### `crypto.getCipherInfo(nameOrNid[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-09-26 19:20:03 -07:00
|
|
|
<!-- YAML
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
added: v15.0.0
|
2020-09-26 19:20:03 -07:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `nameOrNid`: {string|number} The name or nid of the cipher to query.
|
|
|
|
* `options`: {Object}
|
|
|
|
* `keyLength`: {number} A test key length.
|
|
|
|
* `ivLength`: {number} A test IV length.
|
|
|
|
* Returns: {Object}
|
|
|
|
* `name` {string} The name of the cipher
|
|
|
|
* `nid` {number} The nid of the cipher
|
|
|
|
* `blockSize` {number} The block size of the cipher in bytes. This property
|
|
|
|
is omitted when `mode` is `'stream'`.
|
|
|
|
* `ivLength` {number} The expected or default initialization vector length in
|
|
|
|
bytes. This property is omitted if the cipher does not use an initialization
|
|
|
|
vector.
|
|
|
|
* `keyLength` {number} The expected or default key length in bytes.
|
|
|
|
* `mode` {string} The cipher mode. One of `'cbc'`, `'ccm'`, `'cfb'`, `'ctr'`,
|
|
|
|
`'ecb'`, `'gcm'`, `'ocb'`, `'ofb'`, `'stream'`, `'wrap'`, `'xts'`.
|
|
|
|
|
|
|
|
Returns information about a given cipher.
|
|
|
|
|
|
|
|
Some ciphers accept variable length keys and initialization vectors. By default,
|
|
|
|
the `crypto.getCipherInfo()` method will return the default values for these
|
|
|
|
ciphers. To test if a given key length or iv length is acceptable for given
|
2021-04-07 10:32:24 +02:00
|
|
|
cipher, use the `keyLength` and `ivLength` options. If the given values are
|
2020-09-26 19:20:03 -07:00
|
|
|
unacceptable, `undefined` will be returned.
|
|
|
|
|
2021-02-13 06:23:24 -08:00
|
|
|
### `crypto.getCiphers()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-02-13 06:23:24 -08:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.9.3
|
|
|
|
-->
|
|
|
|
|
2021-10-10 21:55:04 -07:00
|
|
|
* Returns: {string\[]} An array with the names of the supported cipher
|
2021-02-13 06:23:24 -08:00
|
|
|
algorithms.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
getCiphers,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
console.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...]
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
getCiphers,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
console.log(getCiphers()); // ['aes-128-cbc', 'aes-128-ccm', ...]
|
2021-02-13 06:23:24 -08:00
|
|
|
```
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.getCurves()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v2.3.0
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2021-10-10 21:55:04 -07:00
|
|
|
* Returns: {string\[]} An array with the names of the supported elliptic curves.
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
getCurves,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
console.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
getCurves,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
console.log(getCurves()); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...]
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2011-01-19 02:00:38 +01:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.getDiffieHellman(groupName)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.5
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `groupName` {string}
|
2019-09-25 05:27:37 +09:00
|
|
|
* Returns: {DiffieHellmanGroup}
|
2012-01-22 19:24:37 +01:00
|
|
|
|
2019-09-25 05:27:37 +09:00
|
|
|
Creates a predefined `DiffieHellmanGroup` key exchange object. The
|
2022-09-17 03:00:35 +02:00
|
|
|
supported groups are listed in the documentation for [`DiffieHellmanGroup`][].
|
|
|
|
|
|
|
|
The returned object mimics the interface of objects created by
|
2016-01-05 02:49:54 -08:00
|
|
|
[`crypto.createDiffieHellman()`][], but will not allow changing
|
2018-08-26 19:02:27 +03:00
|
|
|
the keys (with [`diffieHellman.setPublicKey()`][], for example). The
|
2015-12-26 20:54:01 -08:00
|
|
|
advantage of using this method is that the parties do not have to
|
|
|
|
generate nor exchange a group modulus beforehand, saving both processor
|
2015-07-27 16:10:57 +09:00
|
|
|
and communication time.
|
2012-01-22 19:24:37 +01:00
|
|
|
|
|
|
|
Example (obtaining a shared secret):
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
getDiffieHellman,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
const alice = getDiffieHellman('modp14');
|
|
|
|
const bob = getDiffieHellman('modp14');
|
|
|
|
|
|
|
|
alice.generateKeys();
|
|
|
|
bob.generateKeys();
|
|
|
|
|
|
|
|
const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
|
|
|
|
const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');
|
|
|
|
|
|
|
|
/* aliceSecret and bobSecret should be the same */
|
|
|
|
console.log(aliceSecret === bobSecret);
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
getDiffieHellman,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const alice = getDiffieHellman('modp14');
|
|
|
|
const bob = getDiffieHellman('modp14');
|
2012-01-22 19:24:37 +01:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
alice.generateKeys();
|
|
|
|
bob.generateKeys();
|
2012-01-22 19:24:37 +01:00
|
|
|
|
2017-01-20 03:42:50 +02:00
|
|
|
const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
|
|
|
|
const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');
|
2014-08-27 18:01:01 +04:00
|
|
|
|
2017-01-20 03:42:50 +02:00
|
|
|
/* aliceSecret and bobSecret should be the same */
|
|
|
|
console.log(aliceSecret === bobSecret);
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2014-08-27 18:01:01 +04:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.getFips()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-01-23 16:32:19 -08:00
|
|
|
<!-- YAML
|
2018-03-02 09:53:46 -08:00
|
|
|
added: v10.0.0
|
2018-01-23 16:32:19 -08:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-03-31 06:51:47 -04:00
|
|
|
* Returns: {number} `1` if and only if a FIPS compliant crypto provider is
|
2020-04-02 16:22:08 -04:00
|
|
|
currently in use, `0` otherwise. A future semver-major release may change
|
|
|
|
the return type of this API to a {boolean}.
|
2018-01-23 16:32:19 -08:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.getHashes()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.9.3
|
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2021-10-10 21:55:04 -07:00
|
|
|
* Returns: {string\[]} An array of the names of the supported hash algorithms,
|
2019-01-11 11:43:58 -08:00
|
|
|
such as `'RSA-SHA256'`. Hash algorithms are also called "digest" algorithms.
|
2014-08-27 18:01:01 +04:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
getHashes,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
getHashes,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...]
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2012-01-22 19:24:37 +01:00
|
|
|
|
2021-12-27 06:48:59 -08:00
|
|
|
### `crypto.getRandomValues(typedArray)`
|
|
|
|
|
|
|
|
<!-- YAML
|
2022-01-16 15:09:58 +01:00
|
|
|
added: v17.4.0
|
2021-12-27 06:48:59 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `typedArray` {Buffer|TypedArray|DataView|ArrayBuffer}
|
|
|
|
* Returns: {Buffer|TypedArray|DataView|ArrayBuffer} Returns `typedArray`.
|
|
|
|
|
2022-02-22 17:51:50 +01:00
|
|
|
A convenient alias for [`crypto.webcrypto.getRandomValues()`][]. This
|
|
|
|
implementation is not compliant with the Web Crypto spec, to write
|
|
|
|
web-compatible code use [`crypto.webcrypto.getRandomValues()`][] instead.
|
2021-12-27 06:48:59 -08:00
|
|
|
|
2024-11-23 18:10:44 +01:00
|
|
|
### `crypto.hash(algorithm, data[, outputEncoding])`
|
|
|
|
|
|
|
|
<!-- YAML
|
|
|
|
added:
|
|
|
|
- v21.7.0
|
|
|
|
- v20.12.0
|
|
|
|
-->
|
|
|
|
|
|
|
|
> Stability: 1.2 - Release candidate
|
|
|
|
|
|
|
|
* `algorithm` {string|undefined}
|
|
|
|
* `data` {string|Buffer|TypedArray|DataView} When `data` is a
|
|
|
|
string, it will be encoded as UTF-8 before being hashed. If a different
|
|
|
|
input encoding is desired for a string input, user could encode the string
|
|
|
|
into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing
|
|
|
|
the encoded `TypedArray` into this API instead.
|
|
|
|
* `outputEncoding` {string|undefined} [Encoding][encoding] used to encode the
|
|
|
|
returned digest. **Default:** `'hex'`.
|
|
|
|
* Returns: {string|Buffer}
|
|
|
|
|
|
|
|
A utility for creating one-shot hash digests of data. It can be faster than
|
|
|
|
the object-based `crypto.createHash()` when hashing a smaller amount of data
|
|
|
|
(<= 5MB) that's readily available. If the data can be big or if it is streamed,
|
|
|
|
it's still recommended to use `crypto.createHash()` instead.
|
|
|
|
|
|
|
|
The `algorithm` is dependent on the available algorithms supported by the
|
|
|
|
version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
|
|
|
On recent releases of OpenSSL, `openssl list -digest-algorithms` will
|
|
|
|
display the available digest algorithms.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const crypto = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
|
|
|
|
|
|
|
// Hashing a string and return the result as a hex-encoded string.
|
|
|
|
const string = 'Node.js';
|
|
|
|
// 10b3493287f831e81a438811a1ffba01f8cec4b7
|
|
|
|
console.log(crypto.hash('sha1', string));
|
|
|
|
|
|
|
|
// Encode a base64-encoded string into a Buffer, hash it and return
|
|
|
|
// the result as a buffer.
|
|
|
|
const base64 = 'Tm9kZS5qcw==';
|
|
|
|
// <Buffer 10 b3 49 32 87 f8 31 e8 1a 43 88 11 a1 ff ba 01 f8 ce c4 b7>
|
|
|
|
console.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));
|
|
|
|
```
|
|
|
|
|
|
|
|
```mjs
|
|
|
|
import crypto from 'node:crypto';
|
|
|
|
import { Buffer } from 'node:buffer';
|
|
|
|
|
|
|
|
// Hashing a string and return the result as a hex-encoded string.
|
|
|
|
const string = 'Node.js';
|
|
|
|
// 10b3493287f831e81a438811a1ffba01f8cec4b7
|
|
|
|
console.log(crypto.hash('sha1', string));
|
|
|
|
|
|
|
|
// Encode a base64-encoded string into a Buffer, hash it and return
|
|
|
|
// the result as a buffer.
|
|
|
|
const base64 = 'Tm9kZS5qcw==';
|
|
|
|
// <Buffer 10 b3 49 32 87 f8 31 e8 1a 43 88 11 a1 ff ba 01 f8 ce c4 b7>
|
|
|
|
console.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));
|
|
|
|
```
|
|
|
|
|
2021-07-20 21:15:50 +02:00
|
|
|
### `crypto.hkdf(digest, ikm, salt, info, keylen, callback)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!-- YAML
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
added: v15.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
changes:
|
2022-10-11 14:54:19 -05:00
|
|
|
- version:
|
|
|
|
- v18.8.0
|
|
|
|
- v16.18.0
|
2022-08-11 11:53:00 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/44201
|
|
|
|
description: The input keying material can now be zero-length.
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2020-08-25 10:05:51 -07:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `digest` {string} The digest algorithm to use.
|
2021-07-20 21:15:50 +02:00
|
|
|
* `ikm` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject} The input
|
2022-08-11 11:53:00 +02:00
|
|
|
keying material. Must be provided but can be zero-length.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `salt` {string|ArrayBuffer|Buffer|TypedArray|DataView} The salt value. Must
|
|
|
|
be provided but can be zero-length.
|
|
|
|
* `info` {string|ArrayBuffer|Buffer|TypedArray|DataView} Additional info value.
|
|
|
|
Must be provided but can be zero-length, and cannot be more than 1024 bytes.
|
|
|
|
* `keylen` {number} The length of the key to generate. Must be greater than 0.
|
|
|
|
The maximum allowable value is `255` times the number of bytes produced by
|
|
|
|
the selected digest function (e.g. `sha512` generates 64-byte hashes, making
|
|
|
|
the maximum HKDF output 16320 bytes).
|
|
|
|
* `callback` {Function}
|
|
|
|
* `err` {Error}
|
2021-07-19 22:38:21 +02:00
|
|
|
* `derivedKey` {ArrayBuffer}
|
2020-08-25 10:05:51 -07:00
|
|
|
|
2021-07-20 21:15:50 +02:00
|
|
|
HKDF is a simple key derivation function defined in RFC 5869. The given `ikm`,
|
2020-08-25 10:05:51 -07:00
|
|
|
`salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
|
|
|
|
|
|
|
|
The supplied `callback` function is called with two arguments: `err` and
|
|
|
|
`derivedKey`. If an errors occurs while deriving the key, `err` will be set;
|
|
|
|
otherwise `err` will be `null`. The successfully generated `derivedKey` will
|
|
|
|
be passed to the callback as an {ArrayBuffer}. An error will be thrown if any
|
2021-06-15 19:44:11 -04:00
|
|
|
of the input arguments specify invalid values or types.
|
2020-08-25 10:05:51 -07:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
hkdf,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653'
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
hkdf,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
hkdf('sha512', 'key', 'salt', 'info', 64, (err, derivedKey) => {
|
2020-08-25 10:05:51 -07:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653'
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2021-07-20 21:15:50 +02:00
|
|
|
### `crypto.hkdfSync(digest, ikm, salt, info, keylen)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!-- YAML
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
added: v15.0.0
|
2022-08-11 11:53:00 +02:00
|
|
|
changes:
|
2022-10-11 14:54:19 -05:00
|
|
|
- version:
|
|
|
|
- v18.8.0
|
|
|
|
- v16.18.0
|
2022-08-11 11:53:00 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/44201
|
|
|
|
description: The input keying material can now be zero-length.
|
2020-08-25 10:05:51 -07:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `digest` {string} The digest algorithm to use.
|
2021-07-20 21:15:50 +02:00
|
|
|
* `ikm` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject} The input
|
2022-08-11 11:53:00 +02:00
|
|
|
keying material. Must be provided but can be zero-length.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `salt` {string|ArrayBuffer|Buffer|TypedArray|DataView} The salt value. Must
|
|
|
|
be provided but can be zero-length.
|
|
|
|
* `info` {string|ArrayBuffer|Buffer|TypedArray|DataView} Additional info value.
|
|
|
|
Must be provided but can be zero-length, and cannot be more than 1024 bytes.
|
|
|
|
* `keylen` {number} The length of the key to generate. Must be greater than 0.
|
|
|
|
The maximum allowable value is `255` times the number of bytes produced by
|
|
|
|
the selected digest function (e.g. `sha512` generates 64-byte hashes, making
|
|
|
|
the maximum HKDF output 16320 bytes).
|
|
|
|
* Returns: {ArrayBuffer}
|
|
|
|
|
|
|
|
Provides a synchronous HKDF key derivation function as defined in RFC 5869. The
|
2021-07-20 21:15:50 +02:00
|
|
|
given `ikm`, `salt` and `info` are used with the `digest` to derive a key of
|
2020-08-25 10:05:51 -07:00
|
|
|
`keylen` bytes.
|
|
|
|
|
|
|
|
The successfully generated `derivedKey` will be returned as an {ArrayBuffer}.
|
|
|
|
|
2021-06-15 19:44:11 -04:00
|
|
|
An error will be thrown if any of the input arguments specify invalid values or
|
2020-08-25 10:05:51 -07:00
|
|
|
types, or if the derived key cannot be generated.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
hkdfSync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64);
|
|
|
|
console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653'
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
hkdfSync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const derivedKey = hkdfSync('sha512', 'key', 'salt', 'info', 64);
|
2020-08-25 10:05:51 -07:00
|
|
|
console.log(Buffer.from(derivedKey).toString('hex')); // '24156e2...5391653'
|
|
|
|
```
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.pbkdf2(password, salt, iterations, keylen, digest, callback)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.5
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The password and salt arguments can also be ArrayBuffer
|
|
|
|
instances.
|
2020-03-10 17:16:08 +00:00
|
|
|
- version: v14.0.0
|
2019-11-21 11:00:03 -04:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/30578
|
|
|
|
description: The `iterations` parameter is now restricted to positive
|
|
|
|
values. Earlier releases treated other values as one.
|
2017-03-15 20:26:14 -07:00
|
|
|
- version: v8.0.0
|
2017-02-22 00:10:25 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/11305
|
|
|
|
description: The `digest` parameter is always required now.
|
2017-02-21 23:38:44 +01:00
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/4047
|
|
|
|
description: Calling this function without passing the `digest` parameter
|
|
|
|
is deprecated now and will emit a warning.
|
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
|
|
|
description: The default encoding for `password` if it is a string changed
|
|
|
|
from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `password` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `salt` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* `iterations` {number}
|
|
|
|
* `keylen` {number}
|
|
|
|
* `digest` {string}
|
|
|
|
* `callback` {Function}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `err` {Error}
|
|
|
|
* `derivedKey` {Buffer}
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)
|
2016-02-15 03:40:53 +03:00
|
|
|
implementation. A selected HMAC digest algorithm specified by `digest` is
|
2015-12-26 20:54:01 -08:00
|
|
|
applied to derive a key of the requested byte length (`keylen`) from the
|
2015-11-27 10:41:38 +00:00
|
|
|
`password`, `salt` and `iterations`.
|
2011-08-11 17:40:55 +08:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The supplied `callback` function is called with two arguments: `err` and
|
2017-10-02 20:56:49 -07:00
|
|
|
`derivedKey`. If an error occurs while deriving the key, `err` will be set;
|
2018-04-29 20:46:41 +03:00
|
|
|
otherwise `err` will be `null`. By default, the successfully generated
|
2017-10-02 20:56:49 -07:00
|
|
|
`derivedKey` will be passed to the callback as a [`Buffer`][]. An error will be
|
|
|
|
thrown if any of the input arguments specify invalid values or types.
|
2011-09-22 22:12:10 +02:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The `iterations` argument must be a number set as high as possible. The
|
|
|
|
higher the number of iterations, the more secure the derived key will be,
|
|
|
|
but will take a longer amount of time to complete.
|
2015-10-09 13:58:44 +01:00
|
|
|
|
2018-05-18 11:05:20 +02:00
|
|
|
The `salt` should be as unique as possible. It is recommended that a salt is
|
|
|
|
random and at least 16 bytes long. See [NIST SP 800-132][] for details.
|
2015-10-09 13:58:44 +01:00
|
|
|
|
2021-02-06 16:51:50 +01:00
|
|
|
When passing strings for `password` or `salt`, please consider
|
|
|
|
[caveats when using strings as inputs to cryptographic APIs][].
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
pbkdf2,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(derivedKey.toString('hex')); // '3745e48...08d59ae'
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
pbkdf2,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {
|
2016-01-17 18:39:07 +01:00
|
|
|
if (err) throw err;
|
2017-10-14 16:30:41 +02:00
|
|
|
console.log(derivedKey.toString('hex')); // '3745e48...08d59ae'
|
2016-01-17 18:39:07 +01:00
|
|
|
});
|
|
|
|
```
|
2013-11-21 11:29:07 +01:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
An array of supported digest functions can be retrieved using
|
|
|
|
[`crypto.getHashes()`][].
|
2013-11-21 11:29:07 +01:00
|
|
|
|
2019-06-20 14:01:15 -06:00
|
|
|
This API uses libuv's threadpool, which can have surprising and
|
|
|
|
negative performance implications for some applications; see the
|
2017-08-23 14:59:06 -07:00
|
|
|
[`UV_THREADPOOL_SIZE`][] documentation for more information.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.pbkdf2Sync(password, salt, iterations, keylen, digest)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.9.3
|
2017-02-21 23:38:44 +01:00
|
|
|
changes:
|
2020-03-10 17:16:08 +00:00
|
|
|
- version: v14.0.0
|
2019-11-21 11:00:03 -04:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/30578
|
|
|
|
description: The `iterations` parameter is now restricted to positive
|
|
|
|
values. Earlier releases treated other values as one.
|
2017-02-21 23:38:44 +01:00
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/4047
|
|
|
|
description: Calling this function without passing the `digest` parameter
|
|
|
|
is deprecated now and will emit a warning.
|
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/5522
|
|
|
|
description: The default encoding for `password` if it is a string changed
|
|
|
|
from `binary` to `utf8`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `password` {string|Buffer|TypedArray|DataView}
|
|
|
|
* `salt` {string|Buffer|TypedArray|DataView}
|
|
|
|
* `iterations` {number}
|
|
|
|
* `keylen` {number}
|
|
|
|
* `digest` {string}
|
|
|
|
* Returns: {Buffer}
|
2012-10-12 17:36:18 -07:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2)
|
2016-02-15 03:40:53 +03:00
|
|
|
implementation. A selected HMAC digest algorithm specified by `digest` is
|
2015-12-26 20:54:01 -08:00
|
|
|
applied to derive a key of the requested byte length (`keylen`) from the
|
2015-11-27 10:41:38 +00:00
|
|
|
`password`, `salt` and `iterations`.
|
2012-10-12 17:36:18 -07:00
|
|
|
|
2018-04-29 20:46:41 +03:00
|
|
|
If an error occurs an `Error` will be thrown, otherwise the derived key will be
|
2015-12-26 20:54:01 -08:00
|
|
|
returned as a [`Buffer`][].
|
|
|
|
|
|
|
|
The `iterations` argument must be a number set as high as possible. The
|
|
|
|
higher the number of iterations, the more secure the derived key will be,
|
|
|
|
but will take a longer amount of time to complete.
|
|
|
|
|
2018-05-18 11:05:20 +02:00
|
|
|
The `salt` should be as unique as possible. It is recommended that a salt is
|
|
|
|
random and at least 16 bytes long. See [NIST SP 800-132][] for details.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2021-02-06 16:51:50 +01:00
|
|
|
When passing strings for `password` or `salt`, please consider
|
|
|
|
[caveats when using strings as inputs to cryptographic APIs][].
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
pbkdf2Sync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
|
|
|
|
console.log(key.toString('hex')); // '3745e48...08d59ae'
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
pbkdf2Sync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const key = pbkdf2Sync('secret', 'salt', 100000, 64, 'sha512');
|
2017-10-14 16:30:41 +02:00
|
|
|
console.log(key.toString('hex')); // '3745e48...08d59ae'
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2015-12-26 20:54:01 -08:00
|
|
|
|
|
|
|
An array of supported digest functions can be retrieved using
|
|
|
|
[`crypto.getHashes()`][].
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.privateDecrypt(privateKey, buffer)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
2018-09-20 19:53:44 +02:00
|
|
|
changes:
|
2024-02-18 16:04:19 +01:00
|
|
|
- version:
|
|
|
|
- v21.6.2
|
|
|
|
- v20.11.1
|
|
|
|
- v18.19.1
|
2024-02-18 16:18:02 +01:00
|
|
|
pr-url: https://github.com/nodejs-private/node-private/pull/515
|
|
|
|
description: The `RSA_PKCS1_PADDING` padding was disabled unless the
|
|
|
|
OpenSSL build supports implicit rejection.
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: Added string, ArrayBuffer, and CryptoKey as allowable key
|
|
|
|
types. The oaepLabel can be an ArrayBuffer. The buffer can
|
|
|
|
be a string or ArrayBuffer. All types that accept buffers
|
|
|
|
are limited to a maximum of 2 ** 31 - 1 bytes.
|
2019-09-25 00:45:45 +02:00
|
|
|
- version: v12.11.0
|
2019-09-08 04:41:04 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/29489
|
|
|
|
description: The `oaepLabel` option was added.
|
2019-08-19 21:14:22 +02:00
|
|
|
- version: v12.9.0
|
2019-06-21 16:37:06 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/28335
|
|
|
|
description: The `oaepHash` option was added.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: This function now supports key objects.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `privateKey` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
2020-03-18 09:57:30 +01:00
|
|
|
* `oaepHash` {string} The hash function to use for OAEP padding and MGF1.
|
2019-06-21 16:37:06 +02:00
|
|
|
**Default:** `'sha1'`
|
2020-08-25 10:05:51 -07:00
|
|
|
* `oaepLabel` {string|ArrayBuffer|Buffer|TypedArray|DataView} The label to
|
2021-10-10 21:55:04 -07:00
|
|
|
use for OAEP padding. If not specified, no label is used.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `padding` {crypto.constants} An optional padding value defined in
|
2017-03-10 22:30:48 -08:00
|
|
|
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
|
2018-05-27 20:33:48 -05:00
|
|
|
`crypto.constants.RSA_PKCS1_PADDING`, or
|
|
|
|
`crypto.constants.RSA_PKCS1_OAEP_PADDING`.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `buffer` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer} A new `Buffer` with the decrypted content.
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2013-03-03 15:11:08 -06:00
|
|
|
|
2018-09-12 15:25:43 +02:00
|
|
|
Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
|
|
|
|
the corresponding public key, for example using [`crypto.publicEncrypt()`][].
|
2013-10-15 08:31:14 -06:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
If `privateKey` is not a [`KeyObject`][], this function behaves as if
|
|
|
|
`privateKey` had been passed to [`crypto.createPrivateKey()`][]. If it is an
|
|
|
|
object, the `padding` property can be passed. Otherwise, this function uses
|
|
|
|
`RSA_PKCS1_OAEP_PADDING`.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2024-02-18 16:18:02 +01:00
|
|
|
Using `crypto.constants.RSA_PKCS1_PADDING` in [`crypto.privateDecrypt()`][]
|
|
|
|
requires OpenSSL to support implicit rejection (`rsa_pkcs1_implicit_rejection`).
|
|
|
|
If the version of OpenSSL used by Node.js does not support this feature,
|
|
|
|
attempting to use `RSA_PKCS1_PADDING` will fail.
|
2024-02-18 16:04:19 +01:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.privateEncrypt(privateKey, buffer)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v1.1.0
|
2018-09-20 19:53:44 +02:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: Added string, ArrayBuffer, and CryptoKey as allowable key
|
|
|
|
types. The passphrase can be an ArrayBuffer. The buffer can
|
|
|
|
be a string or ArrayBuffer. All types that accept buffers
|
|
|
|
are limited to a maximum of 2 ** 31 - 1 bytes.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: This function now supports key objects.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `privateKey` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
|
|
|
* `key` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
|
|
|
A PEM encoded private key.
|
|
|
|
* `passphrase` {string|ArrayBuffer|Buffer|TypedArray|DataView} An optional
|
|
|
|
passphrase for the private key.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `padding` {crypto.constants} An optional padding value defined in
|
2017-03-10 22:30:48 -08:00
|
|
|
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or
|
2018-05-27 20:33:48 -05:00
|
|
|
`crypto.constants.RSA_PKCS1_PADDING`.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `encoding` {string} The string encoding to use when `buffer`, `key`,
|
2021-02-08 01:37:00 +01:00
|
|
|
or `passphrase` are strings.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `buffer` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer} A new `Buffer` with the encrypted content.
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2018-09-12 15:25:43 +02:00
|
|
|
Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
|
|
|
|
the corresponding public key, for example using [`crypto.publicDecrypt()`][].
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
If `privateKey` is not a [`KeyObject`][], this function behaves as if
|
|
|
|
`privateKey` had been passed to [`crypto.createPrivateKey()`][]. If it is an
|
|
|
|
object, the `padding` property can be passed. Otherwise, this function uses
|
|
|
|
`RSA_PKCS1_PADDING`.
|
2015-12-26 20:54:01 -08:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.publicDecrypt(key, buffer)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v1.1.0
|
2018-09-20 19:53:44 +02:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: Added string, ArrayBuffer, and CryptoKey as allowable key
|
|
|
|
types. The passphrase can be an ArrayBuffer. The buffer can
|
|
|
|
be a string or ArrayBuffer. All types that accept buffers
|
|
|
|
are limited to a maximum of 2 ** 31 - 1 bytes.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: This function now supports key objects.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `key` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
|
|
|
* `passphrase` {string|ArrayBuffer|Buffer|TypedArray|DataView} An optional
|
|
|
|
passphrase for the private key.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `padding` {crypto.constants} An optional padding value defined in
|
2017-07-02 11:18:30 +08:00
|
|
|
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or
|
2018-05-27 20:33:48 -05:00
|
|
|
`crypto.constants.RSA_PKCS1_PADDING`.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `encoding` {string} The string encoding to use when `buffer`, `key`,
|
2021-02-08 01:37:00 +01:00
|
|
|
or `passphrase` are strings.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `buffer` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer} A new `Buffer` with the decrypted content.
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2013-10-15 08:31:14 -06:00
|
|
|
|
2018-09-12 15:25:43 +02:00
|
|
|
Decrypts `buffer` with `key`.`buffer` was previously encrypted using
|
|
|
|
the corresponding private key, for example using [`crypto.privateEncrypt()`][].
|
2013-10-15 08:31:14 -06:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
If `key` is not a [`KeyObject`][], this function behaves as if
|
|
|
|
`key` had been passed to [`crypto.createPublicKey()`][]. If it is an
|
|
|
|
object, the `padding` property can be passed. Otherwise, this function uses
|
|
|
|
`RSA_PKCS1_PADDING`.
|
2013-10-15 08:31:14 -06:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Because RSA public keys can be derived from private keys, a private key may
|
|
|
|
be passed instead of a public key.
|
2013-10-15 08:31:14 -06:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.publicEncrypt(key, buffer)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.14
|
2018-09-20 19:53:44 +02:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: Added string, ArrayBuffer, and CryptoKey as allowable key
|
|
|
|
types. The oaepLabel and passphrase can be ArrayBuffers. The
|
|
|
|
buffer can be a string or ArrayBuffer. All types that accept
|
|
|
|
buffers are limited to a maximum of 2 ** 31 - 1 bytes.
|
2019-09-25 00:45:45 +02:00
|
|
|
- version: v12.11.0
|
2019-09-08 04:41:04 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/29489
|
|
|
|
description: The `oaepLabel` option was added.
|
2019-08-19 21:14:22 +02:00
|
|
|
- version: v12.9.0
|
2019-06-21 16:37:06 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/28335
|
|
|
|
description: The `oaepHash` option was added.
|
2018-12-21 18:13:09 -05:00
|
|
|
- version: v11.6.0
|
2018-09-20 19:53:44 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/24234
|
|
|
|
description: This function now supports key objects.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `key` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
|
|
|
* `key` {string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
|
|
|
A PEM encoded public or private key, {KeyObject}, or {CryptoKey}.
|
2020-03-18 09:57:30 +01:00
|
|
|
* `oaepHash` {string} The hash function to use for OAEP padding and MGF1.
|
2019-06-21 16:37:06 +02:00
|
|
|
**Default:** `'sha1'`
|
2020-08-25 10:05:51 -07:00
|
|
|
* `oaepLabel` {string|ArrayBuffer|Buffer|TypedArray|DataView} The label to
|
|
|
|
use for OAEP padding. If not specified, no label is used.
|
|
|
|
* `passphrase` {string|ArrayBuffer|Buffer|TypedArray|DataView} An optional
|
|
|
|
passphrase for the private key.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `padding` {crypto.constants} An optional padding value defined in
|
2017-03-10 22:30:48 -08:00
|
|
|
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
|
2018-05-27 20:33:48 -05:00
|
|
|
`crypto.constants.RSA_PKCS1_PADDING`, or
|
|
|
|
`crypto.constants.RSA_PKCS1_OAEP_PADDING`.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `encoding` {string} The string encoding to use when `buffer`, `key`,
|
2021-02-08 01:37:00 +01:00
|
|
|
`oaepLabel`, or `passphrase` are strings.
|
2020-08-25 10:05:51 -07:00
|
|
|
* `buffer` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer} A new `Buffer` with the encrypted content.
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2014-05-05 17:35:28 +03:00
|
|
|
|
2017-10-08 19:35:18 +02:00
|
|
|
Encrypts the content of `buffer` with `key` and returns a new
|
2018-09-12 15:25:43 +02:00
|
|
|
[`Buffer`][] with encrypted content. The returned data can be decrypted using
|
|
|
|
the corresponding private key, for example using [`crypto.privateDecrypt()`][].
|
2014-05-05 17:35:28 +03:00
|
|
|
|
2018-09-20 19:53:44 +02:00
|
|
|
If `key` is not a [`KeyObject`][], this function behaves as if
|
|
|
|
`key` had been passed to [`crypto.createPublicKey()`][]. If it is an
|
|
|
|
object, the `padding` property can be passed. Otherwise, this function uses
|
|
|
|
`RSA_PKCS1_OAEP_PADDING`.
|
2014-08-23 17:38:32 +04:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Because RSA public keys can be derived from private keys, a private key may
|
|
|
|
be passed instead of a public key.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.randomBytes(size[, callback])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.5.8
|
2017-12-10 21:12:21 +01:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2017-12-10 21:12:21 +01:00
|
|
|
- version: v9.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/16454
|
|
|
|
description: Passing `null` as the `callback` argument now throws
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `size` {number} The number of bytes to generate. The `size` must
|
|
|
|
not be larger than `2**31 - 1`.
|
2018-07-12 13:48:11 -04:00
|
|
|
* `callback` {Function}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `err` {Error}
|
|
|
|
* `buf` {Buffer}
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer} if the `callback` function is not provided.
|
2014-08-23 17:38:32 +04:00
|
|
|
|
2021-04-10 22:23:34 -07:00
|
|
|
Generates cryptographically strong pseudorandom data. The `size` argument
|
2015-12-26 20:54:01 -08:00
|
|
|
is a number indicating the number of bytes to generate.
|
2014-05-05 17:35:28 +03:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
If a `callback` function is provided, the bytes are generated asynchronously
|
|
|
|
and the `callback` function is invoked with two arguments: `err` and `buf`.
|
2018-04-29 20:46:41 +03:00
|
|
|
If an error occurs, `err` will be an `Error` object; otherwise it is `null`. The
|
2015-12-26 20:54:01 -08:00
|
|
|
`buf` argument is a [`Buffer`][] containing the generated bytes.
|
2014-05-05 17:35:28 +03:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2016-01-17 18:39:07 +01:00
|
|
|
// Asynchronous
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
randomBytes,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
randomBytes(256, (err, buf) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
// Asynchronous
|
|
|
|
const {
|
|
|
|
randomBytes,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
randomBytes(256, (err, buf) => {
|
2016-01-17 18:39:07 +01:00
|
|
|
if (err) throw err;
|
2016-02-15 09:49:00 -06:00
|
|
|
console.log(`${buf.length} bytes of random data: ${buf.toString('hex')}`);
|
2016-01-17 18:39:07 +01:00
|
|
|
});
|
|
|
|
```
|
2014-05-05 17:35:28 +03:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
If the `callback` function is not provided, the random bytes are generated
|
|
|
|
synchronously and returned as a [`Buffer`][]. An error will be thrown if
|
|
|
|
there is a problem generating the bytes.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2016-01-17 18:39:07 +01:00
|
|
|
// Synchronous
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
randomBytes,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const buf = randomBytes(256);
|
|
|
|
console.log(
|
|
|
|
`${buf.length} bytes of random data: ${buf.toString('hex')}`);
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
// Synchronous
|
|
|
|
const {
|
|
|
|
randomBytes,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const buf = randomBytes(256);
|
2016-01-17 18:39:07 +01:00
|
|
|
console.log(
|
2016-03-18 12:22:22 +00:00
|
|
|
`${buf.length} bytes of random data: ${buf.toString('hex')}`);
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2014-08-23 17:38:32 +04:00
|
|
|
|
2017-08-23 14:04:33 -07:00
|
|
|
The `crypto.randomBytes()` method will not complete until there is
|
|
|
|
sufficient entropy available.
|
2015-12-26 20:54:01 -08:00
|
|
|
This should normally never take longer than a few milliseconds. The only time
|
|
|
|
when generating the random bytes may conceivably block for a longer period of
|
|
|
|
time is right after boot, when the whole system is still low on entropy.
|
2014-05-05 17:35:28 +03:00
|
|
|
|
2019-06-20 14:01:15 -06:00
|
|
|
This API uses libuv's threadpool, which can have surprising and
|
|
|
|
negative performance implications for some applications; see the
|
2017-08-23 14:59:06 -07:00
|
|
|
[`UV_THREADPOOL_SIZE`][] documentation for more information.
|
|
|
|
|
2018-02-05 21:55:16 -08:00
|
|
|
The asynchronous version of `crypto.randomBytes()` is carried out in a single
|
|
|
|
threadpool request. To minimize threadpool task length variation, partition
|
|
|
|
large `randomBytes` requests when doing so as part of fulfilling a client
|
|
|
|
request.
|
2017-11-22 10:03:17 -05:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.randomFill(buffer[, offset][, size], callback)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-12-09 17:13:14 -06:00
|
|
|
<!-- YAML
|
2018-12-03 18:13:42 +01:00
|
|
|
added:
|
|
|
|
- v7.10.0
|
|
|
|
- v6.13.0
|
2017-09-06 08:10:34 -07:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2017-09-01 09:50:47 -07:00
|
|
|
- version: v9.0.0
|
2017-09-06 08:10:34 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/15231
|
2017-12-10 21:42:25 +01:00
|
|
|
description: The `buffer` argument may be any `TypedArray` or `DataView`.
|
2016-12-09 17:13:14 -06:00
|
|
|
-->
|
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `buffer` {ArrayBuffer|Buffer|TypedArray|DataView} Must be supplied. The
|
|
|
|
size of the provided `buffer` must not be larger than `2**31 - 1`.
|
2018-04-02 04:44:32 +03:00
|
|
|
* `offset` {number} **Default:** `0`
|
2020-08-25 10:05:51 -07:00
|
|
|
* `size` {number} **Default:** `buffer.length - offset`. The `size` must
|
|
|
|
not be larger than `2**31 - 1`.
|
2016-12-09 17:13:14 -06:00
|
|
|
* `callback` {Function} `function(err, buf) {}`.
|
|
|
|
|
|
|
|
This function is similar to [`crypto.randomBytes()`][] but requires the first
|
|
|
|
argument to be a [`Buffer`][] that will be filled. It also
|
|
|
|
requires that a callback is passed in.
|
|
|
|
|
|
|
|
If the `callback` function is not provided, an error will be thrown.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
|
|
|
const { randomFill } = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const buf = Buffer.alloc(10);
|
|
|
|
randomFill(buf, (err, buf) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
});
|
|
|
|
|
|
|
|
randomFill(buf, 5, (err, buf) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// The above is equivalent to the following:
|
|
|
|
randomFill(buf, 5, 5, (err, buf) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { randomFill } = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
2016-12-09 17:13:14 -06:00
|
|
|
const buf = Buffer.alloc(10);
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(buf, (err, buf) => {
|
2016-12-09 17:13:14 -06:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
});
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(buf, 5, (err, buf) => {
|
2016-12-09 17:13:14 -06:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// The above is equivalent to the following:
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(buf, 5, 5, (err, buf) => {
|
2016-12-09 17:13:14 -06:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2021-04-07 22:38:02 +02:00
|
|
|
Any `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as
|
2020-08-25 10:05:51 -07:00
|
|
|
`buffer`.
|
2017-09-06 08:10:34 -07:00
|
|
|
|
2021-04-08 12:02:17 +02:00
|
|
|
While this includes instances of `Float32Array` and `Float64Array`, this
|
|
|
|
function should not be used to generate random floating-point numbers. The
|
|
|
|
result may contain `+Infinity`, `-Infinity`, and `NaN`, and even if the array
|
|
|
|
contains finite numbers only, they are not drawn from a uniform random
|
|
|
|
distribution and have no meaningful lower or upper bounds.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
|
|
|
const { randomFill } = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const a = new Uint32Array(10);
|
|
|
|
randomFill(a, (err, buf) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
|
|
.toString('hex'));
|
|
|
|
});
|
|
|
|
|
2021-04-08 12:02:17 +02:00
|
|
|
const b = new DataView(new ArrayBuffer(10));
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(b, (err, buf) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
|
|
.toString('hex'));
|
|
|
|
});
|
|
|
|
|
2021-04-08 12:02:17 +02:00
|
|
|
const c = new ArrayBuffer(10);
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(c, (err, buf) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(Buffer.from(buf).toString('hex'));
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { randomFill } = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
2017-09-06 08:10:34 -07:00
|
|
|
const a = new Uint32Array(10);
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(a, (err, buf) => {
|
2017-09-06 08:10:34 -07:00
|
|
|
if (err) throw err;
|
2018-06-26 23:49:47 +02:00
|
|
|
console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
|
|
.toString('hex'));
|
2017-09-06 08:10:34 -07:00
|
|
|
});
|
|
|
|
|
2021-04-08 12:02:17 +02:00
|
|
|
const b = new DataView(new ArrayBuffer(10));
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(b, (err, buf) => {
|
2017-09-06 08:10:34 -07:00
|
|
|
if (err) throw err;
|
2018-06-26 23:49:47 +02:00
|
|
|
console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
|
|
.toString('hex'));
|
2017-09-06 08:10:34 -07:00
|
|
|
});
|
|
|
|
|
2021-04-08 12:02:17 +02:00
|
|
|
const c = new ArrayBuffer(10);
|
2021-03-03 14:25:03 -08:00
|
|
|
randomFill(c, (err, buf) => {
|
2020-08-25 10:05:51 -07:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(Buffer.from(buf).toString('hex'));
|
|
|
|
});
|
2017-09-06 08:10:34 -07:00
|
|
|
```
|
|
|
|
|
2019-06-20 14:01:15 -06:00
|
|
|
This API uses libuv's threadpool, which can have surprising and
|
|
|
|
negative performance implications for some applications; see the
|
2017-08-23 14:59:06 -07:00
|
|
|
[`UV_THREADPOOL_SIZE`][] documentation for more information.
|
|
|
|
|
2018-02-05 21:55:16 -08:00
|
|
|
The asynchronous version of `crypto.randomFill()` is carried out in a single
|
|
|
|
threadpool request. To minimize threadpool task length variation, partition
|
|
|
|
large `randomFill` requests when doing so as part of fulfilling a client
|
|
|
|
request.
|
2017-11-22 10:03:17 -05:00
|
|
|
|
2024-11-23 18:10:44 +01:00
|
|
|
### `crypto.randomFillSync(buffer[, offset][, size])`
|
|
|
|
|
|
|
|
<!-- YAML
|
|
|
|
added:
|
|
|
|
- v7.10.0
|
|
|
|
- v6.13.0
|
|
|
|
changes:
|
|
|
|
- version: v9.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/15231
|
|
|
|
description: The `buffer` argument may be any `TypedArray` or `DataView`.
|
|
|
|
-->
|
|
|
|
|
|
|
|
* `buffer` {ArrayBuffer|Buffer|TypedArray|DataView} Must be supplied. The
|
|
|
|
size of the provided `buffer` must not be larger than `2**31 - 1`.
|
|
|
|
* `offset` {number} **Default:** `0`
|
|
|
|
* `size` {number} **Default:** `buffer.length - offset`. The `size` must
|
|
|
|
not be larger than `2**31 - 1`.
|
|
|
|
* Returns: {ArrayBuffer|Buffer|TypedArray|DataView} The object passed as
|
|
|
|
`buffer` argument.
|
|
|
|
|
|
|
|
Synchronous version of [`crypto.randomFill()`][].
|
|
|
|
|
|
|
|
```mjs
|
|
|
|
import { Buffer } from 'node:buffer';
|
|
|
|
const { randomFillSync } = await import('node:crypto');
|
|
|
|
|
|
|
|
const buf = Buffer.alloc(10);
|
|
|
|
console.log(randomFillSync(buf).toString('hex'));
|
|
|
|
|
|
|
|
randomFillSync(buf, 5);
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
|
|
|
|
// The above is equivalent to the following:
|
|
|
|
randomFillSync(buf, 5, 5);
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const { randomFillSync } = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
|
|
|
|
|
|
|
const buf = Buffer.alloc(10);
|
|
|
|
console.log(randomFillSync(buf).toString('hex'));
|
|
|
|
|
|
|
|
randomFillSync(buf, 5);
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
|
|
|
|
// The above is equivalent to the following:
|
|
|
|
randomFillSync(buf, 5, 5);
|
|
|
|
console.log(buf.toString('hex'));
|
|
|
|
```
|
|
|
|
|
|
|
|
Any `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as
|
|
|
|
`buffer`.
|
|
|
|
|
|
|
|
```mjs
|
|
|
|
import { Buffer } from 'node:buffer';
|
|
|
|
const { randomFillSync } = await import('node:crypto');
|
|
|
|
|
|
|
|
const a = new Uint32Array(10);
|
|
|
|
console.log(Buffer.from(randomFillSync(a).buffer,
|
|
|
|
a.byteOffset, a.byteLength).toString('hex'));
|
|
|
|
|
|
|
|
const b = new DataView(new ArrayBuffer(10));
|
|
|
|
console.log(Buffer.from(randomFillSync(b).buffer,
|
|
|
|
b.byteOffset, b.byteLength).toString('hex'));
|
|
|
|
|
|
|
|
const c = new ArrayBuffer(10);
|
|
|
|
console.log(Buffer.from(randomFillSync(c)).toString('hex'));
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const { randomFillSync } = require('node:crypto');
|
|
|
|
const { Buffer } = require('node:buffer');
|
|
|
|
|
|
|
|
const a = new Uint32Array(10);
|
|
|
|
console.log(Buffer.from(randomFillSync(a).buffer,
|
|
|
|
a.byteOffset, a.byteLength).toString('hex'));
|
|
|
|
|
|
|
|
const b = new DataView(new ArrayBuffer(10));
|
|
|
|
console.log(Buffer.from(randomFillSync(b).buffer,
|
|
|
|
b.byteOffset, b.byteLength).toString('hex'));
|
|
|
|
|
|
|
|
const c = new ArrayBuffer(10);
|
|
|
|
console.log(Buffer.from(randomFillSync(c)).toString('hex'));
|
|
|
|
```
|
|
|
|
|
2020-08-02 08:08:39 -04:00
|
|
|
### `crypto.randomInt([min, ]max[, callback])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-02 08:08:39 -04:00
|
|
|
<!-- YAML
|
2020-09-28 10:54:13 -07:00
|
|
|
added:
|
|
|
|
- v14.10.0
|
|
|
|
- v12.19.0
|
2022-01-24 19:39:16 +03:30
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2020-08-02 08:08:39 -04:00
|
|
|
-->
|
|
|
|
|
2021-02-15 13:21:50 -05:00
|
|
|
* `min` {integer} Start of random range (inclusive). **Default:** `0`.
|
2020-08-02 08:08:39 -04:00
|
|
|
* `max` {integer} End of random range (exclusive).
|
|
|
|
* `callback` {Function} `function(err, n) {}`.
|
|
|
|
|
|
|
|
Return a random integer `n` such that `min <= n < max`. This
|
|
|
|
implementation avoids [modulo bias][].
|
|
|
|
|
2020-09-04 11:45:16 +02:00
|
|
|
The range (`max - min`) must be less than 2<sup>48</sup>. `min` and `max` must
|
2020-09-04 11:19:06 +02:00
|
|
|
be [safe integers][].
|
2020-08-02 08:08:39 -04:00
|
|
|
|
|
|
|
If the `callback` function is not provided, the random integer is
|
|
|
|
generated synchronously.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
// Asynchronous
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
randomInt,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
randomInt(3, (err, n) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(`Random number chosen from (0, 1, 2): ${n}`);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2020-08-02 08:08:39 -04:00
|
|
|
// Asynchronous
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
randomInt,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
randomInt(3, (err, n) => {
|
2020-08-02 08:08:39 -04:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(`Random number chosen from (0, 1, 2): ${n}`);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
// Synchronous
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
randomInt,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const n = randomInt(3);
|
|
|
|
console.log(`Random number chosen from (0, 1, 2): ${n}`);
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2020-08-02 08:08:39 -04:00
|
|
|
// Synchronous
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
randomInt,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const n = randomInt(3);
|
2020-08-02 08:08:39 -04:00
|
|
|
console.log(`Random number chosen from (0, 1, 2): ${n}`);
|
|
|
|
```
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2020-08-02 08:08:39 -04:00
|
|
|
// With `min` argument
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
randomInt,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const n = randomInt(1, 7);
|
|
|
|
console.log(`The dice rolled: ${n}`);
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
// With `min` argument
|
|
|
|
const {
|
|
|
|
randomInt,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const n = randomInt(1, 7);
|
2020-08-02 08:08:39 -04:00
|
|
|
console.log(`The dice rolled: ${n}`);
|
|
|
|
```
|
|
|
|
|
2021-01-01 21:59:44 -08:00
|
|
|
### `crypto.randomUUID([options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-01 21:59:44 -08:00
|
|
|
<!-- YAML
|
2021-05-11, Version 14.17.0 'Fermium' (LTS)
Notable Changes:
Diagnostics channel (experimental module):
`diagnostics_channel` is a new experimental module that provides an API
to create named channels to report arbitrary message data for
diagnostics purposes.
The module was initially introduced in Node.js v15.1.0 and is
backported to v14.17.0 to enable testing it at a larger scale.
With `diagnostics_channel`, Node.js core and module authors can publish
contextual data about what they are doing at a given time. This could
be the hostname and query string of a mysql query, for example. Just
create a named channel with `dc.channel(name)` and call
`channel.publish(data)` to send the data to any listeners to that
channel.
```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');
MySQL.prototype.query = function query(queryString, values, callback) {
// Broadcast query information whenever a query is made
channel.publish({
query: queryString,
host: this.hostname,
});
this.doQuery(queryString, values, callback);
};
```
Channels are like one big global event emitter but are split into
separate objects to ensure they get the best performance. If nothing is
listening to the channel, the publishing overhead should be as close to
zero as possible. Consuming channel data is as easy as using
`channel.subscribe(listener)` to run a function whenever a message is
published to that channel.
```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');
channel.subscribe(({ query, host }) => {
console.log(`mysql query to ${host}: ${query}`);
});
```
The data captured can be used to provide context for what an app is
doing at a given time. This can be used for things like augmenting
tracing data, tracking network and filesystem activity, logging
queries, and many other things. It's also a very useful data source
for diagnostics tools to provide a clearer picture of exactly what the
application is doing at a given point in the data they are presenting.
Contributed by Stephen Belanger (https://github.com/nodejs/node/pull/34895).
UUID support in the crypto module:
The new `crypto.randomUUID()` method now allows to generate random
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) Version 4
UUID strings:
```js
const { randomUUID } = require('crypto');
console.log(randomUUID());
// 'aa7c91a1-f8fc-4339-b9db-f93fc7233429'
```
Contributed by James M Snell (https://github.com/nodejs/node/pull/36729).
Experimental support for `AbortController` and `AbortSignal`:
Node.js 14.17.0 adds experimental partial support for `AbortController`
and `AbortSignal`.
Both constructors can be enabled globally using the
`--experimental-abortcontroller` flag.
Additionally, several Node.js APIs have been updated to support
`AbortSignal` for cancellation.
It is not mandatory to use the built-in constructors with them. Any
spec-compliant third-party alternatives should be compatible.
`AbortSignal` support was added to the following methods:
* `child_process.exec`
* `child_process.execFile`
* `child_process.fork`
* `child_process.spawn`
* `dgram.createSocket`
* `events.on`
* `events.once`
* `fs.readFile`
* `fs.watch`
* `fs.writeFile`
* `http.request`
* `https.request`
* `http2Session.request`
* The promisified variants of `setImmediate` and `setTimeout`
Other notable changes:
* doc:
* revoke deprecation of legacy url, change status to legacy (James M Snell) (https://github.com/nodejs/node/pull/37784)
* add legacy status to stability index (James M Snell) (https://github.com/nodejs/node/pull/37784)
* upgrade stability status of report API (Gireesh Punathil) (https://github.com/nodejs/node/pull/35654)
* deps:
* V8: Backport various patches for Apple Silicon support (BoHong Li) (https://github.com/nodejs/node/pull/38051)
* update ICU to 68.1 (Michaël Zasso) (https://github.com/nodejs/node/pull/36187)
* upgrade to libuv 1.41.0 (Colin Ihrig) (https://github.com/nodejs/node/pull/37360)
* http:
* add http.ClientRequest.getRawHeaderNames() (simov) (https://github.com/nodejs/node/pull/37660)
* report request start and end with diagnostics\_channel (Stephen Belanger) (https://github.com/nodejs/node/pull/34895)
* util:
* add getSystemErrorMap() impl (eladkeyshawn) (https://github.com/nodejs/node/pull/38101)
PR-URL: https://github.com/nodejs/node/pull/38507
2021-05-02 23:12:18 -04:00
|
|
|
added:
|
|
|
|
- v15.6.0
|
|
|
|
- v14.17.0
|
2021-01-01 21:59:44 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `options` {Object}
|
|
|
|
* `disableEntropyCache` {boolean} By default, to improve performance,
|
2021-01-07 13:33:24 -08:00
|
|
|
Node.js generates and caches enough
|
2021-01-01 21:59:44 -08:00
|
|
|
random data to generate up to 128 random UUIDs. To generate a UUID
|
|
|
|
without using the cache, set `disableEntropyCache` to `true`.
|
2021-02-15 13:21:50 -05:00
|
|
|
**Default:** `false`.
|
2021-01-01 21:59:44 -08:00
|
|
|
* Returns: {string}
|
|
|
|
|
2021-08-06 02:00:58 +02:00
|
|
|
Generates a random [RFC 4122][] version 4 UUID. The UUID is generated using a
|
2021-04-04 14:06:01 +03:00
|
|
|
cryptographic pseudorandom number generator.
|
2021-01-01 21:59:44 -08:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.scrypt(password, salt, keylen[, options], callback)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-05-18 11:05:20 +02:00
|
|
|
<!-- YAML
|
2018-06-19 09:35:50 +02:00
|
|
|
added: v10.5.0
|
2018-06-25 17:40:59 +02:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The password and salt arguments can also be ArrayBuffer
|
|
|
|
instances.
|
2020-04-24 18:43:06 +02:00
|
|
|
- version:
|
|
|
|
- v12.8.0
|
|
|
|
- v10.17.0
|
2019-07-21 20:14:34 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/28799
|
|
|
|
description: The `maxmem` value can now be any safe integer.
|
2018-08-13 19:02:06 +10:00
|
|
|
- version: v10.9.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/21525
|
2018-06-25 17:40:59 +02:00
|
|
|
description: The `cost`, `blockSize` and `parallelization` option names
|
|
|
|
have been added.
|
2018-05-18 11:05:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `password` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `salt` {string|ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* `keylen` {number}
|
|
|
|
* `options` {Object}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `cost` {number} CPU/memory cost parameter. Must be a power of two greater
|
2018-06-24 09:30:52 +02:00
|
|
|
than one. **Default:** `16384`.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `blockSize` {number} Block size parameter. **Default:** `8`.
|
|
|
|
* `parallelization` {number} Parallelization parameter. **Default:** `1`.
|
|
|
|
* `N` {number} Alias for `cost`. Only one of both may be specified.
|
|
|
|
* `r` {number} Alias for `blockSize`. Only one of both may be specified.
|
|
|
|
* `p` {number} Alias for `parallelization`. Only one of both may be specified.
|
|
|
|
* `maxmem` {number} Memory upper bound. It is an error when (approximately)
|
2018-06-24 09:30:52 +02:00
|
|
|
`128 * N * r > maxmem`. **Default:** `32 * 1024 * 1024`.
|
2018-07-12 13:48:11 -04:00
|
|
|
* `callback` {Function}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `err` {Error}
|
|
|
|
* `derivedKey` {Buffer}
|
2018-05-18 11:05:20 +02:00
|
|
|
|
|
|
|
Provides an asynchronous [scrypt][] implementation. Scrypt is a password-based
|
|
|
|
key derivation function that is designed to be expensive computationally and
|
|
|
|
memory-wise in order to make brute-force attacks unrewarding.
|
|
|
|
|
|
|
|
The `salt` should be as unique as possible. It is recommended that a salt is
|
|
|
|
random and at least 16 bytes long. See [NIST SP 800-132][] for details.
|
|
|
|
|
2021-02-06 16:51:50 +01:00
|
|
|
When passing strings for `password` or `salt`, please consider
|
|
|
|
[caveats when using strings as inputs to cryptographic APIs][].
|
|
|
|
|
2018-05-18 11:05:20 +02:00
|
|
|
The `callback` function is called with two arguments: `err` and `derivedKey`.
|
|
|
|
`err` is an exception object when key derivation fails, otherwise `err` is
|
|
|
|
`null`. `derivedKey` is passed to the callback as a [`Buffer`][].
|
|
|
|
|
|
|
|
An exception is thrown when any of the input arguments specify invalid values
|
|
|
|
or types.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
scrypt,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
// Using the factory defaults.
|
|
|
|
scrypt('password', 'salt', 64, (err, derivedKey) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(derivedKey.toString('hex')); // '3745e48...08d59ae'
|
|
|
|
});
|
|
|
|
// Using a custom N parameter. Must be a power of two.
|
|
|
|
scrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => {
|
|
|
|
if (err) throw err;
|
|
|
|
console.log(derivedKey.toString('hex')); // '3745e48...aa39b34'
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
scrypt,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
2018-05-18 11:05:20 +02:00
|
|
|
// Using the factory defaults.
|
2021-03-03 14:25:03 -08:00
|
|
|
scrypt('password', 'salt', 64, (err, derivedKey) => {
|
2018-05-18 11:05:20 +02:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(derivedKey.toString('hex')); // '3745e48...08d59ae'
|
|
|
|
});
|
|
|
|
// Using a custom N parameter. Must be a power of two.
|
2021-03-03 14:25:03 -08:00
|
|
|
scrypt('password', 'salt', 64, { N: 1024 }, (err, derivedKey) => {
|
2018-05-18 11:05:20 +02:00
|
|
|
if (err) throw err;
|
|
|
|
console.log(derivedKey.toString('hex')); // '3745e48...aa39b34'
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.scryptSync(password, salt, keylen[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-05-18 11:05:20 +02:00
|
|
|
<!-- YAML
|
2018-06-19 09:35:50 +02:00
|
|
|
added: v10.5.0
|
2018-06-25 17:40:59 +02:00
|
|
|
changes:
|
2020-04-24 18:43:06 +02:00
|
|
|
- version:
|
|
|
|
- v12.8.0
|
|
|
|
- v10.17.0
|
2019-07-21 20:14:34 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/28799
|
|
|
|
description: The `maxmem` value can now be any safe integer.
|
2018-08-13 19:02:06 +10:00
|
|
|
- version: v10.9.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/21525
|
2018-06-25 17:40:59 +02:00
|
|
|
description: The `cost`, `blockSize` and `parallelization` option names
|
|
|
|
have been added.
|
2018-05-18 11:05:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `password` {string|Buffer|TypedArray|DataView}
|
|
|
|
* `salt` {string|Buffer|TypedArray|DataView}
|
|
|
|
* `keylen` {number}
|
|
|
|
* `options` {Object}
|
2019-09-13 00:22:29 -04:00
|
|
|
* `cost` {number} CPU/memory cost parameter. Must be a power of two greater
|
2018-06-24 09:30:52 +02:00
|
|
|
than one. **Default:** `16384`.
|
2019-09-13 00:22:29 -04:00
|
|
|
* `blockSize` {number} Block size parameter. **Default:** `8`.
|
|
|
|
* `parallelization` {number} Parallelization parameter. **Default:** `1`.
|
|
|
|
* `N` {number} Alias for `cost`. Only one of both may be specified.
|
|
|
|
* `r` {number} Alias for `blockSize`. Only one of both may be specified.
|
|
|
|
* `p` {number} Alias for `parallelization`. Only one of both may be specified.
|
|
|
|
* `maxmem` {number} Memory upper bound. It is an error when (approximately)
|
2018-06-24 09:30:52 +02:00
|
|
|
`128 * N * r > maxmem`. **Default:** `32 * 1024 * 1024`.
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {Buffer}
|
2018-05-18 11:05:20 +02:00
|
|
|
|
|
|
|
Provides a synchronous [scrypt][] implementation. Scrypt is a password-based
|
|
|
|
key derivation function that is designed to be expensive computationally and
|
|
|
|
memory-wise in order to make brute-force attacks unrewarding.
|
|
|
|
|
|
|
|
The `salt` should be as unique as possible. It is recommended that a salt is
|
|
|
|
random and at least 16 bytes long. See [NIST SP 800-132][] for details.
|
|
|
|
|
2021-02-06 16:51:50 +01:00
|
|
|
When passing strings for `password` or `salt`, please consider
|
|
|
|
[caveats when using strings as inputs to cryptographic APIs][].
|
|
|
|
|
2018-05-18 11:05:20 +02:00
|
|
|
An exception is thrown when key derivation fails, otherwise the derived key is
|
|
|
|
returned as a [`Buffer`][].
|
|
|
|
|
|
|
|
An exception is thrown when any of the input arguments specify invalid values
|
|
|
|
or types.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
|
|
|
const {
|
2022-11-17 08:19:12 -05:00
|
|
|
scryptSync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
// Using the factory defaults.
|
|
|
|
|
|
|
|
const key1 = scryptSync('password', 'salt', 64);
|
|
|
|
console.log(key1.toString('hex')); // '3745e48...08d59ae'
|
|
|
|
// Using a custom N parameter. Must be a power of two.
|
|
|
|
const key2 = scryptSync('password', 'salt', 64, { N: 1024 });
|
|
|
|
console.log(key2.toString('hex')); // '3745e48...aa39b34'
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const {
|
|
|
|
scryptSync,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2018-05-18 11:05:20 +02:00
|
|
|
// Using the factory defaults.
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const key1 = scryptSync('password', 'salt', 64);
|
2018-05-18 11:05:20 +02:00
|
|
|
console.log(key1.toString('hex')); // '3745e48...08d59ae'
|
|
|
|
// Using a custom N parameter. Must be a power of two.
|
2021-03-03 14:25:03 -08:00
|
|
|
const key2 = scryptSync('password', 'salt', 64, { N: 1024 });
|
2018-05-18 11:05:20 +02:00
|
|
|
console.log(key2.toString('hex')); // '3745e48...aa39b34'
|
|
|
|
```
|
|
|
|
|
2021-01-04 09:06:26 -08:00
|
|
|
### `crypto.secureHeapUsed()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-01-04 09:06:26 -08:00
|
|
|
<!-- YAML
|
2021-01-12 08:54:01 -05:00
|
|
|
added: v15.6.0
|
2021-01-04 09:06:26 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Returns: {Object}
|
|
|
|
* `total` {number} The total allocated secure heap size as specified
|
|
|
|
using the `--secure-heap=n` command-line flag.
|
|
|
|
* `min` {number} The minimum allocation from the secure heap as
|
|
|
|
specified using the `--secure-heap-min` command-line flag.
|
|
|
|
* `used` {number} The total number of bytes currently allocated from
|
|
|
|
the secure heap.
|
|
|
|
* `utilization` {number} The calculated ratio of `used` to `total`
|
|
|
|
allocated bytes.
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.setEngine(engine[, flags])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-08-26 17:07:20 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.11.11
|
2024-06-07 17:10:47 +01:00
|
|
|
changes:
|
2024-07-19 15:32:30 +02:00
|
|
|
- version:
|
|
|
|
- v22.4.0
|
|
|
|
- v20.16.0
|
2024-06-07 17:10:47 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/53329
|
|
|
|
description: Custom engine support in OpenSSL 3 is deprecated.
|
2016-08-26 17:07:20 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-07-12 13:48:11 -04:00
|
|
|
* `engine` {string}
|
|
|
|
* `flags` {crypto.constants} **Default:** `crypto.constants.ENGINE_METHOD_ALL`
|
2015-01-27 22:58:14 +03:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Load and set the `engine` for some or all OpenSSL functions (selected by flags).
|
2024-06-07 17:10:47 +01:00
|
|
|
Support for custom engines in OpenSSL is deprecated from OpenSSL 3.
|
2015-01-27 22:58:14 +03:00
|
|
|
|
2015-11-04 11:23:03 -05:00
|
|
|
`engine` could be either an id or a path to the engine's shared library.
|
2012-10-22 10:37:20 -07:00
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
The optional `flags` argument uses `ENGINE_METHOD_ALL` by default. The `flags`
|
2016-05-02 10:27:12 -07:00
|
|
|
is a bit field taking one of or a mix of the following flags (defined in
|
|
|
|
`crypto.constants`):
|
|
|
|
|
|
|
|
* `crypto.constants.ENGINE_METHOD_RSA`
|
|
|
|
* `crypto.constants.ENGINE_METHOD_DSA`
|
|
|
|
* `crypto.constants.ENGINE_METHOD_DH`
|
|
|
|
* `crypto.constants.ENGINE_METHOD_RAND`
|
2018-03-14 19:27:57 +09:00
|
|
|
* `crypto.constants.ENGINE_METHOD_EC`
|
2016-05-02 10:27:12 -07:00
|
|
|
* `crypto.constants.ENGINE_METHOD_CIPHERS`
|
|
|
|
* `crypto.constants.ENGINE_METHOD_DIGESTS`
|
|
|
|
* `crypto.constants.ENGINE_METHOD_PKEY_METHS`
|
|
|
|
* `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS`
|
|
|
|
* `crypto.constants.ENGINE_METHOD_ALL`
|
|
|
|
* `crypto.constants.ENGINE_METHOD_NONE`
|
2012-10-22 10:37:20 -07:00
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.setFips(bool)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-01-23 16:32:19 -08:00
|
|
|
<!-- YAML
|
2018-03-02 09:53:46 -08:00
|
|
|
added: v10.0.0
|
2018-01-23 16:32:19 -08:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2018-01-23 16:32:19 -08:00
|
|
|
* `bool` {boolean} `true` to enable FIPS mode.
|
|
|
|
|
|
|
|
Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build.
|
|
|
|
Throws an error if FIPS mode is not available.
|
|
|
|
|
2021-02-24 13:13:42 +01:00
|
|
|
### `crypto.sign(algorithm, data, key[, callback])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-03-12 09:17:10 -04:00
|
|
|
<!-- YAML
|
2019-03-22 13:19:46 +00:00
|
|
|
added: v12.0.0
|
2020-10-12 12:38:29 +02:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2021-03-16 10:46:04 -04:00
|
|
|
- version: v15.12.0
|
2021-02-24 13:13:42 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/37500
|
|
|
|
description: Optional callback argument added.
|
2020-10-12 12:38:29 +02:00
|
|
|
- version:
|
|
|
|
- v13.2.0
|
2020-11-08 13:35:46 +01:00
|
|
|
- v12.16.0
|
2020-10-12 12:38:29 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/29292
|
|
|
|
description: This function now supports IEEE-P1363 DSA and ECDSA signatures.
|
2019-03-12 09:17:10 -04:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-03-12 09:17:10 -04:00
|
|
|
* `algorithm` {string | null | undefined}
|
2020-08-25 10:05:51 -07:00
|
|
|
* `data` {ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `key` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
2021-02-24 13:13:42 +01:00
|
|
|
* `callback` {Function}
|
|
|
|
* `err` {Error}
|
|
|
|
* `signature` {Buffer}
|
|
|
|
* Returns: {Buffer} if the `callback` function is not provided.
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2019-03-12 09:17:10 -04:00
|
|
|
|
|
|
|
Calculates and returns the signature for `data` using the given private key and
|
|
|
|
algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
|
|
|
|
dependent upon the key type (especially Ed25519 and Ed448).
|
|
|
|
|
|
|
|
If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
|
|
|
|
passed to [`crypto.createPrivateKey()`][]. If it is an object, the following
|
|
|
|
additional properties can be passed:
|
|
|
|
|
2019-08-21 00:05:55 +02:00
|
|
|
* `dsaEncoding` {string} For DSA and ECDSA, this option specifies the
|
|
|
|
format of the generated signature. It can be one of the following:
|
|
|
|
* `'der'` (default): DER-encoded ASN.1 signature structure encoding `(r, s)`.
|
|
|
|
* `'ieee-p1363'`: Signature format `r || s` as proposed in IEEE-P1363.
|
2019-10-23 21:28:42 -07:00
|
|
|
* `padding` {integer} Optional padding value for RSA, one of the following:
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-03-12 09:17:10 -04:00
|
|
|
* `crypto.constants.RSA_PKCS1_PADDING` (default)
|
|
|
|
* `crypto.constants.RSA_PKCS1_PSS_PADDING`
|
|
|
|
|
2019-06-20 14:01:15 -06:00
|
|
|
`RSA_PKCS1_PSS_PADDING` will use MGF1 with the same hash function
|
2019-03-12 09:17:10 -04:00
|
|
|
used to sign the message as specified in section 3.1 of [RFC 4055][].
|
2019-10-23 21:28:42 -07:00
|
|
|
* `saltLength` {integer} Salt length for when padding is
|
2019-03-12 09:17:10 -04:00
|
|
|
`RSA_PKCS1_PSS_PADDING`. The special value
|
|
|
|
`crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest
|
|
|
|
size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the
|
|
|
|
maximum permissible value.
|
|
|
|
|
2021-02-24 13:13:42 +01:00
|
|
|
If the `callback` function is provided this function uses libuv's threadpool.
|
|
|
|
|
2021-12-27 06:48:59 -08:00
|
|
|
### `crypto.subtle`
|
|
|
|
|
|
|
|
<!-- YAML
|
2022-01-16 15:09:58 +01:00
|
|
|
added: v17.4.0
|
2021-12-27 06:48:59 -08:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Type: {SubtleCrypto}
|
|
|
|
|
|
|
|
A convenient alias for [`crypto.webcrypto.subtle`][].
|
|
|
|
|
2019-12-23 16:58:10 -08:00
|
|
|
### `crypto.timingSafeEqual(a, b)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2017-02-13 04:49:35 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v6.6.0
|
2020-08-25 10:05:51 -07:00
|
|
|
changes:
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The a and b arguments can also be ArrayBuffer.
|
2017-02-13 04:49:35 +02:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `a` {ArrayBuffer|Buffer|TypedArray|DataView}
|
|
|
|
* `b` {ArrayBuffer|Buffer|TypedArray|DataView}
|
2018-07-12 13:48:11 -04:00
|
|
|
* Returns: {boolean}
|
2017-02-13 04:49:35 +02:00
|
|
|
|
2022-06-21 13:43:09 +02:00
|
|
|
This function compares the underlying bytes that represent the given
|
|
|
|
`ArrayBuffer`, `TypedArray`, or `DataView` instances using a constant-time
|
|
|
|
algorithm.
|
|
|
|
|
|
|
|
This function does not leak timing information that
|
2017-02-13 04:49:35 +02:00
|
|
|
would allow an attacker to guess one of the values. This is suitable for
|
|
|
|
comparing HMAC digests or secret values like authentication cookies or
|
|
|
|
[capability urls](https://www.w3.org/TR/capability-urls/).
|
|
|
|
|
2017-04-04 15:59:30 -07:00
|
|
|
`a` and `b` must both be `Buffer`s, `TypedArray`s, or `DataView`s, and they
|
2022-01-13 16:49:37 -07:00
|
|
|
must have the same byte length. An error is thrown if `a` and `b` have
|
|
|
|
different byte lengths.
|
2020-11-30 12:55:07 +01:00
|
|
|
|
|
|
|
If at least one of `a` and `b` is a `TypedArray` with more than one byte per
|
|
|
|
entry, such as `Uint16Array`, the result will be computed using the platform
|
|
|
|
byte order.
|
2017-02-13 04:49:35 +02:00
|
|
|
|
2022-06-21 13:43:09 +02:00
|
|
|
<strong class="critical">When both of the inputs are `Float32Array`s or
|
|
|
|
`Float64Array`s, this function might return unexpected results due to IEEE 754
|
|
|
|
encoding of floating-point numbers. In particular, neither `x === y` nor
|
|
|
|
`Object.is(x, y)` implies that the byte representations of two floating-point
|
|
|
|
numbers `x` and `y` are equal.</strong>
|
|
|
|
|
2021-10-10 21:55:04 -07:00
|
|
|
Use of `crypto.timingSafeEqual` does not guarantee that the _surrounding_ code
|
2018-02-05 21:55:16 -08:00
|
|
|
is timing-safe. Care should be taken to ensure that the surrounding code does
|
|
|
|
not introduce timing vulnerabilities.
|
2017-02-13 04:49:35 +02:00
|
|
|
|
2021-02-24 13:13:42 +01:00
|
|
|
### `crypto.verify(algorithm, data, key, signature[, callback])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-03-12 09:17:10 -04:00
|
|
|
<!-- YAML
|
2019-03-22 13:19:46 +00:00
|
|
|
added: v12.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2021-03-16 10:46:04 -04:00
|
|
|
- version: v15.12.0
|
2021-02-24 13:13:42 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/37500
|
|
|
|
description: Optional callback argument added.
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
- version: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/35093
|
|
|
|
description: The data, key, and signature arguments can also be ArrayBuffer.
|
2020-10-12 12:38:29 +02:00
|
|
|
- version:
|
|
|
|
- v13.2.0
|
2020-11-08 13:35:46 +01:00
|
|
|
- v12.16.0
|
2020-10-12 12:38:29 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/29292
|
|
|
|
description: This function now supports IEEE-P1363 DSA and ECDSA signatures.
|
2019-03-12 09:17:10 -04:00
|
|
|
-->
|
2019-09-06 01:42:22 -04:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint disable maximum-line-length remark-lint-->
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
* `algorithm` {string|null|undefined}
|
|
|
|
* `data` {ArrayBuffer| Buffer|TypedArray|DataView}
|
|
|
|
* `key` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
|
|
|
|
* `signature` {ArrayBuffer|Buffer|TypedArray|DataView}
|
2021-02-24 13:13:42 +01:00
|
|
|
* `callback` {Function}
|
|
|
|
* `err` {Error}
|
|
|
|
* `result` {boolean}
|
|
|
|
* Returns: {boolean} `true` or `false` depending on the validity of the
|
|
|
|
signature for the data and public key if the `callback` function is not
|
|
|
|
provided.
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!--lint enable maximum-line-length remark-lint-->
|
2019-03-12 09:17:10 -04:00
|
|
|
|
|
|
|
Verifies the given signature for `data` using the given key and algorithm. If
|
|
|
|
`algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
|
|
|
|
key type (especially Ed25519 and Ed448).
|
|
|
|
|
|
|
|
If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
|
|
|
|
passed to [`crypto.createPublicKey()`][]. If it is an object, the following
|
|
|
|
additional properties can be passed:
|
|
|
|
|
2019-08-21 00:05:55 +02:00
|
|
|
* `dsaEncoding` {string} For DSA and ECDSA, this option specifies the
|
2021-02-20 21:02:31 +01:00
|
|
|
format of the signature. It can be one of the following:
|
2019-08-21 00:05:55 +02:00
|
|
|
* `'der'` (default): DER-encoded ASN.1 signature structure encoding `(r, s)`.
|
|
|
|
* `'ieee-p1363'`: Signature format `r || s` as proposed in IEEE-P1363.
|
2019-10-23 21:28:42 -07:00
|
|
|
* `padding` {integer} Optional padding value for RSA, one of the following:
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-03-12 09:17:10 -04:00
|
|
|
* `crypto.constants.RSA_PKCS1_PADDING` (default)
|
|
|
|
* `crypto.constants.RSA_PKCS1_PSS_PADDING`
|
|
|
|
|
2019-06-20 14:01:15 -06:00
|
|
|
`RSA_PKCS1_PSS_PADDING` will use MGF1 with the same hash function
|
2019-03-12 09:17:10 -04:00
|
|
|
used to sign the message as specified in section 3.1 of [RFC 4055][].
|
2019-10-23 21:28:42 -07:00
|
|
|
* `saltLength` {integer} Salt length for when padding is
|
2019-03-12 09:17:10 -04:00
|
|
|
`RSA_PKCS1_PSS_PADDING`. The special value
|
|
|
|
`crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest
|
|
|
|
size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the
|
|
|
|
maximum permissible value.
|
|
|
|
|
|
|
|
The `signature` argument is the previously calculated signature for the `data`.
|
|
|
|
|
|
|
|
Because public keys can be derived from private keys, a private key or a public
|
|
|
|
key may be passed for `key`.
|
|
|
|
|
2021-02-24 13:13:42 +01:00
|
|
|
If the `callback` function is provided this function uses libuv's threadpool.
|
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
### `crypto.webcrypto`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-08-25 10:05:51 -07:00
|
|
|
<!-- YAML
|
2020-10-20, Version 15.0.0 (Current)
Notable changes:
Deprecations and Removals:
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
npm 7 (https://github.com/nodejs/node/pull/35631):
Node.js 15 comes with a new major release of npm, npm 7. npm 7 comes
with many new features - including npm workspaces and a new
package-lock.json format. npm 7 also includes yarn.lock file support.
One of the big changes in npm 7 is that peer dependencies are now
installed by default.
Throw On Unhandled Rejections
(https://github.com/nodejs/node/pull/33021):
As of Node.js 15, the default mode for `unhandledRejection` is changed
to `throw` (from `warn`). In `throw` mode, if an `unhandledRejection`
hook is not set, the `unhandledRejection` is raised as an uncaught
exception. Users that have an `unhandledRejection` hook should see no
change in behavior, and it’s still possible to switch modes using the
`--unhandled-rejections=mode` process flag.
QUIC (https://github.com/nodejs/node/pull/32379):
Node.js 15 comes with experimental support QUIC, which can be enabled
by compiling Node.js with the `--experimental-quic` configuration flag.
The Node.js QUIC implementation is exposed by the core `net` module.
V8 8.6 (https://github.com/nodejs/node/pull/35415):
The V8 JavaScript engine has been updated to V8 8.6 (V8 8.4 is the
latest available in Node.js 14). Along with performance tweaks and
improvements the V8 update also brings the following language features:
* `Promise.any()` (from V8 8.5)
* `AggregateError` (from V8 8.5)
* `String.prototype.replaceAll()` (from V8 8.5)
* Logical assignment operators `&&=`, `||=`, and `??=` (from V8 8.5)
Other Notable Changes:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
Semver-Major Commits:
- **assert**: add `assert/strict` alias module (ExE Boss)
(https://github.com/nodejs/node/pull/34001)
- **build**: reset embedder string to "-node.0" (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **build**: remove --build-v8-with-gn configure option (Yang Guo)
(https://github.com/nodejs/node/pull/27576)
- **build**: drop support for VS2017 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33694)
- **crypto**: refactoring internals, add WebCrypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **crypto**: move node\_crypto files to src/crypto (James M Snell)
(https://github.com/nodejs/node/pull/35093)
- **deps**: V8: cherry-pick d76abfed3512 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 717543bbf0ef (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: V8: cherry-pick 6be2f6e26e8d (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix V8 build issue with inline methods (Jiawen Geng)
(https://github.com/nodejs/node/pull/35415)
- **deps**: fix platform-embedded-file-writer-win for ARM64 (Michaël
Zasso) (https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 postmortem metadata script (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **deps**: update V8 to 8.6.395 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **deps**: upgrade npm to 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **deps**: update npm to 7.0.0-rc.3 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **deps**: V8: cherry-pick 0d6debcc5f08 (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **dns**: add dns/promises alias (shisama)
(https://github.com/nodejs/node/pull/32953)
- **doc**: move DEP0018 to End-of-Life (Rich Trott)
(https://github.com/nodejs/node/pull/35316)
- **doc**: update support macos version for 15.x (Ash Cripps)
(https://github.com/nodejs/node/pull/35022)
- **fs**: deprecation warning on recursive rmdir (Ian Sutherland)
(https://github.com/nodejs/node/pull/35562)
- **fs**: reimplement read and write streams using stream.construct
(Robert Nagy) (https://github.com/nodejs/node/pull/29656)
- **http**: fixed socket.setEncoding fatal error (iskore)
(https://github.com/nodejs/node/pull/33405)
- **http**: emit 'error' on aborted server request (Robert Nagy)
(https://github.com/nodejs/node/pull/33172)
- **http**: cleanup end argument handling (Robert Nagy)
(https://github.com/nodejs/node/pull/31818)
- **http2**: allow Host in HTTP/2 requests (Alba Mendez)
(https://github.com/nodejs/node/pull/34664)
- **http2**: add `invalidheaders` test (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33161)
- **http2**: refactor state code validation for the http2Stream class
(rickyes) (https://github.com/nodejs/node/pull/33535)
- **http2**: header field valid checks (Pranshu Srivastava)
(https://github.com/nodejs/node/pull/33193)
- **lib**: add EventTarget-related browser globals (Anna Henningsen)
(https://github.com/nodejs/node/pull/35496)
- **lib**: remove ERR\_INVALID\_OPT\_VALUE and
ERR\_INVALID\_OPT\_VALUE\_ENCODING (Denys Otrishko)
(https://github.com/nodejs/node/pull/34682)
- **lib**: handle one of args case in ERR\_MISSING\_ARGS (Denys
Otrishko) (https://github.com/nodejs/node/pull/34022)
- **lib**: remove NodeError from the prototype of errors with code
(Michaël Zasso) (https://github.com/nodejs/node/pull/33857)
- **lib**: unflag AbortController (James M Snell)
(https://github.com/nodejs/node/pull/33527)
- **lib**: initial experimental AbortController implementation (James M
Snell) (https://github.com/nodejs/node/pull/33527)
- **net**: check args in net.connect() and socket.connect() calls
(Denys Otrishko) (https://github.com/nodejs/node/pull/34022)
- **net**: remove long deprecated server.connections property (James M
Snell) (https://github.com/nodejs/node/pull/33647)
- **net**: autoDestroy Socket (Robert Nagy)
(https://github.com/nodejs/node/pull/31806)
- **process**: update v8 fast api calls usage (Maya Lekova)
(https://github.com/nodejs/node/pull/35415)
- **process**: change default --unhandled-rejections=throw (Dan
Fabulich) (https://github.com/nodejs/node/pull/33021)
- **process**: use v8 fast api calls for hrtime (Gus Caplan)
(https://github.com/nodejs/node/pull/33600)
- **process**: delay throwing an error using `throwDeprecation` (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/32312)
- **repl**: remove deprecated repl.memory function (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.turnOffEditorMode() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated repl.parseREPLKeyword() function (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated bufferedCommand property (Ruben
Bridgewater) (https://github.com/nodejs/node/pull/33286)
- **repl**: remove deprecated .rli (Ruben Bridgewater)
(https://github.com/nodejs/node/pull/33286)
- **src**: implement NodePlatform::PostJob (Clemens Backes)
(https://github.com/nodejs/node/pull/35415)
- **src**: update NODE\_MODULE\_VERSION to 88 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **src**: error reporting on CPUUsage (Yash Ladha)
(https://github.com/nodejs/node/pull/34762)
- **src**: use node:moduleName as builtin module filename (Michaël
Zasso) (https://github.com/nodejs/node/pull/35498)
- **src**: enable wasm trap handler on windows (Gus Caplan)
(https://github.com/nodejs/node/pull/35033)
- **src**: update NODE\_MODULE\_VERSION to 86 (Michaël Zasso)
(https://github.com/nodejs/node/pull/33579)
- **src**: disallow JS execution inside FreeEnvironment (Anna
Henningsen) (https://github.com/nodejs/node/pull/33874)
- **src**: remove \_third\_party\_main support (Anna Henningsen)
(https://github.com/nodejs/node/pull/33971)
- **src**: remove deprecated node debug command (James M Snell)
(https://github.com/nodejs/node/pull/33648)
- **src**: remove unused CancelPendingDelayedTasks (Anna Henningsen)
(https://github.com/nodejs/node/pull/32859)
- **stream**: try to wait for flush to complete before 'finish' (Robert
Nagy) (https://github.com/nodejs/node/pull/34314)
- **stream**: cleanup and fix Readable.wrap (Robert Nagy)
(https://github.com/nodejs/node/pull/34204)
- **stream**: add promises version to utility functions (rickyes)
(https://github.com/nodejs/node/pull/33991)
- **stream**: fix writable.end callback behavior (Robert Nagy)
(https://github.com/nodejs/node/pull/34101)
- **stream**: construct (Robert Nagy)
(https://github.com/nodejs/node/pull/29656)
- **stream**: write should throw on unknown encoding (Robert Nagy)
(https://github.com/nodejs/node/pull/33075)
- **stream**: fix \_final and 'prefinish' timing (Robert Nagy)
(https://github.com/nodejs/node/pull/32780)
- **stream**: simplify Transform stream implementation (Robert Nagy)
(https://github.com/nodejs/node/pull/32763)
- **stream**: use callback to properly propagate error (Robert Nagy)
(https://github.com/nodejs/node/pull/29179)
- **test**: update tests after increasing typed array size to 4GB
(Kim-Anh Tran) (https://github.com/nodejs/node/pull/35415)
- **test**: fix tests for npm 7.0.0 (Myles Borins)
(https://github.com/nodejs/node/pull/35631)
- **test**: fix test suite to work with npm 7 (Myles Borins)
(https://github.com/nodejs/node/pull/35474)
- **test**: update WPT harness and tests (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **timers**: introduce timers/promises (James M Snell)
(https://github.com/nodejs/node/pull/33950)
- **tools**: disable x86 safe exception handlers in V8 (Michaël Zasso)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.6 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **tools**: update V8 gypfiles for 8.5 (Ujjwal Sharma)
(https://github.com/nodejs/node/pull/35415)
- **url**: file URL path normalization (Daijiro Wachi)
(https://github.com/nodejs/node/pull/35477)
- **url**: verify domain is not empty after "ToASCII" (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove U+0000 case in the fragment state (Michaël Zasso)
(https://github.com/nodejs/node/pull/33770)
- **url**: remove gopher from special schemes (Michaël Zasso)
(https://github.com/nodejs/node/pull/33325)
- **url**: forbid lt and gt in url host code point (Yash Ladha)
(https://github.com/nodejs/node/pull/33328)
- **util**: change default value of `maxStringLength` to 10000
(unknown) (https://github.com/nodejs/node/pull/32744)
- **wasi**: drop --experimental-wasm-bigint requirement (Colin Ihrig)
(https://github.com/nodejs/node/pull/35415)
- **win, child_process**: sanitize env variables (Bartosz Sosnowski)
(https://github.com/nodejs/node/pull/35210)
- **worker**: make MessageEvent class more Web-compatible (Anna
Henningsen) (https://github.com/nodejs/node/pull/35496)
- **worker**: set trackUnmanagedFds to true by default (Anna
Henningsen) (https://github.com/nodejs/node/pull/34394)
- **worker**: rename error code to be more accurate (Anna Henningsen)
(https://github.com/nodejs/node/pull/33872)
PR-URL: https://github.com/nodejs/node/pull/35014
2020-09-01 21:16:46 +01:00
|
|
|
added: v15.0.0
|
2020-08-25 10:05:51 -07:00
|
|
|
-->
|
|
|
|
|
|
|
|
Type: {Crypto} An implementation of the Web Crypto API standard.
|
|
|
|
|
|
|
|
See the [Web Crypto API documentation][] for details.
|
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
## Notes
|
|
|
|
|
2021-02-06 16:51:50 +01:00
|
|
|
### Using strings as inputs to cryptographic APIs
|
|
|
|
|
|
|
|
For historical reasons, many cryptographic APIs provided by Node.js accept
|
|
|
|
strings as inputs where the underlying cryptographic algorithm works on byte
|
|
|
|
sequences. These instances include plaintexts, ciphertexts, symmetric keys,
|
|
|
|
initialization vectors, passphrases, salts, authentication tags,
|
|
|
|
and additional authenticated data.
|
|
|
|
|
|
|
|
When passing strings to cryptographic APIs, consider the following factors.
|
|
|
|
|
|
|
|
* Not all byte sequences are valid UTF-8 strings. Therefore, when a byte
|
|
|
|
sequence of length `n` is derived from a string, its entropy is generally
|
2021-04-10 22:23:34 -07:00
|
|
|
lower than the entropy of a random or pseudorandom `n` byte sequence.
|
2021-02-06 16:51:50 +01:00
|
|
|
For example, no UTF-8 string will result in the byte sequence `c0 af`. Secret
|
2021-04-10 22:23:34 -07:00
|
|
|
keys should almost exclusively be random or pseudorandom byte sequences.
|
|
|
|
* Similarly, when converting random or pseudorandom byte sequences to UTF-8
|
2021-02-06 16:51:50 +01:00
|
|
|
strings, subsequences that do not represent valid code points may be replaced
|
|
|
|
by the Unicode replacement character (`U+FFFD`). The byte representation of
|
|
|
|
the resulting Unicode string may, therefore, not be equal to the byte sequence
|
|
|
|
that the string was created from.
|
|
|
|
|
|
|
|
```js
|
|
|
|
const original = [0xc0, 0xaf];
|
|
|
|
const bytesAsString = Buffer.from(original).toString('utf8');
|
|
|
|
const stringAsBytes = Buffer.from(bytesAsString, 'utf8');
|
|
|
|
console.log(stringAsBytes);
|
|
|
|
// Prints '<Buffer ef bf bd ef bf bd>'.
|
|
|
|
```
|
|
|
|
|
|
|
|
The outputs of ciphers, hash functions, signature algorithms, and key
|
2021-04-10 22:23:34 -07:00
|
|
|
derivation functions are pseudorandom byte sequences and should not be
|
2021-02-06 16:51:50 +01:00
|
|
|
used as Unicode strings.
|
|
|
|
* When strings are obtained from user input, some Unicode characters can be
|
|
|
|
represented in multiple equivalent ways that result in different byte
|
|
|
|
sequences. For example, when passing a user passphrase to a key derivation
|
|
|
|
function, such as PBKDF2 or scrypt, the result of the key derivation function
|
|
|
|
depends on whether the string uses composed or decomposed characters. Node.js
|
|
|
|
does not normalize character representations. Developers should consider using
|
|
|
|
[`String.prototype.normalize()`][] on user inputs before passing them to
|
|
|
|
cryptographic APIs.
|
|
|
|
|
2020-06-14 14:49:34 -07:00
|
|
|
### Legacy streams API (prior to Node.js 0.10)
|
2012-10-11 08:32:36 -07:00
|
|
|
|
2015-02-07 11:25:13 +01:00
|
|
|
The Crypto module was added to Node.js before there was the concept of a
|
2015-12-26 20:54:01 -08:00
|
|
|
unified Stream API, and before there were [`Buffer`][] objects for handling
|
2023-05-23 01:34:18 +02:00
|
|
|
binary data. As such, many `crypto` classes have methods not
|
2016-02-15 03:40:53 +03:00
|
|
|
typically found on other Node.js classes that implement the [streams][stream]
|
|
|
|
API (e.g. `update()`, `final()`, or `digest()`). Also, many methods accepted
|
2018-04-29 20:46:41 +03:00
|
|
|
and returned `'latin1'` encoded strings by default rather than `Buffer`s. This
|
2015-12-26 20:54:01 -08:00
|
|
|
default was changed after Node.js v0.8 to use [`Buffer`][] objects by default
|
|
|
|
instead.
|
|
|
|
|
|
|
|
### Support for weak or compromised algorithms
|
2015-07-27 16:10:57 +09:00
|
|
|
|
2022-04-20 10:23:41 +02:00
|
|
|
The `node:crypto` module still supports some algorithms which are already
|
2023-08-25 22:08:17 +02:00
|
|
|
compromised and are not recommended for use. The API also allows
|
2019-06-05 22:33:29 -07:00
|
|
|
the use of ciphers and hashes with a small key size that are too weak for safe
|
|
|
|
use.
|
2015-07-27 16:10:57 +09:00
|
|
|
|
|
|
|
Users should take full responsibility for selecting the crypto
|
|
|
|
algorithm and key size according to their security requirements.
|
|
|
|
|
2015-12-26 20:54:01 -08:00
|
|
|
Based on the recommendations of [NIST SP 800-131A][]:
|
2015-07-27 16:10:57 +09:00
|
|
|
|
2019-09-13 00:22:29 -04:00
|
|
|
* MD5 and SHA-1 are no longer acceptable where collision resistance is
|
2015-07-27 16:10:57 +09:00
|
|
|
required such as digital signatures.
|
2019-09-13 00:22:29 -04:00
|
|
|
* The key used with RSA, DSA, and DH algorithms is recommended to have
|
2015-07-27 16:10:57 +09:00
|
|
|
at least 2048 bits and that of the curve of ECDSA and ECDH at least
|
|
|
|
224 bits, to be safe to use for several years.
|
2019-09-13 00:22:29 -04:00
|
|
|
* The DH groups of `modp1`, `modp2` and `modp5` have a key size
|
2015-07-27 16:10:57 +09:00
|
|
|
smaller than 2048 bits and are not recommended.
|
|
|
|
|
|
|
|
See the reference for other recommendations and details.
|
2012-10-11 08:32:36 -07:00
|
|
|
|
2021-10-25 01:05:33 +02:00
|
|
|
Some algorithms that have known weaknesses and are of little relevance in
|
|
|
|
practice are only available through the [legacy provider][], which is not
|
|
|
|
enabled by default.
|
|
|
|
|
2017-12-18 13:22:08 +01:00
|
|
|
### CCM mode
|
|
|
|
|
2018-06-14 15:18:14 +02:00
|
|
|
CCM is one of the supported [AEAD algorithms][]. Applications which use this
|
2017-12-18 13:22:08 +01:00
|
|
|
mode must adhere to certain restrictions when using the cipher API:
|
|
|
|
|
2019-09-13 00:22:29 -04:00
|
|
|
* The authentication tag length must be specified during cipher creation by
|
2017-12-18 13:22:08 +01:00
|
|
|
setting the `authTagLength` option and must be one of 4, 6, 8, 10, 12, 14 or
|
|
|
|
16 bytes.
|
2019-09-13 00:22:29 -04:00
|
|
|
* The length of the initialization vector (nonce) `N` must be between 7 and 13
|
2017-12-18 13:22:08 +01:00
|
|
|
bytes (`7 ≤ N ≤ 13`).
|
2019-09-13 00:22:29 -04:00
|
|
|
* The length of the plaintext is limited to `2 ** (8 * (15 - N))` bytes.
|
|
|
|
* When decrypting, the authentication tag must be set via `setAuthTag()` before
|
2019-07-10 16:35:06 +02:00
|
|
|
calling `update()`.
|
2017-12-18 13:22:08 +01:00
|
|
|
Otherwise, decryption will fail and `final()` will throw an error in
|
|
|
|
compliance with section 2.6 of [RFC 3610][].
|
2019-09-13 00:22:29 -04:00
|
|
|
* Using stream methods such as `write(data)`, `end(data)` or `pipe()` in CCM
|
2017-12-18 13:22:08 +01:00
|
|
|
mode might fail as CCM cannot handle more than one chunk of data per instance.
|
2019-09-13 00:22:29 -04:00
|
|
|
* When passing additional authenticated data (AAD), the length of the actual
|
2017-12-18 13:22:08 +01:00
|
|
|
message in bytes must be passed to `setAAD()` via the `plaintextLength`
|
2020-04-27 08:30:42 -07:00
|
|
|
option.
|
|
|
|
Many crypto libraries include the authentication tag in the ciphertext,
|
|
|
|
which means that they produce ciphertexts of the length
|
|
|
|
`plaintextLength + authTagLength`. Node.js does not include the authentication
|
|
|
|
tag, so the ciphertext length is always `plaintextLength`.
|
|
|
|
This is not necessary if no AAD is used.
|
2021-04-05 23:37:47 +02:00
|
|
|
* As CCM processes the whole message at once, `update()` must be called exactly
|
2017-12-18 13:22:08 +01:00
|
|
|
once.
|
2019-09-13 00:22:29 -04:00
|
|
|
* Even though calling `update()` is sufficient to encrypt/decrypt the message,
|
2021-10-10 21:55:04 -07:00
|
|
|
applications _must_ call `final()` to compute or verify the
|
2017-12-18 13:22:08 +01:00
|
|
|
authentication tag.
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
```mjs
|
2022-04-20 10:23:41 +02:00
|
|
|
import { Buffer } from 'node:buffer';
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
createCipheriv,
|
|
|
|
createDecipheriv,
|
2022-11-17 08:19:12 -05:00
|
|
|
randomBytes,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = await import('node:crypto');
|
2021-03-03 14:25:03 -08:00
|
|
|
|
|
|
|
const key = 'keykeykeykeykeykeykeykey';
|
|
|
|
const nonce = randomBytes(12);
|
|
|
|
|
|
|
|
const aad = Buffer.from('0123456789', 'hex');
|
|
|
|
|
|
|
|
const cipher = createCipheriv('aes-192-ccm', key, nonce, {
|
2022-11-17 08:19:12 -05:00
|
|
|
authTagLength: 16,
|
2021-03-03 14:25:03 -08:00
|
|
|
});
|
|
|
|
const plaintext = 'Hello world';
|
|
|
|
cipher.setAAD(aad, {
|
2022-11-17 08:19:12 -05:00
|
|
|
plaintextLength: Buffer.byteLength(plaintext),
|
2021-03-03 14:25:03 -08:00
|
|
|
});
|
|
|
|
const ciphertext = cipher.update(plaintext, 'utf8');
|
|
|
|
cipher.final();
|
|
|
|
const tag = cipher.getAuthTag();
|
|
|
|
|
|
|
|
// Now transmit { ciphertext, nonce, tag }.
|
|
|
|
|
|
|
|
const decipher = createDecipheriv('aes-192-ccm', key, nonce, {
|
2022-11-17 08:19:12 -05:00
|
|
|
authTagLength: 16,
|
2021-03-03 14:25:03 -08:00
|
|
|
});
|
|
|
|
decipher.setAuthTag(tag);
|
|
|
|
decipher.setAAD(aad, {
|
2022-11-17 08:19:12 -05:00
|
|
|
plaintextLength: ciphertext.length,
|
2021-03-03 14:25:03 -08:00
|
|
|
});
|
|
|
|
const receivedPlaintext = decipher.update(ciphertext, null, 'utf8');
|
|
|
|
|
|
|
|
try {
|
|
|
|
decipher.final();
|
|
|
|
} catch (err) {
|
2021-08-31 01:01:48 +02:00
|
|
|
throw new Error('Authentication failed!', { cause: err });
|
2021-03-03 14:25:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
console.log(receivedPlaintext);
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { Buffer } = require('node:buffer');
|
2021-03-03 14:25:03 -08:00
|
|
|
const {
|
|
|
|
createCipheriv,
|
|
|
|
createDecipheriv,
|
|
|
|
randomBytes,
|
2022-04-20 10:23:41 +02:00
|
|
|
} = require('node:crypto');
|
2017-12-18 13:22:08 +01:00
|
|
|
|
|
|
|
const key = 'keykeykeykeykeykeykeykey';
|
2021-03-03 14:25:03 -08:00
|
|
|
const nonce = randomBytes(12);
|
2017-12-18 13:22:08 +01:00
|
|
|
|
|
|
|
const aad = Buffer.from('0123456789', 'hex');
|
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const cipher = createCipheriv('aes-192-ccm', key, nonce, {
|
2022-11-17 08:19:12 -05:00
|
|
|
authTagLength: 16,
|
2017-12-18 13:22:08 +01:00
|
|
|
});
|
|
|
|
const plaintext = 'Hello world';
|
|
|
|
cipher.setAAD(aad, {
|
2022-11-17 08:19:12 -05:00
|
|
|
plaintextLength: Buffer.byteLength(plaintext),
|
2017-12-18 13:22:08 +01:00
|
|
|
});
|
|
|
|
const ciphertext = cipher.update(plaintext, 'utf8');
|
|
|
|
cipher.final();
|
|
|
|
const tag = cipher.getAuthTag();
|
|
|
|
|
2018-04-06 14:32:35 +02:00
|
|
|
// Now transmit { ciphertext, nonce, tag }.
|
2017-12-18 13:22:08 +01:00
|
|
|
|
2021-03-03 14:25:03 -08:00
|
|
|
const decipher = createDecipheriv('aes-192-ccm', key, nonce, {
|
2022-11-17 08:19:12 -05:00
|
|
|
authTagLength: 16,
|
2017-12-18 13:22:08 +01:00
|
|
|
});
|
|
|
|
decipher.setAuthTag(tag);
|
|
|
|
decipher.setAAD(aad, {
|
2022-11-17 08:19:12 -05:00
|
|
|
plaintextLength: ciphertext.length,
|
2017-12-18 13:22:08 +01:00
|
|
|
});
|
|
|
|
const receivedPlaintext = decipher.update(ciphertext, null, 'utf8');
|
|
|
|
|
|
|
|
try {
|
|
|
|
decipher.final();
|
|
|
|
} catch (err) {
|
2021-08-31 01:01:48 +02:00
|
|
|
throw new Error('Authentication failed!', { cause: err });
|
2017-12-18 13:22:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
console.log(receivedPlaintext);
|
|
|
|
```
|
|
|
|
|
2023-05-30 11:40:25 +00:00
|
|
|
### FIPS mode
|
|
|
|
|
|
|
|
When using OpenSSL 3, Node.js supports FIPS 140-2 when used with an appropriate
|
|
|
|
OpenSSL 3 provider, such as the [FIPS provider from OpenSSL 3][] which can be
|
|
|
|
installed by following the instructions in [OpenSSL's FIPS README file][].
|
|
|
|
|
|
|
|
For FIPS support in Node.js you will need:
|
|
|
|
|
|
|
|
* A correctly installed OpenSSL 3 FIPS provider.
|
|
|
|
* An OpenSSL 3 [FIPS module configuration file][].
|
|
|
|
* An OpenSSL 3 configuration file that references the FIPS module
|
|
|
|
configuration file.
|
|
|
|
|
|
|
|
Node.js will need to be configured with an OpenSSL configuration file that
|
|
|
|
points to the FIPS provider. An example configuration file looks like this:
|
|
|
|
|
|
|
|
```text
|
|
|
|
nodejs_conf = nodejs_init
|
|
|
|
|
|
|
|
.include /<absolute path>/fipsmodule.cnf
|
|
|
|
|
|
|
|
[nodejs_init]
|
|
|
|
providers = provider_sect
|
|
|
|
|
|
|
|
[provider_sect]
|
|
|
|
default = default_sect
|
|
|
|
# The fips section name should match the section name inside the
|
|
|
|
# included fipsmodule.cnf.
|
|
|
|
fips = fips_sect
|
|
|
|
|
|
|
|
[default_sect]
|
|
|
|
activate = 1
|
|
|
|
```
|
|
|
|
|
|
|
|
where `fipsmodule.cnf` is the FIPS module configuration file generated from the
|
|
|
|
FIPS provider installation step:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
openssl fipsinstall
|
|
|
|
```
|
|
|
|
|
|
|
|
Set the `OPENSSL_CONF` environment variable to point to
|
|
|
|
your configuration file and `OPENSSL_MODULES` to the location of the FIPS
|
|
|
|
provider dynamic library. e.g.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
export OPENSSL_CONF=/<path to configuration file>/nodejs.cnf
|
|
|
|
export OPENSSL_MODULES=/<path to openssl lib>/ossl-modules
|
|
|
|
```
|
|
|
|
|
|
|
|
FIPS mode can then be enabled in Node.js either by:
|
|
|
|
|
|
|
|
* Starting Node.js with `--enable-fips` or `--force-fips` command line flags.
|
|
|
|
* Programmatically calling `crypto.setFips(true)`.
|
|
|
|
|
|
|
|
Optionally FIPS mode can be enabled in Node.js via the OpenSSL configuration
|
|
|
|
file. e.g.
|
|
|
|
|
|
|
|
```text
|
|
|
|
nodejs_conf = nodejs_init
|
|
|
|
|
|
|
|
.include /<absolute path>/fipsmodule.cnf
|
|
|
|
|
|
|
|
[nodejs_init]
|
|
|
|
providers = provider_sect
|
|
|
|
alg_section = algorithm_sect
|
|
|
|
|
|
|
|
[provider_sect]
|
|
|
|
default = default_sect
|
|
|
|
# The fips section name should match the section name inside the
|
|
|
|
# included fipsmodule.cnf.
|
|
|
|
fips = fips_sect
|
|
|
|
|
|
|
|
[default_sect]
|
|
|
|
activate = 1
|
|
|
|
|
|
|
|
[algorithm_sect]
|
|
|
|
default_properties = fips=yes
|
|
|
|
```
|
|
|
|
|
2020-06-14 14:49:34 -07:00
|
|
|
## Crypto constants
|
2016-05-02 10:27:12 -07:00
|
|
|
|
2016-11-15 09:56:15 -08:00
|
|
|
The following constants exported by `crypto.constants` apply to various uses of
|
2022-04-20 10:23:41 +02:00
|
|
|
the `node:crypto`, `node:tls`, and `node:https` modules and are generally
|
|
|
|
specific to OpenSSL.
|
2016-05-02 10:27:12 -07:00
|
|
|
|
2020-06-14 14:49:34 -07:00
|
|
|
### OpenSSL options
|
2019-10-13 23:46:56 -04:00
|
|
|
|
2021-08-29 20:19:57 +02:00
|
|
|
See the [list of SSL OP Flags][] for details.
|
|
|
|
|
2016-05-02 10:27:12 -07:00
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>Constant</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_ALL</code></td>
|
|
|
|
<td>Applies multiple bug workarounds within OpenSSL. See
|
2023-03-05 00:15:29 +01:00
|
|
|
<a href="https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html">https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html</a>
|
2018-06-19 22:14:31 -07:00
|
|
|
for detail.</td>
|
2016-05-02 10:27:12 -07:00
|
|
|
</tr>
|
2020-06-17 17:29:06 +02:00
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_ALLOW_NO_DHE_KEX</code></td>
|
|
|
|
<td>Instructs OpenSSL to allow a non-[EC]DHE-based key exchange mode
|
|
|
|
for TLS v1.3</td>
|
|
|
|
</tr>
|
2016-05-02 10:27:12 -07:00
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION</code></td>
|
|
|
|
<td>Allows legacy insecure renegotiation between OpenSSL and unpatched
|
2016-11-15 09:56:15 -08:00
|
|
|
clients or servers. See
|
2023-03-05 00:15:29 +01:00
|
|
|
<a href="https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html">https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html</a>.</td>
|
2016-05-02 10:27:12 -07:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_CIPHER_SERVER_PREFERENCE</code></td>
|
2016-11-23 14:14:34 -08:00
|
|
|
<td>Attempts to use the server's preferences instead of the client's when
|
2017-05-26 13:51:15 -04:00
|
|
|
selecting a cipher. Behavior depends on protocol version. See
|
2023-03-05 00:15:29 +01:00
|
|
|
<a href="https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html">https://www.openssl.org/docs/man3.0/man3/SSL_CTX_set_options.html</a>.</td>
|
2016-05-02 10:27:12 -07:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_CISCO_ANYCONNECT</code></td>
|
2024-03-17 05:10:27 -07:00
|
|
|
<td>Instructs OpenSSL to use Cisco's version identifier of DTLS_BAD_VER.</td>
|
2016-05-02 10:27:12 -07:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_COOKIE_EXCHANGE</code></td>
|
|
|
|
<td>Instructs OpenSSL to turn on cookie exchange.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_CRYPTOPRO_TLSEXT_BUG</code></td>
|
|
|
|
<td>Instructs OpenSSL to add server-hello extension from an early version
|
|
|
|
of the cryptopro draft.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS</code></td>
|
|
|
|
<td>Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability
|
|
|
|
workaround added in OpenSSL 0.9.6d.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_LEGACY_SERVER_CONNECT</code></td>
|
2016-11-23 14:14:34 -08:00
|
|
|
<td>Allows initial connection to servers that do not support RI.</td>
|
2016-05-02 10:27:12 -07:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_COMPRESSION</code></td>
|
|
|
|
<td>Instructs OpenSSL to disable support for SSL/TLS compression.</td>
|
|
|
|
</tr>
|
2020-06-17 17:29:06 +02:00
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_ENCRYPT_THEN_MAC</code></td>
|
|
|
|
<td>Instructs OpenSSL to disable encrypt-then-MAC.</td>
|
|
|
|
</tr>
|
2016-05-02 10:27:12 -07:00
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_QUERY_MTU</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
2020-06-17 17:29:06 +02:00
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_RENEGOTIATION</code></td>
|
|
|
|
<td>Instructs OpenSSL to disable renegotiation.</td>
|
|
|
|
</tr>
|
2016-05-02 10:27:12 -07:00
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION</code></td>
|
|
|
|
<td>Instructs OpenSSL to always start a new session when performing
|
|
|
|
renegotiation.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_SSLv2</code></td>
|
|
|
|
<td>Instructs OpenSSL to turn off SSL v2</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_SSLv3</code></td>
|
|
|
|
<td>Instructs OpenSSL to turn off SSL v3</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_TICKET</code></td>
|
|
|
|
<td>Instructs OpenSSL to disable use of RFC4507bis tickets.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_TLSv1</code></td>
|
|
|
|
<td>Instructs OpenSSL to turn off TLS v1</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_TLSv1_1</code></td>
|
|
|
|
<td>Instructs OpenSSL to turn off TLS v1.1</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_TLSv1_2</code></td>
|
|
|
|
<td>Instructs OpenSSL to turn off TLS v1.2</td>
|
2020-06-17 17:29:06 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_NO_TLSv1_3</code></td>
|
|
|
|
<td>Instructs OpenSSL to turn off TLS v1.3</td>
|
2016-05-02 10:27:12 -07:00
|
|
|
</tr>
|
2020-06-17 17:29:06 +02:00
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_PRIORITIZE_CHACHA</code></td>
|
2022-02-06 00:36:32 +01:00
|
|
|
<td>Instructs OpenSSL server to prioritize ChaCha20-Poly1305
|
|
|
|
when the client does.
|
2020-06-17 17:29:06 +02:00
|
|
|
This option has no effect if
|
|
|
|
<code>SSL_OP_CIPHER_SERVER_PREFERENCE</code>
|
|
|
|
is not enabled.</td>
|
|
|
|
</tr>
|
2016-05-02 10:27:12 -07:00
|
|
|
<tr>
|
|
|
|
<td><code>SSL_OP_TLS_ROLLBACK_BUG</code></td>
|
|
|
|
<td>Instructs OpenSSL to disable version rollback attack detection.</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
2020-06-14 14:49:34 -07:00
|
|
|
### OpenSSL engine constants
|
2016-05-02 10:27:12 -07:00
|
|
|
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>Constant</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_RSA</code></td>
|
|
|
|
<td>Limit engine usage to RSA</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_DSA</code></td>
|
|
|
|
<td>Limit engine usage to DSA</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_DH</code></td>
|
|
|
|
<td>Limit engine usage to DH</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_RAND</code></td>
|
|
|
|
<td>Limit engine usage to RAND</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-03-14 19:27:57 +09:00
|
|
|
<td><code>ENGINE_METHOD_EC</code></td>
|
|
|
|
<td>Limit engine usage to EC</td>
|
2016-05-02 10:27:12 -07:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_CIPHERS</code></td>
|
|
|
|
<td>Limit engine usage to CIPHERS</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_DIGESTS</code></td>
|
|
|
|
<td>Limit engine usage to DIGESTS</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_PKEY_METHS</code></td>
|
2024-09-29 23:15:15 +10:00
|
|
|
<td>Limit engine usage to PKEY_METHS</td>
|
2016-05-02 10:27:12 -07:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_PKEY_ASN1_METHS</code></td>
|
|
|
|
<td>Limit engine usage to PKEY_ASN1_METHS</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_ALL</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>ENGINE_METHOD_NONE</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
2020-06-14 14:49:34 -07:00
|
|
|
### Other OpenSSL constants
|
2016-05-02 10:27:12 -07:00
|
|
|
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>Constant</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>DH_CHECK_P_NOT_SAFE_PRIME</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>DH_CHECK_P_NOT_PRIME</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>DH_UNABLE_TO_CHECK_GENERATOR</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>DH_NOT_SUITABLE_GENERATOR</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>RSA_PKCS1_PADDING</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>RSA_SSLV23_PADDING</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>RSA_NO_PADDING</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>RSA_PKCS1_OAEP_PADDING</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>RSA_X931_PADDING</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>RSA_PKCS1_PSS_PADDING</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
2017-03-06 00:41:26 +01:00
|
|
|
<tr>
|
|
|
|
<td><code>RSA_PSS_SALTLEN_DIGEST</code></td>
|
2018-07-12 13:28:42 -04:00
|
|
|
<td>Sets the salt length for <code>RSA_PKCS1_PSS_PADDING</code> to the
|
|
|
|
digest size when signing or verifying.</td>
|
2017-03-06 00:41:26 +01:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>RSA_PSS_SALTLEN_MAX_SIGN</code></td>
|
2018-07-12 13:28:42 -04:00
|
|
|
<td>Sets the salt length for <code>RSA_PKCS1_PSS_PADDING</code> to the
|
|
|
|
maximum permissible value when signing data.</td>
|
2017-03-06 00:41:26 +01:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>RSA_PSS_SALTLEN_AUTO</code></td>
|
2018-07-12 13:28:42 -04:00
|
|
|
<td>Causes the salt length for <code>RSA_PKCS1_PSS_PADDING</code> to be
|
|
|
|
determined automatically when verifying a signature.</td>
|
2017-03-06 00:41:26 +01:00
|
|
|
</tr>
|
2016-05-02 10:27:12 -07:00
|
|
|
<tr>
|
|
|
|
<td><code>POINT_CONVERSION_COMPRESSED</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>POINT_CONVERSION_UNCOMPRESSED</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>POINT_CONVERSION_HYBRID</code></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
2020-06-14 14:49:34 -07:00
|
|
|
### Node.js crypto constants
|
2016-05-02 10:27:12 -07:00
|
|
|
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>Constant</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>defaultCoreCipherList</code></td>
|
|
|
|
<td>Specifies the built-in default cipher list used by Node.js.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>defaultCipherList</code></td>
|
|
|
|
<td>Specifies the active default cipher list used by the current Node.js
|
|
|
|
process.</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
2020-09-17 18:53:37 +02:00
|
|
|
[AEAD algorithms]: https://en.wikipedia.org/wiki/Authenticated_encryption
|
2021-07-04 20:39:17 -07:00
|
|
|
[CCM mode]: #ccm-mode
|
2021-12-07 00:21:28 +00:00
|
|
|
[CVE-2021-44532]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44532
|
2021-07-04 20:39:17 -07:00
|
|
|
[Caveats]: #support-for-weak-or-compromised-algorithms
|
|
|
|
[Crypto constants]: #crypto-constants
|
2023-05-30 11:40:25 +00:00
|
|
|
[FIPS module configuration file]: https://www.openssl.org/docs/man3.0/man5/fips_config.html
|
|
|
|
[FIPS provider from OpenSSL 3]: https://www.openssl.org/docs/man3.0/man7/crypto.html#FIPS-provider
|
2020-09-17 18:53:37 +02:00
|
|
|
[HTML 5.2]: https://www.w3.org/TR/html52/changes.html#features-removed
|
crypto: add keyObject.export() 'jwk' format option
Adds [JWK](https://tools.ietf.org/html/rfc7517) keyObject.export format
option.
Supported key types: `ec`, `rsa`, `ed25519`, `ed448`, `x25519`, `x448`,
and symmetric keys, resulting in JWK `kty` (Key Type) values `EC`,
`RSA`, `OKP`, and `oct`.
`rsa-pss` is not supported since the JWK format does not support
PSS Parameters.
`EC` JWK curves supported are `P-256`, `secp256k1`, `P-384`, and `P-521`
PR-URL: https://github.com/nodejs/node/pull/37081
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 18:21:14 +01:00
|
|
|
[JWK]: https://tools.ietf.org/html/rfc7517
|
2024-10-06 20:09:02 +02:00
|
|
|
[Key usages]: webcrypto.md#cryptokeyusages
|
2023-08-26 23:11:21 +02:00
|
|
|
[NIST SP 800-131A]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf
|
2020-09-17 18:53:37 +02:00
|
|
|
[NIST SP 800-132]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
|
|
|
|
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
|
2023-05-30 11:40:25 +00:00
|
|
|
[OpenSSL's FIPS README file]: https://github.com/openssl/openssl/blob/openssl-3.0/README-FIPS.md
|
2023-05-19 10:18:58 -07:00
|
|
|
[OpenSSL's SPKAC implementation]: https://www.openssl.org/docs/man3.0/man1/openssl-spkac.html
|
2020-09-17 18:53:37 +02:00
|
|
|
[RFC 1421]: https://www.rfc-editor.org/rfc/rfc1421.txt
|
2022-07-27 22:20:02 +02:00
|
|
|
[RFC 2409]: https://www.rfc-editor.org/rfc/rfc2409.txt
|
2022-01-17 14:35:47 +00:00
|
|
|
[RFC 2818]: https://www.rfc-editor.org/rfc/rfc2818.txt
|
2020-09-17 18:53:37 +02:00
|
|
|
[RFC 3526]: https://www.rfc-editor.org/rfc/rfc3526.txt
|
|
|
|
[RFC 3610]: https://www.rfc-editor.org/rfc/rfc3610.txt
|
|
|
|
[RFC 4055]: https://www.rfc-editor.org/rfc/rfc4055.txt
|
2021-01-01 21:59:44 -08:00
|
|
|
[RFC 4122]: https://www.rfc-editor.org/rfc/rfc4122.txt
|
2020-09-17 18:53:37 +02:00
|
|
|
[RFC 5208]: https://www.rfc-editor.org/rfc/rfc5208.txt
|
2022-01-17 15:48:51 +00:00
|
|
|
[RFC 5280]: https://www.rfc-editor.org/rfc/rfc5280.txt
|
2020-08-25 10:05:51 -07:00
|
|
|
[Web Crypto API documentation]: webcrypto.md
|
2021-01-18 23:03:58 -08:00
|
|
|
[`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
|
2020-09-14 17:09:13 +02:00
|
|
|
[`Buffer`]: buffer.md
|
doc,test: clarify behavior of DH generateKeys
The DiffieHellman class is an old and thin wrapper around certain
OpenSSL functions, many of which are deprecated in OpenSSL 3.0. Because
the Node.js API mirrors the OpenSSL API, it adopts some of its
peculiarities, but the Node.js documentation does not properly reflect
these. Most importantly, despite the documentation saying otherwise,
diffieHellman.generateKeys() does not generate a new private key when
one has already been set or generated. Based on the documentation alone,
users may be led to misuse the API in a way that results in key reuse,
which can have drastic negative consequences for subsequent operations
that consume the shared secret.
These design issues in this old API have been around for many years, and
we are not currently aware of any misuse in the ecosystem that falls
into the above scenario. Changing the behavior of the API would be a
significant breaking change and is thus not appropriate for a security
release (nor is it a goal.) The reported issue is treated as CWE-1068
(after a vast amount of uncertainty whether to treat it as a
vulnerability at all), therefore, this change only updates the
documentation to match the actual behavior. Tests are also added that
demonstrate this particular oddity.
Newer APIs exist that can be used for some, but not all, Diffie-Hellman
operations (e.g., crypto.diffieHellman() that was added in 2020). We
should keep modernizing crypto APIs, but that is a non-goal for this
security release.
The ECDH class mirrors the DiffieHellman class in many ways, but it does
not appear to be affected by this particular peculiarity. In particular,
ecdh.generateKeys() does appear to always generate a new private key.
PR-URL: https://github.com/nodejs-private/node-private/pull/426
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
CVE-ID: CVE-2023-30590
2023-06-12 19:44:48 +02:00
|
|
|
[`DH_generate_key()`]: https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html
|
2022-09-17 03:00:35 +02:00
|
|
|
[`DiffieHellmanGroup`]: #class-diffiehellmangroup
|
2021-07-04 20:39:17 -07:00
|
|
|
[`KeyObject`]: #class-keyobject
|
|
|
|
[`Sign`]: #class-sign
|
2021-02-06 16:51:50 +01:00
|
|
|
[`String.prototype.normalize()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
|
2021-07-04 20:39:17 -07:00
|
|
|
[`UV_THREADPOOL_SIZE`]: cli.md#uv_threadpool_sizesize
|
|
|
|
[`Verify`]: #class-verify
|
|
|
|
[`cipher.final()`]: #cipherfinaloutputencoding
|
|
|
|
[`cipher.update()`]: #cipherupdatedata-inputencoding-outputencoding
|
|
|
|
[`crypto.createCipheriv()`]: #cryptocreatecipherivalgorithm-key-iv-options
|
|
|
|
[`crypto.createDecipheriv()`]: #cryptocreatedecipherivalgorithm-key-iv-options
|
|
|
|
[`crypto.createDiffieHellman()`]: #cryptocreatediffiehellmanprime-primeencoding-generator-generatorencoding
|
|
|
|
[`crypto.createECDH()`]: #cryptocreateecdhcurvename
|
|
|
|
[`crypto.createHash()`]: #cryptocreatehashalgorithm-options
|
|
|
|
[`crypto.createHmac()`]: #cryptocreatehmacalgorithm-key-options
|
|
|
|
[`crypto.createPrivateKey()`]: #cryptocreateprivatekeykey
|
|
|
|
[`crypto.createPublicKey()`]: #cryptocreatepublickeykey
|
|
|
|
[`crypto.createSecretKey()`]: #cryptocreatesecretkeykey-encoding
|
|
|
|
[`crypto.createSign()`]: #cryptocreatesignalgorithm-options
|
|
|
|
[`crypto.createVerify()`]: #cryptocreateverifyalgorithm-options
|
2023-05-24 22:21:07 +02:00
|
|
|
[`crypto.generateKey()`]: #cryptogeneratekeytype-options-callback
|
2021-07-04 20:39:17 -07:00
|
|
|
[`crypto.getCurves()`]: #cryptogetcurves
|
|
|
|
[`crypto.getDiffieHellman()`]: #cryptogetdiffiehellmangroupname
|
|
|
|
[`crypto.getHashes()`]: #cryptogethashes
|
|
|
|
[`crypto.privateDecrypt()`]: #cryptoprivatedecryptprivatekey-buffer
|
|
|
|
[`crypto.privateEncrypt()`]: #cryptoprivateencryptprivatekey-buffer
|
|
|
|
[`crypto.publicDecrypt()`]: #cryptopublicdecryptkey-buffer
|
|
|
|
[`crypto.publicEncrypt()`]: #cryptopublicencryptkey-buffer
|
|
|
|
[`crypto.randomBytes()`]: #cryptorandombytessize-callback
|
|
|
|
[`crypto.randomFill()`]: #cryptorandomfillbuffer-offset-size-callback
|
2021-12-27 06:48:59 -08:00
|
|
|
[`crypto.webcrypto.getRandomValues()`]: webcrypto.md#cryptogetrandomvaluestypedarray
|
|
|
|
[`crypto.webcrypto.subtle`]: webcrypto.md#class-subtlecrypto
|
2021-07-04 20:39:17 -07:00
|
|
|
[`decipher.final()`]: #decipherfinaloutputencoding
|
|
|
|
[`decipher.update()`]: #decipherupdatedata-inputencoding-outputencoding
|
doc,test: clarify behavior of DH generateKeys
The DiffieHellman class is an old and thin wrapper around certain
OpenSSL functions, many of which are deprecated in OpenSSL 3.0. Because
the Node.js API mirrors the OpenSSL API, it adopts some of its
peculiarities, but the Node.js documentation does not properly reflect
these. Most importantly, despite the documentation saying otherwise,
diffieHellman.generateKeys() does not generate a new private key when
one has already been set or generated. Based on the documentation alone,
users may be led to misuse the API in a way that results in key reuse,
which can have drastic negative consequences for subsequent operations
that consume the shared secret.
These design issues in this old API have been around for many years, and
we are not currently aware of any misuse in the ecosystem that falls
into the above scenario. Changing the behavior of the API would be a
significant breaking change and is thus not appropriate for a security
release (nor is it a goal.) The reported issue is treated as CWE-1068
(after a vast amount of uncertainty whether to treat it as a
vulnerability at all), therefore, this change only updates the
documentation to match the actual behavior. Tests are also added that
demonstrate this particular oddity.
Newer APIs exist that can be used for some, but not all, Diffie-Hellman
operations (e.g., crypto.diffieHellman() that was added in 2020). We
should keep modernizing crypto APIs, but that is a non-goal for this
security release.
The ECDH class mirrors the DiffieHellman class in many ways, but it does
not appear to be affected by this particular peculiarity. In particular,
ecdh.generateKeys() does appear to always generate a new private key.
PR-URL: https://github.com/nodejs-private/node-private/pull/426
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
CVE-ID: CVE-2023-30590
2023-06-12 19:44:48 +02:00
|
|
|
[`diffieHellman.generateKeys()`]: #diffiehellmangeneratekeysencoding
|
2021-07-04 20:39:17 -07:00
|
|
|
[`diffieHellman.setPublicKey()`]: #diffiehellmansetpublickeypublickey-encoding
|
|
|
|
[`ecdh.generateKeys()`]: #ecdhgeneratekeysencoding-format
|
|
|
|
[`ecdh.setPrivateKey()`]: #ecdhsetprivatekeyprivatekey-encoding
|
|
|
|
[`hash.digest()`]: #hashdigestencoding
|
|
|
|
[`hash.update()`]: #hashupdatedata-inputencoding
|
|
|
|
[`hmac.digest()`]: #hmacdigestencoding
|
|
|
|
[`hmac.update()`]: #hmacupdatedata-inputencoding
|
2022-07-15 16:44:58 +02:00
|
|
|
[`import()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import
|
2021-07-04 20:39:17 -07:00
|
|
|
[`keyObject.export()`]: #keyobjectexportoptions
|
|
|
|
[`postMessage()`]: worker_threads.md#portpostmessagevalue-transferlist
|
|
|
|
[`sign.sign()`]: #signsignprivatekey-outputencoding
|
|
|
|
[`sign.update()`]: #signupdatedata-inputencoding
|
|
|
|
[`stream.Writable` options]: stream.md#new-streamwritableoptions
|
|
|
|
[`stream.transform` options]: stream.md#new-streamtransformoptions
|
|
|
|
[`util.promisify()`]: util.md#utilpromisifyoriginal
|
|
|
|
[`verify.update()`]: #verifyupdatedata-inputencoding
|
|
|
|
[`verify.verify()`]: #verifyverifyobject-signature-signatureencoding
|
2022-04-01 12:35:27 +02:00
|
|
|
[`x509.fingerprint256`]: #x509fingerprint256
|
2021-07-04 20:39:17 -07:00
|
|
|
[caveats when using strings as inputs to cryptographic APIs]: #using-strings-as-inputs-to-cryptographic-apis
|
|
|
|
[certificate object]: tls.md#certificate-object
|
|
|
|
[encoding]: buffer.md#buffers-and-character-encodings
|
2017-05-08 09:30:13 -07:00
|
|
|
[initialization vector]: https://en.wikipedia.org/wiki/Initialization_vector
|
2021-10-25 01:05:33 +02:00
|
|
|
[legacy provider]: cli.md#--openssl-legacy-provider
|
2020-09-13 21:55:50 -07:00
|
|
|
[list of SSL OP Flags]: https://wiki.openssl.org/index.php/List_of_SSL_OP_Flags#Table_of_Options
|
2020-09-17 18:53:37 +02:00
|
|
|
[modulo bias]: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias
|
2020-09-04 11:19:06 +02:00
|
|
|
[safe integers]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger
|
2018-05-18 11:05:20 +02:00
|
|
|
[scrypt]: https://en.wikipedia.org/wiki/Scrypt
|
2020-09-14 17:09:13 +02:00
|
|
|
[stream]: stream.md
|
2021-07-04 20:39:17 -07:00
|
|
|
[stream-writable-write]: stream.md#writablewritechunk-encoding-callback
|