@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.
|
@@ -21,7 +21,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
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,
|
|
24
|
+
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;
|
|
25
25
|
function _interopNamespaceDefault(e) {
|
|
26
26
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
27
27
|
if (e) {
|
|
@@ -3314,7 +3314,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3314
3314
|
return __privateGet2(obj, member, getter);
|
|
3315
3315
|
}
|
|
3316
3316
|
});
|
|
3317
|
-
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions;
|
|
3317
|
+
var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions, _url, _method, _headers, _data, _agentManager, _timeout, _withCredentials;
|
|
3318
3318
|
var ansiStyles$1 = { exports: {} };
|
|
3319
3319
|
var colorName;
|
|
3320
3320
|
var hasRequiredColorName;
|
|
@@ -5084,6 +5084,105 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
5084
5084
|
_requestCount = /* @__PURE__ */ new WeakMap();
|
|
5085
5085
|
_SetupResetInterval = /* @__PURE__ */ new WeakMap();
|
|
5086
5086
|
_GetAgentOptions = /* @__PURE__ */ new WeakMap();
|
|
5087
|
+
class STSAxiosConfig {
|
|
5088
|
+
constructor(url, method, headers, timeout) {
|
|
5089
|
+
__privateAdd2(this, _url);
|
|
5090
|
+
__privateAdd2(this, _method);
|
|
5091
|
+
__privateAdd2(this, _headers);
|
|
5092
|
+
__privateAdd2(this, _data);
|
|
5093
|
+
__privateAdd2(this, _agentManager);
|
|
5094
|
+
__privateAdd2(this, _timeout);
|
|
5095
|
+
__privateAdd2(this, _withCredentials);
|
|
5096
|
+
__privateSet2(this, _url, url);
|
|
5097
|
+
__privateSet2(this, _method, method);
|
|
5098
|
+
if (headers !== void 0) {
|
|
5099
|
+
__privateSet2(this, _headers, headers);
|
|
5100
|
+
}
|
|
5101
|
+
if (timeout !== void 0) {
|
|
5102
|
+
__privateSet2(this, _timeout, timeout);
|
|
5103
|
+
}
|
|
5104
|
+
}
|
|
5105
|
+
withCookies(cookies) {
|
|
5106
|
+
if (!__privateGet2(this, _headers)) {
|
|
5107
|
+
__privateSet2(this, _headers, {});
|
|
5108
|
+
}
|
|
5109
|
+
__privateGet2(this, _headers)["Cookie"] = cookies.join("; ");
|
|
5110
|
+
return this;
|
|
5111
|
+
}
|
|
5112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5113
|
+
withData(data) {
|
|
5114
|
+
__privateSet2(this, _data, data);
|
|
5115
|
+
return this;
|
|
5116
|
+
}
|
|
5117
|
+
// 'Content-Type': 'application/json'
|
|
5118
|
+
withAuthHeaders(accesssToken, stsUserId) {
|
|
5119
|
+
if (!__privateGet2(this, _headers)) {
|
|
5120
|
+
__privateSet2(this, _headers, {});
|
|
5121
|
+
}
|
|
5122
|
+
__privateGet2(this, _headers)["Content-Type"] = "application/json";
|
|
5123
|
+
__privateGet2(this, _headers)["Authorization"] = "Bearer " + accesssToken;
|
|
5124
|
+
if (stsUserId) {
|
|
5125
|
+
__privateGet2(this, _headers)["x-sts_user_id"] = stsUserId;
|
|
5126
|
+
}
|
|
5127
|
+
return this;
|
|
5128
|
+
}
|
|
5129
|
+
withHeaders(headers) {
|
|
5130
|
+
__privateSet2(this, _headers, headers);
|
|
5131
|
+
return this;
|
|
5132
|
+
}
|
|
5133
|
+
withDefaultHeaders() {
|
|
5134
|
+
if (!__privateGet2(this, _headers)) {
|
|
5135
|
+
__privateSet2(this, _headers, {});
|
|
5136
|
+
}
|
|
5137
|
+
__privateGet2(this, _headers)["Content-Type"] = "application/json";
|
|
5138
|
+
return this;
|
|
5139
|
+
}
|
|
5140
|
+
withCredentials() {
|
|
5141
|
+
__privateSet2(this, _withCredentials, true);
|
|
5142
|
+
return this;
|
|
5143
|
+
}
|
|
5144
|
+
withTimeout(timeout) {
|
|
5145
|
+
__privateSet2(this, _timeout, timeout);
|
|
5146
|
+
return this;
|
|
5147
|
+
}
|
|
5148
|
+
withAgentManager(agentManager) {
|
|
5149
|
+
__privateSet2(this, _agentManager, agentManager);
|
|
5150
|
+
return this;
|
|
5151
|
+
}
|
|
5152
|
+
get config() {
|
|
5153
|
+
const retVal = {
|
|
5154
|
+
url: __privateGet2(this, _url),
|
|
5155
|
+
method: __privateGet2(this, _method)
|
|
5156
|
+
};
|
|
5157
|
+
if (__privateGet2(this, _headers)) {
|
|
5158
|
+
retVal.headers = __privateGet2(this, _headers);
|
|
5159
|
+
}
|
|
5160
|
+
if (__privateGet2(this, _agentManager) !== void 0) {
|
|
5161
|
+
if (__privateGet2(this, _agentManager).IsHttps(__privateGet2(this, _url))) {
|
|
5162
|
+
retVal.httpsAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
5163
|
+
} else {
|
|
5164
|
+
retVal.httpAgent = __privateGet2(this, _agentManager).GetAgent(__privateGet2(this, _url));
|
|
5165
|
+
}
|
|
5166
|
+
}
|
|
5167
|
+
if (__privateGet2(this, _data) !== void 0) {
|
|
5168
|
+
retVal.data = __privateGet2(this, _data);
|
|
5169
|
+
}
|
|
5170
|
+
if (__privateGet2(this, _timeout) !== void 0) {
|
|
5171
|
+
retVal.timeout = __privateGet2(this, _timeout);
|
|
5172
|
+
}
|
|
5173
|
+
if (__privateGet2(this, _withCredentials) !== void 0 && __privateGet2(this, _withCredentials) === true) {
|
|
5174
|
+
retVal.withCredentials = true;
|
|
5175
|
+
}
|
|
5176
|
+
return retVal;
|
|
5177
|
+
}
|
|
5178
|
+
}
|
|
5179
|
+
_url = /* @__PURE__ */ new WeakMap();
|
|
5180
|
+
_method = /* @__PURE__ */ new WeakMap();
|
|
5181
|
+
_headers = /* @__PURE__ */ new WeakMap();
|
|
5182
|
+
_data = /* @__PURE__ */ new WeakMap();
|
|
5183
|
+
_agentManager = /* @__PURE__ */ new WeakMap();
|
|
5184
|
+
_timeout = /* @__PURE__ */ new WeakMap();
|
|
5185
|
+
_withCredentials = /* @__PURE__ */ new WeakMap();
|
|
5087
5186
|
class STSOAuth2Worker {
|
|
5088
5187
|
constructor(workerPort, options, logger) {
|
|
5089
5188
|
__privateAdd(this, _STSOAuth2Worker_instances);
|
|
@@ -5096,7 +5195,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
5096
5195
|
__privateAdd(this, _oauthWorkerPort);
|
|
5097
5196
|
__privateAdd(this, _options3);
|
|
5098
5197
|
__privateAdd(this, _logger);
|
|
5099
|
-
__privateAdd(this,
|
|
5198
|
+
__privateAdd(this, _agentManager2, null);
|
|
5100
5199
|
// Attempt to restore a previous session using the STSBroker
|
|
5101
5200
|
/*
|
|
5102
5201
|
{ parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
|
|
@@ -5237,28 +5336,17 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
5237
5336
|
__privateGet(this, _LogMessage).call(this, "RestoreSession.");
|
|
5238
5337
|
__privateGet(this, _LogMessage).call(this, url);
|
|
5239
5338
|
try {
|
|
5240
|
-
const rConfig = {
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
[stsutils.OAuth2ParameterType.REDIRECT_URI]: __privateGet(this, _options3).redirect_uri,
|
|
5247
|
-
[stsutils.OAuth2ParameterType.AUDIENCE]: __privateGet(this, _options3).audience
|
|
5248
|
-
},
|
|
5249
|
-
withCredentials: true,
|
|
5250
|
-
// Ensure cookies are passed to the service
|
|
5251
|
-
timeout: __privateGet(this, _options3).timeout
|
|
5252
|
-
};
|
|
5339
|
+
const rConfig = new STSAxiosConfig(url, "post").withData({
|
|
5340
|
+
[stsutils.OAuth2ParameterType.CLIENT_ID]: __privateGet(this, _options3).client_id,
|
|
5341
|
+
[stsutils.OAuth2ParameterType.SCOPE]: __privateGet(this, _options3).scope,
|
|
5342
|
+
[stsutils.OAuth2ParameterType.REDIRECT_URI]: __privateGet(this, _options3).redirect_uri,
|
|
5343
|
+
[stsutils.OAuth2ParameterType.AUDIENCE]: __privateGet(this, _options3).audience
|
|
5344
|
+
}).withDefaultHeaders().withCredentials().withTimeout(__privateGet(this, _options3).timeout);
|
|
5253
5345
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
|
|
5254
|
-
if (isNode && __privateGet(this,
|
|
5255
|
-
|
|
5256
|
-
rConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5257
|
-
} else {
|
|
5258
|
-
rConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5259
|
-
}
|
|
5346
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
5347
|
+
rConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
5260
5348
|
}
|
|
5261
|
-
const retVal = await axios(rConfig);
|
|
5349
|
+
const retVal = await axios(rConfig.config);
|
|
5262
5350
|
if (retVal.data.status === StatusCodes.OK) {
|
|
5263
5351
|
restoredSessionData = retVal.data.detail;
|
|
5264
5352
|
if (restoredSessionData) {
|
|
@@ -5383,24 +5471,13 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
5383
5471
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
|
|
5384
5472
|
const url = `${__privateGet(this, _options3).brokerendpoint}:${__privateGet(this, _options3).brokerport}${__privateGet(this, _options3).brokerapiroot}/token`;
|
|
5385
5473
|
try {
|
|
5386
|
-
const rConfig =
|
|
5387
|
-
method: "post",
|
|
5388
|
-
url,
|
|
5389
|
-
data: authorizationCodeFlowParameters,
|
|
5390
|
-
withCredentials: true,
|
|
5391
|
-
// Ensure cookies are passed to the service
|
|
5392
|
-
timeout: __privateGet(this, _options3).timeout
|
|
5393
|
-
};
|
|
5474
|
+
const rConfig = new STSAxiosConfig(url, "post").withDefaultHeaders().withData(authorizationCodeFlowParameters).withCredentials().withTimeout(__privateGet(this, _options3).timeout);
|
|
5394
5475
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
|
|
5395
|
-
if (isNode && __privateGet(this,
|
|
5396
|
-
|
|
5397
|
-
rConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5398
|
-
} else {
|
|
5399
|
-
rConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5400
|
-
}
|
|
5476
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
5477
|
+
rConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
5401
5478
|
}
|
|
5402
5479
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: axios API call`));
|
|
5403
|
-
const retVal = await axios(rConfig);
|
|
5480
|
+
const retVal = await axios(rConfig.config);
|
|
5404
5481
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
|
|
5405
5482
|
if (retVal.status === StatusCodes.OK) {
|
|
5406
5483
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#GetTokenFromBroker: storing tokens`));
|
|
@@ -5510,25 +5587,14 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
5510
5587
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY));
|
|
5511
5588
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
5512
5589
|
try {
|
|
5513
|
-
const rConfig = {
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
},
|
|
5519
|
-
withCredentials: true,
|
|
5520
|
-
// Ensure cookies are passed to the service
|
|
5521
|
-
timeout: __privateGet(this, _options3).timeout
|
|
5522
|
-
};
|
|
5523
|
-
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#Logout: request config: [${rConfig}]`));
|
|
5524
|
-
if (isNode && __privateGet(this, _agentManager)) {
|
|
5525
|
-
if (__privateGet(this, _agentManager).IsHttps(url)) {
|
|
5526
|
-
rConfig.httpsAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5527
|
-
} else {
|
|
5528
|
-
rConfig.httpAgent = __privateGet(this, _agentManager).GetAgent(url);
|
|
5529
|
-
}
|
|
5590
|
+
const rConfig = new STSAxiosConfig(url, "post").withData({
|
|
5591
|
+
sessionId
|
|
5592
|
+
}).withDefaultHeaders().withCredentials().withTimeout(__privateGet(this, _options3).timeout);
|
|
5593
|
+
if (isNode && __privateGet(this, _agentManager2)) {
|
|
5594
|
+
rConfig.withAgentManager(__privateGet(this, _agentManager2));
|
|
5530
5595
|
}
|
|
5531
|
-
|
|
5596
|
+
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, chalk$2.magenta(`#Logout: request config: [${rConfig}]`));
|
|
5597
|
+
const retVal = await axios(rConfig.config);
|
|
5532
5598
|
if (retVal.data.status === StatusCodes.OK) {
|
|
5533
5599
|
return true;
|
|
5534
5600
|
} else {
|
|
@@ -5554,7 +5620,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
5554
5620
|
__privateSet(this, _oauthWorkerPort, workerPort);
|
|
5555
5621
|
__privateMethod(this, _STSOAuth2Worker_instances, LogDebugMessage_fn2).call(this, `STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(__privateGet(this, _oauthWorkerPort))}]`);
|
|
5556
5622
|
if (isNode && __privateGet(this, _options3).agentOptions) {
|
|
5557
|
-
__privateSet(this,
|
|
5623
|
+
__privateSet(this, _agentManager2, new AgentManager({
|
|
5558
5624
|
agentOptions: __privateGet(this, _options3).agentOptions
|
|
5559
5625
|
}));
|
|
5560
5626
|
}
|
|
@@ -5571,7 +5637,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
5571
5637
|
_oauthWorkerPort = new WeakMap();
|
|
5572
5638
|
_options3 = new WeakMap();
|
|
5573
5639
|
_logger = new WeakMap();
|
|
5574
|
-
|
|
5640
|
+
_agentManager2 = new WeakMap();
|
|
5575
5641
|
_STSOAuth2Worker_instances = new WeakSet();
|
|
5576
5642
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5577
5643
|
LogDebugMessage_fn2 = function(message) {
|