@nsshunt/stsoauth2plugin 1.0.163 → 1.0.164
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/index.cjs +14 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +15 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -7
- package/types/stsoauth2manager.d.ts.map +1 -1
- package/types/stsoauth2worker.d.ts.map +1 -1
package/dist/index.cjs
CHANGED
|
@@ -374,9 +374,6 @@ var chalk$1 = createChalk$1();
|
|
|
374
374
|
createChalk$1({ level: stderrColor$1 ? stderrColor$1.level : 0 });
|
|
375
375
|
//#endregion
|
|
376
376
|
//#region src/stsoauth2types.ts
|
|
377
|
-
var import_browser = /* @__PURE__ */ __toESM$1((/* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
378
|
-
module.exports = false;
|
|
379
|
-
})))(), 1);
|
|
380
377
|
var AuthorizeOptionsResponseType = /* @__PURE__ */ function(AuthorizeOptionsResponseType) {
|
|
381
378
|
AuthorizeOptionsResponseType["CODE"] = "code";
|
|
382
379
|
AuthorizeOptionsResponseType["ID_TOKEN"] = "id_token";
|
|
@@ -3119,11 +3116,11 @@ var STSOAuth2Manager = class {
|
|
|
3119
3116
|
#semaphoreRetrySleep = 50;
|
|
3120
3117
|
constructor(app, options) {
|
|
3121
3118
|
this.#options = options;
|
|
3122
|
-
if (!
|
|
3119
|
+
if (!_nsshunt_stsutils.isNode) {
|
|
3123
3120
|
if (app.config.globalProperties.$sts[STSInstrumentControllerPluginKey]) this.#aic = app.config.globalProperties.$sts[STSInstrumentControllerPluginKey];
|
|
3124
3121
|
this.#router = app.config.globalProperties.$router;
|
|
3125
3122
|
}
|
|
3126
|
-
if (
|
|
3123
|
+
if (_nsshunt_stsutils.isNode) this.#transactionStore = new _nsshunt_stsvueutils.ClientStorageFactory({
|
|
3127
3124
|
clientStorageType: _nsshunt_stsvueutils.ClientStorageType.MEMORY_STORAGE,
|
|
3128
3125
|
usePrefix: false
|
|
3129
3126
|
}).GetStorage();
|
|
@@ -3133,7 +3130,7 @@ var STSOAuth2Manager = class {
|
|
|
3133
3130
|
}).GetStorage();
|
|
3134
3131
|
if (this.#options.workerFactory) this.#worker = this.#options.workerFactory();
|
|
3135
3132
|
else throw new Error(`STSOAuth2Manager:constructor: Cannot init STSOAuth2Manager - this.#options.workerFactory not specified`);
|
|
3136
|
-
if (!
|
|
3133
|
+
if (!_nsshunt_stsutils.isNode) {
|
|
3137
3134
|
this.#worker.onmessage = (data) => {
|
|
3138
3135
|
this.#LogInfoMessage(chalk$1.green(`this.#worker.onmessage = [${data}]`));
|
|
3139
3136
|
};
|
|
@@ -3142,7 +3139,7 @@ var STSOAuth2Manager = class {
|
|
|
3142
3139
|
};
|
|
3143
3140
|
}
|
|
3144
3141
|
let workerMessage;
|
|
3145
|
-
if (
|
|
3142
|
+
if (_nsshunt_stsutils.isNode) {
|
|
3146
3143
|
const { port1: oauth2ManagerPort, port2: oauth2WorkerPort } = new node_worker_threads.MessageChannel();
|
|
3147
3144
|
this.#oauth2ManagerPort = oauth2ManagerPort;
|
|
3148
3145
|
workerMessage = {
|
|
@@ -3228,7 +3225,7 @@ var STSOAuth2Manager = class {
|
|
|
3228
3225
|
return STSOauth2Store(this.#options.pinia);
|
|
3229
3226
|
};
|
|
3230
3227
|
#HandleErrorEvent = (error) => {
|
|
3231
|
-
if (
|
|
3228
|
+
if (_nsshunt_stsutils.isNode) {} else {
|
|
3232
3229
|
this.#GetStore().UpdateError({ message: error });
|
|
3233
3230
|
setTimeout(() => {
|
|
3234
3231
|
this.#router.replace(`${this.#options.uriBase}error`);
|
|
@@ -3236,7 +3233,7 @@ var STSOAuth2Manager = class {
|
|
|
3236
3233
|
}
|
|
3237
3234
|
};
|
|
3238
3235
|
#HandleAuthenticateEvent = (id_token) => {
|
|
3239
|
-
if (
|
|
3236
|
+
if (_nsshunt_stsutils.isNode) {} else {
|
|
3240
3237
|
if (this.#options.authenticateEvent) this.#options.authenticateEvent(id_token);
|
|
3241
3238
|
this.#GetStore().UpdateIdToken(id_token);
|
|
3242
3239
|
}
|
|
@@ -3357,7 +3354,7 @@ var STSOAuth2Manager = class {
|
|
|
3357
3354
|
const response = await this.#PostMessage({ command: IOauth2ListenerCommand.AUTHORIZE });
|
|
3358
3355
|
this.#transactionStore.set(this.#STORAGE_AUTHORIZE_OPTIONS_KEY, response.payload.authorizeOptions);
|
|
3359
3356
|
const url = response.payload.url;
|
|
3360
|
-
if (!
|
|
3357
|
+
if (!_nsshunt_stsutils.isNode) window.location.replace(url);
|
|
3361
3358
|
else return response.payload.authorizeOptionsClientCopy;
|
|
3362
3359
|
} catch (error) {
|
|
3363
3360
|
this.#LogErrorMessage(chalk$1.red(`Authorize Error: ${error}`));
|
|
@@ -4321,7 +4318,7 @@ var STSOAuth2Worker = class {
|
|
|
4321
4318
|
}).GetStorage();
|
|
4322
4319
|
this.#oauthWorkerPort = workerPort;
|
|
4323
4320
|
this.#LogDebugMessage(`STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(this.#oauthWorkerPort)}]`);
|
|
4324
|
-
if (
|
|
4321
|
+
if (_nsshunt_stsutils.isNode && this.#options.agentOptions) this.#agentManager = (0, _nsshunt_stsutils.createAgentManager)({
|
|
4325
4322
|
agentOptions: this.#options.agentOptions,
|
|
4326
4323
|
httpAgentFactory(options) {
|
|
4327
4324
|
return new node_http.default.Agent(options);
|
|
@@ -4369,7 +4366,7 @@ var STSOAuth2Worker = class {
|
|
|
4369
4366
|
else return null;
|
|
4370
4367
|
};
|
|
4371
4368
|
#GetCookies = () => {
|
|
4372
|
-
if (
|
|
4369
|
+
if (_nsshunt_stsutils.isNode) {
|
|
4373
4370
|
const sessionData = this.#clientSessionStore.get(this.#STORAGE_SESSION_KEY);
|
|
4374
4371
|
if (sessionData) return sessionData.brokerCookie;
|
|
4375
4372
|
else return null;
|
|
@@ -4444,13 +4441,13 @@ var STSOAuth2Worker = class {
|
|
|
4444
4441
|
[_nsshunt_stsutils.OAuth2ParameterType.AUDIENCE]: this.#options.audience
|
|
4445
4442
|
}).withDefaultHeaders().withCredentials().withTimeout(this.#options.timeout);
|
|
4446
4443
|
this.#LogDebugMessage(chalk$1.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
|
|
4447
|
-
if (
|
|
4444
|
+
if (_nsshunt_stsutils.isNode && this.#agentManager) rConfig.withAgentManager(this.#agentManager);
|
|
4448
4445
|
const retVal = await (0, axios.default)(rConfig.config);
|
|
4449
4446
|
if (retVal.data.status === StatusCodes.OK) {
|
|
4450
4447
|
restoredSessionData = retVal.data.detail;
|
|
4451
4448
|
if (restoredSessionData) {
|
|
4452
4449
|
const newSessionData = { tokenResponse: restoredSessionData };
|
|
4453
|
-
if (
|
|
4450
|
+
if (_nsshunt_stsutils.isNode) newSessionData.brokerCookie = retVal.headers["set-cookie"];
|
|
4454
4451
|
this.#clientSessionStore.set(this.#STORAGE_SESSION_KEY, newSessionData);
|
|
4455
4452
|
this.#LogInfoMessage("Session restored from server side cookie.");
|
|
4456
4453
|
} else {
|
|
@@ -4545,7 +4542,7 @@ var STSOAuth2Worker = class {
|
|
|
4545
4542
|
try {
|
|
4546
4543
|
const rConfig = new _nsshunt_stsutils.STSAxiosConfig(url, "post").withDefaultHeaders().withData(authorizationCodeFlowParameters).withCredentials().withTimeout(this.#options.timeout);
|
|
4547
4544
|
this.#LogDebugMessage(chalk$1.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
|
|
4548
|
-
if (
|
|
4545
|
+
if (_nsshunt_stsutils.isNode && this.#agentManager) rConfig.withAgentManager(this.#agentManager);
|
|
4549
4546
|
this.#LogDebugMessage(chalk$1.magenta(`#GetTokenFromBroker: axios API call`));
|
|
4550
4547
|
const retVal = await (0, axios.default)(rConfig.config);
|
|
4551
4548
|
this.#LogDebugMessage(chalk$1.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
|
|
@@ -4554,7 +4551,7 @@ var STSOAuth2Worker = class {
|
|
|
4554
4551
|
const tokenResponse = retVal.data;
|
|
4555
4552
|
this.#HandleAuthenticateEvent(tokenResponse.id_token);
|
|
4556
4553
|
const newSessionData = { tokenResponse };
|
|
4557
|
-
if (
|
|
4554
|
+
if (_nsshunt_stsutils.isNode) newSessionData.brokerCookie = retVal.headers["set-cookie"];
|
|
4558
4555
|
this.#clientSessionStore.set(this.#STORAGE_SESSION_KEY, newSessionData);
|
|
4559
4556
|
return true;
|
|
4560
4557
|
} else if (retVal.status === StatusCodes.UNAUTHORIZED) {
|
|
@@ -4622,7 +4619,7 @@ var STSOAuth2Worker = class {
|
|
|
4622
4619
|
this.#HandleAuthenticateEvent(null);
|
|
4623
4620
|
try {
|
|
4624
4621
|
const rConfig = new _nsshunt_stsutils.STSAxiosConfig(url, "post").withData({ sessionId }).withDefaultHeaders().withCredentials().withTimeout(this.#options.timeout);
|
|
4625
|
-
if (
|
|
4622
|
+
if (_nsshunt_stsutils.isNode && this.#agentManager) rConfig.withAgentManager(this.#agentManager);
|
|
4626
4623
|
this.#LogDebugMessage(chalk$1.magenta(`#Logout: request config: [${rConfig}]`));
|
|
4627
4624
|
const retVal = await (0, axios.default)(rConfig.config);
|
|
4628
4625
|
if (retVal.data.status === StatusCodes.OK) return true;
|