[@types/node] Fix generateKeyPair optional cipher and passphrase (fixes #33788) (#35091)

This commit is contained in:
Tim Zook
2019-05-13 11:41:03 -05:00
committed by Nathan Shively-Sanders
parent 8dfc211b7e
commit 2deba96b71
2 changed files with 48 additions and 2 deletions

View File

@@ -423,8 +423,8 @@ declare module "crypto" {
interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
format: T;
cipher: string;
passphrase: string;
cipher?: string;
passphrase?: string;
}
interface KeyPairKeyObjectResult {

View File

@@ -337,6 +337,21 @@ import { promisify } from 'util';
},
});
const rsaResNoPassphrase: {
publicKey: Buffer;
privateKey: string;
} = crypto.generateKeyPairSync('rsa', {
modulusLength: 123,
publicKeyEncoding: {
format: 'der',
type: 'pkcs1',
},
privateKeyEncoding: {
format: 'pem',
type: 'pkcs8',
},
});
const dsaRes: {
publicKey: string;
privateKey: Buffer;
@@ -355,6 +370,22 @@ import { promisify } from 'util';
},
});
const dsaResNoPassphrase: {
publicKey: string;
privateKey: Buffer;
} = crypto.generateKeyPairSync('dsa', {
modulusLength: 123,
divisorLength: 123,
publicKeyEncoding: {
format: 'pem',
type: 'spki',
},
privateKeyEncoding: {
format: 'der',
type: 'pkcs8',
},
});
const ecRes: {
publicKey: string;
privateKey: string;
@@ -371,6 +402,21 @@ import { promisify } from 'util';
type: 'pkcs8',
},
});
const ecResNoPassphrase: {
publicKey: string;
privateKey: string;
} = crypto.generateKeyPairSync('ec', {
namedCurve: 'curve',
publicKeyEncoding: {
format: 'pem',
type: 'pkcs1',
},
privateKeyEncoding: {
format: 'pem',
type: 'pkcs8',
},
});
}
{