[node] Infer type of value returned by KeyObject.export more accurately

This commit is contained in:
Akihiko Odaki
2019-04-10 00:11:25 +09:00
parent 30e9238945
commit fdc75e604c
+9 -6
View File
@@ -135,15 +135,18 @@ declare module "crypto" {
export type KeyObjectType = 'secret' | 'public' | 'private';
interface KeyExportOptions<T extends KeyFormat> {
type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1';
format: T;
cipher?: string;
passphrase?: string | Buffer;
}
class KeyObject {
private constructor();
asymmetricKeyType?: KeyType;
export(options?: {
type: 'pkcs1' | 'spki' | 'pkcs8' | 'sec1',
format: KeyFormat,
cipher?: string,
passphrase?: string | Buffer
}): string | Buffer;
export(options: KeyExportOptions<'pem'>): string | Buffer;
export(options?: KeyExportOptions<'der'>): Buffer;
symmetricSize?: number;
type: KeyObjectType;
}