mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #46019 feat(is-secret): new type definition by @peterblazejewicz
This is a redo of staled #45475 The original PR author is listed here as the owner. This commit redos details of original PR as per comments - use default exports as per DT template and Don't/Do's - use default `tslint.json` without non essential overrides /cc @wrumsby https://github.com/watson/is-secret#readme Thanks!
This commit is contained in:
parent
b5490c2e82
commit
56c9ebef90
23
types/is-secret/index.d.ts
vendored
Normal file
23
types/is-secret/index.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Type definitions for is-secret 1.2
|
||||
// Project: https://github.com/watson/is-secret#readme
|
||||
// Definitions by: Walter Rumsby <https://github.com/wrumsby>
|
||||
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// 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;
|
||||
20
types/is-secret/is-secret-tests.ts
Normal file
20
types/is-secret/is-secret-tests.ts
Normal file
@ -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
|
||||
23
types/is-secret/tsconfig.json
Normal file
23
types/is-secret/tsconfig.json
Normal file
@ -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"
|
||||
]
|
||||
}
|
||||
1
types/is-secret/tslint.json
Normal file
1
types/is-secret/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user