From b07a83f244df88ac568875e86f6bbdceb4c1f604 Mon Sep 17 00:00:00 2001 From: Jonathan Pirnay Date: Mon, 9 Jun 2014 22:39:35 +0200 Subject: [PATCH 1/3] Changed HMAC and Hash params to `any`, as Buffers are also allowed / returned. --- node/node.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index f3a778e019..bd4ef8879c 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1040,14 +1040,14 @@ declare module "crypto" { export interface Credentials { context?: any; } export function createCredentials(details: CredentialDetails): Credentials; export function createHash(algorithm: string): Hash; - export function createHmac(algorithm: string, key: string): Hmac; + export function createHmac(algorithm: string, key: any): Hmac; interface Hash { update(data: any, input_encoding?: string): Hash; - digest(encoding?: string): string; + digest(encoding?: string): any; } interface Hmac { update(data: any, input_encoding?: string): Hmac; - digest(encoding?: string): string; + digest(encoding?: string): any; } export function createCipher(algorithm: string, password: any): Cipher; export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; From ff66b8c00a1de7915be565337ffe36e390e415b3 Mon Sep 17 00:00:00 2001 From: Jonathan Pirnay Date: Thu, 19 Jun 2014 12:15:28 +0200 Subject: [PATCH 2/3] Changes agreed on in https://github.com/borisyankov/DefinitelyTyped/pull/2309/files#r13778987 moved `createDecipher` function out of the cipher-interface --- node/node.d.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index bd0429ad12..45dc16a0f4 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1045,14 +1045,19 @@ declare module "crypto" { export interface Credentials { context?: any; } export function createCredentials(details: CredentialDetails): Credentials; export function createHash(algorithm: string): Hash; - export function createHmac(algorithm: string, key: any): Hmac; + export function createHmac(algorithm: string, key: string): Hmac; + export function createHmac(algorithm: string, key: Buffer): Hmac; interface Hash { update(data: any, input_encoding?: string): Hash; - digest(encoding?: string): any; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): any; + digest(): Buffer; } interface Hmac { update(data: any, input_encoding?: string): Hmac; - digest(encoding?: string): any; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): any; + digest(): any; } export function createCipher(algorithm: string, password: any): Cipher; export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; @@ -1060,9 +1065,9 @@ declare module "crypto" { update(data: any, input_encoding?: string, output_encoding?: string): string; final(output_encoding?: string): string; setAutoPadding(auto_padding: boolean): void; - createDecipher(algorithm: string, password: any): Decipher; - createDecipheriv(algorithm: string, key: any, iv: any): Decipher; } + export function createDecipher(algorithm: string, password: any): Decipher; + export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; interface Decipher { update(data: any, input_encoding?: string, output_encoding?: string): void; final(output_encoding?: string): string; From 14af5ff76895c780bb54e971e160f2d35c46ccca Mon Sep 17 00:00:00 2001 From: Jonathan Pirnay Date: Thu, 19 Jun 2014 12:17:48 +0200 Subject: [PATCH 3/3] Fix: Substitute `any` with Buffer --- node/node.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/node.d.ts b/node/node.d.ts index 45dc16a0f4..248b0ad535 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1057,7 +1057,7 @@ declare module "crypto" { update(data: any, input_encoding?: string): Hmac; digest(encoding: 'buffer'): Buffer; digest(encoding: string): any; - digest(): any; + digest(): Buffer; } export function createCipher(algorithm: string, password: any): Cipher; export function createCipheriv(algorithm: string, key: any, iv: any): Cipher;