Merge pull request #17260 from luminopia/master

cryptiles: add initial typing for 3.1
This commit is contained in:
Mine Starks
2017-06-16 18:21:30 -07:00
committed by GitHub
4 changed files with 49 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
import * as cryptiles from "cryptiles";
cryptiles.randomString(0); // $ExpectType string
cryptiles.randomDigits(0); // $ExpectType string
cryptiles.fixedTimeComparison("", ""); // $ExpectTpe boolean
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for cryptiles 3.1
// Project: https://github.com/hapijs/cryptiles
// Definitions by: Alex Wendland <https://github.com/awendland>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Returns a cryptographically strong pseudo-random data string. Takes a size argument for the length of the string.
*/
export function randomString(size: number): string;
/**
* Returns a cryptographically strong pseudo-random data string consisting of only numerical digits (0-9).
* Takes a size argument for the length of the string.
*/
export function randomDigits(size: number): string;
/**
* Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match).
* Returns true if the strings match, false if they differ.
*/
export function fixedTimeComparison(a: string, b: string): boolean;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cryptiles-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }