@cloud-cli/le 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/certificate-manager.d.ts +3 -0
- package/dist/certificate-manager.js +14 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
export interface Certificate {
|
|
2
3
|
rootDomain: string;
|
|
3
4
|
certificate: string;
|
|
@@ -16,5 +17,7 @@ export declare class CertificateManager {
|
|
|
16
17
|
createCertificate({ domain, useWildcard, additionalOptions }: CreateCertificateOptions): true | Promise<string>;
|
|
17
18
|
removeCertificate({ domain }: CertificateOptions): boolean;
|
|
18
19
|
getCertificateList(): string[];
|
|
20
|
+
getCertificate({ domain }: CertificateOptions): Promise<Buffer>;
|
|
21
|
+
getDomainsFromCert({ domain }: CertificateOptions): Promise<string[]>;
|
|
19
22
|
private isValidDomain;
|
|
20
23
|
}
|
|
@@ -21,7 +21,7 @@ export class CertificateManager {
|
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
const domains = [domain, useWildcard ? '*.' + domain : ''].filter(Boolean);
|
|
24
|
-
const domainsWithPrefix = domains.
|
|
24
|
+
const domainsWithPrefix = domains.flatMap((domain) => ['-d', domain]);
|
|
25
25
|
const out = sh('certbot', ['certonly', ...(additionalOptions || []), ...domainsWithPrefix]);
|
|
26
26
|
const stdout = String(out.stdout || '');
|
|
27
27
|
const stderr = String(out.stderr || '').split('\n').map(s => '! ' + s).join('\n');
|
|
@@ -41,6 +41,19 @@ export class CertificateManager {
|
|
|
41
41
|
return statSync(join(certificatesFolder, file)).isDirectory();
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
+
getCertificate({ domain }) {
|
|
45
|
+
const pemFile = join(certificatesFolder, domain, 'cert.pem');
|
|
46
|
+
const out = sh('openssl', ['x509', '-in', pemFile, '-noout', '-text']);
|
|
47
|
+
return out.status !== 0 ? Promise.resolve(out.stdout) : Promise.reject(out.stderr);
|
|
48
|
+
}
|
|
49
|
+
async getDomainsFromCert({ domain }) {
|
|
50
|
+
const cert = await this.getCertificate({ domain });
|
|
51
|
+
const line = String(cert).split('\n').find(s => s.includes('DNS:'));
|
|
52
|
+
if (line) {
|
|
53
|
+
return line.split(',').map(p => p.replace('DNS:', '').trim());
|
|
54
|
+
}
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
44
57
|
isValidDomain(domain) {
|
|
45
58
|
return domain && String(domain).length <= 253 && this.domainPattern.test(domain);
|
|
46
59
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { CertificateOptions, CreateCertificateOptions } from './certificate-manager.js';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
add(certificate: CreateCertificateOptions): true | Promise<string>;
|
|
4
5
|
remove(options: CertificateOptions): boolean;
|
|
5
6
|
list(): string[];
|
|
6
7
|
exists(options: CertificateOptions): boolean;
|
|
8
|
+
show(options: CertificateOptions): Promise<Buffer>;
|
|
9
|
+
showDomains(options: CertificateOptions): Promise<string[]>;
|
|
7
10
|
};
|
|
8
11
|
export default _default;
|
package/dist/index.js
CHANGED