@adobe/ccweb-add-on-ssl 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/.c8rc.json +12 -1
  2. package/dist/app/CommandExecutor.d.ts +6 -7
  3. package/dist/app/CommandExecutor.d.ts.map +1 -1
  4. package/dist/app/PurgeCommandExecutor.d.ts +4 -3
  5. package/dist/app/PurgeCommandExecutor.d.ts.map +1 -1
  6. package/dist/app/PurgeCommandExecutor.js +8 -8
  7. package/dist/app/SSLReader.d.ts +22 -3
  8. package/dist/app/SSLReader.d.ts.map +1 -1
  9. package/dist/app/SSLReader.js +143 -1
  10. package/dist/app/SetupCommandExecutor.d.ts +5 -4
  11. package/dist/app/SetupCommandExecutor.d.ts.map +1 -1
  12. package/dist/app/SetupCommandExecutor.js +12 -12
  13. package/dist/app/index.d.ts +1 -2
  14. package/dist/app/index.d.ts.map +1 -1
  15. package/dist/app/index.js +0 -2
  16. package/dist/commands/purge.js +1 -1
  17. package/dist/commands/setup.d.ts.map +1 -1
  18. package/dist/commands/setup.js +1 -1
  19. package/dist/config/inversify.config.d.ts +1 -1
  20. package/dist/config/inversify.config.d.ts.map +1 -1
  21. package/dist/config/inversify.config.js +5 -3
  22. package/dist/models/{Types.d.ts → SSLTypes.d.ts} +1 -6
  23. package/dist/models/SSLTypes.d.ts.map +1 -0
  24. package/dist/models/{Types.js → SSLTypes.js} +1 -1
  25. package/dist/models/index.d.ts +1 -1
  26. package/dist/models/index.d.ts.map +1 -1
  27. package/dist/models/index.js +1 -1
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/dist/validators/CommandValidator.d.ts +5 -6
  30. package/dist/validators/CommandValidator.d.ts.map +1 -1
  31. package/dist/validators/SetupCommandValidator.d.ts +2 -3
  32. package/dist/validators/SetupCommandValidator.d.ts.map +1 -1
  33. package/dist/validators/SetupCommandValidator.js +1 -2
  34. package/dist/validators/index.d.ts +1 -1
  35. package/dist/validators/index.d.ts.map +1 -1
  36. package/dist/validators/index.js +0 -1
  37. package/package.json +6 -6
  38. package/src/app/CommandExecutor.ts +6 -8
  39. package/src/app/PurgeCommandExecutor.ts +9 -9
  40. package/src/app/SSLReader.ts +144 -6
  41. package/src/app/SetupCommandExecutor.ts +14 -14
  42. package/src/app/index.ts +1 -2
  43. package/src/commands/purge.ts +1 -1
  44. package/src/commands/setup.ts +11 -5
  45. package/src/config/inversify.config.ts +11 -8
  46. package/src/models/{Types.ts → SSLTypes.ts} +0 -7
  47. package/src/models/index.ts +1 -1
  48. package/src/test/app/PurgeCommandExecutor.spec.ts +6 -5
  49. package/src/test/app/{WxpSSLReader.spec.ts → SSLReader.spec.ts} +5 -6
  50. package/src/test/app/SetupCommandExecutor.spec.ts +8 -6
  51. package/src/test/commands/command.spec.ts +2 -1
  52. package/src/test/commands/purge.spec.ts +1 -1
  53. package/src/test/commands/setup.spec.ts +1 -1
  54. package/src/test/models/SetupCommandOptions.spec.ts +1 -1
  55. package/src/test/validators/SetupCommandValidator.spec.ts +3 -3
  56. package/src/validators/CommandValidator.ts +5 -7
  57. package/src/validators/SetupCommandValidator.ts +2 -3
  58. package/src/validators/index.ts +1 -1
  59. package/dist/app/WxpSSLReader.d.ts +0 -67
  60. package/dist/app/WxpSSLReader.d.ts.map +0 -1
  61. package/dist/app/WxpSSLReader.js +0 -167
  62. package/dist/models/Types.d.ts.map +0 -1
  63. package/src/app/WxpSSLReader.ts +0 -187
@@ -24,8 +24,8 @@
24
24
 
25
25
  import type { AnalyticsService } from "@adobe/ccweb-add-on-analytics";
26
26
  import { ITypes as IAnalyticsTypes } from "@adobe/ccweb-add-on-analytics";
27
- import type { Logger, Preferences } from "@adobe/ccweb-add-on-core";
28
- import { ITypes as ICoreTypes } from "@adobe/ccweb-add-on-core";
27
+ import type { Logger } from "@adobe/ccweb-add-on-core";
28
+ import { ITypes as ICoreTypes, UserPreferences } from "@adobe/ccweb-add-on-core";
29
29
  import devcert from "@adobe/ccweb-add-on-devcert";
30
30
  import chalk from "chalk";
31
31
  import fs from "fs-extra";
@@ -33,7 +33,7 @@ import { inject, injectable } from "inversify";
33
33
  import prompts from "prompts";
34
34
  import "reflect-metadata";
35
35
  import { AnalyticsErrorMarkers, AnalyticsSuccessMarkers } from "../AnalyticsMarkers.js";
36
- import { SSLRemoveOption } from "../models/Types.js";
36
+ import { SSLRemoveOption } from "../models/SSLTypes.js";
37
37
  import type { CommandExecutor } from "./CommandExecutor.js";
38
38
 
39
39
  /**
@@ -41,19 +41,19 @@ import type { CommandExecutor } from "./CommandExecutor.js";
41
41
  */
42
42
  @injectable()
43
43
  export class PurgeCommandExecutor implements CommandExecutor {
44
- private readonly _preferences: Preferences;
44
+ private readonly _preferences: UserPreferences;
45
45
  private readonly _analyticsService: AnalyticsService;
46
46
  private readonly _logger: Logger;
47
47
 
48
48
  /**
49
49
  * Instantiate {@link PurgeCommandExecutor}.
50
- * @param preferences - {@link Preferences} reference.
50
+ * @param preferences - {@link UserPreferences} reference.
51
51
  * @param analyticsService - {@link AnalyticsService} reference.
52
52
  * @param logger - {@link Logger} reference.
53
53
  * @returns Reference to a new {@link PurgeCommandExecutor} instance.
54
54
  */
55
55
  constructor(
56
- @inject(ICoreTypes.Preferences) preferences: Preferences,
56
+ @inject(ICoreTypes.UserPreferences) preferences: UserPreferences,
57
57
  @inject(IAnalyticsTypes.AnalyticsService) analyticsService: AnalyticsService,
58
58
  @inject(ICoreTypes.Logger) logger: Logger
59
59
  ) {
@@ -79,7 +79,7 @@ export class PurgeCommandExecutor implements CommandExecutor {
79
79
  });
80
80
 
81
81
  if (!response || !response.purgeConfirmation) {
82
- this._analyticsService.postEvent(
82
+ void this._analyticsService.postEvent(
83
83
  AnalyticsErrorMarkers.ERROR_SSL_PURGE,
84
84
  LOGS.sslPurgeOptionNotSpecified,
85
85
  false
@@ -109,14 +109,14 @@ export class PurgeCommandExecutor implements CommandExecutor {
109
109
  userPreference.ssl = undefined;
110
110
  this._preferences.set(userPreference);
111
111
 
112
- this._analyticsService.postEvent(AnalyticsSuccessMarkers.SUCCESSFUL_SSL_MANUAL_PURGE, "", true);
112
+ void this._analyticsService.postEvent(AnalyticsSuccessMarkers.SUCCESSFUL_SSL_MANUAL_PURGE, "", true);
113
113
  }
114
114
  }
115
115
 
116
116
  private _purgeWxpSSL(): void {
117
117
  if (fs.existsSync(devcert.location())) {
118
118
  devcert.removeAll();
119
- this._analyticsService.postEvent(AnalyticsSuccessMarkers.SUCCESSFUL_SSL_AUTOMATIC_PURGE, "", true);
119
+ void this._analyticsService.postEvent(AnalyticsSuccessMarkers.SUCCESSFUL_SSL_AUTOMATIC_PURGE, "", true);
120
120
  }
121
121
  }
122
122
 
@@ -22,25 +22,54 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
- import type { SSLData } from "../models/index.js";
25
+ import type { Logger, SSLSettings } from "@adobe/ccweb-add-on-core";
26
+ import { ITypes as ICoreTypes, isFile, UserPreferences } from "@adobe/ccweb-add-on-core";
27
+ import devcert from "@adobe/ccweb-add-on-devcert";
28
+ import fs from "fs-extra";
29
+ import { inject, injectable } from "inversify";
30
+ import "reflect-metadata";
31
+ import format from "string-template";
32
+ import type { SSLData } from "../models/SSLTypes.js";
26
33
 
27
34
  /**
28
- * Contracts for reading the SSL artifacts.
35
+ * Implementation class for reading the SSL artifacts.
29
36
  */
30
- export interface SSLReader {
37
+ @injectable()
38
+ export class SSLReader {
39
+ private readonly _preferences: UserPreferences;
40
+ private readonly _logger: Logger;
41
+
42
+ /**
43
+ * Instantiate {@link SSLReader}.
44
+ * @param Preferences - {@link UserPreferences} reference.
45
+ * @param logger - {@link Logger} reference.
46
+ * @returns Reference to a new {@link SSLReader} instance.
47
+ */
48
+ constructor(
49
+ @inject(ICoreTypes.UserPreferences) preferences: UserPreferences,
50
+ @inject(ICoreTypes.Logger) logger: Logger
51
+ ) {
52
+ this._preferences = preferences;
53
+ this._logger = logger;
54
+ }
55
+
31
56
  /**
32
57
  * Is SSL set up manually by the user.
33
58
  * @param hostname - Hostname in the SSL certificate.
34
59
  * @returns Boolean value representing whether SSL is set up manually.
35
60
  */
36
- isCustomSSL(hostname: string): boolean;
61
+ isCustomSSL(hostname: string): boolean {
62
+ return this._getUserDefinedSSL(hostname) !== undefined;
63
+ }
37
64
 
38
65
  /**
39
66
  * Is SSL set up automatically by the tool.
40
67
  * @param hostname - Hostname in the SSL certificate.
41
68
  * @returns Boolean value representing whether SSL is set up automatically.
42
69
  */
43
- isWxpSSL(hostname: string): boolean;
70
+ isWxpSSL(hostname: string): boolean {
71
+ return devcert.hasCertificateFor(hostname);
72
+ }
44
73
 
45
74
  /**
46
75
  * Read the SSL artifacts.
@@ -48,5 +77,114 @@ export interface SSLReader {
48
77
  * @param port - Port where the add-on is being hosted.
49
78
  * @returns Promise of {@link SSLData}.
50
79
  */
51
- read(hostname: string, port: number): Promise<SSLData>;
80
+ async read(hostname: string, port: number): Promise<SSLData> {
81
+ const sslSettings = this._getUserDefinedSSL(hostname);
82
+
83
+ // When SSL is set up manuually by the `user`.
84
+ if (sslSettings !== undefined) {
85
+ const { certificatePath, keyPath } = sslSettings;
86
+ if (!certificatePath || !isFile(certificatePath)) {
87
+ this._handleInvalidUserSSLCertificate(LOGS.invalidCertificatePath);
88
+ return process.exit(1);
89
+ }
90
+
91
+ if (!keyPath || !isFile(keyPath)) {
92
+ this._handleInvalidUserSSLCertificate(LOGS.invalidKeyPath);
93
+ return process.exit(1);
94
+ }
95
+
96
+ this._handleUnknownExpirySSLCertificate(hostname, port);
97
+
98
+ return {
99
+ cert: fs.readFileSync(certificatePath),
100
+ key: fs.readFileSync(keyPath)
101
+ };
102
+ }
103
+
104
+ // When SSL is set up automatically by `devcert`.
105
+ if (this.isWxpSSL(hostname)) {
106
+ const caExpiry = devcert.caExpiryInDays();
107
+ const certificateExpiry = devcert.certificateExpiryInDays(hostname);
108
+
109
+ const expiry = Math.min(certificateExpiry, caExpiry);
110
+ if (expiry <= 0) {
111
+ this._handleExpiredSSLCertificate();
112
+ return process.exit(1);
113
+ }
114
+
115
+ if (expiry <= 7) {
116
+ this._handleNearingExpirySSLCertificate(expiry);
117
+ }
118
+
119
+ return await devcert.certificateFor(hostname);
120
+ }
121
+
122
+ this._handleNoSSLCertificateFound();
123
+ return process.exit(1);
124
+ }
125
+
126
+ private _getUserDefinedSSL(hostname: string): SSLSettings | undefined {
127
+ const { ssl } = this._preferences.get();
128
+ if (ssl === undefined) {
129
+ return undefined;
130
+ }
131
+
132
+ return ssl.get(hostname);
133
+ }
134
+
135
+ private _handleExpiredSSLCertificate() {
136
+ this._logger.error(LOGS.noValidSSLCertificateFound);
137
+ this._logger.error(LOGS.expiredSSLCertificate);
138
+ this._recreateSSLCertificate();
139
+ }
140
+
141
+ private _handleNearingExpirySSLCertificate(expiry: number) {
142
+ this._logger.warning(format(LOGS.nearingExpirySSLCertificate, { expiry }));
143
+ this._recreateSSLCertificate();
144
+ }
145
+
146
+ private _handleNoSSLCertificateFound() {
147
+ this._logger.error(LOGS.noValidSSLCertificateFound);
148
+ this._logger.error(LOGS.invalidatedSSLCertificate);
149
+ this._recreateSSLCertificate();
150
+ }
151
+
152
+ private _handleInvalidUserSSLCertificate(errorMessage: string) {
153
+ this._logger.error(errorMessage);
154
+ this._recreateSSLCertificate();
155
+ }
156
+
157
+ private _handleUnknownExpirySSLCertificate(hostname: string, port: number) {
158
+ this._logger.warning(LOGS.undeterminedExpirySSLCertificate);
159
+ this._logger.warning(LOGS.unableToSideloadAddOn);
160
+ this._logger.warning(format(LOGS.checkCertificateValidity, { hostname, port }));
161
+ this._recreateSSLCertificate();
162
+ }
163
+
164
+ private _recreateSSLCertificate() {
165
+ this._logger.warning(LOGS.recreateSSLCertificate, { prefix: LOGS.newLine });
166
+ this._logger.information(LOGS.setupSSLCommand, { prefix: LOGS.tab });
167
+
168
+ this._logger.warning(LOGS.example, { prefix: LOGS.newLine });
169
+ this._logger.information(LOGS.setupSSLCommandExample, { prefix: LOGS.tab, postfix: LOGS.newLine });
170
+ }
52
171
  }
172
+
173
+ const LOGS = {
174
+ newLine: "\n",
175
+ tab: " ",
176
+ invalidCertificatePath: "Invalid SSL certificate file path.",
177
+ invalidKeyPath: "Invalid SSL key file path.",
178
+ noValidSSLCertificateFound: "Could not locate a valid SSL certificate to host the add-on.",
179
+ expiredSSLCertificate: "The SSL certificate has expired.",
180
+ nearingExpirySSLCertificate: "Your SSL certificate will expire in {expiry} days.",
181
+ invalidatedSSLCertificate:
182
+ "If you had previously set it up, it may have been invalidated due to a version upgrade.",
183
+ undeterminedExpirySSLCertificate: "Could not determine the expiry of your SSL certificate.",
184
+ unableToSideloadAddOn: "If you are unable to sideload your add-on, please check the validity of:",
185
+ checkCertificateValidity: "https://{hostname}:{port} certificate in your browser.",
186
+ recreateSSLCertificate: "To re-create the SSL certificate, you may run:",
187
+ setupSSLCommand: "npx @adobe/ccweb-add-on-ssl setup --hostname [hostname]",
188
+ example: "Example:",
189
+ setupSSLCommandExample: "npx @adobe/ccweb-add-on-ssl setup --hostname localhost"
190
+ };
@@ -24,8 +24,8 @@
24
24
 
25
25
  import type { AnalyticsService } from "@adobe/ccweb-add-on-analytics";
26
26
  import { ITypes as IAnalyticsTypes } from "@adobe/ccweb-add-on-analytics";
27
- import type { Logger, Preferences } from "@adobe/ccweb-add-on-core";
28
- import { ITypes as ICoreTypes, isFile } from "@adobe/ccweb-add-on-core";
27
+ import type { Logger } from "@adobe/ccweb-add-on-core";
28
+ import { ITypes as ICoreTypes, isFile, UserPreferences } from "@adobe/ccweb-add-on-core";
29
29
  import devcert from "@adobe/ccweb-add-on-devcert";
30
30
  import chalk from "chalk";
31
31
  import { inject, injectable } from "inversify";
@@ -37,7 +37,7 @@ import format from "string-template";
37
37
  import { AnalyticsErrorMarkers, AnalyticsSuccessMarkers } from "../AnalyticsMarkers.js";
38
38
  import { ITypes } from "../config/inversify.types.js";
39
39
  import type { SetupCommandOptions } from "../models/SetupCommandOptions.js";
40
- import { SSLRemoveOption, SSLSetupOption } from "../models/Types.js";
40
+ import { SSLRemoveOption, SSLSetupOption } from "../models/SSLTypes.js";
41
41
  import type { CommandExecutor } from "./CommandExecutor.js";
42
42
  import type { SSLReader } from "./SSLReader.js";
43
43
 
@@ -47,22 +47,22 @@ const MAX_PROMPT_RETRIES = 3;
47
47
  * Setup command execution implementation class.
48
48
  */
49
49
  @injectable()
50
- export class SetupCommandExecutor implements CommandExecutor {
51
- private readonly _preferences: Preferences;
50
+ export class SetupCommandExecutor implements CommandExecutor<SetupCommandOptions> {
51
+ private readonly _preferences: UserPreferences;
52
52
  private readonly _sslReader: SSLReader;
53
53
  private readonly _analyticsService: AnalyticsService;
54
54
  private readonly _logger: Logger;
55
55
 
56
56
  /**
57
57
  * Instantiate {@link SetupCommandExecutor}.
58
- * @param preferences - {@link Preferences} reference.
58
+ * @param preferences - {@link UserPreferences} reference.
59
59
  * @param sslReader - {@link SSLReader} reference.
60
60
  * @param analyticsService - {@link AnalyticsService} reference.
61
61
  * @param logger - {@link Logger} reference.
62
62
  * @returns Reference to a new {@link SetupCommandExecutor} instance.
63
63
  */
64
64
  constructor(
65
- @inject(ICoreTypes.Preferences) preferences: Preferences,
65
+ @inject(ICoreTypes.UserPreferences) preferences: UserPreferences,
66
66
  @inject(ITypes.SSLReader) sslReader: SSLReader,
67
67
  @inject(IAnalyticsTypes.AnalyticsService) analyticsService: AnalyticsService,
68
68
  @inject(ICoreTypes.Logger) logger: Logger
@@ -98,7 +98,7 @@ export class SetupCommandExecutor implements CommandExecutor {
98
98
  });
99
99
 
100
100
  if (!response || !response.sslSetupType) {
101
- this._analyticsService.postEvent(
101
+ void this._analyticsService.postEvent(
102
102
  AnalyticsErrorMarkers.ERROR_SSL_SETUP,
103
103
  LOGS.sslSetupOptionNotSpecified,
104
104
  false
@@ -109,14 +109,14 @@ export class SetupCommandExecutor implements CommandExecutor {
109
109
 
110
110
  if (response.sslSetupType === SSLSetupOption.Manually) {
111
111
  await this._setupSSLManually(options.hostname);
112
- this._analyticsService.postEvent(
112
+ void this._analyticsService.postEvent(
113
113
  AnalyticsSuccessMarkers.SUCCESSFUL_SSL_MANUAL_SETUP,
114
114
  options.hostname,
115
115
  true
116
116
  );
117
117
  } else {
118
118
  await this._setupSSLAutomatically(options.hostname);
119
- this._analyticsService.postEvent(
119
+ void this._analyticsService.postEvent(
120
120
  AnalyticsSuccessMarkers.SUCCESSFUL_SSL_AUTOMATIC_SETUP,
121
121
  options.hostname,
122
122
  true
@@ -199,7 +199,7 @@ export class SetupCommandExecutor implements CommandExecutor {
199
199
 
200
200
  // If no response is obtained, which indicates something has gone wrong, then exit.
201
201
  if (!response || !response.shouldRemove) {
202
- this._analyticsService.postEvent(
202
+ void this._analyticsService.postEvent(
203
203
  AnalyticsErrorMarkers.ERROR_SSL_REMOVE,
204
204
  LOGS.sslRemoveOptionNotSpecified,
205
205
  false
@@ -219,7 +219,7 @@ export class SetupCommandExecutor implements CommandExecutor {
219
219
  userPreference.ssl!.delete(options.hostname);
220
220
  this._preferences.set(userPreference);
221
221
 
222
- this._analyticsService.postEvent(
222
+ void this._analyticsService.postEvent(
223
223
  AnalyticsSuccessMarkers.SUCCESSFUL_SSL_MANUAL_REMOVE,
224
224
  options.hostname,
225
225
  true
@@ -233,7 +233,7 @@ export class SetupCommandExecutor implements CommandExecutor {
233
233
  await devcert.removeDomain(options.hostname);
234
234
  }
235
235
 
236
- this._analyticsService.postEvent(
236
+ void this._analyticsService.postEvent(
237
237
  AnalyticsSuccessMarkers.SUCCESSFUL_SSL_AUTOMATIC_REMOVE,
238
238
  options.hostname,
239
239
  true
@@ -270,7 +270,7 @@ export class SetupCommandExecutor implements CommandExecutor {
270
270
  this._logger.error(format(LOGS.invalidPathSpecified, { asset }));
271
271
  }
272
272
 
273
- this._analyticsService.postEvent(
273
+ void this._analyticsService.postEvent(
274
274
  AnalyticsErrorMarkers.ERROR_SSL_SETUP,
275
275
  format(LOGS.invalidPathSpecified, { asset }),
276
276
  false
package/src/app/index.ts CHANGED
@@ -22,8 +22,7 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
- export * from "./CommandExecutor.js";
25
+ export type * from "./CommandExecutor.js";
26
26
  export * from "./PurgeCommandExecutor.js";
27
27
  export * from "./SetupCommandExecutor.js";
28
28
  export * from "./SSLReader.js";
29
- export * from "./WxpSSLReader.js";
@@ -66,7 +66,7 @@ export class Purge extends BaseCommand {
66
66
  }
67
67
 
68
68
  async catch(error: { message: string }): Promise<void> {
69
- this._analyticsService.postEvent(AnalyticsErrorMarkers.ERROR_SSL_PURGE, error.message, false);
69
+ void this._analyticsService.postEvent(AnalyticsErrorMarkers.ERROR_SSL_PURGE, error.message, false);
70
70
  throw error;
71
71
  }
72
72
  }
@@ -40,8 +40,8 @@ import type { CommandValidator } from "../validators/CommandValidator.js";
40
40
  * SSL Setup command.
41
41
  */
42
42
  export class Setup extends BaseCommand {
43
- private readonly _commandValidator: CommandValidator;
44
- private readonly _commandExecutor: CommandExecutor;
43
+ private readonly _commandValidator: CommandValidator<SetupCommandOptions>;
44
+ private readonly _commandExecutor: CommandExecutor<SetupCommandOptions>;
45
45
 
46
46
  static description = "Setup a locally trusted SSL certificate for hosting an add-on.";
47
47
 
@@ -68,8 +68,14 @@ export class Setup extends BaseCommand {
68
68
  constructor(argv: string[], config: Config) {
69
69
  super(argv, config, new CLIProgram(PROGRAM_NAME, config.name + "@" + config.version));
70
70
 
71
- this._commandValidator = IContainer.getNamed<CommandValidator>(ITypes.CommandValidator, "setup");
72
- this._commandExecutor = IContainer.getNamed<CommandExecutor>(ITypes.CommandExecutor, "setup");
71
+ this._commandValidator = IContainer.getNamed<CommandValidator<SetupCommandOptions>>(
72
+ ITypes.CommandValidator,
73
+ "setup"
74
+ );
75
+ this._commandExecutor = IContainer.getNamed<CommandExecutor<SetupCommandOptions>>(
76
+ ITypes.CommandExecutor,
77
+ "setup"
78
+ );
73
79
  }
74
80
 
75
81
  async run(): Promise<void> {
@@ -90,7 +96,7 @@ export class Setup extends BaseCommand {
90
96
  }
91
97
 
92
98
  async catch(error: { message: string }): Promise<void> {
93
- this._analyticsService.postEvent(AnalyticsErrorMarkers.ERROR_SSL_SETUP, error.message, false);
99
+ void this._analyticsService.postEvent(AnalyticsErrorMarkers.ERROR_SSL_SETUP, error.message, false);
94
100
  throw error;
95
101
  }
96
102
  }
@@ -23,18 +23,21 @@
23
23
  ********************************************************************************/
24
24
 
25
25
  import { IContainer as ICoreContainer } from "@adobe/ccweb-add-on-core";
26
- import { Container } from "inversify";
26
+ import type { Container } from "inversify";
27
27
  import "reflect-metadata";
28
- import type { CommandExecutor, SSLReader } from "../app/index.js";
29
- import { PurgeCommandExecutor, SetupCommandExecutor, WxpSSLReader } from "../app/index.js";
30
- import type { CommandValidator } from "../validators/index.js";
31
- import { SetupCommandValidator } from "../validators/index.js";
28
+ import type { CommandExecutor } from "../app/CommandExecutor.js";
29
+ import { PurgeCommandExecutor } from "../app/PurgeCommandExecutor.js";
30
+ import { SetupCommandExecutor } from "../app/SetupCommandExecutor.js";
31
+ import { SSLReader } from "../app/SSLReader.js";
32
+ import type { SetupCommandOptions } from "../models/SetupCommandOptions.js";
33
+ import type { CommandValidator } from "../validators/CommandValidator.js";
34
+ import { SetupCommandValidator } from "../validators/SetupCommandValidator.js";
32
35
  import { ITypes } from "./inversify.types.js";
33
36
 
34
37
  const container: Container = ICoreContainer;
35
38
 
36
39
  container
37
- .bind<CommandExecutor>(ITypes.CommandExecutor)
40
+ .bind<CommandExecutor<SetupCommandOptions>>(ITypes.CommandExecutor)
38
41
  .to(SetupCommandExecutor)
39
42
  .inSingletonScope()
40
43
  .whenTargetNamed("setup");
@@ -46,11 +49,11 @@ container
46
49
  .whenTargetNamed("purge");
47
50
 
48
51
  container
49
- .bind<CommandValidator>(ITypes.CommandValidator)
52
+ .bind<CommandValidator<SetupCommandOptions>>(ITypes.CommandValidator)
50
53
  .to(SetupCommandValidator)
51
54
  .inSingletonScope()
52
55
  .whenTargetNamed("setup");
53
56
 
54
- container.bind<SSLReader>(ITypes.SSLReader).to(WxpSSLReader).inSingletonScope();
57
+ container.bind<SSLReader>(ITypes.SSLReader).to(SSLReader).inSingletonScope();
55
58
 
56
59
  export { container as IContainer };
@@ -22,13 +22,6 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
- import type { SetupCommandOptions } from "./SetupCommandOptions.js";
26
-
27
- /**
28
- * Union of supported command options.
29
- */
30
- export type CommandOptions = SetupCommandOptions;
31
-
32
25
  /**
33
26
  * SSL setup option.
34
27
  */
@@ -23,4 +23,4 @@
23
23
  ********************************************************************************/
24
24
 
25
25
  export * from "./SetupCommandOptions.js";
26
- export * from "./Types.js";
26
+ export * from "./SSLTypes.js";
@@ -23,7 +23,8 @@
23
23
  ********************************************************************************/
24
24
 
25
25
  import type { AnalyticsService } from "@adobe/ccweb-add-on-analytics";
26
- import { PreferenceJson, type Logger, type Preferences } from "@adobe/ccweb-add-on-core";
26
+ import type { Logger, UserPreferences } from "@adobe/ccweb-add-on-core";
27
+ import { PreferenceJson } from "@adobe/ccweb-add-on-core";
27
28
  import devcert from "@adobe/ccweb-add-on-devcert";
28
29
  import { assert } from "chai";
29
30
  import chalk from "chalk";
@@ -36,15 +37,15 @@ import sinon from "sinon";
36
37
  import type { StubbedInstance } from "ts-sinon";
37
38
  import { stubInterface } from "ts-sinon";
38
39
  import { AnalyticsErrorMarkers, AnalyticsSuccessMarkers } from "../../AnalyticsMarkers.js";
39
- import type { CommandExecutor } from "../../app/index.js";
40
- import { PurgeCommandExecutor } from "../../app/index.js";
41
- import { SSLRemoveOption } from "../../models/index.js";
40
+ import type { CommandExecutor } from "../../app/CommandExecutor.js";
41
+ import { PurgeCommandExecutor } from "../../app/PurgeCommandExecutor.js";
42
+ import { SSLRemoveOption } from "../../models/SSLTypes.js";
42
43
 
43
44
  describe("PurgeCommandExecutor", () => {
44
45
  describe("execute", () => {
45
46
  let sandbox: SinonSandbox;
46
47
 
47
- let preferences: StubbedInstance<Preferences>;
48
+ let preferences: StubbedInstance<UserPreferences>;
48
49
  let analyticsService: StubbedInstance<AnalyticsService>;
49
50
  let logger: StubbedInstance<Logger>;
50
51
 
@@ -22,7 +22,7 @@
22
22
  * SOFTWARE.
23
23
  ********************************************************************************/
24
24
 
25
- import type { Logger, Preferences } from "@adobe/ccweb-add-on-core";
25
+ import type { Logger, UserPreferences } from "@adobe/ccweb-add-on-core";
26
26
  import { ADD_ON_PREFERENCES_FILE, PreferenceJson } from "@adobe/ccweb-add-on-core";
27
27
  import devcert from "@adobe/ccweb-add-on-devcert";
28
28
  import chai, { assert, expect } from "chai";
@@ -33,15 +33,14 @@ import "mocha";
33
33
  import sinon from "sinon";
34
34
  import type { StubbedInstance } from "ts-sinon";
35
35
  import { stubInterface } from "ts-sinon";
36
- import type { SSLReader } from "../../app/index.js";
37
- import { WxpSSLReader } from "../../app/index.js";
36
+ import { SSLReader } from "../../app/SSLReader.js";
38
37
 
39
38
  chai.use(chaiAsPromised);
40
39
 
41
- describe("WxpSSLReader", () => {
40
+ describe("SSLReader", () => {
42
41
  let sandbox: sinon.SinonSandbox;
43
42
 
44
- let preferences: StubbedInstance<Preferences>;
43
+ let preferences: StubbedInstance<UserPreferences>;
45
44
  let logger: StubbedInstance<Logger>;
46
45
  let sslReader: SSLReader;
47
46
 
@@ -53,7 +52,7 @@ describe("WxpSSLReader", () => {
53
52
 
54
53
  preferences = stubInterface();
55
54
  logger = stubInterface();
56
- sslReader = new WxpSSLReader(preferences, logger);
55
+ sslReader = new SSLReader(preferences, logger);
57
56
  });
58
57
 
59
58
  afterEach(() => {
@@ -23,7 +23,7 @@
23
23
  ********************************************************************************/
24
24
 
25
25
  import type { AnalyticsService } from "@adobe/ccweb-add-on-analytics";
26
- import type { Logger, Preferences } from "@adobe/ccweb-add-on-core";
26
+ import type { Logger, UserPreferences } from "@adobe/ccweb-add-on-core";
27
27
  import { ADD_ON_PREFERENCES_FILE, PreferenceJson } from "@adobe/ccweb-add-on-core";
28
28
  import devcert from "@adobe/ccweb-add-on-devcert";
29
29
  import chai, { assert, expect } from "chai";
@@ -41,21 +41,23 @@ import format from "string-template";
41
41
  import type { StubbedInstance } from "ts-sinon";
42
42
  import { stubInterface } from "ts-sinon";
43
43
  import { AnalyticsErrorMarkers, AnalyticsSuccessMarkers } from "../../AnalyticsMarkers.js";
44
- import type { CommandExecutor, SSLReader } from "../../app/index.js";
45
- import { SetupCommandExecutor } from "../../app/index.js";
46
- import { SSLRemoveOption, SSLSetupOption, SetupCommandOptions } from "../../models/index.js";
44
+ import type { CommandExecutor } from "../../app/CommandExecutor.js";
45
+ import { SetupCommandExecutor } from "../../app/SetupCommandExecutor.js";
46
+ import type { SSLReader } from "../../app/SSLReader.js";
47
+ import { SetupCommandOptions } from "../../models/SetupCommandOptions.js";
48
+ import { SSLRemoveOption, SSLSetupOption } from "../../models/SSLTypes.js";
47
49
 
48
50
  chai.use(chaiAsPromised);
49
51
 
50
52
  describe("SetupCommandExecutor", () => {
51
53
  let sandbox: SinonSandbox;
52
54
 
53
- let preferences: StubbedInstance<Preferences>;
55
+ let preferences: StubbedInstance<UserPreferences>;
54
56
  let sslReader: StubbedInstance<SSLReader>;
55
57
  let analyticsService: StubbedInstance<AnalyticsService>;
56
58
  let logger: StubbedInstance<Logger>;
57
59
 
58
- let commandExecutor: CommandExecutor;
60
+ let commandExecutor: CommandExecutor<SetupCommandOptions>;
59
61
 
60
62
  beforeEach(() => {
61
63
  sandbox = sinon.createSandbox();
@@ -30,7 +30,8 @@ import "mocha";
30
30
  import sinon from "sinon";
31
31
  import type { StubbedInstance } from "ts-sinon";
32
32
  import { stubInterface } from "ts-sinon";
33
- import type { PurgeCommandExecutor, SetupCommandExecutor } from "../../app/index.js";
33
+ import type { PurgeCommandExecutor } from "../../app/PurgeCommandExecutor.js";
34
+ import type { SetupCommandExecutor } from "../../app/SetupCommandExecutor.js";
34
35
  import { IContainer, ITypes } from "../../config/index.js";
35
36
  import { SetupCommandOptions } from "../../models/SetupCommandOptions.js";
36
37
  import type { SetupCommandValidator } from "../../validators/SetupCommandValidator.js";
@@ -32,7 +32,7 @@ import sinon from "sinon";
32
32
  import type { StubbedInstance } from "ts-sinon";
33
33
  import { stubInterface } from "ts-sinon";
34
34
  import { AnalyticsErrorMarkers } from "../../AnalyticsMarkers.js";
35
- import { PurgeCommandExecutor } from "../../app/index.js";
35
+ import type { PurgeCommandExecutor } from "../../app/PurgeCommandExecutor.js";
36
36
  import { Purge } from "../../commands/purge.js";
37
37
  import { IContainer, ITypes } from "../../config/index.js";
38
38
  import { PROGRAM_NAME } from "../../constants.js";
@@ -32,7 +32,7 @@ import sinon from "sinon";
32
32
  import type { StubbedInstance } from "ts-sinon";
33
33
  import { stubInterface } from "ts-sinon";
34
34
  import { AnalyticsErrorMarkers } from "../../AnalyticsMarkers.js";
35
- import type { SetupCommandExecutor } from "../../app/index.js";
35
+ import type { SetupCommandExecutor } from "../../app/SetupCommandExecutor.js";
36
36
  import { Setup } from "../../commands/setup.js";
37
37
  import { IContainer, ITypes } from "../../config/index.js";
38
38
  import { PROGRAM_NAME } from "../../constants.js";
@@ -24,7 +24,7 @@
24
24
 
25
25
  import { assert } from "chai";
26
26
  import "mocha";
27
- import { SetupCommandOptions } from "../../models/index.js";
27
+ import { SetupCommandOptions } from "../../models/SetupCommandOptions.js";
28
28
 
29
29
  describe("SetupCommandOptions", () => {
30
30
  describe("constructor", () => {
@@ -33,8 +33,8 @@ import type { StubbedInstance } from "ts-sinon";
33
33
  import { stubInterface } from "ts-sinon";
34
34
  import { AnalyticsErrorMarkers } from "../../AnalyticsMarkers.js";
35
35
  import { SetupCommandOptions } from "../../models/SetupCommandOptions.js";
36
- import type { CommandValidator } from "../../validators/index.js";
37
- import { SetupCommandValidator } from "../../validators/index.js";
36
+ import type { CommandValidator } from "../../validators/CommandValidator.js";
37
+ import { SetupCommandValidator } from "../../validators/SetupCommandValidator.js";
38
38
 
39
39
  chai.use(chaiAsPromised);
40
40
 
@@ -46,7 +46,7 @@ describe("SetupCommandValidator", () => {
46
46
  let analyticsService: StubbedInstance<AnalyticsService>;
47
47
  let logger: StubbedInstance<Logger>;
48
48
 
49
- let commandValidator: CommandValidator;
49
+ let commandValidator: CommandValidator<SetupCommandOptions>;
50
50
 
51
51
  beforeEach(() => {
52
52
  sandbox = sinon.createSandbox();