@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.
- package/dist/stsoauth2plugin.mjs +98 -86
- package/dist/stsoauth2plugin.mjs.map +1 -1
- package/dist/stsoauth2plugin.umd.js +98 -86
- package/dist/stsoauth2plugin.umd.js.map +1 -1
- package/package.json +2 -2
- package/types/stsoauth2types.d.ts +2 -0
- package/types/stsoauth2types.d.ts.map +1 -1
- package/types/stsoauth2worker.d.ts.map +1 -1
|
@@ -33,8 +33,12 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
33
33
|
return __privateGet(obj, member, getter);
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
var __privateMethod = (obj, member, method) => {
|
|
37
|
+
__accessCheck(obj, member, "access private method");
|
|
38
|
+
return method;
|
|
39
|
+
};
|
|
36
40
|
|
|
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, _HandleAuthenticateEvent2, _HandleErrorEvent2, _LogMessage, _GetAccessToken, _GetCookies, _UpdateInstrument, _ProcessCommand, _RestoreSession, _Authorize, _HandleRedirect, _GetTokenFromBroker, _GetToken, _RefreshToken, _Logout;
|
|
41
|
+
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;
|
|
38
42
|
function _interopNamespaceDefault(e) {
|
|
39
43
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
40
44
|
if (e) {
|
|
@@ -2542,11 +2546,11 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2542
2546
|
}
|
|
2543
2547
|
*/
|
|
2544
2548
|
});
|
|
2545
|
-
let debug
|
|
2549
|
+
let debug;
|
|
2546
2550
|
if (isNode) {
|
|
2547
|
-
debug
|
|
2551
|
+
debug = Debug(`proc:${process.pid}:stsoauth2manager.ts`);
|
|
2548
2552
|
} else {
|
|
2549
|
-
debug
|
|
2553
|
+
debug = Debug(`proc:0:stsoauth2manager.ts`);
|
|
2550
2554
|
}
|
|
2551
2555
|
class STSOAuth2Manager {
|
|
2552
2556
|
// ms
|
|
@@ -2575,7 +2579,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2575
2579
|
__privateAdd(this, _semaphoreRetrySleep, 50);
|
|
2576
2580
|
__privateAdd(this, _ProcessMessageResponse, (data) => {
|
|
2577
2581
|
const messageResponse = data;
|
|
2578
|
-
debug
|
|
2582
|
+
debug(chalk$1.yellow(`STSOAuth2Manager:#ProcessMessageResponse: message data = [${JSON.stringify(messageResponse)}]`));
|
|
2579
2583
|
if (messageResponse.messageId === -1) {
|
|
2580
2584
|
switch (messageResponse.command) {
|
|
2581
2585
|
case IOauth2ListenerCommand.AUTHENTICATE_EVENT:
|
|
@@ -2612,10 +2616,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2612
2616
|
__privateGet(this, _messageHandlers)[message.messageId] = (response) => {
|
|
2613
2617
|
clearTimeout(timeout);
|
|
2614
2618
|
delete __privateGet(this, _messageHandlers)[message.messageId];
|
|
2615
|
-
debug
|
|
2619
|
+
debug(chalk$1.yellow(`STSOAuth2Manager:#PostMessage: resolve callback response= [${JSON.stringify(response)}]`));
|
|
2616
2620
|
resolve(response);
|
|
2617
2621
|
};
|
|
2618
|
-
debug
|
|
2622
|
+
debug(chalk$1.yellow(`STSOAuth2Manager:#PostMessage: posting message = [${JSON.stringify(message)}]`));
|
|
2619
2623
|
__privateGet(this, _oauth2ManagerPort).postMessage(message);
|
|
2620
2624
|
});
|
|
2621
2625
|
});
|
|
@@ -2623,7 +2627,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2623
2627
|
if (__privateGet(this, _aic)) {
|
|
2624
2628
|
__privateGet(this, _aic).LogEx(message);
|
|
2625
2629
|
}
|
|
2626
|
-
debug
|
|
2630
|
+
debug(message);
|
|
2627
2631
|
});
|
|
2628
2632
|
// UpdateInstrument = (instrumentName: Gauge, telemetry: InstrumentBaseTelemetry): void => {
|
|
2629
2633
|
__privateAdd(this, _HandleUpdateInstrumentEvent, (instrumentName, telemetry) => {
|
|
@@ -2659,10 +2663,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2659
2663
|
}
|
|
2660
2664
|
});
|
|
2661
2665
|
__privateAdd(this, _SetupRoute, (app, router) => {
|
|
2662
|
-
debug
|
|
2666
|
+
debug(chalk$1.gray(`STSOAuth2Manager:#SetupRoute`));
|
|
2663
2667
|
router.beforeEach(async (to, from, next) => {
|
|
2664
2668
|
const oAuth2Manager = app.config.globalProperties.$sts[STSOAuth2ManagerPluginKey];
|
|
2665
|
-
debug
|
|
2669
|
+
debug(chalk$1.gray(`beforeEach: from: [${from.path}], to: [${to.path}]`));
|
|
2666
2670
|
if (__privateGet(this, _GetStore).call(this).LoggedIn === false) {
|
|
2667
2671
|
console.log(`Not logged in`);
|
|
2668
2672
|
if (to.path.localeCompare("/authorize") === 0) {
|
|
@@ -2693,9 +2697,9 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2693
2697
|
}
|
|
2694
2698
|
const str = to.query;
|
|
2695
2699
|
if (str[stsutils.OAuth2ParameterType.CODE] || str[stsutils.OAuth2ParameterType.ERROR]) {
|
|
2696
|
-
debug
|
|
2700
|
+
debug(chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Processing redirect: [${JSON.stringify(str)}]`));
|
|
2697
2701
|
const retVal = await oAuth2Manager.HandleRedirect(str);
|
|
2698
|
-
debug
|
|
2702
|
+
debug(chalk$1.magenta(`STSOAuth2Manager:#SetupRoute:Redirect result: [${retVal}]`));
|
|
2699
2703
|
if (retVal) {
|
|
2700
2704
|
next({
|
|
2701
2705
|
path: "/",
|
|
@@ -2710,11 +2714,11 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2710
2714
|
return;
|
|
2711
2715
|
}
|
|
2712
2716
|
}
|
|
2713
|
-
debug
|
|
2717
|
+
debug(`STSOAuth2Manager:#SetupRoute:Restoring session`);
|
|
2714
2718
|
const sessionRestored = await oAuth2Manager.RestoreSession();
|
|
2715
|
-
debug
|
|
2719
|
+
debug(`STSOAuth2Manager:#SetupRoute:Session restored: [${sessionRestored}]`);
|
|
2716
2720
|
if (sessionRestored !== true) {
|
|
2717
|
-
debug
|
|
2721
|
+
debug(`STSOAuth2Manager:#SetupRoute:Session not restored - need to authorize`);
|
|
2718
2722
|
oAuth2Manager.Authorize();
|
|
2719
2723
|
next();
|
|
2720
2724
|
return;
|
|
@@ -2751,7 +2755,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2751
2755
|
throw new Error(`STSOAuth2Manager:ExecuteRefreshToken:maxSemaphoreRetries: [${__privateGet(this, _maxSemaphoreRetries)}] exceeded.`);
|
|
2752
2756
|
}
|
|
2753
2757
|
await stsutils.Sleep(__privateGet(this, _semaphoreRetrySleep));
|
|
2754
|
-
debug
|
|
2758
|
+
debug(chalk$1.cyan(`STSOAuth2Manager:ExecuteRefreshToken:locked by operationSemaphore, retry count: [${retryCount}]`));
|
|
2755
2759
|
return await this.ExecuteRefreshToken(retryCount + 1);
|
|
2756
2760
|
} else {
|
|
2757
2761
|
__privateSet(this, _operationSemaphore, true);
|
|
@@ -2767,9 +2771,9 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2767
2771
|
});
|
|
2768
2772
|
__publicField(this, "RestoreSession", async () => {
|
|
2769
2773
|
try {
|
|
2770
|
-
debug
|
|
2774
|
+
debug(`STSOAuth2Manager:RestoreSession:postMessage: [${IOauth2ListenerCommand.RESTORE_SESSION}]`);
|
|
2771
2775
|
const response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.RESTORE_SESSION });
|
|
2772
|
-
debug
|
|
2776
|
+
debug(`STSOAuth2Manager:RestoreSession:response: [${JSON.stringify(response.payload)}]`);
|
|
2773
2777
|
return response.payload;
|
|
2774
2778
|
} catch (error) {
|
|
2775
2779
|
console.log(chalk$1.red(`RestoreSession Error: ${error}`));
|
|
@@ -2793,12 +2797,12 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2793
2797
|
});
|
|
2794
2798
|
__publicField(this, "HandleRedirect", async (queryVars) => {
|
|
2795
2799
|
try {
|
|
2796
|
-
debug
|
|
2800
|
+
debug(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect`));
|
|
2797
2801
|
let response = null;
|
|
2798
2802
|
if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
|
|
2799
2803
|
const authorizeOptions = __privateGet(this, _transactionStore).get(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
|
|
2800
2804
|
__privateGet(this, _transactionStore).remove(__privateGet(this, _STORAGE_AUTHORIZE_OPTIONS_KEY));
|
|
2801
|
-
debug
|
|
2805
|
+
debug(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: sending HANDLE_REDIRECT command`));
|
|
2802
2806
|
response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
|
|
2803
2807
|
queryVars,
|
|
2804
2808
|
authorizeOptions
|
|
@@ -2806,7 +2810,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2806
2810
|
} else {
|
|
2807
2811
|
response = await __privateGet(this, _PostMessage).call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
|
|
2808
2812
|
}
|
|
2809
|
-
debug
|
|
2813
|
+
debug(chalk$1.magenta(`STSOAuth2Manager:HandleRedirect: HANDLE_REDIRECT response: [${JSON.stringify(response)}]`));
|
|
2810
2814
|
return response.payload;
|
|
2811
2815
|
} catch (error) {
|
|
2812
2816
|
console.log(chalk$1.red(`HandleRedirect Error: ${error}`));
|
|
@@ -2999,14 +3003,14 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
2999
3003
|
StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
3000
3004
|
StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
3001
3005
|
})(StatusCodes || (StatusCodes = {}));
|
|
3002
|
-
let debug;
|
|
3003
|
-
if (isNode) {
|
|
3004
|
-
debug = Debug(`proc:${process.pid}:stsoauth2worker.ts`);
|
|
3005
|
-
} else {
|
|
3006
|
-
debug = Debug(`proc:0:stsoauth2worker.ts`);
|
|
3007
|
-
}
|
|
3008
3006
|
class STSOAuth2Worker {
|
|
3009
3007
|
constructor(workerPort, options) {
|
|
3008
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3009
|
+
__privateAdd(this, _LogDebugMessage);
|
|
3010
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3011
|
+
__privateAdd(this, _LogInfoMessage);
|
|
3012
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3013
|
+
__privateAdd(this, _LogErrorMessage);
|
|
3010
3014
|
//#storageManager = null;
|
|
3011
3015
|
__privateAdd(this, _clientSessionStore, void 0);
|
|
3012
3016
|
__privateAdd(this, _cUtils2, new CryptoUtils());
|
|
@@ -3105,7 +3109,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3105
3109
|
__publicField(this, "SetupListener", () => {
|
|
3106
3110
|
__privateGet(this, _oauthWorkerPort).onmessage = async (data) => {
|
|
3107
3111
|
const auth2ListenerMessage = data.data;
|
|
3108
|
-
|
|
3112
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, `STSOAuth2Worker:SetupListener:onmessage: [${auth2ListenerMessage.command}]`);
|
|
3109
3113
|
switch (auth2ListenerMessage.command) {
|
|
3110
3114
|
case IOauth2ListenerCommand.RESTORE_SESSION:
|
|
3111
3115
|
__privateGet(this, _ProcessCommand).call(this, auth2ListenerMessage, await __privateGet(this, _RestoreSession).call(this));
|
|
@@ -3133,11 +3137,6 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3133
3137
|
}
|
|
3134
3138
|
};
|
|
3135
3139
|
});
|
|
3136
|
-
/*
|
|
3137
|
-
#GetIDToken = async(): Promise<string> => {
|
|
3138
|
-
return '-- ID Token --';
|
|
3139
|
-
}
|
|
3140
|
-
*/
|
|
3141
3140
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3142
3141
|
__privateAdd(this, _ProcessCommand, async (auth2ListenerMessage, response) => {
|
|
3143
3142
|
const messageResponse = {
|
|
@@ -3152,12 +3151,12 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3152
3151
|
const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3153
3152
|
if (sessionData) {
|
|
3154
3153
|
restoredSessionData = sessionData.tokenResponse;
|
|
3155
|
-
|
|
3154
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Session restored from client storage.");
|
|
3156
3155
|
__privateGet(this, _LogMessage).call(this, "Session restored from client storage.");
|
|
3157
3156
|
} else {
|
|
3158
3157
|
const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/session`;
|
|
3159
|
-
|
|
3160
|
-
|
|
3158
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "RestoreSession");
|
|
3159
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, url);
|
|
3161
3160
|
__privateGet(this, _LogMessage).call(this, "RestoreSession.");
|
|
3162
3161
|
__privateGet(this, _LogMessage).call(this, url);
|
|
3163
3162
|
try {
|
|
@@ -3174,7 +3173,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3174
3173
|
// Ensure cookies are passed to the service
|
|
3175
3174
|
timeout: __privateGet(this, _options2).timeout
|
|
3176
3175
|
};
|
|
3177
|
-
|
|
3176
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#RestoreSession:session request detail: [${JSON.stringify(rConfig)}]`));
|
|
3178
3177
|
if (isNode) {
|
|
3179
3178
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
3180
3179
|
}
|
|
@@ -3189,24 +3188,24 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3189
3188
|
newSessionData.brokerCookie = retVal.headers["set-cookie"];
|
|
3190
3189
|
}
|
|
3191
3190
|
__privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
|
|
3192
|
-
|
|
3191
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Session restored from server side cookie.");
|
|
3193
3192
|
} else {
|
|
3194
|
-
|
|
3195
|
-
|
|
3193
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, `Could not restore previous session. No restoredSessionData available.`);
|
|
3194
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, JSON.stringify(retVal.data));
|
|
3196
3195
|
}
|
|
3197
3196
|
} else {
|
|
3198
|
-
|
|
3199
|
-
|
|
3197
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, "Could not restore previous session:-");
|
|
3198
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, JSON.stringify(retVal.data));
|
|
3200
3199
|
}
|
|
3201
3200
|
} catch (error) {
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3201
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, "Could not restore previous session (error state):-");
|
|
3202
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, error);
|
|
3203
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, JSON.stringify(error));
|
|
3205
3204
|
}
|
|
3206
3205
|
}
|
|
3207
3206
|
if (restoredSessionData !== null) {
|
|
3208
3207
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, restoredSessionData.id_token);
|
|
3209
|
-
|
|
3208
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Refreshing tokens ...");
|
|
3210
3209
|
return await __privateGet(this, _RefreshToken).call(this);
|
|
3211
3210
|
} else {
|
|
3212
3211
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
@@ -3214,7 +3213,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3214
3213
|
}
|
|
3215
3214
|
});
|
|
3216
3215
|
__privateAdd(this, _Authorize, async () => {
|
|
3217
|
-
|
|
3216
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Authorize ...");
|
|
3218
3217
|
const client_id = __privateGet(this, _options2).client_id;
|
|
3219
3218
|
const nonce = __privateGet(this, _cUtils2).CreateRandomString();
|
|
3220
3219
|
const response_type = [AuthorizeOptionsResponseType.CODE];
|
|
@@ -3238,9 +3237,9 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3238
3237
|
};
|
|
3239
3238
|
const authorizeOptionsClientCopy = { ...authorizeOptions };
|
|
3240
3239
|
const url = `${__privateGet(this, _options2).authorizeendpoint}:${__privateGet(this, _options2).authorizeport}${__privateGet(this, _options2).authorizeapiroot}${__privateGet(this, _options2).authorizeapi}?${__privateGet(this, _qParams2).CreateQueryParams(authorizeOptions)}`;
|
|
3241
|
-
|
|
3240
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, url);
|
|
3242
3241
|
authorizeOptions.code_verifier = code_verifier;
|
|
3243
|
-
|
|
3242
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, `Authorize:authorizeOptions: [${JSON.stringify(authorizeOptions)}]`);
|
|
3244
3243
|
return {
|
|
3245
3244
|
url,
|
|
3246
3245
|
authorizeOptions,
|
|
@@ -3251,27 +3250,29 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3251
3250
|
__privateAdd(this, _HandleRedirect, async (payload) => {
|
|
3252
3251
|
const queryVars = payload.queryVars;
|
|
3253
3252
|
const authorizeOptions = payload.authorizeOptions;
|
|
3254
|
-
|
|
3255
|
-
|
|
3253
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#HandleRedirect: HandleRedirect`));
|
|
3254
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#HandleRedirect: HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`));
|
|
3256
3255
|
if (queryVars[stsutils.OAuth2ParameterType.CODE]) {
|
|
3257
3256
|
const response = queryVars;
|
|
3258
|
-
|
|
3257
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, `authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
|
|
3259
3258
|
const redirectState = response.state;
|
|
3260
3259
|
const authorizeOptionsState = authorizeOptions.state;
|
|
3261
3260
|
if (authorizeOptionsState.localeCompare(redirectState) === 0) {
|
|
3262
|
-
|
|
3261
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, chalk$1.green("redirected state (from queryVars) matched previously saved transaction authorizeOptions state"));
|
|
3263
3262
|
return await __privateGet(this, _GetToken).call(this, authorizeOptions, response);
|
|
3264
3263
|
} else {
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3264
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red("redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state"));
|
|
3265
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`authorizeOptionsState: [${authorizeOptionsState}]`));
|
|
3266
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`redirectState: [${redirectState}]`));
|
|
3268
3267
|
__privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
|
|
3269
3268
|
return false;
|
|
3270
3269
|
}
|
|
3271
3270
|
} else if (queryVars[stsutils.OAuth2ParameterType.ERROR]) {
|
|
3271
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`State un-matched (1)`));
|
|
3272
3272
|
__privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
|
|
3273
3273
|
return false;
|
|
3274
3274
|
} else {
|
|
3275
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`State un-matched (2)`));
|
|
3275
3276
|
__privateGet(this, _HandleErrorEvent2).call(this, { message: "State un-matched" });
|
|
3276
3277
|
return false;
|
|
3277
3278
|
}
|
|
@@ -3297,7 +3298,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3297
3298
|
*/
|
|
3298
3299
|
// Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
|
|
3299
3300
|
__privateAdd(this, _GetTokenFromBroker, async (authorizationCodeFlowParameters) => {
|
|
3300
|
-
|
|
3301
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker`));
|
|
3301
3302
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3302
3303
|
const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/token`;
|
|
3303
3304
|
try {
|
|
@@ -3309,15 +3310,15 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3309
3310
|
// Ensure cookies are passed to the service
|
|
3310
3311
|
timeout: __privateGet(this, _options2).timeout
|
|
3311
3312
|
};
|
|
3312
|
-
|
|
3313
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: request config: [${JSON.stringify(rConfig)}]`));
|
|
3313
3314
|
if (isNode) {
|
|
3314
3315
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
3315
3316
|
}
|
|
3316
|
-
|
|
3317
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: axios API call`));
|
|
3317
3318
|
const retVal = await axios(rConfig);
|
|
3318
|
-
|
|
3319
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: axios API call result: [${retVal.status}]`));
|
|
3319
3320
|
if (retVal.status === StatusCodes.OK) {
|
|
3320
|
-
|
|
3321
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: storing tokens`));
|
|
3321
3322
|
const tokenResponse = retVal.data;
|
|
3322
3323
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, tokenResponse.id_token);
|
|
3323
3324
|
const newSessionData = {
|
|
@@ -3329,26 +3330,26 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3329
3330
|
__privateGet(this, _clientSessionStore).set(__privateGet(this, _STORAGE_SESSION_KEY2), newSessionData);
|
|
3330
3331
|
return true;
|
|
3331
3332
|
} else if (retVal.status === StatusCodes.UNAUTHORIZED) {
|
|
3332
|
-
|
|
3333
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens, status: [${retVal.status}]`));
|
|
3333
3334
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3334
3335
|
return false;
|
|
3335
3336
|
} else {
|
|
3336
|
-
|
|
3337
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#GetTokenFromBroker: NOT storing tokens (general error 1), status: [${retVal.status}]`));
|
|
3337
3338
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3338
|
-
|
|
3339
|
-
|
|
3339
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red("Could not obtain access_token from token end-point:-"));
|
|
3340
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(JSON.stringify(retVal.data)));
|
|
3340
3341
|
return false;
|
|
3341
3342
|
}
|
|
3342
3343
|
} catch (error) {
|
|
3343
|
-
|
|
3344
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`#GetTokenFromBroker: NOT storing tokens (general error 2), status: [${error}]`));
|
|
3344
3345
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3345
3346
|
return false;
|
|
3346
3347
|
}
|
|
3347
3348
|
});
|
|
3348
3349
|
// Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
|
|
3349
3350
|
__privateAdd(this, _GetToken, async (authorizeOptions, authorizeResponse) => {
|
|
3350
|
-
|
|
3351
|
-
|
|
3351
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "#GetToken");
|
|
3352
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, authorizeResponse);
|
|
3352
3353
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3353
3354
|
const authorizationCodeFlowParameters = {
|
|
3354
3355
|
client_id: __privateGet(this, _options2).client_id,
|
|
@@ -3386,10 +3387,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3386
3387
|
}
|
|
3387
3388
|
*/
|
|
3388
3389
|
__privateAdd(this, _RefreshToken, async () => {
|
|
3389
|
-
|
|
3390
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:start`));
|
|
3390
3391
|
const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3391
3392
|
if (sessionData) {
|
|
3392
|
-
|
|
3393
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.cyan(`STSOAuth2Worker:#RefreshToken:sessionData: [${JSON.stringify(sessionData)}]`));
|
|
3393
3394
|
const currentSessionData = sessionData.tokenResponse;
|
|
3394
3395
|
const refreshFlowParameters = {
|
|
3395
3396
|
client_id: __privateGet(this, _options2).client_id,
|
|
@@ -3399,7 +3400,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3399
3400
|
};
|
|
3400
3401
|
return await __privateGet(this, _GetTokenFromBroker).call(this, refreshFlowParameters);
|
|
3401
3402
|
} else {
|
|
3402
|
-
|
|
3403
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(`STSOAuth2Worker:#RefreshToken:sessionData not found within clientSessionStore`));
|
|
3403
3404
|
return false;
|
|
3404
3405
|
}
|
|
3405
3406
|
});
|
|
@@ -3409,18 +3410,18 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3409
3410
|
// clear session storage
|
|
3410
3411
|
// clear all state from $store
|
|
3411
3412
|
__privateAdd(this, _Logout, async () => {
|
|
3412
|
-
|
|
3413
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Logout");
|
|
3413
3414
|
const url = `${__privateGet(this, _options2).brokerendpoint}:${__privateGet(this, _options2).brokerport}${__privateGet(this, _options2).brokerapiroot}/logout`;
|
|
3414
|
-
|
|
3415
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, url);
|
|
3415
3416
|
const sessionData = __privateGet(this, _clientSessionStore).get(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3416
3417
|
if (sessionData) {
|
|
3417
3418
|
const currentSessionData = sessionData.tokenResponse;
|
|
3418
3419
|
const refresh_token = currentSessionData.refresh_token;
|
|
3419
|
-
|
|
3420
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, refresh_token);
|
|
3420
3421
|
const decodedRefreshToken = jwtDecode(refresh_token);
|
|
3421
|
-
|
|
3422
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, decodedRefreshToken);
|
|
3422
3423
|
const sessionId = decodedRefreshToken.sts_session;
|
|
3423
|
-
|
|
3424
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, sessionId);
|
|
3424
3425
|
__privateGet(this, _clientSessionStore).remove(__privateGet(this, _STORAGE_SESSION_KEY2));
|
|
3425
3426
|
__privateGet(this, _HandleAuthenticateEvent2).call(this, null);
|
|
3426
3427
|
try {
|
|
@@ -3434,7 +3435,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3434
3435
|
// Ensure cookies are passed to the service
|
|
3435
3436
|
timeout: __privateGet(this, _options2).timeout
|
|
3436
3437
|
};
|
|
3437
|
-
|
|
3438
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, chalk$1.magenta(`#Logout: request config: [${rConfig}]`));
|
|
3438
3439
|
if (isNode) {
|
|
3439
3440
|
rConfig.httpsAgent = __privateGet(this, _httpsAgent);
|
|
3440
3441
|
}
|
|
@@ -3442,27 +3443,26 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3442
3443
|
if (retVal.data.status === StatusCodes.OK) {
|
|
3443
3444
|
return true;
|
|
3444
3445
|
} else {
|
|
3445
|
-
|
|
3446
|
-
|
|
3446
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red("Error during logout (1: server side)"));
|
|
3447
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(JSON.stringify(retVal.data)));
|
|
3447
3448
|
return false;
|
|
3448
3449
|
}
|
|
3449
3450
|
} catch (error) {
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3451
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red("Error during logout (2: server side)"));
|
|
3452
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(error));
|
|
3453
|
+
__privateMethod(this, _LogErrorMessage, LogErrorMessage_fn).call(this, chalk$1.red(JSON.stringify(error)));
|
|
3453
3454
|
return false;
|
|
3454
3455
|
}
|
|
3455
3456
|
} else {
|
|
3456
|
-
|
|
3457
|
+
__privateMethod(this, _LogInfoMessage, LogInfoMessage_fn).call(this, "Error during logout. Could not restore session from session storage.");
|
|
3457
3458
|
return false;
|
|
3458
3459
|
}
|
|
3459
3460
|
});
|
|
3460
|
-
Debug.enable("proc:*");
|
|
3461
3461
|
__privateSet(this, _options2, options);
|
|
3462
|
-
|
|
3462
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, `STSOAuth2Worker:constructor:#options: [${JSON.stringify(__privateGet(this, _options2))}]`);
|
|
3463
3463
|
__privateSet(this, _clientSessionStore, new stsvueutils.ClientStorageFactory({ clientStorageType: stsvueutils.ClientStorageType.MEMORY_STORAGE, usePrefix: false }).GetStorage());
|
|
3464
3464
|
__privateSet(this, _oauthWorkerPort, workerPort);
|
|
3465
|
-
|
|
3465
|
+
__privateMethod(this, _LogDebugMessage, LogDebugMessage_fn).call(this, `STSOAuth2Worker:constructor:#oauthWorkerPort: [${JSON.stringify(__privateGet(this, _oauthWorkerPort))}]`);
|
|
3466
3466
|
if (isNode && __privateGet(this, _options2).agentOptions) {
|
|
3467
3467
|
__privateSet(this, _httpsAgent, new https.Agent({
|
|
3468
3468
|
keepAlive: __privateGet(this, _options2).agentOptions.keepAlive,
|
|
@@ -3487,6 +3487,18 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
3487
3487
|
_oauthWorkerPort = new WeakMap();
|
|
3488
3488
|
_options2 = new WeakMap();
|
|
3489
3489
|
_httpsAgent = new WeakMap();
|
|
3490
|
+
_LogDebugMessage = new WeakSet();
|
|
3491
|
+
LogDebugMessage_fn = function(message) {
|
|
3492
|
+
__privateGet(this, _options2).logger.debug(message);
|
|
3493
|
+
};
|
|
3494
|
+
_LogInfoMessage = new WeakSet();
|
|
3495
|
+
LogInfoMessage_fn = function(message) {
|
|
3496
|
+
__privateGet(this, _options2).logger.info(message);
|
|
3497
|
+
};
|
|
3498
|
+
_LogErrorMessage = new WeakSet();
|
|
3499
|
+
LogErrorMessage_fn = function(message) {
|
|
3500
|
+
__privateGet(this, _options2).logger.error(message);
|
|
3501
|
+
};
|
|
3490
3502
|
_HandleAuthenticateEvent2 = new WeakMap();
|
|
3491
3503
|
_HandleErrorEvent2 = new WeakMap();
|
|
3492
3504
|
_LogMessage = new WeakMap();
|