@git.zone/cli 8.0.0 → 8.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.
@@ -100,7 +100,46 @@ export const deriveS3BucketName = (projectNameArg: string): string => {
100
100
  return canonical;
101
101
  };
102
102
 
103
- export interface IServiceConfig {
103
+ /**
104
+ * The serve.zone capability environment
105
+ * (`serve.zone/docs/developers/app-integration.md`, "Capability environment")
106
+ * that GitZone does not already manage under the same name. `MONGODB_HOST`,
107
+ * `MONGODB_PORT`, `MONGODB_URL`, `S3_PORT`, `S3_REGION` and `S3_BUCKET` share
108
+ * their platform name and meaning with the GitZone fields. `S3_ENDPOINT` shares
109
+ * the name only: GitZone keeps the user's value (a host, `host:port`, or an
110
+ * origin, see `resolveS3Endpoint`), and `AWS_ENDPOINT_URL` carries the endpoint
111
+ * origin. Every value is derived from the GitZone fields and rewritten on each
112
+ * reconciliation.
113
+ */
114
+ export interface IServicePlatformEnvironment {
115
+ /** Identical to `MONGODB_URL` and `MONGO_URL`. */
116
+ MONGODB_URI: string;
117
+ MONGO_URL: string;
118
+ MONGODB_DATABASE: string;
119
+ MONGO_DBNAME: string;
120
+ /** The four credential names are present only while MongoDB auth is enabled. */
121
+ MONGODB_USERNAME?: string;
122
+ MONGO_DBUSER?: string;
123
+ MONGODB_PASSWORD?: string;
124
+ MONGO_DBPASS?: string;
125
+ /** Endpoint origin, e.g. `http://localhost:29000`. */
126
+ AWS_ENDPOINT_URL: string;
127
+ /** Host of `AWS_ENDPOINT_URL`; an IPv6 address without brackets. */
128
+ S3_ENDPOINT_HOST: string;
129
+ /** `true` or `false`, the scheme of `AWS_ENDPOINT_URL`. */
130
+ S3_USE_SSL: string;
131
+ AWS_REGION: string;
132
+ /** Always `true`. */
133
+ AWS_S3_FORCE_PATH_STYLE: string;
134
+ S3_ACCESS_KEY: string;
135
+ S3_ACCESS_KEY_ID: string;
136
+ AWS_ACCESS_KEY_ID: string;
137
+ S3_SECRET_KEY: string;
138
+ S3_SECRET_ACCESS_KEY: string;
139
+ AWS_SECRET_ACCESS_KEY: string;
140
+ }
141
+
142
+ export interface IServiceConfig extends IServicePlatformEnvironment {
104
143
  PROJECT_NAME: string;
105
144
  MONGODB_HOST: string;
106
145
  MONGODB_NAME: string;
@@ -136,6 +175,231 @@ export interface IServiceConfig {
136
175
  ELASTICSEARCH_URL: string;
137
176
  }
138
177
 
178
+ /** The fields derived from GitZone's database and object-storage primitives. */
179
+ export type TDerivedServiceConnectionEnvironment = IServicePlatformEnvironment &
180
+ Pick<IServiceConfig, 'MONGODB_URL'>;
181
+
182
+ /** Every runtime field that is not derived by `deriveServiceConnectionEnvironment`. */
183
+ export type TServiceConfigPrimitives = Omit<IServiceConfig, keyof TDerivedServiceConnectionEnvironment>;
184
+
185
+ /** The primitives the connection environment is derived from. */
186
+ export type TServiceConnectionPrimitives = Pick<
187
+ IServiceConfig,
188
+ | 'MONGODB_HOST'
189
+ | 'MONGODB_PORT'
190
+ | 'MONGODB_NAME'
191
+ | 'MONGODB_USER'
192
+ | 'MONGODB_PASS'
193
+ | 'MONGODB_AUTH_ENABLED'
194
+ | 'S3_HOST'
195
+ | 'S3_ENDPOINT'
196
+ | 'S3_PORT'
197
+ | 'S3_USESSL'
198
+ | 'S3_REGION'
199
+ | 'S3_ACCESSKEY'
200
+ | 'S3_SECRETKEY'
201
+ >;
202
+
203
+ // A complete record, so the compiler proves the name list matches the type.
204
+ const derivedConnectionFieldPresence: {
205
+ [TName in keyof TDerivedServiceConnectionEnvironment]-?: true;
206
+ } = {
207
+ MONGODB_URL: true,
208
+ MONGODB_URI: true,
209
+ MONGO_URL: true,
210
+ MONGODB_DATABASE: true,
211
+ MONGO_DBNAME: true,
212
+ MONGODB_USERNAME: true,
213
+ MONGO_DBUSER: true,
214
+ MONGODB_PASSWORD: true,
215
+ MONGO_DBPASS: true,
216
+ AWS_ENDPOINT_URL: true,
217
+ S3_ENDPOINT_HOST: true,
218
+ S3_USE_SSL: true,
219
+ AWS_REGION: true,
220
+ AWS_S3_FORCE_PATH_STYLE: true,
221
+ S3_ACCESS_KEY: true,
222
+ S3_ACCESS_KEY_ID: true,
223
+ AWS_ACCESS_KEY_ID: true,
224
+ S3_SECRET_KEY: true,
225
+ S3_SECRET_ACCESS_KEY: true,
226
+ AWS_SECRET_ACCESS_KEY: true,
227
+ };
228
+
229
+ /** Names of every derived connection field, in `.nogit/env.json` order. */
230
+ export const serviceDerivedConnectionFieldNames = Object.keys(
231
+ derivedConnectionFieldPresence,
232
+ ) as Array<keyof TDerivedServiceConnectionEnvironment>;
233
+
234
+ /** Platform credential names that exist only while MongoDB auth is enabled. */
235
+ const platformDatabaseCredentialFields = [
236
+ 'MONGODB_USERNAME',
237
+ 'MONGO_DBUSER',
238
+ 'MONGODB_PASSWORD',
239
+ 'MONGO_DBPASS',
240
+ ] as const;
241
+
242
+ /** Runtime fields whose value is or contains a secret; `services config --json` redacts them. */
243
+ export const serviceSecretEnvironmentNames: ReadonlyArray<keyof IServiceConfig> = [
244
+ 'MONGODB_ADMIN_PASSWORD',
245
+ 'S3_ACCESSKEY',
246
+ 'S3_SECRETKEY',
247
+ 'S3_ADMIN_PASSWORD',
248
+ 'MONGODB_URI',
249
+ 'MONGO_URL',
250
+ 'MONGODB_PASSWORD',
251
+ 'MONGO_DBPASS',
252
+ 'S3_ACCESS_KEY',
253
+ 'S3_ACCESS_KEY_ID',
254
+ 'AWS_ACCESS_KEY_ID',
255
+ 'S3_SECRET_KEY',
256
+ 'S3_SECRET_ACCESS_KEY',
257
+ 'AWS_SECRET_ACCESS_KEY',
258
+ ];
259
+
260
+ /**
261
+ * The MongoDB connection URI. The credential lives in `admin`, so a local URI
262
+ * authenticates there; the path names the database, and `directConnection`
263
+ * matches the standalone NoSQLDB node. Credentials and `authSource` are
264
+ * omitted when auth is disabled.
265
+ */
266
+ export const buildMongoConnectionUri = (
267
+ primitivesArg: TServiceConnectionPrimitives,
268
+ hostArg: string = primitivesArg.MONGODB_HOST,
269
+ ): string => {
270
+ const authEnabled = primitivesArg.MONGODB_AUTH_ENABLED !== false;
271
+ const credentials = authEnabled
272
+ ? `${primitivesArg.MONGODB_USER}:${primitivesArg.MONGODB_PASS}@`
273
+ : '';
274
+ const authQuery = authEnabled ? 'authSource=admin&' : '';
275
+ return `mongodb://${credentials}${hostArg}:${primitivesArg.MONGODB_PORT}/${primitivesArg.MONGODB_NAME}?${authQuery}directConnection=true`;
276
+ };
277
+
278
+ /** The object-storage endpoint the platform names describe. */
279
+ export interface IS3Endpoint {
280
+ /** Host only, exactly as written; an IPv6 address without brackets. */
281
+ host: string;
282
+ /** Endpoint origin, e.g. `http://localhost:29000`; the scheme's default port is omitted. */
283
+ origin: string;
284
+ useSsl: boolean;
285
+ }
286
+
287
+ const s3EndpointSchemePattern = /^([a-z][a-z0-9+.-]*):\/\//iu;
288
+
289
+ /** The port as a decimal string when `portTextArg` is a TCP port, otherwise undefined. */
290
+ const parseTcpPort = (portTextArg: string): string | undefined => {
291
+ if (!/^\d{1,5}$/u.test(portTextArg)) {
292
+ return undefined;
293
+ }
294
+ const port = Number(portTextArg);
295
+ return port >= 1 && port <= 65_535 ? String(port) : undefined;
296
+ };
297
+
298
+ /**
299
+ * Resolve the object-storage endpoint from `S3_ENDPOINT`, read but never
300
+ * rewritten. It is user-controlled and accepted in three forms:
301
+ *
302
+ * - a bare host or IP address (`localhost`, `::1`): scheme from `S3_USESSL`,
303
+ * port from `S3_PORT`;
304
+ * - `host:port` or `[ipv6]:port`: its port wins over `S3_PORT`, the scheme
305
+ * comes from `S3_USESSL`;
306
+ * - an origin, `http(s)://host[:port]`: a complete origin, so its scheme wins
307
+ * over `S3_USESSL` and its port, or the scheme's default port, over `S3_PORT`.
308
+ *
309
+ * The host is taken as written, so no URL normalization rewrites IPv4
310
+ * shorthand, IPv4-mapped IPv6, or letter case. User info, a path, a query, a
311
+ * fragment, a scheme other than `http`/`https`, and a port outside 1-65535 are
312
+ * not part of an origin and are not carried over. An endpoint without a host
313
+ * (`:9000`) takes its host from `S3_HOST`, as a missing `S3_ENDPOINT` does.
314
+ * Never throws: 8.0.0 loaded any non-empty `S3_ENDPOINT`.
315
+ */
316
+ export const resolveS3Endpoint = (primitivesArg: TServiceConnectionPrimitives): IS3Endpoint => {
317
+ let rest = primitivesArg.S3_ENDPOINT;
318
+ let useSsl = primitivesArg.S3_USESSL === true;
319
+ let port = primitivesArg.S3_PORT;
320
+ const schemeMatch = s3EndpointSchemePattern.exec(rest);
321
+ if (schemeMatch) {
322
+ rest = rest.slice(schemeMatch[0].length);
323
+ const scheme = schemeMatch[1].toLowerCase();
324
+ if (scheme === 'http' || scheme === 'https') {
325
+ useSsl = scheme === 'https';
326
+ port = useSsl ? '443' : '80';
327
+ }
328
+ }
329
+ const authority = rest.split(/[/?#]/u, 1)[0];
330
+ const hostPort = authority.slice(authority.lastIndexOf('@') + 1);
331
+
332
+ // `[ipv6]:port` or `host:port`; more than one colon without brackets is a bare IPv6 address.
333
+ let host = hostPort;
334
+ let portText: string | undefined;
335
+ const closingBracket = hostPort.startsWith('[') ? hostPort.indexOf(']') : -1;
336
+ const colon = hostPort.indexOf(':');
337
+ if (closingBracket > 0) {
338
+ host = hostPort.slice(1, closingBracket);
339
+ const afterBracket = hostPort.slice(closingBracket + 1);
340
+ portText = afterBracket.startsWith(':') ? afterBracket.slice(1) : undefined;
341
+ } else if (colon !== -1 && colon === hostPort.lastIndexOf(':')) {
342
+ host = hostPort.slice(0, colon);
343
+ portText = hostPort.slice(colon + 1);
344
+ }
345
+ const explicitPort = portText === undefined ? undefined : parseTcpPort(portText);
346
+ if (explicitPort) {
347
+ port = explicitPort;
348
+ }
349
+ if (!host) {
350
+ host = primitivesArg.S3_HOST;
351
+ }
352
+
353
+ const urlHost = host.includes(':') ? `[${host}]` : host;
354
+ const defaultPort = useSsl ? '443' : '80';
355
+ const portSuffix = port === defaultPort ? '' : `:${port}`;
356
+ return {
357
+ host,
358
+ origin: `${useSsl ? 'https' : 'http'}://${urlHost}${portSuffix}`,
359
+ useSsl,
360
+ };
361
+ };
362
+
363
+ /**
364
+ * Derive `MONGODB_URL` and the serve.zone capability environment from the
365
+ * primitives GitZone manages. The single mapping from primitives to both name
366
+ * sets.
367
+ */
368
+ export const deriveServiceConnectionEnvironment = (
369
+ primitivesArg: TServiceConnectionPrimitives,
370
+ ): TDerivedServiceConnectionEnvironment => {
371
+ const mongoUri = buildMongoConnectionUri(primitivesArg);
372
+ const mongoCredentials =
373
+ primitivesArg.MONGODB_AUTH_ENABLED !== false
374
+ ? {
375
+ MONGODB_USERNAME: primitivesArg.MONGODB_USER,
376
+ MONGO_DBUSER: primitivesArg.MONGODB_USER,
377
+ MONGODB_PASSWORD: primitivesArg.MONGODB_PASS,
378
+ MONGO_DBPASS: primitivesArg.MONGODB_PASS,
379
+ }
380
+ : {};
381
+ const s3Endpoint = resolveS3Endpoint(primitivesArg);
382
+ return {
383
+ MONGODB_URL: mongoUri,
384
+ MONGODB_URI: mongoUri,
385
+ MONGO_URL: mongoUri,
386
+ MONGODB_DATABASE: primitivesArg.MONGODB_NAME,
387
+ MONGO_DBNAME: primitivesArg.MONGODB_NAME,
388
+ ...mongoCredentials,
389
+ AWS_ENDPOINT_URL: s3Endpoint.origin,
390
+ S3_ENDPOINT_HOST: s3Endpoint.host,
391
+ S3_USE_SSL: String(s3Endpoint.useSsl),
392
+ AWS_REGION: primitivesArg.S3_REGION,
393
+ AWS_S3_FORCE_PATH_STYLE: 'true',
394
+ S3_ACCESS_KEY: primitivesArg.S3_ACCESSKEY,
395
+ S3_ACCESS_KEY_ID: primitivesArg.S3_ACCESSKEY,
396
+ AWS_ACCESS_KEY_ID: primitivesArg.S3_ACCESSKEY,
397
+ S3_SECRET_KEY: primitivesArg.S3_SECRETKEY,
398
+ S3_SECRET_ACCESS_KEY: primitivesArg.S3_SECRETKEY,
399
+ AWS_SECRET_ACCESS_KEY: primitivesArg.S3_SECRETKEY,
400
+ };
401
+ };
402
+
139
403
  const runtimeStringFields: Array<keyof IServiceConfig> = [
140
404
  'PROJECT_NAME',
141
405
  'MONGODB_HOST',
@@ -159,6 +423,19 @@ const runtimeStringFields: Array<keyof IServiceConfig> = [
159
423
  'ELASTICSEARCH_USER',
160
424
  'ELASTICSEARCH_PASS',
161
425
  'ELASTICSEARCH_URL',
426
+ 'MONGODB_URI',
427
+ 'MONGO_URL',
428
+ 'MONGODB_DATABASE',
429
+ 'MONGO_DBNAME',
430
+ 'AWS_ENDPOINT_URL',
431
+ 'S3_ENDPOINT_HOST',
432
+ 'AWS_REGION',
433
+ 'S3_ACCESS_KEY',
434
+ 'S3_ACCESS_KEY_ID',
435
+ 'AWS_ACCESS_KEY_ID',
436
+ 'S3_SECRET_KEY',
437
+ 'S3_SECRET_ACCESS_KEY',
438
+ 'AWS_SECRET_ACCESS_KEY',
162
439
  ];
163
440
 
164
441
  const runtimePortFields: Array<keyof IServiceConfig> = [
@@ -200,6 +477,21 @@ export const assertCanonicalServiceRuntimeConfig: (
200
477
  if (config.S3_PORT === config.S3_UI_PORT) {
201
478
  throw new Error('.nogit/env.json S3 API and UI ports must differ.');
202
479
  }
480
+ if (config.S3_USE_SSL !== 'true' && config.S3_USE_SSL !== 'false') {
481
+ throw new Error('.nogit/env.json field S3_USE_SSL must be the string "true" or "false".');
482
+ }
483
+ if (config.AWS_S3_FORCE_PATH_STYLE !== 'true') {
484
+ throw new Error('.nogit/env.json field AWS_S3_FORCE_PATH_STYLE must be the string "true".');
485
+ }
486
+ for (const field of platformDatabaseCredentialFields) {
487
+ if (config.MONGODB_AUTH_ENABLED) {
488
+ if (typeof config[field] !== 'string' || !(config[field] as string).trim()) {
489
+ throw new Error(`.nogit/env.json field ${field} must be a non-empty string.`);
490
+ }
491
+ } else if (Object.hasOwn(config, field)) {
492
+ throw new Error(`.nogit/env.json field ${field} must be absent while MongoDB auth is disabled.`);
493
+ }
494
+ }
203
495
  };
204
496
 
205
497
  export class ServiceConfiguration {
@@ -287,25 +579,30 @@ export class ServiceConfiguration {
287
579
  }
288
580
 
289
581
  /**
290
- * Build MONGODB_URL from the current fields.
291
- *
292
- * Credentials are omitted entirely when auth is disabled, so the stored URL
293
- * never advertises a username that the engine would not accept.
582
+ * Recompute every derived field from the primitive ones.
294
583
  */
295
- private buildMongoUrl(): string {
296
- const credentials = this.isMongoAuthEnabled()
297
- ? `${this.config.MONGODB_USER}:${this.config.MONGODB_PASS}@`
298
- : '';
299
- const authQuery = this.isMongoAuthEnabled() ? '?authSource=admin' : '';
300
- return `mongodb://${credentials}${this.config.MONGODB_HOST}:${this.config.MONGODB_PORT}/${this.config.MONGODB_NAME}${authQuery}`;
584
+ private updateDerivedFields(): void {
585
+ this.reconcileDerivedConnectionFields();
586
+ this.config.ELASTICSEARCH_URL = `http://${this.config.ELASTICSEARCH_USER}:${this.config.ELASTICSEARCH_PASS}@${this.config.ELASTICSEARCH_HOST}:${this.config.ELASTICSEARCH_PORT}`;
301
587
  }
302
588
 
303
589
  /**
304
- * Recompute every derived field from the primitive ones.
590
+ * Rewrite `MONGODB_URL` and the serve.zone capability environment from the
591
+ * primitives, in place, and drop the platform database credential names while
592
+ * auth is disabled. Returns the names whose value changed, never the values.
305
593
  */
306
- private updateDerivedFields(): void {
307
- this.config.MONGODB_URL = this.buildMongoUrl();
308
- this.config.ELASTICSEARCH_URL = `http://${this.config.ELASTICSEARCH_USER}:${this.config.ELASTICSEARCH_PASS}@${this.config.ELASTICSEARCH_HOST}:${this.config.ELASTICSEARCH_PORT}`;
594
+ private reconcileDerivedConnectionFields(): string[] {
595
+ const previous: Partial<IServiceConfig> = { ...this.config };
596
+ const derived = deriveServiceConnectionEnvironment(this.config);
597
+ Object.assign(this.config, derived);
598
+ for (const field of platformDatabaseCredentialFields) {
599
+ if (!Object.hasOwn(derived, field)) {
600
+ delete this.config[field];
601
+ }
602
+ }
603
+ return serviceDerivedConnectionFieldNames.filter(
604
+ (fieldArg) => previous[fieldArg] !== this.config[fieldArg],
605
+ );
309
606
  }
310
607
 
311
608
  /**
@@ -406,6 +703,8 @@ export class ServiceConfiguration {
406
703
  * Save the configuration to file
407
704
  */
408
705
  public async saveConfig(): Promise<void> {
706
+ // Derived connection fields never reach disk stale, whichever primitive changed.
707
+ this.reconcileDerivedConnectionFields();
409
708
  assertCanonicalServiceRuntimeConfig(this.config);
410
709
  await withInterProcessLock(
411
710
  {
@@ -504,14 +803,13 @@ export class ServiceConfiguration {
504
803
  const esUser = 'elastic';
505
804
  const esPass = 'elastic';
506
805
 
507
- this.config = {
806
+ const primitives: TServiceConfigPrimitives = {
508
807
  PROJECT_NAME: projectName,
509
808
  MONGODB_HOST: mongoHost,
510
809
  MONGODB_NAME: mongoName,
511
810
  MONGODB_PORT: mongoPortStr,
512
811
  MONGODB_USER: mongoUser,
513
812
  MONGODB_PASS: mongoPass,
514
- MONGODB_URL: `mongodb://${mongoUser}:${mongoPass}@${mongoHost}:${mongoPortStr}/${mongoName}?authSource=admin`,
515
813
  MONGODB_AUTH_ENABLED: true,
516
814
  MONGODB_ADMIN_PASSWORD: plugins.crypto.randomBytes(24).toString('base64url'),
517
815
  S3_HOST: s3Host,
@@ -530,6 +828,7 @@ export class ServiceConfiguration {
530
828
  ELASTICSEARCH_PASS: esPass,
531
829
  ELASTICSEARCH_URL: `http://${esUser}:${esPass}@${esHost}:${esPort}`
532
830
  };
831
+ this.config = { ...primitives, ...deriveServiceConnectionEnvironment(primitives) };
533
832
 
534
833
  assertCanonicalServiceRuntimeConfig(this.config);
535
834
  await this.saveConfig();
@@ -593,14 +892,6 @@ export class ServiceConfiguration {
593
892
  updated = true;
594
893
  }
595
894
 
596
- // Always update MONGODB_URL based on current settings
597
- const oldUrl = this.config.MONGODB_URL;
598
- this.config.MONGODB_URL = this.buildMongoUrl();
599
- if (oldUrl !== this.config.MONGODB_URL) {
600
- fieldsAdded.push('MONGODB_URL');
601
- updated = true;
602
- }
603
-
604
895
  if (!this.config.S3_HOST) {
605
896
  this.config.S3_HOST = 'localhost';
606
897
  fieldsAdded.push('S3_HOST');
@@ -659,6 +950,13 @@ export class ServiceConfiguration {
659
950
  updated = true;
660
951
  }
661
952
 
953
+ // Always rederive MONGODB_URL and the serve.zone capability environment.
954
+ const reconciledFields = this.reconcileDerivedConnectionFields();
955
+ if (reconciledFields.length > 0) {
956
+ fieldsAdded.push(...reconciledFields);
957
+ updated = true;
958
+ }
959
+
662
960
  if (!this.config.ELASTICSEARCH_HOST) {
663
961
  this.config.ELASTICSEARCH_HOST = 'localhost';
664
962
  fieldsAdded.push('ELASTICSEARCH_HOST');
@@ -705,11 +1003,7 @@ export class ServiceConfiguration {
705
1003
  */
706
1004
  public getMongoConnectionString(useNetworkIp: boolean = false): string {
707
1005
  const host = useNetworkIp ? '${networkIp}' : this.config.MONGODB_HOST;
708
- const credentials = this.isMongoAuthEnabled()
709
- ? `${this.config.MONGODB_USER}:${this.config.MONGODB_PASS}@`
710
- : '';
711
- const authQuery = this.isMongoAuthEnabled() ? 'authSource=admin&' : '';
712
- return `mongodb://${credentials}${host}:${this.config.MONGODB_PORT}/${this.config.MONGODB_NAME}?${authQuery}directConnection=true`;
1006
+ return buildMongoConnectionUri(this.config, host);
713
1007
  }
714
1008
 
715
1009
  /**
@@ -3,6 +3,7 @@ import * as helpers from "./helpers.js";
3
3
  import { ServiceManager } from "./classes.servicemanager.js";
4
4
  import { GlobalRegistry } from "./classes.globalregistry.js";
5
5
  import { getServiceDataDirectory } from "./classes.servicedatamarker.js";
6
+ import { serviceSecretEnvironmentNames } from "./classes.serviceconfiguration.js";
6
7
  import {
7
8
  allowedServiceNames,
8
9
  normalizeUserServiceName,
@@ -209,18 +210,25 @@ async function updateEnabledServices(services: string[]): Promise<void> {
209
210
  await writeSmartconfigFile(smartconfigData);
210
211
  }
211
212
 
213
+ /** Replace every secret-bearing runtime field that is present with `***`. */
214
+ function redactServiceEnvironment(
215
+ environmentArg: Record<string, unknown>,
216
+ ): Record<string, unknown> {
217
+ const redacted = { ...environmentArg };
218
+ for (const name of serviceSecretEnvironmentNames) {
219
+ if (Object.hasOwn(redacted, name)) {
220
+ redacted[name] = "***";
221
+ }
222
+ }
223
+ return redacted;
224
+ }
225
+
212
226
  async function handleShowConfig(mode: ICliMode) {
213
227
  const configData = await readServicesConfig();
214
228
 
215
229
  if (mode.json) {
216
230
  const environment = configData.environment
217
- ? {
218
- ...configData.environment,
219
- S3_ACCESSKEY: "***",
220
- S3_SECRETKEY: "***",
221
- S3_ADMIN_PASSWORD: "***",
222
- MONGODB_ADMIN_PASSWORD: "***",
223
- }
231
+ ? redactServiceEnvironment(configData.environment)
224
232
  : null;
225
233
  printJson({ ...configData, environment });
226
234
  return;