@nsshunt/stsappframework 2.19.164 → 2.19.166
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/authutilsnode.js +39 -6
- package/dist/authutilsnode.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/testHelpers.js +303 -0
- package/dist/testHelpers.js.map +1 -0
- package/package.json +7 -1
- package/src/authutilsnode.ts +44 -5
- package/src/index.ts +1 -0
- package/src/testHelpers.ts +306 -0
- package/types/authutilsnode.d.ts +2 -1
- package/types/authutilsnode.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/testHelpers.d.ts +20 -0
- package/types/testHelpers.d.ts.map +1 -0
package/dist/authutilsnode.js
CHANGED
|
@@ -22,11 +22,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
|
-
var _AuthUtilsNode_cookiejar, _AuthUtilsNode_httpsAgent, _AuthUtilsNode_debug,
|
|
25
|
+
var _AuthUtilsNode_cookiejar, _AuthUtilsNode_httpsAgent, _AuthUtilsNode_debug, _AuthUtilsNode_GetHttpsAgent;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.AuthUtilsNode = exports.STSClientID = void 0;
|
|
28
28
|
const tough_cookie_1 = __importDefault(require("tough-cookie"));
|
|
29
29
|
const https_1 = __importDefault(require("https"));
|
|
30
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
31
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
32
|
+
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
|
30
33
|
const axios_1 = __importDefault(require("axios"));
|
|
31
34
|
const stsconfig_1 = require("@nsshunt/stsconfig");
|
|
32
35
|
const goptions = (0, stsconfig_1.$Options)();
|
|
@@ -57,7 +60,7 @@ class AuthUtilsNode {
|
|
|
57
60
|
_AuthUtilsNode_cookiejar.set(this, void 0);
|
|
58
61
|
_AuthUtilsNode_httpsAgent.set(this, null);
|
|
59
62
|
_AuthUtilsNode_debug.set(this, (0, debug_1.default)(`proc:${process.pid}:AuthUtilsNode`));
|
|
60
|
-
|
|
63
|
+
_AuthUtilsNode_GetHttpsAgent.set(this, () => {
|
|
61
64
|
if (__classPrivateFieldGet(this, _AuthUtilsNode_httpsAgent, "f") === null) {
|
|
62
65
|
// https://nodejs.org/api/http.html#class-httpagent
|
|
63
66
|
__classPrivateFieldSet(this, _AuthUtilsNode_httpsAgent, new https_1.default.Agent({
|
|
@@ -87,7 +90,35 @@ class AuthUtilsNode {
|
|
|
87
90
|
this.GetCookiesFromJar = (endpoint) => __awaiter(this, void 0, void 0, function* () {
|
|
88
91
|
return __classPrivateFieldGet(this, _AuthUtilsNode_cookiejar, "f").getCookies(endpoint);
|
|
89
92
|
});
|
|
90
|
-
this.
|
|
93
|
+
this.ValidateJWT = (token, audience, endpoint) => __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const jwksClientUri = (endpoint
|
|
95
|
+
? `${endpoint}${goptions.asoauthapiroot}${goptions.asjwksjsonpath}`
|
|
96
|
+
: `${goptions.asendpoint}:${goptions.asport}${goptions.asoauthapiroot}${goptions.asjwksjsonpath}`);
|
|
97
|
+
const jwks = (0, jwks_rsa_1.default)({
|
|
98
|
+
cache: true,
|
|
99
|
+
cacheMaxEntries: 5,
|
|
100
|
+
cacheMaxAge: 600000,
|
|
101
|
+
rateLimit: true,
|
|
102
|
+
jwksRequestsPerMinute: 10,
|
|
103
|
+
jwksUri: jwksClientUri,
|
|
104
|
+
timeout: 30000,
|
|
105
|
+
requestAgent: __classPrivateFieldGet(this, _AuthUtilsNode_GetHttpsAgent, "f").call(this)
|
|
106
|
+
});
|
|
107
|
+
// Use decode to get the kid
|
|
108
|
+
const decodedRefreshToken = (0, jwt_decode_1.default)(token, { header: true });
|
|
109
|
+
const kid = decodedRefreshToken.kid;
|
|
110
|
+
const key = yield jwks.getSigningKey(kid);
|
|
111
|
+
const signingKey = key.getPublicKey();
|
|
112
|
+
const verifyOptions = {
|
|
113
|
+
issuer: 'https://stsmda.com.au/stsauth/',
|
|
114
|
+
//subject: s,
|
|
115
|
+
audience: audience,
|
|
116
|
+
//expiresIn: 600, // 10 minutes
|
|
117
|
+
algorithm: ["RS256"] // RSASSA [ "RS256", "RS384", "RS512" ]
|
|
118
|
+
};
|
|
119
|
+
return jsonwebtoken_1.default.verify(token, signingKey, verifyOptions);
|
|
120
|
+
});
|
|
121
|
+
this.GetAPITokenFromAuthServer = (clientId, authClientSecret, audience, endPoint) => __awaiter(this, void 0, void 0, function* () {
|
|
91
122
|
try {
|
|
92
123
|
const headers = { 'Content-Type': 'application/json' };
|
|
93
124
|
const payload = {
|
|
@@ -99,13 +130,15 @@ class AuthUtilsNode {
|
|
|
99
130
|
//@@ need scope to be the API identifier
|
|
100
131
|
grant_type: "client_credentials"
|
|
101
132
|
};
|
|
102
|
-
const url =
|
|
133
|
+
const url = (endPoint
|
|
134
|
+
? `${endPoint}${goptions.asoauthapiroot}/token`
|
|
135
|
+
: `${goptions.asendpoint}:${goptions.asport}${goptions.asoauthapiroot}/token`);
|
|
103
136
|
const retVal = yield (0, axios_1.default)({
|
|
104
137
|
url,
|
|
105
138
|
method: 'post',
|
|
106
139
|
data: payload,
|
|
107
140
|
headers: headers,
|
|
108
|
-
httpsAgent: __classPrivateFieldGet(this,
|
|
141
|
+
httpsAgent: __classPrivateFieldGet(this, _AuthUtilsNode_GetHttpsAgent, "f").call(this)
|
|
109
142
|
});
|
|
110
143
|
if (retVal.status) {
|
|
111
144
|
if (retVal.status !== 200) {
|
|
@@ -208,5 +241,5 @@ class AuthUtilsNode {
|
|
|
208
241
|
}
|
|
209
242
|
}
|
|
210
243
|
exports.AuthUtilsNode = AuthUtilsNode;
|
|
211
|
-
_AuthUtilsNode_cookiejar = new WeakMap(), _AuthUtilsNode_httpsAgent = new WeakMap(), _AuthUtilsNode_debug = new WeakMap(),
|
|
244
|
+
_AuthUtilsNode_cookiejar = new WeakMap(), _AuthUtilsNode_httpsAgent = new WeakMap(), _AuthUtilsNode_debug = new WeakMap(), _AuthUtilsNode_GetHttpsAgent = new WeakMap();
|
|
212
245
|
//# sourceMappingURL=authutilsnode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authutilsnode.js","sourceRoot":"","sources":["../src/authutilsnode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAiC;AACjC,kDAAyB;
|
|
1
|
+
{"version":3,"file":"authutilsnode.js","sourceRoot":"","sources":["../src/authutilsnode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAiC;AACjC,kDAAyB;AACzB,gEAA+B;AAC/B,4DAAoC;AACpC,wDAAkC;AAElC,kDAA0B;AAE1B,kDAA6C;AAC7C,MAAM,QAAQ,GAAG,IAAA,oBAAQ,GAAE,CAAA;AAE3B,kDAA+B;AAE/B,gDAA+D;AAE/D,gDAA2D;AAE3D,yDAAgD;AAMhD,IAAY,WAgBX;AAhBD,WAAY,WAAW;IACnB,gFAAiE,CAAA;IACjE,8EAA+D,CAAA;IAC/D,6EAA8D,CAAA;IAC9D,sEAAuD,CAAA;IACvD,2EAA4D,CAAA;IAC5D,qFAAsE,CAAA;IACtE,2FAA4E,CAAA;IAC5E,0FAA2E,CAAA;IAC3E,iFAAkE,CAAA;IAClE,gFAAiE,CAAA;IACjE,iFAAkE,CAAA;IAClE,sFAAuE,CAAA;IACvE,qFAAsE,CAAA;IACtE,iFAAkE,CAAA;IAClE,uFAAwE,CAAA;AAC5E,CAAC,EAhBW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAgBtB;AAED,MAAa,aAAa;IAMtB;QAJA,2CAA4B;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AK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBACzC,MAAM,mBAAmB,GAAG,EAAG,CAAC;oBAChC,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;wBAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;4BAC9B,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;yBACxC;qBACJ;oBACD,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE;wBAChC,MAAM,YAAY,GAAG,IAAA,0BAAe,EAAC,8BAAqB,CAAC,+BAA+B,EAAE,mBAAmB,CAAC,CAAC;wBACjH,GAAG,CAAC,MAAM,CAAC,+BAAW,CAAC,YAAY,CAAC,CAAC,IAAI,CAAE,EAAE,MAAM,EAAE,+BAAW,CAAC,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;wBACtG,OAAO;qBACV;iBACJ;gBACD,IAAI,EAAE,CAAC;YACX,CAAC;SAAA,CAAA;IACL,CAAC;IACD;;;;;;;;;;;;;;;MAeD;IAEO,uBAAuB,CAAC,GAAQ,EAAE,GAAQ,EAAE,IAAS;;YAEvD,IAAI,EAAE,CAAC;YACP;;;;;;;;;;;;;;;;;;cAkBJ;QACA,CAAC;KAAA;CAyMJ;AA9RD,sCA8RC"}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./commonTypes"), exports);
|
|
|
18
18
|
__exportStar(require("./processoptions"), exports);
|
|
19
19
|
__exportStar(require("./authDefs"), exports);
|
|
20
20
|
__exportStar(require("./authutilsnode"), exports);
|
|
21
|
+
__exportStar(require("./testHelpers"), exports);
|
|
21
22
|
__exportStar(require("./stsrouterbase"), exports);
|
|
22
23
|
__exportStar(require("./stscontrollerbase"), exports);
|
|
23
24
|
__exportStar(require("./singleprocessbase"), 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,mDAAgC;AAChC,6CAA0B;AAC1B,kDAA+B;AAC/B,kDAA+B;AAC/B,sDAAmC;AACnC,sDAAmC;AACnC,sDAAmC;AACnC,sDAAmC;AACnC,mDAAgC;AAChC,yDAAsC;AACtC,oDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,mDAAgC;AAChC,6CAA0B;AAC1B,kDAA+B;AAC/B,gDAA6B;AAC7B,kDAA+B;AAC/B,sDAAmC;AACnC,sDAAmC;AACnC,sDAAmC;AACnC,sDAAmC;AACnC,mDAAgC;AAChC,yDAAsC;AACtC,oDAAiC"}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
35
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
36
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
37
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
38
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
39
|
+
};
|
|
40
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
41
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
42
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
43
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
44
|
+
};
|
|
45
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
+
};
|
|
48
|
+
var _TestHelper_regexURLSafeStringComponent, _TestHelper_regexSTSBase64, _TestHelper_regexJWT, _TestHelper_authUtilsNode, _TestHelper_databaseContainer, _TestHelper_stsAuthContainer, _TestHelper_network, _TestHelper_endpoint, _TestHelper_httpsAgent, _TestHelper_GetHttpsAgent;
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.TestHelper = void 0;
|
|
51
|
+
const debug_1 = __importDefault(require("debug"));
|
|
52
|
+
const debug = (0, debug_1.default)(`proc:${process.pid}:stsresourcecontroller.test`);
|
|
53
|
+
const tough = __importStar(require("tough-cookie"));
|
|
54
|
+
const https_1 = __importDefault(require("https"));
|
|
55
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
56
|
+
require("jest-date");
|
|
57
|
+
const axios_1 = __importDefault(require("axios"));
|
|
58
|
+
const testcontainers_1 = require("testcontainers");
|
|
59
|
+
const stsconfig_1 = require("@nsshunt/stsconfig");
|
|
60
|
+
let goptions = (0, stsconfig_1.$Options)();
|
|
61
|
+
const stsutils_1 = require("@nsshunt/stsutils");
|
|
62
|
+
const authutilsnode_1 = require("./authutilsnode");
|
|
63
|
+
class TestHelper {
|
|
64
|
+
constructor() {
|
|
65
|
+
//#regexBase64URL = /^[A-Za-z0-9_-]+$/ // Base64URL - https://base64.guru/standards/base64url
|
|
66
|
+
_TestHelper_regexURLSafeStringComponent.set(this, /[-a-zA-Z0-9@:%._+~#=]{1,256}/
|
|
67
|
+
//#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
|
|
68
|
+
); // URL safe string component
|
|
69
|
+
//#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
|
|
70
|
+
_TestHelper_regexSTSBase64.set(this, /SES_(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?/); // Base64
|
|
71
|
+
_TestHelper_regexJWT.set(this, /[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+/); // JWT (Base64URL.Base64URL.Base64URL)
|
|
72
|
+
_TestHelper_authUtilsNode.set(this, new authutilsnode_1.AuthUtilsNode());
|
|
73
|
+
_TestHelper_databaseContainer.set(this, void 0);
|
|
74
|
+
_TestHelper_stsAuthContainer.set(this, void 0);
|
|
75
|
+
_TestHelper_network.set(this, void 0);
|
|
76
|
+
_TestHelper_endpoint.set(this, '');
|
|
77
|
+
_TestHelper_httpsAgent.set(this, null);
|
|
78
|
+
_TestHelper_GetHttpsAgent.set(this, () => {
|
|
79
|
+
if (__classPrivateFieldGet(this, _TestHelper_httpsAgent, "f") === null) {
|
|
80
|
+
// https://nodejs.org/api/http.html#class-httpagent
|
|
81
|
+
__classPrivateFieldSet(this, _TestHelper_httpsAgent, new https_1.default.Agent({
|
|
82
|
+
keepAlive: goptions.keepAlive,
|
|
83
|
+
maxSockets: goptions.maxSockets,
|
|
84
|
+
maxTotalSockets: goptions.maxTotalSockets,
|
|
85
|
+
maxFreeSockets: goptions.maxFreeSockets,
|
|
86
|
+
timeout: goptions.timeout,
|
|
87
|
+
rejectUnauthorized: false
|
|
88
|
+
}), "f");
|
|
89
|
+
}
|
|
90
|
+
return __classPrivateFieldGet(this, _TestHelper_httpsAgent, "f");
|
|
91
|
+
});
|
|
92
|
+
this.StartNetwork = () => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
__classPrivateFieldSet(this, _TestHelper_network, yield new testcontainers_1.Network().start(), "f");
|
|
94
|
+
});
|
|
95
|
+
this.StopNetwork = () => __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
yield __classPrivateFieldGet(this, _TestHelper_network, "f").stop();
|
|
97
|
+
});
|
|
98
|
+
this.CreateRandomString = () => {
|
|
99
|
+
const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.'; // /[0-9A-Za-z\-_~.]/
|
|
100
|
+
let random = '';
|
|
101
|
+
const randomValues = Array.from(crypto_1.default.getRandomValues(new Uint8Array(43)));
|
|
102
|
+
randomValues.forEach(v => (random += charset[v % charset.length]));
|
|
103
|
+
return random;
|
|
104
|
+
};
|
|
105
|
+
this.Login = (username, password) => __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const client_id = process.env.CLIENT_ID;
|
|
107
|
+
const nonce = crypto_1.default.randomBytes(43).toString('base64'); //CreateRandomString();
|
|
108
|
+
const response_type = 'code';
|
|
109
|
+
const redirect_uri = process.env.REDIRECT_URI;
|
|
110
|
+
const response_mode = 'query';
|
|
111
|
+
const scope = process.env.SCOPE;
|
|
112
|
+
const state = crypto_1.default.randomBytes(43).toString('base64'); // CreateRandomString();
|
|
113
|
+
const code_verifier = this.CreateRandomString();
|
|
114
|
+
const code_challenge = crypto_1.default.createHash('sha256').update(code_verifier).digest('base64');
|
|
115
|
+
const code_challenge_method = 'S256';
|
|
116
|
+
const authoriseOptions = {
|
|
117
|
+
email: username,
|
|
118
|
+
password,
|
|
119
|
+
client_id,
|
|
120
|
+
nonce,
|
|
121
|
+
response_type,
|
|
122
|
+
redirect_uri,
|
|
123
|
+
response_mode,
|
|
124
|
+
scope,
|
|
125
|
+
state,
|
|
126
|
+
code_challenge,
|
|
127
|
+
code_challenge_method
|
|
128
|
+
};
|
|
129
|
+
const url = `${__classPrivateFieldGet(this, _TestHelper_endpoint, "f")}${goptions.asapiroot}/login`;
|
|
130
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
131
|
+
const retVal = yield (0, axios_1.default)({
|
|
132
|
+
url,
|
|
133
|
+
method: 'post',
|
|
134
|
+
data: authoriseOptions,
|
|
135
|
+
headers: headers,
|
|
136
|
+
httpsAgent: __classPrivateFieldGet(this, _TestHelper_GetHttpsAgent, "f").call(this)
|
|
137
|
+
});
|
|
138
|
+
//const cookieString = retVal.headers['set-cookie'];
|
|
139
|
+
/*
|
|
140
|
+
const api = request(this.#endpoint);
|
|
141
|
+
const retVal: any = await (api as any)
|
|
142
|
+
.post(`${goptions.asapiroot}/login`)
|
|
143
|
+
.send(authoriseOptions)
|
|
144
|
+
//.expect('set-cookie', /consent_cookie=.*; Max-Age=86; Path=\/; Expires=.*; HttpOnly; Secure; SameSite=Strict/);
|
|
145
|
+
|
|
146
|
+
const cookieString = retVal.header['set-cookie'];
|
|
147
|
+
|
|
148
|
+
if (cookieString) {
|
|
149
|
+
retVal.cookie = new Cookie(cookieString[0]);
|
|
150
|
+
}
|
|
151
|
+
*/
|
|
152
|
+
return retVal;
|
|
153
|
+
});
|
|
154
|
+
this.GetAuthServerAPITokenFromServer = () => __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
return yield __classPrivateFieldGet(this, _TestHelper_authUtilsNode, "f").GetAPITokenFromAuthServer(authutilsnode_1.STSClientID.STSTestingService, "eN9u0mHZLGWZrdnE1zit2vL6xwUFW466sTZcbkXDml5KWxlvKaZ1uiOZmA==", goptions.asapiidentifier, __classPrivateFieldGet(this, _TestHelper_endpoint, "f"));
|
|
156
|
+
});
|
|
157
|
+
this.ValidateJWT = (token) => __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
return yield __classPrivateFieldGet(this, _TestHelper_authUtilsNode, "f").ValidateJWT(token, goptions.asapiidentifier, __classPrivateFieldGet(this, _TestHelper_endpoint, "f"));
|
|
159
|
+
});
|
|
160
|
+
this.StartDatabase = () => __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
__classPrivateFieldSet(this, _TestHelper_databaseContainer, yield new testcontainers_1.GenericContainer("postgres")
|
|
162
|
+
.withExposedPorts(5432)
|
|
163
|
+
.withEnvironment({
|
|
164
|
+
POSTGRES_PASSWORD: "postgres",
|
|
165
|
+
//UV_THREADPOOL_SIZE: "64"
|
|
166
|
+
})
|
|
167
|
+
.withNetwork(__classPrivateFieldGet(this, _TestHelper_network, "f"))
|
|
168
|
+
.withNetworkAliases("database")
|
|
169
|
+
.start(), "f");
|
|
170
|
+
const httpPort = __classPrivateFieldGet(this, _TestHelper_databaseContainer, "f").getMappedPort(5432);
|
|
171
|
+
const host = __classPrivateFieldGet(this, _TestHelper_databaseContainer, "f").getHost();
|
|
172
|
+
const networkIpAddress = __classPrivateFieldGet(this, _TestHelper_databaseContainer, "f").getIpAddress(__classPrivateFieldGet(this, _TestHelper_network, "f").getName());
|
|
173
|
+
process.env.DB_PORT = httpPort;
|
|
174
|
+
process.env.DB_HOST = host;
|
|
175
|
+
(0, stsconfig_1.$ResetOptions)();
|
|
176
|
+
goptions = (0, stsconfig_1.$Options)();
|
|
177
|
+
debug(`httpPort: [${httpPort}]`.green);
|
|
178
|
+
debug(`host: [${host}]`.green);
|
|
179
|
+
debug(`networkIpAddress: [${networkIpAddress}]`.green);
|
|
180
|
+
debug(`connectionString: [${goptions.connectionString}]`.green);
|
|
181
|
+
debug(`defaultDatabaseConnectionString: [${goptions.defaultDatabaseConnectionString}]`.green);
|
|
182
|
+
});
|
|
183
|
+
this.StopDatabase = () => __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
if (__classPrivateFieldGet(this, _TestHelper_databaseContainer, "f")) {
|
|
185
|
+
yield __classPrivateFieldGet(this, _TestHelper_databaseContainer, "f").stop();
|
|
186
|
+
debug(`Used the following parameters for the database during testing:`.yellow);
|
|
187
|
+
debug(`connectionString: [${goptions.connectionString}]`.yellow);
|
|
188
|
+
debug(`defaultDatabaseConnectionString: [${goptions.defaultDatabaseConnectionString}]`.yellow);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
// Note: .withCopyFilesToContainer and .withCopyContentToContainer have a defect in that Jest will not close. A file handle/stream is left open
|
|
192
|
+
// within the underlying code.
|
|
193
|
+
this.InitializeDatabase = () => __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
const stsAuthContainerInit = yield new testcontainers_1.GenericContainer("serza/stsauth:latest")
|
|
195
|
+
.withEnvironment({
|
|
196
|
+
DB_USER: "postgres",
|
|
197
|
+
DB_PASSWORD: "postgres",
|
|
198
|
+
DB_HOST: "database",
|
|
199
|
+
DB_PORT: "5432",
|
|
200
|
+
POOL_SIZE: "50",
|
|
201
|
+
MAX_CPU: "2",
|
|
202
|
+
DEBUG: "proc*",
|
|
203
|
+
HTTPS_SERVER_KEY_PATH: "/var/lib/sts/stsglobalresources/keys-tmp/server.key",
|
|
204
|
+
HTTPS_SERVER_CERT_PATH: "/var/lib/sts/stsglobalresources/keys-tmp/server.cert",
|
|
205
|
+
AS_CLIENT_ID: "q6a9F0kksXDDcrsCUKRwHKDnTNh7yZfxCShAgIJqfGg=",
|
|
206
|
+
AS_CLIENT_SECRET: "eN9u0mHZLGWZrdnE1zit2vL6xwUFW466sTZcbkXDml5KWxlvKaZ1uiOZmA==",
|
|
207
|
+
AS_ENDPOINT: "https://stscore.stsmda.org"
|
|
208
|
+
})
|
|
209
|
+
.withCommand(["node", "dist/app", "create"])
|
|
210
|
+
.withNetwork(__classPrivateFieldGet(this, _TestHelper_network, "f"))
|
|
211
|
+
.withNetworkAliases("stsauthrunnerinit")
|
|
212
|
+
.withWaitStrategy(testcontainers_1.Wait.forLogMessage(`User Permissions: {"status":200,"detail":["STSREST01ReadPermission","STSREST01CreatePermission","STSREST01UpdatePermission","STSREST01DeletePermission"]}`))
|
|
213
|
+
.start();
|
|
214
|
+
yield (0, stsutils_1.Sleep)(200);
|
|
215
|
+
yield stsAuthContainerInit.stop();
|
|
216
|
+
});
|
|
217
|
+
this.StartAuthService = () => __awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
__classPrivateFieldSet(this, _TestHelper_stsAuthContainer, yield new testcontainers_1.GenericContainer("serza/stsauth:latest")
|
|
219
|
+
.withExposedPorts(3002)
|
|
220
|
+
.withEnvironment({
|
|
221
|
+
DB_USER: "postgres",
|
|
222
|
+
DB_PASSWORD: "postgres",
|
|
223
|
+
DB_HOST: "database",
|
|
224
|
+
DB_PORT: "5432",
|
|
225
|
+
POOL_SIZE: "50",
|
|
226
|
+
MAX_CPU: "2",
|
|
227
|
+
DEBUG: "proc*",
|
|
228
|
+
HTTPS_SERVER_KEY_PATH: "/var/lib/sts/stsglobalresources/keys-tmp/server.key",
|
|
229
|
+
HTTPS_SERVER_CERT_PATH: "/var/lib/sts/stsglobalresources/keys-tmp/server.cert",
|
|
230
|
+
AS_CLIENT_ID: "q6a9F0kksXDDcrsCUKRwHKDnTNh7yZfxCShAgIJqfGg=",
|
|
231
|
+
AS_CLIENT_SECRET: "eN9u0mHZLGWZrdnE1zit2vL6xwUFW466sTZcbkXDml5KWxlvKaZ1uiOZmA==",
|
|
232
|
+
AS_ENDPOINT: "https://stscore.stsmda.org"
|
|
233
|
+
})
|
|
234
|
+
.withNetwork(__classPrivateFieldGet(this, _TestHelper_network, "f"))
|
|
235
|
+
.withNetworkAliases("stsauthrunner")
|
|
236
|
+
.withWaitStrategy(testcontainers_1.Wait.forHttp("/stsauth/v1.0/latency", 3002).usingTls().allowInsecure())
|
|
237
|
+
.start(), "f");
|
|
238
|
+
const httpAuthPort = __classPrivateFieldGet(this, _TestHelper_stsAuthContainer, "f").getMappedPort(3002);
|
|
239
|
+
yield (0, stsutils_1.Sleep)(200);
|
|
240
|
+
debug(`-------------------------------------------------------------------------------------------`.green);
|
|
241
|
+
debug(` *** STSAuth Started ***: [${httpAuthPort}]`.green);
|
|
242
|
+
debug(`-------------------------------------------------------------------------------------------`.green);
|
|
243
|
+
__classPrivateFieldSet(this, _TestHelper_endpoint, `https://localhost:${httpAuthPort}`, "f");
|
|
244
|
+
});
|
|
245
|
+
this.StopAuthService = () => __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
if (__classPrivateFieldGet(this, _TestHelper_stsAuthContainer, "f")) {
|
|
247
|
+
yield __classPrivateFieldGet(this, _TestHelper_stsAuthContainer, "f").stop();
|
|
248
|
+
yield (0, stsutils_1.Sleep)(200);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
this.TestLoginAndVerify = () => __awaiter(this, void 0, void 0, function* () {
|
|
252
|
+
expect.assertions(4);
|
|
253
|
+
const retVal = yield this.Login('user01@stsmda.com.au', 'user01password');
|
|
254
|
+
expect(retVal.status).toEqual(200);
|
|
255
|
+
debug(`${JSON.stringify(retVal.data)}`.red);
|
|
256
|
+
debug(`${JSON.stringify(retVal.headers)}`.magenta);
|
|
257
|
+
debug(`${JSON.stringify(retVal.headers['set-cookie'])}`.yellow);
|
|
258
|
+
const cookies = retVal.headers['set-cookie'];
|
|
259
|
+
debug(`${cookies[0]}`.yellow);
|
|
260
|
+
debug(`${JSON.stringify(tough.Cookie.parse(cookies[0]))}`.green);
|
|
261
|
+
const cookie = tough.Cookie.parse(cookies[0]);
|
|
262
|
+
const desiredCookieResultAxios = {
|
|
263
|
+
key: 'consent_cookie',
|
|
264
|
+
value: expect.stringMatching(__classPrivateFieldGet(this, _TestHelper_regexURLSafeStringComponent, "f")),
|
|
265
|
+
path: '/',
|
|
266
|
+
secure: true,
|
|
267
|
+
httpOnly: true,
|
|
268
|
+
sameSite: 'strict',
|
|
269
|
+
};
|
|
270
|
+
const cookieResult = JSON.parse(JSON.stringify(cookie));
|
|
271
|
+
expect(cookieResult).toMatchObject(desiredCookieResultAxios);
|
|
272
|
+
const cookieExpireDate = new Date(cookie.expires);
|
|
273
|
+
expect(cookieExpireDate).toBeAfter(new Date());
|
|
274
|
+
const desiredResult = {
|
|
275
|
+
sessionId: expect.stringMatching(__classPrivateFieldGet(this, _TestHelper_regexSTSBase64, "f")),
|
|
276
|
+
id_token: expect.stringMatching(__classPrivateFieldGet(this, _TestHelper_regexJWT, "f")),
|
|
277
|
+
consentRequired: ['res01.create', 'res01.read', 'res01.update', 'res01.delete']
|
|
278
|
+
};
|
|
279
|
+
expect(retVal.data.detail).toMatchObject(desiredResult);
|
|
280
|
+
});
|
|
281
|
+
this.TestValidateJWT = () => __awaiter(this, void 0, void 0, function* () {
|
|
282
|
+
expect.assertions(1);
|
|
283
|
+
const token = yield this.GetAuthServerAPITokenFromServer();
|
|
284
|
+
debug(token);
|
|
285
|
+
const retVal = yield this.ValidateJWT(token);
|
|
286
|
+
// https://jestjs.io/docs/expect#tomatchobjectobject
|
|
287
|
+
const desiredJWT = {
|
|
288
|
+
scope: 'offline_access session.read session.update',
|
|
289
|
+
iss: 'https://stsmda.com.au/stsauth/',
|
|
290
|
+
aud: 'https://stsmda.com.au/stsauthapi/v1.0/',
|
|
291
|
+
sub: 'session'
|
|
292
|
+
};
|
|
293
|
+
expect(retVal).toMatchObject(desiredJWT);
|
|
294
|
+
});
|
|
295
|
+
__classPrivateFieldSet(this, _TestHelper_endpoint, 'https://localhost:3002', "f"); //@@
|
|
296
|
+
}
|
|
297
|
+
get network() {
|
|
298
|
+
return __classPrivateFieldGet(this, _TestHelper_network, "f");
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
exports.TestHelper = TestHelper;
|
|
302
|
+
_TestHelper_regexURLSafeStringComponent = new WeakMap(), _TestHelper_regexSTSBase64 = new WeakMap(), _TestHelper_regexJWT = new WeakMap(), _TestHelper_authUtilsNode = new WeakMap(), _TestHelper_databaseContainer = new WeakMap(), _TestHelper_stsAuthContainer = new WeakMap(), _TestHelper_network = new WeakMap(), _TestHelper_endpoint = new WeakMap(), _TestHelper_httpsAgent = new WeakMap(), _TestHelper_GetHttpsAgent = new WeakMap();
|
|
303
|
+
//# sourceMappingURL=testHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testHelpers.js","sourceRoot":"","sources":["../src/testHelpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;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+OJ;AA5RD,gCA4RC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nsshunt/stsappframework",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.166",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -29,13 +29,16 @@
|
|
|
29
29
|
"@types/debug": "^4.1.7",
|
|
30
30
|
"@types/express": "^4.17.17",
|
|
31
31
|
"@types/jest": "^29.5.0",
|
|
32
|
+
"@types/jsonwebtoken": "^9.0.1",
|
|
32
33
|
"@types/pg": "^8.6.6",
|
|
33
34
|
"@types/uuid": "^9.0.1",
|
|
34
35
|
"@typescript-eslint/eslint-plugin": "^5.58.0",
|
|
35
36
|
"@typescript-eslint/parser": "^5.58.0",
|
|
36
37
|
"eslint": "^8.38.0",
|
|
37
38
|
"jest": "^29.5.0",
|
|
39
|
+
"jest-date": "^1.1.6",
|
|
38
40
|
"supertest": "^6.3.3",
|
|
41
|
+
"testcontainers": "^9.5.0",
|
|
39
42
|
"typescript": "^5.0.4"
|
|
40
43
|
},
|
|
41
44
|
"dependencies": {
|
|
@@ -54,6 +57,9 @@
|
|
|
54
57
|
"debug": "^4.3.4",
|
|
55
58
|
"express": "^4.18.2",
|
|
56
59
|
"http-status-codes": "^2.2.0",
|
|
60
|
+
"jsonwebtoken": "^9.0.0",
|
|
61
|
+
"jwks-rsa": "^3.0.1",
|
|
62
|
+
"jwt-decode": "^3.1.2",
|
|
57
63
|
"pidusage": "^3.0.2",
|
|
58
64
|
"prom-client": "^14.2.0",
|
|
59
65
|
"socket.io": "^4.6.1",
|
package/src/authutilsnode.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import tough from 'tough-cookie';
|
|
2
2
|
import https from 'https'
|
|
3
|
+
import jwt from 'jsonwebtoken';
|
|
4
|
+
import jwt_decode from 'jwt-decode';
|
|
5
|
+
import jwksClient from 'jwks-rsa';
|
|
3
6
|
|
|
4
7
|
import axios from 'axios';
|
|
5
8
|
|
|
@@ -8,7 +11,7 @@ const goptions = $Options()
|
|
|
8
11
|
|
|
9
12
|
import debugModule from 'debug'
|
|
10
13
|
|
|
11
|
-
import { GetErrorPayload } from '@nsshunt/stsutils'
|
|
14
|
+
import { GetErrorPayload, JSONObject } from '@nsshunt/stsutils'
|
|
12
15
|
|
|
13
16
|
import { AppFrameworkErrorCode } from './validation/errors'
|
|
14
17
|
|
|
@@ -46,7 +49,7 @@ export class AuthUtilsNode
|
|
|
46
49
|
this.#cookiejar = new tough.CookieJar();
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
#
|
|
52
|
+
#GetHttpsAgent = () =>
|
|
50
53
|
{
|
|
51
54
|
if (this.#httpsAgent === null) {
|
|
52
55
|
// https://nodejs.org/api/http.html#class-httpagent
|
|
@@ -143,7 +146,41 @@ export class AuthUtilsNode
|
|
|
143
146
|
return this.#cookiejar.getCookies(endpoint);
|
|
144
147
|
};
|
|
145
148
|
|
|
146
|
-
|
|
149
|
+
ValidateJWT = async (token: string, audience: string, endpoint?: string): Promise<string> => {
|
|
150
|
+
const jwksClientUri = (endpoint
|
|
151
|
+
? `${endpoint}${goptions.asoauthapiroot}${goptions.asjwksjsonpath}`
|
|
152
|
+
: `${goptions.asendpoint}:${goptions.asport}${goptions.asoauthapiroot}${goptions.asjwksjsonpath}`);
|
|
153
|
+
|
|
154
|
+
const jwks = jwksClient({
|
|
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
|
+
|
|
165
|
+
// Use decode to get the kid
|
|
166
|
+
const decodedRefreshToken = jwt_decode<JSONObject>(token, { header: true });
|
|
167
|
+
const kid = decodedRefreshToken.kid;
|
|
168
|
+
|
|
169
|
+
const key = await jwks.getSigningKey(kid);
|
|
170
|
+
const signingKey = key.getPublicKey();
|
|
171
|
+
|
|
172
|
+
const verifyOptions = {
|
|
173
|
+
issuer: 'https://stsmda.com.au/stsauth/',
|
|
174
|
+
//subject: s,
|
|
175
|
+
audience: audience,
|
|
176
|
+
//expiresIn: 600, // 10 minutes
|
|
177
|
+
algorithm: ["RS256"] // RSASSA [ "RS256", "RS384", "RS512" ]
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
return jwt.verify(token, signingKey, verifyOptions) as string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
GetAPITokenFromAuthServer = async (clientId: STSClientID, authClientSecret: string, audience: string, endPoint?: string): Promise<string> => {
|
|
147
184
|
try {
|
|
148
185
|
const headers = { 'Content-Type': 'application/json'};
|
|
149
186
|
const payload = { //@@ make a type
|
|
@@ -155,13 +192,15 @@ export class AuthUtilsNode
|
|
|
155
192
|
//@@ need scope to be the API identifier
|
|
156
193
|
grant_type: "client_credentials"
|
|
157
194
|
}
|
|
158
|
-
const url =
|
|
195
|
+
const url = (endPoint
|
|
196
|
+
? `${endPoint}${goptions.asoauthapiroot}/token`
|
|
197
|
+
: `${goptions.asendpoint}:${goptions.asport}${goptions.asoauthapiroot}/token`);
|
|
159
198
|
const retVal = await axios({
|
|
160
199
|
url
|
|
161
200
|
,method: 'post'
|
|
162
201
|
,data: payload
|
|
163
202
|
,headers: headers
|
|
164
|
-
,httpsAgent: this.#
|
|
203
|
+
,httpsAgent: this.#GetHttpsAgent()
|
|
165
204
|
});
|
|
166
205
|
|
|
167
206
|
if (retVal.status) {
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import debugModule from 'debug'
|
|
2
|
+
const debug = debugModule(`proc:${process.pid}:stsresourcecontroller.test`);
|
|
3
|
+
|
|
4
|
+
import * as tough from 'tough-cookie'
|
|
5
|
+
|
|
6
|
+
import https from 'https'
|
|
7
|
+
import crypto from 'crypto';
|
|
8
|
+
|
|
9
|
+
import 'jest-date'
|
|
10
|
+
|
|
11
|
+
import axios from 'axios';
|
|
12
|
+
|
|
13
|
+
import { GenericContainer, Network, Wait } from "testcontainers";
|
|
14
|
+
|
|
15
|
+
import { $Options, $ResetOptions } from '@nsshunt/stsconfig'
|
|
16
|
+
let goptions = $Options()
|
|
17
|
+
|
|
18
|
+
import { Sleep } from '@nsshunt/stsutils'
|
|
19
|
+
|
|
20
|
+
import { AuthUtilsNode, STSClientID } from './authutilsnode'
|
|
21
|
+
|
|
22
|
+
export class TestHelper {
|
|
23
|
+
//#regexBase64URL = /^[A-Za-z0-9_-]+$/ // Base64URL - https://base64.guru/standards/base64url
|
|
24
|
+
#regexURLSafeStringComponent = /[-a-zA-Z0-9@:%._+~#=]{1,256}/ // URL safe string component
|
|
25
|
+
//#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
|
|
26
|
+
#regexSTSBase64 = /SES_(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?/ // Base64
|
|
27
|
+
#regexJWT = /[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+/ // JWT (Base64URL.Base64URL.Base64URL)
|
|
28
|
+
|
|
29
|
+
#authUtilsNode = new AuthUtilsNode();
|
|
30
|
+
|
|
31
|
+
#databaseContainer: any;
|
|
32
|
+
#stsAuthContainer: any;
|
|
33
|
+
#network: any;
|
|
34
|
+
#endpoint = '';
|
|
35
|
+
#httpsAgent: https.Agent | null = null;
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
this.#endpoint = 'https://localhost:3002'; //@@
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#GetHttpsAgent = () =>
|
|
42
|
+
{
|
|
43
|
+
if (this.#httpsAgent === null) {
|
|
44
|
+
// https://nodejs.org/api/http.html#class-httpagent
|
|
45
|
+
this.#httpsAgent = new https.Agent({
|
|
46
|
+
keepAlive: goptions.keepAlive,
|
|
47
|
+
maxSockets: goptions.maxSockets,
|
|
48
|
+
maxTotalSockets: goptions.maxTotalSockets,
|
|
49
|
+
maxFreeSockets: goptions.maxFreeSockets,
|
|
50
|
+
timeout: goptions.timeout,
|
|
51
|
+
rejectUnauthorized: false
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return this.#httpsAgent;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
StartNetwork = async () => {
|
|
58
|
+
this.#network = await new Network().start();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
StopNetwork = async () => {
|
|
62
|
+
await this.#network.stop();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get network() {
|
|
66
|
+
return this.#network;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
CreateRandomString = () => {
|
|
70
|
+
const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.'; // /[0-9A-Za-z\-_~.]/
|
|
71
|
+
let random = '';
|
|
72
|
+
const randomValues: number[] = Array.from(crypto.getRandomValues(new Uint8Array(43)));
|
|
73
|
+
randomValues.forEach(v => (random += charset[v % charset.length]));
|
|
74
|
+
return random;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
Login = async (username: string, password: string) => {
|
|
78
|
+
const client_id = process.env.CLIENT_ID as string;
|
|
79
|
+
const nonce = crypto.randomBytes(43).toString('base64'); //CreateRandomString();
|
|
80
|
+
const response_type = 'code';
|
|
81
|
+
const redirect_uri = process.env.REDIRECT_URI as string;
|
|
82
|
+
const response_mode = 'query';
|
|
83
|
+
const scope = process.env.SCOPE as string;
|
|
84
|
+
const state = crypto.randomBytes(43).toString('base64'); // CreateRandomString();
|
|
85
|
+
const code_verifier = this.CreateRandomString();
|
|
86
|
+
const code_challenge = crypto.createHash('sha256').update(code_verifier).digest('base64');
|
|
87
|
+
const code_challenge_method = 'S256';
|
|
88
|
+
|
|
89
|
+
const authoriseOptions: any = {
|
|
90
|
+
email: username,
|
|
91
|
+
password,
|
|
92
|
+
client_id,
|
|
93
|
+
nonce,
|
|
94
|
+
response_type,
|
|
95
|
+
redirect_uri,
|
|
96
|
+
response_mode,
|
|
97
|
+
scope,
|
|
98
|
+
state,
|
|
99
|
+
code_challenge,
|
|
100
|
+
code_challenge_method
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
const url = `${this.#endpoint}${goptions.asapiroot}/login`;
|
|
105
|
+
const headers = { 'Content-Type': 'application/json'};
|
|
106
|
+
|
|
107
|
+
const retVal = await axios({
|
|
108
|
+
url
|
|
109
|
+
,method: 'post'
|
|
110
|
+
,data: authoriseOptions
|
|
111
|
+
,headers: headers
|
|
112
|
+
,httpsAgent: this.#GetHttpsAgent()
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
//const cookieString = retVal.headers['set-cookie'];
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
const api = request(this.#endpoint);
|
|
119
|
+
const retVal: any = await (api as any)
|
|
120
|
+
.post(`${goptions.asapiroot}/login`)
|
|
121
|
+
.send(authoriseOptions)
|
|
122
|
+
//.expect('set-cookie', /consent_cookie=.*; Max-Age=86; Path=\/; Expires=.*; HttpOnly; Secure; SameSite=Strict/);
|
|
123
|
+
|
|
124
|
+
const cookieString = retVal.header['set-cookie'];
|
|
125
|
+
|
|
126
|
+
if (cookieString) {
|
|
127
|
+
retVal.cookie = new Cookie(cookieString[0]);
|
|
128
|
+
}
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
return retVal;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
GetAuthServerAPITokenFromServer = async (): Promise<string> => {
|
|
135
|
+
return await this.#authUtilsNode.GetAPITokenFromAuthServer(STSClientID.STSTestingService,
|
|
136
|
+
"eN9u0mHZLGWZrdnE1zit2vL6xwUFW466sTZcbkXDml5KWxlvKaZ1uiOZmA==",
|
|
137
|
+
goptions.asapiidentifier, this.#endpoint)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
ValidateJWT = async (token: string): Promise<string> => {
|
|
141
|
+
return await this.#authUtilsNode.ValidateJWT(token, goptions.asapiidentifier, this.#endpoint);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
StartDatabase = async () => {
|
|
145
|
+
this.#databaseContainer = await new GenericContainer("postgres")
|
|
146
|
+
.withExposedPorts(5432)
|
|
147
|
+
.withEnvironment({
|
|
148
|
+
POSTGRES_PASSWORD: "postgres",
|
|
149
|
+
//UV_THREADPOOL_SIZE: "64"
|
|
150
|
+
})
|
|
151
|
+
.withNetwork(this.#network)
|
|
152
|
+
.withNetworkAliases("database")
|
|
153
|
+
.start();
|
|
154
|
+
|
|
155
|
+
const httpPort = this.#databaseContainer.getMappedPort(5432);
|
|
156
|
+
const host = this.#databaseContainer.getHost();
|
|
157
|
+
const networkIpAddress = this.#databaseContainer.getIpAddress(this.#network.getName());
|
|
158
|
+
|
|
159
|
+
process.env.DB_PORT = httpPort;
|
|
160
|
+
process.env.DB_HOST = host;
|
|
161
|
+
|
|
162
|
+
$ResetOptions();
|
|
163
|
+
goptions = $Options()
|
|
164
|
+
|
|
165
|
+
debug(`httpPort: [${httpPort}]`.green)
|
|
166
|
+
debug(`host: [${host}]`.green)
|
|
167
|
+
debug(`networkIpAddress: [${networkIpAddress}]`.green)
|
|
168
|
+
debug(`connectionString: [${goptions.connectionString}]`.green)
|
|
169
|
+
debug(`defaultDatabaseConnectionString: [${goptions.defaultDatabaseConnectionString }]`.green)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
StopDatabase = async () => {
|
|
173
|
+
if (this.#databaseContainer) {
|
|
174
|
+
await this.#databaseContainer.stop();
|
|
175
|
+
|
|
176
|
+
debug(`Used the following parameters for the database during testing:`.yellow);
|
|
177
|
+
debug(`connectionString: [${goptions.connectionString}]`.yellow);
|
|
178
|
+
debug(`defaultDatabaseConnectionString: [${goptions.defaultDatabaseConnectionString }]`.yellow);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Note: .withCopyFilesToContainer and .withCopyContentToContainer have a defect in that Jest will not close. A file handle/stream is left open
|
|
183
|
+
// within the underlying code.
|
|
184
|
+
InitializeDatabase = async () => {
|
|
185
|
+
const stsAuthContainerInit = await new GenericContainer("serza/stsauth:latest")
|
|
186
|
+
.withEnvironment({
|
|
187
|
+
DB_USER: "postgres",
|
|
188
|
+
DB_PASSWORD: "postgres",
|
|
189
|
+
DB_HOST: "database", // "192.168.14.101",
|
|
190
|
+
DB_PORT: "5432",
|
|
191
|
+
POOL_SIZE: "50",
|
|
192
|
+
MAX_CPU: "2",
|
|
193
|
+
DEBUG: "proc*",
|
|
194
|
+
HTTPS_SERVER_KEY_PATH: "/var/lib/sts/stsglobalresources/keys-tmp/server.key",
|
|
195
|
+
HTTPS_SERVER_CERT_PATH: "/var/lib/sts/stsglobalresources/keys-tmp/server.cert",
|
|
196
|
+
AS_CLIENT_ID: "q6a9F0kksXDDcrsCUKRwHKDnTNh7yZfxCShAgIJqfGg=",
|
|
197
|
+
AS_CLIENT_SECRET: "eN9u0mHZLGWZrdnE1zit2vL6xwUFW466sTZcbkXDml5KWxlvKaZ1uiOZmA==",
|
|
198
|
+
AS_ENDPOINT: "https://stscore.stsmda.org"
|
|
199
|
+
})
|
|
200
|
+
.withCommand(["node", "dist/app", "create"])
|
|
201
|
+
.withNetwork(this.#network)
|
|
202
|
+
.withNetworkAliases("stsauthrunnerinit")
|
|
203
|
+
.withWaitStrategy(Wait.forLogMessage(`User Permissions: {"status":200,"detail":["STSREST01ReadPermission","STSREST01CreatePermission","STSREST01UpdatePermission","STSREST01DeletePermission"]}`))
|
|
204
|
+
.start();
|
|
205
|
+
|
|
206
|
+
await Sleep(200);
|
|
207
|
+
|
|
208
|
+
await stsAuthContainerInit.stop();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
StartAuthService = async () => {
|
|
212
|
+
this.#stsAuthContainer = await new GenericContainer("serza/stsauth:latest")
|
|
213
|
+
.withExposedPorts(3002)
|
|
214
|
+
.withEnvironment({
|
|
215
|
+
DB_USER: "postgres",
|
|
216
|
+
DB_PASSWORD: "postgres",
|
|
217
|
+
DB_HOST: "database",
|
|
218
|
+
DB_PORT: "5432",
|
|
219
|
+
POOL_SIZE: "50",
|
|
220
|
+
MAX_CPU: "2",
|
|
221
|
+
DEBUG: "proc*",
|
|
222
|
+
HTTPS_SERVER_KEY_PATH: "/var/lib/sts/stsglobalresources/keys-tmp/server.key",
|
|
223
|
+
HTTPS_SERVER_CERT_PATH: "/var/lib/sts/stsglobalresources/keys-tmp/server.cert",
|
|
224
|
+
AS_CLIENT_ID: "q6a9F0kksXDDcrsCUKRwHKDnTNh7yZfxCShAgIJqfGg=",
|
|
225
|
+
AS_CLIENT_SECRET: "eN9u0mHZLGWZrdnE1zit2vL6xwUFW466sTZcbkXDml5KWxlvKaZ1uiOZmA==",
|
|
226
|
+
AS_ENDPOINT: "https://stscore.stsmda.org"
|
|
227
|
+
})
|
|
228
|
+
.withNetwork(this.#network)
|
|
229
|
+
.withNetworkAliases("stsauthrunner")
|
|
230
|
+
.withWaitStrategy(Wait.forHttp("/stsauth/v1.0/latency", 3002).usingTls().allowInsecure())
|
|
231
|
+
.start();
|
|
232
|
+
|
|
233
|
+
const httpAuthPort = this.#stsAuthContainer.getMappedPort(3002);
|
|
234
|
+
|
|
235
|
+
await Sleep(200);
|
|
236
|
+
debug(`-------------------------------------------------------------------------------------------`.green)
|
|
237
|
+
debug(` *** STSAuth Started ***: [${httpAuthPort}]`.green)
|
|
238
|
+
debug(`-------------------------------------------------------------------------------------------`.green)
|
|
239
|
+
|
|
240
|
+
this.#endpoint = `https://localhost:${httpAuthPort}`;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
StopAuthService = async () => {
|
|
244
|
+
if (this.#stsAuthContainer) {
|
|
245
|
+
await this.#stsAuthContainer.stop();
|
|
246
|
+
await Sleep(200);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
TestLoginAndVerify = async () => {
|
|
251
|
+
expect.assertions(4);
|
|
252
|
+
|
|
253
|
+
const retVal = await this.Login('user01@stsmda.com.au', 'user01password');
|
|
254
|
+
expect(retVal.status).toEqual(200);
|
|
255
|
+
|
|
256
|
+
debug(`${JSON.stringify(retVal.data)}`.red);
|
|
257
|
+
debug(`${JSON.stringify(retVal.headers)}`.magenta);
|
|
258
|
+
debug(`${JSON.stringify(retVal.headers['set-cookie'])}`.yellow);
|
|
259
|
+
|
|
260
|
+
const cookies = retVal.headers['set-cookie'] as string[];
|
|
261
|
+
debug(`${cookies[0]}`.yellow);
|
|
262
|
+
debug(`${JSON.stringify(tough.Cookie.parse(cookies[0]))}`.green);
|
|
263
|
+
|
|
264
|
+
const cookie = tough.Cookie.parse(cookies[0]) as tough.Cookie;
|
|
265
|
+
|
|
266
|
+
const desiredCookieResultAxios = {
|
|
267
|
+
key: 'consent_cookie',
|
|
268
|
+
value: expect.stringMatching(this.#regexURLSafeStringComponent),
|
|
269
|
+
path: '/',
|
|
270
|
+
secure: true,
|
|
271
|
+
httpOnly: true,
|
|
272
|
+
sameSite: 'strict',
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const cookieResult = JSON.parse(JSON.stringify(cookie));
|
|
276
|
+
expect(cookieResult).toMatchObject(desiredCookieResultAxios);
|
|
277
|
+
|
|
278
|
+
const cookieExpireDate = new Date(cookie.expires);
|
|
279
|
+
expect(cookieExpireDate).toBeAfter(new Date());
|
|
280
|
+
|
|
281
|
+
const desiredResult = {
|
|
282
|
+
sessionId: expect.stringMatching(this.#regexSTSBase64),
|
|
283
|
+
id_token: expect.stringMatching(this.#regexJWT),
|
|
284
|
+
consentRequired: [ 'res01.create', 'res01.read', 'res01.update', 'res01.delete' ]
|
|
285
|
+
}
|
|
286
|
+
expect(retVal.data.detail).toMatchObject(desiredResult);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
TestValidateJWT = async () => {
|
|
290
|
+
expect.assertions(1);
|
|
291
|
+
|
|
292
|
+
const token = await this.GetAuthServerAPITokenFromServer();
|
|
293
|
+
debug(token);
|
|
294
|
+
|
|
295
|
+
const retVal = await this.ValidateJWT(token);
|
|
296
|
+
// https://jestjs.io/docs/expect#tomatchobjectobject
|
|
297
|
+
const desiredJWT = {
|
|
298
|
+
scope: 'offline_access session.read session.update',
|
|
299
|
+
iss: 'https://stsmda.com.au/stsauth/',
|
|
300
|
+
aud: 'https://stsmda.com.au/stsauthapi/v1.0/',
|
|
301
|
+
sub: 'session'
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
expect(retVal).toMatchObject(desiredJWT);
|
|
305
|
+
}
|
|
306
|
+
}
|
package/types/authutilsnode.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare class AuthUtilsNode {
|
|
|
26
26
|
verifyRequestMiddleware(req: any, res: any, next: any): Promise<void>;
|
|
27
27
|
SetCookiesToJar: (headers: Record<string, any>, endpoint: string) => Promise<tough.Cookie[]>;
|
|
28
28
|
GetCookiesFromJar: (endpoint: string) => Promise<tough.Cookie[]>;
|
|
29
|
-
|
|
29
|
+
ValidateJWT: (token: string, audience: string, endpoint?: string) => Promise<string>;
|
|
30
|
+
GetAPITokenFromAuthServer: (clientId: STSClientID, authClientSecret: string, audience: string, endPoint?: string) => Promise<string>;
|
|
30
31
|
}
|
|
31
32
|
//# sourceMappingURL=authutilsnode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authutilsnode.d.ts","sourceRoot":"","sources":["../src/authutilsnode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"authutilsnode.d.ts","sourceRoot":"","sources":["../src/authutilsnode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAmBjC,MAAM,WAAW,qBAAqB;IAClC,WAAW,EAAE,MAAM,EAAE,CAAA;CACxB;AAED,oBAAY,WAAW;IACnB,gBAAgB,iDAAiD;IACjE,cAAc,iDAAiD;IAC/D,aAAa,iDAAiD;IAC9D,MAAM,iDAAiD;IACvD,WAAW,iDAAiD;IAC5D,qBAAqB,iDAAiD;IACtE,2BAA2B,iDAAiD;IAC5E,0BAA0B,iDAAiD;IAC3E,iBAAiB,iDAAiD;IAClE,gBAAgB,iDAAiD;IACjE,iBAAiB,iDAAiD;IAClE,sBAAsB,iDAAiD;IACvE,qBAAqB,iDAAiD;IACtE,iBAAiB,iDAAiD;IAClE,+BAA+B,yCAAyC;CAC3E;AAED,qBAAa,aAAa;;;IA0BtB,8BAA8B,CAAC,OAAO,EAAE,qBAAqB,SAC9B,GAAG,OAAO,GAAG,QAAQ,GAAG;IAoCjD,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;IAwB3D,eAAe,YAAmB,OAAO,MAAM,EAAE,GAAG,CAAC,YAAY,MAAM,KAAG,QAAQ,MAAM,MAAM,EAAE,CAAC,CAa/F;IAEF,iBAAiB,aAAoB,MAAM,KAAG,QAAQ,MAAM,MAAM,EAAE,CAAC,CAGnE;IAEF,WAAW,UAAiB,MAAM,YAAY,MAAM,aAAa,MAAM,KAAG,QAAQ,MAAM,CAAC,CAgCxF;IAED,yBAAyB,aAAoB,WAAW,oBAAoB,MAAM,YAAY,MAAM,aAAa,MAAM,KAAG,QAAQ,MAAM,CAAC,CAqDxI;CA4FJ"}
|
package/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './commonTypes';
|
|
|
2
2
|
export * from './processoptions';
|
|
3
3
|
export * from './authDefs';
|
|
4
4
|
export * from './authutilsnode';
|
|
5
|
+
export * from './testHelpers';
|
|
5
6
|
export * from './stsrouterbase';
|
|
6
7
|
export * from './stscontrollerbase';
|
|
7
8
|
export * from './singleprocessbase';
|
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,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,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,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import 'jest-date';
|
|
2
|
+
export declare class TestHelper {
|
|
3
|
+
#private;
|
|
4
|
+
constructor();
|
|
5
|
+
StartNetwork: () => Promise<void>;
|
|
6
|
+
StopNetwork: () => Promise<void>;
|
|
7
|
+
get network(): any;
|
|
8
|
+
CreateRandomString: () => string;
|
|
9
|
+
Login: (username: string, password: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
10
|
+
GetAuthServerAPITokenFromServer: () => Promise<string>;
|
|
11
|
+
ValidateJWT: (token: string) => Promise<string>;
|
|
12
|
+
StartDatabase: () => Promise<void>;
|
|
13
|
+
StopDatabase: () => Promise<void>;
|
|
14
|
+
InitializeDatabase: () => Promise<void>;
|
|
15
|
+
StartAuthService: () => Promise<void>;
|
|
16
|
+
StopAuthService: () => Promise<void>;
|
|
17
|
+
TestLoginAndVerify: () => Promise<void>;
|
|
18
|
+
TestValidateJWT: () => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=testHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testHelpers.d.ts","sourceRoot":"","sources":["../src/testHelpers.ts"],"names":[],"mappings":"AAQA,OAAO,WAAW,CAAA;AAalB,qBAAa,UAAU;;;IAmCnB,YAAY,sBAEX;IAED,WAAW,sBAEV;IAED,IAAI,OAAO,QAEV;IAED,kBAAkB,eAMjB;IAED,KAAK,aAAoB,MAAM,YAAY,MAAM,sDAuDhD;IAED,+BAA+B,QAAa,QAAQ,MAAM,CAAC,CAI1D;IAED,WAAW,UAAiB,MAAM,KAAG,QAAQ,MAAM,CAAC,CAEnD;IAED,aAAa,sBA0BZ;IAED,YAAY,sBAQX;IAID,kBAAkB,sBAyBjB;IAED,gBAAgB,sBA8Bf;IAED,eAAe,sBAKd;IAED,kBAAkB,sBAqCjB;IAED,eAAe,sBAgBd;CACJ"}
|