@types/node 18.0.3 → 18.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +1 -1
- node/crypto.d.ts +559 -5
- node/package.json +2 -2
- node/stream.d.ts +28 -0
node/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Sun, 17 Jul 2022 21:02:29 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
|
|
14
14
|
|
node/crypto.d.ts
CHANGED
|
@@ -1541,9 +1541,9 @@ declare module 'crypto' {
|
|
|
1541
1541
|
* @param inputEncoding The `encoding` of an `otherPublicKey` string.
|
|
1542
1542
|
* @param outputEncoding The `encoding` of the return value.
|
|
1543
1543
|
*/
|
|
1544
|
-
computeSecret(otherPublicKey: NodeJS.ArrayBufferView): Buffer;
|
|
1545
|
-
computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): Buffer;
|
|
1546
|
-
computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string;
|
|
1544
|
+
computeSecret(otherPublicKey: NodeJS.ArrayBufferView, inputEncoding?: null, outputEncoding?: null): Buffer;
|
|
1545
|
+
computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding, outputEncoding?: null): Buffer;
|
|
1546
|
+
computeSecret(otherPublicKey: NodeJS.ArrayBufferView, inputEncoding: null, outputEncoding: BinaryToTextEncoding): string;
|
|
1547
1547
|
computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding, outputEncoding: BinaryToTextEncoding): string;
|
|
1548
1548
|
/**
|
|
1549
1549
|
* Returns the Diffie-Hellman prime in the specified `encoding`.
|
|
@@ -1613,6 +1613,36 @@ declare module 'crypto' {
|
|
|
1613
1613
|
*/
|
|
1614
1614
|
verifyError: number;
|
|
1615
1615
|
}
|
|
1616
|
+
/**
|
|
1617
|
+
* The `DiffieHellmanGroup` class takes a well-known modp group as its argument.
|
|
1618
|
+
* It works the same as `DiffieHellman`, except that it does not allow changing its keys after creation.
|
|
1619
|
+
* In other words, it does not implement `setPublicKey()` or `setPrivateKey()` methods.
|
|
1620
|
+
*
|
|
1621
|
+
* ```js
|
|
1622
|
+
* const { createDiffieHellmanGroup } = await import('node:crypto');
|
|
1623
|
+
* const dh = createDiffieHellmanGroup('modp1');
|
|
1624
|
+
* ```
|
|
1625
|
+
* The name (e.g. `'modp1'`) is taken from [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt) (modp1 and 2) and [RFC 3526](https://www.rfc-editor.org/rfc/rfc3526.txt):
|
|
1626
|
+
* ```bash
|
|
1627
|
+
* $ perl -ne 'print "$1\n" if /"(modp\d+)"/' src/node_crypto_groups.h
|
|
1628
|
+
* modp1 # 768 bits
|
|
1629
|
+
* modp2 # 1024 bits
|
|
1630
|
+
* modp5 # 1536 bits
|
|
1631
|
+
* modp14 # 2048 bits
|
|
1632
|
+
* modp15 # etc.
|
|
1633
|
+
* modp16
|
|
1634
|
+
* modp17
|
|
1635
|
+
* modp18
|
|
1636
|
+
* ```
|
|
1637
|
+
* @since v0.7.5
|
|
1638
|
+
*/
|
|
1639
|
+
const DiffieHellmanGroup: DiffieHellmanGroupConstructor;
|
|
1640
|
+
interface DiffieHellmanGroupConstructor {
|
|
1641
|
+
new(name: string): DiffieHellmanGroup;
|
|
1642
|
+
(name: string): DiffieHellmanGroup;
|
|
1643
|
+
readonly prototype: DiffieHellmanGroup;
|
|
1644
|
+
}
|
|
1645
|
+
type DiffieHellmanGroup = Omit<DiffieHellman, 'setPublicKey' | 'setPrivateKey'>;
|
|
1616
1646
|
/**
|
|
1617
1647
|
* Creates a predefined `DiffieHellmanGroup` key exchange object. The
|
|
1618
1648
|
* supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in [RFC 2412](https://www.rfc-editor.org/rfc/rfc2412.txt), but see `Caveats`) and `'modp14'`, `'modp15'`,`'modp16'`, `'modp17'`,
|
|
@@ -1643,7 +1673,12 @@ declare module 'crypto' {
|
|
|
1643
1673
|
* ```
|
|
1644
1674
|
* @since v0.7.5
|
|
1645
1675
|
*/
|
|
1646
|
-
function getDiffieHellman(groupName: string):
|
|
1676
|
+
function getDiffieHellman(groupName: string): DiffieHellmanGroup;
|
|
1677
|
+
/**
|
|
1678
|
+
* An alias for {@link getDiffieHellman}
|
|
1679
|
+
* @since v0.9.3
|
|
1680
|
+
*/
|
|
1681
|
+
function createDiffieHellmanGroup(name: string): DiffieHellmanGroup;
|
|
1647
1682
|
/**
|
|
1648
1683
|
* Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2)
|
|
1649
1684
|
* implementation. A selected HMAC digest algorithm specified by `digest` is
|
|
@@ -2125,6 +2160,12 @@ declare module 'crypto' {
|
|
|
2125
2160
|
* @return `1` if and only if a FIPS compliant crypto provider is currently in use, `0` otherwise. A future semver-major release may change the return type of this API to a {boolean}.
|
|
2126
2161
|
*/
|
|
2127
2162
|
function getFips(): 1 | 0;
|
|
2163
|
+
/**
|
|
2164
|
+
* Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. Throws an error if FIPS mode is not available.
|
|
2165
|
+
* @since v10.0.0
|
|
2166
|
+
* @param bool `true` to enable FIPS mode.
|
|
2167
|
+
*/
|
|
2168
|
+
function setFips(bool: boolean): void;
|
|
2128
2169
|
/**
|
|
2129
2170
|
* ```js
|
|
2130
2171
|
* const {
|
|
@@ -3401,8 +3442,521 @@ declare module 'crypto' {
|
|
|
3401
3442
|
* @return `true` if the candidate is a prime with an error probability less than `0.25 ** options.checks`.
|
|
3402
3443
|
*/
|
|
3403
3444
|
function checkPrimeSync(candidate: LargeNumberLike, options?: CheckPrimeOptions): boolean;
|
|
3445
|
+
/**
|
|
3446
|
+
* Load and set the `engine` for some or all OpenSSL functions (selected by flags).
|
|
3447
|
+
*
|
|
3448
|
+
* `engine` could be either an id or a path to the engine's shared library.
|
|
3449
|
+
*
|
|
3450
|
+
* The optional `flags` argument uses `ENGINE_METHOD_ALL` by default.
|
|
3451
|
+
* The `flags` is a bit field taking one of or a mix of the following flags (defined in `crypto.constants`):
|
|
3452
|
+
*
|
|
3453
|
+
* - `crypto.constants.ENGINE_METHOD_RSA`
|
|
3454
|
+
* - `crypto.constants.ENGINE_METHOD_DSA`
|
|
3455
|
+
* - `crypto.constants.ENGINE_METHOD_DH`
|
|
3456
|
+
* - `crypto.constants.ENGINE_METHOD_RAND`
|
|
3457
|
+
* - `crypto.constants.ENGINE_METHOD_EC`
|
|
3458
|
+
* - `crypto.constants.ENGINE_METHOD_CIPHERS`
|
|
3459
|
+
* - `crypto.constants.ENGINE_METHOD_DIGESTS`
|
|
3460
|
+
* - `crypto.constants.ENGINE_METHOD_PKEY_METHS`
|
|
3461
|
+
* - `crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS`
|
|
3462
|
+
* - `crypto.constants.ENGINE_METHOD_ALL`
|
|
3463
|
+
* - `crypto.constants.ENGINE_METHOD_NONE`
|
|
3464
|
+
*
|
|
3465
|
+
* The flags below are deprecated in OpenSSL-1.1.0.
|
|
3466
|
+
*
|
|
3467
|
+
* - `crypto.constants.ENGINE_METHOD_ECDH`
|
|
3468
|
+
* - `crypto.constants.ENGINE_METHOD_ECDSA`
|
|
3469
|
+
* - `crypto.constants.ENGINE_METHOD_STORE`
|
|
3470
|
+
* @since v0.11.11
|
|
3471
|
+
* @param [flags=crypto.constants.ENGINE_METHOD_ALL]
|
|
3472
|
+
*/
|
|
3473
|
+
function setEngine(engine: string, flags?: number): void;
|
|
3474
|
+
/**
|
|
3475
|
+
* A convenient alias for `crypto.webcrypto.getRandomValues()`.
|
|
3476
|
+
* This implementation is not compliant with the Web Crypto spec,
|
|
3477
|
+
* to write web-compatible code use `crypto.webcrypto.getRandomValues()` instead.
|
|
3478
|
+
* @since v17.4.0
|
|
3479
|
+
* @returns Returns `typedArray`.
|
|
3480
|
+
*/
|
|
3481
|
+
function getRandomValues<T extends webcrypto.BufferSource>(typedArray: T): T;
|
|
3482
|
+
/**
|
|
3483
|
+
* A convenient alias for `crypto.webcrypto.subtle`.
|
|
3484
|
+
* @since v17.4.0
|
|
3485
|
+
*/
|
|
3486
|
+
const subtle: webcrypto.SubtleCrypto;
|
|
3487
|
+
/**
|
|
3488
|
+
* An implementation of the Web Crypto API standard.
|
|
3489
|
+
*
|
|
3490
|
+
* See the {@link https://nodejs.org/docs/latest/api/webcrypto.html Web Crypto API documentation} for details.
|
|
3491
|
+
* @since v15.0.0
|
|
3492
|
+
*/
|
|
3493
|
+
const webcrypto: webcrypto.Crypto;
|
|
3404
3494
|
namespace webcrypto {
|
|
3405
|
-
|
|
3495
|
+
type BufferSource = ArrayBufferView | ArrayBuffer;
|
|
3496
|
+
type KeyFormat = 'jwk' | 'pkcs8' | 'raw' | 'spki';
|
|
3497
|
+
type KeyType = 'private' | 'public' | 'secret';
|
|
3498
|
+
type KeyUsage = 'decrypt' | 'deriveBits' | 'deriveKey' | 'encrypt' | 'sign' | 'unwrapKey' | 'verify' | 'wrapKey';
|
|
3499
|
+
type AlgorithmIdentifier = Algorithm | string;
|
|
3500
|
+
type HashAlgorithmIdentifier = AlgorithmIdentifier;
|
|
3501
|
+
type NamedCurve = string;
|
|
3502
|
+
type BigInteger = Uint8Array;
|
|
3503
|
+
interface AesCbcParams extends Algorithm {
|
|
3504
|
+
iv: BufferSource;
|
|
3505
|
+
}
|
|
3506
|
+
interface AesCtrParams extends Algorithm {
|
|
3507
|
+
counter: BufferSource;
|
|
3508
|
+
length: number;
|
|
3509
|
+
}
|
|
3510
|
+
interface AesDerivedKeyParams extends Algorithm {
|
|
3511
|
+
length: number;
|
|
3512
|
+
}
|
|
3513
|
+
interface AesGcmParams extends Algorithm {
|
|
3514
|
+
additionalData?: BufferSource;
|
|
3515
|
+
iv: BufferSource;
|
|
3516
|
+
tagLength?: number;
|
|
3517
|
+
}
|
|
3518
|
+
interface AesKeyAlgorithm extends KeyAlgorithm {
|
|
3519
|
+
length: number;
|
|
3520
|
+
}
|
|
3521
|
+
interface AesKeyGenParams extends Algorithm {
|
|
3522
|
+
length: number;
|
|
3523
|
+
}
|
|
3524
|
+
interface Algorithm {
|
|
3525
|
+
name: string;
|
|
3526
|
+
}
|
|
3527
|
+
interface EcKeyAlgorithm extends KeyAlgorithm {
|
|
3528
|
+
namedCurve: NamedCurve;
|
|
3529
|
+
}
|
|
3530
|
+
interface EcKeyGenParams extends Algorithm {
|
|
3531
|
+
namedCurve: NamedCurve;
|
|
3532
|
+
}
|
|
3533
|
+
interface EcKeyImportParams extends Algorithm {
|
|
3534
|
+
namedCurve: NamedCurve;
|
|
3535
|
+
}
|
|
3536
|
+
interface EcdhKeyDeriveParams extends Algorithm {
|
|
3537
|
+
public: CryptoKey;
|
|
3538
|
+
}
|
|
3539
|
+
interface EcdsaParams extends Algorithm {
|
|
3540
|
+
hash: HashAlgorithmIdentifier;
|
|
3541
|
+
}
|
|
3542
|
+
interface Ed448Params extends Algorithm {
|
|
3543
|
+
context?: BufferSource;
|
|
3544
|
+
}
|
|
3545
|
+
interface HkdfParams extends Algorithm {
|
|
3546
|
+
hash: HashAlgorithmIdentifier;
|
|
3547
|
+
info: BufferSource;
|
|
3548
|
+
salt: BufferSource;
|
|
3549
|
+
}
|
|
3550
|
+
interface HmacImportParams extends Algorithm {
|
|
3551
|
+
hash: HashAlgorithmIdentifier;
|
|
3552
|
+
length?: number;
|
|
3553
|
+
}
|
|
3554
|
+
interface HmacKeyAlgorithm extends KeyAlgorithm {
|
|
3555
|
+
hash: KeyAlgorithm;
|
|
3556
|
+
length: number;
|
|
3557
|
+
}
|
|
3558
|
+
interface HmacKeyGenParams extends Algorithm {
|
|
3559
|
+
hash: HashAlgorithmIdentifier;
|
|
3560
|
+
length?: number;
|
|
3561
|
+
}
|
|
3562
|
+
interface JsonWebKey {
|
|
3563
|
+
alg?: string;
|
|
3564
|
+
crv?: string;
|
|
3565
|
+
d?: string;
|
|
3566
|
+
dp?: string;
|
|
3567
|
+
dq?: string;
|
|
3568
|
+
e?: string;
|
|
3569
|
+
ext?: boolean;
|
|
3570
|
+
k?: string;
|
|
3571
|
+
key_ops?: string[];
|
|
3572
|
+
kty?: string;
|
|
3573
|
+
n?: string;
|
|
3574
|
+
oth?: RsaOtherPrimesInfo[];
|
|
3575
|
+
p?: string;
|
|
3576
|
+
q?: string;
|
|
3577
|
+
qi?: string;
|
|
3578
|
+
use?: string;
|
|
3579
|
+
x?: string;
|
|
3580
|
+
y?: string;
|
|
3581
|
+
}
|
|
3582
|
+
interface KeyAlgorithm {
|
|
3583
|
+
name: string;
|
|
3584
|
+
}
|
|
3585
|
+
interface Pbkdf2Params extends Algorithm {
|
|
3586
|
+
hash: HashAlgorithmIdentifier;
|
|
3587
|
+
iterations: number;
|
|
3588
|
+
salt: BufferSource;
|
|
3589
|
+
}
|
|
3590
|
+
interface RsaHashedImportParams extends Algorithm {
|
|
3591
|
+
hash: HashAlgorithmIdentifier;
|
|
3592
|
+
}
|
|
3593
|
+
interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm {
|
|
3594
|
+
hash: KeyAlgorithm;
|
|
3595
|
+
}
|
|
3596
|
+
interface RsaHashedKeyGenParams extends RsaKeyGenParams {
|
|
3597
|
+
hash: HashAlgorithmIdentifier;
|
|
3598
|
+
}
|
|
3599
|
+
interface RsaKeyAlgorithm extends KeyAlgorithm {
|
|
3600
|
+
modulusLength: number;
|
|
3601
|
+
publicExponent: BigInteger;
|
|
3602
|
+
}
|
|
3603
|
+
interface RsaKeyGenParams extends Algorithm {
|
|
3604
|
+
modulusLength: number;
|
|
3605
|
+
publicExponent: BigInteger;
|
|
3606
|
+
}
|
|
3607
|
+
interface RsaOaepParams extends Algorithm {
|
|
3608
|
+
label?: BufferSource;
|
|
3609
|
+
}
|
|
3610
|
+
interface RsaOtherPrimesInfo {
|
|
3611
|
+
d?: string;
|
|
3612
|
+
r?: string;
|
|
3613
|
+
t?: string;
|
|
3614
|
+
}
|
|
3615
|
+
interface RsaPssParams extends Algorithm {
|
|
3616
|
+
saltLength: number;
|
|
3617
|
+
}
|
|
3618
|
+
/**
|
|
3619
|
+
* Calling `require('node:crypto').webcrypto` returns an instance of the `Crypto` class.
|
|
3620
|
+
* `Crypto` is a singleton that provides access to the remainder of the crypto API.
|
|
3621
|
+
* @since v15.0.0
|
|
3622
|
+
*/
|
|
3623
|
+
interface Crypto {
|
|
3624
|
+
/**
|
|
3625
|
+
* Provides access to the `SubtleCrypto` API.
|
|
3626
|
+
* @since v15.0.0
|
|
3627
|
+
*/
|
|
3628
|
+
readonly subtle: SubtleCrypto;
|
|
3629
|
+
/**
|
|
3630
|
+
* Generates cryptographically strong random values.
|
|
3631
|
+
* The given `typedArray` is filled with random values, and a reference to `typedArray` is returned.
|
|
3632
|
+
*
|
|
3633
|
+
* The given `typedArray` must be an integer-based instance of {@link NodeJS.TypedArray}, i.e. `Float32Array` and `Float64Array` are not accepted.
|
|
3634
|
+
*
|
|
3635
|
+
* An error will be thrown if the given `typedArray` is larger than 65,536 bytes.
|
|
3636
|
+
* @since v15.0.0
|
|
3637
|
+
*/
|
|
3638
|
+
getRandomValues<T extends Exclude<NodeJS.TypedArray, Float32Array | Float64Array>>(typedArray: T): T;
|
|
3639
|
+
/**
|
|
3640
|
+
* Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID.
|
|
3641
|
+
* The UUID is generated using a cryptographic pseudorandom number generator.
|
|
3642
|
+
* @since v16.7.0
|
|
3643
|
+
*/
|
|
3644
|
+
randomUUID(): string;
|
|
3645
|
+
CryptoKey: CryptoKeyConstructor;
|
|
3646
|
+
}
|
|
3647
|
+
// This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
|
|
3648
|
+
interface CryptoKeyConstructor {
|
|
3649
|
+
/** Illegal constructor */
|
|
3650
|
+
(_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user.
|
|
3651
|
+
readonly length: 0;
|
|
3652
|
+
readonly name: 'CryptoKey';
|
|
3653
|
+
readonly prototype: CryptoKey;
|
|
3654
|
+
}
|
|
3655
|
+
/**
|
|
3656
|
+
* @since v15.0.0
|
|
3657
|
+
*/
|
|
3658
|
+
interface CryptoKey {
|
|
3659
|
+
/**
|
|
3660
|
+
* An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters.
|
|
3661
|
+
* @since v15.0.0
|
|
3662
|
+
*/
|
|
3663
|
+
readonly algorithm: KeyAlgorithm;
|
|
3664
|
+
/**
|
|
3665
|
+
* When `true`, the {@link CryptoKey} can be extracted using either `subtleCrypto.exportKey()` or `subtleCrypto.wrapKey()`.
|
|
3666
|
+
* @since v15.0.0
|
|
3667
|
+
*/
|
|
3668
|
+
readonly extractable: boolean;
|
|
3669
|
+
/**
|
|
3670
|
+
* A string identifying whether the key is a symmetric (`'secret'`) or asymmetric (`'private'` or `'public'`) key.
|
|
3671
|
+
* @since v15.0.0
|
|
3672
|
+
*/
|
|
3673
|
+
readonly type: KeyType;
|
|
3674
|
+
/**
|
|
3675
|
+
* An array of strings identifying the operations for which the key may be used.
|
|
3676
|
+
*
|
|
3677
|
+
* The possible usages are:
|
|
3678
|
+
* - `'encrypt'` - The key may be used to encrypt data.
|
|
3679
|
+
* - `'decrypt'` - The key may be used to decrypt data.
|
|
3680
|
+
* - `'sign'` - The key may be used to generate digital signatures.
|
|
3681
|
+
* - `'verify'` - The key may be used to verify digital signatures.
|
|
3682
|
+
* - `'deriveKey'` - The key may be used to derive a new key.
|
|
3683
|
+
* - `'deriveBits'` - The key may be used to derive bits.
|
|
3684
|
+
* - `'wrapKey'` - The key may be used to wrap another key.
|
|
3685
|
+
* - `'unwrapKey'` - The key may be used to unwrap another key.
|
|
3686
|
+
*
|
|
3687
|
+
* Valid key usages depend on the key algorithm (identified by `cryptokey.algorithm.name`).
|
|
3688
|
+
* @since v15.0.0
|
|
3689
|
+
*/
|
|
3690
|
+
readonly usages: KeyUsage[];
|
|
3691
|
+
}
|
|
3692
|
+
/**
|
|
3693
|
+
* The `CryptoKeyPair` is a simple dictionary object with `publicKey` and `privateKey` properties, representing an asymmetric key pair.
|
|
3694
|
+
* @since v15.0.0
|
|
3695
|
+
*/
|
|
3696
|
+
interface CryptoKeyPair {
|
|
3697
|
+
/**
|
|
3698
|
+
* A {@link CryptoKey} whose type will be `'private'`.
|
|
3699
|
+
* @since v15.0.0
|
|
3700
|
+
*/
|
|
3701
|
+
privateKey: CryptoKey;
|
|
3702
|
+
/**
|
|
3703
|
+
* A {@link CryptoKey} whose type will be `'public'`.
|
|
3704
|
+
* @since v15.0.0
|
|
3705
|
+
*/
|
|
3706
|
+
publicKey: CryptoKey;
|
|
3707
|
+
}
|
|
3708
|
+
/**
|
|
3709
|
+
* @since v15.0.0
|
|
3710
|
+
*/
|
|
3711
|
+
interface SubtleCrypto {
|
|
3712
|
+
/**
|
|
3713
|
+
* Using the method and parameters specified in `algorithm` and the keying material provided by `key`,
|
|
3714
|
+
* `subtle.decrypt()` attempts to decipher the provided `data`. If successful,
|
|
3715
|
+
* the returned promise will be resolved with an `<ArrayBuffer>` containing the plaintext result.
|
|
3716
|
+
*
|
|
3717
|
+
* The algorithms currently supported include:
|
|
3718
|
+
*
|
|
3719
|
+
* - `'RSA-OAEP'`
|
|
3720
|
+
* - `'AES-CTR'`
|
|
3721
|
+
* - `'AES-CBC'`
|
|
3722
|
+
* - `'AES-GCM'`
|
|
3723
|
+
* @since v15.0.0
|
|
3724
|
+
*/
|
|
3725
|
+
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
3726
|
+
/**
|
|
3727
|
+
* Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
|
|
3728
|
+
* `subtle.deriveBits()` attempts to generate `length` bits.
|
|
3729
|
+
* The Node.js implementation requires that `length` is a multiple of `8`.
|
|
3730
|
+
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the generated data.
|
|
3731
|
+
*
|
|
3732
|
+
* The algorithms currently supported include:
|
|
3733
|
+
*
|
|
3734
|
+
* - `'ECDH'`
|
|
3735
|
+
* - `'X25519'`
|
|
3736
|
+
* - `'X448'`
|
|
3737
|
+
* - `'HKDF'`
|
|
3738
|
+
* - `'PBKDF2'`
|
|
3739
|
+
* @since v15.0.0
|
|
3740
|
+
*/
|
|
3741
|
+
deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
|
|
3742
|
+
/**
|
|
3743
|
+
* Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
|
|
3744
|
+
* `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
|
|
3745
|
+
*
|
|
3746
|
+
* Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material,
|
|
3747
|
+
* then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input.
|
|
3748
|
+
*
|
|
3749
|
+
* The algorithms currently supported include:
|
|
3750
|
+
*
|
|
3751
|
+
* - `'ECDH'`
|
|
3752
|
+
* - `'X25519'`
|
|
3753
|
+
* - `'X448'`
|
|
3754
|
+
* - `'HKDF'`
|
|
3755
|
+
* - `'PBKDF2'`
|
|
3756
|
+
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
3757
|
+
* @since v15.0.0
|
|
3758
|
+
*/
|
|
3759
|
+
deriveKey(
|
|
3760
|
+
algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
|
|
3761
|
+
baseKey: CryptoKey,
|
|
3762
|
+
derivedKeyAlgorithm: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params,
|
|
3763
|
+
extractable: boolean,
|
|
3764
|
+
keyUsages: ReadonlyArray<KeyUsage>
|
|
3765
|
+
): Promise<CryptoKey>;
|
|
3766
|
+
/**
|
|
3767
|
+
* Using the method identified by `algorithm`, `subtle.digest()` attempts to generate a digest of `data`.
|
|
3768
|
+
* If successful, the returned promise is resolved with an `<ArrayBuffer>` containing the computed digest.
|
|
3769
|
+
*
|
|
3770
|
+
* If `algorithm` is provided as a `<string>`, it must be one of:
|
|
3771
|
+
*
|
|
3772
|
+
* - `'SHA-1'`
|
|
3773
|
+
* - `'SHA-256'`
|
|
3774
|
+
* - `'SHA-384'`
|
|
3775
|
+
* - `'SHA-512'`
|
|
3776
|
+
*
|
|
3777
|
+
* If `algorithm` is provided as an `<Object>`, it must have a `name` property whose value is one of the above.
|
|
3778
|
+
* @since v15.0.0
|
|
3779
|
+
*/
|
|
3780
|
+
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
|
|
3781
|
+
/**
|
|
3782
|
+
* Using the method and parameters specified by `algorithm` and the keying material provided by `key`,
|
|
3783
|
+
* `subtle.encrypt()` attempts to encipher `data`. If successful,
|
|
3784
|
+
* the returned promise is resolved with an `<ArrayBuffer>` containing the encrypted result.
|
|
3785
|
+
*
|
|
3786
|
+
* The algorithms currently supported include:
|
|
3787
|
+
*
|
|
3788
|
+
* - `'RSA-OAEP'`
|
|
3789
|
+
* - `'AES-CTR'`
|
|
3790
|
+
* - `'AES-CBC'`
|
|
3791
|
+
* - `'AES-GCM'`
|
|
3792
|
+
* @since v15.0.0
|
|
3793
|
+
*/
|
|
3794
|
+
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
3795
|
+
/**
|
|
3796
|
+
* Exports the given key into the specified format, if supported.
|
|
3797
|
+
*
|
|
3798
|
+
* If the `<CryptoKey>` is not extractable, the returned promise will reject.
|
|
3799
|
+
*
|
|
3800
|
+
* When `format` is either `'pkcs8'` or `'spki'` and the export is successful,
|
|
3801
|
+
* the returned promise will be resolved with an `<ArrayBuffer>` containing the exported key data.
|
|
3802
|
+
*
|
|
3803
|
+
* When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a
|
|
3804
|
+
* JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification.
|
|
3805
|
+
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
3806
|
+
* @returns `<Promise>` containing `<ArrayBuffer>`.
|
|
3807
|
+
* @since v15.0.0
|
|
3808
|
+
*/
|
|
3809
|
+
exportKey(format: 'jwk', key: CryptoKey): Promise<JsonWebKey>;
|
|
3810
|
+
exportKey(format: Exclude<KeyFormat, 'jwk'>, key: CryptoKey): Promise<ArrayBuffer>;
|
|
3811
|
+
/**
|
|
3812
|
+
* Using the method and parameters provided in `algorithm`,
|
|
3813
|
+
* `subtle.generateKey()` attempts to generate new keying material.
|
|
3814
|
+
* Depending the method used, the method may generate either a single `<CryptoKey>` or a `<CryptoKeyPair>`.
|
|
3815
|
+
*
|
|
3816
|
+
* The `<CryptoKeyPair>` (public and private key) generating algorithms supported include:
|
|
3817
|
+
*
|
|
3818
|
+
* - `'RSASSA-PKCS1-v1_5'`
|
|
3819
|
+
* - `'RSA-PSS'`
|
|
3820
|
+
* - `'RSA-OAEP'`
|
|
3821
|
+
* - `'ECDSA'`
|
|
3822
|
+
* - `'Ed25519'`
|
|
3823
|
+
* - `'Ed448'`
|
|
3824
|
+
* - `'ECDH'`
|
|
3825
|
+
* - `'X25519'`
|
|
3826
|
+
* - `'X448'`
|
|
3827
|
+
* The `<CryptoKey>` (secret key) generating algorithms supported include:
|
|
3828
|
+
*
|
|
3829
|
+
* - `'HMAC'`
|
|
3830
|
+
* - `'AES-CTR'`
|
|
3831
|
+
* - `'AES-CBC'`
|
|
3832
|
+
* - `'AES-GCM'`
|
|
3833
|
+
* - `'AES-KW'`
|
|
3834
|
+
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
3835
|
+
* @since v15.0.0
|
|
3836
|
+
*/
|
|
3837
|
+
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
|
|
3838
|
+
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
|
|
3839
|
+
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair | CryptoKey>;
|
|
3840
|
+
/**
|
|
3841
|
+
* The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format`
|
|
3842
|
+
* to create a `<CryptoKey>` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments.
|
|
3843
|
+
* If the import is successful, the returned promise will be resolved with the created `<CryptoKey>`.
|
|
3844
|
+
*
|
|
3845
|
+
* If importing a `'PBKDF2'` key, `extractable` must be `false`.
|
|
3846
|
+
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
3847
|
+
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
3848
|
+
* @since v15.0.0
|
|
3849
|
+
*/
|
|
3850
|
+
importKey(
|
|
3851
|
+
format: 'jwk',
|
|
3852
|
+
keyData: JsonWebKey,
|
|
3853
|
+
algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm,
|
|
3854
|
+
extractable: boolean,
|
|
3855
|
+
keyUsages: ReadonlyArray<KeyUsage>
|
|
3856
|
+
): Promise<CryptoKey>;
|
|
3857
|
+
importKey(
|
|
3858
|
+
format: Exclude<KeyFormat, 'jwk'>,
|
|
3859
|
+
keyData: BufferSource,
|
|
3860
|
+
algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm,
|
|
3861
|
+
extractable: boolean,
|
|
3862
|
+
keyUsages: KeyUsage[]
|
|
3863
|
+
): Promise<CryptoKey>;
|
|
3864
|
+
/**
|
|
3865
|
+
* Using the method and parameters given by `algorithm` and the keying material provided by `key`,
|
|
3866
|
+
* `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful,
|
|
3867
|
+
* the returned promise is resolved with an `<ArrayBuffer>` containing the generated signature.
|
|
3868
|
+
*
|
|
3869
|
+
* The algorithms currently supported include:
|
|
3870
|
+
*
|
|
3871
|
+
* - `'RSASSA-PKCS1-v1_5'`
|
|
3872
|
+
* - `'RSA-PSS'`
|
|
3873
|
+
* - `'ECDSA'`
|
|
3874
|
+
* - `'Ed25519'`
|
|
3875
|
+
* - `'Ed448'`
|
|
3876
|
+
* - `'HMAC'`
|
|
3877
|
+
* @since v15.0.0
|
|
3878
|
+
*/
|
|
3879
|
+
sign(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
3880
|
+
/**
|
|
3881
|
+
* In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
|
|
3882
|
+
* The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
|
|
3883
|
+
* It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input)
|
|
3884
|
+
* then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs.
|
|
3885
|
+
* If successful, the returned promise is resolved with a `<CryptoKey>` object.
|
|
3886
|
+
*
|
|
3887
|
+
* The wrapping algorithms currently supported include:
|
|
3888
|
+
*
|
|
3889
|
+
* - `'RSA-OAEP'`
|
|
3890
|
+
* - `'AES-CTR'`
|
|
3891
|
+
* - `'AES-CBC'`
|
|
3892
|
+
* - `'AES-GCM'`
|
|
3893
|
+
* - `'AES-KW'`
|
|
3894
|
+
*
|
|
3895
|
+
* The unwrapped key algorithms supported include:
|
|
3896
|
+
*
|
|
3897
|
+
* - `'RSASSA-PKCS1-v1_5'`
|
|
3898
|
+
* - `'RSA-PSS'`
|
|
3899
|
+
* - `'RSA-OAEP'`
|
|
3900
|
+
* - `'ECDSA'`
|
|
3901
|
+
* - `'Ed25519'`
|
|
3902
|
+
* - `'Ed448'`
|
|
3903
|
+
* - `'ECDH'`
|
|
3904
|
+
* - `'X25519'`
|
|
3905
|
+
* - `'X448'`
|
|
3906
|
+
* - `'HMAC'`
|
|
3907
|
+
* - `'AES-CTR'`
|
|
3908
|
+
* - `'AES-CBC'`
|
|
3909
|
+
* - `'AES-GCM'`
|
|
3910
|
+
* - `'AES-KW'`
|
|
3911
|
+
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
3912
|
+
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
3913
|
+
* @since v15.0.0
|
|
3914
|
+
*/
|
|
3915
|
+
unwrapKey(
|
|
3916
|
+
format: KeyFormat,
|
|
3917
|
+
wrappedKey: BufferSource,
|
|
3918
|
+
unwrappingKey: CryptoKey,
|
|
3919
|
+
unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
|
|
3920
|
+
unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm,
|
|
3921
|
+
extractable: boolean,
|
|
3922
|
+
keyUsages: KeyUsage[]
|
|
3923
|
+
): Promise<CryptoKey>;
|
|
3924
|
+
/**
|
|
3925
|
+
* Using the method and parameters given in `algorithm` and the keying material provided by `key`,
|
|
3926
|
+
* `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`.
|
|
3927
|
+
* The returned promise is resolved with either `true` or `false`.
|
|
3928
|
+
*
|
|
3929
|
+
* The algorithms currently supported include:
|
|
3930
|
+
*
|
|
3931
|
+
* - `'RSASSA-PKCS1-v1_5'`
|
|
3932
|
+
* - `'RSA-PSS'`
|
|
3933
|
+
* - `'ECDSA'`
|
|
3934
|
+
* - `'Ed25519'`
|
|
3935
|
+
* - `'Ed448'`
|
|
3936
|
+
* - `'HMAC'`
|
|
3937
|
+
* @since v15.0.0
|
|
3938
|
+
*/
|
|
3939
|
+
verify(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | Ed448Params, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>;
|
|
3940
|
+
/**
|
|
3941
|
+
* In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
|
|
3942
|
+
* The `subtle.wrapKey()` method exports the keying material into the format identified by `format`,
|
|
3943
|
+
* then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`.
|
|
3944
|
+
* It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments,
|
|
3945
|
+
* then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs.
|
|
3946
|
+
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the encrypted key data.
|
|
3947
|
+
*
|
|
3948
|
+
* The wrapping algorithms currently supported include:
|
|
3949
|
+
*
|
|
3950
|
+
* - `'RSA-OAEP'`
|
|
3951
|
+
* - `'AES-CTR'`
|
|
3952
|
+
* - `'AES-CBC'`
|
|
3953
|
+
* - `'AES-GCM'`
|
|
3954
|
+
* - `'AES-KW'`
|
|
3955
|
+
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
3956
|
+
* @since v15.0.0
|
|
3957
|
+
*/
|
|
3958
|
+
wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams): Promise<ArrayBuffer>;
|
|
3959
|
+
}
|
|
3406
3960
|
}
|
|
3407
3961
|
}
|
|
3408
3962
|
declare module 'node:crypto' {
|
node/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.0.6",
|
|
4
4
|
"description": "TypeScript definitions for Node.js",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -220,6 +220,6 @@
|
|
|
220
220
|
},
|
|
221
221
|
"scripts": {},
|
|
222
222
|
"dependencies": {},
|
|
223
|
-
"typesPublisherContentHash": "
|
|
223
|
+
"typesPublisherContentHash": "66f1b140a3a1f77d215036a5818c51674db9998bb96d0ae9b251d09f2825200e",
|
|
224
224
|
"typeScriptVersion": "4.0"
|
|
225
225
|
}
|
node/stream.d.ts
CHANGED
|
@@ -126,6 +126,16 @@ declare module 'stream' {
|
|
|
126
126
|
* @since v18.0.0
|
|
127
127
|
*/
|
|
128
128
|
destroyed: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Is true after 'close' has been emitted.
|
|
131
|
+
* @since v8.0.0
|
|
132
|
+
*/
|
|
133
|
+
readonly closed: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Returns error if the stream has been destroyed with an error.
|
|
136
|
+
* @since v18.0.0
|
|
137
|
+
*/
|
|
138
|
+
readonly errored: Error | null;
|
|
129
139
|
constructor(opts?: ReadableOptions);
|
|
130
140
|
_construct?(callback: (error?: Error | null) => void): void;
|
|
131
141
|
_read(size: number): void;
|
|
@@ -554,6 +564,21 @@ declare module 'stream' {
|
|
|
554
564
|
* @since v8.0.0
|
|
555
565
|
*/
|
|
556
566
|
destroyed: boolean;
|
|
567
|
+
/**
|
|
568
|
+
* Is true after 'close' has been emitted.
|
|
569
|
+
* @since v8.0.0
|
|
570
|
+
*/
|
|
571
|
+
readonly closed: boolean;
|
|
572
|
+
/**
|
|
573
|
+
* Returns error if the stream has been destroyed with an error.
|
|
574
|
+
* @since v18.0.0
|
|
575
|
+
*/
|
|
576
|
+
readonly errored: Error | null;
|
|
577
|
+
/**
|
|
578
|
+
* Is `true` if the stream's buffer has been full and stream will emit 'drain'.
|
|
579
|
+
* @since v15.2.0, v14.17.0
|
|
580
|
+
*/
|
|
581
|
+
readonly writableNeedDrain: boolean;
|
|
557
582
|
constructor(opts?: WritableOptions);
|
|
558
583
|
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
559
584
|
_writev?(
|
|
@@ -820,6 +845,9 @@ declare module 'stream' {
|
|
|
820
845
|
readonly writableLength: number;
|
|
821
846
|
readonly writableObjectMode: boolean;
|
|
822
847
|
readonly writableCorked: number;
|
|
848
|
+
readonly writableNeedDrain: boolean;
|
|
849
|
+
readonly closed: boolean;
|
|
850
|
+
readonly errored: Error | null;
|
|
823
851
|
/**
|
|
824
852
|
* If `false` then the stream will automatically end the writable side when the
|
|
825
853
|
* readable side ends. Set initially by the `allowHalfOpen` constructor option,
|