@cloud-cli/le 1.0.4 → 1.0.6
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/README.md +12 -25
- package/dist/certificate-manager.d.ts +1 -1
- package/dist/certificate-manager.js +4 -2
- package/dist/index.d.ts +1 -1
- package/package.json +11 -18
- package/.prettierrc +0 -9
package/README.md
CHANGED
|
@@ -1,50 +1,37 @@
|
|
|
1
1
|
# Let's Encrypt certificates
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SSL certificate generation.
|
|
4
|
+
Requires `certbot` to be installed on server and properly configured for Let's Encrypt certs
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
import le from '@cloud-cli/le';
|
|
6
|
+
## API
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
le.add({ domain: 'example.com', useWildcard: true });
|
|
12
|
-
le.remove({ domain: 'example.com' };
|
|
8
|
+
**Create a certificate for example.com**
|
|
13
9
|
|
|
14
10
|
```
|
|
15
|
-
|
|
16
|
-
With Cloudy CLI:
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
import le from '@cloud-cli/le';
|
|
20
|
-
import { cli } from '@cloud-cli/cy';
|
|
21
|
-
|
|
22
|
-
cli.add('le', le);
|
|
11
|
+
cy le.add --domain example.com
|
|
23
12
|
```
|
|
24
13
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
**Create a certificate**
|
|
14
|
+
**Create a certificate for example.com and all its subdomains**
|
|
28
15
|
|
|
29
16
|
```
|
|
30
|
-
cy
|
|
31
|
-
|
|
17
|
+
cy le.add --domain example.com --useWildcard 1
|
|
32
18
|
```
|
|
33
19
|
|
|
34
20
|
**Remove a certificate**
|
|
35
21
|
|
|
36
22
|
```
|
|
37
|
-
cy
|
|
23
|
+
cy le.remove --domain example.com
|
|
38
24
|
```
|
|
39
25
|
|
|
40
26
|
**Check if a certificate exists**
|
|
41
27
|
|
|
42
28
|
```
|
|
43
|
-
cy
|
|
29
|
+
cy le.exists --domain example.com
|
|
44
30
|
```
|
|
45
|
-
|
|
31
|
+
|
|
32
|
+
**List certificates and domains**
|
|
46
33
|
|
|
47
34
|
```
|
|
48
|
-
cy
|
|
35
|
+
cy le.list
|
|
49
36
|
```
|
|
50
37
|
|
|
@@ -14,7 +14,7 @@ export declare class CertificateManager {
|
|
|
14
14
|
private readonly domainPattern;
|
|
15
15
|
certificateExists({ domain }: CertificateOptions): boolean;
|
|
16
16
|
createCertificate({ domain, useWildcard, additionalOptions }: CreateCertificateOptions): true | Promise<string>;
|
|
17
|
-
removeCertificate({ domain }: CertificateOptions):
|
|
17
|
+
removeCertificate({ domain }: CertificateOptions): boolean;
|
|
18
18
|
getCertificateList(): string[];
|
|
19
19
|
private isValidDomain;
|
|
20
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawnSync as sh } from 'child_process';
|
|
2
2
|
import { existsSync, readdirSync, rmdirSync, statSync } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
-
const certificatesFolder = process.env.LE_CERTS_DIR ||
|
|
4
|
+
const certificatesFolder = process.env.LE_CERTS_DIR || '/etc/letsencrypt/live';
|
|
5
5
|
export class CertificateManager {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.domainPattern = /^[a-z0-9-.]+$/i;
|
|
@@ -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');
|
|
@@ -32,7 +32,9 @@ export class CertificateManager {
|
|
|
32
32
|
const path = join(certificatesFolder, domain);
|
|
33
33
|
if (existsSync(path)) {
|
|
34
34
|
rmdirSync(path, { recursive: true });
|
|
35
|
+
return true;
|
|
35
36
|
}
|
|
37
|
+
throw new Error('Invalid domain: ' + domain);
|
|
36
38
|
}
|
|
37
39
|
getCertificateList() {
|
|
38
40
|
return readdirSync(certificatesFolder, { encoding: 'utf-8' }).filter((file) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CertificateOptions, CreateCertificateOptions } from './certificate-manager.js';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
add(certificate: CreateCertificateOptions): true | Promise<string>;
|
|
4
|
-
remove(options: CertificateOptions):
|
|
4
|
+
remove(options: CertificateOptions): boolean;
|
|
5
5
|
list(): string[];
|
|
6
6
|
exists(options: CertificateOptions): boolean;
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-cli/le",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "LetsEncrypt integration for Cloudy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "echo true",
|
|
10
|
-
"
|
|
11
|
-
"tdd": "./node_modules/.bin/nodemon -w src -e ts -x ./node_modules/.bin/ts-node ./node_modules/jasmine/bin/jasmine --config=./jasmine.json",
|
|
12
|
-
"coverage": "./node_modules/.bin/nyc -r html -e .ts -x \"src/**/*.spec.ts\" npm run test",
|
|
13
|
-
"build": "rm -rf ./dist/* && tsc --project ./tsconfig.json",
|
|
14
|
-
"start": "node dist/index.js"
|
|
10
|
+
"build": "rm -rf ./dist/* && tsc"
|
|
15
11
|
},
|
|
16
12
|
"keywords": [
|
|
17
13
|
"cloudy"
|
|
18
14
|
],
|
|
19
15
|
"license": "MIT",
|
|
20
16
|
"author": "Darlan Alves <me@darlanalv.es>",
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@types/jasmine": "^3.6.3",
|
|
23
|
-
"@types/node": "^14.14.31",
|
|
24
|
-
"jasmine": "^3.6.4",
|
|
25
|
-
"nodemon": "^2.0.7",
|
|
26
|
-
"nyc": "^15.1.0",
|
|
27
|
-
"ts-node": "^9.1.1",
|
|
28
|
-
"typescript": "^4.1.3"
|
|
29
|
-
},
|
|
30
17
|
"repository": {
|
|
31
18
|
"type": "git",
|
|
32
19
|
"url": "https://github.com/cloud-cli/le.git"
|
|
@@ -34,7 +21,13 @@
|
|
|
34
21
|
"publishConfig": {
|
|
35
22
|
"access": "public"
|
|
36
23
|
},
|
|
37
|
-
"
|
|
38
|
-
"@cloud-cli/
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@cloud-cli/cli": "^2.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@cloud-cli/typescript-config": "^1.0.1",
|
|
29
|
+
"@types/node": "^20.12.8",
|
|
30
|
+
"typescript": "^5.4.5",
|
|
31
|
+
"vitest": "^1.6.0"
|
|
39
32
|
}
|
|
40
33
|
}
|