now paying respect to same zone subdomains
This commit is contained in:
parent
6c67556756
commit
2e8cfd00d2
44
dist/cert.classes.cert.d.ts
vendored
Normal file
44
dist/cert.classes.cert.d.ts
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./cert.plugins";
|
||||
export interface ICertConstructorOptions {
|
||||
cfEmail: string;
|
||||
cfKey: string;
|
||||
sslDir?: string;
|
||||
gitOriginRepo?: string;
|
||||
testMode?: boolean;
|
||||
}
|
||||
export declare class Cert {
|
||||
private _cfEmail;
|
||||
private _cfKey;
|
||||
private _sslDir;
|
||||
private _gitOriginRepo;
|
||||
private _testMode;
|
||||
domainCertRequestMap: plugins.lik.Stringmap;
|
||||
certificatesPresent: Certificate[];
|
||||
certificatesValid: Certificate[];
|
||||
/**
|
||||
* Constructor for Cert object
|
||||
*/
|
||||
constructor(optionsArg: ICertConstructorOptions);
|
||||
/**
|
||||
* Pulls already requested certificates from git origin
|
||||
*/
|
||||
sslGitOriginPull: () => void;
|
||||
/**
|
||||
* Pushes all new requested certificates to git origin
|
||||
*/
|
||||
sslGitOriginAddCommitPush: () => void;
|
||||
/**
|
||||
* gets a ssl cert for a given domain
|
||||
*/
|
||||
getDomainCert(domainNameArg: string, optionsArg?: {
|
||||
force: boolean;
|
||||
}): plugins.q.Promise<{}>;
|
||||
cleanOldCertificates(): void;
|
||||
}
|
||||
export declare class Certificate {
|
||||
domainName: string;
|
||||
creationDate: Date;
|
||||
expiryDate: Date;
|
||||
constructor();
|
||||
}
|
20
dist/cert.classes.cert.helpers.d.ts
vendored
Normal file
20
dist/cert.classes.cert.helpers.d.ts
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/// <reference types="q" />
|
||||
import { Cert } from "./index.ts";
|
||||
import * as plugins from "./cert.plugins";
|
||||
/**
|
||||
* schedule a retry of certificate request
|
||||
*/
|
||||
export declare let scheduleRetry: (domainArg: string, certClassArg: Cert) => plugins.q.Promise<{}>;
|
||||
/**
|
||||
* check if a given domainCert is still valid
|
||||
*/
|
||||
export declare let checkDomainsStillValid: (domainNameArg: string, sslDirArg: string) => boolean;
|
||||
export interface certConfig {
|
||||
domainName: string;
|
||||
created: number;
|
||||
expires: number;
|
||||
}
|
||||
/**
|
||||
* update a ssl directory
|
||||
*/
|
||||
export declare let updateSslDirSync: (sslDirArg: string, domainNameArg: string) => void;
|
59
dist/cert.classes.cert.helpers.js
vendored
Normal file
59
dist/cert.classes.cert.helpers.js
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
const plugins = require("./cert.plugins");
|
||||
const paths = require("./cert.paths");
|
||||
/**
|
||||
* schedule a retry of certificate request
|
||||
*/
|
||||
exports.scheduleRetry = (domainArg, certClassArg) => {
|
||||
let done = plugins.q.defer();
|
||||
setTimeout(() => {
|
||||
certClassArg.getDomainCert(domainArg)
|
||||
.then(done.resolve);
|
||||
}, 20000);
|
||||
return done.promise;
|
||||
};
|
||||
/**
|
||||
* check if a given domainCert is still valid
|
||||
*/
|
||||
exports.checkDomainsStillValid = (domainNameArg, sslDirArg) => {
|
||||
let domainConfigPath = plugins.path.join(sslDirArg, domainNameArg, "config.json");
|
||||
if (plugins.smartfile.fs.fileExistsSync(domainConfigPath)) {
|
||||
let domainConfig = plugins.smartfile.fs.toObjectSync(domainConfigPath, "json");
|
||||
if (Date.now() >= ((domainConfig.expires - 604800) * 1000)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
;
|
||||
/**
|
||||
* update a ssl directory
|
||||
*/
|
||||
exports.updateSslDirSync = (sslDirArg, domainNameArg) => {
|
||||
plugins.smartfile.fs.ensureDirSync(sslDirArg);
|
||||
let domainCertFolder = plugins.path.join(paths.certDir, domainNameArg);
|
||||
if (plugins.smartfile.fs.listFoldersSync(paths.certDir).indexOf(domainNameArg) != -1) {
|
||||
plugins.smartfile.fs.copySync(plugins.path.join(domainCertFolder, "fullchain.pem"), plugins.path.join(sslDirArg, domainNameArg, "fullchain.pem"));
|
||||
plugins.smartfile.fs.copySync(plugins.path.join(domainCertFolder, "privkey.pem"), plugins.path.join(sslDirArg, domainNameArg, "privkey.pem"));
|
||||
// create cert config
|
||||
let certRegex = /.*\-([0-9]*)\.pem/;
|
||||
let certFileNameWithTime = plugins.smartfile.fs.listFilesSync(domainCertFolder, certRegex)[0];
|
||||
let certTime = parseInt(certRegex.exec(certFileNameWithTime)[1]);
|
||||
let certConfig = {
|
||||
domainName: domainNameArg,
|
||||
created: certTime,
|
||||
expires: certTime + 7776000
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(JSON.stringify(certConfig), plugins.path.join(sslDirArg, domainNameArg, "config.json"));
|
||||
}
|
||||
;
|
||||
};
|
||||
let updateGitOrigin = (syncDirectionArg) => {
|
||||
};
|
||||
updateGitOrigin(0 /* toOrigin */);
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2VydC5jbGFzc2VzLmNlcnQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2NlcnQuY2xhc3Nlcy5jZXJ0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBLE1BQVksT0FBTyxXQUFNLGdCQUFnQixDQUFDLENBQUE7QUFDMUMsTUFBWSxLQUFLLFdBQU0sY0FBYyxDQUFDLENBQUE7QUFJdEM7O0dBRUc7QUFDUSxxQkFBYSxHQUFHLENBQUMsU0FBZ0IsRUFBQyxZQUFpQjtJQUMxRCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLFVBQVUsQ0FBQztRQUNQLFlBQVksQ0FBQyxhQUFhLENBQUMsU0FBUyxDQUFDO2FBQ2hDLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUM7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USxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsb0JBQW9CLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ2pFLElBQUksVUFBVSxHQUFlO1lBQ3pCLFVBQVUsRUFBRSxhQUFhO1lBQ3pCLE9BQU8sRUFBRSxRQUFRO1lBQ2pCLE9BQU8sRUFBRSxRQUFRLEdBQUcsT0FBTztTQUM5QixDQUFDO1FBQ0YsT0FBTyxDQUFDLFNBQVMsQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUM3QixJQUFJLENBQUMsU0FBUyxDQUFDLFVBQVUsQ0FBQyxFQUMxQixPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUUsYUFBYSxFQUFFLGFBQWEsQ0FBQyxDQUM3RCxDQUFDO0lBQ04sQ0FBQztJQUFBLENBQUM7QUFDTixDQUFDLENBQUE7QUFPRCxJQUFJLGVBQWUsR0FBRyxDQUFDLGdCQUFrQztBQUV6RCxDQUFDLENBQUM7QUFFRixlQUFlLENBQUMsZ0JBQXlCLENBQUMsQ0FBQyJ9
|
137
dist/cert.classes.cert.js
vendored
Normal file
137
dist/cert.classes.cert.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
dist/cert.helpers.d.ts
vendored
5
dist/cert.helpers.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
/// <reference types="q" />
|
||||
import { Cert } from "./index.ts";
|
||||
import * as plugins from "./cert.plugins";
|
||||
export declare let accountsKeyPresent: () => plugins.q.Promise<{}>;
|
||||
export declare let scheduleRetry: (domainArg: string, certClassArg: Cert) => plugins.q.Promise<{}>;
|
25
dist/cert.helpers.js
vendored
25
dist/cert.helpers.js
vendored
@ -1,25 +0,0 @@
|
||||
"use strict";
|
||||
const plugins = require("./cert.plugins");
|
||||
let firstCall = true;
|
||||
let enoughTime = false;
|
||||
exports.accountsKeyPresent = () => {
|
||||
let done = plugins.q.defer();
|
||||
if (firstCall) {
|
||||
done.resolve();
|
||||
firstCall = false;
|
||||
}
|
||||
else {
|
||||
setTimeout(done.resolve, 5000);
|
||||
}
|
||||
;
|
||||
return done.promise;
|
||||
};
|
||||
exports.scheduleRetry = (domainArg, certClassArg) => {
|
||||
let done = plugins.q.defer();
|
||||
setTimeout(() => {
|
||||
certClassArg.getDomainCert(domainArg)
|
||||
.then(done.resolve);
|
||||
}, 20000);
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2VydC5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvY2VydC5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFDQSxNQUFZLE9BQU8sV0FBTSxnQkFBZ0IsQ0FBQyxDQUFBO0FBRzFDLElBQUksU0FBUyxHQUFHLElBQUksQ0FBQztBQUNyQixJQUFJLFVBQVUsR0FBRyxLQUFLLENBQUM7QUFDWiwwQkFBa0IsR0FBRztJQUM1QixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLEVBQUUsQ0FBQyxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUM7UUFDWixJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDZixTQUFTLEdBQUcsS0FBSyxDQUFDO0lBQ3RCLENBQUM7SUFBRSxJQUFJLENBQUMsQ0FBQztRQUNMLFVBQVUsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFDLElBQUksQ0FBQyxDQUFDO0lBQ2xDLENBQUM7SUFBQSxDQUFDO0lBQ0YsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFDO0FBRVMscUJBQWEsR0FBRyxDQUFDLFNBQWdCLEVBQUMsWUFBaUI7SUFDMUQsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixVQUFVLENBQUM7UUFDUCxZQUFZLENBQUMsYUFBYSxDQUFDLFNBQVMsQ0FBQzthQUNoQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQzVCLENBQUMsRUFBQyxLQUFLLENBQUMsQ0FBQztJQUNULE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQyJ9
|
4
dist/cert.hook.js
vendored
4
dist/cert.hook.js
vendored
@ -29,7 +29,7 @@ let cleanChallenge = (domainNameArg) => {
|
||||
};
|
||||
let cooldown = () => {
|
||||
let done = plugins.q.defer();
|
||||
let cooldowntime = 120000;
|
||||
let cooldowntime = 40000;
|
||||
let passedTime = 0;
|
||||
plugins.beautylog.log("Cooling down! " + (cooldowntime / 1000).toString() + " seconds left");
|
||||
let coolDownCounter = () => {
|
||||
@ -62,4 +62,4 @@ smartcli.addCommand({
|
||||
cleanChallenge(argv._[1]);
|
||||
});
|
||||
smartcli.startParse();
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2VydC5ob29rLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvY2VydC5ob29rLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBR0EsTUFBWSxPQUFPLFdBQU0sZ0JBQWdCLENBQUMsQ0FBQTtBQUMxQyxNQUFZLEtBQUssV0FBTSxjQUFjLENBQUMsQ0FBQTtBQUV0QyxJQUFJLFFBQVEsR0FBRyxJQUFJLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUM7QUFFL0MsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsQ0FB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BQyJ9
|
45
dist/index.d.ts
vendored
45
dist/index.d.ts
vendored
@ -1,44 +1 @@
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./cert.plugins";
|
||||
export interface ICertConstructorOptions {
|
||||
cfEmail: string;
|
||||
cfKey: string;
|
||||
sslDir?: string;
|
||||
gitOriginRepo?: string;
|
||||
testMode?: boolean;
|
||||
}
|
||||
export declare class Cert {
|
||||
private _cfEmail;
|
||||
private _cfKey;
|
||||
private _sslDir;
|
||||
private _gitOriginRepo;
|
||||
private _testMode;
|
||||
domainsCurrentlyRequesting: plugins.lik.Stringmap;
|
||||
certificatesPresent: Certificate[];
|
||||
certificatesValid: Certificate[];
|
||||
/**
|
||||
* Constructor for Cert object
|
||||
*/
|
||||
constructor(optionsArg: ICertConstructorOptions);
|
||||
/**
|
||||
* Pulls already requested certificates from git origin
|
||||
*/
|
||||
sslGitOriginPull: () => void;
|
||||
/**
|
||||
* Pushes all new requested certificates to git origin
|
||||
*/
|
||||
sslGitOriginAddCommitPush: () => void;
|
||||
/**
|
||||
* gets a ssl cert for a given domain
|
||||
*/
|
||||
getDomainCert(domainNameArg: string, optionsArg?: {
|
||||
force: boolean;
|
||||
}): plugins.q.Promise<{}>;
|
||||
cleanOldCertificates(): void;
|
||||
}
|
||||
export declare class Certificate {
|
||||
domainName: string;
|
||||
creationDate: Date;
|
||||
expiryDate: Date;
|
||||
constructor();
|
||||
}
|
||||
export * from "./cert.classes.cert";
|
||||
|
161
dist/index.js
vendored
161
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -30,12 +30,12 @@
|
||||
"@types/minimatch": "^2.0.28",
|
||||
"@types/q": "^0.0.27",
|
||||
"@types/shelljs": "^0.3.27",
|
||||
"beautylog": "^5.0.14",
|
||||
"beautylog": "^5.0.18",
|
||||
"cflare": "0.0.9",
|
||||
"fs-extra": "^0.30.0",
|
||||
"lik": "^1.0.2",
|
||||
"lik": "^1.0.5",
|
||||
"q": "^1.4.1",
|
||||
"shelljs": "^0.7.0",
|
||||
"shelljs": "^0.7.1",
|
||||
"smartcli": "^1.0.4",
|
||||
"smartfile": "^4.0.12",
|
||||
"smartgit": "0.1.9",
|
||||
|
@ -36,12 +36,12 @@ describe("cert", function () {
|
||||
return Math.floor(Math.random() * (max - min) + min);
|
||||
}
|
||||
promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1, 100000)}.bleu.de`));
|
||||
//promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
|
||||
//promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
|
||||
promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1, 100000)}.bleu.de`));
|
||||
promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1, 100000)}.bleu.de`));
|
||||
q.all(promiseArray).then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQix1QkFBbUIsTUFBTSxDQUFDLENBQUE7QUFDMUIsTUFBTyxJQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDOUIsTUFBTyxDQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDeEIsMEJBQTJCLGlCQUFpQixDQUFDLENBQUE7QUFDN0MsTUFBWSxJQUFJLFdBQU0sZUFBZSxDQUFDLENBQUE7QUFHdEMsSUFBSSxRQUFRLEdBQUcsSUFBSSxXQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxFQUFFLE9BQU8sQ0FBQyxHQUFHLEVBQUUsR0FBRyxTQUFTLENB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floor(Math.random() * (max - min) + min);
|
||||
}
|
||||
promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
|
||||
//promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
|
||||
//promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
|
||||
promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
|
||||
promiseArray.push(testCert.getDomainCert(`testing${getRandomArbitrary(1,100000)}.bleu.de`));
|
||||
q.all(promiseArray).then(() => {
|
||||
done();
|
||||
});
|
||||
|
86
ts/cert.classes.cert.helpers.ts
Normal file
86
ts/cert.classes.cert.helpers.ts
Normal file
@ -0,0 +1,86 @@
|
||||
import {Cert} from "./index.ts";
|
||||
import * as plugins from "./cert.plugins";
|
||||
import * as paths from "./cert.paths";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* schedule a retry of certificate request
|
||||
*/
|
||||
export let scheduleRetry = (domainArg:string,certClassArg:Cert) => {
|
||||
let done = plugins.q.defer();
|
||||
setTimeout(() => {
|
||||
certClassArg.getDomainCert(domainArg)
|
||||
.then(done.resolve);
|
||||
},20000);
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* check if a given domainCert is still valid
|
||||
*/
|
||||
export let checkDomainsStillValid = (domainNameArg: string, sslDirArg: string): boolean => {
|
||||
let domainConfigPath = plugins.path.join(sslDirArg, domainNameArg, "config.json");
|
||||
if (plugins.smartfile.fs.fileExistsSync(domainConfigPath)) {
|
||||
let domainConfig = plugins.smartfile.fs.toObjectSync(
|
||||
domainConfigPath,
|
||||
"json"
|
||||
);
|
||||
if (Date.now() >= ((domainConfig.expires - 604800) * 1000)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface certConfig {
|
||||
domainName: string;
|
||||
created: number;
|
||||
expires: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* update a ssl directory
|
||||
*/
|
||||
export let updateSslDirSync = (sslDirArg: string, domainNameArg: string) => {
|
||||
plugins.smartfile.fs.ensureDirSync(sslDirArg);
|
||||
let domainCertFolder = plugins.path.join(paths.certDir, domainNameArg)
|
||||
if (plugins.smartfile.fs.listFoldersSync(paths.certDir).indexOf(domainNameArg) != -1) {
|
||||
plugins.smartfile.fs.copySync(
|
||||
plugins.path.join(domainCertFolder, "fullchain.pem"),
|
||||
plugins.path.join(sslDirArg, domainNameArg, "fullchain.pem")
|
||||
);
|
||||
plugins.smartfile.fs.copySync(
|
||||
plugins.path.join(domainCertFolder, "privkey.pem"),
|
||||
plugins.path.join(sslDirArg, domainNameArg, "privkey.pem")
|
||||
);
|
||||
// create cert config
|
||||
let certRegex = /.*\-([0-9]*)\.pem/;
|
||||
let certFileNameWithTime: string = plugins.smartfile.fs.listFilesSync(domainCertFolder, certRegex)[0];
|
||||
let certTime = parseInt(certRegex.exec(certFileNameWithTime)[1]);
|
||||
let certConfig: certConfig = {
|
||||
domainName: domainNameArg,
|
||||
created: certTime,
|
||||
expires: certTime + 7776000
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
JSON.stringify(certConfig),
|
||||
plugins.path.join(sslDirArg, domainNameArg, "config.json")
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
const enum gitSyncDirection {
|
||||
toOrigin,
|
||||
fromOrigin
|
||||
}
|
||||
|
||||
let updateGitOrigin = (syncDirectionArg: gitSyncDirection) => {
|
||||
|
||||
};
|
||||
|
||||
updateGitOrigin(gitSyncDirection.toOrigin);
|
160
ts/cert.classes.cert.ts
Normal file
160
ts/cert.classes.cert.ts
Normal file
@ -0,0 +1,160 @@
|
||||
import * as plugins from "./cert.plugins";
|
||||
import * as paths from "./cert.paths";
|
||||
import * as helpers from "./cert.classes.cert.helpers"
|
||||
|
||||
export interface ICertConstructorOptions {
|
||||
cfEmail: string,
|
||||
cfKey: string,
|
||||
sslDir?: string,
|
||||
gitOriginRepo?: string,
|
||||
testMode?: boolean
|
||||
};
|
||||
|
||||
export class Cert {
|
||||
private _cfEmail: string;
|
||||
private _cfKey: string;
|
||||
private _sslDir: string;
|
||||
private _gitOriginRepo: string;
|
||||
private _testMode: boolean;
|
||||
domainCertRequestMap: plugins.lik.Stringmap = new plugins.lik.Stringmap();
|
||||
certificatesPresent: Certificate[];
|
||||
certificatesValid: Certificate[];
|
||||
|
||||
/**
|
||||
* Constructor for Cert object
|
||||
*/
|
||||
constructor(optionsArg: ICertConstructorOptions) {
|
||||
this._cfEmail = optionsArg.cfEmail;
|
||||
this._cfKey = optionsArg.cfKey;
|
||||
this._sslDir = optionsArg.sslDir;
|
||||
this._gitOriginRepo = optionsArg.gitOriginRepo;
|
||||
this._testMode = optionsArg.testMode;
|
||||
// write hook config
|
||||
let config = {
|
||||
cfEmail: this._cfEmail,
|
||||
cfKey: this._cfKey
|
||||
}
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
JSON.stringify(config),
|
||||
plugins.path.join(__dirname, "assets/config.json")
|
||||
);
|
||||
// setup sslDir
|
||||
if (!this._sslDir) this._sslDir = paths.defaultSslDir;
|
||||
// setup Git
|
||||
if (this._gitOriginRepo) {
|
||||
plugins.smartgit.init(this._sslDir);
|
||||
plugins.smartgit.remote.add(this._sslDir, "origin", this._gitOriginRepo);
|
||||
this.sslGitOriginPull();
|
||||
}
|
||||
// setup leSh config;
|
||||
let leShConfigString;
|
||||
if (this._testMode) {
|
||||
leShConfigString = `CA="https://acme-staging.api.letsencrypt.org/directory"\n`;
|
||||
} else {
|
||||
leShConfigString = " ";
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
leShConfigString,
|
||||
paths.leShConfig
|
||||
);
|
||||
plugins.shelljs.exec("chmod 700 " + paths.letsencryptSh);
|
||||
plugins.shelljs.exec("chmod 700 " + paths.certHook);
|
||||
plugins.shelljs.exec(
|
||||
`bash -c "${paths.letsencryptSh} -c --no-lock -f ${paths.leShConfig} -d notthere.notthere -t dns-01 -k ${paths.certHook} -o ${paths.certDir}"`,
|
||||
{
|
||||
silent: true
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Pulls already requested certificates from git origin
|
||||
*/
|
||||
sslGitOriginPull = () => {
|
||||
if (this._gitOriginRepo) {
|
||||
plugins.smartgit.pull(this._sslDir, "origin", "master");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Pushes all new requested certificates to git origin
|
||||
*/
|
||||
sslGitOriginAddCommitPush = () => {
|
||||
if (this._gitOriginRepo) {
|
||||
plugins.smartgit.add.addAll(this._sslDir);
|
||||
plugins.smartgit.commit(this._sslDir, "added new SSL certificates and deleted obsolete ones.");
|
||||
plugins.smartgit.push(this._sslDir, "origin", "master");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* gets a ssl cert for a given domain
|
||||
*/
|
||||
getDomainCert(domainNameArg: string, optionsArg: { force: boolean } = { force: false }) {
|
||||
let done = plugins.q.defer();
|
||||
let domainStringData = new plugins.smartstring.Domain(domainNameArg);
|
||||
let sameZoneRequesting: boolean = this.domainCertRequestMap.checkMinimatch("*" + domainStringData.zoneName)
|
||||
// make sure no one else requires the same domain at the same time
|
||||
if (!this.domainCertRequestMap.checkString(domainNameArg)) {
|
||||
this.domainCertRequestMap.addString(domainNameArg);
|
||||
if (!helpers.checkDomainsStillValid(domainNameArg, this._sslDir) || optionsArg.force) {
|
||||
if (!sameZoneRequesting) {
|
||||
plugins.smartfile.fs.ensureDir(paths.certDir);
|
||||
plugins.beautylog.info(`getting cert for ${domainNameArg}`);
|
||||
plugins.shelljs.exec(
|
||||
`bash -c "${paths.letsencryptSh} -c --no-lock -f ${paths.leShConfig} -d ${domainNameArg} -t dns-01 -k ${paths.certHook} -o ${paths.certDir}"`,
|
||||
{
|
||||
silent: true
|
||||
},
|
||||
(codeArg, stdoutArg) => {
|
||||
if (codeArg == 0) {
|
||||
console.log(stdoutArg);
|
||||
let fetchedCertsArray: string[] = plugins.smartfile.fs.listFoldersSync(paths.certDir);
|
||||
if (fetchedCertsArray.indexOf(domainNameArg) != -1) {
|
||||
helpers.updateSslDirSync(this._sslDir, domainNameArg);
|
||||
plugins.smartfile.fs.removeSync(plugins.path.join(paths.certDir, domainNameArg));
|
||||
};
|
||||
done.resolve();
|
||||
} else {
|
||||
plugins.beautylog.warn(`${domainNameArg} scheduled for retry`);
|
||||
helpers.scheduleRetry(domainNameArg, this).then(done.resolve);
|
||||
}
|
||||
this.domainCertRequestMap.removeString(domainNameArg);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
plugins.beautylog.info(`${domainNameArg} is waiting for domains names of same zone to finish`);
|
||||
this.domainCertRequestMap.removeString(domainNameArg);
|
||||
this.domainCertRequestMap.registerUntilTrue(
|
||||
() => {
|
||||
return !this.domainCertRequestMap.checkMinimatch("*" + domainStringData.zoneName);
|
||||
},
|
||||
() => {
|
||||
this.getDomainCert(domainNameArg).then(done.resolve);
|
||||
}
|
||||
);
|
||||
}
|
||||
} else {
|
||||
plugins.beautylog.info("certificate for " + domainNameArg + " is still valid! Not fetching new one!");
|
||||
this.domainCertRequestMap.removeString(domainNameArg);
|
||||
done.resolve();
|
||||
};
|
||||
} else {
|
||||
plugins.beautylog.warn(`${domainNameArg} is already requesting`);
|
||||
};
|
||||
|
||||
return done.promise;
|
||||
};
|
||||
cleanOldCertificates() {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
export class Certificate {
|
||||
domainName: string;
|
||||
creationDate: Date;
|
||||
expiryDate: Date;
|
||||
constructor() {
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -1,25 +0,0 @@
|
||||
import {Cert} from "./index.ts";
|
||||
import * as plugins from "./cert.plugins";
|
||||
import * as paths from "./cert.paths";
|
||||
|
||||
let firstCall = true;
|
||||
let enoughTime = false;
|
||||
export let accountsKeyPresent = () => {
|
||||
let done = plugins.q.defer();
|
||||
if (firstCall) {
|
||||
done.resolve();
|
||||
firstCall = false;
|
||||
} else {
|
||||
setTimeout(done.resolve,5000);
|
||||
};
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
export let scheduleRetry = (domainArg:string,certClassArg:Cert) => {
|
||||
let done = plugins.q.defer();
|
||||
setTimeout(() => {
|
||||
certClassArg.getDomainCert(domainArg)
|
||||
.then(done.resolve);
|
||||
},20000);
|
||||
return done.promise;
|
||||
};
|
203
ts/index.ts
203
ts/index.ts
@ -1,205 +1,4 @@
|
||||
import * as plugins from "./cert.plugins";
|
||||
import * as paths from "./cert.paths";
|
||||
import * as helpers from "./cert.helpers"
|
||||
|
||||
export interface ICertConstructorOptions {
|
||||
cfEmail: string,
|
||||
cfKey: string,
|
||||
sslDir?: string,
|
||||
gitOriginRepo?: string,
|
||||
testMode?: boolean
|
||||
};
|
||||
|
||||
export class Cert {
|
||||
private _cfEmail: string;
|
||||
private _cfKey: string;
|
||||
private _sslDir: string;
|
||||
private _gitOriginRepo: string;
|
||||
private _testMode: boolean;
|
||||
domainsCurrentlyRequesting: plugins.lik.Stringmap = new plugins.lik.Stringmap();
|
||||
certificatesPresent: Certificate[];
|
||||
certificatesValid: Certificate[];
|
||||
|
||||
/**
|
||||
* Constructor for Cert object
|
||||
*/
|
||||
constructor(optionsArg: ICertConstructorOptions) {
|
||||
this._cfEmail = optionsArg.cfEmail;
|
||||
this._cfKey = optionsArg.cfKey;
|
||||
this._sslDir = optionsArg.sslDir;
|
||||
this._gitOriginRepo = optionsArg.gitOriginRepo;
|
||||
this._testMode = optionsArg.testMode;
|
||||
// write hook config
|
||||
let config = {
|
||||
cfEmail: this._cfEmail,
|
||||
cfKey: this._cfKey
|
||||
}
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
JSON.stringify(config),
|
||||
plugins.path.join(__dirname, "assets/config.json")
|
||||
);
|
||||
// setup sslDir
|
||||
if (!this._sslDir) this._sslDir = paths.defaultSslDir;
|
||||
// setup Git
|
||||
if (this._gitOriginRepo) {
|
||||
plugins.smartgit.init(this._sslDir);
|
||||
plugins.smartgit.remote.add(this._sslDir, "origin", this._gitOriginRepo);
|
||||
this.sslGitOriginPull();
|
||||
}
|
||||
// setup leSh config;
|
||||
let leShConfigString;
|
||||
if (this._testMode) {
|
||||
leShConfigString = `CA="https://acme-staging.api.letsencrypt.org/directory"\n`;
|
||||
} else {
|
||||
leShConfigString = " ";
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
leShConfigString,
|
||||
paths.leShConfig
|
||||
);
|
||||
plugins.shelljs.exec("chmod 700 " + paths.letsencryptSh);
|
||||
plugins.shelljs.exec("chmod 700 " + paths.certHook);
|
||||
};
|
||||
|
||||
/**
|
||||
* Pulls already requested certificates from git origin
|
||||
*/
|
||||
sslGitOriginPull = () => {
|
||||
if (this._gitOriginRepo) {
|
||||
plugins.smartgit.pull(this._sslDir, "origin", "master");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Pushes all new requested certificates to git origin
|
||||
*/
|
||||
sslGitOriginAddCommitPush = () => {
|
||||
if (this._gitOriginRepo) {
|
||||
plugins.smartgit.add.addAll(this._sslDir);
|
||||
plugins.smartgit.commit(this._sslDir, "added new SSL certificates and deleted obsolete ones.");
|
||||
plugins.smartgit.push(this._sslDir, "origin", "master");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* gets a ssl cert for a given domain
|
||||
*/
|
||||
getDomainCert(domainNameArg: string, optionsArg: { force: boolean } = { force: false }) {
|
||||
let done = plugins.q.defer();
|
||||
// make sure no one else requires the same domain at the same time
|
||||
helpers.accountsKeyPresent().then(() => {
|
||||
if (!this.domainsCurrentlyRequesting.checkString(domainNameArg)) {
|
||||
this.domainsCurrentlyRequesting.addString(domainNameArg);
|
||||
if (!checkDomainsStillValid(domainNameArg, this._sslDir) || optionsArg.force) {
|
||||
plugins.smartfile.fs.ensureDir(paths.certDir);
|
||||
plugins.beautylog.info(`getting cert for ${domainNameArg}`);
|
||||
plugins.shelljs.exec(
|
||||
`bash -c "${paths.letsencryptSh} -c --no-lock -f ${paths.leShConfig} -d ${domainNameArg} -t dns-01 -k ${paths.certHook} -o ${paths.certDir}"`,
|
||||
{
|
||||
silent: true
|
||||
},
|
||||
(codeArg, stdoutArg) => {
|
||||
if (codeArg == 0) {
|
||||
console.log(stdoutArg);
|
||||
let fetchedCertsArray: string[] = plugins.smartfile.fs.listFoldersSync(paths.certDir);
|
||||
if (fetchedCertsArray.indexOf(domainNameArg) != -1) {
|
||||
updateSslDirSync(this._sslDir, domainNameArg);
|
||||
plugins.smartfile.fs.removeSync(plugins.path.join(paths.certDir, domainNameArg));
|
||||
}
|
||||
this.domainsCurrentlyRequesting.removeString(domainNameArg);
|
||||
done.resolve();
|
||||
} else {
|
||||
this.domainsCurrentlyRequesting.removeString(domainNameArg);
|
||||
plugins.beautylog.warn(`${domainNameArg} scheduled for retry`);
|
||||
helpers.scheduleRetry(domainNameArg,this).then(done.resolve);
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
plugins.beautylog.info("certificate for " + domainNameArg + " is still valid! Not fetching new one!");
|
||||
this.domainsCurrentlyRequesting.removeString(domainNameArg);
|
||||
done.resolve();
|
||||
};
|
||||
} else {
|
||||
plugins.beautylog.warn(`${domainNameArg} is already requesting`);
|
||||
};
|
||||
});
|
||||
|
||||
return done.promise;
|
||||
};
|
||||
cleanOldCertificates() {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
export class Certificate {
|
||||
domainName: string;
|
||||
creationDate: Date;
|
||||
expiryDate: Date;
|
||||
constructor() {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
interface certConfig {
|
||||
domainName: string;
|
||||
created: number;
|
||||
expires: number;
|
||||
}
|
||||
|
||||
let checkDomainsStillValid = (domainNameArg: string, sslDirArg: string): boolean => {
|
||||
let domainConfigPath = plugins.path.join(sslDirArg, domainNameArg, "config.json");
|
||||
if (plugins.smartfile.fs.fileExistsSync(domainConfigPath)) {
|
||||
let domainConfig = plugins.smartfile.fs.toObjectSync(
|
||||
domainConfigPath,
|
||||
"json"
|
||||
);
|
||||
if (Date.now() >= ((domainConfig.expires - 604800) * 1000)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let updateSslDirSync = (sslDirArg: string, domainNameArg: string) => {
|
||||
plugins.smartfile.fs.ensureDirSync(sslDirArg);
|
||||
let domainCertFolder = plugins.path.join(paths.certDir, domainNameArg)
|
||||
if (plugins.smartfile.fs.listFoldersSync(paths.certDir).indexOf(domainNameArg) != -1) {
|
||||
plugins.smartfile.fs.copySync(
|
||||
plugins.path.join(domainCertFolder, "fullchain.pem"),
|
||||
plugins.path.join(sslDirArg, domainNameArg, "fullchain.pem")
|
||||
);
|
||||
plugins.smartfile.fs.copySync(
|
||||
plugins.path.join(domainCertFolder, "privkey.pem"),
|
||||
plugins.path.join(sslDirArg, domainNameArg, "privkey.pem")
|
||||
);
|
||||
// create cert config
|
||||
let certRegex = /.*\-([0-9]*)\.pem/;
|
||||
let certFileNameWithTime: string = plugins.smartfile.fs.listFilesSync(domainCertFolder, certRegex)[0];
|
||||
let certTime = parseInt(certRegex.exec(certFileNameWithTime)[1]);
|
||||
let certConfig: certConfig = {
|
||||
domainName: domainNameArg,
|
||||
created: certTime,
|
||||
expires: certTime + 7776000
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
JSON.stringify(certConfig),
|
||||
plugins.path.join(sslDirArg, domainNameArg, "config.json")
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
const enum gitSyncDirection {
|
||||
toOrigin,
|
||||
fromOrigin
|
||||
}
|
||||
|
||||
let updateGitOrigin = (syncDirectionArg: gitSyncDirection) => {
|
||||
|
||||
};
|
||||
|
||||
updateGitOrigin(gitSyncDirection.toOrigin);
|
||||
export * from "./cert.classes.cert";
|
Loading…
Reference in New Issue
Block a user