diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ead0547a6294b7..9525e6a1fb9768 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -270,7 +270,7 @@ /types/apidoc/ @rigwild @hoonga @NicolasCARPi /types/apigee-access/ @CasperSkydt /types/apimocker/ @uchilaka -/types/apollo-upload-client/ @Slessi @tyankatsu0105 +/types/apollo-upload-client/ @tyankatsu0105 /types/apostrophe/ @afholderman /types/app-module-path/ @darkwebdev /types/appcache-webpack-plugin/ @peterblazejewicz @@ -302,7 +302,6 @@ /types/are.na/ @huntercaron /types/argon2-browser/ @ivangabriele @mymindstorm @jdforsythe /types/argparse/ @arcticwaters @tlaziuk @eps1lon @cakoose @ondkloss @doberkofler -/types/args/ @Slessi /types/argv/ @hookclaw /types/ari-client/ @dioris-moreno /types/aria-query/ @eps1lon @@ -310,7 +309,6 @@ /types/arr-union/ @mrmlnc /types/array-binarysearch.closest/ @hvoecking /types/array-bounds/ @BendingBender -/types/array-equal/ @MysteryBlokHed /types/array-find-index/ @samverschueren /types/array-foreach/ @skysteve /types/array-initial/ @Richienb @@ -442,7 +440,6 @@ /types/babel-plugin-react-html-attrs/ @insin /types/babel-plugin-react-pug/ @jpap /types/babel-plugin-syntax-jsx/ @marvinhagemeister -/types/babel-plugin-tester/ @ifiokjr @mathieutu /types/babel-template/ @yortus @marvinhagemeister /types/babel-traverse/ @yortus @marvinhagemeister @rpetrich /types/babel-types/ @yortus @baxtersa @marvinhagemeister @bcherny @ExE-Boss @@ -1489,7 +1486,6 @@ /types/dexie-batch/ @ffflorian /types/df-visible/ @Litee /types/dhtmlxgantt/ @mkozhukh @chriscamicas -/types/dhtmlxscheduler/ @mkozhukh /types/di/ @johnjbarton /types/di-lite/ @dcrusader /types/diacritics/ @otociulis @@ -2003,7 +1999,7 @@ /types/extjs/ @brian428 /types/extra-watch-webpack-plugin/ @davecardwell /types/extract-domain/ @peterblazejewicz -/types/extract-files/ @Slessi @lynxtaa +/types/extract-files/ @lynxtaa /types/extract-text-webpack-plugin/ @flying-sheep @katyo /types/eyes/ @brynbellomy /types/eyevinn-iaf/ @birme @oscnord @@ -3340,7 +3336,6 @@ /types/imagesloaded/ @apexskier /types/imap/ @psnider /types/imap-simple/ @pushplay @iaarnio -/types/imapflow/ @jeffreyratton98 @martin-badin @grayson-code @remscar /types/img-clipboard/ @Nigecat /types/imgur-rest-api/ @lukewestby /types/immediate/ @BendingBender @@ -3413,7 +3408,7 @@ /types/intro.js/ @anahkiasen @LeonMontealegre @vkrol /types/invariant/ @bennett000 @dtinth @turadg /types/inversify-devtools/ @inversify -/types/invity-api/ @martinboehm @LukasRada +/types/invity-api/ @FreeWall @tomasklim @vytick /types/ion-rangeslider/ @Karel-van-de-Plassche /types/ion-rangeslider/v1/ @dduugg @Karel-van-de-Plassche /types/iopipe__iopipe/ @javonharper @@ -3422,7 +3417,6 @@ /types/iota.lib.js/ @fogsh /types/ip/ @codeanimal @BendingBender /types/ip-packet/ @BendingBender -/types/ip-subnet-calculator/ @dahool /types/ip-to-int/ @yutak23 /types/ip1sms__is-disposable-phone-number/ @ziishaned /types/ip6addr/ @slaweet @@ -3610,7 +3604,6 @@ /types/josa/ @vichyssoise /types/jotform-css.js/ @pandawood /types/jp-conversion/ @NicolasNewman -/types/jpeg-autorotate/ @Slessi /types/jpegtran-bin/ @hikoma /types/jqgrid/ @lokeshpeta /types/jqrangeslider/ @qcz @@ -4238,7 +4231,6 @@ /types/librato-node/ @jgeurts /types/libsodium-wrappers/ @ffflorian /types/libsodium-wrappers-sumo/ @ffflorian -/types/libxmljs/ @fdecampredon @ComFreek /types/libxslt/ @alejo90 @daniel-pedersen /types/license-checker/ @rogierschouten @unindented @alechemy /types/license-key-gen/ @abh80 @@ -6433,7 +6425,6 @@ /types/react-native-modalbox/ @iRoachie /types/react-native-modals/ @PaitoAnderson @jbcrestot /types/react-native-modern-datepicker/ @Ankan002 -/types/react-native-multi-slider/ @Slessi /types/react-native-navbar/ @ryokik /types/react-native-onboarding-swiper/ @zhirzh @yek-plus /types/react-native-orientation/ @MoLow @@ -7096,7 +7087,6 @@ /types/search-index/ @TravisYeah @thehenrytsai /types/searchjs/ @iammerus /types/season/ @dex4er -/types/secp256k1/ @anler /types/secret-blob/ @BendingBender /types/secret-box/ @BendingBender /types/secretbox-encoding/ @BendingBender @@ -7162,6 +7152,7 @@ /types/semver-utils/ @JamieMagee /types/sencha_touch/ @brian428 /types/send/ @MikeJerred @peterblazejewicz @bjohansebas +/types/send/v0/ @MikeJerred @peterblazejewicz @bjohansebas /types/sendcloud/ @bangbang93 /types/sendmail/ @saostad /types/sendsay-api/ @T0R0NT0T0KY0 @@ -7490,14 +7481,13 @@ /types/stdin/ @g-rath /types/stdout-stream/ @yoursunny /types/steam/ @kant2002 -/types/steam-client/ @Slessi /types/steam-login/ @Nicell /types/steam-totp/ @phenomax @dsyncerek /types/steam-tradeoffer-manager/ @kldzj @kjsmita6 /types/steam-user/ @joshuajeschek /types/steamapi/ @joshuajeschek @claabs /types/steamcommunity/ @SenTisso -/types/steamid/ @Slessi @joshuajeschek +/types/steamid/ @joshuajeschek /types/steed/ @Paul-Isache /types/steelseries/ @ricky-rebo /types/stegcloak/ @ktjd123 @@ -8302,7 +8292,7 @@ /types/webcl/ @NCARalph /types/webcomponents.js/ @adidahiya /types/webcrypto/ @iislucas -/types/webextension-polyfill/ @Lusito @mnoorenberghe +/types/webextension-polyfill/ @Lusito @mnoorenberghe @josh-berry /types/webfontloader/ @sectsect /types/webgl-ext/ @zenmumbler /types/webgl2/ @nkemnitz @karhu diff --git a/types/node/crypto.d.ts b/types/node/crypto.d.ts index 19ca6c7f919ab0..73e39d30a7900a 100644 --- a/types/node/crypto.d.ts +++ b/types/node/crypto.d.ts @@ -591,21 +591,8 @@ declare module "crypto" { */ static from(key: webcrypto.CryptoKey): KeyObject; /** - * 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) - * * `'dh'` (OID 1.2.840.113549.1.3.1) - * * `'ml-dsa-44'` (OID 2.16.840.1.101.3.4.3.17) - * * `'ml-dsa-65'` (OID 2.16.840.1.101.3.4.3.18) - * * `'ml-dsa-87'` (OID 2.16.840.1.101.3.4.3.19) + * For asymmetric keys, this property represents the type of the key. See the + * supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types). * * This property is `undefined` for unrecognized `KeyObject` types and symmetric * keys. @@ -2460,17 +2447,21 @@ declare module "crypto" { */ function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean; type KeyType = - | "rsa" - | "rsa-pss" + | "dh" | "dsa" | "ec" | "ed25519" | "ed448" - | "x25519" - | "x448" | "ml-dsa-44" | "ml-dsa-65" - | "ml-dsa-87"; + | "ml-dsa-87" + | "ml-kem-1024" + | "ml-kem-512" + | "ml-kem-768" + | "rsa-pss" + | "rsa" + | "x25519" + | "x448"; type KeyFormat = "pem" | "der" | "jwk"; interface BasePrivateKeyEncodingOptions { format: T; @@ -2486,6 +2477,7 @@ declare module "crypto" { interface X25519KeyPairKeyObjectOptions {} interface X448KeyPairKeyObjectOptions {} interface MLDSAKeyPairKeyObjectOptions {} + interface MLKEMKeyPairKeyObjectOptions {} interface ECKeyPairKeyObjectOptions { /** * Name of the curve to use @@ -2659,6 +2651,15 @@ declare module "crypto" { type: "pkcs8"; }; } + interface MLKEMKeyPairOptions { + publicKeyEncoding: { + type: "spki"; + format: PubF; + }; + privateKeyEncoding: BasePrivateKeyEncodingOptions & { + type: "pkcs8"; + }; + } interface KeyPairSyncResult { publicKey: T1; privateKey: T2; @@ -2702,8 +2703,8 @@ declare module "crypto" { * When PEM encoding was selected, the respective key will be a string, otherwise * it will be a buffer containing the data encoded as DER. * @since v10.12.0 - * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, - * `'ed448'`, `'x25519'`, `'x448'`, `'dh'`, `'ml-dsa-44'`, `'ml-dsa-65'`, or `'ml-dsa-87'`. + * @param type The asymmetric key type to generate. See the + * supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types). */ function generateKeyPairSync( type: "rsa", @@ -2861,6 +2862,26 @@ declare module "crypto" { type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87", options?: MLDSAKeyPairKeyObjectOptions, ): KeyPairKeyObjectResult; + function generateKeyPairSync( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"pem", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"pem", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"der", "pem">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"der", "der">, + ): KeyPairSyncResult; + function generateKeyPairSync( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options?: MLKEMKeyPairKeyObjectOptions, + ): KeyPairKeyObjectResult; /** * Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC, * Ed25519, Ed448, X25519, X448, and DH are currently supported. @@ -2898,8 +2919,8 @@ declare module "crypto" { * If this method is invoked as its `util.promisify()` ed version, it returns * a `Promise` for an `Object` with `publicKey` and `privateKey` properties. * @since v10.12.0 - * @param type Must be `'rsa'`, `'rsa-pss'`, `'dsa'`, `'ec'`, `'ed25519'`, - * `'ed448'`, `'x25519'`, `'x448'`, `'dh'`, `'ml-dsa-44'`, `'ml-dsa-65'`, or `'ml-dsa-87'`. + * @param type The asymmetric key type to generate. See the + * supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types). */ function generateKeyPair( type: "rsa", @@ -3126,6 +3147,31 @@ declare module "crypto" { options: MLDSAKeyPairKeyObjectOptions | undefined, callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, ): void; + function generateKeyPair( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"pem", "pem">, + callback: (err: Error | null, publicKey: string, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"pem", "der">, + callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"der", "pem">, + callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void, + ): void; + function generateKeyPair( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"der", "der">, + callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void, + ): void; + function generateKeyPair( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairKeyObjectOptions | undefined, + callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void, + ): void; namespace generateKeyPair { function __promisify__( type: "rsa", @@ -3400,6 +3446,38 @@ declare module "crypto" { type: "ml-dsa-44" | "ml-dsa-65" | "ml-dsa-87", options?: MLDSAKeyPairKeyObjectOptions, ): Promise; + function __promisify__( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"pem", "pem">, + ): Promise<{ + publicKey: string; + privateKey: string; + }>; + function __promisify__( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"pem", "der">, + ): Promise<{ + publicKey: string; + privateKey: Buffer; + }>; + function __promisify__( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"der", "pem">, + ): Promise<{ + publicKey: Buffer; + privateKey: string; + }>; + function __promisify__( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options: MLKEMKeyPairOptions<"der", "der">, + ): Promise<{ + publicKey: Buffer; + privateKey: Buffer; + }>; + function __promisify__( + type: "ml-kem-1024" | "ml-kem-512" | "ml-kem-768", + options?: MLKEMKeyPairKeyObjectOptions, + ): Promise; } /** * Calculates and returns the signature for `data` using the given private key and @@ -3461,9 +3539,37 @@ declare module "crypto" { callback: (error: Error | null, result: boolean) => void, ): void; /** - * 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'` - * (for Diffie-Hellman), `'ec'`, `'x448'`, or `'x25519'` (for ECDH). + * Key decapsulation using a KEM algorithm with a private key. + * + * Supported key types and their KEM algorithms are: + * + * * `'rsa'` RSA Secret Value Encapsulation + * * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256) + * * `'x25519'` DHKEM(X25519, HKDF-SHA256) + * * `'x448'` DHKEM(X448, HKDF-SHA512) + * * `'ml-kem-512'` ML-KEM + * * `'ml-kem-768'` ML-KEM + * * `'ml-kem-1024'` ML-KEM + * + * If `key` is not a {@link KeyObject}, this function behaves as if `key` had been + * passed to `crypto.createPrivateKey()`. + * + * If the `callback` function is provided this function uses libuv's threadpool. + * @since v24.7.0 + */ + function decapsulate( + key: KeyLike | PrivateKeyInput | JsonWebKeyInput, + ciphertext: ArrayBuffer | NodeJS.ArrayBufferView, + ): Buffer; + function decapsulate( + key: KeyLike | PrivateKeyInput | JsonWebKeyInput, + ciphertext: ArrayBuffer | NodeJS.ArrayBufferView, + callback: (err: Error, sharedKey: Buffer) => void, + ): void; + /** + * Computes the Diffie-Hellman shared secret based on a `privateKey` and a `publicKey`. + * Both keys must have the same `asymmetricKeyType` and must support either the DH or + * ECDH operation. * * If the `callback` function is provided this function uses libuv's threadpool. * @since v13.9.0, v12.17.0 @@ -3473,6 +3579,30 @@ declare module "crypto" { options: { privateKey: KeyObject; publicKey: KeyObject }, callback: (err: Error | null, secret: Buffer) => void, ): void; + /** + * Key encapsulation using a KEM algorithm with a public key. + * + * Supported key types and their KEM algorithms are: + * + * * `'rsa'` RSA Secret Value Encapsulation + * * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256) + * * `'x25519'` DHKEM(X25519, HKDF-SHA256) + * * `'x448'` DHKEM(X448, HKDF-SHA512) + * * `'ml-kem-512'` ML-KEM + * * `'ml-kem-768'` ML-KEM + * * `'ml-kem-1024'` ML-KEM + * + * If `key` is not a {@link KeyObject}, this function behaves as if `key` had been + * passed to `crypto.createPublicKey()`. + * + * If the `callback` function is provided this function uses libuv's threadpool. + * @since v24.7.0 + */ + function encapsulate(key: KeyLike | PublicKeyInput | JsonWebKeyInput): { sharedKey: Buffer; ciphertext: Buffer }; + function encapsulate( + key: KeyLike | PublicKeyInput | JsonWebKeyInput, + callback: (err: Error, result: { sharedKey: Buffer; ciphertext: Buffer }) => void, + ): void; interface OneShotDigestOptions { /** * Encoding used to encode the returned digest. @@ -4115,6 +4245,130 @@ declare module "crypto" { * @return Returns `typedArray`. */ function getRandomValues(typedArray: T): T; + type Argon2Algorithm = "argon2d" | "argon2i" | "argon2id"; + interface Argon2Parameters { + /** + * REQUIRED, this is the password for password hashing applications of Argon2. + */ + message: string | ArrayBuffer | NodeJS.ArrayBufferView; + /** + * REQUIRED, must be at least 8 bytes long. This is the salt for password hashing applications of Argon2. + */ + nonce: string | ArrayBuffer | NodeJS.ArrayBufferView; + /** + * REQUIRED, degree of parallelism determines how many computational chains (lanes) + * can be run. Must be greater than 1 and less than `2**24-1`. + */ + parallelism: number; + /** + * REQUIRED, the length of the key to generate. Must be greater than 4 and + * less than `2**32-1`. + */ + tagLength: number; + /** + * REQUIRED, memory cost in 1KiB blocks. Must be greater than + * `8 * parallelism` and less than `2**32-1`. The actual number of blocks is rounded + * down to the nearest multiple of `4 * parallelism`. + */ + memory: number; + /** + * REQUIRED, number of passes (iterations). Must be greater than 1 and less + * than `2**32-1`. + */ + passes: number; + /** + * OPTIONAL, Random additional input, + * similar to the salt, that should **NOT** be stored with the derived key. This is known as pepper in + * password hashing applications. If used, must have a length not greater than `2**32-1` bytes. + */ + secret?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined; + /** + * OPTIONAL, Additional data to + * be added to the hash, functionally equivalent to salt or secret, but meant for + * non-random data. If used, must have a length not greater than `2**32-1` bytes. + */ + associatedData?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined; + } + /** + * Provides an asynchronous [Argon2](https://www.rfc-editor.org/rfc/rfc9106.html) implementation. Argon2 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 `nonce` should be as unique as possible. It is recommended that a nonce is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `message`, `nonce`, `secret` or `associatedData`, please + * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v24.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis). + * + * 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. + * + * ```js + * const { argon2, randomBytes } = await import('node:crypto'); + * + * const parameters = { + * message: 'password', + * nonce: randomBytes(16), + * parallelism: 4, + * tagLength: 64, + * memory: 65536, + * passes: 3, + * }; + * + * argon2('argon2id', parameters, (err, derivedKey) => { + * if (err) throw err; + * console.log(derivedKey.toString('hex')); // 'af91dad...9520f15' + * }); + * ``` + * @since v24.7.0 + * @param algorithm Variant of Argon2, one of `"argon2d"`, `"argon2i"` or `"argon2id"`. + * @experimental + */ + function argon2( + algorithm: Argon2Algorithm, + parameters: Argon2Parameters, + callback: (err: Error | null, derivedKey: Buffer) => void, + ): void; + /** + * Provides a synchronous [Argon2][] implementation. Argon2 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 `nonce` should be as unique as possible. It is recommended that a nonce is + * random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details. + * + * When passing strings for `message`, `nonce`, `secret` or `associatedData`, please + * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v24.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis). + * + * 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. + * + * ```js + * const { argon2Sync, randomBytes } = await import('node:crypto'); + * + * const parameters = { + * message: 'password', + * nonce: randomBytes(16), + * parallelism: 4, + * tagLength: 64, + * memory: 65536, + * passes: 3, + * }; + * + * const derivedKey = argon2Sync('argon2id', parameters); + * console.log(derivedKey.toString('hex')); // 'af91dad...9520f15' + * ``` + * @since v24.7.0 + * @experimental + */ + function argon2Sync(algorithm: Argon2Algorithm, parameters: Argon2Parameters): Buffer; /** * A convenient alias for `crypto.webcrypto.subtle`. * @since v17.4.0 @@ -4129,21 +4383,30 @@ declare module "crypto" { const webcrypto: webcrypto.Crypto; namespace webcrypto { type BufferSource = ArrayBufferView | ArrayBuffer; - type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki"; + type KeyFormat = "jwk" | "pkcs8" | "raw" | "raw-public" | "raw-secret" | "raw-seed" | "spki"; type KeyType = "private" | "public" | "secret"; type KeyUsage = - | "decrypt" - | "deriveBits" - | "deriveKey" | "encrypt" + | "decrypt" | "sign" - | "unwrapKey" | "verify" - | "wrapKey"; + | "deriveKey" + | "deriveBits" + | "encapsulateBits" + | "decapsulateBits" + | "encapsulateKey" + | "decapsulateKey" + | "wrapKey" + | "unwrapKey"; type AlgorithmIdentifier = Algorithm | string; type HashAlgorithmIdentifier = AlgorithmIdentifier; type NamedCurve = string; type BigInteger = Uint8Array; + interface AeadParams extends Algorithm { + additionalData?: BufferSource; + iv: BufferSource; + tagLength: number; + } interface AesCbcParams extends Algorithm { iv: BufferSource; } @@ -4154,6 +4417,8 @@ declare module "crypto" { interface AesDerivedKeyParams extends Algorithm { length: number; } + // TODO: remove in next major + /** @deprecated Replaced by `AeadParams`. */ interface AesGcmParams extends Algorithm { additionalData?: BufferSource; iv: BufferSource; @@ -4168,6 +4433,14 @@ declare module "crypto" { interface Algorithm { name: string; } + interface CShakeParams extends Algorithm { + customization?: BufferSource; + functionName?: BufferSource; + length: number; + } + interface ContextParams extends Algorithm { + context?: BufferSource; + } interface EcKeyAlgorithm extends KeyAlgorithm { namedCurve: NamedCurve; } @@ -4279,22 +4552,15 @@ declare module "crypto" { * An error will be thrown if the given `typedArray` is larger than 65,536 bytes. * @since v15.0.0 */ - getRandomValues>(typedArray: T): T; + getRandomValues>( + typedArray: T, + ): T; /** * Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID. * The UUID is generated using a cryptographic pseudorandom number generator. * @since v16.7.0 */ randomUUID(): UUID; - CryptoKey: CryptoKeyConstructor; - } - // This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable. - interface CryptoKeyConstructor { - /** Illegal constructor */ - (_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user. - readonly length: 0; - readonly name: "CryptoKey"; - readonly prototype: CryptoKey; } /** * @since v15.0.0 @@ -4349,10 +4615,50 @@ declare module "crypto" { */ publicKey: CryptoKey; } + interface EncapsulatedBits { + sharedKey: ArrayBuffer; + ciphertext: ArrayBuffer; + } + interface EncapsulatedKey { + sharedKey: CryptoKey; + ciphertext: ArrayBuffer; + } /** * @since v15.0.0 */ interface SubtleCrypto { + /** + * The algorithms currently supported include: + * + * * `'ML-KEM-512'` + * * `'ML-KEM-768'` + * * `'ML-KEM-1024'` + * @since v24.7.0 + * @returns Fulfills with `ArrayBuffer` upon success. + */ + decapsulateBits( + decapsulationAlgorithm: AlgorithmIdentifier, + decapsulationKey: CryptoKey, + ciphertext: BufferSource, + ): Promise; + /** + * The algorithms currently supported include: + * + * * `'ML-KEM-512'` + * * `'ML-KEM-768'` + * * `'ML-KEM-1024'` + * @since v24.7.0 + * @param usages See [Key usages](https://nodejs.org/docs/latest-v24.x/api/webcrypto.html#cryptokeyusages). + * @returns Fulfills with `CryptoKey` upon success. + */ + decapsulateKey( + decapsulationAlgorithm: AlgorithmIdentifier, + decapsulationKey: CryptoKey, + ciphertext: BufferSource, + sharedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams, + extractable: boolean, + usages: KeyUsage[], + ): Promise; /** * Using the method and parameters specified in `algorithm` and the keying material provided by `key`, * `subtle.decrypt()` attempts to decipher the provided `data`. If successful, @@ -4360,14 +4666,16 @@ declare module "crypto" { * * The algorithms currently supported include: * - * - `'RSA-OAEP'` - * - `'AES-CTR'` - * - `'AES-CBC'` - * - `'AES-GCM'` + * * `'AES-CBC'` + * * `'AES-CTR'` + * * `'AES-GCM'` + * * `'AES-OCB'` + * * `'ChaCha20-Poly1305'` + * * `'RSA-OAEP'` * @since v15.0.0 */ decrypt( - algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams, key: CryptoKey, data: BufferSource, ): Promise; @@ -4381,11 +4689,11 @@ declare module "crypto" { * * The algorithms currently supported include: * - * - `'ECDH'` - * - `'X25519'` - * - `'X448'` - * - `'HKDF'` - * - `'PBKDF2'` + * * `'ECDH'` + * * `'HKDF'` + * * `'PBKDF2'` + * * `'X25519'` + * * `'X448'` * @since v15.0.0 */ deriveBits( @@ -4407,11 +4715,11 @@ declare module "crypto" { * * The algorithms currently supported include: * - * - `'ECDH'` - * - `'X25519'` - * - `'X448'` - * - `'HKDF'` - * - `'PBKDF2'` + * * `'ECDH'` + * * `'HKDF'` + * * `'PBKDF2'` + * * `'X25519'` + * * `'X448'` * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. * @since v15.0.0 */ @@ -4428,15 +4736,50 @@ declare module "crypto" { * * If `algorithm` is provided as a ``, it must be one of: * - * - `'SHA-1'` - * - `'SHA-256'` - * - `'SHA-384'` - * - `'SHA-512'` + * * `'cSHAKE128'` + * * `'cSHAKE256'` + * * `'SHA-1'` + * * `'SHA-256'` + * * `'SHA-384'` + * * `'SHA-512'` + * * `'SHA3-256'` + * * `'SHA3-384'` + * * `'SHA3-512'` * * If `algorithm` is provided as an ``, it must have a `name` property whose value is one of the above. * @since v15.0.0 */ - digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise; + digest(algorithm: AlgorithmIdentifier | CShakeParams, data: BufferSource): Promise; + /** + * The algorithms currently supported include: + * + * * `'ML-KEM-512'` + * * `'ML-KEM-768'` + * * `'ML-KEM-1024'` + * @since v24.7.0 + * @returns Fulfills with `EncapsulatedBits` upon success. + */ + encapsulateBits( + encapsulationAlgorithm: AlgorithmIdentifier, + encapsulationKey: CryptoKey, + ): Promise; + /** + * The algorithms currently supported include: + * + * * `'ML-KEM-512'` + * * `'ML-KEM-768'` + * * `'ML-KEM-1024'` + * @since v24.7.0 + * @param usages See [Key usages](https://nodejs.org/docs/latest-v24.x/api/webcrypto.html#cryptokeyusages). + * @returns Fulfills with `EncapsulatedKey` upon success. + */ + encapsulateKey( + encapsulationAlgorithm: AlgorithmIdentifier, + encapsulationKey: CryptoKey, + sharedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams, + extractable: boolean, + usages: KeyUsage[], + ): Promise; /** * Using the method and parameters specified by `algorithm` and the keying material provided by `key`, * `subtle.encrypt()` attempts to encipher `data`. If successful, @@ -4444,14 +4787,16 @@ declare module "crypto" { * * The algorithms currently supported include: * - * - `'RSA-OAEP'` - * - `'AES-CTR'` - * - `'AES-CBC'` - * - `'AES-GCM'` + * * `'AES-CBC'` + * * `'AES-CTR'` + * * `'AES-GCM'` + * * `'AES-OCB'` + * * `'ChaCha20-Poly1305'` + * * `'RSA-OAEP'` * @since v15.0.0 */ encrypt( - algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams, key: CryptoKey, data: BufferSource, ): Promise; @@ -4465,35 +4810,45 @@ declare module "crypto" { * * When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a * JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification. - * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, + * `'raw-public'`, or `'raw-seed'`. * @returns `` containing ``. * @since v15.0.0 */ exportKey(format: "jwk", key: CryptoKey): Promise; exportKey(format: Exclude, key: CryptoKey): Promise; /** - * Using the method and parameters provided in `algorithm`, - * `subtle.generateKey()` attempts to generate new keying material. - * Depending the method used, the method may generate either a single `` or a ``. + * Using the method and parameters provided in `algorithm`, `subtle.generateKey()` + * attempts to generate new keying material. Depending the method used, the method + * may generate either a single `CryptoKey` or a `CryptoKeyPair`. * - * The `` (public and private key) generating algorithms supported include: + * The `CryptoKeyPair` (public and private key) generating algorithms supported + * include: * - * - `'RSASSA-PKCS1-v1_5'` - * - `'RSA-PSS'` - * - `'RSA-OAEP'` - * - `'ECDSA'` - * - `'Ed25519'` - * - `'Ed448'` - * - `'ECDH'` - * - `'X25519'` - * - `'X448'` - * The `` (secret key) generating algorithms supported include: + * * `'ECDH'` + * * `'ECDSA'` + * * `'Ed25519'` + * * `'Ed448'` + * * `'ML-DSA-44'` + * * `'ML-DSA-65'` + * * `'ML-DSA-87'` + * * `'ML-KEM-512'` + * * `'ML-KEM-768'` + * * `'ML-KEM-1024'` + * * `'RSA-OAEP'` + * * `'RSA-PSS'` + * * `'RSASSA-PKCS1-v1_5'` + * * `'X25519'` + * * `'X448'` * - * - `'HMAC'` - * - `'AES-CTR'` - * - `'AES-CBC'` - * - `'AES-GCM'` - * - `'AES-KW'` + * The {CryptoKey} (secret key) generating algorithms supported include: + * * `'AES-CBC'` + * * `'AES-CTR'` + * * `'AES-GCM'` + * * `'AES-KW'` + * * `'AES-OCB'` + * * `'ChaCha20-Poly1305'` + * * `'HMAC'` * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. * @since v15.0.0 */ @@ -4512,13 +4867,22 @@ declare module "crypto" { extractable: boolean, keyUsages: KeyUsage[], ): Promise; + /** + * Derives the public key from a given private key. + * @since v24.7.0 + * @param key A private key from which to derive the corresponding public key. + * @param keyUsages See [Key usages](https://nodejs.org/docs/latest-v24.x/api/webcrypto.html#cryptokeyusages). + * @returns Fulfills with a `CryptoKey` upon success. + */ + getPublicKey(key: CryptoKey, keyUsages: KeyUsage[]): Promise; /** * The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format` * to create a `` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments. * If the import is successful, the returned promise will be resolved with the created ``. * * If importing a `'PBKDF2'` key, `extractable` must be `false`. - * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, + * `'raw-public'`, or `'raw-seed'`. * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. * @since v15.0.0 */ @@ -4553,16 +4917,19 @@ declare module "crypto" { * * The algorithms currently supported include: * - * - `'RSASSA-PKCS1-v1_5'` - * - `'RSA-PSS'` - * - `'ECDSA'` - * - `'Ed25519'` - * - `'Ed448'` - * - `'HMAC'` + * * `'ECDSA'` + * * `'Ed25519'` + * * `'Ed448'` + * * `'HMAC'` + * * `'ML-DSA-44'` + * * `'ML-DSA-65'` + * * `'ML-DSA-87'` + * * `'RSA-PSS'` + * * `'RSASSA-PKCS1-v1_5'` * @since v15.0.0 */ sign( - algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, + algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params | ContextParams, key: CryptoKey, data: BufferSource, ): Promise; @@ -4575,29 +4942,40 @@ declare module "crypto" { * * The wrapping algorithms currently supported include: * - * - `'RSA-OAEP'` - * - `'AES-CTR'` - * - `'AES-CBC'` - * - `'AES-GCM'` - * - `'AES-KW'` + * * `'AES-CBC'` + * * `'AES-CTR'` + * * `'AES-GCM'` + * * `'AES-KW'` + * * `'AES-OCB'` + * * `'ChaCha20-Poly1305'` + * * `'RSA-OAEP'` * * The unwrapped key algorithms supported include: * - * - `'RSASSA-PKCS1-v1_5'` - * - `'RSA-PSS'` - * - `'RSA-OAEP'` - * - `'ECDSA'` - * - `'Ed25519'` - * - `'Ed448'` - * - `'ECDH'` - * - `'X25519'` - * - `'X448'` - * - `'HMAC'` - * - `'AES-CTR'` - * - `'AES-CBC'` - * - `'AES-GCM'` - * - `'AES-KW'` - * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * * `'AES-CBC'` + * * `'AES-CTR'` + * * `'AES-GCM'` + * * `'AES-KW'` + * * `'AES-OCB'` + * * `'ChaCha20-Poly1305'` + * * `'ECDH'` + * * `'ECDSA'` + * * `'Ed25519'` + * * `'Ed448'` + * * `'HMAC'` + * * `'ML-DSA-44'` + * * `'ML-DSA-65'` + * * `'ML-DSA-87'` + * * `'ML-KEM-512'` + * * `'ML-KEM-768'` + * * `'ML-KEM-1024'` + * * `'RSA-OAEP'` + * * `'RSA-PSS'` + * * `'RSASSA-PKCS1-v1_5'` + * * `'X25519'` + * * `'X448'` + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, + * `'raw-public'`, or `'raw-seed'`. * @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}. * @since v15.0.0 */ @@ -4605,7 +4983,7 @@ declare module "crypto" { format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, - unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams, unwrappedKeyAlgorithm: | AlgorithmIdentifier | RsaHashedImportParams @@ -4622,16 +5000,19 @@ declare module "crypto" { * * The algorithms currently supported include: * - * - `'RSASSA-PKCS1-v1_5'` - * - `'RSA-PSS'` - * - `'ECDSA'` - * - `'Ed25519'` - * - `'Ed448'` - * - `'HMAC'` + * * `'ECDSA'` + * * `'Ed25519'` + * * `'Ed448'`[^secure-curves] + * * `'HMAC'` + * * `'ML-DSA-44'` + * * `'ML-DSA-65'` + * * `'ML-DSA-87'` + * * `'RSA-PSS'` + * * `'RSASSA-PKCS1-v1_5'` * @since v15.0.0 */ verify( - algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, + algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params | ContextParams, key: CryptoKey, signature: BufferSource, data: BufferSource, @@ -4646,30 +5027,25 @@ declare module "crypto" { * * The wrapping algorithms currently supported include: * - * - `'RSA-OAEP'` - * - `'AES-CTR'` - * - `'AES-CBC'` - * - `'AES-GCM'` - * - `'AES-KW'` - * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`. + * * `'AES-CBC'` + * * `'AES-CTR'` + * * `'AES-GCM'` + * * `'AES-KW'` + * * `'AES-OCB'` + * * `'ChaCha20-Poly1305'` + * * `'RSA-OAEP'` + * @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, + * `'raw-public'`, or `'raw-seed'`. * @since v15.0.0 */ wrapKey( format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, - wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, + wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams, ): Promise; } } - - global { - var crypto: typeof globalThis extends { - crypto: infer T; - onmessage: any; - } ? T - : webcrypto.Crypto; - } } declare module "node:crypto" { export * from "crypto"; diff --git a/types/node/fs.d.ts b/types/node/fs.d.ts index 7ca6b0d98bf614..25956fce4bbea3 100644 --- a/types/node/fs.d.ts +++ b/types/node/fs.d.ts @@ -4600,6 +4600,7 @@ declare module "fs" { */ export function cpSync(source: string | URL, destination: string | URL, opts?: CopySyncOptions): void; + // TODO: collapse interface _GlobOptions { /** * Current working directory. @@ -4616,6 +4617,9 @@ declare module "fs" { * Function to filter out files/directories or a * list of glob patterns to be excluded. If a function is provided, return * `true` to exclude the item, `false` to include it. + * If a string array is provided, each string should be a glob pattern that + * specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are + * not supported. * @default undefined */ exclude?: ((fileName: T) => boolean) | readonly string[] | undefined; diff --git a/types/node/http.d.ts b/types/node/http.d.ts index e219e41a894ff8..fe3a0eec4a58d2 100644 --- a/types/node/http.d.ts +++ b/types/node/http.d.ts @@ -1462,6 +1462,16 @@ declare module "http" { * Only relevant if keepAlive is set to true. */ keepAliveMsecs?: number | undefined; + /** + * Milliseconds to subtract from + * the server-provided `keep-alive: timeout=...` hint when determining socket + * expiration time. This buffer helps ensure the agent closes the socket + * slightly before the server does, reducing the chance of sending a request + * on a socket that’s about to be closed by the server. + * @since v24.7.0 + * @default 1000 + */ + agentKeepAliveTimeoutBuffer?: number | undefined; /** * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity */ diff --git a/types/node/http2.d.ts b/types/node/http2.d.ts index 5e53de79f93eeb..3f95e7c785c3d6 100644 --- a/types/node/http2.d.ts +++ b/types/node/http2.d.ts @@ -423,7 +423,7 @@ declare module "http2" { * ``` * @since v8.4.0 */ - respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void; + respond(headers?: OutgoingHttpHeaders | readonly string[], options?: ServerStreamResponseOptions): void; /** * Initiates a response whose data is read from the given file descriptor. No * validation is performed on the given file descriptor. If an error occurs while diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 70f3eb69d7f04d..c140e0b49b51d0 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -39,11 +39,13 @@ // Definitions for Node.js modules that are not specific to any version of TypeScript: /// /// +/// /// /// /// /// /// +/// /// /// /// diff --git a/types/node/inspector.d.ts b/types/node/inspector.d.ts index 584daa283e40f5..dd0b888890c900 100644 --- a/types/node/inspector.d.ts +++ b/types/node/inspector.d.ts @@ -159,6 +159,30 @@ declare module "inspector" { * @since v22.7.0 */ function loadingFailed(params: LoadingFailedEventDataType): void; + /** + * This feature is only available with the `--experimental-network-inspection` flag enabled. + * + * Broadcasts the `Network.webSocketCreated` event to connected frontends. This event indicates that + * a WebSocket connection has been initiated. + * @since v24.7.0 + */ + function webSocketCreated(params: WebSocketCreatedEventDataType): void; + /** + * This feature is only available with the `--experimental-network-inspection` flag enabled. + * + * Broadcasts the `Network.webSocketHandshakeResponseReceived` event to connected frontends. + * This event indicates that the WebSocket handshake response has been received. + * @since v24.7.0 + */ + function webSocketHandshakeResponseReceived(params: WebSocketHandshakeResponseReceivedEventDataType): void; + /** + * This feature is only available with the `--experimental-network-inspection` flag enabled. + * + * Broadcasts the `Network.webSocketClosed` event to connected frontends. + * This event indicates that a WebSocket connection has been closed. + * @since v24.7.0 + */ + function webSocketClosed(params: WebSocketClosedEventDataType): void; } namespace NetworkResources { /** diff --git a/types/node/inspector.generated.d.ts b/types/node/inspector.generated.d.ts index bcf0b3bb0ec95a..17352e7916d9c8 100644 --- a/types/node/inspector.generated.d.ts +++ b/types/node/inspector.generated.d.ts @@ -1774,6 +1774,23 @@ declare module "inspector" { success: boolean; stream?: IO.StreamHandle | undefined; } + /** + * WebSocket response data. + */ + interface WebSocketResponse { + /** + * HTTP response status code. + */ + status: number; + /** + * HTTP response status text. + */ + statusText: string; + /** + * HTTP response headers. + */ + headers: Headers; + } interface GetRequestPostDataParameterType { /** * Identifier of the network request to get content for. @@ -1914,6 +1931,44 @@ declare module "inspector" { */ data?: string | undefined; } + interface WebSocketCreatedEventDataType { + /** + * Request identifier. + */ + requestId: RequestId; + /** + * WebSocket request URL. + */ + url: string; + /** + * Request initiator. + */ + initiator: Initiator; + } + interface WebSocketClosedEventDataType { + /** + * Request identifier. + */ + requestId: RequestId; + /** + * Timestamp. + */ + timestamp: MonotonicTime; + } + interface WebSocketHandshakeResponseReceivedEventDataType { + /** + * Request identifier. + */ + requestId: RequestId; + /** + * Timestamp. + */ + timestamp: MonotonicTime; + /** + * WebSocket response data. + */ + response: WebSocketResponse; + } } namespace NodeRuntime { interface NotifyWhenWaitingForDisconnectParameterType { @@ -2483,6 +2538,18 @@ declare module "inspector" { * Fired when data chunk was received over the network. */ addListener(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + addListener(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + addListener(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + addListener(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. @@ -2529,6 +2596,9 @@ declare module "inspector" { emit(event: "Network.loadingFailed", message: InspectorNotification): boolean; emit(event: "Network.loadingFinished", message: InspectorNotification): boolean; emit(event: "Network.dataReceived", message: InspectorNotification): boolean; + emit(event: "Network.webSocketCreated", message: InspectorNotification): boolean; + emit(event: "Network.webSocketClosed", message: InspectorNotification): boolean; + emit(event: "Network.webSocketHandshakeResponseReceived", message: InspectorNotification): boolean; emit(event: "NodeRuntime.waitingForDisconnect"): boolean; emit(event: "NodeRuntime.waitingForDebugger"): boolean; emit(event: "Target.targetCreated", message: InspectorNotification): boolean; @@ -2642,6 +2712,18 @@ declare module "inspector" { * Fired when data chunk was received over the network. */ on(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + on(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + on(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + on(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. @@ -2765,6 +2847,18 @@ declare module "inspector" { * Fired when data chunk was received over the network. */ once(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + once(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + once(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + once(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. @@ -2888,6 +2982,18 @@ declare module "inspector" { * Fired when data chunk was received over the network. */ prependListener(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + prependListener(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + prependListener(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + prependListener(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. @@ -3011,6 +3117,18 @@ declare module "inspector" { * Fired when data chunk was received over the network. */ prependOnceListener(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + prependOnceListener(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + prependOnceListener(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + prependOnceListener(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. @@ -3506,6 +3624,18 @@ declare module "inspector/promises" { * Fired when data chunk was received over the network. */ addListener(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + addListener(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + addListener(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + addListener(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. @@ -3552,6 +3682,9 @@ declare module "inspector/promises" { emit(event: "Network.loadingFailed", message: InspectorNotification): boolean; emit(event: "Network.loadingFinished", message: InspectorNotification): boolean; emit(event: "Network.dataReceived", message: InspectorNotification): boolean; + emit(event: "Network.webSocketCreated", message: InspectorNotification): boolean; + emit(event: "Network.webSocketClosed", message: InspectorNotification): boolean; + emit(event: "Network.webSocketHandshakeResponseReceived", message: InspectorNotification): boolean; emit(event: "NodeRuntime.waitingForDisconnect"): boolean; emit(event: "NodeRuntime.waitingForDebugger"): boolean; emit(event: "Target.targetCreated", message: InspectorNotification): boolean; @@ -3665,6 +3798,18 @@ declare module "inspector/promises" { * Fired when data chunk was received over the network. */ on(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + on(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + on(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + on(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. @@ -3788,6 +3933,18 @@ declare module "inspector/promises" { * Fired when data chunk was received over the network. */ once(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + once(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + once(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + once(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. @@ -3911,6 +4068,18 @@ declare module "inspector/promises" { * Fired when data chunk was received over the network. */ prependListener(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + prependListener(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + prependListener(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + prependListener(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. @@ -4034,6 +4203,18 @@ declare module "inspector/promises" { * Fired when data chunk was received over the network. */ prependOnceListener(event: "Network.dataReceived", listener: (message: InspectorNotification) => void): this; + /** + * Fired upon WebSocket creation. + */ + prependOnceListener(event: "Network.webSocketCreated", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket is closed. + */ + prependOnceListener(event: "Network.webSocketClosed", listener: (message: InspectorNotification) => void): this; + /** + * Fired when WebSocket handshake response becomes available. + */ + prependOnceListener(event: "Network.webSocketHandshakeResponseReceived", listener: (message: InspectorNotification) => void): this; /** * This event is fired instead of `Runtime.executionContextDestroyed` when * enabled. diff --git a/types/node/package.json b/types/node/package.json index 02de456d1335bd..5bb3786a227210 100644 --- a/types/node/package.json +++ b/types/node/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/node", - "version": "24.6.9999", + "version": "24.7.9999", "nonNpm": "conflict", "nonNpmDescription": "Node.js", "projects": [ @@ -18,7 +18,7 @@ } }, "dependencies": { - "undici-types": "~7.13.0" + "undici-types": "~7.14.0" }, "devDependencies": { "@types/node": "workspace:." diff --git a/types/node/sqlite.d.ts b/types/node/sqlite.d.ts index be10af035fb696..50be8b539bb5b8 100644 --- a/types/node/sqlite.d.ts +++ b/types/node/sqlite.d.ts @@ -637,8 +637,9 @@ declare module "node:sqlite" { */ rate?: number | undefined; /** - * Callback function that will be called with the number of pages copied and the total number of - * pages. + * An optional callback function that will be called after each backup step. The argument passed + * to this callback is an `Object` with `remainingPages` and `totalPages` properties, describing the current progress + * of the backup operation. */ progress?: ((progressInfo: BackupProgressInfo) => void) | undefined; } @@ -675,9 +676,10 @@ declare module "node:sqlite" { * the contents will be overwritten. * @param options Optional configuration for the backup. The * following properties are supported: - * @returns A promise that resolves when the backup is completed and rejects if an error occurs. + * @returns A promise that fulfills with the total number of backed-up pages upon completion, or rejects if an + * error occurs. */ - function backup(sourceDb: DatabaseSync, path: string | Buffer | URL, options?: BackupOptions): Promise; + function backup(sourceDb: DatabaseSync, path: string | Buffer | URL, options?: BackupOptions): Promise; /** * @since v22.13.0 */ diff --git a/types/node/stream/web.d.ts b/types/node/stream/web.d.ts index 881e29c089fdb1..bc7c011c3823da 100644 --- a/types/node/stream/web.d.ts +++ b/types/node/stream/web.d.ts @@ -1,11 +1,7 @@ type _ByteLengthQueuingStrategy = typeof globalThis extends { onmessage: any } ? {} : import("stream/web").ByteLengthQueuingStrategy; -type _CompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {} - : import("stream/web").CompressionStream; type _CountQueuingStrategy = typeof globalThis extends { onmessage: any } ? {} : import("stream/web").CountQueuingStrategy; -type _DecompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {} - : import("stream/web").DecompressionStream; type _QueuingStrategy = typeof globalThis extends { onmessage: any } ? {} : import("stream/web").QueuingStrategy; type _ReadableByteStreamController = typeof globalThis extends { onmessage: any } ? {} @@ -412,22 +408,17 @@ declare module "stream/web" { prototype: TextDecoderStream; new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream; }; - interface CompressionStream { + type CompressionFormat = "brotli" | "deflate" | "deflate-raw" | "gzip"; + class CompressionStream { + constructor(format: CompressionFormat); readonly readable: ReadableStream; readonly writable: WritableStream; } - const CompressionStream: { - prototype: CompressionStream; - new(format: "deflate" | "deflate-raw" | "gzip"): CompressionStream; - }; - interface DecompressionStream { - readonly writable: WritableStream; + class DecompressionStream { + constructor(format: CompressionFormat); readonly readable: ReadableStream; + readonly writable: WritableStream; } - const DecompressionStream: { - prototype: DecompressionStream; - new(format: "deflate" | "deflate-raw" | "gzip"): DecompressionStream; - }; global { interface ByteLengthQueuingStrategy extends _ByteLengthQueuingStrategy {} @@ -440,26 +431,6 @@ declare module "stream/web" { ? T : typeof import("stream/web").ByteLengthQueuingStrategy; - interface CompressionStream extends _CompressionStream {} - /** - * `CompressionStream` class is a global reference for `import { CompressionStream } from 'node:stream/web'`. - * https://nodejs.org/api/globals.html#class-compressionstream - * @since v18.0.0 - */ - var CompressionStream: typeof globalThis extends { - onmessage: any; - // CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit. - // If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts - ReportingObserver: any; - CompressionStream: infer T; - } ? T - // TS 4.8, 4.9, 5.0 - : typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? { - prototype: T; - new(format: "deflate" | "deflate-raw" | "gzip"): T; - } - : typeof import("stream/web").CompressionStream; - interface CountQueuingStrategy extends _CountQueuingStrategy {} /** * `CountQueuingStrategy` class is a global reference for `import { CountQueuingStrategy } from 'node:stream/web'`. @@ -469,26 +440,6 @@ declare module "stream/web" { var CountQueuingStrategy: typeof globalThis extends { onmessage: any; CountQueuingStrategy: infer T } ? T : typeof import("stream/web").CountQueuingStrategy; - interface DecompressionStream extends _DecompressionStream {} - /** - * `DecompressionStream` class is a global reference for `import { DecompressionStream } from 'node:stream/web'`. - * https://nodejs.org/api/globals.html#class-decompressionstream - * @since v18.0.0 - */ - var DecompressionStream: typeof globalThis extends { - onmessage: any; - // CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit. - // If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts - ReportingObserver: any; - DecompressionStream: infer T extends object; - } ? T - // TS 4.8, 4.9, 5.0 - : typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? { - prototype: T; - new(format: "deflate" | "deflate-raw" | "gzip"): T; - } - : typeof import("stream/web").DecompressionStream; - interface QueuingStrategy extends _QueuingStrategy {} interface ReadableByteStreamController extends _ReadableByteStreamController {} diff --git a/types/node/test.d.ts b/types/node/test.d.ts index 1516d657d9aca2..e1f103d776f3f9 100644 --- a/types/node/test.d.ts +++ b/types/node/test.d.ts @@ -343,6 +343,13 @@ declare module "node:test" { * @default undefined */ shard?: TestShard | undefined; + /** + * A file path where the test runner will + * store the state of the tests to allow rerunning only the failed tests on a next run. + * @since v24.7.0 + * @default undefined + */ + rerunFailuresFilePath?: string | undefined; /** * enable [code coverage](https://nodejs.org/docs/latest-v24.x/api/test.html#collecting-code-coverage) collection. * @since v22.10.0 @@ -711,7 +718,7 @@ declare module "node:test" { /** * The type of the test, used to denote whether this is a suite. */ - type?: "suite"; + type?: "suite" | "test"; }; /** * The test name. @@ -781,7 +788,13 @@ declare module "node:test" { * The type of the test, used to denote whether this is a suite. * @since v20.0.0, v19.9.0, v18.17.0 */ - type?: "suite"; + type?: "suite" | "test"; + /** + * The attempt number of the test run, + * present only when using the `--test-rerun-failures` flag. + * @since v24.7.0 + */ + attempt?: number; }; /** * The test name. @@ -817,7 +830,19 @@ declare module "node:test" { * The type of the test, used to denote whether this is a suite. * @since 20.0.0, 19.9.0, 18.17.0 */ - type?: "suite"; + type?: "suite" | "test"; + /** + * The attempt number of the test run, + * present only when using the `--test-rerun-failures` flag. + * @since v24.7.0 + */ + attempt?: number; + /** + * The attempt number the test passed on, + * present only when using the `--test-rerun-failures` flag. + * @since v24.7.0 + */ + passed_on_attempt?: number; }; /** * The test name. @@ -962,6 +987,7 @@ declare module "node:test" { * @since v22.2.0, v20.15.0 */ readonly assert: TestContextAssert; + readonly attempt: number; /** * This function is used to create a hook running before subtest of the current test. * @param fn The hook function. The first argument to this function is a `TestContext` object. diff --git a/types/node/test/crypto.ts b/types/node/test/crypto.ts index 243060faf82f39..5d4c7851b874a5 100644 --- a/types/node/test/crypto.ts +++ b/types/node/test/crypto.ts @@ -771,6 +771,22 @@ import { promisify } from "node:util"; type: "pkcs8", }, }); + + const mlkemRes: { + publicKey: Buffer; + privateKey: string; + } = crypto.generateKeyPairSync("ml-kem-1024", { + publicKeyEncoding: { + format: "der", + type: "spki", + }, + privateKeyEncoding: { + cipher: "some-cipher", + format: "pem", + passphrase: "secret", + type: "pkcs8", + }, + }); } { @@ -910,6 +926,21 @@ import { promisify } from "node:util"; }, (err: NodeJS.ErrnoException | null, publicKey: string, privateKey: string) => {}, ); + + crypto.generateKeyPair( + "ml-kem-1024", + { + publicKeyEncoding: { + format: "pem", + type: "spki", + }, + privateKeyEncoding: { + format: "pem", + type: "pkcs8", + }, + }, + (err: NodeJS.ErrnoException | null, publicKey: string, privateKey: string) => {}, + ); } { @@ -1025,6 +1056,20 @@ import { promisify } from "node:util"; type: "pkcs8", }, }); + + const mlkemRes: Promise<{ + publicKey: string; + privateKey: string; + }> = generateKeyPairPromisified("ml-kem-1024", { + publicKeyEncoding: { + format: "pem", + type: "spki", + }, + privateKeyEncoding: { + format: "pem", + type: "pkcs8", + }, + }); } { @@ -1708,12 +1753,6 @@ import { promisify } from "node:util"; crypto.webcrypto.getRandomValues(new BigInt64Array(4)); // $ExpectType BigInt64Array || BigInt64Array // @ts-expect-error crypto.webcrypto.getRandomValues(new Float64Array(4)); - crypto.webcrypto.CryptoKey.name; - crypto.webcrypto.CryptoKey.length; - crypto.webcrypto.CryptoKey.prototype; - crypto.webcrypto.CryptoKey.toString(); - // @ts-expect-error - new crypto.webcrypto.CryptoKey(); // Illegal constructor crypto.webcrypto.subtle.generateKey({ name: "HMAC", hash: "SHA-1" }, true, ["sign", "decrypt", "deriveBits"]).then( (out) => { @@ -1733,7 +1772,8 @@ import { promisify } from "node:util"; // Oops, test relied on DOM `globalThis.length` before const length = 123; - subtle.encrypt({ name: "AES-CBC", iv: new Uint8Array(16) }, key, new TextEncoder().encode("hello")); // $ExpectType Promise + subtle.decapsulateBits({ name: "ML-KEM-512" }, key, buf); // $ExpectType Promise + subtle.decapsulateKey({ name: "ML-KEM-512" }, key, buf, { name: "ECDSA" }, false, ["sign", "verify"]); // $ExpectType Promise subtle.decrypt({ name: "AES-CBC", iv: new Uint8Array(16) }, key, new ArrayBuffer(8)); // $ExpectType Promise subtle.deriveBits({ name: "PBKDF2", hash: "SHA-512", salt: new ArrayBuffer(8), iterations: 1000 }, key, length); // $ExpectType Promise subtle.deriveBits({ name: "ECDH", public: key }, key, null); // $ExpectType Promise @@ -1753,9 +1793,13 @@ import { promisify } from "node:util"; ["encrypt", "decrypt"], ); subtle.digest("SHA-384", buf); // $ExpectType Promise + subtle.encapsulateBits({ name: "ML-KEM-512" }, key); // $ExpectType Promise + subtle.encapsulateKey({ name: "ML-KEM-512" }, key, { name: "ECDSA" }, false, ["sign", "verify"]); // $ExpectType Promise + subtle.encrypt({ name: "AES-CBC", iv: new Uint8Array(16) }, key, new TextEncoder().encode("hello")); // $ExpectType Promise subtle.exportKey("jwk", key); // $ExpectType Promise - subtle.importKey("pkcs8", buf, { name: "RSA-PSS", hash: "SHA-1" }, false, []); // $ExpectType Promise subtle.generateKey({ name: "ECDH", namedCurve: "P-256" }, false, ["deriveKey", "deriveBits"]); // $ExpectType Promise + subtle.getPublicKey(key, ["sign", "verify", "deriveBits"]); // $ExpectType Promise + subtle.importKey("pkcs8", buf, { name: "RSA-PSS", hash: "SHA-1" }, false, []); // $ExpectType Promise subtle.sign({ name: "RSA-PSS", saltLength: 64 }, key, buf); // $ExpectType Promise subtle.unwrapKey( "raw", @@ -1777,3 +1821,25 @@ import { promisify } from "node:util"; keyObject.toCryptoKey({ name: "RSA-OAEP", hash: "SHA-256" }, true, ["sign"]); // $ExpectType CryptoKey keyObject.toCryptoKey({ name: "RSA-OAEP", hash: { name: "SHA-256" } }, true, ["sign"]); // $ExpectType CryptoKey } + +{ + const parameters = { + message: Buffer.from("abcde"), + nonce: crypto.randomBytes(8), + parallelism: 4, + tagLength: 8, + memory: 8 * 1024, + passes: 16, + }; + crypto.argon2("argon2i", parameters, (err, derivedKey) => { + err; // $ExpectType Error | null + derivedKey; // $ExpectType Buffer || Buffer + }); + crypto.argon2Sync("argon2i", parameters); // $ExpectType Buffer || Buffer +} + +{ + const { privateKey } = crypto.generateKeyPairSync("ml-kem-1024"); + const publicKey = crypto.decapsulate(privateKey, Buffer.from("the quick brown fox jumped over the lazy dog")); + const { sharedKey, ciphertext } = crypto.encapsulate(publicKey); +} diff --git a/types/node/test/globals-non-dom.ts b/types/node/test/globals-non-dom.ts index 61ce20e30f06c8..f4f5ab5ea1e9f0 100644 --- a/types/node/test/globals-non-dom.ts +++ b/types/node/test/globals-non-dom.ts @@ -37,6 +37,8 @@ out.usages; // $ExpectType KeyUsage[] }, ); + + SubtleCrypto.supports("sign", "ML-DSA-44"); // $ExpectType boolean } { diff --git a/types/node/test/http.ts b/types/node/test/http.ts index dcbf61cf84139c..67bba86b57ffa4 100644 --- a/types/node/test/http.ts +++ b/types/node/test/http.ts @@ -351,6 +351,7 @@ import * as url from "node:url"; let agent: http.Agent = new http.Agent({ keepAlive: true, keepAliveMsecs: 10000, + agentKeepAliveTimeoutBuffer: 1000, maxSockets: Infinity, maxTotalSockets: Infinity, maxFreeSockets: 256, diff --git a/types/node/test/http2.ts b/types/node/test/http2.ts index bbaf820ec43237..1509ba1d621711 100644 --- a/types/node/test/http2.ts +++ b/types/node/test/http2.ts @@ -202,6 +202,7 @@ import { URL } from "node:url"; serverHttp2Stream.respond(); serverHttp2Stream.respond(headers); serverHttp2Stream.respond(headers, options); + serverHttp2Stream.respond([":status", "400"]); const options2: ServerStreamFileResponseOptions = { statCheck: (stats: Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => {}, diff --git a/types/node/test/sqlite.ts b/types/node/test/sqlite.ts index 6c46d085f7bce2..bd2ff1e27bc58b 100644 --- a/types/node/test/sqlite.ts +++ b/types/node/test/sqlite.ts @@ -130,7 +130,7 @@ import { TextEncoder } from "node:util"; { const db = new DatabaseSync(":memory:"); - // $ExpectType Promise + // $ExpectType Promise backup( db, "/var/lib/sqlite/backup", diff --git a/types/node/test/test.ts b/types/node/test/test.ts index eab47fe34272f0..8a9db2c385d016 100644 --- a/types/node/test/test.ts +++ b/types/node/test/test.ts @@ -66,6 +66,7 @@ run({ lineCoverage: 70, branchCoverage: 50, functionCoverage: 80, + rerunFailuresFilePath: "/path/to/file.json", }); // TestsStream should be a NodeJS.ReadableStream @@ -163,6 +164,8 @@ test(undefined, undefined, t => { t.signal; // $ExpectType MockTracker t.mock; + // $ExpectType number + t.attempt; }); // Test the subtest approach. diff --git a/types/node/ts5.6/index.d.ts b/types/node/ts5.6/index.d.ts index c72875625ac3da..52c18699648e57 100644 --- a/types/node/ts5.6/index.d.ts +++ b/types/node/ts5.6/index.d.ts @@ -41,11 +41,13 @@ // Definitions for Node.js modules that are not specific to any version of TypeScript: /// /// +/// /// /// /// /// /// +/// /// /// /// diff --git a/types/node/ts5.7/index.d.ts b/types/node/ts5.7/index.d.ts index 137503b22b643a..b3454a725e4714 100644 --- a/types/node/ts5.7/index.d.ts +++ b/types/node/ts5.7/index.d.ts @@ -41,11 +41,13 @@ // Definitions for Node.js modules that are not specific to any version of TypeScript: /// /// +/// /// /// /// /// /// +/// /// /// /// diff --git a/types/node/web-globals/crypto.d.ts b/types/node/web-globals/crypto.d.ts new file mode 100644 index 00000000000000..9e572c53c12446 --- /dev/null +++ b/types/node/web-globals/crypto.d.ts @@ -0,0 +1,32 @@ +export {}; + +import { webcrypto } from "crypto"; + +declare global { + var Crypto: typeof globalThis extends { onmessage: any; Crypto: infer T } ? T : { + prototype: webcrypto.Crypto; + new(): webcrypto.Crypto; + }; + + var CryptoKey: typeof globalThis extends { onmessage: any; CryptoKey: infer T } ? T : { + prototype: webcrypto.CryptoKey; + new(): webcrypto.CryptoKey; + }; + + var SubtleCrypto: typeof globalThis extends { onmessage: any; SubtleCrypto: infer T } ? T : { + prototype: webcrypto.SubtleCrypto; + new(): webcrypto.SubtleCrypto; + supports( + operation: string, + algorithm: webcrypto.AlgorithmIdentifier, + length?: number, + ): boolean; + supports( + operation: string, + algorithm: webcrypto.AlgorithmIdentifier, + additionalAlgorithm: webcrypto.AlgorithmIdentifier, + ): boolean; + }; + + var crypto: typeof globalThis extends { onmessage: any; crypto: infer T } ? T : webcrypto.Crypto; +} diff --git a/types/node/web-globals/streams.d.ts b/types/node/web-globals/streams.d.ts new file mode 100644 index 00000000000000..a70dde5604d91c --- /dev/null +++ b/types/node/web-globals/streams.d.ts @@ -0,0 +1,22 @@ +export {}; + +import * as webstreams from "stream/web"; + +type _CompressionStream = typeof globalThis extends { onmessage: any } ? {} : webstreams.CompressionStream; +type _DecompressionStream = typeof globalThis extends { onmessage: any } ? {} : webstreams.DecompressionStream; + +declare global { + interface CompressionStream extends _CompressionStream {} + var CompressionStream: typeof globalThis extends { + onmessage: any; + CompressionStream: infer T; + } ? T + : typeof webstreams.CompressionStream; + + interface DecompressionStream extends _DecompressionStream {} + var DecompressionStream: typeof globalThis extends { + onmessage: any; + DecompressionStream: infer T; + } ? T + : typeof webstreams.DecompressionStream; +}