@sequencemedia/pbkdf2 1.0.5 β†’ 1.0.6

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.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @sequencemedia/pbkdf2
2
+
3
+ A password can be validated against a `hash` and `salt` (and the number of `iterations` that were used to compute it)
4
+
5
+ Both the `hash` and `salt` are expected from the command line to be strings in _Base64_ format
6
+
7
+ - The `hash` is decoded to a `Buffer`
8
+ - The `salt` is transformed from _Base64_ into _ASCII_
9
+
10
+ ```bash
11
+ npm test
12
+ bash ./compare.sh
13
+ ```
package/compare.sh ADDED
@@ -0,0 +1,25 @@
1
+ #!/bin/bash
2
+
3
+ #Β the-user-1
4
+ npm run compare -- \
5
+ --password "^49pPaRdVSNC" \
6
+ --hash "kOhpM7//M4I9+WcWLH7vbb/yN2+8qKyxQ0xAfI4JzamcRMdwwl7vAh0ch7UJ0JoBe9AqaAGuUJZF/mVA9EqaLQ==" \
7
+ --salt "YzFjMTY4MmMyMWE4MjFkYjRhNWE5YjJmNDY0OTUzM2Q=" \
8
+ --iterations 32768 \
9
+ --digest sha512
10
+
11
+ # the-user-2
12
+ npm run compare -- \
13
+ --password "S0uSaC&FzDOO" \
14
+ --hash "BrtOel2qy5HrYWn45jBKf5b3HUKdVeQfIj1ljhGxQ/SiWsmMMuOl756H4MXkMOnVJKrgFfHFy7cgFXUaSFA2ow==" \
15
+ --salt "MDI2OGM0MDU4NWJiOTgxNWEyYzQwN2RkYjM1YTY5YWU=" \
16
+ --iterations 32768 \
17
+ --digest sha512
18
+
19
+ # the-user-3
20
+ npm run compare -- \
21
+ --password "@^EJmdlkt5A#" \
22
+ --hash "bV76sVqsM0doKBFnaHsZQC9OgcVnF/+gzkG7HFXdD7jyQdN1PqCVijyXKMijmYQPWJohi5f7sVxhoLJ5kf8aQA==" \
23
+ --salt "ZDI3OTZmZWU3M2I3M2Y3MTgxMmYyNGM3MjU4NDE2NDM=" \
24
+ --iterations 32768 \
25
+ --digest sha512
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequencemedia/pbkdf2",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "main": "./index.mjs",
5
5
  "type": "module",
6
6
  "author": {
@@ -14,12 +14,12 @@
14
14
  "url": "git@github.com:sequencemedia/pbkdf2.git"
15
15
  },
16
16
  "scripts": {
17
- "lint": "cross-env NODE_ENV=production eslint . --ext .mjs --ext .cjs",
17
+ "lint": "eslint . --ext .mjs --ext .cjs",
18
18
  "lint:fix": "npm run lint -- --fix",
19
19
  "test": "cross-env NODE_ENV=test mocha tests --recursive --verbose --color",
20
- "compare": "cross-env NODE_ENV=production node scripts/compare.mjs",
21
- "hash": "cross-env NODE_ENV=production node scripts/hash.mjs",
22
- "salt": "cross-env NODE_ENV=production node scripts/salt.mjs",
20
+ "compare": "node scripts/compare.mjs",
21
+ "hash": "node scripts/hash.mjs",
22
+ "salt": "node scripts/salt.mjs",
23
23
  "prepare": "husky install"
24
24
  },
25
25
  "dependencies": {
@@ -43,6 +43,6 @@ compare(password, { hash, salt, iterations, keylen, digest })
43
43
  .then((isValid) => {
44
44
  console.log(isValid ? 'πŸ‘' : 'πŸ‘Ž')
45
45
  })
46
- .catch(() => {
47
- console.error('πŸ’©')
46
+ .catch(({ message }) => {
47
+ console.error(`πŸ’© - ${message}`)
48
48
  })
package/scripts/hash.mjs CHANGED
@@ -40,6 +40,6 @@ hash(password, { salt, iterations, keylen, digest })
40
40
  .then((buffer) => {
41
41
  console.log(fromBufferToBase64(buffer))
42
42
  })
43
- .catch(() => {
44
- console.error('πŸ’©')
43
+ .catch(({ message }) => {
44
+ console.error(`πŸ’© - ${message}`)
45
45
  })
package/scripts/salt.mjs CHANGED
@@ -13,6 +13,6 @@ salt(size)
13
13
  .then((buffer) => {
14
14
  console.log(fromBufferToBase64(buffer))
15
15
  })
16
- .catch(() => {
17
- console.error('πŸ’©')
16
+ .catch(({ message }) => {
17
+ console.error(`πŸ’© - ${message}`)
18
18
  })
package/utils/common.mjs CHANGED
@@ -7,7 +7,7 @@ export function fromBufferToBase64 (buffer) {
7
7
  }
8
8
 
9
9
  export function fromBase64 (string) {
10
- return Buffer.from(string, 'base64').toString()
10
+ return Buffer.from(string, 'base64').toString('ascii')
11
11
  }
12
12
 
13
13
  export function toBase64 (string) {