forked from nodejscn/node-api-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
121 changed files
with
1,851 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
* `asyncId` {number} | ||
|
||
Called when the `resolve` function passed to the `Promise` constructor is | ||
invoked (either directly or through other means of resolving a promise). | ||
|
||
Note that `resolve()` does not do any observable synchronous work. | ||
|
||
*Note:* This does not necessarily mean that the `Promise` is fulfilled or | ||
rejected at this point, if the `Promise` was resolved by assuming the state | ||
of another `Promise`. | ||
|
||
For example: | ||
|
||
```js | ||
new Promise((resolve) => resolve(true)).then((a) => {}); | ||
``` | ||
|
||
calls the following callbacks: | ||
|
||
``` | ||
init for PROMISE with id 5, trigger id: 1 | ||
promise resolve 5 # corresponds to resolve(true) | ||
init for PROMISE with id 6, trigger id: 5 # the Promise returned by then() | ||
before 6 # the then() callback is entered | ||
promise resolve 6 # the then() callback resolves the promise by returning | ||
after 6 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Set the number of threads used in libuv's threadpool to `size` threads. | ||
|
||
Asynchronous system APIs are used by Node.js whenever possible, but where they | ||
do not exist, libuv's threadpool is used to create asynchronous node APIs based | ||
on synchronous system APIs. Node.js APIs that use the threadpool are: | ||
|
||
- all `fs` APIs, other than the file watcher APIs and those that are explicitly | ||
synchronous | ||
- `crypto.pbkdf2()` | ||
- `crypto.randomBytes()`, unless it is used without a callback | ||
- `crypto.randomFill()` | ||
- `dns.lookup()` | ||
- all `zlib` APIs, other than those that are explicitly synchronous | ||
|
||
Because libuv's threadpool has a fixed size, it means that if for whatever | ||
reason any of these APIs takes a long time, other (seemingly unrelated) APIs | ||
that run in libuv's threadpool will experience degraded performance. In order to | ||
mitigate this issue, one potential solution is to increase the size of libuv's | ||
threadpool by setting the `'UV_THREADPOOL_SIZE'` environment variable to a value | ||
greater than `4` (its current default value). For more information, see the | ||
[libuv threadpool documentation][]. | ||
|
||
[`--openssl-config`]: #cli_openssl_config_file | ||
[Buffer]: buffer.html#buffer_buffer | ||
[Chrome Debugging Protocol]: https://chromedevtools.github.io/debugger-protocol-viewer | ||
[REPL]: repl.html | ||
[SlowBuffer]: buffer.html#buffer_class_slowbuffer | ||
[debugger]: debugger.html | ||
[emit_warning]: process.html#process_process_emitwarning_warning_type_code_ctor | ||
[libuv threadpool documentation]: http://docs.libuv.org/en/latest/threadpool.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- YAML | ||
added: v8.5.0 | ||
--> | ||
|
||
* `label` {any} | ||
|
||
Increases indentation of subsequent lines by two spaces. | ||
|
||
If one or more `label`s are provided, those are printed first without the | ||
additional indentation. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!-- YAML | ||
added: v8.5.0 | ||
--> | ||
|
||
An alias for [`console.group()`][]. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!-- YAML | ||
added: v8.5.0 | ||
--> | ||
|
||
Decreases indentation of subsequent lines by two spaces. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!-- YAML | ||
added: v0.1.94 | ||
--> | ||
- `algorithm` {string} | ||
- `password` {string | Buffer | TypedArray | DataView} | ||
- `options` {Object} [`stream.transform` options][] | ||
|
||
Creates and returns a `Cipher` object that uses the given `algorithm` and | ||
`password`. Optional `options` argument controls stream behavior. | ||
|
||
The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On | ||
recent OpenSSL releases, `openssl list-cipher-algorithms` will display the | ||
available cipher algorithms. | ||
|
||
The `password` is used to derive the cipher key and initialization vector (IV). | ||
The value must be either a `'latin1'` encoded string, a [`Buffer`][], a | ||
`TypedArray`, or a `DataView`. | ||
|
||
The implementation of `crypto.createCipher()` derives keys using the OpenSSL | ||
function [`EVP_BytesToKey`][] with the digest algorithm set to MD5, one | ||
iteration, and no salt. The lack of salt allows dictionary attacks as the same | ||
password always creates the same key. The low iteration count and | ||
non-cryptographically secure hash algorithm allow passwords to be tested very | ||
rapidly. | ||
|
||
In line with OpenSSL's recommendation to use pbkdf2 instead of | ||
[`EVP_BytesToKey`][] it is recommended that developers derive a key and IV on | ||
their own using [`crypto.pbkdf2()`][] and to use [`crypto.createCipheriv()`][] | ||
to create the `Cipher` object. Users should not use ciphers with counter mode | ||
(e.g. CTR, GCM or CCM) in `crypto.createCipher()`. A warning is emitted when | ||
they are used in order to avoid the risk of IV reuse that causes | ||
vulnerabilities. For the case when IV is reused in GCM, see [Nonce-Disrespecting | ||
Adversaries][] for details. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
- `algorithm` {string} | ||
- `key` {string | Buffer | TypedArray | DataView} | ||
- `iv` {string | Buffer | TypedArray | DataView} | ||
- `options` {Object} [`stream.transform` options][] | ||
|
||
Creates and returns a `Cipher` object, with the given `algorithm`, `key` and | ||
initialization vector (`iv`). Optional `options` argument controls stream behavior. | ||
|
||
The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On | ||
recent OpenSSL releases, `openssl list-cipher-algorithms` will display the | ||
available cipher algorithms. | ||
|
||
The `key` is the raw key used by the `algorithm` and `iv` is an | ||
[initialization vector][]. Both arguments must be `'utf8'` encoded strings, | ||
[Buffers][`Buffer`], `TypedArray`, or `DataView`s. | ||
|
22 changes: 22 additions & 0 deletions
22
crypto/crypto_createdecipher_algorithm_password_options.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- YAML | ||
added: v0.1.94 | ||
--> | ||
- `algorithm` {string} | ||
- `password` {string | Buffer | TypedArray | DataView} | ||
- `options` {Object} [`stream.transform` options][] | ||
|
||
Creates and returns a `Decipher` object that uses the given `algorithm` and | ||
`password` (key). Optional `options` argument controls stream behavior. | ||
|
||
The implementation of `crypto.createDecipher()` derives keys using the OpenSSL | ||
function [`EVP_BytesToKey`][] with the digest algorithm set to MD5, one | ||
iteration, and no salt. The lack of salt allows dictionary attacks as the same | ||
password always creates the same key. The low iteration count and | ||
non-cryptographically secure hash algorithm allow passwords to be tested very | ||
rapidly. | ||
|
||
In line with OpenSSL's recommendation to use pbkdf2 instead of | ||
[`EVP_BytesToKey`][] it is recommended that developers derive a key and IV on | ||
their own using [`crypto.pbkdf2()`][] and to use [`crypto.createDecipheriv()`][] | ||
to create the `Decipher` object. | ||
|
20 changes: 20 additions & 0 deletions
20
crypto/crypto_createdecipheriv_algorithm_key_iv_options.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- YAML | ||
added: v0.1.94 | ||
--> | ||
- `algorithm` {string} | ||
- `key` {string | Buffer | TypedArray | DataView} | ||
- `iv` {string | Buffer | TypedArray | DataView} | ||
- `options` {Object} [`stream.transform` options][] | ||
|
||
Creates and returns a `Decipher` object that uses the given `algorithm`, `key` | ||
and initialization vector (`iv`). Optional `options` argument controls stream | ||
behavior. | ||
|
||
The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On | ||
recent OpenSSL releases, `openssl list-cipher-algorithms` will display the | ||
available cipher algorithms. | ||
|
||
The `key` is the raw key used by the `algorithm` and `iv` is an | ||
[initialization vector][]. Both arguments must be `'utf8'` encoded strings or | ||
[buffers][`Buffer`]. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!-- YAML | ||
added: v0.1.92 | ||
--> | ||
- `algorithm` {string} | ||
- `options` {Object} [`stream.transform` options][] | ||
|
||
Creates and returns a `Hash` object that can be used to generate hash digests | ||
using the given `algorithm`. Optional `options` argument controls stream | ||
behavior. | ||
|
||
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-message-digest-algorithms` will | ||
display the available digest algorithms. | ||
|
||
Example: generating the sha256 sum of a file | ||
|
||
```js | ||
const filename = process.argv[2]; | ||
const crypto = require('crypto'); | ||
const fs = require('fs'); | ||
const hash = crypto.createHash('sha256'); | ||
const input = fs.createReadStream(filename); | ||
input.on('readable', () => { | ||
const data = input.read(); | ||
if (data) | ||
hash.update(data); | ||
else { | ||
console.log(`${hash.digest('hex')} ${filename}`); | ||
} | ||
}); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- YAML | ||
added: v0.1.94 | ||
--> | ||
- `algorithm` {string} | ||
- `key` {string | Buffer | TypedArray | DataView} | ||
- `options` {Object} [`stream.transform` options][] | ||
|
||
Creates and returns an `Hmac` object that uses the given `algorithm` and `key`. | ||
Optional `options` argument controls stream behavior. | ||
|
||
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-message-digest-algorithms` will | ||
display the available digest algorithms. | ||
|
||
The `key` is the HMAC key used to generate the cryptographic HMAC hash. | ||
|
||
Example: generating the sha256 HMAC of a file | ||
|
||
```js | ||
const filename = process.argv[2]; | ||
const crypto = require('crypto'); | ||
const fs = require('fs'); | ||
const hmac = crypto.createHmac('sha256', 'a secret'); | ||
const input = fs.createReadStream(filename); | ||
input.on('readable', () => { | ||
const data = input.read(); | ||
if (data) | ||
hmac.update(data); | ||
else { | ||
console.log(`${hmac.digest('hex')} ${filename}`); | ||
} | ||
}); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- YAML | ||
added: v0.1.92 | ||
--> | ||
- `algorithm` {string} | ||
- `options` {Object} [`stream.Writable` options][] | ||
|
||
Creates and returns a `Sign` object that uses the given `algorithm`. | ||
Use [`crypto.getHashes()`][] to obtain an array of names of the available | ||
signing algorithms. Optional `options` argument controls the | ||
`stream.Writable` behavior. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- YAML | ||
added: v0.1.92 | ||
--> | ||
- `algorithm` {string} | ||
- `options` {Object} [`stream.Writable` options][] | ||
|
||
Creates and returns a `Verify` object that uses the given algorithm. | ||
Use [`crypto.getHashes()`][] to obtain an array of names of the available | ||
signing algorithms. Optional `options` argument controls the | ||
`stream.Writable` behavior. | ||
|
6 changes: 6 additions & 0 deletions
6
deprecations/dep0013_fs_asynchronous_function_without_callback.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
Type: Runtime | ||
|
||
Calling an asynchronous function without a callback is deprecated. | ||
|
||
<a id="DEP0014"></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
|
||
Type: Documentation-only | ||
|
||
`tls.parseCertString()` is a trivial parsing helper that was made public by | ||
mistake. This function can usually be replaced with: | ||
|
||
```js | ||
const querystring = require('querystring'); | ||
querystring.parse(str, '\n', '='); | ||
``` | ||
|
||
*Note*: This function is not completely equivalent to `querystring.parse()`. One | ||
difference is that `querystring.parse()` does url encoding: | ||
|
||
```sh | ||
> querystring.parse('%E5%A5%BD=1', '\n', '='); | ||
{ '好': '1' } | ||
> tls.parseCertString('%E5%A5%BD=1'); | ||
{ '%E5%A5%BD': '1' } | ||
``` | ||
|
||
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size | ||
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array | ||
[`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer | ||
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj | ||
[`Domain.dispose()`]: domain.html#domain_domain_dispose | ||
[`EventEmitter.listenerCount(emitter, eventName)`]: events.html#events_eventemitter_listenercount_emitter_eventname | ||
[`Server.connections`]: net.html#net_server_connections | ||
[`Server.getConnections()`]: net.html#net_server_getconnections_callback | ||
[`Server.listen({fd: <number>})`]: net.html#net_server_listen_handle_backlog_callback | ||
[`SlowBuffer`]: buffer.html#buffer_class_slowbuffer | ||
[`child_process`]: child_process.html | ||
[`console.error()`]: console.html#console_console_error_data_args | ||
[`console.log()`]: console.html#console_console_log_data_args | ||
[`crypto.createCredentials()`]: crypto.html#crypto_crypto_createcredentials_details | ||
[`crypto.pbkdf2()`]: crypto.html#crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback | ||
[`domain`]: domain.html | ||
[`ecdh.setPublicKey()`]: crypto.html#crypto_ecdh_setpublickey_publickey_encoding | ||
[`emitter.listenerCount(eventName)`]: events.html#events_emitter_listenercount_eventname | ||
[`fs.access()`]: fs.html#fs_fs_access_path_mode_callback | ||
[`fs.exists(path, callback)`]: fs.html#fs_fs_exists_path_callback | ||
[`fs.lchmod(path, mode, callback)`]: fs.html#fs_fs_lchmod_path_mode_callback | ||
[`fs.lchmodSync(path, mode)`]: fs.html#fs_fs_lchmodsync_path_mode | ||
[`fs.lchown(path, uid, gid, callback)`]: fs.html#fs_fs_lchown_path_uid_gid_callback | ||
[`fs.lchownSync(path, uid, gid)`]: fs.html#fs_fs_lchownsync_path_uid_gid | ||
[`fs.read()`]: fs.html#fs_fs_read_fd_buffer_offset_length_position_callback | ||
[`fs.readSync()`]: fs.html#fs_fs_readsync_fd_buffer_offset_length_position | ||
[`fs.stat()`]: fs.html#fs_fs_stat_path_callback | ||
[`os.networkInterfaces`]: os.html#os_os_networkinterfaces | ||
[`os.tmpdir()`]: os.html#os_os_tmpdir | ||
[`punycode`]: punycode.html | ||
[`require.extensions`]: modules.html#modules_require_extensions | ||
[`tls.CryptoStream`]: tls.html#tls_class_cryptostream | ||
[`tls.SecureContext`]: tls.html#tls_tls_createsecurecontext_options | ||
[`tls.SecurePair`]: tls.html#tls_class_securepair | ||
[`tls.TLSSocket`]: tls.html#tls_class_tls_tlssocket | ||
[`tls.createSecureContext()`]: tls.html#tls_tls_createsecurecontext_options | ||
[`util._extend()`]: util.html#util_util_extend_target_source | ||
[`util.debug()`]: util.html#util_util_debug_string | ||
[`util.error()`]: util.html#util_util_error_strings | ||
[`util.isArray()`]: util.html#util_util_isarray_object | ||
[`util.isBoolean()`]: util.html#util_util_isboolean_object | ||
[`util.isBuffer()`]: util.html#util_util_isbuffer_object | ||
[`util.isDate()`]: util.html#util_util_isdate_object | ||
[`util.isError()`]: util.html#util_util_iserror_object | ||
[`util.isFunction()`]: util.html#util_util_isfunction_object | ||
[`util.isNull()`]: util.html#util_util_isnull_object | ||
[`util.isNullOrUndefined()`]: util.html#util_util_isnullorundefined_object | ||
[`util.isNumber()`]: util.html#util_util_isnumber_object | ||
[`util.isObject()`]: util.html#util_util_isobject_object | ||
[`util.isPrimitive()`]: util.html#util_util_isprimitive_object | ||
[`util.isRegExp()`]: util.html#util_util_isregexp_object | ||
[`util.isString()`]: util.html#util_util_isstring_object | ||
[`util.isSymbol()`]: util.html#util_util_issymbol_object | ||
[`util.isUndefined()`]: util.html#util_util_isundefined_object | ||
[`util.log()`]: util.html#util_util_log_string | ||
[`util.print()`]: util.html#util_util_print_strings | ||
[`util.puts()`]: util.html#util_util_puts_strings | ||
[`util`]: util.html | ||
[`worker.exitedAfterDisconnect`]: cluster.html#cluster_worker_exitedafterdisconnect | ||
[`worker.suicide`]: cluster.html#cluster_worker_suicide | ||
[alloc]: buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding | ||
[alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size | ||
[from_arraybuffer]: buffer.html#buffer_class_method_buffer_from_arraybuffer_byteoffset_length | ||
[from_string_encoding]: buffer.html#buffer_class_method_buffer_from_string_encoding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
A call on a socket that is not ready to send or no longer open may throw a *Not | ||
running* [`Error`][]. | ||
|
||
If `multicastInterface` can not be parsed into an IP then an *EINVAL* | ||
[`System Error`][] is thrown. | ||
|
||
On IPv4, if `multicastInterface` is a valid address but does not match any | ||
interface, or if the address does not match the family then | ||
a [`System Error`][] such as `EADDRNOTAVAIL` or `EPROTONOSUP` is thrown. | ||
|
||
On IPv6, most errors with specifying or omiting scope will result in the socket | ||
continuing to use (or returning to) the system's default interface selection. | ||
|
||
A socket's address family's ANY address (IPv4 `'0.0.0.0'` or IPv6 `'::'`) can be | ||
used to return control of the sockets default outgoing interface to the system | ||
for future multicast packets. | ||
|
||
|
Oops, something went wrong.