@nsshunt/stsoauth2plugin 1.0.150 → 1.0.152

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3437 +0,0 @@
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: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
- "use strict";
5
- function _interopNamespaceDefault(e) {
6
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
- if (e) {
8
- for (const k in e) {
9
- if (k !== "default") {
10
- const d = Object.getOwnPropertyDescriptor(e, k);
11
- Object.defineProperty(n, k, d.get ? d : {
12
- enumerable: true,
13
- get: () => e[k]
14
- });
15
- }
16
- }
17
- }
18
- n.default = e;
19
- return Object.freeze(n);
20
- }
21
- const wt__namespace = /* @__PURE__ */ _interopNamespaceDefault(wt);
22
- const STSOAuth2ManagerPluginKey = /* @__PURE__ */ Symbol();
23
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
24
- function getDefaultExportFromCjs(x) {
25
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
26
- }
27
- var ansiStyles = { exports: {} };
28
- var colorName;
29
- var hasRequiredColorName;
30
- function requireColorName() {
31
- if (hasRequiredColorName) return colorName;
32
- hasRequiredColorName = 1;
33
- colorName = {
34
- "aliceblue": [240, 248, 255],
35
- "antiquewhite": [250, 235, 215],
36
- "aqua": [0, 255, 255],
37
- "aquamarine": [127, 255, 212],
38
- "azure": [240, 255, 255],
39
- "beige": [245, 245, 220],
40
- "bisque": [255, 228, 196],
41
- "black": [0, 0, 0],
42
- "blanchedalmond": [255, 235, 205],
43
- "blue": [0, 0, 255],
44
- "blueviolet": [138, 43, 226],
45
- "brown": [165, 42, 42],
46
- "burlywood": [222, 184, 135],
47
- "cadetblue": [95, 158, 160],
48
- "chartreuse": [127, 255, 0],
49
- "chocolate": [210, 105, 30],
50
- "coral": [255, 127, 80],
51
- "cornflowerblue": [100, 149, 237],
52
- "cornsilk": [255, 248, 220],
53
- "crimson": [220, 20, 60],
54
- "cyan": [0, 255, 255],
55
- "darkblue": [0, 0, 139],
56
- "darkcyan": [0, 139, 139],
57
- "darkgoldenrod": [184, 134, 11],
58
- "darkgray": [169, 169, 169],
59
- "darkgreen": [0, 100, 0],
60
- "darkgrey": [169, 169, 169],
61
- "darkkhaki": [189, 183, 107],
62
- "darkmagenta": [139, 0, 139],
63
- "darkolivegreen": [85, 107, 47],
64
- "darkorange": [255, 140, 0],
65
- "darkorchid": [153, 50, 204],
66
- "darkred": [139, 0, 0],
67
- "darksalmon": [233, 150, 122],
68
- "darkseagreen": [143, 188, 143],
69
- "darkslateblue": [72, 61, 139],
70
- "darkslategray": [47, 79, 79],
71
- "darkslategrey": [47, 79, 79],
72
- "darkturquoise": [0, 206, 209],
73
- "darkviolet": [148, 0, 211],
74
- "deeppink": [255, 20, 147],
75
- "deepskyblue": [0, 191, 255],
76
- "dimgray": [105, 105, 105],
77
- "dimgrey": [105, 105, 105],
78
- "dodgerblue": [30, 144, 255],
79
- "firebrick": [178, 34, 34],
80
- "floralwhite": [255, 250, 240],
81
- "forestgreen": [34, 139, 34],
82
- "fuchsia": [255, 0, 255],
83
- "gainsboro": [220, 220, 220],
84
- "ghostwhite": [248, 248, 255],
85
- "gold": [255, 215, 0],
86
- "goldenrod": [218, 165, 32],
87
- "gray": [128, 128, 128],
88
- "green": [0, 128, 0],
89
- "greenyellow": [173, 255, 47],
90
- "grey": [128, 128, 128],
91
- "honeydew": [240, 255, 240],
92
- "hotpink": [255, 105, 180],
93
- "indianred": [205, 92, 92],
94
- "indigo": [75, 0, 130],
95
- "ivory": [255, 255, 240],
96
- "khaki": [240, 230, 140],
97
- "lavender": [230, 230, 250],
98
- "lavenderblush": [255, 240, 245],
99
- "lawngreen": [124, 252, 0],
100
- "lemonchiffon": [255, 250, 205],
101
- "lightblue": [173, 216, 230],
102
- "lightcoral": [240, 128, 128],
103
- "lightcyan": [224, 255, 255],
104
- "lightgoldenrodyellow": [250, 250, 210],
105
- "lightgray": [211, 211, 211],
106
- "lightgreen": [144, 238, 144],
107
- "lightgrey": [211, 211, 211],
108
- "lightpink": [255, 182, 193],
109
- "lightsalmon": [255, 160, 122],
110
- "lightseagreen": [32, 178, 170],
111
- "lightskyblue": [135, 206, 250],
112
- "lightslategray": [119, 136, 153],
113
- "lightslategrey": [119, 136, 153],
114
- "lightsteelblue": [176, 196, 222],
115
- "lightyellow": [255, 255, 224],
116
- "lime": [0, 255, 0],
117
- "limegreen": [50, 205, 50],
118
- "linen": [250, 240, 230],
119
- "magenta": [255, 0, 255],
120
- "maroon": [128, 0, 0],
121
- "mediumaquamarine": [102, 205, 170],
122
- "mediumblue": [0, 0, 205],
123
- "mediumorchid": [186, 85, 211],
124
- "mediumpurple": [147, 112, 219],
125
- "mediumseagreen": [60, 179, 113],
126
- "mediumslateblue": [123, 104, 238],
127
- "mediumspringgreen": [0, 250, 154],
128
- "mediumturquoise": [72, 209, 204],
129
- "mediumvioletred": [199, 21, 133],
130
- "midnightblue": [25, 25, 112],
131
- "mintcream": [245, 255, 250],
132
- "mistyrose": [255, 228, 225],
133
- "moccasin": [255, 228, 181],
134
- "navajowhite": [255, 222, 173],
135
- "navy": [0, 0, 128],
136
- "oldlace": [253, 245, 230],
137
- "olive": [128, 128, 0],
138
- "olivedrab": [107, 142, 35],
139
- "orange": [255, 165, 0],
140
- "orangered": [255, 69, 0],
141
- "orchid": [218, 112, 214],
142
- "palegoldenrod": [238, 232, 170],
143
- "palegreen": [152, 251, 152],
144
- "paleturquoise": [175, 238, 238],
145
- "palevioletred": [219, 112, 147],
146
- "papayawhip": [255, 239, 213],
147
- "peachpuff": [255, 218, 185],
148
- "peru": [205, 133, 63],
149
- "pink": [255, 192, 203],
150
- "plum": [221, 160, 221],
151
- "powderblue": [176, 224, 230],
152
- "purple": [128, 0, 128],
153
- "rebeccapurple": [102, 51, 153],
154
- "red": [255, 0, 0],
155
- "rosybrown": [188, 143, 143],
156
- "royalblue": [65, 105, 225],
157
- "saddlebrown": [139, 69, 19],
158
- "salmon": [250, 128, 114],
159
- "sandybrown": [244, 164, 96],
160
- "seagreen": [46, 139, 87],
161
- "seashell": [255, 245, 238],
162
- "sienna": [160, 82, 45],
163
- "silver": [192, 192, 192],
164
- "skyblue": [135, 206, 235],
165
- "slateblue": [106, 90, 205],
166
- "slategray": [112, 128, 144],
167
- "slategrey": [112, 128, 144],
168
- "snow": [255, 250, 250],
169
- "springgreen": [0, 255, 127],
170
- "steelblue": [70, 130, 180],
171
- "tan": [210, 180, 140],
172
- "teal": [0, 128, 128],
173
- "thistle": [216, 191, 216],
174
- "tomato": [255, 99, 71],
175
- "turquoise": [64, 224, 208],
176
- "violet": [238, 130, 238],
177
- "wheat": [245, 222, 179],
178
- "white": [255, 255, 255],
179
- "whitesmoke": [245, 245, 245],
180
- "yellow": [255, 255, 0],
181
- "yellowgreen": [154, 205, 50]
182
- };
183
- return colorName;
184
- }
185
- var conversions;
186
- var hasRequiredConversions;
187
- function requireConversions() {
188
- if (hasRequiredConversions) return conversions;
189
- hasRequiredConversions = 1;
190
- const cssKeywords = requireColorName();
191
- const reverseKeywords = {};
192
- for (const key of Object.keys(cssKeywords)) {
193
- reverseKeywords[cssKeywords[key]] = key;
194
- }
195
- const convert = {
196
- rgb: { channels: 3, labels: "rgb" },
197
- hsl: { channels: 3, labels: "hsl" },
198
- hsv: { channels: 3, labels: "hsv" },
199
- hwb: { channels: 3, labels: "hwb" },
200
- cmyk: { channels: 4, labels: "cmyk" },
201
- xyz: { channels: 3, labels: "xyz" },
202
- lab: { channels: 3, labels: "lab" },
203
- lch: { channels: 3, labels: "lch" },
204
- hex: { channels: 1, labels: ["hex"] },
205
- keyword: { channels: 1, labels: ["keyword"] },
206
- ansi16: { channels: 1, labels: ["ansi16"] },
207
- ansi256: { channels: 1, labels: ["ansi256"] },
208
- hcg: { channels: 3, labels: ["h", "c", "g"] },
209
- apple: { channels: 3, labels: ["r16", "g16", "b16"] },
210
- gray: { channels: 1, labels: ["gray"] }
211
- };
212
- conversions = convert;
213
- for (const model of Object.keys(convert)) {
214
- if (!("channels" in convert[model])) {
215
- throw new Error("missing channels property: " + model);
216
- }
217
- if (!("labels" in convert[model])) {
218
- throw new Error("missing channel labels property: " + model);
219
- }
220
- if (convert[model].labels.length !== convert[model].channels) {
221
- throw new Error("channel and label counts mismatch: " + model);
222
- }
223
- const { channels, labels } = convert[model];
224
- delete convert[model].channels;
225
- delete convert[model].labels;
226
- Object.defineProperty(convert[model], "channels", { value: channels });
227
- Object.defineProperty(convert[model], "labels", { value: labels });
228
- }
229
- convert.rgb.hsl = function(rgb) {
230
- const r = rgb[0] / 255;
231
- const g = rgb[1] / 255;
232
- const b = rgb[2] / 255;
233
- const min = Math.min(r, g, b);
234
- const max = Math.max(r, g, b);
235
- const delta = max - min;
236
- let h;
237
- let s;
238
- if (max === min) {
239
- h = 0;
240
- } else if (r === max) {
241
- h = (g - b) / delta;
242
- } else if (g === max) {
243
- h = 2 + (b - r) / delta;
244
- } else if (b === max) {
245
- h = 4 + (r - g) / delta;
246
- }
247
- h = Math.min(h * 60, 360);
248
- if (h < 0) {
249
- h += 360;
250
- }
251
- const l = (min + max) / 2;
252
- if (max === min) {
253
- s = 0;
254
- } else if (l <= 0.5) {
255
- s = delta / (max + min);
256
- } else {
257
- s = delta / (2 - max - min);
258
- }
259
- return [h, s * 100, l * 100];
260
- };
261
- convert.rgb.hsv = function(rgb) {
262
- let rdif;
263
- let gdif;
264
- let bdif;
265
- let h;
266
- let s;
267
- const r = rgb[0] / 255;
268
- const g = rgb[1] / 255;
269
- const b = rgb[2] / 255;
270
- const v = Math.max(r, g, b);
271
- const diff = v - Math.min(r, g, b);
272
- const diffc = function(c) {
273
- return (v - c) / 6 / diff + 1 / 2;
274
- };
275
- if (diff === 0) {
276
- h = 0;
277
- s = 0;
278
- } else {
279
- s = diff / v;
280
- rdif = diffc(r);
281
- gdif = diffc(g);
282
- bdif = diffc(b);
283
- if (r === v) {
284
- h = bdif - gdif;
285
- } else if (g === v) {
286
- h = 1 / 3 + rdif - bdif;
287
- } else if (b === v) {
288
- h = 2 / 3 + gdif - rdif;
289
- }
290
- if (h < 0) {
291
- h += 1;
292
- } else if (h > 1) {
293
- h -= 1;
294
- }
295
- }
296
- return [
297
- h * 360,
298
- s * 100,
299
- v * 100
300
- ];
301
- };
302
- convert.rgb.hwb = function(rgb) {
303
- const r = rgb[0];
304
- const g = rgb[1];
305
- let b = rgb[2];
306
- const h = convert.rgb.hsl(rgb)[0];
307
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
308
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
309
- return [h, w * 100, b * 100];
310
- };
311
- convert.rgb.cmyk = function(rgb) {
312
- const r = rgb[0] / 255;
313
- const g = rgb[1] / 255;
314
- const b = rgb[2] / 255;
315
- const k = Math.min(1 - r, 1 - g, 1 - b);
316
- const c = (1 - r - k) / (1 - k) || 0;
317
- const m = (1 - g - k) / (1 - k) || 0;
318
- const y = (1 - b - k) / (1 - k) || 0;
319
- return [c * 100, m * 100, y * 100, k * 100];
320
- };
321
- function comparativeDistance(x, y) {
322
- return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
323
- }
324
- convert.rgb.keyword = function(rgb) {
325
- const reversed = reverseKeywords[rgb];
326
- if (reversed) {
327
- return reversed;
328
- }
329
- let currentClosestDistance = Infinity;
330
- let currentClosestKeyword;
331
- for (const keyword of Object.keys(cssKeywords)) {
332
- const value = cssKeywords[keyword];
333
- const distance = comparativeDistance(rgb, value);
334
- if (distance < currentClosestDistance) {
335
- currentClosestDistance = distance;
336
- currentClosestKeyword = keyword;
337
- }
338
- }
339
- return currentClosestKeyword;
340
- };
341
- convert.keyword.rgb = function(keyword) {
342
- return cssKeywords[keyword];
343
- };
344
- convert.rgb.xyz = function(rgb) {
345
- let r = rgb[0] / 255;
346
- let g = rgb[1] / 255;
347
- let b = rgb[2] / 255;
348
- r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
349
- g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
350
- b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
351
- const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
352
- const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
353
- const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
354
- return [x * 100, y * 100, z * 100];
355
- };
356
- convert.rgb.lab = function(rgb) {
357
- const xyz = convert.rgb.xyz(rgb);
358
- let x = xyz[0];
359
- let y = xyz[1];
360
- let z = xyz[2];
361
- x /= 95.047;
362
- y /= 100;
363
- z /= 108.883;
364
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
365
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
366
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
367
- const l = 116 * y - 16;
368
- const a = 500 * (x - y);
369
- const b = 200 * (y - z);
370
- return [l, a, b];
371
- };
372
- convert.hsl.rgb = function(hsl) {
373
- const h = hsl[0] / 360;
374
- const s = hsl[1] / 100;
375
- const l = hsl[2] / 100;
376
- let t2;
377
- let t3;
378
- let val;
379
- if (s === 0) {
380
- val = l * 255;
381
- return [val, val, val];
382
- }
383
- if (l < 0.5) {
384
- t2 = l * (1 + s);
385
- } else {
386
- t2 = l + s - l * s;
387
- }
388
- const t1 = 2 * l - t2;
389
- const rgb = [0, 0, 0];
390
- for (let i = 0; i < 3; i++) {
391
- t3 = h + 1 / 3 * -(i - 1);
392
- if (t3 < 0) {
393
- t3++;
394
- }
395
- if (t3 > 1) {
396
- t3--;
397
- }
398
- if (6 * t3 < 1) {
399
- val = t1 + (t2 - t1) * 6 * t3;
400
- } else if (2 * t3 < 1) {
401
- val = t2;
402
- } else if (3 * t3 < 2) {
403
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
404
- } else {
405
- val = t1;
406
- }
407
- rgb[i] = val * 255;
408
- }
409
- return rgb;
410
- };
411
- convert.hsl.hsv = function(hsl) {
412
- const h = hsl[0];
413
- let s = hsl[1] / 100;
414
- let l = hsl[2] / 100;
415
- let smin = s;
416
- const lmin = Math.max(l, 0.01);
417
- l *= 2;
418
- s *= l <= 1 ? l : 2 - l;
419
- smin *= lmin <= 1 ? lmin : 2 - lmin;
420
- const v = (l + s) / 2;
421
- const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
422
- return [h, sv * 100, v * 100];
423
- };
424
- convert.hsv.rgb = function(hsv) {
425
- const h = hsv[0] / 60;
426
- const s = hsv[1] / 100;
427
- let v = hsv[2] / 100;
428
- const hi = Math.floor(h) % 6;
429
- const f = h - Math.floor(h);
430
- const p = 255 * v * (1 - s);
431
- const q = 255 * v * (1 - s * f);
432
- const t = 255 * v * (1 - s * (1 - f));
433
- v *= 255;
434
- switch (hi) {
435
- case 0:
436
- return [v, t, p];
437
- case 1:
438
- return [q, v, p];
439
- case 2:
440
- return [p, v, t];
441
- case 3:
442
- return [p, q, v];
443
- case 4:
444
- return [t, p, v];
445
- case 5:
446
- return [v, p, q];
447
- }
448
- };
449
- convert.hsv.hsl = function(hsv) {
450
- const h = hsv[0];
451
- const s = hsv[1] / 100;
452
- const v = hsv[2] / 100;
453
- const vmin = Math.max(v, 0.01);
454
- let sl;
455
- let l;
456
- l = (2 - s) * v;
457
- const lmin = (2 - s) * vmin;
458
- sl = s * vmin;
459
- sl /= lmin <= 1 ? lmin : 2 - lmin;
460
- sl = sl || 0;
461
- l /= 2;
462
- return [h, sl * 100, l * 100];
463
- };
464
- convert.hwb.rgb = function(hwb) {
465
- const h = hwb[0] / 360;
466
- let wh = hwb[1] / 100;
467
- let bl = hwb[2] / 100;
468
- const ratio = wh + bl;
469
- let f;
470
- if (ratio > 1) {
471
- wh /= ratio;
472
- bl /= ratio;
473
- }
474
- const i = Math.floor(6 * h);
475
- const v = 1 - bl;
476
- f = 6 * h - i;
477
- if ((i & 1) !== 0) {
478
- f = 1 - f;
479
- }
480
- const n = wh + f * (v - wh);
481
- let r;
482
- let g;
483
- let b;
484
- switch (i) {
485
- default:
486
- case 6:
487
- case 0:
488
- r = v;
489
- g = n;
490
- b = wh;
491
- break;
492
- case 1:
493
- r = n;
494
- g = v;
495
- b = wh;
496
- break;
497
- case 2:
498
- r = wh;
499
- g = v;
500
- b = n;
501
- break;
502
- case 3:
503
- r = wh;
504
- g = n;
505
- b = v;
506
- break;
507
- case 4:
508
- r = n;
509
- g = wh;
510
- b = v;
511
- break;
512
- case 5:
513
- r = v;
514
- g = wh;
515
- b = n;
516
- break;
517
- }
518
- return [r * 255, g * 255, b * 255];
519
- };
520
- convert.cmyk.rgb = function(cmyk) {
521
- const c = cmyk[0] / 100;
522
- const m = cmyk[1] / 100;
523
- const y = cmyk[2] / 100;
524
- const k = cmyk[3] / 100;
525
- const r = 1 - Math.min(1, c * (1 - k) + k);
526
- const g = 1 - Math.min(1, m * (1 - k) + k);
527
- const b = 1 - Math.min(1, y * (1 - k) + k);
528
- return [r * 255, g * 255, b * 255];
529
- };
530
- convert.xyz.rgb = function(xyz) {
531
- const x = xyz[0] / 100;
532
- const y = xyz[1] / 100;
533
- const z = xyz[2] / 100;
534
- let r;
535
- let g;
536
- let b;
537
- r = x * 3.2406 + y * -1.5372 + z * -0.4986;
538
- g = x * -0.9689 + y * 1.8758 + z * 0.0415;
539
- b = x * 0.0557 + y * -0.204 + z * 1.057;
540
- r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
541
- g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
542
- b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
543
- r = Math.min(Math.max(0, r), 1);
544
- g = Math.min(Math.max(0, g), 1);
545
- b = Math.min(Math.max(0, b), 1);
546
- return [r * 255, g * 255, b * 255];
547
- };
548
- convert.xyz.lab = function(xyz) {
549
- let x = xyz[0];
550
- let y = xyz[1];
551
- let z = xyz[2];
552
- x /= 95.047;
553
- y /= 100;
554
- z /= 108.883;
555
- x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
556
- y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
557
- z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
558
- const l = 116 * y - 16;
559
- const a = 500 * (x - y);
560
- const b = 200 * (y - z);
561
- return [l, a, b];
562
- };
563
- convert.lab.xyz = function(lab) {
564
- const l = lab[0];
565
- const a = lab[1];
566
- const b = lab[2];
567
- let x;
568
- let y;
569
- let z;
570
- y = (l + 16) / 116;
571
- x = a / 500 + y;
572
- z = y - b / 200;
573
- const y2 = y ** 3;
574
- const x2 = x ** 3;
575
- const z2 = z ** 3;
576
- y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
577
- x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
578
- z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
579
- x *= 95.047;
580
- y *= 100;
581
- z *= 108.883;
582
- return [x, y, z];
583
- };
584
- convert.lab.lch = function(lab) {
585
- const l = lab[0];
586
- const a = lab[1];
587
- const b = lab[2];
588
- let h;
589
- const hr = Math.atan2(b, a);
590
- h = hr * 360 / 2 / Math.PI;
591
- if (h < 0) {
592
- h += 360;
593
- }
594
- const c = Math.sqrt(a * a + b * b);
595
- return [l, c, h];
596
- };
597
- convert.lch.lab = function(lch) {
598
- const l = lch[0];
599
- const c = lch[1];
600
- const h = lch[2];
601
- const hr = h / 360 * 2 * Math.PI;
602
- const a = c * Math.cos(hr);
603
- const b = c * Math.sin(hr);
604
- return [l, a, b];
605
- };
606
- convert.rgb.ansi16 = function(args, saturation = null) {
607
- const [r, g, b] = args;
608
- let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
609
- value = Math.round(value / 50);
610
- if (value === 0) {
611
- return 30;
612
- }
613
- let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
614
- if (value === 2) {
615
- ansi += 60;
616
- }
617
- return ansi;
618
- };
619
- convert.hsv.ansi16 = function(args) {
620
- return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
621
- };
622
- convert.rgb.ansi256 = function(args) {
623
- const r = args[0];
624
- const g = args[1];
625
- const b = args[2];
626
- if (r === g && g === b) {
627
- if (r < 8) {
628
- return 16;
629
- }
630
- if (r > 248) {
631
- return 231;
632
- }
633
- return Math.round((r - 8) / 247 * 24) + 232;
634
- }
635
- const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
636
- return ansi;
637
- };
638
- convert.ansi16.rgb = function(args) {
639
- let color = args % 10;
640
- if (color === 0 || color === 7) {
641
- if (args > 50) {
642
- color += 3.5;
643
- }
644
- color = color / 10.5 * 255;
645
- return [color, color, color];
646
- }
647
- const mult = (~~(args > 50) + 1) * 0.5;
648
- const r = (color & 1) * mult * 255;
649
- const g = (color >> 1 & 1) * mult * 255;
650
- const b = (color >> 2 & 1) * mult * 255;
651
- return [r, g, b];
652
- };
653
- convert.ansi256.rgb = function(args) {
654
- if (args >= 232) {
655
- const c = (args - 232) * 10 + 8;
656
- return [c, c, c];
657
- }
658
- args -= 16;
659
- let rem;
660
- const r = Math.floor(args / 36) / 5 * 255;
661
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
662
- const b = rem % 6 / 5 * 255;
663
- return [r, g, b];
664
- };
665
- convert.rgb.hex = function(args) {
666
- const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
667
- const string = integer.toString(16).toUpperCase();
668
- return "000000".substring(string.length) + string;
669
- };
670
- convert.hex.rgb = function(args) {
671
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
672
- if (!match) {
673
- return [0, 0, 0];
674
- }
675
- let colorString = match[0];
676
- if (match[0].length === 3) {
677
- colorString = colorString.split("").map((char) => {
678
- return char + char;
679
- }).join("");
680
- }
681
- const integer = parseInt(colorString, 16);
682
- const r = integer >> 16 & 255;
683
- const g = integer >> 8 & 255;
684
- const b = integer & 255;
685
- return [r, g, b];
686
- };
687
- convert.rgb.hcg = function(rgb) {
688
- const r = rgb[0] / 255;
689
- const g = rgb[1] / 255;
690
- const b = rgb[2] / 255;
691
- const max = Math.max(Math.max(r, g), b);
692
- const min = Math.min(Math.min(r, g), b);
693
- const chroma = max - min;
694
- let grayscale;
695
- let hue;
696
- if (chroma < 1) {
697
- grayscale = min / (1 - chroma);
698
- } else {
699
- grayscale = 0;
700
- }
701
- if (chroma <= 0) {
702
- hue = 0;
703
- } else if (max === r) {
704
- hue = (g - b) / chroma % 6;
705
- } else if (max === g) {
706
- hue = 2 + (b - r) / chroma;
707
- } else {
708
- hue = 4 + (r - g) / chroma;
709
- }
710
- hue /= 6;
711
- hue %= 1;
712
- return [hue * 360, chroma * 100, grayscale * 100];
713
- };
714
- convert.hsl.hcg = function(hsl) {
715
- const s = hsl[1] / 100;
716
- const l = hsl[2] / 100;
717
- const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
718
- let f = 0;
719
- if (c < 1) {
720
- f = (l - 0.5 * c) / (1 - c);
721
- }
722
- return [hsl[0], c * 100, f * 100];
723
- };
724
- convert.hsv.hcg = function(hsv) {
725
- const s = hsv[1] / 100;
726
- const v = hsv[2] / 100;
727
- const c = s * v;
728
- let f = 0;
729
- if (c < 1) {
730
- f = (v - c) / (1 - c);
731
- }
732
- return [hsv[0], c * 100, f * 100];
733
- };
734
- convert.hcg.rgb = function(hcg) {
735
- const h = hcg[0] / 360;
736
- const c = hcg[1] / 100;
737
- const g = hcg[2] / 100;
738
- if (c === 0) {
739
- return [g * 255, g * 255, g * 255];
740
- }
741
- const pure = [0, 0, 0];
742
- const hi = h % 1 * 6;
743
- const v = hi % 1;
744
- const w = 1 - v;
745
- let mg = 0;
746
- switch (Math.floor(hi)) {
747
- case 0:
748
- pure[0] = 1;
749
- pure[1] = v;
750
- pure[2] = 0;
751
- break;
752
- case 1:
753
- pure[0] = w;
754
- pure[1] = 1;
755
- pure[2] = 0;
756
- break;
757
- case 2:
758
- pure[0] = 0;
759
- pure[1] = 1;
760
- pure[2] = v;
761
- break;
762
- case 3:
763
- pure[0] = 0;
764
- pure[1] = w;
765
- pure[2] = 1;
766
- break;
767
- case 4:
768
- pure[0] = v;
769
- pure[1] = 0;
770
- pure[2] = 1;
771
- break;
772
- default:
773
- pure[0] = 1;
774
- pure[1] = 0;
775
- pure[2] = w;
776
- }
777
- mg = (1 - c) * g;
778
- return [
779
- (c * pure[0] + mg) * 255,
780
- (c * pure[1] + mg) * 255,
781
- (c * pure[2] + mg) * 255
782
- ];
783
- };
784
- convert.hcg.hsv = function(hcg) {
785
- const c = hcg[1] / 100;
786
- const g = hcg[2] / 100;
787
- const v = c + g * (1 - c);
788
- let f = 0;
789
- if (v > 0) {
790
- f = c / v;
791
- }
792
- return [hcg[0], f * 100, v * 100];
793
- };
794
- convert.hcg.hsl = function(hcg) {
795
- const c = hcg[1] / 100;
796
- const g = hcg[2] / 100;
797
- const l = g * (1 - c) + 0.5 * c;
798
- let s = 0;
799
- if (l > 0 && l < 0.5) {
800
- s = c / (2 * l);
801
- } else if (l >= 0.5 && l < 1) {
802
- s = c / (2 * (1 - l));
803
- }
804
- return [hcg[0], s * 100, l * 100];
805
- };
806
- convert.hcg.hwb = function(hcg) {
807
- const c = hcg[1] / 100;
808
- const g = hcg[2] / 100;
809
- const v = c + g * (1 - c);
810
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
811
- };
812
- convert.hwb.hcg = function(hwb) {
813
- const w = hwb[1] / 100;
814
- const b = hwb[2] / 100;
815
- const v = 1 - b;
816
- const c = v - w;
817
- let g = 0;
818
- if (c < 1) {
819
- g = (v - c) / (1 - c);
820
- }
821
- return [hwb[0], c * 100, g * 100];
822
- };
823
- convert.apple.rgb = function(apple) {
824
- return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
825
- };
826
- convert.rgb.apple = function(rgb) {
827
- return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
828
- };
829
- convert.gray.rgb = function(args) {
830
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
831
- };
832
- convert.gray.hsl = function(args) {
833
- return [0, 0, args[0]];
834
- };
835
- convert.gray.hsv = convert.gray.hsl;
836
- convert.gray.hwb = function(gray) {
837
- return [0, 100, gray[0]];
838
- };
839
- convert.gray.cmyk = function(gray) {
840
- return [0, 0, 0, gray[0]];
841
- };
842
- convert.gray.lab = function(gray) {
843
- return [gray[0], 0, 0];
844
- };
845
- convert.gray.hex = function(gray) {
846
- const val = Math.round(gray[0] / 100 * 255) & 255;
847
- const integer = (val << 16) + (val << 8) + val;
848
- const string = integer.toString(16).toUpperCase();
849
- return "000000".substring(string.length) + string;
850
- };
851
- convert.rgb.gray = function(rgb) {
852
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
853
- return [val / 255 * 100];
854
- };
855
- return conversions;
856
- }
857
- var route;
858
- var hasRequiredRoute;
859
- function requireRoute() {
860
- if (hasRequiredRoute) return route;
861
- hasRequiredRoute = 1;
862
- const conversions2 = requireConversions();
863
- function buildGraph() {
864
- const graph = {};
865
- const models = Object.keys(conversions2);
866
- for (let len = models.length, i = 0; i < len; i++) {
867
- graph[models[i]] = {
868
- // http://jsperf.com/1-vs-infinity
869
- // micro-opt, but this is simple.
870
- distance: -1,
871
- parent: null
872
- };
873
- }
874
- return graph;
875
- }
876
- function deriveBFS(fromModel) {
877
- const graph = buildGraph();
878
- const queue = [fromModel];
879
- graph[fromModel].distance = 0;
880
- while (queue.length) {
881
- const current = queue.pop();
882
- const adjacents = Object.keys(conversions2[current]);
883
- for (let len = adjacents.length, i = 0; i < len; i++) {
884
- const adjacent = adjacents[i];
885
- const node = graph[adjacent];
886
- if (node.distance === -1) {
887
- node.distance = graph[current].distance + 1;
888
- node.parent = current;
889
- queue.unshift(adjacent);
890
- }
891
- }
892
- }
893
- return graph;
894
- }
895
- function link(from, to) {
896
- return function(args) {
897
- return to(from(args));
898
- };
899
- }
900
- function wrapConversion(toModel, graph) {
901
- const path = [graph[toModel].parent, toModel];
902
- let fn = conversions2[graph[toModel].parent][toModel];
903
- let cur = graph[toModel].parent;
904
- while (graph[cur].parent) {
905
- path.unshift(graph[cur].parent);
906
- fn = link(conversions2[graph[cur].parent][cur], fn);
907
- cur = graph[cur].parent;
908
- }
909
- fn.conversion = path;
910
- return fn;
911
- }
912
- route = function(fromModel) {
913
- const graph = deriveBFS(fromModel);
914
- const conversion = {};
915
- const models = Object.keys(graph);
916
- for (let len = models.length, i = 0; i < len; i++) {
917
- const toModel = models[i];
918
- const node = graph[toModel];
919
- if (node.parent === null) {
920
- continue;
921
- }
922
- conversion[toModel] = wrapConversion(toModel, graph);
923
- }
924
- return conversion;
925
- };
926
- return route;
927
- }
928
- var colorConvert;
929
- var hasRequiredColorConvert;
930
- function requireColorConvert() {
931
- if (hasRequiredColorConvert) return colorConvert;
932
- hasRequiredColorConvert = 1;
933
- const conversions2 = requireConversions();
934
- const route2 = requireRoute();
935
- const convert = {};
936
- const models = Object.keys(conversions2);
937
- function wrapRaw(fn) {
938
- const wrappedFn = function(...args) {
939
- const arg0 = args[0];
940
- if (arg0 === void 0 || arg0 === null) {
941
- return arg0;
942
- }
943
- if (arg0.length > 1) {
944
- args = arg0;
945
- }
946
- return fn(args);
947
- };
948
- if ("conversion" in fn) {
949
- wrappedFn.conversion = fn.conversion;
950
- }
951
- return wrappedFn;
952
- }
953
- function wrapRounded(fn) {
954
- const wrappedFn = function(...args) {
955
- const arg0 = args[0];
956
- if (arg0 === void 0 || arg0 === null) {
957
- return arg0;
958
- }
959
- if (arg0.length > 1) {
960
- args = arg0;
961
- }
962
- const result = fn(args);
963
- if (typeof result === "object") {
964
- for (let len = result.length, i = 0; i < len; i++) {
965
- result[i] = Math.round(result[i]);
966
- }
967
- }
968
- return result;
969
- };
970
- if ("conversion" in fn) {
971
- wrappedFn.conversion = fn.conversion;
972
- }
973
- return wrappedFn;
974
- }
975
- models.forEach((fromModel) => {
976
- convert[fromModel] = {};
977
- Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
978
- Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
979
- const routes = route2(fromModel);
980
- const routeModels = Object.keys(routes);
981
- routeModels.forEach((toModel) => {
982
- const fn = routes[toModel];
983
- convert[fromModel][toModel] = wrapRounded(fn);
984
- convert[fromModel][toModel].raw = wrapRaw(fn);
985
- });
986
- });
987
- colorConvert = convert;
988
- return colorConvert;
989
- }
990
- ansiStyles.exports;
991
- var hasRequiredAnsiStyles;
992
- function requireAnsiStyles() {
993
- if (hasRequiredAnsiStyles) return ansiStyles.exports;
994
- hasRequiredAnsiStyles = 1;
995
- (function(module2) {
996
- const wrapAnsi16 = (fn, offset) => (...args) => {
997
- const code = fn(...args);
998
- return `\x1B[${code + offset}m`;
999
- };
1000
- const wrapAnsi256 = (fn, offset) => (...args) => {
1001
- const code = fn(...args);
1002
- return `\x1B[${38 + offset};5;${code}m`;
1003
- };
1004
- const wrapAnsi16m = (fn, offset) => (...args) => {
1005
- const rgb = fn(...args);
1006
- return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1007
- };
1008
- const ansi2ansi = (n) => n;
1009
- const rgb2rgb = (r, g, b) => [r, g, b];
1010
- const setLazyProperty = (object, property, get) => {
1011
- Object.defineProperty(object, property, {
1012
- get: () => {
1013
- const value = get();
1014
- Object.defineProperty(object, property, {
1015
- value,
1016
- enumerable: true,
1017
- configurable: true
1018
- });
1019
- return value;
1020
- },
1021
- enumerable: true,
1022
- configurable: true
1023
- });
1024
- };
1025
- let colorConvert2;
1026
- const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1027
- if (colorConvert2 === void 0) {
1028
- colorConvert2 = requireColorConvert();
1029
- }
1030
- const offset = isBackground ? 10 : 0;
1031
- const styles = {};
1032
- for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
1033
- const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1034
- if (sourceSpace === targetSpace) {
1035
- styles[name] = wrap(identity, offset);
1036
- } else if (typeof suite === "object") {
1037
- styles[name] = wrap(suite[targetSpace], offset);
1038
- }
1039
- }
1040
- return styles;
1041
- };
1042
- function assembleStyles() {
1043
- const codes = /* @__PURE__ */ new Map();
1044
- const styles = {
1045
- modifier: {
1046
- reset: [0, 0],
1047
- // 21 isn't widely supported and 22 does the same thing
1048
- bold: [1, 22],
1049
- dim: [2, 22],
1050
- italic: [3, 23],
1051
- underline: [4, 24],
1052
- inverse: [7, 27],
1053
- hidden: [8, 28],
1054
- strikethrough: [9, 29]
1055
- },
1056
- color: {
1057
- black: [30, 39],
1058
- red: [31, 39],
1059
- green: [32, 39],
1060
- yellow: [33, 39],
1061
- blue: [34, 39],
1062
- magenta: [35, 39],
1063
- cyan: [36, 39],
1064
- white: [37, 39],
1065
- // Bright color
1066
- blackBright: [90, 39],
1067
- redBright: [91, 39],
1068
- greenBright: [92, 39],
1069
- yellowBright: [93, 39],
1070
- blueBright: [94, 39],
1071
- magentaBright: [95, 39],
1072
- cyanBright: [96, 39],
1073
- whiteBright: [97, 39]
1074
- },
1075
- bgColor: {
1076
- bgBlack: [40, 49],
1077
- bgRed: [41, 49],
1078
- bgGreen: [42, 49],
1079
- bgYellow: [43, 49],
1080
- bgBlue: [44, 49],
1081
- bgMagenta: [45, 49],
1082
- bgCyan: [46, 49],
1083
- bgWhite: [47, 49],
1084
- // Bright color
1085
- bgBlackBright: [100, 49],
1086
- bgRedBright: [101, 49],
1087
- bgGreenBright: [102, 49],
1088
- bgYellowBright: [103, 49],
1089
- bgBlueBright: [104, 49],
1090
- bgMagentaBright: [105, 49],
1091
- bgCyanBright: [106, 49],
1092
- bgWhiteBright: [107, 49]
1093
- }
1094
- };
1095
- styles.color.gray = styles.color.blackBright;
1096
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
1097
- styles.color.grey = styles.color.blackBright;
1098
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
1099
- for (const [groupName, group] of Object.entries(styles)) {
1100
- for (const [styleName, style] of Object.entries(group)) {
1101
- styles[styleName] = {
1102
- open: `\x1B[${style[0]}m`,
1103
- close: `\x1B[${style[1]}m`
1104
- };
1105
- group[styleName] = styles[styleName];
1106
- codes.set(style[0], style[1]);
1107
- }
1108
- Object.defineProperty(styles, groupName, {
1109
- value: group,
1110
- enumerable: false
1111
- });
1112
- }
1113
- Object.defineProperty(styles, "codes", {
1114
- value: codes,
1115
- enumerable: false
1116
- });
1117
- styles.color.close = "\x1B[39m";
1118
- styles.bgColor.close = "\x1B[49m";
1119
- setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
1120
- setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
1121
- setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
1122
- setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
1123
- setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
1124
- setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
1125
- return styles;
1126
- }
1127
- Object.defineProperty(module2, "exports", {
1128
- enumerable: true,
1129
- get: assembleStyles
1130
- });
1131
- })(ansiStyles);
1132
- return ansiStyles.exports;
1133
- }
1134
- var browser;
1135
- var hasRequiredBrowser;
1136
- function requireBrowser() {
1137
- if (hasRequiredBrowser) return browser;
1138
- hasRequiredBrowser = 1;
1139
- browser = {
1140
- stdout: false,
1141
- stderr: false
1142
- };
1143
- return browser;
1144
- }
1145
- var util;
1146
- var hasRequiredUtil;
1147
- function requireUtil() {
1148
- if (hasRequiredUtil) return util;
1149
- hasRequiredUtil = 1;
1150
- const stringReplaceAll = (string, substring, replacer) => {
1151
- let index = string.indexOf(substring);
1152
- if (index === -1) {
1153
- return string;
1154
- }
1155
- const substringLength = substring.length;
1156
- let endIndex = 0;
1157
- let returnValue = "";
1158
- do {
1159
- returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
1160
- endIndex = index + substringLength;
1161
- index = string.indexOf(substring, endIndex);
1162
- } while (index !== -1);
1163
- returnValue += string.substr(endIndex);
1164
- return returnValue;
1165
- };
1166
- const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
1167
- let endIndex = 0;
1168
- let returnValue = "";
1169
- do {
1170
- const gotCR = string[index - 1] === "\r";
1171
- returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1172
- endIndex = index + 1;
1173
- index = string.indexOf("\n", endIndex);
1174
- } while (index !== -1);
1175
- returnValue += string.substr(endIndex);
1176
- return returnValue;
1177
- };
1178
- util = {
1179
- stringReplaceAll,
1180
- stringEncaseCRLFWithFirstIndex
1181
- };
1182
- return util;
1183
- }
1184
- var templates;
1185
- var hasRequiredTemplates;
1186
- function requireTemplates() {
1187
- if (hasRequiredTemplates) return templates;
1188
- hasRequiredTemplates = 1;
1189
- 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;
1190
- const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1191
- const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1192
- const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
1193
- const ESCAPES = /* @__PURE__ */ new Map([
1194
- ["n", "\n"],
1195
- ["r", "\r"],
1196
- ["t", " "],
1197
- ["b", "\b"],
1198
- ["f", "\f"],
1199
- ["v", "\v"],
1200
- ["0", "\0"],
1201
- ["\\", "\\"],
1202
- ["e", "\x1B"],
1203
- ["a", "\x07"]
1204
- ]);
1205
- function unescape2(c) {
1206
- const u = c[0] === "u";
1207
- const bracket = c[1] === "{";
1208
- if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
1209
- return String.fromCharCode(parseInt(c.slice(1), 16));
1210
- }
1211
- if (u && bracket) {
1212
- return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
1213
- }
1214
- return ESCAPES.get(c) || c;
1215
- }
1216
- function parseArguments(name, arguments_) {
1217
- const results = [];
1218
- const chunks = arguments_.trim().split(/\s*,\s*/g);
1219
- let matches;
1220
- for (const chunk of chunks) {
1221
- const number = Number(chunk);
1222
- if (!Number.isNaN(number)) {
1223
- results.push(number);
1224
- } else if (matches = chunk.match(STRING_REGEX)) {
1225
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape2, character) => escape2 ? unescape2(escape2) : character));
1226
- } else {
1227
- throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1228
- }
1229
- }
1230
- return results;
1231
- }
1232
- function parseStyle(style) {
1233
- STYLE_REGEX.lastIndex = 0;
1234
- const results = [];
1235
- let matches;
1236
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
1237
- const name = matches[1];
1238
- if (matches[2]) {
1239
- const args = parseArguments(name, matches[2]);
1240
- results.push([name].concat(args));
1241
- } else {
1242
- results.push([name]);
1243
- }
1244
- }
1245
- return results;
1246
- }
1247
- function buildStyle(chalk2, styles) {
1248
- const enabled = {};
1249
- for (const layer of styles) {
1250
- for (const style of layer.styles) {
1251
- enabled[style[0]] = layer.inverse ? null : style.slice(1);
1252
- }
1253
- }
1254
- let current = chalk2;
1255
- for (const [styleName, styles2] of Object.entries(enabled)) {
1256
- if (!Array.isArray(styles2)) {
1257
- continue;
1258
- }
1259
- if (!(styleName in current)) {
1260
- throw new Error(`Unknown Chalk style: ${styleName}`);
1261
- }
1262
- current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
1263
- }
1264
- return current;
1265
- }
1266
- templates = (chalk2, temporary) => {
1267
- const styles = [];
1268
- const chunks = [];
1269
- let chunk = [];
1270
- temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
1271
- if (escapeCharacter) {
1272
- chunk.push(unescape2(escapeCharacter));
1273
- } else if (style) {
1274
- const string = chunk.join("");
1275
- chunk = [];
1276
- chunks.push(styles.length === 0 ? string : buildStyle(chalk2, styles)(string));
1277
- styles.push({ inverse, styles: parseStyle(style) });
1278
- } else if (close) {
1279
- if (styles.length === 0) {
1280
- throw new Error("Found extraneous } in Chalk template literal");
1281
- }
1282
- chunks.push(buildStyle(chalk2, styles)(chunk.join("")));
1283
- chunk = [];
1284
- styles.pop();
1285
- } else {
1286
- chunk.push(character);
1287
- }
1288
- });
1289
- chunks.push(chunk.join(""));
1290
- if (styles.length > 0) {
1291
- const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
1292
- throw new Error(errMessage);
1293
- }
1294
- return chunks.join("");
1295
- };
1296
- return templates;
1297
- }
1298
- var source;
1299
- var hasRequiredSource;
1300
- function requireSource() {
1301
- if (hasRequiredSource) return source;
1302
- hasRequiredSource = 1;
1303
- const ansiStyles2 = requireAnsiStyles();
1304
- const { stdout: stdoutColor, stderr: stderrColor } = requireBrowser();
1305
- const {
1306
- stringReplaceAll,
1307
- stringEncaseCRLFWithFirstIndex
1308
- } = requireUtil();
1309
- const { isArray } = Array;
1310
- const levelMapping = [
1311
- "ansi",
1312
- "ansi",
1313
- "ansi256",
1314
- "ansi16m"
1315
- ];
1316
- const styles = /* @__PURE__ */ Object.create(null);
1317
- const applyOptions = (object, options = {}) => {
1318
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1319
- throw new Error("The `level` option should be an integer from 0 to 3");
1320
- }
1321
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
1322
- object.level = options.level === void 0 ? colorLevel : options.level;
1323
- };
1324
- class ChalkClass {
1325
- constructor(options) {
1326
- return chalkFactory(options);
1327
- }
1328
- }
1329
- const chalkFactory = (options) => {
1330
- const chalk3 = {};
1331
- applyOptions(chalk3, options);
1332
- chalk3.template = (...arguments_) => chalkTag(chalk3.template, ...arguments_);
1333
- Object.setPrototypeOf(chalk3, Chalk.prototype);
1334
- Object.setPrototypeOf(chalk3.template, chalk3);
1335
- chalk3.template.constructor = () => {
1336
- throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
1337
- };
1338
- chalk3.template.Instance = ChalkClass;
1339
- return chalk3.template;
1340
- };
1341
- function Chalk(options) {
1342
- return chalkFactory(options);
1343
- }
1344
- for (const [styleName, style] of Object.entries(ansiStyles2)) {
1345
- styles[styleName] = {
1346
- get() {
1347
- const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
1348
- Object.defineProperty(this, styleName, { value: builder });
1349
- return builder;
1350
- }
1351
- };
1352
- }
1353
- styles.visible = {
1354
- get() {
1355
- const builder = createBuilder(this, this._styler, true);
1356
- Object.defineProperty(this, "visible", { value: builder });
1357
- return builder;
1358
- }
1359
- };
1360
- const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
1361
- for (const model of usedModels) {
1362
- styles[model] = {
1363
- get() {
1364
- const { level } = this;
1365
- return function(...arguments_) {
1366
- const styler = createStyler(ansiStyles2.color[levelMapping[level]][model](...arguments_), ansiStyles2.color.close, this._styler);
1367
- return createBuilder(this, styler, this._isEmpty);
1368
- };
1369
- }
1370
- };
1371
- }
1372
- for (const model of usedModels) {
1373
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1374
- styles[bgModel] = {
1375
- get() {
1376
- const { level } = this;
1377
- return function(...arguments_) {
1378
- const styler = createStyler(ansiStyles2.bgColor[levelMapping[level]][model](...arguments_), ansiStyles2.bgColor.close, this._styler);
1379
- return createBuilder(this, styler, this._isEmpty);
1380
- };
1381
- }
1382
- };
1383
- }
1384
- const proto = Object.defineProperties(() => {
1385
- }, {
1386
- ...styles,
1387
- level: {
1388
- enumerable: true,
1389
- get() {
1390
- return this._generator.level;
1391
- },
1392
- set(level) {
1393
- this._generator.level = level;
1394
- }
1395
- }
1396
- });
1397
- const createStyler = (open, close, parent) => {
1398
- let openAll;
1399
- let closeAll;
1400
- if (parent === void 0) {
1401
- openAll = open;
1402
- closeAll = close;
1403
- } else {
1404
- openAll = parent.openAll + open;
1405
- closeAll = close + parent.closeAll;
1406
- }
1407
- return {
1408
- open,
1409
- close,
1410
- openAll,
1411
- closeAll,
1412
- parent
1413
- };
1414
- };
1415
- const createBuilder = (self2, _styler, _isEmpty) => {
1416
- const builder = (...arguments_) => {
1417
- if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
1418
- return applyStyle(builder, chalkTag(builder, ...arguments_));
1419
- }
1420
- return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1421
- };
1422
- Object.setPrototypeOf(builder, proto);
1423
- builder._generator = self2;
1424
- builder._styler = _styler;
1425
- builder._isEmpty = _isEmpty;
1426
- return builder;
1427
- };
1428
- const applyStyle = (self2, string) => {
1429
- if (self2.level <= 0 || !string) {
1430
- return self2._isEmpty ? "" : string;
1431
- }
1432
- let styler = self2._styler;
1433
- if (styler === void 0) {
1434
- return string;
1435
- }
1436
- const { openAll, closeAll } = styler;
1437
- if (string.indexOf("\x1B") !== -1) {
1438
- while (styler !== void 0) {
1439
- string = stringReplaceAll(string, styler.close, styler.open);
1440
- styler = styler.parent;
1441
- }
1442
- }
1443
- const lfIndex = string.indexOf("\n");
1444
- if (lfIndex !== -1) {
1445
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1446
- }
1447
- return openAll + string + closeAll;
1448
- };
1449
- let template;
1450
- const chalkTag = (chalk3, ...strings) => {
1451
- const [firstString] = strings;
1452
- if (!isArray(firstString) || !isArray(firstString.raw)) {
1453
- return strings.join(" ");
1454
- }
1455
- const arguments_ = strings.slice(1);
1456
- const parts = [firstString.raw[0]];
1457
- for (let i = 1; i < firstString.length; i++) {
1458
- parts.push(
1459
- String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
1460
- String(firstString.raw[i])
1461
- );
1462
- }
1463
- if (template === void 0) {
1464
- template = requireTemplates();
1465
- }
1466
- return template(chalk3, parts.join(""));
1467
- };
1468
- Object.defineProperties(Chalk.prototype, styles);
1469
- const chalk2 = Chalk();
1470
- chalk2.supportsColor = stdoutColor;
1471
- chalk2.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
1472
- chalk2.stderr.supportsColor = stderrColor;
1473
- source = chalk2;
1474
- return source;
1475
- }
1476
- var sourceExports = requireSource();
1477
- const chalk = /* @__PURE__ */ getDefaultExportFromCjs(sourceExports);
1478
- const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
1479
- var AuthorizeOptionsResponseType = /* @__PURE__ */ ((AuthorizeOptionsResponseType2) => {
1480
- AuthorizeOptionsResponseType2["CODE"] = "code";
1481
- AuthorizeOptionsResponseType2["ID_TOKEN"] = "id_token";
1482
- AuthorizeOptionsResponseType2["TOKEN"] = "token";
1483
- return AuthorizeOptionsResponseType2;
1484
- })(AuthorizeOptionsResponseType || {});
1485
- var AuthorizeOptionsResponseMode = /* @__PURE__ */ ((AuthorizeOptionsResponseMode2) => {
1486
- AuthorizeOptionsResponseMode2["QUERY"] = "query";
1487
- AuthorizeOptionsResponseMode2["FRAGMENT"] = "fragment";
1488
- AuthorizeOptionsResponseMode2["FORM_POST"] = "form_post";
1489
- return AuthorizeOptionsResponseMode2;
1490
- })(AuthorizeOptionsResponseMode || {});
1491
- var OAuthGrantTypes = /* @__PURE__ */ ((OAuthGrantTypes2) => {
1492
- OAuthGrantTypes2["CLIENT_CREDENTIALS"] = "client_credentials";
1493
- OAuthGrantTypes2["AUTHORIZATION_CODE"] = "authorization_code";
1494
- OAuthGrantTypes2["REFRESH_TOKEN"] = "refresh_token";
1495
- return OAuthGrantTypes2;
1496
- })(OAuthGrantTypes || {});
1497
- var IOauth2ListenerCommand = /* @__PURE__ */ ((IOauth2ListenerCommand2) => {
1498
- IOauth2ListenerCommand2["RESTORE_SESSION"] = "RestoreSession";
1499
- IOauth2ListenerCommand2["AUTHORIZE"] = "Authorize";
1500
- IOauth2ListenerCommand2["HANDLE_REDIRECT"] = "HandleRedirect";
1501
- IOauth2ListenerCommand2["LOGOUT"] = "Logout";
1502
- IOauth2ListenerCommand2["AUTHENTICATE_EVENT"] = "AuthenticateEvent";
1503
- IOauth2ListenerCommand2["ERROR"] = "Error";
1504
- IOauth2ListenerCommand2["LOG"] = "__LOG";
1505
- IOauth2ListenerCommand2["UPDATE_INSTRUMENT"] = "__UPDATE_INSTRUMENT";
1506
- IOauth2ListenerCommand2["ID_TOKEN"] = "__ID_TOKEN";
1507
- IOauth2ListenerCommand2["ACCESS_TOKEN"] = "__ACCESS_TOKEN";
1508
- IOauth2ListenerCommand2["COOKIES"] = "__COOKIES";
1509
- IOauth2ListenerCommand2["EXECUTE_REFRESH_TOKEN"] = "__EXECUTE_REFRESH_TOKEN";
1510
- return IOauth2ListenerCommand2;
1511
- })(IOauth2ListenerCommand || {});
1512
- class InvalidTokenError extends Error {
1513
- }
1514
- InvalidTokenError.prototype.name = "InvalidTokenError";
1515
- function b64DecodeUnicode(str) {
1516
- return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
1517
- let code = p.charCodeAt(0).toString(16).toUpperCase();
1518
- if (code.length < 2) {
1519
- code = "0" + code;
1520
- }
1521
- return "%" + code;
1522
- }));
1523
- }
1524
- function base64UrlDecode(str) {
1525
- let output = str.replace(/-/g, "+").replace(/_/g, "/");
1526
- switch (output.length % 4) {
1527
- case 0:
1528
- break;
1529
- case 2:
1530
- output += "==";
1531
- break;
1532
- case 3:
1533
- output += "=";
1534
- break;
1535
- default:
1536
- throw new Error("base64 string is not of the correct length");
1537
- }
1538
- try {
1539
- return b64DecodeUnicode(output);
1540
- } catch (err) {
1541
- return atob(output);
1542
- }
1543
- }
1544
- function jwtDecode(token, options) {
1545
- if (typeof token !== "string") {
1546
- throw new InvalidTokenError("Invalid token specified: must be a string");
1547
- }
1548
- options || (options = {});
1549
- const pos = options.header === true ? 0 : 1;
1550
- const part = token.split(".")[pos];
1551
- if (typeof part !== "string") {
1552
- throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
1553
- }
1554
- let decoded;
1555
- try {
1556
- decoded = base64UrlDecode(part);
1557
- } catch (e) {
1558
- throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`);
1559
- }
1560
- try {
1561
- return JSON.parse(decoded);
1562
- } catch (e) {
1563
- throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`);
1564
- }
1565
- }
1566
- const STSOauth2Store = pinia.defineStore("__sts__STSOauth2Store", {
1567
- state: () => {
1568
- return {
1569
- id_token: null,
1570
- error: null
1571
- };
1572
- },
1573
- actions: {
1574
- UpdateIdToken(id_token) {
1575
- this.id_token = id_token;
1576
- },
1577
- UpdateError(error) {
1578
- if (this.error) {
1579
- this.error.message = error;
1580
- } else {
1581
- this.error = {
1582
- message: error
1583
- };
1584
- }
1585
- }
1586
- },
1587
- getters: {
1588
- LoggedIn: (state) => {
1589
- if (typeof state.id_token === "undefined") {
1590
- return false;
1591
- }
1592
- if (state.id_token === null) {
1593
- return false;
1594
- }
1595
- return true;
1596
- },
1597
- UserDetails: (state) => {
1598
- if (state.id_token) {
1599
- const id_token = state.id_token;
1600
- const decodedIdToken = jwtDecode(id_token);
1601
- return decodedIdToken;
1602
- } else {
1603
- return null;
1604
- }
1605
- }
1606
- }
1607
- /*
1608
- persist: {
1609
- storage: globalThis.sessionStorage
1610
- }
1611
- */
1612
- });
1613
- class STSOAuth2Manager {
1614
- #router = null;
1615
- #STORAGE_AUTHORIZE_OPTIONS_KEY = "authorize_options.stsmda.com.au";
1616
- #aic = null;
1617
- #options;
1618
- #oauth2ManagerPort;
1619
- #messageId = 0;
1620
- #messageHandlers = {};
1621
- // keyed by messageId
1622
- #messageTimeout = 1e4;
1623
- #worker;
1624
- #transactionStore;
1625
- // Transient transaction data used to establish a session via OAuth2 authorize handshake
1626
- #operationSemaphore = false;
1627
- #maxSemaphoreRetries = 100;
1628
- // 100 retries, i.e. allow 100 x 50 = 5000ms to unblock
1629
- #semaphoreRetrySleep = 50;
1630
- // ms
1631
- constructor(app, options) {
1632
- this.#options = options;
1633
- if (!isNode) {
1634
- if (app.config.globalProperties.$sts[stsobservability.STSInstrumentControllerPluginKey]) {
1635
- const STSInstrumentController = app.config.globalProperties.$sts[stsobservability.STSInstrumentControllerPluginKey];
1636
- this.#aic = STSInstrumentController;
1637
- }
1638
- this.#router = app.config.globalProperties.$router;
1639
- }
1640
- if (isNode) {
1641
- this.#transactionStore = new stsvueutils.ClientStorageFactory({ clientStorageType: stsvueutils.ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage();
1642
- } else {
1643
- this.#transactionStore = new stsvueutils.ClientStorageFactory({ clientStorageType: stsvueutils.ClientStorageType.SESSION_STORAGE, usePrefix: false }).GetStorage();
1644
- }
1645
- if (this.#options.workerFactory) {
1646
- this.#worker = this.#options.workerFactory();
1647
- } else {
1648
- throw new Error(`STSOAuth2Manager:constructor: Cannot init STSOAuth2Manager - this.#options.workerFactory not specified`);
1649
- }
1650
- if (!isNode) {
1651
- this.#worker.onmessage = (data) => {
1652
- this.#LogInfoMessage(chalk.green(`this.#worker.onmessage = [${data}]`));
1653
- };
1654
- this.#worker.onerror = (error) => {
1655
- this.#LogInfoMessage(chalk.green(`this.#worker.onerror = [${JSON.stringify(error)}]`));
1656
- };
1657
- }
1658
- let workerMessage;
1659
- if (isNode) {
1660
- const {
1661
- port1: oauth2ManagerPort,
1662
- // this process port
1663
- port2: oauth2WorkerPort
1664
- // worker port
1665
- } = new wt__namespace.MessageChannel();
1666
- this.#oauth2ManagerPort = oauth2ManagerPort;
1667
- workerMessage = {
1668
- workerPort: oauth2WorkerPort,
1669
- options: this.#options.workerOptions
1670
- };
1671
- this.#worker.postMessage(workerMessage, [oauth2WorkerPort]);
1672
- this.#oauth2ManagerPort.on("message", (payload) => {
1673
- this.#ProcessMessageResponse(payload);
1674
- }).unref();
1675
- } else {
1676
- const {
1677
- port1: oauth2ManagerPort,
1678
- // this process port
1679
- port2: oauth2WorkerPort
1680
- // worker port
1681
- } = new MessageChannel();
1682
- this.#oauth2ManagerPort = oauth2ManagerPort;
1683
- workerMessage = {
1684
- workerPort: oauth2WorkerPort,
1685
- options: this.#options.workerOptions
1686
- };
1687
- this.#worker.postMessage(workerMessage, [oauth2WorkerPort]);
1688
- this.#oauth2ManagerPort.onmessage = (data) => {
1689
- this.#ProcessMessageResponse(data.data);
1690
- };
1691
- this.#SetupRoute(app, this.#router);
1692
- }
1693
- }
1694
- #LogDebugMessage(message) {
1695
- this.#options.logger.debug(message);
1696
- }
1697
- #LogInfoMessage(message) {
1698
- this.#options.logger.info(message);
1699
- }
1700
- #LogErrorMessage(message) {
1701
- this.#options.logger.error(message);
1702
- }
1703
- #ProcessMessageResponse = (data) => {
1704
- const messageResponse = data;
1705
- this.#LogDebugMessage(chalk.yellow(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`));
1706
- if (messageResponse.messageId === -1) {
1707
- switch (messageResponse.command) {
1708
- case IOauth2ListenerCommand.AUTHENTICATE_EVENT:
1709
- this.#HandleAuthenticateEvent(messageResponse.payload);
1710
- break;
1711
- case IOauth2ListenerCommand.ERROR:
1712
- this.#HandleErrorEvent(messageResponse.payload);
1713
- break;
1714
- case IOauth2ListenerCommand.LOG:
1715
- this.#HandleLogEvent(messageResponse.payload);
1716
- break;
1717
- case IOauth2ListenerCommand.UPDATE_INSTRUMENT:
1718
- this.#HandleUpdateInstrumentEvent(messageResponse.payload.instrumentName, messageResponse.payload.telemetry);
1719
- break;
1720
- default:
1721
- throw new Error(`ProcessMessageResponse command [${messageResponse.command}] not valid.`);
1722
- }
1723
- } else {
1724
- const callBack = this.#messageHandlers[messageResponse.messageId];
1725
- if (callBack) {
1726
- callBack(messageResponse);
1727
- } else {
1728
- throw new Error(`Message: [${messageResponse.messageId}] does not exists in callBacks.`);
1729
- }
1730
- }
1731
- };
1732
- #PostMessage = (message) => {
1733
- message.messageId = this.#messageId++;
1734
- return new Promise((resolve, reject) => {
1735
- const timeout = setTimeout(() => {
1736
- delete this.#messageHandlers[message.messageId];
1737
- reject(`Message: [${message.messageId}] timeout error after: [${this.#messageTimeout}] ms.`);
1738
- }, this.#messageTimeout);
1739
- this.#messageHandlers[message.messageId] = (response) => {
1740
- clearTimeout(timeout);
1741
- delete this.#messageHandlers[message.messageId];
1742
- this.#LogDebugMessage(chalk.yellow(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`));
1743
- resolve(response);
1744
- };
1745
- this.#LogDebugMessage(chalk.yellow(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`));
1746
- this.#oauth2ManagerPort.postMessage(message);
1747
- });
1748
- };
1749
- #HandleLogEvent = (message) => {
1750
- if (this.#aic) {
1751
- this.#aic.LogEx(message);
1752
- }
1753
- this.#LogDebugMessage(message);
1754
- };
1755
- // UpdateInstrument = (instrumentName: Gauge, telemetry: InstrumentBaseTelemetry): void => {
1756
- #HandleUpdateInstrumentEvent = (instrumentName, telemetry) => {
1757
- if (this.#aic) {
1758
- this.#aic.UpdateInstrument(instrumentName, telemetry);
1759
- }
1760
- };
1761
- #GetStore = () => {
1762
- return STSOauth2Store(this.#options.pinia);
1763
- };
1764
- // Will come from message channel
1765
- #HandleErrorEvent = (error) => {
1766
- if (isNode) ;
1767
- else {
1768
- this.#GetStore().UpdateError({
1769
- // Authorize applications store
1770
- message: error
1771
- });
1772
- setTimeout(() => {
1773
- this.#router.replace(`${this.#options.uriBase}error`);
1774
- }, 0);
1775
- }
1776
- };
1777
- #HandleAuthenticateEvent = (id_token) => {
1778
- if (isNode) ;
1779
- else {
1780
- if (this.#options.authenticateEvent) {
1781
- this.#options.authenticateEvent(id_token);
1782
- }
1783
- this.#GetStore().UpdateIdToken(id_token);
1784
- }
1785
- };
1786
- #SetupRoute = (app, router) => {
1787
- this.#LogDebugMessage(chalk.gray(`STSOAuth2Manager:#SetupRoute`));
1788
- router.beforeEach(async (to, from, next) => {
1789
- const oAuth2Manager = app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey];
1790
- this.#LogDebugMessage(chalk.gray(`beforeEach: from: [${from.path}], to: [${to.path}]`));
1791
- if (this.#GetStore().LoggedIn === false) {
1792
- this.#LogInfoMessage(`Not logged in`);
1793
- if (to.path.localeCompare(`${this.#options.uriBase}authorize`) === 0) {
1794
- this.#LogInfoMessage(`to = ${this.#options.uriBase}authorize`);
1795
- next();
1796
- return;
1797
- } else if (to.path.localeCompare(`${this.#options.uriBase}consent`) === 0) {
1798
- if (this.#GetStore().id_token) {
1799
- next();
1800
- return;
1801
- }
1802
- }
1803
- if (to.path.localeCompare(`${this.#options.uriBase}logout`) === 0) {
1804
- next();
1805
- return;
1806
- }
1807
- if (to.path.localeCompare(`${this.#options.uriBase}error`) === 0) {
1808
- next();
1809
- return;
1810
- }
1811
- if (to.path.localeCompare(`${this.#options.uriBase}config`) === 0) {
1812
- next();
1813
- return;
1814
- }
1815
- if (to.path.localeCompare(`${this.#options.uriBase}redirected`) === 0) {
1816
- next();
1817
- return;
1818
- }
1819
- const str = to.query;
1820
- if (str[stsutils.OAuth2ParameterType.CODE] || str[stsutils.OAuth2ParameterType.ERROR]) {
1821
- this.#LogDebugMessage(chalk.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
1822
- const retVal = await oAuth2Manager.HandleRedirect(str);
1823
- this.#LogDebugMessage(chalk.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
1824
- if (retVal) {
1825
- next({
1826
- path: `${this.#options.uriBase}`,
1827
- replace: true
1828
- });
1829
- return;
1830
- } else {
1831
- next({
1832
- path: `${this.#options.uriBase}error`,
1833
- replace: true
1834
- });
1835
- return;
1836
- }
1837
- }
1838
- this.#LogDebugMessage(`STSOAuth2Manager:#SetupRoute:Restoring session`);
1839
- const sessionRestored = await oAuth2Manager.RestoreSession();
1840
- this.#LogDebugMessage(`STSOAuth2Manager:#SetupRoute:Session restored: [${sessionRestored}]`);
1841
- if (sessionRestored !== true) {
1842
- this.#LogDebugMessage(`STSOAuth2Manager:#SetupRoute:Session not restored - need to authorize`);
1843
- oAuth2Manager.Authorize();
1844
- next();
1845
- return;
1846
- } else {
1847
- next(`${this.#options.uriBase}`);
1848
- return;
1849
- }
1850
- } else {
1851
- if (to.path.localeCompare(`${this.#options.uriBase}consent`) === 0) {
1852
- next(`${this.#options.uriBase}`);
1853
- return;
1854
- }
1855
- if (to.path.localeCompare(`${this.#options.uriBase}authorize`) === 0) {
1856
- next(`${this.#options.uriBase}`);
1857
- return;
1858
- }
1859
- if (to.path.localeCompare(`${this.#options.uriBase}logout`) === 0) {
1860
- next(`${this.#options.uriBase}`);
1861
- return;
1862
- }
1863
- next();
1864
- }
1865
- });
1866
- };
1867
- //@@ this needs to be re-implemented so that access_token never leaves the auth worker
1868
- GetAccessToken = async () => {
1869
- const response = await this.#PostMessage({ command: IOauth2ListenerCommand.ACCESS_TOKEN });
1870
- return response.payload;
1871
- };
1872
- // Update operation protected using operationSemaphore. This may occur when using workers and/or multiple async fetch operations.
1873
- ExecuteRefreshToken = async (retryCount = 0) => {
1874
- if (this.#operationSemaphore === true) {
1875
- if (retryCount > this.#maxSemaphoreRetries) {
1876
- throw new Error(`STSOAuth2Manager:ExecuteRefreshToken:maxSemaphoreRetries: [${this.#maxSemaphoreRetries}] exceeded.`);
1877
- }
1878
- await stsutils.Sleep(this.#semaphoreRetrySleep);
1879
- this.#LogDebugMessage(chalk.cyan(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`));
1880
- return await this.ExecuteRefreshToken(retryCount + 1);
1881
- } else {
1882
- this.#operationSemaphore = true;
1883
- const response = await this.#PostMessage({ command: IOauth2ListenerCommand.EXECUTE_REFRESH_TOKEN });
1884
- this.#operationSemaphore = false;
1885
- return response.payload;
1886
- }
1887
- };
1888
- GetCookies = async () => {
1889
- const response = await this.#PostMessage({ command: IOauth2ListenerCommand.COOKIES });
1890
- return response.payload;
1891
- };
1892
- RestoreSession = async () => {
1893
- try {
1894
- this.#LogDebugMessage(`STSOAuth2Manager:RestoreSession:postMessage: [${IOauth2ListenerCommand.RESTORE_SESSION}]`);
1895
- const response = await this.#PostMessage({ command: IOauth2ListenerCommand.RESTORE_SESSION });
1896
- this.#LogDebugMessage(`STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
1897
- return response.payload;
1898
- } catch (error) {
1899
- this.#LogErrorMessage(chalk.red(`RestoreSession Error: ${error}`));
1900
- return false;
1901
- }
1902
- };
1903
- Authorize = async () => {
1904
- try {
1905
- const response = await this.#PostMessage({ command: IOauth2ListenerCommand.AUTHORIZE });
1906
- this.#transactionStore.set(this.#STORAGE_AUTHORIZE_OPTIONS_KEY, response.payload.authorizeOptions);
1907
- const url = response.payload.url;
1908
- if (!isNode) {
1909
- window.location.replace(url);
1910
- } else {
1911
- return response.payload.authorizeOptionsClientCopy;
1912
- }
1913
- } catch (error) {
1914
- this.#LogErrorMessage(chalk.red(`Authorize Error: ${error}`));
1915
- }
1916
- return {};
1917
- };
1918
- HandleRedirect = async (queryVars) => {
1919
- try {
1920
- this.#LogDebugMessage(chalk.magenta(`STSOAuth2Manager:HandleRedirect`));
1921
- let response = null;
1922
- if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
1923
- const authorizeOptions = this.#transactionStore.get(this.#STORAGE_AUTHORIZE_OPTIONS_KEY);
1924
- this.#transactionStore.remove(this.#STORAGE_AUTHORIZE_OPTIONS_KEY);
1925
- this.#LogDebugMessage(chalk.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
1926
- response = await this.#PostMessage({ command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
1927
- queryVars,
1928
- authorizeOptions
1929
- } });
1930
- } else {
1931
- response = await this.#PostMessage({ command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
1932
- }
1933
- this.#LogDebugMessage(chalk.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
1934
- return response.payload;
1935
- } catch (error) {
1936
- this.#LogErrorMessage(chalk.red(`HandleRedirect Error: ${error}`));
1937
- return false;
1938
- }
1939
- };
1940
- Logout = async () => {
1941
- try {
1942
- const response = await this.#PostMessage({ command: IOauth2ListenerCommand.LOGOUT });
1943
- return response.payload;
1944
- } catch (error) {
1945
- this.#LogErrorMessage(chalk.red(`Logout Error: ${error}`));
1946
- return false;
1947
- }
1948
- };
1949
- InvokeExternalAPI = async () => {
1950
- try {
1951
- const response = await this.#PostMessage({ command: IOauth2ListenerCommand.LOGOUT });
1952
- return response.payload;
1953
- } catch (error) {
1954
- this.#LogErrorMessage(chalk.red(`InvokeExternalAPI Error: ${error}`));
1955
- return null;
1956
- }
1957
- };
1958
- LoggedIn = () => {
1959
- try {
1960
- return this.#GetStore().LoggedIn;
1961
- } catch (error) {
1962
- return false;
1963
- }
1964
- };
1965
- }
1966
- var sha256$2 = { exports: {} };
1967
- function commonjsRequire(path) {
1968
- 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.');
1969
- }
1970
- var core$1 = { exports: {} };
1971
- var core = core$1.exports;
1972
- var hasRequiredCore;
1973
- function requireCore() {
1974
- if (hasRequiredCore) return core$1.exports;
1975
- hasRequiredCore = 1;
1976
- (function(module2, exports3) {
1977
- (function(root, factory) {
1978
- {
1979
- module2.exports = factory();
1980
- }
1981
- })(core, function() {
1982
- var CryptoJS = CryptoJS || (function(Math2, undefined$1) {
1983
- var crypto2;
1984
- if (typeof window !== "undefined" && window.crypto) {
1985
- crypto2 = window.crypto;
1986
- }
1987
- if (typeof self !== "undefined" && self.crypto) {
1988
- crypto2 = self.crypto;
1989
- }
1990
- if (typeof globalThis !== "undefined" && globalThis.crypto) {
1991
- crypto2 = globalThis.crypto;
1992
- }
1993
- if (!crypto2 && typeof window !== "undefined" && window.msCrypto) {
1994
- crypto2 = window.msCrypto;
1995
- }
1996
- if (!crypto2 && typeof commonjsGlobal !== "undefined" && commonjsGlobal.crypto) {
1997
- crypto2 = commonjsGlobal.crypto;
1998
- }
1999
- if (!crypto2 && typeof commonjsRequire === "function") {
2000
- try {
2001
- crypto2 = require("crypto");
2002
- } catch (err) {
2003
- }
2004
- }
2005
- var cryptoSecureRandomInt = function() {
2006
- if (crypto2) {
2007
- if (typeof crypto2.getRandomValues === "function") {
2008
- try {
2009
- return crypto2.getRandomValues(new Uint32Array(1))[0];
2010
- } catch (err) {
2011
- }
2012
- }
2013
- if (typeof crypto2.randomBytes === "function") {
2014
- try {
2015
- return crypto2.randomBytes(4).readInt32LE();
2016
- } catch (err) {
2017
- }
2018
- }
2019
- }
2020
- throw new Error("Native crypto module could not be used to get secure random number.");
2021
- };
2022
- var create = Object.create || /* @__PURE__ */ (function() {
2023
- function F() {
2024
- }
2025
- return function(obj) {
2026
- var subtype;
2027
- F.prototype = obj;
2028
- subtype = new F();
2029
- F.prototype = null;
2030
- return subtype;
2031
- };
2032
- })();
2033
- var C = {};
2034
- var C_lib = C.lib = {};
2035
- var Base = C_lib.Base = /* @__PURE__ */ (function() {
2036
- return {
2037
- /**
2038
- * Creates a new object that inherits from this object.
2039
- *
2040
- * @param {Object} overrides Properties to copy into the new object.
2041
- *
2042
- * @return {Object} The new object.
2043
- *
2044
- * @static
2045
- *
2046
- * @example
2047
- *
2048
- * var MyType = CryptoJS.lib.Base.extend({
2049
- * field: 'value',
2050
- *
2051
- * method: function () {
2052
- * }
2053
- * });
2054
- */
2055
- extend: function(overrides) {
2056
- var subtype = create(this);
2057
- if (overrides) {
2058
- subtype.mixIn(overrides);
2059
- }
2060
- if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
2061
- subtype.init = function() {
2062
- subtype.$super.init.apply(this, arguments);
2063
- };
2064
- }
2065
- subtype.init.prototype = subtype;
2066
- subtype.$super = this;
2067
- return subtype;
2068
- },
2069
- /**
2070
- * Extends this object and runs the init method.
2071
- * Arguments to create() will be passed to init().
2072
- *
2073
- * @return {Object} The new object.
2074
- *
2075
- * @static
2076
- *
2077
- * @example
2078
- *
2079
- * var instance = MyType.create();
2080
- */
2081
- create: function() {
2082
- var instance = this.extend();
2083
- instance.init.apply(instance, arguments);
2084
- return instance;
2085
- },
2086
- /**
2087
- * Initializes a newly created object.
2088
- * Override this method to add some logic when your objects are created.
2089
- *
2090
- * @example
2091
- *
2092
- * var MyType = CryptoJS.lib.Base.extend({
2093
- * init: function () {
2094
- * // ...
2095
- * }
2096
- * });
2097
- */
2098
- init: function() {
2099
- },
2100
- /**
2101
- * Copies properties into this object.
2102
- *
2103
- * @param {Object} properties The properties to mix in.
2104
- *
2105
- * @example
2106
- *
2107
- * MyType.mixIn({
2108
- * field: 'value'
2109
- * });
2110
- */
2111
- mixIn: function(properties) {
2112
- for (var propertyName in properties) {
2113
- if (properties.hasOwnProperty(propertyName)) {
2114
- this[propertyName] = properties[propertyName];
2115
- }
2116
- }
2117
- if (properties.hasOwnProperty("toString")) {
2118
- this.toString = properties.toString;
2119
- }
2120
- },
2121
- /**
2122
- * Creates a copy of this object.
2123
- *
2124
- * @return {Object} The clone.
2125
- *
2126
- * @example
2127
- *
2128
- * var clone = instance.clone();
2129
- */
2130
- clone: function() {
2131
- return this.init.prototype.extend(this);
2132
- }
2133
- };
2134
- })();
2135
- var WordArray = C_lib.WordArray = Base.extend({
2136
- /**
2137
- * Initializes a newly created word array.
2138
- *
2139
- * @param {Array} words (Optional) An array of 32-bit words.
2140
- * @param {number} sigBytes (Optional) The number of significant bytes in the words.
2141
- *
2142
- * @example
2143
- *
2144
- * var wordArray = CryptoJS.lib.WordArray.create();
2145
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
2146
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
2147
- */
2148
- init: function(words, sigBytes) {
2149
- words = this.words = words || [];
2150
- if (sigBytes != undefined$1) {
2151
- this.sigBytes = sigBytes;
2152
- } else {
2153
- this.sigBytes = words.length * 4;
2154
- }
2155
- },
2156
- /**
2157
- * Converts this word array to a string.
2158
- *
2159
- * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
2160
- *
2161
- * @return {string} The stringified word array.
2162
- *
2163
- * @example
2164
- *
2165
- * var string = wordArray + '';
2166
- * var string = wordArray.toString();
2167
- * var string = wordArray.toString(CryptoJS.enc.Utf8);
2168
- */
2169
- toString: function(encoder) {
2170
- return (encoder || Hex).stringify(this);
2171
- },
2172
- /**
2173
- * Concatenates a word array to this word array.
2174
- *
2175
- * @param {WordArray} wordArray The word array to append.
2176
- *
2177
- * @return {WordArray} This word array.
2178
- *
2179
- * @example
2180
- *
2181
- * wordArray1.concat(wordArray2);
2182
- */
2183
- concat: function(wordArray) {
2184
- var thisWords = this.words;
2185
- var thatWords = wordArray.words;
2186
- var thisSigBytes = this.sigBytes;
2187
- var thatSigBytes = wordArray.sigBytes;
2188
- this.clamp();
2189
- if (thisSigBytes % 4) {
2190
- for (var i = 0; i < thatSigBytes; i++) {
2191
- var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
2192
- thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
2193
- }
2194
- } else {
2195
- for (var j = 0; j < thatSigBytes; j += 4) {
2196
- thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
2197
- }
2198
- }
2199
- this.sigBytes += thatSigBytes;
2200
- return this;
2201
- },
2202
- /**
2203
- * Removes insignificant bits.
2204
- *
2205
- * @example
2206
- *
2207
- * wordArray.clamp();
2208
- */
2209
- clamp: function() {
2210
- var words = this.words;
2211
- var sigBytes = this.sigBytes;
2212
- words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
2213
- words.length = Math2.ceil(sigBytes / 4);
2214
- },
2215
- /**
2216
- * Creates a copy of this word array.
2217
- *
2218
- * @return {WordArray} The clone.
2219
- *
2220
- * @example
2221
- *
2222
- * var clone = wordArray.clone();
2223
- */
2224
- clone: function() {
2225
- var clone = Base.clone.call(this);
2226
- clone.words = this.words.slice(0);
2227
- return clone;
2228
- },
2229
- /**
2230
- * Creates a word array filled with random bytes.
2231
- *
2232
- * @param {number} nBytes The number of random bytes to generate.
2233
- *
2234
- * @return {WordArray} The random word array.
2235
- *
2236
- * @static
2237
- *
2238
- * @example
2239
- *
2240
- * var wordArray = CryptoJS.lib.WordArray.random(16);
2241
- */
2242
- random: function(nBytes) {
2243
- var words = [];
2244
- for (var i = 0; i < nBytes; i += 4) {
2245
- words.push(cryptoSecureRandomInt());
2246
- }
2247
- return new WordArray.init(words, nBytes);
2248
- }
2249
- });
2250
- var C_enc = C.enc = {};
2251
- var Hex = C_enc.Hex = {
2252
- /**
2253
- * Converts a word array to a hex string.
2254
- *
2255
- * @param {WordArray} wordArray The word array.
2256
- *
2257
- * @return {string} The hex string.
2258
- *
2259
- * @static
2260
- *
2261
- * @example
2262
- *
2263
- * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
2264
- */
2265
- stringify: function(wordArray) {
2266
- var words = wordArray.words;
2267
- var sigBytes = wordArray.sigBytes;
2268
- var hexChars = [];
2269
- for (var i = 0; i < sigBytes; i++) {
2270
- var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
2271
- hexChars.push((bite >>> 4).toString(16));
2272
- hexChars.push((bite & 15).toString(16));
2273
- }
2274
- return hexChars.join("");
2275
- },
2276
- /**
2277
- * Converts a hex string to a word array.
2278
- *
2279
- * @param {string} hexStr The hex string.
2280
- *
2281
- * @return {WordArray} The word array.
2282
- *
2283
- * @static
2284
- *
2285
- * @example
2286
- *
2287
- * var wordArray = CryptoJS.enc.Hex.parse(hexString);
2288
- */
2289
- parse: function(hexStr) {
2290
- var hexStrLength = hexStr.length;
2291
- var words = [];
2292
- for (var i = 0; i < hexStrLength; i += 2) {
2293
- words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
2294
- }
2295
- return new WordArray.init(words, hexStrLength / 2);
2296
- }
2297
- };
2298
- var Latin1 = C_enc.Latin1 = {
2299
- /**
2300
- * Converts a word array to a Latin1 string.
2301
- *
2302
- * @param {WordArray} wordArray The word array.
2303
- *
2304
- * @return {string} The Latin1 string.
2305
- *
2306
- * @static
2307
- *
2308
- * @example
2309
- *
2310
- * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
2311
- */
2312
- stringify: function(wordArray) {
2313
- var words = wordArray.words;
2314
- var sigBytes = wordArray.sigBytes;
2315
- var latin1Chars = [];
2316
- for (var i = 0; i < sigBytes; i++) {
2317
- var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
2318
- latin1Chars.push(String.fromCharCode(bite));
2319
- }
2320
- return latin1Chars.join("");
2321
- },
2322
- /**
2323
- * Converts a Latin1 string to a word array.
2324
- *
2325
- * @param {string} latin1Str The Latin1 string.
2326
- *
2327
- * @return {WordArray} The word array.
2328
- *
2329
- * @static
2330
- *
2331
- * @example
2332
- *
2333
- * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
2334
- */
2335
- parse: function(latin1Str) {
2336
- var latin1StrLength = latin1Str.length;
2337
- var words = [];
2338
- for (var i = 0; i < latin1StrLength; i++) {
2339
- words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
2340
- }
2341
- return new WordArray.init(words, latin1StrLength);
2342
- }
2343
- };
2344
- var Utf8 = C_enc.Utf8 = {
2345
- /**
2346
- * Converts a word array to a UTF-8 string.
2347
- *
2348
- * @param {WordArray} wordArray The word array.
2349
- *
2350
- * @return {string} The UTF-8 string.
2351
- *
2352
- * @static
2353
- *
2354
- * @example
2355
- *
2356
- * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
2357
- */
2358
- stringify: function(wordArray) {
2359
- try {
2360
- return decodeURIComponent(escape(Latin1.stringify(wordArray)));
2361
- } catch (e) {
2362
- throw new Error("Malformed UTF-8 data");
2363
- }
2364
- },
2365
- /**
2366
- * Converts a UTF-8 string to a word array.
2367
- *
2368
- * @param {string} utf8Str The UTF-8 string.
2369
- *
2370
- * @return {WordArray} The word array.
2371
- *
2372
- * @static
2373
- *
2374
- * @example
2375
- *
2376
- * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
2377
- */
2378
- parse: function(utf8Str) {
2379
- return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
2380
- }
2381
- };
2382
- var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
2383
- /**
2384
- * Resets this block algorithm's data buffer to its initial state.
2385
- *
2386
- * @example
2387
- *
2388
- * bufferedBlockAlgorithm.reset();
2389
- */
2390
- reset: function() {
2391
- this._data = new WordArray.init();
2392
- this._nDataBytes = 0;
2393
- },
2394
- /**
2395
- * Adds new data to this block algorithm's buffer.
2396
- *
2397
- * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
2398
- *
2399
- * @example
2400
- *
2401
- * bufferedBlockAlgorithm._append('data');
2402
- * bufferedBlockAlgorithm._append(wordArray);
2403
- */
2404
- _append: function(data) {
2405
- if (typeof data == "string") {
2406
- data = Utf8.parse(data);
2407
- }
2408
- this._data.concat(data);
2409
- this._nDataBytes += data.sigBytes;
2410
- },
2411
- /**
2412
- * Processes available data blocks.
2413
- *
2414
- * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
2415
- *
2416
- * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
2417
- *
2418
- * @return {WordArray} The processed data.
2419
- *
2420
- * @example
2421
- *
2422
- * var processedData = bufferedBlockAlgorithm._process();
2423
- * var processedData = bufferedBlockAlgorithm._process(!!'flush');
2424
- */
2425
- _process: function(doFlush) {
2426
- var processedWords;
2427
- var data = this._data;
2428
- var dataWords = data.words;
2429
- var dataSigBytes = data.sigBytes;
2430
- var blockSize = this.blockSize;
2431
- var blockSizeBytes = blockSize * 4;
2432
- var nBlocksReady = dataSigBytes / blockSizeBytes;
2433
- if (doFlush) {
2434
- nBlocksReady = Math2.ceil(nBlocksReady);
2435
- } else {
2436
- nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
2437
- }
2438
- var nWordsReady = nBlocksReady * blockSize;
2439
- var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
2440
- if (nWordsReady) {
2441
- for (var offset = 0; offset < nWordsReady; offset += blockSize) {
2442
- this._doProcessBlock(dataWords, offset);
2443
- }
2444
- processedWords = dataWords.splice(0, nWordsReady);
2445
- data.sigBytes -= nBytesReady;
2446
- }
2447
- return new WordArray.init(processedWords, nBytesReady);
2448
- },
2449
- /**
2450
- * Creates a copy of this object.
2451
- *
2452
- * @return {Object} The clone.
2453
- *
2454
- * @example
2455
- *
2456
- * var clone = bufferedBlockAlgorithm.clone();
2457
- */
2458
- clone: function() {
2459
- var clone = Base.clone.call(this);
2460
- clone._data = this._data.clone();
2461
- return clone;
2462
- },
2463
- _minBufferSize: 0
2464
- });
2465
- C_lib.Hasher = BufferedBlockAlgorithm.extend({
2466
- /**
2467
- * Configuration options.
2468
- */
2469
- cfg: Base.extend(),
2470
- /**
2471
- * Initializes a newly created hasher.
2472
- *
2473
- * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
2474
- *
2475
- * @example
2476
- *
2477
- * var hasher = CryptoJS.algo.SHA256.create();
2478
- */
2479
- init: function(cfg) {
2480
- this.cfg = this.cfg.extend(cfg);
2481
- this.reset();
2482
- },
2483
- /**
2484
- * Resets this hasher to its initial state.
2485
- *
2486
- * @example
2487
- *
2488
- * hasher.reset();
2489
- */
2490
- reset: function() {
2491
- BufferedBlockAlgorithm.reset.call(this);
2492
- this._doReset();
2493
- },
2494
- /**
2495
- * Updates this hasher with a message.
2496
- *
2497
- * @param {WordArray|string} messageUpdate The message to append.
2498
- *
2499
- * @return {Hasher} This hasher.
2500
- *
2501
- * @example
2502
- *
2503
- * hasher.update('message');
2504
- * hasher.update(wordArray);
2505
- */
2506
- update: function(messageUpdate) {
2507
- this._append(messageUpdate);
2508
- this._process();
2509
- return this;
2510
- },
2511
- /**
2512
- * Finalizes the hash computation.
2513
- * Note that the finalize operation is effectively a destructive, read-once operation.
2514
- *
2515
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
2516
- *
2517
- * @return {WordArray} The hash.
2518
- *
2519
- * @example
2520
- *
2521
- * var hash = hasher.finalize();
2522
- * var hash = hasher.finalize('message');
2523
- * var hash = hasher.finalize(wordArray);
2524
- */
2525
- finalize: function(messageUpdate) {
2526
- if (messageUpdate) {
2527
- this._append(messageUpdate);
2528
- }
2529
- var hash = this._doFinalize();
2530
- return hash;
2531
- },
2532
- blockSize: 512 / 32,
2533
- /**
2534
- * Creates a shortcut function to a hasher's object interface.
2535
- *
2536
- * @param {Hasher} hasher The hasher to create a helper for.
2537
- *
2538
- * @return {Function} The shortcut function.
2539
- *
2540
- * @static
2541
- *
2542
- * @example
2543
- *
2544
- * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
2545
- */
2546
- _createHelper: function(hasher) {
2547
- return function(message, cfg) {
2548
- return new hasher.init(cfg).finalize(message);
2549
- };
2550
- },
2551
- /**
2552
- * Creates a shortcut function to the HMAC's object interface.
2553
- *
2554
- * @param {Hasher} hasher The hasher to use in this HMAC helper.
2555
- *
2556
- * @return {Function} The shortcut function.
2557
- *
2558
- * @static
2559
- *
2560
- * @example
2561
- *
2562
- * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
2563
- */
2564
- _createHmacHelper: function(hasher) {
2565
- return function(message, key) {
2566
- return new C_algo.HMAC.init(hasher, key).finalize(message);
2567
- };
2568
- }
2569
- });
2570
- var C_algo = C.algo = {};
2571
- return C;
2572
- })(Math);
2573
- return CryptoJS;
2574
- });
2575
- })(core$1);
2576
- return core$1.exports;
2577
- }
2578
- var sha256$1 = sha256$2.exports;
2579
- var hasRequiredSha256;
2580
- function requireSha256() {
2581
- if (hasRequiredSha256) return sha256$2.exports;
2582
- hasRequiredSha256 = 1;
2583
- (function(module2, exports3) {
2584
- (function(root, factory) {
2585
- {
2586
- module2.exports = factory(requireCore());
2587
- }
2588
- })(sha256$1, function(CryptoJS) {
2589
- (function(Math2) {
2590
- var C = CryptoJS;
2591
- var C_lib = C.lib;
2592
- var WordArray = C_lib.WordArray;
2593
- var Hasher = C_lib.Hasher;
2594
- var C_algo = C.algo;
2595
- var H = [];
2596
- var K = [];
2597
- (function() {
2598
- function isPrime(n2) {
2599
- var sqrtN = Math2.sqrt(n2);
2600
- for (var factor = 2; factor <= sqrtN; factor++) {
2601
- if (!(n2 % factor)) {
2602
- return false;
2603
- }
2604
- }
2605
- return true;
2606
- }
2607
- function getFractionalBits(n2) {
2608
- return (n2 - (n2 | 0)) * 4294967296 | 0;
2609
- }
2610
- var n = 2;
2611
- var nPrime = 0;
2612
- while (nPrime < 64) {
2613
- if (isPrime(n)) {
2614
- if (nPrime < 8) {
2615
- H[nPrime] = getFractionalBits(Math2.pow(n, 1 / 2));
2616
- }
2617
- K[nPrime] = getFractionalBits(Math2.pow(n, 1 / 3));
2618
- nPrime++;
2619
- }
2620
- n++;
2621
- }
2622
- })();
2623
- var W = [];
2624
- var SHA256 = C_algo.SHA256 = Hasher.extend({
2625
- _doReset: function() {
2626
- this._hash = new WordArray.init(H.slice(0));
2627
- },
2628
- _doProcessBlock: function(M, offset) {
2629
- var H2 = this._hash.words;
2630
- var a = H2[0];
2631
- var b = H2[1];
2632
- var c = H2[2];
2633
- var d = H2[3];
2634
- var e = H2[4];
2635
- var f = H2[5];
2636
- var g = H2[6];
2637
- var h = H2[7];
2638
- for (var i = 0; i < 64; i++) {
2639
- if (i < 16) {
2640
- W[i] = M[offset + i] | 0;
2641
- } else {
2642
- var gamma0x = W[i - 15];
2643
- var gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
2644
- var gamma1x = W[i - 2];
2645
- var gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
2646
- W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
2647
- }
2648
- var ch = e & f ^ ~e & g;
2649
- var maj = a & b ^ a & c ^ b & c;
2650
- var sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
2651
- var sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
2652
- var t1 = h + sigma1 + ch + K[i] + W[i];
2653
- var t2 = sigma0 + maj;
2654
- h = g;
2655
- g = f;
2656
- f = e;
2657
- e = d + t1 | 0;
2658
- d = c;
2659
- c = b;
2660
- b = a;
2661
- a = t1 + t2 | 0;
2662
- }
2663
- H2[0] = H2[0] + a | 0;
2664
- H2[1] = H2[1] + b | 0;
2665
- H2[2] = H2[2] + c | 0;
2666
- H2[3] = H2[3] + d | 0;
2667
- H2[4] = H2[4] + e | 0;
2668
- H2[5] = H2[5] + f | 0;
2669
- H2[6] = H2[6] + g | 0;
2670
- H2[7] = H2[7] + h | 0;
2671
- },
2672
- _doFinalize: function() {
2673
- var data = this._data;
2674
- var dataWords = data.words;
2675
- var nBitsTotal = this._nDataBytes * 8;
2676
- var nBitsLeft = data.sigBytes * 8;
2677
- dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
2678
- dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math2.floor(nBitsTotal / 4294967296);
2679
- dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
2680
- data.sigBytes = dataWords.length * 4;
2681
- this._process();
2682
- return this._hash;
2683
- },
2684
- clone: function() {
2685
- var clone = Hasher.clone.call(this);
2686
- clone._hash = this._hash.clone();
2687
- return clone;
2688
- }
2689
- });
2690
- C.SHA256 = Hasher._createHelper(SHA256);
2691
- C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
2692
- })(Math);
2693
- return CryptoJS.SHA256;
2694
- });
2695
- })(sha256$2);
2696
- return sha256$2.exports;
2697
- }
2698
- var sha256Exports = requireSha256();
2699
- const sha256 = /* @__PURE__ */ getDefaultExportFromCjs(sha256Exports);
2700
- var encBase64$1 = { exports: {} };
2701
- var encBase64 = encBase64$1.exports;
2702
- var hasRequiredEncBase64;
2703
- function requireEncBase64() {
2704
- if (hasRequiredEncBase64) return encBase64$1.exports;
2705
- hasRequiredEncBase64 = 1;
2706
- (function(module2, exports3) {
2707
- (function(root, factory) {
2708
- {
2709
- module2.exports = factory(requireCore());
2710
- }
2711
- })(encBase64, function(CryptoJS) {
2712
- (function() {
2713
- var C = CryptoJS;
2714
- var C_lib = C.lib;
2715
- var WordArray = C_lib.WordArray;
2716
- var C_enc = C.enc;
2717
- C_enc.Base64 = {
2718
- /**
2719
- * Converts a word array to a Base64 string.
2720
- *
2721
- * @param {WordArray} wordArray The word array.
2722
- *
2723
- * @return {string} The Base64 string.
2724
- *
2725
- * @static
2726
- *
2727
- * @example
2728
- *
2729
- * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
2730
- */
2731
- stringify: function(wordArray) {
2732
- var words = wordArray.words;
2733
- var sigBytes = wordArray.sigBytes;
2734
- var map = this._map;
2735
- wordArray.clamp();
2736
- var base64Chars = [];
2737
- for (var i = 0; i < sigBytes; i += 3) {
2738
- var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
2739
- var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
2740
- var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
2741
- var triplet = byte1 << 16 | byte2 << 8 | byte3;
2742
- for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) {
2743
- base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63));
2744
- }
2745
- }
2746
- var paddingChar = map.charAt(64);
2747
- if (paddingChar) {
2748
- while (base64Chars.length % 4) {
2749
- base64Chars.push(paddingChar);
2750
- }
2751
- }
2752
- return base64Chars.join("");
2753
- },
2754
- /**
2755
- * Converts a Base64 string to a word array.
2756
- *
2757
- * @param {string} base64Str The Base64 string.
2758
- *
2759
- * @return {WordArray} The word array.
2760
- *
2761
- * @static
2762
- *
2763
- * @example
2764
- *
2765
- * var wordArray = CryptoJS.enc.Base64.parse(base64String);
2766
- */
2767
- parse: function(base64Str) {
2768
- var base64StrLength = base64Str.length;
2769
- var map = this._map;
2770
- var reverseMap = this._reverseMap;
2771
- if (!reverseMap) {
2772
- reverseMap = this._reverseMap = [];
2773
- for (var j = 0; j < map.length; j++) {
2774
- reverseMap[map.charCodeAt(j)] = j;
2775
- }
2776
- }
2777
- var paddingChar = map.charAt(64);
2778
- if (paddingChar) {
2779
- var paddingIndex = base64Str.indexOf(paddingChar);
2780
- if (paddingIndex !== -1) {
2781
- base64StrLength = paddingIndex;
2782
- }
2783
- }
2784
- return parseLoop(base64Str, base64StrLength, reverseMap);
2785
- },
2786
- _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
2787
- };
2788
- function parseLoop(base64Str, base64StrLength, reverseMap) {
2789
- var words = [];
2790
- var nBytes = 0;
2791
- for (var i = 0; i < base64StrLength; i++) {
2792
- if (i % 4) {
2793
- var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2;
2794
- var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2;
2795
- var bitsCombined = bits1 | bits2;
2796
- words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8;
2797
- nBytes++;
2798
- }
2799
- }
2800
- return WordArray.create(words, nBytes);
2801
- }
2802
- })();
2803
- return CryptoJS.enc.Base64;
2804
- });
2805
- })(encBase64$1);
2806
- return encBase64$1.exports;
2807
- }
2808
- var encBase64Exports = requireEncBase64();
2809
- const Base64 = /* @__PURE__ */ getDefaultExportFromCjs(encBase64Exports);
2810
- class CryptoUtils {
2811
- #crypto;
2812
- constructor() {
2813
- try {
2814
- this.#crypto = crypto;
2815
- } catch {
2816
- this.#crypto = require("node:crypto");
2817
- }
2818
- }
2819
- DigestMessage = async function(message) {
2820
- const hashDigest = sha256(message);
2821
- return Base64.stringify(hashDigest);
2822
- };
2823
- CreateRandomString = (size = 43) => {
2824
- const randomValues = Array.from(this.#crypto.getRandomValues(new Uint8Array(size)));
2825
- const b64 = btoa(String.fromCharCode(...randomValues));
2826
- return b64;
2827
- };
2828
- }
2829
- class QueryParams {
2830
- DecodeQueryParams = (params) => {
2831
- const retObj = {};
2832
- Object.keys(params).filter((k) => typeof params[k] !== "undefined").map((k) => {
2833
- retObj[decodeURIComponent(k)] = decodeURIComponent(params[k]);
2834
- });
2835
- return retObj;
2836
- };
2837
- CreateQueryParams = (params) => {
2838
- return Object.keys(params).filter((k) => typeof params[k] !== "undefined").map((k) => {
2839
- if (Array.isArray(params[k])) {
2840
- return encodeURIComponent(k) + "=" + encodeURIComponent(params[k].join(" "));
2841
- } else {
2842
- return encodeURIComponent(k) + "=" + encodeURIComponent(params[k]);
2843
- }
2844
- }).join("&");
2845
- };
2846
- _GetQueryParams = (param) => {
2847
- let retVal = {};
2848
- const uri = param.split("?");
2849
- if (uri.length == 2) {
2850
- const vars = uri[1].split("&");
2851
- const getVars = {};
2852
- let tmp;
2853
- vars.forEach(function(v) {
2854
- tmp = v.split("=");
2855
- if (tmp.length == 2) getVars[tmp[0]] = tmp[1];
2856
- });
2857
- retVal = this.DecodeQueryParams(getVars);
2858
- }
2859
- return retVal;
2860
- };
2861
- GetQueryParams = () => {
2862
- return this._GetQueryParams(window.location.href);
2863
- };
2864
- }
2865
- var StatusCodes;
2866
- (function(StatusCodes2) {
2867
- StatusCodes2[StatusCodes2["CONTINUE"] = 100] = "CONTINUE";
2868
- StatusCodes2[StatusCodes2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
2869
- StatusCodes2[StatusCodes2["PROCESSING"] = 102] = "PROCESSING";
2870
- StatusCodes2[StatusCodes2["EARLY_HINTS"] = 103] = "EARLY_HINTS";
2871
- StatusCodes2[StatusCodes2["OK"] = 200] = "OK";
2872
- StatusCodes2[StatusCodes2["CREATED"] = 201] = "CREATED";
2873
- StatusCodes2[StatusCodes2["ACCEPTED"] = 202] = "ACCEPTED";
2874
- StatusCodes2[StatusCodes2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
2875
- StatusCodes2[StatusCodes2["NO_CONTENT"] = 204] = "NO_CONTENT";
2876
- StatusCodes2[StatusCodes2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
2877
- StatusCodes2[StatusCodes2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
2878
- StatusCodes2[StatusCodes2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
2879
- StatusCodes2[StatusCodes2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
2880
- StatusCodes2[StatusCodes2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
2881
- StatusCodes2[StatusCodes2["MOVED_TEMPORARILY"] = 302] = "MOVED_TEMPORARILY";
2882
- StatusCodes2[StatusCodes2["SEE_OTHER"] = 303] = "SEE_OTHER";
2883
- StatusCodes2[StatusCodes2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
2884
- StatusCodes2[StatusCodes2["USE_PROXY"] = 305] = "USE_PROXY";
2885
- StatusCodes2[StatusCodes2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
2886
- StatusCodes2[StatusCodes2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
2887
- StatusCodes2[StatusCodes2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
2888
- StatusCodes2[StatusCodes2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
2889
- StatusCodes2[StatusCodes2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
2890
- StatusCodes2[StatusCodes2["FORBIDDEN"] = 403] = "FORBIDDEN";
2891
- StatusCodes2[StatusCodes2["NOT_FOUND"] = 404] = "NOT_FOUND";
2892
- StatusCodes2[StatusCodes2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
2893
- StatusCodes2[StatusCodes2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
2894
- StatusCodes2[StatusCodes2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
2895
- StatusCodes2[StatusCodes2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
2896
- StatusCodes2[StatusCodes2["CONFLICT"] = 409] = "CONFLICT";
2897
- StatusCodes2[StatusCodes2["GONE"] = 410] = "GONE";
2898
- StatusCodes2[StatusCodes2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
2899
- StatusCodes2[StatusCodes2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
2900
- StatusCodes2[StatusCodes2["REQUEST_TOO_LONG"] = 413] = "REQUEST_TOO_LONG";
2901
- StatusCodes2[StatusCodes2["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG";
2902
- StatusCodes2[StatusCodes2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
2903
- StatusCodes2[StatusCodes2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
2904
- StatusCodes2[StatusCodes2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
2905
- StatusCodes2[StatusCodes2["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
2906
- StatusCodes2[StatusCodes2["INSUFFICIENT_SPACE_ON_RESOURCE"] = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE";
2907
- StatusCodes2[StatusCodes2["METHOD_FAILURE"] = 420] = "METHOD_FAILURE";
2908
- StatusCodes2[StatusCodes2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
2909
- StatusCodes2[StatusCodes2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
2910
- StatusCodes2[StatusCodes2["LOCKED"] = 423] = "LOCKED";
2911
- StatusCodes2[StatusCodes2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
2912
- StatusCodes2[StatusCodes2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
2913
- StatusCodes2[StatusCodes2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
2914
- StatusCodes2[StatusCodes2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
2915
- StatusCodes2[StatusCodes2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
2916
- StatusCodes2[StatusCodes2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
2917
- StatusCodes2[StatusCodes2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
2918
- StatusCodes2[StatusCodes2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
2919
- StatusCodes2[StatusCodes2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
2920
- StatusCodes2[StatusCodes2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
2921
- StatusCodes2[StatusCodes2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
2922
- StatusCodes2[StatusCodes2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
2923
- StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
2924
- StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
2925
- })(StatusCodes || (StatusCodes = {}));
2926
- class STSOAuth2Worker {
2927
- //#storageManager = null;
2928
- #clientSessionStore;
2929
- #cUtils = new CryptoUtils();
2930
- #qParams = new QueryParams();
2931
- #STORAGE_SESSION_KEY = "session.stsmda.com.au";
2932
- //@@#aic = null;
2933
- #oauthWorkerPort;
2934
- #options;
2935
- #logger;
2936
- #agentManager = null;
2937
- constructor(workerPort, options, logger) {
2938
- this.#options = options;
2939
- this.#logger = logger;
2940
- this.#LogDebugMessage(`STSOAuth2Worker:constructor:#options: [${JSON.stringify(this.#options)}]`);
2941
- this.#clientSessionStore = new stsvueutils.ClientStorageFactory({ clientStorageType: stsvueutils.ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage();
2942
- this.#oauthWorkerPort = workerPort;
2943
- this.#LogDebugMessage(`STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(this.#oauthWorkerPort)}]`);
2944
- if (isNode && this.#options.agentOptions) {
2945
- this.#agentManager = new stsutils.AgentManager({
2946
- agentOptions: this.#options.agentOptions,
2947
- httpAgentFactory(options2) {
2948
- return new http.Agent(options2);
2949
- },
2950
- httpsAgentFactory(options2) {
2951
- return new https.Agent(options2);
2952
- }
2953
- });
2954
- }
2955
- this.SetupListener();
2956
- this.#UpdateInstrument(stsobservability.Gauge.LOGGER, {
2957
- LogMessage: `STSOauth2 Plugin - Successfully Loaded`
2958
- });
2959
- }
2960
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2961
- #LogDebugMessage(message) {
2962
- this.#logger.debug(message);
2963
- }
2964
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2965
- #LogInfoMessage(message) {
2966
- this.#logger.info(message);
2967
- }
2968
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2969
- #LogErrorMessage(message) {
2970
- this.#logger.error(message);
2971
- }
2972
- // Attempt to restore a previous session using the STSBroker
2973
- /*
2974
- { parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
2975
- { parameterType: OAuth2ParameterType.SCOPE, errorType: authErrorType.SCOPE_MISMATCH }
2976
- { parameterType: OAuth2ParameterType.REDIRECT_URI, errorType: authErrorType.REDIRECT_URI_MISMATCH },
2977
- { parameterType: OAuth2ParameterType.AUDIENCE, errorType: authErrorType.SCOPE_MISMATCH }
2978
-
2979
- Successful Response
2980
- {
2981
- "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",
2982
- "token_type": "Bearer",
2983
- "expires_in": 3599,
2984
- "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",
2985
- "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",
2986
- "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
2987
- }
2988
-
2989
- Error Response
2990
- {
2991
- "error": "invalid_scope",
2992
- "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",
2993
- "error_codes": [
2994
- 70011
2995
- ],
2996
- "timestamp": "2016-01-09 02:02:12Z",
2997
- }
2998
-
2999
- */
3000
- #HandleAuthenticateEvent = (id_token) => {
3001
- const message = {
3002
- messageId: -1,
3003
- // un-solicited message
3004
- command: IOauth2ListenerCommand.AUTHENTICATE_EVENT
3005
- };
3006
- this.#ProcessCommand(message, id_token);
3007
- };
3008
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3009
- #HandleErrorEvent = (error) => {
3010
- const message = {
3011
- messageId: -1,
3012
- // un-solicited message
3013
- command: IOauth2ListenerCommand.ERROR
3014
- };
3015
- this.#ProcessCommand(message, error);
3016
- };
3017
- #LogMessage = (messageToSend) => {
3018
- const message = {
3019
- messageId: -1,
3020
- // un-solicited message
3021
- command: IOauth2ListenerCommand.LOG
3022
- };
3023
- this.#ProcessCommand(message, messageToSend);
3024
- };
3025
- #GetAccessToken = () => {
3026
- const sessionData = this.#clientSessionStore.get(this.#STORAGE_SESSION_KEY);
3027
- if (sessionData) {
3028
- const tokens = sessionData.tokenResponse;
3029
- return tokens.access_token;
3030
- } else {
3031
- return null;
3032
- }
3033
- };
3034
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3035
- #GetCookies = () => {
3036
- if (isNode) {
3037
- const sessionData = this.#clientSessionStore.get(this.#STORAGE_SESSION_KEY);
3038
- if (sessionData) {
3039
- return sessionData.brokerCookie;
3040
- } else {
3041
- return null;
3042
- }
3043
- } else {
3044
- return null;
3045
- }
3046
- };
3047
- #UpdateInstrument = (instrumentName, telemetry) => {
3048
- const message = {
3049
- messageId: -1,
3050
- // un-solicited message
3051
- command: IOauth2ListenerCommand.UPDATE_INSTRUMENT
3052
- };
3053
- this.#ProcessCommand(message, {
3054
- instrumentName,
3055
- telemetry
3056
- });
3057
- };
3058
- SetupListener = () => {
3059
- this.#oauthWorkerPort.onmessage = async (data) => {
3060
- const auth2ListenerMessage = data.data;
3061
- this.#LogDebugMessage(`STSOAuth2Worker:SetupListener:onmessage: [${auth2ListenerMessage.command}]`);
3062
- switch (auth2ListenerMessage.command) {
3063
- case IOauth2ListenerCommand.RESTORE_SESSION:
3064
- this.#ProcessCommand(auth2ListenerMessage, await this.#RestoreSession());
3065
- break;
3066
- case IOauth2ListenerCommand.AUTHORIZE:
3067
- this.#ProcessCommand(auth2ListenerMessage, await this.#Authorize());
3068
- break;
3069
- case IOauth2ListenerCommand.HANDLE_REDIRECT:
3070
- this.#ProcessCommand(auth2ListenerMessage, await this.#HandleRedirect(auth2ListenerMessage.payload));
3071
- break;
3072
- case IOauth2ListenerCommand.LOGOUT:
3073
- this.#ProcessCommand(auth2ListenerMessage, await this.#Logout());
3074
- break;
3075
- //@@ Need a way of keeping this out of the main thread - should always stay within the worker
3076
- case IOauth2ListenerCommand.ACCESS_TOKEN:
3077
- this.#ProcessCommand(auth2ListenerMessage, await this.#GetAccessToken());
3078
- break;
3079
- case IOauth2ListenerCommand.EXECUTE_REFRESH_TOKEN:
3080
- this.#ProcessCommand(auth2ListenerMessage, await this.#RefreshToken());
3081
- break;
3082
- case IOauth2ListenerCommand.COOKIES:
3083
- this.#ProcessCommand(auth2ListenerMessage, await this.#GetCookies());
3084
- break;
3085
- default:
3086
- throw new Error(`Command: [${auth2ListenerMessage.command}'] not found.`);
3087
- }
3088
- };
3089
- };
3090
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3091
- #ProcessCommand = async (auth2ListenerMessage, response) => {
3092
- const messageResponse = {
3093
- messageId: auth2ListenerMessage.messageId,
3094
- command: auth2ListenerMessage.command,
3095
- payload: response
3096
- };
3097
- this.#oauthWorkerPort.postMessage(messageResponse);
3098
- };
3099
- #RestoreSession = async () => {
3100
- let restoredSessionData = null;
3101
- const sessionData = this.#clientSessionStore.get(this.#STORAGE_SESSION_KEY);
3102
- if (sessionData) {
3103
- restoredSessionData = sessionData.tokenResponse;
3104
- this.#LogInfoMessage("Session restored from client storage.");
3105
- this.#LogMessage("Session restored from client storage.");
3106
- } else {
3107
- const url = `${this.#options.brokerendpoint}:${this.#options.brokerport}${this.#options.brokerapiroot}/session`;
3108
- this.#LogInfoMessage("RestoreSession");
3109
- this.#LogInfoMessage(url);
3110
- this.#LogMessage("RestoreSession.");
3111
- this.#LogMessage(url);
3112
- try {
3113
- const rConfig = new stsutils.STSAxiosConfig(url, "post").withData({
3114
- [stsutils.OAuth2ParameterType.CLIENT_ID]: this.#options.client_id,
3115
- [stsutils.OAuth2ParameterType.SCOPE]: this.#options.scope,
3116
- [stsutils.OAuth2ParameterType.REDIRECT_URI]: this.#options.redirect_uri,
3117
- [stsutils.OAuth2ParameterType.AUDIENCE]: this.#options.audience
3118
- }).withDefaultHeaders().withCredentials().withTimeout(this.#options.timeout);
3119
- this.#LogDebugMessage(chalk.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
3120
- if (isNode && this.#agentManager) {
3121
- rConfig.withAgentManager(this.#agentManager);
3122
- }
3123
- const retVal = await axios(rConfig.config);
3124
- if (retVal.data.status === StatusCodes.OK) {
3125
- restoredSessionData = retVal.data.detail;
3126
- if (restoredSessionData) {
3127
- const newSessionData = {
3128
- tokenResponse: restoredSessionData
3129
- };
3130
- if (isNode) {
3131
- newSessionData.brokerCookie = retVal.headers["set-cookie"];
3132
- }
3133
- this.#clientSessionStore.set(this.#STORAGE_SESSION_KEY, newSessionData);
3134
- this.#LogInfoMessage("Session restored from server side cookie.");
3135
- } else {
3136
- this.#LogErrorMessage(`Could not restore previous session. No restoredSessionData available.`);
3137
- this.#LogErrorMessage(JSON.stringify(retVal.data));
3138
- }
3139
- } else {
3140
- this.#LogErrorMessage("Could not restore previous session:-");
3141
- this.#LogErrorMessage(JSON.stringify(retVal.data));
3142
- }
3143
- } catch (error) {
3144
- this.#LogErrorMessage("Could not restore previous session (error state):-");
3145
- this.#LogErrorMessage(error);
3146
- this.#LogErrorMessage(JSON.stringify(error));
3147
- }
3148
- }
3149
- if (restoredSessionData !== null) {
3150
- this.#HandleAuthenticateEvent(restoredSessionData.id_token);
3151
- this.#LogInfoMessage("Refreshing tokens ...");
3152
- return await this.#RefreshToken();
3153
- } else {
3154
- this.#HandleAuthenticateEvent(null);
3155
- return false;
3156
- }
3157
- };
3158
- #Authorize = async () => {
3159
- this.#LogInfoMessage("Authorize ...");
3160
- const client_id = this.#options.client_id;
3161
- const nonce = this.#cUtils.CreateRandomString();
3162
- const response_type = [AuthorizeOptionsResponseType.CODE];
3163
- const redirect_uri = this.#options.redirect_uri;
3164
- const response_mode = AuthorizeOptionsResponseMode.QUERY;
3165
- const scope = this.#options.scope;
3166
- const state = this.#cUtils.CreateRandomString();
3167
- const code_verifier = this.#cUtils.CreateRandomString();
3168
- const code_challenge = await this.#cUtils.DigestMessage(code_verifier);
3169
- const code_challenge_method = "S256";
3170
- const authorizeOptions = {
3171
- client_id,
3172
- nonce,
3173
- response_type,
3174
- redirect_uri,
3175
- response_mode,
3176
- scope,
3177
- state,
3178
- code_challenge,
3179
- code_challenge_method
3180
- };
3181
- const authorizeOptionsClientCopy = { ...authorizeOptions };
3182
- const url = `${this.#options.authorizeendpoint}:${this.#options.authorizeport}${this.#options.authorizeapiroot}${this.#options.authorizeapi}?${this.#qParams.CreateQueryParams(authorizeOptions)}`;
3183
- this.#LogInfoMessage(url);
3184
- authorizeOptions.code_verifier = code_verifier;
3185
- this.#LogInfoMessage(`Authorize:authorizeOptions: [${JSON.stringify(authorizeOptions)}]`);
3186
- return {
3187
- url,
3188
- authorizeOptions,
3189
- authorizeOptionsClientCopy
3190
- };
3191
- };
3192
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3193
- #HandleRedirect = async (payload) => {
3194
- const queryVars = payload.queryVars;
3195
- const authorizeOptions = payload.authorizeOptions;
3196
- this.#LogDebugMessage(chalk.magenta(`#HandleRedirect: HandleRedirect`));
3197
- this.#LogDebugMessage(chalk.magenta(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`));
3198
- if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
3199
- const response = queryVars;
3200
- this.#LogInfoMessage(`authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
3201
- const redirectState = response.state;
3202
- const authorizeOptionsState = authorizeOptions.state;
3203
- if (authorizeOptionsState.localeCompare(redirectState) === 0) {
3204
- this.#LogInfoMessage(chalk.green("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"));
3205
- return await this.#GetToken(authorizeOptions, response);
3206
- } else {
3207
- this.#LogErrorMessage(chalk.red("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"));
3208
- this.#LogErrorMessage(chalk.red(`authorizeOptionsState: [${authorizeOptionsState}]`));
3209
- this.#LogErrorMessage(chalk.red(`redirectState: [${redirectState}]`));
3210
- this.#HandleErrorEvent({ message: "State un-matched" });
3211
- return false;
3212
- }
3213
- } else if (queryVars[stsutils.OAuth2ParameterType.ERROR]) {
3214
- this.#LogErrorMessage(chalk.red(`State un-matched (1)`));
3215
- this.#HandleErrorEvent({ message: "State un-matched" });
3216
- return false;
3217
- } else {
3218
- this.#LogErrorMessage(chalk.red(`State un-matched (2)`));
3219
- this.#HandleErrorEvent({ message: "State un-matched" });
3220
- return false;
3221
- }
3222
- };
3223
- /*
3224
- client_id=6731de76-14a6-49ae-97bc-6eba6914391e
3225
- &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
3226
- &code=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq3n8b2JRLk4OxVXr...
3227
- &redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
3228
- &grant_type=authorization_code
3229
- &code_verifier=ThisIsntRandomButItNeedsToBe43CharactersLong
3230
- &client_secret=JqQX2PNo9bpM0uEihUPzyrh // NOTE: Only required for web apps. This secret needs to be URL-Encoded.
3231
-
3232
- Successful Response
3233
- {
3234
- "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",
3235
- "token_type": "Bearer",
3236
- "expires_in": 3599,
3237
- "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",
3238
- "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",
3239
- "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
3240
- }
3241
- */
3242
- // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
3243
- #GetTokenFromBroker = async (authorizationCodeFlowParameters) => {
3244
- this.#LogDebugMessage(chalk.magenta(`#GetTokenFromBroker`));
3245
- this.#clientSessionStore.remove(this.#STORAGE_SESSION_KEY);
3246
- const url = `${this.#options.brokerendpoint}:${this.#options.brokerport}${this.#options.brokerapiroot}/token`;
3247
- try {
3248
- const rConfig = new stsutils.STSAxiosConfig(url, "post").withDefaultHeaders().withData(authorizationCodeFlowParameters).withCredentials().withTimeout(this.#options.timeout);
3249
- this.#LogDebugMessage(chalk.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
3250
- if (isNode && this.#agentManager) {
3251
- rConfig.withAgentManager(this.#agentManager);
3252
- }
3253
- this.#LogDebugMessage(chalk.magenta(`#GetTokenFromBroker: axios API call`));
3254
- const retVal = await axios(rConfig.config);
3255
- this.#LogDebugMessage(chalk.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
3256
- if (retVal.status === StatusCodes.OK) {
3257
- this.#LogDebugMessage(chalk.magenta(`#GetTokenFromBroker: storing tokens`));
3258
- const tokenResponse = retVal.data;
3259
- this.#HandleAuthenticateEvent(tokenResponse.id_token);
3260
- const newSessionData = {
3261
- tokenResponse
3262
- };
3263
- if (isNode) {
3264
- newSessionData.brokerCookie = retVal.headers["set-cookie"];
3265
- }
3266
- this.#clientSessionStore.set(this.#STORAGE_SESSION_KEY, newSessionData);
3267
- return true;
3268
- } else if (retVal.status === StatusCodes.UNAUTHORIZED) {
3269
- this.#LogDebugMessage(chalk.magenta(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`));
3270
- this.#HandleAuthenticateEvent(null);
3271
- return false;
3272
- } else {
3273
- this.#LogDebugMessage(chalk.magenta(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`));
3274
- this.#HandleAuthenticateEvent(null);
3275
- this.#LogErrorMessage(chalk.red("Could not obtain access_token from token end-point:-"));
3276
- this.#LogErrorMessage(chalk.red(JSON.stringify(retVal.data)));
3277
- return false;
3278
- }
3279
- } catch (error) {
3280
- this.#LogErrorMessage(chalk.red(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`));
3281
- this.#HandleAuthenticateEvent(null);
3282
- return false;
3283
- }
3284
- };
3285
- // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
3286
- #GetToken = async (authorizeOptions, authorizeResponse) => {
3287
- this.#LogInfoMessage("#GetToken");
3288
- this.#LogInfoMessage(authorizeResponse);
3289
- this.#clientSessionStore.remove(this.#STORAGE_SESSION_KEY);
3290
- const authorizationCodeFlowParameters = {
3291
- client_id: this.#options.client_id,
3292
- scope: this.#options.scope,
3293
- code: authorizeResponse.code,
3294
- redirect_uri: this.#options.redirect_uri,
3295
- grant_type: OAuthGrantTypes.AUTHORIZATION_CODE,
3296
- code_verifier: authorizeOptions.code_verifier
3297
- };
3298
- return await this.#GetTokenFromBroker(authorizationCodeFlowParameters);
3299
- };
3300
- /*
3301
- // Line breaks for legibility only
3302
-
3303
- POST /{tenant}/oauth2/v2.0/token HTTP/1.1
3304
- Host: https://login.microsoftonline.com
3305
- Content-Type: application/x-www-form-urlencoded
3306
-
3307
- client_id=535fb089-9ff3-47b6-9bfb-4f1264799865
3308
- &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
3309
- &refresh_token=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq...
3310
- &grant_type=refresh_token
3311
- &client_secret=sampleCredentia1s // NOTE: Only required for web apps. This secret needs to be URL-Encoded
3312
-
3313
- Error Response
3314
- {
3315
- "error": "invalid_scope",
3316
- "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",
3317
- "error_codes": [
3318
- 70011
3319
- ],
3320
- "timestamp": "2016-01-09 02:02:12Z",
3321
- "trace_id": "255d1aef-8c98-452f-ac51-23d051240864",
3322
- "correlation_id": "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7"
3323
- }
3324
- */
3325
- #RefreshToken = async () => {
3326
- this.#LogDebugMessage(chalk.cyan(`STSOAuth2Worker:#RefreshToken:start`));
3327
- const sessionData = this.#clientSessionStore.get(this.#STORAGE_SESSION_KEY);
3328
- if (sessionData) {
3329
- this.#LogDebugMessage(chalk.cyan(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(sessionData)}]`));
3330
- const currentSessionData = sessionData.tokenResponse;
3331
- const refreshFlowParameters = {
3332
- client_id: this.#options.client_id,
3333
- scope: this.#options.scope,
3334
- refresh_token: currentSessionData.refresh_token,
3335
- grant_type: OAuthGrantTypes.REFRESH_TOKEN
3336
- };
3337
- return await this.#GetTokenFromBroker(refreshFlowParameters);
3338
- } else {
3339
- this.#LogErrorMessage(chalk.red(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`));
3340
- return false;
3341
- }
3342
- };
3343
- // call broker to logout
3344
- // broker to logout of server
3345
- // delete cookie
3346
- // clear session storage
3347
- // clear all state from $store
3348
- #Logout = async () => {
3349
- this.#LogInfoMessage("Logout");
3350
- const url = `${this.#options.brokerendpoint}:${this.#options.brokerport}${this.#options.brokerapiroot}/logout`;
3351
- this.#LogInfoMessage(url);
3352
- const sessionData = this.#clientSessionStore.get(this.#STORAGE_SESSION_KEY);
3353
- if (sessionData) {
3354
- const currentSessionData = sessionData.tokenResponse;
3355
- const refresh_token = currentSessionData.refresh_token;
3356
- this.#LogInfoMessage(refresh_token);
3357
- const decodedRefreshToken = jwtDecode(refresh_token);
3358
- this.#LogInfoMessage(decodedRefreshToken);
3359
- const sessionId = decodedRefreshToken.sts_session;
3360
- this.#LogInfoMessage(sessionId);
3361
- this.#clientSessionStore.remove(this.#STORAGE_SESSION_KEY);
3362
- this.#HandleAuthenticateEvent(null);
3363
- try {
3364
- const rConfig = new stsutils.STSAxiosConfig(url, "post").withData({
3365
- sessionId
3366
- }).withDefaultHeaders().withCredentials().withTimeout(this.#options.timeout);
3367
- if (isNode && this.#agentManager) {
3368
- rConfig.withAgentManager(this.#agentManager);
3369
- }
3370
- this.#LogDebugMessage(chalk.magenta(`#Logout: request config: [${rConfig}]`));
3371
- const retVal = await axios(rConfig.config);
3372
- if (retVal.data.status === StatusCodes.OK) {
3373
- return true;
3374
- } else {
3375
- this.#LogErrorMessage(chalk.red("Error during logout (1: server side)"));
3376
- this.#LogErrorMessage(chalk.red(JSON.stringify(retVal.data)));
3377
- return false;
3378
- }
3379
- } catch (error) {
3380
- this.#LogErrorMessage(chalk.red("Error during logout (2: server side)"));
3381
- this.#LogErrorMessage(chalk.red(error));
3382
- this.#LogErrorMessage(chalk.red(JSON.stringify(error)));
3383
- return false;
3384
- }
3385
- } else {
3386
- this.#LogInfoMessage("Error during logout. Could not restore session from session storage.");
3387
- return false;
3388
- }
3389
- };
3390
- }
3391
- const TestStore = pinia.defineStore("__sts__TestStore", {
3392
- state: () => {
3393
- return {
3394
- count: 0
3395
- };
3396
- },
3397
- actions: {
3398
- UpdateCount() {
3399
- this.count++;
3400
- }
3401
- },
3402
- getters: {
3403
- CountXX: (state) => {
3404
- return state.count * 2;
3405
- }
3406
- }
3407
- /*
3408
- persist: {
3409
- storage: globalThis.sessionStorage
3410
- }
3411
- */
3412
- });
3413
- const useSTSOAuth2ManagerPlugin = () => vue.inject(STSOAuth2ManagerPluginKey);
3414
- const STSOAuth2ManagerPlugin = {
3415
- install: (app, options) => {
3416
- const om = new STSOAuth2Manager(app, options);
3417
- if (!app.config.globalProperties.$sts) {
3418
- app.config.globalProperties.$sts = {};
3419
- }
3420
- app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey] = om;
3421
- app.provide(STSOAuth2ManagerPluginKey, om);
3422
- }
3423
- };
3424
- exports2.AuthorizeOptionsResponseMode = AuthorizeOptionsResponseMode;
3425
- exports2.AuthorizeOptionsResponseType = AuthorizeOptionsResponseType;
3426
- exports2.IOauth2ListenerCommand = IOauth2ListenerCommand;
3427
- exports2.OAuthGrantTypes = OAuthGrantTypes;
3428
- exports2.STSOAuth2Manager = STSOAuth2Manager;
3429
- exports2.STSOAuth2ManagerPlugin = STSOAuth2ManagerPlugin;
3430
- exports2.STSOAuth2ManagerPluginKey = STSOAuth2ManagerPluginKey;
3431
- exports2.STSOAuth2Worker = STSOAuth2Worker;
3432
- exports2.STSOauth2Store = STSOauth2Store;
3433
- exports2.TestStore = TestStore;
3434
- exports2.useSTSOAuth2ManagerPlugin = useSTSOAuth2ManagerPlugin;
3435
- Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
3436
- }));
3437
- //# sourceMappingURL=stsoauth2plugin.umd.js.map