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