@nsshunt/stsappframework 3.1.216 → 3.1.218
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.js +0 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/index.ts +0 -2
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +1 -1
- package/dist/authutilsnode.js +0 -310
- package/dist/authutilsnode.js.map +0 -1
- package/dist/testHelpers.js +0 -283
- package/dist/testHelpers.js.map +0 -1
- package/src/authutilsnode.ts +0 -360
- package/src/socketIoServerHelper.ts_bak +0 -165
- package/src/testHelpers.ts +0 -327
- package/types/authutilsnode.d.ts +0 -27
- package/types/authutilsnode.d.ts.map +0 -1
- package/types/testHelpers.d.ts +0 -23
- package/types/testHelpers.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -15,13 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./commonTypes"), exports);
|
|
18
|
-
__exportStar(require("./authutilsnode"), exports);
|
|
19
18
|
__exportStar(require("./stsrouterbase"), exports);
|
|
20
19
|
__exportStar(require("./stscontrollerbase"), exports);
|
|
21
20
|
__exportStar(require("./singleprocessbase"), exports);
|
|
22
21
|
__exportStar(require("./masterprocessbase"), exports);
|
|
23
22
|
__exportStar(require("./workerprocessbase"), exports);
|
|
24
|
-
//export * from './socketIoServerHelper'
|
|
25
23
|
__exportStar(require("./stslatencycontroller"), exports);
|
|
26
24
|
__exportStar(require("./stslatencyroute"), exports);
|
|
27
25
|
__exportStar(require("./kafka/kafkamanager"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,kDAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,kDAA+B;AAC/B,sDAAmC;AACnC,sDAAmC;AACnC,sDAAmC;AACnC,sDAAmC;AACnC,yDAAsC;AACtC,oDAAiC;AACjC,uDAAoC;AACpC,wDAAqC;AACrC,wDAAqC;AACrC,8EAA2D;AAC3D,wDAAqC;AACrC,8DAA2C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nsshunt/stsappframework",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.218",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"@babel/preset-env": "^7.25.8",
|
|
29
29
|
"@babel/preset-typescript": "^7.25.7",
|
|
30
30
|
"@eslint/eslintrc": "^3.1.0",
|
|
31
|
-
"@eslint/js": "^9.
|
|
31
|
+
"@eslint/js": "^9.13.0",
|
|
32
|
+
"@nsshunt/stsdevtools": "^1.0.33",
|
|
32
33
|
"@tsconfig/node20": "^20.1.4",
|
|
33
34
|
"@types/cookie-parser": "^1.4.7",
|
|
34
35
|
"@types/debug": "^4.1.12",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"@types/uuid": "^10.0.0",
|
|
40
41
|
"@typescript-eslint/eslint-plugin": "^8.10.0",
|
|
41
42
|
"@typescript-eslint/parser": "^8.10.0",
|
|
42
|
-
"eslint": "^9.
|
|
43
|
+
"eslint": "^9.13.0",
|
|
43
44
|
"globals": "^15.11.0",
|
|
44
45
|
"jest": "^29.7.0",
|
|
45
46
|
"testcontainers": "^10.13.1",
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"@grpc/grpc-js": "^1.12.2",
|
|
52
53
|
"@grpc/proto-loader": "^0.7.13",
|
|
53
54
|
"@influxdata/influxdb-client": "^1.35.0",
|
|
55
|
+
"@nsshunt/stsauthclient": "^1.0.7",
|
|
54
56
|
"@nsshunt/stsconfig": "^1.25.149",
|
|
55
57
|
"@nsshunt/stsdatamanagement": "^1.18.78",
|
|
56
58
|
"@nsshunt/stsmessaging": "^1.0.9",
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
export * from './commonTypes'
|
|
2
|
-
export * from './authutilsnode'
|
|
3
2
|
export * from './stsrouterbase'
|
|
4
3
|
export * from './stscontrollerbase'
|
|
5
4
|
export * from './singleprocessbase'
|
|
6
5
|
export * from './masterprocessbase'
|
|
7
6
|
export * from './workerprocessbase'
|
|
8
|
-
//export * from './socketIoServerHelper'
|
|
9
7
|
export * from './stslatencycontroller'
|
|
10
8
|
export * from './stslatencyroute'
|
|
11
9
|
export * from './kafka/kafkamanager'
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,6CAA6C,CAAA;AAC3D,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA"}
|
package/dist/authutilsnode.js
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AuthUtilsNode = void 0;
|
|
7
|
-
const tough_cookie_1 = __importDefault(require("tough-cookie"));
|
|
8
|
-
const https_1 = __importDefault(require("https"));
|
|
9
|
-
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
10
|
-
const jwt_decode_1 = require("jwt-decode");
|
|
11
|
-
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
|
12
|
-
const axios_1 = __importDefault(require("axios"));
|
|
13
|
-
const stsconfig_1 = require("@nsshunt/stsconfig");
|
|
14
|
-
const stsutils_1 = require("@nsshunt/stsutils");
|
|
15
|
-
const errors_1 = require("./validation/errors");
|
|
16
|
-
const http_status_codes_1 = require("http-status-codes");
|
|
17
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
-
const stsobservability_1 = require("@nsshunt/stsobservability");
|
|
19
|
-
const commonTypes_1 = require("./commonTypes");
|
|
20
|
-
class AuthUtilsNode {
|
|
21
|
-
#cache = {};
|
|
22
|
-
#cacheTimeout = 1000;
|
|
23
|
-
#logger;
|
|
24
|
-
#cookiejar;
|
|
25
|
-
#httpsAgent = null;
|
|
26
|
-
// Regular expression to match the origin
|
|
27
|
-
#originRegex = /^(api:\/\/\w+)/;
|
|
28
|
-
constructor(logger) {
|
|
29
|
-
this.#logger = logger;
|
|
30
|
-
this.#cookiejar = new tough_cookie_1.default.CookieJar();
|
|
31
|
-
}
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
-
#LogDebugMessage(message) {
|
|
34
|
-
this.#logger.debug(message);
|
|
35
|
-
}
|
|
36
|
-
#GetHttpsAgent = () => {
|
|
37
|
-
if (this.#httpsAgent === null) {
|
|
38
|
-
// https://nodejs.org/api/http.html#class-httpagent
|
|
39
|
-
this.#httpsAgent = new https_1.default.Agent({
|
|
40
|
-
keepAlive: stsconfig_1.goptions.keepAlive,
|
|
41
|
-
maxSockets: stsconfig_1.goptions.maxSockets,
|
|
42
|
-
maxTotalSockets: stsconfig_1.goptions.maxTotalSockets,
|
|
43
|
-
maxFreeSockets: stsconfig_1.goptions.maxFreeSockets,
|
|
44
|
-
timeout: stsconfig_1.goptions.timeout,
|
|
45
|
-
rejectUnauthorized: false
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return this.#httpsAgent;
|
|
49
|
-
};
|
|
50
|
-
ResetAgent = () => {
|
|
51
|
-
this.#httpsAgent = null;
|
|
52
|
-
};
|
|
53
|
-
VerifyRequestMiddlewareFactory = (options) => {
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
return async (req, res, next) => {
|
|
56
|
-
if (options.permissions) {
|
|
57
|
-
const permissionsKey = options.permissions.join('_');
|
|
58
|
-
const scopeKey = req.auth.scope.split(' ').join('_');
|
|
59
|
-
if (this.#cache[permissionsKey] && this.#cache[permissionsKey].scopes[scopeKey]) {
|
|
60
|
-
next();
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const scopes = req.auth.scope.split(' ');
|
|
64
|
-
const requiredPermissions = [];
|
|
65
|
-
for (let i = 0; i < options.permissions.length; i++) {
|
|
66
|
-
const permission = options.permissions[i];
|
|
67
|
-
if (!scopes.includes(permission)) {
|
|
68
|
-
requiredPermissions.push(permission);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (requiredPermissions.length > 0) {
|
|
72
|
-
const errorPayload = (0, stsutils_1.GetErrorPayload)(errors_1.AppFrameworkErrorCode.APPFRAMEWORK_MISSING_PERMISSION, requiredPermissions);
|
|
73
|
-
res.status(http_status_codes_1.StatusCodes.UNAUTHORIZED).send({ status: http_status_codes_1.StatusCodes.UNAUTHORIZED, error: errorPayload });
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (!this.#cache[permissionsKey]) {
|
|
77
|
-
this.#cache[permissionsKey] = {
|
|
78
|
-
scopes: {}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
this.#cache[permissionsKey].scopes[scopeKey] = {
|
|
82
|
-
scope: scopeKey,
|
|
83
|
-
timeout: setTimeout(() => {
|
|
84
|
-
delete this.#cache[permissionsKey].scopes[scopeKey];
|
|
85
|
-
}, this.#cacheTimeout).unref()
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
next();
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
/*
|
|
92
|
-
let cookies = await this.GetCookiesFromJar();
|
|
93
|
-
const valid = this.#ValidateCookies(cookies);
|
|
94
|
-
if (valid) {
|
|
95
|
-
next();
|
|
96
|
-
} else {
|
|
97
|
-
const error = { }; //@@
|
|
98
|
-
const invalidToken = false; //@@
|
|
99
|
-
if (invalidToken)
|
|
100
|
-
{
|
|
101
|
-
res.status(StatusCodes.UNAUTHORIZED).send( { status: StatusCodes.UNAUTHORIZED, error: 'Invalid Token', detail: error } );
|
|
102
|
-
} else{
|
|
103
|
-
res.status(StatusCodes.INTERNAL_SERVER_ERROR).send( { status: StatusCodes.INTERNAL_SERVER_ERROR, error: 'Operation was not successful', detail: error } );
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
*/
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
-
async verifyRequestMiddleware(req, res, next) {
|
|
109
|
-
next();
|
|
110
|
-
/*
|
|
111
|
-
|
|
112
|
-
let cookies = await this.GetCookiesFromJar();
|
|
113
|
-
|
|
114
|
-
const valid = this.#ValidateCookies(cookies);
|
|
115
|
-
|
|
116
|
-
if (valid) {
|
|
117
|
-
next();
|
|
118
|
-
} else {
|
|
119
|
-
const error = { }; //@@
|
|
120
|
-
const invalidToken = false; //@@
|
|
121
|
-
if (invalidToken)
|
|
122
|
-
{
|
|
123
|
-
res.status(StatusCodes.UNAUTHORIZED).send( { status: StatusCodes.UNAUTHORIZED, error: 'Invalid Token', detail: error } );
|
|
124
|
-
} else{
|
|
125
|
-
res.status(StatusCodes.INTERNAL_SERVER_ERROR).send( { status: StatusCodes.INTERNAL_SERVER_ERROR, error: 'Operation was not successful', detail: error } );
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
*/
|
|
129
|
-
}
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
-
SetCookiesToJar = async (headers, endpoint) => {
|
|
132
|
-
if (headers['set-cookie']) {
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
|
-
headers['set-cookie'].map((headerCookie) => {
|
|
135
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
|
-
const cookie = tough_cookie_1.default.Cookie.parse(headerCookie);
|
|
137
|
-
this.#cookiejar.setCookieSync(cookie, endpoint);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
-
const cookie = tough_cookie_1.default.Cookie.parse(headers['set-cookie']);
|
|
143
|
-
this.#cookiejar.setCookieSync(cookie, endpoint);
|
|
144
|
-
}
|
|
145
|
-
return this.#cookiejar.getCookies(endpoint);
|
|
146
|
-
};
|
|
147
|
-
GetCookiesFromJar = async (endpoint) => {
|
|
148
|
-
return this.#cookiejar.getCookies(endpoint);
|
|
149
|
-
};
|
|
150
|
-
ValidateJWT = async (token, audience, endpoint) => {
|
|
151
|
-
const jwksClientUri = (endpoint
|
|
152
|
-
? `${endpoint}${stsconfig_1.goptions.asoauthapiroot}${stsconfig_1.goptions.asjwksjsonpath}`
|
|
153
|
-
: `${stsconfig_1.goptions.asendpoint}:${stsconfig_1.goptions.asport}${stsconfig_1.goptions.asoauthapiroot}${stsconfig_1.goptions.asjwksjsonpath}`);
|
|
154
|
-
const jwks = (0, jwks_rsa_1.default)({
|
|
155
|
-
cache: true, //@@ all config items
|
|
156
|
-
cacheMaxEntries: 5, // Default value
|
|
157
|
-
cacheMaxAge: 600000, // Defaults to 10m
|
|
158
|
-
rateLimit: true,
|
|
159
|
-
jwksRequestsPerMinute: 10, // Default value
|
|
160
|
-
jwksUri: jwksClientUri,
|
|
161
|
-
timeout: 30000, //@@ config
|
|
162
|
-
requestAgent: this.#GetHttpsAgent()
|
|
163
|
-
});
|
|
164
|
-
// Use decode to get the kid
|
|
165
|
-
const decodedRefreshToken = (0, jwt_decode_1.jwtDecode)(token, { header: true });
|
|
166
|
-
const kid = decodedRefreshToken.kid;
|
|
167
|
-
const key = await jwks.getSigningKey(kid);
|
|
168
|
-
const signingKey = key.getPublicKey();
|
|
169
|
-
const verifyOptions = {
|
|
170
|
-
issuer: commonTypes_1.iss,
|
|
171
|
-
//subject: s,
|
|
172
|
-
audience: audience,
|
|
173
|
-
//expiresIn: 600, // 10 minutes
|
|
174
|
-
algorithm: ["RS256"] // RSASSA [ "RS256", "RS384", "RS512" ]
|
|
175
|
-
};
|
|
176
|
-
return jsonwebtoken_1.default.verify(token, signingKey, verifyOptions);
|
|
177
|
-
};
|
|
178
|
-
// Function to extract the origin from a URI
|
|
179
|
-
ExtractOrigin = (uri) => {
|
|
180
|
-
const match = uri.match(this.#originRegex);
|
|
181
|
-
return match ? match[1] : null;
|
|
182
|
-
};
|
|
183
|
-
GetAPITokenFromAuthServerUsingScope = async (options, errorCb) => {
|
|
184
|
-
const { scope, clientId, authClientSecret, endPoint, instrumentController, outputErrorsToConsole } = options;
|
|
185
|
-
let stage = '1';
|
|
186
|
-
const invokeErrorCb = (error) => {
|
|
187
|
-
this.#LogDebugMessage(error);
|
|
188
|
-
if (instrumentController) {
|
|
189
|
-
instrumentController.UpdateInstrument(stsobservability_1.Gauge.AUTHENTICATION_ERROR_COUNT_GAUGE, {
|
|
190
|
-
Inc: 1
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
errorCb(error);
|
|
194
|
-
};
|
|
195
|
-
try {
|
|
196
|
-
stage = '2';
|
|
197
|
-
const scopes = scope.split(' ');
|
|
198
|
-
let origin = null;
|
|
199
|
-
let error = null;
|
|
200
|
-
stage = '3';
|
|
201
|
-
for (let i = 0; i < scopes.length; i++) {
|
|
202
|
-
const s = scopes[i];
|
|
203
|
-
if (!origin) {
|
|
204
|
-
origin = this.ExtractOrigin(s);
|
|
205
|
-
if (!origin) {
|
|
206
|
-
error = new Error(`Scope: [${scope}] not in required format. Must use (space seperated) api://<client id>[/<resource>.<permission>].`);
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
const nextOrigin = this.ExtractOrigin(s);
|
|
212
|
-
if (!nextOrigin) {
|
|
213
|
-
error = new Error(`Scope: [${scope}] not in required format. Must use (space seperated) api://<client id>[/<resource>.<permission>].`);
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
if (origin.localeCompare(nextOrigin) !== 0) {
|
|
218
|
-
error = new Error(`Scope: [${scope}] not all from the same client API. All scopes must come from the same client API.`);
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
stage = '4';
|
|
225
|
-
if (error) {
|
|
226
|
-
invokeErrorCb(error);
|
|
227
|
-
return "";
|
|
228
|
-
}
|
|
229
|
-
stage = '5';
|
|
230
|
-
const headers = { 'Content-Type': 'application/json' };
|
|
231
|
-
const payload = {
|
|
232
|
-
client_id: clientId, // The service calling this method
|
|
233
|
-
client_secret: authClientSecret, // Auth service client secret
|
|
234
|
-
//client_secret: goptions.brokerclientsecret, // Broker service client secret
|
|
235
|
-
scope: scope, // required API
|
|
236
|
-
//@@ remove audience
|
|
237
|
-
//@@ need scope to be the API identifier
|
|
238
|
-
grant_type: "client_credentials"
|
|
239
|
-
};
|
|
240
|
-
stage = '6';
|
|
241
|
-
const url = (endPoint
|
|
242
|
-
? `${endPoint}${stsconfig_1.goptions.asoauthapiroot}/token`
|
|
243
|
-
: `${stsconfig_1.goptions.asendpoint}:${stsconfig_1.goptions.asport}${stsconfig_1.goptions.asoauthapiroot}/token`);
|
|
244
|
-
stage = `6.5: url: [${url}] payload: [${JSON.stringify(payload)}]`;
|
|
245
|
-
const retVal = await (0, axios_1.default)({
|
|
246
|
-
url,
|
|
247
|
-
method: 'post',
|
|
248
|
-
data: payload,
|
|
249
|
-
headers: headers,
|
|
250
|
-
httpsAgent: this.#GetHttpsAgent()
|
|
251
|
-
});
|
|
252
|
-
stage = '7';
|
|
253
|
-
if (retVal.status) {
|
|
254
|
-
if (retVal.status !== 200) {
|
|
255
|
-
// Just provide a warning here
|
|
256
|
-
this.#LogDebugMessage(chalk_1.default.magenta(`Error (AuthUtilsNode:GetAPITokenFromServer): Invalid response from server: [${retVal.status}]`));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
invokeErrorCb(new Error(chalk_1.default.red(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.status)`)));
|
|
261
|
-
return "";
|
|
262
|
-
}
|
|
263
|
-
stage = '8';
|
|
264
|
-
if (retVal.data) {
|
|
265
|
-
stage = '9';
|
|
266
|
-
if (retVal.data.access_token) {
|
|
267
|
-
stage = '10';
|
|
268
|
-
if (instrumentController) {
|
|
269
|
-
stage = '11';
|
|
270
|
-
instrumentController.UpdateInstrument(stsobservability_1.Gauge.AUTHENTICATION_COUNT_GAUGE, {
|
|
271
|
-
Inc: 1
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
stage = '12';
|
|
275
|
-
return retVal.data.access_token;
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
stage = '13';
|
|
279
|
-
invokeErrorCb(new Error(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.data.access_token)`));
|
|
280
|
-
return "";
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
stage = '14';
|
|
285
|
-
invokeErrorCb(new Error(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.data)`));
|
|
286
|
-
return "";
|
|
287
|
-
}
|
|
288
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
289
|
-
}
|
|
290
|
-
catch (error) {
|
|
291
|
-
if (outputErrorsToConsole === true) {
|
|
292
|
-
console.error(error);
|
|
293
|
-
}
|
|
294
|
-
let details = 'None available.';
|
|
295
|
-
if (error.response && error.response.data) {
|
|
296
|
-
try {
|
|
297
|
-
details = JSON.stringify(error.response.data);
|
|
298
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
299
|
-
}
|
|
300
|
-
catch (error) {
|
|
301
|
-
details = `Could not JSON.stringify(error.response.data)`;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
invokeErrorCb(new Error(`Error (AuthUtilsNode:GetAPITokenFromServer:catch): [${error}], Stage: [${stage}], Details: [${details}]`));
|
|
305
|
-
return "";
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
exports.AuthUtilsNode = AuthUtilsNode;
|
|
310
|
-
//# sourceMappingURL=authutilsnode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authutilsnode.js","sourceRoot":"","sources":["../src/authutilsnode.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAiC;AACjC,kDAAyB;AACzB,gEAA+B;AAC/B,2CAAuC;AACvC,wDAAkC;AAElC,kDAA0B;AAE1B,kDAA6C;AAE7C,gDAA2E;AAE3E,gDAA2D;AAE3D,yDAAgD;AAEhD,kDAA0B;AAE1B,gEAA8E;AAE9E,+CAAmC;AAwBnC,MAAa,aAAa;IAEtB,MAAM,GAAiC,EAAG,CAAC;IAC3C,aAAa,GAAW,IAAI,CAAC;IAC7B,OAAO,CAAY;IACnB,UAAU,CAAkB;IAC5B,WAAW,GAAuB,IAAI,CAAC;IACv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