Merge pull request #9241 from Engineer2B/patch-3

Update node.d.ts TLS (SSL); added TLSSocket definitions.
This commit is contained in:
Mohamed Hegazy
2016-06-21 16:13:20 -07:00
committed by GitHub

140
node/node.d.ts vendored
View File

@@ -1828,7 +1828,147 @@ declare module "tls" {
var CLIENT_RENEG_LIMIT: number;
var CLIENT_RENEG_WINDOW: number;
export interface Certificate {
/**
* Country code.
*/
C: string;
/**
* Street.
*/
ST: string;
/**
* Locality.
*/
L: string;
/**
* Organization.
*/
O: string;
/**
* Organizational unit.
*/
OU: string;
/**
* Common name.
*/
CN: string;
}
export interface CipherNameAndProtocol {
/**
* The cipher name.
*/
name: string;
/**
* SSL/TLS protocol version.
*/
version: string;
}
export class TLSSocket extends stream.Duplex {
/**
* Returns the bound address, the address family name and port of the underlying socket as reported by
* the operating system.
* @returns {any} - An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }.
*/
address(): { port: number; family: string; address: string };
/**
* A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false.
*/
authorized: boolean;
/**
* The reason why the peer's certificate has not been verified.
* This property becomes available only when tlsSocket.authorized === false.
*/
authorizationError: Error;
/**
* Static boolean value, always true.
* May be used to distinguish TLS sockets from regular ones.
*/
encrypted: boolean;
/**
* Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
* @returns {CipherNameAndProtocol} - Returns an object representing the cipher name
* and the SSL/TLS protocol version of the current connection.
*/
getCipher(): CipherNameAndProtocol;
/**
* Returns an object representing the peer's certificate.
* The returned object has some properties corresponding to the field of the certificate.
* If detailed argument is true the full chain with issuer property will be returned,
* 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.
*/
getPeerCertificate(detailed?: boolean): {
subject: Certificate;
issuerInfo: Certificate;
issuer: Certificate;
raw: any;
valid_from: string;
valid_to: string;
fingerprint: string;
serialNumber: string;
};
/**
* 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.
*/
getSession(): any;
/**
* NOTE: Works only with client TLS sockets.
* Useful only for debugging, for session reuse provide session option to tls.connect().
* @returns {any} - TLS session ticket or undefined if none was negotiated.
*/
getTLSTicket(): any;
/**
* The string representation of the local IP address.
*/
localAddress: string;
/**
* The numeric representation of the local port.
*/
localPort: string;
/**
* The string representation of the remote IP address.
* For example, '74.125.127.100' or '2001:4860:a005::68'.
*/
remoteAddress: string;
/**
* The string representation of the remote IP family. 'IPv4' or 'IPv6'.
*/
remoteFamily: string;
/**
* The numeric representation of the remote port. For example, 443.
*/
remotePort: number;
/**
* Initiate TLS renegotiation process.
*
* NOTE: Can be used to request peer's certificate after the secure connection has been established.
* ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.
* @param {TlsOptions} options - The options may contain the following fields: rejectUnauthorized,
* requestCert (See tls.createServer() for details).
* @param {Function} callback - callback(err) will be executed with null as err, once the renegotiation
* is successfully completed.
*/
renegotiate(options: TlsOptions, callback: (err: Error) => any): any;
/**
* Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
* Smaller fragment size decreases buffering latency on the client: large fragments are buffered by
* the TLS layer until the entire fragment is received and its integrity is verified;
* large fragments can span multiple roundtrips, and their processing can be delayed due to packet
* loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead,
* which may decrease overall server throughput.
* @param {number} size - TLS fragment size (default and maximum value is: 16384, minimum is: 512).
* @returns {boolean} - Returns true on success, false otherwise.
*/
setMaxSendFragment(size: number): boolean;
}
export interface TlsOptions {
host?: string;
port?: number;