Socket
Socket
Sign inDemoInstall

@adonisjs/hash

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonisjs/hash - npm Package Compare versions

Comparing version 8.0.1-0 to 8.1.0-0

build/src/debug.d.ts

8

build/src/define_config.js

@@ -1,13 +0,13 @@

import { InvalidHashConfigException } from './exceptions/invalid_hash_config.js';
import { RuntimeException } from '@poppinss/utils';
export function defineConfig(config) {
if (!config.list) {
throw new InvalidHashConfigException('Missing "list" property in hash config');
throw new RuntimeException('Missing "list" property in hash config');
}
if (Object.keys(config.list).length && !config.default) {
throw new InvalidHashConfigException('Missing "default" property in hash config. Specify a default hasher');
throw new RuntimeException('Missing "default" property in hash config. Specify a default hasher');
}
if (config.default && !config.list[config.default]) {
throw new InvalidHashConfigException(`Missing "list.${String(config.default)}". It is referenced by the "default" property`);
throw new RuntimeException(`Missing "list.${String(config.default)}". It is referenced by the "default" property`);
}
return config;
}

@@ -5,3 +5,5 @@ import { Hash } from './hash.js';

import { Scrypt } from './drivers/scrypt.js';
import debug from './debug.js';
import { Fake } from './drivers/fake.js';
import { RuntimeException } from '@poppinss/utils';
export class HashManager {

@@ -18,2 +20,3 @@ #config;

this.#config = config;
debug('creating hash manager. config: %O', this.#config);
}

@@ -30,3 +33,3 @@ #createDriver(name, config) {

if (!hasherToUse) {
throw new Error('Cannot create hash instance. No default hasher is defined in the config');
throw new RuntimeException('Cannot create hash instance. No default hasher is defined in the config');
}

@@ -39,4 +42,6 @@ if (this.#fakeHasher) {

if (cachedHasher) {
debug('using hasher from cache. name: "%s"', hasherToUse);
return cachedHasher;
}
debug('creating hash driver. name: "%s", config: %O', hasherToUse, config);
const hash = new Hash(this.#createDriver(config.driver, config));

@@ -47,2 +52,3 @@ this.#hashersCache[config.driver] = hash;

fake() {
debug('enabling fakes');
if (!this.#fakeHasher) {

@@ -53,5 +59,7 @@ this.#fakeHasher = new Hash(new Fake());

restore() {
debug('restoring fakes');
this.#fakeHasher = undefined;
}
extend(driver, factory) {
debug('adding custom driver %s', driver);
this.#drivers[driver] = factory;

@@ -58,0 +66,0 @@ }

{
"name": "@adonisjs/hash",
"version": "8.0.1-0",
"version": "8.1.0-0",
"description": "Multi driver hash module with support for PHC string formats",

@@ -18,3 +18,3 @@ "main": "build/index.js",

"pretest": "npm run lint",
"test": "c8 npm run vscode:test",
"test": "cross-env NODE_DEBUG=adonisjs:hash c8 npm run vscode:test",
"clean": "del-cli build",

@@ -47,5 +47,5 @@ "compile": "npm run lint && npm run clean && tsc",

"@poppinss/dev-utils": "^2.0.3",
"@swc/core": "^1.3.20",
"@swc/core": "^1.3.21",
"@types/bcrypt": "^5.0.0",
"@types/node": "^18.11.9",
"@types/node": "^18.11.10",
"@types/sinon": "^10.0.13",

@@ -55,2 +55,3 @@ "argon2": "^0.30.2",

"c8": "^7.12.0",
"cross-env": "^7.0.3",
"del-cli": "^5.0.0",

@@ -71,3 +72,3 @@ "eslint": "^8.28.0",

"@phc/format": "^1.0.0",
"@poppinss/utils": "^6.0.1-0"
"@poppinss/utils": "^6.1.0-0"
},

@@ -74,0 +75,0 @@ "peerDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc