data-primals-engine 1.1.6 → 1.1.7-rc1
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/package.json +1 -1
- package/src/constants.js +8 -0
- package/src/core.js +3 -2
- package/src/engine.js +16 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-primals-engine",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7-rc1",
|
|
4
4
|
"description": "data-primals-engine is the package responsible from handling large amount of data in a practical and performant way. It can handle large amount of data in a practical and performant way. It can also get workflow models working (for automation), and fully supports internationalisation.",
|
|
5
5
|
"main": "src/engine.js",
|
|
6
6
|
"type": "module",
|
package/src/constants.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {event_trigger} from "./core.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Enables auto-installation at startup
|
|
3
5
|
* @type {boolean}
|
|
@@ -226,6 +228,12 @@ export const defaultMaxRequestData = 500;
|
|
|
226
228
|
*/
|
|
227
229
|
export const databasePoolSize = 30;
|
|
228
230
|
|
|
231
|
+
/**
|
|
232
|
+
* TLS options for MongoDB access
|
|
233
|
+
* @type {boolean}
|
|
234
|
+
*/
|
|
235
|
+
export const tlsAllowInvalidCertificates = false;
|
|
236
|
+
export const tlsAllowInvalidHostnames = false;
|
|
229
237
|
|
|
230
238
|
/**
|
|
231
239
|
* Options for the HTML sanitizer
|
package/src/core.js
CHANGED
|
@@ -224,8 +224,9 @@ export function getRandom(min, max) {
|
|
|
224
224
|
|
|
225
225
|
export function getBrowserRandom(minInclusive, maxInclusive) {
|
|
226
226
|
const randomBuffer = new Uint32Array(1);
|
|
227
|
-
(window.crypto || window.msCrypto)
|
|
228
|
-
|
|
227
|
+
const cr = (window.crypto || window.msCrypto);
|
|
228
|
+
cr?.getRandomValues(randomBuffer);
|
|
229
|
+
const r = cr ? ( randomBuffer[0] / (0xffffffff + 1) ) : getRand();
|
|
229
230
|
return Math.floor(r * (maxInclusive - minInclusive + 1) + minInclusive);
|
|
230
231
|
}
|
|
231
232
|
|
package/src/engine.js
CHANGED
|
@@ -4,7 +4,12 @@ import fs from 'node:fs'
|
|
|
4
4
|
import express from 'express'
|
|
5
5
|
import {MongoClient as InternalMongoClient} from 'mongodb'
|
|
6
6
|
import process from "process";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
cookiesSecret,
|
|
9
|
+
databasePoolSize,
|
|
10
|
+
dbName,
|
|
11
|
+
tlsAllowInvalidCertificates, tlsAllowInvalidHostnames
|
|
12
|
+
} from "./constants.js";
|
|
8
13
|
import http from "http";
|
|
9
14
|
import cookieParser from "cookie-parser";
|
|
10
15
|
import requestIp from 'request-ip';
|
|
@@ -21,15 +26,15 @@ const isProduction = process.env.NODE_ENV === 'production'
|
|
|
21
26
|
let caFile, certFile, keyFile;
|
|
22
27
|
try {
|
|
23
28
|
if (process.env.CA_CERT)
|
|
24
|
-
caFile = fs.readFileSync(process.env.CA_CERT
|
|
29
|
+
caFile = fs.readFileSync(process.env.CA_CERT);
|
|
25
30
|
} catch (e) {}
|
|
26
31
|
try {
|
|
27
32
|
if (process.env.CERT)
|
|
28
|
-
certFile = fs.readFileSync(process.env.CERT
|
|
33
|
+
certFile = fs.readFileSync(process.env.CERT);
|
|
29
34
|
}catch (e) {}
|
|
30
35
|
try{
|
|
31
36
|
if (process.env.CERT_KEY)
|
|
32
|
-
keyFile = fs.readFileSync(process.env.CERT_KEY
|
|
37
|
+
keyFile = fs.readFileSync(process.env.CERT_KEY);
|
|
33
38
|
} catch (e) {}
|
|
34
39
|
|
|
35
40
|
const secureContext = tls.createSecureContext({
|
|
@@ -40,7 +45,13 @@ const isTlsActive = !(!process.env.TLS || ["0", "false"].includes(process.env.TL
|
|
|
40
45
|
|
|
41
46
|
// Connection URL
|
|
42
47
|
export const dbUrl = process.env.CI ? 'mongodb://mongodb:27017' : (process.env.MONGO_DB_URL || 'mongodb://127.0.0.1:27017');
|
|
43
|
-
export const MongoClient = new InternalMongoClient(dbUrl, {
|
|
48
|
+
export const MongoClient = new InternalMongoClient(dbUrl, {
|
|
49
|
+
maxPoolSize: databasePoolSize,
|
|
50
|
+
tls: isTlsActive,
|
|
51
|
+
secureContext,
|
|
52
|
+
tlsAllowInvalidCertificates,
|
|
53
|
+
tlsAllowInvalidHostnames
|
|
54
|
+
});
|
|
44
55
|
|
|
45
56
|
// Database Name
|
|
46
57
|
export const MongoDatabase = MongoClient.db(dbName);
|