@adonisjs/hash
Advanced tools
Comparing version 8.3.1-7 to 8.3.1-8
@@ -1,31 +0,1 @@ | ||
import { ManagerDriverFactory } from '../src/types.js'; | ||
import { HashManager } from '../index.js'; | ||
import { Scrypt } from '../src/drivers/scrypt.js'; | ||
type Config<KnownHashers extends Record<string, ManagerDriverFactory>> = { | ||
default?: keyof KnownHashers; | ||
list: KnownHashers; | ||
}; | ||
/** | ||
* Hash manager factory is used to create an instance of hash manager | ||
* for testing | ||
*/ | ||
declare class HashManagerFactory<KnownHashers extends Record<string, ManagerDriverFactory> = { | ||
scrypt: () => Scrypt; | ||
}> { | ||
#private; | ||
constructor(config?: { | ||
default?: keyof KnownHashers; | ||
list: KnownHashers; | ||
}); | ||
/** | ||
* Merge factory parameters | ||
*/ | ||
merge<Hashers extends Record<string, ManagerDriverFactory>>(config: Config<Hashers>): HashManagerFactory<Hashers>; | ||
/** | ||
* Create hash manager instance | ||
*/ | ||
create(): HashManager<KnownHashers>; | ||
} | ||
export { HashManagerFactory }; | ||
export { HashManagerFactory } from './hash_manager.js'; |
import { | ||
HashManager | ||
} from "../chunk-WTHUFHHU.js"; | ||
} from "../chunk-OGVBAMYL.js"; | ||
import { | ||
Scrypt | ||
} from "../chunk-ZUKNXYT4.js"; | ||
import "../chunk-7RS6HCBK.js"; | ||
import "../chunk-JSA56AE7.js"; | ||
import "../chunk-AXCKF2IS.js"; | ||
} from "../chunk-7JOSD2MP.js"; | ||
import "../chunk-NJXUVUWA.js"; | ||
import "../chunk-HRTBMSFS.js"; | ||
import "../chunk-LQ2VYIYD.js"; | ||
@@ -41,1 +41,2 @@ // factories/hash_manager.ts | ||
}; | ||
//# sourceMappingURL=main.js.map |
@@ -1,109 +0,2 @@ | ||
import { HashDriverContract, ManagerDriverFactory } from './src/types.js'; | ||
/** | ||
* Hash and verify values using a dedicated hash driver. The Hash | ||
* works as an adapter across different drivers. | ||
* | ||
* ```ts | ||
* const hash = new Hash(new Argon()) | ||
* const hashedPassword = await hash.make('secret') | ||
* | ||
* const isValid = await hash.verify(hashedPassword, 'secret') | ||
* console.log(isValid) | ||
* ``` | ||
*/ | ||
declare class Hash implements HashDriverContract { | ||
#private; | ||
constructor(driver: HashDriverContract); | ||
/** | ||
* Check if the value is a valid hash. This method just checks | ||
* for the formatting of the hash | ||
*/ | ||
isValidHash(value: string): boolean; | ||
/** | ||
* Hash plain text value | ||
*/ | ||
make(value: string): Promise<string>; | ||
/** | ||
* Verify the plain text value against an existing hash | ||
*/ | ||
verify(hashedValue: string, plainValue: string): Promise<boolean>; | ||
/** | ||
* Find if the hash value needs a rehash or not. | ||
*/ | ||
needsReHash(hashedValue: string): boolean; | ||
/** | ||
* Assert the plain value passes the hash verification | ||
*/ | ||
assertEquals(hashedValue: string, plainValue: string): Promise<void>; | ||
/** | ||
* Assert the plain value fails the hash verification | ||
*/ | ||
assertNotEquals(hashedValue: string, plainValue: string): Promise<void>; | ||
} | ||
/** | ||
* HashManager implements the manager/builder pattern to create a use multiple | ||
* hashing algorithm without self managing hash instance. | ||
* | ||
* ```ts | ||
* const manager = new HashManager({ | ||
* default: 'argon', | ||
* list: { | ||
* argon: () => new ArgonDriver(), | ||
* bcrypt: () => new BcryptDriver(), | ||
* } | ||
* }) | ||
* ``` | ||
*/ | ||
declare class HashManager<KnownHashers extends Record<string, ManagerDriverFactory>> implements HashDriverContract { | ||
#private; | ||
constructor(config: { | ||
default?: keyof KnownHashers; | ||
list: KnownHashers; | ||
}); | ||
/** | ||
* Use one of the registered hashers to hash values. | ||
* | ||
* ```ts | ||
* manager.use() // returns default hasher | ||
* manager.use('argon') | ||
* ``` | ||
*/ | ||
use<Hasher extends keyof KnownHashers>(hasher?: Hasher): Hash; | ||
/** | ||
* Fake hash drivers to disable hashing values | ||
*/ | ||
fake(): void; | ||
/** | ||
* Restore fake | ||
*/ | ||
restore(): void; | ||
/** | ||
* Check if the value is a valid hash. This method just checks | ||
* for the formatting of the hash | ||
*/ | ||
isValidHash(value: string): boolean; | ||
/** | ||
* Hash plain text value | ||
*/ | ||
make(value: string): Promise<string>; | ||
/** | ||
* Verify the plain text value against an existing hash | ||
*/ | ||
verify(hashedValue: string, plainValue: string): Promise<boolean>; | ||
/** | ||
* Find if the hash value needs a rehash or not. | ||
*/ | ||
needsReHash(hashedValue: string): boolean; | ||
/** | ||
* Assert the plain value passes the hash verification | ||
*/ | ||
assertEquals(hashedValue: string, plainValue: string): Promise<void>; | ||
/** | ||
* Assert the plain value fails the hash verification | ||
*/ | ||
assertNotEquals(hashedValue: string, plainValue: string): Promise<void>; | ||
} | ||
export { Hash, HashManager }; | ||
export { Hash } from './src/hash.js'; | ||
export { HashManager } from './src/hash_manager.js'; |
import { | ||
Hash, | ||
HashManager | ||
} from "./chunk-WTHUFHHU.js"; | ||
import "./chunk-AXCKF2IS.js"; | ||
} from "./chunk-OGVBAMYL.js"; | ||
import "./chunk-LQ2VYIYD.js"; | ||
export { | ||
@@ -10,1 +10,2 @@ Hash, | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,2 @@ | ||
import { HashDriverContract, ArgonConfig } from '../types.js'; | ||
import type { ArgonConfig, HashDriverContract } from '../types.js'; | ||
/** | ||
@@ -17,3 +16,3 @@ * Hash driver built on top of "argon2" hash algorigthm. Under the hood | ||
*/ | ||
declare class Argon implements HashDriverContract { | ||
export declare class Argon implements HashDriverContract { | ||
#private; | ||
@@ -58,2 +57,3 @@ constructor(config: ArgonConfig); | ||
* 5. The argon variant is changed | ||
* 6. The provided hash has not been hashed with argon | ||
* | ||
@@ -71,3 +71,1 @@ * ```ts | ||
} | ||
export { Argon }; |
@@ -7,7 +7,7 @@ import { | ||
randomBytesAsync | ||
} from "../../chunk-7RS6HCBK.js"; | ||
} from "../../chunk-NJXUVUWA.js"; | ||
import { | ||
PhcFormatter | ||
} from "../../chunk-JSA56AE7.js"; | ||
import "../../chunk-AXCKF2IS.js"; | ||
} from "../../chunk-HRTBMSFS.js"; | ||
import "../../chunk-LQ2VYIYD.js"; | ||
@@ -204,2 +204,3 @@ // src/drivers/argon.ts | ||
* 5. The argon variant is changed | ||
* 6. The provided hash has not been hashed with argon | ||
* | ||
@@ -218,3 +219,3 @@ * ```ts | ||
if (!this.#ids.includes(phcNode.id)) { | ||
throw new TypeError("Value is not a valid argon hash"); | ||
return true; | ||
} | ||
@@ -245,1 +246,2 @@ if (phcNode.version !== this.#config.version) { | ||
}; | ||
//# sourceMappingURL=argon.js.map |
@@ -1,3 +0,2 @@ | ||
import { HashDriverContract, BcryptConfig } from '../types.js'; | ||
import type { HashDriverContract, BcryptConfig } from '../types.js'; | ||
/** | ||
@@ -17,3 +16,3 @@ * Hash driver built on top of "bcrypt" hash algorigthm. Under the hood | ||
*/ | ||
declare class Bcrypt implements HashDriverContract { | ||
export declare class Bcrypt implements HashDriverContract { | ||
#private; | ||
@@ -56,2 +55,3 @@ constructor(config: BcryptConfig); | ||
* 3. Bcrypt hash is not using MCF hash format | ||
* 4. The provided hash has not been hashed with bcrypt | ||
* | ||
@@ -69,3 +69,1 @@ * ```ts | ||
} | ||
export { Bcrypt }; |
@@ -5,10 +5,10 @@ import { | ||
randomBytesAsync | ||
} from "../../chunk-7RS6HCBK.js"; | ||
} from "../../chunk-NJXUVUWA.js"; | ||
import { | ||
PhcFormatter | ||
} from "../../chunk-JSA56AE7.js"; | ||
} from "../../chunk-HRTBMSFS.js"; | ||
import { | ||
__commonJS, | ||
__toESM | ||
} from "../../chunk-AXCKF2IS.js"; | ||
} from "../../chunk-LQ2VYIYD.js"; | ||
@@ -380,2 +380,3 @@ // src/legacy/bcrypt_base64.cjs | ||
* 3. Bcrypt hash is not using MCF hash format | ||
* 4. The provided hash has not been hashed with bcrypt | ||
* | ||
@@ -397,3 +398,3 @@ * ```ts | ||
if (phcNode.id !== "bcrypt") { | ||
throw new TypeError("Value is not a valid bcrypt hash"); | ||
return true; | ||
} | ||
@@ -415,1 +416,2 @@ if (phcNode.version !== this.#config.version) { | ||
}; | ||
//# sourceMappingURL=bcrypt.js.map |
@@ -1,3 +0,2 @@ | ||
import { HashDriverContract, ScryptConfig } from '../types.js'; | ||
import type { ScryptConfig, HashDriverContract } from '../types.js'; | ||
/** | ||
@@ -17,3 +16,3 @@ * Hash driver built on top of "scrypt" hash algorigthm. Under the hood | ||
*/ | ||
declare class Scrypt implements HashDriverContract { | ||
export declare class Scrypt implements HashDriverContract { | ||
#private; | ||
@@ -56,2 +55,3 @@ constructor(config: ScryptConfig); | ||
* 3. The parallelization value is changed | ||
* 4. The provided hash has not been hashed with scrypt | ||
* | ||
@@ -69,3 +69,1 @@ * ```ts | ||
} | ||
export { Scrypt }; |
import { | ||
Scrypt | ||
} from "../../chunk-ZUKNXYT4.js"; | ||
import "../../chunk-7RS6HCBK.js"; | ||
import "../../chunk-JSA56AE7.js"; | ||
import "../../chunk-AXCKF2IS.js"; | ||
} from "../../chunk-7JOSD2MP.js"; | ||
import "../../chunk-NJXUVUWA.js"; | ||
import "../../chunk-HRTBMSFS.js"; | ||
import "../../chunk-LQ2VYIYD.js"; | ||
export { | ||
Scrypt | ||
}; | ||
//# sourceMappingURL=scrypt.js.map |
@@ -0,3 +1,3 @@ | ||
/// <reference types="node" resolution-mode="require"/> | ||
import { PhcNode } from './types.js'; | ||
/** | ||
@@ -7,3 +7,3 @@ * Phc formatter is used to serialize a hash to a phc string and | ||
*/ | ||
declare class PhcFormatter<Params extends Record<string, string | number> = Record<string, string | number>> { | ||
export declare class PhcFormatter<Params extends Record<string, string | number> = Record<string, string | number>> { | ||
/** | ||
@@ -22,3 +22,1 @@ * Serialize salt and hash with predefined options. | ||
} | ||
export { PhcFormatter }; |
import { | ||
PhcFormatter | ||
} from "../chunk-JSA56AE7.js"; | ||
import "../chunk-AXCKF2IS.js"; | ||
} from "../chunk-HRTBMSFS.js"; | ||
import "../chunk-LQ2VYIYD.js"; | ||
export { | ||
PhcFormatter | ||
}; | ||
//# sourceMappingURL=phc_formatter.js.map |
@@ -0,5 +1,6 @@ | ||
/// <reference types="node" resolution-mode="require"/> | ||
/** | ||
* The contract Hash drivers should adhere to | ||
*/ | ||
interface HashDriverContract { | ||
export interface HashDriverContract { | ||
/** | ||
@@ -26,3 +27,3 @@ * Check if the value is a valid hash. This method just checks | ||
*/ | ||
type PhcNode<Params extends Record<string, string | number> = Record<string, string | number>> = { | ||
export type PhcNode<Params extends Record<string, string | number> = Record<string, string | number>> = { | ||
id: string; | ||
@@ -37,7 +38,7 @@ salt: Buffer; | ||
*/ | ||
type ArgonVariants = 'd' | 'i' | 'id'; | ||
export type ArgonVariants = 'd' | 'i' | 'id'; | ||
/** | ||
* Shape of argon2 config | ||
*/ | ||
type ArgonConfig = { | ||
export type ArgonConfig = { | ||
/** | ||
@@ -95,3 +96,3 @@ * The argon hash type to use. | ||
*/ | ||
type BcryptConfig = { | ||
export type BcryptConfig = { | ||
/** | ||
@@ -120,3 +121,3 @@ * The cost of processing the data | ||
*/ | ||
type ScryptConfig = { | ||
export type ScryptConfig = { | ||
/** | ||
@@ -164,4 +165,2 @@ * CPU/memory cost parameter. Must be a power of two greater than one. | ||
*/ | ||
type ManagerDriverFactory = () => HashDriverContract; | ||
export { ArgonConfig, ArgonVariants, BcryptConfig, HashDriverContract, ManagerDriverFactory, PhcNode, ScryptConfig }; | ||
export type ManagerDriverFactory = () => HashDriverContract; |
{ | ||
"name": "@adonisjs/hash", | ||
"version": "8.3.1-7", | ||
"version": "8.3.1-8", | ||
"description": "Framework agnostic Password hashing package with support for PHC string format", | ||
@@ -8,3 +8,6 @@ "main": "build/index.js", | ||
"files": [ | ||
"build" | ||
"build", | ||
"!build/bin", | ||
"!build/coverage", | ||
"!build/tests" | ||
], | ||
@@ -28,3 +31,4 @@ "exports": { | ||
"typecheck": "tsc --noEmit", | ||
"compile": "npm run lint && npm run clean && tsup-node", | ||
"precompile": "npm run lint && npm run clean", | ||
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration", | ||
"build": "npm run compile", | ||
@@ -47,14 +51,14 @@ "release": "np", | ||
"devDependencies": { | ||
"@adonisjs/eslint-config": "^1.1.8", | ||
"@adonisjs/prettier-config": "^1.1.8", | ||
"@adonisjs/tsconfig": "^1.1.8", | ||
"@commitlint/cli": "^17.8.0", | ||
"@commitlint/config-conventional": "^17.8.0", | ||
"@japa/assert": "^2.0.0", | ||
"@adonisjs/eslint-config": "^1.1.9", | ||
"@adonisjs/prettier-config": "^1.1.9", | ||
"@adonisjs/tsconfig": "^1.1.9", | ||
"@commitlint/cli": "^18.4.3", | ||
"@commitlint/config-conventional": "^18.4.3", | ||
"@japa/assert": "^2.0.1", | ||
"@japa/expect-type": "^2.0.0", | ||
"@japa/runner": "^3.0.2", | ||
"@swc/core": "1.3.82", | ||
"@types/bcrypt": "^5.0.0", | ||
"@types/node": "^20.8.6", | ||
"argon2": "^0.31.1", | ||
"@japa/runner": "^3.1.0", | ||
"@swc/core": "^1.3.99", | ||
"@types/bcrypt": "^5.0.2", | ||
"@types/node": "^20.9.4", | ||
"argon2": "^0.31.2", | ||
"bcrypt": "^5.1.1", | ||
@@ -64,17 +68,17 @@ "c8": "^8.0.1", | ||
"del-cli": "^5.1.0", | ||
"eslint": "^8.51.0", | ||
"eslint": "^8.54.0", | ||
"github-label-sync": "^2.3.1", | ||
"husky": "^8.0.3", | ||
"np": "^8.0.4", | ||
"prettier": "^3.0.3", | ||
"prettier": "^3.1.0", | ||
"ts-node": "^10.9.1", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
"tsup": "^8.0.1", | ||
"typescript": "5.2.2" | ||
}, | ||
"dependencies": { | ||
"@phc/format": "^1.0.0", | ||
"@poppinss/utils": "^6.5.0" | ||
"@poppinss/utils": "^6.5.1" | ||
}, | ||
"peerDependencies": { | ||
"argon2": "^0.31.0", | ||
"argon2": "^0.31.2", | ||
"bcrypt": "^5.1.1" | ||
@@ -140,5 +144,6 @@ }, | ||
"format": "esm", | ||
"dts": true, | ||
"dts": false, | ||
"sourcemap": true, | ||
"target": "esnext" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
110628
41
1772
0
Updated@poppinss/utils@^6.5.1