bajo-extra 0.2.15 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,16 @@
1
1
  import bcrypt from 'bcrypt'
2
2
  import crypto from 'crypto'
3
3
 
4
- async function hash (text, type = 'md5', { digest = 'hex', salt = 10 } = {}) {
4
+ async function hash (text, type = 'md5', options = {}) {
5
+ options.digest = options.digest ?? 'hex'
6
+ options.salt = options.hash ?? 10
5
7
  if (typeof text !== 'string') text = JSON.stringify(text)
6
- if (type === 'bcrypt') return await bcrypt.hash(text, salt)
7
- return crypto.createHash(type).update(text).digest(digest)
8
+ if (type === 'bcrypt') return await bcrypt.hash(text, options.salt)
9
+ if (type === 'short') {
10
+ type = 'shake256'
11
+ options.outputLength = 6
12
+ }
13
+ return crypto.createHash(type, options).update(text).digest(options.digest)
8
14
  }
9
15
 
10
16
  export default hash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo-extra",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Extra package for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,7 +34,6 @@
34
34
  "fast-csv": "^5.0.1",
35
35
  "fast-jwt": "^3.2.0",
36
36
  "fast-xml-parser": "^4.3.2",
37
- "littlehash": "^1.0.1",
38
37
  "ndjson": "^2.0.0",
39
38
  "performant-array-to-tree": "^1.11.0",
40
39
  "query-string": "^8.1.0",