Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion types/node/crypto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,26 @@ declare module 'crypto' {
},
callback: (err: Error | null, key: KeyObject) => void
): void;
/**
* Synchronously generates a new random secret key of the given `length`. The`type` will determine which validations will be performed on the `length`.
*
* ```js
* const {
* generateKeySync
* } = await import('crypto');
*
* const key = generateKeySync('hmac', 64);
* console.log(key.export().toString('hex')); // e89..........41e
* ```
* @since v15.0.0
* @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`.
*/
function generateKeySync(
type: 'hmac' | 'aes',
options: {
length: number;
}
): KeyObject;
interface JsonWebKeyInput {
key: JsonWebKey;
format: 'jwk';
Expand Down Expand Up @@ -2259,7 +2279,7 @@ declare module 'crypto' {
interface X448KeyPairKeyObjectOptions {}
interface ECKeyPairKeyObjectOptions {
/**
* Name of the curve to use.
* Name of the curve to use
*/
namedCurve: string;
}
Expand All @@ -2269,6 +2289,7 @@ declare module 'crypto' {
*/
modulusLength: number;
/**
* Public exponent
* @default 0x10001
*/
publicExponent?: number | undefined;
Expand All @@ -2279,9 +2300,22 @@ declare module 'crypto' {
*/
modulusLength: number;
/**
* Public exponent
* @default 0x10001
*/
publicExponent?: number | undefined;
/**
* Name of the message digest
*/
hashAlgorithm?: string;
/**
* Name of the message digest used by MGF1
*/
mgf1HashAlgorithm?: string;
/**
* Minimal salt length in bytes
*/
saltLength?: string;
}
interface DSAKeyPairKeyObjectOptions {
/**
Expand All @@ -2299,6 +2333,7 @@ declare module 'crypto' {
*/
modulusLength: number;
/**
* Public exponent
* @default 0x10001
*/
publicExponent?: number | undefined;
Expand All @@ -2316,9 +2351,22 @@ declare module 'crypto' {
*/
modulusLength: number;
/**
* Public exponent
* @default 0x10001
*/
publicExponent?: number | undefined;
/**
* Name of the message digest
*/
hashAlgorithm?: string;
/**
* Name of the message digest used by MGF1
*/
mgf1HashAlgorithm?: string;
/**
* Minimal salt length in bytes
*/
saltLength?: string;
publicKeyEncoding: {
type: 'spki';
format: PubF;
Expand Down
14 changes: 8 additions & 6 deletions types/node/fs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ declare module 'fs' {
* Asynchronously creates a directory.
*
* The callback is given a possible exception and, if `recursive` is `true`, the
* first directory path created, `(err, [path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was
* first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was
* created.
*
* The optional `options` argument can be an integer specifying `mode` (permission
Expand Down Expand Up @@ -2215,9 +2215,9 @@ declare module 'fs' {
* If this method is invoked as its `util.promisify()` ed version, it returns
* a promise for an `Object` with `bytesRead` and `buffer` properties.
* @since v0.0.2
* @param [buffer=Buffer.alloc(16384)] The buffer that the data will be written to.
* @param [offset=0] The position in `buffer` to write the data to.
* @param [length=buffer.byteLength] The number of bytes to read.
* @param buffer The buffer that the data will be written to.
* @param offset The position in `buffer` to write the data to.
* @param length The number of bytes to read.
* @param position Specifies where to begin reading from in the file. If `position` is `null` or `-1 `, data will be read from the current file position, and the file position will be updated. If
* `position` is an integer, the file position will be unchanged.
*/
Expand Down Expand Up @@ -3383,7 +3383,8 @@ declare module 'fs' {
* destroyed, like most `Readable` streams. Set the `emitClose` option to`false` to change this behavior.
*
* By providing the `fs` option, it is possible to override the corresponding `fs`implementations for `open`, `read`, and `close`. When providing the `fs` option,
* overrides for `open`, `read`, and `close` are required.
* an override for `read` is required. If no `fd` is provided, an override for`open` is also required. If `autoClose` is `true`, an override for `close` is
* also required.
*
* ```js
* import { createReadStream } from 'fs';
Expand Down Expand Up @@ -3441,7 +3442,8 @@ declare module 'fs' {
*
* By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev` and `close`. Overriding `write()`without `writev()` can reduce
* performance as some optimizations (`_writev()`)
* will be disabled. When providing the `fs` option, overrides for `open`,`close`, and at least one of `write` and `writev` are required.
* will be disabled. When providing the `fs` option, overrides for at least one of`write` and `writev` are required. If no `fd` option is supplied, an override
* for `open` is also required. If `autoClose` is `true`, an override for `close`is also required.
*
* Like `fs.ReadStream`, if `fd` is specified, `fs.WriteStream` will ignore the`path` argument and will use the specified file descriptor. This means that no`'open'` event will be
* emitted. `fd` should be blocking; non-blocking `fd`s
Expand Down
4 changes: 2 additions & 2 deletions types/node/fs/promises.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ declare module 'fs/promises' {
* number of bytes read is zero.
* @since v10.0.0
* @param buffer A buffer that will be filled with the file data read.
* @param [offset=0] The location in the buffer at which to start filling.
* @param [length=buffer.byteLength] The number of bytes to read.
* @param offset The location in the buffer at which to start filling.
* @param length The number of bytes to read.
* @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an
* integer, the current file position will remain unchanged.
* @return Fulfills upon success with an object with two properties:
Expand Down
16 changes: 13 additions & 3 deletions types/node/http.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ declare module 'http' {
* @since v0.7.0
*/
maxHeadersCount: number | null;
/**
* The maximum number of requests socket can handle
* before closing keep alive connection.
*
* A value of `null` will disable the limit.
*
* When limit is reach it will set `Connection` header value to `closed`,
* but will not actually close the connection, subsequent requests sent
* after the limit is reached will get `503 Service Unavailable` as a response.
* @since v16.10.0
*/
maxRequestsPerSocket: number | null;
/**
* The number of milliseconds of inactivity before a socket is presumed
* to have timed out.
Expand Down Expand Up @@ -341,11 +353,9 @@ declare module 'http' {
readonly socket: Socket | null;
constructor();
/**
* occurs, Same as binding to the `timeout` event.
*
* Once a socket is associated with the message and is connected,`socket.setTimeout()` will be called with `msecs` as the first parameter.
* @since v0.9.12
* @param callback Optional function to be called when a timeout
* @param callback Optional function to be called when a timeout occurs. Same as binding to the `timeout` event.
*/
setTimeout(msecs: number, callback?: () => void): this;
/**
Expand Down
3 changes: 1 addition & 2 deletions types/node/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for non-npm package Node.js 16.9
// Type definitions for non-npm package Node.js 16.10
// Project: https://nodejs.org/
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
// DefinitelyTyped <https://github.com/DefinitelyTyped>
Expand Down Expand Up @@ -37,7 +37,6 @@
// Surasak Chaisurin <https://github.com/Ryan-Willpower>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Anna Henningsen <https://github.com/addaleax>
// Jason Kwok <https://github.com/JasonHK>
// Victor Perin <https://github.com/victorperin>
// Yongsheng Zhang <https://github.com/ZYSzys>
// NodeJS Contributors <https://github.com/NodeJS>
Expand Down
32 changes: 26 additions & 6 deletions types/node/stream.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1083,16 +1083,14 @@ declare module 'stream' {
*
* async function run() {
* const ac = new AbortController();
* const options = {
* signal: ac.signal,
* };
* const signal = ac.signal;
*
* setTimeout(() => ac.abort(), 1);
* await pipeline(
* fs.createReadStream('archive.tar'),
* zlib.createGzip(),
* fs.createWriteStream('archive.tar.gz'),
* options,
* { signal },
* );
* }
*
Expand All @@ -1108,10 +1106,10 @@ declare module 'stream' {
* async function run() {
* await pipeline(
* fs.createReadStream('lowercase.txt'),
* async function* (source) {
* async function* (source, signal) {
* source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
* for await (const chunk of source) {
* yield chunk.toUpperCase();
* yield await processChunk(chunk, { signal });
* }
* },
* fs.createWriteStream('uppercase.txt')
Expand All @@ -1122,6 +1120,28 @@ declare module 'stream' {
* run().catch(console.error);
* ```
*
* Remember to handle the `signal` argument passed into the async generator.
* Especially in the case where the async generator is the source for the
* pipeline (i.e. first argument) or the pipeline will never complete.
*
* ```js
* const { pipeline } = require('stream/promises');
* const fs = require('fs');
*
* async function run() {
* await pipeline(
* async function * (signal) {
* await someLongRunningfn({ signal });
* yield 'asd';
* },
* fs.createWriteStream('uppercase.txt')
* );
* console.log('Pipeline succeeded.');
* }
*
* run().catch(console.error);
* ```
*
* `stream.pipeline()` will call `stream.destroy(err)` on all streams except:
*
* * `Readable` streams which have emitted `'end'` or `'close'`.
Expand Down
4 changes: 4 additions & 0 deletions types/node/test/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1273,3 +1273,7 @@ import { promisify } from 'node:util';
// tslint:disable-next-line no-object-literal-type-assertion (webcrypto.CryptoKey is a placeholder)
crypto.KeyObject.from({} as crypto.webcrypto.CryptoKey); // $ExpectType KeyObject
}

{
crypto.generateKeySync('aes', { length: 128 }); // $ExpectType KeyObject
}
1 change: 1 addition & 0 deletions types/node/test/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import * as net from 'node:net';

// test public props
const maxHeadersCount: number | null = server.maxHeadersCount;
const maxRequestsPerSocket: number | null = server.maxRequestsPerSocket;
const headersTimeout: number = server.headersTimeout;
const timeout: number = server.timeout;
const listening: boolean = server.listening;
Expand Down
1 change: 1 addition & 0 deletions types/node/test/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import * as url from 'node:url';
const listening: boolean = server.listening;
const keepAliveTimeout: number = server.keepAliveTimeout;
const maxHeadersCount: number | null = server.maxHeadersCount;
const maxRequestsPerSocket: number | null = server.maxRequestsPerSocket;
const headersTimeout: number = server.headersTimeout;
server.setTimeout().setTimeout(1000).setTimeout(() => {}).setTimeout(100, () => {});
}
Expand Down
4 changes: 1 addition & 3 deletions types/node/tty.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ declare module 'tty' {
* * `1` for 2,
* * `4` for 16,
* * `8` for 256,
* * `24` for 16,777,216
*
* colors supported.
* * `24` for 16,777,216 colors supported.
*
* Use this to determine what colors the terminal supports. Due to the nature of
* colors in terminals it is possible to either have false positives or false
Expand Down
1 change: 0 additions & 1 deletion types/node/v12/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
// Junxiao Shi <https://github.com/yoursunny>
// Ilia Baryshnikov <https://github.com/qwelias>
// ExE Boss <https://github.com/ExE-Boss>
// Jason Kwok <https://github.com/JasonHK>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

// NOTE: These definitions support NodeJS and TypeScript 3.7.
Expand Down
1 change: 0 additions & 1 deletion types/node/v14/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
// Surasak Chaisurin <https://github.com/Ryan-Willpower>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Anna Henningsen <https://github.com/addaleax>
// Jason Kwok <https://github.com/JasonHK>
// Victor Perin <https://github.com/victorperin>
// Yongsheng Zhang <https://github.com/ZYSzys>
// Bond <https://github.com/bondz>
Expand Down
Loading