Improvements from Codacy.
This commit is contained in:
parent
a229f14017
commit
c11aca651d
|
@ -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
|
To run the tests yourself, create a `.env` file with the following
|
||||||
|
|
||||||
```
|
```console
|
||||||
// .env file
|
// .env file
|
||||||
AWS_ACCESS_KEY_ID=abc // Replace with your accessKeyId
|
AWS_ACCESS_KEY_ID=abc // Replace with your accessKeyId
|
||||||
AWS_SECRET_ACCESS_KEY=abc // Replace with your secretAccessKey
|
AWS_SECRET_ACCESS_KEY=abc // Replace with your secretAccessKey
|
||||||
|
|
6
clean.js
6
clean.js
|
@ -5,15 +5,15 @@ require("dotenv").config();
|
||||||
let accessKeyId = process.env.AWS_ACCESS_KEY_ID
|
let accessKeyId = process.env.AWS_ACCESS_KEY_ID
|
||||||
, secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
|
, secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
|
||||||
, regionName = process.env.AWS_BUCKET_REGION
|
, regionName = process.env.AWS_BUCKET_REGION
|
||||||
, bucketName = process.env.AWS_BUCKET_NAME
|
, bucketName = process.env.AWS_BUCKET_NAME;
|
||||||
|
|
||||||
var AWS = require("aws-sdk");
|
var AWS = require("aws-sdk");
|
||||||
AWS.config.setPromisesDependency(Promise);
|
AWS.config.setPromisesDependency(Promise);
|
||||||
AWS.config.update({
|
AWS.config.update({
|
||||||
region: regionName
|
region: regionName
|
||||||
, credentials: new AWS.Credentials({
|
, credentials: new AWS.Credentials({
|
||||||
accessKeyId: accessKeyId
|
accessKeyId
|
||||||
, secretAccessKey: secretAccessKey
|
, secretAccessKey
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
4
index.js
4
index.js
|
@ -11,7 +11,7 @@ const defaultOptions = {
|
||||||
, bucketRegion: null
|
, bucketRegion: null
|
||||||
, accountsDir: "accounts/"
|
, accountsDir: "accounts/"
|
||||||
, configDir: "acme/"
|
, configDir: "acme/"
|
||||||
}
|
};
|
||||||
|
|
||||||
const s3 = new AWS.S3({ apiVersion: "2006-03-01" });
|
const s3 = new AWS.S3({ apiVersion: "2006-03-01" });
|
||||||
|
|
||||||
|
@ -69,4 +69,4 @@ module.exports.create = (createOptions) => {
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
|
|
||||||
}
|
};
|
|
@ -3,4 +3,4 @@ const fileNames = require("../fileNames");
|
||||||
|
|
||||||
module.exports.check = (opts, options, s3) => {
|
module.exports.check = (opts, options, s3) => {
|
||||||
console.log("accounts.check", opts.account.id);
|
console.log("accounts.check", opts.account.id);
|
||||||
}
|
};
|
|
@ -18,4 +18,4 @@ module.exports.checkKeypair = (opts, options, s3) => {
|
||||||
console.error("There was an error retrieving your account keypair:", err.message);
|
console.error("There was an error retrieving your account keypair:", err.message);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
};
|
|
@ -3,4 +3,4 @@ const fileNames = require("../fileNames");
|
||||||
|
|
||||||
module.exports.set = (opts, options, s3) => {
|
module.exports.set = (opts, options, s3) => {
|
||||||
console.log("accounts.set");
|
console.log("accounts.set");
|
||||||
}
|
};
|
|
@ -5,7 +5,7 @@ module.exports.setKeypair = (opts, options, s3) => {
|
||||||
console.log("accounts.setKeypair for", opts.account);
|
console.log("accounts.setKeypair for", opts.account);
|
||||||
|
|
||||||
let id = opts.account.id || opts.email || "single-user";
|
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({
|
var body = JSON.stringify({
|
||||||
privateKeyPem: opts.keypair.privateKeyPem // string PEM
|
privateKeyPem: opts.keypair.privateKeyPem // string PEM
|
||||||
|
|
|
@ -36,7 +36,7 @@ module.exports.check = (opts, options, s3) => {
|
||||||
privkey: values[0]
|
privkey: values[0]
|
||||||
, cert: values[1]
|
, cert: values[1]
|
||||||
, chain: values[2]
|
, chain: values[2]
|
||||||
}
|
};
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error("There was an error checking the ceritifcates:", err.message);
|
console.error("There was an error checking the ceritifcates:", err.message);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -6,8 +6,8 @@ module.exports.checkKeypair = (opts, options, s3) => {
|
||||||
|
|
||||||
let id = opts.certificate.kid || opts.certificate.id || opts.subject;
|
let id = opts.certificate.kid || opts.certificate.id || opts.subject;
|
||||||
|
|
||||||
pemKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.pem);
|
let pemKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.pem);
|
||||||
jwkKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.jwk);
|
let jwkKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.jwk);
|
||||||
|
|
||||||
return s3.getObject({ Key: pemKeyPath, Bucket: options.bucketName }).promise().then((data) => {
|
return s3.getObject({ Key: pemKeyPath, Bucket: options.bucketName }).promise().then((data) => {
|
||||||
console.log("Successfully retrieved certificate PEM keypair.");
|
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);
|
console.error("There was an error retrieving your certificate PEM keypair:", err.message);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
};
|
|
@ -15,4 +15,4 @@ module.exports.setKeypair = (opts, options, s3) => {
|
||||||
console.error("There was an error setting your PEM privateKey:", err.message);
|
console.error("There was an error setting your PEM privateKey:", err.message);
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
}
|
};
|
|
@ -1,10 +1,10 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
privkey: {
|
privkey: {
|
||||||
pem: 'privkey.pem'
|
pem: "privkey.pem"
|
||||||
, jwk: 'privkey.jwk'
|
, jwk: "privkey.jwk"
|
||||||
}
|
}
|
||||||
, cert: 'cert.pem'
|
, cert: "cert.pem"
|
||||||
, chain: 'chain.pem'
|
, chain: "chain.pem"
|
||||||
, fullchain: 'fullchain.pem'
|
, fullchain: "fullchain.pem"
|
||||||
, bundle: 'bundle.pem'
|
, bundle: "bundle.pem"
|
||||||
}
|
};
|
|
@ -1,6 +1,6 @@
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
tameWild = (wild) => {
|
const tameWild = (wild) => {
|
||||||
return wild.replace(/\*/g, "_");
|
return wild.replace(/\*/g, "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
test.js
10
test.js
|
@ -5,15 +5,15 @@ require("dotenv").config();
|
||||||
let accessKeyId = process.env.AWS_ACCESS_KEY_ID
|
let accessKeyId = process.env.AWS_ACCESS_KEY_ID
|
||||||
, secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
|
, secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
|
||||||
, regionName = process.env.AWS_BUCKET_REGION
|
, 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 tester = require("greenlock-store-test");
|
||||||
|
|
||||||
let store = require("./index").create({
|
let store = require("./index").create({
|
||||||
accessKeyId: accessKeyId
|
accessKeyId
|
||||||
, secretAccessKey: secretAccessKey
|
, secretAccessKey
|
||||||
, regionName: regionName
|
, regionName
|
||||||
, bucketName: bucketName
|
, bucketName
|
||||||
, configDir: "acme/"
|
, configDir: "acme/"
|
||||||
, accountsDir: "accounts/"
|
, accountsDir: "accounts/"
|
||||||
, debug: true
|
, debug: true
|
||||||
|
|
Loading…
Reference in New Issue