[Pkg-javascript-commits] [node-hash.js] 12/19: lib: add typescript declaration file

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 12:00:12 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-hash.js.

commit 2bef751444b991b06a03d50e9c061eca5d7d458e
Author: Jason Dreyzehner <jason at dreyzehner.com>
Date:   Sat Jul 1 11:30:05 2017 -0400

    lib: add typescript declaration file
---
 lib/hash.d.ts | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 package.json  |   1 +
 2 files changed, 106 insertions(+)

diff --git a/lib/hash.d.ts b/lib/hash.d.ts
new file mode 100644
index 0000000..2994a75
--- /dev/null
+++ b/lib/hash.d.ts
@@ -0,0 +1,105 @@
+declare var hash: Hash;
+
+declare module "hash.js" {
+    export default hash;
+}
+
+interface BlockHash<T> {
+    hmacStrength: number
+    padLength: number
+    endian: 'big' | 'little'
+}
+
+interface MessageDigest<T> {
+    blockSize: number
+    outSize: number
+    update(msg: any, enc?: 'hex'): T
+    digest(enc?: 'hex'): T
+}
+
+interface Hash {
+    hmac: HmacConstructor
+    ripemd: RipemdSet
+    ripemd160: Ripemd160Constructor
+    sha: ShaSet
+    sha1: Sha1Constructor
+    sha224: Sha224Constructor
+    sha256: Sha256Constructor
+    sha384: Sha384Constructor
+    sha512: Sha512Constructor
+    utils: Utils
+}
+
+interface Utils {
+    toArray(msg: any, enc: 'hex'): Array<number>
+    toHex(msg: any): string
+}
+
+interface RipemdSet {
+    ripemd160: Ripemd160Constructor
+}
+
+interface ShaSet {
+    sha1: Sha1Constructor
+    sha224: Sha224Constructor
+    sha256: Sha256Constructor
+    sha384: Sha384Constructor
+    sha512: Sha512Constructor
+}
+
+interface HmacConstructor { (hash: BlockHash<any>, key: any, enc?: 'hex'): Hmac }
+interface Ripemd160Constructor { (): Ripemd160 }
+interface Sha1Constructor { (): Sha1; }
+interface Sha224Constructor { (): Sha224; }
+interface Sha256Constructor { (): Sha256; }
+interface Sha384Constructor { (): Sha384; }
+interface Sha512Constructor { (): Sha512; }
+
+interface Hmac extends MessageDigest<Hmac> {
+    blockSize: 512
+    outSize: 160
+}
+
+interface Ripemd160 extends BlockHash<Ripemd160>, MessageDigest<Ripemd160> {
+    blockSize: 512
+    hmacStrength: 192
+    outSize: 160
+    padLength: 64
+    endian: 'little'
+}
+
+interface Sha1 extends BlockHash<Sha1>, MessageDigest<Sha1> {
+    blockSize: 512
+    hmacStrength: 80
+    outSize: 160
+    padLength: 64
+    endian: 'big'
+}
+interface Sha224 extends BlockHash<Sha224>, MessageDigest<Sha224> {
+    blockSize: 512
+    hmacStrength: 192
+    outSize: 224
+    padLength: 64
+    endian: 'big'
+}
+interface Sha256 extends BlockHash<Sha256>, MessageDigest<Sha256> {
+    blockSize: 512
+    hmacStrength: 192
+    outSize: 256
+    padLength: 64
+    endian: 'big'
+}
+interface Sha384 extends BlockHash<Sha384>, MessageDigest<Sha384> {
+    blockSize: 1024
+    hmacStrength: 192
+    outSize: 384
+    padLength: 128
+    endian: 'big'
+}
+interface Sha512 extends BlockHash<Sha512>, MessageDigest<Sha512> {
+    blockSize: 1024
+    hmacStrength: 192
+    outSize: 512
+    padLength: 128
+    endian: 'big'
+}
diff --git a/package.json b/package.json
index 6c76221..85ce533 100644
--- a/package.json
+++ b/package.json
@@ -3,6 +3,7 @@
   "version": "1.1.2",
   "description": "Various hash functions that could be run by both browser and node",
   "main": "lib/hash.js",
+  "typings": "lib/hash.d.ts",
   "scripts": {
     "test": "mocha --reporter=spec test/*-test.js && npm run lint",
     "lint": "eslint lib/*.js lib/**/*.js lib/**/**/*.js test/*.js"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-hash.js.git



More information about the Pkg-javascript-commits mailing list