@idlebox/stripe-node-types 24.0.14 → 24.0.15
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.
- package/README.md +1 -1
- package/assert/strict.d.ts +98 -1
- package/assert.d.ts +147 -248
- package/async_hooks.d.ts +5 -5
- package/buffer.buffer.d.ts +9 -6
- package/buffer.d.ts +49 -169
- package/child_process.d.ts +102 -223
- package/cluster.d.ts +236 -329
- package/console.d.ts +45 -346
- package/constants.d.ts +0 -1
- package/crypto.d.ts +698 -1149
- package/dgram.d.ts +15 -50
- package/diagnostics_channel.d.ts +1 -3
- package/dns.d.ts +135 -131
- package/domain.d.ts +10 -14
- package/events.d.ts +846 -722
- package/fs/promises.d.ts +102 -53
- package/fs.d.ts +714 -484
- package/globals.d.ts +130 -347
- package/globals.typedarray.d.ts +79 -0
- package/http.d.ts +343 -246
- package/http2.d.ts +563 -711
- package/https.d.ts +70 -216
- package/index.d.ts +24 -3
- package/inspector/promises.d.ts +54 -0
- package/inspector.d.ts +167 -3938
- package/inspector.generated.d.ts +4242 -0
- package/module.d.ts +45 -95
- package/net.d.ts +87 -186
- package/os.d.ts +17 -6
- package/package.json +3 -8
- package/path/posix.d.ts +20 -0
- package/path/win32.d.ts +20 -0
- package/path.d.ts +117 -122
- package/perf_hooks.d.ts +295 -644
- package/process.d.ts +177 -138
- package/punycode.d.ts +2 -2
- package/querystring.d.ts +1 -1
- package/quic.d.ts +926 -0
- package/readline/promises.d.ts +1 -1
- package/readline.d.ts +65 -118
- package/repl.d.ts +83 -96
- package/sea.d.ts +10 -1
- package/sqlite.d.ts +262 -13
- package/stream/consumers.d.ts +7 -7
- package/stream/promises.d.ts +133 -12
- package/stream/web.d.ts +173 -495
- package/stream.d.ts +593 -490
- package/string_decoder.d.ts +3 -3
- package/test/reporters.d.ts +112 -0
- package/test.d.ts +223 -199
- package/timers/promises.d.ts +1 -1
- package/timers.d.ts +1 -129
- package/tls.d.ts +148 -163
- package/trace_events.d.ts +6 -6
- package/ts5.6/buffer.buffer.d.ts +10 -8
- package/ts5.6/globals.typedarray.d.ts +16 -0
- package/ts5.6/index.d.ts +24 -3
- package/ts5.7/index.d.ts +24 -3
- package/tty.d.ts +55 -13
- package/url.d.ts +92 -587
- package/util/types.d.ts +571 -0
- package/util.d.ts +143 -792
- package/v8.d.ts +67 -7
- package/vm.d.ts +252 -108
- package/wasi.d.ts +23 -2
- package/web-globals/abortcontroller.d.ts +75 -0
- package/web-globals/blob.d.ts +39 -0
- package/{ts5.1/compatibility/disposable.d.ts → web-globals/console.d.ts} +6 -9
- package/web-globals/crypto.d.ts +55 -0
- package/web-globals/domexception.d.ts +84 -0
- package/web-globals/encoding.d.ts +27 -0
- package/{dom-events.d.ts → web-globals/events.d.ts} +57 -50
- package/web-globals/fetch.d.ts +70 -0
- package/web-globals/importmeta.d.ts +29 -0
- package/web-globals/messaging.d.ts +39 -0
- package/web-globals/navigator.d.ts +41 -0
- package/web-globals/performance.d.ts +61 -0
- package/web-globals/storage.d.ts +40 -0
- package/web-globals/streams.d.ts +131 -0
- package/web-globals/timers.d.ts +60 -0
- package/web-globals/url.d.ts +40 -0
- package/worker_threads.d.ts +291 -349
- package/zlib.d.ts +44 -94
- package/ts5.1/index.d.ts +0 -115
package/crypto.d.ts
CHANGED
|
@@ -29,10 +29,11 @@
|
|
|
29
29
|
* // Prints:
|
|
30
30
|
* // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
|
|
31
31
|
* ```
|
|
32
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
32
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/crypto.js)
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
declare module "node:crypto" {
|
|
36
|
+
import { NonSharedBuffer } from 'node:buffer';
|
|
36
37
|
import * as stream from 'node:stream';
|
|
37
38
|
import { PeerCertificate } from 'node:tls';
|
|
38
39
|
/**
|
|
@@ -60,7 +61,7 @@ declare module "node:crypto" {
|
|
|
60
61
|
* @param encoding The `encoding` of the `spkac` string.
|
|
61
62
|
* @return The challenge component of the `spkac` data structure, which includes a public key and a challenge.
|
|
62
63
|
*/
|
|
63
|
-
static exportChallenge(spkac: BinaryLike):
|
|
64
|
+
static exportChallenge(spkac: BinaryLike): NonSharedBuffer;
|
|
64
65
|
/**
|
|
65
66
|
* ```js
|
|
66
67
|
* const { Certificate } = await import('node:crypto');
|
|
@@ -73,7 +74,7 @@ declare module "node:crypto" {
|
|
|
73
74
|
* @param encoding The `encoding` of the `spkac` string.
|
|
74
75
|
* @return The public key component of the `spkac` data structure, which includes a public key and a challenge.
|
|
75
76
|
*/
|
|
76
|
-
static exportPublicKey(spkac: BinaryLike, encoding?: string):
|
|
77
|
+
static exportPublicKey(spkac: BinaryLike, encoding?: string): NonSharedBuffer;
|
|
77
78
|
/**
|
|
78
79
|
* ```js
|
|
79
80
|
* import { Buffer } from 'node:buffer';
|
|
@@ -94,7 +95,7 @@ declare module "node:crypto" {
|
|
|
94
95
|
* @returns The challenge component of the `spkac` data structure,
|
|
95
96
|
* which includes a public key and a challenge.
|
|
96
97
|
*/
|
|
97
|
-
exportChallenge(spkac: BinaryLike):
|
|
98
|
+
exportChallenge(spkac: BinaryLike): NonSharedBuffer;
|
|
98
99
|
/**
|
|
99
100
|
* @deprecated
|
|
100
101
|
* @param spkac
|
|
@@ -102,7 +103,7 @@ declare module "node:crypto" {
|
|
|
102
103
|
* @returns The public key component of the `spkac` data structure,
|
|
103
104
|
* which includes a public key and a challenge.
|
|
104
105
|
*/
|
|
105
|
-
exportPublicKey(spkac: BinaryLike, encoding?: string):
|
|
106
|
+
exportPublicKey(spkac: BinaryLike, encoding?: string): NonSharedBuffer;
|
|
106
107
|
/**
|
|
107
108
|
* @deprecated
|
|
108
109
|
* @param spkac
|
|
@@ -112,7 +113,7 @@ declare module "node:crypto" {
|
|
|
112
113
|
verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
|
|
113
114
|
}
|
|
114
115
|
namespace constants {
|
|
115
|
-
// https://nodejs.org/dist/latest-
|
|
116
|
+
// https://nodejs.org/dist/latest-v25.x/docs/api/crypto.html#crypto-constants
|
|
116
117
|
const OPENSSL_VERSION_NUMBER: number;
|
|
117
118
|
/** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
|
|
118
119
|
const SSL_OP_ALL: number;
|
|
@@ -418,7 +419,7 @@ declare module "node:crypto" {
|
|
|
418
419
|
* @since v0.1.92
|
|
419
420
|
* @param encoding The `encoding` of the return value.
|
|
420
421
|
*/
|
|
421
|
-
digest():
|
|
422
|
+
digest(): NonSharedBuffer;
|
|
422
423
|
digest(encoding: BinaryToTextEncoding): string;
|
|
423
424
|
}
|
|
424
425
|
/**
|
|
@@ -486,7 +487,6 @@ declare module "node:crypto" {
|
|
|
486
487
|
* // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
|
|
487
488
|
* ```
|
|
488
489
|
* @since v0.1.94
|
|
489
|
-
* @deprecated Since v20.13.0 Calling `Hmac` class directly with `Hmac()` or `new Hmac()` is deprecated due to being internals, not intended for public use. Please use the {@link createHmac} method to create Hmac instances.
|
|
490
490
|
*/
|
|
491
491
|
class Hmac extends stream.Transform {
|
|
492
492
|
private constructor();
|
|
@@ -512,64 +512,98 @@ declare module "node:crypto" {
|
|
|
512
512
|
* @since v0.1.94
|
|
513
513
|
* @param encoding The `encoding` of the return value.
|
|
514
514
|
*/
|
|
515
|
-
digest():
|
|
515
|
+
digest(): NonSharedBuffer;
|
|
516
516
|
digest(encoding: BinaryToTextEncoding): string;
|
|
517
517
|
}
|
|
518
|
+
type KeyFormat = "pem" | "der" | "jwk";
|
|
518
519
|
type KeyObjectType = "secret" | "public" | "private";
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
520
|
+
type PublicKeyExportType = "pkcs1" | "spki";
|
|
521
|
+
type PrivateKeyExportType = "pkcs1" | "pkcs8" | "sec1";
|
|
522
|
+
type KeyExportOptions =
|
|
523
|
+
| SymmetricKeyExportOptions
|
|
524
|
+
| PublicKeyExportOptions
|
|
525
|
+
| PrivateKeyExportOptions
|
|
526
|
+
| JwkKeyExportOptions;
|
|
527
|
+
interface SymmetricKeyExportOptions {
|
|
528
|
+
format?: "buffer" | undefined;
|
|
529
|
+
}
|
|
530
|
+
interface PublicKeyExportOptions<T extends PublicKeyExportType = PublicKeyExportType> {
|
|
531
|
+
type: T;
|
|
532
|
+
format: Exclude<KeyFormat, "jwk">;
|
|
533
|
+
}
|
|
534
|
+
interface PrivateKeyExportOptions<T extends PrivateKeyExportType = PrivateKeyExportType> {
|
|
535
|
+
type: T;
|
|
536
|
+
format: Exclude<KeyFormat, "jwk">;
|
|
522
537
|
cipher?: string | undefined;
|
|
523
538
|
passphrase?: string | Buffer | undefined;
|
|
524
539
|
}
|
|
525
540
|
interface JwkKeyExportOptions {
|
|
526
541
|
format: "jwk";
|
|
527
542
|
}
|
|
528
|
-
interface
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
543
|
+
interface KeyPairExportOptions<
|
|
544
|
+
TPublic extends PublicKeyExportType = PublicKeyExportType,
|
|
545
|
+
TPrivate extends PrivateKeyExportType = PrivateKeyExportType,
|
|
546
|
+
> {
|
|
547
|
+
publicKeyEncoding?: PublicKeyExportOptions<TPublic> | JwkKeyExportOptions | undefined;
|
|
548
|
+
privateKeyEncoding?: PrivateKeyExportOptions<TPrivate> | JwkKeyExportOptions | undefined;
|
|
549
|
+
}
|
|
550
|
+
type KeyExportResult<T, Default> = T extends { format: infer F extends KeyFormat }
|
|
551
|
+
? { der: NonSharedBuffer; jwk: webcrypto.JsonWebKey; pem: string }[F]
|
|
552
|
+
: Default;
|
|
553
|
+
interface KeyPairExportResult<T extends KeyPairExportOptions> {
|
|
554
|
+
publicKey: KeyExportResult<T["publicKeyEncoding"], KeyObject>;
|
|
555
|
+
privateKey: KeyExportResult<T["privateKeyEncoding"], KeyObject>;
|
|
556
|
+
}
|
|
557
|
+
type KeyPairExportCallback<T extends KeyPairExportOptions> = (
|
|
558
|
+
err: Error | null,
|
|
559
|
+
publicKey: KeyExportResult<T["publicKeyEncoding"], KeyObject>,
|
|
560
|
+
privateKey: KeyExportResult<T["privateKeyEncoding"], KeyObject>,
|
|
561
|
+
) => void;
|
|
562
|
+
type MLDSAKeyType = `ml-dsa-${44 | 65 | 87}`;
|
|
563
|
+
type MLKEMKeyType = `ml-kem-${1024 | 512 | 768}`;
|
|
564
|
+
type SLHDSAKeyType = `slh-dsa-${"sha2" | "shake"}-${128 | 192 | 256}${"f" | "s"}`;
|
|
565
|
+
type AsymmetricKeyType =
|
|
566
|
+
| "dh"
|
|
567
|
+
| "dsa"
|
|
568
|
+
| "ec"
|
|
569
|
+
| "ed25519"
|
|
570
|
+
| "ed448"
|
|
571
|
+
| MLDSAKeyType
|
|
572
|
+
| MLKEMKeyType
|
|
573
|
+
| "rsa-pss"
|
|
574
|
+
| "rsa"
|
|
575
|
+
| SLHDSAKeyType
|
|
576
|
+
| "x25519"
|
|
577
|
+
| "x448";
|
|
544
578
|
interface AsymmetricKeyDetails {
|
|
545
579
|
/**
|
|
546
580
|
* Key size in bits (RSA, DSA).
|
|
547
581
|
*/
|
|
548
|
-
modulusLength?: number
|
|
582
|
+
modulusLength?: number;
|
|
549
583
|
/**
|
|
550
584
|
* Public exponent (RSA).
|
|
551
585
|
*/
|
|
552
|
-
publicExponent?: bigint
|
|
586
|
+
publicExponent?: bigint;
|
|
553
587
|
/**
|
|
554
588
|
* Name of the message digest (RSA-PSS).
|
|
555
589
|
*/
|
|
556
|
-
hashAlgorithm?: string
|
|
590
|
+
hashAlgorithm?: string;
|
|
557
591
|
/**
|
|
558
592
|
* Name of the message digest used by MGF1 (RSA-PSS).
|
|
559
593
|
*/
|
|
560
|
-
mgf1HashAlgorithm?: string
|
|
594
|
+
mgf1HashAlgorithm?: string;
|
|
561
595
|
/**
|
|
562
596
|
* Minimal salt length in bytes (RSA-PSS).
|
|
563
597
|
*/
|
|
564
|
-
saltLength?: number
|
|
598
|
+
saltLength?: number;
|
|
565
599
|
/**
|
|
566
600
|
* Size of q in bits (DSA).
|
|
567
601
|
*/
|
|
568
|
-
divisorLength?: number
|
|
602
|
+
divisorLength?: number;
|
|
569
603
|
/**
|
|
570
604
|
* Name of the curve (EC).
|
|
571
605
|
*/
|
|
572
|
-
namedCurve?: string
|
|
606
|
+
namedCurve?: string;
|
|
573
607
|
}
|
|
574
608
|
/**
|
|
575
609
|
* Node.js uses a `KeyObject` class to represent a symmetric or asymmetric key,
|
|
@@ -607,24 +641,14 @@ declare module "node:crypto" {
|
|
|
607
641
|
*/
|
|
608
642
|
static from(key: webcrypto.CryptoKey): KeyObject;
|
|
609
643
|
/**
|
|
610
|
-
* For asymmetric keys, this property represents the type of the key.
|
|
611
|
-
* types
|
|
612
|
-
*
|
|
613
|
-
* * `'rsa'` (OID 1.2.840.113549.1.1.1)
|
|
614
|
-
* * `'rsa-pss'` (OID 1.2.840.113549.1.1.10)
|
|
615
|
-
* * `'dsa'` (OID 1.2.840.10040.4.1)
|
|
616
|
-
* * `'ec'` (OID 1.2.840.10045.2.1)
|
|
617
|
-
* * `'x25519'` (OID 1.3.101.110)
|
|
618
|
-
* * `'x448'` (OID 1.3.101.111)
|
|
619
|
-
* * `'ed25519'` (OID 1.3.101.112)
|
|
620
|
-
* * `'ed448'` (OID 1.3.101.113)
|
|
621
|
-
* * `'dh'` (OID 1.2.840.113549.1.3.1)
|
|
644
|
+
* For asymmetric keys, this property represents the type of the key. See the
|
|
645
|
+
* supported [asymmetric key types](https://nodejs.org/docs/latest-v25.x/api/crypto.html#asymmetric-key-types).
|
|
622
646
|
*
|
|
623
647
|
* This property is `undefined` for unrecognized `KeyObject` types and symmetric
|
|
624
648
|
* keys.
|
|
625
649
|
* @since v11.6.0
|
|
626
650
|
*/
|
|
627
|
-
asymmetricKeyType?:
|
|
651
|
+
asymmetricKeyType?: AsymmetricKeyType;
|
|
628
652
|
/**
|
|
629
653
|
* This property exists only on asymmetric keys. Depending on the type of the key,
|
|
630
654
|
* this object contains information about the key. None of the information obtained
|
|
@@ -638,7 +662,7 @@ declare module "node:crypto" {
|
|
|
638
662
|
* Other key details might be exposed via this API using additional attributes.
|
|
639
663
|
* @since v15.7.0
|
|
640
664
|
*/
|
|
641
|
-
asymmetricKeyDetails?: AsymmetricKeyDetails
|
|
665
|
+
asymmetricKeyDetails?: AsymmetricKeyDetails;
|
|
642
666
|
/**
|
|
643
667
|
* For symmetric keys, the following encoding options can be used:
|
|
644
668
|
*
|
|
@@ -662,9 +686,7 @@ declare module "node:crypto" {
|
|
|
662
686
|
* PKCS#1 and SEC1 encryption.
|
|
663
687
|
* @since v11.6.0
|
|
664
688
|
*/
|
|
665
|
-
export(options
|
|
666
|
-
export(options?: KeyExportOptions<"der">): Buffer;
|
|
667
|
-
export(options?: JwkKeyExportOptions): JsonWebKey;
|
|
689
|
+
export<T extends KeyExportOptions = {}>(options?: T): KeyExportResult<T, NonSharedBuffer>;
|
|
668
690
|
/**
|
|
669
691
|
* Returns `true` or `false` depending on whether the keys have exactly the same
|
|
670
692
|
* type, value, and parameters. This method is not [constant time](https://en.wikipedia.org/wiki/Timing_attack).
|
|
@@ -677,7 +699,7 @@ declare module "node:crypto" {
|
|
|
677
699
|
* property is `undefined` for asymmetric keys.
|
|
678
700
|
* @since v11.6.0
|
|
679
701
|
*/
|
|
680
|
-
symmetricKeySize?: number
|
|
702
|
+
symmetricKeySize?: number;
|
|
681
703
|
/**
|
|
682
704
|
* Converts a `KeyObject` instance to a `CryptoKey`.
|
|
683
705
|
* @since 22.10.0
|
|
@@ -912,8 +934,8 @@ declare module "node:crypto" {
|
|
|
912
934
|
* @param inputEncoding The `encoding` of the data.
|
|
913
935
|
* @param outputEncoding The `encoding` of the return value.
|
|
914
936
|
*/
|
|
915
|
-
update(data: BinaryLike):
|
|
916
|
-
update(data: string, inputEncoding: Encoding):
|
|
937
|
+
update(data: BinaryLike): NonSharedBuffer;
|
|
938
|
+
update(data: string, inputEncoding: Encoding): NonSharedBuffer;
|
|
917
939
|
update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
|
|
918
940
|
update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
|
|
919
941
|
/**
|
|
@@ -924,7 +946,7 @@ declare module "node:crypto" {
|
|
|
924
946
|
* @param outputEncoding The `encoding` of the return value.
|
|
925
947
|
* @return Any remaining enciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned.
|
|
926
948
|
*/
|
|
927
|
-
final():
|
|
949
|
+
final(): NonSharedBuffer;
|
|
928
950
|
final(outputEncoding: BufferEncoding): string;
|
|
929
951
|
/**
|
|
930
952
|
* When using block encryption algorithms, the `Cipheriv` class will automatically
|
|
@@ -950,7 +972,7 @@ declare module "node:crypto" {
|
|
|
950
972
|
plaintextLength: number;
|
|
951
973
|
},
|
|
952
974
|
): this;
|
|
953
|
-
getAuthTag():
|
|
975
|
+
getAuthTag(): NonSharedBuffer;
|
|
954
976
|
}
|
|
955
977
|
interface CipherGCM extends Cipheriv {
|
|
956
978
|
setAAD(
|
|
@@ -959,7 +981,7 @@ declare module "node:crypto" {
|
|
|
959
981
|
plaintextLength: number;
|
|
960
982
|
},
|
|
961
983
|
): this;
|
|
962
|
-
getAuthTag():
|
|
984
|
+
getAuthTag(): NonSharedBuffer;
|
|
963
985
|
}
|
|
964
986
|
interface CipherOCB extends Cipheriv {
|
|
965
987
|
setAAD(
|
|
@@ -968,7 +990,7 @@ declare module "node:crypto" {
|
|
|
968
990
|
plaintextLength: number;
|
|
969
991
|
},
|
|
970
992
|
): this;
|
|
971
|
-
getAuthTag():
|
|
993
|
+
getAuthTag(): NonSharedBuffer;
|
|
972
994
|
}
|
|
973
995
|
interface CipherChaCha20Poly1305 extends Cipheriv {
|
|
974
996
|
setAAD(
|
|
@@ -977,7 +999,7 @@ declare module "node:crypto" {
|
|
|
977
999
|
plaintextLength: number;
|
|
978
1000
|
},
|
|
979
1001
|
): this;
|
|
980
|
-
getAuthTag():
|
|
1002
|
+
getAuthTag(): NonSharedBuffer;
|
|
981
1003
|
}
|
|
982
1004
|
/**
|
|
983
1005
|
* Creates and returns a `Decipheriv` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
|
|
@@ -1162,8 +1184,8 @@ declare module "node:crypto" {
|
|
|
1162
1184
|
* @param inputEncoding The `encoding` of the `data` string.
|
|
1163
1185
|
* @param outputEncoding The `encoding` of the return value.
|
|
1164
1186
|
*/
|
|
1165
|
-
update(data: NodeJS.ArrayBufferView):
|
|
1166
|
-
update(data: string, inputEncoding: Encoding):
|
|
1187
|
+
update(data: NodeJS.ArrayBufferView): NonSharedBuffer;
|
|
1188
|
+
update(data: string, inputEncoding: Encoding): NonSharedBuffer;
|
|
1167
1189
|
update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
|
|
1168
1190
|
update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
|
|
1169
1191
|
/**
|
|
@@ -1174,7 +1196,7 @@ declare module "node:crypto" {
|
|
|
1174
1196
|
* @param outputEncoding The `encoding` of the return value.
|
|
1175
1197
|
* @return Any remaining deciphered contents. If `outputEncoding` is specified, a string is returned. If an `outputEncoding` is not provided, a {@link Buffer} is returned.
|
|
1176
1198
|
*/
|
|
1177
|
-
final():
|
|
1199
|
+
final(): NonSharedBuffer;
|
|
1178
1200
|
final(outputEncoding: BufferEncoding): string;
|
|
1179
1201
|
/**
|
|
1180
1202
|
* When data has been encrypted without standard block padding, calling `decipher.setAutoPadding(false)` will disable automatic padding to prevent `decipher.final()` from checking for and
|
|
@@ -1229,14 +1251,14 @@ declare module "node:crypto" {
|
|
|
1229
1251
|
interface PrivateKeyInput {
|
|
1230
1252
|
key: string | Buffer;
|
|
1231
1253
|
format?: KeyFormat | undefined;
|
|
1232
|
-
type?:
|
|
1254
|
+
type?: PrivateKeyExportType | undefined;
|
|
1233
1255
|
passphrase?: string | Buffer | undefined;
|
|
1234
1256
|
encoding?: string | undefined;
|
|
1235
1257
|
}
|
|
1236
1258
|
interface PublicKeyInput {
|
|
1237
1259
|
key: string | Buffer;
|
|
1238
1260
|
format?: KeyFormat | undefined;
|
|
1239
|
-
type?:
|
|
1261
|
+
type?: PublicKeyExportType | undefined;
|
|
1240
1262
|
encoding?: string | undefined;
|
|
1241
1263
|
}
|
|
1242
1264
|
/**
|
|
@@ -1289,7 +1311,7 @@ declare module "node:crypto" {
|
|
|
1289
1311
|
},
|
|
1290
1312
|
): KeyObject;
|
|
1291
1313
|
interface JsonWebKeyInput {
|
|
1292
|
-
key: JsonWebKey;
|
|
1314
|
+
key: webcrypto.JsonWebKey;
|
|
1293
1315
|
format: "jwk";
|
|
1294
1316
|
}
|
|
1295
1317
|
/**
|
|
@@ -1336,6 +1358,7 @@ declare module "node:crypto" {
|
|
|
1336
1358
|
* @since v0.1.92
|
|
1337
1359
|
* @param options `stream.Writable` options
|
|
1338
1360
|
*/
|
|
1361
|
+
// TODO: signing algorithm type
|
|
1339
1362
|
function createSign(algorithm: string, options?: stream.WritableOptions): Sign;
|
|
1340
1363
|
type DSAEncoding = "der" | "ieee-p1363";
|
|
1341
1364
|
interface SigningOptions {
|
|
@@ -1345,6 +1368,7 @@ declare module "node:crypto" {
|
|
|
1345
1368
|
padding?: number | undefined;
|
|
1346
1369
|
saltLength?: number | undefined;
|
|
1347
1370
|
dsaEncoding?: DSAEncoding | undefined;
|
|
1371
|
+
context?: ArrayBuffer | NodeJS.ArrayBufferView | undefined;
|
|
1348
1372
|
}
|
|
1349
1373
|
interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
|
|
1350
1374
|
interface SignKeyObjectInput extends SigningOptions {
|
|
@@ -1446,7 +1470,7 @@ declare module "node:crypto" {
|
|
|
1446
1470
|
* called. Multiple calls to `sign.sign()` will result in an error being thrown.
|
|
1447
1471
|
* @since v0.1.92
|
|
1448
1472
|
*/
|
|
1449
|
-
sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput):
|
|
1473
|
+
sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput): NonSharedBuffer;
|
|
1450
1474
|
sign(
|
|
1451
1475
|
privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
|
|
1452
1476
|
outputFormat: BinaryToTextEncoding,
|
|
@@ -1605,7 +1629,7 @@ declare module "node:crypto" {
|
|
|
1605
1629
|
* @since v0.5.0
|
|
1606
1630
|
* @param encoding The `encoding` of the return value.
|
|
1607
1631
|
*/
|
|
1608
|
-
generateKeys():
|
|
1632
|
+
generateKeys(): NonSharedBuffer;
|
|
1609
1633
|
generateKeys(encoding: BinaryToTextEncoding): string;
|
|
1610
1634
|
/**
|
|
1611
1635
|
* Computes the shared secret using `otherPublicKey` as the other
|
|
@@ -1620,8 +1644,16 @@ declare module "node:crypto" {
|
|
|
1620
1644
|
* @param inputEncoding The `encoding` of an `otherPublicKey` string.
|
|
1621
1645
|
* @param outputEncoding The `encoding` of the return value.
|
|
1622
1646
|
*/
|
|
1623
|
-
computeSecret(
|
|
1624
|
-
|
|
1647
|
+
computeSecret(
|
|
1648
|
+
otherPublicKey: NodeJS.ArrayBufferView,
|
|
1649
|
+
inputEncoding?: null,
|
|
1650
|
+
outputEncoding?: null,
|
|
1651
|
+
): NonSharedBuffer;
|
|
1652
|
+
computeSecret(
|
|
1653
|
+
otherPublicKey: string,
|
|
1654
|
+
inputEncoding: BinaryToTextEncoding,
|
|
1655
|
+
outputEncoding?: null,
|
|
1656
|
+
): NonSharedBuffer;
|
|
1625
1657
|
computeSecret(
|
|
1626
1658
|
otherPublicKey: NodeJS.ArrayBufferView,
|
|
1627
1659
|
inputEncoding: null,
|
|
@@ -1639,7 +1671,7 @@ declare module "node:crypto" {
|
|
|
1639
1671
|
* @since v0.5.0
|
|
1640
1672
|
* @param encoding The `encoding` of the return value.
|
|
1641
1673
|
*/
|
|
1642
|
-
getPrime():
|
|
1674
|
+
getPrime(): NonSharedBuffer;
|
|
1643
1675
|
getPrime(encoding: BinaryToTextEncoding): string;
|
|
1644
1676
|
/**
|
|
1645
1677
|
* Returns the Diffie-Hellman generator in the specified `encoding`.
|
|
@@ -1648,7 +1680,7 @@ declare module "node:crypto" {
|
|
|
1648
1680
|
* @since v0.5.0
|
|
1649
1681
|
* @param encoding The `encoding` of the return value.
|
|
1650
1682
|
*/
|
|
1651
|
-
getGenerator():
|
|
1683
|
+
getGenerator(): NonSharedBuffer;
|
|
1652
1684
|
getGenerator(encoding: BinaryToTextEncoding): string;
|
|
1653
1685
|
/**
|
|
1654
1686
|
* Returns the Diffie-Hellman public key in the specified `encoding`.
|
|
@@ -1657,7 +1689,7 @@ declare module "node:crypto" {
|
|
|
1657
1689
|
* @since v0.5.0
|
|
1658
1690
|
* @param encoding The `encoding` of the return value.
|
|
1659
1691
|
*/
|
|
1660
|
-
getPublicKey():
|
|
1692
|
+
getPublicKey(): NonSharedBuffer;
|
|
1661
1693
|
getPublicKey(encoding: BinaryToTextEncoding): string;
|
|
1662
1694
|
/**
|
|
1663
1695
|
* Returns the Diffie-Hellman private key in the specified `encoding`.
|
|
@@ -1666,7 +1698,7 @@ declare module "node:crypto" {
|
|
|
1666
1698
|
* @since v0.5.0
|
|
1667
1699
|
* @param encoding The `encoding` of the return value.
|
|
1668
1700
|
*/
|
|
1669
|
-
getPrivateKey():
|
|
1701
|
+
getPrivateKey(): NonSharedBuffer;
|
|
1670
1702
|
getPrivateKey(encoding: BinaryToTextEncoding): string;
|
|
1671
1703
|
/**
|
|
1672
1704
|
* Sets the Diffie-Hellman public key. If the `encoding` argument is provided, `publicKey` is expected
|
|
@@ -1810,7 +1842,7 @@ declare module "node:crypto" {
|
|
|
1810
1842
|
iterations: number,
|
|
1811
1843
|
keylen: number,
|
|
1812
1844
|
digest: string,
|
|
1813
|
-
callback: (err: Error | null, derivedKey:
|
|
1845
|
+
callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
|
|
1814
1846
|
): void;
|
|
1815
1847
|
/**
|
|
1816
1848
|
* Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2)
|
|
@@ -1847,7 +1879,7 @@ declare module "node:crypto" {
|
|
|
1847
1879
|
iterations: number,
|
|
1848
1880
|
keylen: number,
|
|
1849
1881
|
digest: string,
|
|
1850
|
-
):
|
|
1882
|
+
): NonSharedBuffer;
|
|
1851
1883
|
/**
|
|
1852
1884
|
* Generates cryptographically strong pseudorandom data. The `size` argument
|
|
1853
1885
|
* is a number indicating the number of bytes to generate.
|
|
@@ -1900,10 +1932,10 @@ declare module "node:crypto" {
|
|
|
1900
1932
|
* @param size The number of bytes to generate. The `size` must not be larger than `2**31 - 1`.
|
|
1901
1933
|
* @return if the `callback` function is not provided.
|
|
1902
1934
|
*/
|
|
1903
|
-
function randomBytes(size: number):
|
|
1904
|
-
function randomBytes(size: number, callback: (err: Error | null, buf:
|
|
1905
|
-
function pseudoRandomBytes(size: number):
|
|
1906
|
-
function pseudoRandomBytes(size: number, callback: (err: Error | null, buf:
|
|
1935
|
+
function randomBytes(size: number): NonSharedBuffer;
|
|
1936
|
+
function randomBytes(size: number, callback: (err: Error | null, buf: NonSharedBuffer) => void): void;
|
|
1937
|
+
function pseudoRandomBytes(size: number): NonSharedBuffer;
|
|
1938
|
+
function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: NonSharedBuffer) => void): void;
|
|
1907
1939
|
/**
|
|
1908
1940
|
* Return a random integer `n` such that `min <= n < max`. This
|
|
1909
1941
|
* implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).
|
|
@@ -2133,14 +2165,14 @@ declare module "node:crypto" {
|
|
|
2133
2165
|
password: BinaryLike,
|
|
2134
2166
|
salt: BinaryLike,
|
|
2135
2167
|
keylen: number,
|
|
2136
|
-
callback: (err: Error | null, derivedKey:
|
|
2168
|
+
callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
|
|
2137
2169
|
): void;
|
|
2138
2170
|
function scrypt(
|
|
2139
2171
|
password: BinaryLike,
|
|
2140
2172
|
salt: BinaryLike,
|
|
2141
2173
|
keylen: number,
|
|
2142
2174
|
options: ScryptOptions,
|
|
2143
|
-
callback: (err: Error | null, derivedKey:
|
|
2175
|
+
callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
|
|
2144
2176
|
): void;
|
|
2145
2177
|
/**
|
|
2146
2178
|
* Provides a synchronous [scrypt](https://en.wikipedia.org/wiki/Scrypt) implementation. Scrypt is a password-based
|
|
@@ -2172,7 +2204,12 @@ declare module "node:crypto" {
|
|
|
2172
2204
|
* ```
|
|
2173
2205
|
* @since v10.5.0
|
|
2174
2206
|
*/
|
|
2175
|
-
function scryptSync(
|
|
2207
|
+
function scryptSync(
|
|
2208
|
+
password: BinaryLike,
|
|
2209
|
+
salt: BinaryLike,
|
|
2210
|
+
keylen: number,
|
|
2211
|
+
options?: ScryptOptions,
|
|
2212
|
+
): NonSharedBuffer;
|
|
2176
2213
|
interface RsaPublicKey {
|
|
2177
2214
|
key: KeyLike;
|
|
2178
2215
|
padding?: number | undefined;
|
|
@@ -2201,7 +2238,7 @@ declare module "node:crypto" {
|
|
|
2201
2238
|
function publicEncrypt(
|
|
2202
2239
|
key: RsaPublicKey | RsaPrivateKey | KeyLike,
|
|
2203
2240
|
buffer: NodeJS.ArrayBufferView | string,
|
|
2204
|
-
):
|
|
2241
|
+
): NonSharedBuffer;
|
|
2205
2242
|
/**
|
|
2206
2243
|
* Decrypts `buffer` with `key`.`buffer` was previously encrypted using
|
|
2207
2244
|
* the corresponding private key, for example using {@link privateEncrypt}.
|
|
@@ -2216,7 +2253,7 @@ declare module "node:crypto" {
|
|
|
2216
2253
|
function publicDecrypt(
|
|
2217
2254
|
key: RsaPublicKey | RsaPrivateKey | KeyLike,
|
|
2218
2255
|
buffer: NodeJS.ArrayBufferView | string,
|
|
2219
|
-
):
|
|
2256
|
+
): NonSharedBuffer;
|
|
2220
2257
|
/**
|
|
2221
2258
|
* Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
|
|
2222
2259
|
* the corresponding public key, for example using {@link publicEncrypt}.
|
|
@@ -2225,7 +2262,10 @@ declare module "node:crypto" {
|
|
|
2225
2262
|
* object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_OAEP_PADDING`.
|
|
2226
2263
|
* @since v0.11.14
|
|
2227
2264
|
*/
|
|
2228
|
-
function privateDecrypt(
|
|
2265
|
+
function privateDecrypt(
|
|
2266
|
+
privateKey: RsaPrivateKey | KeyLike,
|
|
2267
|
+
buffer: NodeJS.ArrayBufferView | string,
|
|
2268
|
+
): NonSharedBuffer;
|
|
2229
2269
|
/**
|
|
2230
2270
|
* Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
|
|
2231
2271
|
* the corresponding public key, for example using {@link publicDecrypt}.
|
|
@@ -2234,7 +2274,10 @@ declare module "node:crypto" {
|
|
|
2234
2274
|
* object, the `padding` property can be passed. Otherwise, this function uses `RSA_PKCS1_PADDING`.
|
|
2235
2275
|
* @since v1.1.0
|
|
2236
2276
|
*/
|
|
2237
|
-
function privateEncrypt(
|
|
2277
|
+
function privateEncrypt(
|
|
2278
|
+
privateKey: RsaPrivateKey | KeyLike,
|
|
2279
|
+
buffer: NodeJS.ArrayBufferView | string,
|
|
2280
|
+
): NonSharedBuffer;
|
|
2238
2281
|
/**
|
|
2239
2282
|
* ```js
|
|
2240
2283
|
* const {
|
|
@@ -2363,7 +2406,7 @@ declare module "node:crypto" {
|
|
|
2363
2406
|
inputEncoding?: BinaryToTextEncoding,
|
|
2364
2407
|
outputEncoding?: "latin1" | "hex" | "base64" | "base64url",
|
|
2365
2408
|
format?: "uncompressed" | "compressed" | "hybrid",
|
|
2366
|
-
):
|
|
2409
|
+
): NonSharedBuffer | string;
|
|
2367
2410
|
/**
|
|
2368
2411
|
* Generates private and public EC Diffie-Hellman key values, and returns
|
|
2369
2412
|
* the public key in the specified `format` and `encoding`. This key should be
|
|
@@ -2376,7 +2419,7 @@ declare module "node:crypto" {
|
|
|
2376
2419
|
* @param encoding The `encoding` of the return value.
|
|
2377
2420
|
* @param [format='uncompressed']
|
|
2378
2421
|
*/
|
|
2379
|
-
generateKeys():
|
|
2422
|
+
generateKeys(): NonSharedBuffer;
|
|
2380
2423
|
generateKeys(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
|
|
2381
2424
|
/**
|
|
2382
2425
|
* Computes the shared secret using `otherPublicKey` as the other
|
|
@@ -2395,8 +2438,8 @@ declare module "node:crypto" {
|
|
|
2395
2438
|
* @param inputEncoding The `encoding` of the `otherPublicKey` string.
|
|
2396
2439
|
* @param outputEncoding The `encoding` of the return value.
|
|
2397
2440
|
*/
|
|
2398
|
-
computeSecret(otherPublicKey: NodeJS.ArrayBufferView):
|
|
2399
|
-
computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding):
|
|
2441
|
+
computeSecret(otherPublicKey: NodeJS.ArrayBufferView): NonSharedBuffer;
|
|
2442
|
+
computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): NonSharedBuffer;
|
|
2400
2443
|
computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string;
|
|
2401
2444
|
computeSecret(
|
|
2402
2445
|
otherPublicKey: string,
|
|
@@ -2410,7 +2453,7 @@ declare module "node:crypto" {
|
|
|
2410
2453
|
* @param encoding The `encoding` of the return value.
|
|
2411
2454
|
* @return The EC Diffie-Hellman in the specified `encoding`.
|
|
2412
2455
|
*/
|
|
2413
|
-
getPrivateKey():
|
|
2456
|
+
getPrivateKey(): NonSharedBuffer;
|
|
2414
2457
|
getPrivateKey(encoding: BinaryToTextEncoding): string;
|
|
2415
2458
|
/**
|
|
2416
2459
|
* The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified the point will be returned in`'uncompressed'` format.
|
|
@@ -2422,7 +2465,7 @@ declare module "node:crypto" {
|
|
|
2422
2465
|
* @param [format='uncompressed']
|
|
2423
2466
|
* @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
|
|
2424
2467
|
*/
|
|
2425
|
-
getPublicKey(encoding?: null, format?: ECDHKeyFormat):
|
|
2468
|
+
getPublicKey(encoding?: null, format?: ECDHKeyFormat): NonSharedBuffer;
|
|
2426
2469
|
getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
|
|
2427
2470
|
/**
|
|
2428
2471
|
* Sets the EC Diffie-Hellman private key.
|
|
@@ -2472,66 +2515,27 @@ declare module "node:crypto" {
|
|
|
2472
2515
|
* @since v6.6.0
|
|
2473
2516
|
*/
|
|
2474
2517
|
function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
|
|
2475
|
-
|
|
2476
|
-
type KeyFormat = "pem" | "der" | "jwk";
|
|
2477
|
-
interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
|
|
2478
|
-
format: T;
|
|
2479
|
-
cipher?: string | undefined;
|
|
2480
|
-
passphrase?: string | undefined;
|
|
2481
|
-
}
|
|
2482
|
-
interface KeyPairKeyObjectResult {
|
|
2483
|
-
publicKey: KeyObject;
|
|
2484
|
-
privateKey: KeyObject;
|
|
2485
|
-
}
|
|
2486
|
-
interface ED25519KeyPairKeyObjectOptions {}
|
|
2487
|
-
interface ED448KeyPairKeyObjectOptions {}
|
|
2488
|
-
interface X25519KeyPairKeyObjectOptions {}
|
|
2489
|
-
interface X448KeyPairKeyObjectOptions {}
|
|
2490
|
-
interface ECKeyPairKeyObjectOptions {
|
|
2491
|
-
/**
|
|
2492
|
-
* Name of the curve to use
|
|
2493
|
-
*/
|
|
2494
|
-
namedCurve: string;
|
|
2495
|
-
/**
|
|
2496
|
-
* Must be `'named'` or `'explicit'`. Default: `'named'`.
|
|
2497
|
-
*/
|
|
2498
|
-
paramEncoding?: "explicit" | "named" | undefined;
|
|
2499
|
-
}
|
|
2500
|
-
interface RSAKeyPairKeyObjectOptions {
|
|
2501
|
-
/**
|
|
2502
|
-
* Key size in bits
|
|
2503
|
-
*/
|
|
2504
|
-
modulusLength: number;
|
|
2505
|
-
/**
|
|
2506
|
-
* Public exponent
|
|
2507
|
-
* @default 0x10001
|
|
2508
|
-
*/
|
|
2509
|
-
publicExponent?: number | undefined;
|
|
2510
|
-
}
|
|
2511
|
-
interface RSAPSSKeyPairKeyObjectOptions {
|
|
2512
|
-
/**
|
|
2513
|
-
* Key size in bits
|
|
2514
|
-
*/
|
|
2515
|
-
modulusLength: number;
|
|
2518
|
+
interface DHKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
|
|
2516
2519
|
/**
|
|
2517
|
-
*
|
|
2518
|
-
* @default 0x10001
|
|
2520
|
+
* The prime parameter
|
|
2519
2521
|
*/
|
|
2520
|
-
|
|
2522
|
+
prime?: Buffer | undefined;
|
|
2521
2523
|
/**
|
|
2522
|
-
*
|
|
2524
|
+
* Prime length in bits
|
|
2523
2525
|
*/
|
|
2524
|
-
|
|
2526
|
+
primeLength?: number | undefined;
|
|
2525
2527
|
/**
|
|
2526
|
-
*
|
|
2528
|
+
* Custom generator
|
|
2529
|
+
* @default 2
|
|
2527
2530
|
*/
|
|
2528
|
-
|
|
2531
|
+
generator?: number | undefined;
|
|
2529
2532
|
/**
|
|
2530
|
-
*
|
|
2533
|
+
* Diffie-Hellman group name
|
|
2534
|
+
* @see {@link getDiffieHellman}
|
|
2531
2535
|
*/
|
|
2532
|
-
|
|
2536
|
+
groupName?: string | undefined;
|
|
2533
2537
|
}
|
|
2534
|
-
interface
|
|
2538
|
+
interface DSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
|
|
2535
2539
|
/**
|
|
2536
2540
|
* Key size in bits
|
|
2537
2541
|
*/
|
|
@@ -2541,25 +2545,22 @@ declare module "node:crypto" {
|
|
|
2541
2545
|
*/
|
|
2542
2546
|
divisorLength: number;
|
|
2543
2547
|
}
|
|
2544
|
-
interface
|
|
2548
|
+
interface ECKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8" | "sec1"> {
|
|
2545
2549
|
/**
|
|
2546
|
-
*
|
|
2550
|
+
* Name of the curve to use
|
|
2547
2551
|
*/
|
|
2548
|
-
|
|
2552
|
+
namedCurve: string;
|
|
2549
2553
|
/**
|
|
2550
|
-
*
|
|
2551
|
-
* @default
|
|
2554
|
+
* Must be `'named'` or `'explicit'`
|
|
2555
|
+
* @default 'named'
|
|
2552
2556
|
*/
|
|
2553
|
-
|
|
2554
|
-
publicKeyEncoding: {
|
|
2555
|
-
type: "pkcs1" | "spki";
|
|
2556
|
-
format: PubF;
|
|
2557
|
-
};
|
|
2558
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2559
|
-
type: "pkcs1" | "pkcs8";
|
|
2560
|
-
};
|
|
2557
|
+
paramEncoding?: "explicit" | "named" | undefined;
|
|
2561
2558
|
}
|
|
2562
|
-
interface
|
|
2559
|
+
interface ED25519KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2560
|
+
interface ED448KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2561
|
+
interface MLDSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2562
|
+
interface MLKEMKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2563
|
+
interface RSAPSSKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
|
|
2563
2564
|
/**
|
|
2564
2565
|
* Key size in bits
|
|
2565
2566
|
*/
|
|
@@ -2572,92 +2573,33 @@ declare module "node:crypto" {
|
|
|
2572
2573
|
/**
|
|
2573
2574
|
* Name of the message digest
|
|
2574
2575
|
*/
|
|
2575
|
-
hashAlgorithm?: string;
|
|
2576
|
+
hashAlgorithm?: string | undefined;
|
|
2576
2577
|
/**
|
|
2577
2578
|
* Name of the message digest used by MGF1
|
|
2578
2579
|
*/
|
|
2579
|
-
mgf1HashAlgorithm?: string;
|
|
2580
|
+
mgf1HashAlgorithm?: string | undefined;
|
|
2580
2581
|
/**
|
|
2581
2582
|
* Minimal salt length in bytes
|
|
2582
2583
|
*/
|
|
2583
|
-
saltLength?: string;
|
|
2584
|
-
publicKeyEncoding: {
|
|
2585
|
-
type: "spki";
|
|
2586
|
-
format: PubF;
|
|
2587
|
-
};
|
|
2588
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2589
|
-
type: "pkcs8";
|
|
2590
|
-
};
|
|
2584
|
+
saltLength?: string | undefined;
|
|
2591
2585
|
}
|
|
2592
|
-
interface
|
|
2586
|
+
interface RSAKeyPairOptions extends KeyPairExportOptions<"pkcs1" | "spki", "pkcs1" | "pkcs8"> {
|
|
2593
2587
|
/**
|
|
2594
2588
|
* Key size in bits
|
|
2595
2589
|
*/
|
|
2596
2590
|
modulusLength: number;
|
|
2597
2591
|
/**
|
|
2598
|
-
*
|
|
2592
|
+
* Public exponent
|
|
2593
|
+
* @default 0x10001
|
|
2599
2594
|
*/
|
|
2600
|
-
|
|
2601
|
-
publicKeyEncoding: {
|
|
2602
|
-
type: "spki";
|
|
2603
|
-
format: PubF;
|
|
2604
|
-
};
|
|
2605
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2606
|
-
type: "pkcs8";
|
|
2607
|
-
};
|
|
2608
|
-
}
|
|
2609
|
-
interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> extends ECKeyPairKeyObjectOptions {
|
|
2610
|
-
publicKeyEncoding: {
|
|
2611
|
-
type: "pkcs1" | "spki";
|
|
2612
|
-
format: PubF;
|
|
2613
|
-
};
|
|
2614
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2615
|
-
type: "sec1" | "pkcs8";
|
|
2616
|
-
};
|
|
2617
|
-
}
|
|
2618
|
-
interface ED25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2619
|
-
publicKeyEncoding: {
|
|
2620
|
-
type: "spki";
|
|
2621
|
-
format: PubF;
|
|
2622
|
-
};
|
|
2623
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2624
|
-
type: "pkcs8";
|
|
2625
|
-
};
|
|
2626
|
-
}
|
|
2627
|
-
interface ED448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2628
|
-
publicKeyEncoding: {
|
|
2629
|
-
type: "spki";
|
|
2630
|
-
format: PubF;
|
|
2631
|
-
};
|
|
2632
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2633
|
-
type: "pkcs8";
|
|
2634
|
-
};
|
|
2635
|
-
}
|
|
2636
|
-
interface X25519KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2637
|
-
publicKeyEncoding: {
|
|
2638
|
-
type: "spki";
|
|
2639
|
-
format: PubF;
|
|
2640
|
-
};
|
|
2641
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2642
|
-
type: "pkcs8";
|
|
2643
|
-
};
|
|
2644
|
-
}
|
|
2645
|
-
interface X448KeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
|
2646
|
-
publicKeyEncoding: {
|
|
2647
|
-
type: "spki";
|
|
2648
|
-
format: PubF;
|
|
2649
|
-
};
|
|
2650
|
-
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
|
2651
|
-
type: "pkcs8";
|
|
2652
|
-
};
|
|
2653
|
-
}
|
|
2654
|
-
interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
|
|
2655
|
-
publicKey: T1;
|
|
2656
|
-
privateKey: T2;
|
|
2595
|
+
publicExponent?: number | undefined;
|
|
2657
2596
|
}
|
|
2597
|
+
interface SLHDSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2598
|
+
interface X25519KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2599
|
+
interface X448KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
|
|
2658
2600
|
/**
|
|
2659
2601
|
* Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
|
|
2660
|
-
* Ed25519, Ed448, X25519, X448, and
|
|
2602
|
+
* Ed25519, Ed448, X25519, X448, DH, and ML-DSA are currently supported.
|
|
2661
2603
|
*
|
|
2662
2604
|
* If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
|
|
2663
2605
|
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
|
|
@@ -2694,144 +2636,57 @@ declare module "node:crypto" {
|
|
|
2694
2636
|
* When PEM encoding was selected, the respective key will be a string, otherwise
|
|
2695
2637
|
* it will be a buffer containing the data encoded as DER.
|
|
2696
2638
|
* @since v10.12.0
|
|
2697
|
-
* @param type
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
options: RSAKeyPairOptions<"pem", "der">,
|
|
2706
|
-
): KeyPairSyncResult<string, Buffer>;
|
|
2707
|
-
function generateKeyPairSync(
|
|
2708
|
-
type: "rsa",
|
|
2709
|
-
options: RSAKeyPairOptions<"der", "pem">,
|
|
2710
|
-
): KeyPairSyncResult<Buffer, string>;
|
|
2711
|
-
function generateKeyPairSync(
|
|
2712
|
-
type: "rsa",
|
|
2713
|
-
options: RSAKeyPairOptions<"der", "der">,
|
|
2714
|
-
): KeyPairSyncResult<Buffer, Buffer>;
|
|
2715
|
-
function generateKeyPairSync(type: "rsa", options: RSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2716
|
-
function generateKeyPairSync(
|
|
2717
|
-
type: "rsa-pss",
|
|
2718
|
-
options: RSAPSSKeyPairOptions<"pem", "pem">,
|
|
2719
|
-
): KeyPairSyncResult<string, string>;
|
|
2720
|
-
function generateKeyPairSync(
|
|
2721
|
-
type: "rsa-pss",
|
|
2722
|
-
options: RSAPSSKeyPairOptions<"pem", "der">,
|
|
2723
|
-
): KeyPairSyncResult<string, Buffer>;
|
|
2724
|
-
function generateKeyPairSync(
|
|
2725
|
-
type: "rsa-pss",
|
|
2726
|
-
options: RSAPSSKeyPairOptions<"der", "pem">,
|
|
2727
|
-
): KeyPairSyncResult<Buffer, string>;
|
|
2728
|
-
function generateKeyPairSync(
|
|
2729
|
-
type: "rsa-pss",
|
|
2730
|
-
options: RSAPSSKeyPairOptions<"der", "der">,
|
|
2731
|
-
): KeyPairSyncResult<Buffer, Buffer>;
|
|
2732
|
-
function generateKeyPairSync(type: "rsa-pss", options: RSAPSSKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2733
|
-
function generateKeyPairSync(
|
|
2639
|
+
* @param type The asymmetric key type to generate. See the
|
|
2640
|
+
* supported [asymmetric key types](https://nodejs.org/docs/latest-v25.x/api/crypto.html#asymmetric-key-types).
|
|
2641
|
+
*/
|
|
2642
|
+
function generateKeyPairSync<T extends DHKeyPairOptions>(
|
|
2643
|
+
type: "dh",
|
|
2644
|
+
options: T,
|
|
2645
|
+
): KeyPairExportResult<T>;
|
|
2646
|
+
function generateKeyPairSync<T extends DSAKeyPairOptions>(
|
|
2734
2647
|
type: "dsa",
|
|
2735
|
-
options:
|
|
2736
|
-
):
|
|
2737
|
-
function generateKeyPairSync(
|
|
2738
|
-
type: "dsa",
|
|
2739
|
-
options: DSAKeyPairOptions<"pem", "der">,
|
|
2740
|
-
): KeyPairSyncResult<string, Buffer>;
|
|
2741
|
-
function generateKeyPairSync(
|
|
2742
|
-
type: "dsa",
|
|
2743
|
-
options: DSAKeyPairOptions<"der", "pem">,
|
|
2744
|
-
): KeyPairSyncResult<Buffer, string>;
|
|
2745
|
-
function generateKeyPairSync(
|
|
2746
|
-
type: "dsa",
|
|
2747
|
-
options: DSAKeyPairOptions<"der", "der">,
|
|
2748
|
-
): KeyPairSyncResult<Buffer, Buffer>;
|
|
2749
|
-
function generateKeyPairSync(type: "dsa", options: DSAKeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2750
|
-
function generateKeyPairSync(
|
|
2751
|
-
type: "ec",
|
|
2752
|
-
options: ECKeyPairOptions<"pem", "pem">,
|
|
2753
|
-
): KeyPairSyncResult<string, string>;
|
|
2754
|
-
function generateKeyPairSync(
|
|
2755
|
-
type: "ec",
|
|
2756
|
-
options: ECKeyPairOptions<"pem", "der">,
|
|
2757
|
-
): KeyPairSyncResult<string, Buffer>;
|
|
2758
|
-
function generateKeyPairSync(
|
|
2759
|
-
type: "ec",
|
|
2760
|
-
options: ECKeyPairOptions<"der", "pem">,
|
|
2761
|
-
): KeyPairSyncResult<Buffer, string>;
|
|
2762
|
-
function generateKeyPairSync(
|
|
2648
|
+
options: T,
|
|
2649
|
+
): KeyPairExportResult<T>;
|
|
2650
|
+
function generateKeyPairSync<T extends ECKeyPairOptions>(
|
|
2763
2651
|
type: "ec",
|
|
2764
|
-
options:
|
|
2765
|
-
):
|
|
2766
|
-
function generateKeyPairSync
|
|
2767
|
-
function generateKeyPairSync(
|
|
2652
|
+
options: T,
|
|
2653
|
+
): KeyPairExportResult<T>;
|
|
2654
|
+
function generateKeyPairSync<T extends ED25519KeyPairOptions = {}>(
|
|
2768
2655
|
type: "ed25519",
|
|
2769
|
-
options
|
|
2770
|
-
):
|
|
2771
|
-
function generateKeyPairSync(
|
|
2772
|
-
type: "ed25519",
|
|
2773
|
-
options: ED25519KeyPairOptions<"pem", "der">,
|
|
2774
|
-
): KeyPairSyncResult<string, Buffer>;
|
|
2775
|
-
function generateKeyPairSync(
|
|
2776
|
-
type: "ed25519",
|
|
2777
|
-
options: ED25519KeyPairOptions<"der", "pem">,
|
|
2778
|
-
): KeyPairSyncResult<Buffer, string>;
|
|
2779
|
-
function generateKeyPairSync(
|
|
2780
|
-
type: "ed25519",
|
|
2781
|
-
options: ED25519KeyPairOptions<"der", "der">,
|
|
2782
|
-
): KeyPairSyncResult<Buffer, Buffer>;
|
|
2783
|
-
function generateKeyPairSync(type: "ed25519", options?: ED25519KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2784
|
-
function generateKeyPairSync(
|
|
2785
|
-
type: "ed448",
|
|
2786
|
-
options: ED448KeyPairOptions<"pem", "pem">,
|
|
2787
|
-
): KeyPairSyncResult<string, string>;
|
|
2788
|
-
function generateKeyPairSync(
|
|
2789
|
-
type: "ed448",
|
|
2790
|
-
options: ED448KeyPairOptions<"pem", "der">,
|
|
2791
|
-
): KeyPairSyncResult<string, Buffer>;
|
|
2792
|
-
function generateKeyPairSync(
|
|
2656
|
+
options?: T,
|
|
2657
|
+
): KeyPairExportResult<T>;
|
|
2658
|
+
function generateKeyPairSync<T extends ED448KeyPairOptions = {}>(
|
|
2793
2659
|
type: "ed448",
|
|
2794
|
-
options
|
|
2795
|
-
):
|
|
2796
|
-
function generateKeyPairSync(
|
|
2797
|
-
type:
|
|
2798
|
-
options
|
|
2799
|
-
):
|
|
2800
|
-
function generateKeyPairSync
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2660
|
+
options?: T,
|
|
2661
|
+
): KeyPairExportResult<T>;
|
|
2662
|
+
function generateKeyPairSync<T extends MLDSAKeyPairOptions = {}>(
|
|
2663
|
+
type: MLDSAKeyType,
|
|
2664
|
+
options?: T,
|
|
2665
|
+
): KeyPairExportResult<T>;
|
|
2666
|
+
function generateKeyPairSync<T extends MLKEMKeyPairOptions = {}>(
|
|
2667
|
+
type: MLKEMKeyType,
|
|
2668
|
+
options?: T,
|
|
2669
|
+
): KeyPairExportResult<T>;
|
|
2670
|
+
function generateKeyPairSync<T extends RSAPSSKeyPairOptions>(
|
|
2671
|
+
type: "rsa-pss",
|
|
2672
|
+
options: T,
|
|
2673
|
+
): KeyPairExportResult<T>;
|
|
2674
|
+
function generateKeyPairSync<T extends RSAKeyPairOptions>(
|
|
2675
|
+
type: "rsa",
|
|
2676
|
+
options: T,
|
|
2677
|
+
): KeyPairExportResult<T>;
|
|
2678
|
+
function generateKeyPairSync<T extends SLHDSAKeyPairOptions = {}>(
|
|
2679
|
+
type: SLHDSAKeyType,
|
|
2680
|
+
options?: T,
|
|
2681
|
+
): KeyPairExportResult<T>;
|
|
2682
|
+
function generateKeyPairSync<T extends X25519KeyPairOptions = {}>(
|
|
2814
2683
|
type: "x25519",
|
|
2815
|
-
options
|
|
2816
|
-
):
|
|
2817
|
-
function generateKeyPairSync
|
|
2818
|
-
function generateKeyPairSync(
|
|
2684
|
+
options?: T,
|
|
2685
|
+
): KeyPairExportResult<T>;
|
|
2686
|
+
function generateKeyPairSync<T extends X448KeyPairOptions = {}>(
|
|
2819
2687
|
type: "x448",
|
|
2820
|
-
options
|
|
2821
|
-
):
|
|
2822
|
-
function generateKeyPairSync(
|
|
2823
|
-
type: "x448",
|
|
2824
|
-
options: X448KeyPairOptions<"pem", "der">,
|
|
2825
|
-
): KeyPairSyncResult<string, Buffer>;
|
|
2826
|
-
function generateKeyPairSync(
|
|
2827
|
-
type: "x448",
|
|
2828
|
-
options: X448KeyPairOptions<"der", "pem">,
|
|
2829
|
-
): KeyPairSyncResult<Buffer, string>;
|
|
2830
|
-
function generateKeyPairSync(
|
|
2831
|
-
type: "x448",
|
|
2832
|
-
options: X448KeyPairOptions<"der", "der">,
|
|
2833
|
-
): KeyPairSyncResult<Buffer, Buffer>;
|
|
2834
|
-
function generateKeyPairSync(type: "x448", options?: X448KeyPairKeyObjectOptions): KeyPairKeyObjectResult;
|
|
2688
|
+
options?: T,
|
|
2689
|
+
): KeyPairExportResult<T>;
|
|
2835
2690
|
/**
|
|
2836
2691
|
* Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
|
|
2837
2692
|
* Ed25519, Ed448, X25519, X448, and DH are currently supported.
|
|
@@ -2869,455 +2724,126 @@ declare module "node:crypto" {
|
|
|
2869
2724
|
* If this method is invoked as its `util.promisify()` ed version, it returns
|
|
2870
2725
|
* a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
|
|
2871
2726
|
* @since v10.12.0
|
|
2872
|
-
* @param type
|
|
2727
|
+
* @param type The asymmetric key type to generate. See the
|
|
2728
|
+
* supported [asymmetric key types](https://nodejs.org/docs/latest-v25.x/api/crypto.html#asymmetric-key-types).
|
|
2873
2729
|
*/
|
|
2874
|
-
function generateKeyPair(
|
|
2875
|
-
type: "
|
|
2876
|
-
options:
|
|
2877
|
-
callback:
|
|
2878
|
-
): void;
|
|
2879
|
-
function generateKeyPair(
|
|
2880
|
-
type: "rsa",
|
|
2881
|
-
options: RSAKeyPairOptions<"pem", "der">,
|
|
2882
|
-
callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
|
|
2883
|
-
): void;
|
|
2884
|
-
function generateKeyPair(
|
|
2885
|
-
type: "rsa",
|
|
2886
|
-
options: RSAKeyPairOptions<"der", "pem">,
|
|
2887
|
-
callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
|
|
2888
|
-
): void;
|
|
2889
|
-
function generateKeyPair(
|
|
2890
|
-
type: "rsa",
|
|
2891
|
-
options: RSAKeyPairOptions<"der", "der">,
|
|
2892
|
-
callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
|
|
2893
|
-
): void;
|
|
2894
|
-
function generateKeyPair(
|
|
2895
|
-
type: "rsa",
|
|
2896
|
-
options: RSAKeyPairKeyObjectOptions,
|
|
2897
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2898
|
-
): void;
|
|
2899
|
-
function generateKeyPair(
|
|
2900
|
-
type: "rsa-pss",
|
|
2901
|
-
options: RSAPSSKeyPairOptions<"pem", "pem">,
|
|
2902
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2903
|
-
): void;
|
|
2904
|
-
function generateKeyPair(
|
|
2905
|
-
type: "rsa-pss",
|
|
2906
|
-
options: RSAPSSKeyPairOptions<"pem", "der">,
|
|
2907
|
-
callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
|
|
2908
|
-
): void;
|
|
2909
|
-
function generateKeyPair(
|
|
2910
|
-
type: "rsa-pss",
|
|
2911
|
-
options: RSAPSSKeyPairOptions<"der", "pem">,
|
|
2912
|
-
callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
|
|
2913
|
-
): void;
|
|
2914
|
-
function generateKeyPair(
|
|
2915
|
-
type: "rsa-pss",
|
|
2916
|
-
options: RSAPSSKeyPairOptions<"der", "der">,
|
|
2917
|
-
callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
|
|
2918
|
-
): void;
|
|
2919
|
-
function generateKeyPair(
|
|
2920
|
-
type: "rsa-pss",
|
|
2921
|
-
options: RSAPSSKeyPairKeyObjectOptions,
|
|
2922
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2923
|
-
): void;
|
|
2924
|
-
function generateKeyPair(
|
|
2925
|
-
type: "dsa",
|
|
2926
|
-
options: DSAKeyPairOptions<"pem", "pem">,
|
|
2927
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2928
|
-
): void;
|
|
2929
|
-
function generateKeyPair(
|
|
2930
|
-
type: "dsa",
|
|
2931
|
-
options: DSAKeyPairOptions<"pem", "der">,
|
|
2932
|
-
callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
|
|
2730
|
+
function generateKeyPair<T extends DHKeyPairOptions>(
|
|
2731
|
+
type: "dh",
|
|
2732
|
+
options: T,
|
|
2733
|
+
callback: KeyPairExportCallback<T>,
|
|
2933
2734
|
): void;
|
|
2934
|
-
function generateKeyPair(
|
|
2735
|
+
function generateKeyPair<T extends DSAKeyPairOptions>(
|
|
2935
2736
|
type: "dsa",
|
|
2936
|
-
options:
|
|
2937
|
-
callback:
|
|
2737
|
+
options: T,
|
|
2738
|
+
callback: KeyPairExportCallback<T>,
|
|
2938
2739
|
): void;
|
|
2939
|
-
function generateKeyPair(
|
|
2940
|
-
type: "dsa",
|
|
2941
|
-
options: DSAKeyPairOptions<"der", "der">,
|
|
2942
|
-
callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
|
|
2943
|
-
): void;
|
|
2944
|
-
function generateKeyPair(
|
|
2945
|
-
type: "dsa",
|
|
2946
|
-
options: DSAKeyPairKeyObjectOptions,
|
|
2947
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2948
|
-
): void;
|
|
2949
|
-
function generateKeyPair(
|
|
2950
|
-
type: "ec",
|
|
2951
|
-
options: ECKeyPairOptions<"pem", "pem">,
|
|
2952
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2953
|
-
): void;
|
|
2954
|
-
function generateKeyPair(
|
|
2740
|
+
function generateKeyPair<T extends ECKeyPairOptions>(
|
|
2955
2741
|
type: "ec",
|
|
2956
|
-
options:
|
|
2957
|
-
callback:
|
|
2742
|
+
options: T,
|
|
2743
|
+
callback: KeyPairExportCallback<T>,
|
|
2958
2744
|
): void;
|
|
2959
|
-
function generateKeyPair(
|
|
2960
|
-
type: "ec",
|
|
2961
|
-
options: ECKeyPairOptions<"der", "pem">,
|
|
2962
|
-
callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void,
|
|
2963
|
-
): void;
|
|
2964
|
-
function generateKeyPair(
|
|
2965
|
-
type: "ec",
|
|
2966
|
-
options: ECKeyPairOptions<"der", "der">,
|
|
2967
|
-
callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
|
|
2968
|
-
): void;
|
|
2969
|
-
function generateKeyPair(
|
|
2970
|
-
type: "ec",
|
|
2971
|
-
options: ECKeyPairKeyObjectOptions,
|
|
2972
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2973
|
-
): void;
|
|
2974
|
-
function generateKeyPair(
|
|
2975
|
-
type: "ed25519",
|
|
2976
|
-
options: ED25519KeyPairOptions<"pem", "pem">,
|
|
2977
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
2978
|
-
): void;
|
|
2979
|
-
function generateKeyPair(
|
|
2980
|
-
type: "ed25519",
|
|
2981
|
-
options: ED25519KeyPairOptions<"pem", "der">,
|
|
2982
|
-
callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
|
|
2983
|
-
): void;
|
|
2984
|
-
function generateKeyPair(
|
|
2745
|
+
function generateKeyPair<T extends ED25519KeyPairOptions = {}>(
|
|
2985
2746
|
type: "ed25519",
|
|
2986
|
-
options:
|
|
2987
|
-
callback:
|
|
2988
|
-
): void;
|
|
2989
|
-
function generateKeyPair(
|
|
2990
|
-
type: "ed25519",
|
|
2991
|
-
options: ED25519KeyPairOptions<"der", "der">,
|
|
2992
|
-
callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
|
|
2993
|
-
): void;
|
|
2994
|
-
function generateKeyPair(
|
|
2995
|
-
type: "ed25519",
|
|
2996
|
-
options: ED25519KeyPairKeyObjectOptions | undefined,
|
|
2997
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2998
|
-
): void;
|
|
2999
|
-
function generateKeyPair(
|
|
3000
|
-
type: "ed448",
|
|
3001
|
-
options: ED448KeyPairOptions<"pem", "pem">,
|
|
3002
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
3003
|
-
): void;
|
|
3004
|
-
function generateKeyPair(
|
|
3005
|
-
type: "ed448",
|
|
3006
|
-
options: ED448KeyPairOptions<"pem", "der">,
|
|
3007
|
-
callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
|
|
2747
|
+
options: T | undefined,
|
|
2748
|
+
callback: KeyPairExportCallback<T>,
|
|
3008
2749
|
): void;
|
|
3009
|
-
function generateKeyPair(
|
|
2750
|
+
function generateKeyPair<T extends ED448KeyPairOptions = {}>(
|
|
3010
2751
|
type: "ed448",
|
|
3011
|
-
options:
|
|
3012
|
-
callback:
|
|
2752
|
+
options: T | undefined,
|
|
2753
|
+
callback: KeyPairExportCallback<T>,
|
|
3013
2754
|
): void;
|
|
3014
|
-
function generateKeyPair(
|
|
3015
|
-
type:
|
|
3016
|
-
options:
|
|
3017
|
-
callback:
|
|
2755
|
+
function generateKeyPair<T extends MLDSAKeyPairOptions = {}>(
|
|
2756
|
+
type: MLDSAKeyType,
|
|
2757
|
+
options: T | undefined,
|
|
2758
|
+
callback: KeyPairExportCallback<T>,
|
|
3018
2759
|
): void;
|
|
3019
|
-
function generateKeyPair(
|
|
3020
|
-
type:
|
|
3021
|
-
options:
|
|
3022
|
-
callback:
|
|
2760
|
+
function generateKeyPair<T extends MLKEMKeyPairOptions = {}>(
|
|
2761
|
+
type: MLKEMKeyType,
|
|
2762
|
+
options: T | undefined,
|
|
2763
|
+
callback: KeyPairExportCallback<T>,
|
|
3023
2764
|
): void;
|
|
3024
|
-
function generateKeyPair(
|
|
3025
|
-
type: "
|
|
3026
|
-
options:
|
|
3027
|
-
callback:
|
|
2765
|
+
function generateKeyPair<T extends RSAPSSKeyPairOptions>(
|
|
2766
|
+
type: "rsa-pss",
|
|
2767
|
+
options: T,
|
|
2768
|
+
callback: KeyPairExportCallback<T>,
|
|
3028
2769
|
): void;
|
|
3029
|
-
function generateKeyPair(
|
|
3030
|
-
type: "
|
|
3031
|
-
options:
|
|
3032
|
-
callback:
|
|
2770
|
+
function generateKeyPair<T extends RSAKeyPairOptions>(
|
|
2771
|
+
type: "rsa",
|
|
2772
|
+
options: T,
|
|
2773
|
+
callback: KeyPairExportCallback<T>,
|
|
3033
2774
|
): void;
|
|
3034
|
-
function generateKeyPair(
|
|
3035
|
-
type:
|
|
3036
|
-
options:
|
|
3037
|
-
callback:
|
|
2775
|
+
function generateKeyPair<T extends SLHDSAKeyPairOptions = {}>(
|
|
2776
|
+
type: SLHDSAKeyType,
|
|
2777
|
+
options: T | undefined,
|
|
2778
|
+
callback: KeyPairExportCallback<T>,
|
|
3038
2779
|
): void;
|
|
3039
|
-
function generateKeyPair(
|
|
2780
|
+
function generateKeyPair<T extends X25519KeyPairOptions = {}>(
|
|
3040
2781
|
type: "x25519",
|
|
3041
|
-
options:
|
|
3042
|
-
callback:
|
|
2782
|
+
options: T | undefined,
|
|
2783
|
+
callback: KeyPairExportCallback<T>,
|
|
3043
2784
|
): void;
|
|
3044
|
-
function generateKeyPair(
|
|
3045
|
-
type: "x25519",
|
|
3046
|
-
options: X25519KeyPairKeyObjectOptions | undefined,
|
|
3047
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
3048
|
-
): void;
|
|
3049
|
-
function generateKeyPair(
|
|
3050
|
-
type: "x448",
|
|
3051
|
-
options: X448KeyPairOptions<"pem", "pem">,
|
|
3052
|
-
callback: (err: Error | null, publicKey: string, privateKey: string) => void,
|
|
3053
|
-
): void;
|
|
3054
|
-
function generateKeyPair(
|
|
3055
|
-
type: "x448",
|
|
3056
|
-
options: X448KeyPairOptions<"pem", "der">,
|
|
3057
|
-
callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void,
|
|
3058
|
-
): void;
|
|
3059
|
-
function generateKeyPair(
|
|
2785
|
+
function generateKeyPair<T extends X448KeyPairOptions = {}>(
|
|
3060
2786
|
type: "x448",
|
|
3061
|
-
options:
|
|
3062
|
-
callback:
|
|
3063
|
-
): void;
|
|
3064
|
-
function generateKeyPair(
|
|
3065
|
-
type: "x448",
|
|
3066
|
-
options: X448KeyPairOptions<"der", "der">,
|
|
3067
|
-
callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void,
|
|
3068
|
-
): void;
|
|
3069
|
-
function generateKeyPair(
|
|
3070
|
-
type: "x448",
|
|
3071
|
-
options: X448KeyPairKeyObjectOptions | undefined,
|
|
3072
|
-
callback: (err: Error | null, publicKey: KeyObject, privateKey: KeyObject) => void,
|
|
2787
|
+
options: T | undefined,
|
|
2788
|
+
callback: KeyPairExportCallback<T>,
|
|
3073
2789
|
): void;
|
|
3074
2790
|
namespace generateKeyPair {
|
|
3075
|
-
function __promisify__(
|
|
3076
|
-
type: "
|
|
3077
|
-
options:
|
|
3078
|
-
): Promise<
|
|
3079
|
-
|
|
3080
|
-
privateKey: string;
|
|
3081
|
-
}>;
|
|
3082
|
-
function __promisify__(
|
|
3083
|
-
type: "rsa",
|
|
3084
|
-
options: RSAKeyPairOptions<"pem", "der">,
|
|
3085
|
-
): Promise<{
|
|
3086
|
-
publicKey: string;
|
|
3087
|
-
privateKey: Buffer;
|
|
3088
|
-
}>;
|
|
3089
|
-
function __promisify__(
|
|
3090
|
-
type: "rsa",
|
|
3091
|
-
options: RSAKeyPairOptions<"der", "pem">,
|
|
3092
|
-
): Promise<{
|
|
3093
|
-
publicKey: Buffer;
|
|
3094
|
-
privateKey: string;
|
|
3095
|
-
}>;
|
|
3096
|
-
function __promisify__(
|
|
3097
|
-
type: "rsa",
|
|
3098
|
-
options: RSAKeyPairOptions<"der", "der">,
|
|
3099
|
-
): Promise<{
|
|
3100
|
-
publicKey: Buffer;
|
|
3101
|
-
privateKey: Buffer;
|
|
3102
|
-
}>;
|
|
3103
|
-
function __promisify__(type: "rsa", options: RSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
|
3104
|
-
function __promisify__(
|
|
3105
|
-
type: "rsa-pss",
|
|
3106
|
-
options: RSAPSSKeyPairOptions<"pem", "pem">,
|
|
3107
|
-
): Promise<{
|
|
3108
|
-
publicKey: string;
|
|
3109
|
-
privateKey: string;
|
|
3110
|
-
}>;
|
|
3111
|
-
function __promisify__(
|
|
3112
|
-
type: "rsa-pss",
|
|
3113
|
-
options: RSAPSSKeyPairOptions<"pem", "der">,
|
|
3114
|
-
): Promise<{
|
|
3115
|
-
publicKey: string;
|
|
3116
|
-
privateKey: Buffer;
|
|
3117
|
-
}>;
|
|
3118
|
-
function __promisify__(
|
|
3119
|
-
type: "rsa-pss",
|
|
3120
|
-
options: RSAPSSKeyPairOptions<"der", "pem">,
|
|
3121
|
-
): Promise<{
|
|
3122
|
-
publicKey: Buffer;
|
|
3123
|
-
privateKey: string;
|
|
3124
|
-
}>;
|
|
3125
|
-
function __promisify__(
|
|
3126
|
-
type: "rsa-pss",
|
|
3127
|
-
options: RSAPSSKeyPairOptions<"der", "der">,
|
|
3128
|
-
): Promise<{
|
|
3129
|
-
publicKey: Buffer;
|
|
3130
|
-
privateKey: Buffer;
|
|
3131
|
-
}>;
|
|
3132
|
-
function __promisify__(
|
|
3133
|
-
type: "rsa-pss",
|
|
3134
|
-
options: RSAPSSKeyPairKeyObjectOptions,
|
|
3135
|
-
): Promise<KeyPairKeyObjectResult>;
|
|
3136
|
-
function __promisify__(
|
|
3137
|
-
type: "dsa",
|
|
3138
|
-
options: DSAKeyPairOptions<"pem", "pem">,
|
|
3139
|
-
): Promise<{
|
|
3140
|
-
publicKey: string;
|
|
3141
|
-
privateKey: string;
|
|
3142
|
-
}>;
|
|
3143
|
-
function __promisify__(
|
|
3144
|
-
type: "dsa",
|
|
3145
|
-
options: DSAKeyPairOptions<"pem", "der">,
|
|
3146
|
-
): Promise<{
|
|
3147
|
-
publicKey: string;
|
|
3148
|
-
privateKey: Buffer;
|
|
3149
|
-
}>;
|
|
3150
|
-
function __promisify__(
|
|
3151
|
-
type: "dsa",
|
|
3152
|
-
options: DSAKeyPairOptions<"der", "pem">,
|
|
3153
|
-
): Promise<{
|
|
3154
|
-
publicKey: Buffer;
|
|
3155
|
-
privateKey: string;
|
|
3156
|
-
}>;
|
|
3157
|
-
function __promisify__(
|
|
2791
|
+
function __promisify__<T extends DHKeyPairOptions>(
|
|
2792
|
+
type: "dh",
|
|
2793
|
+
options: T,
|
|
2794
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2795
|
+
function __promisify__<T extends DSAKeyPairOptions>(
|
|
3158
2796
|
type: "dsa",
|
|
3159
|
-
options:
|
|
3160
|
-
): Promise<
|
|
3161
|
-
|
|
3162
|
-
privateKey: Buffer;
|
|
3163
|
-
}>;
|
|
3164
|
-
function __promisify__(type: "dsa", options: DSAKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
|
3165
|
-
function __promisify__(
|
|
2797
|
+
options: T,
|
|
2798
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2799
|
+
function __promisify__<T extends ECKeyPairOptions>(
|
|
3166
2800
|
type: "ec",
|
|
3167
|
-
options:
|
|
3168
|
-
): Promise<
|
|
3169
|
-
|
|
3170
|
-
privateKey: string;
|
|
3171
|
-
}>;
|
|
3172
|
-
function __promisify__(
|
|
3173
|
-
type: "ec",
|
|
3174
|
-
options: ECKeyPairOptions<"pem", "der">,
|
|
3175
|
-
): Promise<{
|
|
3176
|
-
publicKey: string;
|
|
3177
|
-
privateKey: Buffer;
|
|
3178
|
-
}>;
|
|
3179
|
-
function __promisify__(
|
|
3180
|
-
type: "ec",
|
|
3181
|
-
options: ECKeyPairOptions<"der", "pem">,
|
|
3182
|
-
): Promise<{
|
|
3183
|
-
publicKey: Buffer;
|
|
3184
|
-
privateKey: string;
|
|
3185
|
-
}>;
|
|
3186
|
-
function __promisify__(
|
|
3187
|
-
type: "ec",
|
|
3188
|
-
options: ECKeyPairOptions<"der", "der">,
|
|
3189
|
-
): Promise<{
|
|
3190
|
-
publicKey: Buffer;
|
|
3191
|
-
privateKey: Buffer;
|
|
3192
|
-
}>;
|
|
3193
|
-
function __promisify__(type: "ec", options: ECKeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
|
3194
|
-
function __promisify__(
|
|
3195
|
-
type: "ed25519",
|
|
3196
|
-
options: ED25519KeyPairOptions<"pem", "pem">,
|
|
3197
|
-
): Promise<{
|
|
3198
|
-
publicKey: string;
|
|
3199
|
-
privateKey: string;
|
|
3200
|
-
}>;
|
|
3201
|
-
function __promisify__(
|
|
3202
|
-
type: "ed25519",
|
|
3203
|
-
options: ED25519KeyPairOptions<"pem", "der">,
|
|
3204
|
-
): Promise<{
|
|
3205
|
-
publicKey: string;
|
|
3206
|
-
privateKey: Buffer;
|
|
3207
|
-
}>;
|
|
3208
|
-
function __promisify__(
|
|
3209
|
-
type: "ed25519",
|
|
3210
|
-
options: ED25519KeyPairOptions<"der", "pem">,
|
|
3211
|
-
): Promise<{
|
|
3212
|
-
publicKey: Buffer;
|
|
3213
|
-
privateKey: string;
|
|
3214
|
-
}>;
|
|
3215
|
-
function __promisify__(
|
|
2801
|
+
options: T,
|
|
2802
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2803
|
+
function __promisify__<T extends ED25519KeyPairOptions = {}>(
|
|
3216
2804
|
type: "ed25519",
|
|
3217
|
-
options
|
|
3218
|
-
): Promise<
|
|
3219
|
-
|
|
3220
|
-
privateKey: Buffer;
|
|
3221
|
-
}>;
|
|
3222
|
-
function __promisify__(
|
|
3223
|
-
type: "ed25519",
|
|
3224
|
-
options?: ED25519KeyPairKeyObjectOptions,
|
|
3225
|
-
): Promise<KeyPairKeyObjectResult>;
|
|
3226
|
-
function __promisify__(
|
|
3227
|
-
type: "ed448",
|
|
3228
|
-
options: ED448KeyPairOptions<"pem", "pem">,
|
|
3229
|
-
): Promise<{
|
|
3230
|
-
publicKey: string;
|
|
3231
|
-
privateKey: string;
|
|
3232
|
-
}>;
|
|
3233
|
-
function __promisify__(
|
|
3234
|
-
type: "ed448",
|
|
3235
|
-
options: ED448KeyPairOptions<"pem", "der">,
|
|
3236
|
-
): Promise<{
|
|
3237
|
-
publicKey: string;
|
|
3238
|
-
privateKey: Buffer;
|
|
3239
|
-
}>;
|
|
3240
|
-
function __promisify__(
|
|
2805
|
+
options?: T,
|
|
2806
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2807
|
+
function __promisify__<T extends ED448KeyPairOptions = {}>(
|
|
3241
2808
|
type: "ed448",
|
|
3242
|
-
options
|
|
3243
|
-
): Promise<
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
): Promise<{
|
|
3266
|
-
publicKey: string;
|
|
3267
|
-
privateKey: Buffer;
|
|
3268
|
-
}>;
|
|
3269
|
-
function __promisify__(
|
|
3270
|
-
type: "x25519",
|
|
3271
|
-
options: X25519KeyPairOptions<"der", "pem">,
|
|
3272
|
-
): Promise<{
|
|
3273
|
-
publicKey: Buffer;
|
|
3274
|
-
privateKey: string;
|
|
3275
|
-
}>;
|
|
3276
|
-
function __promisify__(
|
|
3277
|
-
type: "x25519",
|
|
3278
|
-
options: X25519KeyPairOptions<"der", "der">,
|
|
3279
|
-
): Promise<{
|
|
3280
|
-
publicKey: Buffer;
|
|
3281
|
-
privateKey: Buffer;
|
|
3282
|
-
}>;
|
|
3283
|
-
function __promisify__(
|
|
2809
|
+
options?: T,
|
|
2810
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2811
|
+
function __promisify__<T extends MLDSAKeyPairOptions = {}>(
|
|
2812
|
+
type: MLDSAKeyType,
|
|
2813
|
+
options?: T,
|
|
2814
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2815
|
+
function __promisify__<T extends MLKEMKeyPairOptions = {}>(
|
|
2816
|
+
type: MLKEMKeyType,
|
|
2817
|
+
options?: T,
|
|
2818
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2819
|
+
function __promisify__<T extends RSAPSSKeyPairOptions>(
|
|
2820
|
+
type: "rsa-pss",
|
|
2821
|
+
options: T,
|
|
2822
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2823
|
+
function __promisify__<T extends RSAKeyPairOptions>(
|
|
2824
|
+
type: "rsa",
|
|
2825
|
+
options: T,
|
|
2826
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2827
|
+
function __promisify__<T extends SLHDSAKeyPairOptions = {}>(
|
|
2828
|
+
type: SLHDSAKeyType,
|
|
2829
|
+
options?: T,
|
|
2830
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2831
|
+
function __promisify__<T extends X25519KeyPairOptions = {}>(
|
|
3284
2832
|
type: "x25519",
|
|
3285
|
-
options?:
|
|
3286
|
-
): Promise<
|
|
3287
|
-
function __promisify__(
|
|
3288
|
-
type: "x448",
|
|
3289
|
-
options: X448KeyPairOptions<"pem", "pem">,
|
|
3290
|
-
): Promise<{
|
|
3291
|
-
publicKey: string;
|
|
3292
|
-
privateKey: string;
|
|
3293
|
-
}>;
|
|
3294
|
-
function __promisify__(
|
|
2833
|
+
options?: T,
|
|
2834
|
+
): Promise<KeyPairExportResult<T>>;
|
|
2835
|
+
function __promisify__<T extends X448KeyPairOptions = {}>(
|
|
3295
2836
|
type: "x448",
|
|
3296
|
-
options
|
|
3297
|
-
): Promise<
|
|
3298
|
-
publicKey: string;
|
|
3299
|
-
privateKey: Buffer;
|
|
3300
|
-
}>;
|
|
3301
|
-
function __promisify__(
|
|
3302
|
-
type: "x448",
|
|
3303
|
-
options: X448KeyPairOptions<"der", "pem">,
|
|
3304
|
-
): Promise<{
|
|
3305
|
-
publicKey: Buffer;
|
|
3306
|
-
privateKey: string;
|
|
3307
|
-
}>;
|
|
3308
|
-
function __promisify__(
|
|
3309
|
-
type: "x448",
|
|
3310
|
-
options: X448KeyPairOptions<"der", "der">,
|
|
3311
|
-
): Promise<{
|
|
3312
|
-
publicKey: Buffer;
|
|
3313
|
-
privateKey: Buffer;
|
|
3314
|
-
}>;
|
|
3315
|
-
function __promisify__(type: "x448", options?: X448KeyPairKeyObjectOptions): Promise<KeyPairKeyObjectResult>;
|
|
2837
|
+
options?: T,
|
|
2838
|
+
): Promise<KeyPairExportResult<T>>;
|
|
3316
2839
|
}
|
|
3317
2840
|
/**
|
|
3318
2841
|
* Calculates and returns the signature for `data` using the given private key and
|
|
3319
2842
|
* algorithm. If `algorithm` is `null` or `undefined`, then the algorithm is
|
|
3320
|
-
* dependent upon the key type
|
|
2843
|
+
* dependent upon the key type.
|
|
2844
|
+
*
|
|
2845
|
+
* `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
|
|
2846
|
+
* ML-DSA.
|
|
3321
2847
|
*
|
|
3322
2848
|
* If `key` is not a `KeyObject`, this function behaves as if `key` had been
|
|
3323
2849
|
* passed to {@link createPrivateKey}. If it is an object, the following
|
|
@@ -3330,16 +2856,20 @@ declare module "node:crypto" {
|
|
|
3330
2856
|
algorithm: string | null | undefined,
|
|
3331
2857
|
data: NodeJS.ArrayBufferView,
|
|
3332
2858
|
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
|
|
3333
|
-
):
|
|
2859
|
+
): NonSharedBuffer;
|
|
3334
2860
|
function sign(
|
|
3335
2861
|
algorithm: string | null | undefined,
|
|
3336
2862
|
data: NodeJS.ArrayBufferView,
|
|
3337
2863
|
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
|
|
3338
|
-
callback: (error: Error | null, data:
|
|
2864
|
+
callback: (error: Error | null, data: NonSharedBuffer) => void,
|
|
3339
2865
|
): void;
|
|
3340
2866
|
/**
|
|
3341
|
-
* Verifies the given signature for `data` using the given key and algorithm. If
|
|
3342
|
-
*
|
|
2867
|
+
* Verifies the given signature for `data` using the given key and algorithm. If
|
|
2868
|
+
* `algorithm` is `null` or `undefined`, then the algorithm is dependent upon the
|
|
2869
|
+
* key type.
|
|
2870
|
+
*
|
|
2871
|
+
* `algorithm` is required to be `null` or `undefined` for Ed25519, Ed448, and
|
|
2872
|
+
* ML-DSA.
|
|
3343
2873
|
*
|
|
3344
2874
|
* If `key` is not a `KeyObject`, this function behaves as if `key` had been
|
|
3345
2875
|
* passed to {@link createPublicKey}. If it is an object, the following
|
|
@@ -3367,23 +2897,102 @@ declare module "node:crypto" {
|
|
|
3367
2897
|
callback: (error: Error | null, result: boolean) => void,
|
|
3368
2898
|
): void;
|
|
3369
2899
|
/**
|
|
3370
|
-
*
|
|
3371
|
-
*
|
|
3372
|
-
*
|
|
2900
|
+
* Key decapsulation using a KEM algorithm with a private key.
|
|
2901
|
+
*
|
|
2902
|
+
* Supported key types and their KEM algorithms are:
|
|
2903
|
+
*
|
|
2904
|
+
* * `'rsa'` RSA Secret Value Encapsulation
|
|
2905
|
+
* * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
|
|
2906
|
+
* * `'x25519'` DHKEM(X25519, HKDF-SHA256)
|
|
2907
|
+
* * `'x448'` DHKEM(X448, HKDF-SHA512)
|
|
2908
|
+
* * `'ml-kem-512'` ML-KEM
|
|
2909
|
+
* * `'ml-kem-768'` ML-KEM
|
|
2910
|
+
* * `'ml-kem-1024'` ML-KEM
|
|
2911
|
+
*
|
|
2912
|
+
* If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
|
|
2913
|
+
* passed to `crypto.createPrivateKey()`.
|
|
2914
|
+
*
|
|
2915
|
+
* If the `callback` function is provided this function uses libuv's threadpool.
|
|
2916
|
+
* @since v24.7.0
|
|
2917
|
+
*/
|
|
2918
|
+
function decapsulate(
|
|
2919
|
+
key: KeyLike | PrivateKeyInput | JsonWebKeyInput,
|
|
2920
|
+
ciphertext: ArrayBuffer | NodeJS.ArrayBufferView,
|
|
2921
|
+
): NonSharedBuffer;
|
|
2922
|
+
function decapsulate(
|
|
2923
|
+
key: KeyLike | PrivateKeyInput | JsonWebKeyInput,
|
|
2924
|
+
ciphertext: ArrayBuffer | NodeJS.ArrayBufferView,
|
|
2925
|
+
callback: (err: Error, sharedKey: NonSharedBuffer) => void,
|
|
2926
|
+
): void;
|
|
2927
|
+
/**
|
|
2928
|
+
* Computes the Diffie-Hellman shared secret based on a `privateKey` and a `publicKey`.
|
|
2929
|
+
* Both keys must have the same `asymmetricKeyType` and must support either the DH or
|
|
2930
|
+
* ECDH operation.
|
|
3373
2931
|
*
|
|
3374
2932
|
* If the `callback` function is provided this function uses libuv's threadpool.
|
|
3375
2933
|
* @since v13.9.0, v12.17.0
|
|
3376
2934
|
*/
|
|
3377
|
-
function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }):
|
|
2935
|
+
function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): NonSharedBuffer;
|
|
3378
2936
|
function diffieHellman(
|
|
3379
2937
|
options: { privateKey: KeyObject; publicKey: KeyObject },
|
|
3380
|
-
callback: (err: Error | null, secret:
|
|
2938
|
+
callback: (err: Error | null, secret: NonSharedBuffer) => void,
|
|
2939
|
+
): void;
|
|
2940
|
+
/**
|
|
2941
|
+
* Key encapsulation using a KEM algorithm with a public key.
|
|
2942
|
+
*
|
|
2943
|
+
* Supported key types and their KEM algorithms are:
|
|
2944
|
+
*
|
|
2945
|
+
* * `'rsa'` RSA Secret Value Encapsulation
|
|
2946
|
+
* * `'ec'` DHKEM(P-256, HKDF-SHA256), DHKEM(P-384, HKDF-SHA256), DHKEM(P-521, HKDF-SHA256)
|
|
2947
|
+
* * `'x25519'` DHKEM(X25519, HKDF-SHA256)
|
|
2948
|
+
* * `'x448'` DHKEM(X448, HKDF-SHA512)
|
|
2949
|
+
* * `'ml-kem-512'` ML-KEM
|
|
2950
|
+
* * `'ml-kem-768'` ML-KEM
|
|
2951
|
+
* * `'ml-kem-1024'` ML-KEM
|
|
2952
|
+
*
|
|
2953
|
+
* If `key` is not a {@link KeyObject}, this function behaves as if `key` had been
|
|
2954
|
+
* passed to `crypto.createPublicKey()`.
|
|
2955
|
+
*
|
|
2956
|
+
* If the `callback` function is provided this function uses libuv's threadpool.
|
|
2957
|
+
* @since v24.7.0
|
|
2958
|
+
*/
|
|
2959
|
+
function encapsulate(
|
|
2960
|
+
key: KeyLike | PublicKeyInput | JsonWebKeyInput,
|
|
2961
|
+
): { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer };
|
|
2962
|
+
function encapsulate(
|
|
2963
|
+
key: KeyLike | PublicKeyInput | JsonWebKeyInput,
|
|
2964
|
+
callback: (err: Error, result: { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer }) => void,
|
|
3381
2965
|
): void;
|
|
2966
|
+
interface OneShotDigestOptions {
|
|
2967
|
+
/**
|
|
2968
|
+
* Encoding used to encode the returned digest.
|
|
2969
|
+
* @default 'hex'
|
|
2970
|
+
*/
|
|
2971
|
+
outputEncoding?: BinaryToTextEncoding | "buffer" | undefined;
|
|
2972
|
+
/**
|
|
2973
|
+
* For XOF hash functions such as 'shake256', the outputLength option
|
|
2974
|
+
* can be used to specify the desired output length in bytes.
|
|
2975
|
+
*/
|
|
2976
|
+
outputLength?: number | undefined;
|
|
2977
|
+
}
|
|
2978
|
+
interface OneShotDigestOptionsWithStringEncoding extends OneShotDigestOptions {
|
|
2979
|
+
outputEncoding?: BinaryToTextEncoding | undefined;
|
|
2980
|
+
}
|
|
2981
|
+
interface OneShotDigestOptionsWithBufferEncoding extends OneShotDigestOptions {
|
|
2982
|
+
outputEncoding: "buffer";
|
|
2983
|
+
}
|
|
3382
2984
|
/**
|
|
3383
|
-
* A utility for creating one-shot hash digests of data. It can be faster than
|
|
3384
|
-
*
|
|
3385
|
-
*
|
|
3386
|
-
*
|
|
2985
|
+
* A utility for creating one-shot hash digests of data. It can be faster than
|
|
2986
|
+
* the object-based `crypto.createHash()` when hashing a smaller amount of data
|
|
2987
|
+
* (<= 5MB) that's readily available. If the data can be big or if it is streamed,
|
|
2988
|
+
* it's still recommended to use `crypto.createHash()` instead.
|
|
2989
|
+
*
|
|
2990
|
+
* The `algorithm` is dependent on the available algorithms supported by the
|
|
2991
|
+
* version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
|
|
2992
|
+
* On recent releases of OpenSSL, `openssl list -digest-algorithms` will
|
|
2993
|
+
* display the available digest algorithms.
|
|
2994
|
+
*
|
|
2995
|
+
* If `options` is a string, then it specifies the `outputEncoding`.
|
|
3387
2996
|
*
|
|
3388
2997
|
* Example:
|
|
3389
2998
|
*
|
|
@@ -3403,17 +3012,26 @@ declare module "node:crypto" {
|
|
|
3403
3012
|
* console.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));
|
|
3404
3013
|
* ```
|
|
3405
3014
|
* @since v21.7.0, v20.12.0
|
|
3406
|
-
* @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different
|
|
3407
|
-
*
|
|
3408
|
-
*
|
|
3015
|
+
* @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different
|
|
3016
|
+
* input encoding is desired for a string input, user could encode the string
|
|
3017
|
+
* into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing
|
|
3018
|
+
* the encoded `TypedArray` into this API instead.
|
|
3409
3019
|
*/
|
|
3410
|
-
function hash(algorithm: string, data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
|
|
3411
|
-
function hash(algorithm: string, data: BinaryLike, outputEncoding: "buffer"): Buffer;
|
|
3412
3020
|
function hash(
|
|
3413
3021
|
algorithm: string,
|
|
3414
3022
|
data: BinaryLike,
|
|
3415
|
-
|
|
3416
|
-
): string
|
|
3023
|
+
options?: OneShotDigestOptionsWithStringEncoding | BinaryToTextEncoding,
|
|
3024
|
+
): string;
|
|
3025
|
+
function hash(
|
|
3026
|
+
algorithm: string,
|
|
3027
|
+
data: BinaryLike,
|
|
3028
|
+
options: OneShotDigestOptionsWithBufferEncoding | "buffer",
|
|
3029
|
+
): NonSharedBuffer;
|
|
3030
|
+
function hash(
|
|
3031
|
+
algorithm: string,
|
|
3032
|
+
data: BinaryLike,
|
|
3033
|
+
options: OneShotDigestOptions | BinaryToTextEncoding | "buffer",
|
|
3034
|
+
): string | NonSharedBuffer;
|
|
3417
3035
|
type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts";
|
|
3418
3036
|
interface CipherInfoOptions {
|
|
3419
3037
|
/**
|
|
@@ -3577,23 +3195,23 @@ declare module "node:crypto" {
|
|
|
3577
3195
|
/**
|
|
3578
3196
|
* @default 'always'
|
|
3579
3197
|
*/
|
|
3580
|
-
subject?: "always" | "default" | "never";
|
|
3198
|
+
subject?: "always" | "default" | "never" | undefined;
|
|
3581
3199
|
/**
|
|
3582
3200
|
* @default true
|
|
3583
3201
|
*/
|
|
3584
|
-
wildcards?: boolean;
|
|
3202
|
+
wildcards?: boolean | undefined;
|
|
3585
3203
|
/**
|
|
3586
3204
|
* @default true
|
|
3587
3205
|
*/
|
|
3588
|
-
partialWildcards?: boolean;
|
|
3206
|
+
partialWildcards?: boolean | undefined;
|
|
3589
3207
|
/**
|
|
3590
3208
|
* @default false
|
|
3591
3209
|
*/
|
|
3592
|
-
multiLabelWildcards?: boolean;
|
|
3210
|
+
multiLabelWildcards?: boolean | undefined;
|
|
3593
3211
|
/**
|
|
3594
3212
|
* @default false
|
|
3595
3213
|
*/
|
|
3596
|
-
singleLabelSubdomains?: boolean;
|
|
3214
|
+
singleLabelSubdomains?: boolean | undefined;
|
|
3597
3215
|
}
|
|
3598
3216
|
/**
|
|
3599
3217
|
* Encapsulates an X509 certificate and provides read-only access to
|
|
@@ -3695,7 +3313,7 @@ declare module "node:crypto" {
|
|
|
3695
3313
|
* available.
|
|
3696
3314
|
* @since v15.9.0
|
|
3697
3315
|
*/
|
|
3698
|
-
readonly issuerCertificate
|
|
3316
|
+
readonly issuerCertificate: X509Certificate | undefined;
|
|
3699
3317
|
/**
|
|
3700
3318
|
* The public key `KeyObject` for this certificate.
|
|
3701
3319
|
* @since v15.6.0
|
|
@@ -3705,7 +3323,7 @@ declare module "node:crypto" {
|
|
|
3705
3323
|
* A `Buffer` containing the DER encoding of this certificate.
|
|
3706
3324
|
* @since v15.6.0
|
|
3707
3325
|
*/
|
|
3708
|
-
readonly raw:
|
|
3326
|
+
readonly raw: NonSharedBuffer;
|
|
3709
3327
|
/**
|
|
3710
3328
|
* The serial number of this certificate.
|
|
3711
3329
|
*
|
|
@@ -3715,6 +3333,16 @@ declare module "node:crypto" {
|
|
|
3715
3333
|
* @since v15.6.0
|
|
3716
3334
|
*/
|
|
3717
3335
|
readonly serialNumber: string;
|
|
3336
|
+
/**
|
|
3337
|
+
* The algorithm used to sign the certificate or `undefined` if the signature algorithm is unknown by OpenSSL.
|
|
3338
|
+
* @since v24.9.0
|
|
3339
|
+
*/
|
|
3340
|
+
readonly signatureAlgorithm: string | undefined;
|
|
3341
|
+
/**
|
|
3342
|
+
* The OID of the algorithm used to sign the certificate.
|
|
3343
|
+
* @since v24.9.0
|
|
3344
|
+
*/
|
|
3345
|
+
readonly signatureAlgorithmOid: string;
|
|
3718
3346
|
/**
|
|
3719
3347
|
* The date/time from which this certificate is considered valid.
|
|
3720
3348
|
* @since v15.6.0
|
|
@@ -3787,7 +3415,23 @@ declare module "node:crypto" {
|
|
|
3787
3415
|
*/
|
|
3788
3416
|
checkIP(ip: string): string | undefined;
|
|
3789
3417
|
/**
|
|
3790
|
-
* Checks whether this certificate was issued by the given `otherCert
|
|
3418
|
+
* Checks whether this certificate was potentially issued by the given `otherCert`
|
|
3419
|
+
* by comparing the certificate metadata.
|
|
3420
|
+
*
|
|
3421
|
+
* This is useful for pruning a list of possible issuer certificates which have been
|
|
3422
|
+
* selected using a more rudimentary filtering routine, i.e. just based on subject
|
|
3423
|
+
* and issuer names.
|
|
3424
|
+
*
|
|
3425
|
+
* Finally, to verify that this certificate's signature was produced by a private key
|
|
3426
|
+
* corresponding to `otherCert`'s public key use `x509.verify(publicKey)`
|
|
3427
|
+
* with `otherCert`'s public key represented as a `KeyObject`
|
|
3428
|
+
* like so
|
|
3429
|
+
*
|
|
3430
|
+
* ```js
|
|
3431
|
+
* if (!x509.verify(otherCert.publicKey)) {
|
|
3432
|
+
* throw new Error('otherCert did not issue x509');
|
|
3433
|
+
* }
|
|
3434
|
+
* ```
|
|
3791
3435
|
* @since v15.6.0
|
|
3792
3436
|
*/
|
|
3793
3437
|
checkIssued(otherCert: X509Certificate): boolean;
|
|
@@ -3970,7 +3614,136 @@ declare module "node:crypto" {
|
|
|
3970
3614
|
* @since v17.4.0
|
|
3971
3615
|
* @return Returns `typedArray`.
|
|
3972
3616
|
*/
|
|
3973
|
-
function getRandomValues<
|
|
3617
|
+
function getRandomValues<
|
|
3618
|
+
T extends Exclude<
|
|
3619
|
+
NodeJS.NonSharedTypedArray,
|
|
3620
|
+
NodeJS.NonSharedFloat16Array | NodeJS.NonSharedFloat32Array | NodeJS.NonSharedFloat64Array
|
|
3621
|
+
>,
|
|
3622
|
+
>(typedArray: T): T;
|
|
3623
|
+
type Argon2Algorithm = "argon2d" | "argon2i" | "argon2id";
|
|
3624
|
+
interface Argon2Parameters {
|
|
3625
|
+
/**
|
|
3626
|
+
* REQUIRED, this is the password for password hashing applications of Argon2.
|
|
3627
|
+
*/
|
|
3628
|
+
message: string | ArrayBuffer | NodeJS.ArrayBufferView;
|
|
3629
|
+
/**
|
|
3630
|
+
* REQUIRED, must be at least 8 bytes long. This is the salt for password hashing applications of Argon2.
|
|
3631
|
+
*/
|
|
3632
|
+
nonce: string | ArrayBuffer | NodeJS.ArrayBufferView;
|
|
3633
|
+
/**
|
|
3634
|
+
* REQUIRED, degree of parallelism determines how many computational chains (lanes)
|
|
3635
|
+
* can be run. Must be greater than 1 and less than `2**24-1`.
|
|
3636
|
+
*/
|
|
3637
|
+
parallelism: number;
|
|
3638
|
+
/**
|
|
3639
|
+
* REQUIRED, the length of the key to generate. Must be greater than 4 and
|
|
3640
|
+
* less than `2**32-1`.
|
|
3641
|
+
*/
|
|
3642
|
+
tagLength: number;
|
|
3643
|
+
/**
|
|
3644
|
+
* REQUIRED, memory cost in 1KiB blocks. Must be greater than
|
|
3645
|
+
* `8 * parallelism` and less than `2**32-1`. The actual number of blocks is rounded
|
|
3646
|
+
* down to the nearest multiple of `4 * parallelism`.
|
|
3647
|
+
*/
|
|
3648
|
+
memory: number;
|
|
3649
|
+
/**
|
|
3650
|
+
* REQUIRED, number of passes (iterations). Must be greater than 1 and less
|
|
3651
|
+
* than `2**32-1`.
|
|
3652
|
+
*/
|
|
3653
|
+
passes: number;
|
|
3654
|
+
/**
|
|
3655
|
+
* OPTIONAL, Random additional input,
|
|
3656
|
+
* similar to the salt, that should **NOT** be stored with the derived key. This is known as pepper in
|
|
3657
|
+
* password hashing applications. If used, must have a length not greater than `2**32-1` bytes.
|
|
3658
|
+
*/
|
|
3659
|
+
secret?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined;
|
|
3660
|
+
/**
|
|
3661
|
+
* OPTIONAL, Additional data to
|
|
3662
|
+
* be added to the hash, functionally equivalent to salt or secret, but meant for
|
|
3663
|
+
* non-random data. If used, must have a length not greater than `2**32-1` bytes.
|
|
3664
|
+
*/
|
|
3665
|
+
associatedData?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined;
|
|
3666
|
+
}
|
|
3667
|
+
/**
|
|
3668
|
+
* Provides an asynchronous [Argon2](https://www.rfc-editor.org/rfc/rfc9106.html) implementation. Argon2 is a password-based
|
|
3669
|
+
* key derivation function that is designed to be expensive computationally and
|
|
3670
|
+
* memory-wise in order to make brute-force attacks unrewarding.
|
|
3671
|
+
*
|
|
3672
|
+
* The `nonce` should be as unique as possible. It is recommended that a nonce is
|
|
3673
|
+
* random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
|
|
3674
|
+
*
|
|
3675
|
+
* When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
|
|
3676
|
+
* consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v25.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
|
|
3677
|
+
*
|
|
3678
|
+
* The `callback` function is called with two arguments: `err` and `derivedKey`.
|
|
3679
|
+
* `err` is an exception object when key derivation fails, otherwise `err` is
|
|
3680
|
+
* `null`. `derivedKey` is passed to the callback as a `Buffer`.
|
|
3681
|
+
*
|
|
3682
|
+
* An exception is thrown when any of the input arguments specify invalid values
|
|
3683
|
+
* or types.
|
|
3684
|
+
*
|
|
3685
|
+
* ```js
|
|
3686
|
+
* const { argon2, randomBytes } = await import('node:crypto');
|
|
3687
|
+
*
|
|
3688
|
+
* const parameters = {
|
|
3689
|
+
* message: 'password',
|
|
3690
|
+
* nonce: randomBytes(16),
|
|
3691
|
+
* parallelism: 4,
|
|
3692
|
+
* tagLength: 64,
|
|
3693
|
+
* memory: 65536,
|
|
3694
|
+
* passes: 3,
|
|
3695
|
+
* };
|
|
3696
|
+
*
|
|
3697
|
+
* argon2('argon2id', parameters, (err, derivedKey) => {
|
|
3698
|
+
* if (err) throw err;
|
|
3699
|
+
* console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
|
|
3700
|
+
* });
|
|
3701
|
+
* ```
|
|
3702
|
+
* @since v24.7.0
|
|
3703
|
+
* @param algorithm Variant of Argon2, one of `"argon2d"`, `"argon2i"` or `"argon2id"`.
|
|
3704
|
+
* @experimental
|
|
3705
|
+
*/
|
|
3706
|
+
function argon2(
|
|
3707
|
+
algorithm: Argon2Algorithm,
|
|
3708
|
+
parameters: Argon2Parameters,
|
|
3709
|
+
callback: (err: Error | null, derivedKey: NonSharedBuffer) => void,
|
|
3710
|
+
): void;
|
|
3711
|
+
/**
|
|
3712
|
+
* Provides a synchronous [Argon2][] implementation. Argon2 is a password-based
|
|
3713
|
+
* key derivation function that is designed to be expensive computationally and
|
|
3714
|
+
* memory-wise in order to make brute-force attacks unrewarding.
|
|
3715
|
+
*
|
|
3716
|
+
* The `nonce` should be as unique as possible. It is recommended that a nonce is
|
|
3717
|
+
* random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
|
|
3718
|
+
*
|
|
3719
|
+
* When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
|
|
3720
|
+
* consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v25.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
|
|
3721
|
+
*
|
|
3722
|
+
* An exception is thrown when key derivation fails, otherwise the derived key is
|
|
3723
|
+
* returned as a `Buffer`.
|
|
3724
|
+
*
|
|
3725
|
+
* An exception is thrown when any of the input arguments specify invalid values
|
|
3726
|
+
* or types.
|
|
3727
|
+
*
|
|
3728
|
+
* ```js
|
|
3729
|
+
* const { argon2Sync, randomBytes } = await import('node:crypto');
|
|
3730
|
+
*
|
|
3731
|
+
* const parameters = {
|
|
3732
|
+
* message: 'password',
|
|
3733
|
+
* nonce: randomBytes(16),
|
|
3734
|
+
* parallelism: 4,
|
|
3735
|
+
* tagLength: 64,
|
|
3736
|
+
* memory: 65536,
|
|
3737
|
+
* passes: 3,
|
|
3738
|
+
* };
|
|
3739
|
+
*
|
|
3740
|
+
* const derivedKey = argon2Sync('argon2id', parameters);
|
|
3741
|
+
* console.log(derivedKey.toString('hex')); // 'af91dad...9520f15'
|
|
3742
|
+
* ```
|
|
3743
|
+
* @since v24.7.0
|
|
3744
|
+
* @experimental
|
|
3745
|
+
*/
|
|
3746
|
+
function argon2Sync(algorithm: Argon2Algorithm, parameters: Argon2Parameters): NonSharedBuffer;
|
|
3974
3747
|
/**
|
|
3975
3748
|
* A convenient alias for `crypto.webcrypto.subtle`.
|
|
3976
3749
|
* @since v17.4.0
|
|
@@ -3984,37 +3757,40 @@ declare module "node:crypto" {
|
|
|
3984
3757
|
*/
|
|
3985
3758
|
const webcrypto: webcrypto.Crypto;
|
|
3986
3759
|
namespace webcrypto {
|
|
3987
|
-
type
|
|
3988
|
-
type
|
|
3760
|
+
type AlgorithmIdentifier = Algorithm | string;
|
|
3761
|
+
type BigInteger = NodeJS.NonSharedUint8Array;
|
|
3762
|
+
type KeyFormat = "jwk" | "pkcs8" | "raw" | "raw-public" | "raw-secret" | "raw-seed" | "spki";
|
|
3989
3763
|
type KeyType = "private" | "public" | "secret";
|
|
3990
3764
|
type KeyUsage =
|
|
3765
|
+
| "decapsulateBits"
|
|
3766
|
+
| "decapsulateKey"
|
|
3991
3767
|
| "decrypt"
|
|
3992
3768
|
| "deriveBits"
|
|
3993
3769
|
| "deriveKey"
|
|
3770
|
+
| "encapsulateBits"
|
|
3771
|
+
| "encapsulateKey"
|
|
3994
3772
|
| "encrypt"
|
|
3995
3773
|
| "sign"
|
|
3996
3774
|
| "unwrapKey"
|
|
3997
3775
|
| "verify"
|
|
3998
3776
|
| "wrapKey";
|
|
3999
|
-
type AlgorithmIdentifier = Algorithm | string;
|
|
4000
3777
|
type HashAlgorithmIdentifier = AlgorithmIdentifier;
|
|
4001
3778
|
type NamedCurve = string;
|
|
4002
|
-
|
|
3779
|
+
interface AeadParams extends Algorithm {
|
|
3780
|
+
additionalData?: NodeJS.BufferSource;
|
|
3781
|
+
iv: NodeJS.BufferSource;
|
|
3782
|
+
tagLength: number;
|
|
3783
|
+
}
|
|
4003
3784
|
interface AesCbcParams extends Algorithm {
|
|
4004
|
-
iv: BufferSource;
|
|
3785
|
+
iv: NodeJS.BufferSource;
|
|
4005
3786
|
}
|
|
4006
3787
|
interface AesCtrParams extends Algorithm {
|
|
4007
|
-
counter: BufferSource;
|
|
3788
|
+
counter: NodeJS.BufferSource;
|
|
4008
3789
|
length: number;
|
|
4009
3790
|
}
|
|
4010
3791
|
interface AesDerivedKeyParams extends Algorithm {
|
|
4011
3792
|
length: number;
|
|
4012
3793
|
}
|
|
4013
|
-
interface AesGcmParams extends Algorithm {
|
|
4014
|
-
additionalData?: BufferSource;
|
|
4015
|
-
iv: BufferSource;
|
|
4016
|
-
tagLength?: number;
|
|
4017
|
-
}
|
|
4018
3794
|
interface AesKeyAlgorithm extends KeyAlgorithm {
|
|
4019
3795
|
length: number;
|
|
4020
3796
|
}
|
|
@@ -4024,6 +3800,23 @@ declare module "node:crypto" {
|
|
|
4024
3800
|
interface Algorithm {
|
|
4025
3801
|
name: string;
|
|
4026
3802
|
}
|
|
3803
|
+
interface Argon2Params extends Algorithm {
|
|
3804
|
+
associatedData?: NodeJS.BufferSource;
|
|
3805
|
+
memory: number;
|
|
3806
|
+
nonce: NodeJS.BufferSource;
|
|
3807
|
+
parallelism: number;
|
|
3808
|
+
passes: number;
|
|
3809
|
+
secretValue?: NodeJS.BufferSource;
|
|
3810
|
+
version?: number;
|
|
3811
|
+
}
|
|
3812
|
+
interface CShakeParams extends Algorithm {
|
|
3813
|
+
customization?: NodeJS.BufferSource;
|
|
3814
|
+
functionName?: NodeJS.BufferSource;
|
|
3815
|
+
length: number;
|
|
3816
|
+
}
|
|
3817
|
+
interface ContextParams extends Algorithm {
|
|
3818
|
+
context?: NodeJS.BufferSource;
|
|
3819
|
+
}
|
|
4027
3820
|
interface EcKeyAlgorithm extends KeyAlgorithm {
|
|
4028
3821
|
namedCurve: NamedCurve;
|
|
4029
3822
|
}
|
|
@@ -4039,13 +3832,10 @@ declare module "node:crypto" {
|
|
|
4039
3832
|
interface EcdsaParams extends Algorithm {
|
|
4040
3833
|
hash: HashAlgorithmIdentifier;
|
|
4041
3834
|
}
|
|
4042
|
-
interface Ed448Params extends Algorithm {
|
|
4043
|
-
context?: BufferSource;
|
|
4044
|
-
}
|
|
4045
3835
|
interface HkdfParams extends Algorithm {
|
|
4046
3836
|
hash: HashAlgorithmIdentifier;
|
|
4047
|
-
info: BufferSource;
|
|
4048
|
-
salt: BufferSource;
|
|
3837
|
+
info: NodeJS.BufferSource;
|
|
3838
|
+
salt: NodeJS.BufferSource;
|
|
4049
3839
|
}
|
|
4050
3840
|
interface HmacImportParams extends Algorithm {
|
|
4051
3841
|
hash: HashAlgorithmIdentifier;
|
|
@@ -4082,10 +3872,23 @@ declare module "node:crypto" {
|
|
|
4082
3872
|
interface KeyAlgorithm {
|
|
4083
3873
|
name: string;
|
|
4084
3874
|
}
|
|
3875
|
+
interface KmacImportParams extends Algorithm {
|
|
3876
|
+
length?: number;
|
|
3877
|
+
}
|
|
3878
|
+
interface KmacKeyAlgorithm extends KeyAlgorithm {
|
|
3879
|
+
length: number;
|
|
3880
|
+
}
|
|
3881
|
+
interface KmacKeyGenParams extends Algorithm {
|
|
3882
|
+
length?: number;
|
|
3883
|
+
}
|
|
3884
|
+
interface KmacParams extends Algorithm {
|
|
3885
|
+
customization?: NodeJS.BufferSource;
|
|
3886
|
+
length: number;
|
|
3887
|
+
}
|
|
4085
3888
|
interface Pbkdf2Params extends Algorithm {
|
|
4086
3889
|
hash: HashAlgorithmIdentifier;
|
|
4087
3890
|
iterations: number;
|
|
4088
|
-
salt: BufferSource;
|
|
3891
|
+
salt: NodeJS.BufferSource;
|
|
4089
3892
|
}
|
|
4090
3893
|
interface RsaHashedImportParams extends Algorithm {
|
|
4091
3894
|
hash: HashAlgorithmIdentifier;
|
|
@@ -4105,7 +3908,7 @@ declare module "node:crypto" {
|
|
|
4105
3908
|
publicExponent: BigInteger;
|
|
4106
3909
|
}
|
|
4107
3910
|
interface RsaOaepParams extends Algorithm {
|
|
4108
|
-
label?: BufferSource;
|
|
3911
|
+
label?: NodeJS.BufferSource;
|
|
4109
3912
|
}
|
|
4110
3913
|
interface RsaOtherPrimesInfo {
|
|
4111
3914
|
d?: string;
|
|
@@ -4115,269 +3918,103 @@ declare module "node:crypto" {
|
|
|
4115
3918
|
interface RsaPssParams extends Algorithm {
|
|
4116
3919
|
saltLength: number;
|
|
4117
3920
|
}
|
|
4118
|
-
/**
|
|
4119
|
-
* Importing the `webcrypto` object (`import { webcrypto } from 'node:crypto'`) gives an instance of the `Crypto` class.
|
|
4120
|
-
* `Crypto` is a singleton that provides access to the remainder of the crypto API.
|
|
4121
|
-
* @since v15.0.0
|
|
4122
|
-
*/
|
|
4123
3921
|
interface Crypto {
|
|
4124
|
-
/**
|
|
4125
|
-
* Provides access to the `SubtleCrypto` API.
|
|
4126
|
-
* @since v15.0.0
|
|
4127
|
-
*/
|
|
4128
3922
|
readonly subtle: SubtleCrypto;
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
*/
|
|
4138
|
-
getRandomValues<T extends Exclude<NodeJS.TypedArray, Float32Array | Float64Array>>(typedArray: T): T;
|
|
4139
|
-
/**
|
|
4140
|
-
* Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID.
|
|
4141
|
-
* The UUID is generated using a cryptographic pseudorandom number generator.
|
|
4142
|
-
* @since v16.7.0
|
|
4143
|
-
*/
|
|
3923
|
+
getRandomValues<
|
|
3924
|
+
T extends Exclude<
|
|
3925
|
+
NodeJS.NonSharedTypedArray,
|
|
3926
|
+
NodeJS.NonSharedFloat16Array | NodeJS.NonSharedFloat32Array | NodeJS.NonSharedFloat64Array
|
|
3927
|
+
>,
|
|
3928
|
+
>(
|
|
3929
|
+
typedArray: T,
|
|
3930
|
+
): T;
|
|
4144
3931
|
randomUUID(): UUID;
|
|
4145
|
-
CryptoKey: CryptoKeyConstructor;
|
|
4146
|
-
}
|
|
4147
|
-
// This constructor throws ILLEGAL_CONSTRUCTOR so it should not be newable.
|
|
4148
|
-
interface CryptoKeyConstructor {
|
|
4149
|
-
/** Illegal constructor */
|
|
4150
|
-
(_: { readonly _: unique symbol }): never; // Allows instanceof to work but not be callable by the user.
|
|
4151
|
-
readonly length: 0;
|
|
4152
|
-
readonly name: "CryptoKey";
|
|
4153
|
-
readonly prototype: CryptoKey;
|
|
4154
3932
|
}
|
|
4155
|
-
/**
|
|
4156
|
-
* @since v15.0.0
|
|
4157
|
-
*/
|
|
4158
3933
|
interface CryptoKey {
|
|
4159
|
-
/**
|
|
4160
|
-
* An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters.
|
|
4161
|
-
* @since v15.0.0
|
|
4162
|
-
*/
|
|
4163
3934
|
readonly algorithm: KeyAlgorithm;
|
|
4164
|
-
/**
|
|
4165
|
-
* When `true`, the {@link CryptoKey} can be extracted using either `subtleCrypto.exportKey()` or `subtleCrypto.wrapKey()`.
|
|
4166
|
-
* @since v15.0.0
|
|
4167
|
-
*/
|
|
4168
3935
|
readonly extractable: boolean;
|
|
4169
|
-
/**
|
|
4170
|
-
* A string identifying whether the key is a symmetric (`'secret'`) or asymmetric (`'private'` or `'public'`) key.
|
|
4171
|
-
* @since v15.0.0
|
|
4172
|
-
*/
|
|
4173
3936
|
readonly type: KeyType;
|
|
4174
|
-
/**
|
|
4175
|
-
* An array of strings identifying the operations for which the key may be used.
|
|
4176
|
-
*
|
|
4177
|
-
* The possible usages are:
|
|
4178
|
-
* - `'encrypt'` - The key may be used to encrypt data.
|
|
4179
|
-
* - `'decrypt'` - The key may be used to decrypt data.
|
|
4180
|
-
* - `'sign'` - The key may be used to generate digital signatures.
|
|
4181
|
-
* - `'verify'` - The key may be used to verify digital signatures.
|
|
4182
|
-
* - `'deriveKey'` - The key may be used to derive a new key.
|
|
4183
|
-
* - `'deriveBits'` - The key may be used to derive bits.
|
|
4184
|
-
* - `'wrapKey'` - The key may be used to wrap another key.
|
|
4185
|
-
* - `'unwrapKey'` - The key may be used to unwrap another key.
|
|
4186
|
-
*
|
|
4187
|
-
* Valid key usages depend on the key algorithm (identified by `cryptokey.algorithm.name`).
|
|
4188
|
-
* @since v15.0.0
|
|
4189
|
-
*/
|
|
4190
3937
|
readonly usages: KeyUsage[];
|
|
4191
3938
|
}
|
|
4192
|
-
/**
|
|
4193
|
-
* The `CryptoKeyPair` is a simple dictionary object with `publicKey` and `privateKey` properties, representing an asymmetric key pair.
|
|
4194
|
-
* @since v15.0.0
|
|
4195
|
-
*/
|
|
4196
3939
|
interface CryptoKeyPair {
|
|
4197
|
-
/**
|
|
4198
|
-
* A {@link CryptoKey} whose type will be `'private'`.
|
|
4199
|
-
* @since v15.0.0
|
|
4200
|
-
*/
|
|
4201
3940
|
privateKey: CryptoKey;
|
|
4202
|
-
/**
|
|
4203
|
-
* A {@link CryptoKey} whose type will be `'public'`.
|
|
4204
|
-
* @since v15.0.0
|
|
4205
|
-
*/
|
|
4206
3941
|
publicKey: CryptoKey;
|
|
4207
3942
|
}
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
3943
|
+
interface EncapsulatedBits {
|
|
3944
|
+
sharedKey: ArrayBuffer;
|
|
3945
|
+
ciphertext: ArrayBuffer;
|
|
3946
|
+
}
|
|
3947
|
+
interface EncapsulatedKey {
|
|
3948
|
+
sharedKey: CryptoKey;
|
|
3949
|
+
ciphertext: ArrayBuffer;
|
|
3950
|
+
}
|
|
4211
3951
|
interface SubtleCrypto {
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
3952
|
+
decapsulateBits(
|
|
3953
|
+
decapsulationAlgorithm: AlgorithmIdentifier,
|
|
3954
|
+
decapsulationKey: CryptoKey,
|
|
3955
|
+
ciphertext: NodeJS.BufferSource,
|
|
3956
|
+
): Promise<ArrayBuffer>;
|
|
3957
|
+
decapsulateKey(
|
|
3958
|
+
decapsulationAlgorithm: AlgorithmIdentifier,
|
|
3959
|
+
decapsulationKey: CryptoKey,
|
|
3960
|
+
ciphertext: NodeJS.BufferSource,
|
|
3961
|
+
sharedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | AesDerivedKeyParams | KmacImportParams,
|
|
3962
|
+
extractable: boolean,
|
|
3963
|
+
usages: KeyUsage[],
|
|
3964
|
+
): Promise<CryptoKey>;
|
|
4225
3965
|
decrypt(
|
|
4226
|
-
algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams |
|
|
3966
|
+
algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
|
|
4227
3967
|
key: CryptoKey,
|
|
4228
|
-
data: BufferSource,
|
|
3968
|
+
data: NodeJS.BufferSource,
|
|
4229
3969
|
): Promise<ArrayBuffer>;
|
|
4230
|
-
/**
|
|
4231
|
-
* Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
|
|
4232
|
-
* `subtle.deriveBits()` attempts to generate `length` bits.
|
|
4233
|
-
* The Node.js implementation requires that when `length` is a number it must be multiple of `8`.
|
|
4234
|
-
* When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed
|
|
4235
|
-
* for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms.
|
|
4236
|
-
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the generated data.
|
|
4237
|
-
*
|
|
4238
|
-
* The algorithms currently supported include:
|
|
4239
|
-
*
|
|
4240
|
-
* - `'ECDH'`
|
|
4241
|
-
* - `'X25519'`
|
|
4242
|
-
* - `'X448'`
|
|
4243
|
-
* - `'HKDF'`
|
|
4244
|
-
* - `'PBKDF2'`
|
|
4245
|
-
* @since v15.0.0
|
|
4246
|
-
*/
|
|
4247
3970
|
deriveBits(
|
|
4248
|
-
algorithm: EcdhKeyDeriveParams,
|
|
3971
|
+
algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
|
|
4249
3972
|
baseKey: CryptoKey,
|
|
4250
3973
|
length?: number | null,
|
|
4251
3974
|
): Promise<ArrayBuffer>;
|
|
4252
|
-
deriveBits(
|
|
4253
|
-
algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
|
|
4254
|
-
baseKey: CryptoKey,
|
|
4255
|
-
length: number,
|
|
4256
|
-
): Promise<ArrayBuffer>;
|
|
4257
|
-
/**
|
|
4258
|
-
* Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
|
|
4259
|
-
* `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
|
|
4260
|
-
*
|
|
4261
|
-
* Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material,
|
|
4262
|
-
* then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input.
|
|
4263
|
-
*
|
|
4264
|
-
* The algorithms currently supported include:
|
|
4265
|
-
*
|
|
4266
|
-
* - `'ECDH'`
|
|
4267
|
-
* - `'X25519'`
|
|
4268
|
-
* - `'X448'`
|
|
4269
|
-
* - `'HKDF'`
|
|
4270
|
-
* - `'PBKDF2'`
|
|
4271
|
-
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
4272
|
-
* @since v15.0.0
|
|
4273
|
-
*/
|
|
4274
3975
|
deriveKey(
|
|
4275
|
-
algorithm: EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
|
|
3976
|
+
algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params | Argon2Params,
|
|
4276
3977
|
baseKey: CryptoKey,
|
|
4277
|
-
|
|
3978
|
+
derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | KmacImportParams,
|
|
4278
3979
|
extractable: boolean,
|
|
4279
3980
|
keyUsages: readonly KeyUsage[],
|
|
4280
3981
|
): Promise<CryptoKey>;
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
* @since v15.0.0
|
|
4294
|
-
*/
|
|
4295
|
-
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
|
|
4296
|
-
/**
|
|
4297
|
-
* Using the method and parameters specified by `algorithm` and the keying material provided by `key`,
|
|
4298
|
-
* `subtle.encrypt()` attempts to encipher `data`. If successful,
|
|
4299
|
-
* the returned promise is resolved with an `<ArrayBuffer>` containing the encrypted result.
|
|
4300
|
-
*
|
|
4301
|
-
* The algorithms currently supported include:
|
|
4302
|
-
*
|
|
4303
|
-
* - `'RSA-OAEP'`
|
|
4304
|
-
* - `'AES-CTR'`
|
|
4305
|
-
* - `'AES-CBC'`
|
|
4306
|
-
* - `'AES-GCM'`
|
|
4307
|
-
* @since v15.0.0
|
|
4308
|
-
*/
|
|
3982
|
+
digest(algorithm: AlgorithmIdentifier | CShakeParams, data: NodeJS.BufferSource): Promise<ArrayBuffer>;
|
|
3983
|
+
encapsulateBits(
|
|
3984
|
+
encapsulationAlgorithm: AlgorithmIdentifier,
|
|
3985
|
+
encapsulationKey: CryptoKey,
|
|
3986
|
+
): Promise<EncapsulatedBits>;
|
|
3987
|
+
encapsulateKey(
|
|
3988
|
+
encapsulationAlgorithm: AlgorithmIdentifier,
|
|
3989
|
+
encapsulationKey: CryptoKey,
|
|
3990
|
+
sharedKeyAlgorithm: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | KmacImportParams,
|
|
3991
|
+
extractable: boolean,
|
|
3992
|
+
usages: KeyUsage[],
|
|
3993
|
+
): Promise<EncapsulatedKey>;
|
|
4309
3994
|
encrypt(
|
|
4310
|
-
algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams |
|
|
3995
|
+
algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
|
|
4311
3996
|
key: CryptoKey,
|
|
4312
|
-
data: BufferSource,
|
|
3997
|
+
data: NodeJS.BufferSource,
|
|
4313
3998
|
): Promise<ArrayBuffer>;
|
|
4314
|
-
/**
|
|
4315
|
-
* Exports the given key into the specified format, if supported.
|
|
4316
|
-
*
|
|
4317
|
-
* If the `<CryptoKey>` is not extractable, the returned promise will reject.
|
|
4318
|
-
*
|
|
4319
|
-
* When `format` is either `'pkcs8'` or `'spki'` and the export is successful,
|
|
4320
|
-
* the returned promise will be resolved with an `<ArrayBuffer>` containing the exported key data.
|
|
4321
|
-
*
|
|
4322
|
-
* When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a
|
|
4323
|
-
* JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification.
|
|
4324
|
-
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
4325
|
-
* @returns `<Promise>` containing `<ArrayBuffer>`.
|
|
4326
|
-
* @since v15.0.0
|
|
4327
|
-
*/
|
|
4328
3999
|
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
|
|
4329
4000
|
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
|
|
4330
|
-
|
|
4331
|
-
* Using the method and parameters provided in `algorithm`,
|
|
4332
|
-
* `subtle.generateKey()` attempts to generate new keying material.
|
|
4333
|
-
* Depending the method used, the method may generate either a single `<CryptoKey>` or a `<CryptoKeyPair>`.
|
|
4334
|
-
*
|
|
4335
|
-
* The `<CryptoKeyPair>` (public and private key) generating algorithms supported include:
|
|
4336
|
-
*
|
|
4337
|
-
* - `'RSASSA-PKCS1-v1_5'`
|
|
4338
|
-
* - `'RSA-PSS'`
|
|
4339
|
-
* - `'RSA-OAEP'`
|
|
4340
|
-
* - `'ECDSA'`
|
|
4341
|
-
* - `'Ed25519'`
|
|
4342
|
-
* - `'Ed448'`
|
|
4343
|
-
* - `'ECDH'`
|
|
4344
|
-
* - `'X25519'`
|
|
4345
|
-
* - `'X448'`
|
|
4346
|
-
* The `<CryptoKey>` (secret key) generating algorithms supported include:
|
|
4347
|
-
*
|
|
4348
|
-
* - `'HMAC'`
|
|
4349
|
-
* - `'AES-CTR'`
|
|
4350
|
-
* - `'AES-CBC'`
|
|
4351
|
-
* - `'AES-GCM'`
|
|
4352
|
-
* - `'AES-KW'`
|
|
4353
|
-
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
4354
|
-
* @since v15.0.0
|
|
4355
|
-
*/
|
|
4001
|
+
exportKey(format: KeyFormat, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
|
|
4356
4002
|
generateKey(
|
|
4357
4003
|
algorithm: RsaHashedKeyGenParams | EcKeyGenParams,
|
|
4358
4004
|
extractable: boolean,
|
|
4359
|
-
keyUsages:
|
|
4005
|
+
keyUsages: KeyUsage[],
|
|
4360
4006
|
): Promise<CryptoKeyPair>;
|
|
4361
4007
|
generateKey(
|
|
4362
|
-
algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params,
|
|
4008
|
+
algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params | KmacKeyGenParams,
|
|
4363
4009
|
extractable: boolean,
|
|
4364
|
-
keyUsages:
|
|
4010
|
+
keyUsages: KeyUsage[],
|
|
4365
4011
|
): Promise<CryptoKey>;
|
|
4366
4012
|
generateKey(
|
|
4367
4013
|
algorithm: AlgorithmIdentifier,
|
|
4368
4014
|
extractable: boolean,
|
|
4369
4015
|
keyUsages: KeyUsage[],
|
|
4370
4016
|
): Promise<CryptoKeyPair | CryptoKey>;
|
|
4371
|
-
|
|
4372
|
-
* The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format`
|
|
4373
|
-
* to create a `<CryptoKey>` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments.
|
|
4374
|
-
* If the import is successful, the returned promise will be resolved with the created `<CryptoKey>`.
|
|
4375
|
-
*
|
|
4376
|
-
* If importing a `'PBKDF2'` key, `extractable` must be `false`.
|
|
4377
|
-
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
4378
|
-
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
4379
|
-
* @since v15.0.0
|
|
4380
|
-
*/
|
|
4017
|
+
getPublicKey(key: CryptoKey, keyUsages: KeyUsage[]): Promise<CryptoKey>;
|
|
4381
4018
|
importKey(
|
|
4382
4019
|
format: "jwk",
|
|
4383
4020
|
keyData: JsonWebKey,
|
|
@@ -4386,144 +4023,56 @@ declare module "node:crypto" {
|
|
|
4386
4023
|
| RsaHashedImportParams
|
|
4387
4024
|
| EcKeyImportParams
|
|
4388
4025
|
| HmacImportParams
|
|
4389
|
-
| AesKeyAlgorithm
|
|
4026
|
+
| AesKeyAlgorithm
|
|
4027
|
+
| KmacImportParams,
|
|
4390
4028
|
extractable: boolean,
|
|
4391
|
-
keyUsages:
|
|
4029
|
+
keyUsages: KeyUsage[],
|
|
4392
4030
|
): Promise<CryptoKey>;
|
|
4393
4031
|
importKey(
|
|
4394
4032
|
format: Exclude<KeyFormat, "jwk">,
|
|
4395
|
-
keyData: BufferSource,
|
|
4033
|
+
keyData: NodeJS.BufferSource,
|
|
4396
4034
|
algorithm:
|
|
4397
4035
|
| AlgorithmIdentifier
|
|
4398
4036
|
| RsaHashedImportParams
|
|
4399
4037
|
| EcKeyImportParams
|
|
4400
4038
|
| HmacImportParams
|
|
4401
|
-
| AesKeyAlgorithm
|
|
4039
|
+
| AesKeyAlgorithm
|
|
4040
|
+
| KmacImportParams,
|
|
4402
4041
|
extractable: boolean,
|
|
4403
4042
|
keyUsages: KeyUsage[],
|
|
4404
4043
|
): Promise<CryptoKey>;
|
|
4405
|
-
/**
|
|
4406
|
-
* Using the method and parameters given by `algorithm` and the keying material provided by `key`,
|
|
4407
|
-
* `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful,
|
|
4408
|
-
* the returned promise is resolved with an `<ArrayBuffer>` containing the generated signature.
|
|
4409
|
-
*
|
|
4410
|
-
* The algorithms currently supported include:
|
|
4411
|
-
*
|
|
4412
|
-
* - `'RSASSA-PKCS1-v1_5'`
|
|
4413
|
-
* - `'RSA-PSS'`
|
|
4414
|
-
* - `'ECDSA'`
|
|
4415
|
-
* - `'Ed25519'`
|
|
4416
|
-
* - `'Ed448'`
|
|
4417
|
-
* - `'HMAC'`
|
|
4418
|
-
* @since v15.0.0
|
|
4419
|
-
*/
|
|
4420
4044
|
sign(
|
|
4421
|
-
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams |
|
|
4045
|
+
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
|
|
4422
4046
|
key: CryptoKey,
|
|
4423
|
-
data: BufferSource,
|
|
4047
|
+
data: NodeJS.BufferSource,
|
|
4424
4048
|
): Promise<ArrayBuffer>;
|
|
4425
|
-
/**
|
|
4426
|
-
* In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
|
|
4427
|
-
* The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
|
|
4428
|
-
* It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input)
|
|
4429
|
-
* then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs.
|
|
4430
|
-
* If successful, the returned promise is resolved with a `<CryptoKey>` object.
|
|
4431
|
-
*
|
|
4432
|
-
* The wrapping algorithms currently supported include:
|
|
4433
|
-
*
|
|
4434
|
-
* - `'RSA-OAEP'`
|
|
4435
|
-
* - `'AES-CTR'`
|
|
4436
|
-
* - `'AES-CBC'`
|
|
4437
|
-
* - `'AES-GCM'`
|
|
4438
|
-
* - `'AES-KW'`
|
|
4439
|
-
*
|
|
4440
|
-
* The unwrapped key algorithms supported include:
|
|
4441
|
-
*
|
|
4442
|
-
* - `'RSASSA-PKCS1-v1_5'`
|
|
4443
|
-
* - `'RSA-PSS'`
|
|
4444
|
-
* - `'RSA-OAEP'`
|
|
4445
|
-
* - `'ECDSA'`
|
|
4446
|
-
* - `'Ed25519'`
|
|
4447
|
-
* - `'Ed448'`
|
|
4448
|
-
* - `'ECDH'`
|
|
4449
|
-
* - `'X25519'`
|
|
4450
|
-
* - `'X448'`
|
|
4451
|
-
* - `'HMAC'`
|
|
4452
|
-
* - `'AES-CTR'`
|
|
4453
|
-
* - `'AES-CBC'`
|
|
4454
|
-
* - `'AES-GCM'`
|
|
4455
|
-
* - `'AES-KW'`
|
|
4456
|
-
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
4457
|
-
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
4458
|
-
* @since v15.0.0
|
|
4459
|
-
*/
|
|
4460
4049
|
unwrapKey(
|
|
4461
4050
|
format: KeyFormat,
|
|
4462
|
-
wrappedKey: BufferSource,
|
|
4051
|
+
wrappedKey: NodeJS.BufferSource,
|
|
4463
4052
|
unwrappingKey: CryptoKey,
|
|
4464
|
-
unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams |
|
|
4053
|
+
unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
|
|
4465
4054
|
unwrappedKeyAlgorithm:
|
|
4466
4055
|
| AlgorithmIdentifier
|
|
4467
4056
|
| RsaHashedImportParams
|
|
4468
4057
|
| EcKeyImportParams
|
|
4469
4058
|
| HmacImportParams
|
|
4470
|
-
| AesKeyAlgorithm
|
|
4059
|
+
| AesKeyAlgorithm
|
|
4060
|
+
| KmacImportParams,
|
|
4471
4061
|
extractable: boolean,
|
|
4472
4062
|
keyUsages: KeyUsage[],
|
|
4473
4063
|
): Promise<CryptoKey>;
|
|
4474
|
-
/**
|
|
4475
|
-
* Using the method and parameters given in `algorithm` and the keying material provided by `key`,
|
|
4476
|
-
* `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`.
|
|
4477
|
-
* The returned promise is resolved with either `true` or `false`.
|
|
4478
|
-
*
|
|
4479
|
-
* The algorithms currently supported include:
|
|
4480
|
-
*
|
|
4481
|
-
* - `'RSASSA-PKCS1-v1_5'`
|
|
4482
|
-
* - `'RSA-PSS'`
|
|
4483
|
-
* - `'ECDSA'`
|
|
4484
|
-
* - `'Ed25519'`
|
|
4485
|
-
* - `'Ed448'`
|
|
4486
|
-
* - `'HMAC'`
|
|
4487
|
-
* @since v15.0.0
|
|
4488
|
-
*/
|
|
4489
4064
|
verify(
|
|
4490
|
-
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams |
|
|
4065
|
+
algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams | ContextParams | KmacParams,
|
|
4491
4066
|
key: CryptoKey,
|
|
4492
|
-
signature: BufferSource,
|
|
4493
|
-
data: BufferSource,
|
|
4067
|
+
signature: NodeJS.BufferSource,
|
|
4068
|
+
data: NodeJS.BufferSource,
|
|
4494
4069
|
): Promise<boolean>;
|
|
4495
|
-
/**
|
|
4496
|
-
* In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
|
|
4497
|
-
* The `subtle.wrapKey()` method exports the keying material into the format identified by `format`,
|
|
4498
|
-
* then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`.
|
|
4499
|
-
* It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments,
|
|
4500
|
-
* then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs.
|
|
4501
|
-
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the encrypted key data.
|
|
4502
|
-
*
|
|
4503
|
-
* The wrapping algorithms currently supported include:
|
|
4504
|
-
*
|
|
4505
|
-
* - `'RSA-OAEP'`
|
|
4506
|
-
* - `'AES-CTR'`
|
|
4507
|
-
* - `'AES-CBC'`
|
|
4508
|
-
* - `'AES-GCM'`
|
|
4509
|
-
* - `'AES-KW'`
|
|
4510
|
-
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
4511
|
-
* @since v15.0.0
|
|
4512
|
-
*/
|
|
4513
4070
|
wrapKey(
|
|
4514
4071
|
format: KeyFormat,
|
|
4515
4072
|
key: CryptoKey,
|
|
4516
4073
|
wrappingKey: CryptoKey,
|
|
4517
|
-
wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams |
|
|
4074
|
+
wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AeadParams,
|
|
4518
4075
|
): Promise<ArrayBuffer>;
|
|
4519
4076
|
}
|
|
4520
4077
|
}
|
|
4521
|
-
|
|
4522
|
-
global {
|
|
4523
|
-
var crypto: typeof globalThis extends {
|
|
4524
|
-
crypto: infer T;
|
|
4525
|
-
onmessage: any;
|
|
4526
|
-
} ? T
|
|
4527
|
-
: webcrypto.Crypto;
|
|
4528
|
-
}
|
|
4529
4078
|
}
|