@nsshunt/stsoauth2plugin 1.0.94 → 1.0.96
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 +118 -154
- package/dist/stsoauth2plugin.mjs.map +1 -1
- package/dist/stsoauth2plugin.umd.js +118 -154
- package/dist/stsoauth2plugin.umd.js.map +1 -1
- package/package.json +11 -11
|
@@ -2,29 +2,16 @@
|
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("node:worker_threads"), require("@nsshunt/stsutils"), require("@nsshunt/stsvueutils"), require("pinia"), require("@nsshunt/stsobservability"), require("node:https"), require("colors"), require("axios")) : typeof define === "function" && define.amd ? define(["exports", "vue", "node:worker_threads", "@nsshunt/stsutils", "@nsshunt/stsvueutils", "pinia", "@nsshunt/stsobservability", "node:https", "colors", "axios"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["@nsshunt/stsoauth2plugin"] = {}, global2.vue, global2.worker_threads, global2.stsutils, global2.stsvueutils, global2.pinia, global2.stsobservability, global2.https, null, global2.axios));
|
|
3
3
|
})(this, function(exports2, vue, wt, stsutils, stsvueutils, pinia, stsobservability, https, colors, axios) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
-
return value;
|
|
9
|
-
};
|
|
10
|
-
var __accessCheck = (obj, member, msg) => {
|
|
11
|
-
if (!member.has(obj))
|
|
12
|
-
throw TypeError("Cannot " + msg);
|
|
13
|
-
};
|
|
14
|
-
var __privateGet = (obj, member, getter) => {
|
|
15
|
-
__accessCheck(obj, member, "read from private field");
|
|
16
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
17
|
-
};
|
|
18
|
-
var __privateAdd = (obj, member, value) => {
|
|
19
|
-
if (member.has(obj))
|
|
20
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
21
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
22
|
-
};
|
|
23
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
24
|
-
__accessCheck(obj, member, "write to private field");
|
|
25
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
26
|
-
return value;
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
27
7
|
};
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
11
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
12
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
14
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
28
15
|
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
29
16
|
set _(value) {
|
|
30
17
|
__privateSet(obj, member, value, setter);
|
|
@@ -33,12 +20,8 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
33
20
|
return __privateGet(obj, member, getter);
|
|
34
21
|
}
|
|
35
22
|
});
|
|
36
|
-
var __privateMethod = (obj, member, method) => {
|
|
37
|
-
__accessCheck(obj, member, "access private method");
|
|
38
|
-
return method;
|
|
39
|
-
};
|
|
40
23
|
|
|
41
|
-
var _crypto, _router, _cUtils, _qParams, _STORAGE_AUTHORIZE_OPTIONS_KEY, _STORAGE_SESSION_KEY, _aic, _options, _messages, _oauth2ManagerPort, _messageId, _messageHandlers, _messageTimeout, _worker, _transactionStore, _operationSemaphore, _maxSemaphoreRetries, _semaphoreRetrySleep,
|
|
24
|
+
var _crypto, _router, _cUtils, _qParams, _STORAGE_AUTHORIZE_OPTIONS_KEY, _STORAGE_SESSION_KEY, _aic, _options, _messages, _oauth2ManagerPort, _messageId, _messageHandlers, _messageTimeout, _worker, _transactionStore, _operationSemaphore, _maxSemaphoreRetries, _semaphoreRetrySleep, _STSOAuth2Manager_instances, LogDebugMessage_fn, LogInfoMessage_fn, LogErrorMessage_fn, _ProcessMessageResponse, _PostMessage, _HandleLogEvent, _HandleUpdateInstrumentEvent, _GetStore, _HandleErrorEvent, _HandleAuthenticateEvent, _SetupRoute, _clientSessionStore, _cUtils2, _qParams2, _STORAGE_SESSION_KEY2, _oauthWorkerPort, _options2, _httpsAgent, _logger, _STSOAuth2Worker_instances, LogDebugMessage_fn2, LogInfoMessage_fn2, LogErrorMessage_fn2, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
|
|
42
25
|
function _interopNamespaceDefault(e) {
|
|
43
26
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
44
27
|
if (e) {
|
|
@@ -62,8 +45,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
62
45
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
63
46
|
}
|
|
64
47
|
function getAugmentedNamespace(n) {
|
|
65
|
-
if (n.__esModule)
|
|
66
|
-
return n;
|
|
48
|
+
if (n.__esModule) return n;
|
|
67
49
|
var f = n.default;
|
|
68
50
|
if (typeof f == "function") {
|
|
69
51
|
var a = function a2() {
|
|
@@ -73,8 +55,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
73
55
|
return f.apply(this, arguments);
|
|
74
56
|
};
|
|
75
57
|
a.prototype = f.prototype;
|
|
76
|
-
} else
|
|
77
|
-
a = {};
|
|
58
|
+
} else a = {};
|
|
78
59
|
Object.defineProperty(a, "__esModule", { value: true });
|
|
79
60
|
Object.keys(n).forEach(function(k) {
|
|
80
61
|
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
@@ -91,8 +72,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
91
72
|
var colorName;
|
|
92
73
|
var hasRequiredColorName;
|
|
93
74
|
function requireColorName() {
|
|
94
|
-
if (hasRequiredColorName)
|
|
95
|
-
return colorName;
|
|
75
|
+
if (hasRequiredColorName) return colorName;
|
|
96
76
|
hasRequiredColorName = 1;
|
|
97
77
|
colorName = {
|
|
98
78
|
"aliceblue": [240, 248, 255],
|
|
@@ -249,8 +229,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
249
229
|
var conversions;
|
|
250
230
|
var hasRequiredConversions;
|
|
251
231
|
function requireConversions() {
|
|
252
|
-
if (hasRequiredConversions)
|
|
253
|
-
return conversions;
|
|
232
|
+
if (hasRequiredConversions) return conversions;
|
|
254
233
|
hasRequiredConversions = 1;
|
|
255
234
|
const cssKeywords = requireColorName();
|
|
256
235
|
const reverseKeywords = {};
|
|
@@ -922,8 +901,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
922
901
|
var route;
|
|
923
902
|
var hasRequiredRoute;
|
|
924
903
|
function requireRoute() {
|
|
925
|
-
if (hasRequiredRoute)
|
|
926
|
-
return route;
|
|
904
|
+
if (hasRequiredRoute) return route;
|
|
927
905
|
hasRequiredRoute = 1;
|
|
928
906
|
const conversions2 = requireConversions();
|
|
929
907
|
function buildGraph() {
|
|
@@ -994,8 +972,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
994
972
|
var colorConvert;
|
|
995
973
|
var hasRequiredColorConvert;
|
|
996
974
|
function requireColorConvert() {
|
|
997
|
-
if (hasRequiredColorConvert)
|
|
998
|
-
return colorConvert;
|
|
975
|
+
if (hasRequiredColorConvert) return colorConvert;
|
|
999
976
|
hasRequiredColorConvert = 1;
|
|
1000
977
|
const conversions2 = requireConversions();
|
|
1001
978
|
const route2 = requireRoute();
|
|
@@ -1232,8 +1209,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1232
1209
|
var templates;
|
|
1233
1210
|
var hasRequiredTemplates;
|
|
1234
1211
|
function requireTemplates() {
|
|
1235
|
-
if (hasRequiredTemplates)
|
|
1236
|
-
return templates;
|
|
1212
|
+
if (hasRequiredTemplates) return templates;
|
|
1237
1213
|
hasRequiredTemplates = 1;
|
|
1238
1214
|
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
|
1239
1215
|
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
@@ -1530,8 +1506,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1530
1506
|
const require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
|
|
1531
1507
|
var hasRequiredCore;
|
|
1532
1508
|
function requireCore() {
|
|
1533
|
-
if (hasRequiredCore)
|
|
1534
|
-
return core.exports;
|
|
1509
|
+
if (hasRequiredCore) return core.exports;
|
|
1535
1510
|
hasRequiredCore = 1;
|
|
1536
1511
|
(function(module2, exports3) {
|
|
1537
1512
|
(function(root, factory) {
|
|
@@ -2355,7 +2330,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2355
2330
|
const Base64 = /* @__PURE__ */ getDefaultExportFromCjs(encBase64Exports);
|
|
2356
2331
|
class CryptoUtils {
|
|
2357
2332
|
constructor() {
|
|
2358
|
-
__privateAdd(this, _crypto
|
|
2333
|
+
__privateAdd(this, _crypto);
|
|
2359
2334
|
__publicField(this, "DigestMessage", async function(message) {
|
|
2360
2335
|
const hashDigest = sha256(message);
|
|
2361
2336
|
return Base64.stringify(hashDigest);
|
|
@@ -2400,8 +2375,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2400
2375
|
let tmp;
|
|
2401
2376
|
vars.forEach(function(v) {
|
|
2402
2377
|
tmp = v.split("=");
|
|
2403
|
-
if (tmp.length == 2)
|
|
2404
|
-
getVars[tmp[0]] = tmp[1];
|
|
2378
|
+
if (tmp.length == 2) getVars[tmp[0]] = tmp[1];
|
|
2405
2379
|
});
|
|
2406
2380
|
retVal = this.DecodeQueryParams(getVars);
|
|
2407
2381
|
}
|
|
@@ -2549,9 +2523,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2549
2523
|
class STSOAuth2Manager {
|
|
2550
2524
|
// ms
|
|
2551
2525
|
constructor(app, options) {
|
|
2552
|
-
__privateAdd(this,
|
|
2553
|
-
__privateAdd(this, _LogInfoMessage);
|
|
2554
|
-
__privateAdd(this, _LogErrorMessage);
|
|
2526
|
+
__privateAdd(this, _STSOAuth2Manager_instances);
|
|
2555
2527
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2556
2528
|
__privateAdd(this, _router, null);
|
|
2557
2529
|
__privateAdd(this, _cUtils, new CryptoUtils());
|
|
@@ -2559,16 +2531,16 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2559
2531
|
__privateAdd(this, _STORAGE_AUTHORIZE_OPTIONS_KEY, "authorize_options.stsmda.com.au");
|
|
2560
2532
|
__privateAdd(this, _STORAGE_SESSION_KEY, "session.stsmda.com.au");
|
|
2561
2533
|
__privateAdd(this, _aic, null);
|
|
2562
|
-
__privateAdd(this, _options
|
|
2534
|
+
__privateAdd(this, _options);
|
|
2563
2535
|
__privateAdd(this, _messages, {});
|
|
2564
|
-
__privateAdd(this, _oauth2ManagerPort
|
|
2536
|
+
__privateAdd(this, _oauth2ManagerPort);
|
|
2565
2537
|
__privateAdd(this, _messageId, 0);
|
|
2566
2538
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2567
2539
|
__privateAdd(this, _messageHandlers, {});
|
|
2568
2540
|
// keyed by messageId
|
|
2569
2541
|
__privateAdd(this, _messageTimeout, 1e4);
|
|
2570
|
-
__privateAdd(this, _worker
|
|
2571
|
-
__privateAdd(this, _transactionStore
|
|
2542
|
+
__privateAdd(this, _worker);
|
|
2543
|
+
__privateAdd(this, _transactionStore);
|
|
2572
2544
|
// Transient transaction data used to establish a session via OAuth2 authorize handshake
|
|
2573
2545
|
__privateAdd(this, _operationSemaphore, false);
|
|
2574
2546
|
__privateAdd(this, _maxSemaphoreRetries, 100);
|
|
@@ -2576,7 +2548,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2576
2548
|
__privateAdd(this, _semaphoreRetrySleep, 50);
|
|
2577
2549
|
__privateAdd(this, _ProcessMessageResponse, (data) => {
|
|
2578
2550
|
const messageResponse = data;
|
|
2579
|
-
__privateMethod(this,
|
|
2551
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`));
|
|
2580
2552
|
if (messageResponse.messageId === -1) {
|
|
2581
2553
|
switch (messageResponse.command) {
|
|
2582
2554
|
case IOauth2ListenerCommand.AUTHENTICATE_EVENT:
|
|
@@ -2613,10 +2585,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2613
2585
|
__privateGet(this, _messageHandlers)[message.messageId] = (response) => {
|
|
2614
2586
|
clearTimeout(timeout);
|
|
2615
2587
|
delete __privateGet(this, _messageHandlers)[message.messageId];
|
|
2616
|
-
__privateMethod(this,
|
|
2588
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`));
|
|
2617
2589
|
resolve(response);
|
|
2618
2590
|
};
|
|
2619
|
-
__privateMethod(this,
|
|
2591
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.yellow(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`));
|
|
2620
2592
|
__privateGet(this, _oauth2ManagerPort).postMessage(message);
|
|
2621
2593
|
});
|
|
2622
2594
|
});
|
|
@@ -2624,7 +2596,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2624
2596
|
if (__privateGet(this, _aic)) {
|
|
2625
2597
|
__privateGet(this, _aic).LogEx(message);
|
|
2626
2598
|
}
|
|
2627
|
-
__privateMethod(this,
|
|
2599
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, message);
|
|
2628
2600
|
});
|
|
2629
2601
|
// UpdateInstrument = (instrumentName: Gauge, telemetry: InstrumentBaseTelemetry): void => {
|
|
2630
2602
|
__privateAdd(this, _HandleUpdateInstrumentEvent, (instrumentName, telemetry) => {
|
|
@@ -2637,8 +2609,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2637
2609
|
});
|
|
2638
2610
|
// Will come from message channel
|
|
2639
2611
|
__privateAdd(this, _HandleErrorEvent, (error) => {
|
|
2640
|
-
if (isNode)
|
|
2641
|
-
;
|
|
2612
|
+
if (isNode) ;
|
|
2642
2613
|
else {
|
|
2643
2614
|
__privateGet(this, _GetStore).call(this).UpdateError({
|
|
2644
2615
|
// Authorize applications store
|
|
@@ -2650,8 +2621,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2650
2621
|
}
|
|
2651
2622
|
});
|
|
2652
2623
|
__privateAdd(this, _HandleAuthenticateEvent, (id_token) => {
|
|
2653
|
-
if (isNode)
|
|
2654
|
-
;
|
|
2624
|
+
if (isNode) ;
|
|
2655
2625
|
else {
|
|
2656
2626
|
if (__privateGet(this, _options).authenticateEvent) {
|
|
2657
2627
|
__privateGet(this, _options).authenticateEvent(id_token);
|
|
@@ -2660,14 +2630,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2660
2630
|
}
|
|
2661
2631
|
});
|
|
2662
2632
|
__privateAdd(this, _SetupRoute, (app, router) => {
|
|
2663
|
-
__privateMethod(this,
|
|
2633
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.gray(`STSOAuth2Manager:#SetupRoute`));
|
|
2664
2634
|
router.beforeEach(async (to, from, next) => {
|
|
2665
2635
|
const oAuth2Manager = app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey];
|
|
2666
|
-
__privateMethod(this,
|
|
2636
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.gray(`beforeEach: from: [${from.path}], to: [${to.path}]`));
|
|
2667
2637
|
if (__privateGet(this, _GetStore).call(this).LoggedIn === false) {
|
|
2668
|
-
__privateMethod(this,
|
|
2638
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, `Not logged in`);
|
|
2669
2639
|
if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}authorize`) === 0) {
|
|
2670
|
-
__privateMethod(this,
|
|
2640
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, `to = ${__privateGet(this, _options).uriBase}authorize`);
|
|
2671
2641
|
next();
|
|
2672
2642
|
return;
|
|
2673
2643
|
} else if (to.path.localeCompare(`${__privateGet(this, _options).uriBase}consent`) === 0) {
|
|
@@ -2694,9 +2664,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2694
2664
|
}
|
|
2695
2665
|
const str = to.query;
|
|
2696
2666
|
if (str[stsutils.OAuth2ParameterType.CODE] || str[stsutils.OAuth2ParameterType.ERROR]) {
|
|
2697
|
-
__privateMethod(this,
|
|
2667
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
|
|
2698
2668
|
const retVal = await oAuth2Manager.HandleRedirect(str);
|
|
2699
|
-
__privateMethod(this,
|
|
2669
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
|
|
2700
2670
|
if (retVal) {
|
|
2701
2671
|
next({
|
|
2702
2672
|
path: `${__privateGet(this, _options).uriBase}`,
|
|
@@ -2711,11 +2681,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2711
2681
|
return;
|
|
2712
2682
|
}
|
|
2713
2683
|
}
|
|
2714
|
-
__privateMethod(this,
|
|
2684
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:#SetupRoute:Restoring session`);
|
|
2715
2685
|
const sessionRestored = await oAuth2Manager.RestoreSession();
|
|
2716
|
-
__privateMethod(this,
|
|
2686
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:#SetupRoute:Session restored: [${sessionRestored}]`);
|
|
2717
2687
|
if (sessionRestored !== true) {
|
|
2718
|
-
__privateMethod(this,
|
|
2688
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:#SetupRoute:Session not restored - need to authorize`);
|
|
2719
2689
|
oAuth2Manager.Authorize();
|
|
2720
2690
|
next();
|
|
2721
2691
|
return;
|
|
@@ -2752,7 +2722,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2752
2722
|
throw new Error(`STSOAuth2Manager:ExecuteRefreshToken:maxSemaphoreRetries: [${__privateGet(this, _maxSemaphoreRetries)}] exceeded.`);
|
|
2753
2723
|
}
|
|
2754
2724
|
await stsutils.Sleep(__privateGet(this, _semaphoreRetrySleep));
|
|
2755
|
-
__privateMethod(this,
|
|
2725
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.cyan(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`));
|
|
2756
2726
|
return await this.ExecuteRefreshToken(retryCount + 1);
|
|
2757
2727
|
} else {
|
|
2758
2728
|
__privateSet(this, _operationSemaphore, true);
|
|
@@ -2768,12 +2738,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2768
2738
|
});
|
|
2769
2739
|
__publicField(this, "RestoreSession", async () => {
|
|
2770
2740
|
try {
|
|
2771
|
-
__privateMethod(this,
|
|
2741
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:RestoreSession:postMessage: [${IOauth2ListenerCommand.RESTORE_SESSION}]`);
|
|
2772
2742
|
const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.RESTORE_SESSION });
|
|
2773
|
-
__privateMethod(this,
|
|
2743
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, `STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
|
|
2774
2744
|
return response.payload;
|
|
2775
2745
|
} catch (error) {
|
|
2776
|
-
__privateMethod(this,
|
|
2746
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`RestoreSession Error: ${error}`));
|
|
2777
2747
|
return false;
|
|
2778
2748
|
}
|
|
2779
2749
|
});
|
|
@@ -2788,18 +2758,18 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2788
2758
|
return response.payload.authorizeOptionsClientCopy;
|
|
2789
2759
|
}
|
|
2790
2760
|
} catch (error) {
|
|
2791
|
-
__privateMethod(this,
|
|
2761
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`Authorize Error: ${error}`));
|
|
2792
2762
|
}
|
|
2793
2763
|
return {};
|
|
2794
2764
|
});
|
|
2795
2765
|
__publicField(this, "HandleRedirect", async (queryVars) => {
|
|
2796
2766
|
try {
|
|
2797
|
-
__privateMethod(this,
|
|
2767
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect`));
|
|
2798
2768
|
let response = null;
|
|
2799
2769
|
if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
|
|
2800
2770
|
const authorizeOptions = __privateGet(this, _transactionStore).get(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
|
|
2801
2771
|
__privateGet(this, _transactionStore).remove(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
|
|
2802
|
-
__privateMethod(this,
|
|
2772
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
|
|
2803
2773
|
response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
|
|
2804
2774
|
queryVars,
|
|
2805
2775
|
authorizeOptions
|
|
@@ -2807,10 +2777,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2807
2777
|
} else {
|
|
2808
2778
|
response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
|
|
2809
2779
|
}
|
|
2810
|
-
__privateMethod(this,
|
|
2780
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogDebugMessage_fn).call(this, chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
|
|
2811
2781
|
return response.payload;
|
|
2812
2782
|
} catch (error) {
|
|
2813
|
-
__privateMethod(this,
|
|
2783
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`HandleRedirect Error: ${error}`));
|
|
2814
2784
|
return false;
|
|
2815
2785
|
}
|
|
2816
2786
|
});
|
|
@@ -2819,7 +2789,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2819
2789
|
const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
|
|
2820
2790
|
return response.payload;
|
|
2821
2791
|
} catch (error) {
|
|
2822
|
-
__privateMethod(this,
|
|
2792
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`Logout Error: ${error}`));
|
|
2823
2793
|
return false;
|
|
2824
2794
|
}
|
|
2825
2795
|
});
|
|
@@ -2829,7 +2799,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2829
2799
|
const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.LOGOUT });
|
|
2830
2800
|
return response.payload;
|
|
2831
2801
|
} catch (error) {
|
|
2832
|
-
__privateMethod(this,
|
|
2802
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogErrorMessage_fn).call(this, chalk$1.red(`InvokeExternalAPI Error: ${error}`));
|
|
2833
2803
|
return null;
|
|
2834
2804
|
}
|
|
2835
2805
|
});
|
|
@@ -2860,10 +2830,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2860
2830
|
}
|
|
2861
2831
|
if (!isNode) {
|
|
2862
2832
|
__privateGet(this, _worker).onmessage = (data) => {
|
|
2863
|
-
__privateMethod(this,
|
|
2833
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$1.green(`this.#worker.onmessage = [${data}]`));
|
|
2864
2834
|
};
|
|
2865
2835
|
__privateGet(this, _worker).onerror = (error) => {
|
|
2866
|
-
__privateMethod(this,
|
|
2836
|
+
__privateMethod(this, _STSOAuth2Manager_instances, LogInfoMessage_fn).call(this, chalk$1.green(`this.#worker.onerror = [${JSON.stringify(error)}]`));
|
|
2867
2837
|
};
|
|
2868
2838
|
}
|
|
2869
2839
|
let workerMessage;
|
|
@@ -2920,15 +2890,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2920
2890
|
_operationSemaphore = new WeakMap();
|
|
2921
2891
|
_maxSemaphoreRetries = new WeakMap();
|
|
2922
2892
|
_semaphoreRetrySleep = new WeakMap();
|
|
2923
|
-
|
|
2893
|
+
_STSOAuth2Manager_instances = new WeakSet();
|
|
2924
2894
|
LogDebugMessage_fn = function(message) {
|
|
2925
2895
|
__privateGet(this, _options).logger.debug(message);
|
|
2926
2896
|
};
|
|
2927
|
-
_LogInfoMessage = new WeakSet();
|
|
2928
2897
|
LogInfoMessage_fn = function(message) {
|
|
2929
2898
|
__privateGet(this, _options).logger.info(message);
|
|
2930
2899
|
};
|
|
2931
|
-
_LogErrorMessage = new WeakSet();
|
|
2932
2900
|
LogErrorMessage_fn = function(message) {
|
|
2933
2901
|
__privateGet(this, _options).logger.error(message);
|
|
2934
2902
|
};
|
|
@@ -3003,22 +2971,17 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3003
2971
|
})(StatusCodes || (StatusCodes = {}));
|
|
3004
2972
|
class STSOAuth2Worker {
|
|
3005
2973
|
constructor(workerPort, options, logger) {
|
|
3006
|
-
|
|
3007
|
-
__privateAdd(this, _LogDebugMessage2);
|
|
3008
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3009
|
-
__privateAdd(this, _LogInfoMessage2);
|
|
3010
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3011
|
-
__privateAdd(this, _LogErrorMessage2);
|
|
2974
|
+
__privateAdd(this, _STSOAuth2Worker_instances);
|
|
3012
2975
|
//#storageManager = null;
|
|
3013
|
-
__privateAdd(this, _clientSessionStore
|
|
2976
|
+
__privateAdd(this, _clientSessionStore);
|
|
3014
2977
|
__privateAdd(this, _cUtils2, new CryptoUtils());
|
|
3015
2978
|
__privateAdd(this, _qParams2, new QueryParams());
|
|
3016
2979
|
__privateAdd(this, _STORAGE_SESSION_KEY2, "session.stsmda.com.au");
|
|
3017
2980
|
//@@#aic = null;
|
|
3018
|
-
__privateAdd(this, _oauthWorkerPort
|
|
3019
|
-
__privateAdd(this, _options2
|
|
2981
|
+
__privateAdd(this, _oauthWorkerPort);
|
|
2982
|
+
__privateAdd(this, _options2);
|
|
3020
2983
|
__privateAdd(this, _httpsAgent, null);
|
|
3021
|
-
__privateAdd(this, _logger
|
|
2984
|
+
__privateAdd(this, _logger);
|
|
3022
2985
|
// Attempt to restore a previous session using the STSBroker
|
|
3023
2986
|
/*
|
|
3024
2987
|
{ parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
|
|
@@ -3108,7 +3071,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3108
3071
|
__publicField(this, "SetupListener", () => {
|
|
3109
3072
|
__privateGet(this, _oauthWorkerPort).onmessage = async (data) => {
|
|
3110
3073
|
const auth2ListenerMessage = data.data;
|
|
3111
|
-
__privateMethod(this,
|
|
3074
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, `STSOAuth2Worker:SetupListener:onmessage: [${auth2ListenerMessage.command}]`);
|
|
3112
3075
|
switch (auth2ListenerMessage.command) {
|
|
3113
3076
|
case IOauth2ListenerCommand.RESTORE_SESSION:
|
|
3114
3077
|
__privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _RestoreSession).call(this));
|
|
@@ -3150,12 +3113,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3150
3113
|
const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3151
3114
|
if (sessionData) {
|
|
3152
3115
|
restoredSessionData = sessionData.tokenResponse;
|
|
3153
|
-
__privateMethod(this,
|
|
3116
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Session restored from client storage.");
|
|
3154
3117
|
__privateGet(this, _LogMessage).call(this, "Session restored from client storage.");
|
|
3155
3118
|
} else {
|
|
3156
3119
|
const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/session`;
|
|
3157
|
-
__privateMethod(this,
|
|
3158
|
-
__privateMethod(this,
|
|
3120
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "RestoreSession");
|
|
3121
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, url);
|
|
3159
3122
|
__privateGet(this, _LogMessage).call(this, "RestoreSession.");
|
|
3160
3123
|
__privateGet(this, _LogMessage).call(this, url);
|
|
3161
3124
|
try {
|
|
@@ -3172,7 +3135,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3172
3135
|
// Ensure cookies are passed to the service
|
|
3173
3136
|
timeout: __privateGet(this, _options2).timeout
|
|
3174
3137
|
};
|
|
3175
|
-
__privateMethod(this,
|
|
3138
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
|
|
3176
3139
|
if (isNode) {
|
|
3177
3140
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
3178
3141
|
}
|
|
@@ -3187,24 +3150,24 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3187
3150
|
newSessionData.brokerCookie = retVal.headers["set-cookie"];
|
|
3188
3151
|
}
|
|
3189
3152
|
__privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
|
|
3190
|
-
__privateMethod(this,
|
|
3153
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Session restored from server side cookie.");
|
|
3191
3154
|
} else {
|
|
3192
|
-
__privateMethod(this,
|
|
3193
|
-
__privateMethod(this,
|
|
3155
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, `Could not restore previous session. No restoredSessionData available.`);
|
|
3156
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, JSON.stringify(retVal.data));
|
|
3194
3157
|
}
|
|
3195
3158
|
} else {
|
|
3196
|
-
__privateMethod(this,
|
|
3197
|
-
__privateMethod(this,
|
|
3159
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, "Could not restore previous session:-");
|
|
3160
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, JSON.stringify(retVal.data));
|
|
3198
3161
|
}
|
|
3199
3162
|
} catch (error) {
|
|
3200
|
-
__privateMethod(this,
|
|
3201
|
-
__privateMethod(this,
|
|
3202
|
-
__privateMethod(this,
|
|
3163
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, "Could not restore previous session (error state):-");
|
|
3164
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, error);
|
|
3165
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, JSON.stringify(error));
|
|
3203
3166
|
}
|
|
3204
3167
|
}
|
|
3205
3168
|
if (restoredSessionData !== null) {
|
|
3206
3169
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, restoredSessionData.id_token);
|
|
3207
|
-
__privateMethod(this,
|
|
3170
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Refreshing tokens ...");
|
|
3208
3171
|
return await __privateGet(this, _RefreshToken).call(this);
|
|
3209
3172
|
} else {
|
|
3210
3173
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
@@ -3212,7 +3175,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3212
3175
|
}
|
|
3213
3176
|
});
|
|
3214
3177
|
__privateAdd(this, _Authorize, async () => {
|
|
3215
|
-
__privateMethod(this,
|
|
3178
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Authorize ...");
|
|
3216
3179
|
const client_id = __privateGet(this, _options2).client_id;
|
|
3217
3180
|
const nonce = __privateGet(this, _cUtils2).CreateRandomString();
|
|
3218
3181
|
const response_type = [AuthorizeOptionsResponseType.CODE];
|
|
@@ -3236,9 +3199,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3236
3199
|
};
|
|
3237
3200
|
const authorizeOptionsClientCopy = { ...authorizeOptions };
|
|
3238
3201
|
const url = `${__privateGet(this, _options2).authorizeendpoint}:${__privateGet(this, _options2).authorizeport}${__privateGet(this, _options2).authorizeapiroot}${__privateGet(this, _options2).authorizeapi}?${__privateGet(this, _qParams2).CreateQueryParams(authorizeOptions)}`;
|
|
3239
|
-
__privateMethod(this,
|
|
3202
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, url);
|
|
3240
3203
|
authorizeOptions.code_verifier = code_verifier;
|
|
3241
|
-
__privateMethod(this,
|
|
3204
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, `Authorize:authorizeOptions: [${JSON.stringify(authorizeOptions)}]`);
|
|
3242
3205
|
return {
|
|
3243
3206
|
url,
|
|
3244
3207
|
authorizeOptions,
|
|
@@ -3249,29 +3212,29 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3249
3212
|
__privateAdd(this, _HandleRedirect, async (payload) => {
|
|
3250
3213
|
const queryVars = payload.queryVars;
|
|
3251
3214
|
const authorizeOptions = payload.authorizeOptions;
|
|
3252
|
-
__privateMethod(this,
|
|
3253
|
-
__privateMethod(this,
|
|
3215
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#HandleRedirect: HandleRedirect`));
|
|
3216
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`));
|
|
3254
3217
|
if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
|
|
3255
3218
|
const response = queryVars;
|
|
3256
|
-
__privateMethod(this,
|
|
3219
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, `authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
|
|
3257
3220
|
const redirectState = response.state;
|
|
3258
3221
|
const authorizeOptionsState = authorizeOptions.state;
|
|
3259
3222
|
if (authorizeOptionsState.localeCompare(redirectState) === 0) {
|
|
3260
|
-
__privateMethod(this,
|
|
3223
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, chalk$1.green("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"));
|
|
3261
3224
|
return await __privateGet(this, _GetToken).call(this, authorizeOptions, response);
|
|
3262
3225
|
} else {
|
|
3263
|
-
__privateMethod(this,
|
|
3264
|
-
__privateMethod(this,
|
|
3265
|
-
__privateMethod(this,
|
|
3226
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"));
|
|
3227
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`authorizeOptionsState: [${authorizeOptionsState}]`));
|
|
3228
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`redirectState: [${redirectState}]`));
|
|
3266
3229
|
__privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
|
|
3267
3230
|
return false;
|
|
3268
3231
|
}
|
|
3269
3232
|
} else if (queryVars[stsutils.OAuth2ParameterType.ERROR]) {
|
|
3270
|
-
__privateMethod(this,
|
|
3233
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`State un-matched (1)`));
|
|
3271
3234
|
__privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
|
|
3272
3235
|
return false;
|
|
3273
3236
|
} else {
|
|
3274
|
-
__privateMethod(this,
|
|
3237
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`State un-matched (2)`));
|
|
3275
3238
|
__privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
|
|
3276
3239
|
return false;
|
|
3277
3240
|
}
|
|
@@ -3297,7 +3260,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3297
3260
|
*/
|
|
3298
3261
|
// Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
|
|
3299
3262
|
__privateAdd(this, _GetTokenFromBroker, async (authorizationCodeFlowParameters) => {
|
|
3300
|
-
__privateMethod(this,
|
|
3263
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker`));
|
|
3301
3264
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3302
3265
|
const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/token`;
|
|
3303
3266
|
try {
|
|
@@ -3309,15 +3272,15 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3309
3272
|
// Ensure cookies are passed to the service
|
|
3310
3273
|
timeout: __privateGet(this, _options2).timeout
|
|
3311
3274
|
};
|
|
3312
|
-
__privateMethod(this,
|
|
3275
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
|
|
3313
3276
|
if (isNode) {
|
|
3314
3277
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
3315
3278
|
}
|
|
3316
|
-
__privateMethod(this,
|
|
3279
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: axios API call`));
|
|
3317
3280
|
const retVal = await axios(rConfig);
|
|
3318
|
-
__privateMethod(this,
|
|
3281
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
|
|
3319
3282
|
if (retVal.status === StatusCodes.OK) {
|
|
3320
|
-
__privateMethod(this,
|
|
3283
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: storing tokens`));
|
|
3321
3284
|
const tokenResponse = retVal.data;
|
|
3322
3285
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, tokenResponse.id_token);
|
|
3323
3286
|
const newSessionData = {
|
|
@@ -3329,26 +3292,26 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3329
3292
|
__privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
|
|
3330
3293
|
return true;
|
|
3331
3294
|
} else if (retVal.status === StatusCodes.UNAUTHORIZED) {
|
|
3332
|
-
__privateMethod(this,
|
|
3295
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`));
|
|
3333
3296
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3334
3297
|
return false;
|
|
3335
3298
|
} else {
|
|
3336
|
-
__privateMethod(this,
|
|
3299
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`));
|
|
3337
3300
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3338
|
-
__privateMethod(this,
|
|
3339
|
-
__privateMethod(this,
|
|
3301
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red("Could not obtain access_token from token end-point:-"));
|
|
3302
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(JSON.stringify(retVal.data)));
|
|
3340
3303
|
return false;
|
|
3341
3304
|
}
|
|
3342
3305
|
} catch (error) {
|
|
3343
|
-
__privateMethod(this,
|
|
3306
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`));
|
|
3344
3307
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3345
3308
|
return false;
|
|
3346
3309
|
}
|
|
3347
3310
|
});
|
|
3348
3311
|
// Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
|
|
3349
3312
|
__privateAdd(this, _GetToken, async (authorizeOptions, authorizeResponse) => {
|
|
3350
|
-
__privateMethod(this,
|
|
3351
|
-
__privateMethod(this,
|
|
3313
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "#GetToken");
|
|
3314
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, authorizeResponse);
|
|
3352
3315
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3353
3316
|
const authorizationCodeFlowParameters = {
|
|
3354
3317
|
client_id: __privateGet(this, _options2).client_id,
|
|
@@ -3386,10 +3349,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3386
3349
|
}
|
|
3387
3350
|
*/
|
|
3388
3351
|
__privateAdd(this, _RefreshToken, async () => {
|
|
3389
|
-
__privateMethod(this,
|
|
3352
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:start`));
|
|
3390
3353
|
const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3391
3354
|
if (sessionData) {
|
|
3392
|
-
__privateMethod(this,
|
|
3355
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(sessionData)}]`));
|
|
3393
3356
|
const currentSessionData = sessionData.tokenResponse;
|
|
3394
3357
|
const refreshFlowParameters = {
|
|
3395
3358
|
client_id: __privateGet(this, _options2).client_id,
|
|
@@ -3399,7 +3362,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3399
3362
|
};
|
|
3400
3363
|
return await __privateGet(this, _GetTokenFromBroker).call(this, refreshFlowParameters);
|
|
3401
3364
|
} else {
|
|
3402
|
-
__privateMethod(this,
|
|
3365
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`));
|
|
3403
3366
|
return false;
|
|
3404
3367
|
}
|
|
3405
3368
|
});
|
|
@@ -3409,18 +3372,18 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3409
3372
|
// clear session storage
|
|
3410
3373
|
// clear all state from $store
|
|
3411
3374
|
__privateAdd(this, _Logout, async () => {
|
|
3412
|
-
__privateMethod(this,
|
|
3375
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Logout");
|
|
3413
3376
|
const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/logout`;
|
|
3414
|
-
__privateMethod(this,
|
|
3377
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, url);
|
|
3415
3378
|
const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3416
3379
|
if (sessionData) {
|
|
3417
3380
|
const currentSessionData = sessionData.tokenResponse;
|
|
3418
3381
|
const refresh_token = currentSessionData.refresh_token;
|
|
3419
|
-
__privateMethod(this,
|
|
3382
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, refresh_token);
|
|
3420
3383
|
const decodedRefreshToken = jwtDecode(refresh_token);
|
|
3421
|
-
__privateMethod(this,
|
|
3384
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, decodedRefreshToken);
|
|
3422
3385
|
const sessionId = decodedRefreshToken.sts_session;
|
|
3423
|
-
__privateMethod(this,
|
|
3386
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, sessionId);
|
|
3424
3387
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3425
3388
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3426
3389
|
try {
|
|
@@ -3434,7 +3397,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3434
3397
|
// Ensure cookies are passed to the service
|
|
3435
3398
|
timeout: __privateGet(this, _options2).timeout
|
|
3436
3399
|
};
|
|
3437
|
-
__privateMethod(this,
|
|
3400
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$1.magenta(`#Logout: request config: [${rConfig}]`));
|
|
3438
3401
|
if (isNode) {
|
|
3439
3402
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
3440
3403
|
}
|
|
@@ -3442,27 +3405,27 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3442
3405
|
if (retVal.data.status === StatusCodes.OK) {
|
|
3443
3406
|
return true;
|
|
3444
3407
|
} else {
|
|
3445
|
-
__privateMethod(this,
|
|
3446
|
-
__privateMethod(this,
|
|
3408
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red("Error during logout (1: server side)"));
|
|
3409
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(JSON.stringify(retVal.data)));
|
|
3447
3410
|
return false;
|
|
3448
3411
|
}
|
|
3449
3412
|
} catch (error) {
|
|
3450
|
-
__privateMethod(this,
|
|
3451
|
-
__privateMethod(this,
|
|
3452
|
-
__privateMethod(this,
|
|
3413
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red("Error during logout (2: server side)"));
|
|
3414
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(error));
|
|
3415
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogErrorMessage_fn2).call(this, chalk$1.red(JSON.stringify(error)));
|
|
3453
3416
|
return false;
|
|
3454
3417
|
}
|
|
3455
3418
|
} else {
|
|
3456
|
-
__privateMethod(this,
|
|
3419
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogInfoMessage_fn2).call(this, "Error during logout. Could not restore session from session storage.");
|
|
3457
3420
|
return false;
|
|
3458
3421
|
}
|
|
3459
3422
|
});
|
|
3460
3423
|
__privateSet(this, _options2, options);
|
|
3461
3424
|
__privateSet(this, _logger, logger);
|
|
3462
|
-
__privateMethod(this,
|
|
3425
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, `STSOAuth2Worker:constructor:#options: [${JSON.stringify(__privateGet(this, _options2))}]`);
|
|
3463
3426
|
__privateSet(this, _clientSessionStore, new stsvueutils.ClientStorageFactory({ clientStorageType: stsvueutils.ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage());
|
|
3464
3427
|
__privateSet(this, _oauthWorkerPort, workerPort);
|
|
3465
|
-
__privateMethod(this,
|
|
3428
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, `STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(__privateGet(this, _oauthWorkerPort))}]`);
|
|
3466
3429
|
if (isNode && __privateGet(this, _options2).agentOptions) {
|
|
3467
3430
|
__privateSet(this, _httpsAgent, new https.Agent({
|
|
3468
3431
|
keepAlive: __privateGet(this, _options2).agentOptions.keepAlive,
|
|
@@ -3488,15 +3451,16 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3488
3451
|
_options2 = new WeakMap();
|
|
3489
3452
|
_httpsAgent = new WeakMap();
|
|
3490
3453
|
_logger = new WeakMap();
|
|
3491
|
-
|
|
3454
|
+
_STSOAuth2Worker_instances = new WeakSet();
|
|
3455
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3492
3456
|
LogDebugMessage_fn2 = function(message) {
|
|
3493
3457
|
__privateGet(this, _logger).debug(message);
|
|
3494
3458
|
};
|
|
3495
|
-
|
|
3459
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3496
3460
|
LogInfoMessage_fn2 = function(message) {
|
|
3497
3461
|
__privateGet(this, _logger).info(message);
|
|
3498
3462
|
};
|
|
3499
|
-
|
|
3463
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3500
3464
|
LogErrorMessage_fn2 = function(message) {
|
|
3501
3465
|
__privateGet(this, _logger).error(message);
|
|
3502
3466
|
};
|