From dad073b3fdbd5166aabefdde106eef9215202bba Mon Sep 17 00:00:00 2001 From: Christian Tellnes Date: Fri, 12 May 2017 19:49:42 +0200 Subject: [PATCH] node - update tls `getPeerCertificate` return value definition --- types/node/index.d.ts | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 84c5773976..174423dbe6 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for Node.js v7.x // Project: http://nodejs.org/ -// Definitions by: Microsoft TypeScript , DefinitelyTyped , Parambir Singh +// Definitions by: Microsoft TypeScript +// DefinitelyTyped +// Parambir Singh +// Christian Vaagland Tellnes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /************************************************ @@ -3004,6 +3007,25 @@ declare module "tls" { CN: string; } + export interface PeerCertificate { + subject: Certificate; + issuer: Certificate; + subjectaltname: string; + infoAccess: { [index: string]: string[] }; + modulus: string; + exponent: string; + valid_from: string; + valid_to: string; + fingerprint: string; + ext_key_usage: string[]; + serialNumber: string; + raw: Buffer; + } + + export interface DetailedPeerCertificate extends PeerCertificate { + issuerCertificate: DetailedPeerCertificate; + } + export interface CipherNameAndProtocol { /** * The cipher name. @@ -3112,18 +3134,11 @@ declare module "tls" { * if false only the top certificate without issuer property. * If the peer does not provide a certificate, it returns null or an empty object. * @param {boolean} detailed - If true; the full chain with issuer property will be returned. - * @returns {any} - An object representing the peer's certificate. + * @returns {PeerCertificate | DetailedPeerCertificate} - An object representing the peer's certificate. */ - getPeerCertificate(detailed?: boolean): { - subject: Certificate; - issuerInfo: Certificate; - issuer: Certificate; - raw: any; - valid_from: string; - valid_to: string; - fingerprint: string; - serialNumber: string; - }; + getPeerCertificate(detailed: true): DetailedPeerCertificate; + getPeerCertificate(detailed?: false): PeerCertificate; + getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate; /** * Could be used to speed up handshake establishment when reconnecting to the server. * @returns {any} - ASN.1 encoded TLS session or undefined if none was negotiated.