@nsshunt/stsoauth2plugin 1.0.12 → 1.0.13

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,119 +1,171 @@
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);
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
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))
7
+ var __accessCheck = (obj, member, msg) => {
8
+ if (!member.has(obj))
9
+ throw TypeError("Cannot " + msg);
10
+ };
11
+ var __privateGet = (obj, member, getter) => {
12
+ __accessCheck(obj, member, "read from private field");
13
+ return getter ? getter.call(obj) : member.get(obj);
14
+ };
15
+ var __privateAdd = (obj, member, value) => {
16
+ if (member.has(obj))
9
17
  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);
18
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
19
+ };
20
+ var __privateSet = (obj, member, value, setter) => {
21
+ __accessCheck(obj, member, "write to private field");
22
+ setter ? setter.call(obj, value) : member.set(obj, value);
23
+ return value;
24
+ };
25
+ var __privateWrapper = (obj, member, setter, getter) => ({
26
+ set _(value) {
27
+ __privateSet(obj, member, value, setter);
14
28
  },
15
29
  get _() {
16
- return r(e, t, n);
30
+ return __privateGet(obj, member, getter);
17
31
  }
18
32
  });
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";
33
+ var _crypto, _router, _cUtils, _qParams, _STORAGE_AUTHORIZE_OPTIONS_KEY, _STORAGE_SESSION_KEY, _aic, _options, _messages, _oauth2ManagerPort, _messageId, _messageHandlers, _messageTimeout, _worker, _transactionStore, _operationSemaphore, _maxSemaphoreRetries, _semaphoreRetrySleep, _ProcessMessageResponse, _PostMessage, _HandleLogEvent, _HandleUpdateInstrumentEvent, _GetStore, _HandleErrorEvent, _HandleAuthenticateEvent, _SetupRoute, _clientSessionStore, _cUtils2, _qParams2, _STORAGE_SESSION_KEY2, _oauthWorkerPort, _options2, _httpsAgent, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
34
+ import { inject } from "vue";
35
+ import Debug from "debug";
36
+ import * as wt from "node:worker_threads";
37
+ import { OAuth2ParameterType, Sleep } from "@nsshunt/stsutils";
38
+ import { ClientStorageFactory, ClientStorageType } from "@nsshunt/stsvueutils";
39
+ import { defineStore } from "pinia";
40
+ import { STSInstrumentControllerPluginKey } from "@nsshunt/stspublisherserver";
41
+ import https from "node:https";
27
42
  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
+ import axios from "axios";
44
+ import { Gauge } from "@nsshunt/stsinstrumentation";
45
+ const STSOAuth2ManagerPluginKey = Symbol();
46
+ const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
47
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
48
+ function getAugmentedNamespace(n2) {
49
+ if (n2.__esModule)
50
+ return n2;
51
+ var f = n2.default;
52
+ if (typeof f == "function") {
53
+ var a = function a2() {
54
+ if (this instanceof a2) {
55
+ var args = [null];
56
+ args.push.apply(args, arguments);
57
+ var Ctor = Function.bind.apply(f, args);
58
+ return new Ctor();
43
59
  }
44
- return t.apply(this, arguments);
60
+ return f.apply(this, arguments);
45
61
  };
46
- o.prototype = t.prototype;
62
+ a.prototype = f.prototype;
47
63
  } 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,
64
+ a = {};
65
+ Object.defineProperty(a, "__esModule", { value: true });
66
+ Object.keys(n2).forEach(function(k) {
67
+ var d = Object.getOwnPropertyDescriptor(n2, k);
68
+ Object.defineProperty(a, k, d.get ? d : {
69
+ enumerable: true,
53
70
  get: function() {
54
- return e[n];
71
+ return n2[k];
55
72
  }
56
73
  });
57
- }), o;
74
+ });
75
+ return a;
58
76
  }
59
- var He = {}, Tr = {
77
+ var sha256Exports = {};
78
+ var sha256 = {
60
79
  get exports() {
61
- return He;
80
+ return sha256Exports;
62
81
  },
63
- set exports(e) {
64
- He = e;
82
+ set exports(v) {
83
+ sha256Exports = v;
65
84
  }
66
85
  };
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.');
86
+ function commonjsRequire(path) {
87
+ 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.');
69
88
  }
70
- var pe = {}, Or = {
89
+ var coreExports = {};
90
+ var core = {
71
91
  get exports() {
72
- return pe;
92
+ return coreExports;
73
93
  },
74
- set exports(e) {
75
- pe = e;
94
+ set exports(v) {
95
+ coreExports = v;
76
96
  }
77
97
  };
78
- const dr = {}, Rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
98
+ const __viteBrowserExternal = {};
99
+ const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
79
100
  __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")
101
+ default: __viteBrowserExternal
102
+ }, Symbol.toStringTag, { value: "Module" }));
103
+ const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
104
+ var hasRequiredCore;
105
+ function requireCore() {
106
+ if (hasRequiredCore)
107
+ return coreExports;
108
+ hasRequiredCore = 1;
109
+ (function(module, exports) {
110
+ (function(root, factory) {
111
+ {
112
+ module.exports = factory();
113
+ }
114
+ })(commonjsGlobal, function() {
115
+ var CryptoJS = CryptoJS || function(Math2, undefined$1) {
116
+ var crypto2;
117
+ if (typeof window !== "undefined" && window.crypto) {
118
+ crypto2 = window.crypto;
119
+ }
120
+ if (typeof self !== "undefined" && self.crypto) {
121
+ crypto2 = self.crypto;
122
+ }
123
+ if (typeof globalThis !== "undefined" && globalThis.crypto) {
124
+ crypto2 = globalThis.crypto;
125
+ }
126
+ if (!crypto2 && typeof window !== "undefined" && window.msCrypto) {
127
+ crypto2 = window.msCrypto;
128
+ }
129
+ if (!crypto2 && typeof commonjsGlobal !== "undefined" && commonjsGlobal.crypto) {
130
+ crypto2 = commonjsGlobal.crypto;
131
+ }
132
+ if (!crypto2 && typeof commonjsRequire === "function") {
91
133
  try {
92
- i = mr;
93
- } catch {
134
+ crypto2 = require$$0;
135
+ } catch (err) {
94
136
  }
95
- var g = function() {
96
- if (i) {
97
- if (typeof i.getRandomValues == "function")
137
+ }
138
+ var cryptoSecureRandomInt = function() {
139
+ if (crypto2) {
140
+ if (typeof crypto2.getRandomValues === "function") {
98
141
  try {
99
- return i.getRandomValues(new Uint32Array(1))[0];
100
- } catch {
142
+ return crypto2.getRandomValues(new Uint32Array(1))[0];
143
+ } catch (err) {
101
144
  }
102
- if (typeof i.randomBytes == "function")
145
+ }
146
+ if (typeof crypto2.randomBytes === "function") {
103
147
  try {
104
- return i.randomBytes(4).readInt32LE();
105
- } catch {
148
+ return crypto2.randomBytes(4).readInt32LE();
149
+ } catch (err) {
106
150
  }
151
+ }
107
152
  }
108
153
  throw new Error("Native crypto module could not be used to get secure random number.");
109
- }, R = Object.create || function() {
110
- function s() {
154
+ };
155
+ var create = Object.create || function() {
156
+ function F() {
111
157
  }
112
- return function(c) {
113
- var u;
114
- return s.prototype = c, u = new s(), s.prototype = null, u;
158
+ return function(obj) {
159
+ var subtype;
160
+ F.prototype = obj;
161
+ subtype = new F();
162
+ F.prototype = null;
163
+ return subtype;
115
164
  };
116
- }(), O = {}, y = O.lib = {}, I = y.Base = function() {
165
+ }();
166
+ var C = {};
167
+ var C_lib = C.lib = {};
168
+ var Base = C_lib.Base = function() {
117
169
  return {
118
170
  /**
119
171
  * Creates a new object that inherits from this object.
@@ -133,11 +185,19 @@ function je() {
133
185
  * }
134
186
  * });
135
187
  */
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;
188
+ extend: function(overrides) {
189
+ var subtype = create(this);
190
+ if (overrides) {
191
+ subtype.mixIn(overrides);
192
+ }
193
+ if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
194
+ subtype.init = function() {
195
+ subtype.$super.init.apply(this, arguments);
196
+ };
197
+ }
198
+ subtype.init.prototype = subtype;
199
+ subtype.$super = this;
200
+ return subtype;
141
201
  },
142
202
  /**
143
203
  * Extends this object and runs the init method.
@@ -152,8 +212,9 @@ function je() {
152
212
  * var instance = MyType.create();
153
213
  */
154
214
  create: function() {
155
- var s = this.extend();
156
- return s.init.apply(s, arguments), s;
215
+ var instance = this.extend();
216
+ instance.init.apply(instance, arguments);
217
+ return instance;
157
218
  },
158
219
  /**
159
220
  * Initializes a newly created object.
@@ -180,10 +241,15 @@ function je() {
180
241
  * field: 'value'
181
242
  * });
182
243
  */
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);
244
+ mixIn: function(properties) {
245
+ for (var propertyName in properties) {
246
+ if (properties.hasOwnProperty(propertyName)) {
247
+ this[propertyName] = properties[propertyName];
248
+ }
249
+ }
250
+ if (properties.hasOwnProperty("toString")) {
251
+ this.toString = properties.toString;
252
+ }
187
253
  },
188
254
  /**
189
255
  * Creates a copy of this object.
@@ -198,7 +264,8 @@ function je() {
198
264
  return this.init.prototype.extend(this);
199
265
  }
200
266
  };
201
- }(), T = y.WordArray = I.extend({
267
+ }();
268
+ var WordArray = C_lib.WordArray = Base.extend({
202
269
  /**
203
270
  * Initializes a newly created word array.
204
271
  *
@@ -211,8 +278,13 @@ function je() {
211
278
  * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
212
279
  * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
213
280
  */
214
- init: function(s, c) {
215
- s = this.words = s || [], c != a ? this.sigBytes = c : this.sigBytes = s.length * 4;
281
+ init: function(words, sigBytes) {
282
+ words = this.words = words || [];
283
+ if (sigBytes != undefined$1) {
284
+ this.sigBytes = sigBytes;
285
+ } else {
286
+ this.sigBytes = words.length * 4;
287
+ }
216
288
  },
217
289
  /**
218
290
  * Converts this word array to a string.
@@ -227,8 +299,8 @@ function je() {
227
299
  * var string = wordArray.toString();
228
300
  * var string = wordArray.toString(CryptoJS.enc.Utf8);
229
301
  */
230
- toString: function(s) {
231
- return (s || f).stringify(this);
302
+ toString: function(encoder) {
303
+ return (encoder || Hex).stringify(this);
232
304
  },
233
305
  /**
234
306
  * Concatenates a word array to this word array.
@@ -241,17 +313,24 @@ function je() {
241
313
  *
242
314
  * wordArray1.concat(wordArray2);
243
315
  */
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;
316
+ concat: function(wordArray) {
317
+ var thisWords = this.words;
318
+ var thatWords = wordArray.words;
319
+ var thisSigBytes = this.sigBytes;
320
+ var thatSigBytes = wordArray.sigBytes;
321
+ this.clamp();
322
+ if (thisSigBytes % 4) {
323
+ for (var i = 0; i < thatSigBytes; i++) {
324
+ var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
325
+ thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
250
326
  }
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;
327
+ } else {
328
+ for (var j = 0; j < thatSigBytes; j += 4) {
329
+ thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
330
+ }
331
+ }
332
+ this.sigBytes += thatSigBytes;
333
+ return this;
255
334
  },
256
335
  /**
257
336
  * Removes insignificant bits.
@@ -261,8 +340,10 @@ function je() {
261
340
  * wordArray.clamp();
262
341
  */
263
342
  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);
343
+ var words = this.words;
344
+ var sigBytes = this.sigBytes;
345
+ words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
346
+ words.length = Math2.ceil(sigBytes / 4);
266
347
  },
267
348
  /**
268
349
  * Creates a copy of this word array.
@@ -274,8 +355,9 @@ function je() {
274
355
  * var clone = wordArray.clone();
275
356
  */
276
357
  clone: function() {
277
- var s = I.clone.call(this);
278
- return s.words = this.words.slice(0), s;
358
+ var clone = Base.clone.call(this);
359
+ clone.words = this.words.slice(0);
360
+ return clone;
279
361
  },
280
362
  /**
281
363
  * Creates a word array filled with random bytes.
@@ -290,12 +372,16 @@ function je() {
290
372
  *
291
373
  * var wordArray = CryptoJS.lib.WordArray.random(16);
292
374
  */
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);
375
+ random: function(nBytes) {
376
+ var words = [];
377
+ for (var i = 0; i < nBytes; i += 4) {
378
+ words.push(cryptoSecureRandomInt());
379
+ }
380
+ return new WordArray.init(words, nBytes);
297
381
  }
298
- }), m = O.enc = {}, f = m.Hex = {
382
+ });
383
+ var C_enc = C.enc = {};
384
+ var Hex = C_enc.Hex = {
299
385
  /**
300
386
  * Converts a word array to a hex string.
301
387
  *
@@ -309,12 +395,16 @@ function je() {
309
395
  *
310
396
  * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
311
397
  */
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));
398
+ stringify: function(wordArray) {
399
+ var words = wordArray.words;
400
+ var sigBytes = wordArray.sigBytes;
401
+ var hexChars = [];
402
+ for (var i = 0; i < sigBytes; i++) {
403
+ var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
404
+ hexChars.push((bite >>> 4).toString(16));
405
+ hexChars.push((bite & 15).toString(16));
316
406
  }
317
- return p.join("");
407
+ return hexChars.join("");
318
408
  },
319
409
  /**
320
410
  * Converts a hex string to a word array.
@@ -329,12 +419,16 @@ function je() {
329
419
  *
330
420
  * var wordArray = CryptoJS.enc.Hex.parse(hexString);
331
421
  */
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);
422
+ parse: function(hexStr) {
423
+ var hexStrLength = hexStr.length;
424
+ var words = [];
425
+ for (var i = 0; i < hexStrLength; i += 2) {
426
+ words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
427
+ }
428
+ return new WordArray.init(words, hexStrLength / 2);
336
429
  }
337
- }, N = m.Latin1 = {
430
+ };
431
+ var Latin1 = C_enc.Latin1 = {
338
432
  /**
339
433
  * Converts a word array to a Latin1 string.
340
434
  *
@@ -348,12 +442,15 @@ function je() {
348
442
  *
349
443
  * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
350
444
  */
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));
445
+ stringify: function(wordArray) {
446
+ var words = wordArray.words;
447
+ var sigBytes = wordArray.sigBytes;
448
+ var latin1Chars = [];
449
+ for (var i = 0; i < sigBytes; i++) {
450
+ var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
451
+ latin1Chars.push(String.fromCharCode(bite));
355
452
  }
356
- return p.join("");
453
+ return latin1Chars.join("");
357
454
  },
358
455
  /**
359
456
  * Converts a Latin1 string to a word array.
@@ -368,12 +465,16 @@ function je() {
368
465
  *
369
466
  * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
370
467
  */
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);
468
+ parse: function(latin1Str) {
469
+ var latin1StrLength = latin1Str.length;
470
+ var words = [];
471
+ for (var i = 0; i < latin1StrLength; i++) {
472
+ words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
473
+ }
474
+ return new WordArray.init(words, latin1StrLength);
375
475
  }
376
- }, E = m.Utf8 = {
476
+ };
477
+ var Utf8 = C_enc.Utf8 = {
377
478
  /**
378
479
  * Converts a word array to a UTF-8 string.
379
480
  *
@@ -387,10 +488,10 @@ function je() {
387
488
  *
388
489
  * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
389
490
  */
390
- stringify: function(s) {
491
+ stringify: function(wordArray) {
391
492
  try {
392
- return decodeURIComponent(escape(N.stringify(s)));
393
- } catch {
493
+ return decodeURIComponent(escape(Latin1.stringify(wordArray)));
494
+ } catch (e2) {
394
495
  throw new Error("Malformed UTF-8 data");
395
496
  }
396
497
  },
@@ -407,10 +508,11 @@ function je() {
407
508
  *
408
509
  * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
409
510
  */
410
- parse: function(s) {
411
- return N.parse(unescape(encodeURIComponent(s)));
511
+ parse: function(utf8Str) {
512
+ return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
412
513
  }
413
- }, _ = y.BufferedBlockAlgorithm = I.extend({
514
+ };
515
+ var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
414
516
  /**
415
517
  * Resets this block algorithm's data buffer to its initial state.
416
518
  *
@@ -419,7 +521,8 @@ function je() {
419
521
  * bufferedBlockAlgorithm.reset();
420
522
  */
421
523
  reset: function() {
422
- this._data = new T.init(), this._nDataBytes = 0;
524
+ this._data = new WordArray.init();
525
+ this._nDataBytes = 0;
423
526
  },
424
527
  /**
425
528
  * Adds new data to this block algorithm's buffer.
@@ -431,8 +534,12 @@ function je() {
431
534
  * bufferedBlockAlgorithm._append('data');
432
535
  * bufferedBlockAlgorithm._append(wordArray);
433
536
  */
434
- _append: function(s) {
435
- typeof s == "string" && (s = E.parse(s)), this._data.concat(s), this._nDataBytes += s.sigBytes;
537
+ _append: function(data) {
538
+ if (typeof data == "string") {
539
+ data = Utf8.parse(data);
540
+ }
541
+ this._data.concat(data);
542
+ this._nDataBytes += data.sigBytes;
436
543
  },
437
544
  /**
438
545
  * Processes available data blocks.
@@ -448,16 +555,29 @@ function je() {
448
555
  * var processedData = bufferedBlockAlgorithm._process();
449
556
  * var processedData = bufferedBlockAlgorithm._process(!!'flush');
450
557
  */
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;
558
+ _process: function(doFlush) {
559
+ var processedWords;
560
+ var data = this._data;
561
+ var dataWords = data.words;
562
+ var dataSigBytes = data.sigBytes;
563
+ var blockSize = this.blockSize;
564
+ var blockSizeBytes = blockSize * 4;
565
+ var nBlocksReady = dataSigBytes / blockSizeBytes;
566
+ if (doFlush) {
567
+ nBlocksReady = Math2.ceil(nBlocksReady);
568
+ } else {
569
+ nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
459
570
  }
460
- return new T.init(c, x);
571
+ var nWordsReady = nBlocksReady * blockSize;
572
+ var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
573
+ if (nWordsReady) {
574
+ for (var offset = 0; offset < nWordsReady; offset += blockSize) {
575
+ this._doProcessBlock(dataWords, offset);
576
+ }
577
+ processedWords = dataWords.splice(0, nWordsReady);
578
+ data.sigBytes -= nBytesReady;
579
+ }
580
+ return new WordArray.init(processedWords, nBytesReady);
461
581
  },
462
582
  /**
463
583
  * Creates a copy of this object.
@@ -469,16 +589,17 @@ function je() {
469
589
  * var clone = bufferedBlockAlgorithm.clone();
470
590
  */
471
591
  clone: function() {
472
- var s = I.clone.call(this);
473
- return s._data = this._data.clone(), s;
592
+ var clone = Base.clone.call(this);
593
+ clone._data = this._data.clone();
594
+ return clone;
474
595
  },
475
596
  _minBufferSize: 0
476
597
  });
477
- y.Hasher = _.extend({
598
+ C_lib.Hasher = BufferedBlockAlgorithm.extend({
478
599
  /**
479
600
  * Configuration options.
480
601
  */
481
- cfg: I.extend(),
602
+ cfg: Base.extend(),
482
603
  /**
483
604
  * Initializes a newly created hasher.
484
605
  *
@@ -488,8 +609,9 @@ function je() {
488
609
  *
489
610
  * var hasher = CryptoJS.algo.SHA256.create();
490
611
  */
491
- init: function(s) {
492
- this.cfg = this.cfg.extend(s), this.reset();
612
+ init: function(cfg) {
613
+ this.cfg = this.cfg.extend(cfg);
614
+ this.reset();
493
615
  },
494
616
  /**
495
617
  * Resets this hasher to its initial state.
@@ -499,7 +621,8 @@ function je() {
499
621
  * hasher.reset();
500
622
  */
501
623
  reset: function() {
502
- _.reset.call(this), this._doReset();
624
+ BufferedBlockAlgorithm.reset.call(this);
625
+ this._doReset();
503
626
  },
504
627
  /**
505
628
  * Updates this hasher with a message.
@@ -513,8 +636,10 @@ function je() {
513
636
  * hasher.update('message');
514
637
  * hasher.update(wordArray);
515
638
  */
516
- update: function(s) {
517
- return this._append(s), this._process(), this;
639
+ update: function(messageUpdate) {
640
+ this._append(messageUpdate);
641
+ this._process();
642
+ return this;
518
643
  },
519
644
  /**
520
645
  * Finalizes the hash computation.
@@ -530,12 +655,14 @@ function je() {
530
655
  * var hash = hasher.finalize('message');
531
656
  * var hash = hasher.finalize(wordArray);
532
657
  */
533
- finalize: function(s) {
534
- s && this._append(s);
535
- var c = this._doFinalize();
536
- return c;
658
+ finalize: function(messageUpdate) {
659
+ if (messageUpdate) {
660
+ this._append(messageUpdate);
661
+ }
662
+ var hash = this._doFinalize();
663
+ return hash;
537
664
  },
538
- blockSize: 16,
665
+ blockSize: 512 / 32,
539
666
  /**
540
667
  * Creates a shortcut function to a hasher's object interface.
541
668
  *
@@ -549,9 +676,9 @@ function je() {
549
676
  *
550
677
  * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
551
678
  */
552
- _createHelper: function(s) {
553
- return function(c, u) {
554
- return new s.init(u).finalize(c);
679
+ _createHelper: function(hasher) {
680
+ return function(message, cfg) {
681
+ return new hasher.init(cfg).finalize(message);
555
682
  };
556
683
  },
557
684
  /**
@@ -567,83 +694,154 @@ function je() {
567
694
  *
568
695
  * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
569
696
  */
570
- _createHmacHelper: function(s) {
571
- return function(c, u) {
572
- return new L.HMAC.init(s, u).finalize(c);
697
+ _createHmacHelper: function(hasher) {
698
+ return function(message, key) {
699
+ return new C_algo.HMAC.init(hasher, key).finalize(message);
573
700
  };
574
701
  }
575
702
  });
576
- var L = O.algo = {};
577
- return O;
703
+ var C_algo = C.algo = {};
704
+ return C;
578
705
  }(Math);
579
- return o;
706
+ return CryptoJS;
580
707
  });
581
- }(Or)), pe;
708
+ })(core);
709
+ return coreExports;
582
710
  }
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 = [];
711
+ (function(module, exports) {
712
+ (function(root, factory) {
713
+ {
714
+ module.exports = factory(requireCore());
715
+ }
716
+ })(commonjsGlobal, function(CryptoJS) {
717
+ (function(Math2) {
718
+ var C = CryptoJS;
719
+ var C_lib = C.lib;
720
+ var WordArray = C_lib.WordArray;
721
+ var Hasher = C_lib.Hasher;
722
+ var C_algo = C.algo;
723
+ var H = [];
724
+ var K = [];
589
725
  (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;
726
+ function isPrime(n3) {
727
+ var sqrtN = Math2.sqrt(n3);
728
+ for (var factor = 2; factor <= sqrtN; factor++) {
729
+ if (!(n3 % factor)) {
730
+ return false;
731
+ }
732
+ }
733
+ return true;
734
+ }
735
+ function getFractionalBits(n3) {
736
+ return (n3 - (n3 | 0)) * 4294967296 | 0;
595
737
  }
596
- function N(L) {
597
- return (L - (L | 0)) * 4294967296 | 0;
738
+ var n2 = 2;
739
+ var nPrime = 0;
740
+ while (nPrime < 64) {
741
+ if (isPrime(n2)) {
742
+ if (nPrime < 8) {
743
+ H[nPrime] = getFractionalBits(Math2.pow(n2, 1 / 2));
744
+ }
745
+ K[nPrime] = getFractionalBits(Math2.pow(n2, 1 / 3));
746
+ nPrime++;
747
+ }
748
+ n2++;
598
749
  }
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
750
  })();
602
- var T = [], m = O.SHA256 = R.extend({
751
+ var W = [];
752
+ var SHA256 = C_algo.SHA256 = Hasher.extend({
603
753
  _doReset: function() {
604
- this._hash = new g.init(y.slice(0));
754
+ this._hash = new WordArray.init(H.slice(0));
605
755
  },
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];
756
+ _doProcessBlock: function(M, offset) {
757
+ var H2 = this._hash.words;
758
+ var a = H2[0];
759
+ var b = H2[1];
760
+ var c = H2[2];
761
+ var d = H2[3];
762
+ var e2 = H2[4];
763
+ var f = H2[5];
764
+ var g = H2[6];
765
+ var h = H2[7];
766
+ for (var i = 0; i < 64; i++) {
767
+ if (i < 16) {
768
+ W[i] = M[offset + i] | 0;
769
+ } else {
770
+ var gamma0x = W[i - 15];
771
+ var gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
772
+ var gamma1x = W[i - 2];
773
+ var gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
774
+ W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
613
775
  }
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;
776
+ var ch = e2 & f ^ ~e2 & g;
777
+ var maj = a & b ^ a & c ^ b & c;
778
+ var sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
779
+ var sigma1 = (e2 << 26 | e2 >>> 6) ^ (e2 << 21 | e2 >>> 11) ^ (e2 << 7 | e2 >>> 25);
780
+ var t1 = h + sigma1 + ch + K[i] + W[i];
781
+ var t2 = sigma0 + maj;
782
+ h = g;
783
+ g = f;
784
+ f = e2;
785
+ e2 = d + t1 | 0;
786
+ d = c;
787
+ c = b;
788
+ b = a;
789
+ a = t1 + t2 | 0;
616
790
  }
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;
791
+ H2[0] = H2[0] + a | 0;
792
+ H2[1] = H2[1] + b | 0;
793
+ H2[2] = H2[2] + c | 0;
794
+ H2[3] = H2[3] + d | 0;
795
+ H2[4] = H2[4] + e2 | 0;
796
+ H2[5] = H2[5] + f | 0;
797
+ H2[6] = H2[6] + g | 0;
798
+ H2[7] = H2[7] + h | 0;
618
799
  },
619
800
  _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;
801
+ var data = this._data;
802
+ var dataWords = data.words;
803
+ var nBitsTotal = this._nDataBytes * 8;
804
+ var nBitsLeft = data.sigBytes * 8;
805
+ dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
806
+ dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math2.floor(nBitsTotal / 4294967296);
807
+ dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
808
+ data.sigBytes = dataWords.length * 4;
809
+ this._process();
810
+ return this._hash;
622
811
  },
623
812
  clone: function() {
624
- var f = R.clone.call(this);
625
- return f._hash = this._hash.clone(), f;
813
+ var clone = Hasher.clone.call(this);
814
+ clone._hash = this._hash.clone();
815
+ return clone;
626
816
  }
627
817
  });
628
- a.SHA256 = R._createHelper(m), a.HmacSHA256 = R._createHmacHelper(m);
629
- }(Math), o.SHA256;
818
+ C.SHA256 = Hasher._createHelper(SHA256);
819
+ C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
820
+ })(Math);
821
+ return CryptoJS.SHA256;
630
822
  });
631
- })(Tr);
632
- var Be = {}, yr = {
823
+ })(sha256);
824
+ var encBase64Exports = {};
825
+ var encBase64 = {
633
826
  get exports() {
634
- return Be;
827
+ return encBase64Exports;
635
828
  },
636
- set exports(e) {
637
- Be = e;
829
+ set exports(v) {
830
+ encBase64Exports = v;
638
831
  }
639
832
  };
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 = {
833
+ (function(module, exports) {
834
+ (function(root, factory) {
835
+ {
836
+ module.exports = factory(requireCore());
837
+ }
838
+ })(commonjsGlobal, function(CryptoJS) {
839
+ (function() {
840
+ var C = CryptoJS;
841
+ var C_lib = C.lib;
842
+ var WordArray = C_lib.WordArray;
843
+ var C_enc = C.enc;
844
+ C_enc.Base64 = {
647
845
  /**
648
846
  * Converts a word array to a Base64 string.
649
847
  *
@@ -657,17 +855,28 @@ var Be = {}, yr = {
657
855
  *
658
856
  * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
659
857
  */
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("");
858
+ stringify: function(wordArray) {
859
+ var words = wordArray.words;
860
+ var sigBytes = wordArray.sigBytes;
861
+ var map = this._map;
862
+ wordArray.clamp();
863
+ var base64Chars = [];
864
+ for (var i = 0; i < sigBytes; i += 3) {
865
+ var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
866
+ var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
867
+ var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
868
+ var triplet = byte1 << 16 | byte2 << 8 | byte3;
869
+ for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) {
870
+ base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63));
871
+ }
872
+ }
873
+ var paddingChar = map.charAt(64);
874
+ if (paddingChar) {
875
+ while (base64Chars.length % 4) {
876
+ base64Chars.push(paddingChar);
877
+ }
878
+ }
879
+ return base64Chars.join("");
671
880
  },
672
881
  /**
673
882
  * Converts a Base64 string to a word array.
@@ -682,152 +891,227 @@ var Be = {}, yr = {
682
891
  *
683
892
  * var wordArray = CryptoJS.enc.Base64.parse(base64String);
684
893
  */
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;
894
+ parse: function(base64Str) {
895
+ var base64StrLength = base64Str.length;
896
+ var map = this._map;
897
+ var reverseMap = this._reverseMap;
898
+ if (!reverseMap) {
899
+ reverseMap = this._reverseMap = [];
900
+ for (var j = 0; j < map.length; j++) {
901
+ reverseMap[map.charCodeAt(j)] = j;
902
+ }
691
903
  }
692
- var f = I.charAt(64);
693
- if (f) {
694
- var N = O.indexOf(f);
695
- N !== -1 && (y = N);
904
+ var paddingChar = map.charAt(64);
905
+ if (paddingChar) {
906
+ var paddingIndex = base64Str.indexOf(paddingChar);
907
+ if (paddingIndex !== -1) {
908
+ base64StrLength = paddingIndex;
909
+ }
696
910
  }
697
- return R(O, y, T);
911
+ return parseLoop(base64Str, base64StrLength, reverseMap);
698
912
  },
699
913
  _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
700
914
  };
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++;
915
+ function parseLoop(base64Str, base64StrLength, reverseMap) {
916
+ var words = [];
917
+ var nBytes = 0;
918
+ for (var i = 0; i < base64StrLength; i++) {
919
+ if (i % 4) {
920
+ var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2;
921
+ var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2;
922
+ var bitsCombined = bits1 | bits2;
923
+ words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8;
924
+ nBytes++;
706
925
  }
707
- return i.create(T, m);
926
+ }
927
+ return WordArray.create(words, nBytes);
708
928
  }
709
- }(), o.enc.Base64;
929
+ })();
930
+ return CryptoJS.enc.Base64;
710
931
  });
711
- })(yr);
712
- var re;
713
- class Xe {
932
+ })(encBase64);
933
+ class CryptoUtils {
714
934
  constructor() {
715
- l(this, re, void 0);
716
- D(this, "DigestMessage", async function(t) {
717
- const o = He(t);
718
- return Be.stringify(o);
935
+ __privateAdd(this, _crypto, void 0);
936
+ __publicField(this, "DigestMessage", async function(message) {
937
+ const hashDigest = sha256Exports(message);
938
+ return encBase64Exports.stringify(hashDigest);
719
939
  });
720
- D(this, "CreateRandomString", (t = 43) => {
721
- const o = Array.from(r(this, re).getRandomValues(new Uint8Array(t)));
722
- return btoa(String.fromCharCode(...o));
940
+ __publicField(this, "CreateRandomString", (size = 43) => {
941
+ const randomValues = Array.from(__privateGet(this, _crypto).getRandomValues(new Uint8Array(size)));
942
+ const b64 = btoa(String.fromCharCode(...randomValues));
943
+ return b64;
723
944
  });
724
945
  try {
725
- k(this, re, crypto);
946
+ __privateSet(this, _crypto, crypto);
726
947
  } catch {
727
- k(this, re, require("crypto"));
948
+ __privateSet(this, _crypto, require("crypto"));
728
949
  }
729
950
  }
730
951
  }
731
- re = new WeakMap();
732
- class Ze {
952
+ _crypto = new WeakMap();
953
+ class QueryParams {
733
954
  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;
955
+ __publicField(this, "DecodeQueryParams", (params) => {
956
+ const retObj = {};
957
+ Object.keys(params).filter((k) => typeof params[k] !== "undefined").map((k) => {
958
+ retObj[decodeURIComponent(k)] = decodeURIComponent(params[k]);
959
+ });
960
+ return retObj;
961
+ });
962
+ __publicField(this, "CreateQueryParams", (params) => {
963
+ return Object.keys(params).filter((k) => typeof params[k] !== "undefined").map((k) => {
964
+ if (Array.isArray(params[k])) {
965
+ return encodeURIComponent(k) + "=" + encodeURIComponent(params[k].join(" "));
966
+ } else {
967
+ return encodeURIComponent(k) + "=" + encodeURIComponent(params[k]);
968
+ }
969
+ }).join("&");
739
970
  });
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);
971
+ __publicField(this, "_GetQueryParams", (param) => {
972
+ let retVal = {};
973
+ const uri = param.split("?");
974
+ if (uri.length == 2) {
975
+ const vars = uri[1].split("&");
976
+ const getVars = {};
977
+ let tmp;
978
+ vars.forEach(function(v) {
979
+ tmp = v.split("=");
980
+ if (tmp.length == 2)
981
+ getVars[tmp[0]] = tmp[1];
982
+ });
983
+ retVal = this.DecodeQueryParams(getVars);
750
984
  }
751
- return o;
985
+ return retVal;
986
+ });
987
+ __publicField(this, "GetQueryParams", () => {
988
+ return this._GetQueryParams(window.location.href);
752
989
  });
753
- D(this, "GetQueryParams", () => this._GetQueryParams(window.location.href));
754
990
  }
755
991
  }
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;
992
+ var AuthorizeOptionsResponseType = /* @__PURE__ */ ((AuthorizeOptionsResponseType2) => {
993
+ AuthorizeOptionsResponseType2["CODE"] = "code";
994
+ AuthorizeOptionsResponseType2["ID_TOKEN"] = "id_token";
995
+ AuthorizeOptionsResponseType2["TOKEN"] = "token";
996
+ return AuthorizeOptionsResponseType2;
997
+ })(AuthorizeOptionsResponseType || {});
998
+ var AuthorizeOptionsResponseMode = /* @__PURE__ */ ((AuthorizeOptionsResponseMode2) => {
999
+ AuthorizeOptionsResponseMode2["QUERY"] = "query";
1000
+ AuthorizeOptionsResponseMode2["FRAGMENT"] = "fragment";
1001
+ AuthorizeOptionsResponseMode2["FORM_POST"] = "form_post";
1002
+ return AuthorizeOptionsResponseMode2;
1003
+ })(AuthorizeOptionsResponseMode || {});
1004
+ var OAuthGrantTypes = /* @__PURE__ */ ((OAuthGrantTypes2) => {
1005
+ OAuthGrantTypes2["CLIENT_CREDENTIALS"] = "client_credentials";
1006
+ OAuthGrantTypes2["AUTHORIZATION_CODE"] = "authorization_code";
1007
+ OAuthGrantTypes2["REFRESH_TOKEN"] = "refresh_token";
1008
+ return OAuthGrantTypes2;
1009
+ })(OAuthGrantTypes || {});
1010
+ var IOauth2ListenerCommand = /* @__PURE__ */ ((IOauth2ListenerCommand2) => {
1011
+ IOauth2ListenerCommand2["RESTORE_SESSION"] = "RestoreSession";
1012
+ IOauth2ListenerCommand2["AUTHORIZE"] = "Authorize";
1013
+ IOauth2ListenerCommand2["HANDLE_REDIRECT"] = "HandleRedirect";
1014
+ IOauth2ListenerCommand2["LOGOUT"] = "Logout";
1015
+ IOauth2ListenerCommand2["AUTHENTICATE_EVENT"] = "AuthenticateEvent";
1016
+ IOauth2ListenerCommand2["ERROR"] = "Error";
1017
+ IOauth2ListenerCommand2["LOG"] = "__LOG";
1018
+ IOauth2ListenerCommand2["UPDATE_INSTRUMENT"] = "__UPDATE_INSTRUMENT";
1019
+ IOauth2ListenerCommand2["ID_TOKEN"] = "__ID_TOKEN";
1020
+ IOauth2ListenerCommand2["ACCESS_TOKEN"] = "__ACCESS_TOKEN";
1021
+ IOauth2ListenerCommand2["COOKIES"] = "__COOKIES";
1022
+ IOauth2ListenerCommand2["EXECUTE_REFRESH_TOKEN"] = "__EXECUTE_REFRESH_TOKEN";
1023
+ return IOauth2ListenerCommand2;
1024
+ })(IOauth2ListenerCommand || {});
1025
+ function e(e2) {
1026
+ this.message = e2;
759
1027
  }
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;
1028
+ e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
1029
+ var r = "undefined" != typeof window && window.atob && window.atob.bind(window) || function(r2) {
1030
+ var t2 = String(r2).replace(/=+$/, "");
1031
+ if (t2.length % 4 == 1)
1032
+ throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
1033
+ for (var n2, o2, a = 0, i = 0, c = ""; o2 = t2.charAt(i++); ~o2 && (n2 = a % 4 ? 64 * n2 + o2 : o2, a++ % 4) ? c += String.fromCharCode(255 & n2 >> (-2 * a & 6)) : 0)
1034
+ o2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o2);
1035
+ return c;
768
1036
  };
769
- function Ar(e) {
770
- var t = e.replace(/-/g, "+").replace(/_/g, "/");
771
- switch (t.length % 4) {
1037
+ function t(e2) {
1038
+ var t2 = e2.replace(/-/g, "+").replace(/_/g, "/");
1039
+ switch (t2.length % 4) {
772
1040
  case 0:
773
1041
  break;
774
1042
  case 2:
775
- t += "==";
1043
+ t2 += "==";
776
1044
  break;
777
1045
  case 3:
778
- t += "=";
1046
+ t2 += "=";
779
1047
  break;
780
1048
  default:
781
1049
  throw "Illegal base64url string!";
782
1050
  }
783
1051
  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;
1052
+ return function(e3) {
1053
+ return decodeURIComponent(r(e3).replace(/(.)/g, function(e4, r2) {
1054
+ var t3 = r2.charCodeAt(0).toString(16).toUpperCase();
1055
+ return t3.length < 2 && (t3 = "0" + t3), "%" + t3;
788
1056
  }));
789
- }(t);
790
- } catch {
791
- return Je(t);
1057
+ }(t2);
1058
+ } catch (e3) {
1059
+ return r(t2);
792
1060
  }
793
1061
  }
794
- function Te(e) {
795
- this.message = e;
1062
+ function n(e2) {
1063
+ this.message = e2;
796
1064
  }
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;
1065
+ function o(e2, r2) {
1066
+ if ("string" != typeof e2)
1067
+ throw new n("Invalid token specified");
1068
+ var o2 = true === (r2 = r2 || {}).header ? 0 : 1;
801
1069
  try {
802
- return JSON.parse(Ar(e.split(".")[o]));
803
- } catch (n) {
804
- throw new Te("Invalid token specified: " + n.message);
1070
+ return JSON.parse(t(e2.split(".")[o2]));
1071
+ } catch (e3) {
1072
+ throw new n("Invalid token specified: " + e3.message);
805
1073
  }
806
1074
  }
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
- }),
1075
+ n.prototype = new Error(), n.prototype.name = "InvalidTokenError";
1076
+ const STSOauth2Store = defineStore("__sts__STSOauth2Store", {
1077
+ state: () => {
1078
+ return {
1079
+ id_token: null,
1080
+ error: null
1081
+ };
1082
+ },
813
1083
  actions: {
814
- UpdateIdToken(e) {
815
- this.id_token = e;
1084
+ UpdateIdToken(id_token) {
1085
+ this.id_token = id_token;
816
1086
  },
817
- UpdateError(e) {
818
- this.error ? this.error.message = e : this.error = {
819
- message: e
820
- };
1087
+ UpdateError(error) {
1088
+ if (this.error) {
1089
+ this.error.message = error;
1090
+ } else {
1091
+ this.error = {
1092
+ message: error
1093
+ };
1094
+ }
821
1095
  }
822
1096
  },
823
1097
  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
1098
+ LoggedIn: (state) => {
1099
+ if (typeof state.id_token === "undefined") {
1100
+ return false;
1101
+ }
1102
+ if (state.id_token === null) {
1103
+ return false;
1104
+ }
1105
+ return true;
1106
+ },
1107
+ UserDetails: (state) => {
1108
+ if (state.id_token) {
1109
+ const id_token = state.id_token;
1110
+ const decodedIdToken = o(id_token);
1111
+ return decodedIdToken;
1112
+ } else {
830
1113
  return null;
1114
+ }
831
1115
  }
832
1116
  }
833
1117
  /*
@@ -836,281 +1120,363 @@ const Sr = qe("__sts__STSOauth2Store", {
836
1120
  }
837
1121
  */
838
1122
  });
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 {
1123
+ let debug$1;
1124
+ if (isNode) {
1125
+ debug$1 = Debug(`proc:${process.pid}:stsoauth2manager.ts`);
1126
+ } else {
1127
+ debug$1 = Debug(`proc:0:stsoauth2manager.ts`);
1128
+ }
1129
+ class STSOAuth2Manager {
843
1130
  // ms
844
- constructor(t, o) {
1131
+ constructor(app, options) {
845
1132
  // 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);
1133
+ __privateAdd(this, _router, null);
1134
+ __privateAdd(this, _cUtils, new CryptoUtils());
1135
+ __privateAdd(this, _qParams, new QueryParams());
1136
+ __privateAdd(this, _STORAGE_AUTHORIZE_OPTIONS_KEY, "authorize_options.stsmda.com.au");
1137
+ __privateAdd(this, _STORAGE_SESSION_KEY, "session.stsmda.com.au");
1138
+ __privateAdd(this, _aic, null);
1139
+ __privateAdd(this, _options, void 0);
1140
+ __privateAdd(this, _messages, {});
1141
+ __privateAdd(this, _oauth2ManagerPort, void 0);
1142
+ __privateAdd(this, _messageId, 0);
856
1143
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
857
- l(this, Y, {});
1144
+ __privateAdd(this, _messageHandlers, {});
858
1145
  // keyed by messageId
859
- l(this, le, 1e4);
860
- l(this, W, void 0);
861
- l(this, K, void 0);
1146
+ __privateAdd(this, _messageTimeout, 1e4);
1147
+ __privateAdd(this, _worker, void 0);
1148
+ __privateAdd(this, _transactionStore, void 0);
862
1149
  // Transient transaction data used to establish a session via OAuth2 authorize handshake
863
- l(this, ne, !1);
864
- l(this, he, 100);
1150
+ __privateAdd(this, _operationSemaphore, false);
1151
+ __privateAdd(this, _maxSemaphoreRetries, 100);
865
1152
  // 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);
1153
+ __privateAdd(this, _semaphoreRetrySleep, 50);
1154
+ __privateAdd(this, _ProcessMessageResponse, (data) => {
1155
+ const messageResponse = data;
1156
+ debug$1(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`.yellow);
1157
+ if (messageResponse.messageId === -1) {
1158
+ switch (messageResponse.command) {
1159
+ case IOauth2ListenerCommand.AUTHENTICATE_EVENT:
1160
+ __privateGet(this, _HandleAuthenticateEvent).call(this, messageResponse.payload);
873
1161
  break;
874
- case d.ERROR:
875
- r(this, me).call(this, o.payload);
1162
+ case IOauth2ListenerCommand.ERROR:
1163
+ __privateGet(this, _HandleErrorEvent).call(this, messageResponse.payload);
876
1164
  break;
877
- case d.LOG:
878
- r(this, de).call(this, o.payload);
1165
+ case IOauth2ListenerCommand.LOG:
1166
+ __privateGet(this, _HandleLogEvent).call(this, messageResponse.payload);
879
1167
  break;
880
- case d.UPDATE_INSTRUMENT:
881
- r(this, Re).call(this, o.payload.instrumentName, o.payload.telemetry);
1168
+ case IOauth2ListenerCommand.UPDATE_INSTRUMENT:
1169
+ __privateGet(this, _HandleUpdateInstrumentEvent).call(this, messageResponse.payload.instrumentName, messageResponse.payload.telemetry);
882
1170
  break;
883
1171
  default:
884
- throw new Error(`ProcessMessageResponse command [${o.command}] not valid.`);
1172
+ throw new Error(`ProcessMessageResponse command [${messageResponse.command}] not valid.`);
1173
+ }
1174
+ } else {
1175
+ const callBack = __privateGet(this, _messageHandlers)[messageResponse.messageId];
1176
+ if (callBack) {
1177
+ callBack(messageResponse);
1178
+ } else {
1179
+ throw new Error(`Message: [${messageResponse.messageId}] does not exists in callBacks.`);
885
1180
  }
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
1181
  }
893
1182
  });
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);
1183
+ __privateAdd(this, _PostMessage, (message) => {
1184
+ message.messageId = __privateWrapper(this, _messageId)._++;
1185
+ return new Promise((resolve, reject) => {
1186
+ const timeout = setTimeout(() => {
1187
+ delete __privateGet(this, _messageHandlers)[message.messageId];
1188
+ reject(`Message: [${message.messageId}] timeout error after: [${__privateGet(this, _messageTimeout)}] ms.`);
1189
+ }, __privateGet(this, _messageTimeout));
1190
+ __privateGet(this, _messageHandlers)[message.messageId] = (response) => {
1191
+ clearTimeout(timeout);
1192
+ delete __privateGet(this, _messageHandlers)[message.messageId];
1193
+ debug$1(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`.yellow);
1194
+ resolve(response);
1195
+ };
1196
+ debug$1(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`.yellow);
1197
+ __privateGet(this, _oauth2ManagerPort).postMessage(message);
1198
+ });
1199
+ });
1200
+ __privateAdd(this, _HandleLogEvent, (message) => {
1201
+ if (__privateGet(this, _aic)) {
1202
+ __privateGet(this, _aic).LogEx(message);
1203
+ }
1204
+ debug$1(message);
904
1205
  });
905
1206
  // UpdateInstrument = (instrumentName: Gauge, telemetry: InstrumentBaseTelemetry): void => {
906
- l(this, Re, (t, o) => {
907
- r(this, z) && r(this, z).UpdateInstrument(t, o);
1207
+ __privateAdd(this, _HandleUpdateInstrumentEvent, (instrumentName, telemetry) => {
1208
+ if (__privateGet(this, _aic)) {
1209
+ __privateGet(this, _aic).UpdateInstrument(instrumentName, telemetry);
1210
+ }
1211
+ });
1212
+ __privateAdd(this, _GetStore, () => {
1213
+ return STSOauth2Store(__privateGet(this, _options).pinia);
908
1214
  });
909
- l(this, V, () => Sr(r(this, $).pinia));
910
1215
  // 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));
1216
+ __privateAdd(this, _HandleErrorEvent, (error) => {
1217
+ if (isNode)
1218
+ ;
1219
+ else {
1220
+ __privateGet(this, _GetStore).call(this).UpdateError({
1221
+ // Authorize applications store
1222
+ message: error
1223
+ });
1224
+ setTimeout(() => {
1225
+ __privateGet(this, _router).replace("/error");
1226
+ }, 0);
1227
+ }
918
1228
  });
919
- l(this, ye, (t) => {
920
- M || (r(this, $).authenticateEvent && r(this, $).authenticateEvent(t), r(this, V).call(this).UpdateIdToken(t));
1229
+ __privateAdd(this, _HandleAuthenticateEvent, (id_token) => {
1230
+ if (isNode)
1231
+ ;
1232
+ else {
1233
+ if (__privateGet(this, _options).authenticateEvent) {
1234
+ __privateGet(this, _options).authenticateEvent(id_token);
1235
+ }
1236
+ __privateGet(this, _GetStore).call(this).UpdateIdToken(id_token);
1237
+ }
921
1238
  });
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();
1239
+ __privateAdd(this, _SetupRoute, (app, router) => {
1240
+ debug$1(`STSOAuth2Manager:#SetupRoute`.gray);
1241
+ router.beforeEach(async (to, from, next) => {
1242
+ const oAuth2Manager = app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey];
1243
+ debug$1(`beforeEach: from: [${from.path}], to: [${to.path}]`.gray);
1244
+ if (__privateGet(this, _GetStore).call(this).LoggedIn === false) {
1245
+ console.log(`Not logged in`);
1246
+ if (to.path.localeCompare("/authorize") === 0) {
1247
+ console.log(`to = /authorize`);
1248
+ next();
931
1249
  return;
1250
+ } else if (to.path.localeCompare("/consent") === 0) {
1251
+ if (__privateGet(this, _GetStore).call(this).id_token) {
1252
+ next();
1253
+ return;
1254
+ }
932
1255
  }
933
- if (n.path.localeCompare("/logout") === 0) {
934
- i();
1256
+ if (to.path.localeCompare("/logout") === 0) {
1257
+ next();
935
1258
  return;
936
1259
  }
937
- if (n.path.localeCompare("/error") === 0) {
938
- i();
1260
+ if (to.path.localeCompare("/error") === 0) {
1261
+ next();
939
1262
  return;
940
1263
  }
941
- if (n.path.localeCompare("/config") === 0) {
942
- i();
1264
+ if (to.path.localeCompare("/config") === 0) {
1265
+ next();
943
1266
  return;
944
1267
  }
945
- if (n.path.localeCompare("/redirected") === 0) {
946
- i();
1268
+ if (to.path.localeCompare("/redirected") === 0) {
1269
+ next();
947
1270
  return;
948
1271
  }
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({
1272
+ const str = to.query;
1273
+ if (str[OAuth2ParameterType.CODE] || str[OAuth2ParameterType.ERROR]) {
1274
+ debug$1(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`.magenta);
1275
+ const retVal = await oAuth2Manager.HandleRedirect(str);
1276
+ debug$1(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`.magenta);
1277
+ if (retVal) {
1278
+ next({
955
1279
  path: "/",
956
- replace: !0
1280
+ replace: true
957
1281
  });
958
1282
  return;
959
1283
  } else {
960
- i({
1284
+ next({
961
1285
  path: "/error",
962
- replace: !0
1286
+ replace: true
963
1287
  });
964
1288
  return;
965
1289
  }
966
1290
  }
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();
1291
+ debug$1(`STSOAuth2Manager:#SetupRoute:Restoring session`);
1292
+ const sessionRestored = await oAuth2Manager.RestoreSession();
1293
+ debug$1(`STSOAuth2Manager:#SetupRoute:Session restored: [${sessionRestored}]`);
1294
+ if (sessionRestored !== true) {
1295
+ debug$1(`STSOAuth2Manager:#SetupRoute:Session not restored - need to authorize`);
1296
+ oAuth2Manager.Authorize();
1297
+ next();
971
1298
  return;
972
1299
  } else {
973
- i("/");
1300
+ next("/");
974
1301
  return;
975
1302
  }
976
1303
  } else {
977
- if (n.path.localeCompare("/consent") === 0) {
978
- i("/");
1304
+ if (to.path.localeCompare("/consent") === 0) {
1305
+ next("/");
979
1306
  return;
980
1307
  }
981
- if (n.path.localeCompare("/authorize") === 0) {
982
- i("/");
1308
+ if (to.path.localeCompare("/authorize") === 0) {
1309
+ next("/");
983
1310
  return;
984
1311
  }
985
- if (n.path.localeCompare("/logout") === 0) {
986
- i("/");
1312
+ if (to.path.localeCompare("/logout") === 0) {
1313
+ next("/");
987
1314
  return;
988
1315
  }
989
- i();
1316
+ next();
990
1317
  }
991
1318
  });
992
1319
  });
993
1320
  //@@ 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);
1321
+ __publicField(this, "GetAccessToken", async () => {
1322
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.ACCESS_TOKEN });
1323
+ return response.payload;
1324
+ });
995
1325
  // 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);
1326
+ __publicField(this, "ExecuteRefreshToken", async (retryCount = 0) => {
1327
+ if (__privateGet(this, _operationSemaphore) === true) {
1328
+ if (retryCount > __privateGet(this, _maxSemaphoreRetries)) {
1329
+ throw new Error(`STSOAuth2Manager:ExecuteRefreshToken:maxSemaphoreRetries: [${__privateGet(this, _maxSemaphoreRetries)}] exceeded.`);
1330
+ }
1331
+ await Sleep(__privateGet(this, _semaphoreRetrySleep));
1332
+ debug$1(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`.cyan);
1333
+ return await this.ExecuteRefreshToken(retryCount + 1);
1001
1334
  } 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;
1335
+ __privateSet(this, _operationSemaphore, true);
1336
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.EXECUTE_REFRESH_TOKEN });
1337
+ __privateSet(this, _operationSemaphore, false);
1338
+ return response.payload;
1005
1339
  }
1006
1340
  });
1007
1341
  // 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 () => {
1342
+ __publicField(this, "GetCookies", async () => {
1343
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.COOKIES });
1344
+ return response.payload;
1345
+ });
1346
+ __publicField(this, "RestoreSession", async () => {
1010
1347
  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;
1348
+ debug$1(`STSOAuth2Manager:RestoreSession:postMessage: [${IOauth2ListenerCommand.RESTORE_SESSION}]`);
1349
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.RESTORE_SESSION });
1350
+ debug$1(`STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
1351
+ return response.payload;
1352
+ } catch (error) {
1353
+ console.log(`RestoreSession Error: ${error}`);
1354
+ return false;
1016
1355
  }
1017
1356
  });
1018
- D(this, "Authorize", async () => {
1357
+ __publicField(this, "Authorize", async () => {
1019
1358
  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}`);
1359
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.AUTHORIZE });
1360
+ __privateGet(this, _transactionStore).set(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY), response.payload.authorizeOptions);
1361
+ const url = response.payload.url;
1362
+ if (!isNode) {
1363
+ window.location.replace(url);
1364
+ } else {
1365
+ return response.payload.authorizeOptionsClientCopy;
1366
+ }
1367
+ } catch (error) {
1368
+ console.log(`Authorize Error: ${error}`);
1029
1369
  }
1030
1370
  return {};
1031
1371
  });
1032
- D(this, "HandleRedirect", async (t) => {
1372
+ __publicField(this, "HandleRedirect", async (queryVars) => {
1033
1373
  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
1374
+ debug$1(`STSOAuth2Manager:HandleRedirect`.magenta);
1375
+ let response = null;
1376
+ if (queryVars[OAuth2ParameterType.CODE]) {
1377
+ const authorizeOptions = __privateGet(this, _transactionStore).get(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
1378
+ __privateGet(this, _transactionStore).remove(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
1379
+ debug$1(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`.magenta);
1380
+ response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
1381
+ queryVars,
1382
+ authorizeOptions
1041
1383
  } });
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;
1384
+ } else {
1385
+ response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
1386
+ }
1387
+ debug$1(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`.magenta);
1388
+ return response.payload;
1389
+ } catch (error) {
1390
+ console.log(`HandleRedirect Error: ${error}`);
1391
+ return false;
1047
1392
  }
1048
1393
  });
1049
- D(this, "Logout", async () => {
1394
+ __publicField(this, "Logout", async () => {
1050
1395
  try {
1051
- return (await r(this, C).call(this, { command: d.LOGOUT })).payload;
1052
- } catch (t) {
1053
- return console.log(`Logout Error: ${t}`), !1;
1396
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
1397
+ return response.payload;
1398
+ } catch (error) {
1399
+ console.log(`Logout Error: ${error}`);
1400
+ return false;
1054
1401
  }
1055
1402
  });
1056
1403
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1057
- D(this, "InvokeExternalAPI", async () => {
1404
+ __publicField(this, "InvokeExternalAPI", async () => {
1058
1405
  try {
1059
- return (await r(this, C).call(this, { command: d.LOGOUT })).payload;
1060
- } catch (t) {
1061
- return console.log(`InvokeExternalAPI Error: ${t}`), null;
1406
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
1407
+ return response.payload;
1408
+ } catch (error) {
1409
+ console.log(`InvokeExternalAPI Error: ${error}`);
1410
+ return null;
1062
1411
  }
1063
1412
  });
1064
- D(this, "LoggedIn", () => {
1413
+ __publicField(this, "LoggedIn", () => {
1065
1414
  try {
1066
- return r(this, V).call(this).LoggedIn;
1067
- } catch {
1068
- return !1;
1415
+ return __privateGet(this, _GetStore).call(this).LoggedIn;
1416
+ } catch (error) {
1417
+ return false;
1069
1418
  }
1070
1419
  });
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);
1420
+ __privateSet(this, _options, options);
1421
+ if (!isNode) {
1422
+ if (app.config.globalProperties.$sts[STSInstrumentControllerPluginKey]) {
1423
+ const STSInstrumentController = app.config.globalProperties.$sts[STSInstrumentControllerPluginKey];
1424
+ __privateSet(this, _aic, STSInstrumentController.PrimaryPublishInstrumentController);
1075
1425
  }
1076
- k(this, te, t.config.globalProperties.$router);
1426
+ __privateSet(this, _router, app.config.globalProperties.$router);
1077
1427
  }
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) {
1428
+ if (isNode) {
1429
+ __privateSet(this, _transactionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage());
1430
+ } else {
1431
+ __privateSet(this, _transactionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.SESSION_STORAGE, usePrefix: false }).GetStorage());
1432
+ }
1433
+ if (__privateGet(this, _options).workerFactory) {
1434
+ __privateSet(this, _worker, __privateGet(this, _options).workerFactory());
1435
+ } else {
1436
+ throw new Error(`STSOAuth2Manager:constructor: Cannot init STSOAuth2Manager - this.#options.workerFactory not specified`);
1437
+ }
1438
+ if (!isNode) {
1439
+ __privateGet(this, _worker).onmessage = (data) => {
1440
+ console.log(`this.#worker.onmessage = [${data}]`);
1441
+ };
1442
+ __privateGet(this, _worker).onerror = function(error) {
1443
+ console.log(`this.#worker.onerror = [${JSON.stringify(error)}]`);
1444
+ };
1445
+ }
1446
+ let workerMessage;
1447
+ if (isNode) {
1089
1448
  const {
1090
- port1: a,
1449
+ port1: oauth2ManagerPort,
1091
1450
  // this process port
1092
- port2: i
1451
+ port2: oauth2WorkerPort
1093
1452
  // 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);
1453
+ } = new wt.MessageChannel();
1454
+ __privateSet(this, _oauth2ManagerPort, oauth2ManagerPort);
1455
+ workerMessage = {
1456
+ workerPort: oauth2WorkerPort,
1457
+ options: __privateGet(this, _options).workerOptions
1458
+ };
1459
+ __privateGet(this, _worker).postMessage(workerMessage, [oauth2WorkerPort]);
1460
+ __privateGet(this, _oauth2ManagerPort).on("message", (payload) => {
1461
+ __privateGet(this, _ProcessMessageResponse).call(this, payload);
1100
1462
  }).unref();
1101
1463
  } else {
1102
1464
  const {
1103
- port1: a,
1465
+ port1: oauth2ManagerPort,
1104
1466
  // this process port
1105
- port2: i
1467
+ port2: oauth2WorkerPort
1106
1468
  // worker port
1107
1469
  } = 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));
1470
+ __privateSet(this, _oauth2ManagerPort, oauth2ManagerPort);
1471
+ workerMessage = {
1472
+ workerPort: oauth2WorkerPort,
1473
+ options: __privateGet(this, _options).workerOptions
1474
+ };
1475
+ __privateGet(this, _worker).postMessage(workerMessage, [oauth2WorkerPort]);
1476
+ __privateGet(this, _oauth2ManagerPort).onmessage = (data) => {
1477
+ __privateGet(this, _ProcessMessageResponse).call(this, data.data);
1478
+ };
1479
+ __privateGet(this, _SetupRoute).call(this, app, __privateGet(this, _router));
1114
1480
  }
1115
1481
  }
1116
1482
  /*
@@ -1125,25 +1491,107 @@ class Ir {
1125
1491
  }
1126
1492
  */
1127
1493
  }
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) {
1494
+ _router = new WeakMap();
1495
+ _cUtils = new WeakMap();
1496
+ _qParams = new WeakMap();
1497
+ _STORAGE_AUTHORIZE_OPTIONS_KEY = new WeakMap();
1498
+ _STORAGE_SESSION_KEY = new WeakMap();
1499
+ _aic = new WeakMap();
1500
+ _options = new WeakMap();
1501
+ _messages = new WeakMap();
1502
+ _oauth2ManagerPort = new WeakMap();
1503
+ _messageId = new WeakMap();
1504
+ _messageHandlers = new WeakMap();
1505
+ _messageTimeout = new WeakMap();
1506
+ _worker = new WeakMap();
1507
+ _transactionStore = new WeakMap();
1508
+ _operationSemaphore = new WeakMap();
1509
+ _maxSemaphoreRetries = new WeakMap();
1510
+ _semaphoreRetrySleep = new WeakMap();
1511
+ _ProcessMessageResponse = new WeakMap();
1512
+ _PostMessage = new WeakMap();
1513
+ _HandleLogEvent = new WeakMap();
1514
+ _HandleUpdateInstrumentEvent = new WeakMap();
1515
+ _GetStore = new WeakMap();
1516
+ _HandleErrorEvent = new WeakMap();
1517
+ _HandleAuthenticateEvent = new WeakMap();
1518
+ _SetupRoute = new WeakMap();
1519
+ var StatusCodes;
1520
+ (function(StatusCodes2) {
1521
+ StatusCodes2[StatusCodes2["ACCEPTED"] = 202] = "ACCEPTED";
1522
+ StatusCodes2[StatusCodes2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
1523
+ StatusCodes2[StatusCodes2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
1524
+ StatusCodes2[StatusCodes2["CONFLICT"] = 409] = "CONFLICT";
1525
+ StatusCodes2[StatusCodes2["CONTINUE"] = 100] = "CONTINUE";
1526
+ StatusCodes2[StatusCodes2["CREATED"] = 201] = "CREATED";
1527
+ StatusCodes2[StatusCodes2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
1528
+ StatusCodes2[StatusCodes2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
1529
+ StatusCodes2[StatusCodes2["FORBIDDEN"] = 403] = "FORBIDDEN";
1530
+ StatusCodes2[StatusCodes2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
1531
+ StatusCodes2[StatusCodes2["GONE"] = 410] = "GONE";
1532
+ StatusCodes2[StatusCodes2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
1533
+ StatusCodes2[StatusCodes2["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
1534
+ StatusCodes2[StatusCodes2["INSUFFICIENT_SPACE_ON_RESOURCE"] = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE";
1535
+ StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
1536
+ StatusCodes2[StatusCodes2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
1537
+ StatusCodes2[StatusCodes2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
1538
+ StatusCodes2[StatusCodes2["LOCKED"] = 423] = "LOCKED";
1539
+ StatusCodes2[StatusCodes2["METHOD_FAILURE"] = 420] = "METHOD_FAILURE";
1540
+ StatusCodes2[StatusCodes2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
1541
+ StatusCodes2[StatusCodes2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
1542
+ StatusCodes2[StatusCodes2["MOVED_TEMPORARILY"] = 302] = "MOVED_TEMPORARILY";
1543
+ StatusCodes2[StatusCodes2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
1544
+ StatusCodes2[StatusCodes2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
1545
+ StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
1546
+ StatusCodes2[StatusCodes2["NO_CONTENT"] = 204] = "NO_CONTENT";
1547
+ StatusCodes2[StatusCodes2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
1548
+ StatusCodes2[StatusCodes2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
1549
+ StatusCodes2[StatusCodes2["NOT_FOUND"] = 404] = "NOT_FOUND";
1550
+ StatusCodes2[StatusCodes2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
1551
+ StatusCodes2[StatusCodes2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
1552
+ StatusCodes2[StatusCodes2["OK"] = 200] = "OK";
1553
+ StatusCodes2[StatusCodes2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
1554
+ StatusCodes2[StatusCodes2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
1555
+ StatusCodes2[StatusCodes2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
1556
+ StatusCodes2[StatusCodes2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
1557
+ StatusCodes2[StatusCodes2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
1558
+ StatusCodes2[StatusCodes2["PROCESSING"] = 102] = "PROCESSING";
1559
+ StatusCodes2[StatusCodes2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
1560
+ StatusCodes2[StatusCodes2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
1561
+ StatusCodes2[StatusCodes2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
1562
+ StatusCodes2[StatusCodes2["REQUEST_TOO_LONG"] = 413] = "REQUEST_TOO_LONG";
1563
+ StatusCodes2[StatusCodes2["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG";
1564
+ StatusCodes2[StatusCodes2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
1565
+ StatusCodes2[StatusCodes2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
1566
+ StatusCodes2[StatusCodes2["SEE_OTHER"] = 303] = "SEE_OTHER";
1567
+ StatusCodes2[StatusCodes2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
1568
+ StatusCodes2[StatusCodes2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
1569
+ StatusCodes2[StatusCodes2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
1570
+ StatusCodes2[StatusCodes2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
1571
+ StatusCodes2[StatusCodes2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
1572
+ StatusCodes2[StatusCodes2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
1573
+ StatusCodes2[StatusCodes2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
1574
+ StatusCodes2[StatusCodes2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
1575
+ StatusCodes2[StatusCodes2["USE_PROXY"] = 305] = "USE_PROXY";
1576
+ StatusCodes2[StatusCodes2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
1577
+ })(StatusCodes || (StatusCodes = {}));
1578
+ let debug;
1579
+ if (isNode) {
1580
+ debug = Debug(`proc:${process.pid}:stsoauth2worker.ts`);
1581
+ } else {
1582
+ debug = Debug(`proc:0:stsoauth2worker.ts`);
1583
+ }
1584
+ class STSOAuth2Worker {
1585
+ constructor(workerPort, options) {
1138
1586
  //#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");
1587
+ __privateAdd(this, _clientSessionStore, void 0);
1588
+ __privateAdd(this, _cUtils2, new CryptoUtils());
1589
+ __privateAdd(this, _qParams2, new QueryParams());
1590
+ __privateAdd(this, _STORAGE_SESSION_KEY2, "session.stsmda.com.au");
1143
1591
  //@@#aic = null;
1144
- l(this, q, void 0);
1145
- l(this, h, void 0);
1146
- l(this, j, null);
1592
+ __privateAdd(this, _oauthWorkerPort, void 0);
1593
+ __privateAdd(this, _options2, void 0);
1594
+ __privateAdd(this, _httpsAgent, null);
1147
1595
  // Attempt to restore a previous session using the STSBroker
1148
1596
  /*
1149
1597
  { parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
@@ -1172,81 +1620,92 @@ class Br {
1172
1620
  }
1173
1621
 
1174
1622
  */
1175
- l(this, F, (t) => {
1176
- const o = {
1623
+ __privateAdd(this, _HandleAuthenticateEvent2, (id_token) => {
1624
+ const message = {
1177
1625
  messageId: -1,
1178
1626
  // un-solicited message
1179
- command: d.AUTHENTICATE_EVENT
1627
+ command: IOauth2ListenerCommand.AUTHENTICATE_EVENT
1180
1628
  };
1181
- r(this, H).call(this, o, t);
1629
+ __privateGet(this, _ProcessCommand).call(this, message, id_token);
1182
1630
  });
1183
1631
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1184
- l(this, se, (t) => {
1185
- const o = {
1632
+ __privateAdd(this, _HandleErrorEvent2, (error) => {
1633
+ const message = {
1186
1634
  messageId: -1,
1187
1635
  // un-solicited message
1188
- command: d.ERROR
1636
+ command: IOauth2ListenerCommand.ERROR
1189
1637
  };
1190
- r(this, H).call(this, o, t);
1638
+ __privateGet(this, _ProcessCommand).call(this, message, error);
1191
1639
  });
1192
- l(this, ie, (t) => {
1193
- const o = {
1640
+ __privateAdd(this, _LogMessage, (messageToSend) => {
1641
+ const message = {
1194
1642
  messageId: -1,
1195
1643
  // un-solicited message
1196
- command: d.LOG
1644
+ command: IOauth2ListenerCommand.LOG
1197
1645
  };
1198
- r(this, H).call(this, o, t);
1646
+ __privateGet(this, _ProcessCommand).call(this, message, messageToSend);
1199
1647
  });
1200
- l(this, Ie, () => {
1201
- const t = r(this, b).get(r(this, B));
1202
- return t ? t.tokenResponse.access_token : null;
1648
+ __privateAdd(this, _GetAccessToken, () => {
1649
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
1650
+ if (sessionData) {
1651
+ const tokens = sessionData.tokenResponse;
1652
+ return tokens.access_token;
1653
+ } else {
1654
+ return null;
1655
+ }
1203
1656
  });
1204
1657
  // 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
1658
+ __privateAdd(this, _GetCookies, () => {
1659
+ if (isNode) {
1660
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
1661
+ if (sessionData) {
1662
+ return sessionData.brokerCookie;
1663
+ } else {
1664
+ return null;
1665
+ }
1666
+ } else {
1210
1667
  return null;
1668
+ }
1211
1669
  });
1212
- l(this, ve, (t, o) => {
1213
- const n = {
1670
+ __privateAdd(this, _UpdateInstrument, (instrumentName, telemetry) => {
1671
+ const message = {
1214
1672
  messageId: -1,
1215
1673
  // un-solicited message
1216
- command: d.UPDATE_INSTRUMENT
1674
+ command: IOauth2ListenerCommand.UPDATE_INSTRUMENT
1217
1675
  };
1218
- r(this, H).call(this, n, {
1219
- instrumentName: t,
1220
- telemetry: o
1676
+ __privateGet(this, _ProcessCommand).call(this, message, {
1677
+ instrumentName,
1678
+ telemetry
1221
1679
  });
1222
1680
  });
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));
1681
+ __publicField(this, "SetupListener", () => {
1682
+ __privateGet(this, _oauthWorkerPort).onmessage = async (data) => {
1683
+ const auth2ListenerMessage = data.data;
1684
+ debug(`STSOAuth2Worker:SetupListener:onmessage: [${auth2ListenerMessage.command}]`);
1685
+ switch (auth2ListenerMessage.command) {
1686
+ case IOauth2ListenerCommand.RESTORE_SESSION:
1687
+ __privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _RestoreSession).call(this));
1229
1688
  break;
1230
- case d.AUTHORIZE:
1231
- r(this, H).call(this, o, await r(this, ke).call(this));
1689
+ case IOauth2ListenerCommand.AUTHORIZE:
1690
+ __privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _Authorize).call(this));
1232
1691
  break;
1233
- case d.HANDLE_REDIRECT:
1234
- r(this, H).call(this, o, await r(this, De).call(this, o.payload));
1692
+ case IOauth2ListenerCommand.HANDLE_REDIRECT:
1693
+ __privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _HandleRedirect).call(this, auth2ListenerMessage.payload));
1235
1694
  break;
1236
- case d.LOGOUT:
1237
- r(this, H).call(this, o, await r(this, Pe).call(this));
1695
+ case IOauth2ListenerCommand.LOGOUT:
1696
+ __privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _Logout).call(this));
1238
1697
  break;
1239
- case d.ACCESS_TOKEN:
1240
- r(this, H).call(this, o, await r(this, Ie).call(this));
1698
+ case IOauth2ListenerCommand.ACCESS_TOKEN:
1699
+ __privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _GetAccessToken).call(this));
1241
1700
  break;
1242
- case d.EXECUTE_REFRESH_TOKEN:
1243
- r(this, H).call(this, o, await r(this, fe).call(this));
1701
+ case IOauth2ListenerCommand.EXECUTE_REFRESH_TOKEN:
1702
+ __privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _RefreshToken).call(this));
1244
1703
  break;
1245
- case d.COOKIES:
1246
- r(this, H).call(this, o, await r(this, Ne).call(this));
1704
+ case IOauth2ListenerCommand.COOKIES:
1705
+ __privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _GetCookies).call(this));
1247
1706
  break;
1248
1707
  default:
1249
- throw new Error(`Command: [${o.command}'] not found.`);
1708
+ throw new Error(`Command: [${auth2ListenerMessage.command}'] not found.`);
1250
1709
  }
1251
1710
  };
1252
1711
  });
@@ -1256,83 +1715,142 @@ class Br {
1256
1715
  }
1257
1716
  */
1258
1717
  // 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
1718
+ __privateAdd(this, _ProcessCommand, async (auth2ListenerMessage, response) => {
1719
+ const messageResponse = {
1720
+ messageId: auth2ListenerMessage.messageId,
1721
+ command: auth2ListenerMessage.command,
1722
+ payload: response
1264
1723
  };
1265
- r(this, q).postMessage(n);
1724
+ __privateGet(this, _oauthWorkerPort).postMessage(messageResponse);
1266
1725
  });
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);
1726
+ __privateAdd(this, _RestoreSession, async () => {
1727
+ let restoredSessionData = null;
1728
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
1729
+ if (sessionData) {
1730
+ restoredSessionData = sessionData.tokenResponse;
1731
+ console.log("Session restored from client storage.");
1732
+ __privateGet(this, _LogMessage).call(this, "Session restored from client storage.");
1733
+ } else {
1734
+ const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/session`;
1735
+ console.log("RestoreSession");
1736
+ console.log(url);
1737
+ __privateGet(this, _LogMessage).call(this, "RestoreSession.");
1738
+ __privateGet(this, _LogMessage).call(this, url);
1275
1739
  try {
1276
- const a = {
1740
+ const rConfig = {
1277
1741
  method: "post",
1278
- url: n,
1742
+ url,
1279
1743
  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
1744
+ [OAuth2ParameterType.CLIENT_ID]: __privateGet(this, _options2).client_id,
1745
+ [OAuth2ParameterType.SCOPE]: __privateGet(this, _options2).scope,
1746
+ [OAuth2ParameterType.REDIRECT_URI]: __privateGet(this, _options2).redirect_uri,
1747
+ [OAuth2ParameterType.AUDIENCE]: __privateGet(this, _options2).audience
1284
1748
  },
1285
- withCredentials: !0,
1749
+ withCredentials: true,
1286
1750
  // Ensure cookies are passed to the service
1287
- timeout: r(this, h).timeout
1751
+ timeout: __privateGet(this, _options2).timeout
1288
1752
  };
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
1753
+ debug(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`.magenta);
1754
+ if (isNode) {
1755
+ rConfig.httpsAgent = __privateGet(this, _httpsAgent);
1756
+ }
1757
+ const retVal = await axios(rConfig);
1758
+ if (retVal.data.status === StatusCodes.OK) {
1759
+ restoredSessionData = retVal.data.detail;
1760
+ if (restoredSessionData) {
1761
+ const newSessionData = {
1762
+ tokenResponse: restoredSessionData
1295
1763
  };
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));
1764
+ if (isNode) {
1765
+ newSessionData.brokerCookie = retVal.headers["set-cookie"];
1766
+ }
1767
+ __privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
1768
+ console.log("Session restored from server side cookie.");
1769
+ } else {
1770
+ console.log(`Could not restore previous session. No restoredSessionData available.`);
1771
+ console.log(JSON.stringify(retVal.data));
1772
+ }
1773
+ } else {
1774
+ console.log("Could not restore previous session:-");
1775
+ console.log(JSON.stringify(retVal.data));
1776
+ }
1777
+ } catch (error) {
1778
+ console.log("Could not restore previous session (error state):-");
1779
+ console.log(error);
1780
+ console.log(JSON.stringify(error));
1303
1781
  }
1304
1782
  }
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);
1783
+ if (restoredSessionData !== null) {
1784
+ __privateGet(this, _HandleAuthenticateEvent2).call(this, restoredSessionData.id_token);
1785
+ console.log("Refreshing tokens ...");
1786
+ return await __privateGet(this, _RefreshToken).call(this);
1787
+ } else {
1788
+ __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
1789
+ return false;
1790
+ }
1306
1791
  });
1307
- l(this, ke, async () => {
1792
+ __privateAdd(this, _Authorize, async () => {
1308
1793
  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
1794
+ const client_id = __privateGet(this, _options2).client_id;
1795
+ const nonce = __privateGet(this, _cUtils2).CreateRandomString();
1796
+ const response_type = [AuthorizeOptionsResponseType.CODE];
1797
+ const redirect_uri = __privateGet(this, _options2).redirect_uri;
1798
+ const response_mode = AuthorizeOptionsResponseMode.QUERY;
1799
+ const scope = __privateGet(this, _options2).scope;
1800
+ const state = __privateGet(this, _cUtils2).CreateRandomString();
1801
+ const code_verifier = __privateGet(this, _cUtils2).CreateRandomString();
1802
+ const code_challenge = await __privateGet(this, _cUtils2).DigestMessage(code_verifier);
1803
+ const code_challenge_method = "S256";
1804
+ const authorizeOptions = {
1805
+ client_id,
1806
+ nonce,
1807
+ response_type,
1808
+ redirect_uri,
1809
+ response_mode,
1810
+ scope,
1811
+ state,
1812
+ code_challenge,
1813
+ code_challenge_method
1814
+ };
1815
+ const authorizeOptionsClientCopy = { ...authorizeOptions };
1816
+ const url = `${__privateGet(this, _options2).authorizeendpoint}:${__privateGet(this, _options2).authorizeport}${__privateGet(this, _options2).authorizeapiroot}${__privateGet(this, _options2).authorizeapi}?${__privateGet(this, _qParams2).CreateQueryParams(authorizeOptions)}`;
1817
+ console.log(url);
1818
+ authorizeOptions.code_verifier = code_verifier;
1819
+ console.log(`Authorize:authorizeOptions: [${JSON.stringify(authorizeOptions)}]`);
1820
+ return {
1821
+ url,
1822
+ authorizeOptions,
1823
+ authorizeOptionsClientCopy
1324
1824
  };
1325
1825
  });
1326
1826
  // 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);
1827
+ __privateAdd(this, _HandleRedirect, async (payload) => {
1828
+ const queryVars = payload.queryVars;
1829
+ const authorizeOptions = payload.authorizeOptions;
1830
+ debug(`#HandleRedirect: HandleRedirect`.magenta);
1831
+ debug(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`.magenta);
1832
+ if (queryVars[OAuth2ParameterType.CODE]) {
1833
+ const response = queryVars;
1834
+ console.log(`authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
1835
+ const redirectState = response.state;
1836
+ const authorizeOptionsState = authorizeOptions.state;
1837
+ if (authorizeOptionsState.localeCompare(redirectState) === 0) {
1838
+ console.log("redirected state (from queryVars) matched previously saved transaction authorizeOptions state");
1839
+ return await __privateGet(this, _GetToken).call(this, authorizeOptions, response);
1840
+ } else {
1841
+ console.log("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state");
1842
+ console.log(`authorizeOptionsState: [${authorizeOptionsState}]`);
1843
+ console.log(`redirectState: [${redirectState}]`);
1844
+ __privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
1845
+ return false;
1846
+ }
1847
+ } else if (queryVars[OAuth2ParameterType.ERROR]) {
1848
+ __privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
1849
+ return false;
1850
+ } else {
1851
+ __privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
1852
+ return false;
1853
+ }
1336
1854
  });
1337
1855
  /*
1338
1856
  client_id=6731de76-14a6-49ae-97bc-6eba6914391e
@@ -1354,46 +1872,69 @@ class Br {
1354
1872
  }
1355
1873
  */
1356
1874
  // 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`;
1875
+ __privateAdd(this, _GetTokenFromBroker, async (authorizationCodeFlowParameters) => {
1876
+ debug(`#GetTokenFromBroker`.magenta);
1877
+ __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
1878
+ const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/token`;
1360
1879
  try {
1361
- const n = {
1880
+ const rConfig = {
1362
1881
  method: "post",
1363
- url: o,
1364
- data: t,
1365
- withCredentials: !0,
1882
+ url,
1883
+ data: authorizationCodeFlowParameters,
1884
+ withCredentials: true,
1366
1885
  // Ensure cookies are passed to the service
1367
- timeout: r(this, h).timeout
1886
+ timeout: __privateGet(this, _options2).timeout
1368
1887
  };
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
1888
+ debug(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`.magenta);
1889
+ if (isNode) {
1890
+ rConfig.httpsAgent = __privateGet(this, _httpsAgent);
1891
+ }
1892
+ debug(`#GetTokenFromBroker: axios API call`.magenta);
1893
+ const retVal = await axios(rConfig);
1894
+ debug(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`.magenta);
1895
+ if (retVal.status === StatusCodes.OK) {
1896
+ debug(`#GetTokenFromBroker: storing tokens`.magenta);
1897
+ const tokenResponse = retVal.data;
1898
+ __privateGet(this, _HandleAuthenticateEvent2).call(this, tokenResponse.id_token);
1899
+ const newSessionData = {
1900
+ tokenResponse
1377
1901
  };
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;
1902
+ if (isNode) {
1903
+ newSessionData.brokerCookie = retVal.headers["set-cookie"];
1904
+ }
1905
+ __privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
1906
+ return true;
1907
+ } else if (retVal.status === StatusCodes.UNAUTHORIZED) {
1908
+ debug(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`.magenta);
1909
+ __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
1910
+ return false;
1911
+ } else {
1912
+ debug(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`.magenta);
1913
+ __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
1914
+ console.log("Could not obtain access_token from token end-point:-");
1915
+ console.log(JSON.stringify(retVal.data));
1916
+ return false;
1917
+ }
1918
+ } catch (error) {
1919
+ debug(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`.red);
1920
+ __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
1921
+ return false;
1383
1922
  }
1384
1923
  });
1385
1924
  // 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
1925
+ __privateAdd(this, _GetToken, async (authorizeOptions, authorizeResponse) => {
1926
+ console.log("#GetToken");
1927
+ console.log(authorizeResponse);
1928
+ __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
1929
+ const authorizationCodeFlowParameters = {
1930
+ client_id: __privateGet(this, _options2).client_id,
1931
+ scope: __privateGet(this, _options2).scope,
1932
+ code: authorizeResponse.code,
1933
+ redirect_uri: __privateGet(this, _options2).redirect_uri,
1934
+ grant_type: OAuthGrantTypes.AUTHORIZATION_CODE,
1935
+ code_verifier: authorizeOptions.code_verifier
1395
1936
  };
1396
- return await r(this, ue).call(this, n);
1937
+ return await __privateGet(this, _GetTokenFromBroker).call(this, authorizationCodeFlowParameters);
1397
1938
  });
1398
1939
  /*
1399
1940
  // Line breaks for legibility only
@@ -1420,106 +1961,166 @@ class Br {
1420
1961
  "correlation_id": "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7"
1421
1962
  }
1422
1963
  */
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
1964
+ __privateAdd(this, _RefreshToken, async () => {
1965
+ debug(`STSOAuth2Worker:#RefreshToken:start`.cyan);
1966
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
1967
+ if (sessionData) {
1968
+ debug(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(sessionData)}]`.cyan);
1969
+ const currentSessionData = sessionData.tokenResponse;
1970
+ const refreshFlowParameters = {
1971
+ client_id: __privateGet(this, _options2).client_id,
1972
+ scope: __privateGet(this, _options2).scope,
1973
+ refresh_token: currentSessionData.refresh_token,
1974
+ grant_type: OAuthGrantTypes.REFRESH_TOKEN
1433
1975
  };
1434
- return await r(this, ue).call(this, n);
1435
- } else
1436
- return S("STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore".red), !1;
1976
+ return await __privateGet(this, _GetTokenFromBroker).call(this, refreshFlowParameters);
1977
+ } else {
1978
+ debug(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`.red);
1979
+ return false;
1980
+ }
1437
1981
  });
1438
1982
  // call broker to logout
1439
1983
  // broker to logout of server
1440
1984
  // delete cookie
1441
1985
  // clear session storage
1442
1986
  // clear all state from $store
1443
- l(this, Pe, async () => {
1987
+ __privateAdd(this, _Logout, async () => {
1444
1988
  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);
1989
+ const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/logout`;
1990
+ console.log(url);
1991
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
1992
+ if (sessionData) {
1993
+ const currentSessionData = sessionData.tokenResponse;
1994
+ const refresh_token = currentSessionData.refresh_token;
1995
+ console.log(refresh_token);
1996
+ const decodedRefreshToken = o(refresh_token);
1997
+ console.log(decodedRefreshToken);
1998
+ const sessionId = decodedRefreshToken.sts_session;
1999
+ console.log(sessionId);
2000
+ __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
2001
+ __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
1455
2002
  try {
1456
- const R = {
2003
+ const rConfig = {
1457
2004
  method: "post",
1458
- url: t,
2005
+ url,
1459
2006
  data: {
1460
- sessionId: g
2007
+ sessionId
1461
2008
  },
1462
- withCredentials: !0,
2009
+ withCredentials: true,
1463
2010
  // Ensure cookies are passed to the service
1464
- timeout: r(this, h).timeout
2011
+ timeout: __privateGet(this, _options2).timeout
1465
2012
  };
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;
2013
+ debug(`#Logout: request config: [${rConfig}]`.magenta);
2014
+ if (isNode) {
2015
+ rConfig.httpsAgent = __privateGet(this, _httpsAgent);
2016
+ }
2017
+ const retVal = await axios(rConfig);
2018
+ if (retVal.data.status === StatusCodes.OK) {
2019
+ return true;
2020
+ } else {
2021
+ console.log("Error during logout (1: server side)");
2022
+ console.log(JSON.stringify(retVal.data));
2023
+ return false;
2024
+ }
2025
+ } catch (error) {
2026
+ console.log("Error during logout (2: server side)");
2027
+ console.log(error);
2028
+ console.log(JSON.stringify(error));
2029
+ return false;
1471
2030
  }
1472
- } else
1473
- return console.log("Error during logout. Could not restore session from session storage."), !1;
2031
+ } else {
2032
+ console.log("Error during logout. Could not restore session from session storage.");
2033
+ return false;
2034
+ }
1474
2035
  });
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"
2036
+ Debug.enable("proc:*");
2037
+ __privateSet(this, _options2, options);
2038
+ debug(`STSOAuth2Worker:constructor:#options: [${JSON.stringify(__privateGet(this, _options2))}]`);
2039
+ __privateSet(this, _clientSessionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage());
2040
+ __privateSet(this, _oauthWorkerPort, workerPort);
2041
+ debug(`STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(__privateGet(this, _oauthWorkerPort))}]`);
2042
+ if (isNode && __privateGet(this, _options2).agentOptions) {
2043
+ __privateSet(this, _httpsAgent, new https.Agent({
2044
+ keepAlive: __privateGet(this, _options2).agentOptions.keepAlive,
2045
+ maxSockets: __privateGet(this, _options2).agentOptions.maxSockets,
2046
+ maxTotalSockets: __privateGet(this, _options2).agentOptions.maxTotalSockets,
2047
+ maxFreeSockets: __privateGet(this, _options2).agentOptions.maxFreeSockets,
2048
+ timeout: __privateGet(this, _options2).timeout,
2049
+ rejectUnauthorized: __privateGet(this, _options2).agentOptions.rejectUnauthorized
2050
+ // Allows self-signed certificates if non-production
2051
+ }));
2052
+ }
2053
+ this.SetupListener();
2054
+ __privateGet(this, _UpdateInstrument).call(this, Gauge.LOGGER, {
2055
+ LogMessage: `STSOauth2 Plugin - Successfully Loaded`
1485
2056
  });
1486
2057
  }
1487
2058
  }
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
- }),
2059
+ _clientSessionStore = new WeakMap();
2060
+ _cUtils2 = new WeakMap();
2061
+ _qParams2 = new WeakMap();
2062
+ _STORAGE_SESSION_KEY2 = new WeakMap();
2063
+ _oauthWorkerPort = new WeakMap();
2064
+ _options2 = new WeakMap();
2065
+ _httpsAgent = new WeakMap();
2066
+ _HandleAuthenticateEvent2 = new WeakMap();
2067
+ _HandleErrorEvent2 = new WeakMap();
2068
+ _LogMessage = new WeakMap();
2069
+ _GetAccessToken = new WeakMap();
2070
+ _GetCookies = new WeakMap();
2071
+ _UpdateInstrument = new WeakMap();
2072
+ _ProcessCommand = new WeakMap();
2073
+ _RestoreSession = new WeakMap();
2074
+ _Authorize = new WeakMap();
2075
+ _HandleRedirect = new WeakMap();
2076
+ _GetTokenFromBroker = new WeakMap();
2077
+ _GetToken = new WeakMap();
2078
+ _RefreshToken = new WeakMap();
2079
+ _Logout = new WeakMap();
2080
+ const TestStore = defineStore("__sts__TestStore", {
2081
+ state: () => {
2082
+ return {
2083
+ count: 0
2084
+ };
2085
+ },
1493
2086
  actions: {
1494
2087
  UpdateCount() {
1495
2088
  this.count++;
1496
2089
  }
1497
2090
  },
1498
2091
  getters: {
1499
- CountXX: (e) => e.count * 2
2092
+ CountXX: (state) => {
2093
+ return state.count * 2;
2094
+ }
1500
2095
  }
1501
2096
  /*
1502
2097
  persist: {
1503
2098
  storage: globalThis.sessionStorage
1504
2099
  }
1505
2100
  */
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);
2101
+ });
2102
+ const useSTSOAuth2ManagerPlugin = () => inject(STSOAuth2ManagerPluginKey);
2103
+ const STSOAuth2ManagerPlugin = {
2104
+ install: (app, options) => {
2105
+ const om = new STSOAuth2Manager(app, options);
2106
+ if (!app.config.globalProperties.$sts) {
2107
+ app.config.globalProperties.$sts = {};
2108
+ }
2109
+ app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey] = om;
2110
+ app.provide(STSOAuth2ManagerPluginKey, om);
1510
2111
  }
1511
2112
  };
1512
2113
  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
2114
+ AuthorizeOptionsResponseMode,
2115
+ AuthorizeOptionsResponseType,
2116
+ IOauth2ListenerCommand,
2117
+ OAuthGrantTypes,
2118
+ STSOAuth2Manager,
2119
+ STSOAuth2ManagerPlugin,
2120
+ STSOAuth2ManagerPluginKey,
2121
+ STSOAuth2Worker,
2122
+ STSOauth2Store,
2123
+ TestStore,
2124
+ useSTSOAuth2ManagerPlugin
1524
2125
  };
1525
2126
  //# sourceMappingURL=stsoauth2plugin.mjs.map