import { Socket } from 'net' ; import { DetailedPeerCertificate , PeerCertificate , TLSSocket } from 'tls' ; public export interface IOpenSearchDashboardsSocket { getPeerCertificate ( detailed ) : DetailedPeerCertificate | null ; getPeerCertificate ( detailed ) : PeerCertificate | null ; param detailed returns getPeerCertificate ( detailed ? ) : PeerCertificate | DetailedPeerCertificate | null ; /**
     * Indicates whether or not the peer certificate was signed by one of the specified CAs. When TLS
     * isn't used the value is `undefined`.
     */ readonly authorized ? : boolean ; /**
     * The reason why the peer's certificate has not been verified. This property becomes available
     * only when `authorized` is `false`.
     */ readonly authorizationError ? : Error ; } export class OpenSearchDashboardsSocket implements IOpenSearchDashboardsSocket { readonly authorized ? : boolean ; readonly authorizationError ? : Error ; constructor ( private readonly socket ) { if ( this . socket instanceof TLSSocket ) { this . authorized = this . socket . authorized ; this . authorizationError = this . socket . authorizationError ; } } getPeerCertificate ( detailed ) ; getPeerCertificate ( detailed ) ; getPeerCertificate ( detailed ? ) ; public getPeerCertificate ( detailed ? ) { if ( this . socket instanceof TLSSocket ) { const peerCertificate = this . socket . getPeerCertificate ( detailed ) ; if ( peerCertificate && Object . keys ( peerCertificate ) . length > 0 ) return peerCertificate ; } return null ; } }