@sequencemedia/pbkdf2 1.0.8 → 1.0.10

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 CHANGED
@@ -23,7 +23,13 @@ Etc.
23
23
  The password is expected as the first argument, while the others are fields on a params object
24
24
 
25
25
  ```javascript
26
- const isValid = await compare(password, { hash, salt, iterations, keylen, digest })
26
+ const isValid = await compare(password, {
27
+ hash,
28
+ salt,
29
+ iterations,
30
+ keylen,
31
+ digest
32
+ })
27
33
  ```
28
34
 
29
35
  ### `hash`
@@ -31,16 +37,22 @@ const isValid = await compare(password, { hash, salt, iterations, keylen, digest
31
37
  As with `compare`, the password is expected as the first argument, while the others are fields on a params object (except for `hash` which can of course be omitted)
32
38
 
33
39
  ```javascript
34
- const value = await hash(password, { salt, iterations, keylen, digest })
40
+ const value = await hash(password, {
41
+ hash,
42
+ iterations,
43
+ keylen,
44
+ digest
45
+ })
35
46
  ```
36
47
 
37
48
  ### `salt`
38
49
 
39
- An `async` wrapper around `crypto.randomBytes` to _generate_ a salt from the salt size
50
+ An `async` wrapper around `crypto.randomBytes()` to _generate_ a salt from the salt size
40
51
 
41
52
  ```javascript
42
53
  const value = await salt(size)
43
54
  ```
55
+
44
56
  ## In the shell
45
57
 
46
58
  Scripts are exposed to `npm` in the package and each script can of course be invoked from the command line directly in the shell
package/compare.sh CHANGED
@@ -1,25 +1,52 @@
1
1
  #!/bin/bash
2
2
 
3
- # the-user-1
3
+ # the-user-1 (UMS)
4
4
  npm run compare -- \
5
- --password "^49pPaRdVSNC" \
6
- --hash "kOhpM7//M4I9+WcWLH7vbb/yN2+8qKyxQ0xAfI4JzamcRMdwwl7vAh0ch7UJ0JoBe9AqaAGuUJZF/mVA9EqaLQ==" \
7
- --salt "YzFjMTY4MmMyMWE4MjFkYjRhNWE5YjJmNDY0OTUzM2Q=" \
5
+ --password '^49pPaRdVSNC' \
6
+ --hash 'kOhpM7//M4I9+WcWLH7vbb/yN2+8qKyxQ0xAfI4JzamcRMdwwl7vAh0ch7UJ0JoBe9AqaAGuUJZF/mVA9EqaLQ==' \
7
+ --salt 'YzFjMTY4MmMyMWE4MjFkYjRhNWE5YjJmNDY0OTUzM2Q=' \
8
8
  --iterations 32768 \
9
- --digest sha512
9
+ --digest 'sha512'
10
10
 
11
- # the-user-2
11
+ # the-user-1 (Keycloak)
12
12
  npm run compare -- \
13
- --password "S0uSaC&FzDOO" \
14
- --hash "BrtOel2qy5HrYWn45jBKf5b3HUKdVeQfIj1ljhGxQ/SiWsmMMuOl756H4MXkMOnVJKrgFfHFy7cgFXUaSFA2ow==" \
15
- --salt "MDI2OGM0MDU4NWJiOTgxNWEyYzQwN2RkYjM1YTY5YWU=" \
13
+ --password '$b!6A6t7M7URi.' \
14
+ --hash 'zC9qCa/0XjQOt/fy/XFZ69rvnw6w6hueI294PnqmPeKOeMH3Qr8S5RWhg1v+b60DhkcSlw1FKZWpgNjsQflxYA==' \
15
+ --salt '9xdUcOPkoYYS/kr2URMArw==' \
16
+ --iterations 27500 \
17
+ --digest 'sha256' \
18
+ --keylen 64
19
+
20
+ # the-user-2 (UMS)
21
+ npm run compare -- \
22
+ --password 'S0uSaC&FzDOO' \
23
+ --hash 'BrtOel2qy5HrYWn45jBKf5b3HUKdVeQfIj1ljhGxQ/SiWsmMMuOl756H4MXkMOnVJKrgFfHFy7cgFXUaSFA2ow==' \
24
+ --salt 'MDI2OGM0MDU4NWJiOTgxNWEyYzQwN2RkYjM1YTY5YWU=' \
16
25
  --iterations 32768 \
17
- --digest sha512
26
+ --digest 'sha512'
27
+
28
+ # the-user-2 (Keycloak)
29
+ npm run compare -- \
30
+ --password 'CJPRki*Qx4GsL9' \
31
+ --salt '+7WfVsQDJwz3NhT7sIVAGA==' \
32
+ --hash 'dA0brxazVBjCiiWGJOvUjGKZzEsdHaooUYRWhz3gYsPQJlADznYzk+9Mlzh0AHNgbo4vlWFMGm6vIQC2DxucJw==' \
33
+ --iterations 27500 \
34
+ --digest 'sha256' \
35
+ --keylen 64
18
36
 
19
37
  # the-user-3
20
38
  npm run compare -- \
21
- --password "@^EJmdlkt5A#" \
22
- --hash "bV76sVqsM0doKBFnaHsZQC9OgcVnF/+gzkG7HFXdD7jyQdN1PqCVijyXKMijmYQPWJohi5f7sVxhoLJ5kf8aQA==" \
23
- --salt "ZDI3OTZmZWU3M2I3M2Y3MTgxMmYyNGM3MjU4NDE2NDM=" \
39
+ --password '@^EJmdlkt5A#' \
40
+ --hash 'bV76sVqsM0doKBFnaHsZQC9OgcVnF/+gzkG7HFXdD7jyQdN1PqCVijyXKMijmYQPWJohi5f7sVxhoLJ5kf8aQA==' \
41
+ --salt 'ZDI3OTZmZWU3M2I3M2Y3MTgxMmYyNGM3MjU4NDE2NDM=' \
24
42
  --iterations 32768 \
25
- --digest sha512
43
+ --digest 'sha512'
44
+
45
+ # the-user-3 (Keycloak)
46
+ npm run compare -- \
47
+ --password 'Q*edKXB@@u#7kN' \
48
+ --hash 'Pmmom2yEUX0/M1chwCdyHM0WMiyAoHEVOmbRNUN/695FlkZMPSxSMwBLPBgYoKbP1Shir/NDBWcH6mgtHFPyYw==' \
49
+ --salt 't8U4ClO+biQUa9amFn4bUA==' \
50
+ --iterations 27500 \
51
+ --digest 'sha256' \
52
+ --keylen 64
package/package.json CHANGED
@@ -1,60 +1,60 @@
1
- {
2
- "name": "@sequencemedia/pbkdf2",
3
- "version": "1.0.8",
4
- "keywords": [
5
- "pbkdf2",
6
- "crypto",
7
- "compare",
8
- "hash",
9
- "salt",
10
- "ecmascript",
11
- "typescript"
12
- ],
13
- "main": "./index.mjs",
14
- "type": "module",
15
- "author": {
16
- "name": "Jonathan Perry for Sequence Media Limited",
17
- "email": "sequencemedia@sequencemedia.net",
18
- "url": "http://sequencemedia.net"
19
- },
20
- "license": "ISC",
21
- "repository": {
22
- "type": "git",
23
- "url": "git@github.com:sequencemedia/pbkdf2.git"
24
- },
25
- "scripts": {
26
- "lint": "eslint . --ext .mjs --ext .cjs",
27
- "lint:fix": "npm run lint -- --fix",
28
- "test": "cross-env NODE_ENV=test mocha tests --recursive --verbose --color",
29
- "compare": "node scripts/compare.mjs",
30
- "hash": "node scripts/hash.mjs",
31
- "salt": "node scripts/salt.mjs",
32
- "prepare": "husky install"
33
- },
34
- "dependencies": {
35
- "debug": "^4.3.4",
36
- "yargs-parser": "^21.1.1"
37
- },
38
- "devDependencies": {
39
- "@babel/cli": "^7.20.7",
40
- "@babel/core": "^7.20.12",
41
- "@babel/eslint-parser": "^7.19.1",
42
- "@babel/preset-env": "^7.20.2",
43
- "@sequencemedia/hooks": "^1.0.317",
44
- "@types/node": "^18.11.18",
45
- "chai": "^4.3.7",
46
- "core-js": "^3.27.2",
47
- "cross-env": "^7.0.3",
48
- "eslint": "^8.33.0",
49
- "eslint-config-standard": "^17.0.0",
50
- "eslint-plugin-import": "^2.27.5",
51
- "eslint-plugin-node": "^11.1.0",
52
- "eslint-plugin-promise": "^6.1.1",
53
- "husky": "^8.0.3",
54
- "mocha": "^10.2.0"
55
- },
56
- "imports": {
57
- "#config/*": "./config/*.mjs",
58
- "#utils/*": "./utils/*.mjs"
59
- }
60
- }
1
+ {
2
+ "name": "@sequencemedia/pbkdf2",
3
+ "version": "1.0.10",
4
+ "keywords": [
5
+ "pbkdf2",
6
+ "crypto",
7
+ "compare",
8
+ "hash",
9
+ "salt",
10
+ "ecmascript",
11
+ "typescript"
12
+ ],
13
+ "main": "./index.mjs",
14
+ "type": "module",
15
+ "author": {
16
+ "name": "Jonathan Perry for Sequence Media Limited",
17
+ "email": "sequencemedia@sequencemedia.net",
18
+ "url": "http://sequencemedia.net"
19
+ },
20
+ "license": "ISC",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git@github.com:sequencemedia/pbkdf2.git"
24
+ },
25
+ "scripts": {
26
+ "lint": "eslint . --ext .mjs --ext .cjs",
27
+ "lint:fix": "npm run lint -- --fix",
28
+ "test": "cross-env NODE_ENV=test mocha tests --recursive --verbose --color",
29
+ "compare": "node scripts/compare.mjs",
30
+ "hash": "node scripts/hash.mjs",
31
+ "salt": "node scripts/salt.mjs",
32
+ "prepare": "husky install"
33
+ },
34
+ "dependencies": {
35
+ "debug": "^4.3.4",
36
+ "yargs-parser": "^21.1.1"
37
+ },
38
+ "devDependencies": {
39
+ "@babel/cli": "^7.20.7",
40
+ "@babel/core": "^7.20.12",
41
+ "@babel/eslint-parser": "^7.19.1",
42
+ "@babel/preset-env": "^7.20.2",
43
+ "@sequencemedia/hooks": "^1.0.320",
44
+ "@types/node": "^18.11.18",
45
+ "chai": "^4.3.7",
46
+ "core-js": "^3.27.2",
47
+ "cross-env": "^7.0.3",
48
+ "eslint": "^8.33.0",
49
+ "eslint-config-standard": "^17.0.0",
50
+ "eslint-plugin-import": "^2.27.5",
51
+ "eslint-plugin-node": "^11.1.0",
52
+ "eslint-plugin-promise": "^6.1.1",
53
+ "husky": "^8.0.3",
54
+ "mocha": "^10.2.0"
55
+ },
56
+ "imports": {
57
+ "#config/*": "./config/*.mjs",
58
+ "#utils/*": "./utils/*.mjs"
59
+ }
60
+ }
@@ -3,8 +3,7 @@
3
3
  import argsMap from '#utils/args-map'
4
4
  import compare from '#utils/compare'
5
5
  import {
6
- fromBase64ToBuffer,
7
- fromBase64
6
+ fromBase64ToBuffer
8
7
  } from '#utils/common'
9
8
  import {
10
9
  ITERATIONS,
@@ -19,7 +18,7 @@ if (!argsMap.has('hash')) throw new Error('Parameter `hash` is required')
19
18
  const hash = fromBase64ToBuffer(argsMap.get('hash'))
20
19
 
21
20
  if (!argsMap.has('salt')) throw new Error('Parameter `salt` is required')
22
- const salt = fromBase64(argsMap.get('salt'))
21
+ const salt = fromBase64ToBuffer(argsMap.get('salt'))
23
22
 
24
23
  const iterations = (
25
24
  argsMap.has('iterations')
package/scripts/hash.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import argsMap from '#utils/args-map'
4
4
  import {
5
- fromBase64,
5
+ fromBase64ToBuffer,
6
6
  fromBufferToBase64
7
7
  } from '#utils/common'
8
8
  import hash from '#utils/hash'
@@ -16,7 +16,7 @@ if (!argsMap.has('password')) throw new Error('Parameter `password` is required'
16
16
  const password = argsMap.get('password')
17
17
 
18
18
  if (!argsMap.has('salt')) throw new Error('Parameter `salt` is required')
19
- const salt = fromBase64(argsMap.get('salt'))
19
+ const salt = fromBase64ToBuffer(argsMap.get('salt'))
20
20
 
21
21
  const iterations = (
22
22
  argsMap.has('iterations')
package/scripts/salt.mjs CHANGED
File without changes