@heroku-cli/plugin-mtls 0.8.2 → 0.9.1
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 +18 -33
- package/{lib/base.d.ts → base.d.ts} +11 -11
- package/{lib/base.js → base.js} +2 -2
- package/{lib/commands → commands}/data/mtls/certificates/create.js +7 -7
- package/{lib/commands → commands}/data/mtls/certificates/delete.js +7 -7
- package/{lib/commands → commands}/data/mtls/certificates/download.js +29 -26
- package/{lib/commands → commands}/data/mtls/certificates/get.js +6 -6
- package/{lib/commands → commands}/data/mtls/certificates/index.js +13 -8
- package/{lib/commands → commands}/data/mtls/create.js +8 -8
- package/{lib/commands → commands}/data/mtls/destroy.js +7 -7
- package/{lib/commands → commands}/data/mtls/index.js +15 -10
- package/{lib/commands → commands}/data/mtls/ip-rules/create.js +8 -8
- package/{lib/commands → commands}/data/mtls/ip-rules/delete.js +7 -7
- package/{lib/commands → commands}/data/mtls/ip-rules/get.js +6 -6
- package/{lib/commands → commands}/data/mtls/ip-rules/index.js +7 -7
- package/lib/{lib/fetcher.js → fetcher.js} +17 -17
- package/oclif.manifest.json +1 -1
- package/package.json +6 -39
- package/utils/is-error-http.d.ts +8 -0
- package/utils/is-error-http.js +7 -0
- package/utils/is-error-message.d.ts +3 -0
- package/utils/is-error-message.js +7 -0
- package/utils/table.d.ts +3 -0
- package/{lib/utils → utils}/table.js +5 -2
- package/LICENSE +0 -21
- package/lib/utils/table.d.ts +0 -3
- package/yarn.lock +0 -3334
- package/{lib/commands → commands}/data/mtls/certificates/create.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/certificates/delete.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/certificates/download.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/certificates/get.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/certificates/index.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/create.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/destroy.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/index.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/ip-rules/create.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/ip-rules/delete.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/ip-rules/get.d.ts +2 -2
- package/{lib/commands → commands}/data/mtls/ip-rules/index.d.ts +2 -2
- /package/{lib/index.d.ts → index.d.ts} +0 -0
- /package/{lib/index.js → index.js} +0 -0
- /package/lib/{lib/fetcher.d.ts → fetcher.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
===============
|
|
3
|
-
|
|
4
|
-
heroku mtls cli
|
|
1
|
+
# Heroku CLI MTLS Plugin
|
|
5
2
|
|
|
6
3
|
[](https://oclif.io)
|
|
7
|
-
|
|
8
|
-
[](https://circleci.com/gh/heroku/heroku-mtls-cli/tree/master)
|
|
9
|
-
[](https://npmjs.org/package/heroku-mtls-cli)
|
|
10
|
-
[](https://github.com/heroku/heroku-mtls-cli/blob/master/package.json)
|
|
4
|
+

|
|
11
5
|
|
|
12
6
|
<!-- toc -->
|
|
13
|
-
* [
|
|
7
|
+
* [Heroku CLI MTLS Plugin](#heroku-cli-mtls-plugin)
|
|
8
|
+
* [Installation](#installation)
|
|
14
9
|
* [Commands](#commands)
|
|
15
10
|
<!-- tocstop -->
|
|
16
|
-
#
|
|
17
|
-
<!-- usage -->
|
|
11
|
+
# Installation
|
|
18
12
|
```sh-session
|
|
19
|
-
$
|
|
20
|
-
$ heroku COMMAND
|
|
21
|
-
running command...
|
|
22
|
-
$ heroku (-v|--version|version)
|
|
23
|
-
@heroku-cli/plugin-mtls/0.8.2 darwin-arm64 node-v16.18.0
|
|
24
|
-
$ heroku --help [COMMAND]
|
|
25
|
-
USAGE
|
|
26
|
-
$ heroku COMMAND
|
|
27
|
-
...
|
|
13
|
+
$ heroku plugins:install @heroku-cli/plugin-mtls
|
|
28
14
|
```
|
|
29
|
-
<!-- usagestop -->
|
|
30
15
|
# Commands
|
|
31
16
|
<!-- commands -->
|
|
32
17
|
* [`heroku data:mtls [ADDON]`](#heroku-datamtls-addon)
|
|
@@ -57,7 +42,7 @@ EXAMPLE
|
|
|
57
42
|
$ heroku data:mtls postgresql-sushi-12345
|
|
58
43
|
```
|
|
59
44
|
|
|
60
|
-
_See code: [src/commands/data/mtls/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
45
|
+
_See code: [src/commands/data/mtls/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/index.ts)_
|
|
61
46
|
|
|
62
47
|
## `heroku data:mtls:certificates [ADDON]`
|
|
63
48
|
|
|
@@ -74,7 +59,7 @@ EXAMPLE
|
|
|
74
59
|
$ heroku data:mtls:ip-rules postgresql-sushi-12345
|
|
75
60
|
```
|
|
76
61
|
|
|
77
|
-
_See code: [src/commands/data/mtls/certificates/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
62
|
+
_See code: [src/commands/data/mtls/certificates/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/certificates/index.ts)_
|
|
78
63
|
|
|
79
64
|
## `heroku data:mtls:certificates:create [ADDON]`
|
|
80
65
|
|
|
@@ -91,7 +76,7 @@ EXAMPLE
|
|
|
91
76
|
$ heroku data:mtls:certificates:create postgresql-sushi-12345
|
|
92
77
|
```
|
|
93
78
|
|
|
94
|
-
_See code: [src/commands/data/mtls/certificates/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
79
|
+
_See code: [src/commands/data/mtls/certificates/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/certificates/create.ts)_
|
|
95
80
|
|
|
96
81
|
## `heroku data:mtls:certificates:delete [ADDON]`
|
|
97
82
|
|
|
@@ -109,7 +94,7 @@ EXAMPLE
|
|
|
109
94
|
$ heroku data:mtls:certificates:delete postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c"
|
|
110
95
|
```
|
|
111
96
|
|
|
112
|
-
_See code: [src/commands/data/mtls/certificates/delete.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
97
|
+
_See code: [src/commands/data/mtls/certificates/delete.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/certificates/delete.ts)_
|
|
113
98
|
|
|
114
99
|
## `heroku data:mtls:certificates:download [ADDON]`
|
|
115
100
|
|
|
@@ -133,7 +118,7 @@ EXAMPLES
|
|
|
133
118
|
"prefix_"
|
|
134
119
|
```
|
|
135
120
|
|
|
136
|
-
_See code: [src/commands/data/mtls/certificates/download.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
121
|
+
_See code: [src/commands/data/mtls/certificates/download.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/certificates/download.ts)_
|
|
137
122
|
|
|
138
123
|
## `heroku data:mtls:certificates:get [ADDON]`
|
|
139
124
|
|
|
@@ -151,7 +136,7 @@ EXAMPLE
|
|
|
151
136
|
$ heroku data:mtls:certificates:create postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c"
|
|
152
137
|
```
|
|
153
138
|
|
|
154
|
-
_See code: [src/commands/data/mtls/certificates/get.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
139
|
+
_See code: [src/commands/data/mtls/certificates/get.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/certificates/get.ts)_
|
|
155
140
|
|
|
156
141
|
## `heroku data:mtls:create [ADDON]`
|
|
157
142
|
|
|
@@ -168,7 +153,7 @@ EXAMPLE
|
|
|
168
153
|
$ heroku data:mtls:create postgresql-sushi-12345
|
|
169
154
|
```
|
|
170
155
|
|
|
171
|
-
_See code: [src/commands/data/mtls/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
156
|
+
_See code: [src/commands/data/mtls/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/create.ts)_
|
|
172
157
|
|
|
173
158
|
## `heroku data:mtls:destroy [ADDON]`
|
|
174
159
|
|
|
@@ -188,7 +173,7 @@ EXAMPLE
|
|
|
188
173
|
$ heroku data:mtls:destroy postgresql-sushi-12345
|
|
189
174
|
```
|
|
190
175
|
|
|
191
|
-
_See code: [src/commands/data/mtls/destroy.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
176
|
+
_See code: [src/commands/data/mtls/destroy.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/destroy.ts)_
|
|
192
177
|
|
|
193
178
|
## `heroku data:mtls:ip-rules [ADDON]`
|
|
194
179
|
|
|
@@ -205,7 +190,7 @@ EXAMPLE
|
|
|
205
190
|
$ heroku data:mtls:ip-rules postgresql-sushi-12345
|
|
206
191
|
```
|
|
207
192
|
|
|
208
|
-
_See code: [src/commands/data/mtls/ip-rules/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
193
|
+
_See code: [src/commands/data/mtls/ip-rules/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/ip-rules/index.ts)_
|
|
209
194
|
|
|
210
195
|
## `heroku data:mtls:ip-rules:create [ADDON]`
|
|
211
196
|
|
|
@@ -224,7 +209,7 @@ EXAMPLE
|
|
|
224
209
|
$ heroku data:mtls:ip-rules:create postgresql-sushi-12345 --cidr "1.2.3.4/32" --description "home IP address"
|
|
225
210
|
```
|
|
226
211
|
|
|
227
|
-
_See code: [src/commands/data/mtls/ip-rules/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
212
|
+
_See code: [src/commands/data/mtls/ip-rules/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/ip-rules/create.ts)_
|
|
228
213
|
|
|
229
214
|
## `heroku data:mtls:ip-rules:delete [ADDON]`
|
|
230
215
|
|
|
@@ -243,7 +228,7 @@ EXAMPLE
|
|
|
243
228
|
$ heroku data:mtls:ip-rules:delete postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c"
|
|
244
229
|
```
|
|
245
230
|
|
|
246
|
-
_See code: [src/commands/data/mtls/ip-rules/delete.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
231
|
+
_See code: [src/commands/data/mtls/ip-rules/delete.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/ip-rules/delete.ts)_
|
|
247
232
|
|
|
248
233
|
## `heroku data:mtls:ip-rules:get [ADDON]`
|
|
249
234
|
|
|
@@ -261,5 +246,5 @@ EXAMPLE
|
|
|
261
246
|
$ heroku data:mtls:ip-rules:get postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c"
|
|
262
247
|
```
|
|
263
248
|
|
|
264
|
-
_See code: [src/commands/data/mtls/ip-rules/get.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.
|
|
249
|
+
_See code: [src/commands/data/mtls/ip-rules/get.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.1/src/commands/data/mtls/ip-rules/get.ts)_
|
|
265
250
|
<!-- commandsstop -->
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
+
import type { IConfig } from '@oclif/config';
|
|
1
2
|
import { APIClient, Command } from '@heroku-cli/command';
|
|
2
|
-
import { IConfig } from '@oclif/config';
|
|
3
3
|
export default abstract class extends Command {
|
|
4
4
|
shogun: APIClient;
|
|
5
5
|
protected constructor(argv: string[], config: IConfig);
|
|
6
6
|
}
|
|
7
7
|
export interface MTLSStatus {
|
|
8
|
-
app: string;
|
|
9
8
|
addon: string;
|
|
9
|
+
app: string;
|
|
10
|
+
certificate_authority_chain?: string;
|
|
10
11
|
status: string;
|
|
11
|
-
certificate_authority_chain: string;
|
|
12
12
|
}
|
|
13
13
|
export interface MTLSIPRule {
|
|
14
|
-
id: string;
|
|
15
14
|
cidr: string;
|
|
16
|
-
decription: string;
|
|
17
15
|
created_at: Date;
|
|
18
|
-
|
|
16
|
+
decription: string;
|
|
17
|
+
id: string;
|
|
19
18
|
status: string;
|
|
19
|
+
updated_at: Date;
|
|
20
20
|
}
|
|
21
21
|
export interface MTLSCertificate {
|
|
22
|
-
|
|
23
|
-
status: string;
|
|
22
|
+
certificate_with_chain?: string;
|
|
24
23
|
created_at: Date;
|
|
25
|
-
updated_at: Date;
|
|
26
24
|
expires_at: Date;
|
|
25
|
+
id: string;
|
|
26
|
+
private_key?: string;
|
|
27
27
|
renewal_at: Date;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
status: string;
|
|
29
|
+
updated_at: Date;
|
|
30
30
|
}
|
package/{lib/base.js → base.js}
RENAMED
|
@@ -5,8 +5,8 @@ class default_1 extends command_1.Command {
|
|
|
5
5
|
constructor(argv, config) {
|
|
6
6
|
super(argv, config);
|
|
7
7
|
const client = new command_1.APIClient(this.config, {});
|
|
8
|
-
client.defaults.host = process.env.HEROKU_DATA_HOST || '
|
|
9
|
-
client.defaults.headers = Object.assign({}, this.heroku.defaults.headers, { authorization: `Basic ${Buffer.from(':' + this.heroku.auth).toString('base64')}` });
|
|
8
|
+
client.defaults.host = process.env.HEROKU_DATA_HOST || 'api.data.heroku.com';
|
|
9
|
+
client.defaults.headers = Object.assign(Object.assign({}, this.heroku.defaults.headers), { authorization: `Basic ${Buffer.from(':' + this.heroku.auth).toString('base64')}` });
|
|
10
10
|
this.shogun = client;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -8,24 +8,24 @@ const fetcher_1 = require("../../../../lib/fetcher");
|
|
|
8
8
|
class MTLSCertificateCreate extends base_1.default {
|
|
9
9
|
async run() {
|
|
10
10
|
const { args, flags } = this.parse(MTLSCertificateCreate);
|
|
11
|
-
const addon = await fetcher_1.default(this.heroku, args.addon, flags.app);
|
|
11
|
+
const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
|
|
12
12
|
if (addon.kind === 'kafka') {
|
|
13
13
|
cli_ux_1.cli.error('Kafka certificates are availabe in your app\'s config vars');
|
|
14
14
|
}
|
|
15
|
-
cli_ux_1.cli.action.start(`Creating new certificate for ${color_1.
|
|
15
|
+
cli_ux_1.cli.action.start(`Creating new certificate for ${color_1.color.cyan(addon.name)}`);
|
|
16
16
|
const { body: res } = await this.shogun.post(`${addon.endpoint}/certificates`, this.shogun.defaults);
|
|
17
17
|
cli_ux_1.cli.action.stop();
|
|
18
18
|
cli_ux_1.cli.styledObject(res);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
exports.default = MTLSCertificateCreate;
|
|
22
22
|
MTLSCertificateCreate.args = [
|
|
23
23
|
{ name: 'addon' }
|
|
24
24
|
];
|
|
25
|
-
MTLSCertificateCreate.
|
|
26
|
-
app: command_1.flags.app({ required: true })
|
|
27
|
-
};
|
|
25
|
+
MTLSCertificateCreate.description = 'create a new certificate for your MTLS enabled addon';
|
|
28
26
|
MTLSCertificateCreate.examples = [
|
|
29
27
|
'$ heroku data:mtls:certificates:create postgresql-sushi-12345'
|
|
30
28
|
];
|
|
31
|
-
|
|
29
|
+
MTLSCertificateCreate.flags = {
|
|
30
|
+
app: command_1.flags.app({ required: true })
|
|
31
|
+
};
|
|
@@ -8,24 +8,24 @@ const fetcher_1 = require("../../../../lib/fetcher");
|
|
|
8
8
|
class MTLSCertificateDelete extends base_1.default {
|
|
9
9
|
async run() {
|
|
10
10
|
const { args, flags } = this.parse(MTLSCertificateDelete);
|
|
11
|
-
const addon = await fetcher_1.default(this.heroku, args.addon, flags.app);
|
|
11
|
+
const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
|
|
12
12
|
if (addon.kind === 'kafka') {
|
|
13
13
|
cli_ux_1.cli.error('Kafka certificates are availabe in your app\'s config vars');
|
|
14
14
|
}
|
|
15
|
-
cli_ux_1.cli.action.start(`Deleting certificate for ${color_1.
|
|
15
|
+
cli_ux_1.cli.action.start(`Deleting certificate for ${color_1.color.cyan(addon.name)}`);
|
|
16
16
|
await this.shogun.delete(`${addon.endpoint}/certificates/${flags.id}`, this.shogun.defaults);
|
|
17
17
|
cli_ux_1.cli.action.stop();
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
exports.default = MTLSCertificateDelete;
|
|
21
21
|
MTLSCertificateDelete.args = [
|
|
22
22
|
{ name: 'addon' }
|
|
23
23
|
];
|
|
24
|
+
MTLSCertificateDelete.description = 'delete a specific certificate for your MTLS enabled addon';
|
|
25
|
+
MTLSCertificateDelete.examples = [
|
|
26
|
+
'$ heroku data:mtls:certificates:delete postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c"'
|
|
27
|
+
];
|
|
24
28
|
MTLSCertificateDelete.flags = {
|
|
25
29
|
app: command_1.flags.app({ required: true }),
|
|
26
30
|
id: command_1.flags.string({ required: true, description: 'id of certificate' })
|
|
27
31
|
};
|
|
28
|
-
MTLSCertificateDelete.examples = [
|
|
29
|
-
'$ heroku data:mtls:certificates:delete postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c"'
|
|
30
|
-
];
|
|
31
|
-
exports.default = MTLSCertificateDelete;
|
|
@@ -3,13 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const color_1 = require("@heroku-cli/color");
|
|
4
4
|
const command_1 = require("@heroku-cli/command");
|
|
5
5
|
const cli_ux_1 = require("cli-ux");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
6
|
const inquirer = require("inquirer");
|
|
8
|
-
const
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_os_1 = require("node:os");
|
|
9
9
|
const base_1 = require("../../../../base");
|
|
10
10
|
const fetcher_1 = require("../../../../lib/fetcher");
|
|
11
|
+
const is_error_http_1 = require("../../../../utils/is-error-http");
|
|
12
|
+
const is_error_message_1 = require("../../../../utils/is-error-message");
|
|
11
13
|
const write = (path, data, options = null) => new Promise((resolve, reject) => {
|
|
12
|
-
|
|
14
|
+
(0, node_fs_1.writeFile)(path, data, options, err => {
|
|
13
15
|
if (err)
|
|
14
16
|
reject(err);
|
|
15
17
|
resolve();
|
|
@@ -17,13 +19,14 @@ const write = (path, data, options = null) => new Promise((resolve, reject) => {
|
|
|
17
19
|
});
|
|
18
20
|
class MTLSCertificateDownload extends base_1.default {
|
|
19
21
|
async run() {
|
|
22
|
+
var _a, _b, _c;
|
|
20
23
|
try {
|
|
21
24
|
const { args, flags } = this.parse(MTLSCertificateDownload);
|
|
22
|
-
const addon = await fetcher_1.default(this.heroku, args.addon, flags.app);
|
|
25
|
+
const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
|
|
23
26
|
if (addon.kind === 'kafka') {
|
|
24
27
|
cli_ux_1.cli.error('Kafka certificates are availabe in your app\'s config vars');
|
|
25
28
|
}
|
|
26
|
-
cli_ux_1.cli.action.start(`Downloading certificates for ${color_1.
|
|
29
|
+
cli_ux_1.cli.action.start(`Downloading certificates for ${color_1.color.cyan(addon.name)}`);
|
|
27
30
|
const [{ body: mtls }, { body: certs }] = await Promise.all([
|
|
28
31
|
this.shogun.get(addon.endpoint, this.shogun.defaults),
|
|
29
32
|
this.shogun.get(`${addon.endpoint}/certificates`, this.shogun.defaults)
|
|
@@ -34,14 +37,14 @@ class MTLSCertificateDownload extends base_1.default {
|
|
|
34
37
|
const certById = certs.find(cert => cert.id === flags.id);
|
|
35
38
|
if (!certById) {
|
|
36
39
|
cli_ux_1.cli.action.stop();
|
|
37
|
-
cli_ux_1.cli.error(`No Certificate found with id ${color_1.
|
|
40
|
+
cli_ux_1.cli.error(`No Certificate found with id ${color_1.color.cyan(flags.id)}`, { exit: 0 });
|
|
38
41
|
}
|
|
39
|
-
else if (certById.status
|
|
40
|
-
|
|
41
|
-
cli_ux_1.cli.error('This certificate is not ready to download', { exit: 0 });
|
|
42
|
+
else if (certById.status === 'ready') {
|
|
43
|
+
baseCert = certById;
|
|
42
44
|
}
|
|
43
45
|
else {
|
|
44
|
-
|
|
46
|
+
cli_ux_1.cli.action.stop();
|
|
47
|
+
cli_ux_1.cli.error('This certificate is not ready to download', { exit: 0 });
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
else if (readyCerts.length === 0) {
|
|
@@ -65,23 +68,23 @@ class MTLSCertificateDownload extends base_1.default {
|
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
const { body: cert } = await this.shogun.get(`${addon.endpoint}/certificates/${baseCert.id}`, this.shogun.defaults);
|
|
68
|
-
const path = flags.dir || `${
|
|
69
|
-
!
|
|
71
|
+
const path = flags.dir || `${node_os_1.homedir}/.postgresql`;
|
|
72
|
+
!(0, node_fs_1.existsSync)(path) && (0, node_fs_1.mkdirSync)(path);
|
|
70
73
|
const key = `${path}/${flags.prefix}postgresql.key`;
|
|
71
74
|
const crt = `${path}/${flags.prefix}postgresql.crt`;
|
|
72
75
|
const root = `${path}/${flags.prefix}root.crt`;
|
|
73
76
|
let download = true;
|
|
74
|
-
if (
|
|
77
|
+
if ((0, node_fs_1.existsSync)(root) || (0, node_fs_1.existsSync)(key) || (0, node_fs_1.existsSync)(crt)) {
|
|
75
78
|
download = await cli_ux_1.cli.confirm('One of these files already exist. Would you like to overwrite them? (yes/no)');
|
|
76
79
|
}
|
|
77
80
|
if (download) {
|
|
78
81
|
await Promise.all([
|
|
79
|
-
write(root, mtls.certificate_authority_chain),
|
|
80
|
-
write(key, cert.private_key, { mode: '0600' }),
|
|
81
|
-
write(crt, cert.certificate_with_chain)
|
|
82
|
+
write(root, (_a = mtls === null || mtls === void 0 ? void 0 : mtls.certificate_authority_chain) !== null && _a !== void 0 ? _a : ''),
|
|
83
|
+
write(key, (_b = cert === null || cert === void 0 ? void 0 : cert.private_key) !== null && _b !== void 0 ? _b : '', { mode: '0600' }),
|
|
84
|
+
write(crt, (_c = cert === null || cert === void 0 ? void 0 : cert.certificate_with_chain) !== null && _c !== void 0 ? _c : '')
|
|
82
85
|
]);
|
|
83
86
|
cli_ux_1.cli.action.stop();
|
|
84
|
-
this.log(`your certs are now located in ${color_1.
|
|
87
|
+
this.log(`your certs are now located in ${color_1.color.cyan(path)}`);
|
|
85
88
|
}
|
|
86
89
|
else {
|
|
87
90
|
cli_ux_1.cli.action.stop();
|
|
@@ -89,28 +92,28 @@ class MTLSCertificateDownload extends base_1.default {
|
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
catch (err) {
|
|
92
|
-
if (err.http && err.http.statusCode === 404) {
|
|
95
|
+
if ((0, is_error_http_1.isErrorHttp)(err) && err.http && err.http.statusCode === 404) {
|
|
93
96
|
this.warn('mTLS is not setup yet for this addon');
|
|
94
97
|
}
|
|
95
|
-
else {
|
|
98
|
+
else if ((0, is_error_message_1.isErrorMessage)(err)) {
|
|
96
99
|
this.error(err.message);
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
|
-
|
|
104
|
+
exports.default = MTLSCertificateDownload;
|
|
102
105
|
MTLSCertificateDownload.args = [
|
|
103
106
|
{ name: 'addon' }
|
|
104
107
|
];
|
|
108
|
+
MTLSCertificateDownload.description = 'download your certificate bundle for your mTLS addon';
|
|
109
|
+
MTLSCertificateDownload.examples = [
|
|
110
|
+
'$ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f"',
|
|
111
|
+
'$ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f" --dir "./folder"',
|
|
112
|
+
'$ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f --prefix "prefix_"'
|
|
113
|
+
];
|
|
105
114
|
MTLSCertificateDownload.flags = {
|
|
106
115
|
app: command_1.flags.app({ required: true }),
|
|
107
116
|
dir: command_1.flags.string({ required: false, description: 'directory to download files to. defaults to HOME:/.postgresql' }),
|
|
108
117
|
id: command_1.flags.string({ required: false, description: 'ID of certificate to download' }),
|
|
109
118
|
prefix: command_1.flags.string({ required: true, description: 'prefix to put in front of downloaded file names', default: '' })
|
|
110
119
|
};
|
|
111
|
-
MTLSCertificateDownload.examples = [
|
|
112
|
-
'$ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f"',
|
|
113
|
-
'$ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f" --dir "./folder"',
|
|
114
|
-
'$ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f --prefix "prefix_"'
|
|
115
|
-
];
|
|
116
|
-
exports.default = MTLSCertificateDownload;
|
|
@@ -7,7 +7,7 @@ const fetcher_1 = require("../../../../lib/fetcher");
|
|
|
7
7
|
class MTLSCertificateGet extends base_1.default {
|
|
8
8
|
async run() {
|
|
9
9
|
const { args, flags } = this.parse(MTLSCertificateGet);
|
|
10
|
-
const addon = await fetcher_1.default(this.heroku, args.addon, flags.app);
|
|
10
|
+
const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
|
|
11
11
|
if (addon.kind === 'kafka') {
|
|
12
12
|
cli_ux_1.cli.error('Kafka certificates are availabe in your app\'s config vars');
|
|
13
13
|
}
|
|
@@ -17,15 +17,15 @@ class MTLSCertificateGet extends base_1.default {
|
|
|
17
17
|
cli_ux_1.cli.styledObject(res);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
exports.default = MTLSCertificateGet;
|
|
21
21
|
MTLSCertificateGet.args = [
|
|
22
22
|
{ name: 'addon' }
|
|
23
23
|
];
|
|
24
|
+
MTLSCertificateGet.description = 'get a specific certificate for your MTLS enabled addon';
|
|
25
|
+
MTLSCertificateGet.examples = [
|
|
26
|
+
'$ heroku data:mtls:certificates:create postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c"'
|
|
27
|
+
];
|
|
24
28
|
MTLSCertificateGet.flags = {
|
|
25
29
|
app: command_1.flags.app({ required: true }),
|
|
26
30
|
id: command_1.flags.string({ required: true, description: 'id of IP Rule' })
|
|
27
31
|
};
|
|
28
|
-
MTLSCertificateGet.examples = [
|
|
29
|
-
'$ heroku data:mtls:certificates:create postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c"'
|
|
30
|
-
];
|
|
31
|
-
exports.default = MTLSCertificateGet;
|
|
@@ -4,12 +4,14 @@ const command_1 = require("@heroku-cli/command");
|
|
|
4
4
|
const cli_ux_1 = require("cli-ux");
|
|
5
5
|
const base_1 = require("../../../../base");
|
|
6
6
|
const fetcher_1 = require("../../../../lib/fetcher");
|
|
7
|
+
const is_error_http_1 = require("../../../../utils/is-error-http");
|
|
8
|
+
const is_error_message_1 = require("../../../../utils/is-error-message");
|
|
7
9
|
const table_1 = require("../../../../utils/table");
|
|
8
10
|
class MTLSCertificatesIndex extends base_1.default {
|
|
9
11
|
async run() {
|
|
10
12
|
try {
|
|
11
13
|
const { args, flags } = this.parse(MTLSCertificatesIndex);
|
|
12
|
-
const addon = await fetcher_1.default(this.heroku, args.addon, flags.app);
|
|
14
|
+
const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
|
|
13
15
|
if (addon.kind === 'kafka') {
|
|
14
16
|
cli_ux_1.cli.error('Kafka certificates are availabe in your app\'s config vars');
|
|
15
17
|
}
|
|
@@ -18,11 +20,14 @@ class MTLSCertificatesIndex extends base_1.default {
|
|
|
18
20
|
cli_ux_1.cli.log('You currently have no certificates setup');
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
|
-
table_1.certificatesTable(res);
|
|
23
|
+
(0, table_1.certificatesTable)(res);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
catch (err) {
|
|
25
|
-
if (
|
|
27
|
+
if (!(0, is_error_message_1.isErrorMessage)(err)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if ((0, is_error_http_1.isErrorHttp)(err) && err.http && err.http.statusCode === 404) {
|
|
26
31
|
if (err.http.body.resource === 'add_on') {
|
|
27
32
|
this.error(err.message);
|
|
28
33
|
}
|
|
@@ -36,14 +41,14 @@ class MTLSCertificatesIndex extends base_1.default {
|
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
|
-
|
|
44
|
+
exports.default = MTLSCertificatesIndex;
|
|
40
45
|
MTLSCertificatesIndex.args = [
|
|
41
46
|
{ name: 'addon' }
|
|
42
47
|
];
|
|
43
|
-
MTLSCertificatesIndex.
|
|
44
|
-
app: command_1.flags.app({ required: true })
|
|
45
|
-
};
|
|
48
|
+
MTLSCertificatesIndex.description = 'get the certificates for your MTLS enabled addon';
|
|
46
49
|
MTLSCertificatesIndex.examples = [
|
|
47
50
|
'$ heroku data:mtls:ip-rules postgresql-sushi-12345',
|
|
48
51
|
];
|
|
49
|
-
|
|
52
|
+
MTLSCertificatesIndex.flags = {
|
|
53
|
+
app: command_1.flags.app({ required: true })
|
|
54
|
+
};
|
|
@@ -8,14 +8,14 @@ const fetcher_1 = require("../../../lib/fetcher");
|
|
|
8
8
|
class MTLSCreate extends base_1.default {
|
|
9
9
|
async run() {
|
|
10
10
|
const { args, flags } = this.parse(MTLSCreate);
|
|
11
|
-
const addon = await fetcher_1.default(this.heroku, args.addon, flags.app);
|
|
11
|
+
const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
|
|
12
12
|
if (addon.kind === 'kafka') {
|
|
13
13
|
cli_ux_1.cli.error('Kafka has mTLS enabled by default');
|
|
14
14
|
}
|
|
15
15
|
if (await cli_ux_1.cli.confirm('Enabling Mutual TLS will allow external access to this restricted data service. This action will be logged. Continue?')) {
|
|
16
|
-
cli_ux_1.cli.action.start(`Enabling MTLS on ${color_1.
|
|
16
|
+
cli_ux_1.cli.action.start(`Enabling MTLS on ${color_1.color.cyan(addon.name)}`);
|
|
17
17
|
try {
|
|
18
|
-
const { body: res } = await this.shogun.post(addon.endpoint, Object.assign({}, this.shogun.defaults, { body: {} }));
|
|
18
|
+
const { body: res } = await this.shogun.post(addon.endpoint, Object.assign(Object.assign({}, this.shogun.defaults), { body: {} }));
|
|
19
19
|
cli_ux_1.cli.styledObject(res);
|
|
20
20
|
cli_ux_1.cli.action.stop();
|
|
21
21
|
}
|
|
@@ -29,14 +29,14 @@ class MTLSCreate extends base_1.default {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
exports.default = MTLSCreate;
|
|
33
33
|
MTLSCreate.args = [
|
|
34
34
|
{ name: 'addon' },
|
|
35
35
|
];
|
|
36
|
-
MTLSCreate.
|
|
37
|
-
app: command_1.flags.app({ required: true })
|
|
38
|
-
};
|
|
36
|
+
MTLSCreate.description = 'enable MTLS for your addon';
|
|
39
37
|
MTLSCreate.examples = [
|
|
40
38
|
'$ heroku data:mtls:create postgresql-sushi-12345'
|
|
41
39
|
];
|
|
42
|
-
|
|
40
|
+
MTLSCreate.flags = {
|
|
41
|
+
app: command_1.flags.app({ required: true })
|
|
42
|
+
};
|
|
@@ -8,24 +8,24 @@ const fetcher_1 = require("../../../lib/fetcher");
|
|
|
8
8
|
class MTLSDestroy extends base_1.default {
|
|
9
9
|
async run() {
|
|
10
10
|
const { args, flags } = this.parse(MTLSDestroy);
|
|
11
|
-
const addon = await fetcher_1.default(this.heroku, args.addon, flags.app);
|
|
11
|
+
const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
|
|
12
12
|
if (addon.kind === 'kafka') {
|
|
13
13
|
cli_ux_1.cli.error('Kafka has mTLS enabled by default and you cannot disable it');
|
|
14
14
|
}
|
|
15
|
-
cli_ux_1.cli.action.start(`Disabling MTLS on ${color_1.
|
|
15
|
+
cli_ux_1.cli.action.start(`Disabling MTLS on ${color_1.color.cyan(addon.name)}`);
|
|
16
16
|
await this.shogun.delete(addon.endpoint, this.shogun.defaults);
|
|
17
17
|
cli_ux_1.cli.action.stop();
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
exports.default = MTLSDestroy;
|
|
21
21
|
MTLSDestroy.aliases = ['data:mtls:delete'];
|
|
22
22
|
MTLSDestroy.args = [
|
|
23
23
|
{ name: 'addon' },
|
|
24
24
|
];
|
|
25
|
-
MTLSDestroy.
|
|
26
|
-
app: command_1.flags.app({ required: true })
|
|
27
|
-
};
|
|
25
|
+
MTLSDestroy.description = 'destroy MTLS configuration on your addon';
|
|
28
26
|
MTLSDestroy.examples = [
|
|
29
27
|
'$ heroku data:mtls:destroy postgresql-sushi-12345'
|
|
30
28
|
];
|
|
31
|
-
|
|
29
|
+
MTLSDestroy.flags = {
|
|
30
|
+
app: command_1.flags.app({ required: true })
|
|
31
|
+
};
|
|
@@ -5,12 +5,14 @@ const command_1 = require("@heroku-cli/command");
|
|
|
5
5
|
const cli_ux_1 = require("cli-ux");
|
|
6
6
|
const base_1 = require("../../../base");
|
|
7
7
|
const fetcher_1 = require("../../../lib/fetcher");
|
|
8
|
+
const is_error_http_1 = require("../../../utils/is-error-http");
|
|
9
|
+
const is_error_message_1 = require("../../../utils/is-error-message");
|
|
8
10
|
const table_1 = require("../../../utils/table");
|
|
9
11
|
class MTLSIndex extends base_1.default {
|
|
10
12
|
async run() {
|
|
11
13
|
try {
|
|
12
14
|
const { args, flags } = this.parse(MTLSIndex);
|
|
13
|
-
const addon = await fetcher_1.default(this.heroku, args.addon, flags.app);
|
|
15
|
+
const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
|
|
14
16
|
if (addon.kind === 'kafka') {
|
|
15
17
|
const { body: ipRules } = await this.shogun.get(`${addon.endpoint}/ip-rules`, this.shogun.defaults);
|
|
16
18
|
cli_ux_1.cli.styledObject({
|
|
@@ -21,7 +23,7 @@ class MTLSIndex extends base_1.default {
|
|
|
21
23
|
this.log();
|
|
22
24
|
this.log(color_1.color.underline('IP Rules'));
|
|
23
25
|
this.log();
|
|
24
|
-
table_1.ipRulesTable(ipRules);
|
|
26
|
+
(0, table_1.ipRulesTable)(ipRules);
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
else {
|
|
@@ -40,18 +42,21 @@ class MTLSIndex extends base_1.default {
|
|
|
40
42
|
this.log();
|
|
41
43
|
this.log(color_1.color.underline('Certificates'));
|
|
42
44
|
this.log();
|
|
43
|
-
table_1.certificatesTable(certs);
|
|
45
|
+
(0, table_1.certificatesTable)(certs);
|
|
44
46
|
}
|
|
45
47
|
if (ipRules.length > 0) {
|
|
46
48
|
this.log();
|
|
47
49
|
this.log(color_1.color.underline('IP Rules'));
|
|
48
50
|
this.log();
|
|
49
|
-
table_1.ipRulesTable(ipRules);
|
|
51
|
+
(0, table_1.ipRulesTable)(ipRules);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
catch (err) {
|
|
54
|
-
if (
|
|
56
|
+
if (!(0, is_error_message_1.isErrorMessage)(err)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if ((0, is_error_http_1.isErrorHttp)(err) && err.http && err.http.statusCode === 404) {
|
|
55
60
|
if (err.http.body.resource === 'add_on') {
|
|
56
61
|
this.error(err.message);
|
|
57
62
|
}
|
|
@@ -65,14 +70,14 @@ class MTLSIndex extends base_1.default {
|
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
|
-
|
|
73
|
+
exports.default = MTLSIndex;
|
|
69
74
|
MTLSIndex.args = [
|
|
70
75
|
{ name: 'addon' }
|
|
71
76
|
];
|
|
72
|
-
MTLSIndex.
|
|
73
|
-
app: command_1.flags.app({ required: true })
|
|
74
|
-
};
|
|
77
|
+
MTLSIndex.description = 'get the status of MTLS for your addon';
|
|
75
78
|
MTLSIndex.examples = [
|
|
76
79
|
'$ heroku data:mtls postgresql-sushi-12345',
|
|
77
80
|
];
|
|
78
|
-
|
|
81
|
+
MTLSIndex.flags = {
|
|
82
|
+
app: command_1.flags.app({ required: true })
|
|
83
|
+
};
|
|
@@ -8,9 +8,9 @@ const fetcher_1 = require("../../../../lib/fetcher");
|
|
|
8
8
|
class MTLSIPCreate extends base_1.default {
|
|
9
9
|
async run() {
|
|
10
10
|
const { args, flags } = this.parse(MTLSIPCreate);
|
|
11
|
-
const addon = await fetcher_1.default(this.heroku, args.addon, flags.app);
|
|
12
|
-
cli_ux_1.cli.action.start(`Creating IP Rule for ${color_1.
|
|
13
|
-
const { body: res } = await this.shogun.post(`${addon.endpoint}/ip-rules`, Object.assign({}, this.shogun.defaults, { body: {
|
|
11
|
+
const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
|
|
12
|
+
cli_ux_1.cli.action.start(`Creating IP Rule for ${color_1.color.cyan(addon.name)}`);
|
|
13
|
+
const { body: res } = await this.shogun.post(`${addon.endpoint}/ip-rules`, Object.assign(Object.assign({}, this.shogun.defaults), { body: {
|
|
14
14
|
cidr: flags.cidr,
|
|
15
15
|
description: flags.description
|
|
16
16
|
} }));
|
|
@@ -18,16 +18,16 @@ class MTLSIPCreate extends base_1.default {
|
|
|
18
18
|
cli_ux_1.cli.styledObject(res);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
exports.default = MTLSIPCreate;
|
|
22
22
|
MTLSIPCreate.args = [
|
|
23
23
|
{ name: 'addon' }
|
|
24
24
|
];
|
|
25
|
+
MTLSIPCreate.description = 'create an IP Rule for your MTLS enabled addon';
|
|
26
|
+
MTLSIPCreate.examples = [
|
|
27
|
+
'$ heroku data:mtls:ip-rules:create postgresql-sushi-12345 --cidr "1.2.3.4/32" --description "home IP address"'
|
|
28
|
+
];
|
|
25
29
|
MTLSIPCreate.flags = {
|
|
26
30
|
app: command_1.flags.app({ required: true }),
|
|
27
31
|
cidr: command_1.flags.string({ required: true }),
|
|
28
32
|
description: command_1.flags.string({ required: false })
|
|
29
33
|
};
|
|
30
|
-
MTLSIPCreate.examples = [
|
|
31
|
-
'$ heroku data:mtls:ip-rules:create postgresql-sushi-12345 --cidr "1.2.3.4/32" --description "home IP address"'
|
|
32
|
-
];
|
|
33
|
-
exports.default = MTLSIPCreate;
|