@nsshunt/stsoauth2plugin 1.0.113 → 1.0.114
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
CHANGED
|
@@ -17,7 +17,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
17
17
|
return __privateGet(obj, member, getter);
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
var _router, _STORAGE_AUTHORIZE_OPTIONS_KEY, _aic, _options2, _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, _options3, _logger,
|
|
20
|
+
var _router, _STORAGE_AUTHORIZE_OPTIONS_KEY, _aic, _options2, _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, _options3, _logger, _agentManager2, _STSOAuth2Worker_instances, LogDebugMessage_fn2, LogInfoMessage_fn2, LogErrorMessage_fn2, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
|
|
21
21
|
import { inject } from "vue";
|
|
22
22
|
import * as wt from "node:worker_threads";
|
|
23
23
|
import { OAuth2ParameterType, Sleep } from "@nsshunt/stsutils";
|
|
@@ -3301,7 +3301,7 @@ var __privateWrapper2 = (obj, member, setter, getter) => ({
|
|
|
3301
3301
|
return __privateGet2(obj, member, getter);
|
|
3302
3302
|
}
|
|
3303
3303
|
});
|
|
3304
|
-
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions;
|
|
3304
|
+
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout, _withCredentials;
|
|
3305
3305
|
var ansiStyles$1 = { exports: {} };
|
|
3306
3306
|
var colorName;
|
|
3307
3307
|
var hasRequiredColorName;
|
|
@@ -5071,6 +5071,86 @@ _agentResetInterval = /* @__PURE__ */ new WeakMap();
|
|
|
5071
5071
|
_requestCount = /* @__PURE__ */ new WeakMap();
|
|
5072
5072
|
_SetupResetInterval = /* @__PURE__ */ new WeakMap();
|
|
5073
5073
|
_GetAgentOptions = /* @__PURE__ */ new WeakMap();
|
|
5074
|
+
class STSAxiosConfig {
|
|
5075
|
+
constructor(url, method, headers, timeout) {
|
|
5076
|
+
__privateAdd2(this, _url);
|
|
5077
|
+
__privateAdd2(this, _method);
|
|
5078
|
+
__privateAdd2(this, _headers);
|
|
5079
|
+
__privateAdd2(this, _data);
|
|
5080
|
+
__privateAdd2(this, _agentManager);
|
|
5081
|
+
__privateAdd2(this, _timeout);
|
|
5082
|
+
__privateAdd2(this, _withCredentials);
|
|
5083
|
+
__privateSet2(this, _url, url);
|
|
5084
|
+
__privateSet2(this, _method, method);
|
|
5085
|
+
if (headers !== void 0) {
|
|
5086
|
+
__privateSet2(this, _headers, headers);
|
|
5087
|
+
}
|
|
5088
|
+
if (timeout !== void 0) {
|
|
5089
|
+
__privateSet2(this, _timeout, timeout);
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5093
|
+
withData(data) {
|
|
5094
|
+
__privateSet2(this, _data, data);
|
|
5095
|
+
return this;
|
|
5096
|
+
}
|
|
5097
|
+
// 'Content-Type': 'application/json'
|
|
5098
|
+
withHeaders(headers) {
|
|
5099
|
+
__privateSet2(this, _headers, headers);
|
|
5100
|
+
return this;
|
|
5101
|
+
}
|
|
5102
|
+
withDefaultHeaders() {
|
|
5103
|
+
__privateSet2(this, _headers, {
|
|
5104
|
+
"Content-Type": "application/json"
|
|
5105
|
+
});
|
|
5106
|
+
return this;
|
|
5107
|
+
}
|
|
5108
|
+
withCredentials() {
|
|
5109
|
+
__privateSet2(this, _withCredentials, true);
|
|
5110
|
+
return this;
|
|
5111
|
+
}
|
|
5112
|
+
withTimeout(timeout) {
|
|
5113
|
+
__privateSet2(this, _timeout, timeout);
|
|
5114
|
+
return this;
|
|
5115
|
+
}
|
|
5116
|
+
withAgentManager(agentManager) {
|
|
5117
|
+
__privateSet2(this, _agentManager, agentManager);
|
|
5118
|
+
return this;
|
|
5119
|
+
}
|
|
5120
|
+
get config() {
|
|
5121
|
+
const retVal = {
|
|
5122
|
+
url: __privateGet2(this, _url),
|
|
5123
|
+
method: __privateGet2(this, _method)
|
|
5124
|
+
};
|
|
5125
|
+
if (__privateGet2(this, _headers)) {
|
|
5126
|
+
retVal.headers = __privateGet2(this, _headers);
|
|
5127
|
+
}
|
|
5128
|
+
if (__privateGet2(this, _agentManager) !== void 0) {
|
|
5129
|
+
if (__privateGet2(this, _agentManager).IsHttps(__privateGet2(this, _url))) {
|
|
5130
|
+
retVal.httpsAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
5131
|
+
} else {
|
|
5132
|
+
retVal.httpAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
5133
|
+
}
|
|
5134
|
+
}
|
|
5135
|
+
if (__privateGet2(this, _data) !== void 0) {
|
|
5136
|
+
retVal.data = __privateGet2(this, _data);
|
|
5137
|
+
}
|
|
5138
|
+
if (__privateGet2(this, _timeout) !== void 0) {
|
|
5139
|
+
retVal.timeout = __privateGet2(this, _timeout);
|
|
5140
|
+
}
|
|
5141
|
+
if (__privateGet2(this, _withCredentials) !== void 0 && __privateGet2(this, _withCredentials) === true) {
|
|
5142
|
+
retVal.withCredentials = true;
|
|
5143
|
+
}
|
|
5144
|
+
return retVal;
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5147
|
+
_url = /* @__PURE__ */ new WeakMap();
|
|
5148
|
+
_method = /* @__PURE__ */ new WeakMap();
|
|
5149
|
+
_headers = /* @__PURE__ */ new WeakMap();
|
|
5150
|
+
_data = /* @__PURE__ */ new WeakMap();
|
|
5151
|
+
_agentManager = /* @__PURE__ */ new WeakMap();
|
|
5152
|
+
_timeout = /* @__PURE__ */ new WeakMap();
|
|
5153
|
+
_withCredentials = /* @__PURE__ */ new WeakMap();
|
|
5074
5154
|
class STSOAuth2Worker {
|
|
5075
5155
|
constructor(workerPort, options, logger) {
|
|
5076
5156
|
__privateAdd(this, _STSOAuth2Worker_instances);
|
|
@@ -5083,7 +5163,7 @@ class STSOAuth2Worker {
|
|
|
5083
5163
|
__privateAdd(this, _oauthWorkerPort);
|
|
5084
5164
|
__privateAdd(this, _options3);
|
|
5085
5165
|
__privateAdd(this, _logger);
|
|
5086
|
-
__privateAdd(this,
|
|
5166
|
+
__privateAdd(this, _agentManager2, null);
|
|
5087
5167
|
// Attempt to restore a previous session using the STSBroker
|
|
5088
5168
|
/*
|
|
5089
5169
|
{ parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
|
|
@@ -5224,28 +5304,17 @@ class STSOAuth2Worker {
|
|
|
5224
5304
|
__privateGet(this, _LogMessage).call(this, "RestoreSession.");
|
|
5225
5305
|
__privateGet(this, _LogMessage).call(this, url);
|
|
5226
5306
|
try {
|
|
5227
|
-
const rConfig = {
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
[OAuth2ParameterType.REDIRECT_URI]: __privateGet(this, _options3).redirect_uri,
|
|
5234
|
-
[OAuth2ParameterType.AUDIENCE]: __privateGet(this, _options3).audience
|
|
5235
|
-
},
|
|
5236
|
-
withCredentials: true,
|
|
5237
|
-
// Ensure cookies are passed to the service
|
|
5238
|
-
timeout: __privateGet(this, _options3).timeout
|
|
5239
|
-
};
|
|
5307
|
+
const rConfig = new STSAxiosConfig(url, "post").withData({
|
|
5308
|
+
[OAuth2ParameterType.CLIENT_ID]: __privateGet(this, _options3).client_id,
|
|
5309
|
+
[OAuth2ParameterType.SCOPE]: __privateGet(this, _options3).scope,
|
|
5310
|
+
[OAuth2ParameterType.REDIRECT_URI]: __privateGet(this, _options3).redirect_uri,
|
|
5311
|
+
[OAuth2ParameterType.AUDIENCE]: __privateGet(this, _options3).audience
|
|
5312
|
+
}).withDefaultHeaders().withCredentials().withTimeout(__privateGet(this, _options3).timeout);
|
|
5240
5313
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
|
|
5241
|
-
if (isNode && __privateGet(this,
|
|
5242
|
-
|
|
5243
|
-
rConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5244
|
-
} else {
|
|
5245
|
-
rConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5246
|
-
}
|
|
5314
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
5315
|
+
rConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
5247
5316
|
}
|
|
5248
|
-
const retVal = await axios(rConfig);
|
|
5317
|
+
const retVal = await axios(rConfig.config);
|
|
5249
5318
|
if (retVal.data.status === StatusCodes.OK) {
|
|
5250
5319
|
restoredSessionData = retVal.data.detail;
|
|
5251
5320
|
if (restoredSessionData) {
|
|
@@ -5370,24 +5439,13 @@ class STSOAuth2Worker {
|
|
|
5370
5439
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
|
|
5371
5440
|
const url = `${__privateGet(this, _options3).brokerendpoint}:${__privateGet(this, _options3).brokerport}${__privateGet(this, _options3).brokerapiroot}/token`;
|
|
5372
5441
|
try {
|
|
5373
|
-
const rConfig =
|
|
5374
|
-
method: "post",
|
|
5375
|
-
url,
|
|
5376
|
-
data: authorizationCodeFlowParameters,
|
|
5377
|
-
withCredentials: true,
|
|
5378
|
-
// Ensure cookies are passed to the service
|
|
5379
|
-
timeout: __privateGet(this, _options3).timeout
|
|
5380
|
-
};
|
|
5442
|
+
const rConfig = new STSAxiosConfig(url, "post").withDefaultHeaders().withData(authorizationCodeFlowParameters).withCredentials().withTimeout(__privateGet(this, _options3).timeout);
|
|
5381
5443
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
|
|
5382
|
-
if (isNode && __privateGet(this,
|
|
5383
|
-
|
|
5384
|
-
rConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5385
|
-
} else {
|
|
5386
|
-
rConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5387
|
-
}
|
|
5444
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
5445
|
+
rConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
5388
5446
|
}
|
|
5389
5447
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: axios API call`));
|
|
5390
|
-
const retVal = await axios(rConfig);
|
|
5448
|
+
const retVal = await axios(rConfig.config);
|
|
5391
5449
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
|
|
5392
5450
|
if (retVal.status === StatusCodes.OK) {
|
|
5393
5451
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: storing tokens`));
|
|
@@ -5497,25 +5555,14 @@ class STSOAuth2Worker {
|
|
|
5497
5555
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
|
|
5498
5556
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
5499
5557
|
try {
|
|
5500
|
-
const rConfig = {
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
},
|
|
5506
|
-
withCredentials: true,
|
|
5507
|
-
// Ensure cookies are passed to the service
|
|
5508
|
-
timeout: __privateGet(this, _options3).timeout
|
|
5509
|
-
};
|
|
5510
|
-
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#Logout: request config: [${rConfig}]`));
|
|
5511
|
-
if (isNode && __privateGet(this, _agentManager)) {
|
|
5512
|
-
if (__privateGet(this, _agentManager).IsHttps(url)) {
|
|
5513
|
-
rConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5514
|
-
} else {
|
|
5515
|
-
rConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5516
|
-
}
|
|
5558
|
+
const rConfig = new STSAxiosConfig(url, "post").withData({
|
|
5559
|
+
sessionId
|
|
5560
|
+
}).withDefaultHeaders().withCredentials().withTimeout(__privateGet(this, _options3).timeout);
|
|
5561
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
5562
|
+
rConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
5517
5563
|
}
|
|
5518
|
-
|
|
5564
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#Logout: request config: [${rConfig}]`));
|
|
5565
|
+
const retVal = await axios(rConfig.config);
|
|
5519
5566
|
if (retVal.data.status === StatusCodes.OK) {
|
|
5520
5567
|
return true;
|
|
5521
5568
|
} else {
|
|
@@ -5541,7 +5588,7 @@ class STSOAuth2Worker {
|
|
|
5541
5588
|
__privateSet(this, _oauthWorkerPort, workerPort);
|
|
5542
5589
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, `STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(__privateGet(this, _oauthWorkerPort))}]`);
|
|
5543
5590
|
if (isNode && __privateGet(this, _options3).agentOptions) {
|
|
5544
|
-
__privateSet(this,
|
|
5591
|
+
__privateSet(this, _agentManager2, new AgentManager({
|
|
5545
5592
|
agentOptions: __privateGet(this, _options3).agentOptions
|
|
5546
5593
|
}));
|
|
5547
5594
|
}
|
|
@@ -5558,7 +5605,7 @@ _STORAGE_SESSION_KEY = new WeakMap();
|
|
|
5558
5605
|
_oauthWorkerPort = new WeakMap();
|
|
5559
5606
|
_options3 = new WeakMap();
|
|
5560
5607
|
_logger = new WeakMap();
|
|
5561
|
-
|
|
5608
|
+
_agentManager2 = new WeakMap();
|
|
5562
5609
|
_STSOAuth2Worker_instances = new WeakSet();
|
|
5563
5610
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5564
5611
|
LogDebugMessage_fn2 = function(message) {
|