forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#71619 add type declarations for s-salt-pep…
…per by @kguzek
- Loading branch information
Showing
5 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* | ||
!**/*.d.ts | ||
!**/*.d.cts | ||
!**/*.d.mts | ||
!**/*.d.*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** Gets and sets the salt length. | ||
* @param saltLength default: 32 | ||
* @returns the salt length | ||
*/ | ||
export function saltLength(saltLength?: number): number; | ||
/** Gets and sets the number of hash iterations to make. | ||
* @param iterations default: 1000000 | ||
* @returns the number of hash iterations | ||
*/ | ||
export function iterations(iterations?: number): number; | ||
/** Gets and sets the key length. | ||
* @param keyLength default: 128 | ||
* @returns the key length | ||
*/ | ||
export function keyLength(keyLength?: number): number; | ||
/** Gets and sets the digest algorithm. | ||
* @param digest default: "sha512" | ||
* @returns the digest algorithm | ||
*/ | ||
export function digest(digest?: string): string; | ||
/** Gets and sets the pepper value, which will be concatenated to any salts used from now. | ||
* @param pepper default: "" | ||
* @returns the pepper value | ||
*/ | ||
export function pepper(pepper?: string): string; | ||
|
||
/** Hashes a password. | ||
* @param password the password to hash | ||
* @returns a promise that resolves to an object containing the base 64 salt and hash | ||
*/ | ||
export function hash(password: string): Promise<{ salt: string; hash: string }>; | ||
|
||
/** Compares a password with a salt and hash. | ||
* @param password the unhashed password | ||
* @param salt the salt with which to hash the password | ||
* @param hash the hash to compare the password against | ||
* @returns true if hashing the password with the salt produces the hash, false otherwise | ||
*/ | ||
export function compare(password: string, { salt, hash }: { salt: string; hash: string }): Promise<boolean>; | ||
|
||
/** s-salt-pepper provides password hashing with salt and variable iterations of pbkdf2. */ | ||
export as namespace password; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"private": true, | ||
"name": "@types/s-salt-pepper", | ||
"version": "3.0.9999", | ||
"projects": [ | ||
"https://github.com/sebastiansandqvist/s-salt-pepper" | ||
], | ||
"devDependencies": { | ||
"@types/s-salt-pepper": "workspace:." | ||
}, | ||
"owners": [ | ||
{ | ||
"name": "Konrad Guzek", | ||
"githubUsername": "kguzek" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import password from "s-salt-pepper"; | ||
|
||
// $ExpectType number | ||
password.saltLength(); | ||
|
||
// $ExpectType number | ||
password.saltLength(32); | ||
|
||
// $ExpectType number | ||
password.iterations(); | ||
|
||
// $ExpectType number | ||
password.iterations(1000000); | ||
|
||
// $ExpectType number | ||
password.keyLength(); | ||
|
||
// $ExpectType number | ||
password.keyLength(128); | ||
|
||
// $ExpectType string | ||
password.digest(); | ||
|
||
// $ExpectType string | ||
password.digest("sha512"); | ||
|
||
// $ExpectType string | ||
password.pepper(); | ||
|
||
// $ExpectType string | ||
password.pepper(""); | ||
|
||
// $ExpectType Promise<{ salt: string; hash: string; }> | ||
password.hash("password"); | ||
|
||
// $ExpectType Promise<boolean> | ||
password.compare("password", { salt: "salt", hash: "hash" }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "node16", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"s-salt-pepper-tests.ts" | ||
] | ||
} |