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
2 changes: 1 addition & 1 deletion types/express-serve-static-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ export interface Response<
* After middleware.init executed, Response will contain req property
* See: express/lib/middleware/init.js
*/
req?: Request;
req: Request;
}

export interface Handler extends RequestHandler {}
Expand Down
2 changes: 1 addition & 1 deletion types/express-serve-static-core/ts4.0/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ export interface Response<
* After middleware.init executed, Response will contain req property
* See: express/lib/middleware/init.js
*/
req?: Request;
req: Request;
}

export interface Handler extends RequestHandler {}
Expand Down
62 changes: 62 additions & 0 deletions types/node/buffer.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
declare module 'buffer' {
import { BinaryLike } from 'crypto';

export const INSPECT_MAX_BYTES: number;
export const kMaxLength: number;
export const kStringMaxLength: number;
Expand All @@ -19,4 +21,64 @@ declare module 'buffer' {
};

export { BuffType as Buffer };

/**
* @experimental
*/
export interface BlobOptions {
/**
* @default 'utf8'
*/
encoding?: BufferEncoding;

/**
* The Blob content-type. The intent is for `type` to convey
* the MIME media type of the data, however no validation of the type format
* is performed.
*/
type?: string;
}

/**
* @experimental
*/
export class Blob {
/**
* Returns a promise that fulfills with an {ArrayBuffer} containing a copy of the `Blob` data.
*/
readonly size: number;

/**
* The content-type of the `Blob`.
*/
readonly type: string;

/**
* Creates a new `Blob` object containing a concatenation of the given sources.
*
* {ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into
* the 'Blob' and can therefore be safely modified after the 'Blob' is created.
*
* String sources are also copied into the `Blob`.
*/
constructor(sources: Array<(BinaryLike | Blob)>, options?: BlobOptions);

arrayBuffer(): Promise<ArrayBuffer>;

/**
* @param start The starting index.
* @param end The ending index.
* @param type The content-type for the new `Blob`
*/
slice(start?: number, end?: number, type?: string): Blob;

/**
* Returns a promise that resolves the contents of the `Blob` decoded as a UTF-8 string.
*/
text(): Promise<string>;
}
}

declare module 'node:buffer' {
export * from 'buffer';
}
77 changes: 70 additions & 7 deletions types/node/crypto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,8 @@ declare module 'crypto' {
* 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 `key` is not a `KeyObject`, this function behaves as if `key` had been
* passed to `crypto.createPrivateKey().
*/
function sign(
algorithm: string | null | undefined,
Expand All @@ -1177,8 +1177,8 @@ declare module 'crypto' {
* 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 `key` is not a `KeyObject`, this function behaves as if `key` had been
* passed to `crypto.createPublicKey()`.
*/
function verify(
algorithm: string | null | undefined,
Expand Down Expand Up @@ -1254,7 +1254,7 @@ declare module 'crypto' {
*
* 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`][].
* The successfully generated `derivedKey` will be passed to the callback as an `ArrayBuffer`.
* An error will be thrown if any of the input aguments specify invalid values or types.
*/
function hkdf(digest: string, key: BinaryLike | KeyObject, salt: BinaryLike, info: BinaryLike, keylen: number, callback: (err: Error | null, derivedKey: ArrayBuffer) => any): void;
Expand All @@ -1263,7 +1263,7 @@ declare module 'crypto' {
* Provides a synchronous HKDF key derivation function as defined in RFC 5869.
* The given `key`, `salt` and `info` are used with the `digest` to derive a key of `keylen` bytes.
*
* The successfully generated `derivedKey` will be returned as an [`ArrayBuffer`][].
* The successfully generated `derivedKey` will be returned as an `ArrayBuffer`.
* An error will be thrown if any of the input aguments specify invalid values or types,
* or if the derived key cannot be generated.
*/
Expand Down Expand Up @@ -1372,6 +1372,16 @@ declare module 'crypto' {
*/
readonly keyUsage: string[];

/**
* The issuer identification included in this certificate.
*/
readonly issuer: string;

/**
* The issuer certificate or `undefined` if the issuer certificate is not available.
*/
readonly issuerCertificate?: X509Certificate;

/**
* The public key for this certificate.
*/
Expand Down Expand Up @@ -1438,7 +1448,7 @@ declare module 'crypto' {
toJSON(): string;

/**
* Returns information about this certificate using the legacy [certificate object][] encoding.
* Returns information about this certificate using the legacy certificate object encoding.
*/
toLegacyObject(): PeerCertificate;

Expand All @@ -1453,4 +1463,57 @@ declare module 'crypto' {
*/
verify(publicKey: KeyObject): boolean;
}

type LargeNumberLike = NodeJS.ArrayBufferView | SharedArrayBuffer | ArrayBuffer | bigint;

interface GeneratePrimeOptions {
add?: LargeNumberLike;
rem?: LargeNumberLike;
/**
* @default false
*/
safe?: boolean;
bigint?: boolean;
}

interface GeneratePrimeOptionsBigInt extends GeneratePrimeOptions {
bigint: true;
}

interface GeneratePrimeOptionsArrayBuffer extends GeneratePrimeOptions {
bigint?: false;
}

function generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
function generatePrime(size: number, options: GeneratePrimeOptionsBigInt, callback: (err: Error | null, prime: bigint) => void): void;
function generatePrime(size: number, options: GeneratePrimeOptionsArrayBuffer, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
function generatePrime(size: number, options: GeneratePrimeOptions, callback: (err: Error | null, prime: ArrayBuffer | bigint) => void): void;

function generatePrimeSync(size: number): ArrayBuffer;
function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
function generatePrimeSync(size: number, options: GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
function generatePrimeSync(size: number, options: GeneratePrimeOptions): ArrayBuffer | bigint;

interface CheckPrimeOptions {
/**
* 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-64 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 options for more details.
*
* @default 0
*/
checks?: number;
}

/**
* Checks the primality of the candidate.
*/
function checkPrime(value: LargeNumberLike, callback: (err: Error | null, result: boolean) => void): void;
function checkPrime(value: LargeNumberLike, options: CheckPrimeOptions, callback: (err: Error | null, result: boolean) => void): void;

/**
* Checks the primality of the candidate.
*/
function checkPrimeSync(value: LargeNumberLike, options?: CheckPrimeOptions): boolean;
}
4 changes: 2 additions & 2 deletions types/node/dgram.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare module 'dgram' {
import { AddressInfo } from 'net';
import * as dns from 'dns';
import EventEmitter = require('events');
import { EventEmitter, Abortable } from 'events';

interface RemoteInfo {
address: string;
Expand All @@ -19,7 +19,7 @@ declare module 'dgram' {

type SocketType = "udp4" | "udp6";

interface SocketOptions {
interface SocketOptions extends Abortable {
type: SocketType;
reuseAddr?: boolean;
/**
Expand Down
Loading