diff --git a/types/is-secret/index.d.ts b/types/is-secret/index.d.ts new file mode 100644 index 0000000000..c5d036146f --- /dev/null +++ b/types/is-secret/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for is-secret 1.2 +// Project: https://github.com/watson/is-secret#readme +// Definitions by: Walter Rumsby +// Piotr Błażejewicz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * A distributed maintained collection of patterns that indicate that something probably is secret. + * This is useful if you want to filter sensitive values in a data set. + * This module uses a very simple algorithm that will not catch everything. Use at your own risk. + */ + +/** + * Validates the given string against a list of key names known to typically indicate secret data. + * Returns `true` if the string is considered secret. Otherwise `false`. + */ +export function key(str: string): boolean; + +/** + * Validates the given string against a list of patterns that indicates secret data. + * Returns `true` if the string is considered secret. Otherwise `false`. + */ +export function value(str: string): boolean; diff --git a/types/is-secret/is-secret-tests.ts b/types/is-secret/is-secret-tests.ts new file mode 100644 index 0000000000..a54c8ad9c3 --- /dev/null +++ b/types/is-secret/is-secret-tests.ts @@ -0,0 +1,20 @@ +import isSecret = require('is-secret'); + +interface Data { + username: string; + password: string; + card: string; +} + +const data: Data = { + username: 'watson', + password: 'f8bY2fg8', + card: '1234 1234 1234 1234', // credit card number +}; + +if (isSecret.key('password') || isSecret.value(data.password)) { + data.password = '********'; +} + +isSecret.key('secret-key'); // $ExpectType boolean +isSecret.value('secret-value'); // $ExpectType boolean diff --git a/types/is-secret/tsconfig.json b/types/is-secret/tsconfig.json new file mode 100644 index 0000000000..9db5d85f28 --- /dev/null +++ b/types/is-secret/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-secret-tests.ts" + ] +} diff --git a/types/is-secret/tslint.json b/types/is-secret/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-secret/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }