@types/node 10.12.20 → 10.12.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
node/crypto.d.ts ADDED
@@ -0,0 +1,369 @@
1
+ declare module "crypto" {
2
+ import * as stream from "stream";
3
+
4
+ interface Certificate {
5
+ exportChallenge(spkac: string | Buffer | NodeJS.TypedArray | DataView): Buffer;
6
+ exportPublicKey(spkac: string | Buffer | NodeJS.TypedArray | DataView): Buffer;
7
+ verifySpkac(spkac: Buffer | NodeJS.TypedArray | DataView): boolean;
8
+ }
9
+ const Certificate: {
10
+ new(): Certificate;
11
+ (): Certificate;
12
+ };
13
+
14
+ /** @deprecated since v10.0.0 */
15
+ const fips: boolean;
16
+
17
+ interface CredentialDetails {
18
+ pfx: string;
19
+ key: string;
20
+ passphrase: string;
21
+ cert: string;
22
+ ca: string | string[];
23
+ crl: string | string[];
24
+ ciphers: string;
25
+ }
26
+ interface Credentials { context?: any; }
27
+ function createCredentials(details: CredentialDetails): Credentials;
28
+ function createHash(algorithm: string, options?: stream.TransformOptions): Hash;
29
+ function createHmac(algorithm: string, key: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Hmac;
30
+
31
+ type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1";
32
+ type HexBase64Latin1Encoding = "latin1" | "hex" | "base64";
33
+ type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary";
34
+ type HexBase64BinaryEncoding = "binary" | "base64" | "hex";
35
+ type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
36
+
37
+ interface Hash extends NodeJS.ReadWriteStream {
38
+ update(data: string | Buffer | NodeJS.TypedArray | DataView): Hash;
39
+ update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hash;
40
+ digest(): Buffer;
41
+ digest(encoding: HexBase64Latin1Encoding): string;
42
+ }
43
+ interface Hmac extends NodeJS.ReadWriteStream {
44
+ update(data: string | Buffer | NodeJS.TypedArray | DataView): Hmac;
45
+ update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hmac;
46
+ digest(): Buffer;
47
+ digest(encoding: HexBase64Latin1Encoding): string;
48
+ }
49
+ type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm';
50
+ type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
51
+ interface CipherCCMOptions extends stream.TransformOptions {
52
+ authTagLength: number;
53
+ }
54
+ interface CipherGCMOptions extends stream.TransformOptions {
55
+ authTagLength?: number;
56
+ }
57
+ /** @deprecated since v10.0.0 use createCipheriv() */
58
+ function createCipher(algorithm: CipherCCMTypes, password: string | Buffer | NodeJS.TypedArray | DataView, options: CipherCCMOptions): CipherCCM;
59
+ /** @deprecated since v10.0.0 use createCipheriv() */
60
+ function createCipher(algorithm: CipherGCMTypes, password: string | Buffer | NodeJS.TypedArray | DataView, options?: CipherGCMOptions): CipherGCM;
61
+ /** @deprecated since v10.0.0 use createCipheriv() */
62
+ function createCipher(algorithm: string, password: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Cipher;
63
+
64
+ function createCipheriv(algorithm: CipherCCMTypes, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options: CipherCCMOptions): CipherCCM;
65
+ function createCipheriv(algorithm: CipherGCMTypes, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options?: CipherGCMOptions): CipherGCM;
66
+ function createCipheriv(algorithm: string, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Cipher;
67
+
68
+ interface Cipher extends NodeJS.ReadWriteStream {
69
+ update(data: string | Buffer | NodeJS.TypedArray | DataView): Buffer;
70
+ update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
71
+ update(data: Buffer | NodeJS.TypedArray | DataView, output_encoding: HexBase64BinaryEncoding): string;
72
+ update(data: Buffer | NodeJS.TypedArray | DataView, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string;
73
+ // second arg ignored
74
+ update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string;
75
+ final(): Buffer;
76
+ final(output_encoding: string): string;
77
+ setAutoPadding(auto_padding?: boolean): this;
78
+ // getAuthTag(): Buffer;
79
+ // setAAD(buffer: Buffer): this; // docs only say buffer
80
+ }
81
+ interface CipherCCM extends Cipher {
82
+ setAAD(buffer: Buffer, options: { plaintextLength: number }): this;
83
+ getAuthTag(): Buffer;
84
+ }
85
+ interface CipherGCM extends Cipher {
86
+ setAAD(buffer: Buffer, options?: { plaintextLength: number }): this;
87
+ getAuthTag(): Buffer;
88
+ }
89
+ /** @deprecated since v10.0.0 use createCipheriv() */
90
+ function createDecipher(algorithm: CipherCCMTypes, password: string | Buffer | NodeJS.TypedArray | DataView, options: CipherCCMOptions): DecipherCCM;
91
+ /** @deprecated since v10.0.0 use createCipheriv() */
92
+ function createDecipher(algorithm: CipherGCMTypes, password: string | Buffer | NodeJS.TypedArray | DataView, options?: CipherGCMOptions): DecipherGCM;
93
+ /** @deprecated since v10.0.0 use createCipheriv() */
94
+ function createDecipher(algorithm: string, password: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Decipher;
95
+
96
+ function createDecipheriv(
97
+ algorithm: CipherCCMTypes,
98
+ key: string | Buffer | NodeJS.TypedArray | DataView,
99
+ iv: string | Buffer | NodeJS.TypedArray | DataView,
100
+ options: CipherCCMOptions,
101
+ ): DecipherCCM;
102
+ function createDecipheriv(
103
+ algorithm: CipherGCMTypes,
104
+ key: string | Buffer | NodeJS.TypedArray | DataView,
105
+ iv: string | Buffer | NodeJS.TypedArray | DataView,
106
+ options?: CipherGCMOptions,
107
+ ): DecipherGCM;
108
+ function createDecipheriv(algorithm: string, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Decipher;
109
+
110
+ interface Decipher extends NodeJS.ReadWriteStream {
111
+ update(data: Buffer | NodeJS.TypedArray | DataView): Buffer;
112
+ update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
113
+ update(data: Buffer | NodeJS.TypedArray | DataView, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string;
114
+ // second arg is ignored
115
+ update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string;
116
+ final(): Buffer;
117
+ final(output_encoding: string): string;
118
+ setAutoPadding(auto_padding?: boolean): this;
119
+ // setAuthTag(tag: Buffer | NodeJS.TypedArray | DataView): this;
120
+ // setAAD(buffer: Buffer | NodeJS.TypedArray | DataView): this;
121
+ }
122
+ interface DecipherCCM extends Decipher {
123
+ setAuthTag(buffer: Buffer | NodeJS.TypedArray | DataView): this;
124
+ setAAD(buffer: Buffer | NodeJS.TypedArray | DataView, options: { plaintextLength: number }): this;
125
+ }
126
+ interface DecipherGCM extends Decipher {
127
+ setAuthTag(buffer: Buffer | NodeJS.TypedArray | DataView): this;
128
+ setAAD(buffer: Buffer | NodeJS.TypedArray | DataView, options?: { plaintextLength: number }): this;
129
+ }
130
+
131
+ function createSign(algorithm: string, options?: stream.WritableOptions): Signer;
132
+ interface Signer extends NodeJS.WritableStream {
133
+ update(data: string | Buffer | NodeJS.TypedArray | DataView): Signer;
134
+ update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Signer;
135
+ sign(private_key: string | { key: string; passphrase?: string, padding?: number, saltLength?: number }): Buffer;
136
+ sign(private_key: string | { key: string; passphrase?: string, padding?: number, saltLength?: number }, output_format: HexBase64Latin1Encoding): string;
137
+ }
138
+ function createVerify(algorith: string, options?: stream.WritableOptions): Verify;
139
+ interface Verify extends NodeJS.WritableStream {
140
+ update(data: string | Buffer | NodeJS.TypedArray | DataView): Verify;
141
+ update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Verify;
142
+ verify(object: string | Object, signature: Buffer | NodeJS.TypedArray | DataView): boolean;
143
+ verify(object: string | Object, signature: string, signature_format: HexBase64Latin1Encoding): boolean;
144
+ // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format
145
+ // The signature field accepts a TypedArray type, but it is only available starting ES2017
146
+ }
147
+ function createDiffieHellman(prime_length: number, generator?: number | Buffer | NodeJS.TypedArray | DataView): DiffieHellman;
148
+ function createDiffieHellman(prime: Buffer | NodeJS.TypedArray | DataView): DiffieHellman;
149
+ function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
150
+ function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Buffer | NodeJS.TypedArray | DataView): DiffieHellman;
151
+ function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman;
152
+ interface DiffieHellman {
153
+ generateKeys(): Buffer;
154
+ generateKeys(encoding: HexBase64Latin1Encoding): string;
155
+ computeSecret(other_public_key: Buffer | NodeJS.TypedArray | DataView): Buffer;
156
+ computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
157
+ computeSecret(other_public_key: Buffer | NodeJS.TypedArray | DataView, output_encoding: HexBase64Latin1Encoding): string;
158
+ computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
159
+ getPrime(): Buffer;
160
+ getPrime(encoding: HexBase64Latin1Encoding): string;
161
+ getGenerator(): Buffer;
162
+ getGenerator(encoding: HexBase64Latin1Encoding): string;
163
+ getPublicKey(): Buffer;
164
+ getPublicKey(encoding: HexBase64Latin1Encoding): string;
165
+ getPrivateKey(): Buffer;
166
+ getPrivateKey(encoding: HexBase64Latin1Encoding): string;
167
+ setPublicKey(public_key: Buffer | NodeJS.TypedArray | DataView): void;
168
+ setPublicKey(public_key: string, encoding: string): void;
169
+ setPrivateKey(private_key: Buffer | NodeJS.TypedArray | DataView): void;
170
+ setPrivateKey(private_key: string, encoding: string): void;
171
+ verifyError: number;
172
+ }
173
+ function getDiffieHellman(group_name: string): DiffieHellman;
174
+ function pbkdf2(
175
+ password: string | Buffer | NodeJS.TypedArray | DataView,
176
+ salt: string | Buffer | NodeJS.TypedArray | DataView,
177
+ iterations: number,
178
+ keylen: number,
179
+ digest: string,
180
+ callback: (err: Error | null, derivedKey: Buffer) => any,
181
+ ): void;
182
+ function pbkdf2Sync(password: string | Buffer | NodeJS.TypedArray | DataView, salt: string | Buffer | NodeJS.TypedArray | DataView, iterations: number, keylen: number, digest: string): Buffer;
183
+
184
+ function randomBytes(size: number): Buffer;
185
+ function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
186
+ function pseudoRandomBytes(size: number): Buffer;
187
+ function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
188
+
189
+ function randomFillSync<T extends Buffer | NodeJS.TypedArray | DataView>(buffer: T, offset?: number, size?: number): T;
190
+ function randomFill<T extends Buffer | NodeJS.TypedArray | DataView>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
191
+ function randomFill<T extends Buffer | NodeJS.TypedArray | DataView>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
192
+ function randomFill<T extends Buffer | NodeJS.TypedArray | DataView>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
193
+
194
+ interface ScryptOptions {
195
+ N?: number;
196
+ r?: number;
197
+ p?: number;
198
+ maxmem?: number;
199
+ }
200
+ function scrypt(
201
+ password: string | Buffer | NodeJS.TypedArray | DataView,
202
+ salt: string | Buffer | NodeJS.TypedArray | DataView,
203
+ keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void,
204
+ ): void;
205
+ function scrypt(
206
+ password: string | Buffer | NodeJS.TypedArray | DataView,
207
+ salt: string | Buffer | NodeJS.TypedArray | DataView,
208
+ keylen: number,
209
+ options: ScryptOptions,
210
+ callback: (err: Error | null, derivedKey: Buffer) => void,
211
+ ): void;
212
+ function scryptSync(password: string | Buffer | NodeJS.TypedArray | DataView, salt: string | Buffer | NodeJS.TypedArray | DataView, keylen: number, options?: ScryptOptions): Buffer;
213
+
214
+ interface RsaPublicKey {
215
+ key: string;
216
+ padding?: number;
217
+ }
218
+ interface RsaPrivateKey {
219
+ key: string;
220
+ passphrase?: string;
221
+ padding?: number;
222
+ }
223
+ function publicEncrypt(public_key: string | RsaPublicKey, buffer: Buffer | NodeJS.TypedArray | DataView): Buffer;
224
+ function privateDecrypt(private_key: string | RsaPrivateKey, buffer: Buffer | NodeJS.TypedArray | DataView): Buffer;
225
+ function privateEncrypt(private_key: string | RsaPrivateKey, buffer: Buffer | NodeJS.TypedArray | DataView): Buffer;
226
+ function publicDecrypt(public_key: string | RsaPublicKey, buffer: Buffer | NodeJS.TypedArray | DataView): Buffer;
227
+ function getCiphers(): string[];
228
+ function getCurves(): string[];
229
+ function getHashes(): string[];
230
+ class ECDH {
231
+ static convertKey(
232
+ key: string | Buffer | NodeJS.TypedArray | DataView,
233
+ curve: string,
234
+ inputEncoding?: HexBase64Latin1Encoding,
235
+ outputEncoding?: "latin1" | "hex" | "base64",
236
+ format?: "uncompressed" | "compressed" | "hybrid",
237
+ ): Buffer | string;
238
+ generateKeys(): Buffer;
239
+ generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
240
+ computeSecret(other_public_key: Buffer | NodeJS.TypedArray | DataView): Buffer;
241
+ computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
242
+ computeSecret(other_public_key: Buffer | NodeJS.TypedArray | DataView, output_encoding: HexBase64Latin1Encoding): string;
243
+ computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
244
+ getPrivateKey(): Buffer;
245
+ getPrivateKey(encoding: HexBase64Latin1Encoding): string;
246
+ getPublicKey(): Buffer;
247
+ getPublicKey(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
248
+ setPrivateKey(private_key: Buffer | NodeJS.TypedArray | DataView): void;
249
+ setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
250
+ }
251
+ function createECDH(curve_name: string): ECDH;
252
+ function timingSafeEqual(a: Buffer | NodeJS.TypedArray | DataView, b: Buffer | NodeJS.TypedArray | DataView): boolean;
253
+ /** @deprecated since v10.0.0 */
254
+ const DEFAULT_ENCODING: string;
255
+
256
+ export type KeyType = 'rsa' | 'dsa' | 'ec';
257
+ export type KeyFormat = 'pem' | 'der';
258
+
259
+ interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
260
+ format: T;
261
+ cipher: string;
262
+ passphrase: string;
263
+ }
264
+
265
+ interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
266
+ /**
267
+ * Key size in bits
268
+ */
269
+ modulusLength: number;
270
+ /**
271
+ * @default 0x10001
272
+ */
273
+ publicExponent?: number;
274
+
275
+ publicKeyEncoding: {
276
+ type: 'pkcs1' | 'spki';
277
+ format: PubF;
278
+ };
279
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
280
+ type: 'pkcs1' | 'pkcs8';
281
+ };
282
+ }
283
+
284
+ interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
285
+ /**
286
+ * Key size in bits
287
+ */
288
+ modulusLength: number;
289
+ /**
290
+ * Size of q in bits
291
+ */
292
+ divisorLength: number;
293
+
294
+ publicKeyEncoding: {
295
+ type: 'spki';
296
+ format: PubF;
297
+ };
298
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
299
+ type: 'pkcs8';
300
+ };
301
+ }
302
+
303
+ interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
304
+ /**
305
+ * Name of the curve to use.
306
+ */
307
+ namedCurve: string;
308
+
309
+ publicKeyEncoding: {
310
+ type: 'pkcs1' | 'spki';
311
+ format: PubF;
312
+ };
313
+ privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
314
+ type: 'sec1' | 'pkcs8';
315
+ };
316
+ }
317
+
318
+ interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
319
+ publicKey: T1;
320
+ privateKey: T2;
321
+ }
322
+
323
+ function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
324
+ function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
325
+ function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
326
+ function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
327
+
328
+ function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
329
+ function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
330
+ function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
331
+ function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
332
+
333
+ function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
334
+ function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
335
+ function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
336
+ function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
337
+
338
+ function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
339
+ function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
340
+ function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
341
+ function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
342
+
343
+ function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
344
+ function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
345
+ function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
346
+ function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
347
+
348
+ function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
349
+ function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
350
+ function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
351
+ function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
352
+
353
+ namespace generateKeyPair {
354
+ function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
355
+ function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
356
+ function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
357
+ function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
358
+
359
+ function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
360
+ function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
361
+ function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
362
+ function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
363
+
364
+ function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
365
+ function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
366
+ function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
367
+ function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
368
+ }
369
+ }
node/dgram.d.ts ADDED
@@ -0,0 +1,97 @@
1
+ declare module "dgram" {
2
+ import { AddressInfo } from "net";
3
+ import * as dns from "dns";
4
+ import * as events from "events";
5
+
6
+ interface RemoteInfo {
7
+ address: string;
8
+ family: string;
9
+ port: number;
10
+ }
11
+
12
+ interface BindOptions {
13
+ port: number;
14
+ address?: string;
15
+ exclusive?: boolean;
16
+ }
17
+
18
+ type SocketType = "udp4" | "udp6";
19
+
20
+ interface SocketOptions {
21
+ type: SocketType;
22
+ reuseAddr?: boolean;
23
+ recvBufferSize?: number;
24
+ sendBufferSize?: number;
25
+ lookup?: (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void) => void;
26
+ }
27
+
28
+ function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
29
+ function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
30
+
31
+ class Socket extends events.EventEmitter {
32
+ send(msg: Buffer | string | Uint8Array | any[], port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
33
+ send(msg: Buffer | string | Uint8Array, offset: number, length: number, port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
34
+ bind(port?: number, address?: string, callback?: () => void): void;
35
+ bind(port?: number, callback?: () => void): void;
36
+ bind(callback?: () => void): void;
37
+ bind(options: BindOptions, callback?: Function): void;
38
+ close(callback?: () => void): void;
39
+ address(): AddressInfo | string;
40
+ setBroadcast(flag: boolean): void;
41
+ setTTL(ttl: number): void;
42
+ setMulticastTTL(ttl: number): void;
43
+ setMulticastInterface(multicastInterface: string): void;
44
+ setMulticastLoopback(flag: boolean): void;
45
+ addMembership(multicastAddress: string, multicastInterface?: string): void;
46
+ dropMembership(multicastAddress: string, multicastInterface?: string): void;
47
+ ref(): this;
48
+ unref(): this;
49
+ setRecvBufferSize(size: number): void;
50
+ setSendBufferSize(size: number): void;
51
+ getRecvBufferSize(): number;
52
+ getSendBufferSize(): number;
53
+
54
+ /**
55
+ * events.EventEmitter
56
+ * 1. close
57
+ * 2. error
58
+ * 3. listening
59
+ * 4. message
60
+ */
61
+ addListener(event: string, listener: (...args: any[]) => void): this;
62
+ addListener(event: "close", listener: () => void): this;
63
+ addListener(event: "error", listener: (err: Error) => void): this;
64
+ addListener(event: "listening", listener: () => void): this;
65
+ addListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
66
+
67
+ emit(event: string | symbol, ...args: any[]): boolean;
68
+ emit(event: "close"): boolean;
69
+ emit(event: "error", err: Error): boolean;
70
+ emit(event: "listening"): boolean;
71
+ emit(event: "message", msg: Buffer, rinfo: AddressInfo): boolean;
72
+
73
+ on(event: string, listener: (...args: any[]) => void): this;
74
+ on(event: "close", listener: () => void): this;
75
+ on(event: "error", listener: (err: Error) => void): this;
76
+ on(event: "listening", listener: () => void): this;
77
+ on(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
78
+
79
+ once(event: string, listener: (...args: any[]) => void): this;
80
+ once(event: "close", listener: () => void): this;
81
+ once(event: "error", listener: (err: Error) => void): this;
82
+ once(event: "listening", listener: () => void): this;
83
+ once(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
84
+
85
+ prependListener(event: string, listener: (...args: any[]) => void): this;
86
+ prependListener(event: "close", listener: () => void): this;
87
+ prependListener(event: "error", listener: (err: Error) => void): this;
88
+ prependListener(event: "listening", listener: () => void): this;
89
+ prependListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
90
+
91
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
92
+ prependOnceListener(event: "close", listener: () => void): this;
93
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
94
+ prependOnceListener(event: "listening", listener: () => void): this;
95
+ prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
96
+ }
97
+ }