@sequencemedia/pbkdf2 1.0.5 β†’ 1.0.7

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,21 @@
1
+ # @sequencemedia/pbkdf2
2
+
3
+ ES functions are exported from package root alongside a TS definition
4
+
5
+ ## Password validation
6
+
7
+ A password can be validated against a `hash` and `salt` (and the number of `iterations` that were used to compute it)
8
+
9
+ Both the `hash` and `salt` are expected from the command line to be strings in _Base64_ format
10
+
11
+ - The `hash` is decoded to a `Buffer`
12
+ - The `salt` is transformed from _Base64_ into _ASCII_
13
+
14
+ You can use these utilities from the shell or as part of a Node application
15
+
16
+ ## Tests
17
+
18
+ ```bash
19
+ npm test
20
+ bash ./compare.sh
21
+ ```
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,15 @@
1
1
  {
2
2
  "name": "@sequencemedia/pbkdf2",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
+ "keywords": [
5
+ "pbkdf2",
6
+ "crypto",
7
+ "compare",
8
+ "hash",
9
+ "salt",
10
+ "ecmascript",
11
+ "typescript"
12
+ ],
4
13
  "main": "./index.mjs",
5
14
  "type": "module",
6
15
  "author": {
@@ -14,12 +23,12 @@
14
23
  "url": "git@github.com:sequencemedia/pbkdf2.git"
15
24
  },
16
25
  "scripts": {
17
- "lint": "cross-env NODE_ENV=production eslint . --ext .mjs --ext .cjs",
26
+ "lint": "eslint . --ext .mjs --ext .cjs",
18
27
  "lint:fix": "npm run lint -- --fix",
19
28
  "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",
29
+ "compare": "node scripts/compare.mjs",
30
+ "hash": "node scripts/hash.mjs",
31
+ "salt": "node scripts/salt.mjs",
23
32
  "prepare": "husky install"
24
33
  },
25
34
  "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) {