@nsshunt/stsoauth2plugin 1.0.113 → 1.0.115
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,105 @@ _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
|
+
withCookies(cookies) {
|
|
5093
|
+
if (!__privateGet2(this, _headers)) {
|
|
5094
|
+
__privateSet2(this, _headers, {});
|
|
5095
|
+
}
|
|
5096
|
+
__privateGet2(this, _headers)["Cookie"] = cookies.join("; ");
|
|
5097
|
+
return this;
|
|
5098
|
+
}
|
|
5099
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5100
|
+
withData(data) {
|
|
5101
|
+
__privateSet2(this, _data, data);
|
|
5102
|
+
return this;
|
|
5103
|
+
}
|
|
5104
|
+
// 'Content-Type': 'application/json'
|
|
5105
|
+
withAuthHeaders(accesssToken, stsUserId) {
|
|
5106
|
+
if (!__privateGet2(this, _headers)) {
|
|
5107
|
+
__privateSet2(this, _headers, {});
|
|
5108
|
+
}
|
|
5109
|
+
__privateGet2(this, _headers)["Content-Type"] = "application/json";
|
|
5110
|
+
__privateGet2(this, _headers)["Authorization"] = "Bearer " + accesssToken;
|
|
5111
|
+
if (stsUserId) {
|
|
5112
|
+
__privateGet2(this, _headers)["x-sts_user_id"] = stsUserId;
|
|
5113
|
+
}
|
|
5114
|
+
return this;
|
|
5115
|
+
}
|
|
5116
|
+
withHeaders(headers) {
|
|
5117
|
+
__privateSet2(this, _headers, headers);
|
|
5118
|
+
return this;
|
|
5119
|
+
}
|
|
5120
|
+
withDefaultHeaders() {
|
|
5121
|
+
if (!__privateGet2(this, _headers)) {
|
|
5122
|
+
__privateSet2(this, _headers, {});
|
|
5123
|
+
}
|
|
5124
|
+
__privateGet2(this, _headers)["Content-Type"] = "application/json";
|
|
5125
|
+
return this;
|
|
5126
|
+
}
|
|
5127
|
+
withCredentials() {
|
|
5128
|
+
__privateSet2(this, _withCredentials, true);
|
|
5129
|
+
return this;
|
|
5130
|
+
}
|
|
5131
|
+
withTimeout(timeout) {
|
|
5132
|
+
__privateSet2(this, _timeout, timeout);
|
|
5133
|
+
return this;
|
|
5134
|
+
}
|
|
5135
|
+
withAgentManager(agentManager) {
|
|
5136
|
+
__privateSet2(this, _agentManager, agentManager);
|
|
5137
|
+
return this;
|
|
5138
|
+
}
|
|
5139
|
+
get config() {
|
|
5140
|
+
const retVal = {
|
|
5141
|
+
url: __privateGet2(this, _url),
|
|
5142
|
+
method: __privateGet2(this, _method)
|
|
5143
|
+
};
|
|
5144
|
+
if (__privateGet2(this, _headers)) {
|
|
5145
|
+
retVal.headers = __privateGet2(this, _headers);
|
|
5146
|
+
}
|
|
5147
|
+
if (__privateGet2(this, _agentManager) !== void 0) {
|
|
5148
|
+
if (__privateGet2(this, _agentManager).IsHttps(__privateGet2(this, _url))) {
|
|
5149
|
+
retVal.httpsAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
5150
|
+
} else {
|
|
5151
|
+
retVal.httpAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
5152
|
+
}
|
|
5153
|
+
}
|
|
5154
|
+
if (__privateGet2(this, _data) !== void 0) {
|
|
5155
|
+
retVal.data = __privateGet2(this, _data);
|
|
5156
|
+
}
|
|
5157
|
+
if (__privateGet2(this, _timeout) !== void 0) {
|
|
5158
|
+
retVal.timeout = __privateGet2(this, _timeout);
|
|
5159
|
+
}
|
|
5160
|
+
if (__privateGet2(this, _withCredentials) !== void 0 && __privateGet2(this, _withCredentials) === true) {
|
|
5161
|
+
retVal.withCredentials = true;
|
|
5162
|
+
}
|
|
5163
|
+
return retVal;
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
_url = /* @__PURE__ */ new WeakMap();
|
|
5167
|
+
_method = /* @__PURE__ */ new WeakMap();
|
|
5168
|
+
_headers = /* @__PURE__ */ new WeakMap();
|
|
5169
|
+
_data = /* @__PURE__ */ new WeakMap();
|
|
5170
|
+
_agentManager = /* @__PURE__ */ new WeakMap();
|
|
5171
|
+
_timeout = /* @__PURE__ */ new WeakMap();
|
|
5172
|
+
_withCredentials = /* @__PURE__ */ new WeakMap();
|
|
5074
5173
|
class STSOAuth2Worker {
|
|
5075
5174
|
constructor(workerPort, options, logger) {
|
|
5076
5175
|
__privateAdd(this, _STSOAuth2Worker_instances);
|
|
@@ -5083,7 +5182,7 @@ class STSOAuth2Worker {
|
|
|
5083
5182
|
__privateAdd(this, _oauthWorkerPort);
|
|
5084
5183
|
__privateAdd(this, _options3);
|
|
5085
5184
|
__privateAdd(this, _logger);
|
|
5086
|
-
__privateAdd(this,
|
|
5185
|
+
__privateAdd(this, _agentManager2, null);
|
|
5087
5186
|
// Attempt to restore a previous session using the STSBroker
|
|
5088
5187
|
/*
|
|
5089
5188
|
{ parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
|
|
@@ -5224,28 +5323,17 @@ class STSOAuth2Worker {
|
|
|
5224
5323
|
__privateGet(this, _LogMessage).call(this, "RestoreSession.");
|
|
5225
5324
|
__privateGet(this, _LogMessage).call(this, url);
|
|
5226
5325
|
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
|
-
};
|
|
5326
|
+
const rConfig = new STSAxiosConfig(url, "post").withData({
|
|
5327
|
+
[OAuth2ParameterType.CLIENT_ID]: __privateGet(this, _options3).client_id,
|
|
5328
|
+
[OAuth2ParameterType.SCOPE]: __privateGet(this, _options3).scope,
|
|
5329
|
+
[OAuth2ParameterType.REDIRECT_URI]: __privateGet(this, _options3).redirect_uri,
|
|
5330
|
+
[OAuth2ParameterType.AUDIENCE]: __privateGet(this, _options3).audience
|
|
5331
|
+
}).withDefaultHeaders().withCredentials().withTimeout(__privateGet(this, _options3).timeout);
|
|
5240
5332
|
__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
|
-
}
|
|
5333
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
5334
|
+
rConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
5247
5335
|
}
|
|
5248
|
-
const retVal = await axios(rConfig);
|
|
5336
|
+
const retVal = await axios(rConfig.config);
|
|
5249
5337
|
if (retVal.data.status === StatusCodes.OK) {
|
|
5250
5338
|
restoredSessionData = retVal.data.detail;
|
|
5251
5339
|
if (restoredSessionData) {
|
|
@@ -5370,24 +5458,13 @@ class STSOAuth2Worker {
|
|
|
5370
5458
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
|
|
5371
5459
|
const url = `${__privateGet(this, _options3).brokerendpoint}:${__privateGet(this, _options3).brokerport}${__privateGet(this, _options3).brokerapiroot}/token`;
|
|
5372
5460
|
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
|
-
};
|
|
5461
|
+
const rConfig = new STSAxiosConfig(url, "post").withDefaultHeaders().withData(authorizationCodeFlowParameters).withCredentials().withTimeout(__privateGet(this, _options3).timeout);
|
|
5381
5462
|
__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
|
-
}
|
|
5463
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
5464
|
+
rConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
5388
5465
|
}
|
|
5389
5466
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: axios API call`));
|
|
5390
|
-
const retVal = await axios(rConfig);
|
|
5467
|
+
const retVal = await axios(rConfig.config);
|
|
5391
5468
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
|
|
5392
5469
|
if (retVal.status === StatusCodes.OK) {
|
|
5393
5470
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: storing tokens`));
|
|
@@ -5497,25 +5574,14 @@ class STSOAuth2Worker {
|
|
|
5497
5574
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
|
|
5498
5575
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
5499
5576
|
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
|
-
}
|
|
5577
|
+
const rConfig = new STSAxiosConfig(url, "post").withData({
|
|
5578
|
+
sessionId
|
|
5579
|
+
}).withDefaultHeaders().withCredentials().withTimeout(__privateGet(this, _options3).timeout);
|
|
5580
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
5581
|
+
rConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
5517
5582
|
}
|
|
5518
|
-
|
|
5583
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#Logout: request config: [${rConfig}]`));
|
|
5584
|
+
const retVal = await axios(rConfig.config);
|
|
5519
5585
|
if (retVal.data.status === StatusCodes.OK) {
|
|
5520
5586
|
return true;
|
|
5521
5587
|
} else {
|
|
@@ -5541,7 +5607,7 @@ class STSOAuth2Worker {
|
|
|
5541
5607
|
__privateSet(this, _oauthWorkerPort, workerPort);
|
|
5542
5608
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, `STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(__privateGet(this, _oauthWorkerPort))}]`);
|
|
5543
5609
|
if (isNode && __privateGet(this, _options3).agentOptions) {
|
|
5544
|
-
__privateSet(this,
|
|
5610
|
+
__privateSet(this, _agentManager2, new AgentManager({
|
|
5545
5611
|
agentOptions: __privateGet(this, _options3).agentOptions
|
|
5546
5612
|
}));
|
|
5547
5613
|
}
|
|
@@ -5558,7 +5624,7 @@ _STORAGE_SESSION_KEY = new WeakMap();
|
|
|
5558
5624
|
_oauthWorkerPort = new WeakMap();
|
|
5559
5625
|
_options3 = new WeakMap();
|
|
5560
5626
|
_logger = new WeakMap();
|
|
5561
|
-
|
|
5627
|
+
_agentManager2 = new WeakMap();
|
|
5562
5628
|
_STSOAuth2Worker_instances = new WeakSet();
|
|
5563
5629
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5564
5630
|
LogDebugMessage_fn2 = function(message) {
|