clean up for release

This commit is contained in:
nyaundi brian 2019-11-13 10:35:53 +03:00
parent eed5063b2d
commit 7805d5162c
4 changed files with 41 additions and 42 deletions

View File

@ -30,11 +30,10 @@ First you create an instance with your credentials:
```js
var http01 = require('acme-http-01-s3').create({
awsAccessKey: process.env.,
awsSecretAccessKey: process.env.,
awsRegion: process.env.,
awsBucket: process.env.,
awsHost:process.env.
awsAccessKey: process.env.AWS_ACCESS_KEY,
awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
awsRegion: process.env.AWS_REGION,
awsBucket: process.env.AWS_BUCKET
});
```

View File

@ -1,9 +1,13 @@
RECORD=example.co.uk
awsAccessKey=''
awsSecretAccessKey=''
awsRegion=''
awsBucket=''
awsHost=''
AWS_ACCESS_KEY='xx'
AWS_SECRET_ACCESS_KEY='xx'
# default us-east-1
AWS_REGION='us-east-1'
AWS_BUCKET='xx'
# default s3.[AWS_REGION].amazonaws.com
AWS_HOST='xx'

View File

@ -5,42 +5,42 @@ request = promisify(request);
var aws4 = require('aws4');
var defaults = {
awsAccessKey: 'TQ6UOPROD626SWV5KIP5',
awsSecretAccessKey: 'Tm3dNht5QMKxu7EU44ZLflDeE7sFbqQy3Q+XE+MY',
awsRegion: 'us-east-1',
awsBucket: 'hy8',
awsHost: 's3.switch.lxc'
};
module.exports.create = function(config) {
var awsAccessKey = config.awsAccessKey || defaults.awsAccessKey;
var awsSecretAccessKey = config.awsSecretAccessKey || defaults.awsSecretAccessKey;
var awsAccessKey = config.awsAccessKey || null;
var awsSecretAccessKey = config.awsSecretAccessKey || null;
var awsRegion = config.awsRegion || defaults.awsRegion;
var awsBucket = config.awsBucket || defaults.awsBucket;
var awsHost = config.awsHost || defaults.awsHost;
var awsBucket = config.awsBucket || null;
var awsHost = config.awsHost || 's3.'+awsRegion+'.amazonaws.com';
if (awsAccessKey===null||awsSecretAccessKey===null){
throw new Error('awsAccessKey and awsSecretAccessKey are required');
}
var AWSCredentials = {
accessKeyId: awsAccessKey,
secretAccessKey: awsSecretAccessKey
};
if (awsBucket===null){
throw new Error('awsBucket is required');
}
return {
init: function(opts) {
console.log('init');
return null;
},
set: function(data) {
console.log('Add Key Auth URL');
var ch = data.challenge;
var signed = aws4.sign({
host: awsHost,
service: 's3',
region: awsRegion,
path: '/' + awsBucket + '/' + ch.identifier.value + '/' + ch.token,
headers: {
'Content-Type': 'text/plain;charset=UTF-8'
},
@ -50,11 +50,10 @@ module.exports.create = function(config) {
},
AWSCredentials
);
console.log(signed);
return request({
// debug: true,
method: 'PUT',
url: 'http://' + signed.host + signed.path,
url: 'https://' + signed.host + signed.path,
headers: { 'Content-Type': 'text/plain;charset=UTF-8' },
body: ch.keyAuthorization
@ -67,16 +66,14 @@ module.exports.create = function(config) {
}
return true;
})
.catch(function(err) {
throw err;
// return null;
});
.catch(function(err) {
throw err;
// return null;
});
},
get: function(data) {
console.log('List Key Auth URL');
var ch = data.challenge;
var signed = aws4.sign({
host: awsHost,
service: 's3',
@ -90,18 +87,18 @@ module.exports.create = function(config) {
},
AWSCredentials
);
console.log(signed);
return request({
// debug: true,
method: 'GET',
url: 'http://' + signed.host + signed.path,
url: 'https://' + signed.host + signed.path,
headers: { 'Content-Type': 'text/plain;charset=UTF-8' }
}).then(function(resp) {
if (200 === resp.statusCode) {
return {
keyAuthorization: resp.body
};
}else if (404 === resp.statusCode){
} else if (404 === resp.statusCode) {
return null;
}
// wrong sign returns 403
@ -130,11 +127,10 @@ module.exports.create = function(config) {
},
AWSCredentials
);
console.log(signed);
return request({
// debug: true,
method: 'DELETE',
url: 'http://' + signed.host + signed.path
url: 'https://' + signed.host + signed.path
}).then(function(resp) {
// console.log(resp.statusCode);
if (204 !== resp.statusCode) {
@ -144,10 +140,10 @@ module.exports.create = function(config) {
}
return true;
})
.catch(function(err) {
throw err;
// return null;
});
.catch(function(err) {
throw err;
// return null;
});
}
};

View File

@ -8,10 +8,10 @@ require('dotenv').config();
// Usage: node ./test.js example.com username xxxxxxxxx
var record = process.argv[2] || process.env.RECORD;
var challenger = require('./index.js').create({
databaseUrl: process.env.DATABASE_URL,
tableName: process.env.TABLE_NAME,
dialect: process.env.DIALECT,
storage: process.env.STORAGE
awsAccessKey: process.env.AWS_ACCESS_KEY,
awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
awsRegion: process.env.AWS_REGION,
awsBucket: process.env.AWS_BUCKET
});
// The dry-run tests can pass on, literally, 'example.com'