Add node-phpass (#42894)

* Add node-phpass

* Add tests
This commit is contained in:
Glenn Reyes 2020-03-06 23:35:20 +01:00 committed by GitHub
parent 377936895e
commit accdb12060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 0 deletions

13
types/node-phpass/index.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
// Type definitions for node-phpass 1.0
// Project: https://github.com/glauberportella/password-hash
// Definitions by: Glenn Reyes <https://github.com/DefinitelyTyped>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export const CRYPT_BLOWFISH = 1;
export const CRYPT_EXT_DES = 2;
export class PasswordHash {
constructor(length?: number, portable?: boolean, phpVersion?: number);
CheckPassword(password: string, hash: string): boolean;
HashPassword(password: string, method?: typeof CRYPT_BLOWFISH | typeof CRYPT_EXT_DES): Promise<string>;
}

View File

@ -0,0 +1,11 @@
import { CRYPT_BLOWFISH, CRYPT_EXT_DES, PasswordHash } from 'node-phpass';
const hasher: PasswordHash = new PasswordHash();
const hash: Promise<string> = hasher.HashPassword('foo').then(hash => {
hasher.CheckPassword('foo', hash);
return hash;
});
const blowfishHasher: PasswordHash = new PasswordHash(8, true, CRYPT_BLOWFISH);
const extDesHasher: PasswordHash = new PasswordHash(8, false, CRYPT_EXT_DES);

View 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",
"node-phpass-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }