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