@nsshunt/stsoauth2plugin 1.0.112 → 1.0.113

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.
@@ -1,6 +1,6 @@
1
1
  (function(global2, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("node:worker_threads"), require("@nsshunt/stsutils"), require("@nsshunt/stsvueutils"), require("pinia"), require("@nsshunt/stsobservability"), require("node:https"), require("axios")) : typeof define === "function" && define.amd ? define(["exports", "vue", "node:worker_threads", "@nsshunt/stsutils", "@nsshunt/stsvueutils", "pinia", "@nsshunt/stsobservability", "node:https", "axios"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["@nsshunt/stsoauth2plugin"] = {}, global2.vue, global2.worker_threads, global2.stsutils, global2.stsvueutils, global2.pinia, global2.stsobservability, global2.https, global2.axios));
3
- })(this, function(exports2, vue, wt, stsutils, stsvueutils, pinia, stsobservability, https, axios) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("node:worker_threads"), require("@nsshunt/stsutils"), require("@nsshunt/stsvueutils"), require("pinia"), require("@nsshunt/stsobservability"), require("axios"), require("node:https")) : typeof define === "function" && define.amd ? define(["exports", "vue", "node:worker_threads", "@nsshunt/stsutils", "@nsshunt/stsvueutils", "pinia", "@nsshunt/stsobservability", "axios", "node:https"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["@nsshunt/stsoauth2plugin"] = {}, global2.vue, global2.worker_threads, global2.stsutils, global2.stsvueutils, global2.pinia, global2.stsobservability, global2.axios, global2.https));
3
+ })(this, function(exports2, vue, wt, stsutils, stsvueutils, pinia, stsobservability, axios, https) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __typeError = (msg) => {
6
6
  throw TypeError(msg);
@@ -21,7 +21,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
21
21
  }
22
22
  });
23
23
 
24
- var _router, _STORAGE_AUTHORIZE_OPTIONS_KEY, _aic, _options, _oauth2ManagerPort, _messageId, _messageHandlers, _messageTimeout, _worker, _transactionStore, _operationSemaphore, _maxSemaphoreRetries, _semaphoreRetrySleep, _STSOAuth2Manager_instances, LogDebugMessage_fn, LogInfoMessage_fn, LogErrorMessage_fn, _ProcessMessageResponse, _PostMessage, _HandleLogEvent, _HandleUpdateInstrumentEvent, _GetStore, _HandleErrorEvent, _HandleAuthenticateEvent, _SetupRoute, _crypto, _clientSessionStore, _cUtils, _qParams, _STORAGE_SESSION_KEY, _oauthWorkerPort, _options2, _httpsAgent, _logger, _STSOAuth2Worker_instances, LogDebugMessage_fn2, LogInfoMessage_fn2, LogErrorMessage_fn2, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
24
+ var _router, _STORAGE_AUTHORIZE_OPTIONS_KEY, _aic, _options2, _oauth2ManagerPort, _messageId, _messageHandlers, _messageTimeout, _worker, _transactionStore, _operationSemaphore, _maxSemaphoreRetries, _semaphoreRetrySleep, _STSOAuth2Manager_instances, LogDebugMessage_fn, LogInfoMessage_fn, LogErrorMessage_fn, _ProcessMessageResponse, _PostMessage, _HandleLogEvent, _HandleUpdateInstrumentEvent, _GetStore, _HandleErrorEvent, _HandleAuthenticateEvent, _SetupRoute, _crypto, _clientSessionStore, _cUtils, _qParams, _STORAGE_SESSION_KEY, _oauthWorkerPort, _options3, _logger, _agentManager, _STSOAuth2Worker_instances, LogDebugMessage_fn2, LogInfoMessage_fn2, LogErrorMessage_fn2, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
25
25
  function _interopNamespaceDefault(e) {
26
26
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
27
27
  if (e) {
@@ -68,13 +68,13 @@ var __privateWrapper = (obj, member, setter, getter) => ({
68
68
  });
69
69
  return a;
70
70
  }
71
- var ansiStyles$1 = { exports: {} };
72
- var colorName;
73
- var hasRequiredColorName;
74
- function requireColorName() {
75
- if (hasRequiredColorName) return colorName;
76
- hasRequiredColorName = 1;
77
- colorName = {
71
+ var ansiStyles$3 = { exports: {} };
72
+ var colorName$1;
73
+ var hasRequiredColorName$1;
74
+ function requireColorName$1() {
75
+ if (hasRequiredColorName$1) return colorName$1;
76
+ hasRequiredColorName$1 = 1;
77
+ colorName$1 = {
78
78
  "aliceblue": [240, 248, 255],
79
79
  "antiquewhite": [250, 235, 215],
80
80
  "aqua": [0, 255, 255],
@@ -224,14 +224,14 @@ var __privateWrapper = (obj, member, setter, getter) => ({
224
224
  "yellow": [255, 255, 0],
225
225
  "yellowgreen": [154, 205, 50]
226
226
  };
227
- return colorName;
227
+ return colorName$1;
228
228
  }
229
- var conversions;
230
- var hasRequiredConversions;
231
- function requireConversions() {
232
- if (hasRequiredConversions) return conversions;
233
- hasRequiredConversions = 1;
234
- const cssKeywords = requireColorName();
229
+ var conversions$1;
230
+ var hasRequiredConversions$1;
231
+ function requireConversions$1() {
232
+ if (hasRequiredConversions$1) return conversions$1;
233
+ hasRequiredConversions$1 = 1;
234
+ const cssKeywords = requireColorName$1();
235
235
  const reverseKeywords = {};
236
236
  for (const key of Object.keys(cssKeywords)) {
237
237
  reverseKeywords[cssKeywords[key]] = key;
@@ -253,7 +253,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
253
253
  apple: { channels: 3, labels: ["r16", "g16", "b16"] },
254
254
  gray: { channels: 1, labels: ["gray"] }
255
255
  };
256
- conversions = convert;
256
+ conversions$1 = convert;
257
257
  for (const model of Object.keys(convert)) {
258
258
  if (!("channels" in convert[model])) {
259
259
  throw new Error("missing channels property: " + model);
@@ -896,14 +896,14 @@ var __privateWrapper = (obj, member, setter, getter) => ({
896
896
  const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
897
897
  return [val / 255 * 100];
898
898
  };
899
- return conversions;
899
+ return conversions$1;
900
900
  }
901
- var route;
902
- var hasRequiredRoute;
903
- function requireRoute() {
904
- if (hasRequiredRoute) return route;
905
- hasRequiredRoute = 1;
906
- const conversions2 = requireConversions();
901
+ var route$1;
902
+ var hasRequiredRoute$1;
903
+ function requireRoute$1() {
904
+ if (hasRequiredRoute$1) return route$1;
905
+ hasRequiredRoute$1 = 1;
906
+ const conversions2 = requireConversions$1();
907
907
  function buildGraph() {
908
908
  const graph = {};
909
909
  const models = Object.keys(conversions2);
@@ -942,18 +942,18 @@ var __privateWrapper = (obj, member, setter, getter) => ({
942
942
  };
943
943
  }
944
944
  function wrapConversion(toModel, graph) {
945
- const path = [graph[toModel].parent, toModel];
945
+ const path2 = [graph[toModel].parent, toModel];
946
946
  let fn = conversions2[graph[toModel].parent][toModel];
947
947
  let cur = graph[toModel].parent;
948
948
  while (graph[cur].parent) {
949
- path.unshift(graph[cur].parent);
949
+ path2.unshift(graph[cur].parent);
950
950
  fn = link(conversions2[graph[cur].parent][cur], fn);
951
951
  cur = graph[cur].parent;
952
952
  }
953
- fn.conversion = path;
953
+ fn.conversion = path2;
954
954
  return fn;
955
955
  }
956
- route = function(fromModel) {
956
+ route$1 = function(fromModel) {
957
957
  const graph = deriveBFS(fromModel);
958
958
  const conversion = {};
959
959
  const models = Object.keys(graph);
@@ -967,15 +967,15 @@ var __privateWrapper = (obj, member, setter, getter) => ({
967
967
  }
968
968
  return conversion;
969
969
  };
970
- return route;
970
+ return route$1;
971
971
  }
972
- var colorConvert;
973
- var hasRequiredColorConvert;
974
- function requireColorConvert() {
975
- if (hasRequiredColorConvert) return colorConvert;
976
- hasRequiredColorConvert = 1;
977
- const conversions2 = requireConversions();
978
- const route2 = requireRoute();
972
+ var colorConvert$1;
973
+ var hasRequiredColorConvert$1;
974
+ function requireColorConvert$1() {
975
+ if (hasRequiredColorConvert$1) return colorConvert$1;
976
+ hasRequiredColorConvert$1 = 1;
977
+ const conversions2 = requireConversions$1();
978
+ const route2 = requireRoute$1();
979
979
  const convert = {};
980
980
  const models = Object.keys(conversions2);
981
981
  function wrapRaw(fn) {
@@ -1028,10 +1028,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1028
1028
  convert[fromModel][toModel].raw = wrapRaw(fn);
1029
1029
  });
1030
1030
  });
1031
- colorConvert = convert;
1032
- return colorConvert;
1031
+ colorConvert$1 = convert;
1032
+ return colorConvert$1;
1033
1033
  }
1034
- ansiStyles$1.exports;
1034
+ ansiStyles$3.exports;
1035
1035
  (function(module2) {
1036
1036
  const wrapAnsi16 = (fn, offset) => (...args) => {
1037
1037
  const code = fn(...args);
@@ -1065,16 +1065,16 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1065
1065
  let colorConvert2;
1066
1066
  const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1067
1067
  if (colorConvert2 === void 0) {
1068
- colorConvert2 = requireColorConvert();
1068
+ colorConvert2 = requireColorConvert$1();
1069
1069
  }
1070
1070
  const offset = isBackground ? 10 : 0;
1071
1071
  const styles2 = {};
1072
1072
  for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
1073
- const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1073
+ const name2 = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1074
1074
  if (sourceSpace === targetSpace) {
1075
- styles2[name] = wrap(identity, offset);
1075
+ styles2[name2] = wrap(identity, offset);
1076
1076
  } else if (typeof suite === "object") {
1077
- styles2[name] = wrap(suite[targetSpace], offset);
1077
+ styles2[name2] = wrap(suite[targetSpace], offset);
1078
1078
  }
1079
1079
  }
1080
1080
  return styles2;
@@ -1168,13 +1168,13 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1168
1168
  enumerable: true,
1169
1169
  get: assembleStyles
1170
1170
  });
1171
- })(ansiStyles$1);
1172
- var ansiStylesExports = ansiStyles$1.exports;
1173
- var browser = {
1171
+ })(ansiStyles$3);
1172
+ var ansiStylesExports$1 = ansiStyles$3.exports;
1173
+ var browser$2 = {
1174
1174
  stdout: false,
1175
1175
  stderr: false
1176
1176
  };
1177
- const stringReplaceAll$1 = (string, substring, replacer) => {
1177
+ const stringReplaceAll$3 = (string, substring, replacer) => {
1178
1178
  let index = string.indexOf(substring);
1179
1179
  if (index === -1) {
1180
1180
  return string;
@@ -1190,7 +1190,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1190
1190
  returnValue += string.substr(endIndex);
1191
1191
  return returnValue;
1192
1192
  };
1193
- const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
1193
+ const stringEncaseCRLFWithFirstIndex$3 = (string, prefix, postfix, index) => {
1194
1194
  let endIndex = 0;
1195
1195
  let returnValue = "";
1196
1196
  do {
@@ -1202,15 +1202,15 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1202
1202
  returnValue += string.substr(endIndex);
1203
1203
  return returnValue;
1204
1204
  };
1205
- var util = {
1206
- stringReplaceAll: stringReplaceAll$1,
1207
- stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
1205
+ var util$1 = {
1206
+ stringReplaceAll: stringReplaceAll$3,
1207
+ stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$3
1208
1208
  };
1209
- var templates;
1210
- var hasRequiredTemplates;
1211
- function requireTemplates() {
1212
- if (hasRequiredTemplates) return templates;
1213
- hasRequiredTemplates = 1;
1209
+ var templates$1;
1210
+ var hasRequiredTemplates$1;
1211
+ function requireTemplates$1() {
1212
+ if (hasRequiredTemplates$1) return templates$1;
1213
+ hasRequiredTemplates$1 = 1;
1214
1214
  const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1215
1215
  const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1216
1216
  const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
@@ -1238,7 +1238,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1238
1238
  }
1239
1239
  return ESCAPES.get(c) || c;
1240
1240
  }
1241
- function parseArguments(name, arguments_) {
1241
+ function parseArguments(name2, arguments_) {
1242
1242
  const results = [];
1243
1243
  const chunks = arguments_.trim().split(/\s*,\s*/g);
1244
1244
  let matches;
@@ -1249,7 +1249,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1249
1249
  } else if (matches = chunk.match(STRING_REGEX)) {
1250
1250
  results.push(matches[2].replace(ESCAPE_REGEX, (m, escape2, character) => escape2 ? unescape2(escape2) : character));
1251
1251
  } else {
1252
- throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1252
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name2}')`);
1253
1253
  }
1254
1254
  }
1255
1255
  return results;
@@ -1259,12 +1259,12 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1259
1259
  const results = [];
1260
1260
  let matches;
1261
1261
  while ((matches = STYLE_REGEX.exec(style)) !== null) {
1262
- const name = matches[1];
1262
+ const name2 = matches[1];
1263
1263
  if (matches[2]) {
1264
- const args = parseArguments(name, matches[2]);
1265
- results.push([name].concat(args));
1264
+ const args = parseArguments(name2, matches[2]);
1265
+ results.push([name2].concat(args));
1266
1266
  } else {
1267
- results.push([name]);
1267
+ results.push([name2]);
1268
1268
  }
1269
1269
  }
1270
1270
  return results;
@@ -1288,7 +1288,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1288
1288
  }
1289
1289
  return current;
1290
1290
  }
1291
- templates = (chalk2, temporary) => {
1291
+ templates$1 = (chalk2, temporary) => {
1292
1292
  const styles2 = [];
1293
1293
  const chunks = [];
1294
1294
  let chunk = [];
@@ -1318,92 +1318,92 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1318
1318
  }
1319
1319
  return chunks.join("");
1320
1320
  };
1321
- return templates;
1321
+ return templates$1;
1322
1322
  }
1323
- const ansiStyles = ansiStylesExports;
1324
- const { stdout: stdoutColor, stderr: stderrColor } = browser;
1323
+ const ansiStyles$2 = ansiStylesExports$1;
1324
+ const { stdout: stdoutColor$1, stderr: stderrColor$1 } = browser$2;
1325
1325
  const {
1326
- stringReplaceAll,
1327
- stringEncaseCRLFWithFirstIndex
1328
- } = util;
1329
- const { isArray } = Array;
1330
- const levelMapping = [
1326
+ stringReplaceAll: stringReplaceAll$2,
1327
+ stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$2
1328
+ } = util$1;
1329
+ const { isArray: isArray$1 } = Array;
1330
+ const levelMapping$1 = [
1331
1331
  "ansi",
1332
1332
  "ansi",
1333
1333
  "ansi256",
1334
1334
  "ansi16m"
1335
1335
  ];
1336
- const styles = /* @__PURE__ */ Object.create(null);
1337
- const applyOptions = (object, options = {}) => {
1336
+ const styles$1 = /* @__PURE__ */ Object.create(null);
1337
+ const applyOptions$1 = (object, options = {}) => {
1338
1338
  if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1339
1339
  throw new Error("The `level` option should be an integer from 0 to 3");
1340
1340
  }
1341
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
1341
+ const colorLevel = stdoutColor$1 ? stdoutColor$1.level : 0;
1342
1342
  object.level = options.level === void 0 ? colorLevel : options.level;
1343
1343
  };
1344
- class ChalkClass {
1344
+ let ChalkClass$1 = class ChalkClass {
1345
1345
  constructor(options) {
1346
- return chalkFactory(options);
1346
+ return chalkFactory$1(options);
1347
1347
  }
1348
- }
1349
- const chalkFactory = (options) => {
1348
+ };
1349
+ const chalkFactory$1 = (options) => {
1350
1350
  const chalk2 = {};
1351
- applyOptions(chalk2, options);
1352
- chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
1353
- Object.setPrototypeOf(chalk2, Chalk.prototype);
1351
+ applyOptions$1(chalk2, options);
1352
+ chalk2.template = (...arguments_) => chalkTag$1(chalk2.template, ...arguments_);
1353
+ Object.setPrototypeOf(chalk2, Chalk$1.prototype);
1354
1354
  Object.setPrototypeOf(chalk2.template, chalk2);
1355
1355
  chalk2.template.constructor = () => {
1356
1356
  throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
1357
1357
  };
1358
- chalk2.template.Instance = ChalkClass;
1358
+ chalk2.template.Instance = ChalkClass$1;
1359
1359
  return chalk2.template;
1360
1360
  };
1361
- function Chalk(options) {
1362
- return chalkFactory(options);
1361
+ function Chalk$1(options) {
1362
+ return chalkFactory$1(options);
1363
1363
  }
1364
- for (const [styleName, style] of Object.entries(ansiStyles)) {
1365
- styles[styleName] = {
1364
+ for (const [styleName, style] of Object.entries(ansiStyles$2)) {
1365
+ styles$1[styleName] = {
1366
1366
  get() {
1367
- const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
1367
+ const builder = createBuilder$1(this, createStyler$1(style.open, style.close, this._styler), this._isEmpty);
1368
1368
  Object.defineProperty(this, styleName, { value: builder });
1369
1369
  return builder;
1370
1370
  }
1371
1371
  };
1372
1372
  }
1373
- styles.visible = {
1373
+ styles$1.visible = {
1374
1374
  get() {
1375
- const builder = createBuilder(this, this._styler, true);
1375
+ const builder = createBuilder$1(this, this._styler, true);
1376
1376
  Object.defineProperty(this, "visible", { value: builder });
1377
1377
  return builder;
1378
1378
  }
1379
1379
  };
1380
- const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
1381
- for (const model of usedModels) {
1382
- styles[model] = {
1380
+ const usedModels$1 = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
1381
+ for (const model of usedModels$1) {
1382
+ styles$1[model] = {
1383
1383
  get() {
1384
1384
  const { level } = this;
1385
1385
  return function(...arguments_) {
1386
- const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
1387
- return createBuilder(this, styler, this._isEmpty);
1386
+ const styler = createStyler$1(ansiStyles$2.color[levelMapping$1[level]][model](...arguments_), ansiStyles$2.color.close, this._styler);
1387
+ return createBuilder$1(this, styler, this._isEmpty);
1388
1388
  };
1389
1389
  }
1390
1390
  };
1391
1391
  }
1392
- for (const model of usedModels) {
1392
+ for (const model of usedModels$1) {
1393
1393
  const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1394
- styles[bgModel] = {
1394
+ styles$1[bgModel] = {
1395
1395
  get() {
1396
1396
  const { level } = this;
1397
1397
  return function(...arguments_) {
1398
- const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
1399
- return createBuilder(this, styler, this._isEmpty);
1398
+ const styler = createStyler$1(ansiStyles$2.bgColor[levelMapping$1[level]][model](...arguments_), ansiStyles$2.bgColor.close, this._styler);
1399
+ return createBuilder$1(this, styler, this._isEmpty);
1400
1400
  };
1401
1401
  }
1402
1402
  };
1403
1403
  }
1404
- const proto = Object.defineProperties(() => {
1404
+ const proto$1 = Object.defineProperties(() => {
1405
1405
  }, {
1406
- ...styles,
1406
+ ...styles$1,
1407
1407
  level: {
1408
1408
  enumerable: true,
1409
1409
  get() {
@@ -1414,7 +1414,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1414
1414
  }
1415
1415
  }
1416
1416
  });
1417
- const createStyler = (open, close, parent) => {
1417
+ const createStyler$1 = (open, close, parent) => {
1418
1418
  let openAll;
1419
1419
  let closeAll;
1420
1420
  if (parent === void 0) {
@@ -1432,20 +1432,20 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1432
1432
  parent
1433
1433
  };
1434
1434
  };
1435
- const createBuilder = (self2, _styler, _isEmpty) => {
1435
+ const createBuilder$1 = (self2, _styler, _isEmpty) => {
1436
1436
  const builder = (...arguments_) => {
1437
- if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1438
- return applyStyle(builder, chalkTag(builder, ...arguments_));
1437
+ if (isArray$1(arguments_[0]) && isArray$1(arguments_[0].raw)) {
1438
+ return applyStyle$1(builder, chalkTag$1(builder, ...arguments_));
1439
1439
  }
1440
- return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1440
+ return applyStyle$1(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1441
1441
  };
1442
- Object.setPrototypeOf(builder, proto);
1442
+ Object.setPrototypeOf(builder, proto$1);
1443
1443
  builder._generator = self2;
1444
1444
  builder._styler = _styler;
1445
1445
  builder._isEmpty = _isEmpty;
1446
1446
  return builder;
1447
1447
  };
1448
- const applyStyle = (self2, string) => {
1448
+ const applyStyle$1 = (self2, string) => {
1449
1449
  if (self2.level <= 0 || !string) {
1450
1450
  return self2._isEmpty ? "" : string;
1451
1451
  }
@@ -1456,20 +1456,20 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1456
1456
  const { openAll, closeAll } = styler;
1457
1457
  if (string.indexOf("\x1B") !== -1) {
1458
1458
  while (styler !== void 0) {
1459
- string = stringReplaceAll(string, styler.close, styler.open);
1459
+ string = stringReplaceAll$2(string, styler.close, styler.open);
1460
1460
  styler = styler.parent;
1461
1461
  }
1462
1462
  }
1463
1463
  const lfIndex = string.indexOf("\n");
1464
1464
  if (lfIndex !== -1) {
1465
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1465
+ string = stringEncaseCRLFWithFirstIndex$2(string, closeAll, openAll, lfIndex);
1466
1466
  }
1467
1467
  return openAll + string + closeAll;
1468
1468
  };
1469
- let template;
1470
- const chalkTag = (chalk2, ...strings) => {
1469
+ let template$1;
1470
+ const chalkTag$1 = (chalk2, ...strings) => {
1471
1471
  const [firstString] = strings;
1472
- if (!isArray(firstString) || !isArray(firstString.raw)) {
1472
+ if (!isArray$1(firstString) || !isArray$1(firstString.raw)) {
1473
1473
  return strings.join(" ");
1474
1474
  }
1475
1475
  const arguments_ = strings.slice(1);
@@ -1480,18 +1480,18 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1480
1480
  String(firstString.raw[i])
1481
1481
  );
1482
1482
  }
1483
- if (template === void 0) {
1484
- template = requireTemplates();
1483
+ if (template$1 === void 0) {
1484
+ template$1 = requireTemplates$1();
1485
1485
  }
1486
- return template(chalk2, parts.join(""));
1486
+ return template$1(chalk2, parts.join(""));
1487
1487
  };
1488
- Object.defineProperties(Chalk.prototype, styles);
1489
- const chalk = Chalk();
1490
- chalk.supportsColor = stdoutColor;
1491
- chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
1492
- chalk.stderr.supportsColor = stderrColor;
1493
- var source = chalk;
1494
- const chalk$1 = /* @__PURE__ */ getDefaultExportFromCjs(source);
1488
+ Object.defineProperties(Chalk$1.prototype, styles$1);
1489
+ const chalk$1 = Chalk$1();
1490
+ chalk$1.supportsColor = stdoutColor$1;
1491
+ chalk$1.stderr = Chalk$1({ level: stderrColor$1 ? stderrColor$1.level : 0 });
1492
+ chalk$1.stderr.supportsColor = stderrColor$1;
1493
+ var source = chalk$1;
1494
+ const chalk$2 = /* @__PURE__ */ getDefaultExportFromCjs(source);
1495
1495
  const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
1496
1496
  var AuthorizeOptionsResponseType = /* @__PURE__ */ ((AuthorizeOptionsResponseType2) => {
1497
1497
  AuthorizeOptionsResponseType2["CODE"] = "code";
@@ -1634,7 +1634,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1634
1634
  __privateAdd(this, _router, null);
1635
1635
  __privateAdd(this, _STORAGE_AUTHORIZE_OPTIONS_KEY, "authorize_options.stsmda.com.au");
1636
1636
  __privateAdd(this, _aic, null);
1637
- __privateAdd(this, _options);
1637
+ __privateAdd(this, _options2);
1638
1638
  __privateAdd(this, _oauth2ManagerPort);
1639
1639
  __privateAdd(this, _messageId, 0);
1640
1640
  __privateAdd(this, _messageHandlers, {});
@@ -1649,7 +1649,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1649
1649
  __privateAdd(this, _semaphoreRetrySleep, 50);
1650
1650
  __privateAdd(this, _ProcessMessageResponse, (data) => {
1651
1651
  const messageResponse = data;
1652
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`));
1652
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.yellow(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`));
1653
1653
  if (messageResponse.messageId === -1) {
1654
1654
  switch (messageResponse.command) {
1655
1655
  case IOauth2ListenerCommand.AUTHENTICATE_EVENT:
@@ -1686,10 +1686,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1686
1686
  __privateGet(this, _messageHandlers)[message.messageId] = (response) => {
1687
1687
  clearTimeout(timeout);
1688
1688
  delete __privateGet(this, _messageHandlers)[message.messageId];
1689
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`));
1689
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.yellow(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`));
1690
1690
  resolve(response);
1691
1691
  };
1692
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`));
1692
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.yellow(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`));
1693
1693
  __privateGet(this, _oauth2ManagerPort).postMessage(message);
1694
1694
  });
1695
1695
  });
@@ -1706,7 +1706,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1706
1706
  }
1707
1707
  });
1708
1708
  __privateAdd(this, _GetStore, () => {
1709
- return STSOauth2Store(__privateGet(this, _options).pinia);
1709
+ return STSOauth2Store(__privateGet(this, _options2).pinia);
1710
1710
  });
1711
1711
  // Will come from message channel
1712
1712
  __privateAdd(this, _HandleErrorEvent, (error) => {
@@ -1717,66 +1717,66 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1717
1717
  message: error
1718
1718
  });
1719
1719
  setTimeout(() => {
1720
- __privateGet(this, _router).replace(`${__privateGet(this, _options).uriBase}error`);
1720
+ __privateGet(this, _router).replace(`${__privateGet(this, _options2).uriBase}error`);
1721
1721
  }, 0);
1722
1722
  }
1723
1723
  });
1724
1724
  __privateAdd(this, _HandleAuthenticateEvent, (id_token) => {
1725
1725
  if (isNode) ;
1726
1726
  else {
1727
- if (__privateGet(this, _options).authenticateEvent) {
1728
- __privateGet(this, _options).authenticateEvent(id_token);
1727
+ if (__privateGet(this, _options2).authenticateEvent) {
1728
+ __privateGet(this, _options2).authenticateEvent(id_token);
1729
1729
  }
1730
1730
  __privateGet(this, _GetStore).call(this).UpdateIdToken(id_token);
1731
1731
  }
1732
1732
  });
1733
1733
  __privateAdd(this, _SetupRoute, (app, router) => {
1734
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.gray(`STSOAuth2Manager:#SetupRoute`));
1734
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.gray(`STSOAuth2Manager:#SetupRoute`));
1735
1735
  router.beforeEach(async (to, from, next) => {
1736
1736
  const oAuth2Manager = app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey];
1737
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.gray(`beforeEach: from: [${from.path}], to: [${to.path}]`));
1737
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.gray(`beforeEach: from: [${from.path}], to: [${to.path}]`));
1738
1738
  if (__privateGet(this, _GetStore).call(this).LoggedIn === false) {
1739
1739
  __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, `Not logged in`);
1740
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}authorize`) === 0) {
1741
- __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, `to = ${__privateGet(this, _options).uriBase}authorize`);
1740
+ if (to.path.localeCompare(`${__privateGet(this, _options2).uriBase}authorize`) === 0) {
1741
+ __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, `to = ${__privateGet(this, _options2).uriBase}authorize`);
1742
1742
  next();
1743
1743
  return;
1744
- } else if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}consent`) === 0) {
1744
+ } else if (to.path.localeCompare(`${__privateGet(this, _options2).uriBase}consent`) === 0) {
1745
1745
  if (__privateGet(this, _GetStore).call(this).id_token) {
1746
1746
  next();
1747
1747
  return;
1748
1748
  }
1749
1749
  }
1750
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}logout`) === 0) {
1750
+ if (to.path.localeCompare(`${__privateGet(this, _options2).uriBase}logout`) === 0) {
1751
1751
  next();
1752
1752
  return;
1753
1753
  }
1754
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}error`) === 0) {
1754
+ if (to.path.localeCompare(`${__privateGet(this, _options2).uriBase}error`) === 0) {
1755
1755
  next();
1756
1756
  return;
1757
1757
  }
1758
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}config`) === 0) {
1758
+ if (to.path.localeCompare(`${__privateGet(this, _options2).uriBase}config`) === 0) {
1759
1759
  next();
1760
1760
  return;
1761
1761
  }
1762
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}redirected`) === 0) {
1762
+ if (to.path.localeCompare(`${__privateGet(this, _options2).uriBase}redirected`) === 0) {
1763
1763
  next();
1764
1764
  return;
1765
1765
  }
1766
1766
  const str = to.query;
1767
1767
  if (str[stsutils.OAuth2ParameterType.CODE] || str[stsutils.OAuth2ParameterType.ERROR]) {
1768
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
1768
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
1769
1769
  const retVal = await oAuth2Manager.HandleRedirect(str);
1770
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
1770
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
1771
1771
  if (retVal) {
1772
1772
  next({
1773
- path: `${__privateGet(this, _options).uriBase}`,
1773
+ path: `${__privateGet(this, _options2).uriBase}`,
1774
1774
  replace: true
1775
1775
  });
1776
1776
  return;
1777
1777
  } else {
1778
1778
  next({
1779
- path: `${__privateGet(this, _options).uriBase}error`,
1779
+ path: `${__privateGet(this, _options2).uriBase}error`,
1780
1780
  replace: true
1781
1781
  });
1782
1782
  return;
@@ -1791,20 +1791,20 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1791
1791
  next();
1792
1792
  return;
1793
1793
  } else {
1794
- next(`${__privateGet(this, _options).uriBase}`);
1794
+ next(`${__privateGet(this, _options2).uriBase}`);
1795
1795
  return;
1796
1796
  }
1797
1797
  } else {
1798
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}consent`) === 0) {
1799
- next(`${__privateGet(this, _options).uriBase}`);
1798
+ if (to.path.localeCompare(`${__privateGet(this, _options2).uriBase}consent`) === 0) {
1799
+ next(`${__privateGet(this, _options2).uriBase}`);
1800
1800
  return;
1801
1801
  }
1802
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}authorize`) === 0) {
1803
- next(`${__privateGet(this, _options).uriBase}`);
1802
+ if (to.path.localeCompare(`${__privateGet(this, _options2).uriBase}authorize`) === 0) {
1803
+ next(`${__privateGet(this, _options2).uriBase}`);
1804
1804
  return;
1805
1805
  }
1806
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}logout`) === 0) {
1807
- next(`${__privateGet(this, _options).uriBase}`);
1806
+ if (to.path.localeCompare(`${__privateGet(this, _options2).uriBase}logout`) === 0) {
1807
+ next(`${__privateGet(this, _options2).uriBase}`);
1808
1808
  return;
1809
1809
  }
1810
1810
  next();
@@ -1823,7 +1823,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1823
1823
  throw new Error(`STSOAuth2Manager:ExecuteRefreshToken:maxSemaphoreRetries: [${__privateGet(this, _maxSemaphoreRetries)}] exceeded.`);
1824
1824
  }
1825
1825
  await stsutils.Sleep(__privateGet(this, _semaphoreRetrySleep));
1826
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.cyan(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`));
1826
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.cyan(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`));
1827
1827
  return await this.ExecuteRefreshToken(retryCount + 1);
1828
1828
  } else {
1829
1829
  __privateSet(this, _operationSemaphore, true);
@@ -1843,7 +1843,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1843
1843
  __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
1844
1844
  return response.payload;
1845
1845
  } catch (error) {
1846
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`RestoreSession Error: ${error}`));
1846
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$2.red(`RestoreSession Error: ${error}`));
1847
1847
  return false;
1848
1848
  }
1849
1849
  });
@@ -1858,18 +1858,18 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1858
1858
  return response.payload.authorizeOptionsClientCopy;
1859
1859
  }
1860
1860
  } catch (error) {
1861
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`Authorize Error: ${error}`));
1861
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$2.red(`Authorize Error: ${error}`));
1862
1862
  }
1863
1863
  return {};
1864
1864
  });
1865
1865
  __publicField(this, "HandleRedirect", async (queryVars) => {
1866
1866
  try {
1867
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect`));
1867
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.magenta(`STSOAuth2Manager:HandleRedirect`));
1868
1868
  let response = null;
1869
1869
  if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
1870
1870
  const authorizeOptions = __privateGet(this, _transactionStore).get(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
1871
1871
  __privateGet(this, _transactionStore).remove(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
1872
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
1872
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
1873
1873
  response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
1874
1874
  queryVars,
1875
1875
  authorizeOptions
@@ -1877,10 +1877,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1877
1877
  } else {
1878
1878
  response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
1879
1879
  }
1880
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
1880
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$2.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
1881
1881
  return response.payload;
1882
1882
  } catch (error) {
1883
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`HandleRedirect Error: ${error}`));
1883
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$2.red(`HandleRedirect Error: ${error}`));
1884
1884
  return false;
1885
1885
  }
1886
1886
  });
@@ -1889,7 +1889,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1889
1889
  const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
1890
1890
  return response.payload;
1891
1891
  } catch (error) {
1892
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`Logout Error: ${error}`));
1892
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$2.red(`Logout Error: ${error}`));
1893
1893
  return false;
1894
1894
  }
1895
1895
  });
@@ -1898,7 +1898,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1898
1898
  const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
1899
1899
  return response.payload;
1900
1900
  } catch (error) {
1901
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`InvokeExternalAPI Error: ${error}`));
1901
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$2.red(`InvokeExternalAPI Error: ${error}`));
1902
1902
  return null;
1903
1903
  }
1904
1904
  });
@@ -1909,7 +1909,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1909
1909
  return false;
1910
1910
  }
1911
1911
  });
1912
- __privateSet(this, _options, options);
1912
+ __privateSet(this, _options2, options);
1913
1913
  if (!isNode) {
1914
1914
  if (app.config.globalProperties.$sts[stsobservability.STSInstrumentControllerPluginKey]) {
1915
1915
  const STSInstrumentController = app.config.globalProperties.$sts[stsobservability.STSInstrumentControllerPluginKey];
@@ -1922,17 +1922,17 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1922
1922
  } else {
1923
1923
  __privateSet(this, _transactionStore, new stsvueutils.ClientStorageFactory({ clientStorageType: stsvueutils.ClientStorageType.SESSION_STORAGE, usePrefix: false }).GetStorage());
1924
1924
  }
1925
- if (__privateGet(this, _options).workerFactory) {
1926
- __privateSet(this, _worker, __privateGet(this, _options).workerFactory());
1925
+ if (__privateGet(this, _options2).workerFactory) {
1926
+ __privateSet(this, _worker, __privateGet(this, _options2).workerFactory());
1927
1927
  } else {
1928
1928
  throw new Error(`STSOAuth2Manager:constructor: Cannot init STSOAuth2Manager - this.#options.workerFactory not specified`);
1929
1929
  }
1930
1930
  if (!isNode) {
1931
1931
  __privateGet(this, _worker).onmessage = (data) => {
1932
- __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$1.green(`this.#worker.onmessage = [${data}]`));
1932
+ __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$2.green(`this.#worker.onmessage = [${data}]`));
1933
1933
  };
1934
1934
  __privateGet(this, _worker).onerror = (error) => {
1935
- __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$1.green(`this.#worker.onerror = [${JSON.stringify(error)}]`));
1935
+ __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$2.green(`this.#worker.onerror = [${JSON.stringify(error)}]`));
1936
1936
  };
1937
1937
  }
1938
1938
  let workerMessage;
@@ -1946,7 +1946,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1946
1946
  __privateSet(this, _oauth2ManagerPort, oauth2ManagerPort);
1947
1947
  workerMessage = {
1948
1948
  workerPort: oauth2WorkerPort,
1949
- options: __privateGet(this, _options).workerOptions
1949
+ options: __privateGet(this, _options2).workerOptions
1950
1950
  };
1951
1951
  __privateGet(this, _worker).postMessage(workerMessage, [oauth2WorkerPort]);
1952
1952
  __privateGet(this, _oauth2ManagerPort).on("message", (payload) => {
@@ -1962,7 +1962,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1962
1962
  __privateSet(this, _oauth2ManagerPort, oauth2ManagerPort);
1963
1963
  workerMessage = {
1964
1964
  workerPort: oauth2WorkerPort,
1965
- options: __privateGet(this, _options).workerOptions
1965
+ options: __privateGet(this, _options2).workerOptions
1966
1966
  };
1967
1967
  __privateGet(this, _worker).postMessage(workerMessage, [oauth2WorkerPort]);
1968
1968
  __privateGet(this, _oauth2ManagerPort).onmessage = (data) => {
@@ -1975,7 +1975,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1975
1975
  _router = new WeakMap();
1976
1976
  _STORAGE_AUTHORIZE_OPTIONS_KEY = new WeakMap();
1977
1977
  _aic = new WeakMap();
1978
- _options = new WeakMap();
1978
+ _options2 = new WeakMap();
1979
1979
  _oauth2ManagerPort = new WeakMap();
1980
1980
  _messageId = new WeakMap();
1981
1981
  _messageHandlers = new WeakMap();
@@ -1987,13 +1987,13 @@ var __privateWrapper = (obj, member, setter, getter) => ({
1987
1987
  _semaphoreRetrySleep = new WeakMap();
1988
1988
  _STSOAuth2Manager_instances = new WeakSet();
1989
1989
  LogDebugMessage_fn = function(message) {
1990
- __privateGet(this, _options).logger.debug(message);
1990
+ __privateGet(this, _options2).logger.debug(message);
1991
1991
  };
1992
1992
  LogInfoMessage_fn = function(message) {
1993
- __privateGet(this, _options).logger.info(message);
1993
+ __privateGet(this, _options2).logger.info(message);
1994
1994
  };
1995
1995
  LogErrorMessage_fn = function(message) {
1996
- __privateGet(this, _options).logger.error(message);
1996
+ __privateGet(this, _options2).logger.error(message);
1997
1997
  };
1998
1998
  _ProcessMessageResponse = new WeakMap();
1999
1999
  _PostMessage = new WeakMap();
@@ -2004,16 +2004,16 @@ var __privateWrapper = (obj, member, setter, getter) => ({
2004
2004
  _HandleAuthenticateEvent = new WeakMap();
2005
2005
  _SetupRoute = new WeakMap();
2006
2006
  var sha256$1 = { exports: {} };
2007
- function commonjsRequire(path) {
2008
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
2007
+ function commonjsRequire(path2) {
2008
+ throw new Error('Could not dynamically require "' + path2 + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
2009
2009
  }
2010
2010
  var core = { exports: {} };
2011
- const __viteBrowserExternal = {};
2012
- const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2011
+ const http = {};
2012
+ const fs$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2013
2013
  __proto__: null,
2014
- default: __viteBrowserExternal
2014
+ default: http
2015
2015
  }, Symbol.toStringTag, { value: "Module" }));
2016
- const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
2016
+ const require$$3 = /* @__PURE__ */ getAugmentedNamespace(fs$1);
2017
2017
  var hasRequiredCore;
2018
2018
  function requireCore() {
2019
2019
  if (hasRequiredCore) return core.exports;
@@ -2043,7 +2043,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
2043
2043
  }
2044
2044
  if (!crypto2 && typeof commonjsRequire === "function") {
2045
2045
  try {
2046
- crypto2 = require$$0;
2046
+ crypto2 = require$$3;
2047
2047
  } catch (err) {
2048
2048
  }
2049
2049
  }
@@ -2957,91 +2957,2218 @@ var __privateWrapper = (obj, member, setter, getter) => ({
2957
2957
  StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
2958
2958
  StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
2959
2959
  })(StatusCodes || (StatusCodes = {}));
2960
- class STSOAuth2Worker {
2961
- constructor(workerPort, options, logger) {
2962
- __privateAdd(this, _STSOAuth2Worker_instances);
2963
- //#storageManager = null;
2964
- __privateAdd(this, _clientSessionStore);
2965
- __privateAdd(this, _cUtils, new CryptoUtils());
2966
- __privateAdd(this, _qParams, new QueryParams());
2967
- __privateAdd(this, _STORAGE_SESSION_KEY, "session.stsmda.com.au");
2968
- //@@#aic = null;
2969
- __privateAdd(this, _oauthWorkerPort);
2970
- __privateAdd(this, _options2);
2971
- __privateAdd(this, _httpsAgent, null);
2972
- __privateAdd(this, _logger);
2973
- // Attempt to restore a previous session using the STSBroker
2974
- /*
2975
- { parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
2976
- { parameterType: OAuth2ParameterType.SCOPE, errorType: authErrorType.SCOPE_MISMATCH }
2977
- { parameterType: OAuth2ParameterType.REDIRECT_URI, errorType: authErrorType.REDIRECT_URI_MISMATCH },
2978
- { parameterType: OAuth2ParameterType.AUDIENCE, errorType: authErrorType.SCOPE_MISMATCH }
2979
-
2980
- Successful Response
2981
- {
2982
- "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",
2983
- "token_type": "Bearer",
2984
- "expires_in": 3599,
2985
- "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",
2986
- "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",
2987
- "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
2988
- }
2989
-
2990
- Error Response
2991
- {
2992
- "error": "invalid_scope",
2993
- "error_description": "AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope https://foo.microsoft.com/mail.read is not valid.\r\nTrace ID: 255d1aef-8c98-452f-ac51-23d051240864\r\nCorrelation ID: fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7\r\nTimestamp: 2016-01-09 02:02:12Z",
2994
- "error_codes": [
2995
- 70011
2996
- ],
2997
- "timestamp": "2016-01-09 02:02:12Z",
2960
+ var main$1 = { exports: {} };
2961
+ const name = "dotenv";
2962
+ const version$1 = "16.4.5";
2963
+ const description = "Loads environment variables from .env file";
2964
+ const main = "lib/main.js";
2965
+ const types = "lib/main.d.ts";
2966
+ const exports$1 = {
2967
+ ".": {
2968
+ types: "./lib/main.d.ts",
2969
+ require: "./lib/main.js",
2970
+ "default": "./lib/main.js"
2971
+ },
2972
+ "./config": "./config.js",
2973
+ "./config.js": "./config.js",
2974
+ "./lib/env-options": "./lib/env-options.js",
2975
+ "./lib/env-options.js": "./lib/env-options.js",
2976
+ "./lib/cli-options": "./lib/cli-options.js",
2977
+ "./lib/cli-options.js": "./lib/cli-options.js",
2978
+ "./package.json": "./package.json"
2979
+ };
2980
+ const scripts = {
2981
+ "dts-check": "tsc --project tests/types/tsconfig.json",
2982
+ lint: "standard",
2983
+ "lint-readme": "standard-markdown",
2984
+ pretest: "npm run lint && npm run dts-check",
2985
+ test: "tap tests/*.js --100 -Rspec",
2986
+ "test:coverage": "tap --coverage-report=lcov",
2987
+ prerelease: "npm test",
2988
+ release: "standard-version"
2989
+ };
2990
+ const repository = {
2991
+ type: "git",
2992
+ url: "git://github.com/motdotla/dotenv.git"
2993
+ };
2994
+ const funding = "https://dotenvx.com";
2995
+ const keywords = [
2996
+ "dotenv",
2997
+ "env",
2998
+ ".env",
2999
+ "environment",
3000
+ "variables",
3001
+ "config",
3002
+ "settings"
3003
+ ];
3004
+ const readmeFilename = "README.md";
3005
+ const license = "BSD-2-Clause";
3006
+ const devDependencies = {
3007
+ "@definitelytyped/dtslint": "^0.0.133",
3008
+ "@types/node": "^18.11.3",
3009
+ decache: "^4.6.1",
3010
+ sinon: "^14.0.1",
3011
+ standard: "^17.0.0",
3012
+ "standard-markdown": "^7.1.0",
3013
+ "standard-version": "^9.5.0",
3014
+ tap: "^16.3.0",
3015
+ tar: "^6.1.11",
3016
+ typescript: "^4.8.4"
3017
+ };
3018
+ const engines = {
3019
+ node: ">=12"
3020
+ };
3021
+ const browser$1 = {
3022
+ fs: false
3023
+ };
3024
+ const require$$4 = {
3025
+ name,
3026
+ version: version$1,
3027
+ description,
3028
+ main,
3029
+ types,
3030
+ exports: exports$1,
3031
+ scripts,
3032
+ repository,
3033
+ funding,
3034
+ keywords,
3035
+ readmeFilename,
3036
+ license,
3037
+ devDependencies,
3038
+ engines,
3039
+ browser: browser$1
3040
+ };
3041
+ const fs = require$$3;
3042
+ const path = require$$3;
3043
+ const os = require$$3;
3044
+ const crypto$1 = require$$3;
3045
+ const packageJson = require$$4;
3046
+ const version = packageJson.version;
3047
+ const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
3048
+ function parse(src) {
3049
+ const obj = {};
3050
+ let lines = src.toString();
3051
+ lines = lines.replace(/\r\n?/mg, "\n");
3052
+ let match;
3053
+ while ((match = LINE.exec(lines)) != null) {
3054
+ const key = match[1];
3055
+ let value = match[2] || "";
3056
+ value = value.trim();
3057
+ const maybeQuote = value[0];
3058
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
3059
+ if (maybeQuote === '"') {
3060
+ value = value.replace(/\\n/g, "\n");
3061
+ value = value.replace(/\\r/g, "\r");
3062
+ }
3063
+ obj[key] = value;
3064
+ }
3065
+ return obj;
3066
+ }
3067
+ function _parseVault(options) {
3068
+ const vaultPath = _vaultPath(options);
3069
+ const result = DotenvModule.configDotenv({ path: vaultPath });
3070
+ if (!result.parsed) {
3071
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
3072
+ err.code = "MISSING_DATA";
3073
+ throw err;
3074
+ }
3075
+ const keys = _dotenvKey(options).split(",");
3076
+ const length = keys.length;
3077
+ let decrypted;
3078
+ for (let i = 0; i < length; i++) {
3079
+ try {
3080
+ const key = keys[i].trim();
3081
+ const attrs = _instructions(result, key);
3082
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
3083
+ break;
3084
+ } catch (error) {
3085
+ if (i + 1 >= length) {
3086
+ throw error;
3087
+ }
3088
+ }
3089
+ }
3090
+ return DotenvModule.parse(decrypted);
3091
+ }
3092
+ function _log(message) {
3093
+ console.log(`[dotenv@${version}][INFO] ${message}`);
3094
+ }
3095
+ function _warn(message) {
3096
+ console.log(`[dotenv@${version}][WARN] ${message}`);
3097
+ }
3098
+ function _debug(message) {
3099
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
3100
+ }
3101
+ function _dotenvKey(options) {
3102
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
3103
+ return options.DOTENV_KEY;
3104
+ }
3105
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
3106
+ return process.env.DOTENV_KEY;
3107
+ }
3108
+ return "";
3109
+ }
3110
+ function _instructions(result, dotenvKey) {
3111
+ let uri;
3112
+ try {
3113
+ uri = new URL(dotenvKey);
3114
+ } catch (error) {
3115
+ if (error.code === "ERR_INVALID_URL") {
3116
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
3117
+ err.code = "INVALID_DOTENV_KEY";
3118
+ throw err;
3119
+ }
3120
+ throw error;
3121
+ }
3122
+ const key = uri.password;
3123
+ if (!key) {
3124
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
3125
+ err.code = "INVALID_DOTENV_KEY";
3126
+ throw err;
3127
+ }
3128
+ const environment = uri.searchParams.get("environment");
3129
+ if (!environment) {
3130
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
3131
+ err.code = "INVALID_DOTENV_KEY";
3132
+ throw err;
3133
+ }
3134
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
3135
+ const ciphertext = result.parsed[environmentKey];
3136
+ if (!ciphertext) {
3137
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
3138
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
3139
+ throw err;
3140
+ }
3141
+ return { ciphertext, key };
3142
+ }
3143
+ function _vaultPath(options) {
3144
+ let possibleVaultPath = null;
3145
+ if (options && options.path && options.path.length > 0) {
3146
+ if (Array.isArray(options.path)) {
3147
+ for (const filepath of options.path) {
3148
+ if (fs.existsSync(filepath)) {
3149
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
2998
3150
  }
2999
-
3000
- */
3001
- __privateAdd(this, _HandleAuthenticateEvent2, (id_token) => {
3002
- const message = {
3003
- messageId: -1,
3004
- // un-solicited message
3005
- command: IOauth2ListenerCommand.AUTHENTICATE_EVENT
3006
- };
3007
- __privateGet(this, _ProcessCommand).call(this, message, id_token);
3008
- });
3009
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3010
- __privateAdd(this, _HandleErrorEvent2, (error) => {
3011
- const message = {
3012
- messageId: -1,
3013
- // un-solicited message
3014
- command: IOauth2ListenerCommand.ERROR
3015
- };
3016
- __privateGet(this, _ProcessCommand).call(this, message, error);
3017
- });
3018
- __privateAdd(this, _LogMessage, (messageToSend) => {
3019
- const message = {
3020
- messageId: -1,
3021
- // un-solicited message
3022
- command: IOauth2ListenerCommand.LOG
3023
- };
3024
- __privateGet(this, _ProcessCommand).call(this, message, messageToSend);
3025
- });
3026
- __privateAdd(this, _GetAccessToken, () => {
3027
- const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
3028
- if (sessionData) {
3029
- const tokens = sessionData.tokenResponse;
3030
- return tokens.access_token;
3031
- } else {
3032
- return null;
3033
3151
  }
3034
- });
3035
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3036
- __privateAdd(this, _GetCookies, () => {
3037
- if (isNode) {
3038
- const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
3039
- if (sessionData) {
3040
- return sessionData.brokerCookie;
3152
+ } else {
3153
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
3154
+ }
3155
+ } else {
3156
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
3157
+ }
3158
+ if (fs.existsSync(possibleVaultPath)) {
3159
+ return possibleVaultPath;
3160
+ }
3161
+ return null;
3162
+ }
3163
+ function _resolveHome(envPath) {
3164
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
3165
+ }
3166
+ function _configVault(options) {
3167
+ _log("Loading env from encrypted .env.vault");
3168
+ const parsed = DotenvModule._parseVault(options);
3169
+ let processEnv = process.env;
3170
+ if (options && options.processEnv != null) {
3171
+ processEnv = options.processEnv;
3172
+ }
3173
+ DotenvModule.populate(processEnv, parsed, options);
3174
+ return { parsed };
3175
+ }
3176
+ function configDotenv(options) {
3177
+ const dotenvPath = path.resolve(process.cwd(), ".env");
3178
+ let encoding = "utf8";
3179
+ const debug = Boolean(options && options.debug);
3180
+ if (options && options.encoding) {
3181
+ encoding = options.encoding;
3182
+ } else {
3183
+ if (debug) {
3184
+ _debug("No encoding is specified. UTF-8 is used by default");
3185
+ }
3186
+ }
3187
+ let optionPaths = [dotenvPath];
3188
+ if (options && options.path) {
3189
+ if (!Array.isArray(options.path)) {
3190
+ optionPaths = [_resolveHome(options.path)];
3191
+ } else {
3192
+ optionPaths = [];
3193
+ for (const filepath of options.path) {
3194
+ optionPaths.push(_resolveHome(filepath));
3195
+ }
3196
+ }
3197
+ }
3198
+ let lastError;
3199
+ const parsedAll = {};
3200
+ for (const path2 of optionPaths) {
3201
+ try {
3202
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
3203
+ DotenvModule.populate(parsedAll, parsed, options);
3204
+ } catch (e) {
3205
+ if (debug) {
3206
+ _debug(`Failed to load ${path2} ${e.message}`);
3207
+ }
3208
+ lastError = e;
3209
+ }
3210
+ }
3211
+ let processEnv = process.env;
3212
+ if (options && options.processEnv != null) {
3213
+ processEnv = options.processEnv;
3214
+ }
3215
+ DotenvModule.populate(processEnv, parsedAll, options);
3216
+ if (lastError) {
3217
+ return { parsed: parsedAll, error: lastError };
3218
+ } else {
3219
+ return { parsed: parsedAll };
3220
+ }
3221
+ }
3222
+ function config(options) {
3223
+ if (_dotenvKey(options).length === 0) {
3224
+ return DotenvModule.configDotenv(options);
3225
+ }
3226
+ const vaultPath = _vaultPath(options);
3227
+ if (!vaultPath) {
3228
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
3229
+ return DotenvModule.configDotenv(options);
3230
+ }
3231
+ return DotenvModule._configVault(options);
3232
+ }
3233
+ function decrypt(encrypted, keyStr) {
3234
+ const key = Buffer.from(keyStr.slice(-64), "hex");
3235
+ let ciphertext = Buffer.from(encrypted, "base64");
3236
+ const nonce = ciphertext.subarray(0, 12);
3237
+ const authTag = ciphertext.subarray(-16);
3238
+ ciphertext = ciphertext.subarray(12, -16);
3239
+ try {
3240
+ const aesgcm = crypto$1.createDecipheriv("aes-256-gcm", key, nonce);
3241
+ aesgcm.setAuthTag(authTag);
3242
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
3243
+ } catch (error) {
3244
+ const isRange = error instanceof RangeError;
3245
+ const invalidKeyLength = error.message === "Invalid key length";
3246
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
3247
+ if (isRange || invalidKeyLength) {
3248
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
3249
+ err.code = "INVALID_DOTENV_KEY";
3250
+ throw err;
3251
+ } else if (decryptionFailed) {
3252
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
3253
+ err.code = "DECRYPTION_FAILED";
3254
+ throw err;
3255
+ } else {
3256
+ throw error;
3257
+ }
3258
+ }
3259
+ }
3260
+ function populate(processEnv, parsed, options = {}) {
3261
+ const debug = Boolean(options && options.debug);
3262
+ const override = Boolean(options && options.override);
3263
+ if (typeof parsed !== "object") {
3264
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
3265
+ err.code = "OBJECT_REQUIRED";
3266
+ throw err;
3267
+ }
3268
+ for (const key of Object.keys(parsed)) {
3269
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
3270
+ if (override === true) {
3271
+ processEnv[key] = parsed[key];
3272
+ }
3273
+ if (debug) {
3274
+ if (override === true) {
3275
+ _debug(`"${key}" is already defined and WAS overwritten`);
3041
3276
  } else {
3042
- return null;
3277
+ _debug(`"${key}" is already defined and was NOT overwritten`);
3043
3278
  }
3044
- } else {
3279
+ }
3280
+ } else {
3281
+ processEnv[key] = parsed[key];
3282
+ }
3283
+ }
3284
+ }
3285
+ const DotenvModule = {
3286
+ configDotenv,
3287
+ _configVault,
3288
+ _parseVault,
3289
+ config,
3290
+ decrypt,
3291
+ parse,
3292
+ populate
3293
+ };
3294
+ main$1.exports.configDotenv = DotenvModule.configDotenv;
3295
+ main$1.exports._configVault = DotenvModule._configVault;
3296
+ main$1.exports._parseVault = DotenvModule._parseVault;
3297
+ var config_1 = main$1.exports.config = DotenvModule.config;
3298
+ main$1.exports.decrypt = DotenvModule.decrypt;
3299
+ main$1.exports.parse = DotenvModule.parse;
3300
+ main$1.exports.populate = DotenvModule.populate;
3301
+ main$1.exports = DotenvModule;
3302
+ var __typeError2 = (msg) => {
3303
+ throw TypeError(msg);
3304
+ };
3305
+ var __accessCheck2 = (obj, member, msg) => member.has(obj) || __typeError2("Cannot " + msg);
3306
+ var __privateGet2 = (obj, member, getter) => (__accessCheck2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
3307
+ var __privateAdd2 = (obj, member, value) => member.has(obj) ? __typeError2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3308
+ var __privateSet2 = (obj, member, value, setter) => (__accessCheck2(obj, member, "write to private field"), member.set(obj, value), value);
3309
+ var __privateWrapper2 = (obj, member, setter, getter) => ({
3310
+ set _(value) {
3311
+ __privateSet2(obj, member, value);
3312
+ },
3313
+ get _() {
3314
+ return __privateGet2(obj, member, getter);
3315
+ }
3316
+ });
3317
+ var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions;
3318
+ var ansiStyles$1 = { exports: {} };
3319
+ var colorName;
3320
+ var hasRequiredColorName;
3321
+ function requireColorName() {
3322
+ if (hasRequiredColorName) return colorName;
3323
+ hasRequiredColorName = 1;
3324
+ colorName = {
3325
+ "aliceblue": [240, 248, 255],
3326
+ "antiquewhite": [250, 235, 215],
3327
+ "aqua": [0, 255, 255],
3328
+ "aquamarine": [127, 255, 212],
3329
+ "azure": [240, 255, 255],
3330
+ "beige": [245, 245, 220],
3331
+ "bisque": [255, 228, 196],
3332
+ "black": [0, 0, 0],
3333
+ "blanchedalmond": [255, 235, 205],
3334
+ "blue": [0, 0, 255],
3335
+ "blueviolet": [138, 43, 226],
3336
+ "brown": [165, 42, 42],
3337
+ "burlywood": [222, 184, 135],
3338
+ "cadetblue": [95, 158, 160],
3339
+ "chartreuse": [127, 255, 0],
3340
+ "chocolate": [210, 105, 30],
3341
+ "coral": [255, 127, 80],
3342
+ "cornflowerblue": [100, 149, 237],
3343
+ "cornsilk": [255, 248, 220],
3344
+ "crimson": [220, 20, 60],
3345
+ "cyan": [0, 255, 255],
3346
+ "darkblue": [0, 0, 139],
3347
+ "darkcyan": [0, 139, 139],
3348
+ "darkgoldenrod": [184, 134, 11],
3349
+ "darkgray": [169, 169, 169],
3350
+ "darkgreen": [0, 100, 0],
3351
+ "darkgrey": [169, 169, 169],
3352
+ "darkkhaki": [189, 183, 107],
3353
+ "darkmagenta": [139, 0, 139],
3354
+ "darkolivegreen": [85, 107, 47],
3355
+ "darkorange": [255, 140, 0],
3356
+ "darkorchid": [153, 50, 204],
3357
+ "darkred": [139, 0, 0],
3358
+ "darksalmon": [233, 150, 122],
3359
+ "darkseagreen": [143, 188, 143],
3360
+ "darkslateblue": [72, 61, 139],
3361
+ "darkslategray": [47, 79, 79],
3362
+ "darkslategrey": [47, 79, 79],
3363
+ "darkturquoise": [0, 206, 209],
3364
+ "darkviolet": [148, 0, 211],
3365
+ "deeppink": [255, 20, 147],
3366
+ "deepskyblue": [0, 191, 255],
3367
+ "dimgray": [105, 105, 105],
3368
+ "dimgrey": [105, 105, 105],
3369
+ "dodgerblue": [30, 144, 255],
3370
+ "firebrick": [178, 34, 34],
3371
+ "floralwhite": [255, 250, 240],
3372
+ "forestgreen": [34, 139, 34],
3373
+ "fuchsia": [255, 0, 255],
3374
+ "gainsboro": [220, 220, 220],
3375
+ "ghostwhite": [248, 248, 255],
3376
+ "gold": [255, 215, 0],
3377
+ "goldenrod": [218, 165, 32],
3378
+ "gray": [128, 128, 128],
3379
+ "green": [0, 128, 0],
3380
+ "greenyellow": [173, 255, 47],
3381
+ "grey": [128, 128, 128],
3382
+ "honeydew": [240, 255, 240],
3383
+ "hotpink": [255, 105, 180],
3384
+ "indianred": [205, 92, 92],
3385
+ "indigo": [75, 0, 130],
3386
+ "ivory": [255, 255, 240],
3387
+ "khaki": [240, 230, 140],
3388
+ "lavender": [230, 230, 250],
3389
+ "lavenderblush": [255, 240, 245],
3390
+ "lawngreen": [124, 252, 0],
3391
+ "lemonchiffon": [255, 250, 205],
3392
+ "lightblue": [173, 216, 230],
3393
+ "lightcoral": [240, 128, 128],
3394
+ "lightcyan": [224, 255, 255],
3395
+ "lightgoldenrodyellow": [250, 250, 210],
3396
+ "lightgray": [211, 211, 211],
3397
+ "lightgreen": [144, 238, 144],
3398
+ "lightgrey": [211, 211, 211],
3399
+ "lightpink": [255, 182, 193],
3400
+ "lightsalmon": [255, 160, 122],
3401
+ "lightseagreen": [32, 178, 170],
3402
+ "lightskyblue": [135, 206, 250],
3403
+ "lightslategray": [119, 136, 153],
3404
+ "lightslategrey": [119, 136, 153],
3405
+ "lightsteelblue": [176, 196, 222],
3406
+ "lightyellow": [255, 255, 224],
3407
+ "lime": [0, 255, 0],
3408
+ "limegreen": [50, 205, 50],
3409
+ "linen": [250, 240, 230],
3410
+ "magenta": [255, 0, 255],
3411
+ "maroon": [128, 0, 0],
3412
+ "mediumaquamarine": [102, 205, 170],
3413
+ "mediumblue": [0, 0, 205],
3414
+ "mediumorchid": [186, 85, 211],
3415
+ "mediumpurple": [147, 112, 219],
3416
+ "mediumseagreen": [60, 179, 113],
3417
+ "mediumslateblue": [123, 104, 238],
3418
+ "mediumspringgreen": [0, 250, 154],
3419
+ "mediumturquoise": [72, 209, 204],
3420
+ "mediumvioletred": [199, 21, 133],
3421
+ "midnightblue": [25, 25, 112],
3422
+ "mintcream": [245, 255, 250],
3423
+ "mistyrose": [255, 228, 225],
3424
+ "moccasin": [255, 228, 181],
3425
+ "navajowhite": [255, 222, 173],
3426
+ "navy": [0, 0, 128],
3427
+ "oldlace": [253, 245, 230],
3428
+ "olive": [128, 128, 0],
3429
+ "olivedrab": [107, 142, 35],
3430
+ "orange": [255, 165, 0],
3431
+ "orangered": [255, 69, 0],
3432
+ "orchid": [218, 112, 214],
3433
+ "palegoldenrod": [238, 232, 170],
3434
+ "palegreen": [152, 251, 152],
3435
+ "paleturquoise": [175, 238, 238],
3436
+ "palevioletred": [219, 112, 147],
3437
+ "papayawhip": [255, 239, 213],
3438
+ "peachpuff": [255, 218, 185],
3439
+ "peru": [205, 133, 63],
3440
+ "pink": [255, 192, 203],
3441
+ "plum": [221, 160, 221],
3442
+ "powderblue": [176, 224, 230],
3443
+ "purple": [128, 0, 128],
3444
+ "rebeccapurple": [102, 51, 153],
3445
+ "red": [255, 0, 0],
3446
+ "rosybrown": [188, 143, 143],
3447
+ "royalblue": [65, 105, 225],
3448
+ "saddlebrown": [139, 69, 19],
3449
+ "salmon": [250, 128, 114],
3450
+ "sandybrown": [244, 164, 96],
3451
+ "seagreen": [46, 139, 87],
3452
+ "seashell": [255, 245, 238],
3453
+ "sienna": [160, 82, 45],
3454
+ "silver": [192, 192, 192],
3455
+ "skyblue": [135, 206, 235],
3456
+ "slateblue": [106, 90, 205],
3457
+ "slategray": [112, 128, 144],
3458
+ "slategrey": [112, 128, 144],
3459
+ "snow": [255, 250, 250],
3460
+ "springgreen": [0, 255, 127],
3461
+ "steelblue": [70, 130, 180],
3462
+ "tan": [210, 180, 140],
3463
+ "teal": [0, 128, 128],
3464
+ "thistle": [216, 191, 216],
3465
+ "tomato": [255, 99, 71],
3466
+ "turquoise": [64, 224, 208],
3467
+ "violet": [238, 130, 238],
3468
+ "wheat": [245, 222, 179],
3469
+ "white": [255, 255, 255],
3470
+ "whitesmoke": [245, 245, 245],
3471
+ "yellow": [255, 255, 0],
3472
+ "yellowgreen": [154, 205, 50]
3473
+ };
3474
+ return colorName;
3475
+ }
3476
+ var conversions;
3477
+ var hasRequiredConversions;
3478
+ function requireConversions() {
3479
+ if (hasRequiredConversions) return conversions;
3480
+ hasRequiredConversions = 1;
3481
+ const cssKeywords = requireColorName();
3482
+ const reverseKeywords = {};
3483
+ for (const key of Object.keys(cssKeywords)) {
3484
+ reverseKeywords[cssKeywords[key]] = key;
3485
+ }
3486
+ const convert = {
3487
+ rgb: { channels: 3, labels: "rgb" },
3488
+ hsl: { channels: 3, labels: "hsl" },
3489
+ hsv: { channels: 3, labels: "hsv" },
3490
+ hwb: { channels: 3, labels: "hwb" },
3491
+ cmyk: { channels: 4, labels: "cmyk" },
3492
+ xyz: { channels: 3, labels: "xyz" },
3493
+ lab: { channels: 3, labels: "lab" },
3494
+ lch: { channels: 3, labels: "lch" },
3495
+ hex: { channels: 1, labels: ["hex"] },
3496
+ keyword: { channels: 1, labels: ["keyword"] },
3497
+ ansi16: { channels: 1, labels: ["ansi16"] },
3498
+ ansi256: { channels: 1, labels: ["ansi256"] },
3499
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
3500
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
3501
+ gray: { channels: 1, labels: ["gray"] }
3502
+ };
3503
+ conversions = convert;
3504
+ for (const model of Object.keys(convert)) {
3505
+ if (!("channels" in convert[model])) {
3506
+ throw new Error("missing channels property: " + model);
3507
+ }
3508
+ if (!("labels" in convert[model])) {
3509
+ throw new Error("missing channel labels property: " + model);
3510
+ }
3511
+ if (convert[model].labels.length !== convert[model].channels) {
3512
+ throw new Error("channel and label counts mismatch: " + model);
3513
+ }
3514
+ const { channels, labels } = convert[model];
3515
+ delete convert[model].channels;
3516
+ delete convert[model].labels;
3517
+ Object.defineProperty(convert[model], "channels", { value: channels });
3518
+ Object.defineProperty(convert[model], "labels", { value: labels });
3519
+ }
3520
+ convert.rgb.hsl = function(rgb) {
3521
+ const r = rgb[0] / 255;
3522
+ const g = rgb[1] / 255;
3523
+ const b = rgb[2] / 255;
3524
+ const min = Math.min(r, g, b);
3525
+ const max = Math.max(r, g, b);
3526
+ const delta = max - min;
3527
+ let h;
3528
+ let s;
3529
+ if (max === min) {
3530
+ h = 0;
3531
+ } else if (r === max) {
3532
+ h = (g - b) / delta;
3533
+ } else if (g === max) {
3534
+ h = 2 + (b - r) / delta;
3535
+ } else if (b === max) {
3536
+ h = 4 + (r - g) / delta;
3537
+ }
3538
+ h = Math.min(h * 60, 360);
3539
+ if (h < 0) {
3540
+ h += 360;
3541
+ }
3542
+ const l = (min + max) / 2;
3543
+ if (max === min) {
3544
+ s = 0;
3545
+ } else if (l <= 0.5) {
3546
+ s = delta / (max + min);
3547
+ } else {
3548
+ s = delta / (2 - max - min);
3549
+ }
3550
+ return [h, s * 100, l * 100];
3551
+ };
3552
+ convert.rgb.hsv = function(rgb) {
3553
+ let rdif;
3554
+ let gdif;
3555
+ let bdif;
3556
+ let h;
3557
+ let s;
3558
+ const r = rgb[0] / 255;
3559
+ const g = rgb[1] / 255;
3560
+ const b = rgb[2] / 255;
3561
+ const v = Math.max(r, g, b);
3562
+ const diff = v - Math.min(r, g, b);
3563
+ const diffc = function(c) {
3564
+ return (v - c) / 6 / diff + 1 / 2;
3565
+ };
3566
+ if (diff === 0) {
3567
+ h = 0;
3568
+ s = 0;
3569
+ } else {
3570
+ s = diff / v;
3571
+ rdif = diffc(r);
3572
+ gdif = diffc(g);
3573
+ bdif = diffc(b);
3574
+ if (r === v) {
3575
+ h = bdif - gdif;
3576
+ } else if (g === v) {
3577
+ h = 1 / 3 + rdif - bdif;
3578
+ } else if (b === v) {
3579
+ h = 2 / 3 + gdif - rdif;
3580
+ }
3581
+ if (h < 0) {
3582
+ h += 1;
3583
+ } else if (h > 1) {
3584
+ h -= 1;
3585
+ }
3586
+ }
3587
+ return [
3588
+ h * 360,
3589
+ s * 100,
3590
+ v * 100
3591
+ ];
3592
+ };
3593
+ convert.rgb.hwb = function(rgb) {
3594
+ const r = rgb[0];
3595
+ const g = rgb[1];
3596
+ let b = rgb[2];
3597
+ const h = convert.rgb.hsl(rgb)[0];
3598
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
3599
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
3600
+ return [h, w * 100, b * 100];
3601
+ };
3602
+ convert.rgb.cmyk = function(rgb) {
3603
+ const r = rgb[0] / 255;
3604
+ const g = rgb[1] / 255;
3605
+ const b = rgb[2] / 255;
3606
+ const k = Math.min(1 - r, 1 - g, 1 - b);
3607
+ const c = (1 - r - k) / (1 - k) || 0;
3608
+ const m = (1 - g - k) / (1 - k) || 0;
3609
+ const y = (1 - b - k) / (1 - k) || 0;
3610
+ return [c * 100, m * 100, y * 100, k * 100];
3611
+ };
3612
+ function comparativeDistance(x, y) {
3613
+ return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
3614
+ }
3615
+ convert.rgb.keyword = function(rgb) {
3616
+ const reversed = reverseKeywords[rgb];
3617
+ if (reversed) {
3618
+ return reversed;
3619
+ }
3620
+ let currentClosestDistance = Infinity;
3621
+ let currentClosestKeyword;
3622
+ for (const keyword of Object.keys(cssKeywords)) {
3623
+ const value = cssKeywords[keyword];
3624
+ const distance = comparativeDistance(rgb, value);
3625
+ if (distance < currentClosestDistance) {
3626
+ currentClosestDistance = distance;
3627
+ currentClosestKeyword = keyword;
3628
+ }
3629
+ }
3630
+ return currentClosestKeyword;
3631
+ };
3632
+ convert.keyword.rgb = function(keyword) {
3633
+ return cssKeywords[keyword];
3634
+ };
3635
+ convert.rgb.xyz = function(rgb) {
3636
+ let r = rgb[0] / 255;
3637
+ let g = rgb[1] / 255;
3638
+ let b = rgb[2] / 255;
3639
+ r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
3640
+ g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
3641
+ b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
3642
+ const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
3643
+ const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
3644
+ const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
3645
+ return [x * 100, y * 100, z * 100];
3646
+ };
3647
+ convert.rgb.lab = function(rgb) {
3648
+ const xyz = convert.rgb.xyz(rgb);
3649
+ let x = xyz[0];
3650
+ let y = xyz[1];
3651
+ let z = xyz[2];
3652
+ x /= 95.047;
3653
+ y /= 100;
3654
+ z /= 108.883;
3655
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
3656
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
3657
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
3658
+ const l = 116 * y - 16;
3659
+ const a = 500 * (x - y);
3660
+ const b = 200 * (y - z);
3661
+ return [l, a, b];
3662
+ };
3663
+ convert.hsl.rgb = function(hsl) {
3664
+ const h = hsl[0] / 360;
3665
+ const s = hsl[1] / 100;
3666
+ const l = hsl[2] / 100;
3667
+ let t2;
3668
+ let t3;
3669
+ let val;
3670
+ if (s === 0) {
3671
+ val = l * 255;
3672
+ return [val, val, val];
3673
+ }
3674
+ if (l < 0.5) {
3675
+ t2 = l * (1 + s);
3676
+ } else {
3677
+ t2 = l + s - l * s;
3678
+ }
3679
+ const t1 = 2 * l - t2;
3680
+ const rgb = [0, 0, 0];
3681
+ for (let i = 0; i < 3; i++) {
3682
+ t3 = h + 1 / 3 * -(i - 1);
3683
+ if (t3 < 0) {
3684
+ t3++;
3685
+ }
3686
+ if (t3 > 1) {
3687
+ t3--;
3688
+ }
3689
+ if (6 * t3 < 1) {
3690
+ val = t1 + (t2 - t1) * 6 * t3;
3691
+ } else if (2 * t3 < 1) {
3692
+ val = t2;
3693
+ } else if (3 * t3 < 2) {
3694
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
3695
+ } else {
3696
+ val = t1;
3697
+ }
3698
+ rgb[i] = val * 255;
3699
+ }
3700
+ return rgb;
3701
+ };
3702
+ convert.hsl.hsv = function(hsl) {
3703
+ const h = hsl[0];
3704
+ let s = hsl[1] / 100;
3705
+ let l = hsl[2] / 100;
3706
+ let smin = s;
3707
+ const lmin = Math.max(l, 0.01);
3708
+ l *= 2;
3709
+ s *= l <= 1 ? l : 2 - l;
3710
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
3711
+ const v = (l + s) / 2;
3712
+ const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
3713
+ return [h, sv * 100, v * 100];
3714
+ };
3715
+ convert.hsv.rgb = function(hsv) {
3716
+ const h = hsv[0] / 60;
3717
+ const s = hsv[1] / 100;
3718
+ let v = hsv[2] / 100;
3719
+ const hi = Math.floor(h) % 6;
3720
+ const f = h - Math.floor(h);
3721
+ const p = 255 * v * (1 - s);
3722
+ const q = 255 * v * (1 - s * f);
3723
+ const t = 255 * v * (1 - s * (1 - f));
3724
+ v *= 255;
3725
+ switch (hi) {
3726
+ case 0:
3727
+ return [v, t, p];
3728
+ case 1:
3729
+ return [q, v, p];
3730
+ case 2:
3731
+ return [p, v, t];
3732
+ case 3:
3733
+ return [p, q, v];
3734
+ case 4:
3735
+ return [t, p, v];
3736
+ case 5:
3737
+ return [v, p, q];
3738
+ }
3739
+ };
3740
+ convert.hsv.hsl = function(hsv) {
3741
+ const h = hsv[0];
3742
+ const s = hsv[1] / 100;
3743
+ const v = hsv[2] / 100;
3744
+ const vmin = Math.max(v, 0.01);
3745
+ let sl;
3746
+ let l;
3747
+ l = (2 - s) * v;
3748
+ const lmin = (2 - s) * vmin;
3749
+ sl = s * vmin;
3750
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
3751
+ sl = sl || 0;
3752
+ l /= 2;
3753
+ return [h, sl * 100, l * 100];
3754
+ };
3755
+ convert.hwb.rgb = function(hwb) {
3756
+ const h = hwb[0] / 360;
3757
+ let wh = hwb[1] / 100;
3758
+ let bl = hwb[2] / 100;
3759
+ const ratio = wh + bl;
3760
+ let f;
3761
+ if (ratio > 1) {
3762
+ wh /= ratio;
3763
+ bl /= ratio;
3764
+ }
3765
+ const i = Math.floor(6 * h);
3766
+ const v = 1 - bl;
3767
+ f = 6 * h - i;
3768
+ if ((i & 1) !== 0) {
3769
+ f = 1 - f;
3770
+ }
3771
+ const n = wh + f * (v - wh);
3772
+ let r;
3773
+ let g;
3774
+ let b;
3775
+ switch (i) {
3776
+ default:
3777
+ case 6:
3778
+ case 0:
3779
+ r = v;
3780
+ g = n;
3781
+ b = wh;
3782
+ break;
3783
+ case 1:
3784
+ r = n;
3785
+ g = v;
3786
+ b = wh;
3787
+ break;
3788
+ case 2:
3789
+ r = wh;
3790
+ g = v;
3791
+ b = n;
3792
+ break;
3793
+ case 3:
3794
+ r = wh;
3795
+ g = n;
3796
+ b = v;
3797
+ break;
3798
+ case 4:
3799
+ r = n;
3800
+ g = wh;
3801
+ b = v;
3802
+ break;
3803
+ case 5:
3804
+ r = v;
3805
+ g = wh;
3806
+ b = n;
3807
+ break;
3808
+ }
3809
+ return [r * 255, g * 255, b * 255];
3810
+ };
3811
+ convert.cmyk.rgb = function(cmyk) {
3812
+ const c = cmyk[0] / 100;
3813
+ const m = cmyk[1] / 100;
3814
+ const y = cmyk[2] / 100;
3815
+ const k = cmyk[3] / 100;
3816
+ const r = 1 - Math.min(1, c * (1 - k) + k);
3817
+ const g = 1 - Math.min(1, m * (1 - k) + k);
3818
+ const b = 1 - Math.min(1, y * (1 - k) + k);
3819
+ return [r * 255, g * 255, b * 255];
3820
+ };
3821
+ convert.xyz.rgb = function(xyz) {
3822
+ const x = xyz[0] / 100;
3823
+ const y = xyz[1] / 100;
3824
+ const z = xyz[2] / 100;
3825
+ let r;
3826
+ let g;
3827
+ let b;
3828
+ r = x * 3.2406 + y * -1.5372 + z * -0.4986;
3829
+ g = x * -0.9689 + y * 1.8758 + z * 0.0415;
3830
+ b = x * 0.0557 + y * -0.204 + z * 1.057;
3831
+ r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
3832
+ g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
3833
+ b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
3834
+ r = Math.min(Math.max(0, r), 1);
3835
+ g = Math.min(Math.max(0, g), 1);
3836
+ b = Math.min(Math.max(0, b), 1);
3837
+ return [r * 255, g * 255, b * 255];
3838
+ };
3839
+ convert.xyz.lab = function(xyz) {
3840
+ let x = xyz[0];
3841
+ let y = xyz[1];
3842
+ let z = xyz[2];
3843
+ x /= 95.047;
3844
+ y /= 100;
3845
+ z /= 108.883;
3846
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
3847
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
3848
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
3849
+ const l = 116 * y - 16;
3850
+ const a = 500 * (x - y);
3851
+ const b = 200 * (y - z);
3852
+ return [l, a, b];
3853
+ };
3854
+ convert.lab.xyz = function(lab) {
3855
+ const l = lab[0];
3856
+ const a = lab[1];
3857
+ const b = lab[2];
3858
+ let x;
3859
+ let y;
3860
+ let z;
3861
+ y = (l + 16) / 116;
3862
+ x = a / 500 + y;
3863
+ z = y - b / 200;
3864
+ const y2 = y ** 3;
3865
+ const x2 = x ** 3;
3866
+ const z2 = z ** 3;
3867
+ y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
3868
+ x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
3869
+ z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
3870
+ x *= 95.047;
3871
+ y *= 100;
3872
+ z *= 108.883;
3873
+ return [x, y, z];
3874
+ };
3875
+ convert.lab.lch = function(lab) {
3876
+ const l = lab[0];
3877
+ const a = lab[1];
3878
+ const b = lab[2];
3879
+ let h;
3880
+ const hr = Math.atan2(b, a);
3881
+ h = hr * 360 / 2 / Math.PI;
3882
+ if (h < 0) {
3883
+ h += 360;
3884
+ }
3885
+ const c = Math.sqrt(a * a + b * b);
3886
+ return [l, c, h];
3887
+ };
3888
+ convert.lch.lab = function(lch) {
3889
+ const l = lch[0];
3890
+ const c = lch[1];
3891
+ const h = lch[2];
3892
+ const hr = h / 360 * 2 * Math.PI;
3893
+ const a = c * Math.cos(hr);
3894
+ const b = c * Math.sin(hr);
3895
+ return [l, a, b];
3896
+ };
3897
+ convert.rgb.ansi16 = function(args, saturation = null) {
3898
+ const [r, g, b] = args;
3899
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
3900
+ value = Math.round(value / 50);
3901
+ if (value === 0) {
3902
+ return 30;
3903
+ }
3904
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
3905
+ if (value === 2) {
3906
+ ansi += 60;
3907
+ }
3908
+ return ansi;
3909
+ };
3910
+ convert.hsv.ansi16 = function(args) {
3911
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
3912
+ };
3913
+ convert.rgb.ansi256 = function(args) {
3914
+ const r = args[0];
3915
+ const g = args[1];
3916
+ const b = args[2];
3917
+ if (r === g && g === b) {
3918
+ if (r < 8) {
3919
+ return 16;
3920
+ }
3921
+ if (r > 248) {
3922
+ return 231;
3923
+ }
3924
+ return Math.round((r - 8) / 247 * 24) + 232;
3925
+ }
3926
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
3927
+ return ansi;
3928
+ };
3929
+ convert.ansi16.rgb = function(args) {
3930
+ let color = args % 10;
3931
+ if (color === 0 || color === 7) {
3932
+ if (args > 50) {
3933
+ color += 3.5;
3934
+ }
3935
+ color = color / 10.5 * 255;
3936
+ return [color, color, color];
3937
+ }
3938
+ const mult = (~~(args > 50) + 1) * 0.5;
3939
+ const r = (color & 1) * mult * 255;
3940
+ const g = (color >> 1 & 1) * mult * 255;
3941
+ const b = (color >> 2 & 1) * mult * 255;
3942
+ return [r, g, b];
3943
+ };
3944
+ convert.ansi256.rgb = function(args) {
3945
+ if (args >= 232) {
3946
+ const c = (args - 232) * 10 + 8;
3947
+ return [c, c, c];
3948
+ }
3949
+ args -= 16;
3950
+ let rem;
3951
+ const r = Math.floor(args / 36) / 5 * 255;
3952
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
3953
+ const b = rem % 6 / 5 * 255;
3954
+ return [r, g, b];
3955
+ };
3956
+ convert.rgb.hex = function(args) {
3957
+ const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
3958
+ const string = integer.toString(16).toUpperCase();
3959
+ return "000000".substring(string.length) + string;
3960
+ };
3961
+ convert.hex.rgb = function(args) {
3962
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
3963
+ if (!match) {
3964
+ return [0, 0, 0];
3965
+ }
3966
+ let colorString = match[0];
3967
+ if (match[0].length === 3) {
3968
+ colorString = colorString.split("").map((char) => {
3969
+ return char + char;
3970
+ }).join("");
3971
+ }
3972
+ const integer = parseInt(colorString, 16);
3973
+ const r = integer >> 16 & 255;
3974
+ const g = integer >> 8 & 255;
3975
+ const b = integer & 255;
3976
+ return [r, g, b];
3977
+ };
3978
+ convert.rgb.hcg = function(rgb) {
3979
+ const r = rgb[0] / 255;
3980
+ const g = rgb[1] / 255;
3981
+ const b = rgb[2] / 255;
3982
+ const max = Math.max(Math.max(r, g), b);
3983
+ const min = Math.min(Math.min(r, g), b);
3984
+ const chroma = max - min;
3985
+ let grayscale;
3986
+ let hue;
3987
+ if (chroma < 1) {
3988
+ grayscale = min / (1 - chroma);
3989
+ } else {
3990
+ grayscale = 0;
3991
+ }
3992
+ if (chroma <= 0) {
3993
+ hue = 0;
3994
+ } else if (max === r) {
3995
+ hue = (g - b) / chroma % 6;
3996
+ } else if (max === g) {
3997
+ hue = 2 + (b - r) / chroma;
3998
+ } else {
3999
+ hue = 4 + (r - g) / chroma;
4000
+ }
4001
+ hue /= 6;
4002
+ hue %= 1;
4003
+ return [hue * 360, chroma * 100, grayscale * 100];
4004
+ };
4005
+ convert.hsl.hcg = function(hsl) {
4006
+ const s = hsl[1] / 100;
4007
+ const l = hsl[2] / 100;
4008
+ const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
4009
+ let f = 0;
4010
+ if (c < 1) {
4011
+ f = (l - 0.5 * c) / (1 - c);
4012
+ }
4013
+ return [hsl[0], c * 100, f * 100];
4014
+ };
4015
+ convert.hsv.hcg = function(hsv) {
4016
+ const s = hsv[1] / 100;
4017
+ const v = hsv[2] / 100;
4018
+ const c = s * v;
4019
+ let f = 0;
4020
+ if (c < 1) {
4021
+ f = (v - c) / (1 - c);
4022
+ }
4023
+ return [hsv[0], c * 100, f * 100];
4024
+ };
4025
+ convert.hcg.rgb = function(hcg) {
4026
+ const h = hcg[0] / 360;
4027
+ const c = hcg[1] / 100;
4028
+ const g = hcg[2] / 100;
4029
+ if (c === 0) {
4030
+ return [g * 255, g * 255, g * 255];
4031
+ }
4032
+ const pure = [0, 0, 0];
4033
+ const hi = h % 1 * 6;
4034
+ const v = hi % 1;
4035
+ const w = 1 - v;
4036
+ let mg = 0;
4037
+ switch (Math.floor(hi)) {
4038
+ case 0:
4039
+ pure[0] = 1;
4040
+ pure[1] = v;
4041
+ pure[2] = 0;
4042
+ break;
4043
+ case 1:
4044
+ pure[0] = w;
4045
+ pure[1] = 1;
4046
+ pure[2] = 0;
4047
+ break;
4048
+ case 2:
4049
+ pure[0] = 0;
4050
+ pure[1] = 1;
4051
+ pure[2] = v;
4052
+ break;
4053
+ case 3:
4054
+ pure[0] = 0;
4055
+ pure[1] = w;
4056
+ pure[2] = 1;
4057
+ break;
4058
+ case 4:
4059
+ pure[0] = v;
4060
+ pure[1] = 0;
4061
+ pure[2] = 1;
4062
+ break;
4063
+ default:
4064
+ pure[0] = 1;
4065
+ pure[1] = 0;
4066
+ pure[2] = w;
4067
+ }
4068
+ mg = (1 - c) * g;
4069
+ return [
4070
+ (c * pure[0] + mg) * 255,
4071
+ (c * pure[1] + mg) * 255,
4072
+ (c * pure[2] + mg) * 255
4073
+ ];
4074
+ };
4075
+ convert.hcg.hsv = function(hcg) {
4076
+ const c = hcg[1] / 100;
4077
+ const g = hcg[2] / 100;
4078
+ const v = c + g * (1 - c);
4079
+ let f = 0;
4080
+ if (v > 0) {
4081
+ f = c / v;
4082
+ }
4083
+ return [hcg[0], f * 100, v * 100];
4084
+ };
4085
+ convert.hcg.hsl = function(hcg) {
4086
+ const c = hcg[1] / 100;
4087
+ const g = hcg[2] / 100;
4088
+ const l = g * (1 - c) + 0.5 * c;
4089
+ let s = 0;
4090
+ if (l > 0 && l < 0.5) {
4091
+ s = c / (2 * l);
4092
+ } else if (l >= 0.5 && l < 1) {
4093
+ s = c / (2 * (1 - l));
4094
+ }
4095
+ return [hcg[0], s * 100, l * 100];
4096
+ };
4097
+ convert.hcg.hwb = function(hcg) {
4098
+ const c = hcg[1] / 100;
4099
+ const g = hcg[2] / 100;
4100
+ const v = c + g * (1 - c);
4101
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
4102
+ };
4103
+ convert.hwb.hcg = function(hwb) {
4104
+ const w = hwb[1] / 100;
4105
+ const b = hwb[2] / 100;
4106
+ const v = 1 - b;
4107
+ const c = v - w;
4108
+ let g = 0;
4109
+ if (c < 1) {
4110
+ g = (v - c) / (1 - c);
4111
+ }
4112
+ return [hwb[0], c * 100, g * 100];
4113
+ };
4114
+ convert.apple.rgb = function(apple) {
4115
+ return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
4116
+ };
4117
+ convert.rgb.apple = function(rgb) {
4118
+ return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
4119
+ };
4120
+ convert.gray.rgb = function(args) {
4121
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
4122
+ };
4123
+ convert.gray.hsl = function(args) {
4124
+ return [0, 0, args[0]];
4125
+ };
4126
+ convert.gray.hsv = convert.gray.hsl;
4127
+ convert.gray.hwb = function(gray) {
4128
+ return [0, 100, gray[0]];
4129
+ };
4130
+ convert.gray.cmyk = function(gray) {
4131
+ return [0, 0, 0, gray[0]];
4132
+ };
4133
+ convert.gray.lab = function(gray) {
4134
+ return [gray[0], 0, 0];
4135
+ };
4136
+ convert.gray.hex = function(gray) {
4137
+ const val = Math.round(gray[0] / 100 * 255) & 255;
4138
+ const integer = (val << 16) + (val << 8) + val;
4139
+ const string = integer.toString(16).toUpperCase();
4140
+ return "000000".substring(string.length) + string;
4141
+ };
4142
+ convert.rgb.gray = function(rgb) {
4143
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
4144
+ return [val / 255 * 100];
4145
+ };
4146
+ return conversions;
4147
+ }
4148
+ var route;
4149
+ var hasRequiredRoute;
4150
+ function requireRoute() {
4151
+ if (hasRequiredRoute) return route;
4152
+ hasRequiredRoute = 1;
4153
+ const conversions2 = requireConversions();
4154
+ function buildGraph() {
4155
+ const graph = {};
4156
+ const models = Object.keys(conversions2);
4157
+ for (let len = models.length, i = 0; i < len; i++) {
4158
+ graph[models[i]] = {
4159
+ // http://jsperf.com/1-vs-infinity
4160
+ // micro-opt, but this is simple.
4161
+ distance: -1,
4162
+ parent: null
4163
+ };
4164
+ }
4165
+ return graph;
4166
+ }
4167
+ function deriveBFS(fromModel) {
4168
+ const graph = buildGraph();
4169
+ const queue = [fromModel];
4170
+ graph[fromModel].distance = 0;
4171
+ while (queue.length) {
4172
+ const current = queue.pop();
4173
+ const adjacents = Object.keys(conversions2[current]);
4174
+ for (let len = adjacents.length, i = 0; i < len; i++) {
4175
+ const adjacent = adjacents[i];
4176
+ const node = graph[adjacent];
4177
+ if (node.distance === -1) {
4178
+ node.distance = graph[current].distance + 1;
4179
+ node.parent = current;
4180
+ queue.unshift(adjacent);
4181
+ }
4182
+ }
4183
+ }
4184
+ return graph;
4185
+ }
4186
+ function link(from, to) {
4187
+ return function(args) {
4188
+ return to(from(args));
4189
+ };
4190
+ }
4191
+ function wrapConversion(toModel, graph) {
4192
+ const path2 = [graph[toModel].parent, toModel];
4193
+ let fn = conversions2[graph[toModel].parent][toModel];
4194
+ let cur = graph[toModel].parent;
4195
+ while (graph[cur].parent) {
4196
+ path2.unshift(graph[cur].parent);
4197
+ fn = link(conversions2[graph[cur].parent][cur], fn);
4198
+ cur = graph[cur].parent;
4199
+ }
4200
+ fn.conversion = path2;
4201
+ return fn;
4202
+ }
4203
+ route = function(fromModel) {
4204
+ const graph = deriveBFS(fromModel);
4205
+ const conversion = {};
4206
+ const models = Object.keys(graph);
4207
+ for (let len = models.length, i = 0; i < len; i++) {
4208
+ const toModel = models[i];
4209
+ const node = graph[toModel];
4210
+ if (node.parent === null) {
4211
+ continue;
4212
+ }
4213
+ conversion[toModel] = wrapConversion(toModel, graph);
4214
+ }
4215
+ return conversion;
4216
+ };
4217
+ return route;
4218
+ }
4219
+ var colorConvert;
4220
+ var hasRequiredColorConvert;
4221
+ function requireColorConvert() {
4222
+ if (hasRequiredColorConvert) return colorConvert;
4223
+ hasRequiredColorConvert = 1;
4224
+ const conversions2 = requireConversions();
4225
+ const route2 = requireRoute();
4226
+ const convert = {};
4227
+ const models = Object.keys(conversions2);
4228
+ function wrapRaw(fn) {
4229
+ const wrappedFn = function(...args) {
4230
+ const arg0 = args[0];
4231
+ if (arg0 === void 0 || arg0 === null) {
4232
+ return arg0;
4233
+ }
4234
+ if (arg0.length > 1) {
4235
+ args = arg0;
4236
+ }
4237
+ return fn(args);
4238
+ };
4239
+ if ("conversion" in fn) {
4240
+ wrappedFn.conversion = fn.conversion;
4241
+ }
4242
+ return wrappedFn;
4243
+ }
4244
+ function wrapRounded(fn) {
4245
+ const wrappedFn = function(...args) {
4246
+ const arg0 = args[0];
4247
+ if (arg0 === void 0 || arg0 === null) {
4248
+ return arg0;
4249
+ }
4250
+ if (arg0.length > 1) {
4251
+ args = arg0;
4252
+ }
4253
+ const result = fn(args);
4254
+ if (typeof result === "object") {
4255
+ for (let len = result.length, i = 0; i < len; i++) {
4256
+ result[i] = Math.round(result[i]);
4257
+ }
4258
+ }
4259
+ return result;
4260
+ };
4261
+ if ("conversion" in fn) {
4262
+ wrappedFn.conversion = fn.conversion;
4263
+ }
4264
+ return wrappedFn;
4265
+ }
4266
+ models.forEach((fromModel) => {
4267
+ convert[fromModel] = {};
4268
+ Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
4269
+ Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
4270
+ const routes = route2(fromModel);
4271
+ const routeModels = Object.keys(routes);
4272
+ routeModels.forEach((toModel) => {
4273
+ const fn = routes[toModel];
4274
+ convert[fromModel][toModel] = wrapRounded(fn);
4275
+ convert[fromModel][toModel].raw = wrapRaw(fn);
4276
+ });
4277
+ });
4278
+ colorConvert = convert;
4279
+ return colorConvert;
4280
+ }
4281
+ ansiStyles$1.exports;
4282
+ (function(module2) {
4283
+ const wrapAnsi16 = (fn, offset) => (...args) => {
4284
+ const code = fn(...args);
4285
+ return `\x1B[${code + offset}m`;
4286
+ };
4287
+ const wrapAnsi256 = (fn, offset) => (...args) => {
4288
+ const code = fn(...args);
4289
+ return `\x1B[${38 + offset};5;${code}m`;
4290
+ };
4291
+ const wrapAnsi16m = (fn, offset) => (...args) => {
4292
+ const rgb = fn(...args);
4293
+ return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
4294
+ };
4295
+ const ansi2ansi = (n) => n;
4296
+ const rgb2rgb = (r, g, b) => [r, g, b];
4297
+ const setLazyProperty = (object, property, get) => {
4298
+ Object.defineProperty(object, property, {
4299
+ get: () => {
4300
+ const value = get();
4301
+ Object.defineProperty(object, property, {
4302
+ value,
4303
+ enumerable: true,
4304
+ configurable: true
4305
+ });
4306
+ return value;
4307
+ },
4308
+ enumerable: true,
4309
+ configurable: true
4310
+ });
4311
+ };
4312
+ let colorConvert2;
4313
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
4314
+ if (colorConvert2 === void 0) {
4315
+ colorConvert2 = requireColorConvert();
4316
+ }
4317
+ const offset = isBackground ? 10 : 0;
4318
+ const styles2 = {};
4319
+ for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
4320
+ const name2 = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
4321
+ if (sourceSpace === targetSpace) {
4322
+ styles2[name2] = wrap(identity, offset);
4323
+ } else if (typeof suite === "object") {
4324
+ styles2[name2] = wrap(suite[targetSpace], offset);
4325
+ }
4326
+ }
4327
+ return styles2;
4328
+ };
4329
+ function assembleStyles() {
4330
+ const codes = /* @__PURE__ */ new Map();
4331
+ const styles2 = {
4332
+ modifier: {
4333
+ reset: [0, 0],
4334
+ // 21 isn't widely supported and 22 does the same thing
4335
+ bold: [1, 22],
4336
+ dim: [2, 22],
4337
+ italic: [3, 23],
4338
+ underline: [4, 24],
4339
+ inverse: [7, 27],
4340
+ hidden: [8, 28],
4341
+ strikethrough: [9, 29]
4342
+ },
4343
+ color: {
4344
+ black: [30, 39],
4345
+ red: [31, 39],
4346
+ green: [32, 39],
4347
+ yellow: [33, 39],
4348
+ blue: [34, 39],
4349
+ magenta: [35, 39],
4350
+ cyan: [36, 39],
4351
+ white: [37, 39],
4352
+ // Bright color
4353
+ blackBright: [90, 39],
4354
+ redBright: [91, 39],
4355
+ greenBright: [92, 39],
4356
+ yellowBright: [93, 39],
4357
+ blueBright: [94, 39],
4358
+ magentaBright: [95, 39],
4359
+ cyanBright: [96, 39],
4360
+ whiteBright: [97, 39]
4361
+ },
4362
+ bgColor: {
4363
+ bgBlack: [40, 49],
4364
+ bgRed: [41, 49],
4365
+ bgGreen: [42, 49],
4366
+ bgYellow: [43, 49],
4367
+ bgBlue: [44, 49],
4368
+ bgMagenta: [45, 49],
4369
+ bgCyan: [46, 49],
4370
+ bgWhite: [47, 49],
4371
+ // Bright color
4372
+ bgBlackBright: [100, 49],
4373
+ bgRedBright: [101, 49],
4374
+ bgGreenBright: [102, 49],
4375
+ bgYellowBright: [103, 49],
4376
+ bgBlueBright: [104, 49],
4377
+ bgMagentaBright: [105, 49],
4378
+ bgCyanBright: [106, 49],
4379
+ bgWhiteBright: [107, 49]
4380
+ }
4381
+ };
4382
+ styles2.color.gray = styles2.color.blackBright;
4383
+ styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
4384
+ styles2.color.grey = styles2.color.blackBright;
4385
+ styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
4386
+ for (const [groupName, group] of Object.entries(styles2)) {
4387
+ for (const [styleName, style] of Object.entries(group)) {
4388
+ styles2[styleName] = {
4389
+ open: `\x1B[${style[0]}m`,
4390
+ close: `\x1B[${style[1]}m`
4391
+ };
4392
+ group[styleName] = styles2[styleName];
4393
+ codes.set(style[0], style[1]);
4394
+ }
4395
+ Object.defineProperty(styles2, groupName, {
4396
+ value: group,
4397
+ enumerable: false
4398
+ });
4399
+ }
4400
+ Object.defineProperty(styles2, "codes", {
4401
+ value: codes,
4402
+ enumerable: false
4403
+ });
4404
+ styles2.color.close = "\x1B[39m";
4405
+ styles2.bgColor.close = "\x1B[49m";
4406
+ setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
4407
+ setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
4408
+ setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
4409
+ setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
4410
+ setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
4411
+ setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
4412
+ return styles2;
4413
+ }
4414
+ Object.defineProperty(module2, "exports", {
4415
+ enumerable: true,
4416
+ get: assembleStyles
4417
+ });
4418
+ })(ansiStyles$1);
4419
+ var ansiStylesExports = ansiStyles$1.exports;
4420
+ var browser = {
4421
+ stdout: false,
4422
+ stderr: false
4423
+ };
4424
+ const stringReplaceAll$1 = (string, substring, replacer) => {
4425
+ let index = string.indexOf(substring);
4426
+ if (index === -1) {
4427
+ return string;
4428
+ }
4429
+ const substringLength = substring.length;
4430
+ let endIndex = 0;
4431
+ let returnValue = "";
4432
+ do {
4433
+ returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
4434
+ endIndex = index + substringLength;
4435
+ index = string.indexOf(substring, endIndex);
4436
+ } while (index !== -1);
4437
+ returnValue += string.substr(endIndex);
4438
+ return returnValue;
4439
+ };
4440
+ const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
4441
+ let endIndex = 0;
4442
+ let returnValue = "";
4443
+ do {
4444
+ const gotCR = string[index - 1] === "\r";
4445
+ returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
4446
+ endIndex = index + 1;
4447
+ index = string.indexOf("\n", endIndex);
4448
+ } while (index !== -1);
4449
+ returnValue += string.substr(endIndex);
4450
+ return returnValue;
4451
+ };
4452
+ var util = {
4453
+ stringReplaceAll: stringReplaceAll$1,
4454
+ stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
4455
+ };
4456
+ var templates;
4457
+ var hasRequiredTemplates;
4458
+ function requireTemplates() {
4459
+ if (hasRequiredTemplates) return templates;
4460
+ hasRequiredTemplates = 1;
4461
+ const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
4462
+ const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
4463
+ const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
4464
+ const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
4465
+ const ESCAPES = /* @__PURE__ */ new Map([
4466
+ ["n", "\n"],
4467
+ ["r", "\r"],
4468
+ ["t", " "],
4469
+ ["b", "\b"],
4470
+ ["f", "\f"],
4471
+ ["v", "\v"],
4472
+ ["0", "\0"],
4473
+ ["\\", "\\"],
4474
+ ["e", "\x1B"],
4475
+ ["a", "\x07"]
4476
+ ]);
4477
+ function unescape2(c) {
4478
+ const u = c[0] === "u";
4479
+ const bracket = c[1] === "{";
4480
+ if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
4481
+ return String.fromCharCode(parseInt(c.slice(1), 16));
4482
+ }
4483
+ if (u && bracket) {
4484
+ return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
4485
+ }
4486
+ return ESCAPES.get(c) || c;
4487
+ }
4488
+ function parseArguments(name2, arguments_) {
4489
+ const results = [];
4490
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
4491
+ let matches;
4492
+ for (const chunk of chunks) {
4493
+ const number = Number(chunk);
4494
+ if (!Number.isNaN(number)) {
4495
+ results.push(number);
4496
+ } else if (matches = chunk.match(STRING_REGEX)) {
4497
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape2, character) => escape2 ? unescape2(escape2) : character));
4498
+ } else {
4499
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name2}')`);
4500
+ }
4501
+ }
4502
+ return results;
4503
+ }
4504
+ function parseStyle(style) {
4505
+ STYLE_REGEX.lastIndex = 0;
4506
+ const results = [];
4507
+ let matches;
4508
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
4509
+ const name2 = matches[1];
4510
+ if (matches[2]) {
4511
+ const args = parseArguments(name2, matches[2]);
4512
+ results.push([name2].concat(args));
4513
+ } else {
4514
+ results.push([name2]);
4515
+ }
4516
+ }
4517
+ return results;
4518
+ }
4519
+ function buildStyle(chalk2, styles2) {
4520
+ const enabled = {};
4521
+ for (const layer of styles2) {
4522
+ for (const style of layer.styles) {
4523
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
4524
+ }
4525
+ }
4526
+ let current = chalk2;
4527
+ for (const [styleName, styles3] of Object.entries(enabled)) {
4528
+ if (!Array.isArray(styles3)) {
4529
+ continue;
4530
+ }
4531
+ if (!(styleName in current)) {
4532
+ throw new Error(`Unknown Chalk style: ${styleName}`);
4533
+ }
4534
+ current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
4535
+ }
4536
+ return current;
4537
+ }
4538
+ templates = (chalk2, temporary) => {
4539
+ const styles2 = [];
4540
+ const chunks = [];
4541
+ let chunk = [];
4542
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
4543
+ if (escapeCharacter) {
4544
+ chunk.push(unescape2(escapeCharacter));
4545
+ } else if (style) {
4546
+ const string = chunk.join("");
4547
+ chunk = [];
4548
+ chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
4549
+ styles2.push({ inverse, styles: parseStyle(style) });
4550
+ } else if (close) {
4551
+ if (styles2.length === 0) {
4552
+ throw new Error("Found extraneous } in Chalk template literal");
4553
+ }
4554
+ chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
4555
+ chunk = [];
4556
+ styles2.pop();
4557
+ } else {
4558
+ chunk.push(character);
4559
+ }
4560
+ });
4561
+ chunks.push(chunk.join(""));
4562
+ if (styles2.length > 0) {
4563
+ const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
4564
+ throw new Error(errMessage);
4565
+ }
4566
+ return chunks.join("");
4567
+ };
4568
+ return templates;
4569
+ }
4570
+ const ansiStyles = ansiStylesExports;
4571
+ const { stdout: stdoutColor, stderr: stderrColor } = browser;
4572
+ const {
4573
+ stringReplaceAll,
4574
+ stringEncaseCRLFWithFirstIndex
4575
+ } = util;
4576
+ const { isArray } = Array;
4577
+ const levelMapping = [
4578
+ "ansi",
4579
+ "ansi",
4580
+ "ansi256",
4581
+ "ansi16m"
4582
+ ];
4583
+ const styles = /* @__PURE__ */ Object.create(null);
4584
+ const applyOptions = (object, options = {}) => {
4585
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
4586
+ throw new Error("The `level` option should be an integer from 0 to 3");
4587
+ }
4588
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
4589
+ object.level = options.level === void 0 ? colorLevel : options.level;
4590
+ };
4591
+ class ChalkClass {
4592
+ constructor(options) {
4593
+ return chalkFactory(options);
4594
+ }
4595
+ }
4596
+ const chalkFactory = (options) => {
4597
+ const chalk2 = {};
4598
+ applyOptions(chalk2, options);
4599
+ chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
4600
+ Object.setPrototypeOf(chalk2, Chalk.prototype);
4601
+ Object.setPrototypeOf(chalk2.template, chalk2);
4602
+ chalk2.template.constructor = () => {
4603
+ throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
4604
+ };
4605
+ chalk2.template.Instance = ChalkClass;
4606
+ return chalk2.template;
4607
+ };
4608
+ function Chalk(options) {
4609
+ return chalkFactory(options);
4610
+ }
4611
+ for (const [styleName, style] of Object.entries(ansiStyles)) {
4612
+ styles[styleName] = {
4613
+ get() {
4614
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
4615
+ Object.defineProperty(this, styleName, { value: builder });
4616
+ return builder;
4617
+ }
4618
+ };
4619
+ }
4620
+ styles.visible = {
4621
+ get() {
4622
+ const builder = createBuilder(this, this._styler, true);
4623
+ Object.defineProperty(this, "visible", { value: builder });
4624
+ return builder;
4625
+ }
4626
+ };
4627
+ const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
4628
+ for (const model of usedModels) {
4629
+ styles[model] = {
4630
+ get() {
4631
+ const { level } = this;
4632
+ return function(...arguments_) {
4633
+ const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
4634
+ return createBuilder(this, styler, this._isEmpty);
4635
+ };
4636
+ }
4637
+ };
4638
+ }
4639
+ for (const model of usedModels) {
4640
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
4641
+ styles[bgModel] = {
4642
+ get() {
4643
+ const { level } = this;
4644
+ return function(...arguments_) {
4645
+ const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
4646
+ return createBuilder(this, styler, this._isEmpty);
4647
+ };
4648
+ }
4649
+ };
4650
+ }
4651
+ const proto = Object.defineProperties(() => {
4652
+ }, {
4653
+ ...styles,
4654
+ level: {
4655
+ enumerable: true,
4656
+ get() {
4657
+ return this._generator.level;
4658
+ },
4659
+ set(level) {
4660
+ this._generator.level = level;
4661
+ }
4662
+ }
4663
+ });
4664
+ const createStyler = (open, close, parent) => {
4665
+ let openAll;
4666
+ let closeAll;
4667
+ if (parent === void 0) {
4668
+ openAll = open;
4669
+ closeAll = close;
4670
+ } else {
4671
+ openAll = parent.openAll + open;
4672
+ closeAll = close + parent.closeAll;
4673
+ }
4674
+ return {
4675
+ open,
4676
+ close,
4677
+ openAll,
4678
+ closeAll,
4679
+ parent
4680
+ };
4681
+ };
4682
+ const createBuilder = (self2, _styler, _isEmpty) => {
4683
+ const builder = (...arguments_) => {
4684
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
4685
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
4686
+ }
4687
+ return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
4688
+ };
4689
+ Object.setPrototypeOf(builder, proto);
4690
+ builder._generator = self2;
4691
+ builder._styler = _styler;
4692
+ builder._isEmpty = _isEmpty;
4693
+ return builder;
4694
+ };
4695
+ const applyStyle = (self2, string) => {
4696
+ if (self2.level <= 0 || !string) {
4697
+ return self2._isEmpty ? "" : string;
4698
+ }
4699
+ let styler = self2._styler;
4700
+ if (styler === void 0) {
4701
+ return string;
4702
+ }
4703
+ const { openAll, closeAll } = styler;
4704
+ if (string.indexOf("\x1B") !== -1) {
4705
+ while (styler !== void 0) {
4706
+ string = stringReplaceAll(string, styler.close, styler.open);
4707
+ styler = styler.parent;
4708
+ }
4709
+ }
4710
+ const lfIndex = string.indexOf("\n");
4711
+ if (lfIndex !== -1) {
4712
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
4713
+ }
4714
+ return openAll + string + closeAll;
4715
+ };
4716
+ let template;
4717
+ const chalkTag = (chalk2, ...strings) => {
4718
+ const [firstString] = strings;
4719
+ if (!isArray(firstString) || !isArray(firstString.raw)) {
4720
+ return strings.join(" ");
4721
+ }
4722
+ const arguments_ = strings.slice(1);
4723
+ const parts = [firstString.raw[0]];
4724
+ for (let i = 1; i < firstString.length; i++) {
4725
+ parts.push(
4726
+ String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
4727
+ String(firstString.raw[i])
4728
+ );
4729
+ }
4730
+ if (template === void 0) {
4731
+ template = requireTemplates();
4732
+ }
4733
+ return template(chalk2, parts.join(""));
4734
+ };
4735
+ Object.defineProperties(Chalk.prototype, styles);
4736
+ const chalk = Chalk();
4737
+ chalk.supportsColor = stdoutColor;
4738
+ chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
4739
+ chalk.stderr.supportsColor = stderrColor;
4740
+ const { accessSync, constants, readFileSync } = fs$1;
4741
+ const envOptions = {};
4742
+ function SetupConfig(envOptions2, logger) {
4743
+ const envfile = process.env.STSENVFILE === void 0 ? "/.env" : process.env.STSENVFILE;
4744
+ config_1({ path: envfile });
4745
+ const defconfig = {
4746
+ // Node runtime environment
4747
+ isProduction: process.env.NODE_ENV === void 0 ? false : process.env.NODE_ENV === "production" ? true : false,
4748
+ isTest: process.env.NODE_ENV === void 0 ? false : process.env.NODE_ENV === "test" ? true : false,
4749
+ dbuser: process.env.DB_USER === void 0 ? "postgres" : process.env.DB_USER,
4750
+ dbpassword: process.env.DB_PASSWORD === void 0 ? "postgres" : process.env.DB_PASSWORD,
4751
+ dbpasswordfile: process.env.DB_PASSWORD_FILE,
4752
+ dbhost: process.env.DB_HOST === void 0 ? "localhost:5432" : process.env.DB_HOST,
4753
+ database: process.env.DB_DATABASE === void 0 ? "stsrestmsdb01" : process.env.DB_DATABASE,
4754
+ databaseUrl: process.env.DATABASE_URL,
4755
+ connectionString: "",
4756
+ defaultDatabaseConnectionString: "",
4757
+ STSServerType: process.env.STS_SERVER_TYPE === void 0 ? "EXPRESS_TLS" : process.env.STS_SERVER_TYPE,
4758
+ logToFile: process.env.LOG_TO_FILE === void 0 ? false : process.env.LOG_TO_FILE === "true" ? true : false,
4759
+ logFilePath: process.env.LOG_FILE_PATH === void 0 ? "/var/lib/sts" : process.env.LOG_FILE_PATH,
4760
+ logFileFormat: process.env.LOG_FILE_FORMAT === void 0 ? "csv" : process.env.LOG_FILE_FORMAT,
4761
+ poolSize: process.env.POOL_SIZE === void 0 ? 500 : parseInt(process.env.POOL_SIZE),
4762
+ useCPUs: process.env.MAX_CPU === void 0 ? -1 : parseFloat(process.env.MAX_CPU),
4763
+ respawnOnFail: process.env.RESPAWN === void 0 ? true : process.env.RESPAWN === "true" ? true : false,
4764
+ defaultDatabaseEntries: process.env.DEFAULT_DB_ENTRIES === void 0 ? 1e4 : parseInt(process.env.DEFAULT_DB_ENTRIES),
4765
+ useRedisDatabaseCache: process.env.USE_REDIS_DATABASE_CACHE === void 0 ? false : process.env.USE_REDIS_DATABASE_CACHE === "true" ? true : false,
4766
+ useSocketIoRedisAdaptor: process.env.USE_SOCKET_IO_REDIS_ADAPTOR === void 0 ? false : process.env.USE_SOCKET_IO_REDIS_ADAPTOR === "true" ? true : false,
4767
+ socketIoRedisAdaptorUrl: process.env.SOCKET_IO_REDIS_ADAPTOR_URL === void 0 ? "redis://localhost:6379" : process.env.SOCKET_IO_REDIS_ADAPTOR_URL,
4768
+ useRedisInstrumentationTransport: process.env.USE_REDIS_INSTRUMENTATION_TRANSPORT === void 0 ? false : process.env.USE_REDIS_INSTRUMENTATION_TRANSPORT === "true" ? true : false,
4769
+ redisInstrumentationTransportUrl: process.env.REDIS_INSTRUMENTATION_TRANSPORT_URL === void 0 ? "redis://localhost:6379" : process.env.REDIS_INSTRUMENTATION_TRANSPORT_URL,
4770
+ redisDatabaseCacheEndFlush: process.env.REDIS_DATABASE_CACHE_END_FLUSH === void 0 ? false : process.env.REDIS_DATABASE_CACHE_END_FLUSH === "true" ? true : false,
4771
+ redisDatabaseCacheUrl: process.env.REDIS_DATABASE_CACHE_URL === void 0 ? "redis://localhost:6379" : process.env.REDIS_DATABASE_CACHE_URL,
4772
+ defaultDatabaseMinExtraDataSize: process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE === void 0 ? 0 : parseInt(process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE),
4773
+ defaultDatabaseMaxExtraDataSize: process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE === void 0 ? 2e3 : parseInt(process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE),
4774
+ rest01endpoint: process.env.REST01_ENDPOINT === void 0 ? "https://localhost" : process.env.REST01_ENDPOINT,
4775
+ rest01hostport: process.env.REST01_HOST_PORT === void 0 ? "3003" : process.env.REST01_HOST_PORT,
4776
+ rest01port: process.env.REST01_PORT === void 0 ? "3003" : process.env.REST01_PORT,
4777
+ rest01apiroot: process.env.REST01_APIROOT === void 0 ? "/stsrest01/v1" : process.env.REST01_APIROOT,
4778
+ rest01prometheussupport: process.env.REST01_PROM_SUPPORT === void 0 ? true : process.env.REST01_PROM_SUPPORT === "true" ? true : false,
4779
+ rest01prometheusclusterport: process.env.REST01_PROM_CLUSTER_PORT === void 0 ? "3013" : process.env.REST01_PROM_CLUSTER_PORT,
4780
+ rest01servicename: process.env.REST01_SERVICE_NAME === void 0 ? "STSRest01" : process.env.REST01_SERVICE_NAME,
4781
+ rest01serviceversion: process.env.REST01_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.REST01_SERVICE_VERSION,
4782
+ stsfhirendpoint: process.env.STSFHIR_ENDPOINT === void 0 ? "https://localhost" : process.env.STSFHIR_ENDPOINT,
4783
+ stsfhirhostport: process.env.STSFHIR_HOST_PORT === void 0 ? "3005" : process.env.STSFHIR_HOST_PORT,
4784
+ stsfhirport: process.env.STSFHIR_PORT === void 0 ? "3005" : process.env.STSFHIR_PORT,
4785
+ stsfhirapiroot: process.env.STSFHIR_APIROOT === void 0 ? "/stsfhir/r5" : process.env.STSFHIR_APIROOT,
4786
+ stsfhirprometheussupport: process.env.STSFHIR_PROM_SUPPORT === void 0 ? true : process.env.STSFHIR_PROM_SUPPORT === "true" ? true : false,
4787
+ stsfhirprometheusclusterport: process.env.STSFHIR_PROM_CLUSTER_PORT === void 0 ? "3015" : process.env.STSFHIR_PROM_CLUSTER_PORT,
4788
+ stsfhirservicename: process.env.STSFHIR_SERVICE_NAME === void 0 ? "STSFHIR" : process.env.STSFHIR_SERVICE_NAME,
4789
+ stsfhirserviceversion: process.env.STSFHIR_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.STSFHIR_SERVICE_VERSION,
4790
+ imendpoint: process.env.IM_ENDPOINT === void 0 ? "https://localhost" : process.env.IM_ENDPOINT,
4791
+ imhostport: process.env.IM_HOST_PORT === void 0 ? "3001" : process.env.IM_HOST_PORT,
4792
+ import: process.env.IM_PORT === void 0 ? "3001" : process.env.IM_PORT,
4793
+ imapiroot: process.env.IM_APIROOT === void 0 ? "/stsinstrumentmanager/v1" : process.env.IM_APIROOT,
4794
+ imprometheussupport: process.env.IM_PROM_SUPPORT === void 0 ? true : process.env.IM_PROM_SUPPORT === "true" ? true : false,
4795
+ imprometheusclusterport: process.env.IM_PROM_CLUSTER_PORT === void 0 ? "3011" : process.env.IM_PROM_CLUSTER_PORT,
4796
+ imservicename: process.env.IM_SERVICE_NAME === void 0 ? "STSInstrumentManager" : process.env.IM_SERVICE_NAME,
4797
+ imserviceversion: process.env.IM_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.IM_SERVICE_VERSION,
4798
+ imRedisKeepAliveProcessorUrl: process.env.IM_REDIS_KEEP_ALIVE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.IM_REDIS_KEEP_ALIVE_PROCESSOR_URL,
4799
+ imRedisMessageProcessorUrl: process.env.IM_REDIS_MESSAGE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.IM_REDIS_MESSAGE_PROCESSOR_URL,
4800
+ asendpoint: process.env.AS_ENDPOINT === void 0 ? "https://localhost" : process.env.AS_ENDPOINT,
4801
+ ashostport: process.env.AS_HOST_PORT === void 0 ? "3002" : process.env.AS_HOST_PORT,
4802
+ asport: process.env.AS_PORT === void 0 ? "3002" : process.env.AS_PORT,
4803
+ asapiroot: process.env.AS_API_ROOT === void 0 ? "/stsauth/v1.0" : process.env.AS_API_ROOT,
4804
+ asoauthapiroot: process.env.AS_OAUTH_API_ROOT === void 0 ? "/oauth2/v2.0" : process.env.AS_OAUTH_API_ROOT,
4805
+ asadminapiroot: process.env.AS_ADMIN_API_ROOT === void 0 ? "/admin/v1.0" : process.env.AS_ADMIN_API_ROOT,
4806
+ asprometheussupport: process.env.AS_PROM_SUPPORT === void 0 ? true : process.env.AS_PROM_SUPPORT === "true" ? true : false,
4807
+ asprometheusclusterport: process.env.AS_PROM_CLUSTER_PORT === void 0 ? "3012" : process.env.AS_PROM_CLUSTER_PORT,
4808
+ asservicename: process.env.AS_SERVICE_NAME === void 0 ? "STSAuth" : process.env.AS_SERVICE_NAME,
4809
+ asserviceversion: process.env.AS_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.AS_SERVICE_VERSION,
4810
+ asjwksjsonpath: process.env.AS_JWKS_JSON_PATH === void 0 ? "/.well-known/jwks.json" : process.env.AS_JWKS_JSON_PATH,
4811
+ asjwkskeyrotationtime: process.env.AS_JWKS_KEY_ROTATION_TIME === void 0 ? 86400 : parseInt(process.env.AS_JWKS_KEY_ROTATION_TIME),
4812
+ asjwkskeypurgetimeoffset: process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET === void 0 ? 300 : parseInt(process.env.AS_JWKS_KEY_PURGE_TIME_OFFSET),
4813
+ asjwkskeycount: process.env.AS_JWKS_KEY_COUNT === void 0 ? 4 : parseInt(process.env.AS_JWKS_KEY_COUNT),
4814
+ asaccesstokenexpire: process.env.AS_ACCESS_TOKEN_EXPIRE === void 0 ? 43200 : parseInt(process.env.AS_ACCESS_TOKEN_EXPIRE),
4815
+ authorizeendpoint: process.env.AUTHORIZE_ENDPOINT === void 0 ? "https://localhost" : process.env.AUTHORIZE_ENDPOINT,
4816
+ authorizeport: process.env.AUTHORIZE_PORT === void 0 ? "3010" : process.env.AUTHORIZE_PORT,
4817
+ authorizeapiroot: process.env.AUTHORIZE_API_ROOT === void 0 ? "/stsa" : process.env.AUTHORIZE_API_ROOT,
4818
+ authorizeapi: process.env.AUTHORIZE_API === void 0 ? "/authorize" : process.env.AUTHORIZE_API,
4819
+ brokerendpoint: process.env.BROKER_ENDPOINT === void 0 ? "https://localhost" : process.env.BROKER_ENDPOINT,
4820
+ brokerhostport: process.env.BROKER_HOST_PORT === void 0 ? "3006" : process.env.BROKER_HOST_PORT,
4821
+ brokerport: process.env.BROKER_PORT === void 0 ? "3006" : process.env.BROKER_PORT,
4822
+ brokerapiroot: process.env.BROKER_APIROOT === void 0 ? "/stsbroker/v1.0" : process.env.BROKER_APIROOT,
4823
+ brokerprometheussupport: process.env.BROKER_PROM_SUPPORT === void 0 ? true : process.env.BROKER_PROM_SUPPORT === "true" ? true : false,
4824
+ brokerprometheusclusterport: process.env.BROKER_PROM_CLUSTER_PORT === void 0 ? "3016" : process.env.BROKER_PROM_CLUSTER_PORT,
4825
+ brokerservicename: process.env.BROKER_SERVICE_NAME === void 0 ? "STSBroker" : process.env.BROKER_SERVICE_NAME,
4826
+ brokerserviceversion: process.env.BROKER_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.BROKER_SERVICE_VERSION,
4827
+ trnendpoint: process.env.TRN_ENDPOINT === void 0 ? "https://localhost" : process.env.TRN_ENDPOINT,
4828
+ trnhostport: process.env.TRN_HOST_PORT === void 0 ? "3007" : process.env.TRN_HOST_PORT,
4829
+ trnport: process.env.TRN_PORT === void 0 ? "3007" : process.env.TRN_PORT,
4830
+ trnapiroot: process.env.TRN_APIROOT === void 0 ? "/ststrn/v1.0" : process.env.TRN_APIROOT,
4831
+ trnprometheussupport: process.env.TRN_PROM_SUPPORT === void 0 ? true : process.env.TRN_PROM_SUPPORT === "true" ? true : false,
4832
+ trnprometheusclusterport: process.env.TRN_PROM_CLUSTER_PORT === void 0 ? "3017" : process.env.TRN_PROM_CLUSTER_PORT,
4833
+ trnservicename: process.env.TRN_SERVICE_NAME === void 0 ? "STSTestRunnerNode" : process.env.TRN_SERVICE_NAME,
4834
+ trnserviceversion: process.env.TRN_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.TRN_SERVICE_VERSION,
4835
+ trnautostartdelay: process.env.TRN_AUTO_START_DELAY === void 0 ? 0 : parseInt(process.env.TRN_AUTO_START_DELAY),
4836
+ trnautostartconfig: process.env.TRN_AUTO_START_CONFIG === void 0 ? "" : process.env.TRN_AUTO_START_CONFIG,
4837
+ trnRedisMessageProcessorUrl: process.env.TRN_REDIS_MESSAGE_PROCESSOR_URL === void 0 ? "redis://localhost:6379" : process.env.TRN_REDIS_MESSAGE_PROCESSOR_URL,
4838
+ lambdaendpoint: process.env.LAMBDA_ENDPOINT === void 0 ? "https://localhost" : process.env.LAMBDA_ENDPOINT,
4839
+ lambdahostport: process.env.LAMBDA_HOST_PORT === void 0 ? "3009" : process.env.LAMBDA_HOST_PORT,
4840
+ lambdaport: process.env.LAMBDA_PORT === void 0 ? "3009" : process.env.LAMBDA_PORT,
4841
+ lambdaapiroot: process.env.LAMBDA_APIROOT === void 0 ? "/stslambda/v1.0" : process.env.LAMBDA_APIROOT,
4842
+ lambdaprometheussupport: process.env.LAMBDA_PROM_SUPPORT === void 0 ? true : process.env.LAMBDA_PROM_SUPPORT === "true" ? true : false,
4843
+ lambdaprometheusclusterport: process.env.LAMBDA_PROM_CLUSTER_PORT === void 0 ? "3019" : process.env.LAMBDA_PROM_CLUSTER_PORT,
4844
+ lambdaservicename: process.env.LAMBDA_SERVICE_NAME === void 0 ? "STSLambda" : process.env.LAMBDA_SERVICE_NAME,
4845
+ lambdaserviceversion: process.env.LAMBDA_SERVICE_VERSION === void 0 ? "1.0.0" : process.env.LAMBDA_SERVICE_VERSION,
4846
+ publishinterval: process.env.PUBLISH_INTERVAL === void 0 ? 1e3 : parseInt(process.env.PUBLISH_INTERVAL),
4847
+ publishtimeout: process.env.PUBLISH_TIMEOUT === void 0 ? 750 : parseInt(process.env.PUBLISH_TIMEOUT),
4848
+ transport: process.env.TRANSPORT === void 0 ? "RESTAPI" : process.env.TRANSPORT,
4849
+ useSecureCookies: process.env.USE_SECURE_COOKIES === void 0 ? false : process.env.USE_SECURE_COOKIES === "true" ? true : false,
4850
+ keepAlive: process.env.KEEP_ALIVE === void 0 ? true : process.env.KEEP_ALIVE === "true" ? true : false,
4851
+ maxSockets: process.env.MAX_SOCKETS === void 0 ? 10 : parseInt(process.env.MAX_SOCKETS),
4852
+ maxTotalSockets: process.env.MAX_TOTAL_SOCKETS === void 0 ? 20 : parseInt(process.env.MAX_TOTAL_SOCKETS),
4853
+ maxFreeSockets: process.env.MAX_FREE_SOCKETS === void 0 ? 256 : parseInt(process.env.MAX_FREE_SOCKETS),
4854
+ timeout: process.env.TIMEOUT === void 0 ? 1e4 : parseInt(process.env.TIMEOUT),
4855
+ maxPayloadSize: process.env.MAX_PAYLOAD_SIZE === void 0 ? "50mb" : process.env.MAX_PAYLOAD_SIZE,
4856
+ instrumentationObservationInterval: process.env.INSTRUMENTATION_OBSERVATION_INTERVAL === void 0 ? 1e3 : parseInt(process.env.INSTRUMENTATION_OBSERVATION_INTERVAL),
4857
+ instrumentationTimeWindow: process.env.INSTRUMENTATION_TIME_WINDOW === void 0 ? 600 : parseInt(process.env.INSTRUMENTATION_TIME_WINDOW),
4858
+ authJWTAccessTokenTimeout: process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT === void 0 ? 600 : parseInt(process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT),
4859
+ authJWTRefreshTokenTimeout: process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT === void 0 ? 3600 * 24 : parseInt(process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT),
4860
+ authCookieTimeout: process.env.AUTH_COOKIE_TIMEOUT === void 0 ? 3600 * 24 : parseInt(process.env.AUTH_COOKIE_TIMEOUT),
4861
+ masterProcessExitTime: process.env.MASTER_PROCESS_EXIT_TIME === void 0 ? 500 : parseInt(process.env.MASTER_PROCESS_EXIT_TIME),
4862
+ childProcessExitTime: process.env.CHILD_PROCESS_EXIT_TIME === void 0 ? 500 : parseInt(process.env.CHILD_PROCESS_EXIT_TIME),
4863
+ systemInformationInterval: process.env.SYSTEM_INFORMATION_INTERVAL === void 0 ? 1e3 : parseInt(process.env.SYSTEM_INFORMATION_INTERVAL),
4864
+ ignoresocketio: process.env.IGNORE_SOCKETIO === void 0 ? true : process.env.IGNORE_SOCKETIO === "true" ? true : false,
4865
+ httpsserverkeypath: process.env.HTTPS_SERVER_KEY_PATH === void 0 ? "/var/lib/sts/stsglobalresources/keys/server.key" : process.env.HTTPS_SERVER_KEY_PATH,
4866
+ httpsservercertpath: process.env.HTTPS_SERVER_CERT_PATH === void 0 ? "/var/lib/sts/stsglobalresources/keys/server.cert" : process.env.HTTPS_SERVER_CERT_PATH,
4867
+ tsjwkskeys: process.env.TS_JWKS_KEYS === void 0 ? 3 : parseInt(process.env.TS_JWKS_KEYS),
4868
+ jwksAuthConfigCache: process.env.JWKS_AUTH_CONFIG_CACHE === void 0 ? true : process.env.JWKS_AUTH_CONFIG_CACHE === "true" ? true : false,
4869
+ jwksAuthConfigCacheMaxEntries: process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES === void 0 ? 5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_ENTRIES),
4870
+ jwksAuthConfigCacheMaxAge: process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE === void 0 ? 6e5 : parseInt(process.env.JWKS_AUTH_CONFIG_CACHE_MAX_AGE),
4871
+ jwksAuthConfigRateLimit: process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === void 0 ? true : process.env.JWKS_AUTH_CONFIG_RATE_LIMIT === "true" ? true : false,
4872
+ jwksAuthConfigRateLimitRequestsPerMinute: process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE === void 0 ? 10 : parseInt(process.env.JWKS_AUTH_CONFIG_RATE_LIMIT_REQUESTS_PER_MINUTE),
4873
+ jwksAuthConfigTimeout: process.env.JWKS_AUTH_CONFIG_TIMEOUT === void 0 ? 3e4 : parseInt(process.env.JWKS_AUTH_CONFIG_TIMEOUT),
4874
+ influxDB_APIToken: process.env.INFLUXDB_API_TOKEN === void 0 ? "password" : process.env.INFLUXDB_API_TOKEN,
4875
+ influxDB_APITokenFile: process.env.INFLUXDB_API_TOKEN_FILE,
4876
+ influxDB_Url: process.env.INFLUXDB_URL === void 0 ? "http://localhost:8086" : process.env.INFLUXDB_URL,
4877
+ influxDB_Org: process.env.INFLUXDB_ORG === void 0 ? "my-org" : process.env.INFLUXDB_ORG,
4878
+ influxDB_Bucket: process.env.INFLUXDB_BUCKET === void 0 ? "TestBucket01" : process.env.INFLUXDB_BUCKET,
4879
+ influxDB_keepAlive: process.env.INFLUXDB_KEEP_ALIVE === void 0 ? true : process.env.INFLUXDB_KEEP_ALIVE === "true" ? true : false,
4880
+ influxDB_maxSockets: process.env.INFLUXDB_MAX_SOCKETS === void 0 ? 10 : parseInt(process.env.INFLUXDB_MAX_SOCKETS),
4881
+ influxDB_maxTotalSockets: process.env.INFLUXDB_MAX_TOTAL_SOCKETS === void 0 ? 20 : parseInt(process.env.INFLUXDB_MAX_TOTAL_SOCKETS),
4882
+ influxDB_maxFreeSockets: process.env.INFLUXDB_MAX_FREE_SOCKETS === void 0 ? 256 : parseInt(process.env.INFLUXDB_MAX_FREE_SOCKETS),
4883
+ influxDB_timeout: process.env.INFLUXDB_TIMEOUT === void 0 ? 1e4 : parseInt(process.env.INFLUXDB_TIMEOUT),
4884
+ influxDB_rejectUnauthorized: process.env.INFLUXDB_REJECT_UNAUTHORIZED === void 0 ? true : process.env.INFLUXDB_REJECT_UNAUTHORIZED === "true" ? true : false,
4885
+ influxDB_writeDataPointFlushTimeout: process.env.INFLUXDB_WRITE_DATA_POINT_FLUSH_TIMEOUT === void 0 ? 1e3 : parseInt(process.env.INFLUXDB_WRITE_DATA_POINT_FLUSH_TIMEOUT),
4886
+ kafka_clientId: process.env.KAFKA_CLIENT_ID === void 0 ? "myclient" : process.env.KAFKA_CLIENT_ID,
4887
+ kafka_brokers: process.env.KAFKA_BROKERS === void 0 ? "localhost:9092" : process.env.KAFKA_BROKERS,
4888
+ kafka_admin_timeout: process.env.KAFKA_ADMIN_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_ADMIN_TIMEOUT),
4889
+ kafka_connection_timeout: process.env.KAFKA_CONNECTION_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_CONNECTION_TIMEOUT),
4890
+ kafka_request_timeout: process.env.KAFKA_REQUEST_TIMEOUT === void 0 ? 5e3 : parseInt(process.env.KAFKA_REQUEST_TIMEOUT),
4891
+ kafka_log_level: process.env.KAFKA_LOG_LEVEL === void 0 ? "nothing" : process.env.KAFKA_LOG_LEVEL,
4892
+ kafka_keep_alive: process.env.KAFKA_KEEP_ALIVE === void 0 ? 3e4 : parseInt(process.env.KAFKA_KEEP_ALIVE),
4893
+ kafka_use_ssl: process.env.KAFKA_USE_SSL === void 0 ? false : process.env.KAFKA_USE_SSL === "true" ? true : false,
4894
+ kafka_ssl_rejectUnauthorized: process.env.KAFKA_SSL_REJECT_UNAUTHORIZED === void 0 ? true : process.env.KAFKA_SSL_REJECT_UNAUTHORIZED === "true" ? true : false,
4895
+ kafka_ssl_cafile: process.env.KAFKA_SSL_CAFILE === void 0 ? "/my/custom/ca.crt" : process.env.KAFKA_SSL_CAFILE,
4896
+ kafka_ssl_keyfile: process.env.KAFKA_SSL_KEYFILE === void 0 ? "/my/custom/client-key.pem" : process.env.KAFKA_SSL_KEYFILE,
4897
+ kafka_ssl_certfile: process.env.KAFKA_SSL_CERTFILE === void 0 ? "/my/custom/client-cert.pem" : process.env.KAFKA_SSL_CERTFILE,
4898
+ kafka_consume_from_beginning: process.env.KAFKA_CONSUME_FROM_BEGINNING === void 0 ? true : process.env.KAFKA_CONSUME_FROM_BEGINNING === "true" ? true : false,
4899
+ observabilityPublishMode: process.env.OBSERVABILITY_PUBLISH_MODE === void 0 ? "PROXY" : process.env.OBSERVABILITY_PUBLISH_MODE,
4900
+ stsUiTermObservabilityConsumptionMode: process.env.STSUITERM_OBSERVABILITY_CONSUMPTION_MODE === void 0 ? "PROXY" : process.env.STSUITERM_OBSERVABILITY_CONSUMPTION_MODE
4901
+ };
4902
+ const ReadFile = (passwordFile) => {
4903
+ try {
4904
+ accessSync(passwordFile, constants.R_OK);
4905
+ const data = readFileSync(passwordFile, "utf8");
4906
+ if (logger) ;
4907
+ return data;
4908
+ } catch (err) {
4909
+ return "";
4910
+ }
4911
+ };
4912
+ const fileconfig = [
4913
+ { fileprop: "dbpasswordfile", prop: "dbpassword" },
4914
+ // JWKS secret file processing
4915
+ { fileprop: "tsjwksstorepathfile", prop: "tsjwksstorepath" },
4916
+ // InfluxDB file processing
4917
+ { fileprop: "influxDB_APITokenFile", prop: "influxDB_APIToken" }
4918
+ ];
4919
+ fileconfig.forEach((v) => {
4920
+ if (defconfig[v.fileprop] !== void 0) {
4921
+ defconfig[v.prop] = ReadFile(defconfig[v.fileprop]);
4922
+ }
4923
+ });
4924
+ for (const [key, val] of Object.entries(defconfig)) {
4925
+ envOptions2[key] = val;
4926
+ }
4927
+ }
4928
+ function $SetupOptions(envOptions2) {
4929
+ SetupConfig(envOptions2);
4930
+ const options = envOptions2;
4931
+ if (options.dbhost) {
4932
+ const hosts = options.dbhost.split(",");
4933
+ envOptions2.connectionString = hosts.map((host) => {
4934
+ return `postgresql://${options.dbuser}:${options.dbpassword}@${host}/${options.database}`;
4935
+ }).join(",");
4936
+ envOptions2.defaultDatabaseConnectionString = hosts.map((host) => {
4937
+ return `postgresql://${options.dbuser}:${options.dbpassword}@${host}/postgres`;
4938
+ }).join(",");
4939
+ }
4940
+ }
4941
+ const envOptionsHandler = {
4942
+ get(target, prop, receiver) {
4943
+ if (Object.keys(target).length === 0) {
4944
+ $SetupOptions(target);
4945
+ }
4946
+ return Reflect.get(target, prop, receiver);
4947
+ }
4948
+ };
4949
+ const goptions = new Proxy(envOptions, envOptionsHandler);
4950
+ class AgentManager {
4951
+ constructor(agentManagerOptions) {
4952
+ __privateAdd2(this, _options);
4953
+ __privateAdd2(this, _httpAgent, null);
4954
+ __privateAdd2(this, _httpsAgent, null);
4955
+ __privateAdd2(this, _agentResetInterval, null);
4956
+ __privateAdd2(this, _requestCount, 0);
4957
+ __privateAdd2(this, _SetupResetInterval, () => {
4958
+ if (__privateGet2(this, _options).agentResetInterval && __privateGet2(this, _options).agentResetInterval > 0) {
4959
+ __privateSet2(this, _agentResetInterval, setTimeout(() => {
4960
+ this.ResetAgent();
4961
+ __privateGet2(this, _SetupResetInterval).call(this);
4962
+ }, __privateGet2(this, _options).agentResetInterval).unref());
4963
+ }
4964
+ });
4965
+ __privateAdd2(this, _GetAgentOptions, (https2) => {
4966
+ let options;
4967
+ if (__privateGet2(this, _options).agentOptions) {
4968
+ options = {
4969
+ keepAlive: __privateGet2(this, _options).agentOptions.keepAlive,
4970
+ maxSockets: __privateGet2(this, _options).agentOptions.maxSockets,
4971
+ maxTotalSockets: __privateGet2(this, _options).agentOptions.maxTotalSockets,
4972
+ maxFreeSockets: __privateGet2(this, _options).agentOptions.maxFreeSockets,
4973
+ timeout: __privateGet2(this, _options).agentOptions.timeout
4974
+ //@@ config
4975
+ };
4976
+ if (https2 === true) {
4977
+ options.rejectUnauthorized = __privateGet2(this, _options).agentOptions.rejectUnauthorized;
4978
+ }
4979
+ } else {
4980
+ options = {
4981
+ keepAlive: process.env.NODE_ENV === "test" ? false : goptions.keepAlive,
4982
+ maxSockets: goptions.maxSockets,
4983
+ maxTotalSockets: goptions.maxTotalSockets,
4984
+ maxFreeSockets: goptions.maxFreeSockets,
4985
+ timeout: 3e4
4986
+ //@@ config
4987
+ };
4988
+ if (https2 === true) {
4989
+ options.rejectUnauthorized = goptions.isProduction;
4990
+ }
4991
+ }
4992
+ return options;
4993
+ });
4994
+ __privateSet2(this, _options, agentManagerOptions);
4995
+ if (__privateGet2(this, _options).agentResetInterval) {
4996
+ __privateGet2(this, _SetupResetInterval).call(this);
4997
+ }
4998
+ }
4999
+ get agentResetInterval() {
5000
+ return __privateGet2(this, _options).agentResetInterval;
5001
+ }
5002
+ set agentResetInterval(val) {
5003
+ if (__privateGet2(this, _agentResetInterval)) {
5004
+ clearTimeout(__privateGet2(this, _agentResetInterval));
5005
+ }
5006
+ __privateGet2(this, _options).agentResetInterval = val;
5007
+ __privateGet2(this, _SetupResetInterval).call(this);
5008
+ }
5009
+ get agentResetCount() {
5010
+ return __privateGet2(this, _options).agentResetCount;
5011
+ }
5012
+ set agentResetCount(val) {
5013
+ __privateGet2(this, _options).agentResetCount = val;
5014
+ }
5015
+ IncRequestCount() {
5016
+ __privateWrapper2(this, _requestCount)._++;
5017
+ if (__privateGet2(this, _options).agentResetCount) {
5018
+ if (__privateGet2(this, _requestCount) % __privateGet2(this, _options).agentResetCount === 0) {
5019
+ this.ResetAgent();
5020
+ }
5021
+ }
5022
+ }
5023
+ IsHttps(protocol) {
5024
+ if (protocol.toLowerCase().startsWith("https:")) {
5025
+ return true;
5026
+ }
5027
+ return false;
5028
+ }
5029
+ GetAgent(protocol) {
5030
+ if (protocol.toLowerCase().startsWith("https:")) {
5031
+ if (__privateGet2(this, _httpsAgent) === null) {
5032
+ __privateSet2(this, _httpsAgent, new https.Agent(__privateGet2(this, _GetAgentOptions).call(this, true)));
5033
+ }
5034
+ return __privateGet2(this, _httpsAgent);
5035
+ } else if (protocol.toLowerCase().startsWith("http:")) {
5036
+ if (__privateGet2(this, _httpAgent) === null) {
5037
+ __privateSet2(this, _httpAgent, new http.Agent(__privateGet2(this, _GetAgentOptions).call(this, false)));
5038
+ }
5039
+ return __privateGet2(this, _httpAgent);
5040
+ } else {
5041
+ return null;
5042
+ }
5043
+ }
5044
+ ResetAgent() {
5045
+ __privateSet2(this, _httpAgent, null);
5046
+ __privateSet2(this, _httpsAgent, null);
5047
+ }
5048
+ /*
5049
+ url
5050
+ ,method: 'post'
5051
+ ,data: payload
5052
+ ,headers: headers
5053
+ ,httpsAgent: this.#agentManager.GetAgent(url)
5054
+ */
5055
+ /*
5056
+ postgresContainer = await new GenericContainer("postgres")
5057
+ .withExposedPorts(5432)
5058
+ .withEnvironment({
5059
+ POSTGRES_PASSWORD: "postgres",
5060
+ //UV_THREADPOOL_SIZE: "64"
5061
+ })
5062
+ .withCommand(['-c', 'max_connections=20'])
5063
+ .start();
5064
+ */
5065
+ Terminate() {
5066
+ if (__privateGet2(this, _agentResetInterval)) {
5067
+ clearTimeout(__privateGet2(this, _agentResetInterval));
5068
+ __privateSet2(this, _agentResetInterval, null);
5069
+ }
5070
+ if (__privateGet2(this, _httpAgent)) {
5071
+ __privateGet2(this, _httpAgent).destroy();
5072
+ __privateSet2(this, _httpAgent, null);
5073
+ }
5074
+ if (__privateGet2(this, _httpsAgent)) {
5075
+ __privateGet2(this, _httpsAgent).destroy();
5076
+ __privateSet2(this, _httpsAgent, null);
5077
+ }
5078
+ }
5079
+ }
5080
+ _options = /* @__PURE__ */ new WeakMap();
5081
+ _httpAgent = /* @__PURE__ */ new WeakMap();
5082
+ _httpsAgent = /* @__PURE__ */ new WeakMap();
5083
+ _agentResetInterval = /* @__PURE__ */ new WeakMap();
5084
+ _requestCount = /* @__PURE__ */ new WeakMap();
5085
+ _SetupResetInterval = /* @__PURE__ */ new WeakMap();
5086
+ _GetAgentOptions = /* @__PURE__ */ new WeakMap();
5087
+ class STSOAuth2Worker {
5088
+ constructor(workerPort, options, logger) {
5089
+ __privateAdd(this, _STSOAuth2Worker_instances);
5090
+ //#storageManager = null;
5091
+ __privateAdd(this, _clientSessionStore);
5092
+ __privateAdd(this, _cUtils, new CryptoUtils());
5093
+ __privateAdd(this, _qParams, new QueryParams());
5094
+ __privateAdd(this, _STORAGE_SESSION_KEY, "session.stsmda.com.au");
5095
+ //@@#aic = null;
5096
+ __privateAdd(this, _oauthWorkerPort);
5097
+ __privateAdd(this, _options3);
5098
+ __privateAdd(this, _logger);
5099
+ __privateAdd(this, _agentManager, null);
5100
+ // Attempt to restore a previous session using the STSBroker
5101
+ /*
5102
+ { parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
5103
+ { parameterType: OAuth2ParameterType.SCOPE, errorType: authErrorType.SCOPE_MISMATCH }
5104
+ { parameterType: OAuth2ParameterType.REDIRECT_URI, errorType: authErrorType.REDIRECT_URI_MISMATCH },
5105
+ { parameterType: OAuth2ParameterType.AUDIENCE, errorType: authErrorType.SCOPE_MISMATCH }
5106
+
5107
+ Successful Response
5108
+ {
5109
+ "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",
5110
+ "token_type": "Bearer",
5111
+ "expires_in": 3599,
5112
+ "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",
5113
+ "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",
5114
+ "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
5115
+ }
5116
+
5117
+ Error Response
5118
+ {
5119
+ "error": "invalid_scope",
5120
+ "error_description": "AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope https://foo.microsoft.com/mail.read is not valid.\r\nTrace ID: 255d1aef-8c98-452f-ac51-23d051240864\r\nCorrelation ID: fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7\r\nTimestamp: 2016-01-09 02:02:12Z",
5121
+ "error_codes": [
5122
+ 70011
5123
+ ],
5124
+ "timestamp": "2016-01-09 02:02:12Z",
5125
+ }
5126
+
5127
+ */
5128
+ __privateAdd(this, _HandleAuthenticateEvent2, (id_token) => {
5129
+ const message = {
5130
+ messageId: -1,
5131
+ // un-solicited message
5132
+ command: IOauth2ListenerCommand.AUTHENTICATE_EVENT
5133
+ };
5134
+ __privateGet(this, _ProcessCommand).call(this, message, id_token);
5135
+ });
5136
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5137
+ __privateAdd(this, _HandleErrorEvent2, (error) => {
5138
+ const message = {
5139
+ messageId: -1,
5140
+ // un-solicited message
5141
+ command: IOauth2ListenerCommand.ERROR
5142
+ };
5143
+ __privateGet(this, _ProcessCommand).call(this, message, error);
5144
+ });
5145
+ __privateAdd(this, _LogMessage, (messageToSend) => {
5146
+ const message = {
5147
+ messageId: -1,
5148
+ // un-solicited message
5149
+ command: IOauth2ListenerCommand.LOG
5150
+ };
5151
+ __privateGet(this, _ProcessCommand).call(this, message, messageToSend);
5152
+ });
5153
+ __privateAdd(this, _GetAccessToken, () => {
5154
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
5155
+ if (sessionData) {
5156
+ const tokens = sessionData.tokenResponse;
5157
+ return tokens.access_token;
5158
+ } else {
5159
+ return null;
5160
+ }
5161
+ });
5162
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5163
+ __privateAdd(this, _GetCookies, () => {
5164
+ if (isNode) {
5165
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
5166
+ if (sessionData) {
5167
+ return sessionData.brokerCookie;
5168
+ } else {
5169
+ return null;
5170
+ }
5171
+ } else {
3045
5172
  return null;
3046
5173
  }
3047
5174
  });
@@ -3104,7 +5231,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3104
5231
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Session restored from client storage.");
3105
5232
  __privateGet(this, _LogMessage).call(this, "Session restored from client storage.");
3106
5233
  } else {
3107
- const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/session`;
5234
+ const url = `${__privateGet(this, _options3).brokerendpoint}:${__privateGet(this, _options3).brokerport}${__privateGet(this, _options3).brokerapiroot}/session`;
3108
5235
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "RestoreSession");
3109
5236
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, url);
3110
5237
  __privateGet(this, _LogMessage).call(this, "RestoreSession.");
@@ -3114,18 +5241,22 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3114
5241
  method: "post",
3115
5242
  url,
3116
5243
  data: {
3117
- [stsutils.OAuth2ParameterType.CLIENT_ID]: __privateGet(this, _options2).client_id,
3118
- [stsutils.OAuth2ParameterType.SCOPE]: __privateGet(this, _options2).scope,
3119
- [stsutils.OAuth2ParameterType.REDIRECT_URI]: __privateGet(this, _options2).redirect_uri,
3120
- [stsutils.OAuth2ParameterType.AUDIENCE]: __privateGet(this, _options2).audience
5244
+ [stsutils.OAuth2ParameterType.CLIENT_ID]: __privateGet(this, _options3).client_id,
5245
+ [stsutils.OAuth2ParameterType.SCOPE]: __privateGet(this, _options3).scope,
5246
+ [stsutils.OAuth2ParameterType.REDIRECT_URI]: __privateGet(this, _options3).redirect_uri,
5247
+ [stsutils.OAuth2ParameterType.AUDIENCE]: __privateGet(this, _options3).audience
3121
5248
  },
3122
5249
  withCredentials: true,
3123
5250
  // Ensure cookies are passed to the service
3124
- timeout: __privateGet(this, _options2).timeout
5251
+ timeout: __privateGet(this, _options3).timeout
3125
5252
  };
3126
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
3127
- if (isNode) {
3128
- rConfig.httpsAgent = __privateGet(this, _httpsAgent);
5253
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
5254
+ if (isNode && __privateGet(this, _agentManager)) {
5255
+ if (__privateGet(this, _agentManager).IsHttps(url)) {
5256
+ rConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
5257
+ } else {
5258
+ rConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
5259
+ }
3129
5260
  }
3130
5261
  const retVal = await axios(rConfig);
3131
5262
  if (retVal.data.status === StatusCodes.OK) {
@@ -3164,12 +5295,12 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3164
5295
  });
3165
5296
  __privateAdd(this, _Authorize, async () => {
3166
5297
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Authorize ...");
3167
- const client_id = __privateGet(this, _options2).client_id;
5298
+ const client_id = __privateGet(this, _options3).client_id;
3168
5299
  const nonce = __privateGet(this, _cUtils).CreateRandomString();
3169
5300
  const response_type = [AuthorizeOptionsResponseType.CODE];
3170
- const redirect_uri = __privateGet(this, _options2).redirect_uri;
5301
+ const redirect_uri = __privateGet(this, _options3).redirect_uri;
3171
5302
  const response_mode = AuthorizeOptionsResponseMode.QUERY;
3172
- const scope = __privateGet(this, _options2).scope;
5303
+ const scope = __privateGet(this, _options3).scope;
3173
5304
  const state = __privateGet(this, _cUtils).CreateRandomString();
3174
5305
  const code_verifier = __privateGet(this, _cUtils).CreateRandomString();
3175
5306
  const code_challenge = await __privateGet(this, _cUtils).DigestMessage(code_verifier);
@@ -3186,7 +5317,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3186
5317
  code_challenge_method
3187
5318
  };
3188
5319
  const authorizeOptionsClientCopy = { ...authorizeOptions };
3189
- const url = `${__privateGet(this, _options2).authorizeendpoint}:${__privateGet(this, _options2).authorizeport}${__privateGet(this, _options2).authorizeapiroot}${__privateGet(this, _options2).authorizeapi}?${__privateGet(this, _qParams).CreateQueryParams(authorizeOptions)}`;
5320
+ const url = `${__privateGet(this, _options3).authorizeendpoint}:${__privateGet(this, _options3).authorizeport}${__privateGet(this, _options3).authorizeapiroot}${__privateGet(this, _options3).authorizeapi}?${__privateGet(this, _qParams).CreateQueryParams(authorizeOptions)}`;
3190
5321
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, url);
3191
5322
  authorizeOptions.code_verifier = code_verifier;
3192
5323
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, `Authorize:authorizeOptions: [${JSON.stringify(authorizeOptions)}]`);
@@ -3200,29 +5331,29 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3200
5331
  __privateAdd(this, _HandleRedirect, async (payload) => {
3201
5332
  const queryVars = payload.queryVars;
3202
5333
  const authorizeOptions = payload.authorizeOptions;
3203
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#HandleRedirect: HandleRedirect`));
3204
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`));
5334
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#HandleRedirect: HandleRedirect`));
5335
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`));
3205
5336
  if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
3206
5337
  const response = queryVars;
3207
5338
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, `authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
3208
5339
  const redirectState = response.state;
3209
5340
  const authorizeOptionsState = authorizeOptions.state;
3210
5341
  if (authorizeOptionsState.localeCompare(redirectState) === 0) {
3211
- __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, chalk$1.green("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"));
5342
+ __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, chalk$2.green("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"));
3212
5343
  return await __privateGet(this, _GetToken).call(this, authorizeOptions, response);
3213
5344
  } else {
3214
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"));
3215
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`authorizeOptionsState: [${authorizeOptionsState}]`));
3216
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`redirectState: [${redirectState}]`));
5345
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"));
5346
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(`authorizeOptionsState: [${authorizeOptionsState}]`));
5347
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(`redirectState: [${redirectState}]`));
3217
5348
  __privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
3218
5349
  return false;
3219
5350
  }
3220
5351
  } else if (queryVars[stsutils.OAuth2ParameterType.ERROR]) {
3221
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`State un-matched (1)`));
5352
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(`State un-matched (1)`));
3222
5353
  __privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
3223
5354
  return false;
3224
5355
  } else {
3225
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`State un-matched (2)`));
5356
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(`State un-matched (2)`));
3226
5357
  __privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
3227
5358
  return false;
3228
5359
  }
@@ -3248,9 +5379,9 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3248
5379
  */
3249
5380
  // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
3250
5381
  __privateAdd(this, _GetTokenFromBroker, async (authorizationCodeFlowParameters) => {
3251
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker`));
5382
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker`));
3252
5383
  __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
3253
- const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/token`;
5384
+ const url = `${__privateGet(this, _options3).brokerendpoint}:${__privateGet(this, _options3).brokerport}${__privateGet(this, _options3).brokerapiroot}/token`;
3254
5385
  try {
3255
5386
  const rConfig = {
3256
5387
  method: "post",
@@ -3258,17 +5389,21 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3258
5389
  data: authorizationCodeFlowParameters,
3259
5390
  withCredentials: true,
3260
5391
  // Ensure cookies are passed to the service
3261
- timeout: __privateGet(this, _options2).timeout
5392
+ timeout: __privateGet(this, _options3).timeout
3262
5393
  };
3263
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
3264
- if (isNode) {
3265
- rConfig.httpsAgent = __privateGet(this, _httpsAgent);
5394
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
5395
+ if (isNode && __privateGet(this, _agentManager)) {
5396
+ if (__privateGet(this, _agentManager).IsHttps(url)) {
5397
+ rConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
5398
+ } else {
5399
+ rConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
5400
+ }
3266
5401
  }
3267
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: axios API call`));
5402
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: axios API call`));
3268
5403
  const retVal = await axios(rConfig);
3269
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
5404
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
3270
5405
  if (retVal.status === StatusCodes.OK) {
3271
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: storing tokens`));
5406
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: storing tokens`));
3272
5407
  const tokenResponse = retVal.data;
3273
5408
  __privateGet(this, _HandleAuthenticateEvent2).call(this, tokenResponse.id_token);
3274
5409
  const newSessionData = {
@@ -3280,18 +5415,18 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3280
5415
  __privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY), newSessionData);
3281
5416
  return true;
3282
5417
  } else if (retVal.status === StatusCodes.UNAUTHORIZED) {
3283
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`));
5418
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`));
3284
5419
  __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
3285
5420
  return false;
3286
5421
  } else {
3287
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`));
5422
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`));
3288
5423
  __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
3289
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red("Could not obtain access_token from token end-point:-"));
3290
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(JSON.stringify(retVal.data)));
5424
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red("Could not obtain access_token from token end-point:-"));
5425
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(JSON.stringify(retVal.data)));
3291
5426
  return false;
3292
5427
  }
3293
5428
  } catch (error) {
3294
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`));
5429
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`));
3295
5430
  __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
3296
5431
  return false;
3297
5432
  }
@@ -3302,10 +5437,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3302
5437
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, authorizeResponse);
3303
5438
  __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
3304
5439
  const authorizationCodeFlowParameters = {
3305
- client_id: __privateGet(this, _options2).client_id,
3306
- scope: __privateGet(this, _options2).scope,
5440
+ client_id: __privateGet(this, _options3).client_id,
5441
+ scope: __privateGet(this, _options3).scope,
3307
5442
  code: authorizeResponse.code,
3308
- redirect_uri: __privateGet(this, _options2).redirect_uri,
5443
+ redirect_uri: __privateGet(this, _options3).redirect_uri,
3309
5444
  grant_type: OAuthGrantTypes.AUTHORIZATION_CODE,
3310
5445
  code_verifier: authorizeOptions.code_verifier
3311
5446
  };
@@ -3337,20 +5472,20 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3337
5472
  }
3338
5473
  */
3339
5474
  __privateAdd(this, _RefreshToken, async () => {
3340
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:start`));
5475
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.cyan(`STSOAuth2Worker:#RefreshToken:start`));
3341
5476
  const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
3342
5477
  if (sessionData) {
3343
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(sessionData)}]`));
5478
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.cyan(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(sessionData)}]`));
3344
5479
  const currentSessionData = sessionData.tokenResponse;
3345
5480
  const refreshFlowParameters = {
3346
- client_id: __privateGet(this, _options2).client_id,
3347
- scope: __privateGet(this, _options2).scope,
5481
+ client_id: __privateGet(this, _options3).client_id,
5482
+ scope: __privateGet(this, _options3).scope,
3348
5483
  refresh_token: currentSessionData.refresh_token,
3349
5484
  grant_type: OAuthGrantTypes.REFRESH_TOKEN
3350
5485
  };
3351
5486
  return await __privateGet(this, _GetTokenFromBroker).call(this, refreshFlowParameters);
3352
5487
  } else {
3353
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`));
5488
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`));
3354
5489
  return false;
3355
5490
  }
3356
5491
  });
@@ -3361,7 +5496,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3361
5496
  // clear all state from $store
3362
5497
  __privateAdd(this, _Logout, async () => {
3363
5498
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Logout");
3364
- const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/logout`;
5499
+ const url = `${__privateGet(this, _options3).brokerendpoint}:${__privateGet(this, _options3).brokerport}${__privateGet(this, _options3).brokerapiroot}/logout`;
3365
5500
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, url);
3366
5501
  const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
3367
5502
  if (sessionData) {
@@ -3383,24 +5518,28 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3383
5518
  },
3384
5519
  withCredentials: true,
3385
5520
  // Ensure cookies are passed to the service
3386
- timeout: __privateGet(this, _options2).timeout
5521
+ timeout: __privateGet(this, _options3).timeout
3387
5522
  };
3388
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#Logout: request config: [${rConfig}]`));
3389
- if (isNode) {
3390
- rConfig.httpsAgent = __privateGet(this, _httpsAgent);
5523
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#Logout: request config: [${rConfig}]`));
5524
+ if (isNode && __privateGet(this, _agentManager)) {
5525
+ if (__privateGet(this, _agentManager).IsHttps(url)) {
5526
+ rConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
5527
+ } else {
5528
+ rConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
5529
+ }
3391
5530
  }
3392
5531
  const retVal = await axios(rConfig);
3393
5532
  if (retVal.data.status === StatusCodes.OK) {
3394
5533
  return true;
3395
5534
  } else {
3396
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red("Error during logout (1: server side)"));
3397
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(JSON.stringify(retVal.data)));
5535
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red("Error during logout (1: server side)"));
5536
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(JSON.stringify(retVal.data)));
3398
5537
  return false;
3399
5538
  }
3400
5539
  } catch (error) {
3401
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red("Error during logout (2: server side)"));
3402
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(error));
3403
- __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(JSON.stringify(error)));
5540
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red("Error during logout (2: server side)"));
5541
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(error));
5542
+ __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$2.red(JSON.stringify(error)));
3404
5543
  return false;
3405
5544
  }
3406
5545
  } else {
@@ -3408,21 +5547,15 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3408
5547
  return false;
3409
5548
  }
3410
5549
  });
3411
- __privateSet(this, _options2, options);
5550
+ __privateSet(this, _options3, options);
3412
5551
  __privateSet(this, _logger, logger);
3413
- __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, `STSOAuth2Worker:constructor:#options: [${JSON.stringify(__privateGet(this, _options2))}]`);
5552
+ __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, `STSOAuth2Worker:constructor:#options: [${JSON.stringify(__privateGet(this, _options3))}]`);
3414
5553
  __privateSet(this, _clientSessionStore, new stsvueutils.ClientStorageFactory({ clientStorageType: stsvueutils.ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage());
3415
5554
  __privateSet(this, _oauthWorkerPort, workerPort);
3416
5555
  __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, `STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(__privateGet(this, _oauthWorkerPort))}]`);
3417
- if (isNode && __privateGet(this, _options2).agentOptions) {
3418
- __privateSet(this, _httpsAgent, new https.Agent({
3419
- keepAlive: __privateGet(this, _options2).agentOptions.keepAlive,
3420
- maxSockets: __privateGet(this, _options2).agentOptions.maxSockets,
3421
- maxTotalSockets: __privateGet(this, _options2).agentOptions.maxTotalSockets,
3422
- maxFreeSockets: __privateGet(this, _options2).agentOptions.maxFreeSockets,
3423
- timeout: __privateGet(this, _options2).timeout,
3424
- rejectUnauthorized: __privateGet(this, _options2).agentOptions.rejectUnauthorized
3425
- // Allows self-signed certificates if non-production
5556
+ if (isNode && __privateGet(this, _options3).agentOptions) {
5557
+ __privateSet(this, _agentManager, new AgentManager({
5558
+ agentOptions: __privateGet(this, _options3).agentOptions
3426
5559
  }));
3427
5560
  }
3428
5561
  this.SetupListener();
@@ -3436,9 +5569,9 @@ var __privateWrapper = (obj, member, setter, getter) => ({
3436
5569
  _qParams = new WeakMap();
3437
5570
  _STORAGE_SESSION_KEY = new WeakMap();
3438
5571
  _oauthWorkerPort = new WeakMap();
3439
- _options2 = new WeakMap();
3440
- _httpsAgent = new WeakMap();
5572
+ _options3 = new WeakMap();
3441
5573
  _logger = new WeakMap();
5574
+ _agentManager = new WeakMap();
3442
5575
  _STSOAuth2Worker_instances = new WeakSet();
3443
5576
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3444
5577
  LogDebugMessage_fn2 = function(message) {