From 39e510415cb398c5b982f68adec1a82f84bebadd Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 12 Jan 2016 01:10:13 +0500 Subject: [PATCH] node: definition of the module "crypto" has been changed --- node/node-tests.ts | 7 +++++++ node/node.d.ts | 14 +++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index d3a76a983..9aebe5c53 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -203,6 +203,13 @@ function stream_readable_pipe_test() { var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex'); +{ + let hmac: crypto.Hmac; + (hmac = crypto.createHmac('md5', 'hello')).end('world', 'utf8', () => { + let hash: Buffer|string = hmac.read(); + }); +} + function crypto_cipher_decipher_string_test() { var key:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]); var clearText:string = "This is the clear text."; diff --git a/node/node.d.ts b/node/node.d.ts index 6c4fbfa47..a7f1a1617 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1681,13 +1681,13 @@ declare module "crypto" { export function createHash(algorithm: string): Hash; export function createHmac(algorithm: string, key: string): Hmac; export function createHmac(algorithm: string, key: Buffer): Hmac; - interface Hash { + export interface Hash { update(data: any, input_encoding?: string): Hash; digest(encoding: 'buffer'): Buffer; digest(encoding: string): any; digest(): Buffer; } - interface Hmac { + export interface Hmac extends NodeJS.ReadWriteStream { update(data: any, input_encoding?: string): Hmac; digest(encoding: 'buffer'): Buffer; digest(encoding: string): any; @@ -1695,7 +1695,7 @@ declare module "crypto" { } export function createCipher(algorithm: string, password: any): Cipher; export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; - interface Cipher { + export interface Cipher { update(data: Buffer): Buffer; update(data: string, input_encoding?: string, output_encoding?: string): string; final(): Buffer; @@ -1704,7 +1704,7 @@ declare module "crypto" { } export function createDecipher(algorithm: string, password: any): Decipher; export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; - interface Decipher { + export interface Decipher { update(data: Buffer): Buffer; update(data: string, input_encoding?: string, output_encoding?: string): string; final(): Buffer; @@ -1712,18 +1712,18 @@ declare module "crypto" { setAutoPadding(auto_padding: boolean): void; } export function createSign(algorithm: string): Signer; - interface Signer extends NodeJS.WritableStream { + export interface Signer extends NodeJS.WritableStream { update(data: any): void; sign(private_key: string, output_format: string): string; } export function createVerify(algorith: string): Verify; - interface Verify extends NodeJS.WritableStream { + export interface Verify extends NodeJS.WritableStream { update(data: any): void; verify(object: string, signature: string, signature_format?: string): boolean; } export function createDiffieHellman(prime_length: number): DiffieHellman; export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; - interface DiffieHellman { + export interface DiffieHellman { generateKeys(encoding?: string): string; computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; getPrime(encoding?: string): string;