@nsshunt/stsoauth2plugin 1.0.56 → 1.0.58

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.
@@ -30,7 +30,11 @@ var __privateWrapper = (obj, member, setter, getter) => ({
30
30
  return __privateGet(obj, member, getter);
31
31
  }
32
32
  });
33
- var _crypto, _router, _cUtils, _qParams, _STORAGE_AUTHORIZE_OPTIONS_KEY, _STORAGE_SESSION_KEY, _aic, _options, _messages, _oauth2ManagerPort, _messageId, _messageHandlers, _messageTimeout, _worker, _transactionStore, _operationSemaphore, _maxSemaphoreRetries, _semaphoreRetrySleep, _ProcessMessageResponse, _PostMessage, _HandleLogEvent, _HandleUpdateInstrumentEvent, _GetStore, _HandleErrorEvent, _HandleAuthenticateEvent, _SetupRoute, _clientSessionStore, _cUtils2, _qParams2, _STORAGE_SESSION_KEY2, _oauthWorkerPort, _options2, _httpsAgent, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
33
+ var __privateMethod = (obj, member, method) => {
34
+ __accessCheck(obj, member, "access private method");
35
+ return method;
36
+ };
37
+ var _crypto, _router, _cUtils, _qParams, _STORAGE_AUTHORIZE_OPTIONS_KEY, _STORAGE_SESSION_KEY, _aic, _options, _messages, _oauth2ManagerPort, _messageId, _messageHandlers, _messageTimeout, _worker, _transactionStore, _operationSemaphore, _maxSemaphoreRetries, _semaphoreRetrySleep, _ProcessMessageResponse, _PostMessage, _HandleLogEvent, _HandleUpdateInstrumentEvent, _GetStore, _HandleErrorEvent, _HandleAuthenticateEvent, _SetupRoute, _clientSessionStore, _cUtils2, _qParams2, _STORAGE_SESSION_KEY2, _oauthWorkerPort, _options2, _httpsAgent, _LogDebugMessage, LogDebugMessage_fn, _LogInfoMessage, LogInfoMessage_fn, _LogErrorMessage, LogErrorMessage_fn, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
34
38
  import { inject } from "vue";
35
39
  import Debug from "debug";
36
40
  import * as wt from "node:worker_threads";
@@ -2532,11 +2536,11 @@ const STSOauth2Store = defineStore("__sts__STSOauth2Store", {
2532
2536
  }
2533
2537
  */
2534
2538
  });
2535
- let debug$1;
2539
+ let debug;
2536
2540
  if (isNode) {
2537
- debug$1 = Debug(`proc:${process.pid}:stsoauth2manager.ts`);
2541
+ debug = Debug(`proc:${process.pid}:stsoauth2manager.ts`);
2538
2542
  } else {
2539
- debug$1 = Debug(`proc:0:stsoauth2manager.ts`);
2543
+ debug = Debug(`proc:0:stsoauth2manager.ts`);
2540
2544
  }
2541
2545
  class STSOAuth2Manager {
2542
2546
  // ms
@@ -2565,7 +2569,7 @@ class STSOAuth2Manager {
2565
2569
  __privateAdd(this, _semaphoreRetrySleep, 50);
2566
2570
  __privateAdd(this, _ProcessMessageResponse, (data) => {
2567
2571
  const messageResponse = data;
2568
- debug$1(chalk$1.yellow(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`));
2572
+ debug(chalk$1.yellow(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`));
2569
2573
  if (messageResponse.messageId === -1) {
2570
2574
  switch (messageResponse.command) {
2571
2575
  case IOauth2ListenerCommand.AUTHENTICATE_EVENT:
@@ -2602,10 +2606,10 @@ class STSOAuth2Manager {
2602
2606
  __privateGet(this, _messageHandlers)[message.messageId] = (response) => {
2603
2607
  clearTimeout(timeout);
2604
2608
  delete __privateGet(this, _messageHandlers)[message.messageId];
2605
- debug$1(chalk$1.yellow(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`));
2609
+ debug(chalk$1.yellow(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`));
2606
2610
  resolve(response);
2607
2611
  };
2608
- debug$1(chalk$1.yellow(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`));
2612
+ debug(chalk$1.yellow(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`));
2609
2613
  __privateGet(this, _oauth2ManagerPort).postMessage(message);
2610
2614
  });
2611
2615
  });
@@ -2613,7 +2617,7 @@ class STSOAuth2Manager {
2613
2617
  if (__privateGet(this, _aic)) {
2614
2618
  __privateGet(this, _aic).LogEx(message);
2615
2619
  }
2616
- debug$1(message);
2620
+ debug(message);
2617
2621
  });
2618
2622
  // UpdateInstrument = (instrumentName: Gauge, telemetry: InstrumentBaseTelemetry): void => {
2619
2623
  __privateAdd(this, _HandleUpdateInstrumentEvent, (instrumentName, telemetry) => {
@@ -2649,10 +2653,10 @@ class STSOAuth2Manager {
2649
2653
  }
2650
2654
  });
2651
2655
  __privateAdd(this, _SetupRoute, (app, router) => {
2652
- debug$1(chalk$1.gray(`STSOAuth2Manager:#SetupRoute`));
2656
+ debug(chalk$1.gray(`STSOAuth2Manager:#SetupRoute`));
2653
2657
  router.beforeEach(async (to, from, next) => {
2654
2658
  const oAuth2Manager = app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey];
2655
- debug$1(chalk$1.gray(`beforeEach: from: [${from.path}], to: [${to.path}]`));
2659
+ debug(chalk$1.gray(`beforeEach: from: [${from.path}], to: [${to.path}]`));
2656
2660
  if (__privateGet(this, _GetStore).call(this).LoggedIn === false) {
2657
2661
  console.log(`Not logged in`);
2658
2662
  if (to.path.localeCompare("/authorize") === 0) {
@@ -2683,9 +2687,9 @@ class STSOAuth2Manager {
2683
2687
  }
2684
2688
  const str = to.query;
2685
2689
  if (str[OAuth2ParameterType.CODE] || str[OAuth2ParameterType.ERROR]) {
2686
- debug$1(chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
2690
+ debug(chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
2687
2691
  const retVal = await oAuth2Manager.HandleRedirect(str);
2688
- debug$1(chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
2692
+ debug(chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
2689
2693
  if (retVal) {
2690
2694
  next({
2691
2695
  path: "/",
@@ -2700,11 +2704,11 @@ class STSOAuth2Manager {
2700
2704
  return;
2701
2705
  }
2702
2706
  }
2703
- debug$1(`STSOAuth2Manager:#SetupRoute:Restoring session`);
2707
+ debug(`STSOAuth2Manager:#SetupRoute:Restoring session`);
2704
2708
  const sessionRestored = await oAuth2Manager.RestoreSession();
2705
- debug$1(`STSOAuth2Manager:#SetupRoute:Session restored: [${sessionRestored}]`);
2709
+ debug(`STSOAuth2Manager:#SetupRoute:Session restored: [${sessionRestored}]`);
2706
2710
  if (sessionRestored !== true) {
2707
- debug$1(`STSOAuth2Manager:#SetupRoute:Session not restored - need to authorize`);
2711
+ debug(`STSOAuth2Manager:#SetupRoute:Session not restored - need to authorize`);
2708
2712
  oAuth2Manager.Authorize();
2709
2713
  next();
2710
2714
  return;
@@ -2741,7 +2745,7 @@ class STSOAuth2Manager {
2741
2745
  throw new Error(`STSOAuth2Manager:ExecuteRefreshToken:maxSemaphoreRetries: [${__privateGet(this, _maxSemaphoreRetries)}] exceeded.`);
2742
2746
  }
2743
2747
  await Sleep(__privateGet(this, _semaphoreRetrySleep));
2744
- debug$1(chalk$1.cyan(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`));
2748
+ debug(chalk$1.cyan(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`));
2745
2749
  return await this.ExecuteRefreshToken(retryCount + 1);
2746
2750
  } else {
2747
2751
  __privateSet(this, _operationSemaphore, true);
@@ -2757,9 +2761,9 @@ class STSOAuth2Manager {
2757
2761
  });
2758
2762
  __publicField(this, "RestoreSession", async () => {
2759
2763
  try {
2760
- debug$1(`STSOAuth2Manager:RestoreSession:postMessage: [${IOauth2ListenerCommand.RESTORE_SESSION}]`);
2764
+ debug(`STSOAuth2Manager:RestoreSession:postMessage: [${IOauth2ListenerCommand.RESTORE_SESSION}]`);
2761
2765
  const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.RESTORE_SESSION });
2762
- debug$1(`STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
2766
+ debug(`STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
2763
2767
  return response.payload;
2764
2768
  } catch (error) {
2765
2769
  console.log(chalk$1.red(`RestoreSession Error: ${error}`));
@@ -2783,12 +2787,12 @@ class STSOAuth2Manager {
2783
2787
  });
2784
2788
  __publicField(this, "HandleRedirect", async (queryVars) => {
2785
2789
  try {
2786
- debug$1(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect`));
2790
+ debug(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect`));
2787
2791
  let response = null;
2788
2792
  if (queryVars[OAuth2ParameterType.CODE]) {
2789
2793
  const authorizeOptions = __privateGet(this, _transactionStore).get(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
2790
2794
  __privateGet(this, _transactionStore).remove(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
2791
- debug$1(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
2795
+ debug(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
2792
2796
  response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
2793
2797
  queryVars,
2794
2798
  authorizeOptions
@@ -2796,7 +2800,7 @@ class STSOAuth2Manager {
2796
2800
  } else {
2797
2801
  response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
2798
2802
  }
2799
- debug$1(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
2803
+ debug(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
2800
2804
  return response.payload;
2801
2805
  } catch (error) {
2802
2806
  console.log(chalk$1.red(`HandleRedirect Error: ${error}`));
@@ -2989,14 +2993,14 @@ var StatusCodes;
2989
2993
  StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
2990
2994
  StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
2991
2995
  })(StatusCodes || (StatusCodes = {}));
2992
- let debug;
2993
- if (isNode) {
2994
- debug = Debug(`proc:${process.pid}:stsoauth2worker.ts`);
2995
- } else {
2996
- debug = Debug(`proc:0:stsoauth2worker.ts`);
2997
- }
2998
2996
  class STSOAuth2Worker {
2999
2997
  constructor(workerPort, options) {
2998
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2999
+ __privateAdd(this, _LogDebugMessage);
3000
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3001
+ __privateAdd(this, _LogInfoMessage);
3002
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3003
+ __privateAdd(this, _LogErrorMessage);
3000
3004
  //#storageManager = null;
3001
3005
  __privateAdd(this, _clientSessionStore, void 0);
3002
3006
  __privateAdd(this, _cUtils2, new CryptoUtils());
@@ -3095,7 +3099,7 @@ class STSOAuth2Worker {
3095
3099
  __publicField(this, "SetupListener", () => {
3096
3100
  __privateGet(this, _oauthWorkerPort).onmessage = async (data) => {
3097
3101
  const auth2ListenerMessage = data.data;
3098
- debug(`STSOAuth2Worker:SetupListener:onmessage: [${auth2ListenerMessage.command}]`);
3102
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, `STSOAuth2Worker:SetupListener:onmessage: [${auth2ListenerMessage.command}]`);
3099
3103
  switch (auth2ListenerMessage.command) {
3100
3104
  case IOauth2ListenerCommand.RESTORE_SESSION:
3101
3105
  __privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _RestoreSession).call(this));
@@ -3123,11 +3127,6 @@ class STSOAuth2Worker {
3123
3127
  }
3124
3128
  };
3125
3129
  });
3126
- /*
3127
- #GetIDToken = async(): Promise<string> => {
3128
- return '-- ID Token --';
3129
- }
3130
- */
3131
3130
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3132
3131
  __privateAdd(this, _ProcessCommand, async (auth2ListenerMessage, response) => {
3133
3132
  const messageResponse = {
@@ -3142,12 +3141,12 @@ class STSOAuth2Worker {
3142
3141
  const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
3143
3142
  if (sessionData) {
3144
3143
  restoredSessionData = sessionData.tokenResponse;
3145
- console.log("Session restored from client storage.");
3144
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Session restored from client storage.");
3146
3145
  __privateGet(this, _LogMessage).call(this, "Session restored from client storage.");
3147
3146
  } else {
3148
3147
  const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/session`;
3149
- console.log("RestoreSession");
3150
- console.log(url);
3148
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "RestoreSession");
3149
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, url);
3151
3150
  __privateGet(this, _LogMessage).call(this, "RestoreSession.");
3152
3151
  __privateGet(this, _LogMessage).call(this, url);
3153
3152
  try {
@@ -3164,7 +3163,7 @@ class STSOAuth2Worker {
3164
3163
  // Ensure cookies are passed to the service
3165
3164
  timeout: __privateGet(this, _options2).timeout
3166
3165
  };
3167
- debug(chalk$1.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
3166
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
3168
3167
  if (isNode) {
3169
3168
  rConfig.httpsAgent = __privateGet(this, _httpsAgent);
3170
3169
  }
@@ -3179,24 +3178,24 @@ class STSOAuth2Worker {
3179
3178
  newSessionData.brokerCookie = retVal.headers["set-cookie"];
3180
3179
  }
3181
3180
  __privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
3182
- console.log("Session restored from server side cookie.");
3181
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Session restored from server side cookie.");
3183
3182
  } else {
3184
- console.log(`Could not restore previous session. No restoredSessionData available.`);
3185
- console.log(JSON.stringify(retVal.data));
3183
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, `Could not restore previous session. No restoredSessionData available.`);
3184
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, JSON.stringify(retVal.data));
3186
3185
  }
3187
3186
  } else {
3188
- console.log("Could not restore previous session:-");
3189
- console.log(JSON.stringify(retVal.data));
3187
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, "Could not restore previous session:-");
3188
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, JSON.stringify(retVal.data));
3190
3189
  }
3191
3190
  } catch (error) {
3192
- console.log("Could not restore previous session (error state):-");
3193
- console.log(error);
3194
- console.log(JSON.stringify(error));
3191
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, "Could not restore previous session (error state):-");
3192
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, error);
3193
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, JSON.stringify(error));
3195
3194
  }
3196
3195
  }
3197
3196
  if (restoredSessionData !== null) {
3198
3197
  __privateGet(this, _HandleAuthenticateEvent2).call(this, restoredSessionData.id_token);
3199
- console.log("Refreshing tokens ...");
3198
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Refreshing tokens ...");
3200
3199
  return await __privateGet(this, _RefreshToken).call(this);
3201
3200
  } else {
3202
3201
  __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
@@ -3204,7 +3203,7 @@ class STSOAuth2Worker {
3204
3203
  }
3205
3204
  });
3206
3205
  __privateAdd(this, _Authorize, async () => {
3207
- console.log("Authorize ...");
3206
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Authorize ...");
3208
3207
  const client_id = __privateGet(this, _options2).client_id;
3209
3208
  const nonce = __privateGet(this, _cUtils2).CreateRandomString();
3210
3209
  const response_type = [AuthorizeOptionsResponseType.CODE];
@@ -3228,9 +3227,9 @@ class STSOAuth2Worker {
3228
3227
  };
3229
3228
  const authorizeOptionsClientCopy = { ...authorizeOptions };
3230
3229
  const url = `${__privateGet(this, _options2).authorizeendpoint}:${__privateGet(this, _options2).authorizeport}${__privateGet(this, _options2).authorizeapiroot}${__privateGet(this, _options2).authorizeapi}?${__privateGet(this, _qParams2).CreateQueryParams(authorizeOptions)}`;
3231
- console.log(url);
3230
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, url);
3232
3231
  authorizeOptions.code_verifier = code_verifier;
3233
- console.log(`Authorize:authorizeOptions: [${JSON.stringify(authorizeOptions)}]`);
3232
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, `Authorize:authorizeOptions: [${JSON.stringify(authorizeOptions)}]`);
3234
3233
  return {
3235
3234
  url,
3236
3235
  authorizeOptions,
@@ -3241,27 +3240,29 @@ class STSOAuth2Worker {
3241
3240
  __privateAdd(this, _HandleRedirect, async (payload) => {
3242
3241
  const queryVars = payload.queryVars;
3243
3242
  const authorizeOptions = payload.authorizeOptions;
3244
- debug(chalk$1.magenta(`#HandleRedirect: HandleRedirect`));
3245
- debug(chalk$1.magenta(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`));
3243
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#HandleRedirect: HandleRedirect`));
3244
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`));
3246
3245
  if (queryVars[OAuth2ParameterType.CODE]) {
3247
3246
  const response = queryVars;
3248
- console.log(`authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
3247
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, `authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
3249
3248
  const redirectState = response.state;
3250
3249
  const authorizeOptionsState = authorizeOptions.state;
3251
3250
  if (authorizeOptionsState.localeCompare(redirectState) === 0) {
3252
- console.log(chalk$1.green("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"));
3251
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, chalk$1.green("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"));
3253
3252
  return await __privateGet(this, _GetToken).call(this, authorizeOptions, response);
3254
3253
  } else {
3255
- console.log(chalk$1.red("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"));
3256
- console.log(chalk$1.red(`authorizeOptionsState: [${authorizeOptionsState}]`));
3257
- console.log(chalk$1.red(`redirectState: [${redirectState}]`));
3254
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"));
3255
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`authorizeOptionsState: [${authorizeOptionsState}]`));
3256
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`redirectState: [${redirectState}]`));
3258
3257
  __privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
3259
3258
  return false;
3260
3259
  }
3261
3260
  } else if (queryVars[OAuth2ParameterType.ERROR]) {
3261
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`State un-matched (1)`));
3262
3262
  __privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
3263
3263
  return false;
3264
3264
  } else {
3265
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`State un-matched (2)`));
3265
3266
  __privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
3266
3267
  return false;
3267
3268
  }
@@ -3287,7 +3288,7 @@ class STSOAuth2Worker {
3287
3288
  */
3288
3289
  // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
3289
3290
  __privateAdd(this, _GetTokenFromBroker, async (authorizationCodeFlowParameters) => {
3290
- debug(chalk$1.magenta(`#GetTokenFromBroker`));
3291
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker`));
3291
3292
  __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
3292
3293
  const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/token`;
3293
3294
  try {
@@ -3299,15 +3300,15 @@ class STSOAuth2Worker {
3299
3300
  // Ensure cookies are passed to the service
3300
3301
  timeout: __privateGet(this, _options2).timeout
3301
3302
  };
3302
- debug(chalk$1.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
3303
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
3303
3304
  if (isNode) {
3304
3305
  rConfig.httpsAgent = __privateGet(this, _httpsAgent);
3305
3306
  }
3306
- debug(chalk$1.magenta(`#GetTokenFromBroker: axios API call`));
3307
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: axios API call`));
3307
3308
  const retVal = await axios(rConfig);
3308
- debug(chalk$1.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
3309
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
3309
3310
  if (retVal.status === StatusCodes.OK) {
3310
- debug(chalk$1.magenta(`#GetTokenFromBroker: storing tokens`));
3311
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: storing tokens`));
3311
3312
  const tokenResponse = retVal.data;
3312
3313
  __privateGet(this, _HandleAuthenticateEvent2).call(this, tokenResponse.id_token);
3313
3314
  const newSessionData = {
@@ -3319,26 +3320,26 @@ class STSOAuth2Worker {
3319
3320
  __privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
3320
3321
  return true;
3321
3322
  } else if (retVal.status === StatusCodes.UNAUTHORIZED) {
3322
- debug(chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`));
3323
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`));
3323
3324
  __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
3324
3325
  return false;
3325
3326
  } else {
3326
- debug(chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`));
3327
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`));
3327
3328
  __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
3328
- console.log("Could not obtain access_token from token end-point:-");
3329
- console.log(JSON.stringify(retVal.data));
3329
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red("Could not obtain access_token from token end-point:-"));
3330
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(JSON.stringify(retVal.data)));
3330
3331
  return false;
3331
3332
  }
3332
3333
  } catch (error) {
3333
- debug(chalk$1.red(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`));
3334
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`));
3334
3335
  __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
3335
3336
  return false;
3336
3337
  }
3337
3338
  });
3338
3339
  // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
3339
3340
  __privateAdd(this, _GetToken, async (authorizeOptions, authorizeResponse) => {
3340
- console.log("#GetToken");
3341
- console.log(authorizeResponse);
3341
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "#GetToken");
3342
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, authorizeResponse);
3342
3343
  __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
3343
3344
  const authorizationCodeFlowParameters = {
3344
3345
  client_id: __privateGet(this, _options2).client_id,
@@ -3376,10 +3377,10 @@ class STSOAuth2Worker {
3376
3377
  }
3377
3378
  */
3378
3379
  __privateAdd(this, _RefreshToken, async () => {
3379
- debug(chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:start`));
3380
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:start`));
3380
3381
  const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
3381
3382
  if (sessionData) {
3382
- debug(chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(sessionData)}]`));
3383
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(sessionData)}]`));
3383
3384
  const currentSessionData = sessionData.tokenResponse;
3384
3385
  const refreshFlowParameters = {
3385
3386
  client_id: __privateGet(this, _options2).client_id,
@@ -3389,7 +3390,7 @@ class STSOAuth2Worker {
3389
3390
  };
3390
3391
  return await __privateGet(this, _GetTokenFromBroker).call(this, refreshFlowParameters);
3391
3392
  } else {
3392
- debug(chalk$1.red(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`));
3393
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`));
3393
3394
  return false;
3394
3395
  }
3395
3396
  });
@@ -3399,18 +3400,18 @@ class STSOAuth2Worker {
3399
3400
  // clear session storage
3400
3401
  // clear all state from $store
3401
3402
  __privateAdd(this, _Logout, async () => {
3402
- console.log("Logout");
3403
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Logout");
3403
3404
  const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/logout`;
3404
- console.log(url);
3405
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, url);
3405
3406
  const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
3406
3407
  if (sessionData) {
3407
3408
  const currentSessionData = sessionData.tokenResponse;
3408
3409
  const refresh_token = currentSessionData.refresh_token;
3409
- console.log(refresh_token);
3410
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, refresh_token);
3410
3411
  const decodedRefreshToken = jwtDecode(refresh_token);
3411
- console.log(decodedRefreshToken);
3412
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, decodedRefreshToken);
3412
3413
  const sessionId = decodedRefreshToken.sts_session;
3413
- console.log(sessionId);
3414
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, sessionId);
3414
3415
  __privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
3415
3416
  __privateGet(this, _HandleAuthenticateEvent2).call(this, null);
3416
3417
  try {
@@ -3424,7 +3425,7 @@ class STSOAuth2Worker {
3424
3425
  // Ensure cookies are passed to the service
3425
3426
  timeout: __privateGet(this, _options2).timeout
3426
3427
  };
3427
- debug(chalk$1.magenta(`#Logout: request config: [${rConfig}]`));
3428
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#Logout: request config: [${rConfig}]`));
3428
3429
  if (isNode) {
3429
3430
  rConfig.httpsAgent = __privateGet(this, _httpsAgent);
3430
3431
  }
@@ -3432,27 +3433,26 @@ class STSOAuth2Worker {
3432
3433
  if (retVal.data.status === StatusCodes.OK) {
3433
3434
  return true;
3434
3435
  } else {
3435
- console.log("Error during logout (1: server side)");
3436
- console.log(JSON.stringify(retVal.data));
3436
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red("Error during logout (1: server side)"));
3437
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(JSON.stringify(retVal.data)));
3437
3438
  return false;
3438
3439
  }
3439
3440
  } catch (error) {
3440
- console.log("Error during logout (2: server side)");
3441
- console.log(error);
3442
- console.log(JSON.stringify(error));
3441
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red("Error during logout (2: server side)"));
3442
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(error));
3443
+ __privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(JSON.stringify(error)));
3443
3444
  return false;
3444
3445
  }
3445
3446
  } else {
3446
- console.log("Error during logout. Could not restore session from session storage.");
3447
+ __privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Error during logout. Could not restore session from session storage.");
3447
3448
  return false;
3448
3449
  }
3449
3450
  });
3450
- Debug.enable("proc:*");
3451
3451
  __privateSet(this, _options2, options);
3452
- debug(`STSOAuth2Worker:constructor:#options: [${JSON.stringify(__privateGet(this, _options2))}]`);
3452
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, `STSOAuth2Worker:constructor:#options: [${JSON.stringify(__privateGet(this, _options2))}]`);
3453
3453
  __privateSet(this, _clientSessionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage());
3454
3454
  __privateSet(this, _oauthWorkerPort, workerPort);
3455
- debug(`STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(__privateGet(this, _oauthWorkerPort))}]`);
3455
+ __privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, `STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(__privateGet(this, _oauthWorkerPort))}]`);
3456
3456
  if (isNode && __privateGet(this, _options2).agentOptions) {
3457
3457
  __privateSet(this, _httpsAgent, new https.Agent({
3458
3458
  keepAlive: __privateGet(this, _options2).agentOptions.keepAlive,
@@ -3477,6 +3477,18 @@ _STORAGE_SESSION_KEY2 = new WeakMap();
3477
3477
  _oauthWorkerPort = new WeakMap();
3478
3478
  _options2 = new WeakMap();
3479
3479
  _httpsAgent = new WeakMap();
3480
+ _LogDebugMessage = new WeakSet();
3481
+ LogDebugMessage_fn = function(message) {
3482
+ __privateGet(this, _options2).logger.debug(message);
3483
+ };
3484
+ _LogInfoMessage = new WeakSet();
3485
+ LogInfoMessage_fn = function(message) {
3486
+ __privateGet(this, _options2).logger.info(message);
3487
+ };
3488
+ _LogErrorMessage = new WeakSet();
3489
+ LogErrorMessage_fn = function(message) {
3490
+ __privateGet(this, _options2).logger.error(message);
3491
+ };
3480
3492
  _HandleAuthenticateEvent2 = new WeakMap();
3481
3493
  _HandleErrorEvent2 = new WeakMap();
3482
3494
  _LogMessage = new WeakMap();