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