@nsshunt/stsoauth2plugin 1.0.98 → 1.0.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
17
17
  return __privateGet(obj, member, getter);
18
18
  }
19
19
  });
20
- var _crypto, _router, _cUtils, _qParams, _STORAGE_AUTHORIZE_OPTIONS_KEY, _STORAGE_SESSION_KEY, _aic, _options, _messages, _oauth2ManagerPort, _messageId, _messageHandlers, _messageTimeout, _worker, _transactionStore, _operationSemaphore, _maxSemaphoreRetries, _semaphoreRetrySleep, _STSOAuth2Manager_instances, LogDebugMessage_fn, LogInfoMessage_fn, LogErrorMessage_fn, _ProcessMessageResponse, _PostMessage, _HandleLogEvent, _HandleUpdateInstrumentEvent, _GetStore, _HandleErrorEvent, _HandleAuthenticateEvent, _SetupRoute, _clientSessionStore, _cUtils2, _qParams2, _STORAGE_SESSION_KEY2, _oauthWorkerPort, _options2, _httpsAgent, _logger, _STSOAuth2Worker_instances, LogDebugMessage_fn2, LogInfoMessage_fn2, LogErrorMessage_fn2, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
20
+ var _router, _STORAGE_AUTHORIZE_OPTIONS_KEY, _aic, _options, _oauth2ManagerPort, _messageId, _messageHandlers, _messageTimeout, _worker, _transactionStore, _operationSemaphore, _maxSemaphoreRetries, _semaphoreRetrySleep, _STSOAuth2Manager_instances, LogDebugMessage_fn, LogInfoMessage_fn, LogErrorMessage_fn, _ProcessMessageResponse, _PostMessage, _HandleLogEvent, _HandleUpdateInstrumentEvent, _GetStore, _HandleErrorEvent, _HandleAuthenticateEvent, _SetupRoute, _crypto, _clientSessionStore, _cUtils, _qParams, _STORAGE_SESSION_KEY, _oauthWorkerPort, _options2, _httpsAgent, _logger, _STSOAuth2Worker_instances, LogDebugMessage_fn2, LogInfoMessage_fn2, LogErrorMessage_fn2, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
21
21
  import { inject } from "vue";
22
22
  import * as wt from "node:worker_threads";
23
23
  import { OAuth2ParameterType, Sleep } from "@nsshunt/stsutils";
@@ -1481,1421 +1481,1409 @@ chalk.stderr.supportsColor = stderrColor;
1481
1481
  var source = chalk;
1482
1482
  const chalk$1 = /* @__PURE__ */ getDefaultExportFromCjs(source);
1483
1483
  const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
1484
- var sha256$1 = { exports: {} };
1485
- function commonjsRequire(path) {
1486
- 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.');
1484
+ var AuthorizeOptionsResponseType = /* @__PURE__ */ ((AuthorizeOptionsResponseType2) => {
1485
+ AuthorizeOptionsResponseType2["CODE"] = "code";
1486
+ AuthorizeOptionsResponseType2["ID_TOKEN"] = "id_token";
1487
+ AuthorizeOptionsResponseType2["TOKEN"] = "token";
1488
+ return AuthorizeOptionsResponseType2;
1489
+ })(AuthorizeOptionsResponseType || {});
1490
+ var AuthorizeOptionsResponseMode = /* @__PURE__ */ ((AuthorizeOptionsResponseMode2) => {
1491
+ AuthorizeOptionsResponseMode2["QUERY"] = "query";
1492
+ AuthorizeOptionsResponseMode2["FRAGMENT"] = "fragment";
1493
+ AuthorizeOptionsResponseMode2["FORM_POST"] = "form_post";
1494
+ return AuthorizeOptionsResponseMode2;
1495
+ })(AuthorizeOptionsResponseMode || {});
1496
+ var OAuthGrantTypes = /* @__PURE__ */ ((OAuthGrantTypes2) => {
1497
+ OAuthGrantTypes2["CLIENT_CREDENTIALS"] = "client_credentials";
1498
+ OAuthGrantTypes2["AUTHORIZATION_CODE"] = "authorization_code";
1499
+ OAuthGrantTypes2["REFRESH_TOKEN"] = "refresh_token";
1500
+ return OAuthGrantTypes2;
1501
+ })(OAuthGrantTypes || {});
1502
+ var IOauth2ListenerCommand = /* @__PURE__ */ ((IOauth2ListenerCommand2) => {
1503
+ IOauth2ListenerCommand2["RESTORE_SESSION"] = "RestoreSession";
1504
+ IOauth2ListenerCommand2["AUTHORIZE"] = "Authorize";
1505
+ IOauth2ListenerCommand2["HANDLE_REDIRECT"] = "HandleRedirect";
1506
+ IOauth2ListenerCommand2["LOGOUT"] = "Logout";
1507
+ IOauth2ListenerCommand2["AUTHENTICATE_EVENT"] = "AuthenticateEvent";
1508
+ IOauth2ListenerCommand2["ERROR"] = "Error";
1509
+ IOauth2ListenerCommand2["LOG"] = "__LOG";
1510
+ IOauth2ListenerCommand2["UPDATE_INSTRUMENT"] = "__UPDATE_INSTRUMENT";
1511
+ IOauth2ListenerCommand2["ID_TOKEN"] = "__ID_TOKEN";
1512
+ IOauth2ListenerCommand2["ACCESS_TOKEN"] = "__ACCESS_TOKEN";
1513
+ IOauth2ListenerCommand2["COOKIES"] = "__COOKIES";
1514
+ IOauth2ListenerCommand2["EXECUTE_REFRESH_TOKEN"] = "__EXECUTE_REFRESH_TOKEN";
1515
+ return IOauth2ListenerCommand2;
1516
+ })(IOauth2ListenerCommand || {});
1517
+ class InvalidTokenError extends Error {
1487
1518
  }
1488
- var core = { exports: {} };
1489
- const __viteBrowserExternal = {};
1490
- const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1491
- __proto__: null,
1492
- default: __viteBrowserExternal
1493
- }, Symbol.toStringTag, { value: "Module" }));
1494
- const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
1495
- var hasRequiredCore;
1496
- function requireCore() {
1497
- if (hasRequiredCore) return core.exports;
1498
- hasRequiredCore = 1;
1499
- (function(module, exports) {
1500
- (function(root, factory) {
1501
- {
1502
- module.exports = factory();
1519
+ InvalidTokenError.prototype.name = "InvalidTokenError";
1520
+ function b64DecodeUnicode(str) {
1521
+ return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
1522
+ let code = p.charCodeAt(0).toString(16).toUpperCase();
1523
+ if (code.length < 2) {
1524
+ code = "0" + code;
1525
+ }
1526
+ return "%" + code;
1527
+ }));
1528
+ }
1529
+ function base64UrlDecode(str) {
1530
+ let output = str.replace(/-/g, "+").replace(/_/g, "/");
1531
+ switch (output.length % 4) {
1532
+ case 0:
1533
+ break;
1534
+ case 2:
1535
+ output += "==";
1536
+ break;
1537
+ case 3:
1538
+ output += "=";
1539
+ break;
1540
+ default:
1541
+ throw new Error("base64 string is not of the correct length");
1542
+ }
1543
+ try {
1544
+ return b64DecodeUnicode(output);
1545
+ } catch (err) {
1546
+ return atob(output);
1547
+ }
1548
+ }
1549
+ function jwtDecode(token, options) {
1550
+ if (typeof token !== "string") {
1551
+ throw new InvalidTokenError("Invalid token specified: must be a string");
1552
+ }
1553
+ options || (options = {});
1554
+ const pos = options.header === true ? 0 : 1;
1555
+ const part = token.split(".")[pos];
1556
+ if (typeof part !== "string") {
1557
+ throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
1558
+ }
1559
+ let decoded;
1560
+ try {
1561
+ decoded = base64UrlDecode(part);
1562
+ } catch (e) {
1563
+ throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`);
1564
+ }
1565
+ try {
1566
+ return JSON.parse(decoded);
1567
+ } catch (e) {
1568
+ throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`);
1569
+ }
1570
+ }
1571
+ const STSOauth2Store = defineStore("__sts__STSOauth2Store", {
1572
+ state: () => {
1573
+ return {
1574
+ id_token: null,
1575
+ error: null
1576
+ };
1577
+ },
1578
+ actions: {
1579
+ UpdateIdToken(id_token) {
1580
+ this.id_token = id_token;
1581
+ },
1582
+ UpdateError(error) {
1583
+ if (this.error) {
1584
+ this.error.message = error;
1585
+ } else {
1586
+ this.error = {
1587
+ message: error
1588
+ };
1503
1589
  }
1504
- })(commonjsGlobal, function() {
1505
- var CryptoJS = CryptoJS || function(Math2, undefined$1) {
1506
- var crypto2;
1507
- if (typeof window !== "undefined" && window.crypto) {
1508
- crypto2 = window.crypto;
1509
- }
1510
- if (typeof self !== "undefined" && self.crypto) {
1511
- crypto2 = self.crypto;
1512
- }
1513
- if (typeof globalThis !== "undefined" && globalThis.crypto) {
1514
- crypto2 = globalThis.crypto;
1515
- }
1516
- if (!crypto2 && typeof window !== "undefined" && window.msCrypto) {
1517
- crypto2 = window.msCrypto;
1518
- }
1519
- if (!crypto2 && typeof commonjsGlobal !== "undefined" && commonjsGlobal.crypto) {
1520
- crypto2 = commonjsGlobal.crypto;
1590
+ }
1591
+ },
1592
+ getters: {
1593
+ LoggedIn: (state) => {
1594
+ if (typeof state.id_token === "undefined") {
1595
+ return false;
1596
+ }
1597
+ if (state.id_token === null) {
1598
+ return false;
1599
+ }
1600
+ return true;
1601
+ },
1602
+ UserDetails: (state) => {
1603
+ if (state.id_token) {
1604
+ const id_token = state.id_token;
1605
+ const decodedIdToken = jwtDecode(id_token);
1606
+ return decodedIdToken;
1607
+ } else {
1608
+ return null;
1609
+ }
1610
+ }
1611
+ }
1612
+ /*
1613
+ persist: {
1614
+ storage: globalThis.sessionStorage
1615
+ }
1616
+ */
1617
+ });
1618
+ class STSOAuth2Manager {
1619
+ // ms
1620
+ constructor(app, options) {
1621
+ __privateAdd(this, _STSOAuth2Manager_instances);
1622
+ __privateAdd(this, _router, null);
1623
+ __privateAdd(this, _STORAGE_AUTHORIZE_OPTIONS_KEY, "authorize_options.stsmda.com.au");
1624
+ __privateAdd(this, _aic, null);
1625
+ __privateAdd(this, _options);
1626
+ __privateAdd(this, _oauth2ManagerPort);
1627
+ __privateAdd(this, _messageId, 0);
1628
+ __privateAdd(this, _messageHandlers, {});
1629
+ // keyed by messageId
1630
+ __privateAdd(this, _messageTimeout, 1e4);
1631
+ __privateAdd(this, _worker);
1632
+ __privateAdd(this, _transactionStore);
1633
+ // Transient transaction data used to establish a session via OAuth2 authorize handshake
1634
+ __privateAdd(this, _operationSemaphore, false);
1635
+ __privateAdd(this, _maxSemaphoreRetries, 100);
1636
+ // 100 retries, i.e. allow 100 x 50 = 5000ms to unblock
1637
+ __privateAdd(this, _semaphoreRetrySleep, 50);
1638
+ __privateAdd(this, _ProcessMessageResponse, (data) => {
1639
+ const messageResponse = data;
1640
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`));
1641
+ if (messageResponse.messageId === -1) {
1642
+ switch (messageResponse.command) {
1643
+ case IOauth2ListenerCommand.AUTHENTICATE_EVENT:
1644
+ __privateGet(this, _HandleAuthenticateEvent).call(this, messageResponse.payload);
1645
+ break;
1646
+ case IOauth2ListenerCommand.ERROR:
1647
+ __privateGet(this, _HandleErrorEvent).call(this, messageResponse.payload);
1648
+ break;
1649
+ case IOauth2ListenerCommand.LOG:
1650
+ __privateGet(this, _HandleLogEvent).call(this, messageResponse.payload);
1651
+ break;
1652
+ case IOauth2ListenerCommand.UPDATE_INSTRUMENT:
1653
+ __privateGet(this, _HandleUpdateInstrumentEvent).call(this, messageResponse.payload.instrumentName, messageResponse.payload.telemetry);
1654
+ break;
1655
+ default:
1656
+ throw new Error(`ProcessMessageResponse command [${messageResponse.command}] not valid.`);
1521
1657
  }
1522
- if (!crypto2 && typeof commonjsRequire === "function") {
1523
- try {
1524
- crypto2 = require$$0;
1525
- } catch (err) {
1526
- }
1658
+ } else {
1659
+ const callBack = __privateGet(this, _messageHandlers)[messageResponse.messageId];
1660
+ if (callBack) {
1661
+ callBack(messageResponse);
1662
+ } else {
1663
+ throw new Error(`Message: [${messageResponse.messageId}] does not exists in callBacks.`);
1527
1664
  }
1528
- var cryptoSecureRandomInt = function() {
1529
- if (crypto2) {
1530
- if (typeof crypto2.getRandomValues === "function") {
1531
- try {
1532
- return crypto2.getRandomValues(new Uint32Array(1))[0];
1533
- } catch (err) {
1534
- }
1535
- }
1536
- if (typeof crypto2.randomBytes === "function") {
1537
- try {
1538
- return crypto2.randomBytes(4).readInt32LE();
1539
- } catch (err) {
1540
- }
1541
- }
1542
- }
1543
- throw new Error("Native crypto module could not be used to get secure random number.");
1665
+ }
1666
+ });
1667
+ __privateAdd(this, _PostMessage, (message) => {
1668
+ message.messageId = __privateWrapper(this, _messageId)._++;
1669
+ return new Promise((resolve, reject) => {
1670
+ const timeout = setTimeout(() => {
1671
+ delete __privateGet(this, _messageHandlers)[message.messageId];
1672
+ reject(`Message: [${message.messageId}] timeout error after: [${__privateGet(this, _messageTimeout)}] ms.`);
1673
+ }, __privateGet(this, _messageTimeout));
1674
+ __privateGet(this, _messageHandlers)[message.messageId] = (response) => {
1675
+ clearTimeout(timeout);
1676
+ delete __privateGet(this, _messageHandlers)[message.messageId];
1677
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`));
1678
+ resolve(response);
1544
1679
  };
1545
- var create = Object.create || /* @__PURE__ */ function() {
1546
- function F() {
1547
- }
1548
- return function(obj) {
1549
- var subtype;
1550
- F.prototype = obj;
1551
- subtype = new F();
1552
- F.prototype = null;
1553
- return subtype;
1554
- };
1555
- }();
1556
- var C = {};
1557
- var C_lib = C.lib = {};
1558
- var Base = C_lib.Base = /* @__PURE__ */ function() {
1559
- return {
1560
- /**
1561
- * Creates a new object that inherits from this object.
1562
- *
1563
- * @param {Object} overrides Properties to copy into the new object.
1564
- *
1565
- * @return {Object} The new object.
1566
- *
1567
- * @static
1568
- *
1569
- * @example
1570
- *
1571
- * var MyType = CryptoJS.lib.Base.extend({
1572
- * field: 'value',
1573
- *
1574
- * method: function () {
1575
- * }
1576
- * });
1577
- */
1578
- extend: function(overrides) {
1579
- var subtype = create(this);
1580
- if (overrides) {
1581
- subtype.mixIn(overrides);
1582
- }
1583
- if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
1584
- subtype.init = function() {
1585
- subtype.$super.init.apply(this, arguments);
1586
- };
1587
- }
1588
- subtype.init.prototype = subtype;
1589
- subtype.$super = this;
1590
- return subtype;
1591
- },
1592
- /**
1593
- * Extends this object and runs the init method.
1594
- * Arguments to create() will be passed to init().
1595
- *
1596
- * @return {Object} The new object.
1597
- *
1598
- * @static
1599
- *
1600
- * @example
1601
- *
1602
- * var instance = MyType.create();
1603
- */
1604
- create: function() {
1605
- var instance = this.extend();
1606
- instance.init.apply(instance, arguments);
1607
- return instance;
1608
- },
1609
- /**
1610
- * Initializes a newly created object.
1611
- * Override this method to add some logic when your objects are created.
1612
- *
1613
- * @example
1614
- *
1615
- * var MyType = CryptoJS.lib.Base.extend({
1616
- * init: function () {
1617
- * // ...
1618
- * }
1619
- * });
1620
- */
1621
- init: function() {
1622
- },
1623
- /**
1624
- * Copies properties into this object.
1625
- *
1626
- * @param {Object} properties The properties to mix in.
1627
- *
1628
- * @example
1629
- *
1630
- * MyType.mixIn({
1631
- * field: 'value'
1632
- * });
1633
- */
1634
- mixIn: function(properties) {
1635
- for (var propertyName in properties) {
1636
- if (properties.hasOwnProperty(propertyName)) {
1637
- this[propertyName] = properties[propertyName];
1638
- }
1639
- }
1640
- if (properties.hasOwnProperty("toString")) {
1641
- this.toString = properties.toString;
1642
- }
1643
- },
1644
- /**
1645
- * Creates a copy of this object.
1646
- *
1647
- * @return {Object} The clone.
1648
- *
1649
- * @example
1650
- *
1651
- * var clone = instance.clone();
1652
- */
1653
- clone: function() {
1654
- return this.init.prototype.extend(this);
1655
- }
1656
- };
1657
- }();
1658
- var WordArray = C_lib.WordArray = Base.extend({
1659
- /**
1660
- * Initializes a newly created word array.
1661
- *
1662
- * @param {Array} words (Optional) An array of 32-bit words.
1663
- * @param {number} sigBytes (Optional) The number of significant bytes in the words.
1664
- *
1665
- * @example
1666
- *
1667
- * var wordArray = CryptoJS.lib.WordArray.create();
1668
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
1669
- * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
1670
- */
1671
- init: function(words, sigBytes) {
1672
- words = this.words = words || [];
1673
- if (sigBytes != undefined$1) {
1674
- this.sigBytes = sigBytes;
1675
- } else {
1676
- this.sigBytes = words.length * 4;
1680
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`));
1681
+ __privateGet(this, _oauth2ManagerPort).postMessage(message);
1682
+ });
1683
+ });
1684
+ __privateAdd(this, _HandleLogEvent, (message) => {
1685
+ if (__privateGet(this, _aic)) {
1686
+ __privateGet(this, _aic).LogEx(message);
1687
+ }
1688
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, message);
1689
+ });
1690
+ // UpdateInstrument = (instrumentName: Gauge, telemetry: InstrumentBaseTelemetry): void => {
1691
+ __privateAdd(this, _HandleUpdateInstrumentEvent, (instrumentName, telemetry) => {
1692
+ if (__privateGet(this, _aic)) {
1693
+ __privateGet(this, _aic).UpdateInstrument(instrumentName, telemetry);
1694
+ }
1695
+ });
1696
+ __privateAdd(this, _GetStore, () => {
1697
+ return STSOauth2Store(__privateGet(this, _options).pinia);
1698
+ });
1699
+ // Will come from message channel
1700
+ __privateAdd(this, _HandleErrorEvent, (error) => {
1701
+ if (isNode) ;
1702
+ else {
1703
+ __privateGet(this, _GetStore).call(this).UpdateError({
1704
+ // Authorize applications store
1705
+ message: error
1706
+ });
1707
+ setTimeout(() => {
1708
+ __privateGet(this, _router).replace(`${__privateGet(this, _options).uriBase}error`);
1709
+ }, 0);
1710
+ }
1711
+ });
1712
+ __privateAdd(this, _HandleAuthenticateEvent, (id_token) => {
1713
+ if (isNode) ;
1714
+ else {
1715
+ if (__privateGet(this, _options).authenticateEvent) {
1716
+ __privateGet(this, _options).authenticateEvent(id_token);
1717
+ }
1718
+ __privateGet(this, _GetStore).call(this).UpdateIdToken(id_token);
1719
+ }
1720
+ });
1721
+ __privateAdd(this, _SetupRoute, (app, router) => {
1722
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.gray(`STSOAuth2Manager:#SetupRoute`));
1723
+ router.beforeEach(async (to, from, next) => {
1724
+ const oAuth2Manager = app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey];
1725
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.gray(`beforeEach: from: [${from.path}], to: [${to.path}]`));
1726
+ if (__privateGet(this, _GetStore).call(this).LoggedIn === false) {
1727
+ __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, `Not logged in`);
1728
+ if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}authorize`) === 0) {
1729
+ __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, `to = ${__privateGet(this, _options).uriBase}authorize`);
1730
+ next();
1731
+ return;
1732
+ } else if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}consent`) === 0) {
1733
+ if (__privateGet(this, _GetStore).call(this).id_token) {
1734
+ next();
1735
+ return;
1677
1736
  }
1678
- },
1679
- /**
1680
- * Converts this word array to a string.
1681
- *
1682
- * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
1683
- *
1684
- * @return {string} The stringified word array.
1685
- *
1686
- * @example
1687
- *
1688
- * var string = wordArray + '';
1689
- * var string = wordArray.toString();
1690
- * var string = wordArray.toString(CryptoJS.enc.Utf8);
1691
- */
1692
- toString: function(encoder) {
1693
- return (encoder || Hex).stringify(this);
1694
- },
1695
- /**
1696
- * Concatenates a word array to this word array.
1697
- *
1698
- * @param {WordArray} wordArray The word array to append.
1699
- *
1700
- * @return {WordArray} This word array.
1701
- *
1702
- * @example
1703
- *
1704
- * wordArray1.concat(wordArray2);
1705
- */
1706
- concat: function(wordArray) {
1707
- var thisWords = this.words;
1708
- var thatWords = wordArray.words;
1709
- var thisSigBytes = this.sigBytes;
1710
- var thatSigBytes = wordArray.sigBytes;
1711
- this.clamp();
1712
- if (thisSigBytes % 4) {
1713
- for (var i = 0; i < thatSigBytes; i++) {
1714
- var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
1715
- thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
1716
- }
1737
+ }
1738
+ if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}logout`) === 0) {
1739
+ next();
1740
+ return;
1741
+ }
1742
+ if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}error`) === 0) {
1743
+ next();
1744
+ return;
1745
+ }
1746
+ if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}config`) === 0) {
1747
+ next();
1748
+ return;
1749
+ }
1750
+ if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}redirected`) === 0) {
1751
+ next();
1752
+ return;
1753
+ }
1754
+ const str = to.query;
1755
+ if (str[OAuth2ParameterType.CODE] || str[OAuth2ParameterType.ERROR]) {
1756
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
1757
+ const retVal = await oAuth2Manager.HandleRedirect(str);
1758
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
1759
+ if (retVal) {
1760
+ next({
1761
+ path: `${__privateGet(this, _options).uriBase}`,
1762
+ replace: true
1763
+ });
1764
+ return;
1717
1765
  } else {
1718
- for (var j = 0; j < thatSigBytes; j += 4) {
1719
- thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
1720
- }
1766
+ next({
1767
+ path: `${__privateGet(this, _options).uriBase}error`,
1768
+ replace: true
1769
+ });
1770
+ return;
1721
1771
  }
1722
- this.sigBytes += thatSigBytes;
1723
- return this;
1724
- },
1725
- /**
1726
- * Removes insignificant bits.
1727
- *
1728
- * @example
1729
- *
1730
- * wordArray.clamp();
1731
- */
1732
- clamp: function() {
1733
- var words = this.words;
1734
- var sigBytes = this.sigBytes;
1735
- words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
1736
- words.length = Math2.ceil(sigBytes / 4);
1737
- },
1738
- /**
1739
- * Creates a copy of this word array.
1740
- *
1741
- * @return {WordArray} The clone.
1742
- *
1743
- * @example
1744
- *
1745
- * var clone = wordArray.clone();
1746
- */
1747
- clone: function() {
1748
- var clone = Base.clone.call(this);
1749
- clone.words = this.words.slice(0);
1750
- return clone;
1751
- },
1752
- /**
1753
- * Creates a word array filled with random bytes.
1754
- *
1755
- * @param {number} nBytes The number of random bytes to generate.
1756
- *
1757
- * @return {WordArray} The random word array.
1758
- *
1759
- * @static
1760
- *
1761
- * @example
1762
- *
1763
- * var wordArray = CryptoJS.lib.WordArray.random(16);
1764
- */
1765
- random: function(nBytes) {
1766
- var words = [];
1767
- for (var i = 0; i < nBytes; i += 4) {
1768
- words.push(cryptoSecureRandomInt());
1769
- }
1770
- return new WordArray.init(words, nBytes);
1771
1772
  }
1772
- });
1773
- var C_enc = C.enc = {};
1774
- var Hex = C_enc.Hex = {
1775
- /**
1776
- * Converts a word array to a hex string.
1777
- *
1778
- * @param {WordArray} wordArray The word array.
1779
- *
1780
- * @return {string} The hex string.
1781
- *
1782
- * @static
1783
- *
1784
- * @example
1785
- *
1786
- * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
1787
- */
1788
- stringify: function(wordArray) {
1789
- var words = wordArray.words;
1790
- var sigBytes = wordArray.sigBytes;
1791
- var hexChars = [];
1792
- for (var i = 0; i < sigBytes; i++) {
1793
- var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
1794
- hexChars.push((bite >>> 4).toString(16));
1795
- hexChars.push((bite & 15).toString(16));
1796
- }
1797
- return hexChars.join("");
1798
- },
1799
- /**
1800
- * Converts a hex string to a word array.
1801
- *
1802
- * @param {string} hexStr The hex string.
1803
- *
1804
- * @return {WordArray} The word array.
1805
- *
1806
- * @static
1807
- *
1808
- * @example
1809
- *
1810
- * var wordArray = CryptoJS.enc.Hex.parse(hexString);
1811
- */
1812
- parse: function(hexStr) {
1813
- var hexStrLength = hexStr.length;
1814
- var words = [];
1815
- for (var i = 0; i < hexStrLength; i += 2) {
1816
- words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
1817
- }
1818
- return new WordArray.init(words, hexStrLength / 2);
1773
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:#SetupRoute:Restoring session`);
1774
+ const sessionRestored = await oAuth2Manager.RestoreSession();
1775
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:#SetupRoute:Session restored: [${sessionRestored}]`);
1776
+ if (sessionRestored !== true) {
1777
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:#SetupRoute:Session not restored - need to authorize`);
1778
+ oAuth2Manager.Authorize();
1779
+ next();
1780
+ return;
1781
+ } else {
1782
+ next(`${__privateGet(this, _options).uriBase}`);
1783
+ return;
1819
1784
  }
1820
- };
1821
- var Latin1 = C_enc.Latin1 = {
1822
- /**
1823
- * Converts a word array to a Latin1 string.
1824
- *
1825
- * @param {WordArray} wordArray The word array.
1826
- *
1827
- * @return {string} The Latin1 string.
1828
- *
1829
- * @static
1830
- *
1831
- * @example
1832
- *
1833
- * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
1834
- */
1835
- stringify: function(wordArray) {
1836
- var words = wordArray.words;
1837
- var sigBytes = wordArray.sigBytes;
1838
- var latin1Chars = [];
1839
- for (var i = 0; i < sigBytes; i++) {
1840
- var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
1841
- latin1Chars.push(String.fromCharCode(bite));
1842
- }
1843
- return latin1Chars.join("");
1844
- },
1845
- /**
1846
- * Converts a Latin1 string to a word array.
1847
- *
1848
- * @param {string} latin1Str The Latin1 string.
1849
- *
1850
- * @return {WordArray} The word array.
1851
- *
1852
- * @static
1853
- *
1854
- * @example
1855
- *
1856
- * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
1857
- */
1858
- parse: function(latin1Str) {
1859
- var latin1StrLength = latin1Str.length;
1860
- var words = [];
1861
- for (var i = 0; i < latin1StrLength; i++) {
1862
- words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
1863
- }
1864
- return new WordArray.init(words, latin1StrLength);
1785
+ } else {
1786
+ if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}consent`) === 0) {
1787
+ next(`${__privateGet(this, _options).uriBase}`);
1788
+ return;
1865
1789
  }
1866
- };
1867
- var Utf8 = C_enc.Utf8 = {
1868
- /**
1869
- * Converts a word array to a UTF-8 string.
1870
- *
1871
- * @param {WordArray} wordArray The word array.
1872
- *
1873
- * @return {string} The UTF-8 string.
1874
- *
1875
- * @static
1876
- *
1877
- * @example
1878
- *
1879
- * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
1880
- */
1881
- stringify: function(wordArray) {
1882
- try {
1883
- return decodeURIComponent(escape(Latin1.stringify(wordArray)));
1884
- } catch (e) {
1885
- throw new Error("Malformed UTF-8 data");
1886
- }
1887
- },
1888
- /**
1889
- * Converts a UTF-8 string to a word array.
1890
- *
1891
- * @param {string} utf8Str The UTF-8 string.
1892
- *
1893
- * @return {WordArray} The word array.
1894
- *
1895
- * @static
1896
- *
1897
- * @example
1898
- *
1899
- * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
1900
- */
1901
- parse: function(utf8Str) {
1902
- return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
1790
+ if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}authorize`) === 0) {
1791
+ next(`${__privateGet(this, _options).uriBase}`);
1792
+ return;
1903
1793
  }
1904
- };
1905
- var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
1906
- /**
1907
- * Resets this block algorithm's data buffer to its initial state.
1908
- *
1909
- * @example
1910
- *
1911
- * bufferedBlockAlgorithm.reset();
1912
- */
1913
- reset: function() {
1914
- this._data = new WordArray.init();
1915
- this._nDataBytes = 0;
1916
- },
1917
- /**
1918
- * Adds new data to this block algorithm's buffer.
1919
- *
1920
- * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
1921
- *
1922
- * @example
1923
- *
1924
- * bufferedBlockAlgorithm._append('data');
1925
- * bufferedBlockAlgorithm._append(wordArray);
1926
- */
1927
- _append: function(data) {
1928
- if (typeof data == "string") {
1929
- data = Utf8.parse(data);
1930
- }
1931
- this._data.concat(data);
1932
- this._nDataBytes += data.sigBytes;
1933
- },
1934
- /**
1935
- * Processes available data blocks.
1936
- *
1937
- * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
1938
- *
1939
- * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
1940
- *
1941
- * @return {WordArray} The processed data.
1942
- *
1943
- * @example
1944
- *
1945
- * var processedData = bufferedBlockAlgorithm._process();
1946
- * var processedData = bufferedBlockAlgorithm._process(!!'flush');
1947
- */
1948
- _process: function(doFlush) {
1949
- var processedWords;
1950
- var data = this._data;
1951
- var dataWords = data.words;
1952
- var dataSigBytes = data.sigBytes;
1953
- var blockSize = this.blockSize;
1954
- var blockSizeBytes = blockSize * 4;
1955
- var nBlocksReady = dataSigBytes / blockSizeBytes;
1956
- if (doFlush) {
1957
- nBlocksReady = Math2.ceil(nBlocksReady);
1958
- } else {
1959
- nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
1960
- }
1961
- var nWordsReady = nBlocksReady * blockSize;
1962
- var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
1963
- if (nWordsReady) {
1964
- for (var offset = 0; offset < nWordsReady; offset += blockSize) {
1965
- this._doProcessBlock(dataWords, offset);
1966
- }
1967
- processedWords = dataWords.splice(0, nWordsReady);
1968
- data.sigBytes -= nBytesReady;
1969
- }
1970
- return new WordArray.init(processedWords, nBytesReady);
1971
- },
1972
- /**
1973
- * Creates a copy of this object.
1974
- *
1975
- * @return {Object} The clone.
1976
- *
1977
- * @example
1978
- *
1979
- * var clone = bufferedBlockAlgorithm.clone();
1980
- */
1981
- clone: function() {
1982
- var clone = Base.clone.call(this);
1983
- clone._data = this._data.clone();
1984
- return clone;
1985
- },
1986
- _minBufferSize: 0
1987
- });
1988
- C_lib.Hasher = BufferedBlockAlgorithm.extend({
1989
- /**
1990
- * Configuration options.
1991
- */
1992
- cfg: Base.extend(),
1993
- /**
1994
- * Initializes a newly created hasher.
1995
- *
1996
- * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
1997
- *
1998
- * @example
1999
- *
2000
- * var hasher = CryptoJS.algo.SHA256.create();
2001
- */
2002
- init: function(cfg) {
2003
- this.cfg = this.cfg.extend(cfg);
2004
- this.reset();
2005
- },
2006
- /**
2007
- * Resets this hasher to its initial state.
2008
- *
2009
- * @example
2010
- *
2011
- * hasher.reset();
2012
- */
2013
- reset: function() {
2014
- BufferedBlockAlgorithm.reset.call(this);
2015
- this._doReset();
2016
- },
2017
- /**
2018
- * Updates this hasher with a message.
2019
- *
2020
- * @param {WordArray|string} messageUpdate The message to append.
2021
- *
2022
- * @return {Hasher} This hasher.
2023
- *
2024
- * @example
2025
- *
2026
- * hasher.update('message');
2027
- * hasher.update(wordArray);
2028
- */
2029
- update: function(messageUpdate) {
2030
- this._append(messageUpdate);
2031
- this._process();
2032
- return this;
2033
- },
2034
- /**
2035
- * Finalizes the hash computation.
2036
- * Note that the finalize operation is effectively a destructive, read-once operation.
2037
- *
2038
- * @param {WordArray|string} messageUpdate (Optional) A final message update.
2039
- *
2040
- * @return {WordArray} The hash.
2041
- *
2042
- * @example
2043
- *
2044
- * var hash = hasher.finalize();
2045
- * var hash = hasher.finalize('message');
2046
- * var hash = hasher.finalize(wordArray);
2047
- */
2048
- finalize: function(messageUpdate) {
2049
- if (messageUpdate) {
2050
- this._append(messageUpdate);
2051
- }
2052
- var hash = this._doFinalize();
2053
- return hash;
2054
- },
2055
- blockSize: 512 / 32,
2056
- /**
2057
- * Creates a shortcut function to a hasher's object interface.
2058
- *
2059
- * @param {Hasher} hasher The hasher to create a helper for.
2060
- *
2061
- * @return {Function} The shortcut function.
2062
- *
2063
- * @static
2064
- *
2065
- * @example
2066
- *
2067
- * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
2068
- */
2069
- _createHelper: function(hasher) {
2070
- return function(message, cfg) {
2071
- return new hasher.init(cfg).finalize(message);
2072
- };
2073
- },
2074
- /**
2075
- * Creates a shortcut function to the HMAC's object interface.
2076
- *
2077
- * @param {Hasher} hasher The hasher to use in this HMAC helper.
2078
- *
2079
- * @return {Function} The shortcut function.
2080
- *
2081
- * @static
2082
- *
2083
- * @example
2084
- *
2085
- * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
2086
- */
2087
- _createHmacHelper: function(hasher) {
2088
- return function(message, key) {
2089
- return new C_algo.HMAC.init(hasher, key).finalize(message);
2090
- };
1794
+ if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}logout`) === 0) {
1795
+ next(`${__privateGet(this, _options).uriBase}`);
1796
+ return;
2091
1797
  }
2092
- });
2093
- var C_algo = C.algo = {};
2094
- return C;
2095
- }(Math);
2096
- return CryptoJS;
1798
+ next();
1799
+ }
1800
+ });
2097
1801
  });
2098
- })(core);
2099
- return core.exports;
2100
- }
2101
- (function(module, exports) {
2102
- (function(root, factory) {
2103
- {
2104
- module.exports = factory(requireCore());
2105
- }
2106
- })(commonjsGlobal, function(CryptoJS) {
2107
- (function(Math2) {
2108
- var C = CryptoJS;
2109
- var C_lib = C.lib;
2110
- var WordArray = C_lib.WordArray;
2111
- var Hasher = C_lib.Hasher;
2112
- var C_algo = C.algo;
2113
- var H = [];
2114
- var K = [];
2115
- (function() {
2116
- function isPrime(n2) {
2117
- var sqrtN = Math2.sqrt(n2);
2118
- for (var factor = 2; factor <= sqrtN; factor++) {
2119
- if (!(n2 % factor)) {
2120
- return false;
2121
- }
2122
- }
2123
- return true;
1802
+ //@@ this needs to be re-implemented so that access_token never leaves the auth worker
1803
+ __publicField(this, "GetAccessToken", async () => {
1804
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.ACCESS_TOKEN });
1805
+ return response.payload;
1806
+ });
1807
+ // Update operation protected using operationSemaphore. This may occur when using workers and/or multiple async fetch operations.
1808
+ __publicField(this, "ExecuteRefreshToken", async (retryCount = 0) => {
1809
+ if (__privateGet(this, _operationSemaphore) === true) {
1810
+ if (retryCount > __privateGet(this, _maxSemaphoreRetries)) {
1811
+ throw new Error(`STSOAuth2Manager:ExecuteRefreshToken:maxSemaphoreRetries: [${__privateGet(this, _maxSemaphoreRetries)}] exceeded.`);
2124
1812
  }
2125
- function getFractionalBits(n2) {
2126
- return (n2 - (n2 | 0)) * 4294967296 | 0;
1813
+ await Sleep(__privateGet(this, _semaphoreRetrySleep));
1814
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.cyan(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`));
1815
+ return await this.ExecuteRefreshToken(retryCount + 1);
1816
+ } else {
1817
+ __privateSet(this, _operationSemaphore, true);
1818
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.EXECUTE_REFRESH_TOKEN });
1819
+ __privateSet(this, _operationSemaphore, false);
1820
+ return response.payload;
1821
+ }
1822
+ });
1823
+ __publicField(this, "GetCookies", async () => {
1824
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.COOKIES });
1825
+ return response.payload;
1826
+ });
1827
+ __publicField(this, "RestoreSession", async () => {
1828
+ try {
1829
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:RestoreSession:postMessage: [${IOauth2ListenerCommand.RESTORE_SESSION}]`);
1830
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.RESTORE_SESSION });
1831
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
1832
+ return response.payload;
1833
+ } catch (error) {
1834
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`RestoreSession Error: ${error}`));
1835
+ return false;
1836
+ }
1837
+ });
1838
+ __publicField(this, "Authorize", async () => {
1839
+ try {
1840
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.AUTHORIZE });
1841
+ __privateGet(this, _transactionStore).set(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY), response.payload.authorizeOptions);
1842
+ const url = response.payload.url;
1843
+ if (!isNode) {
1844
+ window.location.replace(url);
1845
+ } else {
1846
+ return response.payload.authorizeOptionsClientCopy;
2127
1847
  }
2128
- var n = 2;
2129
- var nPrime = 0;
2130
- while (nPrime < 64) {
2131
- if (isPrime(n)) {
2132
- if (nPrime < 8) {
2133
- H[nPrime] = getFractionalBits(Math2.pow(n, 1 / 2));
2134
- }
2135
- K[nPrime] = getFractionalBits(Math2.pow(n, 1 / 3));
2136
- nPrime++;
2137
- }
2138
- n++;
1848
+ } catch (error) {
1849
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`Authorize Error: ${error}`));
1850
+ }
1851
+ return {};
1852
+ });
1853
+ __publicField(this, "HandleRedirect", async (queryVars) => {
1854
+ try {
1855
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect`));
1856
+ let response = null;
1857
+ if (queryVars[OAuth2ParameterType.CODE]) {
1858
+ const authorizeOptions = __privateGet(this, _transactionStore).get(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
1859
+ __privateGet(this, _transactionStore).remove(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
1860
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
1861
+ response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
1862
+ queryVars,
1863
+ authorizeOptions
1864
+ } });
1865
+ } else {
1866
+ response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
2139
1867
  }
2140
- })();
2141
- var W = [];
2142
- var SHA256 = C_algo.SHA256 = Hasher.extend({
2143
- _doReset: function() {
2144
- this._hash = new WordArray.init(H.slice(0));
2145
- },
2146
- _doProcessBlock: function(M, offset) {
2147
- var H2 = this._hash.words;
2148
- var a = H2[0];
2149
- var b = H2[1];
2150
- var c = H2[2];
2151
- var d = H2[3];
2152
- var e = H2[4];
2153
- var f = H2[5];
2154
- var g = H2[6];
2155
- var h = H2[7];
2156
- for (var i = 0; i < 64; i++) {
2157
- if (i < 16) {
2158
- W[i] = M[offset + i] | 0;
2159
- } else {
2160
- var gamma0x = W[i - 15];
2161
- var gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
2162
- var gamma1x = W[i - 2];
2163
- var gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
2164
- W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
2165
- }
2166
- var ch = e & f ^ ~e & g;
2167
- var maj = a & b ^ a & c ^ b & c;
2168
- var sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
2169
- var sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
2170
- var t1 = h + sigma1 + ch + K[i] + W[i];
2171
- var t2 = sigma0 + maj;
2172
- h = g;
2173
- g = f;
2174
- f = e;
2175
- e = d + t1 | 0;
2176
- d = c;
2177
- c = b;
2178
- b = a;
2179
- a = t1 + t2 | 0;
2180
- }
2181
- H2[0] = H2[0] + a | 0;
2182
- H2[1] = H2[1] + b | 0;
2183
- H2[2] = H2[2] + c | 0;
2184
- H2[3] = H2[3] + d | 0;
2185
- H2[4] = H2[4] + e | 0;
2186
- H2[5] = H2[5] + f | 0;
2187
- H2[6] = H2[6] + g | 0;
2188
- H2[7] = H2[7] + h | 0;
2189
- },
2190
- _doFinalize: function() {
2191
- var data = this._data;
2192
- var dataWords = data.words;
2193
- var nBitsTotal = this._nDataBytes * 8;
2194
- var nBitsLeft = data.sigBytes * 8;
2195
- dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
2196
- dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math2.floor(nBitsTotal / 4294967296);
2197
- dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
2198
- data.sigBytes = dataWords.length * 4;
2199
- this._process();
2200
- return this._hash;
2201
- },
2202
- clone: function() {
2203
- var clone = Hasher.clone.call(this);
2204
- clone._hash = this._hash.clone();
2205
- return clone;
2206
- }
2207
- });
2208
- C.SHA256 = Hasher._createHelper(SHA256);
2209
- C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
2210
- })(Math);
2211
- return CryptoJS.SHA256;
2212
- });
2213
- })(sha256$1);
2214
- var sha256Exports = sha256$1.exports;
2215
- const sha256 = /* @__PURE__ */ getDefaultExportFromCjs(sha256Exports);
2216
- var encBase64 = { exports: {} };
2217
- (function(module, exports) {
2218
- (function(root, factory) {
2219
- {
2220
- module.exports = factory(requireCore());
2221
- }
2222
- })(commonjsGlobal, function(CryptoJS) {
2223
- (function() {
2224
- var C = CryptoJS;
2225
- var C_lib = C.lib;
2226
- var WordArray = C_lib.WordArray;
2227
- var C_enc = C.enc;
2228
- C_enc.Base64 = {
2229
- /**
2230
- * Converts a word array to a Base64 string.
2231
- *
2232
- * @param {WordArray} wordArray The word array.
2233
- *
2234
- * @return {string} The Base64 string.
2235
- *
2236
- * @static
2237
- *
2238
- * @example
2239
- *
2240
- * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
2241
- */
2242
- stringify: function(wordArray) {
2243
- var words = wordArray.words;
2244
- var sigBytes = wordArray.sigBytes;
2245
- var map = this._map;
2246
- wordArray.clamp();
2247
- var base64Chars = [];
2248
- for (var i = 0; i < sigBytes; i += 3) {
2249
- var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
2250
- var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
2251
- var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
2252
- var triplet = byte1 << 16 | byte2 << 8 | byte3;
2253
- for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) {
2254
- base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63));
2255
- }
2256
- }
2257
- var paddingChar = map.charAt(64);
2258
- if (paddingChar) {
2259
- while (base64Chars.length % 4) {
2260
- base64Chars.push(paddingChar);
2261
- }
2262
- }
2263
- return base64Chars.join("");
2264
- },
2265
- /**
2266
- * Converts a Base64 string to a word array.
2267
- *
2268
- * @param {string} base64Str The Base64 string.
2269
- *
2270
- * @return {WordArray} The word array.
2271
- *
2272
- * @static
2273
- *
2274
- * @example
2275
- *
2276
- * var wordArray = CryptoJS.enc.Base64.parse(base64String);
2277
- */
2278
- parse: function(base64Str) {
2279
- var base64StrLength = base64Str.length;
2280
- var map = this._map;
2281
- var reverseMap = this._reverseMap;
2282
- if (!reverseMap) {
2283
- reverseMap = this._reverseMap = [];
2284
- for (var j = 0; j < map.length; j++) {
2285
- reverseMap[map.charCodeAt(j)] = j;
2286
- }
2287
- }
2288
- var paddingChar = map.charAt(64);
2289
- if (paddingChar) {
2290
- var paddingIndex = base64Str.indexOf(paddingChar);
2291
- if (paddingIndex !== -1) {
2292
- base64StrLength = paddingIndex;
2293
- }
2294
- }
2295
- return parseLoop(base64Str, base64StrLength, reverseMap);
2296
- },
2297
- _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
2298
- };
2299
- function parseLoop(base64Str, base64StrLength, reverseMap) {
2300
- var words = [];
2301
- var nBytes = 0;
2302
- for (var i = 0; i < base64StrLength; i++) {
2303
- if (i % 4) {
2304
- var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2;
2305
- var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2;
2306
- var bitsCombined = bits1 | bits2;
2307
- words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8;
2308
- nBytes++;
2309
- }
2310
- }
2311
- return WordArray.create(words, nBytes);
1868
+ __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
1869
+ return response.payload;
1870
+ } catch (error) {
1871
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`HandleRedirect Error: ${error}`));
1872
+ return false;
2312
1873
  }
2313
- })();
2314
- return CryptoJS.enc.Base64;
2315
- });
2316
- })(encBase64);
2317
- var encBase64Exports = encBase64.exports;
2318
- const Base64 = /* @__PURE__ */ getDefaultExportFromCjs(encBase64Exports);
2319
- class CryptoUtils {
2320
- constructor() {
2321
- __privateAdd(this, _crypto);
2322
- __publicField(this, "DigestMessage", async function(message) {
2323
- const hashDigest = sha256(message);
2324
- return Base64.stringify(hashDigest);
2325
- });
2326
- __publicField(this, "CreateRandomString", (size = 43) => {
2327
- const randomValues = Array.from(__privateGet(this, _crypto).getRandomValues(new Uint8Array(size)));
2328
- const b64 = btoa(String.fromCharCode(...randomValues));
2329
- return b64;
2330
- });
2331
- try {
2332
- __privateSet(this, _crypto, crypto);
2333
- } catch {
2334
- __privateSet(this, _crypto, require("crypto"));
2335
- }
2336
- }
2337
- }
2338
- _crypto = new WeakMap();
2339
- class QueryParams {
2340
- constructor() {
2341
- __publicField(this, "DecodeQueryParams", (params) => {
2342
- const retObj = {};
2343
- Object.keys(params).filter((k) => typeof params[k] !== "undefined").map((k) => {
2344
- retObj[decodeURIComponent(k)] = decodeURIComponent(params[k]);
2345
- });
2346
- return retObj;
2347
1874
  });
2348
- __publicField(this, "CreateQueryParams", (params) => {
2349
- return Object.keys(params).filter((k) => typeof params[k] !== "undefined").map((k) => {
2350
- if (Array.isArray(params[k])) {
2351
- return encodeURIComponent(k) + "=" + encodeURIComponent(params[k].join(" "));
2352
- } else {
2353
- return encodeURIComponent(k) + "=" + encodeURIComponent(params[k]);
2354
- }
2355
- }).join("&");
1875
+ __publicField(this, "Logout", async () => {
1876
+ try {
1877
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
1878
+ return response.payload;
1879
+ } catch (error) {
1880
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`Logout Error: ${error}`));
1881
+ return false;
1882
+ }
2356
1883
  });
2357
- __publicField(this, "_GetQueryParams", (param) => {
2358
- let retVal = {};
2359
- const uri = param.split("?");
2360
- if (uri.length == 2) {
2361
- const vars = uri[1].split("&");
2362
- const getVars = {};
2363
- let tmp;
2364
- vars.forEach(function(v) {
2365
- tmp = v.split("=");
2366
- if (tmp.length == 2) getVars[tmp[0]] = tmp[1];
2367
- });
2368
- retVal = this.DecodeQueryParams(getVars);
1884
+ __publicField(this, "InvokeExternalAPI", async () => {
1885
+ try {
1886
+ const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
1887
+ return response.payload;
1888
+ } catch (error) {
1889
+ __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`InvokeExternalAPI Error: ${error}`));
1890
+ return null;
2369
1891
  }
2370
- return retVal;
2371
1892
  });
2372
- __publicField(this, "GetQueryParams", () => {
2373
- return this._GetQueryParams(window.location.href);
1893
+ __publicField(this, "LoggedIn", () => {
1894
+ try {
1895
+ return __privateGet(this, _GetStore).call(this).LoggedIn;
1896
+ } catch (error) {
1897
+ return false;
1898
+ }
2374
1899
  });
2375
- }
2376
- }
2377
- var AuthorizeOptionsResponseType = /* @__PURE__ */ ((AuthorizeOptionsResponseType2) => {
2378
- AuthorizeOptionsResponseType2["CODE"] = "code";
2379
- AuthorizeOptionsResponseType2["ID_TOKEN"] = "id_token";
2380
- AuthorizeOptionsResponseType2["TOKEN"] = "token";
2381
- return AuthorizeOptionsResponseType2;
2382
- })(AuthorizeOptionsResponseType || {});
2383
- var AuthorizeOptionsResponseMode = /* @__PURE__ */ ((AuthorizeOptionsResponseMode2) => {
2384
- AuthorizeOptionsResponseMode2["QUERY"] = "query";
2385
- AuthorizeOptionsResponseMode2["FRAGMENT"] = "fragment";
2386
- AuthorizeOptionsResponseMode2["FORM_POST"] = "form_post";
2387
- return AuthorizeOptionsResponseMode2;
2388
- })(AuthorizeOptionsResponseMode || {});
2389
- var OAuthGrantTypes = /* @__PURE__ */ ((OAuthGrantTypes2) => {
2390
- OAuthGrantTypes2["CLIENT_CREDENTIALS"] = "client_credentials";
2391
- OAuthGrantTypes2["AUTHORIZATION_CODE"] = "authorization_code";
2392
- OAuthGrantTypes2["REFRESH_TOKEN"] = "refresh_token";
2393
- return OAuthGrantTypes2;
2394
- })(OAuthGrantTypes || {});
2395
- var IOauth2ListenerCommand = /* @__PURE__ */ ((IOauth2ListenerCommand2) => {
2396
- IOauth2ListenerCommand2["RESTORE_SESSION"] = "RestoreSession";
2397
- IOauth2ListenerCommand2["AUTHORIZE"] = "Authorize";
2398
- IOauth2ListenerCommand2["HANDLE_REDIRECT"] = "HandleRedirect";
2399
- IOauth2ListenerCommand2["LOGOUT"] = "Logout";
2400
- IOauth2ListenerCommand2["AUTHENTICATE_EVENT"] = "AuthenticateEvent";
2401
- IOauth2ListenerCommand2["ERROR"] = "Error";
2402
- IOauth2ListenerCommand2["LOG"] = "__LOG";
2403
- IOauth2ListenerCommand2["UPDATE_INSTRUMENT"] = "__UPDATE_INSTRUMENT";
2404
- IOauth2ListenerCommand2["ID_TOKEN"] = "__ID_TOKEN";
2405
- IOauth2ListenerCommand2["ACCESS_TOKEN"] = "__ACCESS_TOKEN";
2406
- IOauth2ListenerCommand2["COOKIES"] = "__COOKIES";
2407
- IOauth2ListenerCommand2["EXECUTE_REFRESH_TOKEN"] = "__EXECUTE_REFRESH_TOKEN";
2408
- return IOauth2ListenerCommand2;
2409
- })(IOauth2ListenerCommand || {});
2410
- class InvalidTokenError extends Error {
2411
- }
2412
- InvalidTokenError.prototype.name = "InvalidTokenError";
2413
- function b64DecodeUnicode(str) {
2414
- return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
2415
- let code = p.charCodeAt(0).toString(16).toUpperCase();
2416
- if (code.length < 2) {
2417
- code = "0" + code;
1900
+ __privateSet(this, _options, options);
1901
+ if (!isNode) {
1902
+ if (app.config.globalProperties.$sts[STSInstrumentControllerPluginKey]) {
1903
+ const STSInstrumentController = app.config.globalProperties.$sts[STSInstrumentControllerPluginKey];
1904
+ __privateSet(this, _aic, STSInstrumentController);
1905
+ }
1906
+ __privateSet(this, _router, app.config.globalProperties.$router);
1907
+ }
1908
+ if (isNode) {
1909
+ __privateSet(this, _transactionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage());
1910
+ } else {
1911
+ __privateSet(this, _transactionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.SESSION_STORAGE, usePrefix: false }).GetStorage());
1912
+ }
1913
+ if (__privateGet(this, _options).workerFactory) {
1914
+ __privateSet(this, _worker, __privateGet(this, _options).workerFactory());
1915
+ } else {
1916
+ throw new Error(`STSOAuth2Manager:constructor: Cannot init STSOAuth2Manager - this.#options.workerFactory not specified`);
1917
+ }
1918
+ if (!isNode) {
1919
+ __privateGet(this, _worker).onmessage = (data) => {
1920
+ __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$1.green(`this.#worker.onmessage = [${data}]`));
1921
+ };
1922
+ __privateGet(this, _worker).onerror = (error) => {
1923
+ __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$1.green(`this.#worker.onerror = [${JSON.stringify(error)}]`));
1924
+ };
1925
+ }
1926
+ let workerMessage;
1927
+ if (isNode) {
1928
+ const {
1929
+ port1: oauth2ManagerPort,
1930
+ // this process port
1931
+ port2: oauth2WorkerPort
1932
+ // worker port
1933
+ } = new wt.MessageChannel();
1934
+ __privateSet(this, _oauth2ManagerPort, oauth2ManagerPort);
1935
+ workerMessage = {
1936
+ workerPort: oauth2WorkerPort,
1937
+ options: __privateGet(this, _options).workerOptions
1938
+ };
1939
+ __privateGet(this, _worker).postMessage(workerMessage, [oauth2WorkerPort]);
1940
+ __privateGet(this, _oauth2ManagerPort).on("message", (payload) => {
1941
+ __privateGet(this, _ProcessMessageResponse).call(this, payload);
1942
+ }).unref();
1943
+ } else {
1944
+ const {
1945
+ port1: oauth2ManagerPort,
1946
+ // this process port
1947
+ port2: oauth2WorkerPort
1948
+ // worker port
1949
+ } = new MessageChannel();
1950
+ __privateSet(this, _oauth2ManagerPort, oauth2ManagerPort);
1951
+ workerMessage = {
1952
+ workerPort: oauth2WorkerPort,
1953
+ options: __privateGet(this, _options).workerOptions
1954
+ };
1955
+ __privateGet(this, _worker).postMessage(workerMessage, [oauth2WorkerPort]);
1956
+ __privateGet(this, _oauth2ManagerPort).onmessage = (data) => {
1957
+ __privateGet(this, _ProcessMessageResponse).call(this, data.data);
1958
+ };
1959
+ __privateGet(this, _SetupRoute).call(this, app, __privateGet(this, _router));
2418
1960
  }
2419
- return "%" + code;
2420
- }));
2421
- }
2422
- function base64UrlDecode(str) {
2423
- let output = str.replace(/-/g, "+").replace(/_/g, "/");
2424
- switch (output.length % 4) {
2425
- case 0:
2426
- break;
2427
- case 2:
2428
- output += "==";
2429
- break;
2430
- case 3:
2431
- output += "=";
2432
- break;
2433
- default:
2434
- throw new Error("base64 string is not of the correct length");
2435
- }
2436
- try {
2437
- return b64DecodeUnicode(output);
2438
- } catch (err) {
2439
- return atob(output);
2440
1961
  }
2441
1962
  }
2442
- function jwtDecode(token, options) {
2443
- if (typeof token !== "string") {
2444
- throw new InvalidTokenError("Invalid token specified: must be a string");
2445
- }
2446
- options || (options = {});
2447
- const pos = options.header === true ? 0 : 1;
2448
- const part = token.split(".")[pos];
2449
- if (typeof part !== "string") {
2450
- throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
2451
- }
2452
- let decoded;
2453
- try {
2454
- decoded = base64UrlDecode(part);
2455
- } catch (e) {
2456
- throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`);
2457
- }
2458
- try {
2459
- return JSON.parse(decoded);
2460
- } catch (e) {
2461
- throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`);
2462
- }
1963
+ _router = new WeakMap();
1964
+ _STORAGE_AUTHORIZE_OPTIONS_KEY = new WeakMap();
1965
+ _aic = new WeakMap();
1966
+ _options = new WeakMap();
1967
+ _oauth2ManagerPort = new WeakMap();
1968
+ _messageId = new WeakMap();
1969
+ _messageHandlers = new WeakMap();
1970
+ _messageTimeout = new WeakMap();
1971
+ _worker = new WeakMap();
1972
+ _transactionStore = new WeakMap();
1973
+ _operationSemaphore = new WeakMap();
1974
+ _maxSemaphoreRetries = new WeakMap();
1975
+ _semaphoreRetrySleep = new WeakMap();
1976
+ _STSOAuth2Manager_instances = new WeakSet();
1977
+ LogDebugMessage_fn = function(message) {
1978
+ __privateGet(this, _options).logger.debug(message);
1979
+ };
1980
+ LogInfoMessage_fn = function(message) {
1981
+ __privateGet(this, _options).logger.info(message);
1982
+ };
1983
+ LogErrorMessage_fn = function(message) {
1984
+ __privateGet(this, _options).logger.error(message);
1985
+ };
1986
+ _ProcessMessageResponse = new WeakMap();
1987
+ _PostMessage = new WeakMap();
1988
+ _HandleLogEvent = new WeakMap();
1989
+ _HandleUpdateInstrumentEvent = new WeakMap();
1990
+ _GetStore = new WeakMap();
1991
+ _HandleErrorEvent = new WeakMap();
1992
+ _HandleAuthenticateEvent = new WeakMap();
1993
+ _SetupRoute = new WeakMap();
1994
+ var sha256$1 = { exports: {} };
1995
+ function commonjsRequire(path) {
1996
+ 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.');
2463
1997
  }
2464
- const STSOauth2Store = defineStore("__sts__STSOauth2Store", {
2465
- state: () => {
2466
- return {
2467
- id_token: null,
2468
- error: null
2469
- };
2470
- },
2471
- actions: {
2472
- UpdateIdToken(id_token) {
2473
- this.id_token = id_token;
2474
- },
2475
- UpdateError(error) {
2476
- if (this.error) {
2477
- this.error.message = error;
2478
- } else {
2479
- this.error = {
2480
- message: error
2481
- };
2482
- }
2483
- }
2484
- },
2485
- getters: {
2486
- LoggedIn: (state) => {
2487
- if (typeof state.id_token === "undefined") {
2488
- return false;
2489
- }
2490
- if (state.id_token === null) {
2491
- return false;
2492
- }
2493
- return true;
2494
- },
2495
- UserDetails: (state) => {
2496
- if (state.id_token) {
2497
- const id_token = state.id_token;
2498
- const decodedIdToken = jwtDecode(id_token);
2499
- return decodedIdToken;
2500
- } else {
2501
- return null;
1998
+ var core = { exports: {} };
1999
+ const __viteBrowserExternal = {};
2000
+ const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2001
+ __proto__: null,
2002
+ default: __viteBrowserExternal
2003
+ }, Symbol.toStringTag, { value: "Module" }));
2004
+ const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
2005
+ var hasRequiredCore;
2006
+ function requireCore() {
2007
+ if (hasRequiredCore) return core.exports;
2008
+ hasRequiredCore = 1;
2009
+ (function(module, exports) {
2010
+ (function(root, factory) {
2011
+ {
2012
+ module.exports = factory();
2502
2013
  }
2503
- }
2504
- }
2505
- /*
2506
- persist: {
2507
- storage: globalThis.sessionStorage
2508
- }
2509
- */
2510
- });
2511
- class STSOAuth2Manager {
2512
- // ms
2513
- constructor(app, options) {
2514
- __privateAdd(this, _STSOAuth2Manager_instances);
2515
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2516
- __privateAdd(this, _router, null);
2517
- __privateAdd(this, _cUtils, new CryptoUtils());
2518
- __privateAdd(this, _qParams, new QueryParams());
2519
- __privateAdd(this, _STORAGE_AUTHORIZE_OPTIONS_KEY, "authorize_options.stsmda.com.au");
2520
- __privateAdd(this, _STORAGE_SESSION_KEY, "session.stsmda.com.au");
2521
- __privateAdd(this, _aic, null);
2522
- __privateAdd(this, _options);
2523
- __privateAdd(this, _messages, {});
2524
- __privateAdd(this, _oauth2ManagerPort);
2525
- __privateAdd(this, _messageId, 0);
2526
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2527
- __privateAdd(this, _messageHandlers, {});
2528
- // keyed by messageId
2529
- __privateAdd(this, _messageTimeout, 1e4);
2530
- __privateAdd(this, _worker);
2531
- __privateAdd(this, _transactionStore);
2532
- // Transient transaction data used to establish a session via OAuth2 authorize handshake
2533
- __privateAdd(this, _operationSemaphore, false);
2534
- __privateAdd(this, _maxSemaphoreRetries, 100);
2535
- // 100 retries, i.e. allow 100 x 50 = 5000ms to unblock
2536
- __privateAdd(this, _semaphoreRetrySleep, 50);
2537
- __privateAdd(this, _ProcessMessageResponse, (data) => {
2538
- const messageResponse = data;
2539
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`));
2540
- if (messageResponse.messageId === -1) {
2541
- switch (messageResponse.command) {
2542
- case IOauth2ListenerCommand.AUTHENTICATE_EVENT:
2543
- __privateGet(this, _HandleAuthenticateEvent).call(this, messageResponse.payload);
2544
- break;
2545
- case IOauth2ListenerCommand.ERROR:
2546
- __privateGet(this, _HandleErrorEvent).call(this, messageResponse.payload);
2547
- break;
2548
- case IOauth2ListenerCommand.LOG:
2549
- __privateGet(this, _HandleLogEvent).call(this, messageResponse.payload);
2550
- break;
2551
- case IOauth2ListenerCommand.UPDATE_INSTRUMENT:
2552
- __privateGet(this, _HandleUpdateInstrumentEvent).call(this, messageResponse.payload.instrumentName, messageResponse.payload.telemetry);
2553
- break;
2554
- default:
2555
- throw new Error(`ProcessMessageResponse command [${messageResponse.command}] not valid.`);
2014
+ })(commonjsGlobal, function() {
2015
+ var CryptoJS = CryptoJS || function(Math2, undefined$1) {
2016
+ var crypto2;
2017
+ if (typeof window !== "undefined" && window.crypto) {
2018
+ crypto2 = window.crypto;
2556
2019
  }
2557
- } else {
2558
- const callBack = __privateGet(this, _messageHandlers)[messageResponse.messageId];
2559
- if (callBack) {
2560
- callBack(messageResponse);
2561
- } else {
2562
- throw new Error(`Message: [${messageResponse.messageId}] does not exists in callBacks.`);
2020
+ if (typeof self !== "undefined" && self.crypto) {
2021
+ crypto2 = self.crypto;
2563
2022
  }
2564
- }
2565
- });
2566
- __privateAdd(this, _PostMessage, (message) => {
2567
- message.messageId = __privateWrapper(this, _messageId)._++;
2568
- return new Promise((resolve, reject) => {
2569
- const timeout = setTimeout(() => {
2570
- delete __privateGet(this, _messageHandlers)[message.messageId];
2571
- reject(`Message: [${message.messageId}] timeout error after: [${__privateGet(this, _messageTimeout)}] ms.`);
2572
- }, __privateGet(this, _messageTimeout));
2573
- __privateGet(this, _messageHandlers)[message.messageId] = (response) => {
2574
- clearTimeout(timeout);
2575
- delete __privateGet(this, _messageHandlers)[message.messageId];
2576
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`));
2577
- resolve(response);
2023
+ if (typeof globalThis !== "undefined" && globalThis.crypto) {
2024
+ crypto2 = globalThis.crypto;
2025
+ }
2026
+ if (!crypto2 && typeof window !== "undefined" && window.msCrypto) {
2027
+ crypto2 = window.msCrypto;
2028
+ }
2029
+ if (!crypto2 && typeof commonjsGlobal !== "undefined" && commonjsGlobal.crypto) {
2030
+ crypto2 = commonjsGlobal.crypto;
2031
+ }
2032
+ if (!crypto2 && typeof commonjsRequire === "function") {
2033
+ try {
2034
+ crypto2 = require$$0;
2035
+ } catch (err) {
2036
+ }
2037
+ }
2038
+ var cryptoSecureRandomInt = function() {
2039
+ if (crypto2) {
2040
+ if (typeof crypto2.getRandomValues === "function") {
2041
+ try {
2042
+ return crypto2.getRandomValues(new Uint32Array(1))[0];
2043
+ } catch (err) {
2044
+ }
2045
+ }
2046
+ if (typeof crypto2.randomBytes === "function") {
2047
+ try {
2048
+ return crypto2.randomBytes(4).readInt32LE();
2049
+ } catch (err) {
2050
+ }
2051
+ }
2052
+ }
2053
+ throw new Error("Native crypto module could not be used to get secure random number.");
2578
2054
  };
2579
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`));
2580
- __privateGet(this, _oauth2ManagerPort).postMessage(message);
2581
- });
2582
- });
2583
- __privateAdd(this, _HandleLogEvent, (message) => {
2584
- if (__privateGet(this, _aic)) {
2585
- __privateGet(this, _aic).LogEx(message);
2586
- }
2587
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, message);
2588
- });
2589
- // UpdateInstrument = (instrumentName: Gauge, telemetry: InstrumentBaseTelemetry): void => {
2590
- __privateAdd(this, _HandleUpdateInstrumentEvent, (instrumentName, telemetry) => {
2591
- if (__privateGet(this, _aic)) {
2592
- __privateGet(this, _aic).UpdateInstrument(instrumentName, telemetry);
2593
- }
2594
- });
2595
- __privateAdd(this, _GetStore, () => {
2596
- return STSOauth2Store(__privateGet(this, _options).pinia);
2597
- });
2598
- // Will come from message channel
2599
- __privateAdd(this, _HandleErrorEvent, (error) => {
2600
- if (isNode) ;
2601
- else {
2602
- __privateGet(this, _GetStore).call(this).UpdateError({
2603
- // Authorize applications store
2604
- message: error
2055
+ var create = Object.create || /* @__PURE__ */ function() {
2056
+ function F() {
2057
+ }
2058
+ return function(obj) {
2059
+ var subtype;
2060
+ F.prototype = obj;
2061
+ subtype = new F();
2062
+ F.prototype = null;
2063
+ return subtype;
2064
+ };
2065
+ }();
2066
+ var C = {};
2067
+ var C_lib = C.lib = {};
2068
+ var Base = C_lib.Base = /* @__PURE__ */ function() {
2069
+ return {
2070
+ /**
2071
+ * Creates a new object that inherits from this object.
2072
+ *
2073
+ * @param {Object} overrides Properties to copy into the new object.
2074
+ *
2075
+ * @return {Object} The new object.
2076
+ *
2077
+ * @static
2078
+ *
2079
+ * @example
2080
+ *
2081
+ * var MyType = CryptoJS.lib.Base.extend({
2082
+ * field: 'value',
2083
+ *
2084
+ * method: function () {
2085
+ * }
2086
+ * });
2087
+ */
2088
+ extend: function(overrides) {
2089
+ var subtype = create(this);
2090
+ if (overrides) {
2091
+ subtype.mixIn(overrides);
2092
+ }
2093
+ if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
2094
+ subtype.init = function() {
2095
+ subtype.$super.init.apply(this, arguments);
2096
+ };
2097
+ }
2098
+ subtype.init.prototype = subtype;
2099
+ subtype.$super = this;
2100
+ return subtype;
2101
+ },
2102
+ /**
2103
+ * Extends this object and runs the init method.
2104
+ * Arguments to create() will be passed to init().
2105
+ *
2106
+ * @return {Object} The new object.
2107
+ *
2108
+ * @static
2109
+ *
2110
+ * @example
2111
+ *
2112
+ * var instance = MyType.create();
2113
+ */
2114
+ create: function() {
2115
+ var instance = this.extend();
2116
+ instance.init.apply(instance, arguments);
2117
+ return instance;
2118
+ },
2119
+ /**
2120
+ * Initializes a newly created object.
2121
+ * Override this method to add some logic when your objects are created.
2122
+ *
2123
+ * @example
2124
+ *
2125
+ * var MyType = CryptoJS.lib.Base.extend({
2126
+ * init: function () {
2127
+ * // ...
2128
+ * }
2129
+ * });
2130
+ */
2131
+ init: function() {
2132
+ },
2133
+ /**
2134
+ * Copies properties into this object.
2135
+ *
2136
+ * @param {Object} properties The properties to mix in.
2137
+ *
2138
+ * @example
2139
+ *
2140
+ * MyType.mixIn({
2141
+ * field: 'value'
2142
+ * });
2143
+ */
2144
+ mixIn: function(properties) {
2145
+ for (var propertyName in properties) {
2146
+ if (properties.hasOwnProperty(propertyName)) {
2147
+ this[propertyName] = properties[propertyName];
2148
+ }
2149
+ }
2150
+ if (properties.hasOwnProperty("toString")) {
2151
+ this.toString = properties.toString;
2152
+ }
2153
+ },
2154
+ /**
2155
+ * Creates a copy of this object.
2156
+ *
2157
+ * @return {Object} The clone.
2158
+ *
2159
+ * @example
2160
+ *
2161
+ * var clone = instance.clone();
2162
+ */
2163
+ clone: function() {
2164
+ return this.init.prototype.extend(this);
2165
+ }
2166
+ };
2167
+ }();
2168
+ var WordArray = C_lib.WordArray = Base.extend({
2169
+ /**
2170
+ * Initializes a newly created word array.
2171
+ *
2172
+ * @param {Array} words (Optional) An array of 32-bit words.
2173
+ * @param {number} sigBytes (Optional) The number of significant bytes in the words.
2174
+ *
2175
+ * @example
2176
+ *
2177
+ * var wordArray = CryptoJS.lib.WordArray.create();
2178
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
2179
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
2180
+ */
2181
+ init: function(words, sigBytes) {
2182
+ words = this.words = words || [];
2183
+ if (sigBytes != undefined$1) {
2184
+ this.sigBytes = sigBytes;
2185
+ } else {
2186
+ this.sigBytes = words.length * 4;
2187
+ }
2188
+ },
2189
+ /**
2190
+ * Converts this word array to a string.
2191
+ *
2192
+ * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
2193
+ *
2194
+ * @return {string} The stringified word array.
2195
+ *
2196
+ * @example
2197
+ *
2198
+ * var string = wordArray + '';
2199
+ * var string = wordArray.toString();
2200
+ * var string = wordArray.toString(CryptoJS.enc.Utf8);
2201
+ */
2202
+ toString: function(encoder) {
2203
+ return (encoder || Hex).stringify(this);
2204
+ },
2205
+ /**
2206
+ * Concatenates a word array to this word array.
2207
+ *
2208
+ * @param {WordArray} wordArray The word array to append.
2209
+ *
2210
+ * @return {WordArray} This word array.
2211
+ *
2212
+ * @example
2213
+ *
2214
+ * wordArray1.concat(wordArray2);
2215
+ */
2216
+ concat: function(wordArray) {
2217
+ var thisWords = this.words;
2218
+ var thatWords = wordArray.words;
2219
+ var thisSigBytes = this.sigBytes;
2220
+ var thatSigBytes = wordArray.sigBytes;
2221
+ this.clamp();
2222
+ if (thisSigBytes % 4) {
2223
+ for (var i = 0; i < thatSigBytes; i++) {
2224
+ var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
2225
+ thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
2226
+ }
2227
+ } else {
2228
+ for (var j = 0; j < thatSigBytes; j += 4) {
2229
+ thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
2230
+ }
2231
+ }
2232
+ this.sigBytes += thatSigBytes;
2233
+ return this;
2234
+ },
2235
+ /**
2236
+ * Removes insignificant bits.
2237
+ *
2238
+ * @example
2239
+ *
2240
+ * wordArray.clamp();
2241
+ */
2242
+ clamp: function() {
2243
+ var words = this.words;
2244
+ var sigBytes = this.sigBytes;
2245
+ words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
2246
+ words.length = Math2.ceil(sigBytes / 4);
2247
+ },
2248
+ /**
2249
+ * Creates a copy of this word array.
2250
+ *
2251
+ * @return {WordArray} The clone.
2252
+ *
2253
+ * @example
2254
+ *
2255
+ * var clone = wordArray.clone();
2256
+ */
2257
+ clone: function() {
2258
+ var clone = Base.clone.call(this);
2259
+ clone.words = this.words.slice(0);
2260
+ return clone;
2261
+ },
2262
+ /**
2263
+ * Creates a word array filled with random bytes.
2264
+ *
2265
+ * @param {number} nBytes The number of random bytes to generate.
2266
+ *
2267
+ * @return {WordArray} The random word array.
2268
+ *
2269
+ * @static
2270
+ *
2271
+ * @example
2272
+ *
2273
+ * var wordArray = CryptoJS.lib.WordArray.random(16);
2274
+ */
2275
+ random: function(nBytes) {
2276
+ var words = [];
2277
+ for (var i = 0; i < nBytes; i += 4) {
2278
+ words.push(cryptoSecureRandomInt());
2279
+ }
2280
+ return new WordArray.init(words, nBytes);
2281
+ }
2605
2282
  });
2606
- setTimeout(() => {
2607
- __privateGet(this, _router).replace(`${__privateGet(this, _options).uriBase}error`);
2608
- }, 0);
2609
- }
2610
- });
2611
- __privateAdd(this, _HandleAuthenticateEvent, (id_token) => {
2612
- if (isNode) ;
2613
- else {
2614
- if (__privateGet(this, _options).authenticateEvent) {
2615
- __privateGet(this, _options).authenticateEvent(id_token);
2616
- }
2617
- __privateGet(this, _GetStore).call(this).UpdateIdToken(id_token);
2618
- }
2619
- });
2620
- __privateAdd(this, _SetupRoute, (app, router) => {
2621
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.gray(`STSOAuth2Manager:#SetupRoute`));
2622
- router.beforeEach(async (to, from, next) => {
2623
- const oAuth2Manager = app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey];
2624
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.gray(`beforeEach: from: [${from.path}], to: [${to.path}]`));
2625
- if (__privateGet(this, _GetStore).call(this).LoggedIn === false) {
2626
- __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, `Not logged in`);
2627
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}authorize`) === 0) {
2628
- __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, `to = ${__privateGet(this, _options).uriBase}authorize`);
2629
- next();
2630
- return;
2631
- } else if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}consent`) === 0) {
2632
- if (__privateGet(this, _GetStore).call(this).id_token) {
2633
- next();
2634
- return;
2283
+ var C_enc = C.enc = {};
2284
+ var Hex = C_enc.Hex = {
2285
+ /**
2286
+ * Converts a word array to a hex string.
2287
+ *
2288
+ * @param {WordArray} wordArray The word array.
2289
+ *
2290
+ * @return {string} The hex string.
2291
+ *
2292
+ * @static
2293
+ *
2294
+ * @example
2295
+ *
2296
+ * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
2297
+ */
2298
+ stringify: function(wordArray) {
2299
+ var words = wordArray.words;
2300
+ var sigBytes = wordArray.sigBytes;
2301
+ var hexChars = [];
2302
+ for (var i = 0; i < sigBytes; i++) {
2303
+ var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
2304
+ hexChars.push((bite >>> 4).toString(16));
2305
+ hexChars.push((bite & 15).toString(16));
2306
+ }
2307
+ return hexChars.join("");
2308
+ },
2309
+ /**
2310
+ * Converts a hex string to a word array.
2311
+ *
2312
+ * @param {string} hexStr The hex string.
2313
+ *
2314
+ * @return {WordArray} The word array.
2315
+ *
2316
+ * @static
2317
+ *
2318
+ * @example
2319
+ *
2320
+ * var wordArray = CryptoJS.enc.Hex.parse(hexString);
2321
+ */
2322
+ parse: function(hexStr) {
2323
+ var hexStrLength = hexStr.length;
2324
+ var words = [];
2325
+ for (var i = 0; i < hexStrLength; i += 2) {
2326
+ words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
2327
+ }
2328
+ return new WordArray.init(words, hexStrLength / 2);
2329
+ }
2330
+ };
2331
+ var Latin1 = C_enc.Latin1 = {
2332
+ /**
2333
+ * Converts a word array to a Latin1 string.
2334
+ *
2335
+ * @param {WordArray} wordArray The word array.
2336
+ *
2337
+ * @return {string} The Latin1 string.
2338
+ *
2339
+ * @static
2340
+ *
2341
+ * @example
2342
+ *
2343
+ * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
2344
+ */
2345
+ stringify: function(wordArray) {
2346
+ var words = wordArray.words;
2347
+ var sigBytes = wordArray.sigBytes;
2348
+ var latin1Chars = [];
2349
+ for (var i = 0; i < sigBytes; i++) {
2350
+ var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
2351
+ latin1Chars.push(String.fromCharCode(bite));
2352
+ }
2353
+ return latin1Chars.join("");
2354
+ },
2355
+ /**
2356
+ * Converts a Latin1 string to a word array.
2357
+ *
2358
+ * @param {string} latin1Str The Latin1 string.
2359
+ *
2360
+ * @return {WordArray} The word array.
2361
+ *
2362
+ * @static
2363
+ *
2364
+ * @example
2365
+ *
2366
+ * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
2367
+ */
2368
+ parse: function(latin1Str) {
2369
+ var latin1StrLength = latin1Str.length;
2370
+ var words = [];
2371
+ for (var i = 0; i < latin1StrLength; i++) {
2372
+ words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
2635
2373
  }
2374
+ return new WordArray.init(words, latin1StrLength);
2636
2375
  }
2637
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}logout`) === 0) {
2638
- next();
2639
- return;
2376
+ };
2377
+ var Utf8 = C_enc.Utf8 = {
2378
+ /**
2379
+ * Converts a word array to a UTF-8 string.
2380
+ *
2381
+ * @param {WordArray} wordArray The word array.
2382
+ *
2383
+ * @return {string} The UTF-8 string.
2384
+ *
2385
+ * @static
2386
+ *
2387
+ * @example
2388
+ *
2389
+ * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
2390
+ */
2391
+ stringify: function(wordArray) {
2392
+ try {
2393
+ return decodeURIComponent(escape(Latin1.stringify(wordArray)));
2394
+ } catch (e) {
2395
+ throw new Error("Malformed UTF-8 data");
2396
+ }
2397
+ },
2398
+ /**
2399
+ * Converts a UTF-8 string to a word array.
2400
+ *
2401
+ * @param {string} utf8Str The UTF-8 string.
2402
+ *
2403
+ * @return {WordArray} The word array.
2404
+ *
2405
+ * @static
2406
+ *
2407
+ * @example
2408
+ *
2409
+ * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
2410
+ */
2411
+ parse: function(utf8Str) {
2412
+ return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
2640
2413
  }
2641
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}error`) === 0) {
2642
- next();
2643
- return;
2414
+ };
2415
+ var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
2416
+ /**
2417
+ * Resets this block algorithm's data buffer to its initial state.
2418
+ *
2419
+ * @example
2420
+ *
2421
+ * bufferedBlockAlgorithm.reset();
2422
+ */
2423
+ reset: function() {
2424
+ this._data = new WordArray.init();
2425
+ this._nDataBytes = 0;
2426
+ },
2427
+ /**
2428
+ * Adds new data to this block algorithm's buffer.
2429
+ *
2430
+ * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
2431
+ *
2432
+ * @example
2433
+ *
2434
+ * bufferedBlockAlgorithm._append('data');
2435
+ * bufferedBlockAlgorithm._append(wordArray);
2436
+ */
2437
+ _append: function(data) {
2438
+ if (typeof data == "string") {
2439
+ data = Utf8.parse(data);
2440
+ }
2441
+ this._data.concat(data);
2442
+ this._nDataBytes += data.sigBytes;
2443
+ },
2444
+ /**
2445
+ * Processes available data blocks.
2446
+ *
2447
+ * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
2448
+ *
2449
+ * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
2450
+ *
2451
+ * @return {WordArray} The processed data.
2452
+ *
2453
+ * @example
2454
+ *
2455
+ * var processedData = bufferedBlockAlgorithm._process();
2456
+ * var processedData = bufferedBlockAlgorithm._process(!!'flush');
2457
+ */
2458
+ _process: function(doFlush) {
2459
+ var processedWords;
2460
+ var data = this._data;
2461
+ var dataWords = data.words;
2462
+ var dataSigBytes = data.sigBytes;
2463
+ var blockSize = this.blockSize;
2464
+ var blockSizeBytes = blockSize * 4;
2465
+ var nBlocksReady = dataSigBytes / blockSizeBytes;
2466
+ if (doFlush) {
2467
+ nBlocksReady = Math2.ceil(nBlocksReady);
2468
+ } else {
2469
+ nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
2470
+ }
2471
+ var nWordsReady = nBlocksReady * blockSize;
2472
+ var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
2473
+ if (nWordsReady) {
2474
+ for (var offset = 0; offset < nWordsReady; offset += blockSize) {
2475
+ this._doProcessBlock(dataWords, offset);
2476
+ }
2477
+ processedWords = dataWords.splice(0, nWordsReady);
2478
+ data.sigBytes -= nBytesReady;
2479
+ }
2480
+ return new WordArray.init(processedWords, nBytesReady);
2481
+ },
2482
+ /**
2483
+ * Creates a copy of this object.
2484
+ *
2485
+ * @return {Object} The clone.
2486
+ *
2487
+ * @example
2488
+ *
2489
+ * var clone = bufferedBlockAlgorithm.clone();
2490
+ */
2491
+ clone: function() {
2492
+ var clone = Base.clone.call(this);
2493
+ clone._data = this._data.clone();
2494
+ return clone;
2495
+ },
2496
+ _minBufferSize: 0
2497
+ });
2498
+ C_lib.Hasher = BufferedBlockAlgorithm.extend({
2499
+ /**
2500
+ * Configuration options.
2501
+ */
2502
+ cfg: Base.extend(),
2503
+ /**
2504
+ * Initializes a newly created hasher.
2505
+ *
2506
+ * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
2507
+ *
2508
+ * @example
2509
+ *
2510
+ * var hasher = CryptoJS.algo.SHA256.create();
2511
+ */
2512
+ init: function(cfg) {
2513
+ this.cfg = this.cfg.extend(cfg);
2514
+ this.reset();
2515
+ },
2516
+ /**
2517
+ * Resets this hasher to its initial state.
2518
+ *
2519
+ * @example
2520
+ *
2521
+ * hasher.reset();
2522
+ */
2523
+ reset: function() {
2524
+ BufferedBlockAlgorithm.reset.call(this);
2525
+ this._doReset();
2526
+ },
2527
+ /**
2528
+ * Updates this hasher with a message.
2529
+ *
2530
+ * @param {WordArray|string} messageUpdate The message to append.
2531
+ *
2532
+ * @return {Hasher} This hasher.
2533
+ *
2534
+ * @example
2535
+ *
2536
+ * hasher.update('message');
2537
+ * hasher.update(wordArray);
2538
+ */
2539
+ update: function(messageUpdate) {
2540
+ this._append(messageUpdate);
2541
+ this._process();
2542
+ return this;
2543
+ },
2544
+ /**
2545
+ * Finalizes the hash computation.
2546
+ * Note that the finalize operation is effectively a destructive, read-once operation.
2547
+ *
2548
+ * @param {WordArray|string} messageUpdate (Optional) A final message update.
2549
+ *
2550
+ * @return {WordArray} The hash.
2551
+ *
2552
+ * @example
2553
+ *
2554
+ * var hash = hasher.finalize();
2555
+ * var hash = hasher.finalize('message');
2556
+ * var hash = hasher.finalize(wordArray);
2557
+ */
2558
+ finalize: function(messageUpdate) {
2559
+ if (messageUpdate) {
2560
+ this._append(messageUpdate);
2561
+ }
2562
+ var hash = this._doFinalize();
2563
+ return hash;
2564
+ },
2565
+ blockSize: 512 / 32,
2566
+ /**
2567
+ * Creates a shortcut function to a hasher's object interface.
2568
+ *
2569
+ * @param {Hasher} hasher The hasher to create a helper for.
2570
+ *
2571
+ * @return {Function} The shortcut function.
2572
+ *
2573
+ * @static
2574
+ *
2575
+ * @example
2576
+ *
2577
+ * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
2578
+ */
2579
+ _createHelper: function(hasher) {
2580
+ return function(message, cfg) {
2581
+ return new hasher.init(cfg).finalize(message);
2582
+ };
2583
+ },
2584
+ /**
2585
+ * Creates a shortcut function to the HMAC's object interface.
2586
+ *
2587
+ * @param {Hasher} hasher The hasher to use in this HMAC helper.
2588
+ *
2589
+ * @return {Function} The shortcut function.
2590
+ *
2591
+ * @static
2592
+ *
2593
+ * @example
2594
+ *
2595
+ * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
2596
+ */
2597
+ _createHmacHelper: function(hasher) {
2598
+ return function(message, key) {
2599
+ return new C_algo.HMAC.init(hasher, key).finalize(message);
2600
+ };
2644
2601
  }
2645
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}config`) === 0) {
2646
- next();
2647
- return;
2602
+ });
2603
+ var C_algo = C.algo = {};
2604
+ return C;
2605
+ }(Math);
2606
+ return CryptoJS;
2607
+ });
2608
+ })(core);
2609
+ return core.exports;
2610
+ }
2611
+ (function(module, exports) {
2612
+ (function(root, factory) {
2613
+ {
2614
+ module.exports = factory(requireCore());
2615
+ }
2616
+ })(commonjsGlobal, function(CryptoJS) {
2617
+ (function(Math2) {
2618
+ var C = CryptoJS;
2619
+ var C_lib = C.lib;
2620
+ var WordArray = C_lib.WordArray;
2621
+ var Hasher = C_lib.Hasher;
2622
+ var C_algo = C.algo;
2623
+ var H = [];
2624
+ var K = [];
2625
+ (function() {
2626
+ function isPrime(n2) {
2627
+ var sqrtN = Math2.sqrt(n2);
2628
+ for (var factor = 2; factor <= sqrtN; factor++) {
2629
+ if (!(n2 % factor)) {
2630
+ return false;
2631
+ }
2648
2632
  }
2649
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}redirected`) === 0) {
2650
- next();
2651
- return;
2633
+ return true;
2634
+ }
2635
+ function getFractionalBits(n2) {
2636
+ return (n2 - (n2 | 0)) * 4294967296 | 0;
2637
+ }
2638
+ var n = 2;
2639
+ var nPrime = 0;
2640
+ while (nPrime < 64) {
2641
+ if (isPrime(n)) {
2642
+ if (nPrime < 8) {
2643
+ H[nPrime] = getFractionalBits(Math2.pow(n, 1 / 2));
2644
+ }
2645
+ K[nPrime] = getFractionalBits(Math2.pow(n, 1 / 3));
2646
+ nPrime++;
2652
2647
  }
2653
- const str = to.query;
2654
- if (str[OAuth2ParameterType.CODE] || str[OAuth2ParameterType.ERROR]) {
2655
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
2656
- const retVal = await oAuth2Manager.HandleRedirect(str);
2657
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
2658
- if (retVal) {
2659
- next({
2660
- path: `${__privateGet(this, _options).uriBase}`,
2661
- replace: true
2662
- });
2663
- return;
2648
+ n++;
2649
+ }
2650
+ })();
2651
+ var W = [];
2652
+ var SHA256 = C_algo.SHA256 = Hasher.extend({
2653
+ _doReset: function() {
2654
+ this._hash = new WordArray.init(H.slice(0));
2655
+ },
2656
+ _doProcessBlock: function(M, offset) {
2657
+ var H2 = this._hash.words;
2658
+ var a = H2[0];
2659
+ var b = H2[1];
2660
+ var c = H2[2];
2661
+ var d = H2[3];
2662
+ var e = H2[4];
2663
+ var f = H2[5];
2664
+ var g = H2[6];
2665
+ var h = H2[7];
2666
+ for (var i = 0; i < 64; i++) {
2667
+ if (i < 16) {
2668
+ W[i] = M[offset + i] | 0;
2664
2669
  } else {
2665
- next({
2666
- path: `${__privateGet(this, _options).uriBase}error`,
2667
- replace: true
2668
- });
2669
- return;
2670
+ var gamma0x = W[i - 15];
2671
+ var gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
2672
+ var gamma1x = W[i - 2];
2673
+ var gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
2674
+ W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
2670
2675
  }
2676
+ var ch = e & f ^ ~e & g;
2677
+ var maj = a & b ^ a & c ^ b & c;
2678
+ var sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
2679
+ var sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
2680
+ var t1 = h + sigma1 + ch + K[i] + W[i];
2681
+ var t2 = sigma0 + maj;
2682
+ h = g;
2683
+ g = f;
2684
+ f = e;
2685
+ e = d + t1 | 0;
2686
+ d = c;
2687
+ c = b;
2688
+ b = a;
2689
+ a = t1 + t2 | 0;
2671
2690
  }
2672
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:#SetupRoute:Restoring session`);
2673
- const sessionRestored = await oAuth2Manager.RestoreSession();
2674
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:#SetupRoute:Session restored: [${sessionRestored}]`);
2675
- if (sessionRestored !== true) {
2676
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:#SetupRoute:Session not restored - need to authorize`);
2677
- oAuth2Manager.Authorize();
2678
- next();
2679
- return;
2680
- } else {
2681
- next(`${__privateGet(this, _options).uriBase}`);
2682
- return;
2691
+ H2[0] = H2[0] + a | 0;
2692
+ H2[1] = H2[1] + b | 0;
2693
+ H2[2] = H2[2] + c | 0;
2694
+ H2[3] = H2[3] + d | 0;
2695
+ H2[4] = H2[4] + e | 0;
2696
+ H2[5] = H2[5] + f | 0;
2697
+ H2[6] = H2[6] + g | 0;
2698
+ H2[7] = H2[7] + h | 0;
2699
+ },
2700
+ _doFinalize: function() {
2701
+ var data = this._data;
2702
+ var dataWords = data.words;
2703
+ var nBitsTotal = this._nDataBytes * 8;
2704
+ var nBitsLeft = data.sigBytes * 8;
2705
+ dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
2706
+ dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math2.floor(nBitsTotal / 4294967296);
2707
+ dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
2708
+ data.sigBytes = dataWords.length * 4;
2709
+ this._process();
2710
+ return this._hash;
2711
+ },
2712
+ clone: function() {
2713
+ var clone = Hasher.clone.call(this);
2714
+ clone._hash = this._hash.clone();
2715
+ return clone;
2716
+ }
2717
+ });
2718
+ C.SHA256 = Hasher._createHelper(SHA256);
2719
+ C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
2720
+ })(Math);
2721
+ return CryptoJS.SHA256;
2722
+ });
2723
+ })(sha256$1);
2724
+ var sha256Exports = sha256$1.exports;
2725
+ const sha256 = /* @__PURE__ */ getDefaultExportFromCjs(sha256Exports);
2726
+ var encBase64 = { exports: {} };
2727
+ (function(module, exports) {
2728
+ (function(root, factory) {
2729
+ {
2730
+ module.exports = factory(requireCore());
2731
+ }
2732
+ })(commonjsGlobal, function(CryptoJS) {
2733
+ (function() {
2734
+ var C = CryptoJS;
2735
+ var C_lib = C.lib;
2736
+ var WordArray = C_lib.WordArray;
2737
+ var C_enc = C.enc;
2738
+ C_enc.Base64 = {
2739
+ /**
2740
+ * Converts a word array to a Base64 string.
2741
+ *
2742
+ * @param {WordArray} wordArray The word array.
2743
+ *
2744
+ * @return {string} The Base64 string.
2745
+ *
2746
+ * @static
2747
+ *
2748
+ * @example
2749
+ *
2750
+ * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
2751
+ */
2752
+ stringify: function(wordArray) {
2753
+ var words = wordArray.words;
2754
+ var sigBytes = wordArray.sigBytes;
2755
+ var map = this._map;
2756
+ wordArray.clamp();
2757
+ var base64Chars = [];
2758
+ for (var i = 0; i < sigBytes; i += 3) {
2759
+ var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
2760
+ var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
2761
+ var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
2762
+ var triplet = byte1 << 16 | byte2 << 8 | byte3;
2763
+ for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) {
2764
+ base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63));
2765
+ }
2683
2766
  }
2684
- } else {
2685
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}consent`) === 0) {
2686
- next(`${__privateGet(this, _options).uriBase}`);
2687
- return;
2767
+ var paddingChar = map.charAt(64);
2768
+ if (paddingChar) {
2769
+ while (base64Chars.length % 4) {
2770
+ base64Chars.push(paddingChar);
2771
+ }
2688
2772
  }
2689
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}authorize`) === 0) {
2690
- next(`${__privateGet(this, _options).uriBase}`);
2691
- return;
2773
+ return base64Chars.join("");
2774
+ },
2775
+ /**
2776
+ * Converts a Base64 string to a word array.
2777
+ *
2778
+ * @param {string} base64Str The Base64 string.
2779
+ *
2780
+ * @return {WordArray} The word array.
2781
+ *
2782
+ * @static
2783
+ *
2784
+ * @example
2785
+ *
2786
+ * var wordArray = CryptoJS.enc.Base64.parse(base64String);
2787
+ */
2788
+ parse: function(base64Str) {
2789
+ var base64StrLength = base64Str.length;
2790
+ var map = this._map;
2791
+ var reverseMap = this._reverseMap;
2792
+ if (!reverseMap) {
2793
+ reverseMap = this._reverseMap = [];
2794
+ for (var j = 0; j < map.length; j++) {
2795
+ reverseMap[map.charCodeAt(j)] = j;
2796
+ }
2692
2797
  }
2693
- if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}logout`) === 0) {
2694
- next(`${__privateGet(this, _options).uriBase}`);
2695
- return;
2798
+ var paddingChar = map.charAt(64);
2799
+ if (paddingChar) {
2800
+ var paddingIndex = base64Str.indexOf(paddingChar);
2801
+ if (paddingIndex !== -1) {
2802
+ base64StrLength = paddingIndex;
2803
+ }
2804
+ }
2805
+ return parseLoop(base64Str, base64StrLength, reverseMap);
2806
+ },
2807
+ _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
2808
+ };
2809
+ function parseLoop(base64Str, base64StrLength, reverseMap) {
2810
+ var words = [];
2811
+ var nBytes = 0;
2812
+ for (var i = 0; i < base64StrLength; i++) {
2813
+ if (i % 4) {
2814
+ var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2;
2815
+ var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2;
2816
+ var bitsCombined = bits1 | bits2;
2817
+ words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8;
2818
+ nBytes++;
2696
2819
  }
2697
- next();
2698
- }
2699
- });
2700
- });
2701
- //@@ this needs to be re-implemented so that access_token never leaves the auth worker
2702
- __publicField(this, "GetAccessToken", async () => {
2703
- const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.ACCESS_TOKEN });
2704
- return response.payload;
2705
- });
2706
- // Update operation protected using operationSemaphore. This may occur when using workers and/or multiple async fetch operations.
2707
- __publicField(this, "ExecuteRefreshToken", async (retryCount = 0) => {
2708
- if (__privateGet(this, _operationSemaphore) === true) {
2709
- if (retryCount > __privateGet(this, _maxSemaphoreRetries)) {
2710
- throw new Error(`STSOAuth2Manager:ExecuteRefreshToken:maxSemaphoreRetries: [${__privateGet(this, _maxSemaphoreRetries)}] exceeded.`);
2711
2820
  }
2712
- await Sleep(__privateGet(this, _semaphoreRetrySleep));
2713
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.cyan(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`));
2714
- return await this.ExecuteRefreshToken(retryCount + 1);
2715
- } else {
2716
- __privateSet(this, _operationSemaphore, true);
2717
- const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.EXECUTE_REFRESH_TOKEN });
2718
- __privateSet(this, _operationSemaphore, false);
2719
- return response.payload;
2821
+ return WordArray.create(words, nBytes);
2720
2822
  }
2823
+ })();
2824
+ return CryptoJS.enc.Base64;
2825
+ });
2826
+ })(encBase64);
2827
+ var encBase64Exports = encBase64.exports;
2828
+ const Base64 = /* @__PURE__ */ getDefaultExportFromCjs(encBase64Exports);
2829
+ class CryptoUtils {
2830
+ constructor() {
2831
+ __privateAdd(this, _crypto);
2832
+ __publicField(this, "DigestMessage", async function(message) {
2833
+ const hashDigest = sha256(message);
2834
+ return Base64.stringify(hashDigest);
2721
2835
  });
2722
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2723
- __publicField(this, "GetCookies", async () => {
2724
- const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.COOKIES });
2725
- return response.payload;
2726
- });
2727
- __publicField(this, "RestoreSession", async () => {
2728
- try {
2729
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:RestoreSession:postMessage: [${IOauth2ListenerCommand.RESTORE_SESSION}]`);
2730
- const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.RESTORE_SESSION });
2731
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
2732
- return response.payload;
2733
- } catch (error) {
2734
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`RestoreSession Error: ${error}`));
2735
- return false;
2736
- }
2836
+ __publicField(this, "CreateRandomString", (size = 43) => {
2837
+ const randomValues = Array.from(__privateGet(this, _crypto).getRandomValues(new Uint8Array(size)));
2838
+ const b64 = btoa(String.fromCharCode(...randomValues));
2839
+ return b64;
2737
2840
  });
2738
- __publicField(this, "Authorize", async () => {
2739
- try {
2740
- const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.AUTHORIZE });
2741
- __privateGet(this, _transactionStore).set(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY), response.payload.authorizeOptions);
2742
- const url = response.payload.url;
2743
- if (!isNode) {
2744
- window.location.replace(url);
2745
- } else {
2746
- return response.payload.authorizeOptionsClientCopy;
2747
- }
2748
- } catch (error) {
2749
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`Authorize Error: ${error}`));
2750
- }
2751
- return {};
2841
+ try {
2842
+ __privateSet(this, _crypto, crypto);
2843
+ } catch {
2844
+ __privateSet(this, _crypto, require("crypto"));
2845
+ }
2846
+ }
2847
+ }
2848
+ _crypto = new WeakMap();
2849
+ class QueryParams {
2850
+ constructor() {
2851
+ __publicField(this, "DecodeQueryParams", (params) => {
2852
+ const retObj = {};
2853
+ Object.keys(params).filter((k) => typeof params[k] !== "undefined").map((k) => {
2854
+ retObj[decodeURIComponent(k)] = decodeURIComponent(params[k]);
2855
+ });
2856
+ return retObj;
2752
2857
  });
2753
- __publicField(this, "HandleRedirect", async (queryVars) => {
2754
- try {
2755
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect`));
2756
- let response = null;
2757
- if (queryVars[OAuth2ParameterType.CODE]) {
2758
- const authorizeOptions = __privateGet(this, _transactionStore).get(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
2759
- __privateGet(this, _transactionStore).remove(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
2760
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
2761
- response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
2762
- queryVars,
2763
- authorizeOptions
2764
- } });
2858
+ __publicField(this, "CreateQueryParams", (params) => {
2859
+ return Object.keys(params).filter((k) => typeof params[k] !== "undefined").map((k) => {
2860
+ if (Array.isArray(params[k])) {
2861
+ return encodeURIComponent(k) + "=" + encodeURIComponent(params[k].join(" "));
2765
2862
  } else {
2766
- response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
2863
+ return encodeURIComponent(k) + "=" + encodeURIComponent(params[k]);
2767
2864
  }
2768
- __privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
2769
- return response.payload;
2770
- } catch (error) {
2771
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`HandleRedirect Error: ${error}`));
2772
- return false;
2773
- }
2774
- });
2775
- __publicField(this, "Logout", async () => {
2776
- try {
2777
- const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
2778
- return response.payload;
2779
- } catch (error) {
2780
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`Logout Error: ${error}`));
2781
- return false;
2782
- }
2865
+ }).join("&");
2783
2866
  });
2784
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2785
- __publicField(this, "InvokeExternalAPI", async () => {
2786
- try {
2787
- const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
2788
- return response.payload;
2789
- } catch (error) {
2790
- __privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`InvokeExternalAPI Error: ${error}`));
2791
- return null;
2867
+ __publicField(this, "_GetQueryParams", (param) => {
2868
+ let retVal = {};
2869
+ const uri = param.split("?");
2870
+ if (uri.length == 2) {
2871
+ const vars = uri[1].split("&");
2872
+ const getVars = {};
2873
+ let tmp;
2874
+ vars.forEach(function(v) {
2875
+ tmp = v.split("=");
2876
+ if (tmp.length == 2) getVars[tmp[0]] = tmp[1];
2877
+ });
2878
+ retVal = this.DecodeQueryParams(getVars);
2792
2879
  }
2880
+ return retVal;
2793
2881
  });
2794
- __publicField(this, "LoggedIn", () => {
2795
- try {
2796
- return __privateGet(this, _GetStore).call(this).LoggedIn;
2797
- } catch (error) {
2798
- return false;
2799
- }
2882
+ __publicField(this, "GetQueryParams", () => {
2883
+ return this._GetQueryParams(window.location.href);
2800
2884
  });
2801
- __privateSet(this, _options, options);
2802
- if (!isNode) {
2803
- if (app.config.globalProperties.$sts[STSInstrumentControllerPluginKey]) {
2804
- const STSInstrumentController = app.config.globalProperties.$sts[STSInstrumentControllerPluginKey];
2805
- __privateSet(this, _aic, STSInstrumentController);
2806
- }
2807
- __privateSet(this, _router, app.config.globalProperties.$router);
2808
- }
2809
- if (isNode) {
2810
- __privateSet(this, _transactionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage());
2811
- } else {
2812
- __privateSet(this, _transactionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.SESSION_STORAGE, usePrefix: false }).GetStorage());
2813
- }
2814
- if (__privateGet(this, _options).workerFactory) {
2815
- __privateSet(this, _worker, __privateGet(this, _options).workerFactory());
2816
- } else {
2817
- throw new Error(`STSOAuth2Manager:constructor: Cannot init STSOAuth2Manager - this.#options.workerFactory not specified`);
2818
- }
2819
- if (!isNode) {
2820
- __privateGet(this, _worker).onmessage = (data) => {
2821
- __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$1.green(`this.#worker.onmessage = [${data}]`));
2822
- };
2823
- __privateGet(this, _worker).onerror = (error) => {
2824
- __privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$1.green(`this.#worker.onerror = [${JSON.stringify(error)}]`));
2825
- };
2826
- }
2827
- let workerMessage;
2828
- if (isNode) {
2829
- const {
2830
- port1: oauth2ManagerPort,
2831
- // this process port
2832
- port2: oauth2WorkerPort
2833
- // worker port
2834
- } = new wt.MessageChannel();
2835
- __privateSet(this, _oauth2ManagerPort, oauth2ManagerPort);
2836
- workerMessage = {
2837
- workerPort: oauth2WorkerPort,
2838
- options: __privateGet(this, _options).workerOptions
2839
- };
2840
- __privateGet(this, _worker).postMessage(workerMessage, [oauth2WorkerPort]);
2841
- __privateGet(this, _oauth2ManagerPort).on("message", (payload) => {
2842
- __privateGet(this, _ProcessMessageResponse).call(this, payload);
2843
- }).unref();
2844
- } else {
2845
- const {
2846
- port1: oauth2ManagerPort,
2847
- // this process port
2848
- port2: oauth2WorkerPort
2849
- // worker port
2850
- } = new MessageChannel();
2851
- __privateSet(this, _oauth2ManagerPort, oauth2ManagerPort);
2852
- workerMessage = {
2853
- workerPort: oauth2WorkerPort,
2854
- options: __privateGet(this, _options).workerOptions
2855
- };
2856
- __privateGet(this, _worker).postMessage(workerMessage, [oauth2WorkerPort]);
2857
- __privateGet(this, _oauth2ManagerPort).onmessage = (data) => {
2858
- __privateGet(this, _ProcessMessageResponse).call(this, data.data);
2859
- };
2860
- __privateGet(this, _SetupRoute).call(this, app, __privateGet(this, _router));
2861
- }
2862
2885
  }
2863
2886
  }
2864
- _router = new WeakMap();
2865
- _cUtils = new WeakMap();
2866
- _qParams = new WeakMap();
2867
- _STORAGE_AUTHORIZE_OPTIONS_KEY = new WeakMap();
2868
- _STORAGE_SESSION_KEY = new WeakMap();
2869
- _aic = new WeakMap();
2870
- _options = new WeakMap();
2871
- _messages = new WeakMap();
2872
- _oauth2ManagerPort = new WeakMap();
2873
- _messageId = new WeakMap();
2874
- _messageHandlers = new WeakMap();
2875
- _messageTimeout = new WeakMap();
2876
- _worker = new WeakMap();
2877
- _transactionStore = new WeakMap();
2878
- _operationSemaphore = new WeakMap();
2879
- _maxSemaphoreRetries = new WeakMap();
2880
- _semaphoreRetrySleep = new WeakMap();
2881
- _STSOAuth2Manager_instances = new WeakSet();
2882
- LogDebugMessage_fn = function(message) {
2883
- __privateGet(this, _options).logger.debug(message);
2884
- };
2885
- LogInfoMessage_fn = function(message) {
2886
- __privateGet(this, _options).logger.info(message);
2887
- };
2888
- LogErrorMessage_fn = function(message) {
2889
- __privateGet(this, _options).logger.error(message);
2890
- };
2891
- _ProcessMessageResponse = new WeakMap();
2892
- _PostMessage = new WeakMap();
2893
- _HandleLogEvent = new WeakMap();
2894
- _HandleUpdateInstrumentEvent = new WeakMap();
2895
- _GetStore = new WeakMap();
2896
- _HandleErrorEvent = new WeakMap();
2897
- _HandleAuthenticateEvent = new WeakMap();
2898
- _SetupRoute = new WeakMap();
2899
2887
  var StatusCodes;
2900
2888
  (function(StatusCodes2) {
2901
2889
  StatusCodes2[StatusCodes2["CONTINUE"] = 100] = "CONTINUE";
@@ -2962,9 +2950,9 @@ class STSOAuth2Worker {
2962
2950
  __privateAdd(this, _STSOAuth2Worker_instances);
2963
2951
  //#storageManager = null;
2964
2952
  __privateAdd(this, _clientSessionStore);
2965
- __privateAdd(this, _cUtils2, new CryptoUtils());
2966
- __privateAdd(this, _qParams2, new QueryParams());
2967
- __privateAdd(this, _STORAGE_SESSION_KEY2, "session.stsmda.com.au");
2953
+ __privateAdd(this, _cUtils, new CryptoUtils());
2954
+ __privateAdd(this, _qParams, new QueryParams());
2955
+ __privateAdd(this, _STORAGE_SESSION_KEY, "session.stsmda.com.au");
2968
2956
  //@@#aic = null;
2969
2957
  __privateAdd(this, _oauthWorkerPort);
2970
2958
  __privateAdd(this, _options2);
@@ -3024,7 +3012,7 @@ class STSOAuth2Worker {
3024
3012
  __privateGet(this, _ProcessCommand).call(this, message, messageToSend);
3025
3013
  });
3026
3014
  __privateAdd(this, _GetAccessToken, () => {
3027
- const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
3015
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
3028
3016
  if (sessionData) {
3029
3017
  const tokens = sessionData.tokenResponse;
3030
3018
  return tokens.access_token;
@@ -3035,7 +3023,7 @@ class STSOAuth2Worker {
3035
3023
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3036
3024
  __privateAdd(this, _GetCookies, () => {
3037
3025
  if (isNode) {
3038
- const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
3026
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
3039
3027
  if (sessionData) {
3040
3028
  return sessionData.brokerCookie;
3041
3029
  } else {
@@ -3098,7 +3086,7 @@ class STSOAuth2Worker {
3098
3086
  });
3099
3087
  __privateAdd(this, _RestoreSession, async () => {
3100
3088
  let restoredSessionData = null;
3101
- const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
3089
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
3102
3090
  if (sessionData) {
3103
3091
  restoredSessionData = sessionData.tokenResponse;
3104
3092
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Session restored from client storage.");
@@ -3137,7 +3125,7 @@ class STSOAuth2Worker {
3137
3125
  if (isNode) {
3138
3126
  newSessionData.brokerCookie = retVal.headers["set-cookie"];
3139
3127
  }
3140
- __privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
3128
+ __privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY), newSessionData);
3141
3129
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Session restored from server side cookie.");
3142
3130
  } else {
3143
3131
  __privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, `Could not restore previous session. No restoredSessionData available.`);
@@ -3165,14 +3153,14 @@ class STSOAuth2Worker {
3165
3153
  __privateAdd(this, _Authorize, async () => {
3166
3154
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Authorize ...");
3167
3155
  const client_id = __privateGet(this, _options2).client_id;
3168
- const nonce = __privateGet(this, _cUtils2).CreateRandomString();
3156
+ const nonce = __privateGet(this, _cUtils).CreateRandomString();
3169
3157
  const response_type = [AuthorizeOptionsResponseType.CODE];
3170
3158
  const redirect_uri = __privateGet(this, _options2).redirect_uri;
3171
3159
  const response_mode = AuthorizeOptionsResponseMode.QUERY;
3172
3160
  const scope = __privateGet(this, _options2).scope;
3173
- const state = __privateGet(this, _cUtils2).CreateRandomString();
3174
- const code_verifier = __privateGet(this, _cUtils2).CreateRandomString();
3175
- const code_challenge = await __privateGet(this, _cUtils2).DigestMessage(code_verifier);
3161
+ const state = __privateGet(this, _cUtils).CreateRandomString();
3162
+ const code_verifier = __privateGet(this, _cUtils).CreateRandomString();
3163
+ const code_challenge = await __privateGet(this, _cUtils).DigestMessage(code_verifier);
3176
3164
  const code_challenge_method = "S256";
3177
3165
  const authorizeOptions = {
3178
3166
  client_id,
@@ -3186,7 +3174,7 @@ class STSOAuth2Worker {
3186
3174
  code_challenge_method
3187
3175
  };
3188
3176
  const authorizeOptionsClientCopy = { ...authorizeOptions };
3189
- const url = `${__privateGet(this, _options2).authorizeendpoint}:${__privateGet(this, _options2).authorizeport}${__privateGet(this, _options2).authorizeapiroot}${__privateGet(this, _options2).authorizeapi}?${__privateGet(this, _qParams2).CreateQueryParams(authorizeOptions)}`;
3177
+ const url = `${__privateGet(this, _options2).authorizeendpoint}:${__privateGet(this, _options2).authorizeport}${__privateGet(this, _options2).authorizeapiroot}${__privateGet(this, _options2).authorizeapi}?${__privateGet(this, _qParams).CreateQueryParams(authorizeOptions)}`;
3190
3178
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, url);
3191
3179
  authorizeOptions.code_verifier = code_verifier;
3192
3180
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, `Authorize:authorizeOptions: [${JSON.stringify(authorizeOptions)}]`);
@@ -3249,7 +3237,7 @@ class STSOAuth2Worker {
3249
3237
  // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
3250
3238
  __privateAdd(this, _GetTokenFromBroker, async (authorizationCodeFlowParameters) => {
3251
3239
  __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker`));
3252
- __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
3240
+ __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
3253
3241
  const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/token`;
3254
3242
  try {
3255
3243
  const rConfig = {
@@ -3277,7 +3265,7 @@ class STSOAuth2Worker {
3277
3265
  if (isNode) {
3278
3266
  newSessionData.brokerCookie = retVal.headers["set-cookie"];
3279
3267
  }
3280
- __privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
3268
+ __privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY), newSessionData);
3281
3269
  return true;
3282
3270
  } else if (retVal.status === StatusCodes.UNAUTHORIZED) {
3283
3271
  __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`));
@@ -3300,7 +3288,7 @@ class STSOAuth2Worker {
3300
3288
  __privateAdd(this, _GetToken, async (authorizeOptions, authorizeResponse) => {
3301
3289
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "#GetToken");
3302
3290
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, authorizeResponse);
3303
- __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
3291
+ __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
3304
3292
  const authorizationCodeFlowParameters = {
3305
3293
  client_id: __privateGet(this, _options2).client_id,
3306
3294
  scope: __privateGet(this, _options2).scope,
@@ -3338,7 +3326,7 @@ class STSOAuth2Worker {
3338
3326
  */
3339
3327
  __privateAdd(this, _RefreshToken, async () => {
3340
3328
  __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:start`));
3341
- const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
3329
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
3342
3330
  if (sessionData) {
3343
3331
  __privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(sessionData)}]`));
3344
3332
  const currentSessionData = sessionData.tokenResponse;
@@ -3363,7 +3351,7 @@ class STSOAuth2Worker {
3363
3351
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Logout");
3364
3352
  const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/logout`;
3365
3353
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, url);
3366
- const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
3354
+ const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY));
3367
3355
  if (sessionData) {
3368
3356
  const currentSessionData = sessionData.tokenResponse;
3369
3357
  const refresh_token = currentSessionData.refresh_token;
@@ -3372,7 +3360,7 @@ class STSOAuth2Worker {
3372
3360
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, decodedRefreshToken);
3373
3361
  const sessionId = decodedRefreshToken.sts_session;
3374
3362
  __privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, sessionId);
3375
- __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
3363
+ __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
3376
3364
  __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
3377
3365
  try {
3378
3366
  const rConfig = {
@@ -3432,9 +3420,9 @@ class STSOAuth2Worker {
3432
3420
  }
3433
3421
  }
3434
3422
  _clientSessionStore = new WeakMap();
3435
- _cUtils2 = new WeakMap();
3436
- _qParams2 = new WeakMap();
3437
- _STORAGE_SESSION_KEY2 = new WeakMap();
3423
+ _cUtils = new WeakMap();
3424
+ _qParams = new WeakMap();
3425
+ _STORAGE_SESSION_KEY = new WeakMap();
3438
3426
  _oauthWorkerPort = new WeakMap();
3439
3427
  _options2 = new WeakMap();
3440
3428
  _httpsAgent = new WeakMap();