@heroku-cli/plugin-mtls 0.8.1 → 0.9.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 (37) hide show
  1. package/README.md +18 -33
  2. package/lib/base.d.ts +11 -11
  3. package/lib/base.js +2 -2
  4. package/lib/commands/data/mtls/certificates/create.d.ts +2 -2
  5. package/lib/commands/data/mtls/certificates/create.js +7 -7
  6. package/lib/commands/data/mtls/certificates/delete.d.ts +2 -2
  7. package/lib/commands/data/mtls/certificates/delete.js +7 -7
  8. package/lib/commands/data/mtls/certificates/download.d.ts +2 -2
  9. package/lib/commands/data/mtls/certificates/download.js +29 -26
  10. package/lib/commands/data/mtls/certificates/get.d.ts +2 -2
  11. package/lib/commands/data/mtls/certificates/get.js +6 -6
  12. package/lib/commands/data/mtls/certificates/index.d.ts +2 -2
  13. package/lib/commands/data/mtls/certificates/index.js +13 -8
  14. package/lib/commands/data/mtls/create.d.ts +2 -2
  15. package/lib/commands/data/mtls/create.js +8 -8
  16. package/lib/commands/data/mtls/destroy.d.ts +2 -2
  17. package/lib/commands/data/mtls/destroy.js +7 -7
  18. package/lib/commands/data/mtls/index.d.ts +2 -2
  19. package/lib/commands/data/mtls/index.js +15 -10
  20. package/lib/commands/data/mtls/ip-rules/create.d.ts +2 -2
  21. package/lib/commands/data/mtls/ip-rules/create.js +8 -8
  22. package/lib/commands/data/mtls/ip-rules/delete.d.ts +2 -2
  23. package/lib/commands/data/mtls/ip-rules/delete.js +7 -7
  24. package/lib/commands/data/mtls/ip-rules/get.d.ts +2 -2
  25. package/lib/commands/data/mtls/ip-rules/get.js +6 -6
  26. package/lib/commands/data/mtls/ip-rules/index.d.ts +2 -2
  27. package/lib/commands/data/mtls/ip-rules/index.js +7 -7
  28. package/lib/lib/fetcher.js +17 -17
  29. package/lib/utils/is-error-http.d.ts +8 -0
  30. package/lib/utils/is-error-http.js +7 -0
  31. package/lib/utils/is-error-message.d.ts +3 -0
  32. package/lib/utils/is-error-message.js +7 -0
  33. package/lib/utils/table.d.ts +2 -2
  34. package/lib/utils/table.js +5 -2
  35. package/oclif.manifest.json +1 -1
  36. package/package.json +18 -13
  37. package/yarn.lock +2701 -1773
package/README.md CHANGED
@@ -1,32 +1,17 @@
1
- heroku-mtls-cli
2
- ===============
3
-
4
- heroku mtls cli
1
+ # Heroku CLI MTLS Plugin
5
2
 
6
3
  [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7
- [![Version](https://img.shields.io/npm/v/heroku-mtls-cli.svg)](https://npmjs.org/package/heroku-mtls-cli)
8
- [![CircleCI](https://circleci.com/gh/heroku/heroku-mtls-cli/tree/master.svg?style=shield)](https://circleci.com/gh/heroku/heroku-mtls-cli/tree/master)
9
- [![Downloads/week](https://img.shields.io/npm/dw/heroku-mtls-cli.svg)](https://npmjs.org/package/heroku-mtls-cli)
10
- [![License](https://img.shields.io/npm/l/heroku-mtls-cli.svg)](https://github.com/heroku/heroku-mtls-cli/blob/master/package.json)
4
+ ![GitHub Actions CI](https://github.com/heroku/heroku-mtls-cli/actions/workflows/ci.yml/badge.svg)
11
5
 
12
6
  <!-- toc -->
13
- * [Usage](#usage)
7
+ * [Heroku CLI MTLS Plugin](#heroku-cli-mtls-plugin)
8
+ * [Installation](#installation)
14
9
  * [Commands](#commands)
15
10
  <!-- tocstop -->
16
- # Usage
17
- <!-- usage -->
11
+ # Installation
18
12
  ```sh-session
19
- $ npm install -g @heroku-cli/plugin-mtls
20
- $ heroku COMMAND
21
- running command...
22
- $ heroku (-v|--version|version)
23
- @heroku-cli/plugin-mtls/0.8.1 darwin-x64 node-v14.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.8.1/src/commands/data/mtls/index.ts)_
45
+ _See code: [src/commands/data/mtls/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/certificates/index.ts)_
62
+ _See code: [src/commands/data/mtls/certificates/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/certificates/create.ts)_
79
+ _See code: [src/commands/data/mtls/certificates/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/certificates/delete.ts)_
97
+ _See code: [src/commands/data/mtls/certificates/delete.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/certificates/download.ts)_
121
+ _See code: [src/commands/data/mtls/certificates/download.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/certificates/get.ts)_
139
+ _See code: [src/commands/data/mtls/certificates/get.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/create.ts)_
156
+ _See code: [src/commands/data/mtls/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/destroy.ts)_
176
+ _See code: [src/commands/data/mtls/destroy.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/ip-rules/index.ts)_
193
+ _See code: [src/commands/data/mtls/ip-rules/index.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/ip-rules/create.ts)_
212
+ _See code: [src/commands/data/mtls/ip-rules/create.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/ip-rules/delete.ts)_
231
+ _See code: [src/commands/data/mtls/ip-rules/delete.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/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.8.1/src/commands/data/mtls/ip-rules/get.ts)_
249
+ _See code: [src/commands/data/mtls/ip-rules/get.ts](https://github.com/heroku/heroku-cli-plugin-mtls/blob/v0.9.0/src/commands/data/mtls/ip-rules/get.ts)_
265
250
  <!-- commandsstop -->
package/lib/base.d.ts CHANGED
@@ -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
- updated_at: Date;
16
+ decription: string;
17
+ id: string;
19
18
  status: string;
19
+ updated_at: Date;
20
20
  }
21
21
  export interface MTLSCertificate {
22
- id: string;
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
- private_key: string;
29
- certificate_with_chain: string;
28
+ status: string;
29
+ updated_at: Date;
30
30
  }
package/lib/base.js CHANGED
@@ -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 || 'postgres-api.heroku.com';
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
  }
@@ -1,13 +1,13 @@
1
1
  import { flags } from '@heroku-cli/command';
2
2
  import BaseCommand from '../../../../base';
3
3
  export default class MTLSCertificateCreate extends BaseCommand {
4
- static description: string;
5
4
  static args: {
6
5
  name: string;
7
6
  }[];
7
+ static description: string;
8
+ static examples: string[];
8
9
  static flags: {
9
10
  app: flags.IOptionFlag<string>;
10
11
  };
11
- static examples: string[];
12
12
  run(): Promise<void>;
13
13
  }
@@ -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.default.cyan(addon.name)}`);
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
- MTLSCertificateCreate.description = 'create a new certificate for your MTLS enabled addon';
21
+ exports.default = MTLSCertificateCreate;
22
22
  MTLSCertificateCreate.args = [
23
23
  { name: 'addon' }
24
24
  ];
25
- MTLSCertificateCreate.flags = {
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
- exports.default = MTLSCertificateCreate;
29
+ MTLSCertificateCreate.flags = {
30
+ app: command_1.flags.app({ required: true })
31
+ };
@@ -1,14 +1,14 @@
1
1
  import { flags } from '@heroku-cli/command';
2
2
  import BaseCommand from '../../../../base';
3
3
  export default class MTLSCertificateDelete extends BaseCommand {
4
- static description: string;
5
4
  static args: {
6
5
  name: string;
7
6
  }[];
7
+ static description: string;
8
+ static examples: string[];
8
9
  static flags: {
9
10
  app: flags.IOptionFlag<string>;
10
11
  id: flags.IOptionFlag<string>;
11
12
  };
12
- static examples: string[];
13
13
  run(): Promise<void>;
14
14
  }
@@ -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.default.cyan(addon.name)}`);
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
- MTLSCertificateDelete.description = 'delete a specific certificate for your MTLS enabled addon';
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;
@@ -1,16 +1,16 @@
1
1
  import { flags } from '@heroku-cli/command';
2
2
  import BaseCommand from '../../../../base';
3
3
  export default class MTLSCertificateDownload extends BaseCommand {
4
- static description: string;
5
4
  static args: {
6
5
  name: string;
7
6
  }[];
7
+ static description: string;
8
+ static examples: string[];
8
9
  static flags: {
9
10
  app: flags.IOptionFlag<string>;
10
11
  dir: flags.IOptionFlag<string | undefined>;
11
12
  id: flags.IOptionFlag<string | undefined>;
12
13
  prefix: flags.IOptionFlag<string>;
13
14
  };
14
- static examples: string[];
15
15
  run(): Promise<void>;
16
16
  }
@@ -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 os_1 = require("os");
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
- fs_1.writeFile(path, data, options, err => {
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.default.cyan(addon.name)}`);
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.default.cyan(flags.id)}`, { exit: 0 });
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 !== 'ready') {
40
- cli_ux_1.cli.action.stop();
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
- baseCert = certById;
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 || `${os_1.homedir}/.postgresql`;
69
- !fs_1.existsSync(path) && fs_1.mkdirSync(path);
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 (fs_1.existsSync(root) || fs_1.existsSync(key) || fs_1.existsSync(crt)) {
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.default.cyan(path)}`);
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
- MTLSCertificateDownload.description = 'download your certificate bundle for your mTLS addon';
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;
@@ -1,14 +1,14 @@
1
1
  import { flags } from '@heroku-cli/command';
2
2
  import BaseCommand from '../../../../base';
3
3
  export default class MTLSCertificateGet extends BaseCommand {
4
- static description: string;
5
4
  static args: {
6
5
  name: string;
7
6
  }[];
7
+ static description: string;
8
+ static examples: string[];
8
9
  static flags: {
9
10
  app: flags.IOptionFlag<string>;
10
11
  id: flags.IOptionFlag<string>;
11
12
  };
12
- static examples: string[];
13
13
  run(): Promise<void>;
14
14
  }
@@ -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
- MTLSCertificateGet.description = 'get a specific certificate for your MTLS enabled addon';
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;
@@ -1,13 +1,13 @@
1
1
  import { flags } from '@heroku-cli/command';
2
2
  import BaseCommand from '../../../../base';
3
3
  export default class MTLSCertificatesIndex extends BaseCommand {
4
- static description: string;
5
4
  static args: {
6
5
  name: string;
7
6
  }[];
7
+ static description: string;
8
+ static examples: string[];
8
9
  static flags: {
9
10
  app: flags.IOptionFlag<string>;
10
11
  };
11
- static examples: string[];
12
12
  run(): Promise<void>;
13
13
  }
@@ -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 (err.http && err.http.statusCode === 404) {
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
- MTLSCertificatesIndex.description = 'get the certificates for your MTLS enabled addon';
44
+ exports.default = MTLSCertificatesIndex;
40
45
  MTLSCertificatesIndex.args = [
41
46
  { name: 'addon' }
42
47
  ];
43
- MTLSCertificatesIndex.flags = {
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
- exports.default = MTLSCertificatesIndex;
52
+ MTLSCertificatesIndex.flags = {
53
+ app: command_1.flags.app({ required: true })
54
+ };
@@ -1,13 +1,13 @@
1
1
  import { flags } from '@heroku-cli/command';
2
2
  import BaseCommand from '../../../base';
3
3
  export default class MTLSCreate extends BaseCommand {
4
- static description: string;
5
4
  static args: {
6
5
  name: string;
7
6
  }[];
7
+ static description: string;
8
+ static examples: string[];
8
9
  static flags: {
9
10
  app: flags.IOptionFlag<string>;
10
11
  };
11
- static examples: string[];
12
12
  run(): Promise<void>;
13
13
  }
@@ -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.default.cyan(addon.name)}`);
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
- MTLSCreate.description = 'enable MTLS for your addon';
32
+ exports.default = MTLSCreate;
33
33
  MTLSCreate.args = [
34
34
  { name: 'addon' },
35
35
  ];
36
- MTLSCreate.flags = {
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
- exports.default = MTLSCreate;
40
+ MTLSCreate.flags = {
41
+ app: command_1.flags.app({ required: true })
42
+ };
@@ -1,14 +1,14 @@
1
1
  import { flags } from '@heroku-cli/command';
2
2
  import BaseCommand from '../../../base';
3
3
  export default class MTLSDestroy extends BaseCommand {
4
- static description: string;
5
4
  static aliases: string[];
6
5
  static args: {
7
6
  name: string;
8
7
  }[];
8
+ static description: string;
9
+ static examples: string[];
9
10
  static flags: {
10
11
  app: flags.IOptionFlag<string>;
11
12
  };
12
- static examples: string[];
13
13
  run(): Promise<void>;
14
14
  }