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