now working
This commit is contained in:
parent
8dc75feb8d
commit
a850243c59
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
node_modules
|
||||
docs/
|
||||
coverage/
|
||||
.nogit/
|
||||
.nogit/
|
||||
dist/assets/
|
@ -6,9 +6,11 @@ stages:
|
||||
- release
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
stage: test1
|
||||
script:
|
||||
- npmci test lts
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- lossless
|
||||
@ -17,6 +19,8 @@ testSTABLE:
|
||||
stage: test2
|
||||
script:
|
||||
- npmci test stable
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- lossless
|
||||
|
@ -1,8 +1,6 @@
|
||||
# Cert
|
||||
Easily obain SSL certificates from LetsEncrypt. Supports DNS-01 challenge. TypeScript ready.
|
||||
|
||||
> Note: this package is in pre-alpha stage and will be ready soon.
|
||||
|
||||
## Usage
|
||||
|
||||
```typescript
|
||||
|
1
dist/cert.hook.d.ts
vendored
1
dist/cert.hook.d.ts
vendored
@ -0,0 +1 @@
|
||||
import "typings-global";
|
50
dist/cert.hook.js
vendored
Normal file → Executable file
50
dist/cert.hook.js
vendored
Normal file → Executable file
@ -1,3 +1,51 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var plugins = require("./cert.plugins");
|
||||
var paths = require("./cert.paths");
|
||||
var smartcli = new plugins.smartcli.Smartcli();
|
||||
var config = plugins.smartfile.local.toObjectSync(paths.config);
|
||||
var cflare = new plugins.cflare.CflareAccount();
|
||||
cflare.auth({
|
||||
email: config.cfEmail,
|
||||
key: config.cfKey
|
||||
});
|
||||
var setChallenge = function (domainNameArg, challengeArg) {
|
||||
var done = plugins.q.defer();
|
||||
cflare.createRecord(prefixName(domainNameArg), "TXT", challengeArg).then(function () {
|
||||
cooldown().then(function () {
|
||||
done.resolve();
|
||||
});
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
var cleanChallenge = function (domainNameArg) {
|
||||
var done = plugins.q.defer();
|
||||
cflare.removeRecord(prefixName(domainNameArg), "TXT");
|
||||
return done.promise;
|
||||
};
|
||||
var cooldown = function () {
|
||||
var done = plugins.q.defer();
|
||||
console.log("Cooling down!");
|
||||
setTimeout(function () {
|
||||
done.resolve();
|
||||
}, 20000);
|
||||
return done.promise;
|
||||
};
|
||||
var prefixName = function (domainNameArg) {
|
||||
return "_acme-challenge." + domainNameArg;
|
||||
};
|
||||
smartcli.addCommand({
|
||||
commandName: "deploy_challenge"
|
||||
}).then(function (argv) {
|
||||
console.log(argv);
|
||||
setChallenge(argv._[1], argv._[3]);
|
||||
});
|
||||
smartcli.addCommand({
|
||||
commandName: "clean_challenge"
|
||||
}).then(function (argv) {
|
||||
cleanChallenge(argv._[1]);
|
||||
});
|
||||
smartcli.startParse();
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJjZXJ0Lmhvb2suanMiLCJzb3VyY2VzQ29udGVudCI6W119
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNlcnQuaG9vay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUdBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxnQkFBZ0IsQ0FBQyxDQUFBO0FBQzFDLElBQVksS0FBSyxXQUFNLGNBQWMsQ0FBQyxDQUFBO0FBRXRDLElBQUksUUFBUSxHQUFHLElBQUksT0FBTyxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQztBQUUvQyxJQUFJLE1BQU0sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsS0FBSyxDQ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ICBjZmxhcmUucmVtb3ZlUmVjb3JkKHByZWZpeE5hbWUoZG9tYWluTmFtZUFyZyksIFwiVFhUXCIpO1xuICAgIHJldHVybiBkb25lLnByb21pc2U7XG59XG5cbmxldCBjb29sZG93biA9ICgpID0+IHtcbiAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgIGNvbnNvbGUubG9nKFwiQ29vbGluZyBkb3duIVwiKTtcbiAgICBzZXRUaW1lb3V0KCgpID0+IHtcbiAgICAgICAgZG9uZS5yZXNvbHZlKCk7XG4gICAgfSwgMjAwMDApXG4gICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcbn1cblxubGV0IHByZWZpeE5hbWUgPSAoZG9tYWluTmFtZUFyZzogc3RyaW5nKTogc3RyaW5nID0+IHtcbiAgICByZXR1cm4gXCJfYWNtZS1jaGFsbGVuZ2UuXCIgKyBkb21haW5OYW1lQXJnO1xufVxuXG5zbWFydGNsaS5hZGRDb21tYW5kKHtcbiAgICBjb21tYW5kTmFtZTogXCJkZXBsb3lfY2hhbGxlbmdlXCJcbn0pLnRoZW4oKGFyZ3YpID0+IHtcbiAgICBjb25zb2xlLmxvZyhhcmd2KVxuICAgIHNldENoYWxsZW5nZShhcmd2Ll9bMV0sIGFyZ3YuX1szXSk7XG59KTtcblxuc21hcnRjbGkuYWRkQ29tbWFuZCh7XG4gICAgY29tbWFuZE5hbWU6IFwiY2xlYW5fY2hhbGxlbmdlXCJcbn0pLnRoZW4oKGFyZ3YpID0+IHtcbiAgICBjbGVhbkNoYWxsZW5nZShhcmd2Ll9bMV0pO1xufSk7XG5cbnNtYXJ0Y2xpLnN0YXJ0UGFyc2UoKTtcbiJdfQ==
|
||||
|
5
dist/cert.paths.d.ts
vendored
5
dist/cert.paths.d.ts
vendored
@ -1,2 +1,5 @@
|
||||
import "typings-global";
|
||||
export import path = require("path");
|
||||
export declare let certHook: string;
|
||||
export declare let config: string;
|
||||
export declare let letsencryptSh: string;
|
||||
export declare let sslDir: string;
|
||||
|
8
dist/cert.paths.js
vendored
8
dist/cert.paths.js
vendored
@ -1,5 +1,9 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.path = require("path");
|
||||
var plugins = require("./cert.plugins");
|
||||
exports.certHook = plugins.path.join(__dirname, "cert.hook.js");
|
||||
exports.config = plugins.path.join(__dirname, "assets/config.json");
|
||||
exports.letsencryptSh = plugins.path.join(__dirname, "assets/letsencrypt.sh");
|
||||
exports.sslDir = plugins.path.join(__dirname, "/assets/certs");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNlcnQucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUNWLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQyIsImZpbGUiOiJjZXJ0LnBhdGhzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcbmV4cG9ydCBpbXBvcnQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuXG4iXX0=
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNlcnQucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxnQkFBZ0IsQ0FBQyxDQUFBO0FBRS9CLGdCQUFRLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLGNBQWMsQ0FBQyxDQUFDO0FBQ3ZELGNBQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUMsb0JBQW9CLENBQUMsQ0FBQztBQUMzRCxxQkFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyx1QkFBdUIsQ0FBQyxDQUFDO0FBQ3JFLGNBQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUMsZUFBZSxDQUFDLENBQUMiLCJmaWxlIjoiY2VydC5wYXRocy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCI7XG5pbXBvcnQgKiBhcyBwbHVnaW5zIGZyb20gXCIuL2NlcnQucGx1Z2luc1wiO1xuXG5leHBvcnQgbGV0IGNlcnRIb29rID0gcGx1Z2lucy5wYXRoLmpvaW4oX19kaXJuYW1lLFwiY2VydC5ob29rLmpzXCIpO1xuZXhwb3J0IGxldCBjb25maWcgPSBwbHVnaW5zLnBhdGguam9pbihfX2Rpcm5hbWUsXCJhc3NldHMvY29uZmlnLmpzb25cIik7XG5leHBvcnQgbGV0IGxldHNlbmNyeXB0U2ggPSBwbHVnaW5zLnBhdGguam9pbihfX2Rpcm5hbWUsXCJhc3NldHMvbGV0c2VuY3J5cHQuc2hcIik7XG5leHBvcnQgbGV0IHNzbERpciA9IHBsdWdpbnMucGF0aC5qb2luKF9fZGlybmFtZSxcIi9hc3NldHMvY2VydHNcIik7Il19
|
||||
|
10
dist/cert.plugins.d.ts
vendored
10
dist/cert.plugins.d.ts
vendored
@ -0,0 +1,10 @@
|
||||
import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
export import cflare = require("cflare");
|
||||
export declare let fs: any;
|
||||
export import path = require("path");
|
||||
export declare let q: any;
|
||||
export declare let shelljs: any;
|
||||
export import smartcli = require("smartcli");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartstring = require("smartstring");
|
14
dist/cert.plugins.js
vendored
14
dist/cert.plugins.js
vendored
@ -1,3 +1,13 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.cflare = require("cflare");
|
||||
exports.fs = require("fs-extra");
|
||||
exports.path = require("path");
|
||||
exports.q = require("q");
|
||||
exports.shelljs = require("shelljs");
|
||||
exports.smartcli = require("smartcli");
|
||||
exports.smartfile = require("smartfile");
|
||||
exports.smartstring = require("smartstring");
|
||||
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJjZXJ0LnBsdWdpbnMuanMiLCJzb3VyY2VzQ29udGVudCI6W119
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNlcnQucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNqQyxjQUFNLFdBQVcsUUFBUSxDQUFDLENBQUM7QUFDOUIsVUFBRSxHQUFHLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztBQUN0QixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDMUIsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNqQixlQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzFCLGdCQUFRLFdBQVcsVUFBVSxDQUFDLENBQUM7QUFDL0IsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNqQyxtQkFBVyxXQUFXLGFBQWEsQ0FBQyxDQUFDIiwiZmlsZSI6ImNlcnQucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCI7XG5leHBvcnQgaW1wb3J0IGJlYXV0eWxvZyA9IHJlcXVpcmUoXCJiZWF1dHlsb2dcIik7XG5leHBvcnQgaW1wb3J0IGNmbGFyZSA9IHJlcXVpcmUoXCJjZmxhcmVcIik7XG5leHBvcnQgbGV0IGZzID0gcmVxdWlyZShcImZzLWV4dHJhXCIpO1xuZXhwb3J0IGltcG9ydCBwYXRoID0gcmVxdWlyZShcInBhdGhcIik7XG5leHBvcnQgbGV0IHEgPSByZXF1aXJlKFwicVwiKTtcbmV4cG9ydCBsZXQgc2hlbGxqcyA9IHJlcXVpcmUoXCJzaGVsbGpzXCIpO1xuZXhwb3J0IGltcG9ydCBzbWFydGNsaSA9IHJlcXVpcmUoXCJzbWFydGNsaVwiKTtcbmV4cG9ydCBpbXBvcnQgc21hcnRmaWxlID0gcmVxdWlyZShcInNtYXJ0ZmlsZVwiKTtcbmV4cG9ydCBpbXBvcnQgc21hcnRzdHJpbmcgPSByZXF1aXJlKFwic21hcnRzdHJpbmdcIik7XG5cbiJdfQ==
|
||||
|
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
@ -11,7 +11,7 @@ export declare class Cert {
|
||||
sslDir: string;
|
||||
gitOriginRepo?: string;
|
||||
});
|
||||
getDomainCert(): void;
|
||||
getDomainCert(domainNameArg: string): any;
|
||||
}
|
||||
export declare class Certificate {
|
||||
domainName: string;
|
||||
|
17
dist/index.js
vendored
17
dist/index.js
vendored
@ -1,13 +1,26 @@
|
||||
"use strict";
|
||||
var plugins = require("./cert.plugins");
|
||||
var paths = require("./cert.paths");
|
||||
var Cert = (function () {
|
||||
function Cert(optionsArg) {
|
||||
this.cfEmail = optionsArg.cfEmail;
|
||||
this.cfKey = optionsArg.cfKey;
|
||||
this.sslDir = optionsArg.sslDir;
|
||||
this.gitOriginRepo = optionsArg.gitOriginRepo;
|
||||
var config = {
|
||||
cfEmail: this.cfEmail,
|
||||
cfKey: this.cfKey
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(JSON.stringify(config), { fileName: "config.json", filePath: plugins.path.join(__dirname, "assets/") });
|
||||
}
|
||||
;
|
||||
Cert.prototype.getDomainCert = function () { };
|
||||
Cert.prototype.getDomainCert = function (domainNameArg) {
|
||||
var done = plugins.q.defer();
|
||||
plugins.shelljs.exec("chmod 700 " + paths.letsencryptSh);
|
||||
plugins.shelljs.exec("chmod 700 " + paths.certHook);
|
||||
plugins.shelljs.exec("bash -c \"" + paths.letsencryptSh + " -c -d " + domainNameArg + " -t dns-01 -k " + paths.certHook + " -o " + paths.sslDir + "\"");
|
||||
return done.promise;
|
||||
};
|
||||
;
|
||||
return Cert;
|
||||
}());
|
||||
@ -20,4 +33,4 @@ var Certificate = (function () {
|
||||
}());
|
||||
exports.Certificate = Certificate;
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQTtJQU9JLGNBQVksVUFLWDtRQUNHLElBQUksQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDLE9BQU8sQ0FBQztRQUNsQyxJQUFJLENBQUMsS0FBSyxHQUFHLFVBQVUsQ0FBQyxLQUFLLENBQUM7UUFDOUIsSUFBSSxDQUFDLE1BQU0sR0FBRyxVQUFVLENBQUMsTUFBTSxDQUFDO1FBQ2hDLElBQUksQ0FBQyxhQUFhLEdBQUcsVUFBVSxDQUFDLGFBQWEsQ0FBQztJQUNsRCxDQUFDOztJQUNELDRCQUFhLEdBQWIsY0FBZ0IsQ0FBQzs7SUFDckIsV0FBQztBQUFELENBbkJBLEFBbUJDLElBQUE7QUFuQlksWUFBSSxPQW1CaEIsQ0FBQTtBQUVEO0lBSUk7SUFFQSxDQUFDOztJQUNMLGtCQUFDO0FBQUQsQ0FQQSxBQU9DLElBQUE7QUFQWSxtQkFBVyxjQU92QixDQUFBIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0ICogYXMgcGF0aHMgZnJvbSBcI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EYXRlO1xuICAgIGV4cGlyeURhdGU6RGF0ZTtcbiAgICBjb25zdHJ1Y3Rvcigpe1xuXG4gICAgfTtcbn0iXX0=
|
||||
|
1
dist/install.d.ts
vendored
1
dist/install.d.ts
vendored
@ -0,0 +1 @@
|
||||
export declare let startInstall: () => any;
|
28
dist/install.js
vendored
28
dist/install.js
vendored
@ -1,12 +1,20 @@
|
||||
"use strict";
|
||||
var beautylog = require("beautylog");
|
||||
var path = require("path");
|
||||
var smartfile = require("smartfile");
|
||||
var fs = require("fs-extra");
|
||||
beautylog.info("installing letsencrypt.sh locally...");
|
||||
fs.ensureDir(path.join(__dirname, "assets/"));
|
||||
smartfile.remote.toFs("https://raw.githubusercontent.com/lukas2511/letsencrypt.sh/master/letsencrypt.sh", path.join(__dirname, "assets/", "le.sh")).then(function () {
|
||||
beautylog.success("Done!");
|
||||
});
|
||||
var plugins = require("./cert.plugins");
|
||||
var paths = require("./cert.paths");
|
||||
exports.startInstall = function () {
|
||||
var done = plugins.q.defer();
|
||||
plugins.beautylog.info("installing letsencrypt.sh locally...");
|
||||
plugins.fs.ensureDir(plugins.path.join(__dirname, "assets/"));
|
||||
plugins.smartfile.remote.toFs("https://raw.githubusercontent.com/lukas2511/letsencrypt.sh/master/letsencrypt.sh", paths.letsencryptSh).then(function () {
|
||||
plugins.beautylog.success("Done!");
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
var smartcli = new plugins.smartcli.Smartcli();
|
||||
smartcli.addCommand({
|
||||
commandName: "install"
|
||||
}).then(exports.startInstall);
|
||||
smartcli.startParse();
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluc3RhbGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLElBQVksU0FBUyxXQUFNLFdBQVcsQ0FBQyxDQUFBO0FBQ3ZDLElBQVksSUFBSSxXQUFNLE1BQU0sQ0FBQyx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NtYXJ0Y2xpLmFkZENvbW1hbmQoe1xuICAgIGNvbW1hbmROYW1lOlwiaW5zdGFsbFwiXG59KS50aGVuKHN0YXJ0SW5zdGFsbCk7XG5zbWFydGNsaS5zdGFydFBhcnNlKCk7Il19
|
||||
|
11
package.json
11
package.json
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "cert",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.8",
|
||||
"description": "Easily obain SSL certificates from LetsEncrypt. Supports DNS-01 challenge. TypeScript ready.",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"test": "(npmts)",
|
||||
"install": "node dist/install.js"
|
||||
"install": "node dist/install.js install"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -25,14 +25,15 @@
|
||||
"homepage": "https://gitlab.com/pushrocks/cert#readme",
|
||||
"dependencies": {
|
||||
"beautylog": "^5.0.12",
|
||||
"cflare": "0.0.6",
|
||||
"cflare": "0.0.7",
|
||||
"fs-extra": "^0.30.0",
|
||||
"letsencrypt": "^1.4.4",
|
||||
"q": "^1.4.1",
|
||||
"smartcli": "^1.0.2",
|
||||
"shelljs": "^0.7.0",
|
||||
"smartcli": "^1.0.4",
|
||||
"smartfile": "^3.0.10",
|
||||
"smartgit": "0.0.10",
|
||||
"smartstring": "^2.0.9",
|
||||
"smartstring": "^2.0.10",
|
||||
"typings-global": "^1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
31
test/test.js
31
test/test.js
@ -2,6 +2,35 @@
|
||||
require("typings-test");
|
||||
require("should");
|
||||
var qenv_1 = require("qenv");
|
||||
var install_1 = require("../dist/install");
|
||||
var cert = require("../dist/index");
|
||||
var testQenv = new qenv_1.Qenv(process.cwd(), process.cwd() + "/.nogit");
|
||||
var testCert;
|
||||
describe("cert", function () {
|
||||
describe("install", function () {
|
||||
it("should download letsencrypt.sh", function (done) {
|
||||
this.timeout(5000);
|
||||
install_1.startInstall().then(function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("Cert", function () {
|
||||
it("should create a new cert", function () {
|
||||
testCert = new cert.Cert({
|
||||
cfEmail: process.env.CF_EMAIL,
|
||||
cfKey: process.env.CF_KEY,
|
||||
sslDir: ""
|
||||
});
|
||||
testCert.should.be.instanceof(cert.Cert);
|
||||
});
|
||||
it("should get a valid certificate", function (done) {
|
||||
this.timeout(120000);
|
||||
testCert.getDomainCert("sub2.bleu.de").then(function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQixxQkFBbUIsTUFBTSxDQUFDLENBQUE7QUFFMUIsSUFBSSxRQUFRLEdBQUcsSUFBSSxXQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxFQUFFLE9BQU8sQ0FBQyxHQUFHLEVBQUUsR0FBRyxTQUFTLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy10ZXN0XCI7XG5pbXBvcnQgXCJzaG91bGRcIjtcbmltcG9ydCAqIGFzIGNlcnQgZnJvbSBcIi4uL2Rpc3QvaW5kZXhcIjtcbmltcG9ydCB7UWVudn0gZnJvbSBcInFlbnZcIjtcblxubGV0IHRlc3RRZW52ID0gbmV3IFFlbnYocHJvY2Vzcy5jd2QoKSwgcHJvY2Vzcy5jd2QoKSArIFwiLy5ub2dpdFwiKTsiXX0=
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtB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7XG4gICAgICAgICAgICB9KVxuICAgICAgICB9KVxuICAgIH0pXG4gICAgZGVzY3JpYmUoXCJDZXJ0XCIsZnVuY3Rpb24oKXtcbiAgICAgICAgaXQoXCJzaG91bGQgY3JlYXRlIGEgbmV3IGNlcnRcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdENlcnQgPSBuZXcgY2VydC5DZXJ0KHtcbiAgICAgICAgICAgICAgICBjZkVtYWlsOiBwcm9jZXNzLmVudi5DRl9FTUFJTCxcbiAgICAgICAgICAgICAgICBjZktleTogcHJvY2Vzcy5lbnYuQ0ZfS0VZLFxuICAgICAgICAgICAgICAgIHNzbERpcjogXCJcIlxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB0ZXN0Q2VydC5zaG91bGQuYmUuaW5zdGFuY2VvZihjZXJ0LkNlcnQpO1xuICAgICAgICB9KVxuICAgICAgICBpdChcInNob3VsZCBnZXQgYSB2YWxpZCBjZXJ0aWZpY2F0ZVwiLGZ1bmN0aW9uKGRvbmUpe1xuICAgICAgICAgICAgdGhpcy50aW1lb3V0KDEyMDAwMCk7XG4gICAgICAgICAgICB0ZXN0Q2VydC5nZXREb21haW5DZXJ0KFwic3ViMi5ibGV1LmRlXCIpLnRoZW4oKCkgPT4ge1xuICAgICAgICAgICAgICAgIGRvbmUoKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KVxuICAgIH0pXG59KTsiXX0=
|
||||
|
33
test/test.ts
33
test/test.ts
@ -1,7 +1,38 @@
|
||||
import "typings-test";
|
||||
import "should";
|
||||
import * as cert from "../dist/index";
|
||||
import {Qenv} from "qenv";
|
||||
|
||||
import {startInstall} from "../dist/install";
|
||||
import * as cert from "../dist/index";
|
||||
|
||||
|
||||
let testQenv = new Qenv(process.cwd(), process.cwd() + "/.nogit");
|
||||
|
||||
let testCert:cert.Cert;
|
||||
|
||||
describe("cert",function(){
|
||||
describe("install",function(){
|
||||
it("should download letsencrypt.sh",function(done){
|
||||
this.timeout(5000);
|
||||
startInstall().then(() => {
|
||||
done();
|
||||
})
|
||||
})
|
||||
})
|
||||
describe("Cert",function(){
|
||||
it("should create a new cert",function(){
|
||||
testCert = new cert.Cert({
|
||||
cfEmail: process.env.CF_EMAIL,
|
||||
cfKey: process.env.CF_KEY,
|
||||
sslDir: ""
|
||||
});
|
||||
testCert.should.be.instanceof(cert.Cert);
|
||||
})
|
||||
it("should get a valid certificate",function(done){
|
||||
this.timeout(120000);
|
||||
testCert.getDomainCert("sub2.bleu.de").then(() => {
|
||||
done();
|
||||
});
|
||||
})
|
||||
})
|
||||
});
|
@ -1,3 +1,58 @@
|
||||
import * as smartcli from "smartcli";
|
||||
import * as cflare from "cflare";
|
||||
#!/usr/bin/env node
|
||||
// the shebang line above makes sure this script will get interpreted by node
|
||||
|
||||
import "typings-global";
|
||||
import * as plugins from "./cert.plugins";
|
||||
import * as paths from "./cert.paths";
|
||||
|
||||
let smartcli = new plugins.smartcli.Smartcli();
|
||||
|
||||
let config = plugins.smartfile.local.toObjectSync(paths.config);
|
||||
let cflare = new plugins.cflare.CflareAccount();
|
||||
cflare.auth({
|
||||
email: config.cfEmail,
|
||||
key: config.cfKey
|
||||
});
|
||||
|
||||
let setChallenge = (domainNameArg: string, challengeArg: string) => {
|
||||
let done = plugins.q.defer();
|
||||
cflare.createRecord(prefixName(domainNameArg), "TXT", challengeArg).then(() => {
|
||||
cooldown().then(() => {
|
||||
done.resolve();
|
||||
});
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
let cleanChallenge = (domainNameArg) => {
|
||||
let done = plugins.q.defer();
|
||||
cflare.removeRecord(prefixName(domainNameArg), "TXT");
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
let cooldown = () => {
|
||||
let done = plugins.q.defer();
|
||||
console.log("Cooling down!");
|
||||
setTimeout(() => {
|
||||
done.resolve();
|
||||
}, 20000)
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
let prefixName = (domainNameArg: string): string => {
|
||||
return "_acme-challenge." + domainNameArg;
|
||||
}
|
||||
|
||||
smartcli.addCommand({
|
||||
commandName: "deploy_challenge"
|
||||
}).then((argv) => {
|
||||
setChallenge(argv._[1], argv._[3]);
|
||||
});
|
||||
|
||||
smartcli.addCommand({
|
||||
commandName: "clean_challenge"
|
||||
}).then((argv) => {
|
||||
cleanChallenge(argv._[1]);
|
||||
});
|
||||
|
||||
smartcli.startParse();
|
||||
|
@ -1,3 +1,7 @@
|
||||
import "typings-global";
|
||||
export import path = require("path");
|
||||
import * as plugins from "./cert.plugins";
|
||||
|
||||
export let certHook = plugins.path.join(__dirname,"cert.hook.js");
|
||||
export let config = plugins.path.join(__dirname,"assets/config.json");
|
||||
export let letsencryptSh = plugins.path.join(__dirname,"assets/letsencrypt.sh");
|
||||
export let sslDir = plugins.path.join(__dirname,"/assets/certs");
|
@ -1,6 +1,11 @@
|
||||
import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
export import cflare = require("cflare");
|
||||
export let fs = require("fs-extra");
|
||||
export import path = require("path");
|
||||
export let q = require("q");
|
||||
export let shelljs = require("shelljs");
|
||||
export import smartcli = require("smartcli");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartstring = require("smartstring");
|
||||
|
||||
|
15
ts/index.ts
15
ts/index.ts
@ -1,3 +1,4 @@
|
||||
import * as plugins from "./cert.plugins";
|
||||
import * as paths from "./cert.paths";
|
||||
|
||||
export class Cert {
|
||||
@ -17,8 +18,20 @@ export class Cert {
|
||||
this.cfKey = optionsArg.cfKey;
|
||||
this.sslDir = optionsArg.sslDir;
|
||||
this.gitOriginRepo = optionsArg.gitOriginRepo;
|
||||
let config = {
|
||||
cfEmail: this.cfEmail,
|
||||
cfKey: this.cfKey
|
||||
}
|
||||
plugins.smartfile.memory.toFsSync(JSON.stringify(config),{fileName:"config.json",filePath:plugins.path.join(__dirname,"assets/")});
|
||||
};
|
||||
getDomainCert(domainNameArg:string){
|
||||
let done = plugins.q.defer();
|
||||
plugins.shelljs.exec("chmod 700 " + paths.letsencryptSh);
|
||||
plugins.shelljs.exec("chmod 700 " + paths.certHook);
|
||||
plugins.shelljs.exec("bash -c \"" + paths.letsencryptSh + " -c -d " + domainNameArg + " -t dns-01 -k " + paths.certHook + " -o "+ paths.sslDir + "\"");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
getDomainCert(){};
|
||||
}
|
||||
|
||||
export class Certificate {
|
||||
|
@ -1,13 +1,23 @@
|
||||
import * as beautylog from "beautylog";
|
||||
import * as path from "path";
|
||||
import * as smartfile from "smartfile";
|
||||
let fs = require("fs-extra");
|
||||
beautylog.info("installing letsencrypt.sh locally...");
|
||||
import * as plugins from "./cert.plugins";
|
||||
import * as paths from "./cert.paths";
|
||||
|
||||
fs.ensureDir(path.join(__dirname,"assets/"));
|
||||
smartfile.remote.toFs(
|
||||
"https://raw.githubusercontent.com/lukas2511/letsencrypt.sh/master/letsencrypt.sh",
|
||||
path.join(__dirname,"assets/","le.sh")
|
||||
).then(() => {
|
||||
beautylog.success("Done!");
|
||||
});
|
||||
export let startInstall = () => {
|
||||
let done = plugins.q.defer();
|
||||
plugins.beautylog.info("installing letsencrypt.sh locally...");
|
||||
|
||||
plugins.fs.ensureDir(plugins.path.join(__dirname, "assets/"));
|
||||
plugins.smartfile.remote.toFs(
|
||||
"https://raw.githubusercontent.com/lukas2511/letsencrypt.sh/master/letsencrypt.sh",
|
||||
paths.letsencryptSh
|
||||
).then(() => {
|
||||
plugins.beautylog.success("Done!");
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
let smartcli = new plugins.smartcli.Smartcli();
|
||||
smartcli.addCommand({
|
||||
commandName:"install"
|
||||
}).then(startInstall);
|
||||
smartcli.startParse();
|
Loading…
Reference in New Issue
Block a user