From c11aca651d137fe2672a8c55429daf2dd94cda66 Mon Sep 17 00:00:00 2001 From: Cyrille Date: Thu, 9 May 2019 00:12:15 +0100 Subject: [PATCH] Improvements from Codacy. --- README.md | 2 +- clean.js | 6 +++--- index.js | 4 ++-- lib/accounts/check.js | 2 +- lib/accounts/checkKeypair.js | 2 +- lib/accounts/set.js | 2 +- lib/accounts/setKeypair.js | 2 +- lib/certificates/check.js | 2 +- lib/certificates/checkKeypair.js | 6 +++--- lib/certificates/setKeypair.js | 2 +- lib/fileNames.js | 14 +++++++------- lib/pathHelper.js | 2 +- test.js | 10 +++++----- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index ff63dbc..06ad380 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ The strategy is tested against the [greenlock-store-test](https://git.coolaj86.c To run the tests yourself, create a `.env` file with the following -``` +```console // .env file AWS_ACCESS_KEY_ID=abc // Replace with your accessKeyId AWS_SECRET_ACCESS_KEY=abc // Replace with your secretAccessKey diff --git a/clean.js b/clean.js index d6db2f2..e1a94ae 100644 --- a/clean.js +++ b/clean.js @@ -5,15 +5,15 @@ require("dotenv").config(); let accessKeyId = process.env.AWS_ACCESS_KEY_ID , secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY , regionName = process.env.AWS_BUCKET_REGION - , bucketName = process.env.AWS_BUCKET_NAME + , bucketName = process.env.AWS_BUCKET_NAME; var AWS = require("aws-sdk"); AWS.config.setPromisesDependency(Promise); AWS.config.update({ region: regionName , credentials: new AWS.Credentials({ - accessKeyId: accessKeyId - , secretAccessKey: secretAccessKey + accessKeyId + , secretAccessKey }) }); diff --git a/index.js b/index.js index e10ef71..6ceb884 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,7 @@ const defaultOptions = { , bucketRegion: null , accountsDir: "accounts/" , configDir: "acme/" -} +}; const s3 = new AWS.S3({ apiVersion: "2006-03-01" }); @@ -69,4 +69,4 @@ module.exports.create = (createOptions) => { return handlers; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/accounts/check.js b/lib/accounts/check.js index 19f9a82..cd37f84 100644 --- a/lib/accounts/check.js +++ b/lib/accounts/check.js @@ -3,4 +3,4 @@ const fileNames = require("../fileNames"); module.exports.check = (opts, options, s3) => { console.log("accounts.check", opts.account.id); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/accounts/checkKeypair.js b/lib/accounts/checkKeypair.js index e2e2bad..804d23c 100644 --- a/lib/accounts/checkKeypair.js +++ b/lib/accounts/checkKeypair.js @@ -18,4 +18,4 @@ module.exports.checkKeypair = (opts, options, s3) => { console.error("There was an error retrieving your account keypair:", err.message); return null; }); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/accounts/set.js b/lib/accounts/set.js index a76fdcb..116e436 100644 --- a/lib/accounts/set.js +++ b/lib/accounts/set.js @@ -3,4 +3,4 @@ const fileNames = require("../fileNames"); module.exports.set = (opts, options, s3) => { console.log("accounts.set"); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/accounts/setKeypair.js b/lib/accounts/setKeypair.js index 77a0d8d..aca9d3a 100644 --- a/lib/accounts/setKeypair.js +++ b/lib/accounts/setKeypair.js @@ -5,7 +5,7 @@ module.exports.setKeypair = (opts, options, s3) => { console.log("accounts.setKeypair for", opts.account); let id = opts.account.id || opts.email || "single-user"; - let key = pathHelper.accountsPath(options, id) + let key = pathHelper.accountsPath(options, id); var body = JSON.stringify({ privateKeyPem: opts.keypair.privateKeyPem // string PEM diff --git a/lib/certificates/check.js b/lib/certificates/check.js index 30ab079..869f9a5 100644 --- a/lib/certificates/check.js +++ b/lib/certificates/check.js @@ -36,7 +36,7 @@ module.exports.check = (opts, options, s3) => { privkey: values[0] , cert: values[1] , chain: values[2] - } + }; }).catch((err) => { console.error("There was an error checking the ceritifcates:", err.message); return null; diff --git a/lib/certificates/checkKeypair.js b/lib/certificates/checkKeypair.js index 201e574..ddecad3 100644 --- a/lib/certificates/checkKeypair.js +++ b/lib/certificates/checkKeypair.js @@ -6,8 +6,8 @@ module.exports.checkKeypair = (opts, options, s3) => { let id = opts.certificate.kid || opts.certificate.id || opts.subject; - pemKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.pem); - jwkKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.jwk); + let pemKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.pem); + let jwkKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.jwk); return s3.getObject({ Key: pemKeyPath, Bucket: options.bucketName }).promise().then((data) => { console.log("Successfully retrieved certificate PEM keypair."); @@ -18,4 +18,4 @@ module.exports.checkKeypair = (opts, options, s3) => { console.error("There was an error retrieving your certificate PEM keypair:", err.message); return null; }); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/certificates/setKeypair.js b/lib/certificates/setKeypair.js index 25ad85b..98751c1 100644 --- a/lib/certificates/setKeypair.js +++ b/lib/certificates/setKeypair.js @@ -15,4 +15,4 @@ module.exports.setKeypair = (opts, options, s3) => { console.error("There was an error setting your PEM privateKey:", err.message); throw err; }); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/fileNames.js b/lib/fileNames.js index 2f0f420..8d9d744 100644 --- a/lib/fileNames.js +++ b/lib/fileNames.js @@ -1,10 +1,10 @@ module.exports = { privkey: { - pem: 'privkey.pem' - , jwk: 'privkey.jwk' + pem: "privkey.pem" + , jwk: "privkey.jwk" } - , cert: 'cert.pem' - , chain: 'chain.pem' - , fullchain: 'fullchain.pem' - , bundle: 'bundle.pem' -} \ No newline at end of file + , cert: "cert.pem" + , chain: "chain.pem" + , fullchain: "fullchain.pem" + , bundle: "bundle.pem" +}; \ No newline at end of file diff --git a/lib/pathHelper.js b/lib/pathHelper.js index d5ca7d3..6304a3a 100644 --- a/lib/pathHelper.js +++ b/lib/pathHelper.js @@ -1,6 +1,6 @@ const path = require("path"); -tameWild = (wild) => { +const tameWild = (wild) => { return wild.replace(/\*/g, "_"); } diff --git a/test.js b/test.js index 50c834b..002041f 100644 --- a/test.js +++ b/test.js @@ -5,15 +5,15 @@ require("dotenv").config(); let accessKeyId = process.env.AWS_ACCESS_KEY_ID , secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY , regionName = process.env.AWS_BUCKET_REGION - , bucketName = process.env.AWS_BUCKET_NAME + , bucketName = process.env.AWS_BUCKET_NAME; let tester = require("greenlock-store-test"); let store = require("./index").create({ - accessKeyId: accessKeyId - , secretAccessKey: secretAccessKey - , regionName: regionName - , bucketName: bucketName + accessKeyId + , secretAccessKey + , regionName + , bucketName , configDir: "acme/" , accountsDir: "accounts/" , debug: true