oneuptime-acme-http-01
Version:
HTTP Authentication (In-Memory) for Let's Encrypt for Node.js - ACME http-01 challenges for OneUptime
50 lines (40 loc) • 1.56 kB
JavaScript
;
const axios = require('axios');
const BASE_URL = `${process.env.BACKEND_PROTOCOL}://${process.env.ONEUPTIME_HOST}`;
module.exports = {
create: function(config) {
return {
// init: function(opts) {
// //request = opts.request;
// return Promise.resolve(null);
// },
set: function(data) {
const ch = data.challenge;
// make api call to backend to store
// keyAuthorization, challengeUrl, and token
const url = `${BASE_URL}/api/ssl/challenge`;
const dataConfig = {
token: ch.token,
keyAuthorization: ch.keyAuthorization,
challengeUrl: ch.challengeUrl,
};
return axios({
url,
method: 'post',
data: dataConfig,
}).finally(() => null); // always return null
},
get: function(data) {
const ch = data.challenge;
const url = `${BASE_URL}/api/ssl/challenge/${ch.token}`;
return axios.get(url).then(result => result);
},
remove: function(data) {
const ch = data.challenge;
const url = `${BASE_URL}/api/ssl/challenge/${ch.token}`;
return axios({ url, method: 'delete' }).finally(() => null); // always return null
},
options: config,
};
},
};