@nsshunt/stsappframework 3.1.216 → 3.1.217
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/dist/testHelpers.js +2 -2
- package/dist/testHelpers.js.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +0 -2
- package/src/testHelpers.ts +4 -4
- 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/src/authutilsnode.ts +0 -360
- package/src/socketIoServerHelper.ts_bak +0 -165
- package/types/authutilsnode.d.ts +0 -27
- package/types/authutilsnode.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/dist/testHelpers.js
CHANGED
|
@@ -36,14 +36,14 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
36
36
|
const testcontainers_1 = require("testcontainers");
|
|
37
37
|
const stsconfig_1 = require("@nsshunt/stsconfig");
|
|
38
38
|
const stsutils_1 = require("@nsshunt/stsutils");
|
|
39
|
-
const
|
|
39
|
+
const stsauthclient_1 = require("@nsshunt/stsauthclient");
|
|
40
40
|
class TestHelper {
|
|
41
41
|
//#regexBase64URL = /^[A-Za-z0-9_-]+$/ // Base64URL - https://base64.guru/standards/base64url
|
|
42
42
|
#regexURLSafeStringComponent = /[-a-zA-Z0-9@:%._+~#=]{1,256}/; // URL safe string component
|
|
43
43
|
//#regexBase64 = /(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?/ // Base64 - https://stackoverflow.com/questions/475074/regex-to-parse-or-validate-base64-data
|
|
44
44
|
#regexSTSBase64 = /SES_(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?/; // Base64
|
|
45
45
|
#regexJWT = /[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+/; // JWT (Base64URL.Base64URL.Base64URL)
|
|
46
|
-
#authUtilsNode = new
|
|
46
|
+
#authUtilsNode = new stsauthclient_1.AuthUtilsNode(stsutils_1.defaultLogger);
|
|
47
47
|
#databaseContainer;
|
|
48
48
|
#stsAuthContainer;
|
|
49
49
|
#network;
|
package/dist/testHelpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testHelpers.js","sourceRoot":"","sources":["../src/testHelpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAkD,CAAE,UAAU;AAC9D,kDAAyB;AAEzB,oDAAqC;AAErC,kDAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"testHelpers.js","sourceRoot":"","sources":["../src/testHelpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAkD,CAAE,UAAU;AAC9D,kDAAyB;AAEzB,oDAAqC;AAErC,kDAAyB;AACzB,oDAA2B;AAE3B,kDAAyB;AAEzB,mDAAgE;AAEhE,kDAA4D;AAE5D,gDAAwD;AAExD,0DAAsD;AAEtD,MAAa,UAAU;IACnB,8FAA8F;IAC9F,4BAA4B,GAAG,8BAA8B,CAAA,CAAC,4BAA4B;IAC1F,+KAA+K;IAC/K,eAAe,GAAG,oEAAoE,CAAA,CAAC,SAAS;IAChG,SAAS,GAAG,gDAAgD,CAAA,CAAC,sCAAsC;IAEnG,cAAc,GAAG,IAAI,6BAAa,CAAC,wBAAa,CAAC,CAAC;IAElD,kBAAkB,CAAM;IACxB,iBAAiB,CAAM;IACvB,QAAQ,CAAM;IACd,aAAa,GAAG,EAAE,CAAC;IACnB,SAAS,GAAG,EAAE,CAAC;IACf,SAAS,GAAG,EAAE,CAAC;IACf,WAAW,GAAuB,IAAI,CAAC;IAEvC;QACI,IAAI,CAAC,aAAa,GAAG,wBAAwB,CAAC,CAAC,IAAI;IACvD,CAAC;IAED,eAAe,CAAC,OAAY;QACxB,wBAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,cAAc,GAAG,GAAG,EAAE;QAElB,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;YAC5B,mDAAmD;YACnD,IAAI,CAAC,WAAW,GAAG,IAAI,eAAK,CAAC,KAAK,CAAC;gBAC/B,SAAS,EAAE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e,EAAE;gBACb,yDAAyD;gBACzD,uDAAuD;gBACvD,yDAAyD;gBACzD,yDAAyD;aAC5D;SACJ,CAAA;QACD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAC5D,CAAC,CAAA;CAqBJ;AApTD,gCAoTC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nsshunt/stsappframework",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.217",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
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
32
|
"@tsconfig/node20": "^20.1.4",
|
|
33
33
|
"@types/cookie-parser": "^1.4.7",
|
|
34
34
|
"@types/debug": "^4.1.12",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/uuid": "^10.0.0",
|
|
40
40
|
"@typescript-eslint/eslint-plugin": "^8.10.0",
|
|
41
41
|
"@typescript-eslint/parser": "^8.10.0",
|
|
42
|
-
"eslint": "^9.
|
|
42
|
+
"eslint": "^9.13.0",
|
|
43
43
|
"globals": "^15.11.0",
|
|
44
44
|
"jest": "^29.7.0",
|
|
45
45
|
"testcontainers": "^10.13.1",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@grpc/grpc-js": "^1.12.2",
|
|
52
52
|
"@grpc/proto-loader": "^0.7.13",
|
|
53
53
|
"@influxdata/influxdb-client": "^1.35.0",
|
|
54
|
+
"@nsshunt/stsauthclient": "^1.0.7",
|
|
54
55
|
"@nsshunt/stsconfig": "^1.25.149",
|
|
55
56
|
"@nsshunt/stsdatamanagement": "^1.18.78",
|
|
56
57
|
"@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/src/testHelpers.ts
CHANGED
|
@@ -4,17 +4,17 @@ import chalk from 'chalk'
|
|
|
4
4
|
import * as tough from 'tough-cookie'
|
|
5
5
|
|
|
6
6
|
import https from 'https'
|
|
7
|
-
import crypto from 'crypto'
|
|
7
|
+
import crypto from 'crypto'
|
|
8
8
|
|
|
9
|
-
import axios from 'axios'
|
|
9
|
+
import axios from 'axios'
|
|
10
10
|
|
|
11
|
-
import { GenericContainer, Network, Wait } from "testcontainers"
|
|
11
|
+
import { GenericContainer, Network, Wait } from "testcontainers"
|
|
12
12
|
|
|
13
13
|
import { goptions, $ResetOptions } from '@nsshunt/stsconfig'
|
|
14
14
|
|
|
15
15
|
import { Sleep, defaultLogger } from '@nsshunt/stsutils'
|
|
16
16
|
|
|
17
|
-
import { AuthUtilsNode } from '
|
|
17
|
+
import { AuthUtilsNode } from '@nsshunt/stsauthclient'
|
|
18
18
|
|
|
19
19
|
export class TestHelper {
|
|
20
20
|
//#regexBase64URL = /^[A-Za-z0-9_-]+$/ // Base64URL - https://base64.guru/standards/base64url
|
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;IACvC,yCAAyC;IACzC,YAAY,GAAG,gBAAgB,CAAC;IAEhC,YAAY,MAAkB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,sBAAK,CAAC,SAAS,EAAE,CAAC;IAC5C,CAAC;IAED,8DAA8D;IAC9D,gBAAgB,CAAC,OAAY;QACzB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,cAAc,GAAG,GAAG,EAAE;QAClB,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;YAC5B,mDAAmD;YACnD,IAAI,CAAC,WAAW,GAAG,IAAI,eAAK,CAAC,KAAK,CAAC;gBAC/B,SAAS,EAAE,oBAAQ,CAAC,SAAS;gBAC7B,UAAU,EAAE,oBAAQ,CAAC,UAAU;gBAC/B,eAAe,EAAE,oBAAQ,CAAC,eAAe;gBACzC,cAAc,EAAE,oBAAQ,CAAC,cAAc;gBACvC,OAAO,EAAE,oBAAQ,CAAC,OAAO;gBACzB,kBAAkB,EAAE,KAAK;a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EAAE,CAAC;gBACxC,IAAI,CAAC;oBACD,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBAClD,6DAA6D;gBAC7D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACb,OAAO,GAAG,+CAA+C,CAAC;gBAC9D,CAAC;YACL,CAAC;YACD,aAAa,CAAC,IAAI,KAAK,CAAC,uDAAuD,KAAK,cAAc,KAAK,gBAAgB,OAAO,GAAG,CAAC,CAAC,CAAC;YACpI,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC,CAAA;CACJ;AA3TD,sCA2TC"}
|
package/src/authutilsnode.ts
DELETED
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import tough from 'tough-cookie';
|
|
2
|
-
import https from 'https'
|
|
3
|
-
import jwt from 'jsonwebtoken';
|
|
4
|
-
import { jwtDecode } from "jwt-decode";
|
|
5
|
-
import jwksClient from 'jwks-rsa';
|
|
6
|
-
|
|
7
|
-
import axios from 'axios';
|
|
8
|
-
|
|
9
|
-
import { goptions } from '@nsshunt/stsconfig'
|
|
10
|
-
|
|
11
|
-
import { GetErrorPayload, ISTSLogger, JSONObject } from '@nsshunt/stsutils'
|
|
12
|
-
|
|
13
|
-
import { AppFrameworkErrorCode } from './validation/errors'
|
|
14
|
-
|
|
15
|
-
import { StatusCodes } from 'http-status-codes';
|
|
16
|
-
|
|
17
|
-
import chalk from 'chalk';
|
|
18
|
-
|
|
19
|
-
import { Gauge, PublishInstrumentController } from '@nsshunt/stsobservability'
|
|
20
|
-
|
|
21
|
-
import { iss } from './commonTypes'
|
|
22
|
-
|
|
23
|
-
export interface IAuthUtilsNodeOptions {
|
|
24
|
-
permissions: string[]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface IGetAPITokenFromAuthServerUsingScopeOptions {
|
|
28
|
-
clientId: string
|
|
29
|
-
authClientSecret: string
|
|
30
|
-
scope: string
|
|
31
|
-
endPoint: string
|
|
32
|
-
instrumentController?: PublishInstrumentController
|
|
33
|
-
outputErrorsToConsole?: boolean
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
declare interface ICacheScopeRecord {
|
|
37
|
-
scope: string
|
|
38
|
-
timeout: NodeJS.Timeout
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare interface ICacheRecord {
|
|
42
|
-
scopes: Record<string, ICacheScopeRecord>
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class AuthUtilsNode
|
|
46
|
-
{
|
|
47
|
-
#cache: Record<string, ICacheRecord> = { };
|
|
48
|
-
#cacheTimeout: number = 1000;
|
|
49
|
-
#logger: ISTSLogger
|
|
50
|
-
#cookiejar: tough.CookieJar;
|
|
51
|
-
#httpsAgent: https.Agent | null = null;
|
|
52
|
-
// Regular expression to match the origin
|
|
53
|
-
#originRegex = /^(api:\/\/\w+)/;
|
|
54
|
-
|
|
55
|
-
constructor(logger: ISTSLogger) {
|
|
56
|
-
this.#logger = logger;
|
|
57
|
-
this.#cookiejar = new tough.CookieJar();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
-
#LogDebugMessage(message: any) {
|
|
62
|
-
this.#logger.debug(message);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
#GetHttpsAgent = () => {
|
|
66
|
-
if (this.#httpsAgent === null) {
|
|
67
|
-
// https://nodejs.org/api/http.html#class-httpagent
|
|
68
|
-
this.#httpsAgent = new https.Agent({
|
|
69
|
-
keepAlive: goptions.keepAlive,
|
|
70
|
-
maxSockets: goptions.maxSockets,
|
|
71
|
-
maxTotalSockets: goptions.maxTotalSockets,
|
|
72
|
-
maxFreeSockets: goptions.maxFreeSockets,
|
|
73
|
-
timeout: goptions.timeout,
|
|
74
|
-
rejectUnauthorized: false
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return this.#httpsAgent;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
ResetAgent = () => {
|
|
81
|
-
this.#httpsAgent = null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
VerifyRequestMiddlewareFactory = (options: IAuthUtilsNodeOptions) => {
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
return async (req: any, res: any, next: any) => {
|
|
87
|
-
if (options.permissions) {
|
|
88
|
-
|
|
89
|
-
const permissionsKey = options.permissions.join('_');
|
|
90
|
-
const scopeKey = (req.auth.scope as string).split(' ').join('_');
|
|
91
|
-
|
|
92
|
-
if (this.#cache[permissionsKey] && this.#cache[permissionsKey].scopes[scopeKey]) {
|
|
93
|
-
next();
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const scopes = req.auth.scope.split(' ');
|
|
98
|
-
|
|
99
|
-
const requiredPermissions = [ ];
|
|
100
|
-
for (let i=0; i < options.permissions.length; i++) {
|
|
101
|
-
const permission = options.permissions[i];
|
|
102
|
-
if (!scopes.includes(permission)) {
|
|
103
|
-
requiredPermissions.push(permission);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (requiredPermissions.length > 0) {
|
|
107
|
-
const errorPayload = GetErrorPayload(AppFrameworkErrorCode.APPFRAMEWORK_MISSING_PERMISSION, requiredPermissions);
|
|
108
|
-
res.status(StatusCodes.UNAUTHORIZED).send( { status: StatusCodes.UNAUTHORIZED, error: errorPayload });
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!this.#cache[permissionsKey]) {
|
|
113
|
-
this.#cache[permissionsKey] = {
|
|
114
|
-
scopes: { }
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
this.#cache[permissionsKey].scopes[scopeKey] = {
|
|
119
|
-
scope: scopeKey,
|
|
120
|
-
timeout: setTimeout(() => {
|
|
121
|
-
delete this.#cache[permissionsKey].scopes[scopeKey]
|
|
122
|
-
}, this.#cacheTimeout).unref()
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
next();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/*
|
|
129
|
-
let cookies = await this.GetCookiesFromJar();
|
|
130
|
-
const valid = this.#ValidateCookies(cookies);
|
|
131
|
-
if (valid) {
|
|
132
|
-
next();
|
|
133
|
-
} else {
|
|
134
|
-
const error = { }; //@@
|
|
135
|
-
const invalidToken = false; //@@
|
|
136
|
-
if (invalidToken)
|
|
137
|
-
{
|
|
138
|
-
res.status(StatusCodes.UNAUTHORIZED).send( { status: StatusCodes.UNAUTHORIZED, error: 'Invalid Token', detail: error } );
|
|
139
|
-
} else{
|
|
140
|
-
res.status(StatusCodes.INTERNAL_SERVER_ERROR).send( { status: StatusCodes.INTERNAL_SERVER_ERROR, error: 'Operation was not successful', detail: error } );
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
*/
|
|
144
|
-
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
-
async verifyRequestMiddleware(req: any, res: any, next: any)
|
|
147
|
-
{
|
|
148
|
-
next();
|
|
149
|
-
/*
|
|
150
|
-
|
|
151
|
-
let cookies = await this.GetCookiesFromJar();
|
|
152
|
-
|
|
153
|
-
const valid = this.#ValidateCookies(cookies);
|
|
154
|
-
|
|
155
|
-
if (valid) {
|
|
156
|
-
next();
|
|
157
|
-
} else {
|
|
158
|
-
const error = { }; //@@
|
|
159
|
-
const invalidToken = false; //@@
|
|
160
|
-
if (invalidToken)
|
|
161
|
-
{
|
|
162
|
-
res.status(StatusCodes.UNAUTHORIZED).send( { status: StatusCodes.UNAUTHORIZED, error: 'Invalid Token', detail: error } );
|
|
163
|
-
} else{
|
|
164
|
-
res.status(StatusCodes.INTERNAL_SERVER_ERROR).send( { status: StatusCodes.INTERNAL_SERVER_ERROR, error: 'Operation was not successful', detail: error } );
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
*/
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
171
|
-
SetCookiesToJar = async (headers: Record<string, any>, endpoint: string): Promise<tough.Cookie[]> =>
|
|
172
|
-
{
|
|
173
|
-
if (headers['set-cookie']) {
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
|
-
headers['set-cookie'].map((headerCookie: any) => {
|
|
176
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
177
|
-
const cookie: any = tough.Cookie.parse(headerCookie);
|
|
178
|
-
this.#cookiejar.setCookieSync(cookie, endpoint);
|
|
179
|
-
});
|
|
180
|
-
} else {
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
|
-
const cookie: any = tough.Cookie.parse(headers['set-cookie']);
|
|
183
|
-
this.#cookiejar.setCookieSync(cookie, endpoint);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return this.#cookiejar.getCookies(endpoint);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
GetCookiesFromJar = async (endpoint: string): Promise<tough.Cookie[]> =>
|
|
190
|
-
{
|
|
191
|
-
return this.#cookiejar.getCookies(endpoint);
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
ValidateJWT = async (token: string, audience: string, endpoint?: string): Promise<string> => {
|
|
195
|
-
const jwksClientUri = (endpoint
|
|
196
|
-
? `${endpoint}${goptions.asoauthapiroot}${goptions.asjwksjsonpath}`
|
|
197
|
-
: `${goptions.asendpoint}:${goptions.asport}${goptions.asoauthapiroot}${goptions.asjwksjsonpath}`);
|
|
198
|
-
|
|
199
|
-
const jwks = jwksClient({
|
|
200
|
-
cache: true, //@@ all config items
|
|
201
|
-
cacheMaxEntries: 5, // Default value
|
|
202
|
-
cacheMaxAge: 600000, // Defaults to 10m
|
|
203
|
-
rateLimit: true,
|
|
204
|
-
jwksRequestsPerMinute: 10, // Default value
|
|
205
|
-
jwksUri: jwksClientUri,
|
|
206
|
-
timeout: 30000, //@@ config
|
|
207
|
-
requestAgent: this.#GetHttpsAgent()
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// Use decode to get the kid
|
|
211
|
-
const decodedRefreshToken = jwtDecode<JSONObject>(token, { header: true });
|
|
212
|
-
const kid = decodedRefreshToken.kid;
|
|
213
|
-
|
|
214
|
-
const key = await jwks.getSigningKey(kid);
|
|
215
|
-
const signingKey = key.getPublicKey();
|
|
216
|
-
|
|
217
|
-
const verifyOptions = {
|
|
218
|
-
issuer: iss,
|
|
219
|
-
//subject: s,
|
|
220
|
-
audience: audience,
|
|
221
|
-
//expiresIn: 600, // 10 minutes
|
|
222
|
-
algorithm: ["RS256"] // RSASSA [ "RS256", "RS384", "RS512" ]
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
return jwt.verify(token, signingKey, verifyOptions) as string;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Function to extract the origin from a URI
|
|
229
|
-
ExtractOrigin = (uri: string) => {
|
|
230
|
-
const match = uri.match(this.#originRegex);
|
|
231
|
-
return match ? match[1] : null;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
GetAPITokenFromAuthServerUsingScope = async (options: IGetAPITokenFromAuthServerUsingScopeOptions, errorCb: (error: Error) => void): Promise<string> => {
|
|
235
|
-
const { scope, clientId, authClientSecret, endPoint, instrumentController, outputErrorsToConsole } = options;
|
|
236
|
-
|
|
237
|
-
let stage = '1';
|
|
238
|
-
|
|
239
|
-
const invokeErrorCb = (error: Error) => {
|
|
240
|
-
this.#LogDebugMessage(error);
|
|
241
|
-
if (instrumentController) {
|
|
242
|
-
instrumentController.UpdateInstrument(Gauge.AUTHENTICATION_ERROR_COUNT_GAUGE, { // auth error
|
|
243
|
-
Inc: 1
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
errorCb(error);
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
stage = '2';
|
|
251
|
-
const scopes = scope.split(' ');
|
|
252
|
-
let origin: string | null = null;
|
|
253
|
-
let error: Error | null = null;
|
|
254
|
-
stage = '3';
|
|
255
|
-
for (let i=0; i < scopes.length; i++) {
|
|
256
|
-
const s = scopes[i];
|
|
257
|
-
if (!origin) {
|
|
258
|
-
origin = this.ExtractOrigin(s);
|
|
259
|
-
if (!origin) {
|
|
260
|
-
error = new Error(`Scope: [${scope}] not in required format. Must use (space seperated) api://<client id>[/<resource>.<permission>].`);
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
} else {
|
|
264
|
-
const nextOrigin: string | null = this.ExtractOrigin(s);
|
|
265
|
-
if (!nextOrigin) {
|
|
266
|
-
error = new Error(`Scope: [${scope}] not in required format. Must use (space seperated) api://<client id>[/<resource>.<permission>].`);
|
|
267
|
-
break;
|
|
268
|
-
} else {
|
|
269
|
-
if (origin.localeCompare(nextOrigin) !== 0) {
|
|
270
|
-
error = new Error(`Scope: [${scope}] not all from the same client API. All scopes must come from the same client API.`);
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
stage = '4';
|
|
277
|
-
if (error) {
|
|
278
|
-
invokeErrorCb(error);
|
|
279
|
-
return "";
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
stage = '5';
|
|
283
|
-
const headers = { 'Content-Type': 'application/json'};
|
|
284
|
-
const payload = { //@@ make a type
|
|
285
|
-
client_id: clientId, // The service calling this method
|
|
286
|
-
client_secret: authClientSecret, // Auth service client secret
|
|
287
|
-
//client_secret: goptions.brokerclientsecret, // Broker service client secret
|
|
288
|
-
scope: scope, // required API
|
|
289
|
-
//@@ remove audience
|
|
290
|
-
//@@ need scope to be the API identifier
|
|
291
|
-
grant_type: "client_credentials"
|
|
292
|
-
}
|
|
293
|
-
stage = '6';
|
|
294
|
-
const url = (endPoint
|
|
295
|
-
? `${endPoint}${goptions.asoauthapiroot}/token`
|
|
296
|
-
: `${goptions.asendpoint}:${goptions.asport}${goptions.asoauthapiroot}/token`);
|
|
297
|
-
|
|
298
|
-
stage = `6.5: url: [${url}] payload: [${JSON.stringify(payload)}]`
|
|
299
|
-
|
|
300
|
-
const retVal = await axios({
|
|
301
|
-
url
|
|
302
|
-
,method: 'post'
|
|
303
|
-
,data: payload
|
|
304
|
-
,headers: headers
|
|
305
|
-
,httpsAgent: this.#GetHttpsAgent()
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
stage = '7';
|
|
309
|
-
if (retVal.status) {
|
|
310
|
-
if (retVal.status !== 200) {
|
|
311
|
-
// Just provide a warning here
|
|
312
|
-
this.#LogDebugMessage(chalk.magenta(`Error (AuthUtilsNode:GetAPITokenFromServer): Invalid response from server: [${retVal.status}]`));
|
|
313
|
-
}
|
|
314
|
-
} else {
|
|
315
|
-
invokeErrorCb(new Error(chalk.red(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.status)`)));
|
|
316
|
-
return "";
|
|
317
|
-
}
|
|
318
|
-
stage = '8';
|
|
319
|
-
if (retVal.data) {
|
|
320
|
-
stage = '9';
|
|
321
|
-
if (retVal.data.access_token) {
|
|
322
|
-
stage = '10';
|
|
323
|
-
if (instrumentController) {
|
|
324
|
-
stage = '11';
|
|
325
|
-
instrumentController.UpdateInstrument(Gauge.AUTHENTICATION_COUNT_GAUGE, {
|
|
326
|
-
Inc: 1
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
stage = '12';
|
|
331
|
-
return retVal.data.access_token as string;
|
|
332
|
-
} else {
|
|
333
|
-
stage = '13';
|
|
334
|
-
invokeErrorCb(new Error(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.data.access_token)`));
|
|
335
|
-
return "";
|
|
336
|
-
}
|
|
337
|
-
} else {
|
|
338
|
-
stage = '14';
|
|
339
|
-
invokeErrorCb(new Error(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.data)`));
|
|
340
|
-
return "";
|
|
341
|
-
}
|
|
342
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
343
|
-
} catch (error: any) {
|
|
344
|
-
if (outputErrorsToConsole === true) {
|
|
345
|
-
console.error(error);
|
|
346
|
-
}
|
|
347
|
-
let details = 'None available.';
|
|
348
|
-
if (error.response && error.response.data) {
|
|
349
|
-
try {
|
|
350
|
-
details = JSON.stringify(error.response.data);
|
|
351
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
352
|
-
} catch (error) {
|
|
353
|
-
details = `Could not JSON.stringify(error.response.data)`;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
invokeErrorCb(new Error(`Error (AuthUtilsNode:GetAPITokenFromServer:catch): [${error}], Stage: [${stage}], Details: [${details}]`));
|
|
357
|
-
return "";
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/* eslint @typescript-eslint/no-explicit-any: 0, @typescript-eslint/no-unused-vars: 0 */ // --> OFF
|
|
2
|
-
import { JSONObject, ISTSLogger } from '@nsshunt/stsutils'
|
|
3
|
-
|
|
4
|
-
import { Server, Namespace, Socket } from "socket.io";
|
|
5
|
-
|
|
6
|
-
import { STSSocketIONamespace, STSServerSocket, STSNamespace,
|
|
7
|
-
ISocketIoServerHelper, ServerEventCb, InterServerEvents, STSSocketIONamespaces } from './commonTypes'
|
|
8
|
-
|
|
9
|
-
import { STSDefaultClientToServerEvents, STSDefaultServerToClientEvents } from '@nsshunt/stsobservability'
|
|
10
|
-
|
|
11
|
-
export interface ISocketIoServerHelperOptions {
|
|
12
|
-
logger: ISTSLogger
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class SocketIoServerHelper<ClientToServerEvents extends STSDefaultClientToServerEvents, ServerToClientEvents extends STSDefaultServerToClientEvents> implements ISocketIoServerHelper<ClientToServerEvents, ServerToClientEvents>
|
|
16
|
-
{
|
|
17
|
-
#socketIoServerHelperOptions: ISocketIoServerHelperOptions
|
|
18
|
-
#namespace: STSSocketIONamespaces = { };
|
|
19
|
-
|
|
20
|
-
constructor(options: ISocketIoServerHelperOptions) { // IProcessBase
|
|
21
|
-
this.#socketIoServerHelperOptions = options;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
LogMessage(namespace: STSSocketIONamespace, message: any) {
|
|
25
|
-
this.#socketIoServerHelperOptions.logger.debug(`${namespace.namespace}: ${message}`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
LeaveRoom = (namespace: STSSocketIONamespace, socket: Socket<ClientToServerEvents, ServerToClientEvents>, room: string): void => {
|
|
29
|
-
this.LogMessage(namespace, `${namespace.socketionamespace.name}: Leaving room [${room}]`);
|
|
30
|
-
socket.leave(room);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
JoinRoom = (namespace: STSSocketIONamespace, socket: Socket<ClientToServerEvents, ServerToClientEvents>, room: string): void => {
|
|
34
|
-
this.LogMessage(namespace, `${namespace.socketionamespace.name}: Socket joining room [${room}], ID: [${socket.id}]`);
|
|
35
|
-
socket.join(room);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
#SetupStandardEvents = (namespace: STSSocketIONamespace, socket: Socket<STSDefaultClientToServerEvents, STSDefaultServerToClientEvents>): void => {
|
|
39
|
-
socket.on('disconnect', (reason: string) => {
|
|
40
|
-
this.LogMessage(namespace, `${namespace.socketionamespace.name}: socket disconnect, ID: [${socket.id}] [${reason}]`);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
socket.on('disconnecting', (reason: string) => {
|
|
44
|
-
this.LogMessage(namespace, `${namespace.socketionamespace.name}: socket disconnecting, ID: [${socket.id}] [${reason}]`);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
socket.on('error', (error: Error) => {
|
|
48
|
-
this.LogMessage(namespace, `${namespace.socketionamespace.name}: socket error, ID: [${socket.id}] [${error}]`);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
socket.on("__STSdisconnect", (reason: string) => {
|
|
52
|
-
this.LogMessage(namespace, `${namespace.socketionamespace.name}: __STSdisconnect: socket disconnect, ID: [${socket.id}] [${reason}]`);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
socket.on("__STSdisconnecting", (reason, callBackResult) => {
|
|
56
|
-
this.LogMessage(namespace, `${namespace.socketionamespace.name}: __STSdisconnecting: socket disconnecting, ID: [${socket.id}] [${reason}]`);
|
|
57
|
-
callBackResult("__STSdisconnecting accepted by server.");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
socket.on('__STSjoinRoom', (rooms: string[]): void => { //@@ names
|
|
61
|
-
rooms.forEach((room) => {
|
|
62
|
-
this.JoinRoom(namespace, socket, room)
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
socket.on('__STSleaveRoom', (rooms: string[]): void => { //@@ names
|
|
67
|
-
rooms.forEach((room) => {
|
|
68
|
-
this.LeaveRoom(namespace, socket, room);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
socket.on('__STSsendToRoom', (rooms: string[], payload: { command: string, payload: JSONObject }): void => {
|
|
73
|
-
rooms.forEach((room) => {
|
|
74
|
-
this.LogMessage(namespace, `${namespace.socketionamespace.name}:socket.on:sendToRoom: __STSsendToRoom: Sending to room [${room}], ID: [${socket.id}]`);
|
|
75
|
-
|
|
76
|
-
namespace.socketionamespace.to(room).emit(payload.command as any, payload);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Use this middleward to check every incomming connection
|
|
82
|
-
#SetupConnectionMiddleware = (nameSpace: STSSocketIONamespace) => {
|
|
83
|
-
nameSpace.socketionamespace.use((socket, next) => {
|
|
84
|
-
//if (isValid(socket.request)) {
|
|
85
|
-
const a=5; // for lint purposes
|
|
86
|
-
if (a === 5) {
|
|
87
|
-
next();
|
|
88
|
-
} else {
|
|
89
|
-
next(new Error("invalid"));
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Use this middleware to check very packet being received
|
|
95
|
-
#SetupMessageMiddleware = (socket: STSServerSocket) => {
|
|
96
|
-
socket.use(([event, ...args], next) => {
|
|
97
|
-
/*
|
|
98
|
-
if (isUnauthorized(event)) {
|
|
99
|
-
return next(new Error("unauthorized event"));
|
|
100
|
-
}
|
|
101
|
-
*/
|
|
102
|
-
next();
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
SetupNamespace = (io: Server, namespace: STSNamespace, rooms: string[], autoJoinRooms: boolean, /* serverSocketEvents: ServerSocketEvent[], */
|
|
107
|
-
socketConnectCallBack: ((socket: Socket<ClientToServerEvents, ServerToClientEvents, InterServerEvents>) => void) | null,
|
|
108
|
-
socketEventsCallBack: ((socket: Socket<ClientToServerEvents, ServerToClientEvents, InterServerEvents>) => void) | null
|
|
109
|
-
): Namespace<ClientToServerEvents, ServerToClientEvents, InterServerEvents> => {
|
|
110
|
-
// Create STS Command Centre Client namespace
|
|
111
|
-
this.#namespace[namespace] = {
|
|
112
|
-
namespace: namespace,
|
|
113
|
-
pid: process.pid,
|
|
114
|
-
socketionamespace: io.of(`/${namespace}/`)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
this.#SetupConnectionMiddleware(this.#namespace[namespace]);
|
|
118
|
-
|
|
119
|
-
this.#namespace[namespace].socketionamespace.on("connection", socket => {
|
|
120
|
-
this.LogMessage(this.#namespace[namespace], `${namespace}: Socket connected, ID: [${socket.id}]`);
|
|
121
|
-
this.LogMessage(this.#namespace[namespace], `${namespace}: Authentication Handshake: [${JSON.stringify(socket.handshake.auth)}]`);
|
|
122
|
-
|
|
123
|
-
this.#SetupMessageMiddleware(socket);
|
|
124
|
-
|
|
125
|
-
if (autoJoinRooms) {
|
|
126
|
-
rooms.map((room) => {
|
|
127
|
-
this.JoinRoom(this.#namespace[namespace], socket, room);
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
this.#SetupStandardEvents(this.#namespace[namespace], socket);
|
|
132
|
-
|
|
133
|
-
if (socketConnectCallBack) {
|
|
134
|
-
setTimeout(() => {
|
|
135
|
-
socketConnectCallBack(socket);
|
|
136
|
-
}, 0);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (socketEventsCallBack) {
|
|
140
|
-
socketEventsCallBack(socket);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
return this.#namespace[namespace].socketionamespace as Namespace<ClientToServerEvents, ServerToClientEvents, InterServerEvents>;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
GetSTSSocketIONamespace = (namespace: string): STSSocketIONamespace => {
|
|
148
|
-
return this.#namespace[namespace];
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
GetSTSSocketIONamespaces = (): STSSocketIONamespaces => {
|
|
152
|
-
return this.#namespace;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
DisconnectSockets = (): void => {
|
|
156
|
-
for (const [, namespace] of Object.entries(this.#namespace)) {
|
|
157
|
-
namespace.socketionamespace.disconnectSockets();
|
|
158
|
-
}
|
|
159
|
-
this.#namespace = { };
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
SetupEvent(event: ClientToServerEvents, eventCb: ServerEventCb): ISocketIoServerHelper<ClientToServerEvents, ServerToClientEvents> {
|
|
163
|
-
return this as any;
|
|
164
|
-
}
|
|
165
|
-
}
|
package/types/authutilsnode.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import tough from 'tough-cookie';
|
|
2
|
-
import { ISTSLogger } from '@nsshunt/stsutils';
|
|
3
|
-
import { PublishInstrumentController } from '@nsshunt/stsobservability';
|
|
4
|
-
export interface IAuthUtilsNodeOptions {
|
|
5
|
-
permissions: string[];
|
|
6
|
-
}
|
|
7
|
-
export interface IGetAPITokenFromAuthServerUsingScopeOptions {
|
|
8
|
-
clientId: string;
|
|
9
|
-
authClientSecret: string;
|
|
10
|
-
scope: string;
|
|
11
|
-
endPoint: string;
|
|
12
|
-
instrumentController?: PublishInstrumentController;
|
|
13
|
-
outputErrorsToConsole?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare class AuthUtilsNode {
|
|
16
|
-
#private;
|
|
17
|
-
constructor(logger: ISTSLogger);
|
|
18
|
-
ResetAgent: () => void;
|
|
19
|
-
VerifyRequestMiddlewareFactory: (options: IAuthUtilsNodeOptions) => (req: any, res: any, next: any) => Promise<void>;
|
|
20
|
-
verifyRequestMiddleware(req: any, res: any, next: any): Promise<void>;
|
|
21
|
-
SetCookiesToJar: (headers: Record<string, any>, endpoint: string) => Promise<tough.Cookie[]>;
|
|
22
|
-
GetCookiesFromJar: (endpoint: string) => Promise<tough.Cookie[]>;
|
|
23
|
-
ValidateJWT: (token: string, audience: string, endpoint?: string) => Promise<string>;
|
|
24
|
-
ExtractOrigin: (uri: string) => string | null;
|
|
25
|
-
GetAPITokenFromAuthServerUsingScope: (options: IGetAPITokenFromAuthServerUsingScopeOptions, errorCb: (error: Error) => void) => Promise<string>;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=authutilsnode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authutilsnode.d.ts","sourceRoot":"","sources":["../src/authutilsnode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAUjC,OAAO,EAAmB,UAAU,EAAc,MAAM,mBAAmB,CAAA;AAQ3E,OAAO,EAAS,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAI9E,MAAM,WAAW,qBAAqB;IAClC,WAAW,EAAE,MAAM,EAAE,CAAA;CACxB;AAED,MAAM,WAAW,2CAA2C;IACxD,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,MAAM,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,oBAAoB,CAAC,EAAE,2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