@adonisjs/hash
Advanced tools
Comparing version 8.3.1-0 to 8.3.1-1
@@ -16,2 +16,4 @@ import { Hash } from './hash.js'; | ||
needsReHash(hashedValue: string): boolean; | ||
assertEquals(hashedValue: string, plainValue: string): Promise<void>; | ||
assertNotEquals(hashedValue: string, plainValue: string): Promise<void>; | ||
} |
@@ -57,2 +57,8 @@ import { RuntimeException } from '@poppinss/utils'; | ||
} | ||
async assertEquals(hashedValue, plainValue) { | ||
return this.use().assertEquals(hashedValue, plainValue); | ||
} | ||
async assertNotEquals(hashedValue, plainValue) { | ||
return this.use().assertNotEquals(hashedValue, plainValue); | ||
} | ||
} |
@@ -9,2 +9,4 @@ import type { HashDriverContract } from './types.js'; | ||
needsReHash(hashedValue: string): boolean; | ||
assertEquals(hashedValue: string, plainValue: string): Promise<void>; | ||
assertNotEquals(hashedValue: string, plainValue: string): Promise<void>; | ||
} |
@@ -0,1 +1,2 @@ | ||
import { AssertionError } from 'node:assert'; | ||
export class Hash { | ||
@@ -18,2 +19,26 @@ #driver; | ||
} | ||
async assertEquals(hashedValue, plainValue) { | ||
const isEqual = await this.#driver.verify(hashedValue, plainValue); | ||
if (!isEqual) { | ||
throw new AssertionError({ | ||
message: `Expected "${plainValue}" to pass hash verification`, | ||
expected: true, | ||
actual: false, | ||
operator: 'strictEqual', | ||
stackStartFn: this.assertEquals, | ||
}); | ||
} | ||
} | ||
async assertNotEquals(hashedValue, plainValue) { | ||
const isEqual = await this.#driver.verify(hashedValue, plainValue); | ||
if (isEqual) { | ||
throw new AssertionError({ | ||
message: `Expected "${plainValue}" to fail hash verification`, | ||
expected: false, | ||
actual: true, | ||
operator: 'strictEqual', | ||
stackStartFn: this.assertNotEquals, | ||
}); | ||
} | ||
} | ||
} |
{ | ||
"name": "@adonisjs/hash", | ||
"version": "8.3.1-0", | ||
"version": "8.3.1-1", | ||
"description": "Multi driver hash module with support for PHC string formats", | ||
@@ -40,30 +40,27 @@ "main": "build/index.js", | ||
"devDependencies": { | ||
"@commitlint/cli": "^17.4.2", | ||
"@commitlint/config-conventional": "^17.4.2", | ||
"@japa/assert": "^1.3.6", | ||
"@japa/expect-type": "^1.0.2", | ||
"@japa/run-failed-tests": "^1.1.0", | ||
"@japa/runner": "^2.2.2", | ||
"@japa/spec-reporter": "^1.3.2", | ||
"@poppinss/dev-utils": "^2.0.3", | ||
"@swc/core": "^1.3.29", | ||
"@commitlint/cli": "^17.4.4", | ||
"@commitlint/config-conventional": "^17.4.4", | ||
"@japa/assert": "^1.4.1", | ||
"@japa/expect-type": "^1.0.3", | ||
"@japa/run-failed-tests": "^1.1.1", | ||
"@japa/runner": "^2.5.1", | ||
"@japa/spec-reporter": "^1.3.3", | ||
"@swc/core": "^1.3.39", | ||
"@types/bcrypt": "^5.0.0", | ||
"@types/node": "^18.11.18", | ||
"@types/sinon": "^10.0.13", | ||
"@types/node": "^18.15.0", | ||
"argon2": "^0.30.3", | ||
"bcrypt": "^5.0.1", | ||
"c8": "^7.12.0", | ||
"bcrypt": "^5.1.0", | ||
"c8": "^7.13.0", | ||
"cross-env": "^7.0.3", | ||
"del-cli": "^5.0.0", | ||
"eslint": "^8.32.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
"eslint": "^8.36.0", | ||
"eslint-config-prettier": "^8.7.0", | ||
"eslint-plugin-adonis": "^3.0.3", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"github-label-sync": "^2.2.0", | ||
"github-label-sync": "^2.3.1", | ||
"husky": "^8.0.3", | ||
"np": "^7.6.3", | ||
"prettier": "^2.8.3", | ||
"sinon": "^15.0.1", | ||
"prettier": "^2.8.4", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.4" | ||
"typescript": "^4.9.5" | ||
}, | ||
@@ -76,3 +73,3 @@ "dependencies": { | ||
"argon2": "^0.30.3", | ||
"bcrypt": "^5.0.1" | ||
"bcrypt": "^5.1.0" | ||
}, | ||
@@ -79,0 +76,0 @@ "peerDependenciesMeta": { |
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
36359
25
836