@nsshunt/stsconfig 1.24.13 → 1.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/stsconfig.ts CHANGED
@@ -9,482 +9,515 @@ import { STSOptions } from './index'
9
9
 
10
10
  import dotenv from 'dotenv'
11
11
 
12
- export class STSConfig {
12
+ let envOptions: STSOptions | null = null;
13
13
 
14
- static #envOptions: STSOptions | null = null;
14
+ // Order for config settings
15
+ // -------------------------
16
+ // Passwords;
17
+ // Use password specified within a database password file (if present)
18
+ // Fall back to use a password from an environment variable
15
19
 
16
- // Order for config settings
17
- // -------------------------
18
- // Passwords;
19
- // Use password specified within a database password file (if present)
20
- // Fall back to use a password from an environment variable
20
+ function SetupConfig(): STSOptions {
21
21
 
22
- #SetupConfig(): STSOptions {
22
+ // Add tthe STSENVFILE to script run commands in order to use the require .env file for configuration
23
+ const envfile = (process.env.STSENVFILE === undefined ? '/.env' : process.env.STSENVFILE);
23
24
 
24
- // Add tthe STSENVFILE to script run commands in order to use the require .env file for configuration
25
- const envfile = (process.env.STSENVFILE === undefined ? '/.env' : process.env.STSENVFILE);
25
+ //require('dotenv').config({ path: envfile });
26
+ //const dotenv = await import('dotenv');
27
+ dotenv.config({ path: envfile })
26
28
 
27
- //require('dotenv').config({ path: envfile });
28
- //const dotenv = await import('dotenv');
29
- dotenv.config({ path: envfile })
30
-
31
- const defconfig: STSOptions =
32
- {
29
+ const defconfig: STSOptions =
30
+ {
33
31
  // Node runtime environment
34
- isProduction: (process.env.NODE_ENV === undefined ? false : (process.env.NODE_ENV === 'production' ? true : false))
35
- // Node runtime environment
36
- ,isTest: (process.env.NODE_ENV === undefined ? false : (process.env.NODE_ENV === 'test' ? true : false))
37
- // Log error messages to the console within the microservice
38
- ,consoleLogErrors: (process.env.CONSOLE_LOG_ERRORS === undefined ? false : (process.env.CONSOLE_LOG_ERRORS === "true" ? true : false ))
39
- // Database username.
40
- ,dbuser: (process.env.DB_USER === undefined ? 'postgres' : process.env.DB_USER)
41
- // Database password.
42
- ,dbpassword: (process.env.DB_PASSWORD === undefined ? 'postgres' : process.env.DB_PASSWORD)
43
- // Database password file
44
- ,dbpasswordfile: process.env.DB_PASSWORD_FILE
45
- // Database host
46
- ,dbhost: (process.env.DB_HOST === undefined ? 'localhost' : process.env.DB_HOST)
47
- // Database port
48
- ,dbport: (process.env.DB_PORT === undefined ? '5432' : process.env.DB_PORT)
49
- // Database name.
50
- ,database: (process.env.DB_DATABASE === undefined ? 'stsrestmsdb01' : process.env.DB_DATABASE) // STS REST MicroService Database 01
51
- // Database connection string to be used in production mode
52
- ,databaseUrl: process.env.DATABASE_URL
53
- // Database script(s) folder
54
- ,databasescriptfolder: (process.env.DB_SCRIPT_FOLDER === undefined ? "/var/lib/sts/stsglobalresources/db-scripts" : process.env.DB_SCRIPT_FOLDER)
55
- // Computed connection string to be used in development mode.
56
- ,connectionString: ''
57
- // Default computed connection string for postgres. Database name = postgres. Used by utilites that create and/or update the STS database(s).
58
- ,defaultDatabaseConnectionString: ''
59
-
60
- // The maximum pool size for pg. There will be one pool per thread.
61
- ,poolSize: (process.env.POOL_SIZE === undefined ? 500 : parseInt(process.env.POOL_SIZE))
62
- // Maximum number of CPUs (incl. logical processors) to use within the Microservice.
63
- // Use -1 to use all available within the runtime container. Each CPU will spawn a node work thread.
64
- ,useCPUs: (process.env.MAX_CPU === undefined ? -1 : parseFloat(process.env.MAX_CPU))
65
- // Automatically re-spawn a worker thread if one dies.
66
- ,respawnOnFail: (process.env.RESPAWN === undefined ? false : (process.env.RESPAWN === "true" ? true : false ))
67
- // Default number of entries to create for a fresh database.
68
- ,defaultDatabaseEntries: (process.env.DEFAULT_DB_ENTRIES === undefined ? 10000 : parseInt(process.env.DEFAULT_DB_ENTRIES))
69
- // Microservice listen port.
70
- ,useRedis: (process.env.USE_REDIS === undefined ? false : (process.env.USE_REDIS === "true" ? true : false ))
71
- // Use redis for Microservice.
72
- ,useL1Redis: (process.env.USE_L1_REDIS === undefined ? false : (process.env.USE_L1_REDIS === "true" ? true : false ))
73
- // Automatically flush the redis cache when terminating the Microservice.
74
- ,endFlush: (process.env.REDIS_END_FLUSH === undefined ? false : (process.env.REDIS_END_FLUSH === "true" ? true : false ))
75
- // Redis server port.
76
- ,redisPort: (process.env.REDIS_PORT === undefined ? '6379' : process.env.REDIS_PORT)
77
- // Redis server endpoint.
78
- ,redisServer: (process.env.REDIS_SERVER === undefined ? 'localhost' : process.env.REDIS_SERVER)
79
- // Default K6 test script path
80
- ,k6ScriptPath: (process.env.K6SCRIPTPATH === undefined ? "." : process.env.K6SCRIPTPATH)
81
- // Default number of entries to create for a fresh database.
82
- ,defaultDatabaseMinExtraDataSize: (process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE === undefined ? 0 : parseInt(process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE))
83
- // Default number of entries to create for a fresh database.
84
- ,defaultDatabaseMaxExtraDataSize: (process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE === undefined ? 2000 : parseInt(process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE))
85
-
86
- // STSREST01 Server endpoint
87
- ,rest01endpoint: (process.env.REST01_ENDPOINT === undefined ? "https://localhost" : process.env.REST01_ENDPOINT)
88
- // STSREST01 Server port (listen port for the service)
89
- ,rest01hostport: (process.env.REST01_HOST_PORT === undefined ? "3003" : process.env.REST01_HOST_PORT)
90
- // STSREST01 Server port (client port to access the service)
91
- ,rest01port: (process.env.REST01_PORT === undefined ? "3003" : process.env.REST01_PORT)
92
- // STSREST01 Server endpoint
93
- ,rest01apiroot: (process.env.REST01_APIROOT === undefined ? "/stsrest01/v1" : process.env.REST01_APIROOT)
94
- // STSREST01 API Identifier. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
95
- ,rest01apiidentifier: process.env.REST01_API_IDENTIFIER
96
- // STSREST01 API Identifier file. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
97
- ,rest01apiidentifierfile: process.env.REST01_API_IDENTIFIER_FILE
98
- // STSREST01 Prometheus metric support
99
- ,rest01prometheussupport: (process.env.REST01_PROM_SUPPORT === undefined ? true : (process.env.REST01_PROM_SUPPORT === "true" ? true : false))
100
- // STSREST01 Cluster Server port (port used for cluster prometheus scrapes). Service will listen on this port at mount point /metrics
101
- ,rest01prometheusclusterport: (process.env.REST01_PROM_CLUSTER_PORT === undefined ? "3013" : process.env.REST01_PROM_CLUSTER_PORT)
102
- // STSREST01 Service Name
103
- ,rest01servicename: (process.env.REST01_SERVICE_NAME === undefined ? "STSRest01" : process.env.REST01_SERVICE_NAME)
104
- // STSREST01 Service Version
105
- ,rest01serviceversion: (process.env.REST01_SERVICE_VERSION === undefined ? "1.0.0" : process.env.REST01_SERVICE_VERSION)
106
- // STSREST01 Server client ID. Used for oauth2 client credentials flow.
107
- // Ref: https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow
108
- // Ref: https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-client-credentials-flow
109
- ,rest01clientid: process.env.REST01_CLIENT_ID
110
- // STSREST01 Server client ID file. Used for oauth2 client credentials flow.
111
- ,rest01clientidfile: process.env.REST01_CLIENT_ID_FILE
112
- // STSREST01 Server client secret. Used for oauth2 client credentials flow.
113
- ,rest01clientsecret: process.env.REST01_CLIENT_SECRET
114
- // STSREST01 Server client secret file. Used for oauth2 client credentials flow.
115
- ,rest01clientsecretfile: process.env.REST01_CLIENT_SECRET_FILE
116
-
117
- // STS Instrument Manager Service endpoint
118
- ,imendpoint: (process.env.IM_ENDPOINT === undefined ? "https://localhost" : process.env.IM_ENDPOINT)
119
- // STS Instrument Manager Service listen port (listen port for the service)
120
- ,imhostport: (process.env.IM_HOST_PORT === undefined ? "3001" : process.env.IM_HOST_PORT)
121
- // STS Instrument Manager Service client access port (client port to access the service)
122
- ,import: (process.env.IM_PORT === undefined ? "3001" : process.env.IM_PORT)
123
- // STS Instrument Manager Service endpoint
124
- ,imapiroot: (process.env.IM_APIROOT === undefined ? "/stsinstrumentmanager/v1" : process.env.IM_APIROOT)
125
- // Instrument Manager API Identifier. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
126
- ,imapiidentifier: process.env.IM_API_IDENTIFIER
127
- // Instrument Manager API Identifier file. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
128
- ,imapiidentifierfile: process.env.IM_API_IDENTIFIER_FILE
129
- // STS Instrument Manager Prometheus metric support
130
- ,imprometheussupport: (process.env.IM_PROM_SUPPORT === undefined ? true : (process.env.IM_PROM_SUPPORT === "true" ? true : false ))
131
- // STS Instrument Manager Cluster Server port (port used for cluster prometheus scrapes)
132
- ,imprometheusclusterport: (process.env.IM_PROM_CLUSTER_PORT === undefined ? "3011" : process.env.IM_PROM_CLUSTER_PORT)
133
- // STS Instrument Manager Service Name
134
- ,imservicename: (process.env.IM_SERVICE_NAME === undefined ? "STSInstrumentManager" : process.env.IM_SERVICE_NAME)
135
- // STS Instrument Manager Service Version
136
- ,imserviceversion: (process.env.IM_SERVICE_VERSION === undefined ? "1.0.0" : process.env.IM_SERVICE_VERSION)
137
- // STS Instrument Manager Server client ID. Used for oauth2 client credentials flow.
138
- ,imclientid: process.env.IM_CLIENT_ID
139
- // STS Instrument Manager Server client ID file. Used for oauth2 client credentials flow.
140
- ,imclientidfile: process.env.IM_CLIENT_ID_FILE
141
- // STS Instrument Manager Server client secret. Used for oauth2 client credentials flow.
142
- ,imclientsecret: process.env.IM_CLIENT_SECRET
143
- // STS Instrument Manager Server client secret file. Used for oauth2 client credentials flow.
144
- ,imclientsecretfile: process.env.IM_CLIENT_SECRET_FILE
145
-
146
- // STS Test Orchestrator Service endpoint
147
- ,toendpoint: (process.env.TO_ENDPOINT === undefined ? "https://localhost" : process.env.TO_ENDPOINT)
148
- // STS Test Orchestrator Service listen port (listen port for the service)
149
- ,tohostport: (process.env.TO_HOST_PORT === undefined ? "3004" : process.env.TO_HOST_PORT)
150
- // STS Test Orchestrator Service client access port (client port to access the service)
151
- ,toport: (process.env.TO_PORT === undefined ? "3004" : process.env.TO_PORT)
152
- // STS Test Orchestrator Service endpoint
153
- ,toapiroot: (process.env.TO_APIROOT === undefined ? "/ststestorchestrator/v1" : process.env.TO_APIROOT)
154
- // Test Orchestrator API Identifier. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
155
- ,toapiidentifier: process.env.TO_API_IDENTIFIER
156
- // Test Orchestrator API Identifier file. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
157
- ,toapiidentifierfile: process.env.TO_API_IDENTIFIER_FILE
158
- // STS Test Orchestrator Prometheus metric support
159
- ,toprometheussupport: (process.env.TO_PROM_SUPPORT === undefined ? true : (process.env.TO_PROM_SUPPORT === "true" ? true : false ))
160
- // STS Test Orchestrator Cluster Server port (port used for cluster prometheus scrapes)
161
- ,toprometheusclusterport: (process.env.TO_PROM_CLUSTER_PORT === undefined ? "3014" : process.env.TO_PROM_CLUSTER_PORT)
162
- // STS Test Orchestrator Service Name
163
- ,toservicename: (process.env.TO_SERVICE_NAME === undefined ? "STSTestOrchestrator" : process.env.TO_SERVICE_NAME)
164
- // STS Test Orchestrator Service Version
165
- ,toserviceversion: (process.env.TO_SERVICE_VERSION === undefined ? "1.0.0" : process.env.TO_SERVICE_VERSION)
166
- // STS Test Orchestrator Server client ID. Used for oauth2 client credentials flow.
167
- ,toclientid: process.env.TO_CLIENT_ID
168
- // STS Test Orchestrator Server client ID file. Used for oauth2 client credentials flow.
169
- ,toclientidfile: process.env.TO_CLIENT_ID_FILE
170
- // STS Test Orchestrator Server client secret. Used for oauth2 client credentials flow.
171
- ,toclientsecret: process.env.TO_CLIENT_SECRET
172
- // STS Test Orchestrator Server client secret file. Used for oauth2 client credentials flow.
173
- ,toclientsecretfile: process.env.TO_CLIENT_SECRET_FILE
174
-
175
- // STS Auth Server
176
- // ---------------
177
- // The auth server assumes the roles as an Identify Provider ([TODO]) and Token Server (OAuth2.0).
178
- //
179
- // Auth Server endpoint
180
- ,asendpoint: (process.env.AS_ENDPOINT === undefined ? "https://localhost" : process.env.AS_ENDPOINT)
181
- // Auth Server host port (listen port for the service)
182
- ,ashostport: (process.env.AS_HOST_PORT === undefined ? "3002" : process.env.AS_HOST_PORT)
183
- // Auth Server port (client port to access the service)
184
- ,asport: (process.env.AS_PORT === undefined ? "3002" : process.env.AS_PORT)
185
- // Auth Server API root.
186
- ,asapiroot: (process.env.AS_API_ROOT === undefined ? "/stsauth/v1.0" : process.env.AS_API_ROOT)
187
- // Auth Server OAuth2 API root.
188
- ,asoauthapiroot: (process.env.AS_OAUTH_API_ROOT === undefined ? "/oauth2/v2.0" : process.env.AS_OAUTH_API_ROOT)
189
- // Auth Server Admin API root.
190
- ,asadminapiroot: (process.env.AS_ADMIN_API_ROOT === undefined ? "/admin/v1.0" : process.env.AS_ADMIN_API_ROOT)
191
- // Auth Server API Identifier.
192
- ,asapiidentifier: (process.env.AS_API_IDENTIFIER === undefined ? 'https://stsmda.com.au/stsauthapi/v1.0/' : process.env.AS_API_IDENTIFIER)
193
- // Auth Server API Identifier file.
194
- ,asapiidentifierfile: process.env.AS_API_IDENTIFIER_FILE
195
- // Auth Server OAuth API Identifier.
196
- ,asoauthapiidentifier: (process.env.AS_OAUTH_API_IDENTIFIER === undefined ? 'https://stsmda.com.au/stsauthoauthapi/v2.0/' : process.env.AS_OAUTH_API_IDENTIFIER)
197
- // Auth Server OAuth API Identifier file.
198
- ,asoauthapiidentifierfile: process.env.AS_OAUTH_API_IDENTIFIER_FILE
199
- // Auth Server Administration API Identifier.
200
- ,asadminapiidentifier: (process.env.AS_ADMIN_API_IDENTIFIER === undefined ? 'https://stsmda.com.au/stsauthadminapi/v1.0/' : process.env.AS_ADMIN_API_IDENTIFIER)
201
- // Auth Server Administration API Identifier file.
202
- ,asadminapiidentifierfile: process.env.AS_ADMIN_API_IDENTIFIER_FILE
203
- // Auth Server Prometheus metric support
204
- ,asprometheussupport: (process.env.AS_PROM_SUPPORT === undefined ? true : (process.env.AS_PROM_SUPPORT === "true" ? true : false ))
205
- // Auth Prometheus Cluster Server port (port used for cluster prometheus scrapes)
206
- ,asprometheusclusterport: (process.env.AS_PROM_CLUSTER_PORT === undefined ? "3012" : process.env.AS_PROM_CLUSTER_PORT)
207
- // STSAuth Service Name
208
- ,asservicename: (process.env.AS_SERVICE_NAME === undefined ? "STSAuth" : process.env.AS_SERVICE_NAME)
209
- // STSAuth Service Version
210
- ,asserviceversion: (process.env.AS_SERVICE_VERSION === undefined ? "1.0.0" : process.env.AS_SERVICE_VERSION)
211
- // STS Auth Server client ID. Used for oauth2 client credentials flow.
212
- ,asclientid: process.env.AS_CLIENT_ID
213
- // STS Auth Server client ID file. Used for oauth2 client credentials flow.
214
- ,asclientidfile: process.env.AS_CLIENT_ID_FILE
215
- // STS Auth Server client secret. Used for oauth2 client credentials flow.
216
- ,asclientsecret: process.env.AS_CLIENT_SECRET
217
- // STS Auth Server client secret file. Used for oauth2 client credentials flow.
218
- ,asclientsecretfile: process.env.AS_CLIENT_SECRET_FILE
219
- // Auth Server - JWKS Public End Point.
220
- ,asjwksjsonpath: (process.env.AS_JWKS_JSON_PATH === undefined ? "/.well-known/jwks.json" : process.env.AS_JWKS_JSON_PATH)
221
- // Auth Server - JWKS key rotation time (seconds).
222
- ,asjwkskeyrotationtime: (process.env.AS_JWKS_KEY_ROTATION_TIME === undefined ? 86400 : parseInt(process.env.AS_JWKS_KEY_ROTATION_TIME)) // 24 Hour default
223
- // Auth Server - JWKS key purge time offset (seconds). Old keys (current keys are considered 'old' immediately after a key rotation) will be kept
224
- // for asaccesstokenexpire + asjwkskeypurgetimeoffset seconds before purging from the JWKS.
225
- ,asjwkskeypurgetimeoffset: (process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET === undefined ? 300 : parseInt(process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET)) // 5 Minutes
226
- // Auth Server - JWKS key count. Defines the number of active keys within the JWKS. Note that the actual key count may be double this value as current
227
- // keys are rotated to old keys prior to old key purge. Old keys will be kept for asaccesstokenexpire + asjwkskeypurgetimeoffset seconds before removal from the JWKS.
228
- // This is to ensure that any tokens signed by a current key that is then expired can still be validated within the life of the issued token.
229
- ,asjwkskeycount: (process.env.AS_JWKS_KEY_COUNT === undefined ? 4 : parseInt(process.env.AS_JWKS_KEY_COUNT))
230
- // Auth Server - JWKS Access token timeout.
231
- ,asaccesstokenexpire: (process.env.AS_ACCESS_TOKEN_EXPIRE === undefined ? 43200 : parseInt(process.env.AS_ACCESS_TOKEN_EXPIRE)) // 12 Hour default
232
-
233
- // STS Broker Server
234
- // ---------------
235
- // The STS broker server is a BFF service used for STS SPAs. The service will use 1st party secured cookies for session management.
236
- // The service also provides proxy API access to other STS and/or external services.
237
- //
238
- // STSBroker Server endpoint
239
- ,brokerendpoint: (process.env.BROKER_ENDPOINT === undefined ? "https://localhost" : process.env.BROKER_ENDPOINT)
240
- // STSBroker Server port (listen port for the service)
241
- ,brokerhostport: (process.env.BROKER_HOST_PORT === undefined ? "3006" : process.env.BROKER_HOST_PORT)
242
- // STSBroker Server port (client port to access the service)
243
- ,brokerport: (process.env.BROKER_PORT === undefined ? "3006" : process.env.BROKER_PORT)
244
- // STSBroker Server endpoint
245
- ,brokerapiroot: (process.env.BROKER_APIROOT === undefined ? "/stsbroker/v1.0" : process.env.BROKER_APIROOT)
246
- // STSBroker API Identifier. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
247
- ,brokerapiidentifier: process.env.BROKER_API_IDENTIFIER
248
- // STSBroker API Identifier file. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
249
- ,brokerapiidentifierfile: process.env.BROKER_API_IDENTIFIER_FILE
250
- // STSBroker Prometheus metric support
251
- ,brokerprometheussupport: (process.env.BROKER_PROM_SUPPORT === undefined ? true : (process.env.BROKER_PROM_SUPPORT === "true" ? true : false))
252
- // STSBroker Cluster Server port (port used for cluster prometheus scrapes). Service will listen on this port at mount point /metrics
253
- ,brokerprometheusclusterport: (process.env.BROKER_PROM_CLUSTER_PORT === undefined ? "3016" : process.env.BROKER_PROM_CLUSTER_PORT)
254
- // STSBroker Service Name
255
- ,brokerservicename: (process.env.BROKER_SERVICE_NAME === undefined ? "STSBroker" : process.env.BROKER_SERVICE_NAME)
256
- // STSBroker Service Version
257
- ,brokerserviceversion: (process.env.BROKER_SERVICE_VERSION === undefined ? "1.0.0" : process.env.BROKER_SERVICE_VERSION)
258
- // STSBroker Server client ID. Used for oauth2 client credentials flow.
259
- ,brokerclientid: process.env.BROKER_CLIENT_ID
260
- // STSBroker Server client ID file. Used for oauth2 client credentials flow.
261
- ,brokerclientidfile: process.env.BROKER_CLIENT_ID_FILE
262
- // STSBroker Server client secret. Used for oauth2 client credentials flow.
263
- ,brokerclientsecret: process.env.BROKER_CLIENT_SECRET
264
- // STSBroker Server client secret file. Used for oauth2 client credentials flow.
265
- ,brokerclientsecretfile: process.env.BROKER_CLIENT_SECRET_FILE
266
-
267
- // STS Test Runner Prometheus metric support
268
- ,trprometheussupport: (process.env.TR_PROM_SUPPORT === undefined ? true : (process.env.TR_PROM_SUPPORT === "true" ? true : false ))
269
- // STS Test Runner Cluster Server port (port used for cluster prometheus scrapes)
270
- ,trprometheusclusterport: (process.env.TR_PROM_CLUSTER_PORT === undefined ? "3015" : process.env.TR_PROM_CLUSTER_PORT)
271
- // STS Test Runner Service Name
272
- ,trservicename: (process.env.TR_SERVICE_NAME === undefined ? "STSRestRunner" : process.env.TR_SERVICE_NAME)
273
- // STS Test Runner Service Version
274
- ,trserviceversion: (process.env.TR_SERVICE_VERSION === undefined ? "1.0.0" : process.env.TR_SERVICE_VERSION)
275
- // STS Test Runner Server client ID. Used for oauth2 client credentials flow.
276
- ,trclientid: process.env.TR_CLIENT_ID
277
- // STS Test Runner Server client ID file. Used for oauth2 client credentials flow.
278
- ,trclientidfile: process.env.TR_CLIENT_ID_FILE
279
- // STS Test Runner Server client secret. Used for oauth2 client credentials flow.
280
- ,trclientsecret: process.env.TR_CLIENT_SECRET
281
- // STS Test Runner Server client secret file. Used for oauth2 client credentials flow.
282
- ,trclientsecretfile: process.env.TR_CLIENT_SECRET_FILE
283
-
284
- // Duration (in ms) between each publish event.
285
- ,publishinterval: (process.env.PUBLISH_INTERVAL === undefined ? 1000 : parseInt(process.env.PUBLISH_INTERVAL))
286
-
287
- // The maximum time (in ms) to wait before timeout error when publishing instruments. Ideally, this should always be lower than the publishinterval frequency
288
- // to avoid cascading http build up errors.
289
- ,publishtimeout: (process.env.PUBLISH_TIMEOUT === undefined ? 750 : parseInt(process.env.PUBLISH_TIMEOUT))
290
-
291
- // If true, instrument publish failures will be logged to debug output.
292
- ,publishdebug: (process.env.PUBLISH_DEBUG === undefined ? false : (process.env.PUBLISH_DEBUG === "true" ? true : false ))
293
-
294
- // Transport(s) to use for sending instrumentation data to the instrumentation server
295
- ,transport: (process.env.TRANSPORT === undefined ? 'RESTAPI' : process.env.TRANSPORT)
296
-
297
- /*
298
- // Instrument Defaults
299
- // Logger lines (sliding window size)
300
- ,instrumentLoggerSize: (process.env.INSTRUMENT_LOGGER_SIZE === undefined ? 200 : parseInt(process.env.INSTRUMENT_LOGGER_SIZE))
301
-
302
- // Histoogram bucket sizes (and default labels)
303
- ,instrumentHistogramBuckets: (process.env.INSTRUMENT_HISTOGRAM_BUCKETS === undefined ? [ 10, 20, 50, 100, 1000, 5000 ] : JSON.parse(process.env.INSTRUMENT_HISTOGRAM_BUCKETS))
304
-
305
- // Sample interval (ms)
306
- ,instrumentSampleInterval: (process.env.INSTRUMENT_SAMPLE_INTERVAL === undefined ? 1000 : parseInt(process.env.INSTRUMENT_SAMPLE_INTERVAL))
307
-
308
- // Sample size (number of readings to use for P(x) calculations. Time approx. (Sample Interval / 1000) * Sample Size, i.e. Caluclate P(x) on the observed data for the last 6 minutes.
309
- ,instrumentSampleSize: (process.env.INSTRUMENT_SAMPLE_SIZE === undefined ? 600 : parseInt(process.env.INSTRUMENT_SAMPLE_SIZE))
310
- */
311
-
312
- // Use secure cookies option when passing back cookies from STS services (such as STSAuth service).
313
- // This setting will be ignore for production mode. In production mode services will always use secure cookies.
314
- ,useSecureCookies: (process.env.USE_SECURE_COOKIES === undefined ? false : (process.env.USE_SECURE_COOKIES === "true" ? true : false ))
315
-
316
- // keepAlive <boolean> Keep sockets around even when there are no outstanding requests, so they can be used for future requests without having to reestablish a
317
- // TCP connection. Not to be confused with the keep-alive value of the Connection header. The Connection: keep-alive header is always sent when using an agent
318
- // except when the Connection header is explicitly specified or when the keepAlive and maxSockets options are respectively set to false and Infinity, in which
319
- // case Connection: close will be used. Default: false.
320
- // Reference: https://nodejs.org/api/http.html#class-httpagent
321
- ,keepAlive: (process.env.KEEP_ALIVE === undefined ? true : (process.env.KEEP_ALIVE === "true" ? true : false ))
322
-
323
- // maxSockets <number> Maximum number of sockets to allow per host. If the same host opens multiple concurrent connections, each request will use new socket until the
324
- // maxSockets value is reached. If the host attempts to open more connections than maxSockets, the additional requests will enter into a pending request queue, and will
325
- // enter active connection state when an existing connection terminates. This makes sure there are at most maxSockets active connections at any point in time,
326
- // from a given host. Default: Infinity.
327
- // Reference: https://nodejs.org/api/http.html#class-httpagent
328
- ,maxSockets: (process.env.MAX_SOCKETS === undefined ? 10 : parseInt(process.env.MAX_SOCKETS))
329
-
330
- // maxTotalSockets <number> Maximum number of sockets allowed for all hosts in total. Each request will use a new socket until the maximum is reached. Default: Infinity.
331
- // Reference: https://nodejs.org/api/http.html#class-httpagent
332
- ,maxTotalSockets: (process.env.MAX_TOTAL_SOCKETS === undefined ? 20 : parseInt(process.env.MAX_TOTAL_SOCKETS))
333
-
334
- // maxFreeSockets <number> Maximum number of sockets per host to leave open in a free state. Only relevant if keepAlive is set to true. Default: 256.
335
- // Reference: https://nodejs.org/api/http.html#class-httpagent
336
- ,maxFreeSockets: (process.env.MAX_FREE_SOCKETS === undefined ? 256 : parseInt(process.env.MAX_FREE_SOCKETS))
337
-
338
- // timeout <number> Socket timeout in milliseconds. This will set the timeout when the socket is created.
339
- // Reference: https://nodejs.org/api/http.html#class-httpagent
340
- ,timeout: (process.env.TIMEOUT === undefined ? 10000 : parseInt(process.env.TIMEOUT))
341
-
342
- // Maximum payload size allowed for express server calls
343
- ,maxPayloadSize: (process.env.MAX_PAYLOAD_SIZE === undefined ? '50mb' : process.env.MAX_PAYLOAD_SIZE)
344
-
345
- // Instrumentation Config Settings
346
- // -------------------------------
347
- // Generic interval (ms) to make on observation for instrumentation objects.
348
- ,instrumentationObservationInterval: (process.env.INSTRUMENTATION_OBSERVATION_INTERVAL === undefined ? 1000 : parseInt(process.env.INSTRUMENTATION_OBSERVATION_INTERVAL))
349
-
350
- // Generic sliding time window (seconds) for instrumentation objects that process telemetry over time (e.g. P(x) instruments).
351
- ,instrumentationTimeWindow: (process.env.INSTRUMENTATION_TIME_WINDOW === undefined ? 600 : parseInt(process.env.INSTRUMENTATION_TIME_WINDOW))
352
-
353
- // Service Specific Config Settings
354
- // --------------------------------
355
- // STSAuth
356
- // -------
357
- // Define the valid age for a JWT access token (in ms). Default 10 minutes.
358
- ,authJWTAccessTokenTimeout: (process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT === undefined ? 600 : parseInt(process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT))
359
-
360
- // Define the valid age for a JWT refresh token (in ms). Default 24 hours.
361
- ,authJWTRefreshTokenTimeout: (process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT === undefined ? (3600 * 24) : parseInt(process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT))
362
-
363
- // Define the valid age for an authentication/session cookie. Default 24 hours.
364
- ,authCookieTimeout: (process.env.AUTH_COOKIE_TIMEOUT === undefined ? (3600 * 24) : parseInt(process.env.AUTH_COOKIE_TIMEOUT))
365
-
366
- // STSAppFramework (library)
367
- // -------------------------
368
- // Define the time (ms) to wait prior to exiting the application (using process.exit(0))
369
- ,masterProcessExitTime: (process.env.MASTER_PROCESS_EXIT_TIME === undefined ? 500 : parseInt(process.env.MASTER_PROCESS_EXIT_TIME))
370
-
371
- // Define the time (ms) to wait prior to exiting the application (using process.exit(0))
372
- ,childProcessExitTime: (process.env.CHILD_PROCESS_EXIT_TIME === undefined ? 500 : parseInt(process.env.CHILD_PROCESS_EXIT_TIME))
373
-
374
- // Define the interval (ms) to collect system information for instrumentation purposes
375
- ,systemInformationInterval: (process.env.SYSTEM_INFORMATION_INTERVAL === undefined ? 1000 : parseInt(process.env.SYSTEM_INFORMATION_INTERVAL))
376
-
377
- // Ignore socket.io REST api calls and/or WebSocket calls when collecting telemetry for instrumentation purposes.
378
- ,ignoresocketio: (process.env.IGNORE_SOCKETIO === undefined ? true : (process.env.IGNORE_SOCKETIO === "true" ? true : false ))
379
-
380
- /*
381
- // STSModels (library)
382
- // -------------------
383
- // Define the interval for checking instrumentation updates on a instrumentation model. Entries in the model will be removed after this timeout value (ms) if no
384
- // activity has been detected. Default 5 seconds.
385
- ,modelPurgeUpdateTimeout: (process.env.MODEL_PURGE_UPDATE_TIMEOUT === undefined ? 5000 : parseInt(process.env.MODEL_PURGE_UPDATE_TIMEOUT))
386
- */
387
-
388
- // Use command below to create self signed cert;
389
- // openssl req -nodes -new -x509 -keyout server.key -out server.cert
390
- // Ref: https://www.geeksforgeeks.org/how-to-create-https-server-with-node-js/
391
- // HTTPS server key path.
392
- ,httpsserverkeypath: (process.env.HTTPS_SERVER_KEY_PATH === undefined ? "/var/lib/sts/stsglobalresources/keys/server.key" : process.env.HTTPS_SERVER_KEY_PATH)
393
- // HTTPS server cert path.
394
- ,httpsservercertpath: (process.env.HTTPS_SERVER_CERT_PATH === undefined ? "/var/lib/sts/stsglobalresources/keys/server.cert" : process.env.HTTPS_SERVER_CERT_PATH)
395
-
396
- // Token Service Settings
397
- // ----------------------
398
- // Maximum number of RSA keys in the JWKS store
399
- ,tsjwkskeys: (process.env.TS_JWKS_KEYS === undefined ? 3 : parseInt(process.env.TS_JWKS_KEYS))
400
-
401
- // File path for JWKS store data. This file will contain the public and private keys for the JWKS store.
402
- ,tsjwksstorepath: (process.env.TS_JWKS_STORE_PATH === undefined ? "/var/lib/sts/stsglobalresources/.stsauthprivate/jwks-private.json" : process.env.TS_JWKS_STORE_PATH)
403
- // File path for JWKS store path config setting (tsjwksstorepath). Use this config item with Docker/Kubernetes secrets.
404
- ,tsjwksstorepathfile: process.env.TS_JWKS_STORE_PATH_FILE
405
- // File path for JWKS public store data. This file will contain only the public signing keys for the JWKS store.
406
- ,tsjwksstorepublicpath: (process.env.TS_JWKS_STORE_PUBLIC_PATH === undefined ? "/var/lib/sts/stsglobalresources/.well-known/jwks.json" : process.env.TS_JWKS_STORE_PUBLIC_PATH)
407
-
408
- // JWKS Authentication Configuration Settings
409
- // Ref: https://github.com/auth0/node-jwks-rsa
410
- // Enables a LRU cache. Ref: https://github.com/auth0/node-jwks-rsa#caching
411
- ,jwksAuthConfigCache: (process.env.JWKS_AUTH_CONFIG_CACHE === undefined ? true : (process.env.JWKS_AUTH_CONFIG_CACHE === "true" ? true : false ))
412
-
413
- // Maximum number of LRU cache entries. Ref: https://github.com/auth0/node-jwks-rsa#caching
414
- ,jwksAuthConfigCacheMaxEntries: (process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES === undefined ? 5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES))
415
-
416
- // Maximum age of LRU cache entries. Ref: https://github.com/auth0/node-jwks-rsa#caching
417
- ,jwksAuthConfigCacheMaxAge: (process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE === undefined ? 600000 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE))
418
-
419
- // Enforce rate limiting for jwks public endpoint query. Ref: https://github.com/auth0/node-jwks-rsa#rate-limiting
420
- ,jwksAuthConfigRateLimit: (process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === undefined ? true : (process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === "true" ? true : false ))
421
-
422
- // Enforce rate limiting maximum number of requests per minute. Ref: https://github.com/auth0/node-jwks-rsa#rate-limiting
423
- ,jwksAuthConfigRateLimitRequestsPerMinute: (process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE === undefined ? 10 : parseInt(process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE))
424
-
425
- // Timeout for the public endpoint query. Note: This will be ignored if an http/https agent is specified.
426
- ,jwksAuthConfigTimeout: (process.env.JWKS_AUTH_CONFIG_TIMEOUT === undefined ? 30000 : parseInt(process.env.JWKS_AUTH_CONFIG_TIMEOUT))
427
- }
32
+ isProduction: (process.env.NODE_ENV === undefined ? false : (process.env.NODE_ENV === 'production' ? true : false))
33
+ // Node runtime environment
34
+ ,isTest: (process.env.NODE_ENV === undefined ? false : (process.env.NODE_ENV === 'test' ? true : false))
35
+ // Log error messages to the console within the microservice
36
+ ,consoleLogErrors: (process.env.CONSOLE_LOG_ERRORS === undefined ? false : (process.env.CONSOLE_LOG_ERRORS === "true" ? true : false ))
37
+ // Database username.
38
+ ,dbuser: (process.env.DB_USER === undefined ? 'postgres' : process.env.DB_USER)
39
+ // Database password.
40
+ ,dbpassword: (process.env.DB_PASSWORD === undefined ? 'postgres' : process.env.DB_PASSWORD)
41
+ // Database password file
42
+ ,dbpasswordfile: process.env.DB_PASSWORD_FILE
43
+ // Database host
44
+ ,dbhost: (process.env.DB_HOST === undefined ? 'localhost' : process.env.DB_HOST)
45
+ // Database port
46
+ ,dbport: (process.env.DB_PORT === undefined ? '5432' : process.env.DB_PORT)
47
+ // Database name.
48
+ ,database: (process.env.DB_DATABASE === undefined ? 'stsrestmsdb01' : process.env.DB_DATABASE) // STS REST MicroService Database 01
49
+ // Database connection string to be used in production mode
50
+ ,databaseUrl: process.env.DATABASE_URL
51
+ // Database script(s) folder
52
+ ,databasescriptfolder: (process.env.DB_SCRIPT_FOLDER === undefined ? "/var/lib/sts/stsglobalresources/db-scripts" : process.env.DB_SCRIPT_FOLDER)
53
+ // Computed connection string to be used in development mode.
54
+ ,connectionString: ''
55
+ // Default computed connection string for postgres. Database name = postgres. Used by utilites that create and/or update the STS database(s).
56
+ ,defaultDatabaseConnectionString: ''
57
+
58
+ // The maximum pool size for pg. There will be one pool per thread.
59
+ ,poolSize: (process.env.POOL_SIZE === undefined ? 500 : parseInt(process.env.POOL_SIZE))
60
+ // Maximum number of CPUs (incl. logical processors) to use within the Microservice.
61
+ // Use -1 to use all available within the runtime container. Each CPU will spawn a node work thread.
62
+ ,useCPUs: (process.env.MAX_CPU === undefined ? -1 : parseFloat(process.env.MAX_CPU))
63
+ // Automatically re-spawn a worker thread if one dies.
64
+ ,respawnOnFail: (process.env.RESPAWN === undefined ? false : (process.env.RESPAWN === "true" ? true : false ))
65
+ // Default number of entries to create for a fresh database.
66
+ ,defaultDatabaseEntries: (process.env.DEFAULT_DB_ENTRIES === undefined ? 10000 : parseInt(process.env.DEFAULT_DB_ENTRIES))
67
+ // Microservice listen port.
68
+ ,useRedis: (process.env.USE_REDIS === undefined ? false : (process.env.USE_REDIS === "true" ? true : false ))
69
+ // Use redis for Microservice.
70
+ ,useL1Redis: (process.env.USE_L1_REDIS === undefined ? false : (process.env.USE_L1_REDIS === "true" ? true : false ))
71
+ // Automatically flush the redis cache when terminating the Microservice.
72
+ ,endFlush: (process.env.REDIS_END_FLUSH === undefined ? false : (process.env.REDIS_END_FLUSH === "true" ? true : false ))
73
+ // Redis server port.
74
+ ,redisPort: (process.env.REDIS_PORT === undefined ? '6379' : process.env.REDIS_PORT)
75
+ // Redis server endpoint.
76
+ ,redisServer: (process.env.REDIS_SERVER === undefined ? 'localhost' : process.env.REDIS_SERVER)
77
+ // Default K6 test script path
78
+ ,k6ScriptPath: (process.env.K6SCRIPTPATH === undefined ? "." : process.env.K6SCRIPTPATH)
79
+ // Default number of entries to create for a fresh database.
80
+ ,defaultDatabaseMinExtraDataSize: (process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE === undefined ? 0 : parseInt(process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE))
81
+ // Default number of entries to create for a fresh database.
82
+ ,defaultDatabaseMaxExtraDataSize: (process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE === undefined ? 2000 : parseInt(process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE))
83
+
84
+ // STSREST01 Server endpoint
85
+ ,rest01endpoint: (process.env.REST01_ENDPOINT === undefined ? "https://localhost" : process.env.REST01_ENDPOINT)
86
+ // STSREST01 Server port (listen port for the service)
87
+ ,rest01hostport: (process.env.REST01_HOST_PORT === undefined ? "3003" : process.env.REST01_HOST_PORT)
88
+ // STSREST01 Server port (client port to access the service)
89
+ ,rest01port: (process.env.REST01_PORT === undefined ? "3003" : process.env.REST01_PORT)
90
+ // STSREST01 Server endpoint
91
+ ,rest01apiroot: (process.env.REST01_APIROOT === undefined ? "/stsrest01/v1" : process.env.REST01_APIROOT)
92
+ // STSREST01 API Identifier. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
93
+ ,rest01apiidentifier: process.env.REST01_API_IDENTIFIER
94
+ // STSREST01 API Identifier file. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
95
+ ,rest01apiidentifierfile: process.env.REST01_API_IDENTIFIER_FILE
96
+ // STSREST01 Prometheus metric support
97
+ ,rest01prometheussupport: (process.env.REST01_PROM_SUPPORT === undefined ? true : (process.env.REST01_PROM_SUPPORT === "true" ? true : false))
98
+ // STSREST01 Cluster Server port (port used for cluster prometheus scrapes). Service will listen on this port at mount point /metrics
99
+ ,rest01prometheusclusterport: (process.env.REST01_PROM_CLUSTER_PORT === undefined ? "3013" : process.env.REST01_PROM_CLUSTER_PORT)
100
+ // STSREST01 Service Name
101
+ ,rest01servicename: (process.env.REST01_SERVICE_NAME === undefined ? "STSRest01" : process.env.REST01_SERVICE_NAME)
102
+ // STSREST01 Service Version
103
+ ,rest01serviceversion: (process.env.REST01_SERVICE_VERSION === undefined ? "1.0.0" : process.env.REST01_SERVICE_VERSION)
104
+ // STSREST01 Server client ID. Used for oauth2 client credentials flow.
105
+ // Ref: https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow
106
+ // Ref: https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-client-credentials-flow
107
+ ,rest01clientid: process.env.REST01_CLIENT_ID
108
+ // STSREST01 Server client ID file. Used for oauth2 client credentials flow.
109
+ ,rest01clientidfile: process.env.REST01_CLIENT_ID_FILE
110
+ // STSREST01 Server client secret. Used for oauth2 client credentials flow.
111
+ ,rest01clientsecret: process.env.REST01_CLIENT_SECRET
112
+ // STSREST01 Server client secret file. Used for oauth2 client credentials flow.
113
+ ,rest01clientsecretfile: process.env.REST01_CLIENT_SECRET_FILE
114
+
115
+ // STS Instrument Manager Service endpoint
116
+ ,imendpoint: (process.env.IM_ENDPOINT === undefined ? "https://localhost" : process.env.IM_ENDPOINT)
117
+ // STS Instrument Manager Service listen port (listen port for the service)
118
+ ,imhostport: (process.env.IM_HOST_PORT === undefined ? "3001" : process.env.IM_HOST_PORT)
119
+ // STS Instrument Manager Service client access port (client port to access the service)
120
+ ,import: (process.env.IM_PORT === undefined ? "3001" : process.env.IM_PORT)
121
+ // STS Instrument Manager Service endpoint
122
+ ,imapiroot: (process.env.IM_APIROOT === undefined ? "/stsinstrumentmanager/v1" : process.env.IM_APIROOT)
123
+ // Instrument Manager API Identifier. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
124
+ ,imapiidentifier: process.env.IM_API_IDENTIFIER
125
+ // Instrument Manager API Identifier file. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
126
+ ,imapiidentifierfile: process.env.IM_API_IDENTIFIER_FILE
127
+ // STS Instrument Manager Prometheus metric support
128
+ ,imprometheussupport: (process.env.IM_PROM_SUPPORT === undefined ? true : (process.env.IM_PROM_SUPPORT === "true" ? true : false ))
129
+ // STS Instrument Manager Cluster Server port (port used for cluster prometheus scrapes)
130
+ ,imprometheusclusterport: (process.env.IM_PROM_CLUSTER_PORT === undefined ? "3011" : process.env.IM_PROM_CLUSTER_PORT)
131
+ // STS Instrument Manager Service Name
132
+ ,imservicename: (process.env.IM_SERVICE_NAME === undefined ? "STSInstrumentManager" : process.env.IM_SERVICE_NAME)
133
+ // STS Instrument Manager Service Version
134
+ ,imserviceversion: (process.env.IM_SERVICE_VERSION === undefined ? "1.0.0" : process.env.IM_SERVICE_VERSION)
135
+ // STS Instrument Manager Server client ID. Used for oauth2 client credentials flow.
136
+ ,imclientid: process.env.IM_CLIENT_ID
137
+ // STS Instrument Manager Server client ID file. Used for oauth2 client credentials flow.
138
+ ,imclientidfile: process.env.IM_CLIENT_ID_FILE
139
+ // STS Instrument Manager Server client secret. Used for oauth2 client credentials flow.
140
+ ,imclientsecret: process.env.IM_CLIENT_SECRET
141
+ // STS Instrument Manager Server client secret file. Used for oauth2 client credentials flow.
142
+ ,imclientsecretfile: process.env.IM_CLIENT_SECRET_FILE
143
+
144
+ // STS Test Orchestrator Service endpoint
145
+ ,toendpoint: (process.env.TO_ENDPOINT === undefined ? "https://localhost" : process.env.TO_ENDPOINT)
146
+ // STS Test Orchestrator Service listen port (listen port for the service)
147
+ ,tohostport: (process.env.TO_HOST_PORT === undefined ? "3004" : process.env.TO_HOST_PORT)
148
+ // STS Test Orchestrator Service client access port (client port to access the service)
149
+ ,toport: (process.env.TO_PORT === undefined ? "3004" : process.env.TO_PORT)
150
+ // STS Test Orchestrator Service endpoint
151
+ ,toapiroot: (process.env.TO_APIROOT === undefined ? "/ststestorchestrator/v1" : process.env.TO_APIROOT)
152
+ // Test Orchestrator API Identifier. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
153
+ ,toapiidentifier: process.env.TO_API_IDENTIFIER
154
+ // Test Orchestrator API Identifier file. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
155
+ ,toapiidentifierfile: process.env.TO_API_IDENTIFIER_FILE
156
+ // STS Test Orchestrator Prometheus metric support
157
+ ,toprometheussupport: (process.env.TO_PROM_SUPPORT === undefined ? true : (process.env.TO_PROM_SUPPORT === "true" ? true : false ))
158
+ // STS Test Orchestrator Cluster Server port (port used for cluster prometheus scrapes)
159
+ ,toprometheusclusterport: (process.env.TO_PROM_CLUSTER_PORT === undefined ? "3014" : process.env.TO_PROM_CLUSTER_PORT)
160
+ // STS Test Orchestrator Service Name
161
+ ,toservicename: (process.env.TO_SERVICE_NAME === undefined ? "STSTestOrchestrator" : process.env.TO_SERVICE_NAME)
162
+ // STS Test Orchestrator Service Version
163
+ ,toserviceversion: (process.env.TO_SERVICE_VERSION === undefined ? "1.0.0" : process.env.TO_SERVICE_VERSION)
164
+ // STS Test Orchestrator Server client ID. Used for oauth2 client credentials flow.
165
+ ,toclientid: process.env.TO_CLIENT_ID
166
+ // STS Test Orchestrator Server client ID file. Used for oauth2 client credentials flow.
167
+ ,toclientidfile: process.env.TO_CLIENT_ID_FILE
168
+ // STS Test Orchestrator Server client secret. Used for oauth2 client credentials flow.
169
+ ,toclientsecret: process.env.TO_CLIENT_SECRET
170
+ // STS Test Orchestrator Server client secret file. Used for oauth2 client credentials flow.
171
+ ,toclientsecretfile: process.env.TO_CLIENT_SECRET_FILE
172
+
173
+ // STS Auth Server
174
+ // ---------------
175
+ // The auth server assumes the roles as an Identify Provider ([TODO]) and Token Server (OAuth2.0).
176
+ //
177
+ // Auth Server endpoint
178
+ ,asendpoint: (process.env.AS_ENDPOINT === undefined ? "https://localhost" : process.env.AS_ENDPOINT)
179
+ // Auth Server host port (listen port for the service)
180
+ ,ashostport: (process.env.AS_HOST_PORT === undefined ? "3002" : process.env.AS_HOST_PORT)
181
+ // Auth Server port (client port to access the service)
182
+ ,asport: (process.env.AS_PORT === undefined ? "3002" : process.env.AS_PORT)
183
+ // Auth Server API root.
184
+ ,asapiroot: (process.env.AS_API_ROOT === undefined ? "/stsauth/v1.0" : process.env.AS_API_ROOT)
185
+ // Auth Server OAuth2 API root.
186
+ ,asoauthapiroot: (process.env.AS_OAUTH_API_ROOT === undefined ? "/oauth2/v2.0" : process.env.AS_OAUTH_API_ROOT)
187
+ // Auth Server Admin API root.
188
+ ,asadminapiroot: (process.env.AS_ADMIN_API_ROOT === undefined ? "/admin/v1.0" : process.env.AS_ADMIN_API_ROOT)
189
+ // Auth Server API Identifier.
190
+ ,asapiidentifier: (process.env.AS_API_IDENTIFIER === undefined ? 'https://stsmda.com.au/stsauthapi/v1.0/' : process.env.AS_API_IDENTIFIER)
191
+ // Auth Server API Identifier file.
192
+ ,asapiidentifierfile: process.env.AS_API_IDENTIFIER_FILE
193
+ // Auth Server OAuth API Identifier.
194
+ ,asoauthapiidentifier: (process.env.AS_OAUTH_API_IDENTIFIER === undefined ? 'https://stsmda.com.au/stsauthoauthapi/v2.0/' : process.env.AS_OAUTH_API_IDENTIFIER)
195
+ // Auth Server OAuth API Identifier file.
196
+ ,asoauthapiidentifierfile: process.env.AS_OAUTH_API_IDENTIFIER_FILE
197
+ // Auth Server Administration API Identifier.
198
+ ,asadminapiidentifier: (process.env.AS_ADMIN_API_IDENTIFIER === undefined ? 'https://stsmda.com.au/stsauthadminapi/v1.0/' : process.env.AS_ADMIN_API_IDENTIFIER)
199
+ // Auth Server Administration API Identifier file.
200
+ ,asadminapiidentifierfile: process.env.AS_ADMIN_API_IDENTIFIER_FILE
201
+ // Auth Server Prometheus metric support
202
+ ,asprometheussupport: (process.env.AS_PROM_SUPPORT === undefined ? true : (process.env.AS_PROM_SUPPORT === "true" ? true : false ))
203
+ // Auth Prometheus Cluster Server port (port used for cluster prometheus scrapes)
204
+ ,asprometheusclusterport: (process.env.AS_PROM_CLUSTER_PORT === undefined ? "3012" : process.env.AS_PROM_CLUSTER_PORT)
205
+ // STSAuth Service Name
206
+ ,asservicename: (process.env.AS_SERVICE_NAME === undefined ? "STSAuth" : process.env.AS_SERVICE_NAME)
207
+ // STSAuth Service Version
208
+ ,asserviceversion: (process.env.AS_SERVICE_VERSION === undefined ? "1.0.0" : process.env.AS_SERVICE_VERSION)
209
+ // STS Auth Server client ID. Used for oauth2 client credentials flow.
210
+ ,asclientid: process.env.AS_CLIENT_ID
211
+ // STS Auth Server client ID file. Used for oauth2 client credentials flow.
212
+ ,asclientidfile: process.env.AS_CLIENT_ID_FILE
213
+ // STS Auth Server client secret. Used for oauth2 client credentials flow.
214
+ ,asclientsecret: process.env.AS_CLIENT_SECRET
215
+ // STS Auth Server client secret file. Used for oauth2 client credentials flow.
216
+ ,asclientsecretfile: process.env.AS_CLIENT_SECRET_FILE
217
+ // Auth Server - JWKS Public End Point.
218
+ ,asjwksjsonpath: (process.env.AS_JWKS_JSON_PATH === undefined ? "/.well-known/jwks.json" : process.env.AS_JWKS_JSON_PATH)
219
+ // Auth Server - JWKS key rotation time (seconds).
220
+ ,asjwkskeyrotationtime: (process.env.AS_JWKS_KEY_ROTATION_TIME === undefined ? 86400 : parseInt(process.env.AS_JWKS_KEY_ROTATION_TIME)) // 24 Hour default
221
+ // Auth Server - JWKS key purge time offset (seconds). Old keys (current keys are considered 'old' immediately after a key rotation) will be kept
222
+ // for asaccesstokenexpire + asjwkskeypurgetimeoffset seconds before purging from the JWKS.
223
+ ,asjwkskeypurgetimeoffset: (process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET === undefined ? 300 : parseInt(process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET)) // 5 Minutes
224
+ // Auth Server - JWKS key count. Defines the number of active keys within the JWKS. Note that the actual key count may be double this value as current
225
+ // keys are rotated to old keys prior to old key purge. Old keys will be kept for asaccesstokenexpire + asjwkskeypurgetimeoffset seconds before removal from the JWKS.
226
+ // This is to ensure that any tokens signed by a current key that is then expired can still be validated within the life of the issued token.
227
+ ,asjwkskeycount: (process.env.AS_JWKS_KEY_COUNT === undefined ? 4 : parseInt(process.env.AS_JWKS_KEY_COUNT))
228
+ // Auth Server - JWKS Access token timeout.
229
+ ,asaccesstokenexpire: (process.env.AS_ACCESS_TOKEN_EXPIRE === undefined ? 43200 : parseInt(process.env.AS_ACCESS_TOKEN_EXPIRE)) // 12 Hour default
230
+
231
+ // STS Broker Server
232
+ // ---------------
233
+ // The STS broker server is a BFF service used for STS SPAs. The service will use 1st party secured cookies for session management.
234
+ // The service also provides proxy API access to other STS and/or external services.
235
+ //
236
+ // STSBroker Server endpoint
237
+ ,brokerendpoint: (process.env.BROKER_ENDPOINT === undefined ? "https://localhost" : process.env.BROKER_ENDPOINT)
238
+ // STSBroker Server port (listen port for the service)
239
+ ,brokerhostport: (process.env.BROKER_HOST_PORT === undefined ? "3006" : process.env.BROKER_HOST_PORT)
240
+ // STSBroker Server port (client port to access the service)
241
+ ,brokerport: (process.env.BROKER_PORT === undefined ? "3006" : process.env.BROKER_PORT)
242
+ // STSBroker Server endpoint
243
+ ,brokerapiroot: (process.env.BROKER_APIROOT === undefined ? "/stsbroker/v1.0" : process.env.BROKER_APIROOT)
244
+ // STSBroker API Identifier. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
245
+ ,brokerapiidentifier: process.env.BROKER_API_IDENTIFIER
246
+ // STSBroker API Identifier file. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
247
+ ,brokerapiidentifierfile: process.env.BROKER_API_IDENTIFIER_FILE
248
+ // STSBroker Prometheus metric support
249
+ ,brokerprometheussupport: (process.env.BROKER_PROM_SUPPORT === undefined ? true : (process.env.BROKER_PROM_SUPPORT === "true" ? true : false))
250
+ // STSBroker Cluster Server port (port used for cluster prometheus scrapes). Service will listen on this port at mount point /metrics
251
+ ,brokerprometheusclusterport: (process.env.BROKER_PROM_CLUSTER_PORT === undefined ? "3016" : process.env.BROKER_PROM_CLUSTER_PORT)
252
+ // STSBroker Service Name
253
+ ,brokerservicename: (process.env.BROKER_SERVICE_NAME === undefined ? "STSBroker" : process.env.BROKER_SERVICE_NAME)
254
+ // STSBroker Service Version
255
+ ,brokerserviceversion: (process.env.BROKER_SERVICE_VERSION === undefined ? "1.0.0" : process.env.BROKER_SERVICE_VERSION)
256
+ // STSBroker Server client ID. Used for oauth2 client credentials flow.
257
+ ,brokerclientid: process.env.BROKER_CLIENT_ID
258
+ // STSBroker Server client ID file. Used for oauth2 client credentials flow.
259
+ ,brokerclientidfile: process.env.BROKER_CLIENT_ID_FILE
260
+ // STSBroker Server client secret. Used for oauth2 client credentials flow.
261
+ ,brokerclientsecret: process.env.BROKER_CLIENT_SECRET
262
+ // STSBroker Server client secret file. Used for oauth2 client credentials flow.
263
+ ,brokerclientsecretfile: process.env.BROKER_CLIENT_SECRET_FILE
264
+
265
+ // STS Test Runner Node (Service)
266
+ // ------------------------------
267
+ // The STS Test Runner Node service is used to execute REST API tests.
268
+ //
269
+ // STSBroker Server endpoint
270
+ ,trnendpoint: (process.env.TRN_ENDPOINT === undefined ? "https://localhost" : process.env.TRN_ENDPOINT)
271
+ // STSBroker Server port (listen port for the service)
272
+ ,trnhostport: (process.env.TRN_HOST_PORT === undefined ? "3007" : process.env.TRN_HOST_PORT)
273
+ // STSBroker Server port (client port to access the service)
274
+ ,trnport: (process.env.TRN_PORT === undefined ? "3007" : process.env.TRN_PORT)
275
+ // STSBroker Server endpoint
276
+ ,trnapiroot: (process.env.TRN_APIROOT === undefined ? "/ststrn/v1.0" : process.env.TRN_APIROOT)
277
+ // STSBroker API Identifier. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
278
+ ,trnapiidentifier: process.env.TRN_API_IDENTIFIER
279
+ // STSBroker API Identifier file. This value will be used as the audience parameter on authorization calls (OAuth2 client credentials flow).
280
+ ,trnapiidentifierfile: process.env.TRN_API_IDENTIFIER_FILE
281
+ // STSBroker Prometheus metric support
282
+ ,trnprometheussupport: (process.env.TRN_PROM_SUPPORT === undefined ? true : (process.env.TRN_PROM_SUPPORT === "true" ? true : false))
283
+ // STSBroker Cluster Server port (port used for cluster prometheus scrapes). Service will listen on this port at mount point /metrics
284
+ ,trnprometheusclusterport: (process.env.TRN_PROM_CLUSTER_PORT === undefined ? "3017" : process.env.TRN_PROM_CLUSTER_PORT)
285
+ // STSBroker Service Name
286
+ ,trnservicename: (process.env.TRN_SERVICE_NAME === undefined ? "STSTestRunnerNode" : process.env.TRN_SERVICE_NAME)
287
+ // STSBroker Service Version
288
+ ,trnserviceversion: (process.env.TRN_SERVICE_VERSION === undefined ? "1.0.0" : process.env.TRN_SERVICE_VERSION)
289
+ // STSBroker Server client ID. Used for oauth2 client credentials flow.
290
+ ,trnclientid: process.env.TRN_CLIENT_ID
291
+ // STSBroker Server client ID file. Used for oauth2 client credentials flow.
292
+ ,trnclientidfile: process.env.TRN_CLIENT_ID_FILE
293
+ // STSBroker Server client secret. Used for oauth2 client credentials flow.
294
+ ,trnclientsecret: process.env.TRN_CLIENT_SECRET
295
+ // STSBroker Server client secret file. Used for oauth2 client credentials flow.
296
+ ,trnclientsecretfile: process.env.TRN_CLIENT_SECRET_FILE
297
+
298
+ // STS Test Runner Prometheus metric support
299
+ ,trprometheussupport: (process.env.TR_PROM_SUPPORT === undefined ? true : (process.env.TR_PROM_SUPPORT === "true" ? true : false ))
300
+ // STS Test Runner Cluster Server port (port used for cluster prometheus scrapes)
301
+ ,trprometheusclusterport: (process.env.TR_PROM_CLUSTER_PORT === undefined ? "3015" : process.env.TR_PROM_CLUSTER_PORT)
302
+ // STS Test Runner Service Name
303
+ ,trservicename: (process.env.TR_SERVICE_NAME === undefined ? "STSRestRunner" : process.env.TR_SERVICE_NAME)
304
+ // STS Test Runner Service Version
305
+ ,trserviceversion: (process.env.TR_SERVICE_VERSION === undefined ? "1.0.0" : process.env.TR_SERVICE_VERSION)
306
+ // STS Test Runner Server client ID. Used for oauth2 client credentials flow.
307
+ ,trclientid: process.env.TR_CLIENT_ID
308
+ // STS Test Runner Server client ID file. Used for oauth2 client credentials flow.
309
+ ,trclientidfile: process.env.TR_CLIENT_ID_FILE
310
+ // STS Test Runner Server client secret. Used for oauth2 client credentials flow.
311
+ ,trclientsecret: process.env.TR_CLIENT_SECRET
312
+ // STS Test Runner Server client secret file. Used for oauth2 client credentials flow.
313
+ ,trclientsecretfile: process.env.TR_CLIENT_SECRET_FILE
314
+
315
+ // Duration (in ms) between each publish event.
316
+ ,publishinterval: (process.env.PUBLISH_INTERVAL === undefined ? 1000 : parseInt(process.env.PUBLISH_INTERVAL))
317
+
318
+ // The maximum time (in ms) to wait before timeout error when publishing instruments. Ideally, this should always be lower than the publishinterval frequency
319
+ // to avoid cascading http build up errors.
320
+ ,publishtimeout: (process.env.PUBLISH_TIMEOUT === undefined ? 750 : parseInt(process.env.PUBLISH_TIMEOUT))
321
+
322
+ // If true, instrument publish failures will be logged to debug output.
323
+ ,publishdebug: (process.env.PUBLISH_DEBUG === undefined ? false : (process.env.PUBLISH_DEBUG === "true" ? true : false ))
324
+
325
+ // Transport(s) to use for sending instrumentation data to the instrumentation server
326
+ ,transport: (process.env.TRANSPORT === undefined ? 'RESTAPI' : process.env.TRANSPORT)
327
+
328
+ /*
329
+ // Instrument Defaults
330
+ // Logger lines (sliding window size)
331
+ ,instrumentLoggerSize: (process.env.INSTRUMENT_LOGGER_SIZE === undefined ? 200 : parseInt(process.env.INSTRUMENT_LOGGER_SIZE))
332
+
333
+ // Histoogram bucket sizes (and default labels)
334
+ ,instrumentHistogramBuckets: (process.env.INSTRUMENT_HISTOGRAM_BUCKETS === undefined ? [ 10, 20, 50, 100, 1000, 5000 ] : JSON.parse(process.env.INSTRUMENT_HISTOGRAM_BUCKETS))
335
+
336
+ // Sample interval (ms)
337
+ ,instrumentSampleInterval: (process.env.INSTRUMENT_SAMPLE_INTERVAL === undefined ? 1000 : parseInt(process.env.INSTRUMENT_SAMPLE_INTERVAL))
338
+
339
+ // Sample size (number of readings to use for P(x) calculations. Time approx. (Sample Interval / 1000) * Sample Size, i.e. Caluclate P(x) on the observed data for the last 6 minutes.
340
+ ,instrumentSampleSize: (process.env.INSTRUMENT_SAMPLE_SIZE === undefined ? 600 : parseInt(process.env.INSTRUMENT_SAMPLE_SIZE))
341
+ */
342
+
343
+ // Use secure cookies option when passing back cookies from STS services (such as STSAuth service).
344
+ // This setting will be ignore for production mode. In production mode services will always use secure cookies.
345
+ ,useSecureCookies: (process.env.USE_SECURE_COOKIES === undefined ? false : (process.env.USE_SECURE_COOKIES === "true" ? true : false ))
346
+
347
+ // keepAlive <boolean> Keep sockets around even when there are no outstanding requests, so they can be used for future requests without having to reestablish a
348
+ // TCP connection. Not to be confused with the keep-alive value of the Connection header. The Connection: keep-alive header is always sent when using an agent
349
+ // except when the Connection header is explicitly specified or when the keepAlive and maxSockets options are respectively set to false and Infinity, in which
350
+ // case Connection: close will be used. Default: false.
351
+ // Reference: https://nodejs.org/api/http.html#class-httpagent
352
+ ,keepAlive: (process.env.KEEP_ALIVE === undefined ? true : (process.env.KEEP_ALIVE === "true" ? true : false ))
353
+
354
+ // maxSockets <number> Maximum number of sockets to allow per host. If the same host opens multiple concurrent connections, each request will use new socket until the
355
+ // maxSockets value is reached. If the host attempts to open more connections than maxSockets, the additional requests will enter into a pending request queue, and will
356
+ // enter active connection state when an existing connection terminates. This makes sure there are at most maxSockets active connections at any point in time,
357
+ // from a given host. Default: Infinity.
358
+ // Reference: https://nodejs.org/api/http.html#class-httpagent
359
+ ,maxSockets: (process.env.MAX_SOCKETS === undefined ? 10 : parseInt(process.env.MAX_SOCKETS))
360
+
361
+ // maxTotalSockets <number> Maximum number of sockets allowed for all hosts in total. Each request will use a new socket until the maximum is reached. Default: Infinity.
362
+ // Reference: https://nodejs.org/api/http.html#class-httpagent
363
+ ,maxTotalSockets: (process.env.MAX_TOTAL_SOCKETS === undefined ? 20 : parseInt(process.env.MAX_TOTAL_SOCKETS))
364
+
365
+ // maxFreeSockets <number> Maximum number of sockets per host to leave open in a free state. Only relevant if keepAlive is set to true. Default: 256.
366
+ // Reference: https://nodejs.org/api/http.html#class-httpagent
367
+ ,maxFreeSockets: (process.env.MAX_FREE_SOCKETS === undefined ? 256 : parseInt(process.env.MAX_FREE_SOCKETS))
368
+
369
+ // timeout <number> Socket timeout in milliseconds. This will set the timeout when the socket is created.
370
+ // Reference: https://nodejs.org/api/http.html#class-httpagent
371
+ ,timeout: (process.env.TIMEOUT === undefined ? 10000 : parseInt(process.env.TIMEOUT))
372
+
373
+ // Maximum payload size allowed for express server calls
374
+ ,maxPayloadSize: (process.env.MAX_PAYLOAD_SIZE === undefined ? '50mb' : process.env.MAX_PAYLOAD_SIZE)
375
+
376
+ // Instrumentation Config Settings
377
+ // -------------------------------
378
+ // Generic interval (ms) to make on observation for instrumentation objects.
379
+ ,instrumentationObservationInterval: (process.env.INSTRUMENTATION_OBSERVATION_INTERVAL === undefined ? 1000 : parseInt(process.env.INSTRUMENTATION_OBSERVATION_INTERVAL))
380
+
381
+ // Generic sliding time window (seconds) for instrumentation objects that process telemetry over time (e.g. P(x) instruments).
382
+ ,instrumentationTimeWindow: (process.env.INSTRUMENTATION_TIME_WINDOW === undefined ? 600 : parseInt(process.env.INSTRUMENTATION_TIME_WINDOW))
383
+
384
+ // Service Specific Config Settings
385
+ // --------------------------------
386
+ // STSAuth
387
+ // -------
388
+ // Define the valid age for a JWT access token (in ms). Default 10 minutes.
389
+ ,authJWTAccessTokenTimeout: (process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT === undefined ? 600 : parseInt(process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT))
390
+
391
+ // Define the valid age for a JWT refresh token (in ms). Default 24 hours.
392
+ ,authJWTRefreshTokenTimeout: (process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT === undefined ? (3600 * 24) : parseInt(process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT))
393
+
394
+ // Define the valid age for an authentication/session cookie. Default 24 hours.
395
+ ,authCookieTimeout: (process.env.AUTH_COOKIE_TIMEOUT === undefined ? (3600 * 24) : parseInt(process.env.AUTH_COOKIE_TIMEOUT))
396
+
397
+ // STSAppFramework (library)
398
+ // -------------------------
399
+ // Define the time (ms) to wait prior to exiting the application (using process.exit(0))
400
+ ,masterProcessExitTime: (process.env.MASTER_PROCESS_EXIT_TIME === undefined ? 500 : parseInt(process.env.MASTER_PROCESS_EXIT_TIME))
401
+
402
+ // Define the time (ms) to wait prior to exiting the application (using process.exit(0))
403
+ ,childProcessExitTime: (process.env.CHILD_PROCESS_EXIT_TIME === undefined ? 500 : parseInt(process.env.CHILD_PROCESS_EXIT_TIME))
404
+
405
+ // Define the interval (ms) to collect system information for instrumentation purposes
406
+ ,systemInformationInterval: (process.env.SYSTEM_INFORMATION_INTERVAL === undefined ? 1000 : parseInt(process.env.SYSTEM_INFORMATION_INTERVAL))
407
+
408
+ // Ignore socket.io REST api calls and/or WebSocket calls when collecting telemetry for instrumentation purposes.
409
+ ,ignoresocketio: (process.env.IGNORE_SOCKETIO === undefined ? true : (process.env.IGNORE_SOCKETIO === "true" ? true : false ))
410
+
411
+ /*
412
+ // STSModels (library)
413
+ // -------------------
414
+ // Define the interval for checking instrumentation updates on a instrumentation model. Entries in the model will be removed after this timeout value (ms) if no
415
+ // activity has been detected. Default 5 seconds.
416
+ ,modelPurgeUpdateTimeout: (process.env.MODEL_PURGE_UPDATE_TIMEOUT === undefined ? 5000 : parseInt(process.env.MODEL_PURGE_UPDATE_TIMEOUT))
417
+ */
418
+
419
+ // Use command below to create self signed cert;
420
+ // openssl req -nodes -new -x509 -keyout server.key -out server.cert
421
+ // Ref: https://www.geeksforgeeks.org/how-to-create-https-server-with-node-js/
422
+ // HTTPS server key path.
423
+ ,httpsserverkeypath: (process.env.HTTPS_SERVER_KEY_PATH === undefined ? "/var/lib/sts/stsglobalresources/keys/server.key" : process.env.HTTPS_SERVER_KEY_PATH)
424
+ // HTTPS server cert path.
425
+ ,httpsservercertpath: (process.env.HTTPS_SERVER_CERT_PATH === undefined ? "/var/lib/sts/stsglobalresources/keys/server.cert" : process.env.HTTPS_SERVER_CERT_PATH)
426
+
427
+ // Token Service Settings
428
+ // ----------------------
429
+ // Maximum number of RSA keys in the JWKS store
430
+ ,tsjwkskeys: (process.env.TS_JWKS_KEYS === undefined ? 3 : parseInt(process.env.TS_JWKS_KEYS))
431
+
432
+ // File path for JWKS store data. This file will contain the public and private keys for the JWKS store.
433
+ ,tsjwksstorepath: (process.env.TS_JWKS_STORE_PATH === undefined ? "/var/lib/sts/stsglobalresources/.stsauthprivate/jwks-private.json" : process.env.TS_JWKS_STORE_PATH)
434
+ // File path for JWKS store path config setting (tsjwksstorepath). Use this config item with Docker/Kubernetes secrets.
435
+ ,tsjwksstorepathfile: process.env.TS_JWKS_STORE_PATH_FILE
436
+ // File path for JWKS public store data. This file will contain only the public signing keys for the JWKS store.
437
+ ,tsjwksstorepublicpath: (process.env.TS_JWKS_STORE_PUBLIC_PATH === undefined ? "/var/lib/sts/stsglobalresources/.well-known/jwks.json" : process.env.TS_JWKS_STORE_PUBLIC_PATH)
438
+
439
+ // JWKS Authentication Configuration Settings
440
+ // Ref: https://github.com/auth0/node-jwks-rsa
441
+ // Enables a LRU cache. Ref: https://github.com/auth0/node-jwks-rsa#caching
442
+ ,jwksAuthConfigCache: (process.env.JWKS_AUTH_CONFIG_CACHE === undefined ? true : (process.env.JWKS_AUTH_CONFIG_CACHE === "true" ? true : false ))
443
+
444
+ // Maximum number of LRU cache entries. Ref: https://github.com/auth0/node-jwks-rsa#caching
445
+ ,jwksAuthConfigCacheMaxEntries: (process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES === undefined ? 5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES))
446
+
447
+ // Maximum age of LRU cache entries. Ref: https://github.com/auth0/node-jwks-rsa#caching
448
+ ,jwksAuthConfigCacheMaxAge: (process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE === undefined ? 600000 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE))
449
+
450
+ // Enforce rate limiting for jwks public endpoint query. Ref: https://github.com/auth0/node-jwks-rsa#rate-limiting
451
+ ,jwksAuthConfigRateLimit: (process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === undefined ? true : (process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === "true" ? true : false ))
452
+
453
+ // Enforce rate limiting maximum number of requests per minute. Ref: https://github.com/auth0/node-jwks-rsa#rate-limiting
454
+ ,jwksAuthConfigRateLimitRequestsPerMinute: (process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE === undefined ? 10 : parseInt(process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE))
455
+
456
+ // Timeout for the public endpoint query. Note: This will be ignored if an http/https agent is specified.
457
+ ,jwksAuthConfigTimeout: (process.env.JWKS_AUTH_CONFIG_TIMEOUT === undefined ? 30000 : parseInt(process.env.JWKS_AUTH_CONFIG_TIMEOUT))
458
+ }
428
459
 
429
- const ReadFile = (passwordFile: string) => {
430
- try {
431
- accessSync(passwordFile, constants.R_OK);
432
- const data = readFileSync(passwordFile, 'utf8');
433
- debug(`Successfully loaded password file: [${passwordFile}]`.green);
434
- return data;
435
- } catch (err) {
436
- debug(`Problem loading password file: [${passwordFile}], Error: [${err}]`.red);
437
- return "";
438
- }
460
+ const ReadFile = (passwordFile: string) => {
461
+ try {
462
+ accessSync(passwordFile, constants.R_OK);
463
+ const data = readFileSync(passwordFile, 'utf8');
464
+ debug(`Successfully loaded password file: [${passwordFile}]`.green);
465
+ return data;
466
+ } catch (err) {
467
+ debug(`Problem loading password file: [${passwordFile}], Error: [${err}]`.red);
468
+ return "";
439
469
  }
440
-
441
- // File based configuration settings. If a file is specified for a setting, this will be used. The non file version (if specified) will be ignored.
442
- const fileconfig = [
443
- { fileprop: 'dbpasswordfile', prop: 'dbpassword' },
444
- // API identifier file processing
445
- { fileprop: 'asapiidentifierfile', prop: 'asapiidentifier' },
446
- { fileprop: 'asoauthapiidentifierfile', prop: 'asoauthapiidentifier' },
447
- { fileprop: 'asadminapiidentifierfile', prop: 'asadminapiidentifier' },
448
- { fileprop: 'rest01apiidentifierfile', prop: 'rest01apiidentifier' },
449
- { fileprop: 'brokerapiidentifierfile', prop: 'brokerapiidentifier' },
450
- { fileprop: 'toapiidentifierfile', prop: 'toapiidentifier' },
451
- { fileprop: 'imapiidentifierfile', prop: 'imapiidentifier' },
452
- // Client ID file processing
453
- { fileprop: 'asclientidfile', prop: 'asclientid' },
454
- { fileprop: 'rest01clientidfile', prop: 'rest01clientid' },
455
- { fileprop: 'brokerclientidfile', prop: 'brokerclientid' },
456
- { fileprop: 'toclientidfile', prop: 'toclientid' },
457
- { fileprop: 'imclientidfile', prop: 'imclientid' },
458
- { fileprop: 'trclientidfile', prop: 'trclientid' },
459
- // Client secret file processing
460
- { fileprop: 'asclientsecretfile', prop: 'asclientsecret' },
461
- { fileprop: 'rest01clientsecretfile', prop: 'rest01clientsecret' },
462
- { fileprop: 'brokerclientsecretfile', prop: 'brokerclientsecret' },
463
- { fileprop: 'toclientsecretfile', prop: 'toclientsecret' },
464
- { fileprop: 'imclientsecretfile', prop: 'imclientsecret' },
465
- { fileprop: 'trclientsecretfile', prop: 'trclientsecret' },
466
- // JWKS secret file processing
467
- { fileprop: 'tsjwksstorepathfile', prop: 'tsjwksstorepath' },
468
- ]
469
-
470
- fileconfig.forEach((v) => {
471
- if (defconfig[v.fileprop] !== undefined) {
472
- defconfig[v.prop] = ReadFile(defconfig[v.fileprop] as string);
473
- }
474
- });
475
-
476
- return defconfig;
477
470
  }
478
471
 
479
- $Options(): STSOptions {
480
- if (STSConfig.#envOptions === null) {
481
- STSConfig.#envOptions = this.#SetupConfig();
482
- // Computed connection string to be used in development mode.
483
- const options = STSConfig.#envOptions;
484
- STSConfig.#envOptions.connectionString = `postgresql://${options.dbuser}:${options.dbpassword}@${options.dbhost}:${options.dbport}/${options.database}`
485
- // Default computed connection string for postgres. Database name = postgres. Used by utilites that create and/or update the STS database(s).
486
- STSConfig.#envOptions.defaultDatabaseConnectionString = `postgresql://${options.dbuser}:${options.dbpassword}@${options.dbhost}:${options.dbport}/postgres`
472
+ // File based configuration settings. If a file is specified for a setting, this will be used. The non file version (if specified) will be ignored.
473
+ const fileconfig = [
474
+ { fileprop: 'dbpasswordfile', prop: 'dbpassword' },
475
+ // API identifier file processing
476
+ { fileprop: 'asapiidentifierfile', prop: 'asapiidentifier' },
477
+ { fileprop: 'asoauthapiidentifierfile', prop: 'asoauthapiidentifier' },
478
+ { fileprop: 'asadminapiidentifierfile', prop: 'asadminapiidentifier' },
479
+ { fileprop: 'rest01apiidentifierfile', prop: 'rest01apiidentifier' },
480
+ { fileprop: 'brokerapiidentifierfile', prop: 'brokerapiidentifier' },
481
+ { fileprop: 'toapiidentifierfile', prop: 'toapiidentifier' },
482
+ { fileprop: 'imapiidentifierfile', prop: 'imapiidentifier' },
483
+ { fileprop: 'trnapiidentifierfile', prop: 'trnapiidentifier' },
484
+ // Client ID file processing
485
+ { fileprop: 'asclientidfile', prop: 'asclientid' },
486
+ { fileprop: 'rest01clientidfile', prop: 'rest01clientid' },
487
+ { fileprop: 'brokerclientidfile', prop: 'brokerclientid' },
488
+ { fileprop: 'toclientidfile', prop: 'toclientid' },
489
+ { fileprop: 'imclientidfile', prop: 'imclientid' },
490
+ { fileprop: 'trclientidfile', prop: 'trclientid' },
491
+ { fileprop: 'trnclientidfile', prop: 'trnclientid' },
492
+ // Client secret file processing
493
+ { fileprop: 'asclientsecretfile', prop: 'asclientsecret' },
494
+ { fileprop: 'rest01clientsecretfile', prop: 'rest01clientsecret' },
495
+ { fileprop: 'brokerclientsecretfile', prop: 'brokerclientsecret' },
496
+ { fileprop: 'toclientsecretfile', prop: 'toclientsecret' },
497
+ { fileprop: 'imclientsecretfile', prop: 'imclientsecret' },
498
+ { fileprop: 'trclientsecretfile', prop: 'trclientsecret' },
499
+ { fileprop: 'trnclientsecretfile', prop: 'trnclientsecret' },
500
+ // JWKS secret file processing
501
+ { fileprop: 'tsjwksstorepathfile', prop: 'tsjwksstorepath' },
502
+ ]
503
+
504
+ fileconfig.forEach((v) => {
505
+ if (defconfig[v.fileprop] !== undefined) {
506
+ defconfig[v.prop] = ReadFile(defconfig[v.fileprop] as string);
487
507
  }
488
- return STSConfig.#envOptions;
508
+ });
509
+
510
+ return defconfig;
511
+ }
512
+
513
+ export function $Options(): STSOptions {
514
+ if (envOptions === null) {
515
+ envOptions = SetupConfig();
516
+ // Computed connection string to be used in development mode.
517
+ const options = envOptions;
518
+ envOptions.connectionString = `postgresql://${options.dbuser}:${options.dbpassword}@${options.dbhost}:${options.dbport}/${options.database}`
519
+ // Default computed connection string for postgres. Database name = postgres. Used by utilites that create and/or update the STS database(s).
520
+ envOptions.defaultDatabaseConnectionString = `postgresql://${options.dbuser}:${options.dbpassword}@${options.dbhost}:${options.dbport}/postgres`
489
521
  }
522
+ return envOptions;
490
523
  }