@nsshunt/stsoauth2plugin 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/stsoauth2plugin.mjs +1525 -0
  2. package/dist/stsoauth2plugin.mjs.map +1 -0
  3. package/dist/stsoauth2plugin.umd.js +2 -0
  4. package/dist/stsoauth2plugin.umd.js.map +1 -0
  5. package/package.json +24 -23
  6. package/types/Utils/CryptoUtils.d.ts +1 -1
  7. package/types/Utils/CryptoUtils.d.ts.map +1 -1
  8. package/types/Utils/QueryParams.d.ts +5 -4
  9. package/types/Utils/QueryParams.d.ts.map +1 -1
  10. package/types/index.d.ts.map +1 -1
  11. package/types/stores/stsoauth2store.d.ts +1 -1
  12. package/types/stores/stsoauth2store.d.ts.map +1 -1
  13. package/types/stsoauth2manager.d.ts.map +1 -1
  14. package/types/stsoauth2types.d.ts +1 -1
  15. package/types/stsoauth2types.d.ts.map +1 -1
  16. package/types/stsoauth2worker.d.ts.map +1 -1
  17. package/dist/Utils/CryptoUtils.js +0 -58
  18. package/dist/Utils/CryptoUtils.js.map +0 -1
  19. package/dist/Utils/QueryParams.js +0 -49
  20. package/dist/Utils/QueryParams.js.map +0 -1
  21. package/dist/index.js +0 -44
  22. package/dist/index.js.map +0 -1
  23. package/dist/index.test.js +0 -8
  24. package/dist/index.test.js.map +0 -1
  25. package/dist/stores/stsoauth2store.js +0 -57
  26. package/dist/stores/stsoauth2store.js.map +0 -1
  27. package/dist/stores/testStore.js +0 -32
  28. package/dist/stores/testStore.js.map +0 -1
  29. package/dist/stsPluginKeys.js +0 -6
  30. package/dist/stsPluginKeys.js.map +0 -1
  31. package/dist/stsoauth2launcher.js +0 -10
  32. package/dist/stsoauth2launcher.js.map +0 -1
  33. package/dist/stsoauth2manager.js +0 -455
  34. package/dist/stsoauth2manager.js.map +0 -1
  35. package/dist/stsoauth2types.js +0 -38
  36. package/dist/stsoauth2types.js.map +0 -1
  37. package/dist/stsoauth2worker.js +0 -611
  38. package/dist/stsoauth2worker.js.map +0 -1
@@ -0,0 +1,1525 @@
1
+ var cr = Object.defineProperty;
2
+ var lr = (e, t, o) => t in e ? cr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var D = (e, t, o) => (lr(e, typeof t != "symbol" ? t + "" : t, o), o), We = (e, t, o) => {
4
+ if (!t.has(e))
5
+ throw TypeError("Cannot " + o);
6
+ };
7
+ var r = (e, t, o) => (We(e, t, "read from private field"), o ? o.call(e) : t.get(e)), l = (e, t, o) => {
8
+ if (t.has(e))
9
+ throw TypeError("Cannot add the same private member more than once");
10
+ t instanceof WeakSet ? t.add(e) : t.set(e, o);
11
+ }, k = (e, t, o, n) => (We(e, t, "write to private field"), n ? n.call(e, o) : t.set(e, o), o), Ke = (e, t, o, n) => ({
12
+ set _(a) {
13
+ k(e, t, a, o);
14
+ },
15
+ get _() {
16
+ return r(e, t, n);
17
+ }
18
+ });
19
+ import { inject as hr } from "vue";
20
+ import ce from "debug";
21
+ import * as Er from "node:worker_threads";
22
+ import { OAuth2ParameterType as G, Sleep as ur } from "@nsshunt/stsutils";
23
+ import { ClientStorageFactory as Le, ClientStorageType as be } from "@nsshunt/stsvueutils";
24
+ import { defineStore as qe } from "pinia";
25
+ import { STSInstrumentControllerPluginKey as Ve } from "@nsshunt/stspublisherserver";
26
+ import fr from "node:https";
27
+ import "colors";
28
+ import Me from "axios";
29
+ import { Gauge as gr } from "@nsshunt/stsinstrumentation";
30
+ const ge = Symbol(), M = Object.prototype.toString.call(typeof process < "u" ? process : 0) === "[object process]";
31
+ var Z = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
32
+ function pr(e) {
33
+ if (e.__esModule)
34
+ return e;
35
+ var t = e.default;
36
+ if (typeof t == "function") {
37
+ var o = function n() {
38
+ if (this instanceof n) {
39
+ var a = [null];
40
+ a.push.apply(a, arguments);
41
+ var i = Function.bind.apply(t, a);
42
+ return new i();
43
+ }
44
+ return t.apply(this, arguments);
45
+ };
46
+ o.prototype = t.prototype;
47
+ } else
48
+ o = {};
49
+ return Object.defineProperty(o, "__esModule", { value: !0 }), Object.keys(e).forEach(function(n) {
50
+ var a = Object.getOwnPropertyDescriptor(e, n);
51
+ Object.defineProperty(o, n, a.get ? a : {
52
+ enumerable: !0,
53
+ get: function() {
54
+ return e[n];
55
+ }
56
+ });
57
+ }), o;
58
+ }
59
+ var He = {}, Tr = {
60
+ get exports() {
61
+ return He;
62
+ },
63
+ set exports(e) {
64
+ He = e;
65
+ }
66
+ };
67
+ function _r(e) {
68
+ throw new Error('Could not dynamically require "' + e + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
69
+ }
70
+ var pe = {}, Or = {
71
+ get exports() {
72
+ return pe;
73
+ },
74
+ set exports(e) {
75
+ pe = e;
76
+ }
77
+ };
78
+ const dr = {}, Rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
79
+ __proto__: null,
80
+ default: dr
81
+ }, Symbol.toStringTag, { value: "Module" })), mr = /* @__PURE__ */ pr(Rr);
82
+ var Ye;
83
+ function je() {
84
+ return Ye || (Ye = 1, function(e, t) {
85
+ (function(o, n) {
86
+ e.exports = n();
87
+ })(Z, function() {
88
+ var o = o || function(n, a) {
89
+ var i;
90
+ if (typeof window < "u" && window.crypto && (i = window.crypto), typeof self < "u" && self.crypto && (i = self.crypto), typeof globalThis < "u" && globalThis.crypto && (i = globalThis.crypto), !i && typeof window < "u" && window.msCrypto && (i = window.msCrypto), !i && typeof Z < "u" && Z.crypto && (i = Z.crypto), !i && typeof _r == "function")
91
+ try {
92
+ i = mr;
93
+ } catch {
94
+ }
95
+ var g = function() {
96
+ if (i) {
97
+ if (typeof i.getRandomValues == "function")
98
+ try {
99
+ return i.getRandomValues(new Uint32Array(1))[0];
100
+ } catch {
101
+ }
102
+ if (typeof i.randomBytes == "function")
103
+ try {
104
+ return i.randomBytes(4).readInt32LE();
105
+ } catch {
106
+ }
107
+ }
108
+ throw new Error("Native crypto module could not be used to get secure random number.");
109
+ }, R = Object.create || function() {
110
+ function s() {
111
+ }
112
+ return function(c) {
113
+ var u;
114
+ return s.prototype = c, u = new s(), s.prototype = null, u;
115
+ };
116
+ }(), O = {}, y = O.lib = {}, I = y.Base = function() {
117
+ return {
118
+ /**
119
+ * Creates a new object that inherits from this object.
120
+ *
121
+ * @param {Object} overrides Properties to copy into the new object.
122
+ *
123
+ * @return {Object} The new object.
124
+ *
125
+ * @static
126
+ *
127
+ * @example
128
+ *
129
+ * var MyType = CryptoJS.lib.Base.extend({
130
+ * field: 'value',
131
+ *
132
+ * method: function () {
133
+ * }
134
+ * });
135
+ */
136
+ extend: function(s) {
137
+ var c = R(this);
138
+ return s && c.mixIn(s), (!c.hasOwnProperty("init") || this.init === c.init) && (c.init = function() {
139
+ c.$super.init.apply(this, arguments);
140
+ }), c.init.prototype = c, c.$super = this, c;
141
+ },
142
+ /**
143
+ * Extends this object and runs the init method.
144
+ * Arguments to create() will be passed to init().
145
+ *
146
+ * @return {Object} The new object.
147
+ *
148
+ * @static
149
+ *
150
+ * @example
151
+ *
152
+ * var instance = MyType.create();
153
+ */
154
+ create: function() {
155
+ var s = this.extend();
156
+ return s.init.apply(s, arguments), s;
157
+ },
158
+ /**
159
+ * Initializes a newly created object.
160
+ * Override this method to add some logic when your objects are created.
161
+ *
162
+ * @example
163
+ *
164
+ * var MyType = CryptoJS.lib.Base.extend({
165
+ * init: function () {
166
+ * // ...
167
+ * }
168
+ * });
169
+ */
170
+ init: function() {
171
+ },
172
+ /**
173
+ * Copies properties into this object.
174
+ *
175
+ * @param {Object} properties The properties to mix in.
176
+ *
177
+ * @example
178
+ *
179
+ * MyType.mixIn({
180
+ * field: 'value'
181
+ * });
182
+ */
183
+ mixIn: function(s) {
184
+ for (var c in s)
185
+ s.hasOwnProperty(c) && (this[c] = s[c]);
186
+ s.hasOwnProperty("toString") && (this.toString = s.toString);
187
+ },
188
+ /**
189
+ * Creates a copy of this object.
190
+ *
191
+ * @return {Object} The clone.
192
+ *
193
+ * @example
194
+ *
195
+ * var clone = instance.clone();
196
+ */
197
+ clone: function() {
198
+ return this.init.prototype.extend(this);
199
+ }
200
+ };
201
+ }(), T = y.WordArray = I.extend({
202
+ /**
203
+ * Initializes a newly created word array.
204
+ *
205
+ * @param {Array} words (Optional) An array of 32-bit words.
206
+ * @param {number} sigBytes (Optional) The number of significant bytes in the words.
207
+ *
208
+ * @example
209
+ *
210
+ * var wordArray = CryptoJS.lib.WordArray.create();
211
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
212
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
213
+ */
214
+ init: function(s, c) {
215
+ s = this.words = s || [], c != a ? this.sigBytes = c : this.sigBytes = s.length * 4;
216
+ },
217
+ /**
218
+ * Converts this word array to a string.
219
+ *
220
+ * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
221
+ *
222
+ * @return {string} The stringified word array.
223
+ *
224
+ * @example
225
+ *
226
+ * var string = wordArray + '';
227
+ * var string = wordArray.toString();
228
+ * var string = wordArray.toString(CryptoJS.enc.Utf8);
229
+ */
230
+ toString: function(s) {
231
+ return (s || f).stringify(this);
232
+ },
233
+ /**
234
+ * Concatenates a word array to this word array.
235
+ *
236
+ * @param {WordArray} wordArray The word array to append.
237
+ *
238
+ * @return {WordArray} This word array.
239
+ *
240
+ * @example
241
+ *
242
+ * wordArray1.concat(wordArray2);
243
+ */
244
+ concat: function(s) {
245
+ var c = this.words, u = s.words, p = this.sigBytes, A = s.sigBytes;
246
+ if (this.clamp(), p % 4)
247
+ for (var v = 0; v < A; v++) {
248
+ var U = u[v >>> 2] >>> 24 - v % 4 * 8 & 255;
249
+ c[p + v >>> 2] |= U << 24 - (p + v) % 4 * 8;
250
+ }
251
+ else
252
+ for (var P = 0; P < A; P += 4)
253
+ c[p + P >>> 2] = u[P >>> 2];
254
+ return this.sigBytes += A, this;
255
+ },
256
+ /**
257
+ * Removes insignificant bits.
258
+ *
259
+ * @example
260
+ *
261
+ * wordArray.clamp();
262
+ */
263
+ clamp: function() {
264
+ var s = this.words, c = this.sigBytes;
265
+ s[c >>> 2] &= 4294967295 << 32 - c % 4 * 8, s.length = n.ceil(c / 4);
266
+ },
267
+ /**
268
+ * Creates a copy of this word array.
269
+ *
270
+ * @return {WordArray} The clone.
271
+ *
272
+ * @example
273
+ *
274
+ * var clone = wordArray.clone();
275
+ */
276
+ clone: function() {
277
+ var s = I.clone.call(this);
278
+ return s.words = this.words.slice(0), s;
279
+ },
280
+ /**
281
+ * Creates a word array filled with random bytes.
282
+ *
283
+ * @param {number} nBytes The number of random bytes to generate.
284
+ *
285
+ * @return {WordArray} The random word array.
286
+ *
287
+ * @static
288
+ *
289
+ * @example
290
+ *
291
+ * var wordArray = CryptoJS.lib.WordArray.random(16);
292
+ */
293
+ random: function(s) {
294
+ for (var c = [], u = 0; u < s; u += 4)
295
+ c.push(g());
296
+ return new T.init(c, s);
297
+ }
298
+ }), m = O.enc = {}, f = m.Hex = {
299
+ /**
300
+ * Converts a word array to a hex string.
301
+ *
302
+ * @param {WordArray} wordArray The word array.
303
+ *
304
+ * @return {string} The hex string.
305
+ *
306
+ * @static
307
+ *
308
+ * @example
309
+ *
310
+ * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
311
+ */
312
+ stringify: function(s) {
313
+ for (var c = s.words, u = s.sigBytes, p = [], A = 0; A < u; A++) {
314
+ var v = c[A >>> 2] >>> 24 - A % 4 * 8 & 255;
315
+ p.push((v >>> 4).toString(16)), p.push((v & 15).toString(16));
316
+ }
317
+ return p.join("");
318
+ },
319
+ /**
320
+ * Converts a hex string to a word array.
321
+ *
322
+ * @param {string} hexStr The hex string.
323
+ *
324
+ * @return {WordArray} The word array.
325
+ *
326
+ * @static
327
+ *
328
+ * @example
329
+ *
330
+ * var wordArray = CryptoJS.enc.Hex.parse(hexString);
331
+ */
332
+ parse: function(s) {
333
+ for (var c = s.length, u = [], p = 0; p < c; p += 2)
334
+ u[p >>> 3] |= parseInt(s.substr(p, 2), 16) << 24 - p % 8 * 4;
335
+ return new T.init(u, c / 2);
336
+ }
337
+ }, N = m.Latin1 = {
338
+ /**
339
+ * Converts a word array to a Latin1 string.
340
+ *
341
+ * @param {WordArray} wordArray The word array.
342
+ *
343
+ * @return {string} The Latin1 string.
344
+ *
345
+ * @static
346
+ *
347
+ * @example
348
+ *
349
+ * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
350
+ */
351
+ stringify: function(s) {
352
+ for (var c = s.words, u = s.sigBytes, p = [], A = 0; A < u; A++) {
353
+ var v = c[A >>> 2] >>> 24 - A % 4 * 8 & 255;
354
+ p.push(String.fromCharCode(v));
355
+ }
356
+ return p.join("");
357
+ },
358
+ /**
359
+ * Converts a Latin1 string to a word array.
360
+ *
361
+ * @param {string} latin1Str The Latin1 string.
362
+ *
363
+ * @return {WordArray} The word array.
364
+ *
365
+ * @static
366
+ *
367
+ * @example
368
+ *
369
+ * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
370
+ */
371
+ parse: function(s) {
372
+ for (var c = s.length, u = [], p = 0; p < c; p++)
373
+ u[p >>> 2] |= (s.charCodeAt(p) & 255) << 24 - p % 4 * 8;
374
+ return new T.init(u, c);
375
+ }
376
+ }, E = m.Utf8 = {
377
+ /**
378
+ * Converts a word array to a UTF-8 string.
379
+ *
380
+ * @param {WordArray} wordArray The word array.
381
+ *
382
+ * @return {string} The UTF-8 string.
383
+ *
384
+ * @static
385
+ *
386
+ * @example
387
+ *
388
+ * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
389
+ */
390
+ stringify: function(s) {
391
+ try {
392
+ return decodeURIComponent(escape(N.stringify(s)));
393
+ } catch {
394
+ throw new Error("Malformed UTF-8 data");
395
+ }
396
+ },
397
+ /**
398
+ * Converts a UTF-8 string to a word array.
399
+ *
400
+ * @param {string} utf8Str The UTF-8 string.
401
+ *
402
+ * @return {WordArray} The word array.
403
+ *
404
+ * @static
405
+ *
406
+ * @example
407
+ *
408
+ * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
409
+ */
410
+ parse: function(s) {
411
+ return N.parse(unescape(encodeURIComponent(s)));
412
+ }
413
+ }, _ = y.BufferedBlockAlgorithm = I.extend({
414
+ /**
415
+ * Resets this block algorithm's data buffer to its initial state.
416
+ *
417
+ * @example
418
+ *
419
+ * bufferedBlockAlgorithm.reset();
420
+ */
421
+ reset: function() {
422
+ this._data = new T.init(), this._nDataBytes = 0;
423
+ },
424
+ /**
425
+ * Adds new data to this block algorithm's buffer.
426
+ *
427
+ * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
428
+ *
429
+ * @example
430
+ *
431
+ * bufferedBlockAlgorithm._append('data');
432
+ * bufferedBlockAlgorithm._append(wordArray);
433
+ */
434
+ _append: function(s) {
435
+ typeof s == "string" && (s = E.parse(s)), this._data.concat(s), this._nDataBytes += s.sigBytes;
436
+ },
437
+ /**
438
+ * Processes available data blocks.
439
+ *
440
+ * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
441
+ *
442
+ * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
443
+ *
444
+ * @return {WordArray} The processed data.
445
+ *
446
+ * @example
447
+ *
448
+ * var processedData = bufferedBlockAlgorithm._process();
449
+ * var processedData = bufferedBlockAlgorithm._process(!!'flush');
450
+ */
451
+ _process: function(s) {
452
+ var c, u = this._data, p = u.words, A = u.sigBytes, v = this.blockSize, U = v * 4, P = A / U;
453
+ s ? P = n.ceil(P) : P = n.max((P | 0) - this._minBufferSize, 0);
454
+ var X = P * v, x = n.min(X * 4, A);
455
+ if (X) {
456
+ for (var ae = 0; ae < X; ae += v)
457
+ this._doProcessBlock(p, ae);
458
+ c = p.splice(0, X), u.sigBytes -= x;
459
+ }
460
+ return new T.init(c, x);
461
+ },
462
+ /**
463
+ * Creates a copy of this object.
464
+ *
465
+ * @return {Object} The clone.
466
+ *
467
+ * @example
468
+ *
469
+ * var clone = bufferedBlockAlgorithm.clone();
470
+ */
471
+ clone: function() {
472
+ var s = I.clone.call(this);
473
+ return s._data = this._data.clone(), s;
474
+ },
475
+ _minBufferSize: 0
476
+ });
477
+ y.Hasher = _.extend({
478
+ /**
479
+ * Configuration options.
480
+ */
481
+ cfg: I.extend(),
482
+ /**
483
+ * Initializes a newly created hasher.
484
+ *
485
+ * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
486
+ *
487
+ * @example
488
+ *
489
+ * var hasher = CryptoJS.algo.SHA256.create();
490
+ */
491
+ init: function(s) {
492
+ this.cfg = this.cfg.extend(s), this.reset();
493
+ },
494
+ /**
495
+ * Resets this hasher to its initial state.
496
+ *
497
+ * @example
498
+ *
499
+ * hasher.reset();
500
+ */
501
+ reset: function() {
502
+ _.reset.call(this), this._doReset();
503
+ },
504
+ /**
505
+ * Updates this hasher with a message.
506
+ *
507
+ * @param {WordArray|string} messageUpdate The message to append.
508
+ *
509
+ * @return {Hasher} This hasher.
510
+ *
511
+ * @example
512
+ *
513
+ * hasher.update('message');
514
+ * hasher.update(wordArray);
515
+ */
516
+ update: function(s) {
517
+ return this._append(s), this._process(), this;
518
+ },
519
+ /**
520
+ * Finalizes the hash computation.
521
+ * Note that the finalize operation is effectively a destructive, read-once operation.
522
+ *
523
+ * @param {WordArray|string} messageUpdate (Optional) A final message update.
524
+ *
525
+ * @return {WordArray} The hash.
526
+ *
527
+ * @example
528
+ *
529
+ * var hash = hasher.finalize();
530
+ * var hash = hasher.finalize('message');
531
+ * var hash = hasher.finalize(wordArray);
532
+ */
533
+ finalize: function(s) {
534
+ s && this._append(s);
535
+ var c = this._doFinalize();
536
+ return c;
537
+ },
538
+ blockSize: 16,
539
+ /**
540
+ * Creates a shortcut function to a hasher's object interface.
541
+ *
542
+ * @param {Hasher} hasher The hasher to create a helper for.
543
+ *
544
+ * @return {Function} The shortcut function.
545
+ *
546
+ * @static
547
+ *
548
+ * @example
549
+ *
550
+ * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
551
+ */
552
+ _createHelper: function(s) {
553
+ return function(c, u) {
554
+ return new s.init(u).finalize(c);
555
+ };
556
+ },
557
+ /**
558
+ * Creates a shortcut function to the HMAC's object interface.
559
+ *
560
+ * @param {Hasher} hasher The hasher to use in this HMAC helper.
561
+ *
562
+ * @return {Function} The shortcut function.
563
+ *
564
+ * @static
565
+ *
566
+ * @example
567
+ *
568
+ * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
569
+ */
570
+ _createHmacHelper: function(s) {
571
+ return function(c, u) {
572
+ return new L.HMAC.init(s, u).finalize(c);
573
+ };
574
+ }
575
+ });
576
+ var L = O.algo = {};
577
+ return O;
578
+ }(Math);
579
+ return o;
580
+ });
581
+ }(Or)), pe;
582
+ }
583
+ (function(e, t) {
584
+ (function(o, n) {
585
+ e.exports = n(je());
586
+ })(Z, function(o) {
587
+ return function(n) {
588
+ var a = o, i = a.lib, g = i.WordArray, R = i.Hasher, O = a.algo, y = [], I = [];
589
+ (function() {
590
+ function f(L) {
591
+ for (var s = n.sqrt(L), c = 2; c <= s; c++)
592
+ if (!(L % c))
593
+ return !1;
594
+ return !0;
595
+ }
596
+ function N(L) {
597
+ return (L - (L | 0)) * 4294967296 | 0;
598
+ }
599
+ for (var E = 2, _ = 0; _ < 64; )
600
+ f(E) && (_ < 8 && (y[_] = N(n.pow(E, 1 / 2))), I[_] = N(n.pow(E, 1 / 3)), _++), E++;
601
+ })();
602
+ var T = [], m = O.SHA256 = R.extend({
603
+ _doReset: function() {
604
+ this._hash = new g.init(y.slice(0));
605
+ },
606
+ _doProcessBlock: function(f, N) {
607
+ for (var E = this._hash.words, _ = E[0], L = E[1], s = E[2], c = E[3], u = E[4], p = E[5], A = E[6], v = E[7], U = 0; U < 64; U++) {
608
+ if (U < 16)
609
+ T[U] = f[N + U] | 0;
610
+ else {
611
+ var P = T[U - 15], X = (P << 25 | P >>> 7) ^ (P << 14 | P >>> 18) ^ P >>> 3, x = T[U - 2], ae = (x << 15 | x >>> 17) ^ (x << 13 | x >>> 19) ^ x >>> 10;
612
+ T[U] = X + T[U - 7] + ae + T[U - 16];
613
+ }
614
+ var or = u & p ^ ~u & A, nr = _ & L ^ _ & s ^ L & s, sr = (_ << 30 | _ >>> 2) ^ (_ << 19 | _ >>> 13) ^ (_ << 10 | _ >>> 22), ir = (u << 26 | u >>> 6) ^ (u << 21 | u >>> 11) ^ (u << 7 | u >>> 25), Qe = v + ir + or + I[U] + T[U], ar = sr + nr;
615
+ v = A, A = p, p = u, u = c + Qe | 0, c = s, s = L, L = _, _ = Qe + ar | 0;
616
+ }
617
+ E[0] = E[0] + _ | 0, E[1] = E[1] + L | 0, E[2] = E[2] + s | 0, E[3] = E[3] + c | 0, E[4] = E[4] + u | 0, E[5] = E[5] + p | 0, E[6] = E[6] + A | 0, E[7] = E[7] + v | 0;
618
+ },
619
+ _doFinalize: function() {
620
+ var f = this._data, N = f.words, E = this._nDataBytes * 8, _ = f.sigBytes * 8;
621
+ return N[_ >>> 5] |= 128 << 24 - _ % 32, N[(_ + 64 >>> 9 << 4) + 14] = n.floor(E / 4294967296), N[(_ + 64 >>> 9 << 4) + 15] = E, f.sigBytes = N.length * 4, this._process(), this._hash;
622
+ },
623
+ clone: function() {
624
+ var f = R.clone.call(this);
625
+ return f._hash = this._hash.clone(), f;
626
+ }
627
+ });
628
+ a.SHA256 = R._createHelper(m), a.HmacSHA256 = R._createHmacHelper(m);
629
+ }(Math), o.SHA256;
630
+ });
631
+ })(Tr);
632
+ var Be = {}, yr = {
633
+ get exports() {
634
+ return Be;
635
+ },
636
+ set exports(e) {
637
+ Be = e;
638
+ }
639
+ };
640
+ (function(e, t) {
641
+ (function(o, n) {
642
+ e.exports = n(je());
643
+ })(Z, function(o) {
644
+ return function() {
645
+ var n = o, a = n.lib, i = a.WordArray, g = n.enc;
646
+ g.Base64 = {
647
+ /**
648
+ * Converts a word array to a Base64 string.
649
+ *
650
+ * @param {WordArray} wordArray The word array.
651
+ *
652
+ * @return {string} The Base64 string.
653
+ *
654
+ * @static
655
+ *
656
+ * @example
657
+ *
658
+ * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
659
+ */
660
+ stringify: function(O) {
661
+ var y = O.words, I = O.sigBytes, T = this._map;
662
+ O.clamp();
663
+ for (var m = [], f = 0; f < I; f += 3)
664
+ for (var N = y[f >>> 2] >>> 24 - f % 4 * 8 & 255, E = y[f + 1 >>> 2] >>> 24 - (f + 1) % 4 * 8 & 255, _ = y[f + 2 >>> 2] >>> 24 - (f + 2) % 4 * 8 & 255, L = N << 16 | E << 8 | _, s = 0; s < 4 && f + s * 0.75 < I; s++)
665
+ m.push(T.charAt(L >>> 6 * (3 - s) & 63));
666
+ var c = T.charAt(64);
667
+ if (c)
668
+ for (; m.length % 4; )
669
+ m.push(c);
670
+ return m.join("");
671
+ },
672
+ /**
673
+ * Converts a Base64 string to a word array.
674
+ *
675
+ * @param {string} base64Str The Base64 string.
676
+ *
677
+ * @return {WordArray} The word array.
678
+ *
679
+ * @static
680
+ *
681
+ * @example
682
+ *
683
+ * var wordArray = CryptoJS.enc.Base64.parse(base64String);
684
+ */
685
+ parse: function(O) {
686
+ var y = O.length, I = this._map, T = this._reverseMap;
687
+ if (!T) {
688
+ T = this._reverseMap = [];
689
+ for (var m = 0; m < I.length; m++)
690
+ T[I.charCodeAt(m)] = m;
691
+ }
692
+ var f = I.charAt(64);
693
+ if (f) {
694
+ var N = O.indexOf(f);
695
+ N !== -1 && (y = N);
696
+ }
697
+ return R(O, y, T);
698
+ },
699
+ _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
700
+ };
701
+ function R(O, y, I) {
702
+ for (var T = [], m = 0, f = 0; f < y; f++)
703
+ if (f % 4) {
704
+ var N = I[O.charCodeAt(f - 1)] << f % 4 * 2, E = I[O.charCodeAt(f)] >>> 6 - f % 4 * 2, _ = N | E;
705
+ T[m >>> 2] |= _ << 24 - m % 4 * 8, m++;
706
+ }
707
+ return i.create(T, m);
708
+ }
709
+ }(), o.enc.Base64;
710
+ });
711
+ })(yr);
712
+ var re;
713
+ class Xe {
714
+ constructor() {
715
+ l(this, re, void 0);
716
+ D(this, "DigestMessage", async function(t) {
717
+ const o = He(t);
718
+ return Be.stringify(o);
719
+ });
720
+ D(this, "CreateRandomString", (t = 43) => {
721
+ const o = Array.from(r(this, re).getRandomValues(new Uint8Array(t)));
722
+ return btoa(String.fromCharCode(...o));
723
+ });
724
+ try {
725
+ k(this, re, crypto);
726
+ } catch {
727
+ k(this, re, require("crypto"));
728
+ }
729
+ }
730
+ }
731
+ re = new WeakMap();
732
+ class Ze {
733
+ constructor() {
734
+ D(this, "DecodeQueryParams", (t) => {
735
+ const o = {};
736
+ return Object.keys(t).filter((n) => typeof t[n] < "u").map((n) => {
737
+ o[decodeURIComponent(n)] = decodeURIComponent(t[n]);
738
+ }), o;
739
+ });
740
+ D(this, "CreateQueryParams", (t) => Object.keys(t).filter((o) => typeof t[o] < "u").map((o) => Array.isArray(t[o]) ? encodeURIComponent(o) + "=" + encodeURIComponent(t[o].join(" ")) : encodeURIComponent(o) + "=" + encodeURIComponent(t[o])).join("&"));
741
+ D(this, "_GetQueryParams", (t) => {
742
+ let o = {};
743
+ const n = t.split("?");
744
+ if (n.length == 2) {
745
+ const a = n[1].split("&"), i = {};
746
+ let g;
747
+ a.forEach(function(R) {
748
+ g = R.split("="), g.length == 2 && (i[g[0]] = g[1]);
749
+ }), o = this.DecodeQueryParams(i);
750
+ }
751
+ return o;
752
+ });
753
+ D(this, "GetQueryParams", () => this._GetQueryParams(window.location.href));
754
+ }
755
+ }
756
+ var er = /* @__PURE__ */ ((e) => (e.CODE = "code", e.ID_TOKEN = "id_token", e.TOKEN = "token", e))(er || {}), rr = /* @__PURE__ */ ((e) => (e.QUERY = "query", e.FRAGMENT = "fragment", e.FORM_POST = "form_post", e))(rr || {}), Ce = /* @__PURE__ */ ((e) => (e.CLIENT_CREDENTIALS = "client_credentials", e.AUTHORIZATION_CODE = "authorization_code", e.REFRESH_TOKEN = "refresh_token", e))(Ce || {}), d = /* @__PURE__ */ ((e) => (e.RESTORE_SESSION = "RestoreSession", e.AUTHORIZE = "Authorize", e.HANDLE_REDIRECT = "HandleRedirect", e.LOGOUT = "Logout", e.AUTHENTICATE_EVENT = "AuthenticateEvent", e.ERROR = "Error", e.LOG = "__LOG", e.UPDATE_INSTRUMENT = "__UPDATE_INSTRUMENT", e.ID_TOKEN = "__ID_TOKEN", e.ACCESS_TOKEN = "__ACCESS_TOKEN", e.COOKIES = "__COOKIES", e.EXECUTE_REFRESH_TOKEN = "__EXECUTE_REFRESH_TOKEN", e))(d || {});
757
+ function $e(e) {
758
+ this.message = e;
759
+ }
760
+ $e.prototype = new Error(), $e.prototype.name = "InvalidCharacterError";
761
+ var Je = typeof window < "u" && window.atob && window.atob.bind(window) || function(e) {
762
+ var t = String(e).replace(/=+$/, "");
763
+ if (t.length % 4 == 1)
764
+ throw new $e("'atob' failed: The string to be decoded is not correctly encoded.");
765
+ for (var o, n, a = 0, i = 0, g = ""; n = t.charAt(i++); ~n && (o = a % 4 ? 64 * o + n : n, a++ % 4) ? g += String.fromCharCode(255 & o >> (-2 * a & 6)) : 0)
766
+ n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);
767
+ return g;
768
+ };
769
+ function Ar(e) {
770
+ var t = e.replace(/-/g, "+").replace(/_/g, "/");
771
+ switch (t.length % 4) {
772
+ case 0:
773
+ break;
774
+ case 2:
775
+ t += "==";
776
+ break;
777
+ case 3:
778
+ t += "=";
779
+ break;
780
+ default:
781
+ throw "Illegal base64url string!";
782
+ }
783
+ try {
784
+ return function(o) {
785
+ return decodeURIComponent(Je(o).replace(/(.)/g, function(n, a) {
786
+ var i = a.charCodeAt(0).toString(16).toUpperCase();
787
+ return i.length < 2 && (i = "0" + i), "%" + i;
788
+ }));
789
+ }(t);
790
+ } catch {
791
+ return Je(t);
792
+ }
793
+ }
794
+ function Te(e) {
795
+ this.message = e;
796
+ }
797
+ function tr(e, t) {
798
+ if (typeof e != "string")
799
+ throw new Te("Invalid token specified");
800
+ var o = (t = t || {}).header === !0 ? 0 : 1;
801
+ try {
802
+ return JSON.parse(Ar(e.split(".")[o]));
803
+ } catch (n) {
804
+ throw new Te("Invalid token specified: " + n.message);
805
+ }
806
+ }
807
+ Te.prototype = new Error(), Te.prototype.name = "InvalidTokenError";
808
+ const Sr = qe("__sts__STSOauth2Store", {
809
+ state: () => ({
810
+ id_token: null,
811
+ error: null
812
+ }),
813
+ actions: {
814
+ UpdateIdToken(e) {
815
+ this.id_token = e;
816
+ },
817
+ UpdateError(e) {
818
+ this.error ? this.error.message = e : this.error = {
819
+ message: e
820
+ };
821
+ }
822
+ },
823
+ getters: {
824
+ LoggedIn: (e) => !(typeof e.id_token > "u" || e.id_token === null),
825
+ UserDetails: (e) => {
826
+ if (e.id_token) {
827
+ const t = e.id_token;
828
+ return tr(t);
829
+ } else
830
+ return null;
831
+ }
832
+ }
833
+ /*
834
+ persist: {
835
+ storage: globalThis.sessionStorage
836
+ }
837
+ */
838
+ });
839
+ let w;
840
+ M ? w = ce(`proc:${process.pid}:stsoauth2manager.ts`) : w = ce("proc:0:stsoauth2manager.ts");
841
+ var te, Fe, Ge, oe, xe, z, $, ze, Q, _e, Y, le, W, K, ne, he, Oe, Ee, C, de, Re, V, me, ye, Ae;
842
+ class Ir {
843
+ // ms
844
+ constructor(t, o) {
845
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
846
+ l(this, te, null);
847
+ l(this, Fe, new Xe());
848
+ l(this, Ge, new Ze());
849
+ l(this, oe, "authorize_options.stsmda.com.au");
850
+ l(this, xe, "session.stsmda.com.au");
851
+ l(this, z, null);
852
+ l(this, $, void 0);
853
+ l(this, ze, {});
854
+ l(this, Q, void 0);
855
+ l(this, _e, 0);
856
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
857
+ l(this, Y, {});
858
+ // keyed by messageId
859
+ l(this, le, 1e4);
860
+ l(this, W, void 0);
861
+ l(this, K, void 0);
862
+ // Transient transaction data used to establish a session via OAuth2 authorize handshake
863
+ l(this, ne, !1);
864
+ l(this, he, 100);
865
+ // 100 retries, i.e. allow 100 x 50 = 5000ms to unblock
866
+ l(this, Oe, 50);
867
+ l(this, Ee, (t) => {
868
+ const o = t;
869
+ if (w(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(o)}]`.yellow), o.messageId === -1)
870
+ switch (o.command) {
871
+ case d.AUTHENTICATE_EVENT:
872
+ r(this, ye).call(this, o.payload);
873
+ break;
874
+ case d.ERROR:
875
+ r(this, me).call(this, o.payload);
876
+ break;
877
+ case d.LOG:
878
+ r(this, de).call(this, o.payload);
879
+ break;
880
+ case d.UPDATE_INSTRUMENT:
881
+ r(this, Re).call(this, o.payload.instrumentName, o.payload.telemetry);
882
+ break;
883
+ default:
884
+ throw new Error(`ProcessMessageResponse command [${o.command}] not valid.`);
885
+ }
886
+ else {
887
+ const n = r(this, Y)[o.messageId];
888
+ if (n)
889
+ n(o);
890
+ else
891
+ throw new Error(`Message: [${o.messageId}] does not exists in callBacks.`);
892
+ }
893
+ });
894
+ l(this, C, (t) => (t.messageId = Ke(this, _e)._++, new Promise((o, n) => {
895
+ const a = setTimeout(() => {
896
+ delete r(this, Y)[t.messageId], n(`Message: [${t.messageId}] timeout error after: [${r(this, le)}] ms.`);
897
+ }, r(this, le));
898
+ r(this, Y)[t.messageId] = (i) => {
899
+ clearTimeout(a), delete r(this, Y)[t.messageId], w(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(i)}]`.yellow), o(i);
900
+ }, w(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(t)}]`.yellow), r(this, Q).postMessage(t);
901
+ })));
902
+ l(this, de, (t) => {
903
+ r(this, z) && r(this, z).LogEx(t), w(t);
904
+ });
905
+ // UpdateInstrument = (instrumentName: Gauge, telemetry: InstrumentBaseTelemetry): void => {
906
+ l(this, Re, (t, o) => {
907
+ r(this, z) && r(this, z).UpdateInstrument(t, o);
908
+ });
909
+ l(this, V, () => Sr(r(this, $).pinia));
910
+ // Will come from message channel
911
+ l(this, me, (t) => {
912
+ M || (r(this, V).call(this).UpdateError({
913
+ // Authorize applications store
914
+ message: t
915
+ }), setTimeout(() => {
916
+ r(this, te).replace("/error");
917
+ }, 0));
918
+ });
919
+ l(this, ye, (t) => {
920
+ M || (r(this, $).authenticateEvent && r(this, $).authenticateEvent(t), r(this, V).call(this).UpdateIdToken(t));
921
+ });
922
+ l(this, Ae, (t, o) => {
923
+ w("STSOAuth2Manager:#SetupRoute".gray), o.beforeEach(async (n, a, i) => {
924
+ const g = t.config.globalProperties.$sts[ge];
925
+ if (w(`beforeEach: from: [${a.path}], to: [${n.path}]`.gray), r(this, V).call(this).LoggedIn === !1) {
926
+ if (console.log("Not logged in"), n.path.localeCompare("/authorize") === 0) {
927
+ console.log("to = /authorize"), i();
928
+ return;
929
+ } else if (n.path.localeCompare("/consent") === 0 && r(this, V).call(this).id_token) {
930
+ i();
931
+ return;
932
+ }
933
+ if (n.path.localeCompare("/logout") === 0) {
934
+ i();
935
+ return;
936
+ }
937
+ if (n.path.localeCompare("/error") === 0) {
938
+ i();
939
+ return;
940
+ }
941
+ if (n.path.localeCompare("/config") === 0) {
942
+ i();
943
+ return;
944
+ }
945
+ if (n.path.localeCompare("/redirected") === 0) {
946
+ i();
947
+ return;
948
+ }
949
+ const R = n.query;
950
+ if (R[G.CODE] || R[G.ERROR]) {
951
+ w(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(R)}]`.magenta);
952
+ const y = await g.HandleRedirect(R);
953
+ if (w(`STSOAuth2Manager:#SetupRoute:Redirect result: [${y}]`.magenta), y) {
954
+ i({
955
+ path: "/",
956
+ replace: !0
957
+ });
958
+ return;
959
+ } else {
960
+ i({
961
+ path: "/error",
962
+ replace: !0
963
+ });
964
+ return;
965
+ }
966
+ }
967
+ w("STSOAuth2Manager:#SetupRoute:Restoring session");
968
+ const O = await g.RestoreSession();
969
+ if (w(`STSOAuth2Manager:#SetupRoute:Session restored: [${O}]`), O !== !0) {
970
+ w("STSOAuth2Manager:#SetupRoute:Session not restored - need to authorize"), g.Authorize(), i();
971
+ return;
972
+ } else {
973
+ i("/");
974
+ return;
975
+ }
976
+ } else {
977
+ if (n.path.localeCompare("/consent") === 0) {
978
+ i("/");
979
+ return;
980
+ }
981
+ if (n.path.localeCompare("/authorize") === 0) {
982
+ i("/");
983
+ return;
984
+ }
985
+ if (n.path.localeCompare("/logout") === 0) {
986
+ i("/");
987
+ return;
988
+ }
989
+ i();
990
+ }
991
+ });
992
+ });
993
+ //@@ this needs to be re-implemented so that access_token never leaves the auth worker
994
+ D(this, "GetAccessToken", async () => (await r(this, C).call(this, { command: d.ACCESS_TOKEN })).payload);
995
+ // Update operation protected using operationSemaphore. This may occur when using workers and/or multiple async fetch operations.
996
+ D(this, "ExecuteRefreshToken", async (t = 0) => {
997
+ if (r(this, ne) === !0) {
998
+ if (t > r(this, he))
999
+ throw new Error(`STSOAuth2Manager:ExecuteRefreshToken:maxSemaphoreRetries: [${r(this, he)}] exceeded.`);
1000
+ return await ur(r(this, Oe)), w(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${t}]`.cyan), await this.ExecuteRefreshToken(t + 1);
1001
+ } else {
1002
+ k(this, ne, !0);
1003
+ const o = await r(this, C).call(this, { command: d.EXECUTE_REFRESH_TOKEN });
1004
+ return k(this, ne, !1), o.payload;
1005
+ }
1006
+ });
1007
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1008
+ D(this, "GetCookies", async () => (await r(this, C).call(this, { command: d.COOKIES })).payload);
1009
+ D(this, "RestoreSession", async () => {
1010
+ try {
1011
+ w(`STSOAuth2Manager:RestoreSession:postMessage: [${d.RESTORE_SESSION}]`);
1012
+ const t = await r(this, C).call(this, { command: d.RESTORE_SESSION });
1013
+ return w(`STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(t.payload)}]`), t.payload;
1014
+ } catch (t) {
1015
+ return console.log(`RestoreSession Error: ${t}`), !1;
1016
+ }
1017
+ });
1018
+ D(this, "Authorize", async () => {
1019
+ try {
1020
+ const t = await r(this, C).call(this, { command: d.AUTHORIZE });
1021
+ r(this, K).set(r(this, oe), t.payload.authorizeOptions);
1022
+ const o = t.payload.url;
1023
+ if (!M)
1024
+ window.location.replace(o);
1025
+ else
1026
+ return t.payload.authorizeOptionsClientCopy;
1027
+ } catch (t) {
1028
+ console.log(`Authorize Error: ${t}`);
1029
+ }
1030
+ return {};
1031
+ });
1032
+ D(this, "HandleRedirect", async (t) => {
1033
+ try {
1034
+ w("STSOAuth2Manager:HandleRedirect".magenta);
1035
+ let o = null;
1036
+ if (t[G.CODE]) {
1037
+ const n = r(this, K).get(r(this, oe));
1038
+ r(this, K).remove(r(this, oe)), w("STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command".magenta), o = await r(this, C).call(this, { command: d.HANDLE_REDIRECT, payload: {
1039
+ queryVars: t,
1040
+ authorizeOptions: n
1041
+ } });
1042
+ } else
1043
+ o = await r(this, C).call(this, { command: d.HANDLE_REDIRECT, payload: t });
1044
+ return w(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(o)}]`.magenta), o.payload;
1045
+ } catch (o) {
1046
+ return console.log(`HandleRedirect Error: ${o}`), !1;
1047
+ }
1048
+ });
1049
+ D(this, "Logout", async () => {
1050
+ try {
1051
+ return (await r(this, C).call(this, { command: d.LOGOUT })).payload;
1052
+ } catch (t) {
1053
+ return console.log(`Logout Error: ${t}`), !1;
1054
+ }
1055
+ });
1056
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1057
+ D(this, "InvokeExternalAPI", async () => {
1058
+ try {
1059
+ return (await r(this, C).call(this, { command: d.LOGOUT })).payload;
1060
+ } catch (t) {
1061
+ return console.log(`InvokeExternalAPI Error: ${t}`), null;
1062
+ }
1063
+ });
1064
+ D(this, "LoggedIn", () => {
1065
+ try {
1066
+ return r(this, V).call(this).LoggedIn;
1067
+ } catch {
1068
+ return !1;
1069
+ }
1070
+ });
1071
+ if (k(this, $, o), !M) {
1072
+ if (t.config.globalProperties.$sts[Ve]) {
1073
+ const a = t.config.globalProperties.$sts[Ve];
1074
+ k(this, z, a.PrimaryPublishInstrumentController);
1075
+ }
1076
+ k(this, te, t.config.globalProperties.$router);
1077
+ }
1078
+ if (M ? k(this, K, new Le({ clientStorageType: be.MEMORY_STORAGE, usePrefix: !1 }).GetStorage()) : k(this, K, new Le({ clientStorageType: be.SESSION_STORAGE, usePrefix: !1 }).GetStorage()), r(this, $).workerFactory)
1079
+ k(this, W, r(this, $).workerFactory());
1080
+ else
1081
+ throw new Error("STSOAuth2Manager:constructor: Cannot init STSOAuth2Manager - this.#options.workerFactory not specified");
1082
+ M || (r(this, W).onmessage = (a) => {
1083
+ console.log(`this.#worker.onmessage = [${a}]`);
1084
+ }, r(this, W).onerror = function(a) {
1085
+ console.log(`this.#worker.onerror = [${JSON.stringify(a)}]`);
1086
+ });
1087
+ let n;
1088
+ if (M) {
1089
+ const {
1090
+ port1: a,
1091
+ // this process port
1092
+ port2: i
1093
+ // worker port
1094
+ } = new Er.MessageChannel();
1095
+ k(this, Q, a), n = {
1096
+ workerPort: i,
1097
+ options: r(this, $).workerOptions
1098
+ }, r(this, W).postMessage(n, [i]), r(this, Q).on("message", (g) => {
1099
+ r(this, Ee).call(this, g);
1100
+ }).unref();
1101
+ } else {
1102
+ const {
1103
+ port1: a,
1104
+ // this process port
1105
+ port2: i
1106
+ // worker port
1107
+ } = new MessageChannel();
1108
+ k(this, Q, a), n = {
1109
+ workerPort: i,
1110
+ options: r(this, $).workerOptions
1111
+ }, r(this, W).postMessage(n, [i]), r(this, Q).onmessage = (g) => {
1112
+ r(this, Ee).call(this, g.data);
1113
+ }, r(this, Ae).call(this, t, r(this, te));
1114
+ }
1115
+ }
1116
+ /*
1117
+ GetIDToken = async (): Promise<string> => {
1118
+ try {
1119
+ const response: IOauth2ListenerMessageResponse = await this.#PostMessage({ command: IOauth2ListenerCommand.ID_TOKEN });
1120
+ return response.payload;
1121
+ } catch (error) {
1122
+ console.log(`Logout Error: ${error}`); // red
1123
+ return null;
1124
+ }
1125
+ }
1126
+ */
1127
+ }
1128
+ te = new WeakMap(), Fe = new WeakMap(), Ge = new WeakMap(), oe = new WeakMap(), xe = new WeakMap(), z = new WeakMap(), $ = new WeakMap(), ze = new WeakMap(), Q = new WeakMap(), _e = new WeakMap(), Y = new WeakMap(), le = new WeakMap(), W = new WeakMap(), K = new WeakMap(), ne = new WeakMap(), he = new WeakMap(), Oe = new WeakMap(), Ee = new WeakMap(), C = new WeakMap(), de = new WeakMap(), Re = new WeakMap(), V = new WeakMap(), me = new WeakMap(), ye = new WeakMap(), Ae = new WeakMap();
1129
+ var ee;
1130
+ (function(e) {
1131
+ e[e.ACCEPTED = 202] = "ACCEPTED", e[e.BAD_GATEWAY = 502] = "BAD_GATEWAY", e[e.BAD_REQUEST = 400] = "BAD_REQUEST", e[e.CONFLICT = 409] = "CONFLICT", e[e.CONTINUE = 100] = "CONTINUE", e[e.CREATED = 201] = "CREATED", e[e.EXPECTATION_FAILED = 417] = "EXPECTATION_FAILED", e[e.FAILED_DEPENDENCY = 424] = "FAILED_DEPENDENCY", e[e.FORBIDDEN = 403] = "FORBIDDEN", e[e.GATEWAY_TIMEOUT = 504] = "GATEWAY_TIMEOUT", e[e.GONE = 410] = "GONE", e[e.HTTP_VERSION_NOT_SUPPORTED = 505] = "HTTP_VERSION_NOT_SUPPORTED", e[e.IM_A_TEAPOT = 418] = "IM_A_TEAPOT", e[e.INSUFFICIENT_SPACE_ON_RESOURCE = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE", e[e.INSUFFICIENT_STORAGE = 507] = "INSUFFICIENT_STORAGE", e[e.INTERNAL_SERVER_ERROR = 500] = "INTERNAL_SERVER_ERROR", e[e.LENGTH_REQUIRED = 411] = "LENGTH_REQUIRED", e[e.LOCKED = 423] = "LOCKED", e[e.METHOD_FAILURE = 420] = "METHOD_FAILURE", e[e.METHOD_NOT_ALLOWED = 405] = "METHOD_NOT_ALLOWED", e[e.MOVED_PERMANENTLY = 301] = "MOVED_PERMANENTLY", e[e.MOVED_TEMPORARILY = 302] = "MOVED_TEMPORARILY", e[e.MULTI_STATUS = 207] = "MULTI_STATUS", e[e.MULTIPLE_CHOICES = 300] = "MULTIPLE_CHOICES", e[e.NETWORK_AUTHENTICATION_REQUIRED = 511] = "NETWORK_AUTHENTICATION_REQUIRED", e[e.NO_CONTENT = 204] = "NO_CONTENT", e[e.NON_AUTHORITATIVE_INFORMATION = 203] = "NON_AUTHORITATIVE_INFORMATION", e[e.NOT_ACCEPTABLE = 406] = "NOT_ACCEPTABLE", e[e.NOT_FOUND = 404] = "NOT_FOUND", e[e.NOT_IMPLEMENTED = 501] = "NOT_IMPLEMENTED", e[e.NOT_MODIFIED = 304] = "NOT_MODIFIED", e[e.OK = 200] = "OK", e[e.PARTIAL_CONTENT = 206] = "PARTIAL_CONTENT", e[e.PAYMENT_REQUIRED = 402] = "PAYMENT_REQUIRED", e[e.PERMANENT_REDIRECT = 308] = "PERMANENT_REDIRECT", e[e.PRECONDITION_FAILED = 412] = "PRECONDITION_FAILED", e[e.PRECONDITION_REQUIRED = 428] = "PRECONDITION_REQUIRED", e[e.PROCESSING = 102] = "PROCESSING", e[e.PROXY_AUTHENTICATION_REQUIRED = 407] = "PROXY_AUTHENTICATION_REQUIRED", e[e.REQUEST_HEADER_FIELDS_TOO_LARGE = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE", e[e.REQUEST_TIMEOUT = 408] = "REQUEST_TIMEOUT", e[e.REQUEST_TOO_LONG = 413] = "REQUEST_TOO_LONG", e[e.REQUEST_URI_TOO_LONG = 414] = "REQUEST_URI_TOO_LONG", e[e.REQUESTED_RANGE_NOT_SATISFIABLE = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE", e[e.RESET_CONTENT = 205] = "RESET_CONTENT", e[e.SEE_OTHER = 303] = "SEE_OTHER", e[e.SERVICE_UNAVAILABLE = 503] = "SERVICE_UNAVAILABLE", e[e.SWITCHING_PROTOCOLS = 101] = "SWITCHING_PROTOCOLS", e[e.TEMPORARY_REDIRECT = 307] = "TEMPORARY_REDIRECT", e[e.TOO_MANY_REQUESTS = 429] = "TOO_MANY_REQUESTS", e[e.UNAUTHORIZED = 401] = "UNAUTHORIZED", e[e.UNAVAILABLE_FOR_LEGAL_REASONS = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS", e[e.UNPROCESSABLE_ENTITY = 422] = "UNPROCESSABLE_ENTITY", e[e.UNSUPPORTED_MEDIA_TYPE = 415] = "UNSUPPORTED_MEDIA_TYPE", e[e.USE_PROXY = 305] = "USE_PROXY", e[e.MISDIRECTED_REQUEST = 421] = "MISDIRECTED_REQUEST";
1132
+ })(ee || (ee = {}));
1133
+ let S;
1134
+ M ? S = ce(`proc:${process.pid}:stsoauth2worker.ts`) : S = ce("proc:0:stsoauth2worker.ts");
1135
+ var b, J, Se, B, q, h, j, F, se, ie, Ie, Ne, ve, H, we, ke, De, ue, Ue, fe, Pe;
1136
+ class Br {
1137
+ constructor(t, o) {
1138
+ //#storageManager = null;
1139
+ l(this, b, void 0);
1140
+ l(this, J, new Xe());
1141
+ l(this, Se, new Ze());
1142
+ l(this, B, "session.stsmda.com.au");
1143
+ //@@#aic = null;
1144
+ l(this, q, void 0);
1145
+ l(this, h, void 0);
1146
+ l(this, j, null);
1147
+ // Attempt to restore a previous session using the STSBroker
1148
+ /*
1149
+ { parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
1150
+ { parameterType: OAuth2ParameterType.SCOPE, errorType: authErrorType.SCOPE_MISMATCH }
1151
+ { parameterType: OAuth2ParameterType.REDIRECT_URI, errorType: authErrorType.REDIRECT_URI_MISMATCH },
1152
+ { parameterType: OAuth2ParameterType.AUDIENCE, errorType: authErrorType.SCOPE_MISMATCH }
1153
+
1154
+ Successful Response
1155
+ {
1156
+ "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",
1157
+ "token_type": "Bearer",
1158
+ "expires_in": 3599,
1159
+ "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",
1160
+ "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",
1161
+ "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
1162
+ }
1163
+
1164
+ Error Response
1165
+ {
1166
+ "error": "invalid_scope",
1167
+ "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",
1168
+ "error_codes": [
1169
+ 70011
1170
+ ],
1171
+ "timestamp": "2016-01-09 02:02:12Z",
1172
+ }
1173
+
1174
+ */
1175
+ l(this, F, (t) => {
1176
+ const o = {
1177
+ messageId: -1,
1178
+ // un-solicited message
1179
+ command: d.AUTHENTICATE_EVENT
1180
+ };
1181
+ r(this, H).call(this, o, t);
1182
+ });
1183
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1184
+ l(this, se, (t) => {
1185
+ const o = {
1186
+ messageId: -1,
1187
+ // un-solicited message
1188
+ command: d.ERROR
1189
+ };
1190
+ r(this, H).call(this, o, t);
1191
+ });
1192
+ l(this, ie, (t) => {
1193
+ const o = {
1194
+ messageId: -1,
1195
+ // un-solicited message
1196
+ command: d.LOG
1197
+ };
1198
+ r(this, H).call(this, o, t);
1199
+ });
1200
+ l(this, Ie, () => {
1201
+ const t = r(this, b).get(r(this, B));
1202
+ return t ? t.tokenResponse.access_token : null;
1203
+ });
1204
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1205
+ l(this, Ne, () => {
1206
+ if (M) {
1207
+ const t = r(this, b).get(r(this, B));
1208
+ return t ? t.brokerCookie : null;
1209
+ } else
1210
+ return null;
1211
+ });
1212
+ l(this, ve, (t, o) => {
1213
+ const n = {
1214
+ messageId: -1,
1215
+ // un-solicited message
1216
+ command: d.UPDATE_INSTRUMENT
1217
+ };
1218
+ r(this, H).call(this, n, {
1219
+ instrumentName: t,
1220
+ telemetry: o
1221
+ });
1222
+ });
1223
+ D(this, "SetupListener", () => {
1224
+ r(this, q).onmessage = async (t) => {
1225
+ const o = t.data;
1226
+ switch (S(`STSOAuth2Worker:SetupListener:onmessage: [${o.command}]`), o.command) {
1227
+ case d.RESTORE_SESSION:
1228
+ r(this, H).call(this, o, await r(this, we).call(this));
1229
+ break;
1230
+ case d.AUTHORIZE:
1231
+ r(this, H).call(this, o, await r(this, ke).call(this));
1232
+ break;
1233
+ case d.HANDLE_REDIRECT:
1234
+ r(this, H).call(this, o, await r(this, De).call(this, o.payload));
1235
+ break;
1236
+ case d.LOGOUT:
1237
+ r(this, H).call(this, o, await r(this, Pe).call(this));
1238
+ break;
1239
+ case d.ACCESS_TOKEN:
1240
+ r(this, H).call(this, o, await r(this, Ie).call(this));
1241
+ break;
1242
+ case d.EXECUTE_REFRESH_TOKEN:
1243
+ r(this, H).call(this, o, await r(this, fe).call(this));
1244
+ break;
1245
+ case d.COOKIES:
1246
+ r(this, H).call(this, o, await r(this, Ne).call(this));
1247
+ break;
1248
+ default:
1249
+ throw new Error(`Command: [${o.command}'] not found.`);
1250
+ }
1251
+ };
1252
+ });
1253
+ /*
1254
+ #GetIDToken = async(): Promise<string> => {
1255
+ return '-- ID Token --';
1256
+ }
1257
+ */
1258
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1259
+ l(this, H, async (t, o) => {
1260
+ const n = {
1261
+ messageId: t.messageId,
1262
+ command: t.command,
1263
+ payload: o
1264
+ };
1265
+ r(this, q).postMessage(n);
1266
+ });
1267
+ l(this, we, async () => {
1268
+ let t = null;
1269
+ const o = r(this, b).get(r(this, B));
1270
+ if (o)
1271
+ t = o.tokenResponse, console.log("Session restored from client storage."), r(this, ie).call(this, "Session restored from client storage.");
1272
+ else {
1273
+ const n = `${r(this, h).brokerendpoint}:${r(this, h).brokerport}${r(this, h).brokerapiroot}/session`;
1274
+ console.log("RestoreSession"), console.log(n), r(this, ie).call(this, "RestoreSession."), r(this, ie).call(this, n);
1275
+ try {
1276
+ const a = {
1277
+ method: "post",
1278
+ url: n,
1279
+ data: {
1280
+ [G.CLIENT_ID]: r(this, h).client_id,
1281
+ [G.SCOPE]: r(this, h).scope,
1282
+ [G.REDIRECT_URI]: r(this, h).redirect_uri,
1283
+ [G.AUDIENCE]: r(this, h).audience
1284
+ },
1285
+ withCredentials: !0,
1286
+ // Ensure cookies are passed to the service
1287
+ timeout: r(this, h).timeout
1288
+ };
1289
+ S(`#RestoreSession:session request detail: [${JSON.stringify(a)}]`.magenta), M && (a.httpsAgent = r(this, j));
1290
+ const i = await Me(a);
1291
+ if (i.data.status === ee.OK)
1292
+ if (t = i.data.detail, t) {
1293
+ const g = {
1294
+ tokenResponse: t
1295
+ };
1296
+ M && (g.brokerCookie = i.headers["set-cookie"]), r(this, b).set(r(this, B), g), console.log("Session restored from server side cookie.");
1297
+ } else
1298
+ console.log("Could not restore previous session. No restoredSessionData available."), console.log(JSON.stringify(i.data));
1299
+ else
1300
+ console.log("Could not restore previous session:-"), console.log(JSON.stringify(i.data));
1301
+ } catch (a) {
1302
+ console.log("Could not restore previous session (error state):-"), console.log(a), console.log(JSON.stringify(a));
1303
+ }
1304
+ }
1305
+ return t !== null ? (r(this, F).call(this, t.id_token), console.log("Refreshing tokens ..."), await r(this, fe).call(this)) : (r(this, F).call(this, null), !1);
1306
+ });
1307
+ l(this, ke, async () => {
1308
+ console.log("Authorize ...");
1309
+ const t = r(this, h).client_id, o = r(this, J).CreateRandomString(), n = [er.CODE], a = r(this, h).redirect_uri, i = rr.QUERY, g = r(this, h).scope, R = r(this, J).CreateRandomString(), O = r(this, J).CreateRandomString(), y = await r(this, J).DigestMessage(O), T = {
1310
+ client_id: t,
1311
+ nonce: o,
1312
+ response_type: n,
1313
+ redirect_uri: a,
1314
+ response_mode: i,
1315
+ scope: g,
1316
+ state: R,
1317
+ code_challenge: y,
1318
+ code_challenge_method: "S256"
1319
+ }, m = { ...T }, f = `${r(this, h).authorizeendpoint}:${r(this, h).authorizeport}${r(this, h).authorizeapiroot}${r(this, h).authorizeapi}?${r(this, Se).CreateQueryParams(T)}`;
1320
+ return console.log(f), T.code_verifier = O, console.log(`Authorize:authorizeOptions: [${JSON.stringify(T)}]`), {
1321
+ url: f,
1322
+ authorizeOptions: T,
1323
+ authorizeOptionsClientCopy: m
1324
+ };
1325
+ });
1326
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1327
+ l(this, De, async (t) => {
1328
+ const o = t.queryVars, n = t.authorizeOptions;
1329
+ if (S("#HandleRedirect: HandleRedirect".magenta), S(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(o)}]`.magenta), o[G.CODE]) {
1330
+ const a = o;
1331
+ console.log(`authorizeOptions from transaction state: [${JSON.stringify(n)}]`);
1332
+ const i = a.state, g = n.state;
1333
+ return g.localeCompare(i) === 0 ? (console.log("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"), await r(this, Ue).call(this, n, a)) : (console.log("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"), console.log(`authorizeOptionsState: [${g}]`), console.log(`redirectState: [${i}]`), r(this, se).call(this, { message: "State un-matched" }), !1);
1334
+ } else
1335
+ return o[G.ERROR] ? (r(this, se).call(this, { message: "State un-matched" }), !1) : (r(this, se).call(this, { message: "State un-matched" }), !1);
1336
+ });
1337
+ /*
1338
+ client_id=6731de76-14a6-49ae-97bc-6eba6914391e
1339
+ &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
1340
+ &code=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq3n8b2JRLk4OxVXr...
1341
+ &redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
1342
+ &grant_type=authorization_code
1343
+ &code_verifier=ThisIsntRandomButItNeedsToBe43CharactersLong
1344
+ &client_secret=JqQX2PNo9bpM0uEihUPzyrh // NOTE: Only required for web apps. This secret needs to be URL-Encoded.
1345
+
1346
+ Successful Response
1347
+ {
1348
+ "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",
1349
+ "token_type": "Bearer",
1350
+ "expires_in": 3599,
1351
+ "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",
1352
+ "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",
1353
+ "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
1354
+ }
1355
+ */
1356
+ // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
1357
+ l(this, ue, async (t) => {
1358
+ S("#GetTokenFromBroker".magenta), r(this, b).remove(r(this, B));
1359
+ const o = `${r(this, h).brokerendpoint}:${r(this, h).brokerport}${r(this, h).brokerapiroot}/token`;
1360
+ try {
1361
+ const n = {
1362
+ method: "post",
1363
+ url: o,
1364
+ data: t,
1365
+ withCredentials: !0,
1366
+ // Ensure cookies are passed to the service
1367
+ timeout: r(this, h).timeout
1368
+ };
1369
+ S(`#GetTokenFromBroker: request config: [${JSON.stringify(n)}]`.magenta), M && (n.httpsAgent = r(this, j)), S("#GetTokenFromBroker: axios API call".magenta);
1370
+ const a = await Me(n);
1371
+ if (S(`#GetTokenFromBroker: axios API call result: [${a.status}]`.magenta), a.status === ee.OK) {
1372
+ S("#GetTokenFromBroker: storing tokens".magenta);
1373
+ const i = a.data;
1374
+ r(this, F).call(this, i.id_token);
1375
+ const g = {
1376
+ tokenResponse: i
1377
+ };
1378
+ return M && (g.brokerCookie = a.headers["set-cookie"]), r(this, b).set(r(this, B), g), !0;
1379
+ } else
1380
+ return a.status === ee.UNAUTHORIZED ? (S(`#GetTokenFromBroker: NOT storing tokens, status: [${a.status}]`.magenta), r(this, F).call(this, null), !1) : (S(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${a.status}]`.magenta), r(this, F).call(this, null), console.log("Could not obtain access_token from token end-point:-"), console.log(JSON.stringify(a.data)), !1);
1381
+ } catch (n) {
1382
+ return S(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${n}]`.red), r(this, F).call(this, null), !1;
1383
+ }
1384
+ });
1385
+ // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
1386
+ l(this, Ue, async (t, o) => {
1387
+ console.log("#GetToken"), console.log(o), r(this, b).remove(r(this, B));
1388
+ const n = {
1389
+ client_id: r(this, h).client_id,
1390
+ scope: r(this, h).scope,
1391
+ code: o.code,
1392
+ redirect_uri: r(this, h).redirect_uri,
1393
+ grant_type: Ce.AUTHORIZATION_CODE,
1394
+ code_verifier: t.code_verifier
1395
+ };
1396
+ return await r(this, ue).call(this, n);
1397
+ });
1398
+ /*
1399
+ // Line breaks for legibility only
1400
+
1401
+ POST /{tenant}/oauth2/v2.0/token HTTP/1.1
1402
+ Host: https://login.microsoftonline.com
1403
+ Content-Type: application/x-www-form-urlencoded
1404
+
1405
+ client_id=535fb089-9ff3-47b6-9bfb-4f1264799865
1406
+ &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
1407
+ &refresh_token=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq...
1408
+ &grant_type=refresh_token
1409
+ &client_secret=sampleCredentia1s // NOTE: Only required for web apps. This secret needs to be URL-Encoded
1410
+
1411
+ Error Response
1412
+ {
1413
+ "error": "invalid_scope",
1414
+ "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",
1415
+ "error_codes": [
1416
+ 70011
1417
+ ],
1418
+ "timestamp": "2016-01-09 02:02:12Z",
1419
+ "trace_id": "255d1aef-8c98-452f-ac51-23d051240864",
1420
+ "correlation_id": "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7"
1421
+ }
1422
+ */
1423
+ l(this, fe, async () => {
1424
+ S("STSOAuth2Worker:#RefreshToken:start".cyan);
1425
+ const t = r(this, b).get(r(this, B));
1426
+ if (t) {
1427
+ S(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(t)}]`.cyan);
1428
+ const o = t.tokenResponse, n = {
1429
+ client_id: r(this, h).client_id,
1430
+ scope: r(this, h).scope,
1431
+ refresh_token: o.refresh_token,
1432
+ grant_type: Ce.REFRESH_TOKEN
1433
+ };
1434
+ return await r(this, ue).call(this, n);
1435
+ } else
1436
+ return S("STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore".red), !1;
1437
+ });
1438
+ // call broker to logout
1439
+ // broker to logout of server
1440
+ // delete cookie
1441
+ // clear session storage
1442
+ // clear all state from $store
1443
+ l(this, Pe, async () => {
1444
+ console.log("Logout");
1445
+ const t = `${r(this, h).brokerendpoint}:${r(this, h).brokerport}${r(this, h).brokerapiroot}/logout`;
1446
+ console.log(t);
1447
+ const o = r(this, b).get(r(this, B));
1448
+ if (o) {
1449
+ const a = o.tokenResponse.refresh_token;
1450
+ console.log(a);
1451
+ const i = tr(a);
1452
+ console.log(i);
1453
+ const g = i.sts_session;
1454
+ console.log(g), r(this, b).remove(r(this, B)), r(this, F).call(this, null);
1455
+ try {
1456
+ const R = {
1457
+ method: "post",
1458
+ url: t,
1459
+ data: {
1460
+ sessionId: g
1461
+ },
1462
+ withCredentials: !0,
1463
+ // Ensure cookies are passed to the service
1464
+ timeout: r(this, h).timeout
1465
+ };
1466
+ S(`#Logout: request config: [${R}]`.magenta), M && (R.httpsAgent = r(this, j));
1467
+ const O = await Me(R);
1468
+ return O.data.status === ee.OK ? !0 : (console.log("Error during logout (1: server side)"), console.log(JSON.stringify(O.data)), !1);
1469
+ } catch (R) {
1470
+ return console.log("Error during logout (2: server side)"), console.log(R), console.log(JSON.stringify(R)), !1;
1471
+ }
1472
+ } else
1473
+ return console.log("Error during logout. Could not restore session from session storage."), !1;
1474
+ });
1475
+ ce.enable("proc:*"), k(this, h, o), S(`STSOAuth2Worker:constructor:#options: [${JSON.stringify(r(this, h))}]`), k(this, b, new Le({ clientStorageType: be.MEMORY_STORAGE, usePrefix: !1 }).GetStorage()), k(this, q, t), S(`STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(r(this, q))}]`), M && r(this, h).agentOptions && k(this, j, new fr.Agent({
1476
+ keepAlive: r(this, h).agentOptions.keepAlive,
1477
+ maxSockets: r(this, h).agentOptions.maxSockets,
1478
+ maxTotalSockets: r(this, h).agentOptions.maxTotalSockets,
1479
+ maxFreeSockets: r(this, h).agentOptions.maxFreeSockets,
1480
+ timeout: r(this, h).timeout,
1481
+ rejectUnauthorized: r(this, h).agentOptions.rejectUnauthorized
1482
+ // Allows self-signed certificates if non-production
1483
+ })), this.SetupListener(), r(this, ve).call(this, gr.LOGGER, {
1484
+ LogMessage: "STSOauth2 Plugin - Successfully Loaded"
1485
+ });
1486
+ }
1487
+ }
1488
+ b = new WeakMap(), J = new WeakMap(), Se = new WeakMap(), B = new WeakMap(), q = new WeakMap(), h = new WeakMap(), j = new WeakMap(), F = new WeakMap(), se = new WeakMap(), ie = new WeakMap(), Ie = new WeakMap(), Ne = new WeakMap(), ve = new WeakMap(), H = new WeakMap(), we = new WeakMap(), ke = new WeakMap(), De = new WeakMap(), ue = new WeakMap(), Ue = new WeakMap(), fe = new WeakMap(), Pe = new WeakMap();
1489
+ const Cr = qe("__sts__TestStore", {
1490
+ state: () => ({
1491
+ count: 0
1492
+ }),
1493
+ actions: {
1494
+ UpdateCount() {
1495
+ this.count++;
1496
+ }
1497
+ },
1498
+ getters: {
1499
+ CountXX: (e) => e.count * 2
1500
+ }
1501
+ /*
1502
+ persist: {
1503
+ storage: globalThis.sessionStorage
1504
+ }
1505
+ */
1506
+ }), $r = () => hr(ge), Fr = {
1507
+ install: (e, t) => {
1508
+ const o = new Ir(e, t);
1509
+ e.config.globalProperties.$sts || (e.config.globalProperties.$sts = {}), e.config.globalProperties.$sts[ge] = o, e.provide(ge, o);
1510
+ }
1511
+ };
1512
+ export {
1513
+ rr as AuthorizeOptionsResponseMode,
1514
+ er as AuthorizeOptionsResponseType,
1515
+ d as IOauth2ListenerCommand,
1516
+ Ce as OAuthGrantTypes,
1517
+ Ir as STSOAuth2Manager,
1518
+ Fr as STSOAuth2ManagerPlugin,
1519
+ ge as STSOAuth2ManagerPluginKey,
1520
+ Br as STSOAuth2Worker,
1521
+ Sr as STSOauth2Store,
1522
+ Cr as TestStore,
1523
+ $r as useSTSOAuth2ManagerPlugin
1524
+ };
1525
+ //# sourceMappingURL=stsoauth2plugin.mjs.map