@heroku-cli/plugin-mtls 0.9.2 → 1.0.0-beta.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.
Files changed (69) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +207 -110
  3. package/dist/README.md +347 -0
  4. package/{lib → dist}/base.d.ts +2 -2
  5. package/{lib → dist}/base.js +5 -1
  6. package/dist/commands/data/mtls/certificates/create.d.ts +12 -0
  7. package/dist/commands/data/mtls/certificates/create.js +32 -0
  8. package/dist/commands/data/mtls/certificates/delete.d.ts +13 -0
  9. package/dist/commands/data/mtls/certificates/delete.js +32 -0
  10. package/dist/commands/data/mtls/certificates/download.d.ts +15 -0
  11. package/{lib → dist}/commands/data/mtls/certificates/download.js +41 -40
  12. package/dist/commands/data/mtls/certificates/get.d.ts +13 -0
  13. package/dist/commands/data/mtls/certificates/get.js +32 -0
  14. package/dist/commands/data/mtls/certificates/index.d.ts +12 -0
  15. package/{lib → dist}/commands/data/mtls/certificates/index.js +17 -16
  16. package/dist/commands/data/mtls/create.d.ts +12 -0
  17. package/dist/commands/data/mtls/create.js +43 -0
  18. package/dist/commands/data/mtls/destroy.d.ts +13 -0
  19. package/dist/commands/data/mtls/destroy.js +32 -0
  20. package/dist/commands/data/mtls/index.d.ts +12 -0
  21. package/{lib → dist}/commands/data/mtls/index.js +17 -16
  22. package/dist/commands/data/mtls/ip-rules/create.d.ts +14 -0
  23. package/dist/commands/data/mtls/ip-rules/create.js +37 -0
  24. package/dist/commands/data/mtls/ip-rules/delete.d.ts +14 -0
  25. package/dist/commands/data/mtls/ip-rules/delete.js +49 -0
  26. package/dist/commands/data/mtls/ip-rules/get.d.ts +13 -0
  27. package/dist/commands/data/mtls/ip-rules/get.js +27 -0
  28. package/dist/commands/data/mtls/ip-rules/index.d.ts +12 -0
  29. package/dist/commands/data/mtls/ip-rules/index.js +32 -0
  30. package/{lib → dist}/lib/fetcher.js +6 -6
  31. package/dist/oclif.manifest.json +575 -0
  32. package/dist/tsconfig.tsbuildinfo +1 -0
  33. package/dist/utils/file-helper.d.ts +4 -0
  34. package/dist/utils/file-helper.js +11 -0
  35. package/{lib → dist}/utils/is-error-http.js +1 -2
  36. package/{lib → dist}/utils/is-error-message.js +1 -2
  37. package/dist/utils/table.js +42 -0
  38. package/package.json +20 -19
  39. package/lib/README.md +0 -250
  40. package/lib/commands/data/mtls/certificates/create.d.ts +0 -13
  41. package/lib/commands/data/mtls/certificates/create.js +0 -31
  42. package/lib/commands/data/mtls/certificates/delete.d.ts +0 -14
  43. package/lib/commands/data/mtls/certificates/delete.js +0 -31
  44. package/lib/commands/data/mtls/certificates/download.d.ts +0 -16
  45. package/lib/commands/data/mtls/certificates/get.d.ts +0 -14
  46. package/lib/commands/data/mtls/certificates/get.js +0 -31
  47. package/lib/commands/data/mtls/certificates/index.d.ts +0 -13
  48. package/lib/commands/data/mtls/create.d.ts +0 -13
  49. package/lib/commands/data/mtls/create.js +0 -42
  50. package/lib/commands/data/mtls/destroy.d.ts +0 -14
  51. package/lib/commands/data/mtls/destroy.js +0 -31
  52. package/lib/commands/data/mtls/index.d.ts +0 -13
  53. package/lib/commands/data/mtls/ip-rules/create.d.ts +0 -15
  54. package/lib/commands/data/mtls/ip-rules/create.js +0 -33
  55. package/lib/commands/data/mtls/ip-rules/delete.d.ts +0 -15
  56. package/lib/commands/data/mtls/ip-rules/delete.js +0 -48
  57. package/lib/commands/data/mtls/ip-rules/get.d.ts +0 -14
  58. package/lib/commands/data/mtls/ip-rules/get.js +0 -26
  59. package/lib/commands/data/mtls/ip-rules/index.d.ts +0 -13
  60. package/lib/commands/data/mtls/ip-rules/index.js +0 -31
  61. package/lib/oclif.manifest.json +0 -1
  62. package/lib/package.json +0 -34
  63. package/lib/utils/table.js +0 -18
  64. /package/{lib → dist}/index.d.ts +0 -0
  65. /package/{lib → dist}/index.js +0 -0
  66. /package/{lib → dist}/lib/fetcher.d.ts +0 -0
  67. /package/{lib → dist}/utils/is-error-http.d.ts +0 -0
  68. /package/{lib → dist}/utils/is-error-message.d.ts +0 -0
  69. /package/{lib → dist}/utils/table.d.ts +0 -0
package/dist/README.md ADDED
@@ -0,0 +1,347 @@
1
+ # Heroku CLI MTLS Plugin
2
+
3
+ [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
4
+ ![GitHub Actions CI](https://github.com/heroku/heroku-mtls-cli/actions/workflows/ci.yml/badge.svg)
5
+
6
+ <!-- toc -->
7
+ * [Heroku CLI MTLS Plugin](#heroku-cli-mtls-plugin)
8
+ * [Installation](#installation)
9
+ * [Commands](#commands)
10
+ <!-- tocstop -->
11
+ # Installation
12
+ ```sh-session
13
+ $ heroku plugins:install @heroku-cli/plugin-mtls
14
+ ```
15
+ # Commands
16
+ <!-- commands -->
17
+ * [`heroku data:mtls ADDON`](#heroku-datamtls-addon)
18
+ * [`heroku data:mtls:certificates ADDON`](#heroku-datamtlscertificates-addon)
19
+ * [`heroku data:mtls:certificates:create ADDON`](#heroku-datamtlscertificatescreate-addon)
20
+ * [`heroku data:mtls:certificates:delete ADDON`](#heroku-datamtlscertificatesdelete-addon)
21
+ * [`heroku data:mtls:certificates:download ADDON`](#heroku-datamtlscertificatesdownload-addon)
22
+ * [`heroku data:mtls:certificates:get ADDON`](#heroku-datamtlscertificatesget-addon)
23
+ * [`heroku data:mtls:create ADDON`](#heroku-datamtlscreate-addon)
24
+ * [`heroku data:mtls:delete ADDON`](#heroku-datamtlsdelete-addon)
25
+ * [`heroku data:mtls:destroy ADDON`](#heroku-datamtlsdestroy-addon)
26
+ * [`heroku data:mtls:ip-rules ADDON`](#heroku-datamtlsip-rules-addon)
27
+ * [`heroku data:mtls:ip-rules:create ADDON`](#heroku-datamtlsip-rulescreate-addon)
28
+ * [`heroku data:mtls:ip-rules:delete ADDON`](#heroku-datamtlsip-rulesdelete-addon)
29
+ * [`heroku data:mtls:ip-rules:get ADDON`](#heroku-datamtlsip-rulesget-addon)
30
+
31
+ ## `heroku data:mtls ADDON`
32
+
33
+ get the status of MTLS for your addon
34
+
35
+ ```
36
+ USAGE
37
+ $ heroku data:mtls ADDON -a <value>
38
+
39
+ ARGUMENTS
40
+ ADDON addon
41
+
42
+ FLAGS
43
+ -a, --app=<value> (required) app to run command against
44
+
45
+ DESCRIPTION
46
+ get the status of MTLS for your addon
47
+
48
+ EXAMPLES
49
+ $ heroku data:mtls postgresql-sushi-12345 -a example-app
50
+ ```
51
+
52
+ _See code: [src/commands/data/mtls/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/index.ts)_
53
+
54
+ ## `heroku data:mtls:certificates ADDON`
55
+
56
+ get the certificates for your MTLS enabled addon
57
+
58
+ ```
59
+ USAGE
60
+ $ heroku data:mtls:certificates ADDON -a <value>
61
+
62
+ ARGUMENTS
63
+ ADDON addon
64
+
65
+ FLAGS
66
+ -a, --app=<value> (required) app to run command against
67
+
68
+ DESCRIPTION
69
+ get the certificates for your MTLS enabled addon
70
+
71
+ EXAMPLES
72
+ $ heroku data:mtls:certificates postgresql-sushi-12345 -a example-app
73
+ ```
74
+
75
+ _See code: [src/commands/data/mtls/certificates/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/certificates/index.ts)_
76
+
77
+ ## `heroku data:mtls:certificates:create ADDON`
78
+
79
+ create a new certificate for your MTLS enabled addon
80
+
81
+ ```
82
+ USAGE
83
+ $ heroku data:mtls:certificates:create ADDON -a <value>
84
+
85
+ ARGUMENTS
86
+ ADDON addon
87
+
88
+ FLAGS
89
+ -a, --app=<value> (required) app to run command against
90
+
91
+ DESCRIPTION
92
+ create a new certificate for your MTLS enabled addon
93
+
94
+ EXAMPLES
95
+ $ heroku data:mtls:certificates:create postgresql-sushi-12345 -a example-app
96
+ ```
97
+
98
+ _See code: [src/commands/data/mtls/certificates/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/certificates/create.ts)_
99
+
100
+ ## `heroku data:mtls:certificates:delete ADDON`
101
+
102
+ delete a specific certificate for your MTLS enabled addon
103
+
104
+ ```
105
+ USAGE
106
+ $ heroku data:mtls:certificates:delete ADDON -a <value> --id <value>
107
+
108
+ ARGUMENTS
109
+ ADDON addon
110
+
111
+ FLAGS
112
+ -a, --app=<value> (required) app to run command against
113
+ --id=<value> (required) id of certificate
114
+
115
+ DESCRIPTION
116
+ delete a specific certificate for your MTLS enabled addon
117
+
118
+ EXAMPLES
119
+ $ heroku data:mtls:certificates:delete postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c" -a example-app
120
+ ```
121
+
122
+ _See code: [src/commands/data/mtls/certificates/delete.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/certificates/delete.ts)_
123
+
124
+ ## `heroku data:mtls:certificates:download ADDON`
125
+
126
+ download your certificate bundle for your mTLS addon
127
+
128
+ ```
129
+ USAGE
130
+ $ heroku data:mtls:certificates:download ADDON -a <value> --prefix <value> [--dir <value>] [--id <value>]
131
+
132
+ ARGUMENTS
133
+ ADDON addon
134
+
135
+ FLAGS
136
+ -a, --app=<value> (required) app to run command against
137
+ --dir=<value> directory to download files to. defaults to HOME:/.postgresql
138
+ --id=<value> ID of certificate to download
139
+ --prefix=<value> (required) prefix to put in front of downloaded file names
140
+
141
+ DESCRIPTION
142
+ download your certificate bundle for your mTLS addon
143
+
144
+ EXAMPLES
145
+ $ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f" -a example-app
146
+
147
+ $ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f" --dir "./folder" -a example-app
148
+
149
+ $ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f --prefix "prefix_" -a example-app
150
+ ```
151
+
152
+ _See code: [src/commands/data/mtls/certificates/download.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/certificates/download.ts)_
153
+
154
+ ## `heroku data:mtls:certificates:get ADDON`
155
+
156
+ get a specific certificate for your MTLS enabled addon
157
+
158
+ ```
159
+ USAGE
160
+ $ heroku data:mtls:certificates:get ADDON -a <value> --id <value>
161
+
162
+ ARGUMENTS
163
+ ADDON addon
164
+
165
+ FLAGS
166
+ -a, --app=<value> (required) app to run command against
167
+ --id=<value> (required) id of IP Rule
168
+
169
+ DESCRIPTION
170
+ get a specific certificate for your MTLS enabled addon
171
+
172
+ EXAMPLES
173
+ $ heroku data:mtls:certificates:get postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c" -a example-app
174
+ ```
175
+
176
+ _See code: [src/commands/data/mtls/certificates/get.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/certificates/get.ts)_
177
+
178
+ ## `heroku data:mtls:create ADDON`
179
+
180
+ enable MTLS for your addon
181
+
182
+ ```
183
+ USAGE
184
+ $ heroku data:mtls:create ADDON -a <value>
185
+
186
+ ARGUMENTS
187
+ ADDON addon
188
+
189
+ FLAGS
190
+ -a, --app=<value> (required) app to run command against
191
+
192
+ DESCRIPTION
193
+ enable MTLS for your addon
194
+
195
+ EXAMPLES
196
+ $ heroku data:mtls:create postgresql-sushi-12345 -a example-app
197
+ ```
198
+
199
+ _See code: [src/commands/data/mtls/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/create.ts)_
200
+
201
+ ## `heroku data:mtls:delete ADDON`
202
+
203
+ destroy MTLS configuration on your addon
204
+
205
+ ```
206
+ USAGE
207
+ $ heroku data:mtls:delete ADDON -a <value>
208
+
209
+ ARGUMENTS
210
+ ADDON addon
211
+
212
+ FLAGS
213
+ -a, --app=<value> (required) app to run command against
214
+
215
+ DESCRIPTION
216
+ destroy MTLS configuration on your addon
217
+
218
+ ALIASES
219
+ $ heroku data:mtls:delete
220
+
221
+ EXAMPLES
222
+ $ heroku data:mtls:destroy postgresql-sushi-12345 -a example-app
223
+ ```
224
+
225
+ ## `heroku data:mtls:destroy ADDON`
226
+
227
+ destroy MTLS configuration on your addon
228
+
229
+ ```
230
+ USAGE
231
+ $ heroku data:mtls:destroy ADDON -a <value>
232
+
233
+ ARGUMENTS
234
+ ADDON addon
235
+
236
+ FLAGS
237
+ -a, --app=<value> (required) app to run command against
238
+
239
+ DESCRIPTION
240
+ destroy MTLS configuration on your addon
241
+
242
+ ALIASES
243
+ $ heroku data:mtls:delete
244
+
245
+ EXAMPLES
246
+ $ heroku data:mtls:destroy postgresql-sushi-12345 -a example-app
247
+ ```
248
+
249
+ _See code: [src/commands/data/mtls/destroy.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/destroy.ts)_
250
+
251
+ ## `heroku data:mtls:ip-rules ADDON`
252
+
253
+ get the IP Rules for your MTLS enabled addon
254
+
255
+ ```
256
+ USAGE
257
+ $ heroku data:mtls:ip-rules ADDON -a <value>
258
+
259
+ ARGUMENTS
260
+ ADDON addon
261
+
262
+ FLAGS
263
+ -a, --app=<value> (required) app to run command against
264
+
265
+ DESCRIPTION
266
+ get the IP Rules for your MTLS enabled addon
267
+
268
+ EXAMPLES
269
+ $ heroku data:mtls:ip-rules postgresql-sushi-12345 -a example-app
270
+ ```
271
+
272
+ _See code: [src/commands/data/mtls/ip-rules/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/ip-rules/index.ts)_
273
+
274
+ ## `heroku data:mtls:ip-rules:create ADDON`
275
+
276
+ create an IP Rule for your MTLS enabled addon
277
+
278
+ ```
279
+ USAGE
280
+ $ heroku data:mtls:ip-rules:create ADDON -a <value> --cidr <value> [--description <value>]
281
+
282
+ ARGUMENTS
283
+ ADDON addon
284
+
285
+ FLAGS
286
+ -a, --app=<value> (required) app to run command against
287
+ --cidr=<value> (required)
288
+ --description=<value>
289
+
290
+ DESCRIPTION
291
+ create an IP Rule for your MTLS enabled addon
292
+
293
+ EXAMPLES
294
+ $ heroku data:mtls:ip-rules:create postgresql-sushi-12345 --cidr "1.2.3.4/32" --description "home IP address" -a example-app
295
+ ```
296
+
297
+ _See code: [src/commands/data/mtls/ip-rules/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/ip-rules/create.ts)_
298
+
299
+ ## `heroku data:mtls:ip-rules:delete ADDON`
300
+
301
+ delete a specific IP Rule for your MTLS enabled addon
302
+
303
+ ```
304
+ USAGE
305
+ $ heroku data:mtls:ip-rules:delete ADDON -a <value> [--cidr <value>] [--id <value>]
306
+
307
+ ARGUMENTS
308
+ ADDON addon
309
+
310
+ FLAGS
311
+ -a, --app=<value> (required) app to run command against
312
+ --cidr=<value> cidr of IP Rule
313
+ --id=<value> id of IP Rule
314
+
315
+ DESCRIPTION
316
+ delete a specific IP Rule for your MTLS enabled addon
317
+
318
+ EXAMPLES
319
+ $ heroku data:mtls:ip-rules:delete postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c" -a example-app
320
+ ```
321
+
322
+ _See code: [src/commands/data/mtls/ip-rules/delete.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/ip-rules/delete.ts)_
323
+
324
+ ## `heroku data:mtls:ip-rules:get ADDON`
325
+
326
+ get a specific IP Rule for your MTLS enabled addon
327
+
328
+ ```
329
+ USAGE
330
+ $ heroku data:mtls:ip-rules:get ADDON -a <value> --id <value>
331
+
332
+ ARGUMENTS
333
+ ADDON addon
334
+
335
+ FLAGS
336
+ -a, --app=<value> (required) app to run command against
337
+ --id=<value> (required) id of IP Rule
338
+
339
+ DESCRIPTION
340
+ get a specific IP Rule for your MTLS enabled addon
341
+
342
+ EXAMPLES
343
+ $ heroku data:mtls:ip-rules:get postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c" -a example-app
344
+ ```
345
+
346
+ _See code: [src/commands/data/mtls/ip-rules/get.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v1.0.0-beta.0/src/commands/data/mtls/ip-rules/get.ts)_
347
+ <!-- commandsstop -->
@@ -1,8 +1,8 @@
1
- import type { IConfig } from '@oclif/config';
2
1
  import { APIClient, Command } from '@heroku-cli/command';
2
+ import { Config } from '@oclif/core';
3
3
  export default abstract class extends Command {
4
4
  shogun: APIClient;
5
- protected constructor(argv: string[], config: IConfig);
5
+ protected constructor(argv: string[], config: Config);
6
6
  }
7
7
  export interface MTLSStatus {
8
8
  addon: string;
@@ -2,11 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@heroku-cli/command");
4
4
  class default_1 extends command_1.Command {
5
+ shogun;
5
6
  constructor(argv, config) {
6
7
  super(argv, config);
7
8
  const client = new command_1.APIClient(this.config, {});
8
9
  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
+ client.defaults.headers = {
11
+ ...this.heroku.defaults.headers,
12
+ authorization: `Basic ${Buffer.from(':' + this.heroku.auth).toString('base64')}`
13
+ };
10
14
  this.shogun = client;
11
15
  }
12
16
  }
@@ -0,0 +1,12 @@
1
+ import Command from '../../../../base';
2
+ export default class MTLSCertificateCreate extends Command {
3
+ static args: {
4
+ addon: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const color_1 = require("@heroku-cli/color");
5
+ const command_1 = require("@heroku-cli/command");
6
+ const core_1 = require("@oclif/core");
7
+ const base_1 = tslib_1.__importDefault(require("../../../../base"));
8
+ const fetcher_1 = tslib_1.__importDefault(require("../../../../lib/fetcher"));
9
+ class MTLSCertificateCreate extends base_1.default {
10
+ static args = {
11
+ addon: core_1.Args.string({ required: true, description: 'addon' })
12
+ };
13
+ static description = 'create a new certificate for your MTLS enabled addon';
14
+ static examples = [
15
+ '$ heroku data:mtls:certificates:create postgresql-sushi-12345 -a example-app'
16
+ ];
17
+ static flags = {
18
+ app: command_1.flags.app({ required: true })
19
+ };
20
+ async run() {
21
+ const { args, flags } = await this.parse(MTLSCertificateCreate);
22
+ const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
23
+ if (addon.kind === 'kafka') {
24
+ core_1.ux.error('Kafka certificates are availabe in your app\'s config vars');
25
+ }
26
+ core_1.ux.action.start(`Creating new certificate for ${color_1.color.cyan(addon.name)}`);
27
+ const { body: res } = await this.shogun.post(`${addon.endpoint}/certificates`, this.shogun.defaults);
28
+ core_1.ux.action.stop();
29
+ core_1.ux.styledObject(res);
30
+ }
31
+ }
32
+ exports.default = MTLSCertificateCreate;
@@ -0,0 +1,13 @@
1
+ import Command from '../../../../base';
2
+ export default class MTLSCertificateDelete extends Command {
3
+ static args: {
4
+ addon: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ id: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const color_1 = require("@heroku-cli/color");
5
+ const command_1 = require("@heroku-cli/command");
6
+ const core_1 = require("@oclif/core");
7
+ const base_1 = tslib_1.__importDefault(require("../../../../base"));
8
+ const fetcher_1 = tslib_1.__importDefault(require("../../../../lib/fetcher"));
9
+ class MTLSCertificateDelete extends base_1.default {
10
+ static args = {
11
+ addon: core_1.Args.string({ required: true, description: 'addon' })
12
+ };
13
+ static description = 'delete a specific certificate for your MTLS enabled addon';
14
+ static examples = [
15
+ '$ heroku data:mtls:certificates:delete postgresql-sushi-12345 --id "1862ec85-fdc1-47b3-924e-a91d26ca3a7c" -a example-app'
16
+ ];
17
+ static flags = {
18
+ app: command_1.flags.app({ required: true }),
19
+ id: command_1.flags.string({ required: true, description: 'id of certificate' })
20
+ };
21
+ async run() {
22
+ const { args, flags } = await this.parse(MTLSCertificateDelete);
23
+ const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
24
+ if (addon.kind === 'kafka') {
25
+ core_1.ux.error('Kafka certificates are availabe in your app\'s config vars');
26
+ }
27
+ core_1.ux.action.start(`Deleting certificate for ${color_1.color.cyan(addon.name)}`);
28
+ await this.shogun.delete(`${addon.endpoint}/certificates/${flags.id}`, this.shogun.defaults);
29
+ core_1.ux.action.stop();
30
+ }
31
+ }
32
+ exports.default = MTLSCertificateDelete;
@@ -0,0 +1,15 @@
1
+ import Command from '../../../../base';
2
+ export default class MTLSCertificateDownload extends Command {
3
+ static args: {
4
+ addon: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ dir: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
+ prefix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ };
14
+ run(): Promise<void>;
15
+ }
@@ -1,32 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /* eslint-disable complexity */
3
5
  const color_1 = require("@heroku-cli/color");
4
6
  const command_1 = require("@heroku-cli/command");
5
- const cli_ux_1 = require("cli-ux");
6
- const inquirer = require("inquirer");
7
- const node_fs_1 = require("node:fs");
7
+ const core_1 = require("@oclif/core");
8
+ const inquirer = tslib_1.__importStar(require("inquirer"));
8
9
  const node_os_1 = require("node:os");
9
- const base_1 = require("../../../../base");
10
- const fetcher_1 = require("../../../../lib/fetcher");
10
+ const base_1 = tslib_1.__importDefault(require("../../../../base"));
11
+ const fetcher_1 = tslib_1.__importDefault(require("../../../../lib/fetcher"));
12
+ const file_helper_1 = require("../../../../utils/file-helper");
11
13
  const is_error_http_1 = require("../../../../utils/is-error-http");
12
14
  const is_error_message_1 = require("../../../../utils/is-error-message");
13
15
  const write = (path, data, options = null) => new Promise((resolve, reject) => {
14
- (0, node_fs_1.writeFile)(path, data, options, err => {
16
+ (0, file_helper_1.writeFile)(path, data, options, (err) => {
15
17
  if (err)
16
18
  reject(err);
17
19
  resolve();
18
20
  });
19
21
  });
20
22
  class MTLSCertificateDownload extends base_1.default {
23
+ static args = {
24
+ addon: core_1.Args.string({ required: true, description: 'addon' })
25
+ };
26
+ static description = 'download your certificate bundle for your mTLS addon';
27
+ static examples = [
28
+ '$ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f" -a example-app',
29
+ '$ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f" --dir "./folder" -a example-app',
30
+ '$ heroku data:mtls:certificates:download postgresql-sushi-12345 --id "3559a4df-2c82-4473-86cf-181310a6ef4f --prefix "prefix_" -a example-app'
31
+ ];
32
+ static flags = {
33
+ app: command_1.flags.app({ required: true }),
34
+ dir: command_1.flags.string({ required: false, description: 'directory to download files to. defaults to HOME:/.postgresql' }),
35
+ id: command_1.flags.string({ required: false, description: 'ID of certificate to download' }),
36
+ prefix: command_1.flags.string({ required: true, description: 'prefix to put in front of downloaded file names', default: '' })
37
+ };
21
38
  async run() {
22
- var _a, _b, _c;
23
39
  try {
24
- const { args, flags } = this.parse(MTLSCertificateDownload);
40
+ const { args, flags } = await this.parse(MTLSCertificateDownload);
25
41
  const addon = await (0, fetcher_1.default)(this.heroku, args.addon, flags.app);
26
42
  if (addon.kind === 'kafka') {
27
- cli_ux_1.cli.error('Kafka certificates are availabe in your app\'s config vars');
43
+ core_1.ux.error('Kafka certificates are availabe in your app\'s config vars');
28
44
  }
29
- cli_ux_1.cli.action.start(`Downloading certificates for ${color_1.color.cyan(addon.name)}`);
45
+ core_1.ux.action.start(`Downloading certificates for ${color_1.color.cyan(addon.name)}`);
30
46
  const [{ body: mtls }, { body: certs }] = await Promise.all([
31
47
  this.shogun.get(addon.endpoint, this.shogun.defaults),
32
48
  this.shogun.get(`${addon.endpoint}/certificates`, this.shogun.defaults)
@@ -36,23 +52,23 @@ class MTLSCertificateDownload extends base_1.default {
36
52
  if (flags.id) {
37
53
  const certById = certs.find(cert => cert.id === flags.id);
38
54
  if (!certById) {
39
- cli_ux_1.cli.action.stop();
40
- cli_ux_1.cli.error(`No Certificate found with id ${color_1.color.cyan(flags.id)}`, { exit: 0 });
55
+ core_1.ux.action.stop();
56
+ core_1.ux.error(`No Certificate found with id ${color_1.color.cyan(flags.id)}`, { exit: 0 });
41
57
  }
42
58
  else if (certById.status === 'ready') {
43
59
  baseCert = certById;
44
60
  }
45
61
  else {
46
- cli_ux_1.cli.action.stop();
47
- cli_ux_1.cli.error('This certificate is not ready to download', { exit: 0 });
62
+ core_1.ux.action.stop();
63
+ core_1.ux.error('This certificate is not ready to download', { exit: 0 });
48
64
  }
49
65
  }
50
66
  else if (readyCerts.length === 0) {
51
- cli_ux_1.cli.action.stop();
52
- cli_ux_1.cli.error('There are no certificates to download', { exit: 0 });
67
+ core_1.ux.action.stop();
68
+ core_1.ux.error('There are no certificates to download', { exit: 0 });
53
69
  }
54
70
  else if (readyCerts.length > 1) {
55
- await cli_ux_1.cli.action.pauseAsync(async () => {
71
+ await core_1.ux.action.pauseAsync(async () => {
56
72
  const answers = await inquirer.prompt([
57
73
  {
58
74
  choices: readyCerts.map(cert => ({
@@ -69,25 +85,25 @@ class MTLSCertificateDownload extends base_1.default {
69
85
  }
70
86
  const { body: cert } = await this.shogun.get(`${addon.endpoint}/certificates/${baseCert.id}`, this.shogun.defaults);
71
87
  const path = flags.dir || `${node_os_1.homedir}/.postgresql`;
72
- !(0, node_fs_1.existsSync)(path) && (0, node_fs_1.mkdirSync)(path);
88
+ !(0, file_helper_1.existsSync)(path) && (0, file_helper_1.mkdirSync)(path);
73
89
  const key = `${path}/${flags.prefix}postgresql.key`;
74
90
  const crt = `${path}/${flags.prefix}postgresql.crt`;
75
91
  const root = `${path}/${flags.prefix}root.crt`;
76
92
  let download = true;
77
- if ((0, node_fs_1.existsSync)(root) || (0, node_fs_1.existsSync)(key) || (0, node_fs_1.existsSync)(crt)) {
78
- download = await cli_ux_1.cli.confirm('One of these files already exist. Would you like to overwrite them? (yes/no)');
93
+ if ((0, file_helper_1.existsSync)(root) || (0, file_helper_1.existsSync)(key) || (0, file_helper_1.existsSync)(crt)) {
94
+ download = await core_1.ux.confirm('One of these files already exist. Would you like to overwrite them? (yes/no)');
79
95
  }
80
96
  if (download) {
81
97
  await Promise.all([
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 : '')
98
+ write(root, mtls?.certificate_authority_chain ?? ''),
99
+ write(key, cert?.private_key ?? '', { mode: '0600' }),
100
+ write(crt, cert?.certificate_with_chain ?? '')
85
101
  ]);
86
- cli_ux_1.cli.action.stop();
102
+ core_1.ux.action.stop();
87
103
  this.log(`your certs are now located in ${color_1.color.cyan(path)}`);
88
104
  }
89
105
  else {
90
- cli_ux_1.cli.action.stop();
106
+ core_1.ux.action.stop();
91
107
  this.log('you did not download the certs');
92
108
  }
93
109
  }
@@ -102,18 +118,3 @@ class MTLSCertificateDownload extends base_1.default {
102
118
  }
103
119
  }
104
120
  exports.default = MTLSCertificateDownload;
105
- MTLSCertificateDownload.args = [
106
- { name: 'addon' }
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
- ];
114
- MTLSCertificateDownload.flags = {
115
- app: command_1.flags.app({ required: true }),
116
- dir: command_1.flags.string({ required: false, description: 'directory to download files to. defaults to HOME:/.postgresql' }),
117
- id: command_1.flags.string({ required: false, description: 'ID of certificate to download' }),
118
- prefix: command_1.flags.string({ required: true, description: 'prefix to put in front of downloaded file names', default: '' })
119
- };
@@ -0,0 +1,13 @@
1
+ import Command from '../../../../base';
2
+ export default class MTLSCertificateGet extends Command {
3
+ static args: {
4
+ addon: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ id: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ };
12
+ run(): Promise<void>;
13
+ }