From d251c643c3e8c37dc4554751caf0238b69db5102 Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Fri, 1 Dec 2017 12:52:38 -0800 Subject: [PATCH 1/2] Fix lint error: 'tslint:disable' is forbidden --- types/node/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 61fd375e6f..789e91997f 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -104,8 +104,8 @@ declare namespace setImmediate { declare function clearImmediate(immediateId: any): void; // TODO: change to `type NodeRequireFunction = (id: string) => any;` in next mayor version. -/* tslint:disable:callable-types */ interface NodeRequireFunction { +/* tslint:disable-next-line:callable-types */ (id: string): any; } From a385b18cd63d91f395f54c5c301f74241a884b11 Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Fri, 1 Dec 2017 13:02:40 -0800 Subject: [PATCH 2/2] Export nodejs native tls.checkServerIdentity function --- types/node/index.d.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 789e91997f..1d79e782d2 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -15,6 +15,7 @@ // Alvis HT Tang // Oliver Joseph Ash // Sebastian Silbermann +// Hannes Magnusson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /************************************************ @@ -4881,7 +4882,7 @@ declare module "tls" { servername?: string; path?: string; ALPNProtocols?: Array; - checkServerIdentity?: (servername: string, cert: string | Buffer | Array) => any; + checkServerIdentity?: typeof checkServerIdentity; secureProtocol?: string; secureContext?: Object; session?: Buffer; @@ -4984,6 +4985,14 @@ declare module "tls" { context: any; } + /* + * Verifies the certificate `cert` is issued to host `host`. + * @host The hostname to verify the certificate against + * @cert PeerCertificate representing the peer's certificate + * + * Returns Error object, populating it with the reason, host and cert on failure. On success, returns undefined. + */ + export function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined; export function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server; export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): TLSSocket; export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;