@qelos/api-kit 3.8.3 → 3.9.0
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/LICENSE +11 -22
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/response-error.d.ts +8 -0
- package/dist/response-error.js +22 -0
- package/dist/response-error.js.map +1 -0
- package/dist/shutdown.js +4 -0
- package/dist/shutdown.js.map +1 -1
- package/dist/user-middlewares.d.ts +1 -0
- package/dist/user-middlewares.js +16 -1
- package/dist/user-middlewares.js.map +1 -1
- package/package.json +3 -3
- package/src/app.ts +0 -1
- package/src/index.ts +1 -0
- package/src/response-error.ts +14 -0
- package/src/shutdown.ts +6 -0
- package/src/user-middlewares.ts +17 -1
package/LICENSE
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
Polyform Shield License 1.0.0
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright (c) [שנת הפרסום] Qelos LTD
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Your use of this software is governed by the Polyform Shield License 1.0.0.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **Distribute** copies of the software or modified versions.
|
|
7
|
+
You may obtain a copy of the License at:
|
|
8
|
+
https://polyformproject.org/licenses/shield/1.0.0
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
- You are not required to share modifications you make.
|
|
13
|
-
- You may use this software internally, including within commercial settings, without any restrictions.
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
Additional Terms – Exception Notice:
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
The author of this software grants additional permissions beyond the Polyform Shield License 1.0.0:
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
✅ All uses of the software are permitted — including modification, distribution, commercial use, and sublicensing — as long as the software is not used to create, offer, or operate any product or service that competes directly with Qelos (https://qelos.io), a no-code platform for building AI-assisted SaaS applications.
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
- You **may not** sell, offer, or commercialize this software as a managed service, SaaS, or any similar hosted service.
|
|
18
|
+
❌ "Direct competition" includes platforms, tools, or services that enable users to visually or programmatically create SaaS applications with the assistance of artificial intelligence.
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
If you wish to offer a managed or commercial version of this software, you must obtain a **commercial license** from Velocitech LTD. Please contact us at [support@qelos.io](mailto:support@qelos.io) for details.
|
|
26
|
-
|
|
27
|
-
## Additional Notes
|
|
28
|
-
|
|
29
|
-
This license ensures the software remains free for personal use and community development, while protecting Velocitech LTD’s right to control the commercialization of managed services based on the software.
|
|
30
|
-
|
|
31
|
-
For any questions regarding the license, feel free to reach out at [support@qelos.io].
|
|
20
|
+
This exception does not modify the terms of the original Polyform Shield License for other users and applies only by explicit permission of the licensor.
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA2C;AAG3C,0DAAkC;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA2C;AAG3C,0DAAkC;AAE3B,MAAM,MAAM,GAAG,CAAC,gBAAqB,OAAO,EAAa,EAAE;IAChE,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,aAAa,EAAE,CAAC;IAC3C,OAAO,OAAO,CAAC;AACjB,CAAC,CAAA;AAHY,QAAA,MAAM,UAGlB;AACM,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC;AAAhC,QAAA,GAAG,OAA6B;AAChC,QAAA,KAAK,GAAG,QAAQ,CAAC;AAE9B,IAAI,IAAa,CAAC;AAClB,IAAI,OAAO,GAAc;IACvB,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,KAAK;IACrC,UAAU,EAAG,OAAO,CAAC,GAAG,CAAC,eAAkC,IAAI,MAAM;IACrE,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS;IACjC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI,IAAI,MAAM;IACjC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,WAAW;CAClC,CAAC;AAEF,SAAS,SAAS;IAChB,IAAI,GAAG,IAAA,iBAAO,GAAE,CAAA;IAEhB,YAAY,CAAC,IAAI,CAAC,CAAC;IAEnB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,GAAY;IAChC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QAC1C,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;QACtC,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,EAAE;YAC5B,IAAA,kBAAQ,GAAE,CAAA;QACZ,CAAC,CAAC,CAAA;IACJ,CAAC;SAAM,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC5B,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IACxC,CAAC;AACH,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO,iBAAO,CAAC,IAAI,EAAE,CAAC;AACxB,CAAC;AAFD,sCAEC;AAED,SAAS,QAAQ,CAAC,WAAW,GAAG,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE;IACzE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAc,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE;YAC7C,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,uBAAuB,IAAI,EAAE,CAAC,CAAC;YACzD,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YACpC,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -20,4 +20,5 @@ __exportStar(require("./router"), exports);
|
|
|
20
20
|
__exportStar(require("./internal-service"), exports);
|
|
21
21
|
__exportStar(require("./user-middlewares"), exports);
|
|
22
22
|
__exportStar(require("./emit-internal-event"), exports);
|
|
23
|
+
__exportStar(require("./response-error"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,wCAAqB;AACrB,2CAAwB;AACxB,qDAAkC;AAClC,qDAAkC;AAClC,wDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,wCAAqB;AACrB,2CAAwB;AACxB,qDAAkC;AAClC,qDAAkC;AAClC,wDAAqC;AACrC,mDAAiC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseError = void 0;
|
|
4
|
+
class ResponseError extends Error {
|
|
5
|
+
status;
|
|
6
|
+
responseMessage;
|
|
7
|
+
internalMetadata;
|
|
8
|
+
constructor(messageOrData, status = 401, responseMessage) {
|
|
9
|
+
const message = messageOrData.message || messageOrData;
|
|
10
|
+
super(message);
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.responseMessage = responseMessage;
|
|
13
|
+
if (!this.responseMessage) {
|
|
14
|
+
this.responseMessage = message;
|
|
15
|
+
}
|
|
16
|
+
if (typeof messageOrData === 'object') {
|
|
17
|
+
this.internalMetadata = messageOrData;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ResponseError = ResponseError;
|
|
22
|
+
//# sourceMappingURL=response-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-error.js","sourceRoot":"","sources":["../src/response-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;IAGgC;IAA6B;IAFnG,gBAAgB,CAAM;IAEtB,YAAY,aAAiD,EAAS,SAAiB,GAAG,EAAS,eAAwB;QACzH,MAAM,OAAO,GAAW,aAAa,CAAC,OAAO,IAAI,aAAa,CAAC;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;QAFqD,WAAM,GAAN,MAAM,CAAc;QAAS,oBAAe,GAAf,eAAe,CAAS;QAGzH,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QACjC,CAAC;QACD,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YACtC,IAAI,CAAC,gBAAgB,GAAG,aAAa,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AAbD,sCAaC"}
|
package/dist/shutdown.js
CHANGED
|
@@ -9,6 +9,10 @@ let shutdown = (_code) => {
|
|
|
9
9
|
process.exit();
|
|
10
10
|
};
|
|
11
11
|
if (process.env.NODE_ENV !== 'production') {
|
|
12
|
+
// catch any error and print it
|
|
13
|
+
process.on('uncaughtException', (err) => {
|
|
14
|
+
console.error(err);
|
|
15
|
+
});
|
|
12
16
|
console.log('trying to require tmp file...');
|
|
13
17
|
try {
|
|
14
18
|
const cwd = process.cwd();
|
package/dist/shutdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../src/shutdown.ts"],"names":[],"mappings":";;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,IAAI,QAAQ,GAAG,CAAC,KAAc,EAAE,EAAE;IAChC,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../src/shutdown.ts"],"names":[],"mappings":";;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,IAAI,QAAQ,GAAG,CAAC,KAAc,EAAE,EAAE;IAChC,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;IAE1C,+BAA+B;IAC/B,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;QACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;IAC5C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1B,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,iBAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAC1B,CAAC;QACD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,iBAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,CAAC,QAAQ,CAAC,CAAA;QAEjB,QAAQ,GAAG,CAAC,IAAsB,EAAE,EAAE;YACpC,IAAI,IAAI,EAAE,QAAQ,EAAE,KAAK,GAAG,EAAE,CAAC;gBAC7B,iBAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YAChC,CAAC;YACD,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;IAED,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAED,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAE/B,kBAAe,QAAQ,CAAC"}
|
|
@@ -2,3 +2,4 @@ import type { Response, NextFunction } from 'express';
|
|
|
2
2
|
import type { RequestWithUser } from './types';
|
|
3
3
|
export declare function populateUser(req: RequestWithUser, res: Response, next: NextFunction): void;
|
|
4
4
|
export declare function verifyUser(req: RequestWithUser, res: Response, next: NextFunction): void;
|
|
5
|
+
export declare function verifyInternalCall(req: RequestWithUser, res: Response, next: NextFunction): any;
|
package/dist/user-middlewares.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyUser = exports.populateUser = void 0;
|
|
3
|
+
exports.verifyInternalCall = exports.verifyUser = exports.populateUser = void 0;
|
|
4
4
|
function populateUser(req, res, next) {
|
|
5
5
|
try {
|
|
6
6
|
req.user = req.headers.user ? JSON.parse(req.headers.user) : null;
|
|
@@ -21,4 +21,19 @@ function verifyUser(req, res, next) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.verifyUser = verifyUser;
|
|
24
|
+
function verifyInternalCall(req, res, next) {
|
|
25
|
+
if (!req.headers.internal_secret ||
|
|
26
|
+
req.headers.internal_secret !== process.env.INTERNAL_SECRET ||
|
|
27
|
+
!req.headers.tenant) {
|
|
28
|
+
return res.status(401).end();
|
|
29
|
+
}
|
|
30
|
+
req.user = {
|
|
31
|
+
type: 'internal',
|
|
32
|
+
isPrivileged: true,
|
|
33
|
+
roles: ['admin'],
|
|
34
|
+
tenant: req.headers.tenant,
|
|
35
|
+
};
|
|
36
|
+
next();
|
|
37
|
+
}
|
|
38
|
+
exports.verifyInternalCall = verifyInternalCall;
|
|
24
39
|
//# sourceMappingURL=user-middlewares.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-middlewares.js","sourceRoot":"","sources":["../src/user-middlewares.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"user-middlewares.js","sourceRoot":"","sources":["../src/user-middlewares.ts"],"names":[],"mappings":";;;AAGA,SAAgB,YAAY,CAAC,GAAoB,EAAE,GAAa,EAAE,IAAkB;IAClF,IAAI,CAAC;QACH,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5E,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC;QACpC,IAAI,EAAE,CAAC;IACT,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;IACvD,CAAC;AACH,CAAC;AARD,oCAQC;AAED,SAAgB,UAAU,CAAC,GAAoB,EAAE,GAAa,EAAE,IAAkB;IAChF,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,IAAI,EAAE,CAAC;IACT,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACxB,CAAC;AACH,CAAC;AAND,gCAMC;AAED,SAAgB,kBAAkB,CAAE,GAAoB,EAAE,GAAa,EAAE,IAAkB;IACzF,IACE,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe;QAC5B,GAAG,CAAC,OAAO,CAAC,eAAe,KAAK,OAAO,CAAC,GAAG,CAAC,eAAe;QAC3D,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EACnB,CAAC;QACD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAC/B,CAAC;IAED,GAAG,CAAC,IAAI,GAAG;QACT,IAAI,EAAE,UAAU;QAChB,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,CAAC,OAAO,CAAC;QAChB,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM;KAC3B,CAAC;IACF,IAAI,EAAE,CAAC;AACT,CAAC;AAhBD,gDAgBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qelos/api-kit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "API-Kit package to help with qelos infrastructure and reuse capabilities across services",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"express": "4.19.2",
|
|
19
19
|
"morgan": "^1.10.0"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "13468bc51557291935b96b1aeaa837b8b52861e8",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "^
|
|
23
|
+
"@types/node": "^22.5.4",
|
|
24
24
|
"typescript": "^5.4.5"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/src/app.ts
CHANGED
|
@@ -3,7 +3,6 @@ import express, { Express } from 'express';
|
|
|
3
3
|
import type { ApiConfig, BodyParserType } from './types';
|
|
4
4
|
import shutdown from './shutdown';
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
export const config = (updatedConfig: any = _config): ApiConfig => {
|
|
8
7
|
_config = { ..._config, ...updatedConfig };
|
|
9
8
|
return _config;
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class ResponseError extends Error {
|
|
2
|
+
internalMetadata: any;
|
|
3
|
+
|
|
4
|
+
constructor(messageOrData: string | any & { message: string }, public status: number = 401, public responseMessage?: string) {
|
|
5
|
+
const message: string = messageOrData.message || messageOrData;
|
|
6
|
+
super(message);
|
|
7
|
+
if (!this.responseMessage) {
|
|
8
|
+
this.responseMessage = message;
|
|
9
|
+
}
|
|
10
|
+
if (typeof messageOrData === 'object') {
|
|
11
|
+
this.internalMetadata = messageOrData;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/shutdown.ts
CHANGED
|
@@ -6,6 +6,12 @@ let shutdown = (_code?: number) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
if (process.env.NODE_ENV !== 'production') {
|
|
9
|
+
|
|
10
|
+
// catch any error and print it
|
|
11
|
+
process.on('uncaughtException', (err) => {
|
|
12
|
+
console.error(err)
|
|
13
|
+
})
|
|
14
|
+
|
|
9
15
|
console.log('trying to require tmp file...')
|
|
10
16
|
try {
|
|
11
17
|
const cwd = process.cwd();
|
package/src/user-middlewares.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Response, NextFunction } from 'express';
|
|
2
|
-
|
|
3
2
|
import type { RequestWithUser } from './types';
|
|
4
3
|
|
|
5
4
|
export function populateUser(req: RequestWithUser, res: Response, next: NextFunction): void {
|
|
@@ -20,3 +19,20 @@ export function verifyUser(req: RequestWithUser, res: Response, next: NextFuncti
|
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
|
|
22
|
+
export function verifyInternalCall (req: RequestWithUser, res: Response, next: NextFunction) {
|
|
23
|
+
if (
|
|
24
|
+
!req.headers.internal_secret ||
|
|
25
|
+
req.headers.internal_secret !== process.env.INTERNAL_SECRET ||
|
|
26
|
+
!req.headers.tenant
|
|
27
|
+
) {
|
|
28
|
+
return res.status(401).end();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
req.user = {
|
|
32
|
+
type: 'internal',
|
|
33
|
+
isPrivileged: true,
|
|
34
|
+
roles: ['admin'],
|
|
35
|
+
tenant: req.headers.tenant,
|
|
36
|
+
};
|
|
37
|
+
next();
|
|
38
|
+
}
|