mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
[node] add crypto.generateKeyPair (#30346)
This commit is contained in:
Vendored
+32
@@ -6483,6 +6483,38 @@ declare module "crypto" {
|
||||
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
|
||||
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
|
||||
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
|
||||
|
||||
function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
|
||||
function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
|
||||
function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
|
||||
function generateKeyPair(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
|
||||
|
||||
function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
|
||||
function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
|
||||
function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
|
||||
function generateKeyPair(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
|
||||
|
||||
function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>, callback: (err: Error | null, publicKey: string, privateKey: string) => void): void;
|
||||
function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>, callback: (err: Error | null, publicKey: string, privateKey: Buffer) => void): void;
|
||||
function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>, callback: (err: Error | null, publicKey: Buffer, privateKey: string) => void): void;
|
||||
function generateKeyPair(type: 'ec', options: ECKeyPairOptions<'der', 'der'>, callback: (err: Error | null, publicKey: Buffer, privateKey: Buffer) => void): void;
|
||||
|
||||
namespace generateKeyPair {
|
||||
function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
|
||||
function __promisify__(type: "rsa", options: RSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
|
||||
function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
|
||||
function __promisify__(type: "rsa", options: RSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
|
||||
|
||||
function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
|
||||
function __promisify__(type: "dsa", options: DSAKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
|
||||
function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
|
||||
function __promisify__(type: "dsa", options: DSAKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
|
||||
|
||||
function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'pem'>): Promise<{ publicKey: string, privateKey: string }>;
|
||||
function __promisify__(type: "ec", options: ECKeyPairOptions<'pem', 'der'>): Promise<{ publicKey: string, privateKey: Buffer }>;
|
||||
function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'pem'>): Promise<{ publicKey: Buffer, privateKey: string }>;
|
||||
function __promisify__(type: "ec", options: ECKeyPairOptions<'der', 'der'>): Promise<{ publicKey: Buffer, privateKey: Buffer }>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "stream" {
|
||||
|
||||
@@ -1555,6 +1555,107 @@ async function asyncStreamPipelineFinished() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
crypto.generateKeyPair('rsa', {
|
||||
modulusLength: 123,
|
||||
publicKeyEncoding: {
|
||||
format: 'der',
|
||||
type: 'pkcs1',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
cipher: 'some-cipher',
|
||||
format: 'pem',
|
||||
passphrase: 'secret',
|
||||
type: 'pkcs8',
|
||||
},
|
||||
}, (err: NodeJS.ErrnoException | null, publicKey: Buffer, privateKey: string) => {});
|
||||
|
||||
crypto.generateKeyPair('dsa', {
|
||||
modulusLength: 123,
|
||||
divisorLength: 123,
|
||||
publicKeyEncoding: {
|
||||
format: 'pem',
|
||||
type: 'spki',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
cipher: 'some-cipher',
|
||||
format: 'der',
|
||||
passphrase: 'secret',
|
||||
type: 'pkcs8',
|
||||
},
|
||||
}, (err: NodeJS.ErrnoException | null, publicKey: string, privateKey: Buffer) => {});
|
||||
|
||||
crypto.generateKeyPair('ec', {
|
||||
namedCurve: 'curve',
|
||||
publicKeyEncoding: {
|
||||
format: 'pem',
|
||||
type: 'pkcs1',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
cipher: 'some-cipher',
|
||||
format: 'pem',
|
||||
passphrase: 'secret',
|
||||
type: 'pkcs8',
|
||||
},
|
||||
}, (err: NodeJS.ErrnoException | null, publicKey: string, privateKey: string) => {});
|
||||
}
|
||||
|
||||
{
|
||||
const generateKeyPairPromisified = util.promisify(crypto.generateKeyPair);
|
||||
|
||||
const rsaRes: Promise<{
|
||||
publicKey: Buffer;
|
||||
privateKey: string;
|
||||
}> = generateKeyPairPromisified('rsa', {
|
||||
modulusLength: 123,
|
||||
publicKeyEncoding: {
|
||||
format: 'der',
|
||||
type: 'pkcs1',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
cipher: 'some-cipher',
|
||||
format: 'pem',
|
||||
passphrase: 'secret',
|
||||
type: 'pkcs8',
|
||||
},
|
||||
});
|
||||
|
||||
const dsaRes: Promise<{
|
||||
publicKey: string;
|
||||
privateKey: Buffer;
|
||||
}> = generateKeyPairPromisified('dsa', {
|
||||
modulusLength: 123,
|
||||
divisorLength: 123,
|
||||
publicKeyEncoding: {
|
||||
format: 'pem',
|
||||
type: 'spki',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
cipher: 'some-cipher',
|
||||
format: 'der',
|
||||
passphrase: 'secret',
|
||||
type: 'pkcs8',
|
||||
},
|
||||
});
|
||||
|
||||
const ecRes: Promise<{
|
||||
publicKey: string;
|
||||
privateKey: string;
|
||||
}> = generateKeyPairPromisified('ec', {
|
||||
namedCurve: 'curve',
|
||||
publicKeyEncoding: {
|
||||
format: 'pem',
|
||||
type: 'pkcs1',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
cipher: 'some-cipher',
|
||||
format: 'pem',
|
||||
passphrase: 'secret',
|
||||
type: 'pkcs8',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user