presidium 1.4.6 → 1.4.8
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/DynamoDBGlobalSecondaryIndex.js +1 -0
- package/Password.js +3 -3
- package/Secrets.js +5 -5
- package/package.json +1 -1
|
@@ -24,6 +24,7 @@ const createExpressionAttributeValues =
|
|
|
24
24
|
const createKeyConditionExpression =
|
|
25
25
|
require('./internal/createKeyConditionExpression')
|
|
26
26
|
const createFilterExpression = require('./internal/createFilterExpression')
|
|
27
|
+
const AwsError = require('./internal/AwsError')
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* @name DynamoDBGlobalSecondaryIndex
|
package/Password.js
CHANGED
|
@@ -13,7 +13,7 @@ const Password = {}
|
|
|
13
13
|
*
|
|
14
14
|
* @docs
|
|
15
15
|
* ```coffeescript [specscript]
|
|
16
|
-
* Password.hash(plaintext string) -> hash string
|
|
16
|
+
* Password.hash(plaintext string) -> hash Promise<string>
|
|
17
17
|
* ```
|
|
18
18
|
*
|
|
19
19
|
* Creates a hash of the plaintext password.
|
|
@@ -30,7 +30,7 @@ const Password = {}
|
|
|
30
30
|
* const myPasswordHash = await Password.hash(myPassword)
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
Password.hash = async function (plaintext) {
|
|
33
|
+
Password.hash = async function hash(plaintext) {
|
|
34
34
|
const salt = await bcrypt.genSalt(10)
|
|
35
35
|
const hashed = await bcrypt.hash(plaintext, salt)
|
|
36
36
|
return hashed
|
|
@@ -67,7 +67,7 @@ Password.hash = async function (plaintext) {
|
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
69
|
|
|
70
|
-
Password.verify = async function (plaintext, hashed) {
|
|
70
|
+
Password.verify = async function verify(plaintext, hashed) {
|
|
71
71
|
const isValid = await bcrypt.compare(plaintext, hashed)
|
|
72
72
|
if (!isValid) {
|
|
73
73
|
throw new Error('Invalid password')
|
package/Secrets.js
CHANGED
|
@@ -6,13 +6,13 @@ const fs = require('fs')
|
|
|
6
6
|
*
|
|
7
7
|
* @docs
|
|
8
8
|
* ```coffeescript [specscript]
|
|
9
|
-
* Secrets() -> secrets Promise<Object>
|
|
9
|
+
* Secrets(filepath string) -> secrets Promise<Object>
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
12
|
* Presidium Secrets class. Consumes the `.secrets` file in the current directory.
|
|
13
13
|
*
|
|
14
14
|
* Arguments:
|
|
15
|
-
* *
|
|
15
|
+
* * `filepath` - optional path to the secrets file. Defaults to `'.secrets'`.
|
|
16
16
|
*
|
|
17
17
|
* Return:
|
|
18
18
|
* * `secrets` - a promise of an object of secret key-value pairs.
|
|
@@ -22,13 +22,13 @@ const fs = require('fs')
|
|
|
22
22
|
* console.log(secrets.mySecret) // ********
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
async function Secrets() {
|
|
26
|
-
const secrets = pipe(fs.promises.readFile(
|
|
25
|
+
async function Secrets(filepath = '.secrets') {
|
|
26
|
+
const secrets = pipe(fs.promises.readFile(filepath), [
|
|
27
27
|
content => content.toString('utf8').trim().split('\n'),
|
|
28
28
|
map(line => line.split('=')),
|
|
29
29
|
Object.fromEntries,
|
|
30
30
|
])
|
|
31
|
-
await fs.promises.rm(
|
|
31
|
+
await fs.promises.rm(filepath)
|
|
32
32
|
|
|
33
33
|
return secrets
|
|
34
34
|
}
|