2015-12-15 22:07:02 +00:00
|
|
|
/*!
|
2015-12-16 02:51:38 +00:00
|
|
|
* letiny-core
|
2015-12-15 22:07:02 +00:00
|
|
|
* Copyright(c) 2015 AJ ONeal <aj@daplie.com> https://daplie.com
|
|
|
|
* Apache-2.0 OR MIT (and hence also MPL 2.0)
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-08-08 17:58:08 +00:00
|
|
|
var defaults = {
|
2016-08-08 20:55:06 +00:00
|
|
|
productionServerUrl: 'https://acme-v01.api.letsencrypt.org/directory'
|
|
|
|
, stagingServerUrl: 'https://acme-staging.api.letsencrypt.org/directory'
|
|
|
|
, acmeChallengePrefix: '/.well-known/acme-challenge/'
|
2017-01-12 22:37:34 +00:00
|
|
|
, knownEndpoints: [ 'new-authz', 'new-cert', 'new-reg', 'revoke-cert', 'key-change' ]
|
2016-08-08 20:55:06 +00:00
|
|
|
, challengeType: 'http-01'
|
|
|
|
, rsaKeySize: 2048
|
2016-08-08 17:58:08 +00:00
|
|
|
};
|
|
|
|
|
2015-12-15 22:07:02 +00:00
|
|
|
function create(deps) {
|
2016-08-08 17:58:08 +00:00
|
|
|
deps = deps || {};
|
|
|
|
deps.LeCore = {};
|
|
|
|
|
|
|
|
Object.keys(defaults).forEach(function (key) {
|
|
|
|
deps[key] = defaults[key];
|
|
|
|
deps.LeCore[key] = defaults[key];
|
|
|
|
});
|
2015-12-15 22:07:02 +00:00
|
|
|
|
2016-08-08 17:58:08 +00:00
|
|
|
deps.RSA = deps.RSA || require('rsa-compat').RSA;
|
|
|
|
deps.request = deps.request || require('request');
|
2016-08-08 23:04:31 +00:00
|
|
|
deps.Acme = require('./lib/acme-client').create(deps);
|
2015-12-16 02:36:10 +00:00
|
|
|
|
2016-08-08 23:04:31 +00:00
|
|
|
deps.LeCore.Acme = deps.Acme;
|
2016-08-08 17:58:08 +00:00
|
|
|
deps.LeCore.getAcmeUrls = require('./lib/get-acme-urls').create(deps);
|
|
|
|
deps.LeCore.registerNewAccount = require('./lib/register-new-account').create(deps);
|
|
|
|
deps.LeCore.getCertificate = require('./lib/get-certificate').create(deps);
|
2016-08-08 18:02:53 +00:00
|
|
|
deps.LeCore.getOptions = function () {
|
|
|
|
var defs = {};
|
|
|
|
|
|
|
|
Object.keys(defaults).forEach(function (key) {
|
|
|
|
defs[key] = defs[deps] || defaults[key];
|
|
|
|
});
|
|
|
|
|
|
|
|
return defs;
|
|
|
|
};
|
2015-12-16 02:57:17 +00:00
|
|
|
|
2016-08-08 17:58:08 +00:00
|
|
|
return deps.LeCore;
|
2015-12-15 22:07:02 +00:00
|
|
|
}
|
|
|
|
|
2016-08-08 17:58:08 +00:00
|
|
|
// TODO make this the official usage
|
|
|
|
module.exports.ACME = { create: create };
|
2016-08-08 20:55:06 +00:00
|
|
|
|
|
|
|
Object.keys(defaults).forEach(function (key) {
|
|
|
|
module.exports.ACME[key] = defaults[key];
|
|
|
|
});
|