@nsshunt/stsappframework 3.0.103 → 3.0.105
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 +6 -7
- package/dist/authutilsnode.js.map +1 -1
- package/dist/influxdb/influxDBManager.js +16 -17
- package/dist/influxdb/influxDBManager.js.map +1 -1
- package/dist/influxdb/influxDBManagerAgent.js +9 -13
- package/dist/influxdb/influxDBManagerAgent.js.map +1 -1
- package/dist/influxdb/influxDBManagerBase.js +2 -6
- package/dist/influxdb/influxDBManagerBase.js.map +1 -1
- package/dist/influxdb/influxDBManagerService.js +10 -14
- package/dist/influxdb/influxDBManagerService.js.map +1 -1
- package/dist/instrumentationsubscriber.js +11 -15
- package/dist/instrumentationsubscriber.js.map +1 -1
- package/dist/kafka/IMKafkaManager.js +2 -6
- package/dist/kafka/IMKafkaManager.js.map +1 -1
- package/dist/kafkatesting/produce.js +1 -5
- package/dist/kafkatesting/produce.js.map +1 -1
- package/dist/masterprocessbase.js +19 -20
- package/dist/masterprocessbase.js.map +1 -1
- package/dist/processbase.js +8 -10
- package/dist/processbase.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/singleprocessbase.js +3 -4
- package/dist/singleprocessbase.js.map +1 -1
- package/dist/tcpclient/app2.js +2 -2
- package/dist/tcpserver/appmaster.js +39 -16
- package/dist/tcpserver/appmaster.js.map +1 -1
- package/dist/workerprocessbase.js +3 -4
- package/dist/workerprocessbase.js.map +1 -1
- package/package.json +7 -7
- package/src/authutilsnode.ts +8 -10
- package/src/influxdb/influxDBManager.ts +16 -18
- package/src/influxdb/influxDBManagerAgent.ts +9 -11
- package/src/influxdb/influxDBManagerBase.ts +2 -4
- package/src/influxdb/influxDBManagerService.ts +10 -12
- package/src/instrumentationsubscriber.ts +11 -14
- package/src/kafka/IMKafkaManager.ts +2 -4
- package/src/kafkatesting/produce.ts +1 -3
- package/src/masterprocessbase.ts +32 -24
- package/src/processbase.ts +7 -11
- package/src/server.ts +1 -1
- package/src/singleprocessbase.ts +3 -5
- package/src/tcpclient/app2.ts +2 -2
- package/src/tcpserver/appmaster.ts +39 -17
- package/src/workerprocessbase.ts +3 -5
- package/types/authutilsnode.d.ts.map +1 -1
- package/types/influxdb/influxDBManager.d.ts.map +1 -1
- package/types/influxdb/influxDBManagerAgent.d.ts.map +1 -1
- package/types/influxdb/influxDBManagerBase.d.ts.map +1 -1
- package/types/influxdb/influxDBManagerService.d.ts.map +1 -1
- package/types/instrumentationsubscriber.d.ts.map +1 -1
- package/types/kafka/IMKafkaManager.d.ts.map +1 -1
- package/types/masterprocessbase.d.ts.map +1 -1
- package/types/processbase.d.ts +2 -2
- package/types/processbase.d.ts.map +1 -1
- package/types/singleprocessbase.d.ts.map +1 -1
- package/types/tcpserver/appmaster.d.ts.map +1 -1
- package/types/workerprocessbase.d.ts.map +1 -1
- package/src_new/authDefs.ts +0 -37
- package/src_new/authutilsnode.ts +0 -375
- package/src_new/commonTypes.ts +0 -239
- package/src_new/index.ts +0 -22
- package/src_new/influxdb/influxDBManager.ts +0 -972
- package/src_new/influxdb/influxDBManagerAgent.ts +0 -316
- package/src_new/influxdb/influxDBManagerBase.ts +0 -111
- package/src_new/influxdb/influxDBManagerService.ts +0 -375
- package/src_new/instrumentationsubscriber.ts +0 -286
- package/src_new/kafka/IMKafkaManager.ts +0 -154
- package/src_new/kafka/kafkaconsumer.ts +0 -82
- package/src_new/kafka/kafkamanager.ts +0 -186
- package/src_new/kafka/kafkaproducer.ts +0 -58
- package/src_new/kafkatesting/config.ts +0 -10
- package/src_new/kafkatesting/consume.ts +0 -116
- package/src_new/kafkatesting/produce.ts +0 -155
- package/src_new/masterprocessbase.ts +0 -590
- package/src_new/middleware/serverNetworkMiddleware.ts +0 -240
- package/src_new/network.ts +0 -36
- package/src_new/processbase.ts +0 -413
- package/src_new/processoptions.ts +0 -164
- package/src_new/publishertransports/publishTransportDirect.ts +0 -45
- package/src_new/publishertransports/publishTransportUtils.ts +0 -53
- package/src_new/server.ts +0 -141
- package/src_new/serverprocessbase.ts +0 -393
- package/src_new/singleprocessbase.ts +0 -123
- package/src_new/socketIoServerHelper.ts +0 -177
- package/src_new/stscontrollerbase.ts +0 -15
- package/src_new/stslatencycontroller.ts +0 -27
- package/src_new/stslatencyroute.ts +0 -16
- package/src_new/stsrouterbase.ts +0 -22
- package/src_new/tcpclient/app.ts +0 -19
- package/src_new/tcpclient/app2.ts +0 -56
- package/src_new/tcpserver/app.ts +0 -11
- package/src_new/tcpserver/appConfig.ts +0 -65
- package/src_new/tcpserver/appmaster.ts +0 -522
- package/src_new/validation/errors.ts +0 -6
- package/src_new/webworkertesting/app.ts +0 -49
- package/src_new/webworkertesting/worker.ts +0 -24
- package/src_new/workerprocessbase.test.ts +0 -47
- package/src_new/workerprocessbase.ts +0 -187
- package/src_working/authDefs.ts +0 -37
- package/src_working/authutilsnode.ts +0 -373
- package/src_working/commonTypes.ts +0 -239
- package/src_working/index.ts +0 -22
- package/src_working/influxdb/influxDBManager.ts +0 -970
- package/src_working/influxdb/influxDBManagerAgent.ts +0 -314
- package/src_working/influxdb/influxDBManagerBase.ts +0 -109
- package/src_working/influxdb/influxDBManagerService.ts +0 -373
- package/src_working/instrumentationsubscriber.ts +0 -283
- package/src_working/kafka/IMKafkaManager.ts +0 -152
- package/src_working/kafka/kafkaconsumer.ts +0 -82
- package/src_working/kafka/kafkamanager.ts +0 -186
- package/src_working/kafka/kafkaproducer.ts +0 -58
- package/src_working/kafkatesting/config.ts +0 -10
- package/src_working/kafkatesting/consume.ts +0 -116
- package/src_working/kafkatesting/produce.ts +0 -153
- package/src_working/masterprocessbase.ts +0 -598
- package/src_working/middleware/serverNetworkMiddleware.ts +0 -240
- package/src_working/network.ts +0 -36
- package/src_working/processbase.ts +0 -411
- package/src_working/processoptions.ts +0 -164
- package/src_working/publishertransports/publishTransportDirect.ts +0 -45
- package/src_working/publishertransports/publishTransportUtils.ts +0 -53
- package/src_working/server.ts +0 -141
- package/src_working/serverprocessbase.ts +0 -393
- package/src_working/singleprocessbase.ts +0 -121
- package/src_working/socketIoServerHelper.ts +0 -177
- package/src_working/stscontrollerbase.ts +0 -15
- package/src_working/stslatencycontroller.ts +0 -27
- package/src_working/stslatencyroute.ts +0 -16
- package/src_working/stsrouterbase.ts +0 -22
- package/src_working/tcpclient/app.ts +0 -19
- package/src_working/tcpclient/app2.ts +0 -56
- package/src_working/tcpserver/app.ts +0 -11
- package/src_working/tcpserver/appConfig.ts +0 -65
- package/src_working/tcpserver/appmaster.ts +0 -544
- package/src_working/validation/errors.ts +0 -6
- package/src_working/webworkertesting/app.ts +0 -49
- package/src_working/webworkertesting/worker.ts +0 -24
- package/src_working/workerprocessbase.test.ts +0 -47
- package/src_working/workerprocessbase.ts +0 -185
package/src/workerprocessbase.ts
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import debugModule from 'debug'
|
|
3
3
|
const debug = debugModule(`proc:${process.pid}`);
|
|
4
4
|
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
|
|
7
5
|
import { Gauge, InstrumentGaugeTelemetry } from '@nsshunt/stsinstrumentation'
|
|
8
6
|
import { JSONObject } from '@nsshunt/stsutils'
|
|
9
7
|
import { ProcessOptions } from './processoptions'
|
|
@@ -60,14 +58,14 @@ export class WorkerProcessBase extends ServerProcessBase implements IWorkerProce
|
|
|
60
58
|
setTimeout(() => {
|
|
61
59
|
delete this.#inFlightMessage[message.id];
|
|
62
60
|
}, 0).unref();
|
|
63
|
-
debug(
|
|
61
|
+
debug(`Resolving response message with id: [${message.id}] from parent process via IPC. Details: [${JSON.stringify(this.#inFlightMessage[message.id].iPCMessagePayload)}]`.green);
|
|
64
62
|
resolve(detail);
|
|
65
63
|
},
|
|
66
64
|
timeout: setTimeout(() => {
|
|
67
65
|
setTimeout(() => {
|
|
68
66
|
delete this.#inFlightMessage[message.id];
|
|
69
67
|
}, 0).unref();
|
|
70
|
-
debug(
|
|
68
|
+
debug(`Timeout has occurred after: [${this.#requestResponseMessageTimeout}]ms with message id: [${message.id}]. Details: [${JSON.stringify(this.#inFlightMessage[message.id].iPCMessagePayload)}]`.red);
|
|
71
69
|
reject('Did not receive response form parent process.');
|
|
72
70
|
}, this.#requestResponseMessageTimeout) // max message timeout allowed
|
|
73
71
|
}
|
|
@@ -182,6 +180,6 @@ export class WorkerProcessBase extends ServerProcessBase implements IWorkerProce
|
|
|
182
180
|
|
|
183
181
|
this.WorkerStarted();
|
|
184
182
|
|
|
185
|
-
this.LogEx(
|
|
183
|
+
this.LogEx(`Worker process:${process.pid} started`.green);
|
|
186
184
|
};
|
|
187
185
|
}
|
|
@@ -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;AAsBD,qBAAa,aAAa;;;IA4BtB,8BAA8B,CAAC,OAAO,EAAE,qBAAqB,SAE9B,GAAG,OAAO,GAAG,QAAQ,GAAG;IAqCjD,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;IAyB3D,eAAe,YAAmB,OAAO,MAAM,EAAE,GAAG,CAAC,YAAY,MAAM,KAAG,QAAQ,MAAM,MAAM,EAAE,CAAC,CAgB/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;IAGD,aAAa,QAAS,MAAM,mBAG3B;IAED;;;;;;;OAOG;IACH,mCAAmC,aAAoB,MAAM,oBAAoB,MAAM,SAAS,MAAM,aAAa,MAAM,KAAG,QAAQ,MAAM,CAAC,CA0E1I;CA4FJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManager.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,QAAQ,EAAgD,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"influxDBManager.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,QAAQ,EAAgD,MAAM,6BAA6B,CAAA;AAM9G,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAI9C,OAAO,EAAE,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAA2B,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AA0L7E,qBAAa,eAAe;;;IAyFxB,2BAA2B,CAAC,SAAS,EAAE,MAAM;IAa7C,IAAI,cAAc,IAAI,sBAAsB,CAE3C;IAED,IAAI,YAAY,IAAI,oBAAoB,CAEvC;IAED,KAAK,sBAEJ;IAED,SAAS,sBA2BR;IAQD,sBAAsB,aAAc,GAAG,EAAE,SAUxC;IAGD,kBAAkB,CAAC,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU;IAW9E,IAAI,WAAW,IAAI,QAAQ,CAsG1B;IAIK,cAAc,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CAe/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManagerAgent.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerAgent.ts"],"names":[],"mappings":";AAkGA,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAIvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"influxDBManagerAgent.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerAgent.ts"],"names":[],"mappings":";AAkGA,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAIvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AASpF,qBAAa,oBAAqB,SAAQ,mBAAmB;;gBAE7C,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,QAAQ;IAIhE,IAAa,SAAS,IAAI,MAAM,CAE/B;IAqEK,2BAA2B,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkB7F,uBAAuB,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkBzF,8BAA8B,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBhG,6BAA6B,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAsB/F,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CA6CnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManagerBase.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerBase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEhE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"influxDBManagerBase.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerBase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEhE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAI9C,qBAAa,mBAAmB;;gBAMhB,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,QAAQ;IAKhE,IAAI,OAAO,4BAEV;IACD,IAAI,QAAQ,aAEX;IAED,IAAI,YAAY,IAGM,OAAO,CAD5B;IACD,IAAI,YAAY,CAAC,GAAG,EAAE,OAAO,EAE5B;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAGK,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IAuCxE,sBAAsB,aAAc,GAAG,EAAE,SAUxC;IAED,kBAAkB,CAAC,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU;IAaxE,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CAGnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManagerService.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerService.ts"],"names":[],"mappings":";AA8GA,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAIvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"influxDBManagerService.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerService.ts"],"names":[],"mappings":";AA8GA,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAIvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAgBpF,qBAAa,sBAAuB,SAAQ,mBAAmB;;gBAE/C,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,QAAQ;IAIhE,IAAa,SAAS,IAAI,MAAM,CAE/B;IA6FK,6BAA6B,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkB/F,yBAAyB,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmB3F,kCAAkC,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBpG,iCAAiC,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqBnG,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CA6DnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentationsubscriber.d.ts","sourceRoot":"","sources":["../src/instrumentationsubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAiC,MAAM,6BAA6B,CAAA;AAOnH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"instrumentationsubscriber.d.ts","sourceRoot":"","sources":["../src/instrumentationsubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAiC,MAAM,6BAA6B,CAAA;AAOnH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAkBnD,MAAM,WAAW,iCAAiC;IAC9C,oBAAoB,EAAE,MAAM,CAAA;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAA;CACvB;AAED,qBAAa,yBAA0B,SAAQ,cAAc;;gBAO7C,OAAO,EAAE,iCAAiC;IAoLtD,SAAS,CAAC,eAAe,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI;IAgCxF,WAAW,CAAC,eAAe,EAAE,gBAAgB;IAwBvC,KAAK;IAIL,IAAI;CAIb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IMKafkaManager.d.ts","sourceRoot":"","sources":["../../src/kafka/IMKafkaManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAIpD,OAAO,EAAE,YAAY,EAAuB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"IMKafkaManager.d.ts","sourceRoot":"","sources":["../../src/kafka/IMKafkaManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAIpD,OAAO,EAAE,YAAY,EAAuB,MAAM,gBAAgB,CAAA;AAYlE,qBAAa,cAAc;;;IAiCvB,IAAI,EAAE,IAAI,YAAY,CAErB;IAED,KAAK,QAAa,QAAQ,IAAI,CAAC,CAG9B;IAED,SAAS,QAAa,QAAQ,IAAI,CAAC,CAclC;IAyBK,UAAU,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CAqD3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterprocessbase.d.ts","sourceRoot":"","sources":["../src/masterprocessbase.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"masterprocessbase.d.ts","sourceRoot":"","sources":["../src/masterprocessbase.ts"],"names":[],"mappings":";;;;AA4BA,OAAO,EAAE,cAAc,EAAiB,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAKnE,qBAAa,iBAAkB,SAAQ,WAAY,YAAW,kBAAkB;;gBAkBhE,OAAO,EAAE,cAAc;IAW1B,0BAA0B,IAAI,IAAI;IAQlC,wBAAwB,IAAI,qBAAqB;IAS1D;;;OAGA;IAEA,kBAAkB,CAAC,GAAG,EAAE,GAAG;IAqI3B,WAAW,sBAMV;IAqBD,UAAU,OAAQ,MAAM,+CAA+C,GAAG,eAAe,OAAO,gBAAgB,OAAO,KAAG,OAAO,CAwBhI;IAED,WAAW,WAAY,OAAO,OAAO,KAAG,IAAI,CAgB3C;IAUD,UAAU,QAAO,IAAI,CAIpB;IAED,UAAU,QAAO,IAAI,CAIpB;IAGD,SAAS,YAAa,GAAG,KAAG,MAAM,CAOjC;IA2ED,aAAa,IAAI,IAAI;IAIrB,IAAa,YAAY,IAAI,OAAO,CAEnC;IAED,kBAAkB,QAAa,QAAQ,IAAI,CAAC,CAE3C;IAED,aAAa,sBA8KZ;IAED,sBAAsB,YAAa,GAAG,QAAQ,GAAG,UAahD;CACJ"}
|
package/types/processbase.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import colors from 'colors';
|
|
2
2
|
import { Gauge, InstrumentBaseTelemetry } from '@nsshunt/stsinstrumentation';
|
|
3
3
|
import { PGAccessLayer } from '@nsshunt/stsdatamanagement';
|
|
4
4
|
import { ProcessOptions } from './processoptions';
|
|
@@ -31,6 +31,6 @@ export declare abstract class ProcessBase extends STSOptionsBase implements IPro
|
|
|
31
31
|
get accessLayer(): PGAccessLayer | null;
|
|
32
32
|
GetNumCPUs: () => Promise<number>;
|
|
33
33
|
LogSystemTelemetry: () => Promise<void>;
|
|
34
|
-
GetSignalColour: (signal: any) =>
|
|
34
|
+
GetSignalColour: (signal: any) => colors.Color;
|
|
35
35
|
}
|
|
36
36
|
//# sourceMappingURL=processbase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processbase.d.ts","sourceRoot":"","sources":["../src/processbase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processbase.d.ts","sourceRoot":"","sources":["../src/processbase.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAO3B,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAA+E,MAAM,6BAA6B,CAAA;AAEzJ,OAAO,EAAE,aAAa,EAAyC,MAAM,4BAA4B,CAAA;AAKjG,OAAO,EAAE,cAAc,EAAiB,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,cAAc,EAAc,MAAM,mBAAmB,CAAA;AAG9D,OAAO,EAAE,6BAA6B,EAAyC,qBAAqB,EAEhB,MAAM,6BAA6B,CAAA;AAQvH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAe,MAAM,eAAe,CAAA;AAGhF,OAAO,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAA;AAM5G,8BAAsB,WAAY,SAAQ,cAAe,YAAW,YAAY;;gBAShE,OAAO,EAAE,cAAc;IAUnC,IAAa,OAAO,IAAI,cAAc,CAErC;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IA2FD,oBAAoB;IA2CpB,wBAAwB,IAAI,qBAAqB;IAIjD,0BAA0B,IAAI,IAAI;IAIlC,cAAc,aAuCb;IAED,gBAAgB,mBAAoB,KAAK,aAAa,uBAAuB,UAI5E;IAED,IAAI,oBAAoB,IAAI,6BAA6B,GAAG,IAAI,CAE/D;IAED,KAAK,YAAa,GAAG,UASpB;IAED,gBAAgB,CAAC,cAAc,EAAE,KAAK,GAAG,OAAO;IAQhD,gBAAgB,sBAMf;IAED;;;OAGA;IACA,eAAe,IAAI,GAAG;IAItB,IAAI,oBAAoB,IAAI,qBAAqB,CAAC,8BAA8B,EAAE,8BAA8B,CAAC,GAAG,IAAI,CAGvH;IAED,IAAI,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,CAAC,8BAA8B,EAAE,8BAA8B,CAAC,GAAG,IAAI,EAG3H;IAgBK,iBAAiB;IAOvB,IAAI,WAAW,IAAI,aAAa,GAAG,IAAI,CAyBtC;IAED,UAAU,QAAa,QAAQ,MAAM,CAAC,CAkBrC;IAED,kBAAkB,sBA0BjB;IAED,eAAe,WAAY,GAAG,kBAQ5B;CACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleprocessbase.d.ts","sourceRoot":"","sources":["../src/singleprocessbase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"singleprocessbase.d.ts","sourceRoot":"","sources":["../src/singleprocessbase.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAIvD,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAA;AAEtD,qBAAa,iBAAkB,SAAQ,iBAAkB,YAAW,kBAAkB;IAElF;;;OAGA;gBACY,OAAO,EAAE,cAAc;IAI1B,0BAA0B,IAAI,IAAI;IAWlC,wBAAwB,IAAI,qBAAqB;IAS1D;;;OAGA;IACS,eAAe,IAAI,GAAG;IAI/B,cAAc;IAId,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAmB/B,aAAa,sBAiCZ;IAEK,oBAAoB;IAKjB,kBAAkB,QAAa,QAAQ,IAAI,CAAC,CAEpD;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appmaster.d.ts","sourceRoot":"","sources":["../../src/tcpserver/appmaster.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"appmaster.d.ts","sourceRoot":"","sources":["../../src/tcpserver/appmaster.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAWpD,oBAAY,kBAAkB;IAC1B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,MAAM,WAAW;CACpB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;CAC1B;AAED,qBAAa,SAAU,SAAQ,iBAAiB;;gBA0BhC,aAAa,EAAE,cAAc;IA0dzC,aAAa,IAAI,IAAI;CAKxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workerprocessbase.d.ts","sourceRoot":"","sources":["../src/workerprocessbase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workerprocessbase.d.ts","sourceRoot":"","sources":["../src/workerprocessbase.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAiE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEjH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAMvD;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,iBAAkB,YAAW,kBAAkB;;gBAKtE,OAAO,EAAE,cAAc;IAInC,aAAa;IAKb,yBAAyB,CAAC,GAAG,EAAE,GAAG;IAIzB,0BAA0B,IAAI,IAAI;IAwC3C,SAAS,YAAmB,GAAG,KAAG,QAAQ,MAAM,CAAC,CAUhD;IAGD,YAAY,aAAoB,MAAM,WAAW,GAAG,KAAG,QAAQ,UAAU,CAAC,CAWzE;IAED,kBAAkB,QAAa,QAAQ,IAAI,CAAC,CAE3C;IAED,WAAW,sBAMV;IAED,aAAa,sBAmEX;CACL"}
|
package/src_new/authDefs.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export enum Permission {
|
|
2
|
-
STS_GLOBAL_ADMIN_PERMISSION = "STSGlobalAdminPermission",
|
|
3
|
-
|
|
4
|
-
STSREST01_CREATE_PERMISSION = "STSREST01CreatePermission",
|
|
5
|
-
STSREST01_READ_PERMISSION = "STSREST01ReadPermission",
|
|
6
|
-
STSREST01_UPDATE_PERMISSION = "STSREST01UpdatePermission",
|
|
7
|
-
STSREST01_DELETE_PERMISSION = "STSREST01DeletePermission",
|
|
8
|
-
|
|
9
|
-
STSAUTH_LOGIN_PERMISSION = "STSAuthLoginPermission",
|
|
10
|
-
STSAUTH_CREATE_PERMISSION = "STSAuthCreatePermission",
|
|
11
|
-
STSAUTH_READ_PERMISSION = "STSAuthReadPermission",
|
|
12
|
-
STSAUTH_UPDATE_PERMISSION = "STSAuthUpdatePermission",
|
|
13
|
-
STSAUTH_DELETE_PERMISSION = "STSAuthDeletePermission",
|
|
14
|
-
|
|
15
|
-
STSUITERMINAL_EXECUTE = "STSUITerminalExecute",
|
|
16
|
-
|
|
17
|
-
STSCLI_EXECUTE = "STSCLIExecute",
|
|
18
|
-
|
|
19
|
-
STSUIWEBAPP_EXECUTE = "STSUIWebAppExecute",
|
|
20
|
-
|
|
21
|
-
STSUSERAGENTRUNNER_EXECUTE = "STSUserAgentRunnerExecute",
|
|
22
|
-
|
|
23
|
-
STSINSTRUMENTMANAGER_CREATE_PERMISSION = "STSInstrumentManagerCreatePermission",
|
|
24
|
-
STSINSTRUMENTMANAGER_READ_PERMISSION = "STSInstrumentManagerReadPermission",
|
|
25
|
-
STSINSTRUMENTMANAGER_UPDATE_PERMISSION = "STSInstrumentManagerUpdatePermission",
|
|
26
|
-
STSINSTRUMENTMANAGER_DELETE_PERMISSION = "STSInstrumentManagerDeletePermission",
|
|
27
|
-
|
|
28
|
-
STSTESTORCHESTRATOR_CREATE_PERMISSION = "STSTestOrchestratorCreatePermission",
|
|
29
|
-
STSTESTORCHESTRATOR_READ_PERMISSION = "STSTestOrchestratorReadPermission",
|
|
30
|
-
STSTESTORCHESTRATOR_UPDATE_PERMISSION = "STSTestOrchestratorUpdatePermission",
|
|
31
|
-
STSTESTORCHESTRATOR_DELETE_PERMISSION = "STSTestOrchestratorDeletePermission",
|
|
32
|
-
|
|
33
|
-
STSTESTRUNNER_CREATE_PERMISSION = "STSTestRunnerCreatePermission",
|
|
34
|
-
STSTESTRUNNER_READ_PERMISSION = "STSTestRunnerReadPermission",
|
|
35
|
-
STSTESTRUNNER_UPDATE_PERMISSION = "STSTestRunnerUpdatePermission",
|
|
36
|
-
STSTESTRUNNER_DELETE_PERMISSION = "STSTestRunnerDeletePermission"
|
|
37
|
-
}
|
package/src_new/authutilsnode.ts
DELETED
|
@@ -1,375 +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 { $Options } from '@nsshunt/stsconfig'
|
|
10
|
-
const goptions = $Options()
|
|
11
|
-
|
|
12
|
-
import debugModule from 'debug'
|
|
13
|
-
|
|
14
|
-
import { GetErrorPayload, JSONObject } from '@nsshunt/stsutils'
|
|
15
|
-
|
|
16
|
-
import { AppFrameworkErrorCode } from './validation/errors'
|
|
17
|
-
|
|
18
|
-
import { StatusCodes } from 'http-status-codes';
|
|
19
|
-
|
|
20
|
-
import chalk from 'chalk';
|
|
21
|
-
|
|
22
|
-
export interface IAuthUtilsNodeOptions {
|
|
23
|
-
permissions: string[]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
export enum STSClientID {
|
|
28
|
-
STSRest01Service = 'KgSyRECcvnJwwOZqf7GPqUw508sx7VBFEbDC0iP4oeY=',
|
|
29
|
-
STSAuthService = 'q6a9F0kksXDDcrsCUKRwHKDnTNh7yZfxCShAgIJqfGg=',
|
|
30
|
-
STSUITerminal = 'U0E4c4cuRKlBsGo7OhOl3qTkoNGFBXjORUS/T4R4xyA=',
|
|
31
|
-
STSCLI = 'EcCpnQOIQFizAnWphlFJ4tSylosgVnwKTSNtgwuL2tw=',
|
|
32
|
-
STSUIWebApp = 'lww8Je8n2P0OI/KEfJ+4p/bqsk8uE/noeq13tl4zlQ0=',
|
|
33
|
-
XXSTSUserAgentRunnerX = 'y1h2nNr1BzTVPIzNmP/f041uxbnyZYTJeF/5GcwRCtw=',
|
|
34
|
-
STSInstrumentManagerService = 'l8u2E912eR44ZYRHUkSBCCnDOXxQqYOPahDVQzYowrw=',
|
|
35
|
-
STSTestOrchestratorService = 'CU1sVlS6vsEe3O3VvNzKFdBnQd9pQ83w9RyVx/7tJfc=',
|
|
36
|
-
STSTestRunnerNode = 'aX9dJbsT06V1G4j06xEIQ/rZ2CDlpzggU58aLtZ8fzE=',
|
|
37
|
-
STSBrokerService = 'TRppBuvxcjL7jrY9lCASJ5st8JpU8WlhAUAWoX/KKQ4=',
|
|
38
|
-
STSTestingService = '4Mtb3ABdSzZvSz4T51HPJhT14znVnqVDRFiZsvDNAOg=',
|
|
39
|
-
XXSTSAuthenticateSPAXX = 'v4qBrds3Autl/i86xT+5z0K53kJ/2hHTfxNo0QO/0Jk=',
|
|
40
|
-
STSTestRunnerAgentSPA = 'yDbklCH3awzDNuHICuco9mjDqhdzCa8m7w/UE9Opexc=',
|
|
41
|
-
STSClientApp01SPA = 'FDX/CPyDb3m6d9G2k+wDX8Uvey+yCkllaT4EuEt4QyU=',
|
|
42
|
-
PowerPlatformCustomConnectorSPA = 'fcdcebb5-d154-4699-b99d-87d29e5e148f'
|
|
43
|
-
}
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
export class AuthUtilsNode
|
|
47
|
-
{
|
|
48
|
-
#cookiejar: tough.CookieJar;
|
|
49
|
-
#httpsAgent: https.Agent | null = null;
|
|
50
|
-
#debug = debugModule(`proc:${process.pid}:AuthUtilsNode`);
|
|
51
|
-
// Regular expression to match the origin
|
|
52
|
-
#originRegex = /^(api:\/\/\w+)/;
|
|
53
|
-
|
|
54
|
-
constructor() {
|
|
55
|
-
this.#cookiejar = new tough.CookieJar();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
#GetHttpsAgent = () =>
|
|
59
|
-
{
|
|
60
|
-
if (this.#httpsAgent === null) {
|
|
61
|
-
// https://nodejs.org/api/http.html#class-httpagent
|
|
62
|
-
this.#httpsAgent = new https.Agent({
|
|
63
|
-
keepAlive: goptions.keepAlive,
|
|
64
|
-
maxSockets: goptions.maxSockets,
|
|
65
|
-
maxTotalSockets: goptions.maxTotalSockets,
|
|
66
|
-
maxFreeSockets: goptions.maxFreeSockets,
|
|
67
|
-
timeout: goptions.timeout,
|
|
68
|
-
rejectUnauthorized: false
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return this.#httpsAgent;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
VerifyRequestMiddlewareFactory(options: IAuthUtilsNodeOptions) {
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
-
return async function(req: any, res: any, next: any) {
|
|
77
|
-
if (options.permissions) {
|
|
78
|
-
const scopes = req.auth.scope.split(' ');
|
|
79
|
-
const requiredPermissions = [ ];
|
|
80
|
-
for (let i=0; i < options.permissions.length; i++) {
|
|
81
|
-
const permission = options.permissions[i];
|
|
82
|
-
if (!scopes.includes(permission)) {
|
|
83
|
-
requiredPermissions.push(permission);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (requiredPermissions.length > 0) {
|
|
87
|
-
const errorPayload = GetErrorPayload(AppFrameworkErrorCode.APPFRAMEWORK_MISSING_PERMISSION, requiredPermissions);
|
|
88
|
-
res.status(StatusCodes.UNAUTHORIZED).send( { status: StatusCodes.UNAUTHORIZED, error: errorPayload });
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
next();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/*
|
|
96
|
-
let cookies = await this.GetCookiesFromJar();
|
|
97
|
-
const valid = this.#ValidateCookies(cookies);
|
|
98
|
-
if (valid) {
|
|
99
|
-
next();
|
|
100
|
-
} else {
|
|
101
|
-
const error = { }; //@@
|
|
102
|
-
const invalidToken = false; //@@
|
|
103
|
-
if (invalidToken)
|
|
104
|
-
{
|
|
105
|
-
res.status(StatusCodes.UNAUTHORIZED).send( { status: StatusCodes.UNAUTHORIZED, error: 'Invalid Token', detail: error } );
|
|
106
|
-
} else{
|
|
107
|
-
res.status(StatusCodes.INTERNAL_SERVER_ERROR).send( { status: StatusCodes.INTERNAL_SERVER_ERROR, error: 'Operation was not successful', detail: error } );
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
-
async verifyRequestMiddleware(req: any, res: any, next: any)
|
|
114
|
-
{
|
|
115
|
-
next();
|
|
116
|
-
/*
|
|
117
|
-
|
|
118
|
-
let cookies = await this.GetCookiesFromJar();
|
|
119
|
-
|
|
120
|
-
const valid = this.#ValidateCookies(cookies);
|
|
121
|
-
|
|
122
|
-
if (valid) {
|
|
123
|
-
next();
|
|
124
|
-
} else {
|
|
125
|
-
const error = { }; //@@
|
|
126
|
-
const invalidToken = false; //@@
|
|
127
|
-
if (invalidToken)
|
|
128
|
-
{
|
|
129
|
-
res.status(StatusCodes.UNAUTHORIZED).send( { status: StatusCodes.UNAUTHORIZED, error: 'Invalid Token', detail: error } );
|
|
130
|
-
} else{
|
|
131
|
-
res.status(StatusCodes.INTERNAL_SERVER_ERROR).send( { status: StatusCodes.INTERNAL_SERVER_ERROR, error: 'Operation was not successful', detail: error } );
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
*/
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
-
SetCookiesToJar = async (headers: Record<string, any>, endpoint: string): Promise<tough.Cookie[]> =>
|
|
139
|
-
{
|
|
140
|
-
if (headers['set-cookie']) {
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
-
headers['set-cookie'].map((headerCookie: any) => {
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
-
const cookie: any = tough.Cookie.parse(headerCookie);
|
|
145
|
-
this.#cookiejar.setCookieSync(cookie, endpoint);
|
|
146
|
-
});
|
|
147
|
-
} else {
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
|
-
const cookie: any = tough.Cookie.parse(headers['set-cookie']);
|
|
150
|
-
this.#cookiejar.setCookieSync(cookie, endpoint);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return this.#cookiejar.getCookies(endpoint);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
GetCookiesFromJar = async (endpoint: string): Promise<tough.Cookie[]> =>
|
|
157
|
-
{
|
|
158
|
-
return this.#cookiejar.getCookies(endpoint);
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
ValidateJWT = async (token: string, audience: string, endpoint?: string): Promise<string> => {
|
|
162
|
-
const jwksClientUri = (endpoint
|
|
163
|
-
? `${endpoint}${goptions.asoauthapiroot}${goptions.asjwksjsonpath}`
|
|
164
|
-
: `${goptions.asendpoint}:${goptions.asport}${goptions.asoauthapiroot}${goptions.asjwksjsonpath}`);
|
|
165
|
-
|
|
166
|
-
const jwks = jwksClient({
|
|
167
|
-
cache: true, //@@ all config items
|
|
168
|
-
cacheMaxEntries: 5, // Default value
|
|
169
|
-
cacheMaxAge: 600000, // Defaults to 10m
|
|
170
|
-
rateLimit: true,
|
|
171
|
-
jwksRequestsPerMinute: 10, // Default value
|
|
172
|
-
jwksUri: jwksClientUri,
|
|
173
|
-
timeout: 30000, //@@ config
|
|
174
|
-
requestAgent: this.#GetHttpsAgent()
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
// Use decode to get the kid
|
|
178
|
-
const decodedRefreshToken = jwtDecode<JSONObject>(token, { header: true });
|
|
179
|
-
const kid = decodedRefreshToken.kid;
|
|
180
|
-
|
|
181
|
-
const key = await jwks.getSigningKey(kid);
|
|
182
|
-
const signingKey = key.getPublicKey();
|
|
183
|
-
|
|
184
|
-
const verifyOptions = {
|
|
185
|
-
issuer: 'https://stsmda.com.au/stsauth/',
|
|
186
|
-
//subject: s,
|
|
187
|
-
audience: audience,
|
|
188
|
-
//expiresIn: 600, // 10 minutes
|
|
189
|
-
algorithm: ["RS256"] // RSASSA [ "RS256", "RS384", "RS512" ]
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
return jwt.verify(token, signingKey, verifyOptions) as string;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Function to extract the origin from a URI
|
|
196
|
-
ExtractOrigin = (uri: string) => {
|
|
197
|
-
const match = uri.match(this.#originRegex);
|
|
198
|
-
return match ? match[1] : null;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
*
|
|
203
|
-
* @param clientId
|
|
204
|
-
* @param authClientSecret
|
|
205
|
-
* @param scope space seperate list of fully qualifed required scopes (i.e. api://<<api id>>/<<resource>>.<<permission>>). Note the scopes must all be for the same client api.
|
|
206
|
-
* @param endPoint
|
|
207
|
-
* @returns
|
|
208
|
-
*/
|
|
209
|
-
GetAPITokenFromAuthServerUsingScope = async (clientId: string, authClientSecret: string, scope: string, endPoint?: string): Promise<string> => {
|
|
210
|
-
try {
|
|
211
|
-
const scopes = scope.split(' ');
|
|
212
|
-
let origin: string | null = null;
|
|
213
|
-
scopes.forEach((s) => {
|
|
214
|
-
if (!origin) {
|
|
215
|
-
origin = this.ExtractOrigin(s);
|
|
216
|
-
if (!origin) {
|
|
217
|
-
throw new Error(`Scope: [${scope}] not in required format. Must use (space seperated) api://<client id>[/<resource>.<permission>].`);
|
|
218
|
-
}
|
|
219
|
-
} else {
|
|
220
|
-
const nextOrigin: string | null = this.ExtractOrigin(s);
|
|
221
|
-
if (!nextOrigin) {
|
|
222
|
-
throw new Error(`Scope: [${scope}] not in required format. Must use (space seperated) api://<client id>[/<resource>.<permission>].`);
|
|
223
|
-
} else {
|
|
224
|
-
if (origin.localeCompare(nextOrigin) !== 0) {
|
|
225
|
-
throw new Error(`Scope: [${scope}] not all from the same client API. All scopes must come from the same client API.`);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
const headers = { 'Content-Type': 'application/json'};
|
|
232
|
-
const payload = { //@@ make a type
|
|
233
|
-
client_id: clientId, // The service calling this method
|
|
234
|
-
client_secret: authClientSecret, // Auth service client secret
|
|
235
|
-
//client_secret: goptions.brokerclientsecret, // Broker service client secret
|
|
236
|
-
scope: scope, // required API
|
|
237
|
-
//@@ remove audience
|
|
238
|
-
//@@ need scope to be the API identifier
|
|
239
|
-
grant_type: "client_credentials"
|
|
240
|
-
}
|
|
241
|
-
const url = (endPoint
|
|
242
|
-
? `${endPoint}${goptions.asoauthapiroot}/token`
|
|
243
|
-
: `${goptions.asendpoint}:${goptions.asport}${goptions.asoauthapiroot}/token`);
|
|
244
|
-
const retVal = await axios({
|
|
245
|
-
url
|
|
246
|
-
,method: 'post'
|
|
247
|
-
,data: payload
|
|
248
|
-
,headers: headers
|
|
249
|
-
,httpsAgent: this.#GetHttpsAgent()
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
if (retVal.status) {
|
|
253
|
-
if (retVal.status !== 200) {
|
|
254
|
-
// Just provide a warning here
|
|
255
|
-
this.#debug(chalk.magenta(`Error (AuthUtilsNode:GetAPITokenFromServer): Invalid response from server: [${retVal.status}]`));
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
const msg = chalk.red(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.status)`);
|
|
259
|
-
this.#debug(msg);
|
|
260
|
-
throw new Error(msg);
|
|
261
|
-
}
|
|
262
|
-
if (retVal.data) {
|
|
263
|
-
if (retVal.data.access_token) {
|
|
264
|
-
return retVal.data.access_token as string;
|
|
265
|
-
} else {
|
|
266
|
-
const msg = chalk.red(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.data.access_token)`);
|
|
267
|
-
this.#debug(msg);
|
|
268
|
-
throw new Error(msg);
|
|
269
|
-
}
|
|
270
|
-
} else {
|
|
271
|
-
const msg = chalk.red(`Error (AuthUtilsNode:GetAPITokenFromServer:No retVal.data)`);
|
|
272
|
-
this.#debug(msg);
|
|
273
|
-
throw new Error(msg);
|
|
274
|
-
}
|
|
275
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
276
|
-
} catch (error: any) {
|
|
277
|
-
this.#debug(chalk.red(`Error (AuthUtilsNode:GetAPITokenFromServer:catch): ${error}`));
|
|
278
|
-
if (error.response && error.response.data) {
|
|
279
|
-
this.#debug(chalk.red(`Details: [${JSON.stringify(error.response.data)}]`));
|
|
280
|
-
}
|
|
281
|
-
throw error;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/*
|
|
286
|
-
#getHttpsAgent = () =>
|
|
287
|
-
{
|
|
288
|
-
if (this.#httpsAgent === null) {
|
|
289
|
-
// https://nodejs.org/api/http.html#class-httpagent
|
|
290
|
-
this.#httpsAgent = new https.Agent({
|
|
291
|
-
keepAlive: goptions.keepAlive,
|
|
292
|
-
maxSockets: goptions.maxSockets,
|
|
293
|
-
maxTotalSockets: goptions.maxTotalSockets,
|
|
294
|
-
maxFreeSockets: goptions.maxFreeSockets,
|
|
295
|
-
timeout: goptions.timeout,
|
|
296
|
-
rejectUnauthorized: goptions.isProduction // Allows self signed certs in non production mode(s)
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
return this.#httpsAgent;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
Login = async (opts) =>
|
|
303
|
-
{
|
|
304
|
-
const { authendpoint, authUserName, authUserEMail, authUserPassword, defaultTimeout, publishDebug } = opts;
|
|
305
|
-
try {
|
|
306
|
-
const processStart = performance.now();
|
|
307
|
-
let duration = '';
|
|
308
|
-
let loginData = null;
|
|
309
|
-
const payload = { name: authUserName, password: authUserPassword, email: authUserEMail }
|
|
310
|
-
const retVal = await axios({
|
|
311
|
-
url: `${authendpoint}/login`
|
|
312
|
-
,method: 'post'
|
|
313
|
-
,data: payload
|
|
314
|
-
,timeout: defaultTimeout
|
|
315
|
-
,httpsAgent: this.#getHttpsAgent()
|
|
316
|
-
// Use below if using a socket endpoint
|
|
317
|
-
//,socketPath: '/var/run/sts/stsrest01.sock'
|
|
318
|
-
});
|
|
319
|
-
duration = (performance.now() - processStart).toFixed(4);
|
|
320
|
-
if (publishDebug) debug(`AuthUtilsNode.LoginNode request duration: [${duration}]`);
|
|
321
|
-
loginData = retVal.data.detail;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (retVal.headers['set-cookie'] instanceof Array) {
|
|
325
|
-
this.#cookies = retVal.headers['set-cookie'].map(cookie.parse);
|
|
326
|
-
} else {
|
|
327
|
-
this.#cookies = [cookie.parse(retVal.headers['set-cookie'])];
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
//await this.SetCookiesToJar(retVal.headers);
|
|
331
|
-
|
|
332
|
-
return loginData;
|
|
333
|
-
} catch (error)
|
|
334
|
-
{
|
|
335
|
-
if (publishDebug) debug(chalk.red(`Error (AuthUtilsNode:LoginNode): ${error}`));
|
|
336
|
-
throw error;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// https://stackoverflow.com/questions/43002444/make-axios-send-cookies-in-its-requests-automatically
|
|
341
|
-
// axios.get('some api url', {withCredentials: true});
|
|
342
|
-
// https://medium.com/@adityasrivast/handling-cookies-with-axios-872790241a9b
|
|
343
|
-
// https://www.codegrepper.com/code-examples/javascript/axios+send+cookies
|
|
344
|
-
// http only cookies
|
|
345
|
-
RefreshSessionToken = async (opts) =>
|
|
346
|
-
{
|
|
347
|
-
const { authendpoint, defaultTimeout, publishDebug } = opts;
|
|
348
|
-
try {
|
|
349
|
-
const processStart = performance.now();
|
|
350
|
-
let duration = '';
|
|
351
|
-
let loginData = null;
|
|
352
|
-
const cookies = await this.GetCookiesFromJar();
|
|
353
|
-
const retVal = await axios({
|
|
354
|
-
url: `${authendpoint}/refreshtoken`
|
|
355
|
-
,method: 'post'
|
|
356
|
-
,headers: {
|
|
357
|
-
Cookie: cookies
|
|
358
|
-
}
|
|
359
|
-
,timeout: defaultTimeout
|
|
360
|
-
,httpsAgent: this.#httpsAgent,
|
|
361
|
-
// Use below for socket connections
|
|
362
|
-
//,socketPath: '/var/run/sts/stsrest01.sock'
|
|
363
|
-
});
|
|
364
|
-
duration = (performance.now() - processStart).toFixed(4);
|
|
365
|
-
if (publishDebug) debug(`AuthUtilsNode.RefreshAuthTokenBrowser request duration: [${duration}]`);
|
|
366
|
-
loginData = retVal.data.detail;
|
|
367
|
-
await this.SetCookiesToJar(retVal.headers);
|
|
368
|
-
return loginData;
|
|
369
|
-
} catch (error) {
|
|
370
|
-
if (publishDebug) debug(chalk.red(`Error (AuthUtilsNode:RefreshAuthTokenBrowser): ${error}`));
|
|
371
|
-
throw error;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
*/
|
|
375
|
-
}
|